PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
smgrdesc.c File Reference
#include "postgres.h"
#include "catalog/catalog.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

void smgr_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 22 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.

23 {
24  char *rec = XLogRecGetData(record);
25  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
26 
27  if (info == XLOG_SMGR_CREATE)
28  {
29  xl_smgr_create *xlrec = (xl_smgr_create *) rec;
30  char *path = relpathperm(xlrec->rnode, xlrec->forkNum);
31 
32  appendStringInfoString(buf, path);
33  pfree(path);
34  }
35  else if (info == XLOG_SMGR_TRUNCATE)
36  {
37  xl_smgr_truncate *xlrec = (xl_smgr_truncate *) rec;
38  char *path = relpathperm(xlrec->rnode, MAIN_FORKNUM);
39 
40  appendStringInfo(buf, "%s to %u blocks flags %d", path,
41  xlrec->blkno, xlrec->flags);
42  pfree(path);
43  }
44 }
#define relpathperm(rnode, forknum)
Definition: relpath.h:67
unsigned char uint8
Definition: c.h:266
RelFileNode rnode
Definition: storage_xlog.h:49
#define XLOG_SMGR_CREATE
Definition: storage_xlog.h:30
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
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:189
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:214
#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
const char* smgr_identify ( uint8  info)

Definition at line 47 of file smgrdesc.c.

References NULL, XLOG_SMGR_CREATE, XLOG_SMGR_TRUNCATE, and XLR_INFO_MASK.

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