1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-17 06:41:09 +03:00

Add a paramtypmod field to Param nodes. This is dead weight for Params

representing externally-supplied values, since the APIs that carry such
values only specify type not typmod.  However, for PARAM_SUBLINK Params
it is handy to carry the typmod of the sublink's output column.  This
is a much cleaner solution for the recently reported 'could not find
pathkey item to sort' and 'failed to find unique expression in subplan
tlist' bugs than my original 8.2-compatible patch.  Besides, someday we
might want to support typmods for external parameters ...
This commit is contained in:
Tom Lane
2006-12-10 22:13:27 +00:00
parent 314c7b642b
commit 9fa12ddda6
10 changed files with 50 additions and 47 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_agg.c,v 1.73 2006/07/27 19:52:05 tgl Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_agg.c,v 1.74 2006/12/10 22:13:26 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -394,6 +394,7 @@ build_aggregate_fnexprs(Oid *agg_input_types,
argp->paramkind = PARAM_EXEC;
argp->paramid = -1;
argp->paramtype = agg_state_type;
argp->paramtypmod = -1;
args = list_make1(argp);
@ -403,6 +404,7 @@ build_aggregate_fnexprs(Oid *agg_input_types,
argp->paramkind = PARAM_EXEC;
argp->paramid = -1;
argp->paramtype = agg_input_types[i];
argp->paramtypmod = -1;
args = lappend(args, argp);
}
@ -425,6 +427,7 @@ build_aggregate_fnexprs(Oid *agg_input_types,
argp->paramkind = PARAM_EXEC;
argp->paramid = -1;
argp->paramtype = agg_state_type;
argp->paramtypmod = -1;
args = list_make1(argp);
*finalfnexpr = (Expr *) makeFuncExpr(finalfn_oid,

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.146 2006/11/28 12:54:41 petere Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.147 2006/12/10 22:13:26 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -264,6 +264,14 @@ coerce_type(ParseState *pstate, Node *node,
}
param->paramtype = targetTypeId;
/*
* Note: it is tempting here to set the Param's paramtypmod to
* targetTypeMod, but that is probably unwise because we have no
* infrastructure that enforces that the value delivered for a
* Param will match any particular typmod. Leaving it -1 ensures
* that a run-time length check/coercion will occur if needed.
*/
param->paramtypmod = -1;
return (Node *) param;
}

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.198 2006/10/04 00:29:55 momjian Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.199 2006/12/10 22:13:26 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -572,6 +572,7 @@ transformParamRef(ParseState *pstate, ParamRef *pref)
param->paramkind = PARAM_EXTERN;
param->paramid = paramno;
param->paramtype = toppstate->p_paramtypes[paramno - 1];
param->paramtypmod = -1;
return (Node *) param;
}
@ -1180,6 +1181,7 @@ transformSubLink(ParseState *pstate, SubLink *sublink)
param->paramkind = PARAM_SUBLINK;
param->paramid = tent->resno;
param->paramtype = exprType((Node *) tent->expr);
param->paramtypmod = exprTypmod((Node *) tent->expr);
right_list = lappend(right_list, param);
}
@ -1721,6 +1723,8 @@ exprTypmod(Node *expr)
}
}
break;
case T_Param:
return ((Param *) expr)->paramtypmod;
case T_FuncExpr:
{
int32 coercedTypmod;