mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Add 'active_in' column to pg_replication_slots.
Right now it is visible whether a replication slot is active in any session, but not in which. Adding the active_in column, containing the pid of the backend having acquired the slot, makes it much easier to associate pg_replication_slots entries with the corresponding pg_stat_replication/pg_stat_activity row. This should have been done from the start, but I (Andres) dropped the ball there somehow. Author: Craig Ringer, revised by me Discussion: CAMsr+YFKgZca5_7_ouaMWxA5PneJC9LNViPzpDHusaPhU9pA7g@mail.gmail.com
This commit is contained in:
@@ -158,7 +158,7 @@ pg_drop_replication_slot(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
pg_get_replication_slots(PG_FUNCTION_ARGS)
|
||||
{
|
||||
#define PG_GET_REPLICATION_SLOTS_COLS 8
|
||||
#define PG_GET_REPLICATION_SLOTS_COLS 9
|
||||
ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
|
||||
TupleDesc tupdesc;
|
||||
Tuplestorestate *tupstore;
|
||||
@@ -206,7 +206,7 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
|
||||
TransactionId xmin;
|
||||
TransactionId catalog_xmin;
|
||||
XLogRecPtr restart_lsn;
|
||||
bool active;
|
||||
pid_t active_pid;
|
||||
Oid database;
|
||||
NameData slot_name;
|
||||
NameData plugin;
|
||||
@@ -227,7 +227,7 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
|
||||
namecpy(&slot_name, &slot->data.name);
|
||||
namecpy(&plugin, &slot->data.plugin);
|
||||
|
||||
active = slot->active;
|
||||
active_pid = slot->active_pid;
|
||||
}
|
||||
SpinLockRelease(&slot->mutex);
|
||||
|
||||
@@ -251,7 +251,12 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
|
||||
else
|
||||
values[i++] = database;
|
||||
|
||||
values[i++] = BoolGetDatum(active);
|
||||
values[i++] = BoolGetDatum(active_pid != 0);
|
||||
|
||||
if (active_pid != 0)
|
||||
values[i++] = Int32GetDatum(active_pid);
|
||||
else
|
||||
nulls[i++] = true;
|
||||
|
||||
if (xmin != InvalidTransactionId)
|
||||
values[i++] = TransactionIdGetDatum(xmin);
|
||||
|
Reference in New Issue
Block a user