>From 176087bacec6cbf0b86e4ffeb918f41b4a5b8d7a Mon Sep 17 00:00:00 2001 From: Steve Singer Date: Sun, 27 Jan 2013 12:24:33 -0500 Subject: [PATCH] allow pg_receivellog to pass plugin options from the command line to the plugin --- src/bin/pg_basebackup/pg_receivellog.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/bin/pg_basebackup/pg_receivellog.c b/src/bin/pg_basebackup/pg_receivellog.c index 04bedbe..30b3cea 100644 --- a/src/bin/pg_basebackup/pg_receivellog.c +++ b/src/bin/pg_basebackup/pg_receivellog.c @@ -54,7 +54,7 @@ static XLogRecPtr startpos; static bool do_init_slot = false; static bool do_start_slot = false; static bool do_stop_slot = false; - +static const char * plugin_opts=""; static void usage(void); static void StreamLog(); @@ -84,6 +84,7 @@ usage(void) printf(_(" -s, --status-interval=INTERVAL\n" " time between status packets sent to server (in seconds)\n")); printf(_(" -S, --slot=SLOT use existing replication slot SLOT instead of starting a new one\n")); + printf(_(" -o --options=OPTIONS A comma separated list of options to the plugin\n")); printf(_("\nAction to be performed:\n")); printf(_(" --init initiate a new replication slot (for the slotname see --slot)\n")); printf(_(" --start start streaming in a replication slot (for the slotname see --slot)\n")); @@ -264,8 +265,8 @@ StreamLog(void) slot); /* Initiate the replication stream at specified location */ - snprintf(query, sizeof(query), "START_LOGICAL_REPLICATION '%s' %X/%X", - slot, (uint32) (startpos >> 32), (uint32) startpos); + snprintf(query, sizeof(query), "START_LOGICAL_REPLICATION '%s' %X/%X (%s)", + slot, (uint32) (startpos >> 32), (uint32) startpos,plugin_opts); res = PQexec(conn, query); if (PQresultStatus(res) != PGRES_COPY_BOTH) { @@ -560,6 +561,7 @@ main(int argc, char **argv) {"init", no_argument, NULL, 1}, {"start", no_argument, NULL, 2}, {"stop", no_argument, NULL, 3}, + {"options",required_argument,NULL,'o'}, {NULL, 0, NULL, 0} }; int c; @@ -584,7 +586,7 @@ main(int argc, char **argv) } } - while ((c = getopt_long(argc, argv, "f:nvd:h:p:U:wWP:s:S:", + while ((c = getopt_long(argc, argv, "f:nvd:h:p:U:wWP:s:S:o:", long_options, &option_index)) != -1) { switch (c) @@ -659,6 +661,10 @@ main(int argc, char **argv) case 3: do_stop_slot = true; break; + case 'o': + if(optarg != NULL) + plugin_opts = pg_strdup(optarg); + break; /* action */ default: -- 1.7.0.4