diff options
author | unknown <heikki@donna.mysql.fi> | 2002-02-04 23:55:41 +0200 |
---|---|---|
committer | unknown <heikki@donna.mysql.fi> | 2002-02-04 23:55:41 +0200 |
commit | 9871a6d080f507f58afa91bfd7624c27b27963cd (patch) | |
tree | 8afb00e0a5c01501d06fda6b055c26e219075b91 /sql | |
parent | 3518de828d1c7c384ea3503ae2ce1477bf4a9095 (diff) | |
download | mariadb-git-9871a6d080f507f58afa91bfd7624c27b27963cd.tar.gz |
Many files:
Small improvements
row0mysql.c:
Small improvements + fix the ALTER TABLE problem by introducing a lazy drop table it can use
ha_innobase.cc:
Some fine-tuning of optimization
sql/ha_innobase.cc:
Some fine-tuning of optimization
innobase/include/log0recv.h:
Small improvements
innobase/include/mem0mem.h:
Small improvements
innobase/include/mem0pool.h:
Small improvements
innobase/include/row0mysql.h:
Small improvements
innobase/include/srv0srv.h:
Small improvements
innobase/include/trx0trx.h:
Small improvements
innobase/buf/buf0lru.c:
Small improvements
innobase/fil/fil0fil.c:
Small improvements
innobase/log/log0recv.c:
Small improvements
innobase/mem/mem0mem.c:
Small improvements
innobase/mem/mem0pool.c:
Small improvements
innobase/row/row0mysql.c:
Small improvements + fix the ALTER TABLE problem by introducing a lazy drop table it can use
innobase/srv/srv0srv.c:
Small improvements
innobase/srv/srv0start.c:
Small improvements
innobase/trx/trx0purge.c:
Small improvements
innobase/trx/trx0trx.c:
Small improvements
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_innobase.cc | 140 |
1 files changed, 92 insertions, 48 deletions
diff --git a/sql/ha_innobase.cc b/sql/ha_innobase.cc index 88c7e10e94c..106704d5b75 100644 --- a/sql/ha_innobase.cc +++ b/sql/ha_innobase.cc @@ -16,7 +16,7 @@ /* This file defines the InnoDB handler: the interface between MySQL and InnoDB */ - + /* TODO list for the InnoDB handler: - Ask Monty if strings of different languages can exist in the same database. Answer: in near future yes, but not yet. @@ -229,7 +229,7 @@ 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 +standard output. NOTE that mysql/innobase/trx/trx0trx.c must contain the prototype for this function! */ void @@ -298,6 +298,8 @@ check_trx_exists( thd->transaction.stmt.innobase_tid = (void*)&innodb_dummy_stmt_trx_handle; + } else { + ut_a(trx->magic_n == TRX_MAGIC_N); } return(trx); @@ -835,6 +837,7 @@ innobase_close_connection( whose transaction should be rolled back */ { if (NULL != thd->transaction.all.innobase_tid) { + trx_rollback_for_mysql((trx_t*) (thd->transaction.all.innobase_tid)); trx_free_for_mysql((trx_t*) @@ -2435,44 +2438,6 @@ ha_innobase::position( ref_stored_len = len; } -/*********************************************************************** -Tells something additional to the handler about how to do things. */ - -int -ha_innobase::extra( -/*===============*/ - /* out: 0 or error number */ - enum ha_extra_function operation) - /* in: HA_EXTRA_DONT_USE_CURSOR_TO_UPDATE */ -{ - row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; - - switch (operation) { - case HA_EXTRA_RESET: - case HA_EXTRA_RESET_STATE: - prebuilt->read_just_key = 0; - break; - case HA_EXTRA_NO_KEYREAD: - prebuilt->read_just_key = 0; - break; - case HA_EXTRA_DONT_USE_CURSOR_TO_UPDATE: - prebuilt->in_update_remember_pos = FALSE; - break; - case HA_EXTRA_KEYREAD: - prebuilt->read_just_key = 1; - break; - default:/* Do nothing */ - ; - } - - return(0); -} - -int ha_innobase::reset(void) -{ - return(0); -} - /********************************************************************* Creates a table definition to an InnoDB database. */ static @@ -2952,6 +2917,10 @@ ha_innobase::records_in_range( void* heap2; DBUG_ENTER("records_in_range"); + + /* Warning: since it is not sure that MySQL calls external_lock + before calling this function, the trx field in prebuilt can be + obsolete! */ active_index = keynr; @@ -2984,6 +2953,10 @@ ha_innobase::records_in_range( dtuple_free_for_mysql(heap2); my_free((char*) key_val_buff2, MYF(0)); + + if (prebuilt->trx) { + prebuilt->trx->op_info = ""; + } DBUG_RETURN((ha_rows) n_rows); } @@ -3005,6 +2978,10 @@ ha_innobase::estimate_number_of_rows(void) ulonglong estimate; ulonglong data_file_length; + /* Warning: since it is not sure that MySQL calls external_lock + before calling this function, the trx field in prebuilt can be + obsolete! */ + DBUG_ENTER("info"); index = dict_table_get_first_index_noninline(prebuilt->table); @@ -3035,10 +3012,12 @@ ha_innobase::scan_time() { row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; - /* In the following formula we assume that scanning 10 pages - takes the same time as a disk seek: */ - - return((double) (prebuilt->table->stat_clustered_index_size / 10)); + /* Since MySQL seems to favor table scans too much over index + searches, we pretend that a sequential read takes the same time + as a random disk read, that is, we do not divide the following + by 10, which would be physically realistic. */ + + return((double) (prebuilt->table->stat_clustered_index_size)); } /************************************************************************* @@ -3058,7 +3037,11 @@ ha_innobase::info( ulong i; DBUG_ENTER("info"); - + + /* Warning: since it is not sure that MySQL calls external_lock + before calling this function, the trx field in prebuilt can be + obsolete! */ + ib_table = prebuilt->table; if (flag & HA_STATUS_TIME) { @@ -3105,6 +3088,13 @@ ha_innobase::info( index->stat_n_diff_key_vals[j + 1]); } + /* Since MySQL seems to favor table scans + too much over index searches, we pretend + index selectivity is 2 times better than + our estimate: */ + + rec_per_key = rec_per_key / 2; + if (rec_per_key == 0) { rec_per_key = 1; } @@ -3124,11 +3114,13 @@ ha_innobase::info( pointer and cause a seg fault. */ if (flag & HA_STATUS_ERRKEY) { + ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N); + errkey = (unsigned int) row_get_mysql_key_number_for_index( (dict_index_t*) trx_get_error_info(prebuilt->trx)); } - + DBUG_VOID_RETURN; } @@ -3148,7 +3140,9 @@ ha_innobase::check( { row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; ulint ret; - + + ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N); + if (prebuilt->mysql_template == NULL) { /* Build the template; we will use a dummy template in index scans done in checking */ @@ -3182,6 +3176,10 @@ ha_innobase::update_table_comment( char* str = my_malloc(length + 550, MYF(0)); char* pos; + /* Warning: since it is not sure that MySQL calls external_lock + before calling this function, the trx field in prebuilt can be + obsolete! */ + if (!str) { return((char*)comment); } @@ -3203,6 +3201,53 @@ ha_innobase::update_table_comment( return(str); } +/*********************************************************************** +Tells something additional to the handler about how to do things. */ + +int +ha_innobase::extra( +/*===============*/ + /* out: 0 or error number */ + enum ha_extra_function operation) + /* in: HA_EXTRA_DONT_USE_CURSOR_TO_UPDATE */ +{ + row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt; + + /* Warning: since it is not sure that MySQL calls external_lock + before calling this function, the trx field in prebuilt can be + obsolete! */ + + switch (operation) { + case HA_EXTRA_RESET: + case HA_EXTRA_RESET_STATE: + prebuilt->read_just_key = 0; + break; + case HA_EXTRA_NO_KEYREAD: + prebuilt->read_just_key = 0; + break; + case HA_EXTRA_DONT_USE_CURSOR_TO_UPDATE: + prebuilt->in_update_remember_pos = FALSE; + break; + case HA_EXTRA_KEYREAD: + prebuilt->read_just_key = 1; + break; + default:/* Do nothing */ + ; + } + + return(0); +} + +/********************************************************************** +????????????? */ + +int +ha_innobase::reset(void) +/*====================*/ +{ + return(0); +} + /********************************************************************** As MySQL will execute an external lock for every new table it uses when it starts to process an SQL statement, we can use this function to store the @@ -3427,5 +3472,4 @@ ha_innobase::get_auto_increment() return(nr); } - #endif /* HAVE_INNOBASE_DB */ |