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 1mpYY8-0001u9-FT for pgsql-general@arkaria.postgresql.org; Tue, 23 Nov 2021 16:21:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mpYY7-00013x-7Y for pgsql-general@arkaria.postgresql.org; Tue, 23 Nov 2021 16:21:39 +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 1mpYY6-00013a-TJ for pgsql-general@lists.postgresql.org; Tue, 23 Nov 2021 16:21:38 +0000 Received: from mail.tuxteam.de ([5.199.139.25]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mpYY4-0004zo-LF for pgsql-general@lists.postgresql.org; Tue, 23 Nov 2021 16:21:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject :Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=/Ew5IfZ++gzPT9jyidBvmkQ/DiAoIQ1UOEuUP9pVBbY=; b=jRoDKpDV6Cos1mRlj+ITk/jJmB y7E0kc5k6mi1diJ0EF1diPFb1uYOifOClKCRF0h1tkCjBkG3JsibFkSt6isC/bPRGgU93N/UkHQFF QDOJWitaEfMfUZYz583wY6GKXXYcT0tilFB/yiSFIXFnCPOJ3hi4FbT2weZ3WQtfuAjMIa7glgtvC 6jQxGxz0+evTjGa5emtUgHshjFYIUt+eg+oMQko9dzYbu3xAhTSt57/3E8bZJDWw5ukbLuTj13LEr uGKOZU1f1z5bHRU97I+HQ0TcC1ObMvOfN1tXWlnPFN1TdvOAhPabIYRGuTfpQSvnKQZUENIitq4iJ KKarv9NQ==; Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1mpYY0-0001NR-Sl; Tue, 23 Nov 2021 17:21:32 +0100 Date: Tue, 23 Nov 2021 17:21:32 +0100 From: tomas@tuxteam.de To: Daniel Frey Cc: Tom Lane , "David G. Johnston" , =?utf-8?B?0JTQvNC40YLRgNC40Lkg0JjQstCw0L3QvtCy?= , pgsql-general Subject: Re: PQexecParams, placeholders and variable lists of params Message-ID: References: <4176869.1637682183@sss.pgh.pa.us> <900F5773-6971-4154-94FD-660985E5CB46@icloud.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="0hG7twiQpiagAcQc" Content-Disposition: inline In-Reply-To: <900F5773-6971-4154-94FD-660985E5CB46@icloud.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0hG7twiQpiagAcQc Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 23, 2021 at 05:14:44PM +0100, Daniel Frey wrote: > > On 23. Nov 2021, at 16:43, Tom Lane wrote: > >=20 > > 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.) > >=20 > > 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. >=20 > Would it be possible to extend PQexecParams() et.al. like this: >=20 > You currently have paramValues[], paramLengths[], and paramFormats[] (plu= s other parameters that I'll ignore here). >=20 > The format may currently be 0 or 1 (TEXT or BINARY). What if we allow 2 f= or ARRAY? The corresponding length then specifies how many parameters foll= owing are part of the array. The value should point to a structure, that co= ntains pointers to the values, lengths, and formats of the elements. This a= lso allows nested arrays. That sounds attractive; I think for my particular case it'd be overengineering, though... > If the client library knows that the server is too old to understand it, = it may temporarily assemble a string for those (correctly escaped) values a= nd replace the entries in the original values/lengths/formats arrays tempor= arily before passing it to the old PQexecParams() implementation. >=20 > If the server is new enough the protocol itself can be extended to send t= he array more efficiently instead of quoting and copying data around. >=20 > This would also hide the quoting rules for arrays nicely, as it doesn't r= equire additional methods for escaping. (Currently, escaping for arrays is = different from other escaping methods, it needs to be done manually and, fr= ankly, it's a PITA). =2E..but in the general case it sounds useful, yes :) Cheers - t --0hG7twiQpiagAcQc Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCYZ0VDAAKCRAFyCz1etHa RmapAJ9B1H4KGEsZn68bcgJRnzxKfzHUDgCeJ4x0kTwbtvXmAFg/bOMOJimdq8g= =SaSD -----END PGP SIGNATURE----- --0hG7twiQpiagAcQc--