Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x1GJg-0054jQ-1p for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Sep 2026 04:41:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x1GJd-003uuS-14 for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Sep 2026 04:41:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x1GJc-003uuJ-20 for pgsql-hackers@lists.postgresql.org; Tue, 01 Sep 2026 04:41:45 +0000 Received: from fout-b1-smtp.messagingengine.com ([202.12.124.144]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x1GJa-00000003PfZ-3KqN for pgsql-hackers@postgresql.org; Tue, 01 Sep 2026 04:41:43 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.stl.internal (Postfix) with ESMTP id 475511D00112; Tue, 1 Sep 2026 00:41:41 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-02.internal (MEProxy); Tue, 01 Sep 2026 00:41:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=burd.me; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1788237701; x=1788324101; bh=+8lf0QNfSvRKNC3nCBIbO6xD7HbBNdr0E0MxPoXvNPg=; b= DkEkz8ruL/loE5mlE0tOLy5VGHSE1R8DS0naTGL3U7IpnLaZ89X+4U2Mh8FGjQ08 kO1II/pY65W646/wM//221vPmrjkTxOkLuDTD8Gjeqt3mgp38qn0dhhXDIe8psh1 zs9EcDVM+xLw/qpY+3zM9ntraFar3qP5GxhAfxyX8vxCii71Onmo15nY+lRU42zZ jCBpgKTNCCj1pc4c5ewdxo1is3hf/jImPV+vLFfhKyiuLfVsQUEqrRIu7dd4Br9+ lIJBMD2ahsAR8vsMI8pQihj6fgZtfK393o2/qDxEwh16z11Gqisuqw4J/3etYd2/ jqOFiVvpmjaOW9BA1//e0w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1788237701; x= 1788324101; bh=+8lf0QNfSvRKNC3nCBIbO6xD7HbBNdr0E0MxPoXvNPg=; b=Y Jp1pAL+OzpJPifgVSj6IKQ7qCVYOmdYiY9JkMXyaOfz53RceYz3hmvhl7TSWxfRd oqubrKWCX0uBxL6pX6nLJ0HLWOkRo2w0glxKXrpumxznderBBkVuoAVDjYCzRvXQ pT5hgbtuMtkQidgY9+x5p1kA7GcBSQoR4O6Oe0AbqHcc6mkVuSTeaVBM6Y/ddHcN tCz39GY0IbZfHWiY/jsYguyonnMK1j2JCME7AHgZIme3mMUd2kVIJsRmtwOs6fvE QK/ByPll9+3g8cHnAwfLGpcxeD2M/+W4MQB3gObenZ2E+T91PQv1x2puRhmEHSCh m/0533rkN2UXFKGpIhfcQ== X-ME-Sender: X-ME-Proxy-Cause: dmFkZTGR/QlXCf7iSmAJersHCN0WqKwPIc5rQUIIinBoicHPdv/phyN2MsybAstrHqstyn ZzmsQIKZw8T6nFkVzq+uHscAfa+KxXCkrbo2X/nOCNY6w45D/5fZoZfpCW+vxWmzc6tKLt t26925Jb8izkqY07DtXCtHpCp/12TmmUXY+Qv8IVUHn8HiR5z4BWQHIGGKtAEXBYZ400cD O6+WT80s/s043I8Ees5JscOiCQuDt+fQv7dA3jwr+oaroLPmYbQL4TN+vu8tNC76gvoREg BqE513QxKJgUXPoUPCj615f6iIsqvZgiGZaSE3FZRi/AwScHb1D9wEjZjw1LCreJYvEAEQ EPnZR76SD+90oZnDCNUCCazxACHXHfVWtj78xXf4u9BTcWnQa5jKvoxiOkVYdJ/fls0SsF looZKPUXqBmXrGPMlxg1Nb1V386U+XsAauWa8JHsyAcTboQBqCOueJsURtV7kEgv+lmaAZ XMMMakWS7gZN0eB57h0L/RDN85cPODRzImfjk2WMKkPn50xQE/KD42px6d4M9UeVtShfi5 f3S0J9JQwK4LSHpXCrRs4u134hZAD48ZtC1R4rapjaFp9V3ScuyX0gil7r78sMwpo3gfbn jHQ28UDOZgl8RZAAP/cpnhO/UcBM+ckKzd/qXNP8srPYk7f8UHfDBwMpvvtw X-ME-Proxy: Feedback-ID: i675e48f3:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 50AF3700069; Tue, 1 Sep 2026 00:41:40 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 X-ThreadId: AQjVtvS5d0yk Date: Tue, 01 Sep 2026 00:41:20 -0400 From: "Greg Burd" To: "Nazir Bilal Yavuz" , "Nathan Bossart" Cc: "Manni Wood" , "KAZAR Ayoub" , "Neil Conway" , "Andrew Dunstan" , "Shinya Kato" , pgsql-hackers Message-Id: <78e736c8-7f4e-46c2-9fcf-a6839e393d64@app.fastmail.com> In-Reply-To: References: <43de48dc-701b-4735-881b-50bca6870f39@app.fastmail.com> Subject: Re: Speed up COPY FROM text/CSV parsing using SIMD Content-Type: text/plain Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hey Nathan, Nazir, I've also reproduced the error and confirmed the patch addresses it cleanly. For anyone following along, the mechanism: commit e0a3a3fd53 added CopyReadLineTextSIMDHelper, which refills the input buffer once fewer than sizeof(Vector8) bytes remain: if (copy_buf_len - input_buf_ptr < sizeof(Vector8)) /* reads ahead */ whereas scalar CopyReadLineText only refills when actually empty: if (input_buf_ptr >= copy_buf_len || need_data) That difference is the issue. CopyConvertBuf() deliberately tolerates an invalid byte sequence after the \. end-of-copy marker (see the comment near its convertedlen == 0 block), deferring the error. But CopyLoadInputBuf() raises it the moment input_reached_error is set. The SIMD read-ahead reaches that raise before the scalar loop has consumed \., so a file ending in \.\n errors out where the scalar path would have stopped cleanly at \. +1 on adding the reproducer as a test and calling it good. best, -greg