Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bea0469

Browse files
committed
Merge with pgpro-727
2 parents 53e4f52 + 7bd8037 commit bea0469

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
ifdef USE_PGXS
1515
PG_CONFIG = pg_config
1616
PGXS := $(shell $(PG_CONFIG) --pgxs)
1717
include $(PGXS)
18-
ifndef top_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+
override CPPFLAGS := -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-
override CPPFLAGS := -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
static int standby_message_timeout = 10 * 1000; /* 10 sec = default */
3030
static XLogRecPtr stop_backup_lsn = InvalidXLogRecPtr;
@@ -848,7 +848,7 @@ pg_ptrack_get_and_clear(Oid tablespace_oid, Oid db_oid, Oid rel_oid,
848848
* If current backup started in archive mode wait for 'lsn' to be archived in
849849
* archive 'wal' directory with WAL segment file.
850850
* If current backup started in stream mode wait for 'lsn' to be streamed in
851-
* 'pg_xlog' directory.
851+
* 'pg_wal' directory.
852852
*
853853
* If 'wait_prev_segment' wait for previous segment.
854854
*/
@@ -1938,7 +1938,7 @@ StreamLog(void *arg)
19381938
{
19391939
XLogRecPtr startpos;
19401940
TimeLineID starttli;
1941-
char *basedir = (char *)arg;
1941+
char *basedir = (char *)arg;
19421942

19431943
/*
19441944
* Connect in replication mode to the server
@@ -1995,18 +1995,33 @@ StreamLog(void *arg)
19951995

19961996
#if PG_VERSION_NUM >= 90600
19971997
{
1998-
StreamCtl ctl;
1998+
StreamCtl ctl;
1999+
19992000
ctl.startpos = startpos;
20002001
ctl.timeline = starttli;
20012002
ctl.sysidentifier = NULL;
2003+
2004+
#if PG_VERSION_NUM >= 100000
2005+
ctl.walmethod = CreateWalDirectoryMethod(basedir, 0, true);
2006+
ctl.replication_slot = replication_slot;
2007+
#else
20022008
ctl.basedir = basedir;
2009+
#endif
2010+
20032011
ctl.stream_stop = stop_streaming;
20042012
ctl.standby_message_timeout = standby_message_timeout;
20052013
ctl.partial_suffix = NULL;
20062014
ctl.synchronous = false;
20072015
ctl.mark_done = false;
2016+
20082017
if(ReceiveXlogStream(conn, &ctl) == false)
20092018
elog(ERROR, "Problem in receivexlog");
2019+
2020+
#if PG_VERSION_NUM >= 100000
2021+
if (!ctl.walmethod->finish())
2022+
elog(ERROR, "Could not finish writing WAL files: %s",
2023+
strerror(errno));
2024+
#endif
20102025
}
20112026
#else
20122027
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+
#if PG_VERSION_NUM >= 100000
28+
#define PG_RMGR(symname,name,redo,desc,identify,startup,cleanup,mask) \
29+
name,
30+
#else
2731
#define PG_RMGR(symname,name,redo,desc,identify,startup,cleanup) \
2832
name,
33+
#endif
2934

3035
static const char *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
int num_threads = 1;
4141
bool stream_wal = false;
4242
bool progress = false;
43+
#if PG_VERSION_NUM >= 100000
44+
char *replication_slot = NULL;
45+
#endif
4346

4447
/* backup options */
4548
bool backup_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
#define DATABASE_DIR "database"
4646
#define BACKUPS_DIR "backups"
47+
#if PG_VERSION_NUM >= 100000
48+
#define PG_XLOG_DIR "pg_wal"
49+
#else
4750
#define PG_XLOG_DIR "pg_xlog"
51+
#endif
4852
#define PG_TBLSPC_DIR "pg_tblspc"
4953
#define BACKUP_CONTROL_FILE "backup.control"
5054
#define BACKUP_CATALOG_CONF_FILE "pg_probackup.conf"
@@ -271,6 +275,10 @@ extern char arclog_path[MAXPGPATH];
271275
extern int num_threads;
272276
extern bool stream_wal;
273277
extern bool progress;
278+
#if PG_VERSION_NUM >= 100000
279+
/* In pre-10 'replication_slot' is defined in receivelog.h */
280+
extern char *replication_slot;
281+
#endif
274282

275283
/* backup options */
276284
extern bool smooth_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
static void
6666
digestControlFile(ControlFileData *ControlFile, char *src, size_t size)
6767
{
68-
if (size != PG_CONTROL_SIZE)
68+
#if PG_VERSION_NUM >= 100000
69+
int ControlFileSize = PG_CONTROL_FILE_SIZE;
70+
#else
71+
int ControlFileSize = 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)