From 1006dac44cb208a8b164f2553772de942e79c2d4 Mon Sep 17 00:00:00 2001 From: Nazir Bilal Yavuz Date: Wed, 11 Mar 2026 14:04:55 +0300 Subject: [PATCH v13 2/2] Upcoming improvements --- src/backend/commands/copyfromparse.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/backend/commands/copyfromparse.c b/src/backend/commands/copyfromparse.c index 9f1256353c4..55159b0122c 100644 --- a/src/backend/commands/copyfromparse.c +++ b/src/backend/commands/copyfromparse.c @@ -1333,8 +1333,6 @@ CopyReadLine(CopyFromState cstate, bool is_csv) static bool CopyReadLineTextSIMDHelper(CopyFromState cstate, bool is_csv, bool *temp_hit_eof, int *temp_input_buf_ptr) { - char quotec = '\0'; - char escapec = '\0'; char *copy_input_buf; int input_buf_ptr; int copy_buf_len; @@ -1343,16 +1341,15 @@ CopyReadLineTextSIMDHelper(CopyFromState cstate, bool is_csv, bool *temp_hit_eof bool first_vector = true; Vector8 nl = vector8_broadcast('\n'); Vector8 cr = vector8_broadcast('\r'); - Vector8 bs = vector8_broadcast('\\'); - Vector8 quote = vector8_broadcast(0); + Vector8 bs_or_quote = vector8_broadcast('\\'); Vector8 escape = vector8_broadcast(0); if (is_csv) { - quotec = cstate->opts.quote[0]; - escapec = cstate->opts.escape[0]; + char quotec = cstate->opts.quote[0]; + char escapec = cstate->opts.escape[0]; - quote = vector8_broadcast(quotec); + bs_or_quote = vector8_broadcast(quotec); if (quotec != escapec) { unique_escapec = true; @@ -1397,18 +1394,10 @@ CopyReadLineTextSIMDHelper(CopyFromState cstate, bool is_csv, bool *temp_hit_eof /* Load a chunk of data into a vector register */ vector8_load(&chunk, (const uint8 *) ©_input_buf[input_buf_ptr]); - if (is_csv) - { - match = vector8_or(vector8_eq(chunk, nl), vector8_eq(chunk, cr)); - match = vector8_or(match, vector8_eq(chunk, quote)); - if (unique_escapec) - match = vector8_or(match, vector8_eq(chunk, escape)); - } - else - { - match = vector8_or(vector8_eq(chunk, nl), vector8_eq(chunk, cr)); - match = vector8_or(match, vector8_eq(chunk, bs)); - } + match = vector8_or(vector8_eq(chunk, nl), vector8_eq(chunk, cr)); + match = vector8_or(match, vector8_eq(chunk, bs_or_quote)); + if (unique_escapec) + match = vector8_or(match, vector8_eq(chunk, escape)); /* Check if we found any special characters */ if (vector8_is_highbit_set(match)) -- 2.47.3