diff options
author | unknown <pappa@c-8b0ae253.1238-1-64736c10.cust.bredbandsbolaget.se> | 2005-08-05 18:01:34 -0400 |
---|---|---|
committer | unknown <pappa@c-8b0ae253.1238-1-64736c10.cust.bredbandsbolaget.se> | 2005-08-05 18:01:34 -0400 |
commit | aca6f88ebb4fb6118b8f12a696111fce167762d3 (patch) | |
tree | f2bca76ddf241e417c5d8e8f0ab325105e97cbae /storage/innobase | |
parent | 9216f5f25926197a4b40ac4fd4aeb9ad48a2a247 (diff) | |
parent | e13fa8ebbb095970b9a5a206001eeb06273567de (diff) | |
download | mariadb-git-aca6f88ebb4fb6118b8f12a696111fce167762d3.tar.gz |
Merge mronstrom@bk-internal.mysql.com:/home/bk/mysql-5.0
into c-8b0ae253.1238-1-64736c10.cust.bredbandsbolaget.se:/home/pappa/mysql-5.1
BitKeeper/etc/config:
Auto merged
mysql-test/mysql-test-run.pl:
Auto merged
mysql-test/r/information_schema_db.result:
Auto merged
mysql-test/t/disabled.def:
Auto merged
mysys/default.c:
Auto merged
scripts/Makefile.am:
Auto merged
scripts/mysql_create_system_tables.sh:
Auto merged
scripts/mysql_fix_privilege_tables.sql:
Auto merged
sql/field.cc:
Auto merged
sql/field.h:
Auto merged
sql/ha_federated.cc:
Auto merged
sql/ha_innodb.cc:
Auto merged
sql/ha_innodb.h:
Auto merged
sql/ha_ndbcluster.cc:
Auto merged
sql/ha_ndbcluster.h:
Auto merged
sql/handler.cc:
Auto merged
sql/item.cc:
Auto merged
sql/lock.cc:
Auto merged
sql/log.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/set_var.h:
Auto merged
sql/slave.cc:
Auto merged
sql/slave.h:
Auto merged
sql/sp.cc:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_cache.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_lex.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_prepare.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_show.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/table.cc:
Auto merged
sql/table.h:
Auto merged
sql/tztime.cc:
Auto merged
sql/unireg.cc:
Auto merged
storage/innobase/buf/buf0buf.c:
Auto merged
storage/innobase/include/os0file.h:
Auto merged
storage/innobase/include/read0read.h:
Auto merged
storage/innobase/include/read0types.h:
Auto merged
storage/innobase/include/trx0trx.h:
Auto merged
storage/innobase/os/os0file.c:
Auto merged
storage/innobase/read/read0read.c:
Auto merged
storage/innobase/row/row0sel.c:
Auto merged
storage/innobase/srv/srv0srv.c:
Auto merged
storage/innobase/srv/srv0start.c:
Auto merged
storage/innobase/trx/trx0sys.c:
Auto merged
storage/innobase/trx/trx0trx.c:
Auto merged
storage/myisam/mi_create.c:
Auto merged
storage/myisam/sort.c:
Auto merged
storage/ndb/include/mgmapi/mgmapi.h:
Auto merged
storage/ndb/include/mgmapi/mgmapi_config_parameters.h:
Auto merged
storage/ndb/src/common/portlib/NdbMutex.c:
Auto merged
storage/ndb/src/common/portlib/NdbThread.c:
Auto merged
storage/ndb/src/kernel/blocks/dbacc/DbaccMain.cpp:
Auto merged
storage/ndb/src/kernel/blocks/dbtup/DbtupGen.cpp:
Auto merged
storage/ndb/src/mgmapi/mgmapi.cpp:
Auto merged
storage/ndb/src/mgmsrv/ConfigInfo.cpp:
Auto merged
storage/ndb/src/mgmsrv/ConfigInfo.hpp:
Auto merged
strings/ctype-big5.c:
Auto merged
strings/ctype-ucs2.c:
Auto merged
support-files/mysql.spec.sh:
Auto merged
configure.in:
Manual merge 5.0 -> 5.1
mysql-test/t/alter_table.test:
Manual merge 5.0 -> 5.1
sql/share/errmsg.txt:
Manual merge 5.0 -> 5.1
storage/ndb/tools/Makefile.am:
Manual merge 5.0 -> 5.1
Diffstat (limited to 'storage/innobase')
-rw-r--r-- | storage/innobase/buf/buf0buf.c | 9 | ||||
-rw-r--r-- | storage/innobase/include/os0file.h | 2 | ||||
-rw-r--r-- | storage/innobase/include/read0read.h | 38 | ||||
-rw-r--r-- | storage/innobase/include/read0types.h | 1 | ||||
-rw-r--r-- | storage/innobase/include/trx0trx.h | 14 | ||||
-rw-r--r-- | storage/innobase/os/os0file.c | 14 | ||||
-rw-r--r-- | storage/innobase/read/read0read.c | 141 | ||||
-rw-r--r-- | storage/innobase/row/row0sel.c | 32 | ||||
-rw-r--r-- | storage/innobase/srv/srv0srv.c | 4 | ||||
-rw-r--r-- | storage/innobase/srv/srv0start.c | 10 | ||||
-rw-r--r-- | storage/innobase/trx/trx0sys.c | 3 | ||||
-rw-r--r-- | storage/innobase/trx/trx0trx.c | 24 |
12 files changed, 272 insertions, 20 deletions
diff --git a/storage/innobase/buf/buf0buf.c b/storage/innobase/buf/buf0buf.c index fe4498e6f10..aa3aef7f97c 100644 --- a/storage/innobase/buf/buf0buf.c +++ b/storage/innobase/buf/buf0buf.c @@ -1776,6 +1776,15 @@ buf_page_create( buf_flush_free_margin(); frame = block->frame; + + /* Reset to zero the file flush lsn field in the page; if the first + page of an ibdata file is 'created' in this function into the buffer + pool then we lose the original contents of the file flush lsn stamp. + Then InnoDB could in a crash recovery print a big, false, corruption + warning if the stamp contains an lsn bigger than the ib_logfile lsn. */ + + memset(frame + FIL_PAGE_FILE_FLUSH_LSN, 0, 8); + #ifdef UNIV_DEBUG buf_dbg_counter++; diff --git a/storage/innobase/include/os0file.h b/storage/innobase/include/os0file.h index 362e3552411..adbc4afafd2 100644 --- a/storage/innobase/include/os0file.h +++ b/storage/innobase/include/os0file.h @@ -19,7 +19,9 @@ Created 10/21/1995 Heikki Tuuri typedef struct fil_node_struct fil_node_t; +#ifdef UNIV_DO_FLUSH extern ibool os_do_not_call_flush_at_each_write; +#endif /* UNIV_DO_FLUSH */ extern ibool os_has_said_disk_full; extern ibool os_aio_print_debug; diff --git a/storage/innobase/include/read0read.h b/storage/innobase/include/read0read.h index db6bf888095..b5edcefb544 100644 --- a/storage/innobase/include/read0read.h +++ b/storage/innobase/include/read0read.h @@ -68,7 +68,34 @@ void read_view_print( /*============*/ read_view_t* view); /* in: read view */ +/************************************************************************* +Create a consistent cursor view for mysql to be used in cursors. In this +consistent read view modifications done by the creating transaction or future +transactions are not visible. */ + +cursor_view_t* +read_cursor_view_create_for_mysql( +/*==============================*/ + trx_t* cr_trx);/* in: trx where cursor view is created */ +/************************************************************************* +Close a given consistent cursor view for mysql and restore global read view +back to a transaction read view. */ +void +read_cursor_view_close_for_mysql( +/*=============================*/ + trx_t* trx, /* in: trx */ + cursor_view_t* curview); /* in: cursor view to be closed */ +/************************************************************************* +This function sets a given consistent cursor view to a transaction +read view if given consistent cursor view is not NULL. Otherwise, function +restores a global read view to a transaction read view. */ + +void +read_cursor_set_for_mysql( +/*======================*/ + trx_t* trx, /* in: transaction where cursor is set */ + cursor_view_t* curview);/* in: consistent cursor view to be set */ /* Read view lists the trx ids of those transactions for which a consistent read should not see the modifications to the database. */ @@ -100,6 +127,17 @@ struct read_view_struct{ /* List of read views in trx_sys */ }; +/* Implement InnoDB framework to support consistent read views in +cursors. This struct holds both heap where consistent read view +is allocated and pointer to a read view. */ + +struct cursor_view_struct{ + mem_heap_t* heap; + /* Memory heap for the cursor view */ + read_view_t* read_view; + /* Consistent read view of the cursor*/ +}; + #ifndef UNIV_NONINL #include "read0read.ic" #endif diff --git a/storage/innobase/include/read0types.h b/storage/innobase/include/read0types.h index 5eb3e533f89..7d42728523e 100644 --- a/storage/innobase/include/read0types.h +++ b/storage/innobase/include/read0types.h @@ -10,5 +10,6 @@ Created 2/16/1997 Heikki Tuuri #define read0types_h typedef struct read_view_struct read_view_t; +typedef struct cursor_view_struct cursor_view_t; #endif diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 146730d46f8..a3ef755348c 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -602,8 +602,18 @@ struct trx_struct{ UT_LIST_BASE_NODE_T(lock_t) trx_locks; /* locks reserved by the transaction */ /*------------------------------*/ - mem_heap_t* read_view_heap; /* memory heap for the read view */ - read_view_t* read_view; /* consistent read view or NULL */ + mem_heap_t* global_read_view_heap; + /* memory heap for the global read + view */ + read_view_t* global_read_view; + /* consistent read view associated + to a transaction or NULL */ + read_view_t* read_view; /* consistent read view used in the + transaction or NULL, this read view + if defined can be normal read view + associated to a transaction (i.e. + same as global_read_view) or read view + associated to a cursor */ /*------------------------------*/ UT_LIST_BASE_NODE_T(trx_named_savept_t) trx_savepoints; /* savepoints set with SAVEPOINT ..., diff --git a/storage/innobase/os/os0file.c b/storage/innobase/os/os0file.c index 48dc808e36c..9c87b59f018 100644 --- a/storage/innobase/os/os0file.c +++ b/storage/innobase/os/os0file.c @@ -40,9 +40,13 @@ ulint os_innodb_umask = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP; ulint os_innodb_umask = 0; #endif +#ifdef UNIV_DO_FLUSH /* If the following is set to TRUE, we do not call os_file_flush in every os_file_write. We can set this TRUE when the doublewrite buffer is used. */ ibool os_do_not_call_flush_at_each_write = FALSE; +#else +/* We do not call os_file_flush in every os_file_write. */ +#endif /* UNIV_DO_FLUSH */ /* We use these mutexes to protect lseek + file i/o operation, if the OS does not provide an atomic pread or pwrite, or similar */ @@ -1985,6 +1989,7 @@ os_file_pwrite( os_file_n_pending_pwrites--; os_mutex_exit(os_file_count_mutex); +# ifdef UNIV_DO_FLUSH if (srv_unix_file_flush_method != SRV_UNIX_LITTLESYNC && srv_unix_file_flush_method != SRV_UNIX_NOSYNC && !os_do_not_call_flush_at_each_write) { @@ -1995,6 +2000,7 @@ os_file_pwrite( ut_a(TRUE == os_file_flush(file)); } +# endif /* UNIV_DO_FLUSH */ return(ret); #else @@ -2017,6 +2023,7 @@ os_file_pwrite( ret = write(file, buf, (ssize_t)n); +# ifdef UNIV_DO_FLUSH if (srv_unix_file_flush_method != SRV_UNIX_LITTLESYNC && srv_unix_file_flush_method != SRV_UNIX_NOSYNC && !os_do_not_call_flush_at_each_write) { @@ -2027,6 +2034,7 @@ os_file_pwrite( ut_a(TRUE == os_file_flush(file)); } +# endif /* UNIV_DO_FLUSH */ os_mutex_exit(os_file_seek_mutexes[i]); @@ -2313,9 +2321,11 @@ retry: /* Always do fsync to reduce the probability that when the OS crashes, a database page is only partially physically written to disk. */ +# ifdef UNIV_DO_FLUSH if (!os_do_not_call_flush_at_each_write) { ut_a(TRUE == os_file_flush(file)); } +# endif /* UNIV_DO_FLUSH */ os_mutex_exit(os_file_seek_mutexes[i]); @@ -3533,10 +3543,12 @@ os_aio_windows_handle( if (ret && len == slot->len) { ret_val = TRUE; +# ifdef UNIV_DO_FLUSH if (slot->type == OS_FILE_WRITE && !os_do_not_call_flush_at_each_write) { ut_a(TRUE == os_file_flush(slot->file)); } +# endif /* UNIV_DO_FLUSH */ } else { os_file_handle_error(slot->name, "Windows aio"); @@ -3617,10 +3629,12 @@ os_aio_posix_handle( *message1 = slot->message1; *message2 = slot->message2; +# ifdef UNIV_DO_FLUSH if (slot->type == OS_FILE_WRITE && !os_do_not_call_flush_at_each_write) { ut_a(TRUE == os_file_flush(slot->file)); } +# endif /* UNIV_DO_FLUSH */ os_mutex_exit(array->mutex); diff --git a/storage/innobase/read/read0read.c b/storage/innobase/read/read0read.c index 0c4a037508e..334f9a8a85a 100644 --- a/storage/innobase/read/read0read.c +++ b/storage/innobase/read/read0read.c @@ -212,15 +212,16 @@ read_view_close_for_mysql( /*======================*/ trx_t* trx) /* in: trx which has a read view */ { - ut_a(trx->read_view); + ut_a(trx->global_read_view); mutex_enter(&kernel_mutex); - read_view_close(trx->read_view); + read_view_close(trx->global_read_view); - mem_heap_empty(trx->read_view_heap); + mem_heap_empty(trx->global_read_view_heap); trx->read_view = NULL; + trx->global_read_view = NULL; mutex_exit(&kernel_mutex); } @@ -258,3 +259,137 @@ read_view_print( (ulong) ut_dulint_get_low(read_view_get_nth_trx_id(view, i))); } } + +/************************************************************************* +Create a consistent cursor view for mysql to be used in cursors. In this +consistent read view modifications done by the creating transaction or future +transactions are not visible. */ + +cursor_view_t* +read_cursor_view_create_for_mysql( +/*==============================*/ + trx_t* cr_trx) /* in: trx where cursor view is created */ +{ + cursor_view_t* curview; + read_view_t* view; + mem_heap_t* heap; + trx_t* trx; + ulint n; + + ut_a(cr_trx); + + /* Use larger heap than in trx_create when creating a read_view + because cursors are quite long. */ + + heap = mem_heap_create(512); + + curview = (cursor_view_t*) mem_heap_alloc(heap, sizeof(cursor_view_t)); + curview->heap = heap; + + mutex_enter(&kernel_mutex); + + curview->read_view = read_view_create_low( + UT_LIST_GET_LEN(trx_sys->trx_list), + curview->heap); + + view = curview->read_view; + view->creator = cr_trx; + + /* No future transactions should be visible in the view */ + + view->low_limit_no = trx_sys->max_trx_id; + view->low_limit_id = view->low_limit_no; + + view->can_be_too_old = FALSE; + + n = 0; + trx = UT_LIST_GET_FIRST(trx_sys->trx_list); + + /* No active transaction should be visible, not even cr_trx !*/ + + while (trx) { + if (trx->conc_state == TRX_ACTIVE || + trx->conc_state == TRX_PREPARED) { + + read_view_set_nth_trx_id(view, n, trx->id); + + n++; + + /* NOTE that a transaction whose trx number is < + trx_sys->max_trx_id can still be active, if it is + in the middle of its commit! Note that when a + transaction starts, we initialize trx->no to + ut_dulint_max. */ + + if (ut_dulint_cmp(view->low_limit_no, trx->no) > 0) { + + view->low_limit_no = trx->no; + } + } + + trx = UT_LIST_GET_NEXT(trx_list, trx); + } + + view->n_trx_ids = n; + + if (n > 0) { + /* The last active transaction has the smallest id: */ + view->up_limit_id = read_view_get_nth_trx_id(view, n - 1); + } else { + view->up_limit_id = view->low_limit_id; + } + + UT_LIST_ADD_FIRST(view_list, trx_sys->view_list, view); + + mutex_exit(&kernel_mutex); + + return(curview); +} + +/************************************************************************* +Close a given consistent cursor view for mysql and restore global read view +back to a transaction read view. */ + +void +read_cursor_view_close_for_mysql( +/*=============================*/ + trx_t* trx, /* in: trx */ + cursor_view_t* curview)/* in: cursor view to be closed */ +{ + ut_a(curview); + ut_a(curview->read_view); + ut_a(curview->heap); + + mutex_enter(&kernel_mutex); + + read_view_close(curview->read_view); + trx->read_view = trx->global_read_view; + + mutex_exit(&kernel_mutex); + + mem_heap_free(curview->heap); +} + +/************************************************************************* +This function sets a given consistent cursor view to a transaction +read view if given consistent cursor view is not NULL. Otherwise, function +restores a global read view to a transaction read view. */ + +void +read_cursor_set_for_mysql( +/*======================*/ + trx_t* trx, /* in: transaction where cursor is set */ + cursor_view_t* curview)/* in: consistent cursor view to be set */ +{ + ut_a(trx); + + mutex_enter(&kernel_mutex); + + if (UNIV_LIKELY(curview != NULL)) { + trx->read_view = curview->read_view; + } else { + trx->read_view = trx->global_read_view; + } + + mutex_exit(&kernel_mutex); +} diff --git a/storage/innobase/row/row0sel.c b/storage/innobase/row/row0sel.c index 15439bed7e7..15881cb8c5d 100644 --- a/storage/innobase/row/row0sel.c +++ b/storage/innobase/row/row0sel.c @@ -2524,13 +2524,21 @@ row_sel_store_mysql_rec( (byte) (templ->mysql_null_bit_mask); switch (templ->type) { case DATA_VARCHAR: - case DATA_CHAR: 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: - case DATA_VARMYSQL: - /* MySQL pads all non-BLOB and non-TEXT - string types with space ' ' */ + /* 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 @@ -3092,6 +3100,13 @@ row_search_for_mysql( "http://dev.mysql.com/doc/mysql/en/InnoDB_troubleshooting_datadict.html\n" "InnoDB: how you can resolve the problem.\n", prebuilt->table->name); + + /* Restore a global read view back to a transaction. This + forces MySQL always to set a cursor view before fetch from + a cursor. */ + + trx->read_view = trx->global_read_view; + return(DB_ERROR); } @@ -4083,6 +4098,12 @@ normal_return: } func_exit: + /* Restore a global read view back to a transaction. This + forces MySQL always to set a cursor view before fetch from + a cursor. */ + + trx->read_view = trx->global_read_view; + trx->op_info = ""; if (UNIV_LIKELY_NULL(heap)) { mem_heap_free(heap); @@ -4136,7 +4157,8 @@ row_search_check_if_query_cache_permitted( && !trx->read_view) { trx->read_view = read_view_open_now(trx, - trx->read_view_heap); + trx->global_read_view_heap); + trx->global_read_view = trx->read_view; } } diff --git a/storage/innobase/srv/srv0srv.c b/storage/innobase/srv/srv0srv.c index 837c5be2bb6..dc85750f0be 100644 --- a/storage/innobase/srv/srv0srv.c +++ b/storage/innobase/srv/srv0srv.c @@ -1711,6 +1711,10 @@ srv_printf_innodb_monitor( fprintf(file, "%ld queries inside InnoDB, %lu queries in queue\n", (long) srv_conc_n_threads, (ulong) srv_conc_n_waiting_threads); + + fprintf(file, "%lu read views open inside InnoDB\n", + UT_LIST_GET_LEN(trx_sys->view_list)); + n_reserved = fil_space_get_n_reserved_extents(0); if (n_reserved > 0) { fprintf(file, diff --git a/storage/innobase/srv/srv0start.c b/storage/innobase/srv/srv0start.c index 7798e0c8e32..ffe4ba08ee9 100644 --- a/storage/innobase/srv/srv0start.c +++ b/storage/innobase/srv/srv0start.c @@ -1833,6 +1833,16 @@ innobase_shutdown_for_mysql(void) srv_free(); os_sync_free(); + /* Check that all read views are closed except read view owned + by a purge. */ + + if (UT_LIST_GET_LEN(trx_sys->view_list) > 1) { + fprintf(stderr, +"InnoDB: Error: all read views were not closed before shutdown:\n" +"InnoDB: %lu read views open \n", + UT_LIST_GET_LEN(trx_sys->view_list) - 1); + } + /* 5. Free all allocated memory and the os_fast_mutex created in ut0mem.c */ diff --git a/storage/innobase/trx/trx0sys.c b/storage/innobase/trx/trx0sys.c index 68fe6d5079a..bf48c30e942 100644 --- a/storage/innobase/trx/trx0sys.c +++ b/storage/innobase/trx/trx0sys.c @@ -97,8 +97,9 @@ trx_doublewrite_init( /* Since we now start to use the doublewrite buffer, no need to call fsync() after every write to a data file */ - +#ifdef UNIV_DO_FLUSH os_do_not_call_flush_at_each_write = TRUE; +#endif /* UNIV_DO_FLUSH */ mutex_create(&(trx_doublewrite->mutex)); mutex_set_level(&(trx_doublewrite->mutex), SYNC_DOUBLEWRITE); diff --git a/storage/innobase/trx/trx0trx.c b/storage/innobase/trx/trx0trx.c index 10fbf3468c0..1681bed9af2 100644 --- a/storage/innobase/trx/trx0trx.c +++ b/storage/innobase/trx/trx0trx.c @@ -159,7 +159,8 @@ trx_create( trx->auto_inc_lock = NULL; - trx->read_view_heap = mem_heap_create(256); + trx->global_read_view_heap = mem_heap_create(256); + trx->global_read_view = NULL; trx->read_view = NULL; /* Set X/Open XA transaction identification to NULL */ @@ -318,10 +319,12 @@ trx_free( ut_a(UT_LIST_GET_LEN(trx->trx_locks) == 0); - if (trx->read_view_heap) { - mem_heap_free(trx->read_view_heap); + if (trx->global_read_view_heap) { + mem_heap_free(trx->global_read_view_heap); } + trx->global_read_view = NULL; + ut_a(trx->read_view == NULL); mem_free(trx); @@ -830,13 +833,14 @@ trx_commit_off_kernel( lock_release_off_kernel(trx); - if (trx->read_view) { - read_view_close(trx->read_view); - - mem_heap_empty(trx->read_view_heap); - trx->read_view = NULL; + if (trx->global_read_view) { + read_view_close(trx->global_read_view); + mem_heap_empty(trx->global_read_view_heap); + trx->global_read_view = NULL; } + trx->read_view = NULL; + if (must_flush_log) { mutex_exit(&kernel_mutex); @@ -964,7 +968,9 @@ trx_assign_read_view( mutex_enter(&kernel_mutex); if (!trx->read_view) { - trx->read_view = read_view_open_now(trx, trx->read_view_heap); + trx->read_view = read_view_open_now(trx, + trx->global_read_view_heap); + trx->global_read_view = trx->read_view; } mutex_exit(&kernel_mutex); |