summaryrefslogtreecommitdiff
path: root/src/include/optimizer
diff options
context:
space:
mode:
authorTom Lane2011-03-20 00:29:08 +0000
committerTom Lane2011-03-20 00:30:08 +0000
commitb310b6e31ce5aa9e456c43c0e8e93248b0c84c02 (patch)
treee5168fcfdb231a9889e87e309f38a9e0f05a7896 /src/include/optimizer
parent025f4c72f029242a6aaf3f14bb6d7da4ce070f72 (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/include/optimizer')
-rw-r--r--src/include/optimizer/clauses.h3
-rw-r--r--src/include/optimizer/paths.h5
-rw-r--r--src/include/optimizer/planmain.h2
3 files changed, 8 insertions, 2 deletions
diff --git a/src/include/optimizer/clauses.h b/src/include/optimizer/clauses.h
index 945957244c..7ae236d167 100644
--- a/src/include/optimizer/clauses.h
+++ b/src/include/optimizer/clauses.h
@@ -36,7 +36,8 @@ typedef struct
extern Expr *make_opclause(Oid opno, Oid opresulttype, bool opretset,
- Expr *leftop, Expr *rightop);
+ Expr *leftop, Expr *rightop,
+ Oid opcollid, Oid inputcollid);
extern Node *get_leftop(Expr *clause);
extern Node *get_rightop(Expr *clause);
diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h
index ef769bf04d..06aed5f317 100644
--- a/src/include/optimizer/paths.h
+++ b/src/include/optimizer/paths.h
@@ -111,11 +111,14 @@ extern bool have_join_order_restriction(PlannerInfo *root,
*/
extern bool process_equivalence(PlannerInfo *root, RestrictInfo *restrictinfo,
bool below_outer_join);
+extern Expr *canonicalize_ec_expression(Expr *expr,
+ Oid req_type, Oid req_collation);
extern void reconsider_outer_join_clauses(PlannerInfo *root);
extern EquivalenceClass *get_eclass_for_sort_expr(PlannerInfo *root,
Expr *expr,
- Oid expr_datatype,
List *opfamilies,
+ Oid opcintype,
+ Oid collation,
Index sortref,
bool create_it);
extern void generate_base_implied_equalities(PlannerInfo *root);
diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h
index 7e03bc924e..d48bf39e41 100644
--- a/src/include/optimizer/planmain.h
+++ b/src/include/optimizer/planmain.h
@@ -98,12 +98,14 @@ extern void distribute_restrictinfo_to_rels(PlannerInfo *root,
RestrictInfo *restrictinfo);
extern void process_implied_equality(PlannerInfo *root,
Oid opno,
+ Oid collation,
Expr *item1,
Expr *item2,
Relids qualscope,
bool below_outer_join,
bool both_const);
extern RestrictInfo *build_implied_join_equality(Oid opno,
+ Oid collation,
Expr *item1,
Expr *item2,
Relids qualscope);