Skip to content

Commit 9606f36

Browse files
committed
Someone (probably me) forgot about handling of typecasts applied to
parameters.
1 parent 91124a2 commit 9606f36

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/backend/parser/parse_expr.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.71 2000/02/26 21:11:10 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.72 2000/03/07 23:30:53 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -78,19 +78,21 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
7878
ParamNo *pno = (ParamNo *) expr;
7979
int paramno = pno->number;
8080
Oid toid = param_type(paramno);
81-
Param *param;
81+
Param *param = makeNode(Param);
8282

8383
if (!OidIsValid(toid))
8484
elog(ERROR, "Parameter '$%d' is out of range", paramno);
85-
param = makeNode(Param);
8685
param->paramkind = PARAM_NUM;
8786
param->paramid = (AttrNumber) paramno;
8887
param->paramname = "<unnamed>";
89-
param->paramtype = (Oid) toid;
90-
param->param_tlist = (List *) NULL;
88+
param->paramtype = toid;
89+
param->param_tlist = NIL;
9190
result = transformIndirection(pstate, (Node *) param,
9291
pno->indirection);
93-
/* XXX what about cast (typename) applied to Param ??? */
92+
/* cope with typecast applied to param */
93+
if (pno->typename != NULL)
94+
result = parser_typecast_expression(pstate, result,
95+
pno->typename);
9496
break;
9597
}
9698
case T_TypeCast:
@@ -732,6 +734,7 @@ exprTypmod(Node *expr)
732734
* We assume that a two-argument function named for a datatype, whose
733735
* output and first argument types are that datatype, and whose second
734736
* input is an int32 constant, represents a forced length coercion.
737+
*
735738
* XXX It'd be better if the parsetree retained some explicit indication
736739
* of the coercion, so we didn't need these heuristics.
737740
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy