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 1wcx8u-003mE6-0u for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Jun 2026 03:22:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wcx8t-008Whe-0P for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Jun 2026 03:22:11 +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.96) (envelope-from ) id 1wcx8s-008WhT-05 for pgsql-hackers@lists.postgresql.org; Fri, 26 Jun 2026 03:22:10 +0000 Received: from mail.clear-code.com ([2401:2500:102:3037:153:126:203:179]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wcx8o-00000000IdS-0XCF for pgsql-hackers@postgresql.org; Fri, 26 Jun 2026 03:22:09 +0000 Received: from localhost (unknown [IPv6:2404:7a80:9f01:f500:1788:74de:dc85:ea72]) by mail.clear-code.com (Postfix) with ESMTPSA id 665FA10018D; Fri, 26 Jun 2026 12:21:53 +0900 (JST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.clear-code.com 665FA10018D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=clear-code.com; s=default; t=1782444113; bh=xVQEn4SSxkkAq1KbjJmpHJJuV0eKIO03AZFXITZfxY0=; h=Date:To:Cc:Subject:From:In-Reply-To:References:From; b=nG/oA28qwLrQEtGp9Y6d4Lx41s6JuyiFjJEcc/QdsX9w4440C+AYTAVwc2ZYh0DdI LnJAQtl7w1pRvbMCESACY4Tt9YvTgbvY2cWWVB32VnjTrTEYVsVWfVZzWksJSXV9NA 8oO99WpfYVW1PRD+Vr/quI0MwTj1EhU6o8ZA1Q2s= Date: Fri, 26 Jun 2026 12:21:50 +0900 (JST) Message-Id: <20260626.122150.1718021693730851340.kou@clear-code.com> To: sawada.mshk@gmail.com Cc: tomas@vondra.me, andres@anarazel.de, michael@paquier.xyz, david.g.johnston@gmail.com, tgl@sss.pgh.pa.us, zhjwpku@gmail.com, pgsql-hackers@postgresql.org Subject: Re: Make COPY format extendable: Extract COPY TO format implementations From: Sutou Kouhei In-Reply-To: References: <20260623.144149.439869848255136426.kou@clear-code.com> X-Mailer: Mew version 6.8 on Emacs 30.2 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 665FA10018D X-Spamd-Result: default: False [2.90 / 999.00]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; MV_CASE(0.50)[]; MIME_GOOD(-0.10)[text/plain]; ASN(0.00)[asn:2518, ipnet:2404:7a80::/29, country:JP]; ARC_NA(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; RCPT_COUNT_SEVEN(0.00)[8]; RCVD_COUNT_ZERO(0.00)[0]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; ALIAS_RESOLVED(0.00)[]; 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)[]; LOCAL_OUTBOUND(0.00)[]; FREEMAIL_CC(0.00)[vondra.me,anarazel.de,paquier.xyz,gmail.com,sss.pgh.pa.us,postgresql.org] X-Rspamd-Action: no action X-Rspamd-Server: mail.clear-code.com 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 Tue, 23 Jun 2026 18:15:10 -0700, Masahiko Sawada wrote: > Thank you for reviewing the patches! I've attached updated patches. +1 I have only a few minor comments: 0002: > --- /dev/null > +++ b/src/backend/commands/copyapi.c > +void > +RegisterCopyCustomFormat(const char *name, const CopyToRoutine *to, > + const CopyFromRoutine *from, ProcessOneCopyOptionFn option_fn) How about using "const CopyCustomFormatEntry *" instead of "to", "from" and "option_fn"? If we use CopyCustomFormatEntry here, we don't need change the signature of this function when we add more items. > +const CopyCustomFormatEntry * > +GetCopyCustomFormatRoutines(const char *name) How about renaming this to "...FormatEntry" from "...FormatRoutines"? > --- a/src/include/commands/copy.h > +++ b/src/include/commands/copy.h > +#define CopyFormatIsBuiltins(format) ((format) != COPY_FORMAT_CUSTOM) How about removing the last "s" ("...IsBuiltin") because this processes only one format? > + const struct CopyCustomFormatEntry *custom_format_ent; It may be better that we don't abbreviate "_entry" to "_ent" here for readability. It seems that we use this abbreviation only in a few places: $ git grep '_ent;' src/ src/backend/replication/logical/reorderbuffer.c: ReorderBufferTupleCidEnt *new_ent; src/backend/utils/cache/catcache.c: CatCInProgress in_progress_ent; src/backend/utils/cache/catcache.c: catcache_in_progress_stack = &in_progress_ent; src/backend/utils/cache/catcache.c: CatCInProgress in_progress_ent; src/backend/utils/cache/catcache.c: catcache_in_progress_stack = &in_progress_ent; > I'll verify that the new API works well with an experimental custom > copy format extension. I think that we need to provide more APIs to read/write data like we did in v40-0003 to implement a custom copy format extension: https://www.postgresql.org/message-id/flat/20250425.214534.1841428689427124725.kou%40clear-code.com At least https://github.com/kou/pg-copy-arrow needs them. Thanks, -- kou