Aw: Re: Minor documentation error regarding streaming replication protocol

Поиск
Список
Период
Сортировка
От Brar Piening
Тема Aw: Re: Minor documentation error regarding streaming replication protocol
Дата
Msg-id trinity-b5c0c9ec-957a-42f8-9f58-cb01cd00dd39-1602743271839@3c-app-gmx-bs50
обсуждение исходный текст
Ответ на Re: Minor documentation error regarding streaming replication protocol  (Bruce Momjian <bruce@momjian.us>)
Ответы Re: Aw: Re: Minor documentation error regarding streaming replication protocol  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Bruce Momjian <bruce(at)momjian(dot)us> wrote:
>> Good point. The reporter was assuming the data would come to the client
>> in the bytea output format specified by the GUC, e.g. \x..., so that
>> doesn't happen either. As I said before, it is more raw bytes, but we
>> don't have an SQL data type for that.

> I did some more research on this. It turns out timeline 'content' is
> the only BYTEA listed in the protocol docs, even though it just passes C
> strings to pq_sendbytes(), just like many other fields like the field
> above it, the timeline history filename. The proper fix is to change
> the code to return the timeline history file contents as TEXT instead of
> BYTEA.

In the light of what Michael wrote above, I don't think that this is really enough.

If the timeline history file can contain strings which "may not be made just of ASCII characters" this would probably
makethe client side assume that the content is being sent as TEXT encoded in client_encoding which again isn't true.
 
In the worst case this could lead to nasty decoding bugs on the client side which could even result in security
issues.

Since you probably can't tell in which encoding the aforementioned "recovery target name" was written to the timeline
historyfile, I agree with Michael that BYTEA is probably the sanest way to send this file.
 

IMO the best way out of this is to either really encode the content as BYTEA by passing it through byteaout() and by
thatescaping characters <0x20 and >0x7e, or to document that the file is being sent "as raw bytes that can be read as
'byteaEscape Format' by parsers compatible with byteain()" (this works because byteain() doesn't check whether bytes
<0x20or >0x7e are actually escaped).
 

Again, reading the raw bytes, either via byteain() or just as raw bytes, isn't really a problem and I don't want to
bringyou into a situation where the cure is worse than the disease.
 



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Kyotaro Horiguchi
Дата:
Сообщение: Re: Add Information during standby recovery conflicts
Следующее
От: "tsunakawa.takay@fujitsu.com"
Дата:
Сообщение: RE: [Patch] Optimize dropping of relation buffers using dlist