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 1tFOUn-00ClrU-Tw for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Nov 2024 02:06:38 +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 1tFOUm-00AxJU-9d for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Nov 2024 02:06:36 +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 1tFOUl-00AxIz-76 for pgsql-hackers@lists.postgresql.org; Mon, 25 Nov 2024 02:06:35 +0000 Received: from mail.clear-code.com ([2401:2500:102:3037:153:126:203:179]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tFOUg-003cTN-CJ for pgsql-hackers@postgresql.org; Mon, 25 Nov 2024 02:06:32 +0000 Received: from localhost (unknown [IPv6:2404:7a80:9f01:f500:af1b:fa00:91d6:aaa9]) by mail.clear-code.com (Postfix) with ESMTPSA id 16EF4DD890; Mon, 25 Nov 2024 11:06:23 +0900 (JST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.clear-code.com 16EF4DD890 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=clear-code.com; s=default; t=1732500383; bh=7U6TdhpLzCK38pYrmsoctxdwXus0XSHWZuYbzN6laXg=; h=Date:To:Cc:Subject:From:In-Reply-To:References:From; b=YGDMENQu1OYm8+vX6/pe8fPn7qs30+aB2IDUfVJlJNfVgwV4JHV/jbJrUOp9yrxie 0Bm0NmpaZ5U5S27724BilJ47m8IuuDWlEQdCwNZy12LxK0P73Izxbq+IldLbEEcNwn o7Fvbx6qoaqbAh8HtSPaoIUhtWtVKAcRgFhN8Epc= Date: Mon, 25 Nov 2024 11:06:20 +0900 (JST) Message-Id: <20241125.110620.313152541320718947.kou@clear-code.com> To: sawada.mshk@gmail.com Cc: michael@paquier.xyz, pgsql-hackers@postgresql.org Subject: Re: Make COPY format extendable: Extract COPY TO format implementations From: Sutou Kouhei In-Reply-To: References: <20241121.115531.1600295431613712107.kou@clear-code.com> X-Mailer: Mew version 6.8 on Emacs 29.4 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spamd-Result: default: False [1.40 / 999.00]; MID_CONTAINS_FROM(1.00)[]; MV_CASE(0.50)[]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; TAGGED_RCPT(0.00)[]; ASN(0.00)[asn:2518, ipnet:2404:7a80::/29, country:JP]; FREEMAIL_TO(0.00)[gmail.com]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_NONE(0.00)[]; RCPT_COUNT_THREE(0.00)[3] X-Rspamd-Server: mail.clear-code.com X-Rspamd-Action: no action X-Rspamd-Queue-Id: 16EF4DD890 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, In "Re: Make COPY format extendable: Extract COPY TO format implementations" on Fri, 22 Nov 2024 13:01:06 -0800, Masahiko Sawada wrote: >> @@ -1237,7 +1219,7 @@ CopyReadLine(CopyFromState cstate, bool is_csv) >> /* >> * CopyReadLineText - inner loop of CopyReadLine for text mode >> */ >> -static pg_attribute_always_inline bool >> +static bool >> CopyReadLineText(CopyFromState cstate, bool is_csv) >> >> Is this an intentional change? >> CopyReadLineText() has "bool in_csv". > > Yes, I'm not sure it's really necessary to make it inline since the > benchmark results don't show much difference. Probably this is because > the function has 'is_csv' in some 'if' branches but the compiler > cannot optimize out the whole 'if' branches as most 'if' branches > check 'is_csv' and other variables. I see. If explicit "inline" isn't related to performance, we don't need explicit "inline". > I've attached the v25 patches that squashed the minor changes I made > in v24 and incorporated all comments I got so far. I think these two > patches are in good shape. Could you rebase remaining patches on top > of them so that we can see the big picture of this feature? OK. I'll work on it. > Regarding exposing the structs such as CopyToStateData, v22-0004 patch > moves most of all copy-related structs to copyapi.h from copyto.c, > copyfrom_internal.h, and copy.h, which seems odd to me. I think we can > expose CopyToStateData (and related structs) in a new file > copyto_internal.h and keep other structs in the original header files. Custom COPY format extensions need to use CopyToStateData/CopyFromStateData. For example, CopyToStateData::rel is used to retrieve table schema. If we move CopyToStateData to copyto_internal.h not copyapi.h, custom COPY format extensions need to include copyto_internal.h. I feel that it's strange that extensions need to use internal headers. What is your real concern? If you don't want to export CopyToStateData/CopyFromStateData entirely, we can provide accessors only for some members of them. FYI: We discussed this in the past. For example: https://www.postgresql.org/message-id/flat/20240115.152350.1128880926282754664.kou%40clear-code.com#1b523fb95e8fb46702f5568ae19e3649 Thanks, -- kou