PostgreSQL Source Code  git master
xactdesc.c File Reference
#include "postgres.h"
#include "access/transam.h"
#include "access/xact.h"
#include "replication/origin.h"
#include "storage/sinval.h"
#include "storage/standbydefs.h"
#include "utils/timestamp.h"
Include dependency graph for xactdesc.c:

Go to the source code of this file.

Functions

void ParseCommitRecord (uint8 info, xl_xact_commit *xlrec, xl_xact_parsed_commit *parsed)
 
void ParseAbortRecord (uint8 info, xl_xact_abort *xlrec, xl_xact_parsed_abort *parsed)
 
void ParsePrepareRecord (uint8 info, xl_xact_prepare *xlrec, xl_xact_parsed_prepare *parsed)
 
static void xact_desc_relations (StringInfo buf, char *label, int nrels, RelFileNode *xnodes)
 
static void xact_desc_subxacts (StringInfo buf, int nsubxacts, TransactionId *subxacts)
 
static void xact_desc_stats (StringInfo buf, const char *label, int ndropped, xl_xact_stats_item *dropped_stats)
 
static void xact_desc_commit (StringInfo buf, uint8 info, xl_xact_commit *xlrec, RepOriginId origin_id)
 
static void xact_desc_abort (StringInfo buf, uint8 info, xl_xact_abort *xlrec, RepOriginId origin_id)
 
static void xact_desc_prepare (StringInfo buf, uint8 info, xl_xact_prepare *xlrec, RepOriginId origin_id)
 
static void xact_desc_assignment (StringInfo buf, xl_xact_assignment *xlrec)
 
void xact_desc (StringInfo buf, XLogReaderState *record)
 
const char * xact_identify (uint8 info)
 

Function Documentation

◆ ParseAbortRecord()

void ParseAbortRecord ( uint8  info,
xl_xact_abort xlrec,
xl_xact_parsed_abort parsed 
)

Definition at line 141 of file xactdesc.c.

