Commit c7836bb3 authored by Rich Prohaska's avatar Rich Prohaska

#166 add this handler to debug enter and return

parent 3a789b41
This diff is collapsed.
......@@ -127,7 +127,7 @@ static int analyze_progress(void *v_extra, uint64_t rows) {
}
int ha_tokudb::analyze(THD *thd, HA_CHECK_OPT *check_opt) {
TOKUDB_DBUG_ENTER("ha_tokudb::analyze");
TOKUDB_HANDLER_DBUG_ENTER("");
uint64_t rec_per_key[table_share->key_parts];
int result = HA_ADMIN_OK;
DB_TXN *txn = transaction;
......@@ -165,7 +165,7 @@ int ha_tokudb::analyze(THD *thd, HA_CHECK_OPT *check_opt) {
}
if (result == HA_ADMIN_OK)
tokudb::set_card_in_status(share->status_block, txn, table_share->key_parts, rec_per_key);
TOKUDB_DBUG_RETURN(result);
TOKUDB_HANDLER_DBUG_RETURN(result);
}
static int hot_poll_fun(void *extra, float progress) {
......@@ -192,7 +192,7 @@ static int hot_poll_fun(void *extra, float progress) {
// flatten all DB's in this table, to do so, peform hot optimize on each db
int ha_tokudb::optimize(THD * thd, HA_CHECK_OPT * check_opt) {
TOKUDB_DBUG_ENTER("ha_tokudb::optimize");
TOKUDB_HANDLER_DBUG_ENTER("");
int error;
uint curr_num_DBs = table->s->keys + tokudb_test(hidden_primary_key);
......@@ -233,7 +233,7 @@ cleanup:
thd_progress_end(thd);
#endif
TOKUDB_DBUG_RETURN(error);
TOKUDB_HANDLER_DBUG_RETURN(error);
}
struct check_context {
......@@ -262,7 +262,7 @@ static void ha_tokudb_check_info(THD *thd, TABLE *table, const char *msg) {
}
int ha_tokudb::check(THD *thd, HA_CHECK_OPT *check_opt) {
TOKUDB_DBUG_ENTER("check");
TOKUDB_HANDLER_DBUG_ENTER("");
const char *old_proc_info = thd->proc_info;
thd_proc_info(thd, "tokudb::check");
......@@ -319,5 +319,5 @@ int ha_tokudb::check(THD *thd, HA_CHECK_OPT *check_opt) {
}
}
thd_proc_info(thd, old_proc_info);
TOKUDB_DBUG_RETURN(result);
TOKUDB_HANDLER_DBUG_RETURN(result);
}
......@@ -282,7 +282,7 @@ static bool only_flags(ulong bits, ulong mask) {
// must set WRITE_ALLOW_WRITE lock type in the external lock method to avoid deadlocks
// with the MDL lock and the table lock
enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(TABLE *altered_table, Alter_inplace_info *ha_alter_info) {
TOKUDB_DBUG_ENTER("check_if_supported_alter");
TOKUDB_HANDLER_DBUG_ENTER("");
if (tokudb_debug & TOKUDB_DEBUG_ALTER_TABLE_INFO) {
print_alter_info(altered_table, ha_alter_info);
......@@ -437,7 +437,7 @@ enum_alter_inplace_result ha_tokudb::check_if_supported_inplace_alter(TABLE *alt
// Prepare for the alter operations
bool ha_tokudb::prepare_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info) {
TOKUDB_DBUG_ENTER("prepare_inplace_alter_table");
TOKUDB_HANDLER_DBUG_ENTER("");
tokudb_alter_ctx *ctx = static_cast<tokudb_alter_ctx *>(ha_alter_info->handler_ctx);
assert(transaction); // transaction must exist after table is locked
ctx->alter_txn = transaction;
......@@ -447,7 +447,7 @@ bool ha_tokudb::prepare_inplace_alter_table(TABLE *altered_table, Alter_inplace_
// Execute the alter operations.
bool ha_tokudb::inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info) {
TOKUDB_DBUG_ENTER("inplace_alter_table");
TOKUDB_HANDLER_DBUG_ENTER("");
int error = 0;
tokudb_alter_ctx *ctx = static_cast<tokudb_alter_ctx *>(ha_alter_info->handler_ctx);
......@@ -674,7 +674,7 @@ int ha_tokudb::alter_table_add_or_drop_column(TABLE *altered_table, Alter_inplac
// If commit then write the new frm data to the status using the alter transaction.
// If abort then abort the alter transaction and try to rollback the non-transactional changes.
bool ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *ha_alter_info, bool commit) {
TOKUDB_DBUG_ENTER("commit_inplace_alter_table");
TOKUDB_HANDLER_DBUG_ENTER("");
tokudb_alter_ctx *ctx = static_cast<tokudb_alter_ctx *>(ha_alter_info->handler_ctx);
bool result = false; // success
......
......@@ -252,7 +252,7 @@ static uint32_t blob_field_index(TABLE *table, KEY_AND_COL_INFO *kc_info, uint i
// of where conditions (conds). The function returns 0 if the update is handled in the storage engine.
// Otherwise, an error is returned.
int ha_tokudb::fast_update(THD *thd, List<Item> &update_fields, List<Item> &update_values, Item *conds) {
TOKUDB_DBUG_ENTER("ha_tokudb::fast_update");
TOKUDB_HANDLER_DBUG_ENTER("");
int error = 0;
if (tokudb_debug & TOKUDB_DEBUG_UPSERT) {
......@@ -287,7 +287,7 @@ check_error:
}
return_error:
TOKUDB_DBUG_RETURN(error);
TOKUDB_HANDLER_DBUG_RETURN(error);
}
// Return true if an expression is a simple int expression or a simple function of +- int expression.
......@@ -856,7 +856,7 @@ int ha_tokudb::send_update_message(List<Item> &update_fields, List<Item> &update
// An upsert consists of a row and a list of update expressions (update_fields[i] = update_values[i]).
// The function returns 0 if the upsert is handled in the storage engine. Otherwise, an error code is returned.
int ha_tokudb::upsert(THD *thd, List<Item> &update_fields, List<Item> &update_values) {
TOKUDB_DBUG_ENTER("ha_tokudb::upsert");
TOKUDB_HANDLER_DBUG_ENTER("");
int error = 0;
......@@ -890,7 +890,7 @@ check_error:
}
return_error:
TOKUDB_DBUG_RETURN(error);
TOKUDB_HANDLER_DBUG_RETURN(error);
}
// Check if an upsert can be handled by this storage engine. Return trus if it can.
......
......@@ -241,8 +241,7 @@ extern ulong tokudb_debug;
#define TOKUDB_DEBUG_ANALYZE (1<<15)
#define TOKUDB_TRACE(f, ...) \
fprintf(stderr, "%d:%s:%d:" f, my_tid(), __FILE__, __LINE__, ##__VA_ARGS__);
fprintf(stderr, "%u %s:%u " f "\n", my_tid(), __FILE__, __LINE__, ##__VA_ARGS__);
static inline unsigned int my_tid() {
return (unsigned int)toku_os_gettid();
......@@ -251,17 +250,33 @@ static inline unsigned int my_tid() {
#define TOKUDB_DBUG_ENTER(f, ...) \
{ \
if (tokudb_debug & TOKUDB_DEBUG_ENTER) { \
TOKUDB_TRACE(f "\n", ##__VA_ARGS__); \
TOKUDB_TRACE("%s " f, __FUNCTION__, ##__VA_ARGS__); \
} \
} \
DBUG_ENTER(__FUNCTION__);
#define TOKUDB_DBUG_RETURN(r) \
{ \
int rr = (r); \
if ((tokudb_debug & TOKUDB_DEBUG_RETURN) || (rr != 0 && (tokudb_debug & TOKUDB_DEBUG_ERROR))) { \
TOKUDB_TRACE("%s:return %d\n", __FUNCTION__, rr); \
TOKUDB_TRACE("%s return %d", __FUNCTION__, rr); \
} \
DBUG_RETURN(rr); \
}
#define TOKUDB_HANDLER_DBUG_ENTER(f, ...) \
{ \
if (tokudb_debug & TOKUDB_DEBUG_ENTER) { \
fprintf(stderr, "%u %p %s:%u ha_tokudb::%s " f "\n", my_tid(), this, __FILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__); \
} \
} \
DBUG_ENTER(__FUNCTION__);
#define TOKUDB_HANDLER_DBUG_RETURN(r) \
{ \
int rr = (r); \
if ((tokudb_debug & TOKUDB_DEBUG_RETURN) || (rr != 0 && (tokudb_debug & TOKUDB_DEBUG_ERROR))) { \
fprintf(stderr, "%u %p %s:%u ha_tokudb::%s return %d" "\n", my_tid(), this, __FILE__, __LINE__, __FUNCTION__, rr); \
} \
DBUG_RETURN(rr); \
}
......@@ -353,14 +368,14 @@ static inline int txn_begin(DB_ENV *env, DB_TXN *parent, DB_TXN **txn, uint32_t
this_txn->set_client_id(this_txn, thd_get_thread_id(thd));
}
if ((tokudb_debug & TOKUDB_DEBUG_TXN)) {
TOKUDB_TRACE("begin txn %p %p %u r=%d\n", parent, *txn, flags, r);
TOKUDB_TRACE("begin txn %p %p %u r=%d", parent, *txn, flags, r);
}
return r;
}
static inline void commit_txn(DB_TXN* txn, uint32_t flags) {
if (tokudb_debug & TOKUDB_DEBUG_TXN)
TOKUDB_TRACE("commit txn %p\n", txn);
TOKUDB_TRACE("commit txn %p", txn);
int r = txn->commit(txn, flags);
if (r != 0) {
sql_print_error("tried committing transaction %p and got error code %d", txn, r);
......@@ -370,7 +385,7 @@ static inline void commit_txn(DB_TXN* txn, uint32_t flags) {
static inline void abort_txn(DB_TXN* txn) {
if (tokudb_debug & TOKUDB_DEBUG_TXN)
TOKUDB_TRACE("abort txn %p\n", txn);
TOKUDB_TRACE("abort txn %p", txn);
int r = txn->abort(txn);
if (r != 0) {
sql_print_error("tried aborting transaction %p and got error code %d", txn, r);
......
This diff is collapsed.
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