Re: Force lookahead in COPY FROM parsing

From: John Naylor <john(dot)naylor(at)enterprisedb(dot)com>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Force lookahead in COPY FROM parsing
Date: 2021-03-04 14:37:50
Message-ID: CAFBsxsGrmVaLNY8AHfSVzqCa6e3KeR6uZia0Cozb8FQMpM07CA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 4, 2021 at 5:13 AM Heikki Linnakangas <hlinnaka(at)iki(dot)fi> wrote:
>
> I posted this earlier at
>
https://www.postgresql.org/message-id/9ec25819-0a8a-d51a-17dc-4150bb3cca3b@iki.fi
,
> and that led to removing FE/BE protocol version 2 support. That's been
> committed now, so here's COPY FROM patch again, rebased.

Looks good to me. Just a couple minor things:

+ * Look at the next character. If we're at EOF, c2 will wind
+ * up as '\0' because of the guaranteed pad of raw_buf.
*/
- IF_NEED_REFILL_AND_NOT_EOF_CONTINUE(0);
-
- /* get next char */
c = copy_raw_buf[raw_buf_ptr];

The new comment seems copy-pasted from the c2 statements further down.

- if (raw_buf_ptr >= copy_buf_len || need_data)
+#define COPY_READ_LINE_LOOKAHEAD 4
+ if (raw_buf_ptr + COPY_READ_LINE_LOOKAHEAD >= copy_buf_len)

Is this #define deliberately put down here rather than at the top of the
file?

- * of the buffer and then we load more data after that. This case occurs
only
- * when a multibyte character crosses a bufferload boundary.
+ * of the buffer and then we load more data after that.

Is the removed comment really invalidated by this patch? I figured it was
something not affected until the patch to do the encoding conversion in
larger chunks.

--
John Naylor
EDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message gkokolatos 2021-03-04 14:47:18 Re: New default role- 'pg_read_all_data'
Previous Message walker 2021-03-04 14:34:38 011_crash_recovery.pl failes using wal_block_size=16K