pg_recvlogical broken in back branches

From: Euler Taveira <euler(at)timbira(dot)com(dot)br>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: noah(at)leadboat(dot)com
Subject: pg_recvlogical broken in back branches
Date: 2018-04-17 06:01:33
Message-ID: CAHE3wgg8b-79jC626FhryirKZkJUP+Z4NQK10=1CSdFMVNHRgw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

An issue [1] reported that pg_recvlogical emitted an error in 9.6.8. I
confirmed that it was broken in recent minor versions (9.6.8, 9.5.12,
9.4.17 -- using same server/client version). It was broken by commit
582edc369cdbd348d68441fc50fa26a84afd0c1a and its siblings.

$ postgres --version
postgres (PostgreSQL) 9.6.8
$ pg_recvlogical --version
pg_recvlogical (PostgreSQL) 9.6.8
$ pg_recvlogical -d postgres --slot test_slot --create-slot -P test_decoding
ERRO: syntax error
pg_recvlogical: could not clear search_path: ERRO: syntax error

Replication protocol supports queries since 10 so the code seems correct to it.

* The capacity to run normal SQL queries was added in PostgreSQL
* 10, so the search path cannot be changed (by us or attackers) on
* earlier versions.

It seems version >= 10 should be checked in old clients too. Version
9.6.8 could not connect to 9.4.17.

$ pg_recvlogical --version
pg_recvlogical (PostgreSQL) 9.6.8

$ psql -p 9994 postgres
psql (9.6.8, servidor 9.4.17)
Digite "help" para ajuda.
$ pg_recvlogical -p 9994 -d postgres --slot test_slot --create-slot -P
test_decoding
pg_recvlogical: could not clear search_path: ERRO: syntax error

A proposed fix is attached. It should be applied to 9.4, 9.5, 9.6, and
10. (Although, client version 10 can connect to server version 10,
client version 10 can't connect to server version 9.6.)

Comments?

[1] https://github.com/eulerto/wal2json/issues/61

--
Euler Taveira Timbira -
http://www.timbira.com.br/
PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento

Attachment Content-Type Size
recvl.patch text/x-patch 611 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-04-17 06:38:13 Re: pg_recvlogical broken in back branches
Previous Message Michael Paquier 2018-04-17 03:28:58 Re: SHOW ALL does not honor pg_read_all_settings membership