PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
committsdesc.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * committsdesc.c
4  * rmgr descriptor routines for access/transam/commit_ts.c
5  *
6  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  * src/backend/access/rmgrdesc/committsdesc.c
12  *
13  *-------------------------------------------------------------------------
14  */
15 #include "postgres.h"
16 
17 #include "access/commit_ts.h"
18 #include "utils/timestamp.h"
19 
20 
21 void
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 }
67 
68 const char *
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
uint32 TransactionId
Definition: c.h:397
unsigned char uint8
Definition: c.h:266
TimestampTz timestamp
Definition: commit_ts.h:55
void commit_ts_desc(StringInfo buf, XLogReaderState *record)
Definition: committsdesc.c:22
const char * commit_ts_identify(uint8 info)
Definition: committsdesc.c:69
void pfree(void *pointer)
Definition: mcxt.c:950
#define XLogRecGetData(decoder)
Definition: xlogreader.h:220
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:78
#define XLogRecGetDataLen(decoder)
Definition: xlogreader.h:221
#define SizeOfCommitTsSet
Definition: commit_ts.h:61
static char * buf
Definition: pg_test_fsync.c:66
TransactionId oldestXid
Definition: commit_ts.h:67
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:216
#define COMMIT_TS_TRUNCATE
Definition: commit_ts.h:50
TransactionId mainxid
Definition: commit_ts.h:57
#define NULL
Definition: c.h:229
#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:1710