diff options
author | unknown <bar@mysql.com> | 2006-06-21 13:00:19 +0500 |
---|---|---|
committer | unknown <bar@mysql.com> | 2006-06-21 13:00:19 +0500 |
commit | 4e138572a01afc7e88f1b3040d3c4a81012e298f (patch) | |
tree | 7c85af3bc9c8dc533856bb892be54c3448879a77 /sql/key.cc | |
parent | 9addb8fd7bc47c186805eeefa51bb69805fd59a6 (diff) | |
download | mariadb-git-4e138572a01afc7e88f1b3040d3c4a81012e298f.tar.gz |
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.
Diffstat (limited to 'sql/key.cc')
-rw-r--r-- | sql/key.cc | 4 |
1 files changed, 4 insertions, 0 deletions
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 |