1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2024-11-28 09:33:54 +02:00

Add support postgres 9.6.

This commit is contained in:
stalkerg 2016-08-30 17:21:02 +03:00
parent 0fa7e2fdbd
commit a0fb3912a8
3 changed files with 69 additions and 2 deletions

View File

@ -21,7 +21,7 @@ OBJS = backup.o \
pgut/pgut.o \
pgut/pgut-port.o
EXTRA_CLEAN = datapagemap.c datapagemap.h xlogreader.c receivelog.h streamutil.h
EXTRA_CLEAN = datapagemap.c datapagemap.h xlogreader.c receivelog.h streamutil.h logging.h
PG_CPPFLAGS = -I$(libpq_srcdir) ${PTHREAD_CFLAGS}
override CPPFLAGS := -DFRONTEND $(CPPFLAGS)
@ -29,7 +29,7 @@ PG_LIBS = $(libpq_pgport) ${PTHREAD_LIBS} ${PTHREAD_CFLAGS}
REGRESS = init option show delete backup restore
all: checksrcdir datapagemap.h receivelog.h streamutil.h pg_arman
all: checksrcdir datapagemap.h logging.h receivelog.h streamutil.h pg_arman
# This rule's only purpose is to give the user instructions on how to pass
# the path to PostgreSQL source tree to the makefile.
@ -49,6 +49,10 @@ datapagemap.c: % : $(top_srcdir)/src/bin/pg_rewind/%
rm -f $@ && $(LN_S) $< .
datapagemap.h: % : $(top_srcdir)/src/bin/pg_rewind/%
rm -f && $(LN_S) $< .
#logging.c: % : $(top_srcdir)/src/bin/pg_rewind/%
# rm -f && $(LN_S) $< .
logging.h: % : $(top_srcdir)/src/bin/pg_rewind/%
rm -f && $(LN_S) $< .
receivelog.c: % : $(top_srcdir)/src/bin/pg_basebackup/%
rm -f && $(LN_S) $< .
receivelog.h: % : $(top_srcdir)/src/bin/pg_basebackup/%

View File

@ -1326,9 +1326,23 @@ StreamLog(void *arg)
progname, (uint32) (startpos >> 32), (uint32) startpos,
starttli);
#if PG_VERSION_NUM >= 90600
StreamCtl ctl;
ctl.startpos = startpos;
ctl.timeline = starttli;
ctl.sysidentifier = NULL;
ctl.basedir = basedir;
ctl.stream_stop = stop_streaming;
ctl.standby_message_timeout = standby_message_timeout;
ctl.partial_suffix = ".partial";
ctl.synchronous = false;
ctl.mark_done = false;
ReceiveXlogStream(conn, &ctl);
#else
ReceiveXlogStream(conn, startpos, starttli, NULL, basedir,
stop_streaming, standby_message_timeout, ".partial",
false, false);
#endif
PQfinish(conn);
conn = NULL;

View File

@ -50,6 +50,16 @@ static bool in_cleanup = false;
static bool parse_pair(const char buffer[], char key[], char value[]);
typedef enum
{
PG_DEBUG,
PG_PROGRESS,
PG_WARNING,
PG_FATAL
} eLogType;
void pg_log(eLogType type, const char *fmt,...) pg_attribute_printf(2, 3);
/* Connection routines */
static void init_cancel_handler(void);
static void on_before_exec(PGconn *conn);
@ -1202,6 +1212,45 @@ elog(int elevel, const char *fmt, ...)
exit_or_abort(elevel);
}
void pg_log(eLogType type, const char *fmt, ...)
{
va_list args;
if (!verbose && type <= PG_PROGRESS)
return;
if (quiet && type < PG_WARNING)
return;
switch (type)
{
case PG_DEBUG:
fputs("DEBUG: ", stderr);
break;
case PG_PROGRESS:
fputs("PROGRESS: ", stderr);
break;
case PG_WARNING:
fputs("WARNING: ", stderr);
break;
case PG_FATAL:
fputs("FATAL: ", stderr);
break;
default:
if (type >= PG_FATAL)
fputs("ERROR: ", stderr);
break;
}
va_start(args, fmt);
vfprintf(stderr, fmt, args);
fputc('\n', stderr);
fflush(stderr);
va_end(args);
if (type > 0)
exit_or_abort(type);
}
#ifdef WIN32
static CRITICAL_SECTION cancelConnLock;
#endif