Commit 36967090 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #808

no longer append hidden primary key at end of data inserted in tokudb table

git-svn-id: file:///svn/mysql/tokudb-engine/src@3900 c7de825b-a66e-492c-adef-691d508d4ae1
parent 8125c7c2
......@@ -1192,11 +1192,11 @@ int ha_tokudb::pack_row(DBT * row, const uchar * record, bool new_row) {
bzero((void *) row, sizeof(*row));
if (share->fixed_length_row) {
row->data = (void *) record;
row->size = table_share->reclength + hidden_primary_key;
row->size = table_share->reclength;
if (hidden_primary_key) {
if (new_row)
if (new_row) {
get_auto_primary_key(current_ident);
memcpy_fixed((char *) record + table_share->reclength, (char *) current_ident, TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH);
}
}
return 0;
}
......@@ -1214,10 +1214,9 @@ int ha_tokudb::pack_row(DBT * row, const uchar * record, bool new_row) {
(record + field_offset(*field)));
if (hidden_primary_key) {
if (new_row)
if (new_row) {
get_auto_primary_key(current_ident);
memcpy_fixed((char *) ptr, (char *) current_ident, TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH);
ptr += TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH;
}
}
row->data = rec_buff;
row->size = (size_t) (ptr - rec_buff);
......@@ -1232,7 +1231,7 @@ int ha_tokudb::pack_row(DBT * row, const uchar * record, bool new_row) {
//
void ha_tokudb::unpack_row(uchar * record, DBT * row) {
if (share->fixed_length_row)
memcpy(record, (void *) row->data, table_share->reclength + hidden_primary_key);
memcpy(record, (void *) row->data, table_share->reclength);
else {
/* Copy null bits */
my_bitmap_map *old_map = dbug_tmp_use_all_columns(table, table->write_set);
......@@ -2029,12 +2028,15 @@ int ha_tokudb::read_row(int error, uchar * buf, uint keynr, DBT * row, DBT * fou
TOKUDB_DBUG_RETURN(error);
}
//
// TODO: figure out the most appropriate place to put this comment
// Autogenerated primary keys are are appended to the end of the row, and we extract
// its value into current_ident
// extract hidden primary key to current_ident
//
if (hidden_primary_key) {
memcpy_fixed(current_ident, (char *) row->data + row->size - TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH, TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH);
if (keynr == primary_key) {
memcpy_fixed(current_ident, (char *) found_key->data, TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH);
}
else {
memcpy_fixed(current_ident, (char *) row->data, TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH);
}
}
table->status = 0;
//
......
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