Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaa282d4

Browse files
committed
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 aglobal variable, and put the info into ParseState instead. This touchesa lot of files because of adjustment of routine parameter lists, butit's really not a large patch. Note: PREPARE statement still insists onexact specification of parameter types, but that could easily be relaxednow, if we wanted to do so.
1 parent19141f5 commitaa282d4

29 files changed

+441
-246
lines changed

‎src/backend/catalog/heap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.241 2003/03/23 05:14:36 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.242 2003/04/29 22:13:08 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1592,7 +1592,7 @@ AddRelationRawConstraints(Relation rel,
15921592
/*
15931593
* Make sure it yields a boolean result.
15941594
*/
1595-
expr=coerce_to_boolean(expr,"CHECK");
1595+
expr=coerce_to_boolean(pstate,expr,"CHECK");
15961596

15971597
/*
15981598
* Make sure no outside relations are referred to.
@@ -1743,7 +1743,7 @@ cookDefault(ParseState *pstate,
17431743
{
17441744
Oidtype_id=exprType(expr);
17451745

1746-
if (coerce_to_target_type(expr,type_id,
1746+
if (coerce_to_target_type(pstate,expr,type_id,
17471747
atttypid,atttypmod,
17481748
COERCION_ASSIGNMENT,
17491749
COERCE_IMPLICIT_CAST)==NULL)

‎src/backend/commands/schemacmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/schemacmds.c,v 1.7 2002/12/05 04:04:42 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/schemacmds.c,v 1.8 2003/04/29 22:13:08 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -124,7 +124,7 @@ CreateSchemaCommand(CreateSchemaStmt *stmt)
124124
List*querytree_list,
125125
*querytree_item;
126126

127-
querytree_list=parse_analyze(parsetree,NULL);
127+
querytree_list=parse_analyze(parsetree,NULL,0);
128128

129129
foreach(querytree_item,querytree_list)
130130
{

‎src/backend/commands/tablecmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.71 2003/04/21 15:19:55 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.72 2003/04/29 22:13:08 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2852,7 +2852,7 @@ AlterTableAddCheckConstraint(Relation rel, Constraint *constr)
28522852
/*
28532853
* Make sure it yields a boolean result.
28542854
*/
2855-
expr=coerce_to_boolean(expr,"CHECK");
2855+
expr=coerce_to_boolean(pstate,expr,"CHECK");
28562856

28572857
/*
28582858
* Make sure no outside relations are referred to.

‎src/backend/commands/typecmds.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.33 2003/04/08 16:57:45 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.34 2003/04/29 22:13:08 tgl Exp $
1212
*
1313
* DESCRIPTION
1414
* The "DefineFoo" routines take the parse tree and pick out the
@@ -1601,7 +1601,7 @@ domainAddConstraint(Oid domainOid, Oid domainNamespace, Oid baseTypeOid,
16011601
/*
16021602
* Make sure it yields a boolean result.
16031603
*/
1604-
expr=coerce_to_boolean(expr,"CHECK");
1604+
expr=coerce_to_boolean(pstate,expr,"CHECK");
16051605

16061606
/*
16071607
* Make sure no outside relations are

‎src/backend/executor/spi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.92 2003/04/2903:21:29 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.93 2003/04/2922:13:09 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -993,7 +993,7 @@ _SPI_execute(const char *src, int tcount, _SPI_plan *plan)
993993
/*
994994
* Parse the request string into a list of raw parse trees.
995995
*/
996-
raw_parsetree_list=pg_parse_query(src,argtypes,nargs);
996+
raw_parsetree_list=pg_parse_query(src);
997997

998998
/*
999999
* Do parse analysis and rule rewrite for each raw parsetree.
@@ -1036,7 +1036,7 @@ _SPI_execute(const char *src, int tcount, _SPI_plan *plan)
10361036
if (plan)
10371037
plan->origCmdType=origCmdType;
10381038

1039-
query_list=pg_analyze_and_rewrite(parsetree);
1039+
query_list=pg_analyze_and_rewrite(parsetree,argtypes,nargs);
10401040

10411041
query_list_list=lappend(query_list_list,query_list);
10421042

‎src/backend/optimizer/plan/subselect.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.74 2003/04/08 23:20:01 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.75 2003/04/29 22:13:09 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -495,10 +495,13 @@ convert_sublink_opers(List *lefthand, List *operOids,
495495
* Make the expression node.
496496
*
497497
* Note: we use make_op_expr in case runtime type conversion
498-
* function calls must be inserted for this operator!
498+
* function calls must be inserted for this operator! (But we
499+
* are not expecting to have to resolve unknown Params, so
500+
* it's okay to pass a null pstate.)
499501
*/
500502
result=lappend(result,
501-
make_op_expr(tup,
503+
make_op_expr(NULL,
504+
tup,
502505
leftop,
503506
rightop,
504507
exprType(leftop),

‎src/backend/optimizer/prep/prepunion.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
*
1616
* IDENTIFICATION
17-
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.93 2003/04/24 23:43:09 tgl Exp $
17+
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.94 2003/04/29 22:13:09 tgl Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
@@ -418,7 +418,8 @@ generate_setop_tlist(List *colTypes, int flag,
418418
}
419419
else
420420
{
421-
expr=coerce_to_common_type(expr,
421+
expr=coerce_to_common_type(NULL,/* no UNKNOWNs here */
422+
expr,
422423
colType,
423424
"UNION/INTERSECT/EXCEPT");
424425
colTypmod=-1;

‎src/backend/optimizer/util/clauses.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.135 2003/04/27 20:09:44 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.136 2003/04/29 22:13:09 tgl Exp $
1212
*
1313
* HISTORY
1414
* AUTHORDATEMAJOR EVENT
@@ -1747,17 +1747,17 @@ inline_function(Oid funcid, Oid result_type, List *args,
17471747

17481748
/*
17491749
* We just do parsing and parse analysis, not rewriting, because
1750-
* rewriting will not affect SELECT-only queries, which is all that
1751-
* we care about. Also, we can punt as soon as we detect more than
1750+
* rewriting will not affecttable-free-SELECT-only queries, which is all
1751+
*thatwe care about. Also, we can punt as soon as we detect more than
17521752
* one command in the function body.
17531753
*/
1754-
raw_parsetree_list=pg_parse_query(src,
1755-
funcform->proargtypes,
1756-
funcform->pronargs);
1754+
raw_parsetree_list=pg_parse_query(src);
17571755
if (length(raw_parsetree_list)!=1)
17581756
gotofail;
17591757

1760-
querytree_list=parse_analyze(lfirst(raw_parsetree_list),NULL);
1758+
querytree_list=parse_analyze(lfirst(raw_parsetree_list),
1759+
funcform->proargtypes,
1760+
funcform->pronargs);
17611761

17621762
if (length(querytree_list)!=1)
17631763
gotofail;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp