1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

Bug#20086: Can't get data from key partitioned tables with VARCHAR key

The problem appeared because the same values produced different hash
during INSERT and SELECT for VARCHAR data type.
Fix:
VARCHAR required special treatment to avoid hashing of length bytes
(leftmost one or two bytes) as well as trailing bytes beyond real length,
which could contain garbage. Fix is done by introducing hash() - new method
in the Field class.
This commit is contained in:
bar@mysql.com
2006-06-21 13:00:19 +05:00
parent 66d7d65000
commit bfae7303d7
7 changed files with 68 additions and 15 deletions

View File

@@ -2103,26 +2103,15 @@ static inline longlong part_val_int(Item *item_expr)
static uint32 calculate_key_value(Field **field_array)
{
uint32 hashnr= 0;
ulong nr1= 1;
ulong nr2= 4;
do
{
Field *field= *field_array;
if (field->is_null())
{
hashnr^= (hashnr << 1) | 1;
}
else
{
uint len= field->pack_length();
ulong nr1= 1;
CHARSET_INFO *cs= field->charset();
cs->coll->hash_sort(cs, (uchar*)field->ptr, len, &nr1, &nr2);
hashnr^= (uint32)nr1;
}
field->hash(&nr1, &nr2);
} while (*(++field_array));
return hashnr;
return (uint32) nr1;
}