142 {
143  char *data = ((char *) xlrec) + MinSizeOfXactAbort;
144 
145  memset(parsed, 0, sizeof(*parsed));
146 
147  parsed->xinfo = 0; /* default, if no XLOG_XACT_HAS_INFO is
148  * present */
149 
150  parsed->xact_time = xlrec->xact_time;
151 
152  if (info & XLOG_XACT_HAS_INFO)
153  {
154  xl_xact_xinfo *xl_xinfo = (xl_xact_xinfo *) data;
155 
156  parsed->xinfo = xl_xinfo->xinfo;
157 
158  data += sizeof(xl_xact_xinfo);
159  }
160 
161  if (parsed->xinfo & XACT_XINFO_HAS_DBINFO)
162  {
163  xl_xact_dbinfo *xl_dbinfo = (xl_xact_dbinfo *) data;
164 
165  parsed->dbId = xl_dbinfo->dbId;
166  parsed->tsId = xl_dbinfo->tsId;
167 
168  data += sizeof(xl_xact_dbinfo);
169  }
170 
171  if (parsed->xinfo & XACT_XINFO_HAS_SUBXACTS)
172  {
173  xl_xact_subxacts *xl_subxacts = (xl_xact_subxacts *) data;
174 
175  parsed->nsubxacts = xl_subxacts->nsubxacts;
176  parsed->subxacts = xl_subxacts->subxacts;
177 
179  data += parsed->nsubxacts * sizeof(TransactionId);
180  }
181 
182  if (parsed->xinfo & XACT_XINFO_HAS_RELFILENODES)
183  {
184  xl_xact_relfilenodes *xl_relfilenodes = (xl_xact_relfilenodes *) data;
185 
186  parsed->nrels = xl_relfilenodes->nrels;
187  parsed->xnodes = xl_relfilenodes->xnodes;
188 
190  data += xl_relfilenodes->nrels * sizeof(RelFileNode);
191  }
192 
193  if (parsed->xinfo & XACT_XINFO_HAS_DROPPED_STATS)
194  {
196 
197  parsed->nstats = xl_drops->nitems;
198  parsed->stats = xl_drops->items;
199 
201  data += xl_drops->nitems * sizeof(xl_xact_stats_item);
202  }
203 
204  if (parsed->xinfo & XACT_XINFO_HAS_TWOPHASE)
205  {
206  xl_xact_twophase *xl_twophase = (xl_xact_twophase *) data;
207 
208  parsed->twophase_xid = xl_twophase->xid;
209 
210  data += sizeof(xl_xact_twophase);
211 
212  if (parsed->xinfo & XACT_XINFO_HAS_GID)
213  {
214  strlcpy(parsed->twophase_gid, data, sizeof(parsed->twophase_gid));
215  data += strlen(data) + 1;
216  }
217  }
218 
219  /* Note: no alignment is guaranteed after this point */
220 
221  if (parsed->xinfo & XACT_XINFO_HAS_ORIGIN)
222  {
223  xl_xact_origin xl_origin;
224 
225  /* no alignment is guaranteed, so copy onto stack */
226  memcpy(&xl_origin, data, sizeof(xl_origin));
227 
228  parsed->origin_lsn = xl_origin.origin_lsn;
229  parsed->origin_timestamp = xl_origin.origin_timestamp;
230 
231  data += sizeof(xl_xact_origin);
232  }
233 }
uint32 TransactionId
Definition: c.h:587
const void * data
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:45
struct RelFileNode RelFileNode
TimestampTz xact_time
Definition: xact.h:319
Oid tsId
Definition: xact.h:245
Oid dbId
Definition: xact.h:244
TimestampTz origin_timestamp
Definition: xact.h:298
XLogRecPtr origin_lsn
Definition: xact.h:297
xl_xact_stats_item * stats
Definition: xact.h:406
TransactionId twophase_xid
Definition: xact.h:408
TimestampTz xact_time
Definition: xact.h:393
RelFileNode * xnodes
Definition: xact.h:403
TransactionId * subxacts
Definition: xact.h:400
XLogRecPtr origin_lsn
Definition: xact.h:411
char twophase_gid[GIDSIZE]
Definition: xact.h:409
TimestampTz origin_timestamp
Definition: xact.h:412
RelFileNode xnodes[FLEXIBLE_ARRAY_MEMBER]
Definition: xact.h:258
xl_xact_stats_item items[FLEXIBLE_ARRAY_MEMBER]
Definition: xact.h:279
TransactionId subxacts[FLEXIBLE_ARRAY_MEMBER]
Definition: xact.h:251
int nsubxacts
Definition: xact.h:250
TransactionId xid
Definition: xact.h:292
uint32 xinfo
Definition: xact.h:239
struct xl_xact_stats_item xl_xact_stats_item
#define XACT_XINFO_HAS_RELFILENODES
Definition: xact.h:177
#define MinSizeOfXactSubxacts
Definition: xact.h:253
struct xl_xact_dbinfo xl_xact_dbinfo
#define XACT_XINFO_HAS_GID
Definition: xact.h:182
struct xl_xact_origin xl_xact_origin
#define XACT_XINFO_HAS_ORIGIN
Definition: xact.h:180
#define XACT_XINFO_HAS_TWOPHASE
Definition: xact.h:179
#define MinSizeOfXactStatsItems
Definition: xact.h:281
#define MinSizeOfXactRelfilenodes
Definition: xact.h:260
#define MinSizeOfXactAbort
Definition: xact.h:331
struct xl_xact_xinfo xl_xact_xinfo
#define XACT_XINFO_HAS_DBINFO
Definition: xact.h:175
struct xl_xact_twophase xl_xact_twophase
#define XLOG_XACT_HAS_INFO
Definition: xact.h:169
#define XACT_XINFO_HAS_SUBXACTS
Definition: xact.h:176
#define XACT_XINFO_HAS_DROPPED_STATS
Definition: xact.h:183

References data, xl_xact_dbinfo::dbId, xl_xact_parsed_abort::dbId, xl_xact_stats_items::items, MinSizeOfXactAbort, MinSizeOfXactRelfilenodes, MinSizeOfXactStatsItems, MinSizeOfXactSubxacts, xl_xact_stats_items::nitems, xl_xact_relfilenodes::nrels, xl_xact_parsed_abort::nrels, xl_xact_parsed_abort::nstats, xl_xact_subxacts::nsubxacts, xl_xact_parsed_abort::nsubxacts, xl_xact_origin::origin_lsn, xl_xact_parsed_abort::origin_lsn, xl_xact_origin::origin_timestamp, xl_xact_parsed_abort::origin_timestamp, xl_xact_parsed_abort::stats, strlcpy(), xl_xact_subxacts::subxacts, xl_xact_parsed_abort::subxacts, xl_xact_dbinfo::tsId, xl_xact_parsed_abort::tsId, xl_xact_parsed_abort::twophase_gid, xl_xact_parsed_abort::twophase_xid, xl_xact_abort::xact_time, xl_xact_parsed_abort::xact_time, XACT_XINFO_HAS_DBINFO, XACT_XINFO_HAS_DROPPED_STATS, XACT_XINFO_HAS_GID, XACT_XINFO_HAS_ORIGIN, XACT_XINFO_HAS_RELFILENODES, XACT_XINFO_HAS_SUBXACTS, XACT_XINFO_HAS_TWOPHASE, xl_xact_twophase::xid, xl_xact_xinfo::xinfo, xl_xact_parsed_abort::xinfo, XLOG_XACT_HAS_INFO, xl_xact_relfilenodes::xnodes, and xl_xact_parsed_abort::xnodes.

Referenced by recoveryStopsAfter(), recoveryStopsBefore(), xact_decode(), xact_desc_abort(), and xact_redo().

◆ ParseCommitRecord()

void ParseCommitRecord ( uint8  info,
xl_xact_commit xlrec,
xl_xact_parsed_commit parsed 
)

Definition at line 35 of file xactdesc.c.

36 {
37  char *data = ((char *) xlrec) + MinSizeOfXactCommit;
38 
39  memset(parsed, 0, sizeof(*parsed));
40 
41  parsed->xinfo = 0; /* default, if no XLOG_XACT_HAS_INFO is
42  * present */
43 
44  parsed->xact_time = xlrec->xact_time;
45 
46  if (info & XLOG_XACT_HAS_INFO)
47  {
48  xl_xact_xinfo *xl_xinfo = (xl_xact_xinfo *) data;
49 
50  parsed->xinfo = xl_xinfo->xinfo;
51 
52  data += sizeof(xl_xact_xinfo);
53  }
54 
55  if (parsed->xinfo & XACT_XINFO_HAS_DBINFO)
56  {
57  xl_xact_dbinfo *xl_dbinfo = (xl_xact_dbinfo *) data;
58 
59  parsed->dbId = xl_dbinfo->dbId;
60  parsed->tsId = xl_dbinfo->tsId;
61 
62  data += sizeof(xl_xact_dbinfo);
63  }
64 
65  if (parsed->xinfo & XACT_XINFO_HAS_SUBXACTS)
66  {
67  xl_xact_subxacts *xl_subxacts = (xl_xact_subxacts *) data;
68 
69  parsed->nsubxacts = xl_subxacts->nsubxacts;
70  parsed->subxacts = xl_subxacts->subxacts;
71 
73  data += parsed->nsubxacts * sizeof(TransactionId);
74  }
75 
76  if (parsed->xinfo & XACT_XINFO_HAS_RELFILENODES)
77  {
78  xl_xact_relfilenodes *xl_relfilenodes = (xl_xact_relfilenodes *) data;
79 
80  parsed->nrels = xl_relfilenodes->nrels;
81  parsed->xnodes = xl_relfilenodes->xnodes;
82 
84  data += xl_relfilenodes->nrels * sizeof(RelFileNode);
85  }
86 
87  if (parsed->xinfo & XACT_XINFO_HAS_DROPPED_STATS)
88  {
90 
91  parsed->nstats = xl_drops->nitems;
92  parsed->stats = xl_drops->items;
93 
95  data += xl_drops->nitems * sizeof(xl_xact_stats_item);
96  }
97 
98  if (parsed->xinfo & XACT_XINFO_HAS_INVALS)
99  {
100  xl_xact_invals *xl_invals = (xl_xact_invals *) data;
101 
102  parsed->nmsgs = xl_invals->nmsgs;
103  parsed->msgs = xl_invals->msgs;
104 
106  data += xl_invals->nmsgs * sizeof(SharedInvalidationMessage);
107  }
108 
109  if (parsed->xinfo & XACT_XINFO_HAS_TWOPHASE)
110  {
111  xl_xact_twophase *xl_twophase = (xl_xact_twophase *) data;
112 
113  parsed->twophase_xid = xl_twophase->xid;
114 
115  data += sizeof(xl_xact_twophase);
116 
117  if (parsed->xinfo & XACT_XINFO_HAS_GID)
118  {
119  strlcpy(parsed->twophase_gid, data, sizeof(parsed->twophase_gid));
120  data += strlen(data) + 1;
121  }
122  }
123 
124  /* Note: no alignment is guaranteed after this point */
125 
126  if (parsed->xinfo & XACT_XINFO_HAS_ORIGIN)
127  {
128  xl_xact_origin xl_origin;
129 
130  /* no alignment is guaranteed, so copy onto stack */
131  memcpy(&xl_origin, data, sizeof(xl_origin));
132 
133  parsed->origin_lsn = xl_origin.origin_lsn;
134  parsed->origin_timestamp = xl_origin.origin_timestamp;
135 
136  data += sizeof(xl_xact_origin);
137  }
138 }
TimestampTz xact_time
Definition: xact.h:303
SharedInvalidationMessage msgs[FLEXIBLE_ARRAY_MEMBER]
Definition: xact.h:286
int nmsgs
Definition: xact.h:285
xl_xact_stats_item * stats
Definition: xact.h:373
TimestampTz xact_time
Definition: xact.h:360
TransactionId twophase_xid
Definition: xact.h:378
RelFileNode * xnodes
Definition: xact.h:370
TimestampTz origin_timestamp
Definition: xact.h:386
TransactionId * subxacts
Definition: xact.h:367
char twophase_gid[GIDSIZE]
Definition: xact.h:379
XLogRecPtr origin_lsn
Definition: xact.h:385
SharedInvalidationMessage * msgs
Definition: xact.h:376
#define MinSizeOfXactInvals
Definition: xact.h:288
#define MinSizeOfXactCommit
Definition: xact.h:315
#define XACT_XINFO_HAS_INVALS
Definition: xact.h:178

