1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

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
This commit is contained in:
Tom Lane
2017-05-11 11:49:59 -04:00
parent b66adb7b0c
commit d10c626de4
31 changed files with 185 additions and 185 deletions

View File

@ -17908,17 +17908,17 @@ SELECT collation for ('foo' COLLATE "de_DE");
<tbody>
<row>
<entry><literal>checkpoint_location</literal></entry>
<entry><literal>checkpoint_lsn</literal></entry>
<entry><type>pg_lsn</type></entry>
</row>
<row>
<entry><literal>prior_location</literal></entry>
<entry><literal>prior_lsn</literal></entry>
<entry><type>pg_lsn</type></entry>
</row>
<row>
<entry><literal>redo_location</literal></entry>
<entry><literal>redo_lsn</literal></entry>
<entry><type>pg_lsn</type></entry>
</row>
@ -18146,7 +18146,7 @@ SELECT collation for ('foo' COLLATE "de_DE");
<tbody>
<row>
<entry><literal>min_recovery_end_location</literal></entry>
<entry><literal>min_recovery_end_lsn</literal></entry>
<entry><type>pg_lsn</type></entry>
</row>
@ -18156,12 +18156,12 @@ SELECT collation for ('foo' COLLATE "de_DE");
</row>
<row>
<entry><literal>backup_start_location</literal></entry>
<entry><literal>backup_start_lsn</literal></entry>
<entry><type>pg_lsn</type></entry>
</row>
<row>
<entry><literal>backup_end_location</literal></entry>
<entry><literal>backup_end_lsn</literal></entry>
<entry><type>pg_lsn</type></entry>
</row>
@ -18404,13 +18404,13 @@ SELECT set_config('log_statement_stats', 'off', false);
<primary>pg_create_restore_point</primary>
</indexterm>
<indexterm>
<primary>pg_current_wal_flush_location</primary>
<primary>pg_current_wal_flush_lsn</primary>
</indexterm>
<indexterm>
<primary>pg_current_wal_insert_location</primary>
<primary>pg_current_wal_insert_lsn</primary>
</indexterm>
<indexterm>
<primary>pg_current_wal_location</primary>
<primary>pg_current_wal_lsn</primary>
</indexterm>
<indexterm>
<primary>pg_start_backup</primary>
@ -18434,7 +18434,7 @@ SELECT set_config('log_statement_stats', 'off', false);
<primary>pg_walfile_name_offset</primary>
</indexterm>
<indexterm>
<primary>pg_wal_location_diff</primary>
<primary>pg_wal_lsn_diff</primary>
</indexterm>
<para>
@ -18442,7 +18442,7 @@ SELECT set_config('log_statement_stats', 'off', false);
linkend="functions-admin-backup-table"> assist in making on-line backups.
These functions cannot be executed during recovery (except
<function>pg_is_in_backup</function>, <function>pg_backup_start_time</function>
and <function>pg_wal_location_diff</function>).
and <function>pg_wal_lsn_diff</function>).
</para>
<table id="functions-admin-backup-table">
@ -18463,21 +18463,21 @@ SELECT set_config('log_statement_stats', 'off', false);
</row>
<row>
<entry>
<literal><function>pg_current_wal_flush_location()</function></literal>
<literal><function>pg_current_wal_flush_lsn()</function></literal>
</entry>
<entry><type>pg_lsn</type></entry>
<entry>Get current transaction log flush location</entry>
</row>
<row>
<entry>
<literal><function>pg_current_wal_insert_location()</function></literal>
<literal><function>pg_current_wal_insert_lsn()</function></literal>
</entry>
<entry><type>pg_lsn</type></entry>
<entry>Get current transaction log insert location</entry>
</row>
<row>
<entry>
<literal><function>pg_current_wal_location()</function></literal>
<literal><function>pg_current_wal_lsn()</function></literal>
</entry>
<entry><type>pg_lsn</type></entry>
<entry>Get current transaction log write location</entry>
@ -18526,21 +18526,21 @@ SELECT set_config('log_statement_stats', 'off', false);
</row>
<row>
<entry>
<literal><function>pg_walfile_name(<parameter>location</> <type>pg_lsn</>)</function></literal>
<literal><function>pg_walfile_name(<parameter>lsn</> <type>pg_lsn</>)</function></literal>
</entry>
<entry><type>text</type></entry>
<entry>Convert transaction log location string to file name</entry>
<entry>Convert transaction log location to file name</entry>
</row>
<row>
<entry>
<literal><function>pg_walfile_name_offset(<parameter>location</> <type>pg_lsn</>)</function></literal>
<literal><function>pg_walfile_name_offset(<parameter>lsn</> <type>pg_lsn</>)</function></literal>
</entry>
<entry><type>text</>, <type>integer</></entry>
<entry>Convert transaction log location string to file name and decimal byte offset within file</entry>
<entry>Convert transaction log location to file name and decimal byte offset within file</entry>
</row>
<row>
<entry>
<literal><function>pg_wal_location_diff(<parameter>location</> <type>pg_lsn</>, <parameter>location</> <type>pg_lsn</>)</function></literal>
<literal><function>pg_wal_lsn_diff(<parameter>lsn</> <type>pg_lsn</>, <parameter>lsn</> <type>pg_lsn</>)</function></literal>
</entry>
<entry><type>numeric</></entry>
<entry>Calculate the difference between two transaction log locations</entry>
@ -18623,17 +18623,17 @@ postgres=# select pg_start_backup('label_goes_here');
</para>
<para>
<function>pg_current_wal_location</> displays the current transaction log write
<function>pg_current_wal_lsn</> displays the current transaction log write
location in the same format used by the above functions. Similarly,
<function>pg_current_wal_insert_location</> displays the current transaction log
insertion point and <function>pg_current_wal_flush_location</> displays the
current transaction log flush point. The insertion point is the <quote>logical</>
<function>pg_current_wal_insert_lsn</> displays the current transaction log
insertion location and <function>pg_current_wal_flush_lsn</> displays the
current transaction log flush location. The insertion location is the <quote>logical</>
end of the transaction log at any instant, while the write location is the end of
what has actually been written out from the server's internal buffers and flush
location is the location guaranteed to be written to durable storage. The write
location is the end of what can be examined from outside the server, and is usually
what you want if you are interested in archiving partially-complete transaction log
files. The insertion and flush points are made available primarily for server
files. The insertion and flush locations are made available primarily for server
debugging purposes. These are both read-only operations and do not
require superuser permissions.
</para>
@ -18658,7 +18658,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
</para>
<para>
<function>pg_wal_location_diff</> calculates the difference in bytes
<function>pg_wal_lsn_diff</> calculates the difference in bytes
between two transaction log locations. It can be used with
<structname>pg_stat_replication</structname> or some functions shown in
<xref linkend="functions-admin-backup-table"> to get the replication lag.
@ -18678,10 +18678,10 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
<primary>pg_is_in_recovery</primary>
</indexterm>
<indexterm>
<primary>pg_last_wal_receive_location</primary>
<primary>pg_last_wal_receive_lsn</primary>
</indexterm>
<indexterm>
<primary>pg_last_wal_replay_location</primary>
<primary>pg_last_wal_replay_lsn</primary>
</indexterm>
<indexterm>
<primary>pg_last_xact_replay_timestamp</primary>
@ -18713,7 +18713,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
</row>
<row>
<entry>
<literal><function>pg_last_wal_receive_location()</function></literal>
<literal><function>pg_last_wal_receive_lsn()</function></literal>
</entry>
<entry><type>pg_lsn</type></entry>
<entry>Get last transaction log location received and synced to disk by
@ -18727,7 +18727,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
</row>
<row>
<entry>
<literal><function>pg_last_wal_replay_location()</function></literal>
<literal><function>pg_last_wal_replay_lsn()</function></literal>
</entry>
<entry><type>pg_lsn</type></entry>
<entry>Get last transaction log location replayed during recovery.
@ -18950,7 +18950,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
<literal><function>pg_create_physical_replication_slot(<parameter>slot_name</parameter> <type>name</type> <optional>, <parameter>immediately_reserve</> <type>boolean</>, <parameter>temporary</> <type>boolean</></optional>)</function></literal>
</entry>
<entry>
(<parameter>slot_name</parameter> <type>name</type>, <parameter>wal_position</parameter> <type>pg_lsn</type>)
(<parameter>slot_name</parameter> <type>name</type>, <parameter>lsn</parameter> <type>pg_lsn</type>)
</entry>
<entry>
Creates a new physical replication slot named
@ -18995,7 +18995,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
<literal><function>pg_create_logical_replication_slot(<parameter>slot_name</parameter> <type>name</type>, <parameter>plugin</parameter> <type>name</type> <optional>, <parameter>temporary</> <type>boolean</></optional>)</function></literal>
</entry>
<entry>
(<parameter>slot_name</parameter> <type>name</type>, <parameter>wal_position</parameter> <type>pg_lsn</type>)
(<parameter>slot_name</parameter> <type>name</type>, <parameter>lsn</parameter> <type>pg_lsn</type>)
</entry>
<entry>
Creates a new logical (decoding) replication slot named
@ -19018,7 +19018,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
<literal><function>pg_logical_slot_get_changes(<parameter>slot_name</parameter> <type>name</type>, <parameter>upto_lsn</parameter> <type>pg_lsn</type>, <parameter>upto_nchanges</parameter> <type>int</type>, VARIADIC <parameter>options</parameter> <type>text[]</type>)</function></literal>
</entry>
<entry>
(<parameter>location</parameter> <type>pg_lsn</type>, <parameter>xid</parameter> <type>xid</type>, <parameter>data</parameter> <type>text</type>)
(<parameter>lsn</parameter> <type>pg_lsn</type>, <parameter>xid</parameter> <type>xid</type>, <parameter>data</parameter> <type>text</type>)
</entry>
<entry>
Returns changes in the slot <parameter>slot_name</parameter>, starting
@ -19043,7 +19043,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
<literal><function>pg_logical_slot_peek_changes(<parameter>slot_name</parameter> <type>name</type>, <parameter>upto_lsn</parameter> <type>pg_lsn</type>, <parameter>upto_nchanges</parameter> <type>int</type>, VARIADIC <parameter>options</parameter> <type>text[]</type>)</function></literal>
</entry>
<entry>
(<parameter>location</parameter> <type>text</type>, <parameter>xid</parameter> <type>xid</type>, <parameter>data</parameter> <type>text</type>)
(<parameter>lsn</parameter> <type>pg_lsn</type>, <parameter>xid</parameter> <type>xid</type>, <parameter>data</parameter> <type>text</type>)
</entry>
<entry>
Behaves just like
@ -19061,7 +19061,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
<literal><function>pg_logical_slot_get_binary_changes(<parameter>slot_name</parameter> <type>name</type>, <parameter>upto_lsn</parameter> <type>pg_lsn</type>, <parameter>upto_nchanges</parameter> <type>int</type>, VARIADIC <parameter>options</parameter> <type>text[]</type>)</function></literal>
</entry>
<entry>
(<parameter>location</parameter> <type>pg_lsn</type>, <parameter>xid</parameter> <type>xid</type>, <parameter>data</parameter> <type>bytea</type>)
(<parameter>lsn</parameter> <type>pg_lsn</type>, <parameter>xid</parameter> <type>xid</type>, <parameter>data</parameter> <type>bytea</type>)
</entry>
<entry>
Behaves just like
@ -19078,7 +19078,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
<literal><function>pg_logical_slot_peek_binary_changes(<parameter>slot_name</parameter> <type>name</type>, <parameter>upto_lsn</parameter> <type>pg_lsn</type>, <parameter>upto_nchanges</parameter> <type>int</type>, VARIADIC <parameter>options</parameter> <type>text[]</type>)</function></literal>
</entry>
<entry>
(<parameter>location</parameter> <type>pg_lsn</type>, <parameter>xid</parameter> <type>xid</type>, <parameter>data</parameter> <type>bytea</type>)
(<parameter>lsn</parameter> <type>pg_lsn</type>, <parameter>xid</parameter> <type>xid</type>, <parameter>data</parameter> <type>bytea</type>)
</entry>
<entry>
Behaves just like
@ -19197,7 +19197,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
<type>pg_lsn</type>
</entry>
<entry>
Return the replay position for the replication origin configured in
Return the replay location for the replication origin configured in
the current session. The parameter <parameter>flush</parameter>
determines whether the corresponding local transaction will be
guaranteed to have been flushed to disk or not.
@ -19244,15 +19244,15 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
<indexterm>
<primary>pg_replication_origin_advance</primary>
</indexterm>
<literal>pg_replication_origin_advance<function>(<parameter>node_name</parameter> <type>text</type>, <parameter>pos</parameter> <type>pg_lsn</type>)</function></literal>
<literal>pg_replication_origin_advance<function>(<parameter>node_name</parameter> <type>text</type>, <parameter>lsn</parameter> <type>pg_lsn</type>)</function></literal>
</entry>
<entry>
<type>void</>
</entry>
<entry>
Set replication progress for the given node to the given
position. This primarily is useful for setting up the initial position
or a new position after configuration changes and similar. Be aware
location. This primarily is useful for setting up the initial location
or a new location after configuration changes and similar. Be aware
that careless use of this function can lead to inconsistently
replicated data.
</entry>
@ -19269,7 +19269,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
<type>pg_lsn</type>
</entry>
<entry>
Return the replay position for the given replication origin. The
Return the replay location for the given replication origin. The
parameter <parameter>flush</parameter> determines whether the
corresponding local transaction will be guaranteed to have been
flushed to disk or not.

