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.94.2) (envelope-from ) id 1to6K8-0063wU-LE for pgsql-committers@arkaria.postgresql.org; Fri, 28 Feb 2025 19:47:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1to6K9-00EFph-P4 for pgsql-committers@arkaria.postgresql.org; Fri, 28 Feb 2025 19:47:04 +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.94.2) (envelope-from ) id 1to6K9-00EFoS-AE for pgsql-committers@lists.postgresql.org; Fri, 28 Feb 2025 19:47:04 +0000 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1to6K5-000Dum-1C for pgsql-committers@lists.postgresql.org; Fri, 28 Feb 2025 19:47:02 +0000 Received: by mail-qk1-x734.google.com with SMTP id af79cd13be357-7c0a974d433so328715385a.1 for ; Fri, 28 Feb 2025 11:47:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20230601.gappssmtp.com; s=20230601; t=1740772020; x=1741376820; darn=lists.postgresql.org; h=in-reply-to:autocrypt:content-language:from:references:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=bdRfiW6hjg3R52PvR/h/PAC8wKmEfZv7mDDMI2HLZrY=; b=fs+s8zy8XkbcCwpXlvp5+3myPrdSG+j2siLBNCYq0LH2DlRkpa+NiE4T6DbVjnhgsK QGDMx575M4piHfgEftEZxKcT74HQmfICJCHwFytTHuAD85L647XVG0gUo/bM+uUdmFPs s3N8bSXZr5IEmd/vsXMaMKofPht2c6xDYgFkBinvxrCCfmpsLD+nIzovb4sNScu1/Zsi LH4KibSRlNIgcQdO2jcd8lNdFXUdfgXL06wvlFgMgrs5bQaJmGYAp3QYvIjnfTABut4C A9y7u9rPcT6lwEaqSfUNFMK216GpgGqyFxX4rYDbRutGDtF9X6MCu1B3kgdSlUag9O9n rz9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740772020; x=1741376820; h=in-reply-to:autocrypt:content-language:from:references:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=bdRfiW6hjg3R52PvR/h/PAC8wKmEfZv7mDDMI2HLZrY=; b=dQVZ7ERf7fBXC5CozLRsWvIT+s1YAp7sC5hfSEs/gkGKwaNzI55qDfPlBdrubeAraH csvQ5ly1qEaIRmnn010kz6JBdQRTML5tOk7WwHSZlEfWXe0K/fHYnKfzFFF4PbSQpKSa Cd0iOaK8Q2+YnFCzYFDRwwCQJz+fwmI91Sm9hCJ07W0awdszua01s+sQ9eH9Lvg4IC+I UMrH/86GYcX+TzKxVy468IMBUYTGscZpdBNcb3Jx/LaP0nACcNA9YzHzqdn31nmfn1qm l7lfqPtSjL357fi1NfpYErq2/d6JHtSL2jBxxj4+xxIoaOe0ToDcywfrHFVzNomTSf7h 2Prw== X-Forwarded-Encrypted: i=1; AJvYcCXAOabo/3tePCYvUX/YrSF2tymlnz1dnGSZVxTDy24elOPjr6QVB2qqRAaXTF6FNvKhR0DwykGMep53TdN3tr5n@lists.postgresql.org X-Gm-Message-State: AOJu0Yy83AkNZxASkXBgTNyCAC6XM7PvdPM0WkcrSDqRg0ZMlJb4Q2wZ 00h/lLvcDI3m5xeBnqTs/04XKDcdGR6XurdtKzTp/cCZsFSHNHwkeBWScyY75aK5YK5PccQu/zb 7 X-Gm-Gg: ASbGnctUzba8KUB9LSMB915zFUAuyrUt5sD0Hh49f/IuQMvD+vovidpofgWvPbKbZ52 fkv6RhWEEVnLxeH7i8wvyaBUY+HybNZ1qbsu0e5bil5UTTLIvCqIC4NQRprNkmcEFbSCwb7XEdU +V30+n6KcnaqH78zF41R7/MS4qljJHyREYulOn6sktFo1wx+x3DcHxelmb8p6ze6Vk9WkrHk/J8 fdRq+TPX7AXzJdSM3DJd0C5BLe0GjW7Sm6QWfm757i2M1xDp+Ph02cYV4YEi2rlFh6gUJtdoYyd JFwWgx0UjQVp8OVxPSzvIzUwMxeidEg0yBcL X-Google-Smtp-Source: AGHT+IG9QVniU7bGNmIFt2vz+rMeTcU1if3zWIpqHINx07/YANPgPjZtqrFBqE2LZQ4uylhIVEQYzA== X-Received: by 2002:a05:620a:178a:b0:7b1:44ee:644d with SMTP id af79cd13be357-7c29f423b19mr1338232885a.10.1740772019940; Fri, 28 Feb 2025 11:46:59 -0800 (PST) Received: from ?IPV6:2605:a601:a681:6b00::1cb? ([2605:a601:a681:6b00::1cb]) by smtp.googlemail.com with ESMTPSA id 6a1803df08f44-6e8972b9aa8sm25394386d6.0.2025.02.28.11.46.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Feb 2025 11:46:59 -0800 (PST) Content-Type: multipart/alternative; boundary="------------6gTkJ3RQv3nBOATcg0ulvwd0" Message-ID: <5c7e1ac8-5083-4c08-af19-cb9ade2f16ce@dunslane.net> Date: Fri, 28 Feb 2025 14:46:58 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pgsql: Refactor COPY FROM to use format callback functions. To: Masahiko Sawada , pgsql-committers@lists.postgresql.org References: From: Andrew Dunstan Content-Language: en-US Autocrypt: addr=andrew@dunslane.net; keydata= xsBNBE7KWFkBCAClridxur2AIc7eW2AR7izbfp3EnNefie2HbLF0izW5Ik5UjX2HBXBx4syI gY6b0ugohXrr274+baoAlvSbq6cAoQuEVrk5IZFzt20b1Xkx65FwGSEj526yiKLocqkJceSq Xr9xcA5SGY+FZv441chh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qq5b 5tk76kKmUbZxABEBAAHCwHwEGAEIACYCGwwWIQTkPlhGHfx8v0RpFaWZ+n/LWfw7gQUCZFlx 5wUJGVGAjgAKCRCZ+n/LWfw7gf+iB/4g8CPY5jihf5r/8EsoIGe2H+dpVmpPF8YGBzTIvCz/ fQoOq8AX/pE76QEuFnFZWfjw+wgBXgCVmkox2Eflkk6z4ND3pcwGZ6CfCxTQCDk/dij+2DQ4 6bmDCy/sBgcbz9mTpoLC11HLoPae6YN9nBNQRZDcEFEu54OaVOqlIdbA6m+POIBCXZdHOFc0 WoDTgxHRzC1jgQNidyd6tKqcsVJs0dzF0oKTmFFmUAqTdJO12LBuNA1rlqrR3EtpYk8B/wtS 5dIMD7Q8hwQpL+4C6GNpb6ZKnPkLi47pDOLhz2qBrqN+rqUEsT3YnExYpzj5yOBi+FlmV1Hw 49QYe1sn2ZPs In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------6gTkJ3RQv3nBOATcg0ulvwd0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2025-02-28 Fr 1:31 PM, Masahiko Sawada wrote: > Refactor COPY FROM to use format callback functions. > > This commit introduces a new CopyFromRoutine struct, which is a set of > callback routines to read tuples in a specific format. It also makes > COPY FROM with the existing formats (text, CSV, and binary) utilize > these format callbacks. > > This change is a preliminary step towards making the COPY FROM command > extensible in terms of input formats. > > Similar to 2e4127b6d2d, this refactoring contributes to a performance > improvement by reducing the number of "if" branches that need to be > checked on a per-row basis when sending field representations in text > or CSV mode. The performance benchmark results showed ~5% performance > gain in text or CSV mode. > > Author: Sutou Kouhei > Reviewed-by: Masahiko Sawada > Reviewed-by: Michael Paquier > Reviewed-by: Andres Freund > Reviewed-by: Tomas Vondra > Reviewed-by: Junwang Zhao > Discussion:https://postgr.es/m/20231204.153548.2126325458835528809.kou@clear-code.com This patch has completely broken the file_textarray fdw, which uses NextCopyFromRawFields(). Removing that from API is not a good thing. cheers andrew -- Andrew Dunstan EDB:https://www.enterprisedb.com --------------6gTkJ3RQv3nBOATcg0ulvwd0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit


On 2025-02-28 Fr 1:31 PM, Masahiko Sawada wrote:
Refactor COPY FROM to use format callback functions.

This commit introduces a new CopyFromRoutine struct, which is a set of
callback routines to read tuples in a specific format. It also makes
COPY FROM with the existing formats (text, CSV, and binary) utilize
these format callbacks.

This change is a preliminary step towards making the COPY FROM command
extensible in terms of input formats.

Similar to 2e4127b6d2d, this refactoring contributes to a performance
improvement by reducing the number of "if" branches that need to be
checked on a per-row basis when sending field representations in text
or CSV mode. The performance benchmark results showed ~5% performance
gain in text or CSV mode.

Author: Sutou Kouhei <kou@clear-code.com>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Tomas Vondra <tomas.vondra@enterprisedb.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://postgr.es/m/20231204.153548.2126325458835528809.kou@clear-code.com



This patch has completely broken the file_textarray fdw, which uses NextCopyFromRawFields(). Removing that from API is not a good thing.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com
--------------6gTkJ3RQv3nBOATcg0ulvwd0--