diff options
author | Mikael Ronstrom <mikael@mysql.com> | 2009-02-17 13:24:09 +0100 |
---|---|---|
committer | Mikael Ronstrom <mikael@mysql.com> | 2009-02-17 13:24:09 +0100 |
commit | 6db314c628b103b7c4d7fc0ba4c21eda6e6a349e (patch) | |
tree | 8414a0bf16f74515368a6a4ebc7ea528e8f982a2 /storage/innobase/row | |
parent | 805e8ffb9ec3ae7b9353d65f33e4eb20284876ae (diff) | |
parent | 6bd93f670271eaf2bd79bd7fa538e9baaa7dcb0f (diff) | |
download | mariadb-git-6db314c628b103b7c4d7fc0ba4c21eda6e6a349e.tar.gz |
Merged Performance Version 0.2.1 with latest 5.1 tree (last push 11 feb 14.01.13 2009)
Diffstat (limited to 'storage/innobase/row')
-rw-r--r-- | storage/innobase/row/row0mysql.c | 50 | ||||
-rw-r--r-- | storage/innobase/row/row0sel.c | 74 |
2 files changed, 45 insertions, 79 deletions
diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c index d5ef12d0af2..088d944cb91 100644 --- a/storage/innobase/row/row0mysql.c +++ b/storage/innobase/row/row0mysql.c @@ -342,7 +342,7 @@ row_mysql_store_col_in_innobase_format( /* In some cases we strip trailing spaces from UTF-8 and other multibyte charsets, from FIXED-length CHAR columns, to save space. UTF-8 would otherwise normally use 3 * the string length - bytes to store a latin1 string! */ + bytes to store an ASCII string! */ /* We assume that this CHAR field is encoded in a variable-length character set where spaces have @@ -620,6 +620,7 @@ row_create_prebuilt( prebuilt->ins_node = NULL; prebuilt->ins_upd_rec_buff = NULL; + prebuilt->default_rec = NULL; prebuilt->upd_node = NULL; prebuilt->ins_graph = NULL; @@ -661,7 +662,14 @@ row_create_prebuilt( prebuilt->old_vers_heap = NULL; - prebuilt->last_value = 0; + prebuilt->autoinc_error = 0; + prebuilt->autoinc_offset = 0; + + /* Default to 1, we will set the actual value later in + ha_innobase::get_auto_increment(). */ + prebuilt->autoinc_increment = 1; + + prebuilt->autoinc_last_value = 0; return(prebuilt); } @@ -1478,12 +1486,13 @@ row_unlock_for_mysql( ut_ad(prebuilt && trx); ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); - if (!(srv_locks_unsafe_for_binlog - || trx->isolation_level == TRX_ISO_READ_COMMITTED)) { + if (UNIV_UNLIKELY + (!srv_locks_unsafe_for_binlog + && trx->isolation_level != TRX_ISO_READ_COMMITTED)) { fprintf(stderr, "InnoDB: Error: calling row_unlock_for_mysql though\n" - "InnoDB: srv_locks_unsafe_for_binlog is FALSE and\n" + "InnoDB: innodb_locks_unsafe_for_binlog is FALSE and\n" "InnoDB: this session is not using" " READ COMMITTED isolation level.\n"); @@ -1963,6 +1972,7 @@ row_create_index_for_mysql( ulint err; ulint i, j; ulint len; + char* table_name; #ifdef UNIV_SYNC_DEBUG ut_ad(rw_lock_own(&dict_operation_lock, RW_LOCK_EX)); @@ -1972,6 +1982,11 @@ row_create_index_for_mysql( trx->op_info = "creating index"; + /* Copy the table name because we may want to drop the + table later, after the index object is freed (inside + que_run_threads()) and thus index->table_name is not available. */ + table_name = mem_strdup(index->table_name); + trx_start_if_not_started(trx); /* Check that the same column does not appear twice in the index. @@ -2044,13 +2059,15 @@ error_handling: trx_general_rollback_for_mysql(trx, FALSE, NULL); - row_drop_table_for_mysql(index->table_name, trx, FALSE); + row_drop_table_for_mysql(table_name, trx, FALSE); trx->error_state = DB_SUCCESS; } trx->op_info = ""; + mem_free(table_name); + return((int) err); } @@ -2443,8 +2460,8 @@ row_discard_tablespace_for_mysql( new_id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID); - /* Remove any locks there are on the table or its records */ - lock_reset_all_on_table(table); + /* Remove all locks except the table-level S and X locks. */ + lock_remove_all_on_table(table, FALSE); info = pars_info_create(); @@ -2779,9 +2796,8 @@ row_truncate_table_for_mysql( goto funct_exit; } - /* Remove any locks there are on the table or its records */ - - lock_reset_all_on_table(table); + /* Remove all locks except the table-level S and X locks. */ + lock_remove_all_on_table(table, FALSE); trx->table_id = table->id; @@ -2896,7 +2912,7 @@ next_rec: /* MySQL calls ha_innobase::reset_auto_increment() which does the same thing. */ dict_table_autoinc_lock(table); - dict_table_autoinc_initialize(table, 0); + dict_table_autoinc_initialize(table, 1); dict_table_autoinc_unlock(table); dict_update_statistics(table); @@ -3131,9 +3147,8 @@ check_next_foreign: goto funct_exit; } - /* Remove any locks there are on the table or its records */ - - lock_reset_all_on_table(table); + /* Remove all locks there are on the table or its records */ + lock_remove_all_on_table(table, TRUE); trx->dict_operation = TRUE; trx->table_id = table->id; @@ -3429,8 +3444,6 @@ loop: err = row_drop_table_for_mysql(table_name, trx, TRUE); - mem_free(table_name); - if (err != DB_SUCCESS) { fputs("InnoDB: DROP DATABASE ", stderr); ut_print_name(stderr, trx, TRUE, name); @@ -3438,8 +3451,11 @@ loop: (ulint) err); ut_print_name(stderr, trx, TRUE, table_name); putc('\n', stderr); + mem_free(table_name); break; } + + mem_free(table_name); } if (err == DB_SUCCESS) { diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c index 05721014078..8c3b00a7841 100644 --- a/storage/innobase/row/row0sel.c +++ b/storage/innobase/row/row0sel.c @@ -32,6 +32,7 @@ Created 12/19/1997 Heikki Tuuri #include "row0mysql.h" #include "read0read.h" #include "buf0lru.h" +#include "ha_prototypes.h" /* Maximum number of rows to prefetch; MySQL interface has another parameter */ #define SEL_MAX_N_PREFETCH 16 @@ -2596,6 +2597,7 @@ row_sel_store_mysql_rec( ulint i; ut_ad(prebuilt->mysql_template); + ut_ad(prebuilt->default_rec); ut_ad(rec_offs_validate(rec, NULL, offsets)); if (UNIV_LIKELY_NULL(prebuilt->blob_heap)) { @@ -2682,58 +2684,14 @@ row_sel_store_mysql_rec( &= ~(byte) templ->mysql_null_bit_mask; } } else { - /* MySQL seems to assume the field for an SQL NULL - value is set to zero or space. Not taking this into - account caused seg faults with NULL BLOB fields, and - bug number 154 in the MySQL bug database: GROUP BY - and DISTINCT could treat NULL values inequal. */ - int pad_char; + /* MySQL assumes that the field for an SQL + NULL value is set to the default value. */ mysql_rec[templ->mysql_null_byte_offset] |= (byte) templ->mysql_null_bit_mask; - switch (templ->type) { - case DATA_VARCHAR: - case DATA_BINARY: - case DATA_VARMYSQL: - if (templ->mysql_type - == DATA_MYSQL_TRUE_VARCHAR) { - /* This is a >= 5.0.3 type - true VARCHAR. Zero the field. */ - pad_char = 0x00; - break; - } - /* Fall through */ - case DATA_CHAR: - case DATA_FIXBINARY: - case DATA_MYSQL: - /* MySQL pads all string types (except - BLOB, TEXT and true VARCHAR) with space. */ - if (UNIV_UNLIKELY(templ->mbminlen == 2)) { - /* Treat UCS2 as a special case. */ - data = mysql_rec - + templ->mysql_col_offset; - len = templ->mysql_col_len; - /* There are two UCS2 bytes per char, - so the length has to be even. */ - ut_a(!(len & 1)); - /* Pad with 0x0020. */ - while (len) { - *data++ = 0x00; - *data++ = 0x20; - len -= 2; - } - continue; - } - pad_char = 0x20; - break; - default: - pad_char = 0x00; - break; - } - - ut_ad(!pad_char || templ->mbminlen == 1); - memset(mysql_rec + templ->mysql_col_offset, - pad_char, templ->mysql_col_len); + memcpy(mysql_rec + templ->mysql_col_offset, + prebuilt->default_rec + templ->mysql_col_offset, + templ->mysql_col_len); } } @@ -3577,20 +3535,12 @@ shortcut_fails_too_big_rec: if (trx->isolation_level <= TRX_ISO_READ_COMMITTED && prebuilt->select_lock_type != LOCK_NONE - && trx->mysql_query_str != NULL - && *trx->mysql_query_str != NULL - && trx->mysql_thd != NULL) { - - /* Scan the MySQL query string; check if SELECT is the first - word there */ + && trx->mysql_thd != NULL + && thd_is_select(trx->mysql_thd)) { + /* It is a plain locking SELECT and the isolation + level is low: do not lock gaps */ - if (dict_str_starts_with_keyword( - trx->mysql_thd, *trx->mysql_query_str, "SELECT")) { - /* It is a plain locking SELECT and the isolation - level is low: do not lock gaps */ - - set_also_gap_locks = FALSE; - } + set_also_gap_locks = FALSE; } /* Note that if the search mode was GE or G, then the cursor |