1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-07 19:06:32 +03:00

Infrastructure for deducing Param types from context, in the same way

that the types of untyped string-literal constants are deduced (ie,
when coerce_type is applied to 'em, that's what the type must be).
Remove the ancient hack of storing the input Param-types array as a
global variable, and put the info into ParseState instead.  This touches
a lot of files because of adjustment of routine parameter lists, but
it's really not a large patch.  Note: PREPARE statement still insists on
exact specification of parameter types, but that could easily be relaxed
now, if we wanted to do so.
This commit is contained in:
Tom Lane
2003-04-29 22:13:11 +00:00
parent 19141f5584
commit aa282d4446
29 changed files with 442 additions and 247 deletions

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.74 2003/04/08 23:20:01 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.75 2003/04/29 22:13:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -495,10 +495,13 @@ convert_sublink_opers(List *lefthand, List *operOids,
* Make the expression node.
*
* Note: we use make_op_expr in case runtime type conversion
* function calls must be inserted for this operator!
* function calls must be inserted for this operator! (But we
* are not expecting to have to resolve unknown Params, so
* it's okay to pass a null pstate.)
*/
result = lappend(result,
make_op_expr(tup,
make_op_expr(NULL,
tup,
leftop,
rightop,
exprType(leftop),

View File

@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.93 2003/04/24 23:43:09 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.94 2003/04/29 22:13:09 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -418,7 +418,8 @@ generate_setop_tlist(List *colTypes, int flag,
}
else
{
expr = coerce_to_common_type(expr,
expr = coerce_to_common_type(NULL, /* no UNKNOWNs here */
expr,
colType,
"UNION/INTERSECT/EXCEPT");
colTypmod = -1;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.135 2003/04/27 20:09:44 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.136 2003/04/29 22:13:09 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -1747,17 +1747,17 @@ inline_function(Oid funcid, Oid result_type, List *args,
/*
* We just do parsing and parse analysis, not rewriting, because
* rewriting will not affect SELECT-only queries, which is all that
* we care about. Also, we can punt as soon as we detect more than
* rewriting will not affect table-free-SELECT-only queries, which is all
* that we care about. Also, we can punt as soon as we detect more than
* one command in the function body.
*/
raw_parsetree_list = pg_parse_query(src,
funcform->proargtypes,
funcform->pronargs);
raw_parsetree_list = pg_parse_query(src);
if (length(raw_parsetree_list) != 1)
goto fail;
querytree_list = parse_analyze(lfirst(raw_parsetree_list), NULL);
querytree_list = parse_analyze(lfirst(raw_parsetree_list),
funcform->proargtypes,
funcform->pronargs);
if (length(querytree_list) != 1)
goto fail;