libpq: pipeline mode might desynchronize client and server

From: Ivan Trofimov <i(dot)trofimow(at)yandex(dot)ru>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: libpq: pipeline mode might desynchronize client and server
Date: 2023-11-22 00:13:46
Message-ID: 1efe6f16-30f1-8dd2-7d5a-a6acc4203cc1@yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi!

This is a follow up on
https://www.postgresql.org/message-id/17948-fcace7557e449957@postgresql.org.

Libpq in pipeline mode considers '< 2TDCEZ' a sufficient response to
'> BDESS', when according to specification one more 'Z' is expected.
This leads to client <-> server desynchronization, when libpq parses the
very next message server sends (which is Z, as expected).

A bit more context and a MRE:
https://github.com/itrofimow/libpq_protocol_desync

I'm pretty sure that this branch
https://github.com/postgres/postgres/blob/3af101ce8be8eeb0e8adc61e293b5d12989f68be/src/interfaces/libpq/fe-exec.c#L2124
should be adjusted to handle the case and do not match error response
against sync query.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2023-11-22 01:14:38 Re: [BUGS] \copy produces CSV output that cannot be read by \copy
Previous Message Tom Lane 2023-11-21 18:34:10 Re: ERROR: value out of range: underflow in numeric log calculation