PostgreSQL Source Code  git master
standbydesc.c File Reference
#include "postgres.h"
#include "storage/standbydefs.h"
Include dependency graph for standbydesc.c:

Go to the source code of this file.

Functions

static void standby_desc_running_xacts (StringInfo buf, xl_running_xacts *xlrec)
 
void standby_desc (StringInfo buf, XLogReaderState *record)
 
const char * standby_identify (uint8 info)
 
void standby_desc_invalidations (StringInfo buf, int nmsgs, SharedInvalidationMessage *msgs, Oid dbId, Oid tsId, bool relcacheInitFileInval)
 

Function Documentation

◆ standby_desc()

void standby_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 47 of file standbydesc.c.

48 {
49  char *rec = XLogRecGetData(record);
50  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
51 
52  if (info == XLOG_STANDBY_LOCK)
53  {
54  xl_standby_locks *xlrec = (xl_standby_locks *) rec;
55  int i;
56 
57  for (i = 0; i < xlrec->nlocks; i++)
58  appendStringInfo(buf, "xid %u db %u rel %u ",
59  xlrec->locks[i].xid, xlrec->locks[i].dbOid,
60  xlrec->locks[i].relOid);
61  }
62  else if (info == XLOG_RUNNING_XACTS)
63  {
64  xl_running_xacts *xlrec = (xl_running_xacts *) rec;
65 
67  }
68  else if (info == XLOG_INVALIDATIONS)
69  {
70  xl_invalidations *xlrec = (xl_invalidations *) rec;
71 
72  standby_desc_invalidations(buf, xlrec->nmsgs, xlrec->msgs,
73  xlrec->dbId, xlrec->tsId,
74  xlrec->relcacheInitFileInval);
75  }
76 }
unsigned char uint8
Definition: c.h:440
int i
Definition: isn.c:73
static char * buf
Definition: pg_test_fsync.c:67
#define XLOG_INVALIDATIONS
Definition: standbydefs.h:36
#define XLOG_STANDBY_LOCK
Definition: standbydefs.h:34
#define XLOG_RUNNING_XACTS
Definition: standbydefs.h:35
void standby_desc_invalidations(StringInfo buf, int nmsgs, SharedInvalidationMessage *msgs, Oid dbId, Oid tsId, bool relcacheInitFileInval)
Definition: standbydesc.c:105
static void standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
Definition: standbydesc.c:20
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
SharedInvalidationMessage msgs[FLEXIBLE_ARRAY_MEMBER]
Definition: standbydefs.h:69
bool relcacheInitFileInval
Definition: standbydefs.h:67
TransactionId xid
Definition: lockdefs.h:51
xl_standby_lock locks[FLEXIBLE_ARRAY_MEMBER]
Definition: standbydefs.h:41
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:411
#define XLogRecGetData(decoder)
Definition: xlogreader.h:416
#define XLR_INFO_MASK
Definition: xlogrecord.h:62

References appendStringInfo(), buf, xl_invalidations::dbId, xl_standby_lock::dbOid, i, xl_standby_locks::locks, xl_invalidations::msgs, xl_standby_locks::nlocks, xl_invalidations::nmsgs, xl_invalidations::relcacheInitFileInval, xl_standby_lock::relOid, standby_desc_invalidations(), standby_desc_running_xacts(), xl_invalidations::tsId, xl_standby_lock::xid, XLOG_INVALIDATIONS, XLOG_RUNNING_XACTS, XLOG_STANDBY_LOCK, XLogRecGetData, XLogRecGetInfo, and XLR_INFO_MASK.

◆ standby_desc_invalidations()

void standby_desc_invalidations ( StringInfo  buf,
int  nmsgs,
SharedInvalidationMessage msgs,
Oid  dbId,
Oid  tsId,
bool  relcacheInitFileInval 
)

Definition at line 105 of file standbydesc.c.

