Removing support for COPY FROM STDIN in protocol version 2

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Removing support for COPY FROM STDIN in protocol version 2
Date: 2021-02-03 15:43:47
Message-ID: 9ec25819-0a8a-d51a-17dc-4150bb3cca3b@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

The server still supports the old protocol version 2. Protocol version 3
was introduced in PostgreSQL 7.4, so there shouldn't be many clients
around anymore that don't support it.

COPY FROM STDIN is particularly problematic with the old protocol,
because the end-of-copy can only be detected by the \. marker. So the
server has to read the input one byte at a time, and check for \. as it
goes. At [1], I'm working on a patch to change the way the encoding
conversion is performed in COPY FROM, so that we convert the data in
larger chunks, before scanning the input for line boundaries. We can't
do that safely in the old protocol.

I propose that we remove server support for COPY FROM STDIN with
protocol version 2, per attached patch. Even if we could still support
it, it would be a very rarely used and tested codepath, prone to bugs.
Perhaps we could remove support for the old protocol altogether, but I'm
not proposing that we go that far just yet.

[1]
https://www.postgresql.org/message-id/e7861509-3960-538a-9025-b75a61188e01%40iki.fi

- Heikki

Attachment Content-Type Size
0001-Remove-support-for-COPY-FROM-with-protocol-version-2.patch text/x-patch 13.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-02-03 16:00:52 Re: Removing support for COPY FROM STDIN in protocol version 2
Previous Message Stephen Frost 2021-02-03 15:33:57 Re: Key management with tests