1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

mysql-5.5.32 merge

This commit is contained in:
Sergei Golubchik
2013-07-16 19:09:54 +02:00
1489 changed files with 3085 additions and 1941 deletions

View File

@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
Copyright (c) 2008-2011 Monty Program Ab
/* Copyright (c) 2000, 2013, Oracle and/or its affiliates.
Copyright (c) 2008, 2013, Monty Program Ab.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -843,8 +843,17 @@ public:
/* Number of SEL_ARG objects allocated by SEL_ARG::clone_tree operations */
uint alloced_sel_args;
bool force_default_mrr;
KEY_PART *key[MAX_KEY]; /* First key parts of keys used in the query */
bool statement_should_be_aborted() const
{
return
thd->is_fatal_error ||
thd->is_error() ||
alloced_sel_args > SEL_ARG::MAX_SEL_ARGS;
}
};
class PARAM : public RANGE_OPT_PARAM
@ -7124,6 +7133,34 @@ static SEL_TREE *get_func_mm_tree(RANGE_OPT_PARAM *param, Item_func *cond_func,
{
new_interval->min_value= last_val->max_value;
new_interval->min_flag= NEAR_MIN;
/*
If the interval is over a partial keypart, the
interval must be "c_{i-1} <= X < c_i" instead of
"c_{i-1} < X < c_i". Reason:
Consider a table with a column "my_col VARCHAR(3)",
and an index with definition
"INDEX my_idx my_col(1)". If the table contains rows
with my_col values "f" and "foo", the index will not
distinguish the two rows.
Note that tree_or() below will effectively merge
this range with the range created for c_{i-1} and
we'll eventually end up with only one range:
"NULL < X".
Partitioning indexes are never partial.
*/
if (param->using_real_indexes)
{
const KEY key=
param->table->key_info[param->real_keynr[idx]];
const KEY_PART_INFO *kpi= key.key_part + new_interval->part;
if (kpi->key_part_flag & HA_PART_KEY_SEG)
new_interval->min_flag= 0;
}
}
}
/*
@ -7336,34 +7373,35 @@ static SEL_TREE *get_mm_tree(RANGE_OPT_PARAM *param,COND *cond)
if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
{
tree=0;
tree= NULL;
Item *item;
while ((item=li++))
{
SEL_TREE *new_tree=get_mm_tree(param,item);
if (param->thd->is_fatal_error ||
param->alloced_sel_args > SEL_ARG::MAX_SEL_ARGS)
DBUG_RETURN(0); // out of memory
tree=tree_and(param,tree,new_tree);
if (tree && tree->type == SEL_TREE::IMPOSSIBLE)
break;
SEL_TREE *new_tree= get_mm_tree(param,item);
if (param->statement_should_be_aborted())
DBUG_RETURN(NULL);
tree= tree_and(param,tree,new_tree);
if (tree && tree->type == SEL_TREE::IMPOSSIBLE)
break;
}
}
else
{ // COND OR
tree=get_mm_tree(param,li++);
{ // COND OR
tree= get_mm_tree(param,li++);
if (param->statement_should_be_aborted())
DBUG_RETURN(NULL);
if (tree)
{
Item *item;
while ((item=li++))
{
SEL_TREE *new_tree=get_mm_tree(param,item);
if (!new_tree)
DBUG_RETURN(0); // out of memory
tree=tree_or(param,tree,new_tree);
if (!tree || tree->type == SEL_TREE::ALWAYS)
break;
}
Item *item;
while ((item=li++))
{
SEL_TREE *new_tree=get_mm_tree(param,item);
if (new_tree == NULL || param->statement_should_be_aborted())
DBUG_RETURN(NULL);
tree= tree_or(param,tree,new_tree);
if (tree == NULL || tree->type == SEL_TREE::ALWAYS)
break;
}
}
}
DBUG_RETURN(tree);
@ -7617,6 +7655,7 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field,
if (key_part->image_type == Field::itMBR)
{
// @todo: use is_spatial_operator() instead?
switch (type) {
case Item_func::SP_EQUALS_FUNC:
case Item_func::SP_DISJOINT_FUNC: