On 13-01-22 11:30 AM, Andres Freund wrote:
Hi,
I pushed a new rebased version (the xlogreader commit made it annoying
to merge).
The main improvements are
* way much coherent code internally for intializing logical rep
* explicit control over slots
* options for logical replication
Exactly what is the syntax for using that. My reading your changes to
repl_gram.y make me think that any of the following should work (but
they don't).
START_LOGICAL_REPLICATION 'slon1' 0/0 ('opt1')
ERROR: syntax error: unexpected character "("
"START_LOGICAL_REPLICATION 'slon1' 0/0 ('opt1' 'val1')
ERROR: syntax error: unexpected character "("
START_LOGICAL_REPLICATION 'slon1' 0/0 ('opt1','opt2')
ERROR: syntax error: unexpected character "("
I'm also attaching a patch to pg_receivellog that allows you to specify
these options on the command line. I'm not saying I think that it is
appropriate to be adding more bells and whistles to the utilities two
weeks into the CF but I found this useful for testing so I'm sharing it.
Greetings,
Andres Freund
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
>From 176087bacec6cbf0b86e4ffeb918f41b4a5b8d7a Mon Sep 17 00:00:00 2001
From: Steve Singer <ssin...@ca.afilias.info>
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
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers