Skip to content

Commit a0fb391

Browse files
committed
Add support postgres 9.6.
1 parent 0fa7e2f commit a0fb391

File tree

3 files changed

+69
-2
lines changed

3 files changed

+69
-2
lines changed

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ OBJS = backup.o \
2121
pgut/pgut.o \
2222
pgut/pgut-port.o
2323

24-
EXTRA_CLEAN = datapagemap.c datapagemap.h xlogreader.c receivelog.h streamutil.h
24+
EXTRA_CLEAN = datapagemap.c datapagemap.h xlogreader.c receivelog.h streamutil.h logging.h
2525

2626
PG_CPPFLAGS = -I$(libpq_srcdir) ${PTHREAD_CFLAGS}
2727
override CPPFLAGS := -DFRONTEND $(CPPFLAGS)
2828
PG_LIBS = $(libpq_pgport) ${PTHREAD_LIBS} ${PTHREAD_CFLAGS}
2929

3030
REGRESS = init option show delete backup restore
3131

32-
all: checksrcdir datapagemap.h receivelog.h streamutil.h pg_arman
32+
all: checksrcdir datapagemap.h logging.h receivelog.h streamutil.h pg_arman
3333

3434
# This rule's only purpose is to give the user instructions on how to pass
3535
# the path to PostgreSQL source tree to the makefile.
@@ -49,6 +49,10 @@ datapagemap.c: % : $(top_srcdir)/src/bin/pg_rewind/%
4949
rm -f $@ && $(LN_S) $< .
5050
datapagemap.h: % : $(top_srcdir)/src/bin/pg_rewind/%
5151
rm -f && $(LN_S) $< .
52+
#logging.c: % : $(top_srcdir)/src/bin/pg_rewind/%
53+
# rm -f && $(LN_S) $< .
54+
logging.h: % : $(top_srcdir)/src/bin/pg_rewind/%
55+
rm -f && $(LN_S) $< .
5256
receivelog.c: % : $(top_srcdir)/src/bin/pg_basebackup/%
5357
rm -f && $(LN_S) $< .
5458
receivelog.h: % : $(top_srcdir)/src/bin/pg_basebackup/%

backup.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,9 +1326,23 @@ StreamLog(void *arg)
13261326
progname, (uint32) (startpos >> 32), (uint32) startpos,
13271327
starttli);
13281328

1329+
#if PG_VERSION_NUM >= 90600
1330+
StreamCtl ctl;
1331+
ctl.startpos = startpos;
1332+
ctl.timeline = starttli;
1333+
ctl.sysidentifier = NULL;
1334+
ctl.basedir = basedir;
1335+
ctl.stream_stop = stop_streaming;
1336+
ctl.standby_message_timeout = standby_message_timeout;
1337+
ctl.partial_suffix = ".partial";
1338+
ctl.synchronous = false;
1339+
ctl.mark_done = false;
1340+
ReceiveXlogStream(conn, &ctl);
1341+
#else
13291342
ReceiveXlogStream(conn, startpos, starttli, NULL, basedir,
13301343
stop_streaming, standby_message_timeout, ".partial",
13311344
false, false);
1345+
#endif
13321346

13331347
PQfinish(conn);
13341348
conn = NULL;

pgut/pgut.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ static bool in_cleanup = false;
5050

5151
static bool parse_pair(const char buffer[], char key[], char value[]);
5252

53+
typedef enum
54+
{
55+
PG_DEBUG,
56+
PG_PROGRESS,
57+
PG_WARNING,
58+
PG_FATAL
59+
} eLogType;
60+
61+
void pg_log(eLogType type, const char *fmt,...) pg_attribute_printf(2, 3);
62+
5363
/* Connection routines */
5464
static void init_cancel_handler(void);
5565
static void on_before_exec(PGconn *conn);
@@ -1202,6 +1212,45 @@ elog(int elevel, const char *fmt, ...)
12021212
exit_or_abort(elevel);
12031213
}
12041214

1215+
void pg_log(eLogType type, const char *fmt, ...)
1216+
{
1217+
va_list args;
1218+
1219+
if (!verbose && type <= PG_PROGRESS)
1220+
return;
1221+
if (quiet && type < PG_WARNING)
1222+
return;
1223+
1224+
switch (type)
1225+
{
1226+
case PG_DEBUG:
1227+
fputs("DEBUG: ", stderr);
1228+
break;
1229+
case PG_PROGRESS:
1230+
fputs("PROGRESS: ", stderr);
1231+
break;
1232+
case PG_WARNING:
1233+
fputs("WARNING: ", stderr);
1234+
break;
1235+
case PG_FATAL:
1236+
fputs("FATAL: ", stderr);
1237+
break;
1238+
default:
1239+
if (type >= PG_FATAL)
1240+
fputs("ERROR: ", stderr);
1241+
break;
1242+
}
1243+
1244+
va_start(args, fmt);
1245+
vfprintf(stderr, fmt, args);
1246+
fputc('\n', stderr);
1247+
fflush(stderr);
1248+
va_end(args);
1249+
1250+
if (type > 0)
1251+
exit_or_abort(type);
1252+
}
1253+
12051254
#ifdef WIN32
12061255
static CRITICAL_SECTION cancelConnLock;
12071256
#endif

0 commit comments

Comments
 (0)