View File

@ -850,9 +850,9 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
of WAL records generated in the primary, but not yet applied in the
standby. You can calculate this lag by comparing the current WAL write
location on the primary with the last WAL location received by the
standby. They can be retrieved using
<function>pg_current_wal_location</> on the primary and the
<function>pg_last_wal_receive_location</> on the standby,
standby. These locations can be retrieved using
<function>pg_current_wal_lsn</> on the primary and
<function>pg_last_wal_receive_lsn</> on the standby,
respectively (see <xref linkend="functions-admin-backup-table"> and
<xref linkend="functions-recovery-info-table"> for details).
The last WAL receive location in the standby is also displayed in the
@ -863,10 +863,10 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
You can retrieve a list of WAL sender processes via the
<link linkend="monitoring-stats-views-table">
<literal>pg_stat_replication</></link> view. Large differences between
<function>pg_current_wal_location</> and <literal>sent_location</> field
<function>pg_current_wal_lsn</> and the view's <literal>sent_lsn</> field
might indicate that the master server is under heavy load, while
differences between <literal>sent_location</> and
<function>pg_last_wal_receive_location</> on the standby might indicate
differences between <literal>sent_lsn</> and
<function>pg_last_wal_receive_lsn</> on the standby might indicate
network delay, or that the standby is under heavy load.
</para>
</sect3>
@ -927,8 +927,8 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
You can create a replication slot like this:
<programlisting>
postgres=# SELECT * FROM pg_create_physical_replication_slot('node_a_slot');
slot_name | wal_position
-------------+---------------
slot_name | lsn
-------------+-----
node_a_slot |
postgres=# SELECT * FROM pg_replication_slots;

