Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5a1cd89

Browse files
committed
Split out list of XLog resource managers
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.
1 parent cb9b66d commit 5a1cd89

File tree

4 files changed

+68
-38
lines changed

4 files changed

+68
-38
lines changed

src/backend/access/transam/rmgr.c

+4-17
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,10 @@
2424
#include "storage/standby.h"
2525
#include "utils/relmapper.h"
2626

27+
/* must be kept in sync with RmgrData definition in xlog_internal.h */
28+
#define PG_RMGR(symname,name,redo,desc,startup,cleanup,restartpoint) \
29+
{ name, redo, desc, startup, cleanup, restartpoint },
2730

2831
const RmgrData RmgrTable[RM_MAX_ID + 1] = {
29-
{"XLOG", xlog_redo, xlog_desc, NULL, NULL, NULL},
30-
{"Transaction", xact_redo, xact_desc, NULL, NULL, NULL},
31-
{"Storage", smgr_redo, smgr_desc, NULL, NULL, NULL},
32-
{"CLOG", clog_redo, clog_desc, NULL, NULL, NULL},
33-
{"Database", dbase_redo, dbase_desc, NULL, NULL, NULL},
34-
{"Tablespace", tblspc_redo, tblspc_desc, NULL, NULL, NULL},
35-
{"MultiXact", multixact_redo, multixact_desc, NULL, NULL, NULL},
36-
{"RelMap", relmap_redo, relmap_desc, NULL, NULL, NULL},
37-
{"Standby", standby_redo, standby_desc, NULL, NULL, NULL},
38-
{"Heap2", heap2_redo, heap2_desc, NULL, NULL, NULL},
39-
{"Heap", heap_redo, heap_desc, NULL, NULL, NULL},
40-
{"Btree", btree_redo, btree_desc, btree_xlog_startup, btree_xlog_cleanup, btree_safe_restartpoint},
41-
{"Hash", hash_redo, hash_desc, NULL, NULL, NULL},
42-
{"Gin", gin_redo, gin_desc, gin_xlog_startup, gin_xlog_cleanup, gin_safe_restartpoint},
43-
{"Gist", gist_redo, gist_desc, gist_xlog_startup, gist_xlog_cleanup, NULL},
44-
{"Sequence", seq_redo, seq_desc, NULL, NULL, NULL},
45-
{"SPGist", spg_redo, spg_desc, spg_xlog_startup, spg_xlog_cleanup, NULL}
32+
#include "access/rmgrlist.h"
4633
};

src/include/access/rmgr.h

+16-20
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,23 @@ typedef uint8 RmgrId;
1313
/*
1414
* Built-in resource managers
1515
*
16-
* Note: RM_MAX_ID could be as much as 255 without breaking the XLOG file
17-
* format, but we keep it small to minimize the size of RmgrTable[].
16+
* The actual numerical values for each rmgr ID are defined by the order
17+
* of entries in rmgrlist.h.
18+
*
19+
* Note: RM_MAX_ID must fit in RmgrId; widening that type will affect the XLOG
20+
* file format.
1821
*/
19-
#define RM_XLOG_ID 0
20-
#define RM_XACT_ID 1
21-
#define RM_SMGR_ID 2
22-
#define RM_CLOG_ID 3
23-
#define RM_DBASE_ID 4
24-
#define RM_TBLSPC_ID 5
25-
#define RM_MULTIXACT_ID 6
26-
#define RM_RELMAP_ID 7
27-
#define RM_STANDBY_ID 8
28-
#define RM_HEAP2_ID 9
29-
#define RM_HEAP_ID 10
30-
#define RM_BTREE_ID 11
31-
#define RM_HASH_ID 12
32-
#define RM_GIN_ID 13
33-
#define RM_GIST_ID 14
34-
#define RM_SEQ_ID 15
35-
#define RM_SPGIST_ID 16
22+
#define PG_RMGR(symname,name,redo,desc,startup,cleanup,restartpoint) \
23+
symname,
24+
25+
typedef enum RmgrIds
26+
{
27+
#include "access/rmgrlist.h"
28+
RM_NEXT_ID
29+
} RmgrIds;
30+
31+
#undef PG_RMGR
3632

