Commit efaf0f0d authored by unknown's avatar unknown

sql_select.cc, opt_range.cc, item.cc:

  After merge fixes.


sql/item.cc:
  After merge fixes.
sql/opt_range.cc:
  After merge fixes.
sql/sql_select.cc:
  After merge fixes.
parent fd98ed36
...@@ -333,7 +333,7 @@ Item_field::Item_field(THD *thd, Item_field *item) ...@@ -333,7 +333,7 @@ Item_field::Item_field(THD *thd, Item_field *item)
result_field(item->result_field) result_field(item->result_field)
{ {
collation.set(DERIVATION_IMPLICIT); collation.set(DERIVATION_IMPLICIT);
item_equal= item.item_equal; item_equal= item->item_equal;
} }
void Item_field::set_field(Field *field_par) void Item_field::set_field(Field *field_par)
...@@ -1002,6 +1002,7 @@ void Item_field::cleanup() ...@@ -1002,6 +1002,7 @@ void Item_field::cleanup()
{ {
Item_ident::cleanup(); Item_ident::cleanup();
field= result_field= 0; field= result_field= 0;
}
/* /*
Find a field among specified multiple equalities Find a field among specified multiple equalities
......
...@@ -1530,21 +1530,21 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func, ...@@ -1530,21 +1530,21 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func,
switch (cond_func->functype()) { switch (cond_func->functype()) {
case Item_func::NE_FUNC: case Item_func::NE_FUNC:
tree= get_mm_parts(param, field, Item_func::LT_FUNC, tree= get_mm_parts(param, cond_func, field, Item_func::LT_FUNC,
value, cmp_type); value, cmp_type);
if (tree) if (tree)
{ {
tree= tree_or(param, tree, get_mm_parts(param, field, tree= tree_or(param, tree, get_mm_parts(param, cond_func, field,
Item_func::GT_FUNC, Item_func::GT_FUNC,
value, cmp_type)); value, cmp_type));
} }
break; break;
case Item_func::BETWEEN: case Item_func::BETWEEN:
tree= get_mm_parts(param, field, Item_func::GE_FUNC, tree= get_mm_parts(param, cond_func, field, Item_func::GE_FUNC,
cond_func->arguments()[1],cmp_type); cond_func->arguments()[1],cmp_type);
if (tree) if (tree)
{ {
tree= tree_and(param, tree, get_mm_parts(param, field, tree= tree_and(param, tree, get_mm_parts(param, cond_func, field,
Item_func::LE_FUNC, Item_func::LE_FUNC,
cond_func->arguments()[2], cond_func->arguments()[2],
cmp_type)); cmp_type));
...@@ -1553,7 +1553,7 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func, ...@@ -1553,7 +1553,7 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func,
case Item_func::IN_FUNC: case Item_func::IN_FUNC:
{ {
Item_func_in *func=(Item_func_in*) cond_func; Item_func_in *func=(Item_func_in*) cond_func;
tree= get_mm_parts(param, field, Item_func::EQ_FUNC, tree= get_mm_parts(param, cond_func, field, Item_func::EQ_FUNC,
func->arguments()[1], cmp_type); func->arguments()[1], cmp_type);
if (tree) if (tree)
{ {
...@@ -1561,7 +1561,7 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func, ...@@ -1561,7 +1561,7 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func,
for (arg= func->arguments()+2, end= arg+func->argument_count()-2; for (arg= func->arguments()+2, end= arg+func->argument_count()-2;
arg < end ; arg++) arg < end ; arg++)
{ {
tree= tree_or(param, tree, get_mm_parts(param, field, tree= tree_or(param, tree, get_mm_parts(param, cond_func, field,
Item_func::EQ_FUNC, Item_func::EQ_FUNC,
*arg, *arg,
cmp_type)); cmp_type));
...@@ -1581,7 +1581,7 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func, ...@@ -1581,7 +1581,7 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func,
Item_func::Functype func_type= Item_func::Functype func_type=
(value != cond_func->arguments()[0]) ? cond_func->functype() : (value != cond_func->arguments()[0]) ? cond_func->functype() :
((Item_bool_func2*) cond_func)->rev_functype(); ((Item_bool_func2*) cond_func)->rev_functype();
tree= get_mm_parts(param, field, func_type, value, cmp_type); tree= get_mm_parts(param, cond_func, field, func_type, value, cmp_type);
} }
} }
...@@ -1690,7 +1690,7 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond) ...@@ -1690,7 +1690,7 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond)
Item_result cmp_type= field->cmp_type(); Item_result cmp_type= field->cmp_type();
if (!((ref_tables | field->table->map) & param_comp)) if (!((ref_tables | field->table->map) & param_comp))
{ {
tree= get_mm_parts(param, field, Item_func::EQ_FUNC, tree= get_mm_parts(param, cond, field, Item_func::EQ_FUNC,
value,cmp_type); value,cmp_type);
ftree= !ftree ? tree : tree_and(param, ftree, tree); ftree= !ftree ? tree : tree_and(param, ftree, tree);
} }
......
...@@ -2190,6 +2190,7 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end, ...@@ -2190,6 +2190,7 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end,
add_key_field() add_key_field()
key_fields Pointer to add key, if usable key_fields Pointer to add key, if usable
and_level And level, to be stored in KEY_FIELD and_level And level, to be stored in KEY_FIELD
cond Condition predicate
field Field used in comparision field Field used in comparision
eq_func True if we used =, <=> or IS NULL eq_func True if we used =, <=> or IS NULL
value Value used for comparison with field value Value used for comparison with field
...@@ -2205,8 +2206,8 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end, ...@@ -2205,8 +2206,8 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end,
*/ */
static void static void
add_key_field(KEY_FIELD **key_fields,uint and_level, COND *cond, add_key_field(KEY_FIELD **key_fields, uint and_level, COND *cond,
Field *field,bool eq_func,Item **value, uint num_values, Field *field, bool eq_func, Item **value, uint num_values,
table_map usable_tables) table_map usable_tables)
{ {
uint exists_optimize= 0; uint exists_optimize= 0;
...@@ -2305,9 +2306,10 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, COND *cond, ...@@ -2305,9 +2306,10 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, COND *cond,
Add possible keys to array of possible keys originated from a simple predicate Add possible keys to array of possible keys originated from a simple predicate
SYNPOSIS SYNPOSIS
add_key_equal_field() add_key_equal_fields()
key_fields Pointer to add key, if usable key_fields Pointer to add key, if usable
and_level And level, to be stored in KEY_FIELD and_level And level, to be stored in KEY_FIELD
cond Condition predicate
field Field used in comparision field Field used in comparision
eq_func True if we used =, <=> or IS NULL eq_func True if we used =, <=> or IS NULL
value Value used for comparison with field value Value used for comparison with field
...@@ -2324,12 +2326,12 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, COND *cond, ...@@ -2324,12 +2326,12 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, COND *cond,
static void static void
add_key_equal_fields(KEY_FIELD **key_fields, uint and_level, add_key_equal_fields(KEY_FIELD **key_fields, uint and_level,
Item_field *field_item, COND *cond, Item_field *field_item,
bool eq_func, Item **val, bool eq_func, Item **val,
uint num_values, table_map usable_tables) uint num_values, table_map usable_tables)
{ {
Field *field= field_item->field; Field *field= field_item->field;
add_key_field(key_fields, and_level, field, add_key_field(key_fields, and_level, cond, field,
eq_func, val, num_values, usable_tables); eq_func, val, num_values, usable_tables);
Item_equal *item_equal= field_item->item_equal; Item_equal *item_equal= field_item->item_equal;
if (item_equal) if (item_equal)
...@@ -2344,7 +2346,7 @@ add_key_equal_fields(KEY_FIELD **key_fields, uint and_level, ...@@ -2344,7 +2346,7 @@ add_key_equal_fields(KEY_FIELD **key_fields, uint and_level,
{ {
if (!field->eq(item->field)) if (!field->eq(item->field))
{ {
add_key_field(key_fields, and_level, item->field, add_key_field(key_fields, and_level, cond, item->field,
eq_func, val, num_values, usable_tables); eq_func, val, num_values, usable_tables);
} }
} }
...@@ -2396,7 +2398,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, ...@@ -2396,7 +2398,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level,
// BETWEEN or IN // BETWEEN or IN
if (cond_func->key_item()->real_item()->type() == Item::FIELD_ITEM && if (cond_func->key_item()->real_item()->type() == Item::FIELD_ITEM &&
!(cond_func->used_tables() & OUTER_REF_TABLE_BIT)) !(cond_func->used_tables() & OUTER_REF_TABLE_BIT))
add_key_equal_fields(key_fields,*and_level, add_key_equal_fields(key_fields, *and_level, cond_func,
(Item_field*) (cond_func->key_item()->real_item()), (Item_field*) (cond_func->key_item()->real_item()),
0, cond_func->arguments()+1, 0, cond_func->arguments()+1,
cond_func->argument_count()-1, cond_func->argument_count()-1,
...@@ -2410,7 +2412,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, ...@@ -2410,7 +2412,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level,
if (cond_func->arguments()[0]->real_item()->type() == Item::FIELD_ITEM && if (cond_func->arguments()[0]->real_item()->type() == Item::FIELD_ITEM &&
!(cond_func->arguments()[0]->used_tables() & OUTER_REF_TABLE_BIT)) !(cond_func->arguments()[0]->used_tables() & OUTER_REF_TABLE_BIT))
{ {
add_key_equal_fields(key_fields, *and_level, add_key_equal_fields(key_fields, *and_level, cond_func,
(Item_field*) (cond_func->arguments()[0])->real_item(), (Item_field*) (cond_func->arguments()[0])->real_item(),
equal_func, equal_func,
cond_func->arguments()+1, 1, usable_tables); cond_func->arguments()+1, 1, usable_tables);
...@@ -2419,7 +2421,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, ...@@ -2419,7 +2421,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level,
cond_func->functype() != Item_func::LIKE_FUNC && cond_func->functype() != Item_func::LIKE_FUNC &&
!(cond_func->arguments()[1]->used_tables() & OUTER_REF_TABLE_BIT)) !(cond_func->arguments()[1]->used_tables() & OUTER_REF_TABLE_BIT))
{ {
add_key_equal_fields(key_fields,*and_level, add_key_equal_fields(key_fields, *and_level, cond_func,
(Item_field*) (cond_func->arguments()[1])->real_item(), (Item_field*) (cond_func->arguments()[1])->real_item(),
equal_func, equal_func,
cond_func->arguments(),1,usable_tables); cond_func->arguments(),1,usable_tables);
...@@ -2434,7 +2436,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, ...@@ -2434,7 +2436,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level,
Item *tmp=new Item_null; Item *tmp=new Item_null;
if (!tmp) // Should never be true if (!tmp) // Should never be true
return; return;
add_key_equal_fields(key_fields,*and_level, add_key_equal_fields(key_fields, *and_level, cond_func,
(Item_field*) (cond_func->arguments()[0])->real_item(), (Item_field*) (cond_func->arguments()[0])->real_item(),
cond_func->functype() == Item_func::ISNULL_FUNC, cond_func->functype() == Item_func::ISNULL_FUNC,
&tmp, 1, usable_tables); &tmp, 1, usable_tables);
...@@ -2454,7 +2456,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, ...@@ -2454,7 +2456,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level,
*/ */
while ((item= it++)) while ((item= it++))
{ {
add_key_field(key_fields, *and_level, item->field, add_key_field(key_fields, *and_level, cond, item->field,
TRUE, &const_item, 1, usable_tables); TRUE, &const_item, 1, usable_tables);
} }
} }
...@@ -2474,7 +2476,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, ...@@ -2474,7 +2476,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level,
{ {
if (!field->eq(item->field)) if (!field->eq(item->field))
{ {
add_key_field(key_fields, *and_level, field, add_key_field(key_fields, *and_level, cond, field,
TRUE, (Item **) &item, 1, usable_tables); TRUE, (Item **) &item, 1, usable_tables);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment