Removing support for COPY FROM STDIN in protocol version 2 - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Removing support for COPY FROM STDIN in protocol version 2
Date
Msg-id 9ec25819-0a8a-d51a-17dc-4150bb3cca3b@iki.fi
Whole thread Raw
Responses Re: Removing support for COPY FROM STDIN in protocol version 2
List 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

pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: Key management with tests
Next
From: Tom Lane
Date:
Subject: Re: Removing support for COPY FROM STDIN in protocol version 2