37-
#define RM_MAX_ID RM_SPGIST_ID
33+
#define RM_MAX_ID (RM_NEXT_ID - 1)
3834

3935
#endif /* RMGR_H */

src/include/access/rmgrlist.h

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*---------------------------------------------------------------------------
2+
* rmgrlist.h
3+
*
4+
* The resource manager list is kept in its own source file for possible
5+
* use by automatic tools. The exact representation of a rmgr is determined
6+
* by the PG_RMGR macro, which is not defined in this file; it can be
7+
* defined by the caller for special purposes.
8+
*
9+
* Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
10+
* Portions Copyright (c) 1994, Regents of the University of California
11+
*
12+
* src/include/access/rmgrlist.h
13+
*---------------------------------------------------------------------------
14+
*/
15+
16+
/* there is deliberately not an #ifndef RMGRLIST_H here */
17+
18+
/*
19+
* List of resource manager entries. Note that order of entries defines the
20+
* numerical values of each rmgr's ID, which is stored in WAL records. New
21+
* entries should be added at the end, to avoid changing IDs of existing
22+
* entries.
23+
*
24+
* Changes to this list possibly need a XLOG_PAGE_MAGIC bump.
25+
*/
26+
27+
/* symbol name, textual name, redo, desc, startup, cleanup, restartpoint */
28+
PG_RMGR(RM_XLOG_ID, "XLOG", xlog_redo, xlog_desc, NULL, NULL, NULL)
29+
PG_RMGR(RM_XACT_ID, "Transaction", xact_redo, xact_desc, NULL, NULL, NULL)
30+
PG_RMGR(RM_SMGR_ID, "Storage", smgr_redo, smgr_desc, NULL, NULL, NULL)
31+
PG_RMGR(RM_CLOG_ID, "CLOG", clog_redo, clog_desc, NULL, NULL, NULL)
32+
PG_RMGR(RM_DBASE_ID, "Database", dbase_redo, dbase_desc, NULL, NULL, NULL)
33+
PG_RMGR(RM_TBLSPC_ID, "Tablespace", tblspc_redo, tblspc_desc, NULL, NULL, NULL)
34+
PG_RMGR(RM_MULTIXACT_ID, "MultiXact", multixact_redo, multixact_desc, NULL, NULL, NULL)
35+
PG_RMGR(RM_RELMAP_ID, "RelMap", relmap_redo, relmap_desc, NULL, NULL, NULL)
36+
PG_RMGR(RM_STANDBY_ID, "Standby", standby_redo, standby_desc, NULL, NULL, NULL)
37+
PG_RMGR(RM_HEAP2_ID, "Heap2", heap2_redo, heap2_desc, NULL, NULL, NULL)
38+
PG_RMGR(RM_HEAP_ID, "Heap", heap_redo, heap_desc, NULL, NULL, NULL)
39+
PG_RMGR(RM_BTREE_ID, "Btree", btree_redo, btree_desc, btree_xlog_startup, btree_xlog_cleanup, btree_safe_restartpoint)
40+
PG_RMGR(RM_HASH_ID, "Hash", hash_redo, hash_desc, NULL, NULL, NULL)
41+
PG_RMGR(RM_GIN_ID, "Gin", gin_redo, gin_desc, gin_xlog_startup, gin_xlog_cleanup, gin_safe_restartpoint)
42+
PG_RMGR(RM_GIST_ID, "Gist", gist_redo, gist_desc, gist_xlog_startup, gist_xlog_cleanup, NULL)
43+
PG_RMGR(RM_SEQ_ID, "Sequence", seq_redo, seq_desc, NULL, NULL, NULL)
44+
PG_RMGR(RM_SPGIST_ID, "SPGist", spg_redo, spg_desc, spg_xlog_startup, spg_xlog_cleanup, NULL)

src/include/access/xlog_internal.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,10 @@ struct XLogRecord;
233233
/*
234234
* Method table for resource managers.
235235
*
236-
* RmgrTable[] is indexed by RmgrId values (see rmgr.h).
236+
* This struct must be kept in sync with the PG_RMGR definition in
237+
* rmgr.c.
238+
*
239+
* RmgrTable[] is indexed by RmgrId values (see rmgrlist.h).
237240
*/
238241
typedef struct RmgrData
239242
{

0 commit comments

Comments
 (0)