PostgreSQL Source Code  git master
dbasedesc.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * dbasedesc.c
4  * rmgr descriptor routines for commands/dbcommands.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/dbasedesc.c
12  *
13  *-------------------------------------------------------------------------
14  */
15 #include "postgres.h"
16 
18 #include "lib/stringinfo.h"
19 
20 
21 void
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_db_id, xlrec->src_tablespace_id,
33  xlrec->db_id, xlrec->tablespace_id);
34  }
35  else if (info == XLOG_DBASE_DROP)
36  {
37  xl_dbase_drop_rec *xlrec = (xl_dbase_drop_rec *) rec;
38 
39  appendStringInfo(buf, "dir %u/%u",
40  xlrec->db_id, xlrec->tablespace_id);
41  }
42 }
43 
44 const char *
46 {
47  const char *id = NULL;
48 
49  switch (info & ~XLR_INFO_MASK)
50  {
51  case XLOG_DBASE_CREATE:
52  id = "CREATE";
53  break;
54  case XLOG_DBASE_DROP:
55  id = "DROP";
56  break;
57  }
58 
59  return id;
60 }
void dbase_desc(StringInfo buf, XLogReaderState *record)
Definition: dbasedesc.c:22
const char * dbase_identify(uint8 info)
Definition: dbasedesc.c:45
unsigned char uint8
Definition: c.h:294
#define XLogRecGetData(decoder)
Definition: xlogreader.h:226
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:78
#define XLOG_DBASE_DROP
static char * buf
Definition: pg_test_fsync.c:67
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:222
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_DBASE_CREATE