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

Commitb3fc672

Browse files
committed
Allow using connection URI in primary_conninfo.
The old method of appending options to the connection string didn't work ifthe primary_conninfo was a postgres:// style URI, instead of a traditionalconnection string. Use PQconnectdbParams instead.Alex Shulgin
1 parentadd1b05 commitb3fc672

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

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

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,28 @@ _PG_init(void)
8989
staticvoid
9090
libpqrcv_connect(char*conninfo)
9191
{
92-
charconninfo_repl[MAXCONNINFO+75];
92+
constchar*keys[5];
93+
constchar*vals[5];
9394

9495
/*
95-
* Connect using deliberately undocumented parameter: replication. The
96-
* database name is ignored by the server in replication mode, but specify
97-
* "replication" for .pgpass lookup.
96+
* We use the expand_dbname parameter to process the connection string
97+
* (or URI), and pass some extra options. The deliberately undocumented
98+
* parameter "replication=true" makes it a replication connection.
99+
* The database name is ignored by the server in replication mode, but
100+
* specify "replication" for .pgpass lookup.
98101
*/
99-
snprintf(conninfo_repl,sizeof(conninfo_repl),
100-
"%s dbname=replication replication=true fallback_application_name=walreceiver",
101-
conninfo);
102-
103-
streamConn=PQconnectdb(conninfo_repl);
102+
keys[0]="dbname";
103+
vals[0]=conninfo;
104+
keys[1]="replication";
105+
vals[1]="true";
106+
keys[2]="dbname";
107+
vals[2]="replication";
108+
keys[3]="fallback_application_name";
109+
vals[3]="walreceiver";
110+
keys[4]=NULL;
111+
vals[4]=NULL;
112+
113+
streamConn=PQconnectdbParams(keys,vals,/* expand_dbname = */ true);
104114
if (PQstatus(streamConn)!=CONNECTION_OK)
105115
ereport(ERROR,
106116
(errmsg("could not connect to the primary server: %s",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp