PostgreSQL Source Code  git master
rmgrdesc.c
Go to the documentation of this file.
1 /*
2  * rmgrdesc.c
3  *
4  * pg_waldump resource managers definition
5  *
6  * src/bin/pg_waldump/rmgrdesc.c
7  */
8 #define FRONTEND 1
9 #include "postgres.h"
10 
11 #include "access/brin_xlog.h"
12 #include "access/clog.h"
13 #include "access/commit_ts.h"
14 #include "access/generic_xlog.h"
15 #include "access/ginxlog.h"
16 #include "access/gistxlog.h"
17 #include "access/hash_xlog.h"
18 #include "access/heapam_xlog.h"
19 #include "access/multixact.h"
20 #include "access/nbtxlog.h"
21 #include "access/rmgr.h"
22 #include "access/spgxlog.h"
23 #include "access/xact.h"
24 #include "access/xlog_internal.h"
25 #include "catalog/storage_xlog.h"
27 #include "commands/sequence.h"
28 #include "commands/tablespace.h"
29 #include "replication/message.h"
30 #include "replication/origin.h"
31 #include "rmgrdesc.h"
32 #include "storage/standbydefs.h"
33 #include "utils/relmapper.h"
34 
35 #define PG_RMGR(symname,name,redo,desc,identify,startup,cleanup,mask,decode) \
36  { name, desc, identify},
37 
39 #include "access/rmgrlist.h"
40 };
41 
42 #define CUSTOM_NUMERIC_NAME_LEN sizeof("custom###")
43 
46 static bool CustomRmgrDescInitialized = false;
47 
48 /*
49  * No information on custom resource managers; just print the ID.
50  */
51 static void
53 {
54  appendStringInfo(buf, "rmid: %d", XLogRecGetRmid(record));
55 }
56 
57 /*
58  * No information on custom resource managers; just return NULL and let the
59  * caller handle it.
60  */
61 static const char *
63 {
64  return NULL;
65 }
66 
67 /*
68  * We are unable to get the real name of a custom rmgr because the module is
69  * not loaded. Generate a table of rmgrs with numeric names of the form
70  * "custom###", where "###" is the 3-digit resource manager ID.
71  */
72 static void
74 {
75  for (int i = 0; i < RM_N_CUSTOM_IDS; i++)
76  {
78  "custom%03d", i + RM_MIN_CUSTOM_ID);
82  }
84 }
85 
86 const RmgrDescData *
88 {
89  Assert(RmgrIdIsValid(rmid));
90 
91  if (RmgrIdIsBuiltin(rmid))
92  return &RmgrDescTable[rmid];
93  else
94  {
97  return &CustomRmgrDesc[rmid - RM_MIN_CUSTOM_ID];
98  }
99 }
#define Assert(condition)
Definition: c.h:858
unsigned char uint8
Definition: c.h:504
int i
Definition: isn.c:73
static char * buf
Definition: pg_test_fsync.c:73
#define snprintf
Definition: port.h:238
#define RmgrIdIsValid(rmid)
Definition: rmgr.h:53
#define RM_N_BUILTIN_IDS
Definition: rmgr.h:38
uint8 RmgrId
Definition: rmgr.h:11
#define RM_N_CUSTOM_IDS
Definition: rmgr.h:39
static bool RmgrIdIsBuiltin(int rmid)
Definition: rmgr.h:42
#define RM_MIN_CUSTOM_ID
Definition: rmgr.h:35
static const RmgrDescData RmgrDescTable[RM_N_BUILTIN_IDS]
Definition: rmgrdesc.c:38
const RmgrDescData * GetRmgrDesc(RmgrId rmid)
Definition: rmgrdesc.c:87
static char CustomNumericNames[RM_N_CUSTOM_IDS][CUSTOM_NUMERIC_NAME_LEN]
Definition: rmgrdesc.c:44
static void default_desc(StringInfo buf, XLogReaderState *record)
Definition: rmgrdesc.c:52
static const char * default_identify(uint8 info)
Definition: rmgrdesc.c:62
static void initialize_custom_rmgrs(void)
Definition: rmgrdesc.c:73
static bool CustomRmgrDescInitialized
Definition: rmgrdesc.c:46
#define CUSTOM_NUMERIC_NAME_LEN
Definition: rmgrdesc.c:42
static RmgrDescData CustomRmgrDesc[RM_N_CUSTOM_IDS]
Definition: rmgrdesc.c:45
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:97
const char *(* rm_identify)(uint8 info)
Definition: rmgrdesc.h:18
const char * rm_name
Definition: rmgrdesc.h:16
void(* rm_desc)(StringInfo buf, XLogReaderState *record)
Definition: rmgrdesc.h:17
#define XLogRecGetRmid(decoder)
Definition: xlogreader.h:411