Commit 37ccd7b7 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:885], put entries for data_length, index_length, and mean_rec_length for show table status

git-svn-id: file:///svn/mysql/tokudb-engine/src@14345 c7de825b-a66e-492c-adef-691d508d4ae1
parent a5c7177a
......@@ -3945,10 +3945,41 @@ void ha_tokudb::position(const uchar * record) {
//
int ha_tokudb::info(uint flag) {
TOKUDB_DBUG_ENTER("ha_tokudb::info %p %d %lld", this, flag, share->rows);
int error;
DB_TXN* txn = NULL;
uint curr_num_DBs = table->s->keys + test(hidden_primary_key);
DB_BTREE_STAT64 dict_stats;
if (flag & HA_STATUS_VARIABLE) {
// Just to get optimizations right
stats.records = share->rows + share->rows_from_locked_table;
stats.deleted = 0;
if (!(flag & HA_STATUS_NO_LOCK)) {
error = db_env->txn_begin(db_env, NULL, &txn, DB_READ_UNCOMMITTED);
if (error) { goto cleanup; }
error = share->file->stat64(
share->file,
txn,
&dict_stats
);
if (error) { goto cleanup; }
stats.data_file_length = dict_stats.bt_dsize;
stats.mean_rec_length = stats.data_file_length/stats.records;
stats.index_file_length = 0;
for (uint i = 0; i < curr_num_DBs; i++) {
if (i == primary_key) {
continue;
}
error = share->key_file[i]->stat64(
share->key_file[i],
txn,
&dict_stats
);
if (error) { goto cleanup; }
stats.index_file_length += dict_stats.bt_dsize;
}
}
}
if ((flag & HA_STATUS_CONST)) {
for (uint i = 0; i < table_share->keys; i++) {
......@@ -3964,7 +3995,13 @@ int ha_tokudb::info(uint flag) {
struct system_variables *variables= &thd->variables;
stats.auto_increment_value = share->last_auto_increment + variables->auto_increment_increment;
}
TOKUDB_DBUG_RETURN(0);
error = 0;
cleanup:
if (txn != NULL) {
txn->commit(txn, DB_TXN_NOSYNC);
txn = NULL;
}
TOKUDB_DBUG_RETURN(error);
}
//
......
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