Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5276687

Browse files
committed
Make xlog_internal.h includable in frontend context.
This makes unnecessary the ugly hack used to #include postgres.h inpg_basebackup.Based on Alvaro Herrera's patch
1 parent6264cd3 commit5276687

File tree

12 files changed

+58
-56
lines changed

12 files changed

+58
-56
lines changed

‎src/backend/access/rmgrdesc/xlogdesc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515
#include"postgres.h"
1616

17+
#include"access/xlog.h"
1718
#include"access/xlog_internal.h"
1819
#include"catalog/pg_control.h"
1920
#include"utils/guc.h"

‎src/backend/access/transam/xlogarchive.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include<signal.h>
2121
#include<unistd.h>
2222

23+
#include"access/xlog.h"
2324
#include"access/xlog_internal.h"
2425
#include"miscadmin.h"
2526
#include"postmaster/startup.h"

‎src/backend/access/transam/xlogfuncs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include"access/htup_details.h"
2020
#include"access/xlog.h"
21+
#include"access/xlog_fn.h"
2122
#include"access/xlog_internal.h"
2223
#include"access/xlogutils.h"
2324
#include"catalog/catalog.h"

‎src/backend/postmaster/bgwriter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include<time.h>
4040
#include<unistd.h>
4141

42+
#include"access/xlog.h"
4243
#include"access/xlog_internal.h"
4344
#include"libpq/pqsignal.h"
4445
#include"miscadmin.h"

‎src/backend/postmaster/checkpointer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include<time.h>
4242
#include<unistd.h>
4343

44+
#include"access/xlog.h"
4445
#include"access/xlog_internal.h"
4546
#include"libpq/pqsignal.h"
4647
#include"miscadmin.h"

‎src/backend/postmaster/pgarch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include<sys/wait.h>
3333
#include<unistd.h>
3434

35+
#include"access/xlog.h"
3536
#include"access/xlog_internal.h"
3637
#include"libpq/pqsignal.h"
3738
#include"miscadmin.h"

‎src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@
1111
*-------------------------------------------------------------------------
1212
*/
1313

14-
/*
15-
* We have to use postgres.h not postgres_fe.h here, because there's so much
16-
* backend-only stuff in the XLOG include files we need. But we need a
17-
* frontend-ish environment otherwise.Hence this ugly hack.
18-
*/
19-
#defineFRONTEND 1
20-
#include"postgres.h"
14+
#include"postgres_fe.h"
2115
#include"libpq-fe.h"
2216

2317
#include<unistd.h>

‎src/bin/pg_basebackup/pg_receivexlog.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@
1212
*-------------------------------------------------------------------------
1313
*/
1414

15-
/*
16-
* We have to use postgres.h not postgres_fe.h here, because there's so much
17-
* backend-only stuff in the XLOG include files we need. But we need a
18-
* frontend-ish environment otherwise.Hence this ugly hack.
19-
*/
20-
#defineFRONTEND 1
21-
#include"postgres.h"
15+
#include"postgres_fe.h"
2216
#include"libpq-fe.h"
2317
#include"libpq/pqsignal.h"
2418
#include"access/xlog_internal.h"

‎src/bin/pg_basebackup/receivelog.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@
1111
* src/bin/pg_basebackup/receivelog.c
1212
*-------------------------------------------------------------------------
1313
*/
14-
15-
/*
16-
* We have to use postgres.h not postgres_fe.h here, because there's so much
17-
* backend-only stuff in the XLOG include files we need. But we need a
18-
* frontend-ish environment otherwise.Hence this ugly hack.
19-
*/
20-
#defineFRONTEND 1
21-
#include"postgres.h"
14+
#include"postgres_fe.h"
2215

2316
#include<sys/stat.h>
2417
#include<sys/time.h>
@@ -30,8 +23,6 @@
3023

3124
#include"libpq-fe.h"
3225
#include"access/xlog_internal.h"
33-
#include"utils/datetime.h"
34-
#include"utils/timestamp.h"
3526

3627
#include"receivelog.h"
3728
#include"streamutil.h"

‎src/bin/pg_basebackup/streamutil.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@
1111
*-------------------------------------------------------------------------
1212
*/
1313

14-
/*
15-
* We have to use postgres.h not postgres_fe.h here, because there's so much
16-
* backend-only stuff in the XLOG include files we need. But we need a
17-
* frontend-ish environment otherwise.Hence this ugly hack.
18-
*/
19-
#defineFRONTEND 1
20-
#include"postgres.h"
14+
#include"postgres_fe.h"
2115
#include"streamutil.h"
2216

2317
#include<stdio.h>

