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:
unknown 2006-06-21 13:00:19 +05:00
commit 4e138572a0
7 changed files with 68 additions and 15 deletions

View file

@ -351,6 +351,8 @@ public:
return field_length / charset()->mbmaxlen;
}
/* Hash value */
virtual void hash(ulong *nr, ulong *nr2);
friend bool reopen_table(THD *,struct st_table *,bool);
friend int cre_myisam(my_string name, register TABLE *form, uint options,
ulonglong auto_increment_value);
@ -1120,6 +1122,7 @@ public:
char *new_ptr, uchar *new_null_ptr,
uint new_null_bit);
uint is_equal(create_field *new_field);
void hash(ulong *nr, ulong *nr2);
};