]> granicus.if.org Git - postgresql/commitdiff
Make xlog_internal.h includable in frontend context.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 13 Dec 2012 12:59:13 +0000 (14:59 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 13 Dec 2012 12:59:13 +0000 (14:59 +0200)
This makes unnecessary the ugly hack used to #include postgres.h in
pg_basebackup.

Based on Alvaro Herrera's patch

12 files changed:
src/backend/access/rmgrdesc/xlogdesc.c
src/backend/access/transam/xlogarchive.c
src/backend/access/transam/xlogfuncs.c
src/backend/postmaster/bgwriter.c
src/backend/postmaster/checkpointer.c
src/backend/postmaster/pgarch.c
src/bin/pg_basebackup/pg_basebackup.c
src/bin/pg_basebackup/pg_receivexlog.c
src/bin/pg_basebackup/receivelog.c
src/bin/pg_basebackup/streamutil.c
src/include/access/xlog_fn.h [new file with mode: 0644]
src/include/access/xlog_internal.h

index 862e3fa754eb66cb6b42d8c8ef94e07667acad9f..c958a4ff533bb3f83740ce45d5be00af6f8c57ce 100644 (file)
@@ -14,6 +14,7 @@
  */
 #include "postgres.h"
 
+#include "access/xlog.h"
 #include "access/xlog_internal.h"
 #include "catalog/pg_control.h"
 #include "utils/guc.h"
index 9bd6b8e3a2f5d667ae26ef24724e99b909525cab..0ef53e7cbf68f470fd6afdab5b757fca0f7a4fa7 100644 (file)
@@ -20,6 +20,7 @@
 #include <signal.h>
 #include <unistd.h>
 
+#include "access/xlog.h"
 #include "access/xlog_internal.h"
 #include "miscadmin.h"
 #include "postmaster/startup.h"
index d3457615986080634ba0f25b6d6537c8aa86683c..40c0bd67b57a1b11fa7d47e5224a41f3a75abef9 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "access/htup_details.h"
 #include "access/xlog.h"
+#include "access/xlog_fn.h"
 #include "access/xlog_internal.h"
 #include "access/xlogutils.h"
 #include "catalog/catalog.h"
index 709ccf1f2561907f96f1ae2bf8ddc47e326efbb1..ff0a9cb560117173b41dec5d0a9e03b9bbafc9bf 100644 (file)
@@ -39,6 +39,7 @@
 #include <time.h>
 #include <unistd.h>
 
+#include "access/xlog.h"
 #include "access/xlog_internal.h"
 #include "libpq/pqsignal.h"
 #include "miscadmin.h"
index 18e6a4e8c4be1c1e6041cd854a55f367ffd4ba6e..c8a68a1b22710aee0c5feaabfd653d9740ee82d8 100644 (file)
@@ -41,6 +41,7 @@
 #include <time.h>
 #include <unistd.h>
 
+#include "access/xlog.h"
 #include "access/xlog_internal.h"
 #include "libpq/pqsignal.h"
 #include "miscadmin.h"
index a6c0aea3d6a957ee4f4a1652b82987f1d1aeae9f..b075231ed3dbb79335607066d421a57ce66033ae 100644 (file)
@@ -32,6 +32,7 @@
 #include <sys/wait.h>
 #include <unistd.h>
 
+#include "access/xlog.h"
 #include "access/xlog_internal.h"
 #include "libpq/pqsignal.h"
 #include "miscadmin.h"
index 4f22116c3eed11e2c3b7028e24b84b077df3a8d7..4249c0417d18d133d4118396fbf58538502abbbf 100644 (file)
  *-------------------------------------------------------------------------
  */
 
-/*
- * We have to use postgres.h not postgres_fe.h here, because there's so much
- * backend-only stuff in the XLOG include files we need.  But we need a
- * frontend-ish environment otherwise. Hence this ugly hack.
- */
-#define FRONTEND 1
-#include "postgres.h"
+#include "postgres_fe.h"
 #include "libpq-fe.h"
 
 #include <unistd.h>
index 54524834f755ee1369f6ebf9fe550dacb1109fef..7f6121a945b169a1f55e0f62b0e5c712e6a745be 100644 (file)
  *-------------------------------------------------------------------------
  */
 
-/*
- * We have to use postgres.h not postgres_fe.h here, because there's so much
- * backend-only stuff in the XLOG include files we need.  But we need a
- * frontend-ish environment otherwise. Hence this ugly hack.
- */
-#define FRONTEND 1
-#include "postgres.h"
+#include "postgres_fe.h"
 #include "libpq-fe.h"
 #include "libpq/pqsignal.h"
 #include "access/xlog_internal.h"
index de82ff54d8e762215624c80bf59565feb60004fe..8502d560678441fc943d0d37963f811e71a2c44f 100644 (file)
  *               src/bin/pg_basebackup/receivelog.c
  *-------------------------------------------------------------------------
  */
-
-/*
- * We have to use postgres.h not postgres_fe.h here, because there's so much
- * backend-only stuff in the XLOG include files we need.  But we need a
- * frontend-ish environment otherwise. Hence this ugly hack.
- */
-#define FRONTEND 1
-#include "postgres.h"
+#include "postgres_fe.h"
 
 #include <sys/stat.h>
 #include <sys/time.h>
@@ -30,8 +23,6 @@
 
 #include "libpq-fe.h"
 #include "access/xlog_internal.h"
-#include "utils/datetime.h"
-#include "utils/timestamp.h"
 
 #include "receivelog.h"
 #include "streamutil.h"
index 22f41281808d47ece9d1d3e8a1206def4f1bf456..2ab0d8a4e8baf7b315ab9c38ebf79568f4b03d0c 100644 (file)
  *-------------------------------------------------------------------------
  */
 
-/*
- * We have to use postgres.h not postgres_fe.h here, because there's so much
- * backend-only stuff in the XLOG include files we need.  But we need a
- * frontend-ish environment otherwise. Hence this ugly hack.
- */
-#define FRONTEND 1
-#include "postgres.h"
+#include "postgres_fe.h"
 #include "streamutil.h"
 
 #include <stdio.h>
diff --git a/src/include/access/xlog_fn.h b/src/include/access/xlog_fn.h
new file mode 100644 (file)
index 0000000..65376fe
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * xlog_fn.h
+ *
+ * PostgreSQL transaction log SQL-callable function declarations
+ *
+ * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/access/xlog_fn.h
+ */
+#ifndef XLOG_FN_H
+#define XLOG_FN_H
+
+#include "fmgr.h"
+
+extern Datum pg_start_backup(PG_FUNCTION_ARGS);
+extern Datum pg_stop_backup(PG_FUNCTION_ARGS);
+extern Datum pg_switch_xlog(PG_FUNCTION_ARGS);
+extern Datum pg_create_restore_point(PG_FUNCTION_ARGS);
+extern Datum pg_current_xlog_location(PG_FUNCTION_ARGS);
+extern Datum pg_current_xlog_insert_location(PG_FUNCTION_ARGS);
+extern Datum pg_last_xlog_receive_location(PG_FUNCTION_ARGS);
+extern Datum pg_last_xlog_replay_location(PG_FUNCTION_ARGS);
+extern Datum pg_last_xact_replay_timestamp(PG_FUNCTION_ARGS);
+extern Datum pg_xlogfile_name_offset(PG_FUNCTION_ARGS);
+extern Datum pg_xlogfile_name(PG_FUNCTION_ARGS);
+extern Datum pg_is_in_recovery(PG_FUNCTION_ARGS);
+extern Datum pg_xlog_replay_pause(PG_FUNCTION_ARGS);
+extern Datum pg_xlog_replay_resume(PG_FUNCTION_ARGS);
+extern Datum pg_is_xlog_replay_paused(PG_FUNCTION_ARGS);
+extern Datum pg_xlog_location_diff(PG_FUNCTION_ARGS);
+extern Datum pg_is_in_backup(PG_FUNCTION_ARGS);
+extern Datum pg_backup_start_time(PG_FUNCTION_ARGS);
+
+#endif   /* XLOG_FN_H */
index 89252d023015e590e05cdcaa09e238072bb2bb00..0acebd4e287c31e543ef9f374bb8c3924eeb62c8 100644 (file)
@@ -8,6 +8,9 @@
  * needed by rmgr routines (redo support for individual record types).
  * So the XLogRecord typedef and associated stuff appear in xlog.h.
  *
+ * Note: This file must be includable in both frontend and backend contexts,
+ * to allow stand-alone tools like pg_receivexlog to deal with WAL files.
+ *
  * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
@@ -16,8 +19,9 @@
 #ifndef XLOG_INTERNAL_H
 #define XLOG_INTERNAL_H
 
-#include "access/xlog.h"
-#include "fmgr.h"
+#include "access/xlogdefs.h"
+#include "datatype/timestamp.h"
+#include "lib/stringinfo.h"
 #include "pgtime.h"
 #include "storage/block.h"
 #include "storage/relfilenode.h"
@@ -225,6 +229,12 @@ typedef struct xl_restore_point
 } xl_restore_point;
 
 
