PostgreSQL Source Code  git master
tblspcdesc.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * tblspcdesc.c
4  * rmgr descriptor routines for commands/tablespace.c
5  *
6  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  * src/backend/access/rmgrdesc/tblspcdesc.c
12  *
13  *-------------------------------------------------------------------------
14  */
15 #include "postgres.h"
16 
17 #include "commands/tablespace.h"
18 
19 
20 void
22 {
23  char *rec = XLogRecGetData(record);
24  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
25 
26  if (info == XLOG_TBLSPC_CREATE)
27  {
29 
30  appendStringInfo(buf, "%u \"%s\"", xlrec->ts_id, xlrec->ts_path);
31  }
32  else if (info == XLOG_TBLSPC_DROP)
33  {
34  xl_tblspc_drop_rec *xlrec = (xl_tblspc_drop_rec *) rec;
35 
36  appendStringInfo(buf, "%u", xlrec->ts_id);
37  }
38 }
39 
40 const char *
42 {
43  const char *id = NULL;
44 
45  switch (info & ~XLR_INFO_MASK)
46  {
47  case XLOG_TBLSPC_CREATE:
48  id = "CREATE";
49  break;
50  case XLOG_TBLSPC_DROP:
51  id = "DROP";
52  break;
53  }
54 
55  return id;
56 }
unsigned char uint8
Definition: c.h:504
static char * buf
Definition: pg_test_fsync.c:73
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:97
char ts_path[FLEXIBLE_ARRAY_MEMBER]
Definition: tablespace.h:31
#define XLOG_TBLSPC_DROP
Definition: tablespace.h:26
#define XLOG_TBLSPC_CREATE
Definition: tablespace.h:25
void tblspc_desc(StringInfo buf, XLogReaderState *record)
Definition: tblspcdesc.c:21
const char * tblspc_identify(uint8 info)
Definition: tblspcdesc.c:41
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:410
#define XLogRecGetData(decoder)
Definition: xlogreader.h:415
#define XLR_INFO_MASK
Definition: xlogrecord.h:62