Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oi2id-00031w-M0 for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Oct 2022 00:02:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oi2ib-0002TX-6D for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Oct 2022 00:01:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oi2iZ-0002TO-GI for pgsql-hackers@lists.postgresql.org; Tue, 11 Oct 2022 00:01:56 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oi2iU-000304-Ld for pgsql-hackers@postgresql.org; Tue, 11 Oct 2022 00:01:54 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 8A6735C00DD; Mon, 10 Oct 2022 20:01:47 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 10 Oct 2022 20:01:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; t=1665446507; x=1665532907; bh=IrYWkuLIPo N0LPQ66nWBGC7djgWA2kv614+mPSkOERw=; b=alMwoe8LTIXfGlHWeLRZSFLMbg TVoOz7uZyhmyBOp6XwZDqIgCVkSwwZTIit4iI1I8cRwhN1N7WmKKws59HxzRaffn eHYiGjg9k9u3Vt/fP7qW25PjLn4SKwYUOhTadDMX3oZcURGJmqB+1hcKof/RJrJL zI6ZVVyxZuOMucAWaWWEGCm8n5TipHR0O1cjUytlBShh58RvfjM89tqLEEihyyl6 nu4f3D1HqKwsKReK4TCkjTF1CUvUXXZr09yXprfrEGfMTxm2VzSJgXMRZjfETUKE 6FSjsxOcVAspzCuiTLijr158UVjkdXnNbRT4g3LAkWrtmRHyaoYK9KMwBzUQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1665446507; x=1665532907; bh=IrYWkuLIPoN0LPQ66nWBGC7djgWA 2kv614+mPSkOERw=; b=WX9B8xtifKC06dBn6rlt6nRond7EO3BrpO0mAG3JPdnb UPFu5xYoPlxDB0WiEtCgdeHzgjiVPoJTlSxw2M10o+r8GT6GrOCDfsMW3x7SWh1N inO60DeU3blZlorLTxRtVjv87o7ViaiAR3YXRbyrYbTooL3zzE78WzYv61Nfnh6L r48dEc6RUSe0zfqM3/LwYjzUN0ldUWgIKkD0fp33zm4AjARd20i9/U8Zr4sMGCpd mVnjoVU8UVCEeVnnx7U01ZnWqtDHF/s7mjbFPKFEeKAYLVPPphv2kvbF3T9Tey24 uDd7QSLqXf87GKqtSwizF7EcWIGBHtBwxGWS/v4YSQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeejhedgvdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeg geegfffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 10 Oct 2022 20:01:45 -0400 (EDT) Date: Tue, 11 Oct 2022 09:01:41 +0900 From: Michael Paquier To: Nathan Bossart Cc: Bharath Rupireddy , Soumyadeep Chakraborty , "Sanaba, Bilva" , "pgsql-hackers@postgresql.org" Subject: Re: Adding Support for Copy callback functionality on COPY TO api Message-ID: References: <20200930074151.GR1996@paquier.xyz> <20220802234919.GA841243@nathanxps13> <20221007214824.GA814385@nathanxps13> <20221008173741.GB882834@nathanxps13> <20221008211404.GA893744@nathanxps13> <20221010163859.GA993859@nathanxps13> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="yp10l+utgh8Zbv3g" Content-Disposition: inline In-Reply-To: <20221010163859.GA993859@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --yp10l+utgh8Zbv3g Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Oct 10, 2022 at 09:38:59AM -0700, Nathan Bossart wrote: > This new callback allows the use of COPY TO's machinery in extensions. A > couple of generic use-cases are listed upthread [0], and one concrete > use-case is the aws_s3 extension [1]. FWIW, I understand that the proposal is to have an easier control of how, what and where to the data is processed. COPY TO PROGRAM provides that with exactly the same kind of interface (data input, its length) once you have a program able to process the data piped out the same way. However, it is in the shape of an external process that receives the data through a pipe hence it provides a much wider attack surface which is something that all cloud provider care about. The thing is that this allows extension developers to avoid arbitrary commands on the backend as the OS user running the Postgres instance, while still being able to process the data the way they want (auditing, analytics, whatever) within the strict context of the process running an extension code. I'd say that this is a very cheap change to allow people to have more fun with the backend engine (similar to the recent changes with archive libraries for archive_command, but much less complex): src/backend/commands/copy.c | 2 +- src/backend/commands/copyto.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) (Not to mention that we've had our share of CVEs regarding COPY PROGRAM even if it is superuser-only). > I really doubt that this small test case is going to cause anything > approaching undue maintenance burden. I think it's important to ensure > this functionality continues to work as expected long into the future. I like these toy modules, they provide test coverage while acting as a template for new developers. I am wondering whether it should have something for the copy from callback, actually, as it is named "test_copy_callbacks" but I see no need to extend the module more than necessary in the context of this thread (logical decoding uses it, anyway). -- Michael --yp10l+utgh8Zbv3g Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmNEsmUACgkQnvQgOdby QH16WQ/8CEn9qSWEdhHwEWIbMKZn8MoF+sfwBifp2HfO6vSggbLUE3vjI+yM+Huz UuUaVLQIAMBP1N3ry8R/3lbS7trGaG7h8qnjGh4lDO+tZtF0Lmd2xzWMC7E2O/pF OIIr916PsXnIne3amHkCaUQ6MDdzAtj4pL6L+jPasEs5NjH6jWBvAM+lgn5hqoEQ H8mGpKne2CoTLtcdCWl7f3mgR+23dbik1A+ximI/41+1KrY1q6wS8cKpOpmTm6AQ aW0MAF2OORraQlF15YPPhrKJDQRP1frAW1ctuCuMqjN6dU019zqNU9hN1mZMjAqH lfpzWz+6qRGaYjmR/I1684KIQ0L2/smJYswBVWqJXZ6GIdQDGhm34QsBV107unqI zLdLQS3QuMhGfKgbus5fYhPJ/wo1HgYOs4XyfwIWWfRBJkPnL1Uy+yMcvxuEDIiN /UAJcrkWcsHxLQXoV2TLOZAXKj2UVflehKX7GcqunbJtjqRtdfhhwawdzrIkKWki KY7jFAtgfpBDRCJpp5sk7ecBYyvpsF1QKNoXyrLJbpoH2gAbEkaviSaAefoXykhK bVfhhjVucRdG/ssa0v438BSPQdVWl/TKoh+f7yeBQkSAESE1ILDPDWLrUbZmKI6m 1jtZK7IcoM864Gko5BPsDh5f1ATaNS/u6FysQpU38qUZf5scVoU= =78RG -----END PGP SIGNATURE----- --yp10l+utgh8Zbv3g--