From 4e138572a01afc7e88f1b3040d3c4a81012e298f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Jun 2006 13:00:19 +0500 Subject: 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. --- sql/key.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sql/key.cc') diff --git a/sql/key.cc b/sql/key.cc index 11dd267875f..69557d971e8 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -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 -- cgit v1.2.1