Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fLvRY-0005W1-3W for pgsql-general@arkaria.postgresql.org; Thu, 24 May 2018 18:58:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fLvRW-0007km-M1 for pgsql-general@arkaria.postgresql.org; Thu, 24 May 2018 18:58:30 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fLvRW-0007kc-E7 for pgsql-general@lists.postgresql.org; Thu, 24 May 2018 18:58:30 +0000 Received: from [195.159.176.226] (helo=blaine.gmane.org) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fLvRP-0005rB-HE for pgsql-general@postgresql.org; Thu, 24 May 2018 18:58:29 +0000 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fLvPH-0005X2-1D for pgsql-general@postgresql.org; Thu, 24 May 2018 20:56:11 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-general@postgresql.org From: Lele Gaifax Subject: Re: Parameter placeholders, $n vs ? Date: Thu, 24 May 2018 20:58:16 +0200 Organization: Nautilus Entertainments Lines: 35 Message-ID: <87k1rsc247.fsf@metapensiero.it> References: <87o9h5bjhs.fsf@metapensiero.it> <24317.1527170577@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@blaine.gmane.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cancel-Lock: sha1:qQMwN75We5uL0z/Kzj2PX5TVt+k= X-Host-Lookup-Failed: Reverse DNS lookup failed for 195.159.176.226 (failed) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Tom Lane writes: > "David G. Johnston" writes: >> On Thursday, May 24, 2018, Lele Gaifax wrote: >>> So the questions: is the '?' style placeholder a supported variant? and >>> if so, should the ParamRef doc tell something about that? > >> PostgreSQL's Prepare statement doesn't accept question mark as a parameter >> symbol, and cannot ever because it is already a valid operator symbol. > > To enlarge on that a bit: > > * PG's core parser certainly does not accept ? as a parameter symbol. > I speculate that you fed the input through some frontend that converts > ? to $n (JDBC, perhaps)? > > * The only thing in the core code that would print a ParamRef in any > sort of symbolic form is _outParamRef, and it's easily seen by inspection > to be incapable of omitting the "number" field ... not to mention that > it doesn't emit the JSON-esque representation you're showing us. So > that behavior must also be due to some non-core pretty-printing code you > haven't identified to us. No idea what rules that might have for deciding > to omit "number". Thank you to both. As said, the tool is built on the PG 10 parser extracted as a standalone library, that serializes the statement AST as JSON. I assumed it didn't diverge much from what the core parser accepts. I will clarify my doubt with libpg_query's author. bye, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929.