References data, xl_xact_dbinfo::dbId, xl_xact_parsed_commit::dbId, xl_xact_stats_items::items, MinSizeOfXactCommit, MinSizeOfXactInvals, MinSizeOfXactRelfilenodes, MinSizeOfXactStatsItems, MinSizeOfXactSubxacts, xl_xact_invals::msgs, xl_xact_parsed_commit::msgs, xl_xact_stats_items::nitems, xl_xact_invals::nmsgs, xl_xact_parsed_commit::nmsgs, xl_xact_relfilenodes::nrels, xl_xact_parsed_commit::nrels, xl_xact_parsed_commit::nstats, xl_xact_subxacts::nsubxacts, xl_xact_parsed_commit::nsubxacts, xl_xact_origin::origin_lsn, xl_xact_parsed_commit::origin_lsn, xl_xact_origin::origin_timestamp, xl_xact_parsed_commit::origin_timestamp, xl_xact_parsed_commit::stats, strlcpy(), xl_xact_subxacts::subxacts, xl_xact_parsed_commit::subxacts, xl_xact_dbinfo::tsId, xl_xact_parsed_commit::tsId, xl_xact_parsed_commit::twophase_gid, xl_xact_parsed_commit::twophase_xid, xl_xact_commit::xact_time, xl_xact_parsed_commit::xact_time, XACT_XINFO_HAS_DBINFO, XACT_XINFO_HAS_DROPPED_STATS, XACT_XINFO_HAS_GID, XACT_XINFO_HAS_INVALS, XACT_XINFO_HAS_ORIGIN, XACT_XINFO_HAS_RELFILENODES, XACT_XINFO_HAS_SUBXACTS, XACT_XINFO_HAS_TWOPHASE, xl_xact_twophase::xid, xl_xact_xinfo::xinfo, xl_xact_parsed_commit::xinfo, XLOG_XACT_HAS_INFO, xl_xact_relfilenodes::xnodes, and xl_xact_parsed_commit::xnodes.

Referenced by recoveryStopsAfter(), recoveryStopsBefore(), xact_decode(), xact_desc_commit(), and xact_redo().

◆ ParsePrepareRecord()

void ParsePrepareRecord ( uint8  info,
xl_xact_prepare xlrec,
xl_xact_parsed_prepare parsed 
)

Definition at line 239 of file xactdesc.c.

240 {
241  char *bufptr;
242 
243  bufptr = ((char *) xlrec) + MAXALIGN(sizeof(xl_xact_prepare));
244 
245  memset(parsed, 0, sizeof(*parsed));
246 
247  parsed->xact_time = xlrec->prepared_at;
248  parsed->origin_lsn = xlrec->origin_lsn;
249  parsed->origin_timestamp = xlrec->origin_timestamp;
250  parsed->twophase_xid = xlrec->xid;
251  parsed->dbId = xlrec->database;
252  parsed->nsubxacts = xlrec->nsubxacts;
253  parsed->nrels = xlrec->ncommitrels;
254  parsed->nabortrels = xlrec->nabortrels;
255  parsed->nmsgs = xlrec->ninvalmsgs;
256 
257  strncpy(parsed->twophase_gid, bufptr, xlrec->gidlen);
258  bufptr += MAXALIGN(xlrec->gidlen);
259 
260  parsed->subxacts = (TransactionId *) bufptr;
261  bufptr += MAXALIGN(xlrec->nsubxacts * sizeof(TransactionId));
262 
263  parsed->xnodes = (RelFileNode *) bufptr;
264  bufptr += MAXALIGN(xlrec->ncommitrels * sizeof(RelFileNode));
265 
266  parsed->abortnodes = (RelFileNode *) bufptr;
267  bufptr += MAXALIGN(xlrec->nabortrels * sizeof(RelFileNode));
268 
269  parsed->stats = (xl_xact_stats_item *) bufptr;
270  bufptr += MAXALIGN(xlrec->ncommitstats * sizeof(xl_xact_stats_item));
271 
272  parsed->abortstats = (xl_xact_stats_item *) bufptr;
273  bufptr += MAXALIGN(xlrec->nabortstats * sizeof(xl_xact_stats_item));
274 
275  parsed->msgs = (SharedInvalidationMessage *) bufptr;
276  bufptr += MAXALIGN(xlrec->ninvalmsgs * sizeof(SharedInvalidationMessage));
277 }
#define MAXALIGN(LEN)
Definition: c.h:757
RelFileNode * abortnodes
Definition: xact.h:381
xl_xact_stats_item * abortstats
Definition: xact.h:383
TimestampTz prepared_at
Definition: xact.h:339
int32 nabortrels
Definition: xact.h:343
int32 ninvalmsgs
Definition: xact.h:346
int32 ncommitstats
Definition: xact.h:344
TimestampTz origin_timestamp
Definition: xact.h:350
uint16 gidlen
Definition: xact.h:348
int32 nabortstats
Definition: xact.h:345
Oid database
Definition: xact.h:338
XLogRecPtr origin_lsn
Definition: xact.h:349
int32 ncommitrels
Definition: xact.h:342
TransactionId xid
Definition: xact.h:337
int32 nsubxacts
Definition: xact.h:341

