From 6615e77439a3c8c26c0091a616f00eefdea22604 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Mon, 24 Feb 2014 10:38:45 -0500 Subject: [PATCH] Use pg_lsn data type in pg_stat_replication, too. Michael Paquier, per a suggestion from Andres Freund --- doc/src/sgml/monitoring.sgml | 8 ++++---- src/backend/replication/walsender.c | 19 +++++-------------- src/include/catalog/catversion.h | 2 +- src/include/catalog/pg_proc.h | 2 +- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index a37e6b6f33..370857a0e8 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -1490,24 +1490,24 @@ postgres: user database host sent_location - text + pg_lsn Last transaction log position sent on this connection write_location - text + pg_lsn Last transaction log position written to disk by this standby server flush_location - text + pg_lsn Last transaction log position flushed to disk by this standby server replay_location - text + pg_lsn Last transaction log position replayed into the database on this standby server diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 06b22e2aba..048367af29 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -67,6 +67,7 @@ #include "utils/builtins.h" #include "utils/guc.h" #include "utils/memutils.h" +#include "utils/pg_lsn.h" #include "utils/ps_status.h" #include "utils/resowner.h" #include "utils/timeout.h" @@ -2137,7 +2138,6 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS) { /* use volatile pointer to prevent code rearrangement */ volatile WalSnd *walsnd = &WalSndCtl->walsnds[i]; - char location[MAXFNAMELEN]; XLogRecPtr sentPtr; XLogRecPtr write; XLogRecPtr flush; @@ -2171,28 +2171,19 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS) else { values[1] = CStringGetTextDatum(WalSndGetStateString(state)); - - snprintf(location, sizeof(location), "%X/%X", - (uint32) (sentPtr >> 32), (uint32) sentPtr); - values[2] = CStringGetTextDatum(location); + values[2] = LSNGetDatum(sentPtr); if (write == 0) nulls[3] = true; - snprintf(location, sizeof(location), "%X/%X", - (uint32) (write >> 32), (uint32) write); - values[3] = CStringGetTextDatum(location); + values[3] = LSNGetDatum(write); if (flush == 0) nulls[4] = true; - snprintf(location, sizeof(location), "%X/%X", - (uint32) (flush >> 32), (uint32) flush); - values[4] = CStringGetTextDatum(location); + values[4] = LSNGetDatum(flush); if (apply == 0) nulls[5] = true; - snprintf(location, sizeof(location), "%X/%X", - (uint32) (apply >> 32), (uint32) apply); - values[5] = CStringGetTextDatum(location); + values[5] = LSNGetDatum(apply); values[6] = Int32GetDatum(sync_priority[i]); diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 1789eb357d..68f96bebaf 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 201402192 +#define CATALOG_VERSION_NO 201402241 #endif diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 11c1e1abc1..a2cc19fd7b 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -2634,7 +2634,7 @@ DATA(insert OID = 1936 ( pg_stat_get_backend_idset PGNSP PGUID 12 1 100 0 0 f DESCR("statistics: currently active backend IDs"); DATA(insert OID = 2022 ( pg_stat_get_activity PGNSP PGUID 12 1 100 0 0 f f f f f t s 1 0 2249 "23" "{23,26,23,26,25,25,25,16,1184,1184,1184,1184,869,25,23}" "{i,o,o,o,o,o,o,o,o,o,o,o,o,o,o}" "{pid,datid,pid,usesysid,application_name,state,query,waiting,xact_start,query_start,backend_start,state_change,client_addr,client_hostname,client_port}" _null_ pg_stat_get_activity _null_ _null_ _null_ )); DESCR("statistics: information about currently active backends"); -DATA(insert OID = 3099 ( pg_stat_get_wal_senders PGNSP PGUID 12 1 10 0 0 f f f f f t s 0 0 2249 "" "{23,25,25,25,25,25,23,25}" "{o,o,o,o,o,o,o,o}" "{pid,state,sent_location,write_location,flush_location,replay_location,sync_priority,sync_state}" _null_ pg_stat_get_wal_senders _null_ _null_ _null_ )); +DATA(insert OID = 3099 ( pg_stat_get_wal_senders PGNSP PGUID 12 1 10 0 0 f f f f f t s 0 0 2249 "" "{23,25,3220,3220,3220,3220,23,25}" "{o,o,o,o,o,o,o,o}" "{pid,state,sent_location,write_location,flush_location,replay_location,sync_priority,sync_state}" _null_ pg_stat_get_wal_senders _null_ _null_ _null_ )); DESCR("statistics: information about currently active replication"); DATA(insert OID = 2026 ( pg_backend_pid PGNSP PGUID 12 1 0 0 0 f f f f t f s 0 0 23 "" _null_ _null_ _null_ _null_ pg_backend_pid _null_ _null_ _null_ )); DESCR("statistics: current backend PID"); -- 2.40.0