mirror of
https://github.com/MariaDB/server.git
synced 2026-05-02 05:05:33 +02: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. mysql-test/r/partition_innodb.result: Adding test case mysql-test/r/partition_pruning.result: Fixing test results (results differ due to changes in hash function) mysql-test/t/partition_innodb.test: Adding test case sql/field.cc: Adding generic hash() method, and a special method for VARCHAR. sql/field.h: Adding prototypes for new methods sql/key.cc: Mark columns for write before executinf of set_key_image(). Thanks for Mikael for suggesting this fix. sql/sql_partition.cc: Removing old hash code. Using new methid field->hash() instead.
This commit is contained in:
parent
9addb8fd7b
commit
4e138572a0
7 changed files with 68 additions and 15 deletions
|
|
@ -210,9 +210,13 @@ void key_restore(byte *to_record, byte *from_key, KEY *key_info,
|
|||
}
|
||||
else if (key_part->key_part_flag & HA_VAR_LENGTH_PART)
|
||||
{
|
||||
my_bitmap_map *old_map;
|
||||
key_length-= HA_KEY_BLOB_LENGTH;
|
||||
length= min(key_length, key_part->length);
|
||||
old_map= dbug_tmp_use_all_columns(key_part->field->table,
|
||||
key_part->field->table->write_set);
|
||||
key_part->field->set_key_image((char *) from_key, length);
|
||||
dbug_tmp_restore_column_map(key_part->field->table->write_set, old_map);
|
||||
from_key+= HA_KEY_BLOB_LENGTH;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue