PostgreSQL Source Code  git master
dbasedesc.c File Reference
#include "postgres.h"
#include "commands/dbcommands_xlog.h"
#include "lib/stringinfo.h"
Include dependency graph for dbasedesc.c:

Go to the source code of this file.

Functions

void dbase_desc (StringInfo buf, XLogReaderState *record)
 
const char * dbase_identify (uint8 info)
 

Function Documentation

◆ dbase_desc()

void dbase_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 22 of file dbasedesc.c.

References appendStringInfo(), xl_dbase_create_rec::db_id, xl_dbase_drop_rec::db_id, i, xl_dbase_drop_rec::ntablespaces, xl_dbase_create_rec::src_db_id, xl_dbase_create_rec::src_tablespace_id, xl_dbase_create_rec::tablespace_id, xl_dbase_drop_rec::tablespace_ids, XLOG_DBASE_CREATE, XLOG_DBASE_DROP, 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_DBASE_CREATE)
28  {
30 
31  appendStringInfo(buf, "copy dir %u/%u to %u/%u",
32  xlrec->src_tablespace_id, xlrec->src_db_id,
33  xlrec->tablespace_id, xlrec->db_id);
34  }
35  else if (info == XLOG_DBASE_DROP)
36  {
37  xl_dbase_drop_rec *xlrec = (xl_dbase_drop_rec *) rec;
38  int i;
39 
40  appendStringInfo(buf, "dir");
41  for (i = 0; i < xlrec->ntablespaces; i++)
42  appendStringInfo(buf, " %u/%u",
43  xlrec->tablespace_ids[i], xlrec->db_id);
44  }
45 }
unsigned char uint8
Definition: c.h:357
#define XLogRecGetData(decoder)
Definition: xlogreader.h:283
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
#define XLOG_DBASE_DROP
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:279
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_DBASE_CREATE
Oid tablespace_ids[FLEXIBLE_ARRAY_MEMBER]
int i

◆ dbase_identify()

const char* dbase_identify ( uint8  info)

Definition at line 48 of file dbasedesc.c.

References XLOG_DBASE_CREATE, XLOG_DBASE_DROP, and XLR_INFO_MASK.

49 {
50  const char *id = NULL;
51 
52  switch (info & ~XLR_INFO_MASK)
53  {
54  case XLOG_DBASE_CREATE:
55  id = "CREATE";
56  break;
57  case XLOG_DBASE_DROP:
58  id = "DROP";
59  break;
60  }
61 
62  return id;
63 }
#define XLOG_DBASE_DROP
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_DBASE_CREATE