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

Commit7bd8037

Browse files
committed
pg_probackup now is built with PostgreSQL 10
1 parent5ab28f9 commit7bd8037

File tree

7 files changed

+75
-42
lines changed

7 files changed

+75
-42
lines changed

‎.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
/results
2828
/env
2929
/tests/__pycache__/
30+
/tests/helpers/__pycache__/
3031
/tests/tmp_dirs/
3132
/tests/*pyc
3233
/tests/helpers/*pyc
@@ -40,3 +41,5 @@
4041
/src/streamutil.c
4142
/src/streamutil.h
4243
/src/xlogreader.c
44+
/src/walmethods.c
45+
/src/walmethods.h

‎Makefile

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,41 @@ OBJS = src/backup.o src/catalog.o src/configure.o src/data.o \
99
EXTRA_CLEAN = src/datapagemap.c src/datapagemap.h src/xlogreader.c\
1010
src/receivelog.c src/receivelog.h src/streamutil.c src/streamutil.h src/logging.h
1111

12-
all: checksrcdir src/datapagemap.h src/logging.h src/receivelog.h src/streamutil.h pg_probackup
12+
INCLUDES = src/datapagemap.h src/logging.h src/receivelog.h src/streamutil.h
1313

1414
ifdefUSE_PGXS
1515
PG_CONFIG = pg_config
1616
PGXS :=$(shell$(PG_CONFIG) --pgxs)
1717
include$(PGXS)
18-
ifndeftop_srcdir
19-
@echo "You must have PostgreSQL source tree available to compile."
20-
@echo "Pass the path to the PostgreSQL source tree to make, in the top_srcdir"
21-
@echo "variable: \"make top_srcdir=<path to PostgreSQL source tree>\""
22-
@exit 1
23-
endif
24-
# Those files are symlinked from the PostgreSQL sources.
25-
src/xlogreader.c:% :$(top_srcdir)/src/backend/access/transam/xlogreader.c
26-
rm -f$@&&$(LN_S)$< ./src/xlogreader.c
27-
src/datapagemap.c:% :$(top_srcdir)/src/bin/pg_rewind/datapagemap.c
28-
rm -f$@&&$(LN_S)$< ./src/datapagemap.c
29-
src/datapagemap.h:% :$(top_srcdir)/src/bin/pg_rewind/datapagemap.h
30-
rm -f$@&&$(LN_S)$< src/datapagemap.h
31-
src/logging.h:% :$(top_srcdir)/src/bin/pg_rewind/logging.h
32-
rm -f$@&&$(LN_S)$< ./src
33-
src/receivelog.c:% :$(top_srcdir)/src/bin/pg_basebackup/receivelog.c
34-
rm -f$@&&$(LN_S)$< ./src
35-
src/receivelog.h:% :$(top_srcdir)/src/bin/pg_basebackup/receivelog.h
36-
rm -f$@&&$(LN_S)$< ./src
37-
src/streamutil.c:% :$(top_srcdir)/src/bin/pg_basebackup/streamutil.c
38-
rm -f$@&&$(LN_S)$< ./src
39-
src/streamutil.h:% :$(top_srcdir)/src/bin/pg_basebackup/streamutil.h
40-
rm -f$@&&$(LN_S)$< ./src
18+
# !USE_PGXS
4119
else
4220
subdir=contrib/pg_probackup
4321
top_builddir=../..
4422
include$(top_builddir)/src/Makefile.global
4523
include$(top_srcdir)/contrib/contrib-global.mk
46-
ifeq ("$(top_srcdir)","../..")
47-
srchome="$(top_srcdir)/.."
24+
endif# USE_PGXS
25+
26+
ifeq ($(top_srcdir),../..)
27+
srchome=$(top_srcdir)/..
4828
else
49-
srchome="$(top_srcdir)"
29+
srchome=$(top_srcdir)
30+
endif
31+
32+
ifeq ($(MAJORVERSION),10)
33+
OBJS += src/walmethods.o
34+
EXTRA_CLEAN += src/walmethods.c src/walmethods.h
35+
INCLUDES += src/walmethods.h
5036
endif
51-
# Those files are symlinked from the PostgreSQL sources.
37+
38+
PG_CPPFLAGS = -I$(libpq_srcdir) ${PTHREAD_CFLAGS} -Isrc
39+
overrideCPPFLAGS := -DFRONTEND$(CPPFLAGS)$(PG_CPPFLAGS)
40+
PG_LIBS =$(libpq_pgport) ${PTHREAD_CFLAGS}
41+
42+
all: checksrcdir$(INCLUDES)$(PROGRAM);
43+
44+
$(PROGRAM):$(OBJS)
45+
$(CC)$(CFLAGS)$(OBJS)$(PG_LIBS)$(LDFLAGS)$(LDFLAGS_EX)$(LIBS) -o$@$(X)
46+
5247
src/xlogreader.c:$(top_srcdir)/src/backend/access/transam/xlogreader.c
5348
rm -f$@&&$(LN_S)$(srchome)/src/backend/access/transam/xlogreader.c$@
5449
src/datapagemap.c:$(top_srcdir)/src/bin/pg_rewind/datapagemap.c
@@ -65,20 +60,18 @@ src/streamutil.c: $(top_srcdir)/src/bin/pg_basebackup/streamutil.c
6560
rm -f$@&&$(LN_S)$(srchome)/src/bin/pg_basebackup/streamutil.c$@
6661
src/streamutil.h:$(top_srcdir)/src/bin/pg_basebackup/streamutil.h
6762
rm -f$@&&$(LN_S)$(srchome)/src/bin/pg_basebackup/streamutil.h$@
68-
endif
6963

70-
PG_CPPFLAGS = -I$(libpq_srcdir) ${PTHREAD_CFLAGS} -Isrc
71-
overrideCPPFLAGS := -DFRONTEND$(CPPFLAGS)$(PG_CPPFLAGS)
72-
PG_LIBS =$(libpq_pgport) ${PTHREAD_CFLAGS}
64+
ifeq ($(MAJORVERSION),10)
65+
src/walmethods.c:$(top_srcdir)/src/bin/pg_basebackup/walmethods.c
66+
rm -f$@&&$(LN_S)$(srchome)/src/bin/pg_basebackup/walmethods.c$@
67+
src/walmethods.h:$(top_srcdir)/src/bin/pg_basebackup/walmethods.h
68+
rm -f$@&&$(LN_S)$(srchome)/src/bin/pg_basebackup/walmethods.h$@
69+
endif
7370

7471
ifeq ($(PORTNAME), aix)
7572
CC=xlc_r
7673
endif
7774

78-
envtest:
79-
: top_srcdir=$()
80-
: libpq_srcdir =$(libpq_srcdir)
81-
8275
# This rule's only purpose is to give the user instructions on how to pass
8376
# the path to PostgreSQL source tree to the makefile.
8477
.PHONY: checksrcdir

‎src/backup.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
#include"libpq/pqsignal.h"
2424
#include"storage/bufpage.h"
2525
#include"datapagemap.h"
26-
#include"streamutil.h"
2726
#include"receivelog.h"
27+
#include"streamutil.h"
2828

2929
staticintstandby_message_timeout=10*1000;/* 10 sec = default */
3030
staticXLogRecPtrstop_backup_lsn=InvalidXLogRecPtr;
@@ -836,7 +836,7 @@ pg_ptrack_get_and_clear(Oid tablespace_oid, Oid db_oid, Oid rel_oid,
836836
* If current backup started in archive mode wait for 'lsn' to be archived in
837837
* archive 'wal' directory with WAL segment file.
838838
* If current backup started in stream mode wait for 'lsn' to be streamed in
839-
* 'pg_xlog' directory.
839+
* 'pg_wal' directory.
840840
*/
841841
staticvoid
842842
wait_wal_lsn(XLogRecPtrlsn)
@@ -1895,7 +1895,7 @@ StreamLog(void *arg)
18951895
{
18961896
XLogRecPtrstartpos;
18971897
TimeLineIDstarttli;
1898-
char*basedir= (char*)arg;
1898+
char*basedir= (char*)arg;
18991899

19001900
/*
19011901
* Connect in replication mode to the server
@@ -1952,18 +1952,33 @@ StreamLog(void *arg)
19521952

19531953
#ifPG_VERSION_NUM >=90600
19541954
{
1955-
StreamCtlctl;
1955+
StreamCtlctl;
1956+
19561957
ctl.startpos=startpos;
19571958
ctl.timeline=starttli;
19581959
ctl.sysidentifier=NULL;
1960+
1961+
#ifPG_VERSION_NUM >=100000
1962+
ctl.walmethod=CreateWalDirectoryMethod(basedir,0, true);
1963+
ctl.replication_slot=replication_slot;
1964+
#else
19591965
ctl.basedir=basedir;
1966+
#endif
1967+
19601968
ctl.stream_stop=stop_streaming;
19611969
ctl.standby_message_timeout=standby_message_timeout;
19621970
ctl.partial_suffix=NULL;
19631971
ctl.synchronous= false;
19641972
ctl.mark_done= false;
1973+
19651974
if(ReceiveXlogStream(conn,&ctl)== false)
19661975
elog(ERROR,"Problem in receivexlog");
1976+
1977+
#ifPG_VERSION_NUM >=100000
1978+
if (!ctl.walmethod->finish())
1979+
elog(ERROR,"Could not finish writing WAL files: %s",
1980+
strerror(errno));
1981+
#endif
19671982
}
19681983
#else
19691984
if(ReceiveXlogStream(conn,startpos,starttli,NULL,basedir,

‎src/parsexlog.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@
2424
* RmgrNames is an array of resource manager names, to make error messages
2525
* a bit nicer.
2626
*/
27+
#ifPG_VERSION_NUM >=100000
28+
#definePG_RMGR(symname,name,redo,desc,identify,startup,cleanup,mask) \
29+
name,
30+
#else
2731
#definePG_RMGR(symname,name,redo,desc,identify,startup,cleanup) \
2832
name,
33+
#endif
2934

3035
staticconstchar*RmgrNames[RM_MAX_ID+1]= {
3136
#include"access/rmgrlist.h"

‎src/pg_probackup.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ char *backup_id_string_param = NULL;
4040
intnum_threads=1;
4141
boolstream_wal= false;
4242
boolprogress= false;
43+
#ifPG_VERSION_NUM >=100000
44+
char*replication_slot=NULL;
45+
#endif
4346

4447
/* backup options */
4548
boolbackup_logs= false;

‎src/pg_probackup.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@
4444
/* Directory/File names */
4545
#defineDATABASE_DIR"database"
4646
#defineBACKUPS_DIR"backups"
47+
#ifPG_VERSION_NUM >=100000
48+
#definePG_XLOG_DIR"pg_wal"
49+
#else
4750
#definePG_XLOG_DIR"pg_xlog"
51+
#endif
4852
#definePG_TBLSPC_DIR"pg_tblspc"
4953
#defineBACKUP_CONTROL_FILE"backup.control"
5054
#defineBACKUP_CATALOG_CONF_FILE"pg_probackup.conf"
@@ -271,6 +275,10 @@ extern char arclog_path[MAXPGPATH];
271275
externintnum_threads;
272276
externboolstream_wal;
273277
externboolprogress;
278+
#ifPG_VERSION_NUM >=100000
279+
/* In pre-10 'replication_slot' is defined in receivelog.h */
280+
externchar*replication_slot;
281+
#endif
274282

275283
/* backup options */
276284
externboolsmooth_checkpoint;

‎src/util.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,15 @@ checkControlFile(ControlFileData *ControlFile)
6565
staticvoid
6666
digestControlFile(ControlFileData*ControlFile,char*src,size_tsize)
6767
{
68-
if (size!=PG_CONTROL_SIZE)
68+
#ifPG_VERSION_NUM >=100000
69+
intControlFileSize=PG_CONTROL_FILE_SIZE;
70+
#else
71+
intControlFileSize=PG_CONTROL_SIZE;
72+
#endif
73+
74+
if (size!=ControlFileSize)
6975
elog(ERROR,"unexpected control file size %d, expected %d",
70-
(int)size,PG_CONTROL_SIZE);
76+
(int)size,ControlFileSize);
7177

7278
memcpy(ControlFile,src,sizeof(ControlFileData));
7379

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp