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 1rDwSA-003d1J-Pw for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Dec 2023 00:53:23 +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 1rDwS8-00DbaE-AW for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Dec 2023 00:53:20 +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 1rDwS7-00Dba5-6B for pgsql-hackers@lists.postgresql.org; Fri, 15 Dec 2023 00:53:20 +0000 Received: from mail.clear-code.com ([153.126.206.245]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rDwS2-00C38D-Dp for pgsql-hackers@postgresql.org; Fri, 15 Dec 2023 00:53:17 +0000 Received: from localhost (unknown [IPv6:2404:7a80:89c1:1200:1653:202c:ea56:2daf]) by mail.clear-code.com (Postfix) with ESMTPSA id 362D56FE597; Fri, 15 Dec 2023 09:53:07 +0900 (JST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.clear-code.com 362D56FE597 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=clear-code.com; s=default; t=1702601587; bh=CPFRHH9DljL/U/xUi4pPaTh08FNKWiMKA6699pjncC0=; h=Date:To:Cc:Subject:From:In-Reply-To:References:From; b=WhN8cIK1cFQ3zj1Embp55gLg8qGrwsZn00PuWidhvsUkW/K/JTX1FLqjiOpx/KFZQ PNdqDzldYdW2j5eJBaRKU6O1NggkEnLRObpbMu4L3bp4MjC9CQI5WC6ha4RYCx1bLJ eb0LFhkRfomUBa0nExdpkznvH1ZRMiPr60suui/w= Date: Fri, 15 Dec 2023 09:53:05 +0900 (JST) Message-Id: <20231215.095305.1361997086905276509.kou@clear-code.com> To: sawada.mshk@gmail.com Cc: michael@paquier.xyz, zhjwpku@gmail.com, andrew@dunslane.net, nathandbossart@gmail.com, pgsql-hackers@postgresql.org Subject: Re: Make COPY format extendable: Extract COPY TO format implementations From: Sutou Kouhei In-Reply-To: References: <20231214.184414.2179134502876898942.kou@clear-code.com> X-Mailer: Mew version 6.8 on Emacs 29.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 362D56FE597 X-Rspamd-Server: mail.clear-code.com 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]; RCVD_COUNT_ZERO(0.00)[0]; TAGGED_RCPT(0.00)[]; ASN(0.00)[asn:2518, ipnet:2404:7a80::/29, country:JP]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FREEMAIL_TO(0.00)[gmail.com]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; URIBL_BLOCKED(0.00)[localhost:helo]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_CC(0.00)[paquier.xyz,gmail.com,dunslane.net,postgresql.org]; RCPT_COUNT_FIVE(0.00)[6]; TO_DN_NONE(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; SURBL_MULTI_FAIL(0.00)[localhost:server fail] X-Rspamd-Action: no action 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, 15 Dec 2023 05:19:43 +0900, Masahiko Sawada wrote: > To avoid collisions, extensions can be created in a > different schema than public. Thanks. I didn't notice it. > And note that built-in format copy handler doesn't need to > declare its handler function. Right. I know it. > Adding a prefix or suffix would be one option but to give extensions > more flexibility, another option would be to support format = 'custom' > and add the "handler" option to specify a copy handler function name > to call. For example, COPY ... FROM ... WITH (FORMAT = 'custom', > HANDLER = 'arrow_copy_handler'). Interesting. If we use this option, users can choose an COPY FORMAT implementation they like from multiple implementations. For example, a developer may implement a COPY FROM FORMAT = 'json' handler with PostgreSQL's JSON related API and another developer may implement a handler with simdjson[1] which is a fast JSON parser. Users can choose whichever they like. But specifying HANDLER = '...' explicitly is a bit inconvenient. Because only one handler will be installed in most use cases. In the case, users don't need to choose one handler. If we choose this option, it may be better that we also provide a mechanism that can work without HANDLER. Searching a function by name like tablesample method does is an option. [1]: https://github.com/simdjson/simdjson Thanks, -- kou