mirror of
https://github.com/postgres/postgres.git
synced 2025-05-05 09:19:17 +03:00
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>
This commit is contained in:
parent
e8d016d819
commit
c3368f9173
@ -22,6 +22,7 @@
|
|||||||
#include "libpq-fe.h"
|
#include "libpq-fe.h"
|
||||||
#include "pqexpbuffer.h"
|
#include "pqexpbuffer.h"
|
||||||
#include "access/xlog.h"
|
#include "access/xlog.h"
|
||||||
|
#include "mb/pg_wchar.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
#include "pgstat.h"
|
#include "pgstat.h"
|
||||||
#include "replication/logicalproto.h"
|
#include "replication/logicalproto.h"
|
||||||
@ -134,9 +135,16 @@ libpqrcv_connect(const char *conninfo, bool logical, const char *appname,
|
|||||||
}
|
}
|
||||||
keys[++i] = "fallback_application_name";
|
keys[++i] = "fallback_application_name";
|
||||||
vals[i] = appname;
|
vals[i] = appname;
|
||||||
|
if (logical)
|
||||||
|
{
|
||||||
|
keys[++i] = "client_encoding";
|
||||||
|
vals[i] = GetDatabaseEncodingName();
|
||||||
|
}
|
||||||
keys[++i] = NULL;
|
keys[++i] = NULL;
|
||||||
vals[i] = NULL;
|
vals[i] = NULL;
|
||||||
|
|
||||||
|
Assert(i < sizeof(keys));
|
||||||
|
|
||||||
conn = palloc0(sizeof(WalReceiverConn));
|
conn = palloc0(sizeof(WalReceiverConn));
|
||||||
conn->streamConn = PQconnectdbParams(keys, vals, /* expand_dbname = */ true);
|
conn->streamConn = PQconnectdbParams(keys, vals, /* expand_dbname = */ true);
|
||||||
if (PQstatus(conn->streamConn) != CONNECTION_OK)
|
if (PQstatus(conn->streamConn) != CONNECTION_OK)
|
||||||
|
@ -444,7 +444,7 @@ logicalrep_write_tuple(StringInfo out, Relation rel, HeapTuple tuple)
|
|||||||
outputstr = OidOutputFunctionCall(typclass->typoutput, values[i]);
|
outputstr = OidOutputFunctionCall(typclass->typoutput, values[i]);
|
||||||
len = strlen(outputstr) + 1; /* null terminated */
|
len = strlen(outputstr) + 1; /* null terminated */
|
||||||
pq_sendint(out, len, 4); /* length */
|
pq_sendint(out, len, 4); /* length */
|
||||||
appendBinaryStringInfo(out, outputstr, len); /* data */
|
pq_sendstring(out, outputstr); /* data */
|
||||||
|
|
||||||
pfree(outputstr);
|
pfree(outputstr);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user