Commit f1d3304e authored by unknown's avatar unknown

Merge jcole@bk-internal.mysql.com:/home/bk/mysql-4.0

into mugatu.spaceapes.com:/home/jcole/bk/mysql-4.0
parents a595f86f cb88d20c
...@@ -345,7 +345,7 @@ SQL_SELECT *make_select(TABLE *head, table_map const_tables, ...@@ -345,7 +345,7 @@ SQL_SELECT *make_select(TABLE *head, table_map const_tables,
DBUG_RETURN(0); DBUG_RETURN(0);
if (!(select= new SQL_SELECT)) if (!(select= new SQL_SELECT))
{ {
*error= 1; *error= 1; // out of memory
DBUG_RETURN(0); /* purecov: inspected */ DBUG_RETURN(0); /* purecov: inspected */
} }
select->read_tables=read_tables; select->read_tables=read_tables;
...@@ -460,15 +460,17 @@ SEL_ARG *SEL_ARG::clone(SEL_ARG *new_parent,SEL_ARG **next_arg) ...@@ -460,15 +460,17 @@ SEL_ARG *SEL_ARG::clone(SEL_ARG *new_parent,SEL_ARG **next_arg)
SEL_ARG *tmp; SEL_ARG *tmp;
if (type != KEY_RANGE) if (type != KEY_RANGE)
{ {
tmp=new SEL_ARG(type); if(!(tmp=new SEL_ARG(type)))
return 0; // out of memory
tmp->prev= *next_arg; // Link into next/prev chain tmp->prev= *next_arg; // Link into next/prev chain
(*next_arg)->next=tmp; (*next_arg)->next=tmp;
(*next_arg)= tmp; (*next_arg)= tmp;
} }
else else
{ {
tmp=new SEL_ARG(field,part, min_value,max_value, if(!(tmp=new SEL_ARG(field,part, min_value,max_value,
min_flag, max_flag, maybe_flag); min_flag, max_flag, maybe_flag)))
return 0; // out of memory
tmp->parent=new_parent; tmp->parent=new_parent;
tmp->next_key_part=next_key_part; tmp->next_key_part=next_key_part;
if (left != &null_element) if (left != &null_element)
...@@ -763,6 +765,8 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond) ...@@ -763,6 +765,8 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond)
while ((item=li++)) while ((item=li++))
{ {
SEL_TREE *new_tree=get_mm_tree(param,item); SEL_TREE *new_tree=get_mm_tree(param,item);
if(current_thd->fatal_error)
DBUG_RETURN(0); // out of memory
tree=tree_and(param,tree,new_tree); tree=tree_and(param,tree,new_tree);
if (tree && tree->type == SEL_TREE::IMPOSSIBLE) if (tree && tree->type == SEL_TREE::IMPOSSIBLE)
break; break;
...@@ -778,7 +782,7 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond) ...@@ -778,7 +782,7 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond)
{ {
SEL_TREE *new_tree=get_mm_tree(param,item); SEL_TREE *new_tree=get_mm_tree(param,item);
if (!new_tree) if (!new_tree)
DBUG_RETURN(0); DBUG_RETURN(0); // out of memory
tree=tree_or(param,tree,new_tree); tree=tree_or(param,tree,new_tree);
if (!tree || tree->type == SEL_TREE::ALWAYS) if (!tree || tree->type == SEL_TREE::ALWAYS)
break; break;
...@@ -814,12 +818,13 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond) ...@@ -814,12 +818,13 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond)
{ {
Field *field=((Item_field*) (cond_func->arguments()[0]))->field; Field *field=((Item_field*) (cond_func->arguments()[0]))->field;
Item_result cmp_type=field->cmp_type(); Item_result cmp_type=field->cmp_type();
tree= get_mm_parts(param,field,Item_func::GE_FUNC, DBUG_RETURN(tree_and(param,
cond_func->arguments()[1],cmp_type); get_mm_parts(param, field,
DBUG_RETURN(tree_and(param,tree, Item_func::GE_FUNC,
cond_func->arguments()[1], cmp_type),
get_mm_parts(param, field, get_mm_parts(param, field,
Item_func::LE_FUNC, Item_func::LE_FUNC,
cond_func->arguments()[2],cmp_type))); cond_func->arguments()[2], cmp_type)));
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -882,14 +887,15 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond) ...@@ -882,14 +887,15 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond)
static SEL_TREE * static SEL_TREE *
get_mm_parts(PARAM *param,Field *field, Item_func::Functype type,Item *value, get_mm_parts(PARAM *param, Field *field, Item_func::Functype type,
Item_result cmp_type) Item *value, Item_result cmp_type)
{ {
DBUG_ENTER("get_mm_parts"); DBUG_ENTER("get_mm_parts");
if (field->table != param->table) if (field->table != param->table)
DBUG_RETURN(0); DBUG_RETURN(0);
KEY_PART *key_part = param->key_parts,*end=param->key_parts_end; KEY_PART *key_part = param->key_parts;
KEY_PART *end = param->key_parts_end;
SEL_TREE *tree=0; SEL_TREE *tree=0;
if (value && if (value &&
value->used_tables() & ~(param->prev_tables | param->read_tables)) value->used_tables() & ~(param->prev_tables | param->read_tables))
...@@ -899,8 +905,8 @@ get_mm_parts(PARAM *param,Field *field, Item_func::Functype type,Item *value, ...@@ -899,8 +905,8 @@ get_mm_parts(PARAM *param,Field *field, Item_func::Functype type,Item *value,
if (field->eq(key_part->field)) if (field->eq(key_part->field))
{ {
SEL_ARG *sel_arg=0; SEL_ARG *sel_arg=0;
if (!tree) if (!tree && !(tree=new SEL_TREE()))
tree=new SEL_TREE(); DBUG_RETURN(0); // out of memory
if (!value || !(value->used_tables() & ~param->read_tables)) if (!value || !(value->used_tables() & ~param->read_tables))
{ {
sel_arg=get_mm_leaf(param,key_part->field,key_part,type,value); sel_arg=get_mm_leaf(param,key_part->field,key_part,type,value);
...@@ -912,8 +918,11 @@ get_mm_parts(PARAM *param,Field *field, Item_func::Functype type,Item *value, ...@@ -912,8 +918,11 @@ get_mm_parts(PARAM *param,Field *field, Item_func::Functype type,Item *value,
DBUG_RETURN(tree); DBUG_RETURN(tree);
} }
} }
else else {
sel_arg=new SEL_ARG(SEL_ARG::MAYBE_KEY);// This key may be used later // This key may be used later
if(!(sel_arg=new SEL_ARG(SEL_ARG::MAYBE_KEY)))
DBUG_RETURN(0); // out of memory
}
sel_arg->part=(uchar) key_part->part; sel_arg->part=(uchar) key_part->part;
tree->keys[key_part->key]=sel_add(tree->keys[key_part->key],sel_arg); tree->keys[key_part->key]=sel_add(tree->keys[key_part->key],sel_arg);
} }
...@@ -1011,9 +1020,8 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part, ...@@ -1011,9 +1020,8 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
DBUG_RETURN(0); DBUG_RETURN(0);
if (!maybe_null) // Not null field if (!maybe_null) // Not null field
DBUG_RETURN(type == Item_func::ISNULL_FUNC ? &null_element : 0); DBUG_RETURN(type == Item_func::ISNULL_FUNC ? &null_element : 0);
tree=new SEL_ARG(field,is_null_string,is_null_string); if (!(tree=new SEL_ARG(field,is_null_string,is_null_string)))
if (!tree) DBUG_RETURN(0); // out of memory
DBUG_RETURN(0);
if (type == Item_func::ISNOTNULL_FUNC) if (type == Item_func::ISNOTNULL_FUNC)
{ {
tree->min_flag=NEAR_MIN; /* IS NOT NULL -> X > NULL */ tree->min_flag=NEAR_MIN; /* IS NOT NULL -> X > NULL */
...@@ -1050,7 +1058,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part, ...@@ -1050,7 +1058,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part,
*str= (char) field->is_real_null(); // Set to 1 if null *str= (char) field->is_real_null(); // Set to 1 if null
field->get_key_image(str+maybe_null,key_part->part_length); field->get_key_image(str+maybe_null,key_part->part_length);
if (!(tree=new SEL_ARG(field,str,str))) if (!(tree=new SEL_ARG(field,str,str)))
DBUG_RETURN(0); DBUG_RETURN(0); // out of memory
switch (type) { switch (type) {
case Item_func::LT_FUNC: case Item_func::LT_FUNC:
...@@ -1518,7 +1526,8 @@ key_or(SEL_ARG *key1,SEL_ARG *key2) ...@@ -1518,7 +1526,8 @@ key_or(SEL_ARG *key1,SEL_ARG *key2)
SEL_ARG *key2_next=key2->next; SEL_ARG *key2_next=key2->next;
if (key2_shared) if (key2_shared)
{ {
key2=new SEL_ARG(*key2); if(!(key2=new SEL_ARG(*key2)))
return 0; // out of memory
key2->increment_use_count(key1->use_count+1); key2->increment_use_count(key1->use_count+1);
key2->next=key2_next; // New copy of key2 key2->next=key2_next; // New copy of key2
} }
...@@ -2342,15 +2351,15 @@ get_quick_keys(PARAM *param,QUICK_SELECT *quick,KEY_PART *key, ...@@ -2342,15 +2351,15 @@ get_quick_keys(PARAM *param,QUICK_SELECT *quick,KEY_PART *key,
} }
/* Get range for retrieving rows in QUICK_SELECT::get_next */ /* Get range for retrieving rows in QUICK_SELECT::get_next */
range= new QUICK_RANGE(param->min_key, if(!(range= new QUICK_RANGE(param->min_key,
(uint) (tmp_min_key - param->min_key), (uint) (tmp_min_key - param->min_key),
param->max_key, param->max_key,
(uint) (tmp_max_key - param->max_key), (uint) (tmp_max_key - param->max_key),
flag); flag)))
return 1; // out of memory
set_if_bigger(quick->max_used_key_length,range->min_length); set_if_bigger(quick->max_used_key_length,range->min_length);
set_if_bigger(quick->max_used_key_length,range->max_length); set_if_bigger(quick->max_used_key_length,range->max_length);
if (!range) // Not enough memory
return 1;
quick->ranges.push_back(range); quick->ranges.push_back(range);
end: end:
...@@ -2411,17 +2420,17 @@ QUICK_SELECT *get_quick_select_for_ref(TABLE *table, TABLE_REF *ref) ...@@ -2411,17 +2420,17 @@ QUICK_SELECT *get_quick_select_for_ref(TABLE *table, TABLE_REF *ref)
uint part; uint part;
if (!quick) if (!quick)
return 0; return 0; /* no ranges found */
if (cp_buffer_from_ref(ref)) if (cp_buffer_from_ref(ref))
{ {
if (current_thd->fatal_error) if (current_thd->fatal_error)
return 0; // End of memory return 0; // out of memory
return quick; // empty range return quick; // empty range
} }
QUICK_RANGE *range= new QUICK_RANGE(); QUICK_RANGE *range= new QUICK_RANGE();
if (!range) if (!range)
goto err; goto err; // out of memory
range->min_key=range->max_key=(char*) ref->key_buff; range->min_key=range->max_key=(char*) ref->key_buff;
range->min_length=range->max_length=ref->key_length; range->min_length=range->max_length=ref->key_length;
......
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