← Back to team overview

maria-developers team mailing list archive

constant propagation & LIKE


Hello Sergei,

The attached patch fixes
MDEV-7149 Constant propagation erroneously applied for LIKE

All tests pass.

But I'm not 100% sure about the patch.
Is eq_cmp_result() proper place to fix this?

If it's the right place, I can test the collation properties
and return:
- COND_TRUE for simple collations with one-character-to-one-weight rules,
- COND_OK for the complex collations with tricky character to weight mapping.

diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 87b19f4..a4ff780 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -1526,7 +1526,7 @@ class Item_func_like :public Item_bool_func2
   longlong val_int();
   enum Functype functype() const { return LIKE_FUNC; }
   optimize_type select_optimize() const;
-  cond_result eq_cmp_result() const { return COND_TRUE; }
+  cond_result eq_cmp_result() const { return COND_OK; }
   const char *func_name() const { return "like"; }
   bool fix_fields(THD *thd, Item **ref);
   void cleanup();