mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge 4.1 -> 5.0.
This commit is contained in:
@ -296,6 +296,7 @@ typedef struct st_qsel_param {
|
||||
char min_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH],
|
||||
max_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH];
|
||||
bool quick; // Don't calulate possible keys
|
||||
COND *cond;
|
||||
|
||||
uint *imerge_cost_buff; /* buffer for index_merge cost estimates */
|
||||
uint imerge_cost_buff_size; /* size of the buffer */
|
||||
@ -807,6 +808,7 @@ SEL_ARG *SEL_ARG::clone(SEL_ARG *new_parent,SEL_ARG **next_arg)
|
||||
return 0; // OOM
|
||||
}
|
||||
increment_use_count(1);
|
||||
tmp->color= color;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@ -969,7 +971,6 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use,
|
||||
param.keys=0;
|
||||
param.mem_root= &alloc;
|
||||
param.imerge_cost_buff_size= 0;
|
||||
|
||||
thd->no_errors=1; // Don't warn about NULL
|
||||
init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0);
|
||||
if (!(param.key_parts = (KEY_PART*) alloc_root(&alloc,
|
||||
@ -1570,6 +1571,8 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond)
|
||||
if (cond_func->select_optimize() == Item_func::OPTIMIZE_NONE)
|
||||
DBUG_RETURN(0); // Can't be calculated
|
||||
|
||||
param->cond= cond;
|
||||
|
||||
if (cond_func->functype() == Item_func::BETWEEN)
|
||||
{
|
||||
if (cond_func->arguments()[0]->type() == Item::FIELD_ITEM)
|
||||
@ -1794,14 +1797,15 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
|
||||
max_str[0]= min_str[0]=0;
|
||||
|
||||
like_error= my_like_range(field->charset(),
|
||||
res->ptr(),res->length(),
|
||||
wild_prefix,wild_one,wild_many,
|
||||
field_length,
|
||||
min_str+offset, max_str+offset,
|
||||
&min_length,&max_length);
|
||||
|
||||
res->ptr(), res->length(),
|
||||
((Item_func_like*)(param->cond))->escape,
|
||||
wild_one, wild_many,
|
||||
field_length,
|
||||
min_str+offset, max_str+offset,
|
||||
&min_length, &max_length);
|
||||
if (like_error) // Can't optimize with LIKE
|
||||
DBUG_RETURN(0);
|
||||
|
||||
if (offset != maybe_null) // Blob
|
||||
{
|
||||
int2store(min_str+maybe_null,min_length);
|
||||
@ -1824,7 +1828,7 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part,
|
||||
field->cmp_type() != value->result_type())
|
||||
DBUG_RETURN(0);
|
||||
|
||||
if (value->save_in_field(field, 1) > 0)
|
||||
if (value->save_in_field(field, 1) < 0)
|
||||
{
|
||||
/* This happens when we try to insert a NULL field in a not null column */
|
||||
DBUG_RETURN(&null_element); // cmp with NULL is never true
|
||||
@ -2536,6 +2540,8 @@ key_or(SEL_ARG *key1,SEL_ARG *key2)
|
||||
return 0; // OOM
|
||||
tmp->copy_max_to_min(&key);
|
||||
tmp->increment_use_count(key1->use_count+1);
|
||||
/* Increment key count as it may be used for next loop */
|
||||
key.increment_use_count(1);
|
||||
new_arg->next_key_part=key_or(tmp->next_key_part,key.next_key_part);
|
||||
key1=key1->insert(new_arg);
|
||||
break;
|
||||
@ -2967,6 +2973,7 @@ static ulong count_key_part_usage(SEL_ARG *root, SEL_ARG *key)
|
||||
|
||||
void SEL_ARG::test_use_count(SEL_ARG *root)
|
||||
{
|
||||
uint e_count=0;
|
||||
if (this == root && use_count != 1)
|
||||
{
|
||||
sql_print_error("Note: Use_count: Wrong count %lu for root",use_count);
|
||||
@ -2974,7 +2981,6 @@ void SEL_ARG::test_use_count(SEL_ARG *root)
|
||||
}
|
||||
if (this->type != SEL_ARG::KEY_RANGE)
|
||||
return;
|
||||
uint e_count=0;
|
||||
for (SEL_ARG *pos=first(); pos ; pos=pos->next)
|
||||
{
|
||||
e_count++;
|
||||
@ -2991,8 +2997,8 @@ void SEL_ARG::test_use_count(SEL_ARG *root)
|
||||
}
|
||||
}
|
||||
if (e_count != elements)
|
||||
sql_print_error("Warning: Wrong use count: %u for tree at %lx", e_count,
|
||||
(gptr) this);
|
||||
sql_print_error("Warning: Wrong use count: %u (should be %u) for tree at %lx",
|
||||
e_count, elements, (gptr) this);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -3260,9 +3266,9 @@ get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key,
|
||||
}
|
||||
|
||||
/* Get range for retrieving rows in QUICK_SELECT::get_next */
|
||||
if (!(range= new QUICK_RANGE(param->min_key,
|
||||
if (!(range= new QUICK_RANGE((const char *) param->min_key,
|
||||
(uint) (tmp_min_key - param->min_key),
|
||||
param->max_key,
|
||||
(const char *) param->max_key,
|
||||
(uint) (tmp_max_key - param->max_key),
|
||||
flag)))
|
||||
return 1; // out of memory
|
||||
@ -3383,8 +3389,8 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table,
|
||||
QUICK_RANGE *null_range;
|
||||
|
||||
*ref->null_ref_key= 1; // Set null byte then create a range
|
||||
if (!(null_range= new QUICK_RANGE(ref->key_buff, ref->key_length,
|
||||
ref->key_buff, ref->key_length,
|
||||
if (!(null_range= new QUICK_RANGE((char*)ref->key_buff, ref->key_length,
|
||||
(char*)ref->key_buff, ref->key_length,
|
||||
EQ_RANGE)))
|
||||
goto err;
|
||||
*ref->null_ref_key= 0; // Clear null byte
|
||||
@ -3791,15 +3797,17 @@ int QUICK_SELECT_DESC::get_next()
|
||||
((range->flag & NEAR_MAX) ?
|
||||
HA_READ_BEFORE_KEY : HA_READ_PREFIX_LAST_OR_PREV));
|
||||
#else
|
||||
/* Heikki changed Sept 11, 2002: since InnoDB does not store the cursor
|
||||
position if READ_KEY_EXACT is used to a primary key with all
|
||||
key columns specified, we must use below HA_READ_KEY_OR_NEXT,
|
||||
so that InnoDB stores the cursor position and is able to move
|
||||
the cursor one step backward after the search. */
|
||||
|
||||
/* Note: even if max_key is only a prefix, HA_READ_AFTER_KEY will
|
||||
* do the right thing - go past all keys which match the prefix */
|
||||
|
||||
/*
|
||||
Heikki changed Sept 11, 2002: since InnoDB does not store the cursor
|
||||
position if READ_KEY_EXACT is used to a primary key with all
|
||||
key columns specified, we must use below HA_READ_KEY_OR_NEXT,
|
||||
so that InnoDB stores the cursor position and is able to move
|
||||
the cursor one step backward after the search.
|
||||
*/
|
||||
/*
|
||||
Note: even if max_key is only a prefix, HA_READ_AFTER_KEY will
|
||||
do the right thing - go past all keys which match the prefix
|
||||
*/
|
||||
result=file->index_read(record, (byte*) range->max_key,
|
||||
range->max_length,
|
||||
((range->flag & NEAR_MAX) ?
|
||||
|
Reference in New Issue
Block a user