‎src/include/access/xlog_fn.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* xlog_fn.h
3+
*
4+
* PostgreSQL transaction log SQL-callable function declarations
5+
*
6+
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
7+
* Portions Copyright (c) 1994, Regents of the University of California
8+
*
9+
* src/include/access/xlog_fn.h
10+
*/
11+
#ifndefXLOG_FN_H
12+
#defineXLOG_FN_H
13+
14+
#include"fmgr.h"
15+
16+
externDatumpg_start_backup(PG_FUNCTION_ARGS);
17+
externDatumpg_stop_backup(PG_FUNCTION_ARGS);
18+
externDatumpg_switch_xlog(PG_FUNCTION_ARGS);
19+
externDatumpg_create_restore_point(PG_FUNCTION_ARGS);
20+
externDatumpg_current_xlog_location(PG_FUNCTION_ARGS);
21+
externDatumpg_current_xlog_insert_location(PG_FUNCTION_ARGS);
22+
externDatumpg_last_xlog_receive_location(PG_FUNCTION_ARGS);
23+
externDatumpg_last_xlog_replay_location(PG_FUNCTION_ARGS);
24+
externDatumpg_last_xact_replay_timestamp(PG_FUNCTION_ARGS);
25+
externDatumpg_xlogfile_name_offset(PG_FUNCTION_ARGS);
26+
externDatumpg_xlogfile_name(PG_FUNCTION_ARGS);
27+
externDatumpg_is_in_recovery(PG_FUNCTION_ARGS);
28+
externDatumpg_xlog_replay_pause(PG_FUNCTION_ARGS);
29+
externDatumpg_xlog_replay_resume(PG_FUNCTION_ARGS);
30+
externDatumpg_is_xlog_replay_paused(PG_FUNCTION_ARGS);
31+
externDatumpg_xlog_location_diff(PG_FUNCTION_ARGS);
32+
externDatumpg_is_in_backup(PG_FUNCTION_ARGS);
33+
externDatumpg_backup_start_time(PG_FUNCTION_ARGS);
34+
35+
#endif/* XLOG_FN_H */

‎src/include/access/xlog_internal.h

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
* needed by rmgr routines (redo support for individual record types).
99
* So the XLogRecord typedef and associated stuff appear in xlog.h.
1010
*
11+
* Note: This file must be includable in both frontend and backend contexts,
12+
* to allow stand-alone tools like pg_receivexlog to deal with WAL files.
13+
*
1114
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
1215
* Portions Copyright (c) 1994, Regents of the University of California
1316
*
@@ -16,8 +19,9 @@
1619
#ifndefXLOG_INTERNAL_H
1720
#defineXLOG_INTERNAL_H
1821

19-
#include"access/xlog.h"
20-
#include"fmgr.h"
22+
#include"access/xlogdefs.h"
23+
#include"datatype/timestamp.h"
24+
#include"lib/stringinfo.h"
2125
#include"pgtime.h"
2226
#include"storage/block.h"
2327
#include"storage/relfilenode.h"
@@ -225,6 +229,12 @@ typedef struct xl_restore_point
225229
}xl_restore_point;
226230

227231

232+
/*
233+
* XLogRecord is defined in xlog.h, but we avoid #including that to keep
234+
* this file includable in stand-alone programs.
235+
*/
236+
structXLogRecord;
237+
228238
/*
229239
* Method table for resource managers.
230240
*
@@ -233,7 +243,7 @@ typedef struct xl_restore_point
233243
typedefstructRmgrData
234244
{
235245
constchar*rm_name;
236-
void(*rm_redo) (XLogRecPtrlsn,XLogRecord*rptr);
246+
void(*rm_redo) (XLogRecPtrlsn,structXLogRecord*rptr);
237247
void(*rm_desc) (StringInfobuf,uint8xl_info,char*rec);
238248
void(*rm_startup) (void);
239249
void(*rm_cleanup) (void);
@@ -272,26 +282,4 @@ extern bool XLogArchiveCheckDone(const char *xlog);
272282
externboolXLogArchiveIsBusy(constchar*xlog);
273283
externvoidXLogArchiveCleanup(constchar*xlog);
274284

275-
/*
276-
* These aren't in xlog.h because I'd rather not include fmgr.h there.
277-
*/
278-
externDatumpg_start_backup(PG_FUNCTION_ARGS);
279-
externDatumpg_stop_backup(PG_FUNCTION_ARGS);
280-
externDatumpg_switch_xlog(PG_FUNCTION_ARGS);
281-
externDatumpg_create_restore_point(PG_FUNCTION_ARGS);
282-
externDatumpg_current_xlog_location(PG_FUNCTION_ARGS);
283-
externDatumpg_current_xlog_insert_location(PG_FUNCTION_ARGS);
284-
externDatumpg_last_xlog_receive_location(PG_FUNCTION_ARGS);
285-
externDatumpg_last_xlog_replay_location(PG_FUNCTION_ARGS);
286-
externDatumpg_last_xact_replay_timestamp(PG_FUNCTION_ARGS);
287-
externDatumpg_xlogfile_name_offset(PG_FUNCTION_ARGS);
288-
externDatumpg_xlogfile_name(PG_FUNCTION_ARGS);
289-
externDatumpg_is_in_recovery(PG_FUNCTION_ARGS);
290-
externDatumpg_xlog_replay_pause(PG_FUNCTION_ARGS);
291-
externDatumpg_xlog_replay_resume(PG_FUNCTION_ARGS);
292-
externDatumpg_is_xlog_replay_paused(PG_FUNCTION_ARGS);
293-
externDatumpg_xlog_location_diff(PG_FUNCTION_ARGS);
294-
externDatumpg_is_in_backup(PG_FUNCTION_ARGS);
295-
externDatumpg_backup_start_time(PG_FUNCTION_ARGS);
296-
297285
#endif/* XLOG_INTERNAL_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp