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)
result_field(item->result_field)
{
collation.set(DERIVATION_IMPLICIT);
item_equal= item.item_equal;
item_equal= item->item_equal;
}
void Item_field::set_field(Field *field_par)
......@@ -1002,6 +1002,7 @@ void Item_field::cleanup()
{
Item_ident::cleanup();
field= result_field= 0;
}
/*
Find a field among specified multiple equalities
......
......@@ -1530,21 +1530,21 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func,
switch (cond_func->functype()) {
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);
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,
value, cmp_type));
}
break;
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);
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,
cond_func->arguments()[2],
cmp_type));
......@@ -1553,7 +1553,7 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func,
case Item_func::IN_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);
if (tree)
{
......@@ -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;
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,
*arg,
cmp_type));
......@@ -1581,7 +1581,7 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func,
Item_func::Functype func_type=
(value != cond_func->arguments()[0]) ? cond_func->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)
Item_result cmp_type= field->cmp_type();
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);
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,
add_key_field()
key_fields Pointer to add key, if usable
and_level And level, to be stored in KEY_FIELD
cond Condition predicate
field Field used in comparision
eq_func True if we used =, <=> or IS NULL
value Value used for comparison with field
......@@ -2205,8 +2206,8 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end,
*/
static void
add_key_field(KEY_FIELD **key_fields,uint and_level, COND *cond,
Field *field,bool eq_func,Item **value, uint num_values,
add_key_field(KEY_FIELD **key_fields, uint and_level, COND *cond,
Field *field, bool eq_func, Item **value, uint num_values,
table_map usable_tables)
{
uint exists_optimize= 0;
......@@ -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
SYNPOSIS
add_key_equal_field()
add_key_equal_fields()
key_fields Pointer to add key, if usable
and_level And level, to be stored in KEY_FIELD
cond Condition predicate
field Field used in comparision
eq_func True if we used =, <=> or IS NULL
value Value used for comparison with field
......@@ -2324,12 +2326,12 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, COND *cond,
static void
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,
uint num_values, table_map usable_tables)
{
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);
Item_equal *item_equal= field_item->item_equal;
if (item_equal)
......@@ -2344,7 +2346,7 @@ add_key_equal_fields(KEY_FIELD **key_fields, uint and_level,
{
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);
}
}
......@@ -2396,7 +2398,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level,
// BETWEEN or IN
if (cond_func->key_item()->real_item()->type() == Item::FIELD_ITEM &&
!(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()),
0, cond_func->arguments()+1,
cond_func->argument_count()-1,
......@@ -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 &&
!(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(),
equal_func,
cond_func->arguments()+1, 1, usable_tables);
......@@ -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->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(),
equal_func,
cond_func->arguments(),1,usable_tables);
......@@ -2434,7 +2436,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level,
Item *tmp=new Item_null;
if (!tmp) // Should never be true
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(),
cond_func->functype() == Item_func::ISNULL_FUNC,
&tmp, 1, usable_tables);
......@@ -2454,7 +2456,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level,
*/
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);
}
}
......@@ -2474,7 +2476,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level,
{
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);
}
}
......
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