1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-30 06:01:21 +03:00

Make pg_stat_wal_receiver consistent with the WAL receiver's shmem info

d140f2f3 has renamed receivedUpto to flushedUpto, and has added
writtenUpto to the WAL receiver's shared memory information, but
pg_stat_wal_receiver was not consistent with that.  This commit renames
received_lsn to flushed_lsn, and adds a new column called written_lsn.

Bump catalog version.

Author: Michael Paquier
Reviewed-by: Álvaro Herrera
Discussion: https://postgr.es/m/20200515090817.GA212736@paquier.xyz
This commit is contained in:
Michael Paquier
2020-05-17 09:22:07 +09:00
parent e78b930945
commit 2c8dd05d6c
6 changed files with 48 additions and 30 deletions

View File

@@ -812,7 +812,8 @@ CREATE VIEW pg_stat_wal_receiver AS
s.status,
s.receive_start_lsn,
s.receive_start_tli,
s.received_lsn,
s.written_lsn,
s.flushed_lsn,
s.received_tli,
s.last_msg_send_time,
s.last_msg_receipt_time,

View File

@@ -1348,7 +1348,8 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
WalRcvState state;
XLogRecPtr receive_start_lsn;
TimeLineID receive_start_tli;
XLogRecPtr received_lsn;
XLogRecPtr written_lsn;
XLogRecPtr flushed_lsn;
TimeLineID received_tli;
TimestampTz last_send_time;
TimestampTz last_receipt_time;
@@ -1366,7 +1367,8 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
state = WalRcv->walRcvState;
receive_start_lsn = WalRcv->receiveStart;
receive_start_tli = WalRcv->receiveStartTLI;
received_lsn = WalRcv->flushedUpto;
written_lsn = pg_atomic_read_u64(&WalRcv->writtenUpto);
flushed_lsn = WalRcv->flushedUpto;
received_tli = WalRcv->receivedTLI;
last_send_time = WalRcv->lastMsgSendTime;
last_receipt_time = WalRcv->lastMsgReceiptTime;
@@ -1413,43 +1415,47 @@ pg_stat_get_wal_receiver(PG_FUNCTION_ARGS)
else
values[2] = LSNGetDatum(receive_start_lsn);
values[3] = Int32GetDatum(receive_start_tli);
if (XLogRecPtrIsInvalid(received_lsn))
if (XLogRecPtrIsInvalid(written_lsn))
nulls[4] = true;
else
values[4] = LSNGetDatum(received_lsn);
values[5] = Int32GetDatum(received_tli);
if (last_send_time == 0)
nulls[6] = true;
values[4] = LSNGetDatum(written_lsn);
if (XLogRecPtrIsInvalid(flushed_lsn))
nulls[5] = true;
else
values[6] = TimestampTzGetDatum(last_send_time);
if (last_receipt_time == 0)
values[5] = LSNGetDatum(flushed_lsn);
values[6] = Int32GetDatum(received_tli);
if (last_send_time == 0)
nulls[7] = true;
else
values[7] = TimestampTzGetDatum(last_receipt_time);
if (XLogRecPtrIsInvalid(latest_end_lsn))
values[7] = TimestampTzGetDatum(last_send_time);
if (last_receipt_time == 0)
nulls[8] = true;
else
values[8] = LSNGetDatum(latest_end_lsn);
if (latest_end_time == 0)
values[8] = TimestampTzGetDatum(last_receipt_time);
if (XLogRecPtrIsInvalid(latest_end_lsn))
nulls[9] = true;
else
values[9] = TimestampTzGetDatum(latest_end_time);
if (*slotname == '\0')
values[9] = LSNGetDatum(latest_end_lsn);
if (latest_end_time == 0)
nulls[10] = true;
else
values[10] = CStringGetTextDatum(slotname);
if (*sender_host == '\0')
values[10] = TimestampTzGetDatum(latest_end_time);
if (*slotname == '\0')
nulls[11] = true;
else
values[11] = CStringGetTextDatum(sender_host);
if (sender_port == 0)
values[11] = CStringGetTextDatum(slotname);
if (*sender_host == '\0')
nulls[12] = true;
else
values[12] = Int32GetDatum(sender_port);
if (*conninfo == '\0')
values[12] = CStringGetTextDatum(sender_host);
if (sender_port == 0)
nulls[13] = true;
else
values[13] = CStringGetTextDatum(conninfo);
values[13] = Int32GetDatum(sender_port);
if (*conninfo == '\0')
nulls[14] = true;
else
values[14] = CStringGetTextDatum(conninfo);
}
/* Returns the record as Datum */