PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pg_receivewal.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * pg_receivewal.c - receive streaming transaction log data and write it
4  * to a local file.
5  *
6  * Author: Magnus Hagander <magnus@hagander.net>
7  *
8  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
9  *
10  * IDENTIFICATION
11  * src/bin/pg_basebackup/pg_receivewal.c
12  *-------------------------------------------------------------------------
13  */
14 
15 #include "postgres_fe.h"
16 
17 #include <dirent.h>
18 #include <signal.h>
19 #include <sys/stat.h>
20 #include <sys/types.h>
21 #include <unistd.h>
22 
23 #include "libpq-fe.h"
24 #include "access/xlog_internal.h"
25 #include "getopt_long.h"
26 
27 #include "receivelog.h"
28 #include "streamutil.h"
29 
30 
31 /* Time to sleep between reconnection attempts */
32 #define RECONNECT_SLEEP_TIME 5
33 
34 /* Global options */
35 static char *basedir = NULL;
36 static int verbose = 0;
37 static int compresslevel = 0;
38 static int noloop = 0;
39 static int standby_message_timeout = 10 * 1000; /* 10 sec = default */
40 static volatile bool time_to_abort = false;
41 static bool do_create_slot = false;
42 static bool slot_exists_ok = false;
43 static bool do_drop_slot = false;
44 static bool synchronous = false;
45 static char *replication_slot = NULL;
46 
47 
48 static void usage(void);
49 static DIR *get_destination_dir(char *dest_folder);
50 static void close_destination_dir(DIR *dest_dir, char *dest_folder);
52 static void StreamLog(void);
53 static bool stop_streaming(XLogRecPtr segendpos, uint32 timeline,
54  bool segment_finished);
55 
56 #define disconnect_and_exit(code) \
57  { \
58  if (conn != NULL) PQfinish(conn); \
59  exit(code); \
60  }
61 
62 /* Routines to evaluate segment file format */
63 #define IsCompressXLogFileName(fname) \
64  (strlen(fname) == XLOG_FNAME_LEN + strlen(".gz") && \
65  strspn(fname, "0123456789ABCDEF") == XLOG_FNAME_LEN && \
66  strcmp((fname) + XLOG_FNAME_LEN, ".gz") == 0)
67 #define IsPartialCompressXLogFileName(fname) \
68  (strlen(fname) == XLOG_FNAME_LEN + strlen(".gz.partial") && \
69  strspn(fname, "0123456789ABCDEF") == XLOG_FNAME_LEN && \
70  strcmp((fname) + XLOG_FNAME_LEN, ".gz.partial") == 0)
71 
72 static void
73 usage(void)
74 {
75  printf(_("%s receives PostgreSQL streaming transaction logs.\n\n"),
76  progname);
77  printf(_("Usage:\n"));
78  printf(_(" %s [OPTION]...\n"), progname);
79  printf(_("\nOptions:\n"));
80  printf(_(" -D, --directory=DIR receive transaction log files into this directory\n"));
81  printf(_(" --if-not-exists do not error if slot already exists when creating a slot\n"));
82  printf(_(" -n, --no-loop do not loop on connection lost\n"));
83  printf(_(" -s, --status-interval=SECS\n"
84  " time between status packets sent to server (default: %d)\n"), (standby_message_timeout / 1000));
85  printf(_(" -S, --slot=SLOTNAME replication slot to use\n"));
86  printf(_(" --synchronous flush transaction log immediately after writing\n"));
87  printf(_(" -v, --verbose output verbose messages\n"));
88  printf(_(" -V, --version output version information, then exit\n"));
89  printf(_(" -Z, --compress=0-9 compress logs with given compression level\n"));
90  printf(_(" -?, --help show this help, then exit\n"));
91  printf(_("\nConnection options:\n"));
92  printf(_(" -d, --dbname=CONNSTR connection string\n"));
93  printf(_(" -h, --host=HOSTNAME database server host or socket directory\n"));
94  printf(_(" -p, --port=PORT database server port number\n"));
95  printf(_(" -U, --username=NAME connect as specified database user\n"));
96  printf(_(" -w, --no-password never prompt for password\n"));
97  printf(_(" -W, --password force password prompt (should happen automatically)\n"));
98  printf(_("\nOptional actions:\n"));
99  printf(_(" --create-slot create a new replication slot (for the slot's name see --slot)\n"));
100  printf(_(" --drop-slot drop the replication slot (for the slot's name see --slot)\n"));
101  printf(_("\nReport bugs to <pgsql-bugs@postgresql.org>.\n"));
102 }
103 
104 static bool
105 stop_streaming(XLogRecPtr xlogpos, uint32 timeline, bool segment_finished)
106 {
107  static uint32 prevtimeline = 0;
108  static XLogRecPtr prevpos = InvalidXLogRecPtr;
109 
110  /* we assume that we get called once at the end of each segment */
111  if (verbose && segment_finished)
112  fprintf(stderr, _("%s: finished segment at %X/%X (timeline %u)\n"),
113  progname, (uint32) (xlogpos >> 32), (uint32) xlogpos,
114  timeline);
115 
116  /*
117  * Note that we report the previous, not current, position here. After a
118  * timeline switch, xlogpos points to the beginning of the segment because
119  * that's where we always begin streaming. Reporting the end of previous
120  * timeline isn't totally accurate, because the next timeline can begin
121  * slightly before the end of the WAL that we received on the previous
122  * timeline, but it's close enough for reporting purposes.
123  */
124  if (prevtimeline != 0 && prevtimeline != timeline)
125  fprintf(stderr, _("%s: switched to timeline %u at %X/%X\n"),
126  progname, timeline,
127  (uint32) (prevpos >> 32), (uint32) prevpos);
128 
129  prevtimeline = timeline;
130  prevpos = xlogpos;
131 
132  if (time_to_abort)
133  {
134  fprintf(stderr, _("%s: received interrupt signal, exiting\n"),
135  progname);
136  return true;
137  }
138  return false;
139 }
140 
141 
142 /*
143  * Get destination directory.
144  */
145 static DIR *
146 get_destination_dir(char *dest_folder)
147 {
148  DIR *dir;
149 
150  Assert(dest_folder != NULL);
151  dir = opendir(dest_folder);
152  if (dir == NULL)
153  {
154  fprintf(stderr, _("%s: could not open directory \"%s\": %s\n"),
155  progname, basedir, strerror(errno));
157  }
158 
159  return dir;
160 }
161 
162 
163 /*
164  * Close existing directory.
165  */
166 static void
167 close_destination_dir(DIR *dest_dir, char *dest_folder)
168 {
169  Assert(dest_dir != NULL && dest_folder != NULL);
170  if (closedir(dest_dir))
171  {
172  fprintf(stderr, _("%s: could not close directory \"%s\": %s\n"),
173  progname, dest_folder, strerror(errno));
175  }
176 }
177 
178 
179 /*
180  * Determine starting location for streaming, based on any existing xlog
181  * segments in the directory. We start at the end of the last one that is
182  * complete (size matches XLogSegSize), on the timeline with highest ID.
183  *
184  * If there are no WAL files in the directory, returns InvalidXLogRecPtr.
185  */
186 static XLogRecPtr
188 {
189  DIR *dir;
190  struct dirent *dirent;
191  XLogSegNo high_segno = 0;
192  uint32 high_tli = 0;
193  bool high_ispartial = false;
194 
196 
197  while (errno = 0, (dirent = readdir(dir)) != NULL)
198  {
199  uint32 tli;
200  XLogSegNo segno;
201  bool ispartial;
202  bool iscompress;
203 
204  /*
205  * Check if the filename looks like an xlog file, or a .partial file.
206  */
207  if (IsXLogFileName(dirent->d_name))
208  {
209  ispartial = false;
210  iscompress = false;
211  }
212  else if (IsPartialXLogFileName(dirent->d_name))
213  {
214  ispartial = true;
215  iscompress = false;
216  }
217  else if (IsCompressXLogFileName(dirent->d_name))
218  {
219  ispartial = false;
220  iscompress = true;
221  }
222  else if (IsPartialCompressXLogFileName(dirent->d_name))
223  {
224  ispartial = true;
225  iscompress = true;
226  }
227  else
228  continue;
229 
230  /*
231  * Looks like an xlog file. Parse its position.
232  */
233  XLogFromFileName(dirent->d_name, &tli, &segno);
234 
235  /*
236  * Check that the segment has the right size, if it's supposed to be
237  * completed. For non-compressed segments just check the on-disk size
238  * and see if it matches a completed segment.
239  * For compressed segments, look at the last 4 bytes of the compressed
240  * file, which is where the uncompressed size is located for gz files
241  * with a size lower than 4GB, and then compare it to the size of a
242  * completed segment. The 4 last bytes correspond to the ISIZE member
243  * according to http://www.zlib.org/rfc-gzip.html.
244  */
245  if (!ispartial && !iscompress)
246  {
247  struct stat statbuf;
248  char fullpath[MAXPGPATH];
249 
250  snprintf(fullpath, sizeof(fullpath), "%s/%s", basedir, dirent->d_name);
251  if (stat(fullpath, &statbuf) != 0)
252  {
253  fprintf(stderr, _("%s: could not stat file \"%s\": %s\n"),
254  progname, fullpath, strerror(errno));
256  }
257 
258  if (statbuf.st_size != XLOG_SEG_SIZE)
259  {
260  fprintf(stderr,
261  _("%s: segment file \"%s\" has incorrect size %d, skipping\n"),
262  progname, dirent->d_name, (int) statbuf.st_size);
263  continue;
264  }
265  }
266  else if (!ispartial && iscompress)
267  {
268  int fd;
269  char buf[4];
270  int bytes_out;
271  char fullpath[MAXPGPATH];
272 
273  snprintf(fullpath, sizeof(fullpath), "%s/%s", basedir, dirent->d_name);
274 
275  fd = open(fullpath, O_RDONLY | PG_BINARY);
276  if (fd < 0)
277  {
278  fprintf(stderr, _("%s: could not open compressed file \"%s\": %s\n"),
279  progname, fullpath, strerror(errno));
281  }
282  if (lseek(fd, (off_t)(-4), SEEK_END) < 0)
283  {
284  fprintf(stderr, _("%s: could not seek compressed file \"%s\": %s\n"),
285  progname, fullpath, strerror(errno));
287  }
288  if (read(fd, (char *) buf, sizeof(buf)) != sizeof(buf))
289  {
290  fprintf(stderr, _("%s: could not read compressed file \"%s\": %s\n"),
291  progname, fullpath, strerror(errno));
293  }
294 
295  close(fd);
296  bytes_out = (buf[3] << 24) | (buf[2] << 16) |
297  (buf[1] << 8) | buf[0];
298 
299  if (bytes_out != XLOG_SEG_SIZE)
300  {
301  fprintf(stderr,
302  _("%s: compressed segment file \"%s\" has incorrect uncompressed size %d, skipping\n"),
303  progname, dirent->d_name, bytes_out);
304  continue;
305  }
306  }
307 
308  /* Looks like a valid segment. Remember that we saw it. */
309  if ((segno > high_segno) ||
310  (segno == high_segno && tli > high_tli) ||
311  (segno == high_segno && tli == high_tli && high_ispartial && !ispartial))
312  {
313  high_segno = segno;
314  high_tli = tli;
315  high_ispartial = ispartial;
316  }
317  }
318 
319  if (errno)
320  {
321  fprintf(stderr, _("%s: could not read directory \"%s\": %s\n"),
322  progname, basedir, strerror(errno));
324  }
325 
327 
328  if (high_segno > 0)
329  {
330  XLogRecPtr high_ptr;
331 
332  /*
333  * Move the starting pointer to the start of the next segment, if the
334  * highest one we saw was completed. Otherwise start streaming from
335  * the beginning of the .partial segment.
336  */
337  if (!high_ispartial)
338  high_segno++;
339 
340  XLogSegNoOffsetToRecPtr(high_segno, 0, high_ptr);
341 
342  *tli = high_tli;
343  return high_ptr;
344  }
345  else
346  return InvalidXLogRecPtr;
347 }
348 
349 /*
350  * Start the log streaming
351  */
352 static void
354 {
355  XLogRecPtr serverpos;
356  TimeLineID servertli;
357  StreamCtl stream;
358 
359  MemSet(&stream, 0, sizeof(stream));
360 
361  /*
362  * Connect in replication mode to the server
363  */
364  if (conn == NULL)
365  conn = GetConnection();
366  if (!conn)
367  /* Error message already written in GetConnection() */
368  return;
369 
371  {
372  /*
373  * Error message already written in CheckServerVersionForStreaming().
374  * There's no hope of recovering from a version mismatch, so don't
375  * retry.
376  */
378  }
379 
380  /*
381  * Identify server, obtaining start LSN position and current timeline ID
382  * at the same time, necessary if not valid data can be found in the
383  * existing output directory.
384  */
385  if (!RunIdentifySystem(conn, NULL, &servertli, &serverpos, NULL))
387 
388  /*
389  * Figure out where to start streaming.
390  */
391  stream.startpos = FindStreamingStart(&stream.timeline);
392  if (stream.startpos == InvalidXLogRecPtr)
393  {
394  stream.startpos = serverpos;
395  stream.timeline = servertli;
396  }
397 
398  /*
399  * Always start streaming at the beginning of a segment
400  */
401  stream.startpos -= stream.startpos % XLOG_SEG_SIZE;
402 
403  /*
404  * Start the replication
405  */
406  if (verbose)
407  fprintf(stderr,
408  _("%s: starting log streaming at %X/%X (timeline %u)\n"),
409  progname, (uint32) (stream.startpos >> 32), (uint32) stream.startpos,
410  stream.timeline);
411 
412  stream.stream_stop = stop_streaming;
414  stream.synchronous = synchronous;
415  stream.do_sync = true;
416  stream.mark_done = false;
418  stream.do_sync);
419  stream.partial_suffix = ".partial";
421  stream.temp_slot = false;
422 
423  ReceiveXlogStream(conn, &stream);
424 
425  if (!stream.walmethod->finish())
426  {
427  fprintf(stderr,
428  _("%s: could not finish writing WAL files: %s\n"),
429  progname, strerror(errno));
430  return;
431  }
432 
433  PQfinish(conn);
434 
436  pg_free(stream.walmethod);
437 
438  conn = NULL;
439 }
440 
441 /*
442  * When sigint is called, just tell the system to exit at the next possible
443  * moment.
444  */
445 #ifndef WIN32
446 
447 static void
448 sigint_handler(int signum)
449 {
450  time_to_abort = true;
451 }
452 #endif
453 
454 int
455 main(int argc, char **argv)
456 {
457  static struct option long_options[] = {
458  {"help", no_argument, NULL, '?'},
459  {"version", no_argument, NULL, 'V'},
460  {"directory", required_argument, NULL, 'D'},
461  {"dbname", required_argument, NULL, 'd'},
462  {"host", required_argument, NULL, 'h'},
463  {"port", required_argument, NULL, 'p'},
464  {"username", required_argument, NULL, 'U'},
465  {"no-loop", no_argument, NULL, 'n'},
466  {"no-password", no_argument, NULL, 'w'},
467  {"password", no_argument, NULL, 'W'},
468  {"status-interval", required_argument, NULL, 's'},
469  {"slot", required_argument, NULL, 'S'},
470  {"verbose", no_argument, NULL, 'v'},
471  {"compress", required_argument, NULL, 'Z'},
472 /* action */
473  {"create-slot", no_argument, NULL, 1},
474  {"drop-slot", no_argument, NULL, 2},
475  {"if-not-exists", no_argument, NULL, 3},
476  {"synchronous", no_argument, NULL, 4},
477  {NULL, 0, NULL, 0}
478  };
479 
480  int c;
481  int option_index;
482  char *db_name;
483 
484  progname = get_progname(argv[0]);
485  set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_basebackup"));
486 
487  if (argc > 1)
488  {
489  if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
490  {
491  usage();
492  exit(0);
493  }
494  else if (strcmp(argv[1], "-V") == 0 ||
495  strcmp(argv[1], "--version") == 0)
496  {
497  puts("pg_receivewal (PostgreSQL) " PG_VERSION);
498  exit(0);
499  }
500  }
501 
502  while ((c = getopt_long(argc, argv, "D:d:h:p:U:s:S:nwWvZ:",
503  long_options, &option_index)) != -1)
504  {
505  switch (c)
506  {
507  case 'D':
509  break;
510  case 'd':
512  break;
513  case 'h':
515  break;
516  case 'p':
517  if (atoi(optarg) <= 0)
518  {
519  fprintf(stderr, _("%s: invalid port number \"%s\"\n"),
520  progname, optarg);
521  exit(1);
522  }
524  break;
525  case 'U':
527  break;
528  case 'w':
529  dbgetpassword = -1;
530  break;
531  case 'W':
532  dbgetpassword = 1;
533  break;
534  case 's':
535  standby_message_timeout = atoi(optarg) * 1000;
536  if (standby_message_timeout < 0)
537  {
538  fprintf(stderr, _("%s: invalid status interval \"%s\"\n"),
539  progname, optarg);
540  exit(1);
541  }
542  break;
543  case 'S':
545  break;
546  case 'n':
547  noloop = 1;
548  break;
549  case 'v':
550  verbose++;
551  break;
552  case 'Z':
553  compresslevel = atoi(optarg);
554  if (compresslevel < 0 || compresslevel > 9)
555  {
556  fprintf(stderr, _("%s: invalid compression level \"%s\"\n"),
557  progname, optarg);
558  exit(1);
559  }
560  break;
561 /* action */
562  case 1:
563  do_create_slot = true;
564  break;
565  case 2:
566  do_drop_slot = true;
567  break;
568  case 3:
569  slot_exists_ok = true;
570  break;
571  case 4:
572  synchronous = true;
573  break;
574  default:
575 
576  /*
577  * getopt_long already emitted a complaint
578  */
579  fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
580  progname);
581  exit(1);
582  }
583  }
584 
585  /*
586  * Any non-option arguments?
587  */
588  if (optind < argc)
589  {
590  fprintf(stderr,
591  _("%s: too many command-line arguments (first is \"%s\")\n"),
592  progname, argv[optind]);
593  fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
594  progname);
595  exit(1);
596  }
597 
599  {
600  fprintf(stderr, _("%s: cannot use --create-slot together with --drop-slot\n"), progname);
601  fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
602  progname);
603  exit(1);
604  }
605 
607  {
608  /* translator: second %s is an option name */
609  fprintf(stderr, _("%s: %s needs a slot to be specified using --slot\n"), progname,
610  do_drop_slot ? "--drop-slot" : "--create-slot");
611  fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
612  progname);
613  exit(1);
614  }
615 
616  /*
617  * Required arguments
618  */
619  if (basedir == NULL && !do_drop_slot && !do_create_slot)
620  {
621  fprintf(stderr, _("%s: no target directory specified\n"), progname);
622  fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
623  progname);
624  exit(1);
625  }
626 
627 #ifndef HAVE_LIBZ
628  if (compresslevel != 0)
629  {
630  fprintf(stderr,
631  _("%s: this build does not support compression\n"),
632  progname);
633  exit(1);
634  }
635 #endif
636 
637  /*
638  * Check existence of destination folder.
639  */
640  if (!do_drop_slot && !do_create_slot)
641  {
643 
645  }
646 
647 #ifndef WIN32
648  pqsignal(SIGINT, sigint_handler);
649 #endif
650 
651  /*
652  * Obtain a connection before doing anything.
653  */
654  conn = GetConnection();
655  if (!conn)
656  /* error message already written in GetConnection() */
657  exit(1);
658 
659  /*
660  * Run IDENTIFY_SYSTEM to make sure we've successfully have established a
661  * replication connection and haven't connected using a database specific
662  * connection.
663  */
664  if (!RunIdentifySystem(conn, NULL, NULL, NULL, &db_name))
666 
667  /*
668  * Check that there is a database associated with connection, none should
669  * be defined in this context.
670  */
671  if (db_name)
672  {
673  fprintf(stderr,
674  _("%s: replication connection using slot \"%s\" is unexpectedly database specific\n"),
677  }
678 
679  /*
680  * Drop a replication slot.
681  */
682  if (do_drop_slot)
683  {
684  if (verbose)
685  fprintf(stderr,
686  _("%s: dropping replication slot \"%s\"\n"),
688 
692  }
693 
694  /* Create a replication slot */
695  if (do_create_slot)
696  {
697  if (verbose)
698  fprintf(stderr,
699  _("%s: creating replication slot \"%s\"\n"),
701 
706  }
707 
708  /*
709  * Don't close the connection here so that subsequent StreamLog() can
710  * reuse it.
711  */
712 
713  while (true)
714  {
715  StreamLog();
716  if (time_to_abort)
717  {
718  /*
719  * We've been Ctrl-C'ed. That's not an error, so exit without an
720  * errorcode.
721  */
722  exit(0);
723  }
724  else if (noloop)
725  {
726  fprintf(stderr, _("%s: disconnected\n"), progname);
727  exit(1);
728  }
729  else
730  {
731  fprintf(stderr,
732  /* translator: check source for value for %d */
733  _("%s: disconnected; waiting %d seconds to try again\n"),
735  pg_usleep(RECONNECT_SLEEP_TIME * 1000000);
736  }
737  }
738 }
static char * replication_slot
Definition: pg_receivewal.c:45
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28
int main(int argc, char **argv)
static int standby_message_timeout
Definition: pg_receivewal.c:39
uint32 TimeLineID
Definition: xlogdefs.h:45
bool do_sync
Definition: receivelog.h:40
const char * get_progname(const char *argv0)
Definition: path.c:453
static void DropReplicationSlot(DropReplicationSlotCmd *cmd)
Definition: walsender.c:877
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
Definition: getopt_long.c:57
static void usage(void)
Definition: pg_receivewal.c:73
#define IsPartialCompressXLogFileName(fname)
Definition: pg_receivewal.c:67
bool RunIdentifySystem(PGconn *conn, char **sysid, TimeLineID *starttli, XLogRecPtr *startpos, char **db_name)
Definition: streamutil.c:245
int closedir(DIR *)
Definition: dirent.c:113
void PQfinish(PGconn *conn)
Definition: fe-connect.c:3517
#define MemSet(start, val, len)
Definition: c.h:853
static bool synchronous
Definition: pg_receivewal.c:44
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
XLogRecPtr startpos
Definition: receivelog.h:32
char * partial_suffix
Definition: receivelog.h:46
static bool stop_streaming(XLogRecPtr segendpos, uint32 timeline, bool segment_finished)
const char * progname
Definition: pg_standby.c:37
static void close_destination_dir(DIR *dest_dir, char *dest_folder)
Definition: dirent.h:9
static int fd(const char *x, int i)
Definition: preproc-init.c:105
#define PG_BINARY
Definition: c.h:1038
TimeLineID timeline
Definition: receivelog.h:33
WalWriteMethod * CreateWalDirectoryMethod(const char *basedir, int compression, bool sync)
Definition: walmethods.c:346
bool(* finish)(void)
Definition: walmethods.h:33
#define XLogSegNoOffsetToRecPtr(segno, offset, dest)
Definition: xlog_internal.h:95
static void sigint_handler(int signum)
static bool slot_exists_ok
Definition: pg_receivewal.c:42
static void StreamLog(void)
void pg_usleep(long microsec)
Definition: signal.c:53
#define required_argument
Definition: getopt_long.h:25
int optind
Definition: getopt.c:51
Definition: dirent.c:25
#define IsXLogFileName(fname)
char * connection_string
Definition: streamutil.c:37
PGconn * conn
Definition: streamutil.c:45
#define MAXPGPATH
#define disconnect_and_exit(code)
Definition: pg_receivewal.c:56
DIR * opendir(const char *)
Definition: dirent.c:33
static int noloop
Definition: pg_receivewal.c:38
char * replication_slot
Definition: receivelog.h:47
bool mark_done
Definition: receivelog.h:39
char * c
static char * buf
Definition: pg_test_fsync.c:65
uint64 XLogSegNo
Definition: xlogdefs.h:34
static XLogRecPtr FindStreamingStart(uint32 *tli)
static char * basedir
Definition: pg_receivewal.c:35
char * pg_strdup(const char *in)
Definition: fe_memutils.c:85
unsigned int uint32
Definition: c.h:265
stream_stop_callback stream_stop
Definition: receivelog.h:43
static bool do_drop_slot
Definition: pg_receivewal.c:43
WalWriteMethod * walmethod
Definition: receivelog.h:45
int dbgetpassword
Definition: streamutil.c:42
#define no_argument
Definition: getopt_long.h:24
#define PG_TEXTDOMAIN(domain)
Definition: c.h:1012
char * dbport
Definition: streamutil.c:40
pqsigfunc pqsignal(int signum, pqsigfunc handler)
Definition: signal.c:168
static DIR * get_destination_dir(char *dest_folder)
PGconn * GetConnection(UserMapping *user, bool will_prep_stmt)
Definition: connection.c:97
#define NULL
Definition: c.h:226
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define Assert(condition)
Definition: c.h:671
char * dbhost
Definition: streamutil.c:38
bool ReceiveXlogStream(PGconn *conn, StreamCtl *stream)
Definition: receivelog.c:433
#define RECONNECT_SLEEP_TIME
Definition: pg_receivewal.c:32
struct dirent * readdir(DIR *)
Definition: dirent.c:78
static int compresslevel
Definition: pg_receivewal.c:37
static bool do_create_slot
Definition: pg_receivewal.c:41
bool synchronous
Definition: receivelog.h:38
void pg_free(void *ptr)
Definition: fe_memutils.c:105
static void CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
Definition: walsender.c:739
#define IsPartialXLogFileName(fname)
void set_pglocale_pgservice(const char *argv0, const char *app)
Definition: exec.c:550
char * dbuser
Definition: streamutil.c:39
char * optarg
Definition: getopt.c:53
const char * strerror(int errnum)
Definition: strerror.c:19
int standby_message_timeout
Definition: receivelog.h:36
char d_name[MAX_PATH]
Definition: dirent.h:14
#define close(a)
Definition: win32.h:17
bool temp_slot
Definition: receivelog.h:48
#define XLogFromFileName(fname, tli, logSegNo)
static int verbose
Definition: pg_receivewal.c:36
#define _(x)
Definition: elog.c:84
#define read(a, b, c)
Definition: win32.h:18
#define IsCompressXLogFileName(fname)
Definition: pg_receivewal.c:63
static volatile bool time_to_abort
Definition: pg_receivewal.c:40
void FreeWalDirectoryMethod(void)
Definition: walmethods.c:370
bool CheckServerVersionForStreaming(PGconn *conn)
Definition: receivelog.c:360