PostgreSQL Source Code  git master
smgrdesc.c File Reference
#include "postgres.h"
#include "catalog/storage_xlog.h"
Include dependency graph for smgrdesc.c:

Go to the source code of this file.

Functions

void smgr_desc (StringInfo buf, XLogReaderState *record)
 
const char * smgr_identify (uint8 info)
 

Function Documentation

◆ smgr_desc()

void smgr_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 21 of file smgrdesc.c.

References appendStringInfo(), appendStringInfoString(), xl_smgr_truncate::blkno, xl_smgr_truncate::flags, xl_smgr_create::forkNum, MAIN_FORKNUM, pfree(), relpathperm, xl_smgr_create::rnode, xl_smgr_truncate::rnode, XLOG_SMGR_CREATE, XLOG_SMGR_TRUNCATE, XLogRecGetData, XLogRecGetInfo, and XLR_INFO_MASK.

22 {
23  char *rec = XLogRecGetData(record);
24  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
25 
26  if (info == XLOG_SMGR_CREATE)
27  {
28  xl_smgr_create *xlrec = (xl_smgr_create *) rec;
29  char *path = relpathperm(xlrec->rnode, xlrec->forkNum);
30 
31  appendStringInfoString(buf, path);
32  pfree(path);
33  }
34  else if (info == XLOG_SMGR_TRUNCATE)
35  {
36  xl_smgr_truncate *xlrec = (xl_smgr_truncate *) rec;
37  char *path = relpathperm(xlrec->rnode, MAIN_FORKNUM);
38 
39  appendStringInfo(buf, "%s to %u blocks flags %d", path,
40  xlrec->blkno, xlrec->flags);
41  pfree(path);
42  }
43 }
#define relpathperm(rnode, forknum)
Definition: relpath.h:83
unsigned char uint8
Definition: c.h:323
RelFileNode rnode
Definition: storage_xlog.h:49
#define XLOG_SMGR_CREATE
Definition: storage_xlog.h:30
void pfree(void *pointer)
Definition: mcxt.c:1031
#define XLogRecGetData(decoder)
Definition: xlogreader.h:226
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:78
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:157
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:222
#define XLOG_SMGR_TRUNCATE
Definition: storage_xlog.h:31
ForkNumber forkNum
Definition: storage_xlog.h:36
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
BlockNumber blkno
Definition: storage_xlog.h:48
RelFileNode rnode
Definition: storage_xlog.h:35

◆ smgr_identify()

const char* smgr_identify ( uint8  info)

Definition at line 46 of file smgrdesc.c.

References XLOG_SMGR_CREATE, XLOG_SMGR_TRUNCATE, and XLR_INFO_MASK.

47 {
48  const char *id = NULL;
49 
50  switch (info & ~XLR_INFO_MASK)
51  {
52  case XLOG_SMGR_CREATE:
53  id = "CREATE";
54  break;
55  case XLOG_SMGR_TRUNCATE:
56  id = "TRUNCATE";
57  break;
58  }
59 
60  return id;
61 }
#define XLOG_SMGR_CREATE
Definition: storage_xlog.h:30
#define XLOG_SMGR_TRUNCATE
Definition: storage_xlog.h:31
#define XLR_INFO_MASK
Definition: xlogrecord.h:62