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 1lK1z8-00072j-Jp for pgsql-bugs@arkaria.postgresql.org; Wed, 10 Mar 2021 16:46:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lK1z7-0006Dw-5w for pgsql-bugs@arkaria.postgresql.org; Wed, 10 Mar 2021 16:46:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lK1z6-0006Dp-W6 for pgsql-bugs@lists.postgresql.org; Wed, 10 Mar 2021 16:46:56 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lK1z4-0004ir-Fq for pgsql-bugs@lists.postgresql.org; Wed, 10 Mar 2021 16:46:56 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 12AGkpLF2107099; Wed, 10 Mar 2021 11:46:51 -0500 From: Tom Lane To: "David G. Johnston" cc: Joe Conway , =?UTF-8?B?RsOkcmJlciwgRnJhbnotSm9zZWYgKFN0TVVLKQ==?= , "pgsql-bugs@lists.postgresql.org" Subject: Re: COPY TO (query) allows no function arguments In-reply-to: References: <609326d4d6854085aeb909ae564d4ccb@stmuk.bayern.de> Comments: In-reply-to "David G. Johnston" message dated "Wed, 10 Mar 2021 08:45:07 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2107097.1615394811.1@sss.pgh.pa.us> Date: Wed, 10 Mar 2021 11:46:51 -0500 Message-ID: <2107098.1615394811@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > If COPY itself can be parameterized/prepared (I'm unsure and not able to > test right now) then it should be able to accept variables when used in a > function - within the rules for variable substitution. COPY is a utility command, so it doesn't accept parameters. Basically only the big four DML commands (SELECT/INSERT/UPDATE/DELETE) can take parameters. For everything else, you've got to build a string and EXECUTE it, as Joe illustrated. regards, tom lane