From c2d5d8e1e8d76fb7fc4619e26b4a75ed2bffa61e Mon Sep 17 00:00:00 2001 From: Zardosht Kasheff Date: Thu, 6 Aug 2009 15:49:36 +0000 Subject: [PATCH] [t:1925], use db->getf_set in a couple of places git-svn-id: file:///svn/mysql/tokudb-engine/src@13866 c7de825b-a66e-492c-adef-691d508d4ae1 --- storage/tokudb/ha_tokudb.cc | 52 +++++++++++++++++++++++++++---------- storage/tokudb/ha_tokudb.h | 1 + 2 files changed, 40 insertions(+), 13 deletions(-) diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc index 4452c4e3a32..0def965b92b 100644 --- a/storage/tokudb/ha_tokudb.cc +++ b/storage/tokudb/ha_tokudb.cc @@ -361,6 +361,13 @@ static int smart_dbt_do_nothing (DBT const *key, DBT const *row, void *context) } +static int +smart_dbt_callback_rowread_ptquery (DBT const *key, DBT const *row, void *context) { + SMART_DBT_INFO info = (SMART_DBT_INFO)context; + info->ha->read_row_callback(info->buf,info->keynr,row,key); + return 0; +} + // // Smart DBT callback function in case where we have a covering index // @@ -3250,6 +3257,12 @@ void ha_tokudb::extract_hidden_primary_key(uint keynr, DBT const *row, DBT const } } + +void ha_tokudb::read_row_callback (uchar * buf, uint keynr, DBT const *row, DBT const *found_key) { + assert(keynr == primary_key); + unpack_row(buf, row,found_key, keynr); +} + // // Reads the contents of row and found_key, DBT's retrieved from the DB associated to keynr, into buf // This function assumes that we are using a covering index, as a result, if keynr is the primary key, @@ -3320,15 +3333,25 @@ exit: int ha_tokudb::read_full_row(uchar * buf) { TOKUDB_DBUG_ENTER("ha_tokudb::read_full_row"); int error; + struct smart_dbt_info info; + info.ha = this; + info.buf = buf; + info.keynr = primary_key; // - // Read the data into current_row, assumes key is stored in this->last_key + // assumes key is stored in this->last_key // - current_row.flags = DB_DBT_REALLOC; - if ((error = share->file->get(share->file, transaction, &last_key, ¤t_row, 0))) { + error = share->file->getf_set( + share->file, + transaction, + 0, + &last_key, + smart_dbt_callback_rowread_ptquery, + &info + ); + if (error) { table->status = STATUS_NOT_FOUND; TOKUDB_DBUG_RETURN(error == DB_NOTFOUND ? HA_ERR_CRASHED : error); } - error = unpack_row(buf, ¤t_row, &last_key, primary_key); TOKUDB_DBUG_RETURN(error); } @@ -3924,22 +3947,25 @@ int ha_tokudb::rnd_pos(uchar * buf, uchar * pos) { TOKUDB_DBUG_ENTER("ha_tokudb::rnd_pos"); DBT db_pos; int error; + struct smart_dbt_info info; + bool old_unpack_entire_row = unpack_entire_row; + DBT* key = get_pos(&db_pos, pos); + + unpack_entire_row = true; statistic_increment(table->in_use->status_var.ha_read_rnd_count, &LOCK_status); active_index = MAX_KEY; - DBT* key = get_pos(&db_pos, pos); - error = share->file->get(share->file, transaction, key, ¤t_row, 0); + + info.ha = this; + info.buf = buf; + info.keynr = primary_key; + + error = share->file->getf_set(share->file, transaction, 0, key, smart_dbt_callback_rowread_ptquery, &info); if (error == DB_NOTFOUND) { error = HA_ERR_KEY_NOT_FOUND; goto cleanup; - } - - if (!error) { - bool old_unpack_entire_row = unpack_entire_row; - unpack_entire_row = true; - error = read_row(buf, primary_key, ¤t_row, key); - unpack_entire_row = old_unpack_entire_row; } cleanup: + unpack_entire_row = old_unpack_entire_row; TOKUDB_DBUG_RETURN(error); } diff --git a/storage/tokudb/ha_tokudb.h b/storage/tokudb/ha_tokudb.h index 9c9e687983f..1d91d9a4f8d 100644 --- a/storage/tokudb/ha_tokudb.h +++ b/storage/tokudb/ha_tokudb.h @@ -421,6 +421,7 @@ public: int delete_all_rows(); void extract_hidden_primary_key(uint keynr, DBT const *row, DBT const *found_key); void read_key_only(uchar * buf, uint keynr, DBT const *row, DBT const *found_key); + void read_row_callback (uchar * buf, uint keynr, DBT const *row, DBT const *found_key); int read_primary_key(uchar * buf, uint keynr, DBT const *row, DBT const *found_key); int read_row(uchar * buf, uint keynr, DBT const *row, DBT const *found_key); int unpack_blobs(