aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-06-11 10:13:09 +0000
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2010-06-11 10:13:09 +0000
commite751b71b56f1ba6fa3bb277059f9d5a8ea7b84af (patch)
tree7444f4c07dd491053adced0ea429074db79480c0 /src
parentc46f861c0dde5813b8c472a65dfc4e76d093ad0f (diff)
downloadpostgresql-e751b71b56f1ba6fa3bb277059f9d5a8ea7b84af.tar.gz
postgresql-e751b71b56f1ba6fa3bb277059f9d5a8ea7b84af.zip
Use "replication" as the database name when constructing a connection
string for a streaming replication connection. It's ignored by the server, but allows libpq to pick up the password from .pgpass where "replication" is specified as the database name. Patch by Fujii Masao per Tom's suggestion, with some wording changes by me.
Diffstat (limited to 'src')
-rw-r--r--src/backend/replication/libpqwalreceiver/libpqwalreceiver.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
index 1807fde9e4b..b62f48be825 100644
--- a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
+++ b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c,v 1.10 2010/04/21 03:32:53 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c,v 1.11 2010/06/11 10:13:09 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -77,7 +77,7 @@ _PG_init(void)
static bool
libpqrcv_connect(char *conninfo, XLogRecPtr startpoint)
{
- char conninfo_repl[MAXCONNINFO + 18];
+ char conninfo_repl[MAXCONNINFO + 37];
char *primary_sysid;
char standby_sysid[32];
TimeLineID primary_tli;
@@ -85,8 +85,14 @@ libpqrcv_connect(char *conninfo, XLogRecPtr startpoint)
PGresult *res;
char cmd[64];
- /* Connect using deliberately undocumented parameter: replication */
- snprintf(conninfo_repl, sizeof(conninfo_repl), "%s replication=true", conninfo);
+ /*
+ * Connect using deliberately undocumented parameter: replication.
+ * The database name is ignored by the server in replication mode, but
+ * specify "replication" for .pgpass lookup.
+ */
+ snprintf(conninfo_repl, sizeof(conninfo_repl),
+ "%s dbname=replication replication=true",
+ conninfo);
streamConn = PQconnectdb(conninfo_repl);
if (PQstatus(streamConn) != CONNECTION_OK)