On 2/27/17 00:23, Kyotaro HORIGUCHI wrote: > Yeah, the patch sends converted string with the length of the > orignal length. Usually encoding conversion changes the length of > a string. I doubt that the reverse case was working correctly.
I think we shouldn't send the length value at all. This might have been a leftover from an earlier version of the patch. See attached patch that removes the length value. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>From 11b1ecf696294b891dff36d332db18e1b0c54814 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <pete...@gmx.net> Date: Fri, 3 Mar 2017 14:35:34 -0500 Subject: [PATCH] Logical replication protocol fix Don't send the length value for a column value in logical replication tuple messages. --- doc/src/sgml/protocol.sgml | 10 ---------- src/backend/replication/logical/proto.c | 15 ++------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml index 589b881ef2..bd43c321ae 100644 --- a/doc/src/sgml/protocol.sgml +++ b/doc/src/sgml/protocol.sgml @@ -5915,16 +5915,6 @@ <title>Logical Replication Message Formats</title> </varlistentry> <varlistentry> <term> - Int32 -</term> -<listitem> -<para> - Length of the column value. -</para> -</listitem> -</varlistentry> -<varlistentry> -<term> String </term> <listitem> diff --git a/src/backend/replication/logical/proto.c b/src/backend/replication/logical/proto.c index bc6e9b5a98..a42b799e76 100644 --- a/src/backend/replication/logical/proto.c +++ b/src/backend/replication/logical/proto.c @@ -417,7 +417,6 @@ logicalrep_write_tuple(StringInfo out, Relation rel, HeapTuple tuple) Form_pg_type typclass; Form_pg_attribute att = desc->attrs[i]; char *outputstr; - int len; /* skip dropped columns */ if (att->attisdropped) @@ -442,10 +441,7 @@ logicalrep_write_tuple(StringInfo out, Relation rel, HeapTuple tuple) pq_sendbyte(out, 't'); /* 'text' data follows */ outputstr = OidOutputFunctionCall(typclass->typoutput, values[i]); - len = strlen(outputstr) + 1; /* null terminated */ - pq_sendint(out, len, 4); /* length */ pq_sendstring(out, outputstr); /* data */ - pfree(outputstr); ReleaseSysCache(typtup); @@ -472,7 +468,6 @@ logicalrep_read_tuple(StringInfo in, LogicalRepTupleData *tuple) for (i = 0; i < natts; i++) { char kind; - int len; kind = pq_getmsgbyte(in); @@ -486,14 +481,8 @@ logicalrep_read_tuple(StringInfo in, LogicalRepTupleData *tuple) tuple->values[i] = (char *) 0xdeadbeef; /* make bad usage more obvious */ break; case 't': /* text formatted value */ - { - tuple->changed[i] = true; - - len = pq_getmsgint(in, 4); /* read length */ - - /* and data */ - tuple->values[i] = (char *) pq_getmsgbytes(in, len); - } + tuple->changed[i] = true; + tuple->values[i] = (char *) pq_getmsgrawstring(in); break; default: elog(ERROR, "unknown data representation type '%c'", kind); -- 2.12.0
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers