mirror of
https://github.com/postgres/postgres.git
synced 2025-08-22 21:53:06 +03:00
Add option to control snapshot export to CREATE_REPLICATION_SLOT
We used to export snapshots unconditionally in CREATE_REPLICATION_SLOT in the replication protocol, but several upcoming patches want more control over what happens. Suppress snapshot export in pg_recvlogical, which neither needs nor can use the exported snapshot. Since snapshot exporting can fail this improves reliability. This also paves the way for allowing the creation of replication slots on standbys, which cannot export snapshots because they cannot allocate new XIDs. Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
This commit is contained in:
@@ -338,8 +338,13 @@ CreateReplicationSlot(PGconn *conn, const char *slot_name, const char *plugin,
|
||||
appendPQExpBuffer(query, "CREATE_REPLICATION_SLOT \"%s\" PHYSICAL",
|
||||
slot_name);
|
||||
else
|
||||
{
|
||||
appendPQExpBuffer(query, "CREATE_REPLICATION_SLOT \"%s\" LOGICAL \"%s\"",
|
||||
slot_name, plugin);
|
||||
if (PQserverVersion(conn) >= 100000)
|
||||
/* pg_recvlogical doesn't use an exported snapshot, so suppress */
|
||||
appendPQExpBuffer(query, " NOEXPORT_SNAPSHOT");
|
||||
}
|
||||
|
||||
res = PQexec(conn, query->data);
|
||||
if (PQresultStatus(res) != PGRES_TUPLES_OK)
|
||||
|
Reference in New Issue
Block a user