Skip to content

Commit c3368f9

Browse files
committed
Fix logical replication with different encodings
reported by Shinoda, Noriyoshi <noriyoshi.shinoda@hpe.com>; partial patch by Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
1 parent e8d016d commit c3368f9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "libpq-fe.h"
2323
#include "pqexpbuffer.h"
2424
#include "access/xlog.h"
25+
#include "mb/pg_wchar.h"
2526
#include "miscadmin.h"
2627
#include "pgstat.h"
2728
#include "replication/logicalproto.h"
@@ -134,9 +135,16 @@ libpqrcv_connect(const char *conninfo, bool logical, const char *appname,
134135
}
135136
keys[++i] = "fallback_application_name";
136137
vals[i] = appname;
138+
if (logical)
139+
{
140+
keys[++i] = "client_encoding";
141+
vals[i] = GetDatabaseEncodingName();
142+
}
137143
keys[++i] = NULL;
138144
vals[i] = NULL;
139145

146+
Assert(i < sizeof(keys));
147+
140148
conn = palloc0(sizeof(WalReceiverConn));
141149
conn->streamConn = PQconnectdbParams(keys, vals, /* expand_dbname = */ true);
142150
if (PQstatus(conn->streamConn) != CONNECTION_OK)

src/backend/replication/logical/proto.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ logicalrep_write_tuple(StringInfo out, Relation rel, HeapTuple tuple)
444444
outputstr = OidOutputFunctionCall(typclass->typoutput, values[i]);
445445
len = strlen(outputstr) + 1; /* null terminated */
446446
pq_sendint(out, len, 4); /* length */
447-
appendBinaryStringInfo(out, outputstr, len); /* data */
447+
pq_sendstring(out, outputstr); /* data */
448448

449449
pfree(outputstr);
450450

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy