summaryrefslogtreecommitdiff
path: root/sql/sql_partition.cc
diff options
context:
space:
mode:
authorunknown <bar@mysql.com>2006-06-21 13:00:19 +0500
committerunknown <bar@mysql.com>2006-06-21 13:00:19 +0500
commit4e138572a01afc7e88f1b3040d3c4a81012e298f (patch)
tree7c85af3bc9c8dc533856bb892be54c3448879a77 /sql/sql_partition.cc
parent9addb8fd7bc47c186805eeefa51bb69805fd59a6 (diff)
downloadmariadb-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/sql_partition.cc')
-rw-r--r--sql/sql_partition.cc17
1 files changed, 3 insertions, 14 deletions
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 00c15c2dbca..8eb9bfa1782 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -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;
}