Line data Source code
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"
26 : #include "commands/dbcommands_xlog.h"
27 : #include "commands/sequence_xlog.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 :
38 : static const RmgrDescData RmgrDescTable[RM_N_BUILTIN_IDS] = {
39 : #include "access/rmgrlist.h"
40 : };
41 :
42 : #define CUSTOM_NUMERIC_NAME_LEN sizeof("custom###")
43 :
44 : static char CustomNumericNames[RM_N_CUSTOM_IDS][CUSTOM_NUMERIC_NAME_LEN] = {0};
45 : static RmgrDescData CustomRmgrDesc[RM_N_CUSTOM_IDS] = {0};
46 : static bool CustomRmgrDescInitialized = false;
47 :
48 : /*
49 : * No information on custom resource managers; just print the ID.
50 : */
51 : static void
52 0 : default_desc(StringInfo buf, XLogReaderState *record)
53 : {
54 0 : appendStringInfo(buf, "rmid: %d", XLogRecGetRmid(record));
55 0 : }
56 :
57 : /*
58 : * No information on custom resource managers; just return NULL and let the
59 : * caller handle it.
60 : */
61 : static const char *
62 0 : default_identify(uint8 info)
63 : {
64 0 : 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
73 0 : initialize_custom_rmgrs(void)
74 : {
75 0 : for (int i = 0; i < RM_N_CUSTOM_IDS; i++)
76 : {
77 0 : snprintf(CustomNumericNames[i], CUSTOM_NUMERIC_NAME_LEN,
78 0 : "custom%03d", i + RM_MIN_CUSTOM_ID);
79 0 : CustomRmgrDesc[i].rm_name = CustomNumericNames[i];
80 0 : CustomRmgrDesc[i].rm_desc = default_desc;
81 0 : CustomRmgrDesc[i].rm_identify = default_identify;
82 0 : }
83 0 : CustomRmgrDescInitialized = true;
84 0 : }
85 :
86 : const RmgrDescData *
87 0 : GetRmgrDesc(RmgrId rmid)
88 : {
89 0 : Assert(RmgrIdIsValid(rmid));
90 :
91 0 : if (RmgrIdIsBuiltin(rmid))
92 0 : return &RmgrDescTable[rmid];
93 : else
94 : {
95 0 : if (!CustomRmgrDescInitialized)
96 0 : initialize_custom_rmgrs();
97 0 : return &CustomRmgrDesc[rmid - RM_MIN_CUSTOM_ID];
98 : }
99 0 : }
|