Commit ee1e9cfd authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#4921 add per table data size to the tokudb_user_data information schema....

#4921 add per table data size to the tokudb_user_data information schema. also, combine all handlerton source into one compiled file refs[t:4921]

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@43824 c7de825b-a66e-492c-adef-691d508d4ae1
parent 3c1c690b
...@@ -9,5 +9,5 @@ FIND_LIBRARY(TOKUFRACTALTREE_LIB NAMES ${TOKUFRACTALTREE_LIBNAME} HINTS ${TOKUFR ...@@ -9,5 +9,5 @@ FIND_LIBRARY(TOKUFRACTALTREE_LIB NAMES ${TOKUFRACTALTREE_LIBNAME} HINTS ${TOKUFR
FIND_LIBRARY(TOKUPORTABILITY_LIB NAMES ${TOKUPORTABILITY_LIBNAME} HINTS ${TOKUFRACTALTREE_RELEASE_DIR}/lib) FIND_LIBRARY(TOKUPORTABILITY_LIB NAMES ${TOKUPORTABILITY_LIBNAME} HINTS ${TOKUFRACTALTREE_RELEASE_DIR}/lib)
SET(TOKUDB_PLUGIN_DYNAMIC "ha_tokudb") SET(TOKUDB_PLUGIN_DYNAMIC "ha_tokudb")
SET(TOKUDB_SOURCES hatoku_hton.cc hatoku_cmp.cc ha_tokudb.cc) SET(TOKUDB_SOURCES ha_tokudb.cc)
MYSQL_ADD_PLUGIN(tokudb ${TOKUDB_SOURCES} STORAGE_ENGINE MODULE_ONLY LINK_LIBRARIES ${TOKUFRACTALTREE_LIB} ${TOKUPORTABILITY_LIB}) MYSQL_ADD_PLUGIN(tokudb ${TOKUDB_SOURCES} STORAGE_ENGINE MODULE_ONLY LINK_LIBRARIES ${TOKUFRACTALTREE_LIB} ${TOKUPORTABILITY_LIB})
...@@ -23,12 +23,12 @@ pkgplugin_LTLIBRARIES = @plugin_tokudb_shared_target@ ...@@ -23,12 +23,12 @@ pkgplugin_LTLIBRARIES = @plugin_tokudb_shared_target@
ha_tokudb_la_LIBADD = -L$(TOKUFRACTALTREE)/lib -l$(TOKUFRACTALTREE_LIBNAME) -l$(TOKUPORTABILITY_LIBNAME) ha_tokudb_la_LIBADD = -L$(TOKUFRACTALTREE)/lib -l$(TOKUFRACTALTREE_LIBNAME) -l$(TOKUPORTABILITY_LIBNAME)
ha_tokudb_la_LDFLAGS = -module -rpath $(pkgplugindir) ha_tokudb_la_LDFLAGS = -module -rpath $(pkgplugindir)
ha_tokudb_la_CXXFLAGS = $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN -DTOKUDB_VERSION=\"$(TOKUDB_VERSION)\" -Wall ha_tokudb_la_CXXFLAGS = $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN -DTOKUDB_VERSION=\"$(TOKUDB_VERSION)\" -Wall
ha_tokudb_la_SOURCES = hatoku_hton.cc hatoku_cmp.cc ha_tokudb.cc ha_tokudb_la_SOURCES = ha_tokudb.cc
EXTRA_LIBRARIES = libtokudb.a EXTRA_LIBRARIES = libtokudb.a
noinst_LIBRARIES = @plugin_tokudb_static_target@ noinst_LIBRARIES = @plugin_tokudb_static_target@
libtokudb_a_CXXFLAGS = $(AM_CXXFLAGS) -Wall libtokudb_a_CXXFLAGS = $(AM_CXXFLAGS) -Wall
libtokudb_a_SOURCES = hatoku_hton.cc hatoku_cmp.cc ha_tokudb.cc libtokudb_a_SOURCES = ha_tokudb.cc
EXTRA_DIST = CMakeLists.txt plug.in EXTRA_DIST = CMakeLists.txt plug.in
# Don't update the files from bitkeeper # Don't update the files from bitkeeper
......
This diff is collapsed.
#if !defined(HA_TOKUDB_H)
#define HA_TOKUDB_H
#ifdef USE_PRAGMA_INTERFACE #ifdef USE_PRAGMA_INTERFACE
#pragma interface /* gcc class implementation */ #pragma interface /* gcc class implementation */
#endif #endif
...@@ -141,31 +144,6 @@ typedef enum { ...@@ -141,31 +144,6 @@ typedef enum {
lock_write lock_write
} TABLE_LOCK_TYPE; } TABLE_LOCK_TYPE;
int create_tokudb_trx_data_instance(tokudb_trx_data** out_trx);
int generate_row_for_del(
DB *dest_db,
DB *src_db,
DBT *dest_key,
const DBT *src_key,
const DBT *src_val
);
int generate_row_for_put(
DB *dest_db,
DB *src_db,
DBT *dest_key,
DBT *dest_val,
const DBT *src_key,
const DBT *src_val
);
int tokudb_update_fun(
DB* db,
const DBT *key,
const DBT *old_val,
const DBT *extra,
void (*set_val)(const DBT *new_val, void *set_extra),
void *set_extra
);
// the number of rows bulk fetched in one callback grows exponentially // the number of rows bulk fetched in one callback grows exponentially
// with the bulk fetch iteration, so the max iteration is the max number // with the bulk fetch iteration, so the max iteration is the max number
// of shifts we can perform on a 64 bit integer. // of shifts we can perform on a 64 bit integer.
...@@ -706,9 +684,6 @@ private: ...@@ -706,9 +684,6 @@ private:
int delete_all_rows_internal(); int delete_all_rows_internal();
}; };
int open_status_dictionary(DB** ptr, const char* name, DB_TXN* txn);
#if MYSQL_VERSION_ID >= 50506 #if MYSQL_VERSION_ID >= 50506
static inline void my_free(void *p, int arg) { static inline void my_free(void *p, int arg) {
...@@ -721,3 +696,5 @@ static inline void *memcpy_fixed(void *a, const void *b, size_t n) { ...@@ -721,3 +696,5 @@ static inline void *memcpy_fixed(void *a, const void *b, size_t n) {
#endif #endif
#endif
...@@ -128,7 +128,7 @@ void get_blob_field_info( ...@@ -128,7 +128,7 @@ void get_blob_field_info(
u_int32_t num_offset_bytes u_int32_t num_offset_bytes
); );
inline u_int32_t get_blob_field_len( static inline u_int32_t get_blob_field_len(
const uchar* from_tokudb, const uchar* from_tokudb,
u_int32_t len_bytes u_int32_t len_bytes
) )
...@@ -154,7 +154,7 @@ inline u_int32_t get_blob_field_len( ...@@ -154,7 +154,7 @@ inline u_int32_t get_blob_field_len(
} }
inline const uchar* unpack_toku_field_blob( static inline const uchar* unpack_toku_field_blob(
uchar *to_mysql, uchar *to_mysql,
const uchar* from_tokudb, const uchar* from_tokudb,
u_int32_t len_bytes, u_int32_t len_bytes,
...@@ -175,7 +175,7 @@ inline const uchar* unpack_toku_field_blob( ...@@ -175,7 +175,7 @@ inline const uchar* unpack_toku_field_blob(
return (from_tokudb + len_bytes + length); return (from_tokudb + len_bytes + length);
} }
inline uint get_null_offset(TABLE* table, Field* field) { static inline uint get_null_offset(TABLE* table, Field* field) {
return (uint) ((uchar*) field->null_ptr - (uchar*) table->record[0]); return (uint) ((uchar*) field->null_ptr - (uchar*) table->record[0]);
} }
...@@ -255,14 +255,14 @@ uchar* unpack_toku_key_field( ...@@ -255,14 +255,14 @@ uchar* unpack_toku_key_field(
// //
// function to convert a hidden primary key into a byte stream that can be stored in DBT // function to convert a hidden primary key into a byte stream that can be stored in DBT
// //
inline void hpk_num_to_char(uchar* to, ulonglong num) { static inline void hpk_num_to_char(uchar* to, ulonglong num) {
int8store(to, num); int8store(to, num);
} }
// //
// function that takes a byte stream of a hidden primary key and returns a ulonglong // function that takes a byte stream of a hidden primary key and returns a ulonglong
// //
inline ulonglong hpk_char_to_num(uchar* val) { static inline ulonglong hpk_char_to_num(uchar* val) {
return uint8korr(val); return uint8korr(val);
} }
...@@ -308,7 +308,7 @@ u_int32_t create_toku_clustering_val_pack_descriptor ( ...@@ -308,7 +308,7 @@ u_int32_t create_toku_clustering_val_pack_descriptor (
bool is_clustering bool is_clustering
); );
inline bool is_key_clustering( static inline bool is_key_clustering(
void* row_desc, void* row_desc,
u_int32_t row_desc_size u_int32_t row_desc_size
) )
...@@ -338,7 +338,7 @@ u_int32_t create_toku_secondary_key_pack_descriptor ( ...@@ -338,7 +338,7 @@ u_int32_t create_toku_secondary_key_pack_descriptor (
KEY* prim_key KEY* prim_key
); );
inline bool is_key_pk( static inline bool is_key_pk(
void* row_desc, void* row_desc,
u_int32_t row_desc_size u_int32_t row_desc_size
) )
......
...@@ -43,7 +43,7 @@ extern ulong tokudb_debug; ...@@ -43,7 +43,7 @@ extern ulong tokudb_debug;
printf("%d:%s:%d:" f, my_tid(), __FILE__, __LINE__, ##__VA_ARGS__); printf("%d:%s:%d:" f, my_tid(), __FILE__, __LINE__, ##__VA_ARGS__);
inline unsigned int my_tid() { static inline unsigned int my_tid() {
return (unsigned int)toku_os_gettid(); return (unsigned int)toku_os_gettid();
} }
......
...@@ -39,15 +39,6 @@ typedef struct savepoint_info { ...@@ -39,15 +39,6 @@ typedef struct savepoint_info {
bool in_sub_stmt; bool in_sub_stmt;
} *SP_INFO, SP_INFO_T; } *SP_INFO, SP_INFO_T;
static inline void *thd_data_get(THD *thd, int slot) {
return thd->ha_data[slot].ha_ptr;
}
static inline void thd_data_set(THD *thd, int slot, void *data) {
thd->ha_data[slot].ha_ptr = data;
}
static uchar *tokudb_get_key(TOKUDB_SHARE * share, size_t * length, my_bool not_used __attribute__ ((unused))) { static uchar *tokudb_get_key(TOKUDB_SHARE * share, size_t * length, my_bool not_used __attribute__ ((unused))) {
*length = share->table_name_length; *length = share->table_name_length;
return (uchar *) share->table_name; return (uchar *) share->table_name;
...@@ -145,11 +136,10 @@ static MYSQL_THDVAR_UINT(read_buf_size, ...@@ -145,11 +136,10 @@ static MYSQL_THDVAR_UINT(read_buf_size,
1 // blocksize??? 1 // blocksize???
); );
void tokudb_checkpoint_lock(THD * thd); static void tokudb_checkpoint_lock(THD * thd);
void tokudb_checkpoint_unlock(THD * thd); static void tokudb_checkpoint_unlock(THD * thd);
static static void
void
tokudb_checkpoint_lock_update( tokudb_checkpoint_lock_update(
THD* thd, THD* thd,
struct st_mysql_sys_var* var, struct st_mysql_sys_var* var,
...@@ -1000,6 +990,7 @@ static int tokudb_release_savepoint(handlerton * hton, THD * thd, void *savepoin ...@@ -1000,6 +990,7 @@ static int tokudb_release_savepoint(handlerton * hton, THD * thd, void *savepoin
TOKUDB_DBUG_RETURN(error); TOKUDB_DBUG_RETURN(error);
} }
#if 0
static int static int
smart_dbt_callback_verify_frm (DBT const *key, DBT const *row, void *context) { smart_dbt_callback_verify_frm (DBT const *key, DBT const *row, void *context) {
DBT* stored_frm = (DBT *)context; DBT* stored_frm = (DBT *)context;
...@@ -1009,6 +1000,8 @@ smart_dbt_callback_verify_frm (DBT const *key, DBT const *row, void *context) { ...@@ -1009,6 +1000,8 @@ smart_dbt_callback_verify_frm (DBT const *key, DBT const *row, void *context) {
memcpy(stored_frm->data, row->data, row->size); memcpy(stored_frm->data, row->data, row->size);
return 0; return 0;
} }
#endif
static int tokudb_discover(handlerton *hton, THD* thd, const char *db, static int tokudb_discover(handlerton *hton, THD* thd, const char *db,
const char *name, const char *name,
uchar **frmblob, uchar **frmblob,
...@@ -1060,14 +1053,8 @@ cleanup: ...@@ -1060,14 +1053,8 @@ cleanup:
TOKUDB_DBUG_RETURN(error); TOKUDB_DBUG_RETURN(error);
} }
static int smart_dbt_do_nothing (DBT const *key, DBT const *row, void *context) { static int tokudb_get_user_data_size(TABLE *table, THD *thd, bool exact) {
return 0;
}
static int tokudb_get_user_data_size(THD *thd, bool exact, u_int64_t *data_size_ret) {
int error; int error;
u_int64_t num_bytes_in_db = 0;
DB* curr_db = NULL; DB* curr_db = NULL;
DB_TXN* txn = NULL; DB_TXN* txn = NULL;
DBC* tmp_cursor = NULL; DBC* tmp_cursor = NULL;
...@@ -1186,7 +1173,21 @@ static int tokudb_get_user_data_size(THD *thd, bool exact, u_int64_t *data_size_ ...@@ -1186,7 +1173,21 @@ static int tokudb_get_user_data_size(THD *thd, bool exact, u_int64_t *data_size_
curr_num_bytes = (inf_byte_space > curr_num_bytes) ? 0 : curr_num_bytes - inf_byte_space; curr_num_bytes = (inf_byte_space > curr_num_bytes) ? 0 : curr_num_bytes - inf_byte_space;
} }
num_bytes_in_db += curr_num_bytes; char *tablename = strrchr(name, '/');
if (tablename == NULL) goto cleanup;
*tablename++ = 0;
char *dbname = strchr(name, '/');
if (dbname == NULL)
dbname = name;
else
dbname++;
table->field[0]->store(dbname, strlen(dbname), system_charset_info);
table->field[1]->store(tablename, strlen(tablename), system_charset_info);
table->field[2]->store(curr_num_bytes, false);
error = schema_table_store_record(thd, table);
if (error) goto cleanup;
{ {
int r = curr_db->close(curr_db, 0); int r = curr_db->close(curr_db, 0);
...@@ -1202,8 +1203,6 @@ static int tokudb_get_user_data_size(THD *thd, bool exact, u_int64_t *data_size_ ...@@ -1202,8 +1203,6 @@ static int tokudb_get_user_data_size(THD *thd, bool exact, u_int64_t *data_size_
} }
} }
*data_size_ret = num_bytes_in_db;
error = 0; error = 0;
cleanup: cleanup:
...@@ -1344,7 +1343,7 @@ static bool tokudb_show_engine_status(THD * thd, stat_print_fn * stat_print) { ...@@ -1344,7 +1343,7 @@ static bool tokudb_show_engine_status(THD * thd, stat_print_fn * stat_print) {
TOKUDB_DBUG_RETURN(error); TOKUDB_DBUG_RETURN(error);
} }
void tokudb_checkpoint_lock(THD * thd) { static void tokudb_checkpoint_lock(THD * thd) {
int error; int error;
tokudb_trx_data* trx = NULL; tokudb_trx_data* trx = NULL;
char status_msg[200]; //buffer of 200 should be a good upper bound. char status_msg[200]; //buffer of 200 should be a good upper bound.
...@@ -1375,7 +1374,7 @@ cleanup: ...@@ -1375,7 +1374,7 @@ cleanup:
return; return;
} }
void tokudb_checkpoint_unlock(THD * thd) { static void tokudb_checkpoint_unlock(THD * thd) {
int error; int error;
char status_msg[200]; //buffer of 200 should be a good upper bound. char status_msg[200]; //buffer of 200 should be a good upper bound.
tokudb_trx_data* trx = NULL; tokudb_trx_data* trx = NULL;
...@@ -1402,10 +1401,7 @@ cleanup: ...@@ -1402,10 +1401,7 @@ cleanup:
return; return;
} }
static bool tokudb_show_status(handlerton * hton, THD * thd, stat_print_fn * stat_print, enum ha_stat_type stat_type) {
bool tokudb_show_status(handlerton * hton, THD * thd, stat_print_fn * stat_print, enum ha_stat_type stat_type) {
switch (stat_type) { switch (stat_type) {
case HA_ENGINE_STATUS: case HA_ENGINE_STATUS:
return tokudb_show_engine_status(thd, stat_print); return tokudb_show_engine_status(thd, stat_print);
...@@ -1420,7 +1416,7 @@ static void tokudb_print_error(const DB_ENV * db_env, const char *db_errpfx, con ...@@ -1420,7 +1416,7 @@ static void tokudb_print_error(const DB_ENV * db_env, const char *db_errpfx, con
sql_print_error("%s: %s", db_errpfx, buffer); sql_print_error("%s: %s", db_errpfx, buffer);
} }
void tokudb_cleanup_log_files(void) { static void tokudb_cleanup_log_files(void) {
TOKUDB_DBUG_ENTER("tokudb_cleanup_log_files"); TOKUDB_DBUG_ENTER("tokudb_cleanup_log_files");
char **names; char **names;
int error; int error;
...@@ -1602,7 +1598,9 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = { ...@@ -1602,7 +1598,9 @@ static struct st_mysql_sys_var *tokudb_system_variables[] = {
struct st_mysql_storage_engine tokudb_storage_engine = { MYSQL_HANDLERTON_INTERFACE_VERSION }; struct st_mysql_storage_engine tokudb_storage_engine = { MYSQL_HANDLERTON_INTERFACE_VERSION };
static ST_FIELD_INFO tokudb_user_data_field_info[] = { static ST_FIELD_INFO tokudb_user_data_field_info[] = {
{"User Data Size", 8, MYSQL_TYPE_LONGLONG, 0, 0, "user data size", SKIP_OPEN_TABLE }, {"database_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE },
{"table_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE },
{"data_size", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE },
{NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE} {NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE}
}; };
...@@ -1612,7 +1610,6 @@ static int tokudb_user_data_fill_table(THD *thd, TABLE_LIST *tables, Item *cond) ...@@ -1612,7 +1610,6 @@ static int tokudb_user_data_fill_table(THD *thd, TABLE_LIST *tables, Item *cond)
static int tokudb_user_data_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) { static int tokudb_user_data_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) {
#endif #endif
int error; int error;
uint64_t data_size;
TABLE *table = tables->table; TABLE *table = tables->table;
// 3938: Get a read lock on the status flag, since we must // 3938: Get a read lock on the status flag, since we must
...@@ -1623,11 +1620,7 @@ static int tokudb_user_data_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) ...@@ -1623,11 +1620,7 @@ static int tokudb_user_data_fill_table(THD *thd, TABLE_LIST *tables, COND *cond)
my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), "TokuDB"); my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), "TokuDB");
error = -1; error = -1;
} else { } else {
error = tokudb_get_user_data_size(thd, false, &data_size); error = tokudb_get_user_data_size(table, thd, false);
if (error == 0) {
table->field[0]->store(data_size, false);
error = schema_table_store_record(thd, table);
}
} }
// 3938: unlock the status flag lock // 3938: unlock the status flag lock
...@@ -1646,10 +1639,12 @@ static int tokudb_user_data_done(void *p) { ...@@ -1646,10 +1639,12 @@ static int tokudb_user_data_done(void *p) {
return 0; return 0;
} }
struct st_mysql_information_schema tokudb_user_data_information_schema = { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION }; static struct st_mysql_information_schema tokudb_user_data_information_schema = { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION };
static ST_FIELD_INFO tokudb_user_data_exact_field_info[] = { static ST_FIELD_INFO tokudb_user_data_exact_field_info[] = {
{"User Data Size", 8, MYSQL_TYPE_LONGLONG, 0, 0, "user data size", SKIP_OPEN_TABLE }, {"database_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE },
{"table_name", 256, MYSQL_TYPE_STRING, 0, 0, NULL, SKIP_OPEN_TABLE },
{"data_size", 0, MYSQL_TYPE_LONGLONG, 0, 0, NULL, SKIP_OPEN_TABLE },
{NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE} {NULL, 0, MYSQL_TYPE_NULL, 0, 0, NULL, SKIP_OPEN_TABLE}
}; };
...@@ -1659,7 +1654,6 @@ static int tokudb_user_data_exact_fill_table(THD *thd, TABLE_LIST *tables, Item ...@@ -1659,7 +1654,6 @@ static int tokudb_user_data_exact_fill_table(THD *thd, TABLE_LIST *tables, Item
static int tokudb_user_data_exact_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) { static int tokudb_user_data_exact_fill_table(THD *thd, TABLE_LIST *tables, COND *cond) {
#endif #endif
int error; int error;
uint64_t data_size;
TABLE *table = tables->table; TABLE *table = tables->table;
// 3938: Get a read lock on the status flag, since we must // 3938: Get a read lock on the status flag, since we must
...@@ -1670,11 +1664,7 @@ static int tokudb_user_data_exact_fill_table(THD *thd, TABLE_LIST *tables, COND ...@@ -1670,11 +1664,7 @@ static int tokudb_user_data_exact_fill_table(THD *thd, TABLE_LIST *tables, COND
my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), "TokuDB"); my_error(ER_PLUGIN_IS_NOT_LOADED, MYF(0), "TokuDB");
error = -1; error = -1;
} else { } else {
error = tokudb_get_user_data_size(thd, true, &data_size); error = tokudb_get_user_data_size(table, thd, true);
if (error == 0) {
table->field[0]->store(data_size, false);
error = schema_table_store_record(thd, table);
}
} }
//3938: unlock the status flag lock //3938: unlock the status flag lock
...@@ -1693,7 +1683,7 @@ static int tokudb_user_data_exact_done(void *p) { ...@@ -1693,7 +1683,7 @@ static int tokudb_user_data_exact_done(void *p) {
return 0; return 0;
} }
struct st_mysql_information_schema tokudb_user_data_exact_information_schema = { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION }; static struct st_mysql_information_schema tokudb_user_data_exact_information_schema = { MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION };
enum { TOKUDB_PLUGIN_VERSION = 0x0400 }; enum { TOKUDB_PLUGIN_VERSION = 0x0400 };
#define TOKUDB_PLUGIN_VERSION_STR "1024" #define TOKUDB_PLUGIN_VERSION_STR "1024"
......
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