Re: Logical Replication and Character encoding

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: petr(dot)jelinek(at)2ndquadrant(dot)com
Cc: peter(dot)eisentraut(at)2ndquadrant(dot)com, noriyoshi(dot)shinoda(at)hpe(dot)com, pgsql-hackers(at)postgresql(dot)org, craig(at)2ndquadrant(dot)com
Subject: Re: Logical Replication and Character encoding
Date: 2017-03-21 10:24:19
Message-ID: 20170321.192419.96677899.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Mon, 6 Mar 2017 11:13:48 +0100, Petr Jelinek <petr(dot)jelinek(at)2ndquadrant(dot)com> wrote in <a7c0cc59-9c21-238c-b6a7-d6eb519ad9ee(at)2ndquadrant(dot)com>
> >>> Well the length is necessary to be able to add binary format support in
> >>> future so it's definitely not an omission.
> >>
> >> Right. So it appears the right function to use here is
> >> pq_sendcountedtext(). However, this sends the strings without null
> >> termination, so we'd have to do extra processing on the receiving end.
> >> Or we could add an option to pq_sendcountedtext() to make it do what we
> >> want. I'd rather stick to standard pqformat.c functions for handling
> >> the protocol.
> >
> > It seems reasonable. I changed the prototype of
> > pg_sendcountedtext as the following,
> >
> > | extern void pq_sendcountedtext(StringInfo buf, const char *str, int slen,
> > | bool countincludesself, bool binary);
> >
> > I think 'binary' seems fine for the parameter here. The patch
> > size increased a bit.
> >
>
> Hmm I find it bit weird that binary true means NULL terminated while
> false means not NULL terminated, I would think that the behaviour would
> be exactly opposite given that text strings are the ones where NULL
> termination matters?

You're right. I renamed it as with more straightforward
name. Addition to that, it contained a stupid bug that sends a
garbage byte when non-null-terminated string is not converted.
And the comment is edited to reflect the new behavior.

> > By the way, I noticed that postmaster launches logical
> > replication launcher even if wal_level < logical. Is it right?
>
> Yes, that came up couple of times in various threads. The logical
> replication launcher is needed only to start subscriptions and
> subscriptions don't need wal_level to be logical, only publication needs
> that.

regards,

--
Kyotaro Horiguchi
NTT Open Source Software Center

Attachment Content-Type Size
fix_logrep_conversion_20170321.patch text/x-patch 5.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2017-03-21 10:32:40 Re: Logical Replication and Character encoding
Previous Message Rajkumar Raghuwanshi 2017-03-21 10:22:13 Re: Partition-wise join for join between (declaratively) partitioned tables