On Mon, Feb 20, 2023 at 05:02:01PM +0900, Michael Paquier wrote: > On Fri, Feb 17, 2023 at 02:35:30PM -0800, Nathan Bossart wrote: >> I'm happy to move this new test to wherever folks think it should go. I'll >> look around to see if I can find a better place, too. > > I think that src/test/recovery/ is the best fit, because this stresses > a code path for WAL replay on pg_class for the template db. The name > is not specific enough, though, why not just using something like > 0NN_create_database.pl?
Okay. I've renamed the test file as suggested in v3. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index ef05633bb0..a0259cc593 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -296,7 +296,7 @@ ScanSourceDatabasePgClass(Oid tbid, Oid dbid, char *srcpath) CHECK_FOR_INTERRUPTS(); buf = ReadBufferWithoutRelcache(rlocator, MAIN_FORKNUM, blkno, - RBM_NORMAL, bstrategy, false); + RBM_NORMAL, bstrategy, true); LockBuffer(buf, BUFFER_LOCK_SHARE); page = BufferGetPage(buf); diff --git a/src/test/recovery/meson.build b/src/test/recovery/meson.build index 209118a639..59465b97f3 100644 --- a/src/test/recovery/meson.build +++ b/src/test/recovery/meson.build @@ -39,6 +39,7 @@ tests += { 't/031_recovery_conflict.pl', 't/032_relfilenode_reuse.pl', 't/033_replay_tsp_drops.pl', + 't/034_create_database.pl', ], }, } diff --git a/src/test/recovery/t/034_create_database.pl b/src/test/recovery/t/034_create_database.pl new file mode 100644 index 0000000000..872969ad85 --- /dev/null +++ b/src/test/recovery/t/034_create_database.pl @@ -0,0 +1,23 @@ + +# Copyright (c) 2023, PostgreSQL Global Development Group + +use strict; +use warnings; +use PostgreSQL::Test::Cluster; +use PostgreSQL::Test::Utils; +use Test::More; + +# DDL on template is persisted after creating database using WAL_LOG strategy +my $node = PostgreSQL::Test::Cluster->new('node'); +$node->init; +$node->start; +$node->safe_psql("postgres", "CREATE DATABASE test STRATEGY WAL_LOG;"); +$node->safe_psql("template1", "CREATE TABLE test (a INT);"); +$node->safe_psql("postgres", "CHECKPOINT;"); +$node->stop('immediate'); +$node->start; +my $result = $node->safe_psql("template1", "SELECT count(*) FROM test;"); +is($result, "0", "check table still exists"); +$node->stop; + +done_testing();