Commit 90b526a5 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

file->offset(addr) were assuming addr was within the field's record, which is...

file->offset(addr) were assuming addr was within the field's record, which is not always the case.  closes #592

git-svn-id: file:///svn/mysql/tokudb-engine/src@3058 c7de825b-a66e-492c-adef-691d508d4ae1
parent cebc556c
...@@ -918,7 +918,7 @@ ulong ha_tokudb::max_row_length(const uchar * buf) { ...@@ -918,7 +918,7 @@ ulong ha_tokudb::max_row_length(const uchar * buf) {
uint *ptr, *end; uint *ptr, *end;
for (ptr = table_share->blob_field, end = ptr + table_share->blob_fields; ptr != end; ptr++) { for (ptr = table_share->blob_field, end = ptr + table_share->blob_fields; ptr != end; ptr++) {
Field_blob *blob = ((Field_blob *) table->field[*ptr]); Field_blob *blob = ((Field_blob *) table->field[*ptr]);
length += blob->get_length((uchar *) (buf + blob->offset((uchar *) buf))) + 2; length += blob->get_length((uchar *) (buf + field_offset(blob))) + 2;
} }
return length; return length;
} }
...@@ -956,7 +956,7 @@ int ha_tokudb::pack_row(DBT * row, const uchar * record, bool new_row) { ...@@ -956,7 +956,7 @@ int ha_tokudb::pack_row(DBT * row, const uchar * record, bool new_row) {
for (Field ** field = table->field; *field; field++) for (Field ** field = table->field; *field; field++)
ptr = (*field)->pack(ptr, (const uchar *) ptr = (*field)->pack(ptr, (const uchar *)
(record + (*field)->offset((uchar *) record))); (record + field_offset(*field)));
if (hidden_primary_key) { if (hidden_primary_key) {
if (new_row) if (new_row)
...@@ -978,11 +978,8 @@ void ha_tokudb::unpack_row(uchar * record, DBT * row) { ...@@ -978,11 +978,8 @@ void ha_tokudb::unpack_row(uchar * record, DBT * row) {
const uchar *ptr = (const uchar *) row->data; const uchar *ptr = (const uchar *) row->data;
memcpy(record, ptr, table_share->null_bytes); memcpy(record, ptr, table_share->null_bytes);
ptr += table_share->null_bytes; ptr += table_share->null_bytes;
uchar *fieldrecord = record;
if (fieldrecord == table->record[1])
fieldrecord = table->record[0];
for (Field ** field = table->field; *field; field++) for (Field ** field = table->field; *field; field++)
ptr = (*field)->unpack(record + (*field)->offset(fieldrecord), ptr); ptr = (*field)->unpack(record + field_offset(*field), ptr);
dbug_tmp_restore_column_map(table->write_set, old_map); dbug_tmp_restore_column_map(table->write_set, old_map);
} }
} }
...@@ -1005,7 +1002,7 @@ void ha_tokudb::unpack_key(uchar * record, DBT * key, uint index) { ...@@ -1005,7 +1002,7 @@ void ha_tokudb::unpack_key(uchar * record, DBT * key, uint index) {
} }
record[key_part->null_offset] &= ~key_part->null_bit; record[key_part->null_offset] &= ~key_part->null_bit;
} }
pos = (uchar *) key_part->field->unpack_key(record + key_part->field->offset(record), pos, pos = (uchar *) key_part->field->unpack_key(record + field_offset(key_part->field), pos,
#if MYSQL_VERSION_ID < 50123 #if MYSQL_VERSION_ID < 50123
key_part->length); key_part->length);
#else #else
...@@ -2478,6 +2475,12 @@ int ha_tokudb::check(THD * thd, HA_CHECK_OPT * check_opt) { ...@@ -2478,6 +2475,12 @@ int ha_tokudb::check(THD * thd, HA_CHECK_OPT * check_opt) {
} }
#endif #endif
ulong ha_tokudb::field_offset(Field *field) {
if (table->record[0] <= field->ptr && field->ptr < table->record[1])
return field->offset(table->record[0]);
assert(0);
return 0;
}
struct st_mysql_storage_engine storage_engine_structure = { MYSQL_HANDLERTON_INTERFACE_VERSION }; struct st_mysql_storage_engine storage_engine_structure = { MYSQL_HANDLERTON_INTERFACE_VERSION };
......
...@@ -147,4 +147,5 @@ class ha_tokudb : public handler { ...@@ -147,4 +147,5 @@ class ha_tokudb : public handler {
private: private:
int __close(int mutex_is_locked); int __close(int mutex_is_locked);
int read_last(); int read_last();
ulong field_offset(Field *);
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment