1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-07-14 06:54:15 +02:00

pg_probackup now is built with PostgreSQL 10

This commit is contained in:
Arthur Zakirov
2017-08-07 16:23:37 +03:00
parent 5ab28f954e
commit 7bd80376bd
7 changed files with 75 additions and 42 deletions

3
.gitignore vendored
View File

@ -27,6 +27,7 @@
/results /results
/env /env
/tests/__pycache__/ /tests/__pycache__/
/tests/helpers/__pycache__/
/tests/tmp_dirs/ /tests/tmp_dirs/
/tests/*pyc /tests/*pyc
/tests/helpers/*pyc /tests/helpers/*pyc
@ -40,3 +41,5 @@
/src/streamutil.c /src/streamutil.c
/src/streamutil.h /src/streamutil.h
/src/xlogreader.c /src/xlogreader.c
/src/walmethods.c
/src/walmethods.h

View File

@ -9,46 +9,41 @@ OBJS = src/backup.o src/catalog.o src/configure.o src/data.o \
EXTRA_CLEAN = src/datapagemap.c src/datapagemap.h src/xlogreader.c \ EXTRA_CLEAN = src/datapagemap.c src/datapagemap.h src/xlogreader.c \
src/receivelog.c src/receivelog.h src/streamutil.c src/streamutil.h src/logging.h src/receivelog.c src/receivelog.h src/streamutil.c src/streamutil.h src/logging.h
all: checksrcdir src/datapagemap.h src/logging.h src/receivelog.h src/streamutil.h pg_probackup INCLUDES = src/datapagemap.h src/logging.h src/receivelog.h src/streamutil.h
ifdef USE_PGXS ifdef USE_PGXS
PG_CONFIG = pg_config PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs) PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS) include $(PGXS)
ifndef top_srcdir # !USE_PGXS
@echo "You must have PostgreSQL source tree available to compile."
@echo "Pass the path to the PostgreSQL source tree to make, in the top_srcdir"
@echo "variable: \"make top_srcdir=<path to PostgreSQL source tree>\""
@exit 1
endif
# Those files are symlinked from the PostgreSQL sources.
src/xlogreader.c: % : $(top_srcdir)/src/backend/access/transam/xlogreader.c
rm -f $@ && $(LN_S) $< ./src/xlogreader.c
src/datapagemap.c: % : $(top_srcdir)/src/bin/pg_rewind/datapagemap.c
rm -f $@ && $(LN_S) $< ./src/datapagemap.c
src/datapagemap.h: % : $(top_srcdir)/src/bin/pg_rewind/datapagemap.h
rm -f $@ && $(LN_S) $< src/datapagemap.h
src/logging.h: % : $(top_srcdir)/src/bin/pg_rewind/logging.h
rm -f $@ && $(LN_S) $< ./src
src/receivelog.c: % : $(top_srcdir)/src/bin/pg_basebackup/receivelog.c
rm -f $@ && $(LN_S) $< ./src
src/receivelog.h: % : $(top_srcdir)/src/bin/pg_basebackup/receivelog.h
rm -f $@ && $(LN_S) $< ./src
src/streamutil.c: % : $(top_srcdir)/src/bin/pg_basebackup/streamutil.c
rm -f $@ && $(LN_S) $< ./src
src/streamutil.h: % : $(top_srcdir)/src/bin/pg_basebackup/streamutil.h
rm -f $@ && $(LN_S) $< ./src
else else
subdir=contrib/pg_probackup subdir=contrib/pg_probackup
top_builddir=../.. top_builddir=../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
include $(top_srcdir)/contrib/contrib-global.mk include $(top_srcdir)/contrib/contrib-global.mk
ifeq ("$(top_srcdir)","../..") endif # USE_PGXS
srchome="$(top_srcdir)/.."
ifeq ($(top_srcdir),../..)
srchome=$(top_srcdir)/..
else else
srchome="$(top_srcdir)" srchome=$(top_srcdir)
endif endif
# Those files are symlinked from the PostgreSQL sources.
ifeq ($(MAJORVERSION),10)
OBJS += src/walmethods.o
EXTRA_CLEAN += src/walmethods.c src/walmethods.h
INCLUDES += src/walmethods.h
endif
PG_CPPFLAGS = -I$(libpq_srcdir) ${PTHREAD_CFLAGS} -Isrc
override CPPFLAGS := -DFRONTEND $(CPPFLAGS) $(PG_CPPFLAGS)
PG_LIBS = $(libpq_pgport) ${PTHREAD_CFLAGS}
all: checksrcdir $(INCLUDES) $(PROGRAM);
$(PROGRAM): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) $(PG_LIBS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
src/xlogreader.c: $(top_srcdir)/src/backend/access/transam/xlogreader.c src/xlogreader.c: $(top_srcdir)/src/backend/access/transam/xlogreader.c
rm -f $@ && $(LN_S) $(srchome)/src/backend/access/transam/xlogreader.c $@ rm -f $@ && $(LN_S) $(srchome)/src/backend/access/transam/xlogreader.c $@
src/datapagemap.c: $(top_srcdir)/src/bin/pg_rewind/datapagemap.c 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
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_basebackup/streamutil.c $@ rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_basebackup/streamutil.c $@
src/streamutil.h: $(top_srcdir)/src/bin/pg_basebackup/streamutil.h src/streamutil.h: $(top_srcdir)/src/bin/pg_basebackup/streamutil.h
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_basebackup/streamutil.h $@ rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_basebackup/streamutil.h $@
endif
PG_CPPFLAGS = -I$(libpq_srcdir) ${PTHREAD_CFLAGS} -Isrc ifeq ($(MAJORVERSION),10)
override CPPFLAGS := -DFRONTEND $(CPPFLAGS) $(PG_CPPFLAGS) src/walmethods.c: $(top_srcdir)/src/bin/pg_basebackup/walmethods.c
PG_LIBS = $(libpq_pgport) ${PTHREAD_CFLAGS} rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_basebackup/walmethods.c $@
src/walmethods.h: $(top_srcdir)/src/bin/pg_basebackup/walmethods.h
rm -f $@ && $(LN_S) $(srchome)/src/bin/pg_basebackup/walmethods.h $@
endif
ifeq ($(PORTNAME), aix) ifeq ($(PORTNAME), aix)
CC=xlc_r CC=xlc_r
endif endif
envtest:
: top_srcdir=$( )
: libpq_srcdir = $(libpq_srcdir)
# This rule's only purpose is to give the user instructions on how to pass # This rule's only purpose is to give the user instructions on how to pass
# the path to PostgreSQL source tree to the makefile. # the path to PostgreSQL source tree to the makefile.
.PHONY: checksrcdir .PHONY: checksrcdir

View File

@ -23,8 +23,8 @@
#include "libpq/pqsignal.h" #include "libpq/pqsignal.h"
#include "storage/bufpage.h" #include "storage/bufpage.h"
#include "datapagemap.h" #include "datapagemap.h"
#include "streamutil.h"
#include "receivelog.h" #include "receivelog.h"
#include "streamutil.h"
static int standby_message_timeout = 10 * 1000; /* 10 sec = default */ static int standby_message_timeout = 10 * 1000; /* 10 sec = default */
static XLogRecPtr stop_backup_lsn = InvalidXLogRecPtr; static XLogRecPtr stop_backup_lsn = InvalidXLogRecPtr;
@ -836,7 +836,7 @@ pg_ptrack_get_and_clear(Oid tablespace_oid, Oid db_oid, Oid rel_oid,
* If current backup started in archive mode wait for 'lsn' to be archived in * If current backup started in archive mode wait for 'lsn' to be archived in
* archive 'wal' directory with WAL segment file. * archive 'wal' directory with WAL segment file.
* If current backup started in stream mode wait for 'lsn' to be streamed in * If current backup started in stream mode wait for 'lsn' to be streamed in
* 'pg_xlog' directory. * 'pg_wal' directory.
*/ */
static void static void
wait_wal_lsn(XLogRecPtr lsn) wait_wal_lsn(XLogRecPtr lsn)
@ -1953,17 +1953,32 @@ StreamLog(void *arg)
#if PG_VERSION_NUM >= 90600 #if PG_VERSION_NUM >= 90600
{ {
StreamCtl ctl; StreamCtl ctl;
ctl.startpos = startpos; ctl.startpos = startpos;
ctl.timeline = starttli; ctl.timeline = starttli;
ctl.sysidentifier = NULL; ctl.sysidentifier = NULL;
#if PG_VERSION_NUM >= 100000
ctl.walmethod = CreateWalDirectoryMethod(basedir, 0, true);
ctl.replication_slot = replication_slot;
#else
ctl.basedir = basedir; ctl.basedir = basedir;
#endif
ctl.stream_stop = stop_streaming; ctl.stream_stop = stop_streaming;
ctl.standby_message_timeout = standby_message_timeout; ctl.standby_message_timeout = standby_message_timeout;
ctl.partial_suffix = NULL; ctl.partial_suffix = NULL;
ctl.synchronous = false; ctl.synchronous = false;
ctl.mark_done = false; ctl.mark_done = false;
if(ReceiveXlogStream(conn, &ctl) == false) if(ReceiveXlogStream(conn, &ctl) == false)
elog(ERROR, "Problem in receivexlog"); elog(ERROR, "Problem in receivexlog");
#if PG_VERSION_NUM >= 100000
if (!ctl.walmethod->finish())
elog(ERROR, "Could not finish writing WAL files: %s",
strerror(errno));
#endif
} }
#else #else
if(ReceiveXlogStream(conn, startpos, starttli, NULL, basedir, if(ReceiveXlogStream(conn, startpos, starttli, NULL, basedir,

View File

@ -24,8 +24,13 @@
* RmgrNames is an array of resource manager names, to make error messages * RmgrNames is an array of resource manager names, to make error messages
* a bit nicer. * a bit nicer.
*/ */
#if PG_VERSION_NUM >= 100000
#define PG_RMGR(symname,name,redo,desc,identify,startup,cleanup,mask) \
name,
#else
#define PG_RMGR(symname,name,redo,desc,identify,startup,cleanup) \ #define PG_RMGR(symname,name,redo,desc,identify,startup,cleanup) \
name, name,
#endif
static const char *RmgrNames[RM_MAX_ID + 1] = { static const char *RmgrNames[RM_MAX_ID + 1] = {
#include "access/rmgrlist.h" #include "access/rmgrlist.h"

View File

@ -40,6 +40,9 @@ char *backup_id_string_param = NULL;
int num_threads = 1; int num_threads = 1;
bool stream_wal = false; bool stream_wal = false;
bool progress = false; bool progress = false;
#if PG_VERSION_NUM >= 100000
char *replication_slot = NULL;
#endif
/* backup options */ /* backup options */
bool backup_logs = false; bool backup_logs = false;

View File

@ -44,7 +44,11 @@
/* Directory/File names */ /* Directory/File names */
#define DATABASE_DIR "database" #define DATABASE_DIR "database"
#define BACKUPS_DIR "backups" #define BACKUPS_DIR "backups"
#if PG_VERSION_NUM >= 100000
#define PG_XLOG_DIR "pg_wal"
#else
#define PG_XLOG_DIR "pg_xlog" #define PG_XLOG_DIR "pg_xlog"
#endif
#define PG_TBLSPC_DIR "pg_tblspc" #define PG_TBLSPC_DIR "pg_tblspc"
#define BACKUP_CONTROL_FILE "backup.control" #define BACKUP_CONTROL_FILE "backup.control"
#define BACKUP_CATALOG_CONF_FILE "pg_probackup.conf" #define BACKUP_CATALOG_CONF_FILE "pg_probackup.conf"
@ -271,6 +275,10 @@ extern char arclog_path[MAXPGPATH];
extern int num_threads; extern int num_threads;
extern bool stream_wal; extern bool stream_wal;
extern bool progress; extern bool progress;
#if PG_VERSION_NUM >= 100000
/* In pre-10 'replication_slot' is defined in receivelog.h */
extern char *replication_slot;
#endif
/* backup options */ /* backup options */
extern bool smooth_checkpoint; extern bool smooth_checkpoint;

View File

@ -65,9 +65,15 @@ checkControlFile(ControlFileData *ControlFile)
static void static void
digestControlFile(ControlFileData *ControlFile, char *src, size_t size) digestControlFile(ControlFileData *ControlFile, char *src, size_t size)
{ {
if (size != PG_CONTROL_SIZE) #if PG_VERSION_NUM >= 100000
int ControlFileSize = PG_CONTROL_FILE_SIZE;
#else
int ControlFileSize = PG_CONTROL_SIZE;
#endif
if (size != ControlFileSize)
elog(ERROR, "unexpected control file size %d, expected %d", elog(ERROR, "unexpected control file size %d, expected %d",
(int) size, PG_CONTROL_SIZE); (int) size, ControlFileSize);
memcpy(ControlFile, src, sizeof(ControlFileData)); memcpy(ControlFile, src, sizeof(ControlFileData));