References xl_xact_parsed_commit::abortnodes, xl_xact_parsed_commit::abortstats, xl_xact_prepare::database, xl_xact_parsed_commit::dbId, xl_xact_prepare::gidlen, MAXALIGN, xl_xact_parsed_commit::msgs, xl_xact_prepare::nabortrels, xl_xact_parsed_commit::nabortrels, xl_xact_prepare::nabortstats, xl_xact_prepare::ncommitrels, xl_xact_prepare::ncommitstats, xl_xact_prepare::ninvalmsgs, xl_xact_parsed_commit::nmsgs, xl_xact_parsed_commit::nrels, xl_xact_prepare::nsubxacts, xl_xact_parsed_commit::nsubxacts, xl_xact_prepare::origin_lsn, xl_xact_parsed_commit::origin_lsn, xl_xact_prepare::origin_timestamp, xl_xact_parsed_commit::origin_timestamp, xl_xact_prepare::prepared_at, xl_xact_parsed_commit::stats, xl_xact_parsed_commit::subxacts, xl_xact_parsed_commit::twophase_gid, xl_xact_parsed_commit::twophase_xid, xl_xact_parsed_commit::xact_time, xl_xact_prepare::xid, and xl_xact_parsed_commit::xnodes.

Referenced by xact_decode(), and xact_desc_prepare().

◆ xact_desc()

void xact_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 436 of file xactdesc.c.

437 {
438  char *rec = XLogRecGetData(record);
439  uint8 info = XLogRecGetInfo(record) & XLOG_XACT_OPMASK;
440 
441  if (info == XLOG_XACT_COMMIT || info == XLOG_XACT_COMMIT_PREPARED)
442  {
443  xl_xact_commit *xlrec = (xl_xact_commit *) rec;
444 
445  xact_desc_commit(buf, XLogRecGetInfo(record), xlrec,
446  XLogRecGetOrigin(record));
447  }
448  else if (info == XLOG_XACT_ABORT || info == XLOG_XACT_ABORT_PREPARED)
449  {
450  xl_xact_abort *xlrec = (xl_xact_abort *) rec;
451 
452  xact_desc_abort(buf, XLogRecGetInfo(record), xlrec,
453  XLogRecGetOrigin(record));
454  }
455  else if (info == XLOG_XACT_PREPARE)
456  {
457  xl_xact_prepare *xlrec = (xl_xact_prepare *) rec;
458 
459  xact_desc_prepare(buf, XLogRecGetInfo(record), xlrec,
460  XLogRecGetOrigin(record));
461  }
462  else if (info == XLOG_XACT_ASSIGNMENT)
463  {
464  xl_xact_assignment *xlrec = (xl_xact_assignment *) rec;
465 
466  /*
467  * Note that we ignore the WAL record's xid, since we're more
468  * interested in the top-level xid that issued the record and which
469  * xids are being reported here.
470  */
471  appendStringInfo(buf, "xtop %u: ", xlrec->xtop);
472  xact_desc_assignment(buf, xlrec);
473  }
474  else if (info == XLOG_XACT_INVALIDATIONS)
475  {
476  xl_xact_invals *xlrec = (xl_xact_invals *) rec;
477 
479  InvalidOid, false);
480  }
481 }
unsigned char uint8
Definition: c.h:439
static char * buf
Definition: pg_test_fsync.c:67
#define InvalidOid
Definition: postgres_ext.h:36
void standby_desc_invalidations(StringInfo buf, int nmsgs, SharedInvalidationMessage *msgs, Oid dbId, Oid tsId, bool relcacheInitFileInval)
Definition: standbydesc.c:98
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
TransactionId xtop
Definition: xact.h:207
#define XLOG_XACT_COMMIT_PREPARED
Definition: xact.h:159
#define XLOG_XACT_INVALIDATIONS
Definition: xact.h:162
#define XLOG_XACT_PREPARE
Definition: xact.h:157
#define XLOG_XACT_COMMIT
Definition: xact.h:156
#define XLOG_XACT_OPMASK
Definition: xact.h:166
#define XLOG_XACT_ABORT
Definition: xact.h:158
#define XLOG_XACT_ASSIGNMENT
Definition: xact.h:161
#define XLOG_XACT_ABORT_PREPARED
Definition: xact.h:160
static void xact_desc_commit(StringInfo buf, uint8 info, xl_xact_commit *xlrec, RepOriginId origin_id)
Definition: xactdesc.c:331
static void xact_desc_abort(StringInfo buf, uint8 info, xl_xact_abort *xlrec, RepOriginId origin_id)
Definition: xactdesc.c:367
static void xact_desc_assignment(StringInfo buf, xl_xact_assignment *xlrec)
Definition: xactdesc.c:425
static void xact_desc_prepare(StringInfo buf, uint8 info, xl_xact_prepare *xlrec, RepOriginId origin_id)
Definition: xactdesc.c:394
#define XLogRecGetOrigin(decoder)
Definition: xlogreader.h:411
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:408
#define XLogRecGetData(decoder)
Definition: xlogreader.h:413

