Hi,
pg_xlogdump needs access to the *_desc functions for each rmgr. We
already moved forward quite a bit by splitting those functions out of
their containing files; so now they are compilable separately. Good.
The remaining task is enabling the code to find those functions in the
first place; currently, the function pointers live in rmgr.c which is
not compilable by frontend code because it contains pointers to other
functions. Hence the attached patch splits RmgrData into two; the names
and rm_desc functions go into a new file which can be compiled easily by
frontend.
Proposed patch attached.
This comes from
http://www.postgresql.org/message-id/[email protected]
which is part of the pg_xlogdump patch in commitfest.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
*** a/src/backend/access/transam/Makefile
--- b/src/backend/access/transam/Makefile
***************
*** 12,20 **** 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
include $(top_srcdir)/src/backend/common.mk
--- 12,20 ----
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
! 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
*** a/src/backend/access/transam/rmgr.c
--- b/src/backend/access/transam/rmgr.c
***************
*** 24,46 ****
#include "storage/standby.h"
#include "utils/relmapper.h"
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}
};
--- 24,47 ----
#include "storage/standby.h"
#include "utils/relmapper.h"
+ /* See rmgrdesc.c, too */
const RmgrData RmgrTable[RM_MAX_ID + 1] = {
! {xlog_redo, NULL, NULL, NULL},
! {xact_redo, NULL, NULL, NULL},
! {smgr_redo, NULL, NULL, NULL},
! {clog_redo, NULL, NULL, NULL},
! {dbase_redo, NULL, NULL, NULL},
! {tblspc_redo, NULL, NULL, NULL},
! {multixact_redo, NULL, NULL, NULL},
! {relmap_redo, NULL, NULL, NULL},
! {standby_redo, NULL, NULL, NULL},
! {heap2_redo, NULL, NULL, NULL},
! {heap_redo, NULL, NULL, NULL},
! {btree_redo, btree_xlog_startup, btree_xlog_cleanup, btree_safe_restartpoint},
! {hash_redo, NULL, NULL, NULL},
! {gin_redo, gin_xlog_startup, gin_xlog_cleanup, gin_safe_restartpoint},
! {gist_redo, gist_xlog_startup, gist_xlog_cleanup, NULL},
! {seq_redo, NULL, NULL, NULL},
! {spg_redo, spg_xlog_startup, spg_xlog_cleanup, NULL}
};
*** /dev/null
--- b/src/backend/access/transam/rmgrdesc.c
***************
*** 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", xlog_desc},
+ {"Transaction", xact_desc},
+ {"Storage", smgr_desc},
+ {"CLOG", clog_desc},
+ {"Database", dbase_desc},
+ {"Tablespace", tblspc_desc},
+ {"MultiXact", multixact_desc},
+ {"RelMap", relmap_desc},
+ {"Standby", standby_desc},
+ {"Heap2", heap2_desc},
+ {"Heap", heap_desc},
+ {"Btree", btree_desc},
+ {"Hash", hash_desc},
+ {"Gin", gin_desc},
+ {"Gist", gist_desc},
+ {"Sequence", seq_desc},
+ {"SPGist", spg_desc},
+ };
*** a/src/backend/access/transam/xlog.c
--- b/src/backend/access/transam/xlog.c
***************
*** 1042,1048 **** begin:;
if (rdata->data != NULL)
{
appendStringInfo(&buf, " - ");
! RmgrTable[rechdr->xl_rmid].rm_desc(&buf, rechdr->xl_info, rdata->data);
}
elog(LOG, "%s", buf.data);
pfree(buf.data);
--- 1042,1048 ----
if (rdata->data != NULL)
{
appendStringInfo(&buf, " - ");
! RmgrDescTable[rechdr->xl_rmid].rm_desc(&buf, rechdr->xl_info, rdata->data);
}
elog(LOG, "%s", buf.data);
pfree(buf.data);
***************
*** 5352,5358 **** StartupXLOG(void)
(uint32) (EndRecPtr >> 32), (uint32) EndRecPtr);
xlog_outrec(&buf, record);
appendStringInfo(&buf, " - ");
! RmgrTable[record->xl_rmid].rm_desc(&buf,
record->xl_info,
XLogRecGetData(record));
elog(LOG, "%s", buf.data);
--- 5352,5358 ----
(uint32) (EndRecPtr >> 32), (uint32) EndRecPtr);
xlog_outrec(&buf, record);
appendStringInfo(&buf, " - ");
! RmgrDescTable[record->xl_rmid].rm_desc(&buf,
record->xl_info,
XLogRecGetData(record));
elog(LOG, "%s", buf.data);
***************
*** 7882,7888 **** xlog_outrec(StringInfo buf, XLogRecord *record)
appendStringInfo(buf, "; bkpb%d", i);
}
! appendStringInfo(buf, ": %s", RmgrTable[record->xl_rmid].rm_name);
}
#endif /* WAL_DEBUG */
--- 7882,7888 ----
appendStringInfo(buf, "; bkpb%d", i);
}
! appendStringInfo(buf, ": %s", RmgrDescTable[record->xl_rmid].rm_name);
}
#endif /* WAL_DEBUG */
***************
*** 8924,8930 **** rm_redo_error_callback(void *arg)
StringInfoData buf;
initStringInfo(&buf);
! RmgrTable[record->xl_rmid].rm_desc(&buf,
record->xl_info,
XLogRecGetData(record));
--- 8924,8930 ----
StringInfoData buf;
initStringInfo(&buf);
! RmgrDescTable[record->xl_rmid].rm_desc(&buf,
record->xl_info,
XLogRecGetData(record));
*** a/src/include/access/rmgr.h
--- b/src/include/access/rmgr.h
***************
*** 14,20 **** 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[].
*/
#define RM_XLOG_ID 0
#define RM_XACT_ID 1
--- 14,21 ----
* 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[]/
! * RmgrDescTable[].
*/
#define RM_XLOG_ID 0
#define RM_XACT_ID 1
*** a/src/include/access/xlog_internal.h
--- b/src/include/access/xlog_internal.h
***************
*** 231,245 **** typedef struct xl_end_of_recovery
struct XLogRecord;
/*
! * Method table for resource managers.
*
! * RmgrTable[] is 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);
--- 231,246 ----
struct XLogRecord;
/*
! * Method tables for resource managers.
*
! * 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
{
void (*rm_redo) (XLogRecPtr lsn, struct XLogRecord *rptr);
void (*rm_startup) (void);
void (*rm_cleanup) (void);
bool (*rm_safe_restartpoint) (void);
***************
*** 247,252 **** typedef struct RmgrData
--- 248,262 ----
extern const RmgrData RmgrTable[];
+ typedef struct RmgrDescData
+ {
+ const char *rm_name;
+ 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