Re: Removing support for COPY FROM STDIN in protocol version 2

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Removing support for COPY FROM STDIN in protocol version 2
Date: 2021-03-04 08:59:41
Message-ID: 8a174f9b-59e4-e231-5b66-1f01b314882a@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 04/03/2021 01:32, Tom Lane wrote:
> Patched psql, trying to connect to a 7.3 server, reports this:
>
> $ psql -h ...
> psql: error: connection to server at "sss2" (192.168.1.3), port 5432 failed: FATAL: unsupported frontend protocol
>
> $
>
> Conversely, 7.3 psql trying to connect to a patched server reports:
>
> $ psql -h ...
> psql: FATAL: unsupported frontend protocol 2.0: server supports 3.0 to 3.0
>
> $
>
> I'm not sure where the extra newlines are coming from, and it seems
> unlikely to be worth worrying over. This behavior is good enough for me.

fe-connect.c appends a newline for any errors in pre-3.0 format:

>
> /*
> * The postmaster typically won't end its message with a
> * newline, so add one to conform to libpq conventions.
> */
> appendPQExpBufferChar(&conn->errorMessage, '\n');

That comment is wrong. The postmaster *does* end all its error messages
with a newline. This changed in commit 9b4bfbdc2c in 7.2. Before that,
postmaster had its own function, PacketSendError(), to send error
messages, and it did not append a newline. Commit 9b4bfbdc2 changed
postmaster to use elog(...) like everyone else, and elog(...) has always
appended a newline. So I think this extra newline that libpq adds is
needed if you try to connect to PostgreSQL 7.1 or earlier. I couldn't
commpile a 7.1 server to verify this, though.

I changed that code in libpq to check if the message already has a
newline, and only append one if it doesn't. This fixes the extra newline
when connecting with new libpq to a 7.3 server (and in the fork failure
message).

> I concur that 0001 attached is committable. I have not looked at
> your 0002, though.

Removed the entry from nls.mk, and pushed 0001. Thanks!

- Heikki

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2021-03-04 09:05:10 Re: Parallel INSERT (INTO ... SELECT ...)
Previous Message Georgios 2021-03-04 08:43:51 Re: Shared memory size computation oversight?