Hi! I think your work is important)
I started reviewing it and want to suggest some changes to better code:
I think we should consider the case where the expression is not neither
an OpExpr and VarOpVar expression.
Have you tested this code with any benchmarks?
--
Regards,
Alena Rybakina
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
diff --git a/src/backend/statistics/extended_stats.c
b/src/backend/statistics/extended_stats.c
index cb7d6d04ce5..07b3610d24e 100644
--- a/src/backend/statistics/extended_stats.c
+++ b/src/backend/statistics/extended_stats.c
@@ -1432,6 +1432,8 @@ statext_is_compatible_clause_internal(PlannerInfo *root,
Node *clause,
return true;
}
+ else
+ return false;
}
/* Var/Expr IN Array */
@@ -2137,13 +2139,13 @@ examine_opclause_args(List *args, Node **exprp, Const
**cstp,
* non-null pointers (exprp_left, exprp_right).
*/
bool
-is_opclause_var_op_var(List *args, Node **exprp_left, Node **exprp_right)
+is_opclause_var_op_var(List *args, Node **expr_left, Node **expr_right)
{
Node *leftop,
*rightop;
- Node *expr_left,
- *expr_right;
-
+
+ *expr_left = NULL;
+ *expr_right = NULL;
/* enforced by statext_is_compatible_clause_internal */
Assert(list_length(args) == 2);
@@ -2157,20 +2159,16 @@ is_opclause_var_op_var(List *args, Node **exprp_left,
Node **exprp_right)
if (IsA(rightop, RelabelType))
rightop = (Node *) ((RelabelType *) rightop)->arg;
+
if (IsA(rightop, Var) && IsA(leftop, Var))
{
- expr_left = (Node *) leftop;
- expr_right = (Node *) rightop;
+ *expr_left = (Node *) leftop;
+ *expr_right = (Node *) rightop;
}
else
return false;
- /* return pointers to the extracted parts if requested */
- if (exprp_left && exprp_right)
- {
- *exprp_left = expr_left;
- *exprp_right = expr_right;
- }
+ Assert(expr_left && expr_right);
return true;
}
diff --git a/src/backend/statistics/mcv.c b/src/backend/statistics/mcv.c
index 2e2c028e0f0..dd1a1c0c829 100644
--- a/src/backend/statistics/mcv.c
+++ b/src/backend/statistics/mcv.c
@@ -1745,6 +1745,8 @@ mcv_get_match_bitmap(PlannerInfo *root, List *clauses,
item->values[idx_right]));
}
}
+ else
+ elog(ERROR, "incompatible clause");
}
else if (IsA(clause, ScalarArrayOpExpr))
{