1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Merge mysql-next-mr --> mysql-trunk-signal

This commit is contained in:
Marc Alff
2009-09-17 03:20:11 -06:00
168 changed files with 6871 additions and 909 deletions

View File

@ -1526,12 +1526,8 @@ JOIN::optimize()
}
}
/*
If this join belongs to an uncacheable subquery save
the original join
*/
if (select_lex->uncacheable && !is_top_level_join() &&
init_save_join_tab())
/* If this join belongs to an uncacheable query save the original join */
if (select_lex->uncacheable && init_save_join_tab())
DBUG_RETURN(-1); /* purecov: inspected */
}
@ -2255,7 +2251,7 @@ JOIN::destroy()
tab->cleanup();
}
tmp_join->tmp_join= 0;
tmp_table_param.copy_field=0;
tmp_table_param.cleanup();
DBUG_RETURN(tmp_join->destroy());
}
cond_equal= 0;
@ -3302,6 +3298,28 @@ add_key_equal_fields(KEY_FIELD **key_fields, uint and_level,
}
}
/**
Check if an expression is a non-outer field.
Checks if an expression is a field and belongs to the current select.
@param field Item expression to check
@return boolean
@retval TRUE the expression is a local field
@retval FALSE it's something else
*/
inline static bool
is_local_field (Item *field)
{
field= field->real_item();
return field->type() == Item::FIELD_ITEM &&
!((Item_field *)field)->depended_from;
}
static void
add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
COND *cond, table_map usable_tables,
@ -3377,13 +3395,12 @@ add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
{
Item **values;
// BETWEEN, IN, NE
if (cond_func->key_item()->real_item()->type() == Item::FIELD_ITEM &&
if (is_local_field (cond_func->key_item()) &&
!(cond_func->used_tables() & OUTER_REF_TABLE_BIT))
{
values= cond_func->arguments()+1;
if (cond_func->functype() == Item_func::NE_FUNC &&
cond_func->arguments()[1]->real_item()->type() == Item::FIELD_ITEM &&
!(cond_func->arguments()[0]->used_tables() & OUTER_REF_TABLE_BIT))
is_local_field (cond_func->arguments()[1]))
values--;
DBUG_ASSERT(cond_func->functype() != Item_func::IN_FUNC ||
cond_func->argument_count() != 2);
@ -3399,9 +3416,7 @@ add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
for (uint i= 1 ; i < cond_func->argument_count() ; i++)
{
Item_field *field_item;
if (cond_func->arguments()[i]->real_item()->type() == Item::FIELD_ITEM
&&
!(cond_func->arguments()[i]->used_tables() & OUTER_REF_TABLE_BIT))
if (is_local_field (cond_func->arguments()[i]))
{
field_item= (Item_field *) (cond_func->arguments()[i]->real_item());
add_key_equal_fields(key_fields, *and_level, cond_func,
@ -3417,8 +3432,7 @@ add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
bool equal_func=(cond_func->functype() == Item_func::EQ_FUNC ||
cond_func->functype() == Item_func::EQUAL_FUNC);
if (cond_func->arguments()[0]->real_item()->type() == Item::FIELD_ITEM &&
!(cond_func->arguments()[0]->used_tables() & OUTER_REF_TABLE_BIT))
if (is_local_field (cond_func->arguments()[0]))
{
add_key_equal_fields(key_fields, *and_level, cond_func,
(Item_field*) (cond_func->arguments()[0])->real_item(),
@ -3426,9 +3440,8 @@ add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
cond_func->arguments()+1, 1, usable_tables,
sargables);
}
if (cond_func->arguments()[1]->real_item()->type() == Item::FIELD_ITEM &&
cond_func->functype() != Item_func::LIKE_FUNC &&
!(cond_func->arguments()[1]->used_tables() & OUTER_REF_TABLE_BIT))
if (is_local_field (cond_func->arguments()[1]) &&
cond_func->functype() != Item_func::LIKE_FUNC)
{
add_key_equal_fields(key_fields, *and_level, cond_func,
(Item_field*) (cond_func->arguments()[1])->real_item(),
@ -3440,7 +3453,7 @@ add_key_fields(JOIN *join, KEY_FIELD **key_fields, uint *and_level,
}
case Item_func::OPTIMIZE_NULL:
/* column_name IS [NOT] NULL */
if (cond_func->arguments()[0]->real_item()->type() == Item::FIELD_ITEM &&
if (is_local_field (cond_func->arguments()[0]) &&
!(cond_func->used_tables() & OUTER_REF_TABLE_BIT))
{
Item *tmp=new Item_null;
@ -13670,7 +13683,10 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field,
if (error)
{
if (error == HA_ERR_RECORD_DELETED)
continue;
{
error= file->rnd_next(record);
continue;
}
if (error == HA_ERR_END_OF_FILE)
break;
goto err;