View File

@ -56,8 +56,8 @@
<programlisting>
postgres=# -- Create a slot named 'regression_slot' using the output plugin 'test_decoding'
postgres=# SELECT * FROM pg_create_logical_replication_slot('regression_slot', 'test_decoding');
slot_name | wal_position
-----------------+---------------
slot_name | lsn
-----------------+-----------
regression_slot | 0/16B1970
(1 row)
@ -69,8 +69,8 @@ postgres=# SELECT slot_name, plugin, slot_type, database, active, restart_lsn, c
postgres=# -- There are no changes to see yet
postgres=# SELECT * FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL);
location | xid | data
----------+-----+------
lsn | xid | data
-----+-----+------
(0 rows)
postgres=# CREATE TABLE data(id serial primary key, data text);
@ -78,17 +78,17 @@ CREATE TABLE
postgres=# -- DDL isn't replicated, so all you'll see is the transaction
postgres=# SELECT * FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL);
location | xid | data
-----------+-----+------------
0/16D5D48 | 688 | BEGIN 688
0/16E0380 | 688 | COMMIT 688
lsn | xid | data
-----------+-------+--------------
0/BA2DA58 | 10297 | BEGIN 10297
0/BA5A5A0 | 10297 | COMMIT 10297
(2 rows)
postgres=# -- Once changes are read, they're consumed and not emitted
postgres=# -- in a subsequent call:
postgres=# SELECT * FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL);
location | xid | data
----------+-----+------
lsn | xid | data
-----+-----+------
(0 rows)
postgres=# BEGIN;
@ -97,41 +97,41 @@ postgres=# INSERT INTO data(data) VALUES('2');
postgres=# COMMIT;
postgres=# SELECT * FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL);
location | xid | data
-----------+-----+-----------------------------------------------
0/16E0478 | 689 | BEGIN 689
0/16E0478 | 689 | table public.data: INSERT: id[integer]:1 data[text]:'1'
0/16E0580 | 689 | table public.data: INSERT: id[integer]:2 data[text]:'2'
0/16E0650 | 689 | COMMIT 689
lsn | xid | data
-----------+-------+---------------------------------------------------------
0/BA5A688 | 10298 | BEGIN 10298
0/BA5A6F0 | 10298 | table public.data: INSERT: id[integer]:1 data[text]:'1'
0/BA5A7F8 | 10298 | table public.data: INSERT: id[integer]:2 data[text]:'2'
0/BA5A8A8 | 10298 | COMMIT 10298
(4 rows)
postgres=# INSERT INTO data(data) VALUES('3');
postgres=# -- You can also peek ahead in the change stream without consuming changes
postgres=# SELECT * FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL);
location | xid | data
-----------+-----+-----------------------------------------------
0/16E09C0 | 690 | BEGIN 690
0/16E09C0 | 690 | table public.data: INSERT: id[integer]:3 data[text]:'3'
0/16E0B90 | 690 | COMMIT 690
lsn | xid | data
-----------+-------+---------------------------------------------------------
0/BA5A8E0 | 10299 | BEGIN 10299
0/BA5A8E0 | 10299 | table public.data: INSERT: id[integer]:3 data[text]:'3'
0/BA5A990 | 10299 | COMMIT 10299
(3 rows)
postgres=# -- The next call to pg_logical_slot_peek_changes() returns the same changes again
postgres=# SELECT * FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL);
location | xid | data
-----------+-----+-----------------------------------------------
0/16E09C0 | 690 | BEGIN 690
0/16E09C0 | 690 | table public.data: INSERT: id[integer]:3 data[text]:'3'
0/16E0B90 | 690 | COMMIT 690
lsn | xid | data
-----------+-------+---------------------------------------------------------
0/BA5A8E0 | 10299 | BEGIN 10299
0/BA5A8E0 | 10299 | table public.data: INSERT: id[integer]:3 data[text]:'3'
0/BA5A990 | 10299 | COMMIT 10299
(3 rows)
postgres=# -- options can be passed to output plugin, to influence the formatting
postgres=# SELECT * FROM pg_logical_slot_peek_changes('regression_slot', NULL, NULL, 'include-timestamp', 'on');
location | xid | data
-----------+-----+-----------------------------------------------
0/16E09C0 | 690 | BEGIN 690
0/16E09C0 | 690 | table public.data: INSERT: id[integer]:3 data[text]:'3'
0/16E0B90 | 690 | COMMIT 690 (at 2014-02-27 16:41:51.863092+01)
lsn | xid | data
-----------+-------+---------------------------------------------------------
0/BA5A8E0 | 10299 | BEGIN 10299
0/BA5A8E0 | 10299 | table public.data: INSERT: id[integer]:3 data[text]:'3'
0/BA5A990 | 10299 | COMMIT 10299 (at 2017-05-10 12:07:21.272494-04)
(3 rows)
postgres=# -- Remember to destroy a slot you no longer need to stop it consuming

