diff options
| author | Tom Lane | 2017-05-11 15:49:59 +0000 |
|---|---|---|
| committer | Tom Lane | 2017-05-11 15:49:59 +0000 |
| commit | d10c626de47d8b048b663471c7785603a2ec8641 (patch) | |
| tree | 5506d3a60630deacc55d8f7edb9c51d7f634eec6 /src/test | |
| parent | b66adb7b0c83e632e0f881f828fa6f4233d01d06 (diff) | |
Rename WAL-related functions and views to use "lsn" not "location".
Per discussion, "location" is a rather vague term that could refer to
multiple concepts. "LSN" is an unambiguous term for WAL locations and
should be preferred. Some function names, view column names, and function
output argument names used "lsn" already, but others used "location",
as well as yet other terms such as "wal_position". Since we've already
renamed a lot of things in this area from "xlog" to "wal" for v10,
we may as well incur a bit more compatibility pain and make these names
all consistent.
David Rowley, minor additional docs hacking by me
Discussion: https://postgr.es/m/CAKJS1f8O0njDKe8ePFQ-LK5-EjwThsDws6ohJ-+c6nWK+oUxtg@mail.gmail.com
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/modules/commit_ts/t/002_standby.pl | 8 | ||||
| -rw-r--r-- | src/test/modules/commit_ts/t/003_standby_2.pl | 4 | ||||
| -rw-r--r-- | src/test/perl/PostgresNode.pm | 38 | ||||
| -rw-r--r-- | src/test/recovery/t/002_archiving.pl | 4 | ||||
| -rw-r--r-- | src/test/recovery/t/003_recovery_targets.pl | 14 | ||||
| -rw-r--r-- | src/test/recovery/t/005_replay_delay.pl | 4 | ||||
| -rw-r--r-- | src/test/recovery/t/006_logical_decoding.pl | 4 | ||||
| -rw-r--r-- | src/test/recovery/t/008_fsm_truncation.pl | 4 | ||||
| -rw-r--r-- | src/test/recovery/t/010_logical_decoding_timelines.pl | 2 | ||||
| -rw-r--r-- | src/test/regress/expected/rules.out | 10 | ||||
| -rw-r--r-- | src/test/subscription/t/001_rep_changes.pl | 2 | ||||
| -rw-r--r-- | src/test/subscription/t/002_types.pl | 2 | ||||
| -rw-r--r-- | src/test/subscription/t/003_constraints.pl | 2 | ||||
| -rw-r--r-- | src/test/subscription/t/004_sync.pl | 2 | ||||
| -rw-r--r-- | src/test/subscription/t/005_encoding.pl | 2 |
15 files changed, 51 insertions, 51 deletions
diff --git a/src/test/modules/commit_ts/t/002_standby.pl b/src/test/modules/commit_ts/t/002_standby.pl index 203b75d35bc..e7221e982be 100644 --- a/src/test/modules/commit_ts/t/002_standby.pl +++ b/src/test/modules/commit_ts/t/002_standby.pl @@ -31,9 +31,9 @@ my $master_ts = $master->safe_psql('postgres', qq{SELECT ts.* FROM pg_class, pg_xact_commit_timestamp(xmin) AS ts WHERE relname = 't10'} ); my $master_lsn = - $master->safe_psql('postgres', 'select pg_current_wal_location()'); + $master->safe_psql('postgres', 'select pg_current_wal_lsn()'); $standby->poll_query_until('postgres', - qq{SELECT '$master_lsn'::pg_lsn <= pg_last_wal_replay_location()}) + qq{SELECT '$master_lsn'::pg_lsn <= pg_last_wal_replay_lsn()}) or die "slave never caught up"; my $standby_ts = $standby->safe_psql('postgres', @@ -45,9 +45,9 @@ $master->append_conf('postgresql.conf', 'track_commit_timestamp = off'); $master->restart; $master->safe_psql('postgres', 'checkpoint'); $master_lsn = - $master->safe_psql('postgres', 'select pg_current_wal_location()'); + $master->safe_psql('postgres', 'select pg_current_wal_lsn()'); $standby->poll_query_until('postgres', - qq{SELECT '$master_lsn'::pg_lsn <= pg_last_wal_replay_location()}) + qq{SELECT '$master_lsn'::pg_lsn <= pg_last_wal_replay_lsn()}) or die "slave never caught up"; $standby->safe_psql('postgres', 'checkpoint'); diff --git a/src/test/modules/commit_ts/t/003_standby_2.pl b/src/test/modules/commit_ts/t/003_standby_2.pl index d7898b83556..2fd561115cb 100644 --- a/src/test/modules/commit_ts/t/003_standby_2.pl +++ b/src/test/modules/commit_ts/t/003_standby_2.pl @@ -30,9 +30,9 @@ $master->append_conf('postgresql.conf', 'track_commit_timestamp = off'); $master->restart; $master->safe_psql('postgres', 'checkpoint'); my $master_lsn = - $master->safe_psql('postgres', 'select pg_current_wal_location()'); + $master->safe_psql('postgres', 'select pg_current_wal_lsn()'); $standby->poll_query_until('postgres', - qq{SELECT '$master_lsn'::pg_lsn <= pg_last_wal_replay_location()}) + qq{SELECT '$master_lsn'::pg_lsn <= pg_last_wal_replay_lsn()}) or die "slave never caught up"; $standby->safe_psql('postgres', 'checkpoint'); diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm index 51cbec8e5d9..e2274681b10 100644 --- a/src/test/perl/PostgresNode.pm +++ b/src/test/perl/PostgresNode.pm @@ -1347,13 +1347,13 @@ sub run_log =item $node->lsn(mode) -Look up WAL positions on the server: +Look up WAL locations on the server: - * insert position (master only, error on replica) - * write position (master only, error on replica) - * flush position (master only, error on replica) - * receive position (always undef on master) - * replay position (always undef on master) + * insert location (master only, error on replica) + * write location (master only, error on replica) + * flush location (master only, error on replica) + * receive location (always undef on master) + * replay location (always undef on master) mode must be specified. @@ -1362,11 +1362,11 @@ mode must be specified. sub lsn { my ($self, $mode) = @_; - my %modes = ('insert' => 'pg_current_wal_insert_location()', - 'flush' => 'pg_current_wal_flush_location()', - 'write' => 'pg_current_wal_location()', - 'receive' => 'pg_last_wal_receive_location()', - 'replay' => 'pg_last_wal_replay_location()'); + my %modes = ('insert' => 'pg_current_wal_insert_lsn()', + 'flush' => 'pg_current_wal_flush_lsn()', + 'write' => 'pg_current_wal_lsn()', + 'receive' => 'pg_last_wal_receive_lsn()', + 'replay' => 'pg_last_wal_replay_lsn()'); $mode = '<undef>' if !defined($mode); die "unknown mode for 'lsn': '$mode', valid modes are " . join(', ', keys %modes) @@ -1389,10 +1389,10 @@ sub lsn =item $node->wait_for_catchup(standby_name, mode, target_lsn) Wait for the node with application_name standby_name (usually from node->name) -until its replication position in pg_stat_replication equals or passes the +until its replication location in pg_stat_replication equals or passes the upstream's WAL insert point at the time this function is called. By default -the replay_location is waited for, but 'mode' may be specified to wait for any -of sent|write|flush|replay. +the replay_lsn is waited for, but 'mode' may be specified to wait for any of +sent|write|flush|replay. If there is no active replication connection from this peer, waits until poll_query_until timeout. @@ -1417,10 +1417,10 @@ sub wait_for_catchup $standby_name = $standby_name->name; } die 'target_lsn must be specified' unless defined($target_lsn); - print "Waiting for replication conn " . $standby_name . "'s " . $mode . "_location to pass " . $target_lsn . " on " . $self->name . "\n"; - my $query = qq[SELECT '$target_lsn' <= ${mode}_location FROM pg_catalog.pg_stat_replication WHERE application_name = '$standby_name';]; + print "Waiting for replication conn " . $standby_name . "'s " . $mode . "_lsn to pass " . $target_lsn . " on " . $self->name . "\n"; + my $query = qq[SELECT '$target_lsn' <= ${mode}_lsn FROM pg_catalog.pg_stat_replication WHERE application_name = '$standby_name';]; $self->poll_query_until('postgres', $query) - or die "timed out waiting for catchup, current position is " . ($self->safe_psql('postgres', $query) || '(unknown)'); + or die "timed out waiting for catchup, current location is " . ($self->safe_psql('postgres', $query) || '(unknown)'); print "done\n"; } @@ -1429,7 +1429,7 @@ sub wait_for_catchup =item $node->wait_for_slot_catchup(slot_name, mode, target_lsn) Wait for the named replication slot to equal or pass the supplied target_lsn. -The position used is the restart_lsn unless mode is given, in which case it may +The location used is the restart_lsn unless mode is given, in which case it may be 'restart' or 'confirmed_flush'. Requires that the 'postgres' db exists and is accessible. @@ -1456,7 +1456,7 @@ sub wait_for_slot_catchup print "Waiting for replication slot " . $slot_name . "'s " . $mode . "_lsn to pass " . $target_lsn . " on " . $self->name . "\n"; my $query = qq[SELECT '$target_lsn' <= ${mode}_lsn FROM pg_catalog.pg_replication_slots WHERE slot_name = '$slot_name';]; $self->poll_query_until('postgres', $query) - or die "timed out waiting for catchup, current position is " . ($self->safe_psql('postgres', $query) || '(unknown)'); + or die "timed out waiting for catchup, current location is " . ($self->safe_psql('postgres', $query) || '(unknown)'); print "done\n"; } diff --git a/src/test/recovery/t/002_archiving.pl b/src/test/recovery/t/002_archiving.pl index e4a643d82d2..42a9afb2f34 100644 --- a/src/test/recovery/t/002_archiving.pl +++ b/src/test/recovery/t/002_archiving.pl @@ -31,7 +31,7 @@ $node_standby->start; $node_master->safe_psql('postgres', "CREATE TABLE tab_int AS SELECT generate_series(1,1000) AS a"); my $current_lsn = - $node_master->safe_psql('postgres', "SELECT pg_current_wal_location();"); + $node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn();"); # Force archiving of WAL file to make it present on master $node_master->safe_psql('postgres', "SELECT pg_switch_wal()"); @@ -42,7 +42,7 @@ $node_master->safe_psql('postgres', # Wait until necessary replay has been done on standby my $caughtup_query = - "SELECT '$current_lsn'::pg_lsn <= pg_last_wal_replay_location()"; + "SELECT '$current_lsn'::pg_lsn <= pg_last_wal_replay_lsn()"; $node_standby->poll_query_until('postgres', $caughtup_query) or die "Timed out while waiting for standby to catch up"; diff --git a/src/test/recovery/t/003_recovery_targets.pl b/src/test/recovery/t/003_recovery_targets.pl index 203a46419e0..66025cdbe3e 100644 --- a/src/test/recovery/t/003_recovery_targets.pl +++ b/src/test/recovery/t/003_recovery_targets.pl @@ -30,7 +30,7 @@ sub test_recovery_standby # Wait until standby has replayed enough data my $caughtup_query = - "SELECT '$until_lsn'::pg_lsn <= pg_last_wal_replay_location()"; + "SELECT '$until_lsn'::pg_lsn <= pg_last_wal_replay_lsn()"; $node_standby->poll_query_until('postgres', $caughtup_query) or die "Timed out while waiting for standby to catch up"; @@ -55,7 +55,7 @@ $node_master->start; $node_master->safe_psql('postgres', "CREATE TABLE tab_int AS SELECT generate_series(1,1000) AS a"); my $lsn1 = - $node_master->safe_psql('postgres', "SELECT pg_current_wal_location();"); + $node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn();"); # Take backup from which all operations will be run $node_master->backup('my_backup'); @@ -65,14 +65,14 @@ $node_master->backup('my_backup'); $node_master->safe_psql('postgres', "INSERT INTO tab_int VALUES (generate_series(1001,2000))"); my $ret = $node_master->safe_psql('postgres', - "SELECT pg_current_wal_location(), txid_current();"); + "SELECT pg_current_wal_lsn(), txid_current();"); my ($lsn2, $recovery_txid) = split /\|/, $ret; # More data, with recovery target timestamp $node_master->safe_psql('postgres', "INSERT INTO tab_int VALUES (generate_series(2001,3000))"); $ret = $node_master->safe_psql('postgres', - "SELECT pg_current_wal_location(), now();"); + "SELECT pg_current_wal_lsn(), now();"); my ($lsn3, $recovery_time) = split /\|/, $ret; # Even more data, this time with a recovery target name @@ -80,16 +80,16 @@ $node_master->safe_psql('postgres', "INSERT INTO tab_int VALUES (generate_series(3001,4000))"); my $recovery_name = "my_target"; my $lsn4 = - $node_master->safe_psql('postgres', "SELECT pg_current_wal_location();"); + $node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn();"); $node_master->safe_psql('postgres', "SELECT pg_create_restore_point('$recovery_name');"); # And now for a recovery target LSN $node_master->safe_psql('postgres', "INSERT INTO tab_int VALUES (generate_series(4001,5000))"); -my $recovery_lsn = $node_master->safe_psql('postgres', "SELECT pg_current_wal_location()"); +my $recovery_lsn = $node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn()"); my $lsn5 = - $node_master->safe_psql('postgres', "SELECT pg_current_wal_location();"); + $node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn();"); $node_master->safe_psql('postgres', "INSERT INTO tab_int VALUES (generate_series(5001,6000))"); diff --git a/src/test/recovery/t/005_replay_delay.pl b/src/test/recovery/t/005_replay_delay.pl index cd9e8f5c12f..4185f58e0d8 100644 --- a/src/test/recovery/t/005_replay_delay.pl +++ b/src/test/recovery/t/005_replay_delay.pl @@ -42,7 +42,7 @@ $node_master->safe_psql('postgres', # Now wait for replay to complete on standby. We're done waiting when the # slave has replayed up to the previously saved master LSN. my $until_lsn = - $node_master->safe_psql('postgres', "SELECT pg_current_wal_location()"); + $node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn()"); my $remaining = 90; while ($remaining-- > 0) @@ -50,7 +50,7 @@ while ($remaining-- > 0) # Done waiting? my $replay_status = $node_standby->safe_psql('postgres', - "SELECT (pg_last_wal_replay_location() - '$until_lsn'::pg_lsn) >= 0" + "SELECT (pg_last_wal_replay_lsn() - '$until_lsn'::pg_lsn) >= 0" ); last if $replay_status eq 't'; diff --git a/src/test/recovery/t/006_logical_decoding.pl b/src/test/recovery/t/006_logical_decoding.pl index bf9b50a6a35..31b1218cc06 100644 --- a/src/test/recovery/t/006_logical_decoding.pl +++ b/src/test/recovery/t/006_logical_decoding.pl @@ -53,7 +53,7 @@ COMMIT}; my $stdout_sql = $node_master->safe_psql('postgres', qq[SELECT data FROM pg_logical_slot_peek_changes('test_slot', NULL, NULL, 'include-xids', '0', 'skip-empty-xacts', '1');]); is($stdout_sql, $expected, 'got expected output from SQL decoding session'); -my $endpos = $node_master->safe_psql('postgres', "SELECT location FROM pg_logical_slot_peek_changes('test_slot', NULL, NULL) ORDER BY location DESC LIMIT 1;"); +my $endpos = $node_master->safe_psql('postgres', "SELECT lsn FROM pg_logical_slot_peek_changes('test_slot', NULL, NULL) ORDER BY lsn DESC LIMIT 1;"); print "waiting to replay $endpos\n"; my $stdout_recv = $node_master->pg_recvlogical_upto('postgres', 'test_slot', $endpos, 10, 'include-xids' => '0', 'skip-empty-xacts' => '1'); @@ -66,7 +66,7 @@ is($stdout_recv, '', 'pg_recvlogical acknowledged changes, nothing pending on sl $node_master->safe_psql('postgres', 'CREATE DATABASE otherdb'); -is($node_master->psql('otherdb', "SELECT location FROM pg_logical_slot_peek_changes('test_slot', NULL, NULL) ORDER BY location DESC LIMIT 1;"), 3, +is($node_master->psql('otherdb', "SELECT lsn FROM pg_logical_slot_peek_changes('test_slot', NULL, NULL) ORDER BY lsn DESC LIMIT 1;"), 3, 'replaying logical slot from another database fails'); $node_master->safe_psql('otherdb', qq[SELECT pg_create_logical_replication_slot('otherdb_slot', 'test_decoding');]); diff --git a/src/test/recovery/t/008_fsm_truncation.pl b/src/test/recovery/t/008_fsm_truncation.pl index 8aa8a4fe821..055cac324c5 100644 --- a/src/test/recovery/t/008_fsm_truncation.pl +++ b/src/test/recovery/t/008_fsm_truncation.pl @@ -68,11 +68,11 @@ vacuum verbose testtab; $node_master->psql('postgres', 'checkpoint'); my $until_lsn = - $node_master->safe_psql('postgres', "SELECT pg_current_wal_location();"); + $node_master->safe_psql('postgres', "SELECT pg_current_wal_lsn();"); # Wait long enough for standby to receive and apply all WAL my $caughtup_query = - "SELECT '$until_lsn'::pg_lsn <= pg_last_wal_replay_location()"; + "SELECT '$until_lsn'::pg_lsn <= pg_last_wal_replay_lsn()"; $node_standby->poll_query_until('postgres', $caughtup_query) or die "Timed out while waiting for standby to catch up"; diff --git a/src/test/recovery/t/010_logical_decoding_timelines.pl b/src/test/recovery/t/010_logical_decoding_timelines.pl index cdddb4d13d4..e168cbc161a 100644 --- a/src/test/recovery/t/010_logical_decoding_timelines.pl +++ b/src/test/recovery/t/010_logical_decoding_timelines.pl @@ -169,7 +169,7 @@ is($stderr, '', 'replay from slot before_basebackup produces no stderr'); # pg_recvlogical we should get complete results. First, find out the commit lsn # of the last transaction. There's no max(pg_lsn), so: -my $endpos = $node_replica->safe_psql('postgres', "SELECT location FROM pg_logical_slot_peek_changes('before_basebackup', NULL, NULL) ORDER BY location DESC LIMIT 1;"); +my $endpos = $node_replica->safe_psql('postgres', "SELECT lsn FROM pg_logical_slot_peek_changes('before_basebackup', NULL, NULL) ORDER BY lsn DESC LIMIT 1;"); # now use the walsender protocol to peek the slot changes and make sure we see # the same results. diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out index 259b26b6f73..a4b2d8635dc 100644 --- a/src/test/regress/expected/rules.out +++ b/src/test/regress/expected/rules.out @@ -1851,17 +1851,17 @@ pg_stat_replication| SELECT s.pid, s.backend_start, s.backend_xmin, w.state, - w.sent_location, - w.write_location, - w.flush_location, - w.replay_location, + w.sent_lsn, + w.write_lsn, + w.flush_lsn, + w.replay_lsn, w.write_lag, w.flush_lag, w.replay_lag, w.sync_priority, w.sync_state FROM ((pg_stat_get_activity(NULL::integer) s(datid, pid, usesysid, application_name, state, query, wait_event_type, wait_event, xact_start, query_start, backend_start, state_change, client_addr, client_hostname, client_port, backend_xid, backend_xmin, backend_type, ssl, sslversion, sslcipher, sslbits, sslcompression, sslclientdn) - JOIN pg_stat_get_wal_senders() w(pid, state, sent_location, write_location, flush_location, replay_location, write_lag, flush_lag, replay_lag, sync_priority, sync_state) ON ((s.pid = w.pid))) + JOIN pg_stat_get_wal_senders() w(pid, state, sent_lsn, write_lsn, flush_lsn, replay_lsn, write_lag, flush_lag, replay_lag, sync_priority, sync_state) ON ((s.pid = w.pid))) LEFT JOIN pg_authid u ON ((s.usesysid = u.oid))); pg_stat_ssl| SELECT s.pid, s.ssl, diff --git a/src/test/subscription/t/001_rep_changes.pl b/src/test/subscription/t/001_rep_changes.pl index 8e79fa3c44b..ea99f84534c 100644 --- a/src/test/subscription/t/001_rep_changes.pl +++ b/src/test/subscription/t/001_rep_changes.pl @@ -52,7 +52,7 @@ $node_subscriber->safe_psql('postgres', # Wait for subscriber to finish initialization my $caughtup_query = -"SELECT pg_current_wal_location() <= replay_location FROM pg_stat_replication WHERE application_name = '$appname';"; +"SELECT pg_current_wal_lsn() <= replay_lsn FROM pg_stat_replication WHERE application_name = '$appname';"; $node_publisher->poll_query_until('postgres', $caughtup_query) or die "Timed out while waiting for subscriber to catch up"; diff --git a/src/test/subscription/t/002_types.pl b/src/test/subscription/t/002_types.pl index ad15e85c0ca..16e8b478855 100644 --- a/src/test/subscription/t/002_types.pl +++ b/src/test/subscription/t/002_types.pl @@ -107,7 +107,7 @@ $node_subscriber->safe_psql('postgres', # Wait for subscriber to finish initialization my $caughtup_query = -"SELECT pg_current_wal_location() <= replay_location FROM pg_stat_replication WHERE application_name = '$appname';"; +"SELECT pg_current_wal_lsn() <= replay_lsn FROM pg_stat_replication WHERE application_name = '$appname';"; $node_publisher->poll_query_until('postgres', $caughtup_query) or die "Timed out while waiting for subscriber to catch up"; diff --git a/src/test/subscription/t/003_constraints.pl b/src/test/subscription/t/003_constraints.pl index 11b82541551..074fdb1a30c 100644 --- a/src/test/subscription/t/003_constraints.pl +++ b/src/test/subscription/t/003_constraints.pl @@ -38,7 +38,7 @@ $node_subscriber->safe_psql('postgres', # Wait for subscriber to finish initialization my $caughtup_query = -"SELECT pg_current_wal_location() <= replay_location FROM pg_stat_replication WHERE application_name = '$appname';"; +"SELECT pg_current_wal_lsn() <= replay_lsn FROM pg_stat_replication WHERE application_name = '$appname';"; $node_publisher->poll_query_until('postgres', $caughtup_query) or die "Timed out while waiting for subscriber to catch up"; diff --git a/src/test/subscription/t/004_sync.pl b/src/test/subscription/t/004_sync.pl index fa0bf7f49fc..ceeb7a3b5d0 100644 --- a/src/test/subscription/t/004_sync.pl +++ b/src/test/subscription/t/004_sync.pl @@ -37,7 +37,7 @@ $node_subscriber->safe_psql('postgres', # Wait for subscriber to finish initialization my $caughtup_query = -"SELECT pg_current_wal_location() <= replay_location FROM pg_stat_replication WHERE application_name = '$appname';"; +"SELECT pg_current_wal_lsn() <= replay_lsn FROM pg_stat_replication WHERE application_name = '$appname';"; $node_publisher->poll_query_until('postgres', $caughtup_query) or die "Timed out while waiting for subscriber to catch up"; diff --git a/src/test/subscription/t/005_encoding.pl b/src/test/subscription/t/005_encoding.pl index 42a4eee5b4d..7a62e05cc6b 100644 --- a/src/test/subscription/t/005_encoding.pl +++ b/src/test/subscription/t/005_encoding.pl @@ -10,7 +10,7 @@ sub wait_for_caught_up my ($node, $appname) = @_; $node->poll_query_until('postgres', - "SELECT pg_current_wal_location() <= replay_location FROM pg_stat_replication WHERE application_name = '$appname';") + "SELECT pg_current_wal_lsn() <= replay_lsn FROM pg_stat_replication WHERE application_name = '$appname';") or die "Timed out while waiting for subscriber to catch up"; } |
