Commit 4ecea7d3 authored by unknown's avatar unknown

cleanups


myisam/mi_write.c:
  cleanup
mysys/tree.c:
  cleanup
sql/sql_show.cc:
  bad merge fixed
parent bfefbf8b
...@@ -765,34 +765,47 @@ int _mi_init_bulk_insert(MI_INFO *info) ...@@ -765,34 +765,47 @@ int _mi_init_bulk_insert(MI_INFO *info)
MYISAM_SHARE *share=info->s; MYISAM_SHARE *share=info->s;
MI_KEYDEF *key=share->keyinfo; MI_KEYDEF *key=share->keyinfo;
bulk_insert_param *params; bulk_insert_param *params;
uint i; uint i, num_keys;
ulonglong key_map=0;
if (info->bulk_insert) if (info->bulk_insert)
return 0; return 0;
for (i=num_keys=0 ; i < share->base.keys ; i++)
{
if (!(key[i].flag & HA_NOSAME) && share->base.auto_key != i+1
&& test(share->state.key_map & ((ulonglong) 1 << i)))
{
num_keys++;
key_map |=((ulonglong) 1 << i);
}
}
if (!num_keys)
return 0;
info->bulk_insert=(TREE *) info->bulk_insert=(TREE *)
my_malloc((sizeof(TREE)+sizeof(bulk_insert_param))*share->base.keys, my_malloc((sizeof(TREE)*share->base.keys+
MYF(0)); sizeof(bulk_insert_param)*num_keys),MYF(0));
if (!info->bulk_insert) if (!info->bulk_insert)
return HA_ERR_OUT_OF_MEM; return HA_ERR_OUT_OF_MEM;
params=(bulk_insert_param *)(info->bulk_insert+share->base.keys); params=(bulk_insert_param *)(info->bulk_insert+share->base.keys);
for (i=0 ; i < share->base.keys ; i++,key++)
for (i=0 ; i < share->base.keys ; i++,key++,params++)
{ {
params->info=info; params->info=info;
params->keynr=i; params->keynr=i;
if (!(key->flag & HA_NOSAME) && share->base.auto_key != i+1 if (test(key_map & ((ulonglong) 1 << i)))
&& test(share->state.key_map & ((ulonglong) 1 << i)))
{ {
init_tree(& info->bulk_insert[i], 0, init_tree(& info->bulk_insert[i], 0,
myisam_bulk_insert_tree_size / share->base.keys, 0, myisam_bulk_insert_tree_size / num_keys, 0,
(qsort_cmp2)keys_compare, 0, (qsort_cmp2)keys_compare, 0,
(tree_element_free) keys_free, (void *)params); (tree_element_free) keys_free, (void *)params++);
} }
else else
info->bulk_insert[i].root=0; info->bulk_insert[i].root=0;
} }
return 0; return 0;
} }
...@@ -63,31 +63,7 @@ static void rb_delete_fixup(TREE *tree,TREE_ELEMENT ***parent); ...@@ -63,31 +63,7 @@ static void rb_delete_fixup(TREE *tree,TREE_ELEMENT ***parent);
/* The actuall code for handling binary trees */ /* The actuall code for handling binary trees */
#ifndef DBUG_OFF #ifndef DBUG_OFF
static int test_rb_tree(TREE_ELEMENT *element);
/* Test that the proporties for a red-black tree holds */
static int test_rb_tree(TREE_ELEMENT *element)
{
int count_l,count_r;
if (!element->left)
return 0; /* Found end of tree */
if (element->colour == RED &&
(element->left->colour == RED || element->right->colour == RED))
{
printf("Wrong tree: Found two red in a row\n");
return -1;
}
count_l=test_rb_tree(element->left);
count_r=test_rb_tree(element->right);
if (count_l >= 0 && count_r >= 0)
{
if (count_l == count_r)
return count_l+(element->colour == BLACK);
printf("Wrong tree: Incorrect black-count: %d - %d\n",count_l,count_r);
}
return -1;
}
#endif #endif
void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit, void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit,
...@@ -546,3 +522,31 @@ static void rb_delete_fixup(TREE *tree, TREE_ELEMENT ***parent) ...@@ -546,3 +522,31 @@ static void rb_delete_fixup(TREE *tree, TREE_ELEMENT ***parent)
} }
x->colour=BLACK; x->colour=BLACK;
} }
#ifndef DBUG_OFF
/* Test that the proporties for a red-black tree holds */
static int test_rb_tree(TREE_ELEMENT *element)
{
int count_l,count_r;
if (!element->left)
return 0; /* Found end of tree */
if (element->colour == RED &&
(element->left->colour == RED || element->right->colour == RED))
{
printf("Wrong tree: Found two red in a row\n");
return -1;
}
count_l=test_rb_tree(element->left);
count_r=test_rb_tree(element->right);
if (count_l >= 0 && count_r >= 0)
{
if (count_l == count_r)
return count_l+(element->colour == BLACK);
printf("Wrong tree: Incorrect black-count: %d - %d\n",count_l,count_r);
}
return -1;
}
#endif
...@@ -114,7 +114,7 @@ int mysqld_show_open_tables(THD *thd,const char *db,const char *wild) ...@@ -114,7 +114,7 @@ int mysqld_show_open_tables(THD *thd,const char *db,const char *wild)
if (send_fields(thd,field_list,1)) if (send_fields(thd,field_list,1))
DBUG_RETURN(1); DBUG_RETURN(1);
if (!(open_list=list_open_tables(thd,wild)) && thd->fatal_error) if (!(list_open_tables(thd,&tables,db,wild)) && thd->fatal_error)
DBUG_RETURN(-1); DBUG_RETURN(-1);
List_iterator<char> it(tables); List_iterator<char> it(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