diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 3068e1e94a..38a2edf860 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -2889,13 +2889,13 @@ include_dir 'conf.d' When wal_level is minimal and a - transaction commits after creating or rewriting a permanent table, - materialized view, or index, this setting determines how to persist - the new data. If the data is smaller than this setting, write it to - the WAL log; otherwise, use an fsync of the data file. Depending on - the properties of your storage, raising or lowering this value might - help if such commits are slowing concurrent transactions. The default - is two megabytes (2MB). + transaction commits after creating or truncating a permanent table, + refreshing a materialized view, or reindexing, this setting determines + how to persist the new data. If the data is smaller than this + setting, write it to the WAL log; otherwise, use an fsync of the data + file. Depending on the properties of your storage, raising or + lowering this value might help if such commits are slowing concurrent + transactions. The default is two megabytes (2MB). diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 391a8a9ea3..682619c9db 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -1118,16 +1118,18 @@ swap_relation_files(Oid r1, Oid r2, bool target_is_pg_class, */ { Relation rel1, - rel2; + rel2 PG_USED_FOR_ASSERTS_ONLY; rel1 = relation_open(r1, NoLock); +#ifdef USE_ASSERT_CHECKING rel2 = relation_open(r2, NoLock); rel2->rd_createSubid = rel1->rd_createSubid; rel2->rd_newRelfilenodeSubid = rel1->rd_newRelfilenodeSubid; rel2->rd_firstRelfilenodeSubid = rel1->rd_firstRelfilenodeSubid; + relation_close(rel2, NoLock); +#endif RelationAssumeNewRelfilenode(rel1); relation_close(rel1, NoLock); - relation_close(rel2, NoLock); } /* diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index 7c2181ac2f..3c500944cd 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -1985,7 +1985,8 @@ select * from another; drop table another; -- Create an index that skips WAL, then perform a SET DATA TYPE that skips --- rewriting the index. +-- rewriting the index. Inadvertent changes on rd_createSubid causes +-- asseertion failure. begin; create table skip_wal_skip_rewrite_index (c varchar(10) primary key); alter table skip_wal_skip_rewrite_index alter c type varchar(20); diff --git a/src/test/regress/expected/create_table.out b/src/test/regress/expected/create_table.out index 6acf31725f..dae7595957 100644 --- a/src/test/regress/expected/create_table.out +++ b/src/test/regress/expected/create_table.out @@ -332,6 +332,7 @@ ERROR: set-returning functions are not allowed in DEFAULT expressions LINE 1: CREATE TABLE default_expr_agg (a int DEFAULT (generate_serie... ^ -- Verify that subtransaction rollback restores rd_createSubid. +-- This and the following are expected not causing assertion failure. BEGIN; CREATE TABLE remember_create_subid (c int); SAVEPOINT q; DROP TABLE remember_create_subid; ROLLBACK TO q; diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql index 1b1315f316..ce87ed9ab0 100644 --- a/src/test/regress/sql/alter_table.sql +++ b/src/test/regress/sql/alter_table.sql @@ -1361,7 +1361,8 @@ select * from another; drop table another; -- Create an index that skips WAL, then perform a SET DATA TYPE that skips --- rewriting the index. +-- rewriting the index. Inadvertent changes on rd_createSubid causes +-- asseertion failure. begin; create table skip_wal_skip_rewrite_index (c varchar(10) primary key); alter table skip_wal_skip_rewrite_index alter c type varchar(20); diff --git a/src/test/regress/sql/create_table.sql b/src/test/regress/sql/create_table.sql index a670438c48..3051b5d4e6 100644 --- a/src/test/regress/sql/create_table.sql +++ b/src/test/regress/sql/create_table.sql @@ -319,6 +319,7 @@ CREATE TABLE default_expr_agg (a int DEFAULT (select 1)); CREATE TABLE default_expr_agg (a int DEFAULT (generate_series(1,3))); -- Verify that subtransaction rollback restores rd_createSubid. +-- This and the following are expected not causing assertion failure. BEGIN; CREATE TABLE remember_create_subid (c int); SAVEPOINT q; DROP TABLE remember_create_subid; ROLLBACK TO q;