Re: Perform COPY FROM encoding conversions in larger chunks - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Perform COPY FROM encoding conversions in larger chunks
Date
Msg-id 21e3331f-d4f8-4750-d004-74a5abae42ec@iki.fi
Whole thread Raw
In response to Re: Perform COPY FROM encoding conversions in larger chunks  (John Naylor <john.naylor@enterprisedb.com>)
Responses Re: Perform COPY FROM encoding conversions in larger chunks
List pgsql-hackers
On 02/02/2021 23:42, John Naylor wrote:
> Although a new patch is likely forthcoming, I did take a brief look and 
> found the following:
> 
> 
> In copyfromparse.c, this is now out of date:
> 
>   * Read the next input line and stash it in line_buf, with conversion to
>   * server encoding.
> 
> 
> One of your FIXME comments seems to allude to this, but if we really 
> need a difference here, maybe it should be explained:
> 
> +#define INPUT_BUF_SIZE 65536 /* we palloc INPUT_BUF_SIZE+1 bytes */
> 
> +#define RAW_BUF_SIZE 65536 /* allocated size of the buffer */

We do in fact still need the +1 for the NUL terminator. It was missing 
from the last patch version, but that was wrong; my fuzz testing 
actually uncovered a bug caused by that. Fixed.

Attached are new patch versions. The first patch is same as before, but 
rebased, pgindented, and with a couple of tiny fixes where conversion 
functions were still missing the "if (noError) break;" checks.

I've hacked on the second patch more, doing more refactoring and 
commenting for readability. I think it's in pretty good shape now.

- Heikki

Attachment

pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: GlobalVisIsRemovableFullXid() vs GlobalVisCheckRemovableXid()
Next
From: Zhihong Yu
Date:
Subject: Re: jsonb_array_elements_recursive()