summaryrefslogtreecommitdiff
path: root/src/backend/optimizer
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/optimizer')
-rw-r--r--src/backend/optimizer/path/clausesel.c10
-rw-r--r--src/backend/optimizer/util/plancat.c26
2 files changed, 22 insertions, 14 deletions
diff --git a/src/backend/optimizer/path/clausesel.c b/src/backend/optimizer/path/clausesel.c
index ca068991c16..b9e97d414d8 100644
--- a/src/backend/optimizer/path/clausesel.c
+++ b/src/backend/optimizer/path/clausesel.c
@@ -579,6 +579,7 @@ clause_selectivity(PlannerInfo *root,
list_make2(var,
makeBoolConst(true,
false)),
+ InvalidOid,
varRelid);
}
}
@@ -650,13 +651,15 @@ clause_selectivity(PlannerInfo *root,
}
else if (is_opclause(clause) || IsA(clause, DistinctExpr))
{
- Oid opno = ((OpExpr *) clause)->opno;
+ OpExpr *opclause = (OpExpr *) clause;
+ Oid opno = opclause->opno;
if (treat_as_join_clause(clause, rinfo, varRelid, sjinfo))
{
/* Estimate selectivity for a join clause. */
s1 = join_selectivity(root, opno,
- ((OpExpr *) clause)->args,
+ opclause->args,
+ opclause->inputcollid,
jointype,
sjinfo);
}
@@ -664,7 +667,8 @@ clause_selectivity(PlannerInfo *root,
{
/* Estimate selectivity for a restriction clause. */
s1 = restriction_selectivity(root, opno,
- ((OpExpr *) clause)->args,
+ opclause->args,
+ opclause->inputcollid,
varRelid);
}
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index a92d2485289..77e701d2fc9 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -907,6 +907,7 @@ Selectivity
restriction_selectivity(PlannerInfo *root,
Oid operatorid,
List *args,
+ Oid inputcollid,
int varRelid)
{
RegProcedure oprrest = get_oprrest(operatorid);
@@ -919,11 +920,12 @@ restriction_selectivity(PlannerInfo *root,
if (!oprrest)
return (Selectivity) 0.5;
- result = DatumGetFloat8(OidFunctionCall4(oprrest,
- PointerGetDatum(root),
- ObjectIdGetDatum(operatorid),
- PointerGetDatum(args),
- Int32GetDatum(varRelid)));
+ result = DatumGetFloat8(OidFunctionCall4Coll(oprrest,
+ inputcollid,
+ PointerGetDatum(root),
+ ObjectIdGetDatum(operatorid),
+ PointerGetDatum(args),
+ Int32GetDatum(varRelid)));
if (result < 0.0 || result > 1.0)
elog(ERROR, "invalid restriction selectivity: %f", result);
@@ -942,6 +944,7 @@ Selectivity
join_selectivity(PlannerInfo *root,
Oid operatorid,
List *args,
+ Oid inputcollid,
JoinType jointype,
SpecialJoinInfo *sjinfo)
{
@@ -955,12 +958,13 @@ join_selectivity(PlannerInfo *root,
if (!oprjoin)
return (Selectivity) 0.5;
- result = DatumGetFloat8(OidFunctionCall5(oprjoin,
- PointerGetDatum(root),
- ObjectIdGetDatum(operatorid),
- PointerGetDatum(args),
- Int16GetDatum(jointype),
- PointerGetDatum(sjinfo)));
+ result = DatumGetFloat8(OidFunctionCall5Coll(oprjoin,
+ inputcollid,
+ PointerGetDatum(root),
+ ObjectIdGetDatum(operatorid),
+ PointerGetDatum(args),
+ Int16GetDatum(jointype),
+ PointerGetDatum(sjinfo)));
if (result < 0.0 || result > 1.0)
elog(ERROR, "invalid join selectivity: %f", result);