I didn't like this bit too much:
> diff --git a/contrib/pg_xlogdump/tables.c b/contrib/pg_xlogdump/tables.c
> new file mode 100644
> index 0000000..e947e0d
> --- /dev/null
> +++ b/contrib/pg_xlogdump/tables.c
> @@ -0,0 +1,78 @@
> +/*
> + * RmgrTable linked only to functions available outside of the backend.
> + *
> + * needs to be synced with src/backend/access/transam/rmgr.c
> + */
> +const RmgrData RmgrTable[RM_MAX_ID + 1] = {
> + {"XLOG", NULL, xlog_desc, NULL, NULL, NULL},
> + {"Transaction", NULL, xact_desc, NULL, NULL, NULL},
So I propose the following patch instead. This lets pg_xlogdump compile
only the file it needs, and not concern itself with the rest of rmgr.c.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
commit 6779c7ff81323699e82252a6e5b92a97319cb924
Author: Alvaro Herrera <[email protected]>
Date: Mon Feb 4 13:12:54 2013 -0300
Split out rm_desc pointers into their own table
This allows the split file to be compiled by frontend code
diff --git a/src/backend/access/transam/Makefile b/src/backend/access/transam/Makefile
index eb6cfc5..3f1a9e4 100644
--- a/src/backend/access/transam/Makefile
+++ b/src/backend/access/transam/Makefile
@@ -12,9 +12,9 @@ subdir = src/backend/access/transam
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
-OBJS = clog.o transam.o varsup.o xact.o rmgr.o slru.o subtrans.o multixact.o \
- timeline.o twophase.o twophase_rmgr.o xlog.o xlogarchive.o xlogfuncs.o \
- xlogreader.o xlogutils.o
+OBJS = clog.o multixact.o rmgrdesc.o rmgr.o slru.o subtrans.o timeline.o \
+ transam.o twophase.o twophase_rmgr.o varsup.o xact.o xlogarchive.o \
+ xlogfuncs.o xlog.o xlogreader.o xlogutils.o
include $(top_srcdir)/src/backend/common.mk
diff --git a/src/backend/access/transam/rmgr.c b/src/backend/access/transam/rmgr.c
index cc210a7..0c0a2d1 100644
--- a/src/backend/access/transam/rmgr.c
+++ b/src/backend/access/transam/rmgr.c
@@ -24,23 +24,24 @@
#include "storage/standby.h"
#include "utils/relmapper.h"
+/* See rmgrdesc.c, too */
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}
+ {"XLOG", xlog_redo, NULL, NULL, NULL},
+ {"Transaction", xact_redo, NULL, NULL, NULL},
+ {"Storage", smgr_redo, NULL, NULL, NULL},
+ {"CLOG", clog_redo, NULL, NULL, NULL},
+ {"Database", dbase_redo, NULL, NULL, NULL},
+ {"Tablespace", tblspc_redo, NULL, NULL, NULL},
+ {"MultiXact", multixact_redo, NULL, NULL, NULL},
+ {"RelMap", relmap_redo, NULL, NULL, NULL},
+ {"Standby", standby_redo, NULL, NULL, NULL},
+ {"Heap2", heap2_redo, NULL, NULL, NULL},
+ {"Heap", heap_redo, NULL, NULL, NULL},
+ {"Btree", btree_redo, btree_xlog_startup, btree_xlog_cleanup, btree_safe_restartpoint},
+ {"Hash", hash_redo, NULL, NULL, NULL},
+ {"Gin", gin_redo, gin_xlog_startup, gin_xlog_cleanup, gin_safe_restartpoint},
+ {"Gist", gist_redo, gist_xlog_startup, gist_xlog_cleanup, NULL},
+ {"Sequence", seq_redo, NULL, NULL, NULL},
+ {"SPGist", spg_redo, spg_xlog_startup, spg_xlog_cleanup, NULL}
};
diff --git a/src/backend/access/transam/rmgrdesc.c b/src/backend/access/transam/rmgrdesc.c
new file mode 100644
index 0000000..20315c4
--- /dev/null
+++ b/src/backend/access/transam/rmgrdesc.c
@@ -0,0 +1,47 @@
+/*
+ * rmgrdesc.c
+ *
+ * Resource managers descriptor function definitions
+ *
+ * src/backend/access/transam/rmgrdesc.c
+ */
+#include "postgres.h"
+
+#include "access/clog.h"
+#include "access/gin.h"
+#include "access/gist_private.h"
+#include "access/hash.h"
+#include "access/heapam_xlog.h"
+#include "access/multixact.h"
+#include "access/nbtree.h"
+#include "access/spgist.h"
+#include "access/xact.h"
+#include "access/xlog_internal.h"
+#include "catalog/storage_xlog.h"
+#include "commands/dbcommands.h"
+#include "commands/sequence.h"
+#include "commands/tablespace.h"
+#include "storage/standby.h"
+#include "utils/relmapper.h"
+
+/* See rmgr.c, too */
+
+const RmgrDescData RmgrDescTable[RM_MAX_ID + 1] = {
+ { xlog_desc },
+ { xact_desc },
+ { smgr_desc },
+ { clog_desc },
+ { dbase_desc },
+ { tblspc_desc },
+ { multixact_desc },
+ { relmap_desc },
+ { standby_desc },
+ { heap2_desc },
+ { heap_desc },
+ { btree_desc },
+ { hash_desc },
+ { gin_desc },
+ { gist_desc },
+ { seq_desc },
+ { spg_desc }
+};
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index d644e39..31c854d 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -1042,7 +1042,7 @@ begin:;
if (rdata->data != NULL)
{
appendStringInfo(&buf, " - ");
- RmgrTable[rechdr->xl_rmid].rm_desc(&buf, rechdr->xl_info, rdata->data);
+ RmgrDescTable[rechdr->xl_rmid].rm_desc(&buf, rechdr->xl_info, rdata->data);
}
elog(LOG, "%s", buf.data);
pfree(buf.data);
@@ -5352,7 +5352,7 @@ StartupXLOG(void)
(uint32) (EndRecPtr >> 32), (uint32) EndRecPtr);
xlog_outrec(&buf, record);
appendStringInfo(&buf, " - ");
- RmgrTable[record->xl_rmid].rm_desc(&buf,
+ RmgrDescTable[record->xl_rmid].rm_desc(&buf,
record->xl_info,
XLogRecGetData(record));
elog(LOG, "%s", buf.data);
@@ -8924,7 +8924,7 @@ rm_redo_error_callback(void *arg)
StringInfoData buf;
initStringInfo(&buf);
- RmgrTable[record->xl_rmid].rm_desc(&buf,
+ RmgrDescTable[record->xl_rmid].rm_desc(&buf,
record->xl_info,
XLogRecGetData(record));
diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h
index ce9957e..b751882 100644
--- a/src/include/access/xlog_internal.h
+++ b/src/include/access/xlog_internal.h
@@ -231,15 +231,17 @@ typedef struct xl_end_of_recovery
struct XLogRecord;
/*
- * Method table for resource managers.
+ * Method tables for resource managers.
*
- * RmgrTable[] is indexed by RmgrId values (see rmgr.h).
+ * RmgrDescData (for textual descriptor functions) is split so that the file it
+ * lives in can be used by frontend programs.
+ *
+ * RmgrTable[] and RmgrDescTable[] are indexed by RmgrId values (see rmgr.h).
*/
typedef struct RmgrData
{
const char *rm_name;
void (*rm_redo) (XLogRecPtr lsn, struct XLogRecord *rptr);
- void (*rm_desc) (StringInfo buf, uint8 xl_info, char *rec);
void (*rm_startup) (void);
void (*rm_cleanup) (void);
bool (*rm_safe_restartpoint) (void);
@@ -247,6 +249,14 @@ typedef struct RmgrData
extern const RmgrData RmgrTable[];
+typedef struct RmgrDescData
+{
+ void (*rm_desc) (StringInfo buf, uint8 xl_info, char *rec);
+} RmgrDescData;
+
+extern const RmgrDescData RmgrDescTable[];
+
+
/*
* Exported to support xlog switching from checkpointer
*/
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers