diff options
author | monty@hundin.mysql.fi <> | 2001-09-02 19:58:08 +0300 |
---|---|---|
committer | monty@hundin.mysql.fi <> | 2001-09-02 19:58:08 +0300 |
commit | 381093b3228524f151c8e5e61120e827c0441aea (patch) | |
tree | c1066773b871f44ebb365c32dab0432f7da6da94 /sql/ha_innobase.cc | |
parent | 35118a00c1f52495b17783f546425084c28b0235 (diff) | |
parent | 447c18954e904e5770d64ae3b0817a16b9060b74 (diff) | |
download | mariadb-git-381093b3228524f151c8e5e61120e827c0441aea.tar.gz |
merge
Diffstat (limited to 'sql/ha_innobase.cc')
-rw-r--r-- | sql/ha_innobase.cc | 126 |
1 files changed, 109 insertions, 17 deletions
diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 254fa6970a7..5920ce86116 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -185,6 +185,47 @@ convert_error_code_to_mysql( } } +extern "C" { +/***************************************************************** +Prints info of a THD object (== user session thread) to the +standatd output. NOTE that mysql/innobase/trx/trx0trx.c must contain +the prototype for this function! */ + +void +innobase_mysql_print_thd( +/*=====================*/ + void* input_thd)/* in: pointer to a MySQL THD object */ +{ + THD* thd; + + thd = (THD*) input_thd; + + printf("MySQL thread id %lu, query id %lu", + thd->thread_id, thd->query_id); + if (thd->host) { + printf(" %s", thd->host); + } + + if (thd->ip) { + printf(" %s", thd->ip); + } + + if (thd->user) { + printf(" %s", thd->user); + } + + if (thd->proc_info) { + printf(" %s", thd->proc_info); + } + + if (thd->query) { + printf(" %0.100s", thd->query); + } + + printf("\n"); +} +} + /************************************************************************* Gets the InnoDB transaction handle for a MySQL handler object, creates an InnoDB transaction struct if the corresponding MySQL thread struct still @@ -204,6 +245,8 @@ check_trx_exists( dbug_assert(thd != NULL); trx = trx_allocate_for_mysql(); + trx->mysql_thd = thd; + thd->transaction.all.innobase_tid = trx; /* The execution of a single SQL statement is denoted by @@ -504,7 +547,15 @@ innobase_init(void) if (!innobase_data_file_path) { fprintf(stderr, - "Can't initialize InnoDB as 'innodb_data_file_path' is not set\n"); + "Cannot initialize InnoDB as 'innodb_data_file_path' is not set.\n" + "If you do not want to use transactional InnoDB tables, add a line\n" + "skip-innodb\n" + "to the [mysqld] section of init parameters in your my.cnf\n" + "or my.ini. If you want to use InnoDB tables, add for example,\n" + "innodb_data_file_path = /mysql/data/ibdata1:20M\n" + "More information on setting the parameters you find in the\n" + "manual.\n"); + innodb_skip=1; DBUG_RETURN(FALSE); // Continue without innobase } @@ -638,7 +689,7 @@ innobase_commit( if (trx_handle != (void*)&innodb_dummy_stmt_trx_handle) { trx_commit_for_mysql(trx); - trx_mark_sql_stat_end(trx); + trx_mark_sql_stat_end_do_not_start_new(trx); } else { trx_mark_sql_stat_end(trx); } @@ -677,6 +728,7 @@ innobase_rollback( if (trx_handle != (void*)&innodb_dummy_stmt_trx_handle) { error = trx_rollback_for_mysql(trx); + trx_mark_sql_stat_end_do_not_start_new(trx); } else { error = trx_rollback_last_sql_stat_for_mysql(trx); trx_mark_sql_stat_end(trx); @@ -826,10 +878,6 @@ ha_innobase::open( DBUG_RETURN(1); } - /* MySQL allocates the buffer for ref */ - - ref_length = buff_len; - /* Get pointer to a table object in InnoDB dictionary cache */ if (NULL == (ib_table = dict_table_get(norm_name, NULL))) { @@ -866,10 +914,20 @@ ha_innobase::open( primary_key = 0; key_used_on_scan = 0; + + /* MySQL allocates the buffer for ref */ + + ref_length = table->key_info->key_length + + table->key_info->key_parts + 10; + + /* One byte per key field is consumed to the SQL NULL + info of the field; we add also 10 bytes of safety margin */ } else { ((row_prebuilt_t*)innobase_prebuilt) ->clust_index_was_generated = TRUE; + ref_length = DATA_ROW_ID_LEN + 10; + dbug_assert(key_used_on_scan == MAX_KEY); } @@ -1334,6 +1392,15 @@ ha_innobase::write_row( auto_inc = table->next_number_field->val_int(); + /* In replication and also otherwise the auto-inc column + can be set with SET INSERT_ID. Then we must look at + user_thd->next_insert_id. If it is nonzero and the user + has not supplied a value, we must use it. */ + + if (auto_inc == 0 && user_thd->next_insert_id != 0) { + auto_inc = user_thd->next_insert_id; + } + if (auto_inc != 0) { /* This call will calculate the max of the current value and the value supplied by the user, if @@ -2218,29 +2285,29 @@ ha_innobase::external_lock( if (trx->n_mysql_tables_in_use == 0) { trx_mark_sql_stat_end(trx); } - + thd->transaction.all.innodb_active_trans = 1; trx->n_mysql_tables_in_use++; if (prebuilt->select_lock_type != LOCK_NONE) { - trx->mysql_n_tables_locked++; + trx->mysql_n_tables_locked++; } } else { trx->n_mysql_tables_in_use--; if (trx->n_mysql_tables_in_use == 0) { - trx->mysql_n_tables_locked = 0; + trx->mysql_n_tables_locked = 0; - if (trx->has_search_latch) { + if (trx->has_search_latch) { - trx_search_latch_release_if_reserved(trx); - } + trx_search_latch_release_if_reserved(trx); + } - if (!(thd->options - & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN))) { - innobase_commit(thd, trx); - } + if (!(thd->options + & (OPTION_NOT_AUTO_COMMIT | OPTION_BEGIN))) { + innobase_commit(thd, trx); + } } } @@ -2636,6 +2703,10 @@ ha_innobase::records_in_range( DBUG_ENTER("records_in_range"); + if (prebuilt->trx) { + prebuilt->trx->op_info = "estimating range size"; + } + active_index = keynr; key = table->key_info + active_index; @@ -2668,6 +2739,10 @@ ha_innobase::records_in_range( my_free((char*) key_val_buff2, MYF(0)); + if (prebuilt->trx) { + prebuilt->trx->op_info = ""; + } + DBUG_RETURN((ha_rows) n_rows); } @@ -2687,10 +2762,15 @@ ha_innobase::estimate_number_of_rows(void) row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; dict_table_t* ib_table; + if (prebuilt->trx) { + prebuilt->trx->op_info = + "estimating upper bound of table size"; + } + DBUG_ENTER("info"); ib_table = prebuilt->table; - + dict_update_statistics(ib_table); data_file_length = ((ulonglong) @@ -2699,6 +2779,10 @@ ha_innobase::estimate_number_of_rows(void) /* The minimum clustered index record size is 20 bytes */ + if (prebuilt->trx) { + prebuilt->trx->op_info = ""; + } + return((ha_rows) (1000 + data_file_length / 20)); } @@ -2737,6 +2821,10 @@ ha_innobase::info( DBUG_ENTER("info"); + if (prebuilt->trx) { + prebuilt->trx->op_info = "calculating table stats"; + } + ib_table = prebuilt->table; if (flag & HA_STATUS_TIME) { @@ -2799,6 +2887,10 @@ ha_innobase::info( trx_get_error_info(prebuilt->trx)); } + if (prebuilt->trx) { + prebuilt->trx->op_info = ""; + } + DBUG_VOID_RETURN; } |