Fix hangs in COPY FROM (FORMAT text). The SIMD path for this command reads ahead via CopyLoadInputBuf() whenever fewer than sizeof(Vector8) bytes remain in the input buffer, even if those bytes hold a complete end-of-copy marker. If the input is a pipe whose writer has sent the marker but not closed the pipe, that read blocks, and COPY waits for data it will never use. The scalar loop asks only for the bytes it needs, so it stops at the marker without reading any further.
To fix, teach CopyLoadInputBuf() to decline a speculative load when the caller's remaining bytes contain a backslash, which in text mode might begin such a marker. (CSV mode doesn't treat \. as special, so it is unaffected.) The SIMD path then hands those bytes to the scalar loop, as it already does when a load comes up short. Checking for the marker in the SIMD helper itself would be more direct, but a call there costs the compiler registers on every line, which measurably slowed COPY of short lines in testing. Oversight in commit e0a3a3fd53. Author: Nazir Bilal Yavuz <[email protected]> Reviewed-by: Greg Burd <[email protected]> Discussion: https://postgr.es/m/CAN55FZ1qFb4Yo3-MWeQfGQnu1_Ksx4xcFC2m3hyw8a--%2BeHQYQ%40mail.gmail.com Backpatch-through: 19 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/d1895a11c8f1b19b3fe0db45cc10a9d26c56bc8c Modified Files -------------- src/backend/commands/copyfromparse.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
