From db8f4fd3d274873811109f524000fb52da45ebf9 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Wed, 11 Sep 2002 16:07:52 +0300 Subject: [PATCH 1/5] srv0srv.c, srv0srv.h: Change srv_flush_log_at_trx_commit to ulint, note that ibool is defined as ulint, so this is purely formal change os0file.c: Start using unbuffered i/o again in Windows because sequential read using normal i/o was 4 times slower in XP --- innobase/include/srv0srv.h | 2 +- innobase/os/os0file.c | 21 +++++++++++++++------ innobase/srv/srv0srv.c | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h index 1f76974b03d..f457d52dec7 100644 --- a/innobase/include/srv0srv.h +++ b/innobase/include/srv0srv.h @@ -53,7 +53,7 @@ extern ulint srv_n_log_files; extern ulint srv_log_file_size; extern ibool srv_log_archive_on; extern ulint srv_log_buffer_size; -extern ibool srv_flush_log_at_trx_commit; +extern ulint srv_flush_log_at_trx_commit; extern byte srv_latin1_ordering[256];/* The sort order table of the latin1 character set */ diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index 2a17c554dc1..b2881581fc7 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -15,8 +15,6 @@ Created 10/21/1995 Heikki Tuuri #undef HAVE_FDATASYNC -#undef UNIV_NON_BUFFERED_IO - #ifdef POSIX_ASYNC_IO /* We assume in this case that the OS has standard Posix aio (at least SunOS 2.6, HP-UX 11i and AIX 4.3 have) */ @@ -500,14 +498,25 @@ try_again: } #endif #ifdef UNIV_NON_BUFFERED_IO - attributes = attributes | FILE_FLAG_NO_BUFFERING; + if (type == OS_LOG_FILE && srv_flush_log_at_trx_commit == 2) { + /* Do not use unbuffered i/o to log files because + value 2 denotes that we do not flush the log at every + commit, but only once per second */ + } else { + attributes = attributes | FILE_FLAG_NO_BUFFERING; + } #endif } else if (purpose == OS_FILE_NORMAL) { - attributes = 0 + attributes = 0; #ifdef UNIV_NON_BUFFERED_IO - | FILE_FLAG_NO_BUFFERING + if (type == OS_LOG_FILE && srv_flush_log_at_trx_commit == 2) { + /* Do not use unbuffered i/o to log files because + value 2 denotes that we do not flush the log at every + commit, but only once per second */ + } else { + attributes = attributes | FILE_FLAG_NO_BUFFERING; + } #endif - ; } else { attributes = 0; ut_error; diff --git a/innobase/srv/srv0srv.c b/innobase/srv/srv0srv.c index 7b5aa79b3c7..84d48bebf97 100644 --- a/innobase/srv/srv0srv.c +++ b/innobase/srv/srv0srv.c @@ -96,7 +96,7 @@ ulint srv_n_log_files = ULINT_MAX; ulint srv_log_file_size = ULINT_MAX; /* size in database pages */ ibool srv_log_archive_on = TRUE; ulint srv_log_buffer_size = ULINT_MAX; /* size in database pages */ -ibool srv_flush_log_at_trx_commit = TRUE; +ulint srv_flush_log_at_trx_commit = 1; byte srv_latin1_ordering[256] /* The sort order table of the latin1 character set. The following table is From 69f571db0c4eb0c3018379f9f8faefe7beafbfb0 Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Fri, 13 Sep 2002 13:55:25 +0300 Subject: [PATCH 2/5] row0mysql.c: Allow CREATE TABLE and DROP TABLE even if innodb_force_recovery is used, the user can drop a problematic table --- innobase/row/row0mysql.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index d7b685c7f9d..d0175e8723a 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -1186,7 +1186,12 @@ row_create_table_for_mysql( ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); ut_ad(mutex_own(&(dict_sys->mutex))); - if (srv_created_new_raw || srv_force_recovery) { + /* We create table also if innodb_force_recovery is used. This + enables the user to stop a runaway rollback or a crash caused by + a temporary table #sql... He can use the trick explained in the + manual to rename the temporary table, and the drop it. */ + + if (srv_created_new_raw) { fprintf(stderr, "InnoDB: A new raw disk partition was initialized or\n" "InnoDB: innodb_force_recovery is on: we do not allow\n" @@ -1705,7 +1710,13 @@ row_drop_table_for_mysql( ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); ut_a(name != NULL); - if (srv_created_new_raw || srv_force_recovery) { + /* Note that we allow dropping of a table even if innodb_force_recovery + is used. If a rollback or purge would crash because of a corrupt + table, the user can try dropping it to avoid the crash. This is also + a nice way to stop a runaway rollback caused by a failing big + table import in a single transaction. */ + + if (srv_created_new_raw) { fprintf(stderr, "InnoDB: A new raw disk partition was initialized or\n" "InnoDB: innodb_force_recovery is on: we do not allow\n" From a7a24b8a9c2ec97ff7770acb2d66bb7f097ba8be Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Fri, 13 Sep 2002 14:23:09 +0300 Subject: [PATCH 3/5] row0mysql.c: Fix typos in previous push --- innobase/row/row0mysql.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index d0175e8723a..26878f8c97c 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -1186,10 +1186,10 @@ row_create_table_for_mysql( ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); ut_ad(mutex_own(&(dict_sys->mutex))); - /* We create table also if innodb_force_recovery is used. This + /* We allow a create table also if innodb_force_recovery is used. This enables the user to stop a runaway rollback or a crash caused by a temporary table #sql... He can use the trick explained in the - manual to rename the temporary table, and the drop it. */ + manual to rename the temporary table to rsql..., and then drop it. */ if (srv_created_new_raw) { fprintf(stderr, From 344c24d390638157354ed487d63d23b1c9656c81 Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Sun, 15 Sep 2002 01:23:01 +0300 Subject: [PATCH 4/5] Fixed core dump bug in ORDER BY ... LIMIT --- Docs/manual.texi | 2 ++ sql/filesort.cc | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index 4e0e9179bec..7e3f455e0f8 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -46929,6 +46929,8 @@ not yet 100% confident in this code. @appendixsubsec Changes in release 3.23.53 @itemize @bullet @item +Fixed unlikely core dump with @code{SELECT ... ORDER BY ... LIMIT}. +@item Changed @code{AND/OR} to report that they can return NULL. This fixes a bug in @code{GROUP BY} on @code{AND/OR} expression that return @code{NULL}. diff --git a/sql/filesort.cc b/sql/filesort.cc index 86c95395965..ee87d508dd3 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -378,13 +378,18 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, if (indexpos >= *maxbuffer || write_keys(param,sort_keys,idx,buffpek+indexpos,tempfile)) DBUG_RETURN(HA_POS_ERROR); - idx=0; indexpos++; + idx=0; if (param->ref_length == param->sort_length && my_b_tell(tempfile)/param->sort_length >= param->max_rows) { + /* + We are writing the result index file and have found all + rows that we need. Abort the sort and return the result. + */ error=HA_ERR_END_OF_FILE; break; /* Found enough records */ } + indexpos++; } make_sortkey(param,sort_keys[idx++],ref_pos); } @@ -399,7 +404,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, file->print_error(error,MYF(ME_ERROR | ME_WAITTANG)); /* purecov: inspected */ DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */ } - if (indexpos) + if (indexpos && idx) if (indexpos >= *maxbuffer || write_keys(param,sort_keys,idx,buffpek+indexpos,tempfile)) DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */ From ff993695a43914561488f71f3819bdf81d4df97a Mon Sep 17 00:00:00 2001 From: "monty@mashka.mysql.fi" <> Date: Mon, 16 Sep 2002 15:24:54 +0300 Subject: [PATCH 5/5] Fixed bug in ALTER TABLE and RENAME TABLE when running with lower-case-table-names. --- Docs/manual.texi | 6 +++++- sql/sql_table.cc | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index 7e3f455e0f8..509f46dab08 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -46929,10 +46929,14 @@ not yet 100% confident in this code. @appendixsubsec Changes in release 3.23.53 @itemize @bullet @item +Fixed bug in @code{ALTER TABLE} and @code{RENAME TABLE} when running with +@code{-O lower_case_table_names=1} (typically on windows) when giving the +table name in uppercase. +@item Fixed unlikely core dump with @code{SELECT ... ORDER BY ... LIMIT}. @item Changed @code{AND/OR} to report that they can return NULL. This fixes a -bug in @code{GROUP BY} on @code{AND/OR} expression that return +bug in @code{GROUP BY} on @code{AND/OR} expressions that return @code{NULL}. @item Fixed a bug that @code{OPTIMIZE} of locked and modified MyISAM table, diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2bb46b5c47d..e947de553cf 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -779,7 +779,7 @@ bool close_cached_table(THD *thd,TABLE *table) #if defined(USING_TRANSACTIONS) || defined( __WIN__) || defined( __EMX__) || !defined(OS2) /* Wait until all there are no other threads that has this table open */ while (remove_table_from_cache(thd,table->table_cache_key, - table->table_name)) + table->real_name)) { dropping_tables++; (void) pthread_cond_wait(&COND_refresh,&LOCK_open); @@ -787,7 +787,7 @@ bool close_cached_table(THD *thd,TABLE *table) } #else (void) remove_table_from_cache(thd,table->table_cache_key, - table->table_name); + table->real_name); #endif /* When lock on LOCK_open is freed other threads can continue */ pthread_cond_broadcast(&COND_refresh);