@@ -122,6 +122,31 @@ class Arg_comparator: public Sql_alloc
122
122
123
123
class Item_bool_func :public Item_int_func
124
124
{
125
+ protected:
126
+ /*
127
+ Build a SEL_TREE for a simple predicate
128
+ @param param PARAM from SQL_SELECT::test_quick_select
129
+ @param field field in the predicate
130
+ @param value constant in the predicate
131
+ @param cmp_type compare type for the field
132
+ @return Pointer to the tree built tree
133
+ */
134
+ virtual SEL_TREE *get_func_mm_tree (RANGE_OPT_PARAM *param,
135
+ Field *field, Item *value,
136
+ Item_result cmp_type)
137
+ {
138
+ DBUG_ENTER (" Item_bool_func2::get_func_mm_tree" );
139
+ DBUG_ASSERT (0 );
140
+ DBUG_RETURN (0 );
141
+ }
142
+ SEL_TREE *get_full_func_mm_tree (RANGE_OPT_PARAM *param,
143
+ Item_field *field_item, Item *value);
144
+ SEL_TREE *get_mm_parts (RANGE_OPT_PARAM *param, Field *field,
145
+ Item_func::Functype type,
146
+ Item *value, Item_result cmp_type);
147
+ SEL_TREE *get_ne_mm_tree (RANGE_OPT_PARAM *param,
148
+ Field *field, Item *lt_value, Item *gt_value,
149
+ Item_result cmp_type);
125
150
public:
126
151
Item_bool_func () :Item_int_func() {}
127
152
Item_bool_func (Item *a) :Item_int_func(a) {}
@@ -291,6 +316,21 @@ class Item_bool_func2 :public Item_bool_func
291
316
void add_key_fields_optimize_op (JOIN *join, KEY_FIELD **key_fields,
292
317
uint *and_level, table_map usable_tables,
293
318
SARGABLE_PARAM **sargables, bool equal_func);
319
+ SEL_TREE *get_func_mm_tree (RANGE_OPT_PARAM *param,
320
+ Field *field, Item *value, Item_result cmp_type)
321
+ {
322
+ DBUG_ENTER (" Item_bool_func2::get_func_mm_tree" );
323
+ /*
324
+ Here the function for the following predicates are processed:
325
+ <, <=, =, <=>, >=, >, LIKE, spatial relations
326
+ If the predicate is of the form (value op field) it is handled
327
+ as the equivalent predicate (field rev_op value), e.g.
328
+ 2 <= a is handled as a >= 2.
329
+ */
330
+ Item_func::Functype func_type=
331
+ (value != arguments ()[0 ]) ? functype () : rev_functype ();
332
+ DBUG_RETURN (get_mm_parts (param, field, func_type, value, cmp_type));
333
+ }
294
334
public:
295
335
Item_bool_func2 (Item *a,Item *b)
296
336
:Item_bool_func(a,b) { }
@@ -587,6 +627,13 @@ class Item_func_lt :public Item_bool_rowready_func2
587
627
588
628
class Item_func_ne :public Item_bool_rowready_func2
589
629
{
630
+ protected:
631
+ SEL_TREE *get_func_mm_tree (RANGE_OPT_PARAM *param,
632
+ Field *field, Item *value, Item_result cmp_type)
633
+ {
634
+ DBUG_ENTER (" Item_func_ne::get_func_mm_tree" );
635
+ DBUG_RETURN (get_ne_mm_tree (param, field, value, value, cmp_type));
636
+ }
590
637
public:
591
638
Item_func_ne (Item *a,Item *b) :Item_bool_rowready_func2(a,b) {}
592
639
longlong val_int ();
@@ -635,6 +682,9 @@ class Item_func_opt_neg :public Item_bool_func
635
682
class Item_func_between :public Item_func_opt_neg
636
683
{
637
684
DTCollation cmp_collation;
685
+ protected:
686
+ SEL_TREE *get_func_mm_tree (RANGE_OPT_PARAM *param,
687
+ Field *field, Item *value, Item_result cmp_type);
638
688
public:
639
689
Item_result cmp_type;
640
690
String value0,value1,value2;
@@ -1292,6 +1342,9 @@ class Item_func_case :public Item_func_hybrid_field_type
1292
1342
*/
1293
1343
class Item_func_in :public Item_func_opt_neg
1294
1344
{
1345
+ protected:
1346
+ SEL_TREE *get_func_mm_tree (RANGE_OPT_PARAM *param,
1347
+ Field *field, Item *value, Item_result cmp_type);
1295
1348
public:
1296
1349
/*
1297
1350
an array of values when the right hand arguments of IN
@@ -1377,6 +1430,13 @@ class in_row :public in_vector
1377
1430
/* Functions used by where clause */
1378
1431
class Item_func_null_predicate :public Item_bool_func
1379
1432
{
1433
+ protected:
1434
+ SEL_TREE *get_func_mm_tree (RANGE_OPT_PARAM *param,
1435
+ Field *field, Item *value, Item_result cmp_type)
1436
+ {
1437
+ DBUG_ENTER (" Item_func_null_predicate::get_func_mm_tree" );
1438
+ DBUG_RETURN (get_mm_parts (param, field, functype (), value, cmp_type));
1439
+ }
1380
1440
public:
1381
1441
Item_func_null_predicate (Item *a) :Item_bool_func(a) { }
1382
1442
void add_key_fields (JOIN *join, KEY_FIELD **key_fields, uint *and_level,
0 commit comments