PostgreSQL Source Code  git master
clogdesc.c File Reference
#include "postgres.h"
#include "access/clog.h"
Include dependency graph for clogdesc.c:

Go to the source code of this file.

Functions

void clog_desc (StringInfo buf, XLogReaderState *record)
 
const char * clog_identify (uint8 info)
 

Function Documentation

◆ clog_desc()

void clog_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 21 of file clogdesc.c.

References appendStringInfo(), CLOG_TRUNCATE, CLOG_ZEROPAGE, xl_clog_truncate::oldestXact, xl_clog_truncate::pageno, XLogRecGetData, XLogRecGetInfo, and XLR_INFO_MASK.

22 {
23  char *rec = XLogRecGetData(record);
24  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
25 
26  if (info == CLOG_ZEROPAGE)
27  {
28  int pageno;
29 
30  memcpy(&pageno, rec, sizeof(int));
31  appendStringInfo(buf, "page %d", pageno);
32  }
33  else if (info == CLOG_TRUNCATE)
34  {
35  xl_clog_truncate xlrec;
36 
37  memcpy(&xlrec, rec, sizeof(xl_clog_truncate));
38  appendStringInfo(buf, "page %d; oldestXact %u",
39  xlrec.pageno, xlrec.oldestXact);
40  }
41 }
unsigned char uint8
Definition: c.h:294
#define CLOG_ZEROPAGE
Definition: clog.h:54
#define XLogRecGetData(decoder)
Definition: xlogreader.h:226
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:78
int pageno
Definition: clog.h:33
#define CLOG_TRUNCATE
Definition: clog.h:55
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:222
TransactionId oldestXact
Definition: clog.h:34
#define XLR_INFO_MASK
Definition: xlogrecord.h:62

◆ clog_identify()

const char* clog_identify ( uint8  info)

Definition at line 44 of file clogdesc.c.

References CLOG_TRUNCATE, CLOG_ZEROPAGE, and XLR_INFO_MASK.

45 {
46  const char *id = NULL;
47 
48  switch (info & ~XLR_INFO_MASK)
49  {
50  case CLOG_ZEROPAGE:
51  id = "ZEROPAGE";
52  break;
53  case CLOG_TRUNCATE:
54  id = "TRUNCATE";
55  break;
56  }
57 
58  return id;
59 }
#define CLOG_ZEROPAGE
Definition: clog.h:54
#define CLOG_TRUNCATE
Definition: clog.h:55
#define XLR_INFO_MASK
Definition: xlogrecord.h:62