diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2016-03-03 17:58:30 -0300 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2016-03-03 17:58:30 -0300 |
commit | 2c83f435a3deca745c666e9778229d64cb2dfc79 (patch) | |
tree | 4fd862e34299e2abee0fbd58e075a9fbdb3fbf66 /src/test/modules/commit_ts/t/001_base.pl | |
parent | 7d9a4301c08148509136c296866196f6b19ee2c2 (diff) | |
download | postgresql-2c83f435a3deca745c666e9778229d64cb2dfc79.tar.gz postgresql-2c83f435a3deca745c666e9778229d64cb2dfc79.zip |
Rework PostgresNode's psql method
This makes the psql() method much more capable: it captures both stdout
and stderr; it now returns the psql exit code rather than stdout; a
timeout can now be specified, as can ON_ERROR_STOP behavior; it gained a
new "on_error_die" (defaulting to off) parameter to raise an exception
if there's any problem. Finally, additional parameters to psql can be
passed if there's need for further tweaking.
For convenience, a new safe_psql() method retains much of the old
behavior of psql(), except that it uses on_error_die on, so that
problems like syntax errors in SQL commands can be detected more easily.
Many existing TAP test files now use safe_psql, which is what is really
wanted. A couple of ->psql() calls are now added in the commit_ts
tests, which verify that the right thing is happening on certain errors.
Some ->command_fails() calls in recovery tests that were verifying that
psql failed also became ->psql() calls now.
Author: Craig Ringer. Some tweaks by Álvaro Herrera
Reviewed-By: Michaël Paquier
Diffstat (limited to 'src/test/modules/commit_ts/t/001_base.pl')
-rw-r--r-- | src/test/modules/commit_ts/t/001_base.pl | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/test/modules/commit_ts/t/001_base.pl b/src/test/modules/commit_ts/t/001_base.pl index 122b51557ad..f076a2739d4 100644 --- a/src/test/modules/commit_ts/t/001_base.pl +++ b/src/test/modules/commit_ts/t/001_base.pl @@ -13,17 +13,17 @@ $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', +$node->safe_psql('postgres', 'create table t as select now from (select now(), pg_sleep(1)) f'); +my $true = $node->safe_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', +my $ts = $node->safe_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', +my $recovered_ts = $node->safe_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'); |