PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
committsdesc.c File Reference
#include "postgres.h"
#include "access/commit_ts.h"
#include "utils/timestamp.h"
Include dependency graph for committsdesc.c:

Go to the source code of this file.

Functions

void commit_ts_desc (StringInfo buf, XLogReaderState *record)
 
const char * commit_ts_identify (uint8 info)
 

Function Documentation

void commit_ts_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 22 of file committsdesc.c.

References appendStringInfo(), COMMIT_TS_SETTS, COMMIT_TS_TRUNCATE, COMMIT_TS_ZEROPAGE, i, xl_commit_ts_set::mainxid, xl_commit_ts_set::nodeid, xl_commit_ts_truncate::oldestXid, xl_commit_ts_truncate::pageno, palloc(), pfree(), SizeOfCommitTsSet, xl_commit_ts_set::timestamp, timestamptz_to_str(), XLogRecGetData, XLogRecGetDataLen, XLogRecGetInfo, and XLR_INFO_MASK.

23 {
24  char *rec = XLogRecGetData(record);
25  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
26 
27  if (info == COMMIT_TS_ZEROPAGE)
28  {
29  int pageno;
30 
31  memcpy(&pageno, rec, sizeof(int));
32  appendStringInfo(buf, "%d", pageno);
33  }
34  else if (info == COMMIT_TS_TRUNCATE)
35  {
37 
38  appendStringInfo(buf, "pageno %d, oldestXid %u",
39  trunc->pageno, trunc->oldestXid);
40  }
41  else if (info == COMMIT_TS_SETTS)
42  {
43  xl_commit_ts_set *xlrec = (xl_commit_ts_set *) rec;
44  int nsubxids;
45 
46  appendStringInfo(buf, "set %s/%d for: %u",
48  xlrec->nodeid,
49  xlrec->mainxid);
50  nsubxids = ((XLogRecGetDataLen(record) - SizeOfCommitTsSet) /
51  sizeof(TransactionId));
52  if (nsubxids > 0)
53  {
54  int i;
55  TransactionId *subxids;
56 
57  subxids = palloc(sizeof(TransactionId) * nsubxids);
58  memcpy(subxids,
60  sizeof(TransactionId) * nsubxids);
61  for (i = 0; i < nsubxids; i++)
62  appendStringInfo(buf, ", %u", subxids[i]);
63  pfree(subxids);
64  }
65  }
66 }
#define COMMIT_TS_ZEROPAGE
Definition: commit_ts.h:49
#define COMMIT_TS_SETTS
Definition: commit_ts.h:51
uint32 TransactionId
Definition: c.h:397
unsigned char uint8
Definition: c.h:266
TimestampTz timestamp
Definition: commit_ts.h:55
void pfree(void *pointer)
Definition: mcxt.c:950
#define XLogRecGetData(decoder)
Definition: xlogreader.h:218
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:110
#define XLogRecGetDataLen(decoder)
Definition: xlogreader.h:219
#define SizeOfCommitTsSet
Definition: commit_ts.h:61
TransactionId oldestXid
Definition: commit_ts.h:67
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:214
#define COMMIT_TS_TRUNCATE
Definition: commit_ts.h:50
TransactionId mainxid
Definition: commit_ts.h:57
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
void * palloc(Size size)
Definition: mcxt.c:849
RepOriginId nodeid
Definition: commit_ts.h:56
int i
const char * timestamptz_to_str(TimestampTz t)
Definition: timestamp.c:1709
const char* commit_ts_identify ( uint8  info)

Definition at line 69 of file committsdesc.c.

References COMMIT_TS_SETTS, COMMIT_TS_TRUNCATE, COMMIT_TS_ZEROPAGE, and NULL.

70 {
71  switch (info)
72  {
73  case COMMIT_TS_ZEROPAGE:
74  return "ZEROPAGE";
75  case COMMIT_TS_TRUNCATE:
76  return "TRUNCATE";
77  case COMMIT_TS_SETTS:
78  return "SETTS";
79  default:
80  return NULL;
81  }
82 }
#define COMMIT_TS_ZEROPAGE
Definition: commit_ts.h:49
#define COMMIT_TS_SETTS
Definition: commit_ts.h:51
#define COMMIT_TS_TRUNCATE
Definition: commit_ts.h:50
#define NULL
Definition: c.h:229