References appendStringInfo(), buf, InvalidOid, xl_xact_invals::msgs, xl_xact_invals::nmsgs, standby_desc_invalidations(), xact_desc_abort(), xact_desc_assignment(), xact_desc_commit(), xact_desc_prepare(), XLOG_XACT_ABORT, XLOG_XACT_ABORT_PREPARED, XLOG_XACT_ASSIGNMENT, XLOG_XACT_COMMIT, XLOG_XACT_COMMIT_PREPARED, XLOG_XACT_INVALIDATIONS, XLOG_XACT_OPMASK, XLOG_XACT_PREPARE, XLogRecGetData, XLogRecGetInfo, XLogRecGetOrigin, and xl_xact_assignment::xtop.

◆ xact_desc_abort()

static void xact_desc_abort ( StringInfo  buf,
uint8  info,
xl_xact_abort xlrec,
RepOriginId  origin_id 
)
static

Definition at line 367 of file xactdesc.c.

368 {
369  xl_xact_parsed_abort parsed;
370 
371  ParseAbortRecord(info, xlrec, &parsed);
372 
373  /* If this is a prepared xact, show the xid of the original xact */
375  appendStringInfo(buf, "%u: ", parsed.twophase_xid);
376 
378 
379  xact_desc_relations(buf, "rels", parsed.nrels, parsed.xnodes);
380  xact_desc_subxacts(buf, parsed.nsubxacts, parsed.subxacts);
381 
382  if (parsed.xinfo & XACT_XINFO_HAS_ORIGIN)
383  {
384  appendStringInfo(buf, "; origin: node %u, lsn %X/%X, at %s",
385  origin_id,
386  LSN_FORMAT_ARGS(parsed.origin_lsn),
388  }
389 
390  xact_desc_stats(buf, "", parsed.nstats, parsed.stats);
391 }
const char * timestamptz_to_str(TimestampTz t)
Definition: timestamp.c:1768
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
#define TransactionIdIsValid(xid)
Definition: transam.h:41
static void xact_desc_stats(StringInfo buf, const char *label, int ndropped, xl_xact_stats_item *dropped_stats)
Definition: xactdesc.c:312
static void xact_desc_subxacts(StringInfo buf, int nsubxacts, TransactionId *subxacts)
Definition: xactdesc.c:299
static void xact_desc_relations(StringInfo buf, char *label, int nrels, RelFileNode *xnodes)
Definition: xactdesc.c:280
void ParseAbortRecord(uint8 info, xl_xact_abort *xlrec, xl_xact_parsed_abort *parsed)
Definition: xactdesc.c:141
#define LSN_FORMAT_ARGS(lsn)
Definition: xlogdefs.h:43

References appendStringInfo(), appendStringInfoString(), buf, LSN_FORMAT_ARGS, xl_xact_parsed_abort::nrels, xl_xact_parsed_abort::nstats, xl_xact_parsed_abort::nsubxacts, xl_xact_parsed_abort::origin_lsn, xl_xact_parsed_abort::origin_timestamp, ParseAbortRecord(), xl_xact_parsed_abort::stats, xl_xact_parsed_abort::subxacts, timestamptz_to_str(), TransactionIdIsValid, xl_xact_parsed_abort::twophase_xid, xact_desc_relations(), xact_desc_stats(), xact_desc_subxacts(), xl_xact_abort::xact_time, XACT_XINFO_HAS_ORIGIN, xl_xact_parsed_abort::xinfo, and xl_xact_parsed_abort::xnodes.

Referenced by xact_desc().

◆ xact_desc_assignment()

static void xact_desc_assignment ( StringInfo  buf,
xl_xact_assignment xlrec 
)
static

Definition at line 425 of file xactdesc.c.

426 {
427  int i;
428 
429  appendStringInfoString(buf, "subxacts:");
430 
431  for (i = 0; i < xlrec->nsubxacts; i++)
432  appendStringInfo(buf, " %u", xlrec->xsub[i]);
433 }
int i
Definition: isn.c:73
TransactionId xsub[FLEXIBLE_ARRAY_MEMBER]
Definition: xact.h:209

References appendStringInfo(), appendStringInfoString(), buf, i, xl_xact_assignment::nsubxacts, and xl_xact_assignment::xsub.

Referenced by xact_desc().

◆ xact_desc_commit()

static void xact_desc_commit ( StringInfo  buf,
uint8  info,
xl_xact_commit xlrec,
RepOriginId  origin_id 
)
static

Definition at line 331 of file xactdesc.c.

332 {
333  xl_xact_parsed_commit parsed;
334 
335  ParseCommitRecord(info, xlrec, &parsed);
336 
337  /* If this is a prepared xact, show the xid of the original xact */
339  appendStringInfo(buf, "%u: ", parsed.twophase_xid);
340 
342 
343  xact_desc_relations(buf, "rels", parsed.nrels, parsed.xnodes);
344  xact_desc_subxacts(buf, parsed.nsubxacts, parsed.subxacts);
345  xact_desc_stats(buf, "", parsed.nstats, parsed.stats);
346 
347  standby_desc_invalidations(buf, parsed.nmsgs, parsed.msgs, parsed.dbId,
348  parsed.tsId,
350 
352  appendStringInfoString(buf, "; apply_feedback");
353 
355  appendStringInfoString(buf, "; sync");
356 
357  if (parsed.xinfo & XACT_XINFO_HAS_ORIGIN)
358  {
359  appendStringInfo(buf, "; origin: node %u, lsn %X/%X, at %s",
360  origin_id,
361  LSN_FORMAT_ARGS(parsed.origin_lsn),
363  }
364 }
#define XactCompletionForceSyncCommit(xinfo)
Definition: xact.h:202
#define XactCompletionApplyFeedback(xinfo)
Definition: xact.h:198
#define XactCompletionRelcacheInitFileInval(xinfo)
Definition: xact.h:200
void ParseCommitRecord(uint8 info, xl_xact_commit *xlrec, xl_xact_parsed_commit *parsed)
Definition: xactdesc.c:35

References appendStringInfo(), appendStringInfoString(), buf, xl_xact_parsed_commit::dbId, LSN_FORMAT_ARGS, xl_xact_parsed_commit::msgs, xl_xact_parsed_commit::nmsgs, xl_xact_parsed_commit::nrels, xl_xact_parsed_commit::nstats, xl_xact_parsed_commit::nsubxacts, xl_xact_parsed_commit::origin_lsn, xl_xact_parsed_commit::origin_timestamp, ParseCommitRecord(), standby_desc_invalidations(), xl_xact_parsed_commit::stats, xl_xact_parsed_commit::subxacts, timestamptz_to_str(), TransactionIdIsValid, xl_xact_parsed_commit::tsId, xl_xact_parsed_commit::twophase_xid, xact_desc_relations(), xact_desc_stats(), xact_desc_subxacts(), xl_xact_commit::xact_time, XACT_XINFO_HAS_ORIGIN, XactCompletionApplyFeedback, XactCompletionForceSyncCommit, XactCompletionRelcacheInitFileInval, xl_xact_parsed_commit::xinfo, and xl_xact_parsed_commit::xnodes.

Referenced by xact_desc().

◆ xact_desc_prepare()

static void xact_desc_prepare ( StringInfo  buf,
uint8  info,
xl_xact_prepare xlrec,
RepOriginId  origin_id 
)
static

Definition at line 394 of file xactdesc.c.

395 {
396  xl_xact_parsed_prepare parsed;
397 
398  ParsePrepareRecord(info, xlrec, &parsed);
399 
400  appendStringInfo(buf, "gid %s: ", parsed.twophase_gid);
402 
403  xact_desc_relations(buf, "rels(commit)", parsed.nrels, parsed.xnodes);
404  xact_desc_relations(buf, "rels(abort)", parsed.nabortrels,
405  parsed.abortnodes);
406  xact_desc_stats(buf, "commit ", parsed.nstats, parsed.stats);
407  xact_desc_stats(buf, "abort ", parsed.nabortstats, parsed.abortstats);
408  xact_desc_subxacts(buf, parsed.nsubxacts, parsed.subxacts);
409 
410  standby_desc_invalidations(buf, parsed.nmsgs, parsed.msgs, parsed.dbId,
411  parsed.tsId, xlrec->initfileinval);
412 
413  /*
414  * Check if the replication origin has been set in this record in the same
415  * way as PrepareRedoAdd().
416  */
417  if (origin_id != InvalidRepOriginId)
418  appendStringInfo(buf, "; origin: node %u, lsn %X/%X, at %s",
419  origin_id,
420  LSN_FORMAT_ARGS(parsed.origin_lsn),
422 }
#define InvalidRepOriginId
Definition: origin.h:33
bool initfileinval
Definition: xact.h:347
void ParsePrepareRecord(uint8 info, xl_xact_prepare *xlrec, xl_xact_parsed_prepare *parsed)
Definition: xactdesc.c:239

References xl_xact_parsed_commit::abortnodes, xl_xact_parsed_commit::abortstats, appendStringInfo(), appendStringInfoString(), buf, xl_xact_parsed_commit::dbId, xl_xact_prepare::initfileinval, InvalidRepOriginId, LSN_FORMAT_ARGS, xl_xact_parsed_commit::msgs, xl_xact_parsed_commit::nabortrels, xl_xact_parsed_commit::nabortstats, xl_xact_parsed_commit::nmsgs, xl_xact_parsed_commit::nrels, xl_xact_parsed_commit::nstats, xl_xact_parsed_commit::nsubxacts, xl_xact_parsed_commit::origin_lsn, xl_xact_parsed_commit::origin_timestamp, ParsePrepareRecord(), standby_desc_invalidations(), xl_xact_parsed_commit::stats, xl_xact_parsed_commit::subxacts, timestamptz_to_str(), xl_xact_parsed_commit::tsId, xl_xact_parsed_commit::twophase_gid, xact_desc_relations(), xact_desc_stats(), xact_desc_subxacts(), xl_xact_parsed_commit::xact_time, and xl_xact_parsed_commit::xnodes.

Referenced by xact_desc().

◆ xact_desc_relations()

static void xact_desc_relations ( StringInfo  buf,
char *  label,
int  nrels,
RelFileNode xnodes 
)
static

Definition at line 280 of file xactdesc.c.

282 {
283  int i;
284 
285  if (nrels > 0)
286  {
287  appendStringInfo(buf, "; %s:", label);
288  for (i = 0; i < nrels; i++)
289  {
290  char *path = relpathperm(xnodes[i], MAIN_FORKNUM);
291 
292  appendStringInfo(buf, " %s", path);
293  pfree(path);
294  }
295  }
296 }
void pfree(void *pointer)
Definition: mcxt.c:1175
static char * label
@ MAIN_FORKNUM
Definition: relpath.h:43
#define relpathperm(rnode, forknum)
Definition: relpath.h:83

References appendStringInfo(), buf, i, label, MAIN_FORKNUM, pfree(), and relpathperm.

Referenced by xact_desc_abort(), xact_desc_commit(), and xact_desc_prepare().

◆ xact_desc_stats()

static void xact_desc_stats ( StringInfo  buf,
const char *  label,
int  ndropped,
xl_xact_stats_item dropped_stats 
)
static

Definition at line 312 of file xactdesc.c.

314 {
315  int i;
316 
317  if (ndropped > 0)
318  {
319  appendStringInfo(buf, "; %sdropped stats:", label);
320  for (i = 0; i < ndropped; i++)
321  {
322  appendStringInfo(buf, " %d/%u/%u",
323  dropped_stats[i].kind,
324  dropped_stats[i].dboid,
325  dropped_stats[i].objoid);
326  }
327  }
328 }

References appendStringInfo(), buf, i, and label.

Referenced by xact_desc_abort(), xact_desc_commit(), and xact_desc_prepare().

◆ xact_desc_subxacts()

static void xact_desc_subxacts ( StringInfo  buf,
int  nsubxacts,
TransactionId subxacts 
)
static

Definition at line 299 of file xactdesc.c.

300 {
301  int i;
302 
303  if (nsubxacts > 0)
304  {
305  appendStringInfoString(buf, "; subxacts:");
306  for (i = 0; i < nsubxacts; i++)
307  appendStringInfo(buf, " %u", subxacts[i]);
308  }
309 }

References appendStringInfo(), appendStringInfoString(), buf, and i.

Referenced by xact_desc_abort(), xact_desc_commit(), and xact_desc_prepare().

◆ xact_identify()

const char* xact_identify ( uint8  info)

Definition at line 484 of file xactdesc.c.

485 {
486  const char *id = NULL;
487 
488  switch (info & XLOG_XACT_OPMASK)
489  {
490  case XLOG_XACT_COMMIT:
491  id = "COMMIT";
492  break;
493  case XLOG_XACT_PREPARE:
494  id = "PREPARE";
495  break;
496  case XLOG_XACT_ABORT:
497  id = "ABORT";
498  break;
500  id = "COMMIT_PREPARED";
501  break;
503  id = "ABORT_PREPARED";
504  break;
506  id = "ASSIGNMENT";
507  break;
509  id = "INVALIDATION";
510  break;
511  }
512 
513  return id;
514 }

References XLOG_XACT_ABORT, XLOG_XACT_ABORT_PREPARED, XLOG_XACT_ASSIGNMENT, XLOG_XACT_COMMIT, XLOG_XACT_COMMIT_PREPARED, XLOG_XACT_INVALIDATIONS, XLOG_XACT_OPMASK, and XLOG_XACT_PREPARE.