View File

@ -1699,26 +1699,26 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
</entry>
</row>
<row>
<entry><structfield>sent_location</></entry>
<entry><structfield>sent_lsn</></entry>
<entry><type>pg_lsn</></entry>
<entry>Last transaction log position sent on this connection</entry>
<entry>Last transaction log location sent on this connection</entry>
</row>
<row>
<entry><structfield>write_location</></entry>
<entry><structfield>write_lsn</></entry>
<entry><type>pg_lsn</></entry>
<entry>Last transaction log position written to disk by this standby
<entry>Last transaction log location written to disk by this standby
server</entry>
</row>
<row>
<entry><structfield>flush_location</></entry>
<entry><structfield>flush_lsn</></entry>
<entry><type>pg_lsn</></entry>
<entry>Last transaction log position flushed to disk by this standby
<entry>Last transaction log location flushed to disk by this standby
server</entry>
</row>
<row>
<entry><structfield>replay_location</></entry>
<entry><structfield>replay_lsn</></entry>
<entry><type>pg_lsn</></entry>
<entry>Last transaction log position replayed into the database on this
<entry>Last transaction log location replayed into the database on this
standby server</entry>
</row>
<row>

View File

@ -25,7 +25,7 @@
<programlisting>
postgres=# SELECT * FROM pg_logical_slot_get_changes('test_slot', NULL, NULL, 'include-xids', '0');
location | xid | data
lsn | xid | data
-----------+-----+--------------------------------------------------
0/16D30F8 | 691 | BEGIN
0/16D32A0 | 691 | table public.data: INSERT: id[int4]:2 data[text]:'arg'