Re: the parsing of parameters

From: Jan Wieck <janwieck(at)yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: the parsing of parameters
Date: 2002-05-09 20:49:11
Message-ID: 200205092049.g49KnBl02557@saturn.janwieck.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Neil Conway <nconway(at)klamath(dot)dyndns(dot)org> writes:
> > nconway=> prepare q2 as select $1;
> > ERROR: Parameter '$1' is out of range
>
> > (You'll see the same parse error with simply "select $1;")
>
> You need to tell the parser the number of parameters to expect and their
> datatypes. This is what the last two arguments to parser() are all
> about. Look at _SPI_prepare for an example (I think plpgsql uses that).
> Also, the plpgsql code for parameterized cursors might be a helpful
> reference.
>
> The actual syntax of PREPARE probably has to be something like
>
> PREPARE queryname(parameter type list) FROM query
>
> else you'll not have any way to get the type info.
>
> > BTW, is this a legacy from postquel? (from include/nodes/primnodes.h)
>
> I don't believe anything is using named parameters presently. PARAM_NEW
> and PARAM_OLD also seem to be leftovers from an old implementation of
> rules.

I have a little patch that actually allows SPI_prepare() to
use UNKNOWN_OID in the passed in parameter type array and
put's the choosen datatypes Oid back into there.

The parser treats those parameters like single quoted
literals of unknown type and chooses what would be the most
useful datatype here.

Any objections?

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Iavor Raytchev 2002-05-09 21:08:17 Re: www.pgaccess.org - the official story (the way I saw it)
Previous Message Ross J. Reedstrom 2002-05-09 20:42:22 Re: www.pgaccess.org - the official story (the way I saw it)