From f327a37cf7537f14a7b3f68d2996fc3101fdba92 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 29 Jan 2010 21:35:56 +0100 Subject: [PATCH 1/8] Support building with system libevent --- config/ac-macros/libevent.m4 | 76 +++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 18 deletions(-) diff --git a/config/ac-macros/libevent.m4 b/config/ac-macros/libevent.m4 index 58ba2d6ebde..a3479fbf0ca 100644 --- a/config/ac-macros/libevent.m4 +++ b/config/ac-macros/libevent.m4 @@ -14,13 +14,6 @@ AC_DEFUN([MYSQL_USE_BUNDLED_LIBEVENT], [ libevent_libs="\$(top_builddir)/extra/libevent/libevent.a" libevent_includes="-I\$(top_srcdir)/extra/libevent" - libevent_test_option="--mysqld=--thread-handling=pool-of-threads" - AC_SUBST(libevent_libs) - AC_SUBST(libevent_includes) - AC_SUBST(libevent_test_option) - - AC_DEFINE([HAVE_LIBEVENT], [1], [If we want to use libevent and have connection pooling]) - AC_MSG_RESULT([using bundled libevent]) dnl Get the upstream file with the original libevent configure macros. dnl Use builtin include for this, to work around path problems in old versions of aclocal. @@ -39,17 +32,64 @@ AC_DEFUN([MYSQL_CHECK_LIBEVENT], [ AC_CONFIG_FILES(extra/libevent/Makefile) - AC_MSG_CHECKING(for libevent) - AC_ARG_WITH([libevent], - [ --with-libevent use libevent and have connection pooling], - [with_libevent=$withval], - [with_libevent=no] - ) + AC_MSG_NOTICE([checking what libevent library to use]) - if test "$with_libevent" != "no"; then - MYSQL_USE_BUNDLED_LIBEVENT - else - AC_MSG_RESULT([disabled]) + AC_ARG_WITH([libevent], + AC_HELP_STRING([--with-libevent=yes|no|bundled|DIR], + [Use libevent and have connection pooling. + A location of libevent library can be specified. + Given DIR, libevent library is + assumed to be in $DIR/lib and header files + in $DIR/include.]), + [with_libevent=${withval}], + [with_libevent=no]) + + case "$with_libevent" in + "no") + with_libevent=disabled + ;; + "bundled") + MYSQL_USE_BUNDLED_LIBEVENT + ;; + "" | "yes") + libevent_includes="" + libevent_libs="-levent" + AC_CHECK_LIB(event, event_get_version,[with_libevent=system], + [with_libevent=bundled]) + AC_CHECK_HEADER(event.h,,[with_libevent=bundled]) + if test "$with_libevent" = "bundled"; then + MYSQL_USE_BUNDLED_LIBEVENT + fi + ;; + *) + # Test for libevent using all known library file endings + if test \( -f "$with_libevent/lib/libevent.a" -o \ + -f "$with_libevent/lib/libevent.so" -o \ + -f "$with_libevent/lib/libevent.sl" -o \ + -f "$with_libevent/lib/libevent.dylib" \) \ + -a -f "$with_libevent/include/event.h"; then + libevent_includes="-I$with_libevent/include" + libevent_libs="-L$with_libevent/lib -levent" + AC_CHECK_LIB(event, event_get_version,[with_libevent=$with_libevent], + [with_libevent=no], [$libevent_libs]) + else + with_libevent=no + fi + if test "$with_libevent" = "no"; then + AC_MSG_ERROR([libevent headers or binaries were not found]) + fi + ;; + esac + AC_MSG_CHECKING(for libevent) + AC_MSG_RESULT([$with_libevent]) + + if test "$with_libevent" != "disabled"; then + libevent_test_option="--mysqld=--thread-handling=pool-of-threads" + AC_SUBST(libevent_libs) + AC_SUBST(libevent_includes) + AC_SUBST(libevent_test_option) + AC_DEFINE([HAVE_LIBEVENT], [1], [If we want to use libevent and have connection pooling]) fi - AM_CONDITIONAL([HAVE_LIBEVENT], [ test "$with_libevent" != "no" ]) + AM_CONDITIONAL([HAVE_LIBEVENT], [ test "$with_libevent" != "disabled" ]) ]) + From d25273ed223a54b5d983709e07d6ef52ce9c6ef6 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 29 Jan 2010 21:37:22 +0100 Subject: [PATCH 2/8] hide nm warnings in configure --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 96bc09a4470..16f16f6b8bc 100644 --- a/configure.in +++ b/configure.in @@ -604,7 +604,7 @@ AC_CHECK_TOOL([NM], [nm]) if test "$TARGET_LINUX" = "true" -a "$static_nss" = "" then - tmp=`$NM ${other_libc_lib:-/usr/lib*}/libc.a | grep _nss_files_getaliasent_r1` + tmp=`$NM ${other_libc_lib:-/usr/lib*}/libc.a 2>&1 | grep _nss_files_getaliasent_r1` if test -n "$tmp" then STATIC_NSS_FLAGS="-lc -lnss_files -lnss_dns -lresolv" From 7cb11859c7ba09709546038078e0617da9fa9537 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 30 Jan 2010 13:39:39 +0100 Subject: [PATCH 3/8] now we force at least libevent-1.4 --- config/ac-macros/libevent.m4 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/ac-macros/libevent.m4 b/config/ac-macros/libevent.m4 index a3479fbf0ca..73fa59a1d3c 100644 --- a/config/ac-macros/libevent.m4 +++ b/config/ac-macros/libevent.m4 @@ -54,9 +54,9 @@ AC_DEFUN([MYSQL_CHECK_LIBEVENT], [ "" | "yes") libevent_includes="" libevent_libs="-levent" - AC_CHECK_LIB(event, event_get_version,[with_libevent=system], + AC_CHECK_LIB(event, evutil_socketpair,[with_libevent=system], [with_libevent=bundled]) - AC_CHECK_HEADER(event.h,,[with_libevent=bundled]) + AC_CHECK_HEADER(evutil.h,,[with_libevent=bundled]) if test "$with_libevent" = "bundled"; then MYSQL_USE_BUNDLED_LIBEVENT fi @@ -67,10 +67,10 @@ AC_DEFUN([MYSQL_CHECK_LIBEVENT], [ -f "$with_libevent/lib/libevent.so" -o \ -f "$with_libevent/lib/libevent.sl" -o \ -f "$with_libevent/lib/libevent.dylib" \) \ - -a -f "$with_libevent/include/event.h"; then + -a -f "$with_libevent/include/evutil.h"; then libevent_includes="-I$with_libevent/include" libevent_libs="-L$with_libevent/lib -levent" - AC_CHECK_LIB(event, event_get_version,[with_libevent=$with_libevent], + AC_CHECK_LIB(event, evutil_socketpair,[with_libevent=$with_libevent], [with_libevent=no], [$libevent_libs]) else with_libevent=no From 756d0b864fbeeef22427901b9bc150fa24d2af13 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 31 Jan 2010 10:13:21 +0100 Subject: [PATCH 4/8] Fix windows build of embedded server (forgotten dependency). --- libmysqld/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index 7d2abb64065..9adf91c997b 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -153,7 +153,7 @@ FILE(WRITE cmake_dummy.c " ") # custom targets to "sql/CMakeLists.txt" and reference them here. ADD_LIBRARY(mysqlserver STATIC ${LIBMYSQLD_SOURCES}) ADD_DEPENDENCIES(mysqlserver GenServerSource GenError) -TARGET_LINK_LIBRARIES(mysqlserver) +TARGET_LINK_LIBRARIES(mysqlserver psapi.lib) # Add any additional libraries requested by engine(s) FOREACH (ENGINE_LIB ${MYSQLD_STATIC_ENGINE_LIBS}) From d474428c9aef708a4d2af049efcca4886911126f Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Tue, 9 Feb 2010 19:17:04 +0200 Subject: [PATCH 5/8] Added --connect-command="sql-string" to sql-bench test suite. This allows one to send an extra command to the mysql server to setup the environment before starting tests. --- sql-bench/bench-init.pl.sh | 8 ++++++-- sql-bench/server-cfg.sh | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sql-bench/bench-init.pl.sh b/sql-bench/bench-init.pl.sh index 919ddcedf16..2d9927947d2 100644 --- a/sql-bench/bench-init.pl.sh +++ b/sql-bench/bench-init.pl.sh @@ -40,7 +40,7 @@ require "$pwd/server-cfg" || die "Can't read Configuration file: $!\n"; $|=1; # Output data immediately $opt_skip_test=$opt_skip_create=$opt_skip_delete=$opt_verbose=$opt_fast_insert=$opt_lock_tables=$opt_debug=$opt_skip_delete=$opt_fast=$opt_force=$opt_log=$opt_use_old_results=$opt_help=$opt_odbc=$opt_small_test=$opt_small_tables=$opt_samll_key_tables=$opt_stage=$opt_old_headers=$opt_die_on_errors=$opt_tcpip=$opt_random=$opt_only_missing_tests=0; -$opt_cmp=$opt_user=$opt_password=$opt_connect_options=""; +$opt_cmp=$opt_user=$opt_password=$opt_connect_options=$opt_connect_command= ""; $opt_server="mysql"; $opt_dir="output"; $opt_host="localhost";$opt_database="test"; $opt_machine=""; $opt_suffix=""; @@ -59,7 +59,7 @@ $log_prog_args=join(" ", skip_arguments(\@ARGV,"comments","cmp","server", "use-old-results","skip-test", "optimization","hw", "machine", "dir", "suffix", "log")); -GetOptions("skip-test=s","comments=s","cmp=s","server=s","user=s","host=s","database=s","password=s","loop-count=i","row-count=i","skip-create","skip-delete","verbose","fast-insert","lock-tables","debug","fast","force","field-count=i","regions=i","groups=i","time-limit=i","log","use-old-results","machine=s","dir=s","suffix=s","help","odbc","small-test","small-tables","small-key-tables","stage=i","threads=i","random","old-headers","die-on-errors","create-options=s","hires","tcpip","silent","optimization=s","hw=s","socket=s","connect-options=s","only-missing-tests") || usage(); +GetOptions("skip-test=s","comments=s","cmp=s","server=s","user=s","host=s","database=s","password=s","loop-count=i","row-count=i","skip-create","skip-delete","verbose","fast-insert","lock-tables","debug","fast","force","field-count=i","regions=i","groups=i","time-limit=i","log","use-old-results","machine=s","dir=s","suffix=s","help","odbc","small-test","small-tables","small-key-tables","stage=i","threads=i","random","old-headers","die-on-errors","create-options=s","hires","tcpip","silent","optimization=s","hw=s","socket=s","connect-options=s","connect-command=s","only-missing-tests") || usage(); usage() if ($opt_help); $server=get_server($opt_server,$opt_host,$opt_database,$opt_odbc, @@ -595,6 +595,10 @@ All benchmarks takes the following options: Add options, which uses at DBI connect. For example --connect-options=mysql_read_default_file=/etc/my.cnf. +--connect-command='SQL command' + Initialization command to execute when logged in. Useful for setting + up the environment. + EOF exit(0); } diff --git a/sql-bench/server-cfg.sh b/sql-bench/server-cfg.sh index 5ed7fdf482c..3ff1ce99659 100644 --- a/sql-bench/server-cfg.sh +++ b/sql-bench/server-cfg.sh @@ -249,6 +249,11 @@ sub connect die "Got error: '$DBI::errstr' when connecting to " . $self->{'data_source'} ." with user: '$main::opt_user' password: '$main::opt_password'\n"; $dbh->do("SET OPTION LOG_OFF=1,UPDATE_LOG=0"); + if ($main::opt_connect_command ne "") + { + $dbh->do($main::opt_connect_command) or + die "Can't execute connect_command: $main::opt_connect_command error: $DBI::errstr\n"; + } return $dbh; } From d77e3cde5f43426271f7ac64a922e5ddbf6e675d Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 10 Feb 2010 21:06:24 +0200 Subject: [PATCH 6/8] When one does a drop table, the indexes are not flushed to disk before drop anymore (with MyISAM/Maria) myisam-recover options changed from OFF to 'DEFAULT' to get less change of data loss when using MyISAM. (The disadvantage is that changed MyISAM tables will be checked at access time; Use --myisam-recover=OFF for old behavior) Don't call extra(HA_EXTRA_FORCE_REOPEN) in ALTER TABLE if table is locked as this will mark table as crashed! Added assert to detect if we accidently would use MyISAM versioning in MySQL include/my_base.h: Mark NOT_USED as USED, as we now use this as a flag to not call extra() mysql-test/mysql-test-run.pl: Don't write all options when there is something wrong with the arguments mysql-test/r/sp-destruct.result: Add missing flush of mysql.proc (as the test copied live tables) mysql-test/r/variables.result: myisam-recover options changed to 'default' mysql-test/r/view.result: Don't show create time in result mysql-test/suite/maria/t/maria-recovery2-master.opt: Don't run test with myisam-recover (as this produces extra warnings during simulated death) mysql-test/t/sp-destruct.test: Add missing flush of mysql.proc (as the test copied live tables) mysql-test/t/view.test: Don't show create time in result sql/lock.cc: Added marker if table was deleted to argument list sql/mysql_priv.h: Added marker if table was deleted to argument list sql/mysqld.cc: myisam-recover options changed from OFF to 'DEFAULT' to get less change of data loss when using MyISAM Allow one to specify OFF as argument to myisam-recover (was default before but one couldn't specify it) sql/sql_base.cc: Mark if table is going to be deleted sql/sql_delete.cc: Mark if table is going to be deleted sql/sql_table.cc: Mark if table is going to be deleted Don't call extra(HA_EXTRA_FORCE_REOPEN) in ALTER TABLE if table is locked as this will mark table as crashed! sql/table.cc: Signal to handler if table is getting deleted as part of getting droped from table cache. sql/table.h: Added marker if table is going to be deleted. storage/maria/ha_maria.cc: Don't search for transaction handler if file is not transactional or outside of transaction (Fixed possible core dump) storage/maria/ma_blockrec.c: Don't write changed information if table is going to be deleted. storage/maria/ma_close.c: Don't write changed information if table is going to be deleted. storage/maria/ma_extra.c: Mark tables that are deleted as crased, to ensure good behavior on restart if we suddenly crash. storage/maria/ma_locking.c: Cleanup storage/maria/ma_recovery.c: We need trnman to be inited during redo phase (to be able to open tables checked with maria_chk) storage/maria/maria_def.h: Added marker if table is going to be deleted. storage/myisam/mi_close.c: Don't write changed information if table is going to be deleted. storage/myisam/mi_extra.c: Mark tables that are deleted as crased, to ensure good behavior on restart if we suddenly crash. storage/myisam/mi_open.c: Added assert to detect if we accidently would use MyISAM versioning in MySQL storage/myisam/myisamdef.h: Added marker if table is going to be deleted. --- include/my_base.h | 2 +- mysql-test/mysql-test-run.pl | 2 + mysql-test/r/sp-destruct.result | 1 + mysql-test/r/variables.result | 4 +- mysql-test/r/view.result | 14 +++---- .../suite/maria/t/maria-recovery2-master.opt | 2 +- mysql-test/t/sp-destruct.test | 1 + mysql-test/t/view.test | 2 +- sql/lock.cc | 6 ++- sql/mysql_priv.h | 2 +- sql/mysqld.cc | 39 ++++++++++++------- sql/sql_base.cc | 17 ++++++-- sql/sql_delete.cc | 4 ++ sql/sql_table.cc | 26 +++++++++---- sql/table.cc | 4 ++ sql/table.h | 3 +- storage/maria/ha_maria.cc | 5 ++- storage/maria/ma_blockrec.c | 5 ++- storage/maria/ma_close.c | 2 +- storage/maria/ma_extra.c | 6 +++ storage/maria/ma_locking.c | 5 ++- storage/maria/ma_recovery.c | 3 ++ storage/maria/maria_def.h | 1 + storage/myisam/mi_close.c | 5 ++- storage/myisam/mi_extra.c | 7 +++- storage/myisam/mi_open.c | 2 + storage/myisam/myisamdef.h | 1 + 27 files changed, 121 insertions(+), 50 deletions(-) diff --git a/include/my_base.h b/include/my_base.h index 59929fe4d49..f76903dcb6b 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -111,7 +111,7 @@ enum ha_storage_media { enum ha_extra_function { HA_EXTRA_NORMAL=0, /* Optimize for space (def) */ HA_EXTRA_QUICK=1, /* Optimize for speed */ - HA_EXTRA_NOT_USED=2, + HA_EXTRA_NOT_USED=2, /* Should be ignored by handler */ HA_EXTRA_CACHE=3, /* Cache record in HA_rrnd() */ HA_EXTRA_NO_CACHE=4, /* End caching of records (def) */ HA_EXTRA_NO_READCHECK=5, /* No readcheck on update */ diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 8d577d1e788..5ff40b1916c 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -5542,6 +5542,8 @@ sub usage ($) { if ( $message ) { print STDERR "$message\n"; + print STDERR "For full list of options, use $0 --help\n"; + exit; } print <table=table; + table->s->deleting= table_list->deleting; /* Return 1 if table is in use */ DBUG_RETURN(test(remove_table_from_cache(thd, db, table_list->table_name, - check_in_use ? RTFC_NO_FLAG : RTFC_WAIT_OTHER_THREAD_FLAG))); + (check_in_use ? + RTFC_NO_FLAG : + RTFC_WAIT_OTHER_THREAD_FLAG), + table_list->deleting))); } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 2af7654e381..d11fc4f900b 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1636,7 +1636,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info, #define RTFC_WAIT_OTHER_THREAD_FLAG 0x0002 #define RTFC_CHECK_KILLED_FLAG 0x0004 bool remove_table_from_cache(THD *thd, const char *db, const char *table, - uint flags); + uint flags, my_bool deleting); #define NORMAL_PART_NAME 0 #define TEMP_PART_NAME 1 diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a45950c3af9..bf09df8a465 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -7962,7 +7962,13 @@ static int mysql_init_variables(void) refresh_version= 1L; /* Increments on each reload */ global_query_id= thread_id= 1L; strmov(server_version, MYSQL_SERVER_VERSION); - myisam_recover_options_str= sql_mode_str= "OFF"; + sql_mode_str= ""; + + /* By default, auto-repair MyISAM tables after crash */ + myisam_recover_options_str= "DEFAULT"; + myisam_recover_options= HA_RECOVER_DEFAULT; + ha_open_options|= HA_OPEN_ABORT_IF_CRASHED; + myisam_stats_method_str= "nulls_unequal"; my_bind_addr = htonl(INADDR_ANY); threads.empty(); @@ -8616,26 +8622,31 @@ mysqld_get_one_option(int optid, #endif case OPT_MYISAM_RECOVER: { - if (!argument) - { - myisam_recover_options= HA_RECOVER_DEFAULT; - myisam_recover_options_str= myisam_recover_typelib.type_names[0]; - } - else if (!argument[0]) + if (argument && (!argument[0] || + my_strcasecmp(system_charset_info, argument, "OFF") == 0)) { myisam_recover_options= HA_RECOVER_NONE; myisam_recover_options_str= "OFF"; + ha_open_options&= ~HA_OPEN_ABORT_IF_CRASHED; } else { - myisam_recover_options_str=argument; - myisam_recover_options= - find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name, - &error); - if (error) - return 1; + if (!argument) + { + myisam_recover_options= HA_RECOVER_DEFAULT; + myisam_recover_options_str= myisam_recover_typelib.type_names[0]; + } + else + { + myisam_recover_options_str=argument; + myisam_recover_options= + find_bit_type_or_exit(argument, &myisam_recover_typelib, opt->name, + &error); + if (error) + return 1; + } + ha_open_options|=HA_OPEN_ABORT_IF_CRASHED; } - ha_open_options|=HA_OPEN_ABORT_IF_CRASHED; break; } case OPT_CONCURRENT_INSERT: diff --git a/sql/sql_base.cc b/sql/sql_base.cc index adcd42719e1..8cc0b1574a3 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -930,7 +930,7 @@ bool close_cached_tables(THD *thd, TABLE_LIST *tables, bool have_lock, for (TABLE_LIST *table= tables; table; table= table->next_local) { if (remove_table_from_cache(thd, table->db, table->table_name, - RTFC_OWNED_BY_THD_FLAG)) + RTFC_OWNED_BY_THD_FLAG, table->deleting)) found=1; } if (!found) @@ -8404,6 +8404,11 @@ void remove_db_from_cache(const char *db) if (!strcmp(table->s->db.str, db)) { table->s->version= 0L; /* Free when thread is ready */ + /* + This functions only called from DROP DATABASE code, so we are going + to drop all tables so we mark them as deleting + */ + table->s->deleting= TRUE; if (!table->in_use) relink_unused(table); } @@ -8446,7 +8451,7 @@ void flush_tables() */ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, - uint flags) + uint flags, my_bool deleting) { char key[MAX_DBKEY_LENGTH]; uint key_length; @@ -8540,7 +8545,10 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, } } while (unused_tables && !unused_tables->s->version) + { + unused_tables->s->deleting= deleting; VOID(hash_delete(&open_cache,(uchar*) unused_tables)); + } DBUG_PRINT("info", ("Removing table from table_def_cache")); /* Remove table from table definition cache if it's not in use */ @@ -8734,7 +8742,8 @@ int abort_and_upgrade_lock(ALTER_PARTITION_PARAM_TYPE *lpt) /* If MERGE child, forward lock handling to parent. */ mysql_lock_abort(lpt->thd, lpt->table->parent ? lpt->table->parent : lpt->table, TRUE); - VOID(remove_table_from_cache(lpt->thd, lpt->db, lpt->table_name, flags)); + VOID(remove_table_from_cache(lpt->thd, lpt->db, lpt->table_name, flags, + FALSE)); VOID(pthread_mutex_unlock(&LOCK_open)); DBUG_RETURN(0); } @@ -8759,7 +8768,7 @@ void close_open_tables_and_downgrade(ALTER_PARTITION_PARAM_TYPE *lpt) { VOID(pthread_mutex_lock(&LOCK_open)); remove_table_from_cache(lpt->thd, lpt->db, lpt->table_name, - RTFC_WAIT_OTHER_THREAD_FLAG); + RTFC_WAIT_OTHER_THREAD_FLAG, FALSE); VOID(pthread_mutex_unlock(&LOCK_open)); /* If MERGE child, forward lock handling to parent. */ mysql_lock_downgrade_write(lpt->thd, lpt->table->parent ? lpt->table->parent : diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 2f8f62408b3..cea9b2857e2 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -1088,6 +1088,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) HA_CREATE_INFO create_info; char path[FN_REFLEN + 1]; TABLE *table; + TABLE_LIST *tbl; bool error; uint path_length; bool is_temporary_table= false; @@ -1108,6 +1109,9 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) if (!ha_check_storage_engine_flag(table_type, HTON_CAN_RECREATE)) goto trunc_by_del; + for (tbl= table_list; tbl; tbl= tbl->next_local) + tbl->deleting= TRUE; /* to trigger HA_PREPARE_FOR_DROP */ + table->file->info(HA_STATUS_AUTO | HA_STATUS_NO_LOCK); create_info.options|= HA_LEX_CREATE_TMP_TABLE; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index dc156fea894..1c72f1986ec 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1880,6 +1880,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, { TABLE_SHARE *share; table->db_type= NULL; + if ((share= get_cached_table_share(table->db, table->table_name))) table->db_type= share->db_type(); @@ -1974,9 +1975,10 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, { TABLE *locked_table; abort_locked_tables(thd, db, table->table_name); + table->deleting= TRUE; remove_table_from_cache(thd, db, table->table_name, RTFC_WAIT_OTHER_THREAD_FLAG | - RTFC_CHECK_KILLED_FLAG); + RTFC_CHECK_KILLED_FLAG, FALSE); /* If the table was used in lock tables, remember it so that unlock_table_names can free it @@ -4213,9 +4215,10 @@ void wait_while_table_is_used(THD *thd,TABLE *table, /* Wait until all there are no other threads that has this table open */ remove_table_from_cache(thd, table->s->db.str, table->s->table_name.str, - RTFC_WAIT_OTHER_THREAD_FLAG); + RTFC_WAIT_OTHER_THREAD_FLAG, FALSE); /* extra() call must come only after all instances above are closed */ - VOID(table->file->extra(function)); + if (function != HA_EXTRA_NOT_USED) + VOID(table->file->extra(function)); DBUG_VOID_RETURN; } @@ -4717,7 +4720,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, remove_table_from_cache(thd, table->table->s->db.str, table->table->s->table_name.str, RTFC_WAIT_OTHER_THREAD_FLAG | - RTFC_CHECK_KILLED_FLAG); + RTFC_CHECK_KILLED_FLAG, FALSE); thd->exit_cond(old_message); DBUG_EXECUTE_IF("wait_in_mysql_admin_table", wait_for_kill_signal(thd);); if (thd->killed) @@ -4975,7 +4978,8 @@ send_result_message: { pthread_mutex_lock(&LOCK_open); remove_table_from_cache(thd, table->table->s->db.str, - table->table->s->table_name.str, RTFC_NO_FLAG); + table->table->s->table_name.str, + RTFC_NO_FLAG, FALSE); pthread_mutex_unlock(&LOCK_open); } /* May be something modified consequently we have to invalidate cache */ @@ -6738,7 +6742,9 @@ view_err: from concurrent DDL statements. */ VOID(pthread_mutex_lock(&LOCK_open)); - wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); + wait_while_table_is_used(thd, table, + thd->locked_tables ? HA_EXTRA_NOT_USED : + HA_EXTRA_FORCE_REOPEN); VOID(pthread_mutex_unlock(&LOCK_open)); DBUG_EXECUTE_IF("sleep_alter_enable_indexes", my_sleep(6000000);); error= table->file->ha_enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); @@ -6746,7 +6752,9 @@ view_err: break; case DISABLE: VOID(pthread_mutex_lock(&LOCK_open)); - wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); + wait_while_table_is_used(thd, table, + thd->locked_tables ? HA_EXTRA_NOT_USED : + HA_EXTRA_FORCE_REOPEN); VOID(pthread_mutex_unlock(&LOCK_open)); error=table->file->ha_disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); /* COND_refresh will be signaled in close_thread_tables() */ @@ -7192,7 +7200,9 @@ view_err: else { VOID(pthread_mutex_lock(&LOCK_open)); - wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); + wait_while_table_is_used(thd, table, + thd->locked_tables ? HA_EXTRA_NOT_USED : + HA_EXTRA_FORCE_REOPEN); VOID(pthread_mutex_unlock(&LOCK_open)); thd_proc_info(thd, "manage keys"); alter_table_manage_keys(table, table->file->indexes_are_disabled(), diff --git a/sql/table.cc b/sql/table.cc index 92487a4a34e..8ceda6e7513 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1977,7 +1977,11 @@ int closefrm(register TABLE *table, bool free_share) DBUG_PRINT("enter", ("table: 0x%lx", (long) table)); if (table->db_stat) + { + if (table->s->deleting) + table->file->extra(HA_EXTRA_PREPARE_FOR_DROP); error=table->file->close(); + } my_free((char*) table->alias, MYF(MY_ALLOW_ZERO_PTR)); table->alias= 0; if (table->field) diff --git a/sql/table.h b/sql/table.h index 137b380e0f5..a24e79e26cf 100644 --- a/sql/table.h +++ b/sql/table.h @@ -431,6 +431,7 @@ typedef struct st_table_share bool is_view; bool name_lock, replace_with_name_lock; bool waiting_on_cond; /* Protection against free */ + bool deleting; /* going to delete this table */ ulong table_map_id; /* for row-based replication */ ulonglong table_map_version; @@ -1379,7 +1380,7 @@ struct TABLE_LIST */ bool create; bool internal_tmp_table; - + bool deleting; /* going to delete this table */ /* View creation context. */ diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index dc2ba8c43f4..5ec0a6b748e 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -2255,9 +2255,12 @@ int ha_maria::extra(enum ha_extra_function operation) extern_lock(F_UNLOCK) (which resets file->trn) followed by maria_close() without calling commit/rollback in between. If file->trn is not set we can't remove file->share from the transaction list in the extra() call. + + table->in_use is not set in the case this is a done as part of closefrm() + as part of drop table. */ - if (!file->trn && + if (file->s->now_transactional && !file->trn && table->in_use && (operation == HA_EXTRA_PREPARE_FOR_DROP || operation == HA_EXTRA_PREPARE_FOR_RENAME)) { diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index 9097731c227..89701913c9a 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -430,8 +430,9 @@ my_bool _ma_once_end_block_record(MARIA_SHARE *share) if (share->bitmap.file.file >= 0) { if (flush_pagecache_blocks(share->pagecache, &share->bitmap.file, - share->temporary ? FLUSH_IGNORE_CHANGED : - FLUSH_RELEASE)) + ((share->temporary || share->deleting) ? + FLUSH_IGNORE_CHANGED : + FLUSH_RELEASE))) res= 1; /* File must be synced as it is going out of the maria_open_list and so diff --git a/storage/maria/ma_close.c b/storage/maria/ma_close.c index e46beec71b4..df525d45d14 100644 --- a/storage/maria/ma_close.c +++ b/storage/maria/ma_close.c @@ -79,7 +79,7 @@ int maria_close(register MARIA_HA *info) if ((*share->once_end)(share)) error= my_errno; if (flush_pagecache_blocks(share->pagecache, &share->kfile, - (share->temporary ? + ((share->temporary || share->deleting) ? FLUSH_IGNORE_CHANGED : FLUSH_RELEASE))) error= my_errno; diff --git a/storage/maria/ma_extra.c b/storage/maria/ma_extra.c index 691e55b2a2a..81f3789523f 100644 --- a/storage/maria/ma_extra.c +++ b/storage/maria/ma_extra.c @@ -305,6 +305,12 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, pthread_mutex_unlock(&THR_LOCK_maria); break; case HA_EXTRA_PREPARE_FOR_DROP: + /* Signals about intent to delete this table */ + share->deleting= TRUE; + share->global_changed= FALSE; /* force writing changed flag */ + /* To force repair if reopened */ + _ma_mark_file_changed(info); + /* Fall trough */ case HA_EXTRA_PREPARE_FOR_RENAME: { my_bool do_flush= test(function != HA_EXTRA_PREPARE_FOR_DROP); diff --git a/storage/maria/ma_locking.c b/storage/maria/ma_locking.c index e1986a7dfaa..b355d7bc792 100644 --- a/storage/maria/ma_locking.c +++ b/storage/maria/ma_locking.c @@ -387,6 +387,9 @@ int _ma_test_if_changed(register MARIA_HA *info) open_count is not maintained on disk for temporary tables. */ +#define _MA_ALREADY_MARKED_FILE_CHANGED \ + ((share->state.changed & STATE_CHANGED) && share->global_changed) + int _ma_mark_file_changed(MARIA_HA *info) { uchar buff[3]; @@ -394,8 +397,6 @@ int _ma_mark_file_changed(MARIA_HA *info) int error= 1; DBUG_ENTER("_ma_mark_file_changed"); -#define _MA_ALREADY_MARKED_FILE_CHANGED \ - ((share->state.changed & STATE_CHANGED) && share->global_changed) if (_MA_ALREADY_MARKED_FILE_CHANGED) DBUG_RETURN(0); pthread_mutex_lock(&share->intern_lock); /* recheck under mutex */ diff --git a/storage/maria/ma_recovery.c b/storage/maria/ma_recovery.c index 65ad767d8ef..7b3065b0208 100644 --- a/storage/maria/ma_recovery.c +++ b/storage/maria/ma_recovery.c @@ -312,11 +312,14 @@ int maria_apply_log(LSN from_lsn, enum maria_apply_log_way apply, now= my_getsystime(); in_redo_phase= TRUE; + trnman_init(max_trid_in_control_file); if (run_redo_phase(from_lsn, apply)) { ma_message_no_user(0, "Redo phase failed"); + trnman_destroy(); goto err; } + trnman_destroy(); if ((uncommitted_trans= end_of_redo_phase(should_run_undo_phase)) == (uint)-1) diff --git a/storage/maria/maria_def.h b/storage/maria/maria_def.h index ad93d566578..1d60beece6b 100644 --- a/storage/maria/maria_def.h +++ b/storage/maria/maria_def.h @@ -390,6 +390,7 @@ typedef struct st_maria_share my_bool now_transactional; my_bool have_versioning; my_bool key_del_used; /* != 0 if key_del is locked */ + my_bool deleting; /* we are going to delete this table */ #ifdef THREAD THR_LOCK lock; void (*lock_restore_status)(void *); diff --git a/storage/myisam/mi_close.c b/storage/myisam/mi_close.c index 3d860bbead6..fbd24237286 100644 --- a/storage/myisam/mi_close.c +++ b/storage/myisam/mi_close.c @@ -64,8 +64,9 @@ int mi_close(register MI_INFO *info) if (share->kfile >= 0) abort();); if (share->kfile >= 0 && flush_key_blocks(share->key_cache, share->kfile, - share->temporary ? FLUSH_IGNORE_CHANGED : - FLUSH_RELEASE)) + ((share->temporary || share->deleting) ? + FLUSH_IGNORE_CHANGED : + FLUSH_RELEASE))) error=my_errno; if (share->kfile >= 0) { diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 9c5dade28ab..64e7a55231d 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -256,8 +256,13 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) share->last_version= 0L; /* Impossible version */ pthread_mutex_unlock(&THR_LOCK_myisam); break; - case HA_EXTRA_PREPARE_FOR_RENAME: case HA_EXTRA_PREPARE_FOR_DROP: + /* Signals about intent to delete this table */ + share->deleting= TRUE; + share->global_changed= FALSE; /* force writing changed flag */ + _mi_mark_file_changed(info); + /* Fall trough */ + case HA_EXTRA_PREPARE_FOR_RENAME: pthread_mutex_lock(&THR_LOCK_myisam); share->last_version= 0L; /* Impossible version */ pthread_mutex_lock(&share->intern_lock); diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index 964501aa979..2ded6a8e8cd 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -58,6 +58,8 @@ MI_INFO *test_if_reopen(char *filename) { MI_INFO *info=(MI_INFO*) pos->data; MYISAM_SHARE *share=info->s; + DBUG_ASSERT(strcmp(share->unique_file_name,filename) || + share->last_version); if (!strcmp(share->unique_file_name,filename) && share->last_version) return info; } diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index 680bdbf16dd..48e5d92a9a9 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -221,6 +221,7 @@ typedef struct st_mi_isam_share my_bool changed, /* If changed since lock */ global_changed, /* If changed since open */ not_flushed, temporary, delay_key_write, concurrent_insert; + my_bool deleting; /* we are going to delete this table */ #ifdef THREAD THR_LOCK lock; pthread_mutex_t intern_lock; /* Locking for use with _locking */ From af51917d1e2e47eaee5e39a3d83ce09815ab4d1c Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Wed, 10 Feb 2010 23:26:06 +0200 Subject: [PATCH 7/8] Added option --temporary-tables to test speed of temporary tables mysql-test/suite/parts/t/partition_repair_myisam-master.opt: Added missing file from last push sql-bench/bench-init.pl.sh: Added options: --temporary-tables to test speed of temporary tables sql-bench/server-cfg.sh: Added limit for number of temporary tables one can create sql-bench/test-connect.sh: Skip test that doesn't work with temporary tables. sql-bench/test-create.sh: Added limit for number of temporary tables one can create --- .../t/partition_repair_myisam-master.opt | 1 + sql-bench/bench-init.pl.sh | 7 ++- sql-bench/server-cfg.sh | 38 +++++++++++++++- sql-bench/test-connect.sh | 45 +++++++++++-------- sql-bench/test-create.sh | 14 ++++-- 5 files changed, 79 insertions(+), 26 deletions(-) create mode 100644 mysql-test/suite/parts/t/partition_repair_myisam-master.opt diff --git a/mysql-test/suite/parts/t/partition_repair_myisam-master.opt b/mysql-test/suite/parts/t/partition_repair_myisam-master.opt new file mode 100644 index 00000000000..44fc50f599c --- /dev/null +++ b/mysql-test/suite/parts/t/partition_repair_myisam-master.opt @@ -0,0 +1 @@ +--myisam-recover=off diff --git a/sql-bench/bench-init.pl.sh b/sql-bench/bench-init.pl.sh index 2d9927947d2..f1d4bd9edec 100644 --- a/sql-bench/bench-init.pl.sh +++ b/sql-bench/bench-init.pl.sh @@ -39,7 +39,7 @@ require "$pwd/server-cfg" || die "Can't read Configuration file: $!\n"; $|=1; # Output data immediately -$opt_skip_test=$opt_skip_create=$opt_skip_delete=$opt_verbose=$opt_fast_insert=$opt_lock_tables=$opt_debug=$opt_skip_delete=$opt_fast=$opt_force=$opt_log=$opt_use_old_results=$opt_help=$opt_odbc=$opt_small_test=$opt_small_tables=$opt_samll_key_tables=$opt_stage=$opt_old_headers=$opt_die_on_errors=$opt_tcpip=$opt_random=$opt_only_missing_tests=0; +$opt_skip_test=$opt_skip_create=$opt_skip_delete=$opt_verbose=$opt_fast_insert=$opt_lock_tables=$opt_debug=$opt_skip_delete=$opt_fast=$opt_force=$opt_log=$opt_use_old_results=$opt_help=$opt_odbc=$opt_small_test=$opt_small_tables=$opt_samll_key_tables=$opt_stage=$opt_old_headers=$opt_die_on_errors=$opt_tcpip=$opt_random=$opt_only_missing_tests=$opt_temporary_tables=0; $opt_cmp=$opt_user=$opt_password=$opt_connect_options=$opt_connect_command= ""; $opt_server="mysql"; $opt_dir="output"; $opt_host="localhost";$opt_database="test"; @@ -59,7 +59,7 @@ $log_prog_args=join(" ", skip_arguments(\@ARGV,"comments","cmp","server", "use-old-results","skip-test", "optimization","hw", "machine", "dir", "suffix", "log")); -GetOptions("skip-test=s","comments=s","cmp=s","server=s","user=s","host=s","database=s","password=s","loop-count=i","row-count=i","skip-create","skip-delete","verbose","fast-insert","lock-tables","debug","fast","force","field-count=i","regions=i","groups=i","time-limit=i","log","use-old-results","machine=s","dir=s","suffix=s","help","odbc","small-test","small-tables","small-key-tables","stage=i","threads=i","random","old-headers","die-on-errors","create-options=s","hires","tcpip","silent","optimization=s","hw=s","socket=s","connect-options=s","connect-command=s","only-missing-tests") || usage(); +GetOptions("skip-test=s","comments=s","cmp=s","server=s","user=s","host=s","database=s","password=s","loop-count=i","row-count=i","skip-create","skip-delete","verbose","fast-insert","lock-tables","debug","fast","force","field-count=i","regions=i","groups=i","time-limit=i","log","use-old-results","machine=s","dir=s","suffix=s","help","odbc","small-test","small-tables","small-key-tables","stage=i","threads=i","random","old-headers","die-on-errors","create-options=s","hires","tcpip","silent","optimization=s","hw=s","socket=s","connect-options=s","connect-command=s","only-missing-tests","temporary-tables") || usage(); usage() if ($opt_help); $server=get_server($opt_server,$opt_host,$opt_database,$opt_odbc, @@ -454,6 +454,9 @@ All benchmarks takes the following options: create all MySQL tables as InnoDB tables use: --create-options=ENGINE=InnoDB +--temporary-tables + Use temporary tables for all tests. + --database (Default $opt_database) In which database the test tables are created. diff --git a/sql-bench/server-cfg.sh b/sql-bench/server-cfg.sh index 3ff1ce99659..76334d76108 100644 --- a/sql-bench/server-cfg.sh +++ b/sql-bench/server-cfg.sh @@ -159,6 +159,7 @@ sub new $limits{'max_index'} = 16; # Max number of keys $limits{'max_index_parts'} = 16; # Max segments/key $limits{'max_tables'} = (($machine || '') =~ "^win") ? 5000 : 65000; + $limits{'max_temporary_tables'}= 400; $limits{'max_text_size'} = 1000000; # Good enough for tests $limits{'multi_drop'} = 1; # Drop table can take many tables $limits{'order_by_position'} = 1; # Can use 'ORDER BY 1' @@ -189,6 +190,7 @@ sub new $self->{'transactions'} = 1; # Transactions enabled $limits{'max_columns'} = 90; # Max number of columns in table $limits{'max_tables'} = 32; # No comments + $limits{'max_temporary_tables'}= $limits{"max_tables"}; } if (defined($main::opt_create_options) && $main::opt_create_options =~ /engine=bdb/i) @@ -200,6 +202,7 @@ sub new { $limits{'working_blobs'} = 0; # Blobs not implemented yet $limits{'max_tables'} = 500; + $limits{'max_temporary_tables'}= $limits{"max_tables"}; $self->{'transactions'} = 1; # Transactions enabled } @@ -270,7 +273,14 @@ sub create my($self,$table_name,$fields,$index,$options) = @_; my($query,@queries); - $query="create table $table_name ("; + if ($main::opt_temporary_tables) + { + $query="create temporary table $table_name ("; + } + else + { + $query="create table $table_name ("; + } foreach $field (@$fields) { # $field =~ s/ decimal/ double(10,2)/i; @@ -393,6 +403,7 @@ sub new $limits{'max_conditions'} = 74; $limits{'max_columns'} = 75; $limits{'max_tables'} = 65000; # Should be big enough + $limits{'max_temporary_tables'}= $limits{"max_tables"}; $limits{'max_text_size'} = 32000; $limits{'query_size'} = 65535; $limits{'max_index'} = 5; @@ -622,7 +633,9 @@ sub new $limits{'max_conditions'} = 9999; # This makes Pg real slow $limits{'max_index'} = 64; # Big enough $limits{'max_index_parts'} = 16; - $limits{'max_tables'} = 5000; # 10000 crashes pg 7.0.2 + $limits{'max_tables'} = 65000; + $limits{'max_temporary_tables'}= $limits{"max_tables"}; + $limits{'max_text_size'} = 65000; # Good enough for test $limits{'multi_drop'} = 1; $limits{'order_by_position'} = 1; @@ -873,6 +886,8 @@ sub new $limits{'max_conditions'} = 9999; # Probably big enough $limits{'max_columns'} = 2000; # From crash-me $limits{'max_tables'} = 65000; # Should be big enough + $limits{'max_temporary_tables'}= $limits{"max_tables"}; + $limits{'max_text_size'} = 65492; # According to tests $limits{'query_size'} = 65535; # Probably a limit $limits{'max_index'} = 64; # Probably big enough @@ -1104,6 +1119,7 @@ sub new # above this value .... but can handle 2419 columns # maybe something for crash-me ... but how to check ??? $limits{'max_tables'} = 65000; # Should be big enough + $limits{'max_temporary_tables'}= $limits{"max_tables"}; $limits{'max_text_size'} = 4095; # max returned .... $limits{'query_size'} = 65535; # Not a limit, big enough $limits{'max_index'} = 64; # Big enough @@ -1374,6 +1390,8 @@ sub new $limits{'max_conditions'} = 9999; # (Actually not a limit) $limits{'max_columns'} = 254; # Max number of columns in table $limits{'max_tables'} = 65000; # Should be big enough + $limits{'max_temporary_tables'}= $limits{"max_tables"}; + $limits{'max_text_size'} = 2000; # Limit for blob test-connect $limits{'query_size'} = 65525; # Max size with default buffers. $limits{'max_index'} = 16; # Max number of keys @@ -1647,6 +1665,8 @@ sub new $limits{'max_column_name'} = 18; # max table and column name $limits{'max_columns'} = 994; # Max number of columns in table $limits{'max_tables'} = 65000; # Should be big enough + $limits{'max_temporary_tables'}= $limits{"max_tables"}; + $limits{'max_index'} = 64; # Max number of keys $limits{'max_index_parts'} = 15; # Max segments/key $limits{'max_text_size'} = 65535; # Max size with default buffers. ?? @@ -1835,6 +1855,8 @@ sub new $limits{'max_conditions'} = 97; # We get 'Query is too complex' $limits{'max_columns'} = 255; # Max number of columns in table $limits{'max_tables'} = 65000; # Should be big enough + $limits{'max_temporary_tables'}= $limits{"max_tables"}; + $limits{'max_text_size'} = 255; # Max size with default buffers. $limits{'query_size'} = 65535; # Not a limit, big enough $limits{'max_index'} = 32; # Max number of keys @@ -2020,6 +2042,8 @@ sub new $limits{'max_conditions'} = 1030; # We get 'Query is too complex' $limits{'max_columns'} = 250; # Max number of columns in table $limits{'max_tables'} = 65000; # Should be big enough + $limits{'max_temporary_tables'}= $limits{"max_tables"}; + $limits{'max_text_size'} = 9830; # Max size with default buffers. $limits{'query_size'} = 9830; # Max size with default buffers. $limits{'max_index'} = 64; # Max number of keys @@ -2216,6 +2240,8 @@ sub new $limits{'max_conditions'} = 1030; # We get 'Query is too complex' $limits{'max_columns'} = 250; # Max number of columns in table $limits{'max_tables'} = 65000; # Should be big enough + $limits{'max_temporary_tables'}= $limits{"max_tables"}; + $limits{'max_text_size'} = 9830; # Max size with default buffers. $limits{'query_size'} = 9830; # Max size with default buffers. $limits{'max_index'} = 64; # Max number of keys @@ -2448,6 +2474,8 @@ sub new $limits{'max_conditions'} = 50; # (Actually not a limit) $limits{'max_columns'} = 254; # Max number of columns in table $limits{'max_tables'} = 65000; # Should be big enough + $limits{'max_temporary_tables'}= $limits{"max_tables"}; + $limits{'max_text_size'} = 2000; # Limit for blob test-connect $limits{'query_size'} = 65525; # Max size with default buffers. $limits{'max_index'} = 16; # Max number of keys @@ -2652,6 +2680,8 @@ sub new $limits{'max_conditions'} = 418; # We get 'Query is too complex' $limits{'max_columns'} = 500; # Max number of columns in table $limits{'max_tables'} = 65000; # Should be big enough + $limits{'max_temporary_tables'}= $limits{"max_tables"}; + $limits{'max_text_size'} = 254; # Max size with default buffers. $limits{'query_size'} = 254; # Max size with default buffers. $limits{'max_index'} = 48; # Max number of keys @@ -2830,6 +2860,7 @@ sub new $limits{'max_conditions'} = 9999; # (Actually not a limit) $limits{'max_columns'} = 252; # Max number of columns in table $limits{'max_tables'} = 65000; # Should be big enough + $limits{'max_temporary_tables'}= $limits{"max_tables"}; $limits{'max_text_size'} = 15000; # Max size with default buffers. $limits{'query_size'} = 1000000; # Max size with default buffers. $limits{'max_index'} = 32; # Max number of keys @@ -3032,6 +3063,7 @@ sub new $limits{'max_conditions'} = 9999; # (Actually not a limit) $limits{'max_columns'} = 252; # Max number of columns in table $limits{'max_tables'} = 65000; # Should be big enough + $limits{'max_temporary_tables'}= $limits{"max_tables"}; $limits{'max_text_size'} = 15000; # Max size with default buffers. $limits{'query_size'} = 1000000; # Max size with default buffers. $limits{'max_index'} = 65000; # Max number of keys @@ -3228,6 +3260,7 @@ sub new # The following should be 8192, but is smaller because Frontbase crashes.. $limits{'max_columns'} = 150; # Max number of columns in table $limits{'max_tables'} = 5000; # 10000 crashed FrontBase + $limits{'max_temporary_tables'}= $limits{"max_tables"}; $limits{'max_text_size'} = 65000; # Max size with default buffers. $limits{'query_size'} = 8000000; # Max size with default buffers. $limits{'max_index'} = 38; # Max number of keys @@ -3440,6 +3473,7 @@ sub new $limits{'max_conditions'} = 9999; # (Actually not a limit) * $limits{'max_columns'} = 1023; # Max number of columns in table * $limits{'max_tables'} = 65000; # Should be big enough * unlimited actually + $limits{'max_temporary_tables'}= $limits{"max_tables"}; $limits{'max_text_size'} = 15000; # Max size with default buffers. $limits{'query_size'} = 64*1024; # Max size with default buffers. *64 kb by default. May be set by system variable $limits{'max_index'} = 510; # Max number of keys * diff --git a/sql-bench/test-connect.sh b/sql-bench/test-connect.sh index d0f3f0791a4..52566f7bb54 100644 --- a/sql-bench/test-connect.sh +++ b/sql-bench/test-connect.sh @@ -161,41 +161,48 @@ if ($opt_fast && defined($server->{vacuum})) { $server->vacuum(0,\$dbh); } -$dbh->disconnect; +if (!$main::opt_temporary_tables) +{ + $dbh->disconnect; +} # # First test connect/select/disconnect # -print "Testing connect/select 1 row from table/disconnect\n"; - -$loop_time=new Benchmark; -$errors=0; - -for ($i=0 ; $i < $small_loop_count ; $i++) +if (!$main::opt_temporary_tables) { - for ($j=0; $j < $max_test ; $j++) + print "Testing connect/select 1 row from table/disconnect\n"; + + $loop_time=new Benchmark; + $errors=0; + + for ($i=0 ; $i < $small_loop_count ; $i++) { - last if ($dbh = DBI->connect($server->{'data_source'}, $opt_user, $opt_password)); - $errors++; - } - die $DBI::errstr if ($j == $max_test); + for ($j=0; $j < $max_test ; $j++) + { + last if ($dbh = DBI->connect($server->{'data_source'}, $opt_user, $opt_password)); + $errors++; + } + die $DBI::errstr if ($j == $max_test); - $sth = $dbh->do("select a,i,s,$i from bench1") # Select * from table with 1 record + $sth = $dbh->do("select a,i,s,$i from bench1") # Select * from table with 1 record or die $DBI::errstr; - $dbh->disconnect; -} + $dbh->disconnect; + } -$end_time=new Benchmark; -print "Warning: $errors connections didn't work without a time delay\n" if ($errors); -print "Time to connect+select_1_row ($small_loop_count): " . + $end_time=new Benchmark; + print "Warning: $errors connections didn't work without a time delay\n" if ($errors); + print "Time to connect+select_1_row ($small_loop_count): " . timestr(timediff($end_time, $loop_time),"all") . "\n\n"; + $dbh = $server->connect(); +} + # # The same test, but without connect/disconnect # print "Testing select 1 row from table\n"; -$dbh = $server->connect(); $loop_time=new Benchmark; for ($i=0 ; $i < $opt_loop_count ; $i++) diff --git a/sql-bench/test-create.sh b/sql-bench/test-create.sh index 40fd9c49ae8..e2a51f96fff 100644 --- a/sql-bench/test-create.sh +++ b/sql-bench/test-create.sh @@ -47,7 +47,15 @@ if ($opt_small_test) $create_loop_count/=1000; } -$max_tables=min($limits->{'max_tables'},$opt_loop_count); +if ($opt_temporary_tables) +{ + $max_tables=min($limits->{'max_tables'},$opt_loop_count); +} +else +{ + $max_tables=min($limits->{'max_tables'},$opt_loop_count); + $max_tables=400; +} if ($opt_small_test) { @@ -71,7 +79,7 @@ $dbh = $server->connect(); if ($opt_force) # If tables used in this test exist, drop 'em { print "Okay..Let's make sure that our tables don't exist yet.\n\n"; - for ($i=1 ; $i <= $max_tables ; $i++) + for ($i=1 ; $i <= max($max_tables, $create_loop_count) ; $i++) { $dbh->do("drop table bench_$i" . $server->{'drop_attr'}); } @@ -245,7 +253,7 @@ for ($i=2 ; $i <= $keys ; $i++) } $loop_time=new Benchmark; -for ($i=1 ; $i <= $opt_loop_count ; $i++) +for ($i=1 ; $i <= $create_loop_count ; $i++) { do_many($dbh,$server->create("bench_$i", \@fields, \@keys)); $dbh->do("drop table bench_$i" . $server->{'drop_attr'}) or die $DBI::errstr; From 6e0d92419e1d251854ef08dcdf901427ad81ea3e Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Thu, 11 Feb 2010 21:15:24 +0200 Subject: [PATCH 8/8] Fix for LPBug#520243: useability bug of thread pool configuration Now mysqld --help --verbose shows the value for thread-handling Fixed also that mysqld --one-thread works as expected. --- sql/mysqld.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index bf09df8a465..5eb18ddda80 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -598,6 +598,7 @@ char *mysqld_unix_port, *opt_mysql_tmpdir; const char **errmesg; /**< Error messages */ const char *myisam_recover_options_str="OFF"; const char *myisam_stats_method_str="nulls_unequal"; +const char *opt_thread_handling= thread_handling_typelib.type_names[0]; /** name of reference on left espression in rewritten IN subquery */ const char *in_left_expr_name= ""; @@ -7290,7 +7291,8 @@ The minimum value for this variable is 4096.", 1024, 0}, {"thread_handling", OPT_THREAD_HANDLING, "Define threads usage for handling queries: " - "one-thread-per-connection or no-threads", 0, 0, + "one-thread-per-connection or no-threads", + (uchar**) &opt_thread_handling, (uchar**) &opt_thread_handling, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"updatable_views_with_limit", OPT_UPDATABLE_VIEWS_WITH_LIMIT, "1 = YES = Don't issue an error message (warning only) if a VIEW without presence of a key of the underlying table is used in queries with a LIMIT clause for updating. 0 = NO = Prohibit update of a VIEW, which does not contain a key of the underlying table and the query uses a LIMIT clause (usually get from GUI tools).", @@ -8721,14 +8723,15 @@ mysqld_get_one_option(int optid, break; } case OPT_ONE_THREAD: - global_system_variables.thread_handling= - SCHEDULER_ONE_THREAD_PER_CONNECTION; + global_system_variables.thread_handling= SCHEDULER_NO_THREADS; + opt_thread_handling= thread_handling_typelib.type_names[global_system_variables.thread_handling]; break; case OPT_THREAD_HANDLING: { int id; if (!find_opt_type(argument, &thread_handling_typelib, opt->name, &id)) global_system_variables.thread_handling= id - 1; + opt_thread_handling= thread_handling_typelib.type_names[global_system_variables.thread_handling]; break; } case OPT_FT_BOOLEAN_SYNTAX: