aboutsummaryrefslogtreecommitdiff
path: root/src/test/modules/commit_ts/t/001_base.pl
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2016-03-01 19:53:18 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2016-03-01 19:53:18 -0300
commit9def031bd2821f35b5f506260d922482648a8bb0 (patch)
treeec5a489d9f13c36448540c0b733d8261335aed9a /src/test/modules/commit_ts/t/001_base.pl
parent88802e068017bee8cea7a5502a712794e761c7b5 (diff)
downloadpostgresql-9def031bd2821f35b5f506260d922482648a8bb0.tar.gz
postgresql-9def031bd2821f35b5f506260d922482648a8bb0.zip
Add more tests for commit_timestamp feature
These tests verify that 1) WAL replay preserves the stored value, 2) a streaming standby server replays the value obtained from the master, and 3) the behavior is sensible in the face of repeated configuration changes. One annoyance is that tmp_check/ subdir from the TAP tests is clobbered when the pg_regress test runs in the same subdirectory. This is bothersome but not too terrible a problem, since the pg_regress test is not run anyway if the TAP tests fail (unless "make -k" is used). I had these tests around since commit 69e7235c93e2; add them now that we have the recovery test framework in place.
Diffstat (limited to 'src/test/modules/commit_ts/t/001_base.pl')
-rw-r--r--src/test/modules/commit_ts/t/001_base.pl29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/modules/commit_ts/t/001_base.pl b/src/test/modules/commit_ts/t/001_base.pl
new file mode 100644
index 00000000000..122b51557ad
--- /dev/null
+++ b/src/test/modules/commit_ts/t/001_base.pl
@@ -0,0 +1,29 @@
+# Single-node test: value can be set, and is still present after recovery
+
+use strict;
+use warnings;
+
+use TestLib;
+use Test::More tests => 2;
+use PostgresNode;
+
+my $node = get_new_node();
+$node->init;
+$node->append_conf('postgresql.conf', 'track_commit_timestamp = on');
+$node->start;
+
+# Create a table, compare "now()" to the commit TS of its xmin
+$node->psql('postgres', 'create table t as select now from (select now(), pg_sleep(1)) f');
+my $true = $node->psql('postgres',
+ 'select t.now - ts.* < \'1s\' from t, pg_class c, pg_xact_commit_timestamp(c.xmin) ts where relname = \'t\'');
+is($true, 't', 'commit TS is set');
+my $ts = $node->psql('postgres',
+ 'select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = \'t\'');
+
+# Verify that we read the same TS after crash recovery
+$node->stop('immediate');
+$node->start;
+
+my $recovered_ts = $node->psql('postgres',
+ 'select ts.* from pg_class, pg_xact_commit_timestamp(xmin) ts where relname = \'t\'');
+is($recovered_ts, $ts, 'commit TS remains after crash recovery');