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 1mpXwr-0008K8-Fp for pgsql-general@arkaria.postgresql.org; Tue, 23 Nov 2021 15:43:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mpXwq-0007jy-95 for pgsql-general@arkaria.postgresql.org; Tue, 23 Nov 2021 15:43:08 +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 1mpXwp-0007jo-Ua for pgsql-general@lists.postgresql.org; Tue, 23 Nov 2021 15:43:07 +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 1mpXwn-0004aT-Oh for pgsql-general@lists.postgresql.org; Tue, 23 Nov 2021 15:43:06 +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 1ANFh3wm4176870; Tue, 23 Nov 2021 10:43:03 -0500 From: Tom Lane To: "David G. Johnston" cc: tomas@tuxteam.de, =?UTF-8?B?0JTQvNC40YLRgNC40Lkg0JjQstCw0L3QvtCy?= , pgsql-general Subject: Re: PQexecParams, placeholders and variable lists of params In-reply-to: References: Comments: In-reply-to "David G. Johnston" message dated "Tue, 23 Nov 2021 08:35:04 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4176868.1637682183.1@sss.pgh.pa.us> Date: Tue, 23 Nov 2021 10:43:03 -0500 Message-ID: <4176869.1637682183@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Tue, Nov 23, 2021 at 7:21 AM wrote: >> Makes sense. Problem is, that, again, the application would be >> responsible of making sure the individual values don't contain nasty >> stuff (for example, if they are strings) before consolidating them to >> one PostgreSQL array literal. > So long as you actually pass the literal value via a parameter the worst > problem you can have is a syntax error in converting the literal into > whatever type is being cast to. PG's array quoting rules are odd enough that I can sympathize with not wanting to deal with them. (Although, if you only have to build an array and not parse one, taking the always-quote-even-if-not-necessary approach makes it easier.) I don't see many other alternatives though. *Somehow* you have to separate one value from the next. If you don't want to pass 'em as distinct parameters, then you have to obey some kind of composite-value syntax. regards, tom lane