Re: Replication protocol doc fix - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: Replication protocol doc fix
Date
Msg-id 6fd5e90a90e25e8b420d183152b708ab23510201.camel@j-davis.com
Whole thread Raw
In response to Re: Replication protocol doc fix  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Replication protocol doc fix
Re: Replication protocol doc fix
List pgsql-hackers
On Mon, 2021-06-14 at 10:51 -0400, Robert Haas wrote:
> but if
> > > you use the extended query protocol, then the result is a
> > > hopeless
> > > mess, because the protocol is badly designed:
> > > 

After looking in more detail, I think I understand a bit better.
Clients don't differentiate between:

* A normal command, where you know that you've sent everything that you
will send. In this case, the client needs to send the Sync message in
order to get the ReadyForQuery message.

* A command that initiates CopyIn/CopyBoth, where you are going to send
more data after the command. In this case, sending the Sync eagerly is
wrong, and you can't pipeline more queries in the middle of
CopyIn/CopyBoth mode. Instead, the client should send Sync after
receiving an ErrorResponse, or after sending a CopyDone/CopyFail
(right?).

One thing I don't fully understand is what would happen if the client
issued the Sync as the *first* message in an extended-protocol series.

> > > But I think you're correct in saying that the discard-until-Sync
> > > behavior only happens if the extended query protocol is used, so
> > > I
> > > agree that the current text is wrong.
> > 
> > Should we just document how CopyBoth works with the simple query
> > protocol, or should we make it match the CopyIn docs?
> 
> I think it would make sense to make it match the CopyIn docs.
> Possibly
> the CopyOut docs should be made more similar as well.

I attached a doc patch that hopefully clarifies this point as well as
the weirdness around CopyIn/CopyBoth and the extended protocol. I
reorganized the sections, as well.

Regards,
    Jeff Davis



Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Python 3.10 breaks regression tests with traceback changes
Next
From: Tom Lane
Date:
Subject: Re: Replication protocol doc fix