diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2011-03-19 20:29:08 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2011-03-19 20:30:08 -0400 |
commit | b310b6e31ce5aa9e456c43c0e8e93248b0c84c02 (patch) | |
tree | e5168fcfdb231a9889e87e309f38a9e0f05a7896 /src/backend/parser/parse_agg.c | |
parent | 025f4c72f029242a6aaf3f14bb6d7da4ce070f72 (diff) |
Revise collation derivation method and expression-tree representation.
All expression nodes now have an explicit output-collation field, unless
they are known to only return a noncollatable data type (such as boolean
or record). Also, nodes that can invoke collation-aware functions store
a separate field that is the collation value to pass to the function.
This avoids confusion that arises when a function has collatable inputs
and noncollatable output type, or vice versa.
Also, replace the parser's on-the-fly collation assignment method with
a post-pass over the completed expression tree. This allows us to use
a more complex (and hopefully more nearly spec-compliant) assignment
rule without paying for it in extra storage in every expression node.
Fix assorted bugs in the planner's handling of collations by making
collation one of the defining properties of an EquivalenceClass and
by converting CollateExprs into discardable RelabelType nodes during
expression preprocessing.
Diffstat (limited to 'src/backend/parser/parse_agg.c')
-rw-r--r-- | src/backend/parser/parse_agg.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/backend/parser/parse_agg.c b/src/backend/parser/parse_agg.c index 8267627c42f..523d6e6989a 100644 --- a/src/backend/parser/parse_agg.c +++ b/src/backend/parser/parse_agg.c @@ -709,6 +709,7 @@ check_ungrouped_columns_walker(Node *node, * agg_input_types, agg_state_type, agg_result_type identify the input, * transition, and result types of the aggregate. These should all be * resolved to actual types (ie, none should ever be ANYELEMENT etc). + * agg_input_collation is the aggregate function's input collation. * * transfn_oid and finalfn_oid identify the funcs to be called; the latter * may be InvalidOid. @@ -721,9 +722,9 @@ build_aggregate_fnexprs(Oid *agg_input_types, int agg_num_inputs, Oid agg_state_type, Oid agg_result_type, + Oid agg_input_collation, Oid transfn_oid, Oid finalfn_oid, - Oid collation, Expr **transfnexpr, Expr **finalfnexpr) { @@ -742,7 +743,7 @@ build_aggregate_fnexprs(Oid *agg_input_types, argp->paramid = -1; argp->paramtype = agg_state_type; argp->paramtypmod = -1; - argp->paramcollation = collation; + argp->paramcollid = agg_input_collation; argp->location = -1; args = list_make1(argp); @@ -754,7 +755,7 @@ build_aggregate_fnexprs(Oid *agg_input_types, argp->paramid = -1; argp->paramtype = agg_input_types[i]; argp->paramtypmod = -1; - argp->paramcollation = collation; + argp->paramcollid = agg_input_collation; argp->location = -1; args = lappend(args, argp); } @@ -762,7 +763,8 @@ build_aggregate_fnexprs(Oid *agg_input_types, *transfnexpr = (Expr *) makeFuncExpr(transfn_oid, agg_state_type, args, - collation, + InvalidOid, + agg_input_collation, COERCE_DONTCARE); /* see if we have a final function */ @@ -780,13 +782,14 @@ build_aggregate_fnexprs(Oid *agg_input_types, argp->paramid = -1; argp->paramtype = agg_state_type; argp->paramtypmod = -1; - argp->paramcollation = collation; + argp->paramcollid = agg_input_collation; argp->location = -1; args = list_make1(argp); *finalfnexpr = (Expr *) makeFuncExpr(finalfn_oid, agg_result_type, args, - collation, + InvalidOid, + agg_input_collation, COERCE_DONTCARE); } |