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 1tfduH-003vag-C1 for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Feb 2025 11:49:25 +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 1tfduD-00DzKH-Rd for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Feb 2025 11:49:21 +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 1tfduC-00DzJ7-W6 for pgsql-hackers@lists.postgresql.org; Wed, 05 Feb 2025 11:49:21 +0000 Received: from fout-b5-smtp.messagingengine.com ([202.12.124.148]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tfduA-003Itz-2T for pgsql-hackers@postgresql.org; Wed, 05 Feb 2025 11:49:20 +0000 Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfout.stl.internal (Postfix) with ESMTP id A615F11401D4; Wed, 5 Feb 2025 06:49:17 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Wed, 05 Feb 2025 06:49:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1738756157; x=1738842557; bh=b J21oFpJ3UxHxCID5MX+zrffL3IS4scHR5mvKiRQuKo=; b=uZHzNGivaeOy6JVMl NtNsGK8ibBab+Yby053h9FyaTViKenVXEzoFbxYznCW4Qc3sHqFAwHvNortNx4KO WlCH8L0n/59qW+qdcJ0D8F4y5LjbgZ7ki0OG2v/FvLQUakV7PHEbwzj/dvy7yJfG q+0lgMwQcJIaUdEB874Sp0+FUinGaeXbEfGoX3jdUdeETA/lyGGcvELKZ4B1OEn3 teYtLKwtHAxe9amwIBDUMde0W442HCKBSlFoFrJP4vf5/etFxr0HoYKs4T0YuRHw jeMB0kaoTavndcCqI6GQb9mIpk8Z8qaPsLyjL11EgUiwBubymw+YpE9S6ZEAEV8S HYp/w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvfeefkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpeffhffvvefukfggtggugfgjsehtkeertddttdej necuhfhrohhmpemllhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvh hhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpedvheeuffehgfeukeeufeeh hefghfeugfefudekjeevudffgeffkeegffffveegheenucffohhmrghinhepvghnthgvrh hprhhishgvuggsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrghdpnhgspg hrtghpthhtohepiedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepkhhouhestghl vggrrhdqtghouggvrdgtohhmpdhrtghpthhtohepshgrfigruggrrdhmshhhkhesghhmrg hilhdrtghomhdprhgtphhtthhopeiihhhjfihpkhhusehgmhgrihhlrdgtohhmpdhrtghp thhtohepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidprhgtphhtthhopehvrdhpoh hpohhlihhtohhvsehpohhsthhgrhgvshhprhhordhruhdprhgtphhtthhopehpghhsqhhl qdhhrggtkhgvrhhssehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 5 Feb 2025 06:49:15 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1738756154; bh=upZo/KmQs9hT49W4VCK21arpMGcjLSVx1Llw0X9iBKI=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=EDDlCVKIs1FS4UduZ7qvVhlCX1v9iIF06Zir4f4M5w7/aQDX45BS98rVx88EuF3Gc Sgkm6dCwv9wItQy1JVrw3dFYHvYm5z/h3iTwOwelP0mcsOhqD9h6qzB4bkMWrJSPK+ IIGYn7EMzdOJHilSxxL8NkrVuQARGH1YwzJH24ELZR3qwRh+ii5zUk7kRPbrtfCH0C l7yEcnY4KUdeuZtg4v8UPzRkVEapPrgW8oTRMcaw94WKLEo3KowE0Zi7dzxhGbBUSv ywY04hvu3t9kPlxbnrx066e0XZIPeh/Pgp73TuB3TIqnpTNbjuvag/OKU/NYOIWuP/ vIWUvT99yUtYQ== Received: by schmee.alvh.no-ip.org (Postfix, from userid 1000) id 8066790; Wed, 5 Feb 2025 12:49:14 +0100 (CET) Date: Wed, 5 Feb 2025 12:49:14 +0100 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Vladlen Popolitov Cc: Sutou Kouhei , sawada.mshk@gmail.com, zhjwpku@gmail.com, michael@paquier.xyz, pgsql-hackers@postgresql.org Subject: Re: Make COPY format extendable: Extract COPY TO format implementations Message-ID: <202502051149.ydnmwifpiyv5@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2025-Feb-03, Vladlen Popolitov wrote: > You use FORMAT option to add new formats, filling it with routine name > in shared library. As result any caller can call any routine in PostgreSQL > kernel. > I think, it will start competition, who can find most dangerous routine > to call just from COPY FROM command. Hah. Maybe it would be a better UI to require that COPY format handlers are registered explicitly before they can be used: CREATE ACCESS METHOD copy_yaml TYPE copy HANDLER copy_yaml_handler; ... and then when the FORMAT is not recognized as one of the hardcoded methods, we go look in pg_am for one with amtype='c' and the given name. That gives you the function that initializes the Copy state. This is convenient enough because system administrators can add COPY formats that anyone can use, and doesn't allow to call arbitrary functions via COPY. -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/ "I can't go to a restaurant and order food because I keep looking at the fonts on the menu. Five minutes later I realize that it's also talking about food" (Donald Knuth)