+/*
+ * XLogRecord is defined in xlog.h, but we avoid #including that to keep
+ * this file includable in stand-alone programs.
+ */
+struct XLogRecord;
+
 /*
  * Method table for resource managers.
  *
@@ -233,7 +243,7 @@ typedef struct xl_restore_point
 typedef struct RmgrData
 {
        const char *rm_name;
-       void            (*rm_redo) (XLogRecPtr lsn, XLogRecord *rptr);
+       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);
@@ -272,26 +282,4 @@ extern bool XLogArchiveCheckDone(const char *xlog);
 extern bool XLogArchiveIsBusy(const char *xlog);
 extern void XLogArchiveCleanup(const char *xlog);
 
-/*
- * These aren't in xlog.h because I'd rather not include fmgr.h there.
- */
-extern Datum pg_start_backup(PG_FUNCTION_ARGS);
-extern Datum pg_stop_backup(PG_FUNCTION_ARGS);
-extern Datum pg_switch_xlog(PG_FUNCTION_ARGS);
-extern Datum pg_create_restore_point(PG_FUNCTION_ARGS);
-extern Datum pg_current_xlog_location(PG_FUNCTION_ARGS);
-extern Datum pg_current_xlog_insert_location(PG_FUNCTION_ARGS);
-extern Datum pg_last_xlog_receive_location(PG_FUNCTION_ARGS);
-extern Datum pg_last_xlog_replay_location(PG_FUNCTION_ARGS);
-extern Datum pg_last_xact_replay_timestamp(PG_FUNCTION_ARGS);
-extern Datum pg_xlogfile_name_offset(PG_FUNCTION_ARGS);
-extern Datum pg_xlogfile_name(PG_FUNCTION_ARGS);
-extern Datum pg_is_in_recovery(PG_FUNCTION_ARGS);
-extern Datum pg_xlog_replay_pause(PG_FUNCTION_ARGS);
-extern Datum pg_xlog_replay_resume(PG_FUNCTION_ARGS);
-extern Datum pg_is_xlog_replay_paused(PG_FUNCTION_ARGS);
-extern Datum pg_xlog_location_diff(PG_FUNCTION_ARGS);
-extern Datum pg_is_in_backup(PG_FUNCTION_ARGS);
-extern Datum pg_backup_start_time(PG_FUNCTION_ARGS);
-
 #endif   /* XLOG_INTERNAL_H */