Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite751b71

Browse files
committed
Use "replication" as the database name when constructing a connection
string for a streaming replication connection. It's ignored by theserver, 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.
1 parentc46f861 commite751b71

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

‎doc/src/sgml/high-availability.sgml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/high-availability.sgml,v 1.72 2010/06/10 08:13:49 itagaki Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/high-availability.sgml,v 1.73 2010/06/11 10:13:08 heikki Exp $ -->
22

33
<chapter id="high-availability">
44
<title>High Availability, Load Balancing, and Replication</title>
@@ -818,8 +818,10 @@ host replication foo 192.168.1.100/32 md5
818818
</para>
819819
<para>
820820
The host name and port number of the primary, connection user name,
821-
and password are specified in the <filename>recovery.conf</> file or
822-
the corresponding environment variable on the standby.
821+
and password are specified in the <filename>recovery.conf</> file.
822+
The password can also be set in the <filename>~/.pgpass</> file on the
823+
standby (specify <literal>replication</> in the <replaceable>database</>
824+
field).
823825
For example, if the primary is running on host IP <literal>192.168.1.50</>,
824826
port <literal>5432</literal>, the superuser's name for replication is
825827
<literal>foo</>, and the password is <literal>foopass</>, the administrator

‎doc/src/sgml/libpq.sgml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.306 2010/05/26 23:49:18 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.307 2010/06/11 10:13:08 heikki Exp $ -->
22

33
<chapter id="libpq">
44
<title><application>libpq</application> - C Library</title>
@@ -6233,7 +6233,8 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough)
62336233
A host name of <literal>localhost</> matches both TCP (host name
62346234
<literal>localhost</>) and Unix domain socket (<literal>pghost</> empty
62356235
or the default socket directory) connections coming from the local
6236-
machine.
6236+
machine. In a standby server, a database name of <literal>replication</>
6237+
matches streaming replication connections made to the master server.
62376238
</para>
62386239

62396240
<para>

‎doc/src/sgml/recovery-config.sgml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/recovery-config.sgml,v 2.7 2010/06/10 08:13:49 itagaki Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/recovery-config.sgml,v 2.8 2010/06/11 10:13:09 heikki Exp $ -->
22

33
<chapter Id="recovery-config">
44
<title>Recovery Configuration</title>
@@ -268,9 +268,10 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows
268268
primary (see
269269
<xref linkend="streaming-replication-authentication">).
270270
A password needs to be provided too, if the primary demands password
271-
authentication. (The password can be provided either in
272-
the <varname>primary_conninfo</varname> string or in a separate
273-
<filename>~/.pgpass</> file on the standby server.)
271+
authentication. It can be provided in the
272+
<varname>primary_conninfo</varname> string, or in a separate
273+
<filename>~/.pgpass</> file on the standby server (use
274+
<literal>replication</> as the database name).
274275
Do not specify a database name in the
275276
<varname>primary_conninfo</varname> string.
276277
</para>

‎src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c,v 1.10 2010/04/21 03:32:53 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c,v 1.11 2010/06/11 10:13:09 heikki Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -77,16 +77,22 @@ _PG_init(void)
7777
staticbool
7878
libpqrcv_connect(char*conninfo,XLogRecPtrstartpoint)
7979
{
80-
charconninfo_repl[MAXCONNINFO+18];
80+
charconninfo_repl[MAXCONNINFO+37];
8181
char*primary_sysid;
8282
charstandby_sysid[32];
8383
TimeLineIDprimary_tli;
8484
TimeLineIDstandby_tli;
8585
PGresult*res;
8686
charcmd[64];
8787

88-
/* Connect using deliberately undocumented parameter: replication */
89-
snprintf(conninfo_repl,sizeof(conninfo_repl),"%s replication=true",conninfo);
88+
/*
89+
* Connect using deliberately undocumented parameter: replication.
90+
* The database name is ignored by the server in replication mode, but
91+
* specify "replication" for .pgpass lookup.
92+
*/
93+
snprintf(conninfo_repl,sizeof(conninfo_repl),
94+
"%s dbname=replication replication=true",
95+
conninfo);
9096

9197
streamConn=PQconnectdb(conninfo_repl);
9298
if (PQstatus(streamConn)!=CONNECTION_OK)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp