aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_param.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-01-13 01:17:07 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-01-13 01:17:07 +0000
commit43a9a2fb89e67f61c50419264a767e7356824067 (patch)
tree0774c1d69469ff47ca12ce00bb32a59998b9ce15 /src/backend/parser/parse_param.c
parentb2aab424675f85799c08d637a71365aeb377fffe (diff)
downloadpostgresql-43a9a2fb89e67f61c50419264a767e7356824067.tar.gz
postgresql-43a9a2fb89e67f61c50419264a767e7356824067.zip
Make fixed_paramref_hook behave properly when there are 'unused' slots
in the parameter array. Noted while experimenting with an example from Pavel. This wouldn't come up in normal use, but it ought to honor the specification that a parameter array can have unused slots.
Diffstat (limited to 'src/backend/parser/parse_param.c')
-rw-r--r--src/backend/parser/parse_param.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/backend/parser/parse_param.c b/src/backend/parser/parse_param.c
index 53f3d625d03..b1282a14626 100644
--- a/src/backend/parser/parse_param.c
+++ b/src/backend/parser/parse_param.c
@@ -17,7 +17,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_param.c,v 2.2 2010/01/02 16:57:50 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_param.c,v 2.3 2010/01/13 01:17:07 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -100,8 +100,9 @@ fixed_paramref_hook(ParseState *pstate, ParamRef *pref)
int paramno = pref->number;
Param *param;
- /* Check parameter number is in range */
- if (paramno <= 0 || paramno > parstate->numParams)
+ /* Check parameter number is valid */
+ if (paramno <= 0 || paramno > parstate->numParams ||
+ !OidIsValid(parstate->paramTypes[paramno - 1]))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_PARAMETER),
errmsg("there is no parameter $%d", paramno),