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.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 4 : initialize_custom_rmgrs(void) 74 : { 75 516 : for (int i = 0; i < RM_N_CUSTOM_IDS; i++) 76 : { 77 512 : snprintf(CustomNumericNames[i], CUSTOM_NUMERIC_NAME_LEN, 78 : "custom%03d", i + RM_MIN_CUSTOM_ID); 79 512 : CustomRmgrDesc[i].rm_name = CustomNumericNames[i]; 80 512 : CustomRmgrDesc[i].rm_desc = default_desc; 81 512 : CustomRmgrDesc[i].rm_identify = default_identify; 82 : } 83 4 : CustomRmgrDescInitialized = true; 84 4 : } 85 : 86 : const RmgrDescData * 87 514892 : GetRmgrDesc(RmgrId rmid) 88 : { 89 : Assert(RmgrIdIsValid(rmid)); 90 : 91 514892 : if (RmgrIdIsBuiltin(rmid)) 92 514380 : return &RmgrDescTable[rmid]; 93 : else 94 : { 95 512 : if (!CustomRmgrDescInitialized) 96 4 : initialize_custom_rmgrs(); 97 512 : return &CustomRmgrDesc[rmid - RM_MIN_CUSTOM_ID]; 98 : } 99 : }