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 1rhO7j-00BC7y-MY for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Mar 2024 06:18:01 +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 1rhO6j-00DnzE-Lw for pgsql-hackers@arkaria.postgresql.org; Tue, 05 Mar 2024 06:16:58 +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 1rhO6h-00Dnz6-S1 for pgsql-hackers@lists.postgresql.org; Tue, 05 Mar 2024 06:16:57 +0000 Received: from fout7-smtp.messagingengine.com ([103.168.172.150]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rhO6d-002v5R-KL for pgsql-hackers@postgresql.org; Tue, 05 Mar 2024 06:16:55 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.nyi.internal (Postfix) with ESMTP id 3015B13800E8; Tue, 5 Mar 2024 01:16:51 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Tue, 05 Mar 2024 01:16:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1709619411; x=1709705811; bh=IlovXWzkkb I2Uf+0roUhUQ2fm1UKF8SIZG1is9Ph+6Q=; b=Xaos/S7VXNGlmVS6bzfaj74Tv3 liw2y8ZbjoiZwWvKBKid8uisUII0WcufoJwgPnQLiS/6CWwDQh0vPtYkEA5en7tV af/K3fORw8/T5AQ7ulFA18NDbOdgBX2VTxj3rDRuAv29rM+qi/l2EeMHWehBbgLC NBUxBalBdTWYd7vbw1ObiJQsi1mDeJwwliG6i7F5jwASByi2w/elemhfg9jxVqfk bTf7qAPMcA5l7WUn1sPFwTicTsMhls1QDfOuxxXqrMJoyjQNaeYnWp8OTBFsRDye m9ctNaf4NMWcoj8bxAMXW0Kbf6fqcoYkrlPmcln/T7KhNUCQ34xCGVFio7pA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1709619411; x=1709705811; bh=IlovXWzkkbI2Uf+0roUhUQ2fm1UK F8SIZG1is9Ph+6Q=; b=m+9Vu/JA3xyMmDrHla36MCrvfMJ9kcRZ86mBTg0wzV9J c7iM3bSJMsuW1zX05JPliHEZ4BDrCRGDsyLVrn/lBvlrbmUCvk5gCowuZxWvCxn5 QXXlEyxGL+rfSo6N5lFGtGX1FaxD7mv0yJl/4uYmW2056QgdFcUh7l3U2bfvQTeA jz4rDtv0K44M92NOZQRpHPAVe4pBpfXSwWPMB2XsYQDoypy+uZtMU5isRDqj3HbO UgXjYyHCyBZo+OWrmpv9V7x9NDs/F5ulcbCRQ8fFwRnlfrJZG5LSB61Pz+i0XAzc QoRprI43laWEv+XNvcvMwS4Sh6VyQjHUxNMcLPcJyw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrheekgdeludcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdejtddmnecujfgurhepfffhvf evuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhu ihgvrhcuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrh hnpeetleeifedufffhhfdtteelgeeggeffhfekueevteeigfduudevudetgfegiedvjeen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthh grvghlsehprghquhhivghrrdighiii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 5 Mar 2024 01:16:48 -0500 (EST) Date: Tue, 5 Mar 2024 15:16:33 +0900 From: Michael Paquier To: Sutou Kouhei Cc: andres@anarazel.de, sawada.mshk@gmail.com, zhjwpku@gmail.com, andrew@dunslane.net, nathandbossart@gmail.com, pgsql-hackers@postgresql.org Subject: Re: Make COPY format extendable: Extract COPY TO format implementations Message-ID: References: <20240222.183948.518018047578925034.kou@clear-code.com> <20240301.154443.618034282613922707.kou@clear-code.com> <20240304.141108.377465274442209834.kou@clear-code.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ZXoaSxMnNGcRxBSh" Content-Disposition: inline In-Reply-To: <20240304.141108.377465274442209834.kou@clear-code.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --ZXoaSxMnNGcRxBSh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Mar 04, 2024 at 02:11:08PM +0900, Sutou Kouhei wrote: > If this is a blocker of making COPY format extendable, can > we defer moving the existing text/csv/binary format > implementations to Copy{From,To}Routine for now as Michael > suggested to proceed making COPY format extendable? (Can we > add Copy{From,To}Routine without changing the existing > text/csv/binary format implementations?) Yeah, I assume that it would be the way to go so as we don't do any dispatching in default cases. A different approach that could be done is to hide some of the parts of binary and text/csv in inline static functions that are equivalent to the routine callbacks. That's similar to the previous versions of the patch set, but if we come back to the argument that there is a risk of blocking optimizations of more of the local areas of the per-row processing in NextCopyFrom() and CopyOneRowTo(), what you have sounds like a good balance. CopyOneRowTo() could do something like that to avoid the extra indentation: if (cstate->routine) { cstate->routine->CopyToOneRow(cstate, slot); MemoryContextSwitchTo(oldcontext); return; } NextCopyFrom() does not need to be concerned by that. > I attach a patch for it. > There is a large hunk for CopyOneRowTo() that is caused by > indent change. I also attach "...-w.patch" that uses "git > -w" to remove space only changes. "...-w.patch" is only for > review. We should use .patch without -w for push. I didn't know this trick. That's indeed nice.. I may use that for other stuff to make patches more presentable to the eyes. And that's available as well with `git diff`. If we basically agree about this part, how would the rest work out with this set of APIs and the possibility to plug in a custom value for FORMAT to do a pg_proc lookup, including an example of how these APIs can be used? -- Michael --ZXoaSxMnNGcRxBSh Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmXmuMEACgkQnvQgOdby QH3bsRAAqSzgdLFgptboDxYfvkVaWeY30Y7S9Q55qxF71dgmSOfeUjYR3w6dO4nX tDzBZfep2oO6vl0CYqYM5YSIoHR5KHspg6tMdAmEuZkmNUuHG/+P0jtF1Q34xE8F JOw6dx2kZjKAWiMmJqt33pd+LmztWsGSmu5D7m5dsG2iJhYHCOt0Dw5UJ/lfBsPu qxHWUSflqzgY40aVO/uVLWT6PqvLlNxhI6mT2wkuCz1vGcIo9GjJ//IXGlfciwyE dzgYCrUPmM+ZIZWJ5bvLuEn3sPa4IU/1CH9VZ5+QxxajH1xXuAItulDO8T4NCxcW K0ezJhxFPbcvZNfJdozUZJGo+lGOTsPJL/m/usJrk3pv+TTSgKcrwUMJAW1QYWuF F+CuNoWZggv/1VMVcJkYvr2wDkCtamHe6tN2dX8BY92w1SnuLAEjHe8IeM07ytfG kY1Ty7pREJ7bnaV0g67w3kkIhQmnBrxZtRKqnIIc4nWInNK34gG+KmJPrk8Y8bFy VXdPJoF7TY/Iw73ANJgtLi6hyN0tC+KxjM9CKAz2sFhBSKqcxaHCO88Zeigb27F4 jmb9PbStkRRmO920agFSzm1/z6CVQVD95/GKqx6zeoax2dbi9vKnWIe37865gRWI NXBgDyvMnDOV44Hxl9ioi3oz9ZoY2iOw+Fd5SwvI+3P4tQKleyM= =j64k -----END PGP SIGNATURE----- --ZXoaSxMnNGcRxBSh--