Re: the parsing of parameters - Mailing list pgsql-hackers

From Tom Lane
Subject Re: the parsing of parameters
Date
Msg-id 10728.1020277979@sss.pgh.pa.us
Whole thread Raw
In response to the parsing of parameters  (Neil Conway <nconway@klamath.dyndns.org>)
Responses Re: the parsing of parameters
List pgsql-hackers
Neil Conway <nconway@klamath.dyndns.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.
        regards, tom lane


pgsql-hackers by date:

Previous
From: mlw
Date:
Subject: PostgreSQL mission statement?
Next
From: "Arthur@LinkLine.com"
Date:
Subject: mV database tools