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 1to9RO-006t4z-Fo for pgsql-committers@arkaria.postgresql.org; Fri, 28 Feb 2025 23:06:47 +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 1to9RP-000fyT-Hv for pgsql-committers@arkaria.postgresql.org; Fri, 28 Feb 2025 23:06:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1to9RP-000fyK-5k for pgsql-committers@lists.postgresql.org; Fri, 28 Feb 2025 23:06:45 +0000 Received: from mail-qk1-x732.google.com ([2607:f8b0:4864:20::732]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1to9RJ-000G7V-32 for pgsql-committers@lists.postgresql.org; Fri, 28 Feb 2025 23:06:45 +0000 Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-7c08b14baa9so231285085a.3 for ; Fri, 28 Feb 2025 15:06:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20230601.gappssmtp.com; s=20230601; t=1740784001; x=1741388801; darn=lists.postgresql.org; h=in-reply-to:autocrypt:content-language:from:references:cc:to :subject:user-agent:mime-version:date:message-id:from:to:cc:subject :date:message-id:reply-to; bh=arP+HPj83cxhjfi1wylmFEzrVaA6R7s8j0l4J1OZzdM=; b=e18JJYGWAvJgT99qsmCQtMcS0h17cMlqFVdv5sau4ZFPUTeaxBMgmCwPV7LNPNvkTk qvR+fTRvnYTUh2beHSVNTns6/upBor6bm1XI5D8GmqaH22Rjs1o/UlisZ5LDPWeDDf/o HjiHnRwH3tNabgzS7Et3MlHczHWXqtLXeP5YTiaaS9IWne9L7CIcMKfXwcKc/IiMqOrF wP0KNX8q7Z/DhC4adwiNatvHGwF8+YlJIVCt6YP2W4HR8BLk764R4eQv+HWGE9RipUQd G5CTvjE1b1oiIT0TYIyXGhlWRRg2HfMv+7E4LI101BJcLiDFI4jq1+ftZaeSjaRsmKOq GDmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740784001; x=1741388801; h=in-reply-to:autocrypt:content-language:from:references:cc:to :subject:user-agent:mime-version:date:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=arP+HPj83cxhjfi1wylmFEzrVaA6R7s8j0l4J1OZzdM=; b=oFcT+SW958H15li5JhMHJ+xdLQ6s87tcW37gEpBUjaCrEmdZ3qWYcgYvjjZo6ilxfU m7Q45B8dnvItIoHZJPt69jFWY9fL/OQV38JSV+TLrUu1TDnQ7YgF8etIYpkTd8p8x6gS KKA5a8fHrK/ZHxDFFy+O7Oap8k0bK3ZhK2baK2/XAlCP84Xmlpzq4Yp8vjUHby4HcFEB ODWjxO2ARC53tOB9v544gnQMg0Niv4jpco6ogajX/EoQcyk83FOBWSEdjt+sYwIbwWW9 vqovncG4pKw10iTWhQndnZDGls6owAgvARu8/G/HvPVolUihYV84NvqryGoxEJZdmhqi MAww== X-Forwarded-Encrypted: i=1; AJvYcCXCiQpSAGxa5j9p8FwIp/U9E/j/4aEH6FiFTFOqMDyfEWf7NqJ10Pg1mDcwOGz4M7BXDthD1ofrb52RPTcx52Ps@lists.postgresql.org X-Gm-Message-State: AOJu0Yyq3mdIHcnUzpddOrvjjLY39ibvi6U8RBK/fy73FEg+3KP9OiYb je9Rciwg1bQBPDxagTvZWeYK49xSuPAEJi4R3r9jMN9tMvka8Ue3/kEURpYCZX4= X-Gm-Gg: ASbGncvU32txhldXUMv1VQUrhDOf1J7p8jIwDHcpruBK3/bZMVZUC+cqA0psdv9utm6 ztElOQGb1kE23t1HFotvPco0ute/yIjpzgSGBVpFTjLwhMoO9sjZWoRO+ojljoMKA8yFcSxi2w8 E9+jrXWtE8z/XECNkmt5W/d+QzEFW3xvhkKFDTn4PsTV3ooVfPJfM7fh9FbQfdsNXAQ6QqLiToe UggrXkxOLNT1/D0fn60pXeTpLEPgX4Us3rPpAwZw8ivD10+hNgGfZnFs9L+C7wWDs+mj2DwSHjD IkCCjJxbh84xmGn37tosgVf6rtRJ0Rtb1GDwzpgQF/NgbjuREKjZA8Y= X-Google-Smtp-Source: AGHT+IHwgv9kovYW0SZh1RzfS3Ha0L/rIQxEtsEolqi5nQgVdydKJWGpQ9FjHDaXiMtZgylP2i90KA== X-Received: by 2002:a05:620a:2941:b0:7c0:a550:89b5 with SMTP id af79cd13be357-7c39c2a881fmr745309285a.0.1740784000710; Fri, 28 Feb 2025 15:06:40 -0800 (PST) Received: from ?IPV6:2605:a601:a681:6b00::1cb? ([2605:a601:a681:6b00::1cb]) by smtp.googlemail.com with ESMTPSA id af79cd13be357-7c36fee963esm302249785a.23.2025.02.28.15.06.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Feb 2025 15:06:40 -0800 (PST) Content-Type: multipart/alternative; boundary="------------8PWEjfVTZgjiV0LcUEt2Iz0f" Message-ID: <85aef1c9-f642-41cf-bc9a-014599f7a214@dunslane.net> Date: Fri, 28 Feb 2025 18:06:39 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: pgsql: Refactor COPY FROM to use format callback functions. To: Masahiko Sawada , Sutou Kouhei Cc: msawada@postgresql.org, pgsql-committers@lists.postgresql.org References: <20250301.071641.1257013931056303227.kou@clear-code.com> From: Andrew Dunstan Content-Language: en-US Autocrypt: addr=andrew@dunslane.net; keydata= xsBNBE7KWFkBCAClridxur2AIc7eW2AR7izbfp3EnNefie2HbLF0izW5Ik5UjX2HBXBx4syI gY6b0ugohXrr274+baoAlvSb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3WfpD4lHMOR/Oc3/8mScEF84rF2jXbsFgelWnbPWAvXY+pD0dXOFRkagGmC/viwBDqq5b 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. --------------8PWEjfVTZgjiV0LcUEt2Iz0f Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2025-02-28 Fr 5:39 PM, Masahiko Sawada wrote: > On Fri, Feb 28, 2025 at 2:16 PM Sutou Kouhei wrote: >> Hi, >> >> Thanks for following up the patch! >> >> In >> "Re: pgsql: Refactor COPY FROM to use format callback functions." on Fri, 28 Feb 2025 12:56:19 -0800, >> Masahiko Sawada wrote: >> >>> Right. I've attached the updated patch. >> In general, this approach will work but could you keep >> the same signature for backward compatibility? >> >>> --- a/src/backend/commands/copyfromparse.c >>> +++ b/src/backend/commands/copyfromparse.c >>> +bool >>> +NextCopyFromRawFields(CopyFromState cstate, char ***fields, int *nfields, bool is_csv) >>> +{ >>> + return NextCopyFromRawFieldsInternal(cstate, fields, nfields, is_csv); >>> +} >> NextCopyFromRawFields() uses >> NextCopyFromRawFields(CopyFromState cstate, char ***fields, >> int *nfields) (no "bool is_csv") before we remove it. So >> could you use the no "bool is_csv" signature for backward >> compatibility? >> >> bool >> NextCopyFromRawFields(CopyFromState cstate, char ***fields, int *nfields) >> { >> return NextCopyFromRawFieldsInternal(cstate, fields, nfields, cstate->opts.csv_mode); >> } > I like this idea. > >> >>> @@ -738,6 +742,15 @@ CopyReadBinaryData(CopyFromState cstate, char *dest, int nbytes) >>> /* >>> * Read raw fields in the next line for COPY FROM in text or csv mode. >>> * Return false if no more lines. >>> + */ >>> +bool >>> +NextCopyFromRawFields(CopyFromState cstate, char ***fields, int *nfields, bool is_csv) >>> +{ >>> + return NextCopyFromRawFieldsInternal(cstate, fields, nfields, is_csv); >>> +} >>> + >>> +/* >>> + * Workhorse for NextCopyFromRawFields(). >> It may be better that we don't split docs for >> NextCopyFromRawFields() and >> NextCopyFromRawFieldsInternal(). How about referring the >> NextCopyFromRawFieldsInternal() doc from the >> NextCopyFromRawFields() doc something like the following? >> >> /* >> * See NextCopyFromRawFieldsInternal() for details. >> */ >> bool >> NextCopyFromRawFields(...) >> { >> ... >> } >> >> /* >> * Workhorse for NextCopyFromRawFields(). >> * >> * Read raw fields ... >> * >> * ... >> */ >> static pg_attribute_always_inline bool >> NextCopyFromRawFieldsInternal() >> { >> ... >> } >> > Agreed. > > I've updated the patch. I'm going to push it, barring any objections > and further comments. > I'm OK either way - I have made changes to adapt to the API change, and tested them. cheers andrew -- Andrew Dunstan EDB:https://www.enterprisedb.com --------------8PWEjfVTZgjiV0LcUEt2Iz0f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 2025-02-28 Fr 5:39 PM, Masahiko Sawada wrote:
On Fri, Feb 28, 2025 at 2:16 PM Sutou Kouhei <kou@clear-code.com> wrote:
Hi,

Thanks for following up the patch!

In <CAD21AoBA414Q76LthY65NJfWbjOxXn1bdFFsD_NBhT2wPUS1SQ@mail.gmail.com>
  "Re: pgsql: Refactor COPY FROM to use format callback functions." on Fri, 28 Feb 2025 12:56:19 -0800,
  Masahiko Sawada <sawada.mshk@gmail.com> wrote:

Right. I've attached the updated patch.
In general, this approach will work but could you keep
the same signature for backward compatibility?

--- a/src/backend/commands/copyfromparse.c
+++ b/src/backend/commands/copyfromparse.c

        
+bool
+NextCopyFromRawFields(CopyFromState cstate, char ***fields, int *nfields, bool is_csv)
+{
+     return NextCopyFromRawFieldsInternal(cstate, fields, nfields, is_csv);
+}
NextCopyFromRawFields() uses
NextCopyFromRawFields(CopyFromState cstate, char ***fields,
int *nfields) (no "bool is_csv") before we remove it. So
could you use the no "bool is_csv" signature for backward
compatibility?

bool
NextCopyFromRawFields(CopyFromState cstate, char ***fields, int *nfields)
{
        return NextCopyFromRawFieldsInternal(cstate, fields, nfields, cstate->opts.csv_mode);
}
I like this idea.


@@ -738,6 +742,15 @@ CopyReadBinaryData(CopyFromState cstate, char *dest, int nbytes)
 /*
  * Read raw fields in the next line for COPY FROM in text or csv mode.
  * Return false if no more lines.
+ */
+bool
+NextCopyFromRawFields(CopyFromState cstate, char ***fields, int *nfields, bool is_csv)
+{
+     return NextCopyFromRawFieldsInternal(cstate, fields, nfields, is_csv);
+}
+
+/*
+ * Workhorse for NextCopyFromRawFields().
It may be better that we don't split docs for
NextCopyFromRawFields() and
NextCopyFromRawFieldsInternal(). How about referring the
NextCopyFromRawFieldsInternal() doc from the
NextCopyFromRawFields() doc something like the following?

/*
 * See NextCopyFromRawFieldsInternal() for details.
 */
bool
NextCopyFromRawFields(...)
{
        ...
}

/*
 * Workhorse for NextCopyFromRawFields().
 *
 * Read raw fields ...
 *
 * ...
 */
static pg_attribute_always_inline bool
NextCopyFromRawFieldsInternal()
{
        ...
}

Agreed.

I've updated the patch. I'm going to push it, barring any objections
and further comments.



I'm OK either way - I have made changes to adapt to the API change, and tested them.


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com
--------------8PWEjfVTZgjiV0LcUEt2Iz0f--