1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Add replication command READ_REPLICATION_SLOT

The command is supported for physical slots for now, and returns the
type of slot, its restart_lsn and its restart_tli.

This will be useful for an upcoming patch related to pg_receivewal, to
allow the tool to be able to stream from the position of a slot, rather
than the last WAL position flushed by the backend (as reported by
IDENTIFY_SYSTEM) if the archive directory is found as empty, which would
be an advantage in the case of switching to a different archive
locations with the same slot used to avoid holes in WAL segment
archives.

Author: Ronan Dunklau
Reviewed-by: Kyotaro Horiguchi, Michael Paquier, Bharath Rupireddy
Discussion: https://postgr.es/m/18708360.4lzOvYHigE@aivenronan
This commit is contained in:
Michael Paquier
2021-10-25 07:40:42 +09:00
parent 70bef49400
commit b4ada4e19f
9 changed files with 224 additions and 3 deletions

View File

@ -2067,6 +2067,54 @@ The commands accepted in replication mode are:
</listitem>
</varlistentry>
<varlistentry>
<term><literal>READ_REPLICATION_SLOT</literal> <replaceable class="parameter">slot_name</replaceable>
<indexterm><primary>READ_REPLICATION_SLOT</primary></indexterm>
</term>
<listitem>
<para>
Read some information associated to a replication slot. Returns a tuple
with <literal>NULL</literal> values if the replication slot does not
exist. This command is currently only supported for physical replication
slots.
</para>
<para>
In response to this command, the server will return a one-row result set,
containing the following fields:
<variablelist>
<varlistentry>
<term><literal>slot_type</literal> (<type>text</type>)</term>
<listitem>
<para>
The replication slot's type, either <literal>physical</literal> or
<literal>NULL</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>restart_lsn</literal> (<type>text</type>)</term>
<listitem>
<para>
The replication slot's <literal>restart_lsn</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>restart_tli</literal> (<type>int8</type>)</term>
<listitem>
<para>
The timeline ID associated to <literal>restart_lsn</literal>,
following the current timeline history.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>START_REPLICATION</literal> [ <literal>SLOT</literal> <replaceable class="parameter">slot_name</replaceable> ] [ <literal>PHYSICAL</literal> ] <replaceable class="parameter">XXX/XXX</replaceable> [ <literal>TIMELINE</literal> <replaceable class="parameter">tli</replaceable> ]
<indexterm><primary>START_REPLICATION</primary></indexterm>