]> granicus.if.org Git - postgresql/commitdiff
Split out list of XLog resource managers
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 5 Feb 2013 20:21:29 +0000 (17:21 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 6 Feb 2013 11:47:28 +0000 (08:47 -0300)
The new rmgrlist.h header, containing all necessary data
about built-in resource managers, allows other pieces of code to
access them.

In particular, this allows a future pg_xlogdump program to extract
rm_desc function pointers, without having to keep a duplicate list of
them.

src/backend/access/transam/rmgr.c
src/include/access/rmgr.h
src/include/access/rmgrlist.h [new file with mode: 0644]
src/include/access/xlog_internal.h

index cc210a7e59c616e98253e057d98832053c1c5043..41d437932cdfd08a884da595876d0655b8adebf9 100644 (file)
 #include "storage/standby.h"
 #include "utils/relmapper.h"
 
+/* must be kept in sync with RmgrData definition in xlog_internal.h */
+#define PG_RMGR(symname,name,redo,desc,startup,cleanup,restartpoint) \
+       { name, redo, desc, startup, cleanup, restartpoint },
 
 const RmgrData RmgrTable[RM_MAX_ID + 1] = {
-       {"XLOG", xlog_redo, xlog_desc, NULL, NULL, NULL},
-       {"Transaction", xact_redo, xact_desc, NULL, NULL, NULL},
-       {"Storage", smgr_redo, smgr_desc, NULL, NULL, NULL},
-       {"CLOG", clog_redo, clog_desc, NULL, NULL, NULL},
-       {"Database", dbase_redo, dbase_desc, NULL, NULL, NULL},
-       {"Tablespace", tblspc_redo, tblspc_desc, NULL, NULL, NULL},
-       {"MultiXact", multixact_redo, multixact_desc, NULL, NULL, NULL},
-       {"RelMap", relmap_redo, relmap_desc, NULL, NULL, NULL},
-       {"Standby", standby_redo, standby_desc, NULL, NULL, NULL},
-       {"Heap2", heap2_redo, heap2_desc, NULL, NULL, NULL},
-       {"Heap", heap_redo, heap_desc, NULL, NULL, NULL},
-       {"Btree", btree_redo, btree_desc, btree_xlog_startup, btree_xlog_cleanup, btree_safe_restartpoint},
-       {"Hash", hash_redo, hash_desc, NULL, NULL, NULL},
-       {"Gin", gin_redo, gin_desc, gin_xlog_startup, gin_xlog_cleanup, gin_safe_restartpoint},
-       {"Gist", gist_redo, gist_desc, gist_xlog_startup, gist_xlog_cleanup, NULL},
-       {"Sequence", seq_redo, seq_desc, NULL, NULL, NULL},
-       {"SPGist", spg_redo, spg_desc, spg_xlog_startup, spg_xlog_cleanup, NULL}
+#include "access/rmgrlist.h"
 };
index e4844fe96c92456b29b5481c7b0380a104067939..f6d27765b25888f3ffe0d58385a38f7dc54da510 100644 (file)
@@ -13,27 +13,23 @@ typedef uint8 RmgrId;
 /*
  * Built-in resource managers
  *
- * Note: RM_MAX_ID could be as much as 255 without breaking the XLOG file
- * format, but we keep it small to minimize the size of RmgrTable[].
+ * The actual numerical values for each rmgr ID are defined by the order
+ * of entries in rmgrlist.h.
+ *
+ * Note: RM_MAX_ID must fit in RmgrId; widening that type will affect the XLOG
+ * file format.
  */
-#define RM_XLOG_ID                             0
-#define RM_XACT_ID                             1
-#define RM_SMGR_ID                             2
-#define RM_CLOG_ID                             3
-#define RM_DBASE_ID                            4
-#define RM_TBLSPC_ID                   5
-#define RM_MULTIXACT_ID                        6
-#define RM_RELMAP_ID                   7
-#define RM_STANDBY_ID                  8
-#define RM_HEAP2_ID                            9
-#define RM_HEAP_ID                             10
-#define RM_BTREE_ID                            11
-#define RM_HASH_ID                             12
-#define RM_GIN_ID                              13
-#define RM_GIST_ID                             14
-#define RM_SEQ_ID                              15
-#define RM_SPGIST_ID                   16
+#define PG_RMGR(symname,name,redo,desc,startup,cleanup,restartpoint) \
+       symname,
+
+typedef enum RmgrIds
+{
+#include "access/rmgrlist.h"
+       RM_NEXT_ID
+} RmgrIds;
+
+#undef PG_RMGR
 
-#define RM_MAX_ID                              RM_SPGIST_ID
+#define RM_MAX_ID                              (RM_NEXT_ID - 1)
 
 #endif   /* RMGR_H */
diff --git a/src/include/access/rmgrlist.h b/src/include/access/rmgrlist.h
new file mode 100644 (file)
index 0000000..7ad71b3
--- /dev/null
@@ -0,0 +1,44 @@
+/*---------------------------------------------------------------------------
+ * rmgrlist.h
+ *
+ * The resource manager list is kept in its own source file for possible
+ * use by automatic tools.     The exact representation of a rmgr is determined
+ * by the PG_RMGR macro, which is not defined in this file; it can be
+ * defined by the caller for special purposes.
+ *
+ * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/access/rmgrlist.h
+ *---------------------------------------------------------------------------
+ */
+
+/* there is deliberately not an #ifndef RMGRLIST_H here */
+
+/*
+ * List of resource manager entries.  Note that order of entries defines the
+ * numerical values of each rmgr's ID, which is stored in WAL records.  New
+ * entries should be added at the end, to avoid changing IDs of existing
+ * entries.
+ *
+ * Changes to this list possibly need a XLOG_PAGE_MAGIC bump.
+ */
+
+/* symbol name, textual name, redo, desc, startup, cleanup, restartpoint */
+PG_RMGR(RM_XLOG_ID, "XLOG", xlog_redo, xlog_desc, NULL, NULL, NULL)
+PG_RMGR(RM_XACT_ID, "Transaction", xact_redo, xact_desc, NULL, NULL, NULL)
+PG_RMGR(RM_SMGR_ID, "Storage", smgr_redo, smgr_desc, NULL, NULL, NULL)
+PG_RMGR(RM_CLOG_ID, "CLOG", clog_redo, clog_desc, NULL, NULL, NULL)
+PG_RMGR(RM_DBASE_ID, "Database", dbase_redo, dbase_desc, NULL, NULL, NULL)
+PG_RMGR(RM_TBLSPC_ID, "Tablespace", tblspc_redo, tblspc_desc, NULL, NULL, NULL)
+PG_RMGR(RM_MULTIXACT_ID, "MultiXact", multixact_redo, multixact_desc, NULL, NULL, NULL)
+PG_RMGR(RM_RELMAP_ID, "RelMap", relmap_redo, relmap_desc, NULL, NULL, NULL)
+PG_RMGR(RM_STANDBY_ID, "Standby", standby_redo, standby_desc, NULL, NULL, NULL)
+PG_RMGR(RM_HEAP2_ID, "Heap2", heap2_redo, heap2_desc, NULL, NULL, NULL)
+PG_RMGR(RM_HEAP_ID, "Heap", heap_redo, heap_desc, NULL, NULL, NULL)
+PG_RMGR(RM_BTREE_ID, "Btree", btree_redo, btree_desc, btree_xlog_startup, btree_xlog_cleanup, btree_safe_restartpoint)
+PG_RMGR(RM_HASH_ID, "Hash", hash_redo, hash_desc, NULL, NULL, NULL)
+PG_RMGR(RM_GIN_ID, "Gin", gin_redo, gin_desc, gin_xlog_startup, gin_xlog_cleanup, gin_safe_restartpoint)
+PG_RMGR(RM_GIST_ID, "Gist", gist_redo, gist_desc, gist_xlog_startup, gist_xlog_cleanup, NULL)
+PG_RMGR(RM_SEQ_ID, "Sequence", seq_redo, seq_desc, NULL, NULL, NULL)
+PG_RMGR(RM_SPGIST_ID, "SPGist", spg_redo, spg_desc, spg_xlog_startup, spg_xlog_cleanup, NULL)
index ce9957e618f7768352ad2e66416be3d33041a49e..34c659314ceb40c949fbacfbe5b64b770322a912 100644 (file)
@@ -233,7 +233,10 @@ struct XLogRecord;
 /*
  * Method table for resource managers.
  *
- * RmgrTable[] is indexed by RmgrId values (see rmgr.h).
+ * This struct must be kept in sync with the PG_RMGR definition in
+ * rmgr.c.
+ *
+ * RmgrTable[] is indexed by RmgrId values (see rmgrlist.h).
  */
 typedef struct RmgrData
 {