109 {
110  int i;
111 
112  /* Do nothing if there are no invalidation messages */
113  if (nmsgs <= 0)
114  return;
115 
116  if (relcacheInitFileInval)
117  appendStringInfo(buf, "; relcache init file inval dbid %u tsid %u",
118  dbId, tsId);
119 
120  appendStringInfoString(buf, "; inval msgs:");
121  for (i = 0; i < nmsgs; i++)
122  {
123  SharedInvalidationMessage *msg = &msgs[i];
124 
125  if (msg->id >= 0)
126  appendStringInfo(buf, " catcache %d", msg->id);
127  else if (msg->id == SHAREDINVALCATALOG_ID)
128  appendStringInfo(buf, " catalog %u", msg->cat.catId);
129  else if (msg->id == SHAREDINVALRELCACHE_ID)
130  appendStringInfo(buf, " relcache %u", msg->rc.relId);
131  /* not expected, but print something anyway */
132  else if (msg->id == SHAREDINVALSMGR_ID)
133  appendStringInfoString(buf, " smgr");
134  /* not expected, but print something anyway */
135  else if (msg->id == SHAREDINVALRELMAP_ID)
136  appendStringInfo(buf, " relmap db %u", msg->rm.dbId);
137  else if (msg->id == SHAREDINVALSNAPSHOT_ID)
138  appendStringInfo(buf, " snapshot %u", msg->sn.relId);
139  else
140  appendStringInfo(buf, " unrecognized id %d", msg->id);
141  }
142 }
#define SHAREDINVALCATALOG_ID
Definition: sinval.h:67
#define SHAREDINVALSMGR_ID
Definition: sinval.h:85
#define SHAREDINVALSNAPSHOT_ID
Definition: sinval.h:104
#define SHAREDINVALRELCACHE_ID
Definition: sinval.h:76
#define SHAREDINVALRELMAP_ID
Definition: sinval.h:96
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
SharedInvalRelcacheMsg rc
Definition: sinval.h:118
SharedInvalCatalogMsg cat
Definition: sinval.h:117
SharedInvalSnapshotMsg sn
Definition: sinval.h:121
SharedInvalRelmapMsg rm
Definition: sinval.h:120

References appendStringInfo(), appendStringInfoString(), buf, SharedInvalidationMessage::cat, SharedInvalCatalogMsg::catId, SharedInvalRelmapMsg::dbId, i, SharedInvalidationMessage::id, SharedInvalidationMessage::rc, SharedInvalRelcacheMsg::relId, SharedInvalSnapshotMsg::relId, SharedInvalidationMessage::rm, SHAREDINVALCATALOG_ID, SHAREDINVALRELCACHE_ID, SHAREDINVALRELMAP_ID, SHAREDINVALSMGR_ID, SHAREDINVALSNAPSHOT_ID, and SharedInvalidationMessage::sn.

Referenced by standby_desc(), xact_desc(), xact_desc_commit(), and xact_desc_prepare().

◆ standby_desc_running_xacts()

static void standby_desc_running_xacts ( StringInfo  buf,
xl_running_xacts xlrec 
)
static

Definition at line 20 of file standbydesc.c.

21 {
22  int i;
23 
24  appendStringInfo(buf, "nextXid %u latestCompletedXid %u oldestRunningXid %u",
25  xlrec->nextXid,
26  xlrec->latestCompletedXid,
27  xlrec->oldestRunningXid);
28  if (xlrec->xcnt > 0)
29  {
30  appendStringInfo(buf, "; %d xacts:", xlrec->xcnt);
31  for (i = 0; i < xlrec->xcnt; i++)
32  appendStringInfo(buf, " %u", xlrec->xids[i]);
33  }
34 
35  if (xlrec->subxid_overflow)
36  appendStringInfoString(buf, "; subxid overflowed");
37 
38  if (xlrec->subxcnt > 0)
39  {
40  appendStringInfo(buf, "; %d subxacts:", xlrec->subxcnt);
41  for (i = 0; i < xlrec->subxcnt; i++)
42  appendStringInfo(buf, " %u", xlrec->xids[xlrec->xcnt + i]);
43  }
44 }
TransactionId latestCompletedXid
Definition: standbydefs.h:54
TransactionId oldestRunningXid
Definition: standbydefs.h:53
TransactionId xids[FLEXIBLE_ARRAY_MEMBER]
Definition: standbydefs.h:56
TransactionId nextXid
Definition: standbydefs.h:52

References appendStringInfo(), appendStringInfoString(), buf, i, xl_running_xacts::latestCompletedXid, xl_running_xacts::nextXid, xl_running_xacts::oldestRunningXid, xl_running_xacts::subxcnt, xl_running_xacts::subxid_overflow, xl_running_xacts::xcnt, and xl_running_xacts::xids.

Referenced by standby_desc().

◆ standby_identify()

const char* standby_identify ( uint8  info)

Definition at line 79 of file standbydesc.c.

80 {
81  const char *id = NULL;
82 
83  switch (info & ~XLR_INFO_MASK)
84  {
85  case XLOG_STANDBY_LOCK:
86  id = "LOCK";
87  break;
88  case XLOG_RUNNING_XACTS:
89  id = "RUNNING_XACTS";
90  break;
91  case XLOG_INVALIDATIONS:
92  id = "INVALIDATIONS";
93  break;
94  }
95 
96  return id;
97 }

References XLOG_INVALIDATIONS, XLOG_RUNNING_XACTS, XLOG_STANDBY_LOCK, and XLR_INFO_MASK.