Commit 24c4877e authored by Michael Widenius's avatar Michael Widenius

tmp commit to try to find crash in windows builds

This commit adds support for more than one key in temporary tables
parent 07232ac0
......@@ -104,7 +104,8 @@ enum ha_key_alg {
HA_KEY_ALG_RTREE= 2, /* R-tree, for spatial searches */
HA_KEY_ALG_HASH= 3, /* HASH keys (HEAP tables) */
HA_KEY_ALG_FULLTEXT= 4, /* FULLTEXT (MyISAM tables) */
HA_KEY_ALG_LONG_HASH= 5 /* long BLOB keys */
HA_KEY_ALG_LONG_HASH= 5, /* long BLOB keys */
HA_KEY_ALG_UNIQUE_HASH= 6 /* Internal UNIQUE hash (Aria) */
};
/* Storage media types */
......@@ -276,11 +277,13 @@ enum ha_base_keytype {
#define HA_SPATIAL 1024U /* For spatial search */
#define HA_NULL_ARE_EQUAL 2048U /* NULL in key are cmp as equal */
#define HA_GENERATED_KEY 8192U /* Automatically generated key */
#define HA_UNIQUE_HASH (1U << 14) /* Part of unique hash key */
/* The combination of the above can be used for key type comparison. */
#define HA_KEYFLAG_MASK (HA_NOSAME | HA_AUTO_KEY | \
HA_FULLTEXT | HA_UNIQUE_CHECK | \
HA_SPATIAL | HA_NULL_ARE_EQUAL | HA_GENERATED_KEY)
HA_SPATIAL | HA_NULL_ARE_EQUAL | HA_GENERATED_KEY | \
HA_UNIQUE_HASH)
/*
Key contains partial segments.
......
......@@ -4899,8 +4899,11 @@ SJ_TMP_TABLE::create_sj_weedout_tmp_table(THD *thd)
share->uniques= MY_TEST(using_unique_constraint);
table->key_info= share->key_info= keyinfo;
keyinfo->key_part=key_part_info;
keyinfo->flags=HA_NOSAME;
keyinfo->flags= HA_NOSAME | (using_unique_constraint ? HA_UNIQUE_HASH : 0);
keyinfo->ext_key_flags= keyinfo->flags;
keyinfo->usable_key_parts= keyinfo->user_defined_key_parts= 1;
keyinfo->ext_key_parts= 1;
share->key_parts= 1;
keyinfo->key_length=0;
keyinfo->rec_per_key=0;
keyinfo->algorithm= HA_KEY_ALG_UNDEF;
......
This diff is collapsed.
......@@ -8473,9 +8473,14 @@ bool TABLE::add_tmp_key(uint key, uint key_parts,
void TABLE::use_index(int key_to_save, key_map *map_to_update)
{
#ifndef NEW
DBUG_ASSERT(!created && key_to_save < (int)s->keys);
uint saved_keys= 0, key_parts= 0;
key_map new_bitmap;
DBUG_ENTER("TABLE::use_index");
DBUG_PRINT("enter", ("key_to_save: %d keys: %u uniques: %u",
key_to_save, s->keys, s->uniques));
new_bitmap.clear_all();
/*
......@@ -8485,11 +8490,14 @@ void TABLE::use_index(int key_to_save, key_map *map_to_update)
{
new_bitmap.set_bit(saved_keys);
KEY tmp_buff= key_info[saved_keys];
key_info[saved_keys]= key_info[key_to_save];
key_info[key_to_save]= tmp_buff;
saved_keys++;
if (key_to_save != 0) // Avoid not needed copy
{
KEY tmp_buff= key_info[saved_keys];
key_info[saved_keys]= key_info[key_to_save];
key_info[key_to_save]= tmp_buff;
}
key_parts= key_info[saved_keys].user_defined_key_parts;
saved_keys++;
}
/*
......@@ -8497,7 +8505,7 @@ void TABLE::use_index(int key_to_save, key_map *map_to_update)
*/
for (uint i= saved_keys; i < s->keys; i++)
{
if (key_info[i].flags & HA_NOSAME)
if (key_info[i].flags & (HA_NOSAME | HA_UNIQUE_HASH))
{
if (map_to_update->is_set(i))
new_bitmap.set_bit(saved_keys);
......@@ -8510,6 +8518,26 @@ void TABLE::use_index(int key_to_save, key_map *map_to_update)
*map_to_update= new_bitmap;
s->keys= saved_keys;
s->key_parts= s->ext_key_parts= key_parts;
#else
uint i= 1;
DBUG_ASSERT(!created && key_to_save < (int)s->keys);
if (key_to_save >= 0)
{
/* Save the given key. */
memmove(key_info, key_info + key_to_save, sizeof(KEY));
map_to_update->clear_all();
map_to_update->set_bit(0);
}
else
{
/* Drop all keys; */
i= 0;
map_to_update->clear_all();
}
s->keys= i;
s->uniques= 0;
#endif
DBUG_VOID_RETURN;
}
/*
......
......@@ -1082,7 +1082,8 @@ const char *ha_maria::index_type(uint key_number)
ulong ha_maria::index_flags(uint inx, uint part, bool all_parts) const
{
ulong flags;
if (table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT)
if (table_share->key_info[inx].algorithm == HA_KEY_ALG_FULLTEXT ||
table_share->key_info[inx].algorithm == HA_KEY_ALG_UNIQUE_HASH)
flags= 0;
else
if ((table_share->key_info[inx].flags & HA_SPATIAL ||
......@@ -2733,10 +2734,13 @@ int ha_maria::info(uint flag)
key < key_end ; key++)
{
ulong *to= key->rec_per_key;
for (ulong *end= to+ key->user_defined_key_parts ;
to < end ;
to++, from++)
*to= (ulong) (*from + 0.5);
if (to)
{
for (ulong *end= to+ key->user_defined_key_parts ;
to < end ;
to++, from++)
*to= (ulong) (*from + 0.5);
}
}
}
/*
......
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