Skip to content

Commit 6615e77

Browse files
committed
Use pg_lsn data type in pg_stat_replication, too.
Michael Paquier, per a suggestion from Andres Freund
1 parent bb818b5 commit 6615e77

File tree

4 files changed

+11
-20
lines changed

4 files changed

+11
-20
lines changed

doc/src/sgml/monitoring.sgml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,24 +1490,24 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
14901490
</row>
14911491
<row>
14921492
<entry><structfield>sent_location</></entry>
1493-
<entry><type>text</></entry>
1493+
<entry><type>pg_lsn</></entry>
14941494
<entry>Last transaction log position sent on this connection</entry>
14951495
</row>
14961496
<row>
14971497
<entry><structfield>write_location</></entry>
1498-
<entry><type>text</></entry>
1498+
<entry><type>pg_lsn</></entry>
14991499
<entry>Last transaction log position written to disk by this standby
15001500
server</entry>
15011501
</row>
15021502
<row>
15031503
<entry><structfield>flush_location</></entry>
1504-
<entry><type>text</></entry>
1504+
<entry><type>pg_lsn</></entry>
15051505
<entry>Last transaction log position flushed to disk by this standby
15061506
server</entry>
15071507
</row>
15081508
<row>
15091509
<entry><structfield>replay_location</></entry>
1510-
<entry><type>text</></entry>
1510+
<entry><type>pg_lsn</></entry>
15111511
<entry>Last transaction log position replayed into the database on this
15121512
standby server</entry>
15131513
</row>

src/backend/replication/walsender.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#include "utils/builtins.h"
6868
#include "utils/guc.h"
6969
#include "utils/memutils.h"
70+
#include "utils/pg_lsn.h"
7071
#include "utils/ps_status.h"
7172
#include "utils/resowner.h"
7273
#include "utils/timeout.h"
@@ -2137,7 +2138,6 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
21372138
{
21382139
/* use volatile pointer to prevent code rearrangement */
21392140
volatile WalSnd *walsnd = &WalSndCtl->walsnds[i];
2140-
char location[MAXFNAMELEN];
21412141
XLogRecPtr sentPtr;
21422142
XLogRecPtr write;
21432143
XLogRecPtr flush;
@@ -2171,28 +2171,19 @@ pg_stat_get_wal_senders(PG_FUNCTION_ARGS)
21712171
else
21722172
{
21732173
values[1] = CStringGetTextDatum(WalSndGetStateString(state));
2174-
2175-
snprintf(location, sizeof(location), "%X/%X",
2176-
(uint32) (sentPtr >> 32), (uint32) sentPtr);
2177-
values[2] = CStringGetTextDatum(location);
2174+
values[2] = LSNGetDatum(sentPtr);
21782175

21792176
if (write == 0)
21802177
nulls[3] = true;
2181-
snprintf(location, sizeof(location), "%X/%X",
2182-
(uint32) (write >> 32), (uint32) write);
2183-
values[3] = CStringGetTextDatum(location);
2178+
values[3] = LSNGetDatum(write);
21842179

21852180
if (flush == 0)
21862181
nulls[4] = true;
2187-
snprintf(location, sizeof(location), "%X/%X",
2188-
(uint32) (flush >> 32), (uint32) flush);
2189-
values[4] = CStringGetTextDatum(location);
2182+
values[4] = LSNGetDatum(flush);
21902183

21912184
if (apply == 0)
21922185
nulls[5] = true;
2193-
snprintf(location, sizeof(location), "%X/%X",
2194-
(uint32) (apply >> 32), (uint32) apply);
2195-
values[5] = CStringGetTextDatum(location);
2186+
values[5] = LSNGetDatum(apply);
21962187

21972188
values[6] = Int32GetDatum(sync_priority[i]);
21982189

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 201402192
56+
#define CATALOG_VERSION_NO 201402241
5757

5858
#endif

src/include/catalog/pg_proc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2634,7 +2634,7 @@ DATA(insert OID = 1936 ( pg_stat_get_backend_idset PGNSP PGUID 12 1 100 0 0 f
26342634
DESCR("statistics: currently active backend IDs");
26352635
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_ ));
26362636
DESCR("statistics: information about currently active backends");
2637-
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_ ));
2637+
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_ ));
26382638
DESCR("statistics: information about currently active replication");
26392639
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_ ));
26402640
DESCR("statistics: current backend PID");

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy