From e99ce4fa658db655b0b2153a65dc4043bb98893f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Oct 2006 17:29:50 +0500 Subject: [PATCH 01/88] Fix for bug #22377: iNCONSISTENCY WITH null Backport. See #20910: NOT NULL column reported as NULL in SHOW FIELDS or INFORMATION_SCHEMA mysql-test/r/type_ranges.result: Fix for bug #22377: iNCONSISTENCY WITH null - results adjusted. mysql-test/r/type_timestamp.result: Fix for bug #22377: iNCONSISTENCY WITH null - results adjusted. sql/sql_show.cc: Fix for bug #22377: iNCONSISTENCY WITH null - as NULL values cannot be stored in 'timestamp not null' fields, don't make an exception for them. --- mysql-test/r/type_ranges.result | 6 +++--- mysql-test/r/type_timestamp.result | 18 +++++++++--------- sql/sql_show.cc | 11 +---------- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result index 90207f39417..2e8fa4c26b7 100644 --- a/mysql-test/r/type_ranges.result +++ b/mysql-test/r/type_ranges.result @@ -54,7 +54,7 @@ ushort smallint(5) unsigned zerofill NULL MUL 00000 # umedium mediumint(8) unsigned NULL MUL 0 # ulong int(11) unsigned NULL MUL 0 # ulonglong bigint(13) unsigned NULL MUL 0 # -time_stamp timestamp NULL YES CURRENT_TIMESTAMP # +time_stamp timestamp NULL CURRENT_TIMESTAMP # date_field date NULL YES NULL # time_field time NULL YES NULL # date_time datetime NULL YES NULL # @@ -222,7 +222,7 @@ ushort smallint(5) unsigned zerofill NULL 00000 # umedium mediumint(8) unsigned NULL MUL 0 # ulong int(11) unsigned NULL MUL 0 # ulonglong bigint(13) unsigned NULL MUL 0 # -time_stamp timestamp NULL YES CURRENT_TIMESTAMP # +time_stamp timestamp NULL CURRENT_TIMESTAMP # date_field varchar(10) latin1_swedish_ci YES NULL # time_field time NULL YES NULL # date_time datetime NULL YES NULL # @@ -248,7 +248,7 @@ ushort smallint(5) unsigned zerofill NULL 00000 # umedium mediumint(8) unsigned NULL 0 # ulong int(11) unsigned NULL 0 # ulonglong bigint(13) unsigned NULL 0 # -time_stamp timestamp NULL YES 0000-00-00 00:00:00 # +time_stamp timestamp NULL 0000-00-00 00:00:00 # date_field varchar(10) latin1_swedish_ci YES NULL # time_field time NULL YES NULL # date_time datetime NULL YES NULL # diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result index c0396e4640d..4e71d76785a 100644 --- a/mysql-test/r/type_timestamp.result +++ b/mysql-test/r/type_timestamp.result @@ -188,9 +188,9 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 show columns from t1; Field Type Null Key Default Extra -t1 timestamp YES 2003-01-01 00:00:00 +t1 timestamp 2003-01-01 00:00:00 t2 datetime YES NULL -t3 timestamp YES 0000-00-00 00:00:00 +t3 timestamp 0000-00-00 00:00:00 drop table t1; create table t1 (t1 timestamp default now(), t2 datetime, t3 timestamp); SET TIMESTAMP=1000000002; @@ -212,9 +212,9 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 show columns from t1; Field Type Null Key Default Extra -t1 timestamp YES CURRENT_TIMESTAMP +t1 timestamp CURRENT_TIMESTAMP t2 datetime YES NULL -t3 timestamp YES 0000-00-00 00:00:00 +t3 timestamp 0000-00-00 00:00:00 drop table t1; create table t1 (t1 timestamp default '2003-01-01 00:00:00' on update now(), t2 datetime); SET TIMESTAMP=1000000004; @@ -238,7 +238,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 show columns from t1; Field Type Null Key Default Extra -t1 timestamp YES 2003-01-01 00:00:00 +t1 timestamp 2003-01-01 00:00:00 t2 datetime YES NULL drop table t1; create table t1 (t1 timestamp default now() on update now(), t2 datetime); @@ -263,7 +263,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 show columns from t1; Field Type Null Key Default Extra -t1 timestamp YES CURRENT_TIMESTAMP +t1 timestamp CURRENT_TIMESTAMP t2 datetime YES NULL drop table t1; create table t1 (t1 timestamp, t2 datetime, t3 timestamp); @@ -289,9 +289,9 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 show columns from t1; Field Type Null Key Default Extra -t1 timestamp YES CURRENT_TIMESTAMP +t1 timestamp CURRENT_TIMESTAMP t2 datetime YES NULL -t3 timestamp YES 0000-00-00 00:00:00 +t3 timestamp 0000-00-00 00:00:00 drop table t1; create table t1 (t1 timestamp default current_timestamp on update current_timestamp, t2 datetime); SET TIMESTAMP=1000000009; @@ -315,7 +315,7 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 show columns from t1; Field Type Null Key Default Extra -t1 timestamp YES CURRENT_TIMESTAMP +t1 timestamp CURRENT_TIMESTAMP t2 datetime YES NULL delete from t1; insert into t1 values ('2004-04-01 00:00:00', '2004-04-01 00:00:00'); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 41e145790e9..bd4d7c4d851 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -714,16 +714,7 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, if (verbose) protocol->store(field->has_charset() ? field->charset()->name : "NULL", system_charset_info); - /* - Even if TIMESTAMP field can't contain NULL as its value it - will accept NULL if you will try to insert such value and will - convert NULL value to current TIMESTAMP. So YES here means - that NULL is allowed for assignment (but may be won't be - returned). - */ - pos=(byte*) ((flags & NOT_NULL_FLAG) && - field->type() != FIELD_TYPE_TIMESTAMP ? - "" : "YES"); + pos= (byte*) ((flags & NOT_NULL_FLAG) ? "" : "YES"); protocol->store((const char*) pos, system_charset_info); pos=(byte*) ((field->flags & PRI_KEY_FLAG) ? "PRI" : (field->flags & UNIQUE_KEY_FLAG) ? "UNI" : From 2e758a7c23fda7fada49d0cca547680cf26cafad Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 27 Nov 2006 19:12:10 +0300 Subject: [PATCH 02/88] Fix for bug #24261 "crash when WHERE contains NOT IN ('') for unsigned column type" When calculating a SEL_TREE for the "c_{i-1} < X < c_i" interval, check if the tree returned for the "-inf < X < c_0" interval is NULL mysql-test/r/func_in.result: Added testcase for bug #24261 "crash when WHERE contains NOT IN ('') for unsigned column type" mysql-test/t/func_in.test: Added testcase for bug #24261 "crash when WHERE contains NOT IN ('') for unsigned column type" sql/opt_range.cc: When calculating a SEL_TREE for the "c_{i-1} < X < c_i" interval, check if the tree returned for the "-inf < X < c_0" interval is NULL --- mysql-test/r/func_in.result | 4 ++++ mysql-test/t/func_in.test | 7 +++++++ sql/opt_range.cc | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index e38e2624e19..60bde9555e4 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -342,4 +342,8 @@ select some_id from t1 where some_id not in(-4,-1,3423534,2342342); some_id 1 2 +select some_id from t1 where some_id not in('-1', '0'); +some_id +1 +2 drop table t1; diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index 8ddf1fbe314..0153da12b53 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -231,4 +231,11 @@ insert into t1 values (1),(2); select some_id from t1 where some_id not in(2,-1); select some_id from t1 where some_id not in(-4,-1,-4); select some_id from t1 where some_id not in(-4,-1,3423534,2342342); + +# +# BUG#24261: crash when WHERE contains NOT IN ('') for unsigned column type +# + +select some_id from t1 where some_id not in('-1', '0'); + drop table t1; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 96239315026..efef9361bda 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3703,7 +3703,8 @@ static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func, for (uint idx= 0; idx < param->keys; idx++) { SEL_ARG *new_interval, *last_val; - if (((new_interval= tree2->keys[idx])) && + if (((new_interval= tree2->keys[idx])) && + (tree->keys[idx]) && ((last_val= tree->keys[idx]->last()))) { new_interval->min_value= last_val->max_value; From 9e48e73f9a8727a1e81a8da12b7634ee47b5779a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 6 Dec 2006 19:13:00 -0500 Subject: [PATCH 03/88] Fix for Bug #20246 (enum mysql_enum_shutdown_level not well-defined in mysql_com.h) MYSQL_VERSION_ID is tested before it has been defined. This leads to a warning when compiling with -Wundef and it also will break the internal logic of mysql_com.h as soon as MYSQL_VERSION_ID exceeds 50000. The fix entailed a simple re-ordering of included files in mysql.h include/mysql.h: Fix for Bug #20246 (enum mysql_enum_shutdown_level not well-defined in mysql_com.h) MYSQL_VERSION_ID is tested before it has been defined. This leads to a warning when compiling with -Wundef and it also will break the internal logic of mysql_com.h as soon as MYSQL_VERSION_ID exceeds 50000. Placed the #include for mysql_version.h above mysql_com.h to resolve conflict --- include/mysql.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mysql.h b/include/mysql.h index 55ef6ee6d10..d0b8f57903d 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -65,9 +65,9 @@ typedef int my_socket; #endif /* my_socket_defined */ #endif /* _global_h */ +#include "mysql_version.h" #include "mysql_com.h" #include "mysql_time.h" -#include "mysql_version.h" #include "typelib.h" #include "my_list.h" /* for LISTs used in 'MYSQL' and 'MYSQL_STMT' */ From 1267a7fb3c589ab8417e71d32036a1b2410c5c03 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Dec 2006 17:01:00 +0100 Subject: [PATCH 04/88] Bug#17498 failed to put data file in custom directory use "data directory" option - Using DATA/INDEX DIRECTORY option on Windows put data/index file into default directory because the OS doesn't support readlink(). - The procedure for changing data/index file directory is different under Windows. - With this fix we report a warning if DATA/INDEX option is used, but OS doesn't support readlink(). mysql-test/r/windows.result: - updated result file. mysql-test/t/windows.test: - Added test case to verify we get warnings if we specify DATA/INDEX DIRECTORY on a platform which doesn't support readlink(). sql/sql_parse.cc: - Added warnings if DATA/INDEX DIRECTORY option is used but not supported by the target platform. --- mysql-test/r/windows.result | 6 ++++++ mysql-test/t/windows.test | 9 +++++++++ sql/sql_parse.cc | 6 ++++++ 3 files changed, 21 insertions(+) diff --git a/mysql-test/r/windows.result b/mysql-test/r/windows.result index 039c5b1476e..1702fd28c18 100644 --- a/mysql-test/r/windows.result +++ b/mysql-test/r/windows.result @@ -6,3 +6,9 @@ use prn; ERROR 42000: Unknown database 'prn' create table nu (a int); drop table nu; +drop table if exists t1; +CREATE TABLE t1 ( `ID` int(6) ) data directory 'c:/tmp/' index directory 'c:/tmp/' engine=MyISAM; +Warnings: +Warning 0 DATA DIRECTORY option ignored +Warning 0 INDEX DIRECTORY option ignored +drop table t1; diff --git a/mysql-test/t/windows.test b/mysql-test/t/windows.test index d6bcfeb8cb3..b5377a9b9b0 100644 --- a/mysql-test/t/windows.test +++ b/mysql-test/t/windows.test @@ -17,4 +17,13 @@ use prn; create table nu (a int); drop table nu; +# +# Bug17489: ailed to put data file in custom directory use "data directory" option +# +--disable_warnings +drop table if exists t1; +--enable_warnings +CREATE TABLE t1 ( `ID` int(6) ) data directory 'c:/tmp/' index directory 'c:/tmp/' engine=MyISAM; +drop table t1; + # End of 4.1 tests diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index cb2fa0f7014..9f443fae215 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2485,6 +2485,12 @@ mysql_execute_command(THD *thd) goto unsent_create_error; #ifndef HAVE_READLINK + if (lex->create_info.data_file_name) + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, + "DATA DIRECTORY option ignored"); + if (lex->create_info.index_file_name) + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, + "INDEX DIRECTORY option ignored"); lex->create_info.data_file_name=lex->create_info.index_file_name=0; #else /* Fix names if symlinked tables */ From 8b5787fa4a065219cfab8a20cd8d629afacf80b8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Dec 2006 12:53:32 -0500 Subject: [PATCH 05/88] Having MYSQL_VERSION_ID defined correctly made this KILL_QUERY enum item visible. This is a forwards-incompatible change. --- include/mysql_h.ic | 1 + 1 file changed, 1 insertion(+) diff --git a/include/mysql_h.ic b/include/mysql_h.ic index 0e546acef92..286c42500ec 100644 --- a/include/mysql_h.ic +++ b/include/mysql_h.ic @@ -575,6 +575,7 @@ enum mysql_enum_shutdown_level SHUTDOWN_WAIT_UPDATES = (unsigned char)((1 << 3)), SHUTDOWN_WAIT_ALL_BUFFERS = ((unsigned char)((1 << 3)) << 1), SHUTDOWN_WAIT_CRITICAL_BUFFERS = (((unsigned char)((1 << 3)) << 1) + 1), + KILL_QUERY = 254, KILL_CONNECTION = 255, }; # 154 "mysql.h" From 9a864bb70a6611e9f513b6df2fe4240f2433f2bf Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Dec 2006 12:13:43 +0100 Subject: [PATCH 06/88] Fix problems with "make dist" and running from "binary dist" mysql-test/Makefile.am: Add missing ($DESTDIR) wich cause "make discheck" to fail scripts/make_binary_distribution.sh: Add std_data/*.MY* files to binary dist --- mysql-test/Makefile.am | 2 +- scripts/make_binary_distribution.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 72998d786b9..341afac1c9a 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -98,7 +98,7 @@ install-data-local: $(INSTALL_DATA) $(srcdir)/std_data/Moscow_leap $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.pem $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.frm $(DESTDIR)$(testdir)/std_data - $(INSTALL_DATA) $(srcdir)/std_data/*.MY* $(distdir)/std_data + $(INSTALL_DATA) $(srcdir)/std_data/*.MY* $(DESTDIR)$(distdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.cnf $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/lib/init_db.sql $(DESTDIR)$(testdir)/lib $(INSTALL_DATA) $(srcdir)/lib/*.pl $(DESTDIR)$(testdir)/lib diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index a6a2f1e3b49..ec1c6b70bb6 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -245,7 +245,7 @@ $CP mysql-test/t/*.def $BASE/mysql-test/t $CP mysql-test/std_data/*.dat mysql-test/std_data/*.frm \ mysql-test/std_data/*.pem mysql-test/std_data/Moscow_leap \ mysql-test/std_data/des_key_file mysql-test/std_data/*.*001 \ - mysql-test/std_data/*.cnf \ + mysql-test/std_data/*.cnf mysql-test/std_data/*.MY* \ $BASE/mysql-test/std_data $CP mysql-test/t/*.test mysql-test/t/*.imtest \ mysql-test/t/*.disabled mysql-test/t/*.opt \ From ca1aebbd57a67381b1016d63f614e21af80a1d0c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Dec 2006 13:37:40 +0100 Subject: [PATCH 07/88] Backport fix for mysqladmin on windows test failure --- mysql-test/t/mysqladmin.test | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/t/mysqladmin.test b/mysql-test/t/mysqladmin.test index 7c016fd7416..850abc1ee69 100644 --- a/mysql-test/t/mysqladmin.test +++ b/mysql-test/t/mysqladmin.test @@ -15,7 +15,7 @@ database=db1 EOF ---replace_regex /\/.*mysqladmin/mysqladmin/ +--replace_regex /.*mysqladmin.*: unknown/mysqladmin: unknown/ --error 7 --exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1 @@ -27,6 +27,6 @@ EOF loose-database=db2 EOF ---replace_regex /Warning: .*mysqladmin/Warning: mysqladmin/ +--replace_regex /Warning: .*mysqladmin.*: unknown/Warning: mysqladmin: unknown/ --exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1 From 33a098bf7607db19f513d80e2391b757e9ce6536 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Dec 2006 16:08:54 +0100 Subject: [PATCH 08/88] Bug#24498 Stack overflow in mysqltest - Thanks to Vasil Dimov for the patch! client/mysqltest.c: Use my_snprintf to protect against exceeding size of buff Since variable name and valu might not be null terminated it's necessary to provide the length of the format specifiers. --- client/mysqltest.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index c6cbf6aabe0..ac186a7361e 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1240,7 +1240,9 @@ void var_set(const char *var_name, const char *var_name_end, v->int_dirty= 0; v->str_val_len= strlen(v->str_val); } - strxmov(buf, v->name, "=", v->str_val, NullS); + my_snprintf(buf, sizeof(buf), "%.*s=%.*s", + v->name_len, v->name, + v->str_val_len, v->str_val); if (!(v->env_s= my_strdup(buf, MYF(MY_WME)))) die("Out of memory"); putenv(v->env_s); From e8d82549afbb8ba46d3a65e027fbbe2c401ec17b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Dec 2006 16:43:50 +0100 Subject: [PATCH 09/88] Bug#19410 Test 'kill' fails on Windows + SCO - Use "mysql_field_count" to determine if there is a need to call "mysql_store_result" client/mysqltest.c: Only call 'mysql_store_result' if 'mysql_field_count' is greater than 0 indicating that this query has a result set. This change is mainly since if mysql_store_result fails the value returned by mysql_field_count will be reset. --- client/mysqltest.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index ac186a7361e..3d9344fb098 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -4680,10 +4680,9 @@ void run_query_normal(struct st_connection *cn, struct st_command *command, } /* - Store the result. If res is NULL, use mysql_field_count to - determine if that was expected + Store the result of the query if it will return any fields */ - if (!(res= mysql_store_result(mysql)) && mysql_field_count(mysql)) + if (mysql_field_count(mysql) && ((res= mysql_store_result(mysql)) == 0)) { handle_error(command, mysql_errno(mysql), mysql_error(mysql), mysql_sqlstate(mysql), ds); @@ -4735,7 +4734,10 @@ void run_query_normal(struct st_connection *cn, struct st_command *command, } if (res) + { mysql_free_result(res); + res= 0; + } counter++; } while (!(err= mysql_next_result(mysql))); if (err > 0) From 8fc4864ed76247b20258d5234e2d42ed34ae35c9 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Dec 2006 16:48:49 +0100 Subject: [PATCH 10/88] Add missing space --- client/mysqltest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 3d9344fb098..ad7124601ab 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -4804,7 +4804,7 @@ void handle_error(struct st_command *command, err_errno, err_error); /* Abort the run of this test, pass the failed query as reason */ - abort_not_supported_test("Query '%s' failed, required functionality" \ + abort_not_supported_test("Query '%s' failed, required functionality " \ "not supported", command->query); } From 0abeff727d7033ae653cd192d48ab302f069993e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Dec 2006 17:09:07 +0100 Subject: [PATCH 11/88] Bug#19410 Test 'kill' fails on Windows + SCO mysql-test/t/kill.test: Move the connect of second connection to just before the query to be killed are sent. This introduces less variance since the connect time is not included in the delay we want between send of query and kill. --- mysql-test/t/kill.test | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test index 50c4239b45e..1cf871d5f9f 100644 --- a/mysql-test/t/kill.test +++ b/mysql-test/t/kill.test @@ -70,11 +70,14 @@ insert into t2 select id from t1; create table t3 (kill_id int); insert into t3 values(connection_id()); +connect (conn2, localhost, root,,); +connection conn2; + +connection conn1; -- disable_result_log send select id from t1 where id in (select distinct id from t2); -- enable_result_log -connect (conn2, localhost, root,,); connection conn2; select ((@id := kill_id) - kill_id) from t3; -- sleep 1 From b8151c7e44ea680f4795c7cff93d2302308bbac6 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Dec 2006 16:17:46 -0700 Subject: [PATCH 12/88] Makefile.am - test* targets are identical (as much as possible) to 5.0 & 5.1 versions - use @PERL@ ./mysql-test-run.pl, instead of depending on /usr/bin/perl location - PHONY: target includes all test targets Makefile.am: - test* targets are identical (as much as possible) to 5.0 & 5.1 versions - use @PERL@ ./mysql-test-run.pl, instead of depending on /usr/bin/perl location - PHONY: target includes all test targets --- Makefile.am | 55 +++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/Makefile.am b/Makefile.am index 36175ce55e4..70ed8fa7bfe 100644 --- a/Makefile.am +++ b/Makefile.am @@ -95,7 +95,11 @@ dist-hook: tags: support-files/build-tags -.PHONY: init-db bin-dist + +.PHONY: init-db bin-dist \ + test test-force test-full test-force-full test-force-mem \ + test-pl test-force-pl test-full-pl test-force-full-pl test-force-pl-mem \ + test-ps test-ns # Target 'test' will run the regression test suite using the built server. # @@ -105,36 +109,33 @@ tags: # will then calculate the various port numbers it needs from this, # making sure each user use different ports. -test: +test-ps: cd mysql-test ; \ - ./mysql-test-run && \ - ./mysql-test-run --ps-protocol + @PERL@ ./mysql-test-run.pl $(force) --ps-protocol + +test-ns: + cd mysql-test ; \ + @PERL@ ./mysql-test-run.pl $(force) + +test: test-ns test-ps + +# To ease script-writing, although in 4.1 it is identical to 'test' +test-full: test test-force: - cd mysql-test; \ - ./mysql-test-run --force && \ - ./mysql-test-run --ps-protocol --force + $(MAKE) force=--force test -test-force-mem: - cd mysql-test; \ - ./mysql-test-run --force --mem && \ - ./mysql-test-run --ps-protocol --force --mem - - -# We are testing a new Perl version of the test script -test-pl: - cd mysql-test; \ - ./mysql-test-run.pl && \ - ./mysql-test-run.pl --ps-protocol - -test-force-pl: - cd mysql-test; \ - ./mysql-test-run.pl --force && \ - ./mysql-test-run.pl --ps-protocol --force +test-force-full: + $(MAKE) force=--force test-full #used by autopush.pl to run memory based tests -test-force-pl-mem: - cd mysql-test; \ - ./mysql-test-run.pl --force --mem && \ - ./mysql-test-run.pl --ps-protocol --force --mem +test-force-mem: + $(MAKE) 'force=--force --mem' test + +# Keep these for a while +test-pl: test +test-full-pl: test-full +test-force-pl: test-force +test-force-pl-mem: test-force-mem +test-force-full-pl: test-force-full From 29ff97f8cce5b5857070982f9ee9ef46c8577488 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Dec 2006 11:25:45 +0100 Subject: [PATCH 13/88] Bug#23735 mysqlbinlog client fails when reading binlog from stdin - Windows opens stdin in text mode by default. Certain characters such as CTRL-Z are interpeted as events and the read() method will stop. CTRL-Z is the EOF marker in Windows. to get past this you have to open stdin in binary mode. Setmode() is used to set stdin in binary mode. Errors on setting this mode result in halting the function and printing an error message to stderr. client/mysqlbinlog.cc: Apply fix to 5.0 as well --- client/mysqlbinlog.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index ff4e0b5a5cf..102c665031d 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -1310,6 +1310,25 @@ static int dump_local_log_entries(const char* logname) } else // reading from stdin; { + /* + Bug fix: #23735 + Author: Chuck Bell + Description: + Windows opens stdin in text mode by default. Certain characters + such as CTRL-Z are interpeted as events and the read() method + will stop. CTRL-Z is the EOF marker in Windows. to get past this + you have to open stdin in binary mode. Setmode() is used to set + stdin in binary mode. Errors on setting this mode result in + halting the function and printing an error message to stderr. + */ +#if defined (__WIN__) || (_WIN64) + if (_setmode(fileno(stdin), O_BINARY) == -1) + { + fprintf(stderr, "Could not set binary mode on stdin.\n"); + return 1; + } +#endif + if (init_io_cache(file, fileno(stdin), 0, READ_CACHE, (my_off_t) 0, 0, MYF(MY_WME | MY_NABP | MY_DONT_CHECK_FILESIZE))) return 1; From bf6239c9aa72433fa21193bd36fef91a85df4f45 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Dec 2006 12:06:12 +0100 Subject: [PATCH 14/88] Fix merge error in mysql-test/Makefile.am mysql-test/Makefile.am: Fix merge error --- mysql-test/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 341afac1c9a..eff2ae740f5 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -98,7 +98,7 @@ install-data-local: $(INSTALL_DATA) $(srcdir)/std_data/Moscow_leap $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.pem $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.frm $(DESTDIR)$(testdir)/std_data - $(INSTALL_DATA) $(srcdir)/std_data/*.MY* $(DESTDIR)$(distdir)/std_data + $(INSTALL_DATA) $(srcdir)/std_data/*.MY* $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.cnf $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/lib/init_db.sql $(DESTDIR)$(testdir)/lib $(INSTALL_DATA) $(srcdir)/lib/*.pl $(DESTDIR)$(testdir)/lib From 0ce5985f111d631829f552d7cfec97392494f54e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Dec 2006 12:16:20 +0100 Subject: [PATCH 15/88] Pass --no-defaults to embedded server to avoid that it reads any defaults file mysql-test/mysql-test-run.pl: Pass "--no-defaults" to embedded server as "--server-arg=--no-defaults" --- mysql-test/mysql-test-run.pl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 5002f778da5..bfc5fc36b32 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3432,11 +3432,10 @@ sub mysqld_arguments ($$$$$) { if ( $glob_use_embedded_server ) { $prefix= "--server-arg="; - } else { - # We can't pass embedded server --no-defaults - mtr_add_arg($args, "--no-defaults"); } + mtr_add_arg($args, "%s--no-defaults", $prefix); + mtr_add_arg($args, "%s--console", $prefix); mtr_add_arg($args, "%s--basedir=%s", $prefix, $path_my_basedir); mtr_add_arg($args, "%s--character-sets-dir=%s", $prefix, $path_charsetsdir); From 4c40881d584eaf693e0b37267d458156824fc700 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Dec 2006 12:33:42 +0100 Subject: [PATCH 16/88] Bug#17489 failed to put data file in custom directory use "data directory" option - Updated result file to fit test case automerge. mysql-test/r/windows.result: Updated result file to fit automerge. --- mysql-test/r/windows.result | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mysql-test/r/windows.result b/mysql-test/r/windows.result index e8c3c81a44e..7472b724f47 100644 --- a/mysql-test/r/windows.result +++ b/mysql-test/r/windows.result @@ -6,6 +6,12 @@ use prn; ERROR 42000: Unknown database 'prn' create table nu (a int); drop table nu; +drop table if exists t1; +CREATE TABLE t1 ( `ID` int(6) ) data directory 'c:/tmp/' index directory 'c:/tmp/' engine=MyISAM; +Warnings: +Warning 0 DATA DIRECTORY option ignored +Warning 0 INDEX DIRECTORY option ignored +drop table t1; create procedure proc_1() install plugin my_plug soname '\\root\\some_plugin.dll'; call proc_1(); ERROR HY000: No paths allowed for shared library From 4693771f28844ec2abd3756414b42fc619baf9f6 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Dec 2006 15:39:15 +0100 Subject: [PATCH 17/88] Bug#20225 mysqltest runs in an endless loop when trying to start rpl_sys test suite - Add printout in safe_connect indicating that mysqltest is in a loop waiting for connection to mysqld. Will be printed when --verbose is passed as argument to mysqltest client/mysqltest.c: Bug#20225 mysqltest runs in an endless loop when trying to start rpl_sys test suite - Add printout in safe_connect indicating that mysqltest is in a loop waiting for connection to mysqld --- client/mysqltest.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/mysqltest.c b/client/mysqltest.c index ad7124601ab..6f0a1ba3498 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -2970,7 +2970,12 @@ void safe_connect(MYSQL* mysql, const char *name, const char *host, if ((mysql_errno(mysql) == CR_CONN_HOST_ERROR || mysql_errno(mysql) == CR_CONNECTION_ERROR) && failed_attempts < opt_max_connect_retries) + { + verbose_msg("Connect attempt %d/%d failed: %d: %s", failed_attempts, + opt_max_connect_retries, mysql_errno(mysql), + mysql_error(mysql)); my_sleep(connection_retry_sleep); + } else { if (failed_attempts > 0) From 58558f0686973d643525b0efd40304179496b18e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Dec 2006 16:43:21 +0100 Subject: [PATCH 18/88] Wait for INSERT DELAYED to finish i.e sleep in while loop until "select count" is one more. --- mysql-test/r/archive.result | 6 ++++++ mysql-test/t/archive.test | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index 3be1cdcf15a..f73a80dde65 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -11120,7 +11120,13 @@ auto fld1 companynr fld3 fld4 fld5 fld6 2 011401 37 breaking dreaded Steinberg W 3 011402 37 Romans scholastics jarring 4 011403 37 intercepted audiology tinily +SELECT COUNT(auto) FROM t2; +COUNT(auto) +1213 INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); +SELECT COUNT(auto) FROM t2; +COUNT(auto) +1214 ALTER TABLE t2 DROP COLUMN fld6; SHOW CREATE TABLE t2; Table Create Table diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index f712a770712..80533f21311 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1345,10 +1345,14 @@ SELECT * FROM t2; CHECK TABLE t2; SELECT * FROM t2; - -# Just test syntax, we will never know if the output is right or wrong -# Must be the last test +# Test INSERT DELAYED and wait until the table has one more record +SELECT COUNT(auto) FROM t2; INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); +while (`SELECT COUNT(auto)!=1214 FROM t2`) +{ + sleep 0.1; +} +SELECT COUNT(auto) FROM t2; # Adding test for alter table ALTER TABLE t2 DROP COLUMN fld6; From e7cd916e0841731ac1e3e821ec1379cd5ea7a7e2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Dec 2006 12:28:02 +0100 Subject: [PATCH 19/88] Improve error message that describes waitpid($pid) returned unexpected result --- mysql-test/lib/mtr_process.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index cf0dc0dc6f8..9cf013d4e9d 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -220,7 +220,8 @@ sub spawn_parent_impl { my $ret_pid= waitpid($pid,0); if ( $ret_pid != $pid ) { - mtr_error("$path ($pid) got lost somehow"); + mtr_error("waitpid($pid, 0) returned $ret_pid " . + "when waiting for '$path'"); } return mtr_process_exit_status($?); From 266d2ea4476ac50cc0380739712cc4cdcdac6ec4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Dec 2006 23:30:20 +0100 Subject: [PATCH 20/88] change all auto_ptr in yaSSL to mySTL since some lack reset extra/yassl/src/ssl.cpp: change all auto_ptr to mySTL since some lack reset --- extra/yassl/src/ssl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp index ec2e99adecb..aa98465069c 100644 --- a/extra/yassl/src/ssl.cpp +++ b/extra/yassl/src/ssl.cpp @@ -122,7 +122,7 @@ int read_file(SSL_CTX* ctx, const char* file, int format, CertType type) EVP_BytesToKey(info.name, "MD5", info.iv, (byte*)password, passwordSz, 1, key, iv); - STL::auto_ptr cipher; + mySTL::auto_ptr cipher; if (strncmp(info.name, "DES-CBC", 7) == 0) cipher.reset(NEW_YS DES); else if (strncmp(info.name, "DES-EDE3-CBC", 13) == 0) @@ -138,7 +138,7 @@ int read_file(SSL_CTX* ctx, const char* file, int format, CertType type) return SSL_BAD_FILE; } cipher->set_decryptKey(key, info.iv); - STL::auto_ptr newx(NEW_YS x509(x->get_length())); + mySTL::auto_ptr newx(NEW_YS x509(x->get_length())); cipher->decrypt(newx->use_buffer(), x->get_buffer(), x->get_length()); ysDelete(x); From e524063beec46de286e4ea1dc1ac1fae2e25d011 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Dec 2006 13:23:31 +0100 Subject: [PATCH 21/88] Bug#17498 failed to put data file in custom directory use "data directory" option - When this bug was corrected it changed the behavior for data/index directory in the myisam test case. - This patch moves the OS depending tests to a non-windows test file. mysql-test/r/myisam.result: moved test from myisam to symlink; new result file mysql-test/r/symlink.result: moved test from myisam to symlink; new result file mysql-test/t/myisam.test: moved test from myisam to symlink mysql-test/t/symlink.test: moved test from myisam to symlink --- mysql-test/r/myisam.result | 21 --------------------- mysql-test/r/symlink.result | 21 +++++++++++++++++++++ mysql-test/t/myisam.test | 37 ------------------------------------- mysql-test/t/symlink.test | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 05f72b22ed1..36356351601 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -797,24 +797,3 @@ a b xxxxxxxxx bbbbbb xxxxxxxxx bbbbbb DROP TABLE t1; -show create table t1; -Table Create Table -t1 CREATE TEMPORARY TABLE `t1` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TEST_DIR/var/log/' -show create table t1; -Table Create Table -t1 CREATE TEMPORARY TABLE `t1` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TEST_DIR/var/log/' -create table t1 (a int) engine=myisam select 42 a; -select * from t1; -a -9 -select * from t1; -a -99 -select * from t1; -a -42 -drop table t1; diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index f6779689133..b104ce50a56 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -102,3 +102,24 @@ t1 CREATE TABLE `t1` ( `i` int(11) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +show create table t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `a` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TEST_DIR/var/log/' +show create table t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `a` int(11) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TEST_DIR/var/log/' +create table t1 (a int) engine=myisam select 42 a; +select * from t1; +a +9 +select * from t1; +a +99 +select * from t1; +a +42 +drop table t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index a62a6487882..6254ff83a2f 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -762,41 +762,4 @@ UPDATE t1 AS ta1,t1 AS ta2 SET ta1.b='aaaaaa',ta2.b='bbbbbb'; SELECT * FROM t1; DROP TABLE t1; -# -# Bug#8706 - temporary table with data directory option fails -# -connect (session1,localhost,root,,); -connect (session2,localhost,root,,); - -connection session1; -disable_query_log; -eval create temporary table t1 (a int) engine=myisam data directory="$MYSQL_TEST_DIR/var/log" select 9 a; -enable_query_log; -# If running test suite with a non standard tmp dir, the "show create table" -# will print "DATA_DIRECTORY=". Use replace_result to mask it out ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -show create table t1; - -connection session2; -disable_query_log; -eval create temporary table t1 (a int) engine=myisam data directory="$MYSQL_TEST_DIR/var/log" select 99 a; -enable_query_log; -# If running test suite with a non standard tmp dir, the "show create table" -# will print "DATA_DIRECTORY=". Use replace_result to mask it out ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR -show create table t1; - -connection default; -create table t1 (a int) engine=myisam select 42 a; - -connection session1; -select * from t1; -disconnect session1; -connection session2; -select * from t1; -disconnect session2; -connection default; -select * from t1; -drop table t1; - # End of 4.1 tests diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test index c0c1db3d553..201a2866c4f 100644 --- a/mysql-test/t/symlink.test +++ b/mysql-test/t/symlink.test @@ -133,4 +133,41 @@ enable_query_log; show create table t1; drop table t1; +# +# Bug#8706 - temporary table with data directory option fails +# +connect (session1,localhost,root,,); +connect (session2,localhost,root,,); + +connection session1; +disable_query_log; +eval create temporary table t1 (a int) engine=myisam data directory="$MYSQL_TEST_DIR/var/log" select 9 a; +enable_query_log; +# If running test suite with a non standard tmp dir, the "show create table" +# will print "DATA_DIRECTORY=". Use replace_result to mask it out +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +show create table t1; + +connection session2; +disable_query_log; +eval create temporary table t1 (a int) engine=myisam data directory="$MYSQL_TEST_DIR/var/log" select 99 a; +enable_query_log; +# If running test suite with a non standard tmp dir, the "show create table" +# will print "DATA_DIRECTORY=". Use replace_result to mask it out +--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +show create table t1; + +connection default; +create table t1 (a int) engine=myisam select 42 a; + +connection session1; +select * from t1; +disconnect session1; +connection session2; +select * from t1; +disconnect session2; +connection default; +select * from t1; +drop table t1; + # End of 4.1 tests From e91334334e83617859c308e9a8f5f99ec34c80da Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Dec 2006 13:45:17 +0100 Subject: [PATCH 22/88] Bug#17498 failed to put data file in custom directory use "data directory" option Merged 4.1->5.0. Updated myisam.test mysql-test/r/myisam.result: updated result file mysql-test/t/myisam.test: Removing symlink specific test from myisam test --- mysql-test/r/myisam.result | 13 ------------- mysql-test/t/myisam.test | 34 ---------------------------------- 2 files changed, 47 deletions(-) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 2ea317754ec..b9e656de6be 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -1608,16 +1608,3 @@ create table t3 (c1 int) engine=myisam pack_keys=default; create table t4 (c1 int) engine=myisam pack_keys=2; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2' at line 1 drop table t1, t2, t3; -show create table t1; -show create table t1; -create table t1 (a int) engine=myisam select 42 a; -select * from t1; -a -9 -select * from t1; -a -99 -select * from t1; -a -42 -drop table t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index d785002abdd..90b71a30c27 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -969,39 +969,5 @@ create table t3 (c1 int) engine=myisam pack_keys=default; --error 1064 create table t4 (c1 int) engine=myisam pack_keys=2; drop table t1, t2, t3; -# -# Bug#8706 - temporary table with data directory option fails -# -connect (session1,localhost,root,,); -connect (session2,localhost,root,,); - -connection session1; -disable_query_log; -eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/tmp" select 9 a; -enable_query_log; -disable_result_log; -show create table t1; -enable_result_log; - -connection session2; -disable_query_log; -eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/tmp" select 99 a; -enable_query_log; -disable_result_log; -show create table t1; -enable_result_log; - -connection default; -create table t1 (a int) engine=myisam select 42 a; - -connection session1; -select * from t1; -disconnect session1; -connection session2; -select * from t1; -disconnect session2; -connection default; -select * from t1; -drop table t1; # End of 4.1 tests From 29bcffd77e32abc94600b9078f254b159a2dde8d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Dec 2006 15:23:44 +0100 Subject: [PATCH 23/88] BUG#24687 func_misc test fails on win64 - Use same precision (milliseconds) for all time functions used when calculating time for pthread_cond_timedwait - Use 'GetSystemTimeAsFileTime' for both start and curr time include/config-win.h: Move all defines for 'pthread_cond_timedwait' to my_pthread.h include/my_global.h: Move all defines for 'pthread_cond_timedwait' to my_pthread.h include/my_pthread.h: Redefine "struct timespec" to better suite the needs of 'pthread_cond_timedwait' for windows implementation Add windows specific define for set_timespec_nsec Move all defines related to pthread_cond_timed wait to same file Declare union for reading FILETIME as __int64 with correct alignment mysys/my_wincond.c: Use 'GetSystemTimeAsFileTime()' both for getting start and current time Use new members of "struct timespec" Make sure the calculated timeout value never exceeds the value passed to set_timespec/set_timespec_nsec server-tools/instance-manager/guardian.cc: Use set_timespec macro server-tools/instance-manager/instance.cc: Use set_timespec macro --- include/config-win.h | 1 - include/my_global.h | 36 +---------- include/my_pthread.h | 79 ++++++++++++++++++++--- mysys/my_wincond.c | 28 ++++++-- server-tools/instance-manager/guardian.cc | 5 +- server-tools/instance-manager/instance.cc | 5 +- 6 files changed, 96 insertions(+), 58 deletions(-) diff --git a/include/config-win.h b/include/config-win.h index 75133ddc837..3c76dee40a1 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -249,7 +249,6 @@ inline double ulonglong2double(ulonglong value) #define tell(A) _telli64(A) #endif -#define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time((time_t*)0) + (time_t) (SEC); (ABSTIME).tv_nsec=0; } #define STACK_DIRECTION -1 diff --git a/include/my_global.h b/include/my_global.h index 7c072b2fc5c..d297f6f543c 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1010,41 +1010,7 @@ typedef char bool; /* Ordinary boolean values 0 1 */ #define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */ #define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */ -#ifdef HAVE_TIMESPEC_TS_SEC -#ifndef set_timespec -#define set_timespec(ABSTIME,SEC) \ -{ \ - (ABSTIME).ts_sec=time(0) + (time_t) (SEC); \ - (ABSTIME).ts_nsec=0; \ -} -#endif /* !set_timespec */ -#ifndef set_timespec_nsec -#define set_timespec_nsec(ABSTIME,NSEC) \ -{ \ - ulonglong now= my_getsystime() + (NSEC/100); \ - (ABSTIME).ts_sec= (now / ULL(10000000)); \ - (ABSTIME).ts_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ -} -#endif /* !set_timespec_nsec */ -#else -#ifndef set_timespec -#define set_timespec(ABSTIME,SEC) \ -{\ - struct timeval tv;\ - gettimeofday(&tv,0);\ - (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\ - (ABSTIME).tv_nsec=tv.tv_usec*1000;\ -} -#endif /* !set_timespec */ -#ifndef set_timespec_nsec -#define set_timespec_nsec(ABSTIME,NSEC) \ -{\ - ulonglong now= my_getsystime() + (NSEC/100); \ - (ABSTIME).tv_sec= (time_t) (now / ULL(10000000)); \ - (ABSTIME).tv_nsec= (long) (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ -} -#endif /* !set_timespec_nsec */ -#endif /* HAVE_TIMESPEC_TS_SEC */ + /* Define-funktions for reading and storing in machine independent format diff --git a/include/my_pthread.h b/include/my_pthread.h index 300291610d3..ebba0ab32e1 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -69,14 +69,6 @@ typedef struct { #endif } pthread_cond_t; - -#ifndef OS2 -struct timespec { /* For pthread_cond_timedwait() */ - time_t tv_sec; - long tv_nsec; -}; -#endif - typedef int pthread_mutexattr_t; #define win_pthread_self my_thread_var->pthread_self #ifdef OS2 @@ -87,6 +79,34 @@ typedef void * (_Optlink *pthread_handler)(void *); typedef void * (__cdecl *pthread_handler)(void *); #endif +/* + Struct and macros to be used in combination with the + windows implementation of pthread_cond_timedwait +*/ + +/* + Declare a union to make sure FILETIME is properly aligned + so it can be used directly as a 64 bit value. The value + stored is in 100ns units. + */ + union ft64 { + FILETIME ft; + __int64 i64; + }; +struct timespec { + union ft64 start; + /* The max timeout value in millisecond for pthread_cond_timedwait */ + long timeout_msec; +}; +#define set_timespec(ABSTIME,SEC) { \ + GetSystemTimeAsFileTime(&((ABSTIME).start.ft)); \ + (ABSTIME).timeout_msec= (long)((SEC)*1000); \ +} +#define set_timespec_nsec(ABSTIME,NSEC) { \ + GetSystemTimeAsFileTime(&((ABSTIME).start.ft)); \ + (ABSTIME).timeout_msec= (long)((NSEC)/1000000); \ +} + void win_pthread_init(void); int win_pthread_setspecific(void *A,void *B,uint length); int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *); @@ -164,8 +184,6 @@ extern int pthread_mutex_destroy (pthread_mutex_t *); #define pthread_condattr_init(A) #define pthread_condattr_destroy(A) -/*Irena: compiler does not like this: */ -/*#define my_pthread_getprio(pthread_t thread_id) pthread_dummy(0) */ #define my_pthread_getprio(thread_id) pthread_dummy(0) #elif defined(HAVE_UNIXWARE7_THREADS) @@ -473,6 +491,47 @@ void my_pthread_attr_getstacksize(pthread_attr_t *attrib, size_t *size); int my_pthread_mutex_trylock(pthread_mutex_t *mutex); #endif +/* + The defines set_timespec and set_timespec_nsec should be used + for calculating an absolute time at which + pthread_cond_timedwait should timeout +*/ +#ifdef HAVE_TIMESPEC_TS_SEC +#ifndef set_timespec +#define set_timespec(ABSTIME,SEC) \ +{ \ + (ABSTIME).ts_sec=time(0) + (time_t) (SEC); \ + (ABSTIME).ts_nsec=0; \ +} +#endif /* !set_timespec */ +#ifndef set_timespec_nsec +#define set_timespec_nsec(ABSTIME,NSEC) \ +{ \ + ulonglong now= my_getsystime() + (NSEC/100); \ + (ABSTIME).ts_sec= (now / ULL(10000000)); \ + (ABSTIME).ts_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ +} +#endif /* !set_timespec_nsec */ +#else +#ifndef set_timespec +#define set_timespec(ABSTIME,SEC) \ +{\ + struct timeval tv;\ + gettimeofday(&tv,0);\ + (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\ + (ABSTIME).tv_nsec=tv.tv_usec*1000;\ +} +#endif /* !set_timespec */ +#ifndef set_timespec_nsec +#define set_timespec_nsec(ABSTIME,NSEC) \ +{\ + ulonglong now= my_getsystime() + (NSEC/100); \ + (ABSTIME).tv_sec= (time_t) (now / ULL(10000000)); \ + (ABSTIME).tv_nsec= (long) (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ +} +#endif /* !set_timespec_nsec */ +#endif /* HAVE_TIMESPEC_TS_SEC */ + /* safe_mutex adds checking to mutex for easier debugging */ #if defined(__NETWARE__) && !defined(SAFE_MUTEX_DETECT_DESTROY) diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c index 8c497e8f250..327addff2cc 100644 --- a/mysys/my_wincond.c +++ b/mysys/my_wincond.c @@ -54,14 +54,30 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, struct timespec *abstime) { - struct _timeb curtime; int result; - long timeout; - _ftime(&curtime); - timeout= ((long) (abstime->tv_sec - curtime.time)*1000L + - (long)((abstime->tv_nsec/1000) - curtime.millitm)/1000L); - if (timeout < 0) /* Some safety */ + long timeout; + union ft64 now; + + GetSystemTimeAsFileTime(&now.ft); + + /* + - subtract start time from current time(values are in 100ns units + - convert to millisec by dividing with 10000 + - subtract time since start from max timeout + */ + timeout= abstime->timeout_msec - (long)((now.i64 - abstime->start.i64) / 10000); + + /* Don't allow the timeout to be negative */ + if (timeout < 0) timeout = 0L; + + /* + Make sure the calucated time does not exceed original timeout + value which could cause "wait for ever" if system time changes + */ + if (timeout > abstime->timeout_msec) + timeout= abstime->timeout_msec; + InterlockedIncrement(&cond->waiting); LeaveCriticalSection(mutex); result=WaitForSingleObject(cond->semaphore,timeout); diff --git a/server-tools/instance-manager/guardian.cc b/server-tools/instance-manager/guardian.cc index 0a037b5b98a..9fabb1923a8 100644 --- a/server-tools/instance-manager/guardian.cc +++ b/server-tools/instance-manager/guardian.cc @@ -228,9 +228,8 @@ void Guardian_thread::run() node= node->next; } - timeout.tv_sec= time(NULL) + monitoring_interval; - timeout.tv_nsec= 0; - + set_timespec(timeout, monitoring_interval); + /* check the loop predicate before sleeping */ if (!(shutdown_requested && (!(guarded_instances)))) thread_registry.cond_timedwait(&thread_info, &COND_guardian, diff --git a/server-tools/instance-manager/instance.cc b/server-tools/instance-manager/instance.cc index daa8082ef2f..39793b9a234 100644 --- a/server-tools/instance-manager/instance.cc +++ b/server-tools/instance-manager/instance.cc @@ -476,10 +476,9 @@ int Instance::stop() waitchild= options.shutdown_delay_val; kill_instance(SIGTERM); - /* sleep on condition to wait for SIGCHLD */ - timeout.tv_sec= time(NULL) + waitchild; - timeout.tv_nsec= 0; + /* sleep on condition to wait for SIGCHLD */ + set_timespec(timeout, waitchild); if (pthread_mutex_lock(&LOCK_instance)) return ER_STOP_INSTANCE; From 5b71281467c85dc705da30f0fe4ebc094f0ff983 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Dec 2006 20:58:07 +0300 Subject: [PATCH 24/88] Fix for bug #24117 "server crash on a FETCH with a cursor on a table which is not in the table cache" Problem: When creating a temporary field for a temporary table in create_tmp_field_from_field(), a resulting field is created as an exact copy of an original one (in Field::new_field()). However, Field_enum and Field_set contain a pointer (typelib) to memory allocated in the parent table's MEM_ROOT, which under some circumstances may be deallocated later by the time a temporary table is used. Solution: Override the new_field() method for Field_enum and Field_set and create a separate copy of the typelib structure in there. include/typelib.h: Added copy_typelib() declaration mysql-test/r/sp.result: Added a testcase for bug #24117 "server crash on a FETCH with a cursor on a table which is not in the table cache" mysql-test/t/sp.test: Added a testcase for bug #24117 "server crash on a FETCH with a cursor on a table which is not in the table cache" mysys/typelib.c: Added copy_typelib() definition sql/field.cc: Create a copy of the internal 'typelib' structure when copying Field_enum of Field_set objects. sql/field.h: Override new_field method in Field_enum (and Field_set) to copy the typelib structure. --- include/typelib.h | 3 +++ mysql-test/r/sp.result | 16 +++++++++++++ mysql-test/t/sp.test | 24 ++++++++++++++++++++ mysys/typelib.c | 51 ++++++++++++++++++++++++++++++++++++++++++ sql/field.cc | 10 +++++++++ sql/field.h | 1 + 6 files changed, 105 insertions(+) diff --git a/include/typelib.h b/include/typelib.h index 4d6a90ad51e..fe19f1001d4 100644 --- a/include/typelib.h +++ b/include/typelib.h @@ -18,6 +18,8 @@ #ifndef _typelib_h #define _typelib_h +#include "my_alloc.h" + typedef struct st_typelib { /* Different types saved here */ unsigned int count; /* How many types */ const char *name; /* Name of typelib */ @@ -28,6 +30,7 @@ typedef struct st_typelib { /* Different types saved here */ extern int find_type(char *x,TYPELIB *typelib,unsigned int full_name); extern void make_type(char *to,unsigned int nr,TYPELIB *typelib); extern const char *get_type(TYPELIB *typelib,unsigned int nr); +extern TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from); extern TYPELIB sql_protocol_typelib; diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 9db4325aea2..793abb417fb 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -5708,4 +5708,20 @@ DROP TABLE bug23760, bug23760_log| DROP PROCEDURE bug23760_update_log| DROP PROCEDURE bug23760_test_row_count| DROP FUNCTION bug23760_rc_test| +DROP PROCEDURE IF EXISTS bug24117| +DROP TABLE IF EXISTS t3| +CREATE TABLE t3(c1 ENUM('abc'))| +INSERT INTO t3 VALUES('abc')| +CREATE PROCEDURE bug24117() +BEGIN +DECLARE t3c1 ENUM('abc'); +DECLARE mycursor CURSOR FOR SELECT c1 FROM t3; +OPEN mycursor; +FLUSH TABLES; +FETCH mycursor INTO t3c1; +CLOSE mycursor; +END| +CALL bug24117()| +DROP PROCEDURE bug24117| +DROP TABLE t3| drop table t1,t2; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 524ee9cf66c..95bb9f7c376 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -6662,6 +6662,30 @@ DROP PROCEDURE bug23760_update_log| DROP PROCEDURE bug23760_test_row_count| DROP FUNCTION bug23760_rc_test| +# +# BUG#24117: server crash on a FETCH with a cursor on a table which is not in +# the table cache +# + +--disable_warnings +DROP PROCEDURE IF EXISTS bug24117| +DROP TABLE IF EXISTS t3| +--enable_warnings +CREATE TABLE t3(c1 ENUM('abc'))| +INSERT INTO t3 VALUES('abc')| +CREATE PROCEDURE bug24117() +BEGIN + DECLARE t3c1 ENUM('abc'); + DECLARE mycursor CURSOR FOR SELECT c1 FROM t3; + OPEN mycursor; + FLUSH TABLES; + FETCH mycursor INTO t3c1; + CLOSE mycursor; +END| +CALL bug24117()| +DROP PROCEDURE bug24117| +DROP TABLE t3| + # # NOTE: The delimiter is `|`, and not `;`. It is changed to `;` # at the end of the file! diff --git a/mysys/typelib.c b/mysys/typelib.c index 90a093b0b32..230a2989cbd 100644 --- a/mysys/typelib.c +++ b/mysys/typelib.c @@ -119,3 +119,54 @@ const char *get_type(TYPELIB *typelib, uint nr) return(typelib->type_names[nr]); return "?"; } + + +/* + Create a copy of a specified TYPELIB structure. + + SYNOPSIS + copy_typelib() + root pointer to a MEM_ROOT object for allocations + from pointer to a source TYPELIB structure + + RETURN + pointer to the new TYPELIB structure on successful copy, or + NULL otherwise +*/ + +TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from) +{ + TYPELIB *to; + uint i; + + if (!from) + return NULL; + + if (!(to= (TYPELIB*) alloc_root(root, sizeof(TYPELIB)))) + return NULL; + + if (!(to->type_names= (const char **) + alloc_root(root, (sizeof(char *) + sizeof(int)) * (from->count + 1)))) + return NULL; + to->type_lengths= (unsigned int *)(to->type_names + from->count + 1); + to->count= from->count; + if (from->name) + { + if (!(to->name= strdup_root(root, from->name))) + return NULL; + } + else + to->name= NULL; + + for (i= 0; i < from->count; i++) + { + if (!(to->type_names[i]= strmake_root(root, from->type_names[i], + from->type_lengths[i]))) + return NULL; + to->type_lengths[i]= from->type_lengths[i]; + } + to->type_names[to->count]= NULL; + to->type_lengths[to->count]= 0; + + return to; +} diff --git a/sql/field.cc b/sql/field.cc index ec97bc92d24..684ce5602d4 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -7672,6 +7672,16 @@ void Field_enum::sql_type(String &res) const } +Field *Field_enum::new_field(MEM_ROOT *root, struct st_table *new_table, + bool keep_type) +{ + Field_enum *res= (Field_enum*) Field::new_field(root, new_table, keep_type); + if (res) + res->typelib= copy_typelib(root, typelib); + return res; +} + + /* set type. This is a string which can have a collection of different values. diff --git a/sql/field.h b/sql/field.h index b79c2bf77a8..01b05d886a8 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1277,6 +1277,7 @@ public: { flags|=ENUM_FLAG; } + Field *new_field(MEM_ROOT *root, struct st_table *new_table, bool keep_type); enum_field_types type() const { return FIELD_TYPE_STRING; } enum Item_result cmp_type () const { return INT_RESULT; } enum Item_result cast_to_int_type () const { return INT_RESULT; } From cd2cf28aa84c4ec1d9899bf7088841a8615edea1 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Dec 2006 14:54:59 -0500 Subject: [PATCH 25/88] Fix for Bug#21970. The mysql-test-run-shell.sh script was improperly evaluating an expression for setting up multiple masters. This fix adds the `expr $MASTER_MYPORT + 1` construct to the offending line in order for the expression to evaluate properly and produce 9307 instead of the string "9306+1" --- mysql-test/mysql-test-run-shell.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run-shell.sh b/mysql-test/mysql-test-run-shell.sh index 544721cf40d..92c64260112 100644 --- a/mysql-test/mysql-test-run-shell.sh +++ b/mysql-test/mysql-test-run-shell.sh @@ -1793,7 +1793,7 @@ then $MYSQLADMIN --no-defaults --socket=$MASTER_MYSOCK1 -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1 $MYSQLADMIN --no-defaults --socket=$SLAVE_MYSOCK -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1 $MYSQLADMIN --no-defaults --host=$hostname --port=$MASTER_MYPORT -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1 - $MYSQLADMIN --no-defaults --host=$hostname --port=$MASTER_MYPORT+1 -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1 + $MYSQLADMIN --no-defaults --host=$hostname --port=`expr $MASTER_MYPORT + 1` -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1 $MYSQLADMIN --no-defaults --host=$hostname --port=$SLAVE_MYPORT -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1 $MYSQLADMIN --no-defaults --host=$hostname --port=`expr $SLAVE_MYPORT + 1` -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1 sleep_until_file_deleted 0 $MASTER_MYPID From b6eaf8cb2c4471f3d492f75ad75d50042a3ca32b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Dec 2006 12:18:36 -0800 Subject: [PATCH 26/88] Change permissions on $mysql_unix_port_dir if we create it so that everyone can access it. --- scripts/mysqld_safe.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index c655910dc2c..c867d15a389 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -195,6 +195,7 @@ if [ ! -d $mysql_unix_port_dir ] then mkdir $mysql_unix_port_dir chown $user $mysql_unix_port_dir + chmod 755 $mysql_unix_port_dir fi # Use the mysqld-max binary by default if the user doesn't specify a binary From 23fbae1f1946fadbf81dc23b8a20a4af1f0e171a Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Dec 2006 21:48:08 +0100 Subject: [PATCH 27/88] Put the DBUG_DUMP inside ifdef DEBUG_DATA_PACKETS --- sql/net_serv.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sql/net_serv.cc b/sql/net_serv.cc index e84b2266e82..3037007ae35 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -597,7 +597,10 @@ net_real_write(NET *net,const char *packet,ulong len) } #endif /* HAVE_COMPRESS */ - /* DBUG_DUMP("net",packet,len); */ +#ifdef DEBUG_DATA_PACKETS + DBUG_DUMP("data",packet,len); +#endif + #ifndef NO_ALARM thr_alarm_init(&alarmed); if (net_blocking) From 33ab28e9ad4e663f4c801064ca80648cdd6e79c9 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Dec 2006 15:36:45 -0700 Subject: [PATCH 28/88] include/my_pthread.h: Fix botched merge - add struct timespec and set_timespec(), etc. include/my_pthread.h: Fix botched merge - add struct timespec and set_timespec(), etc. --- include/my_pthread.h | 71 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/include/my_pthread.h b/include/my_pthread.h index b3d84e70d6a..d44fd97c318 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -66,6 +66,34 @@ typedef int pthread_mutexattr_t; #define pthread_handler_t EXTERNC void * __cdecl typedef void * (__cdecl *pthread_handler)(void *); +/* + Struct and macros to be used in combination with the + windows implementation of pthread_cond_timedwait +*/ + +/* + Declare a union to make sure FILETIME is properly aligned + so it can be used directly as a 64 bit value. The value + stored is in 100ns units. + */ + union ft64 { + FILETIME ft; + __int64 i64; + }; +struct timespec { + union ft64 start; + /* The max timeout value in millisecond for pthread_cond_timedwait */ + long timeout_msec; +}; +#define set_timespec(ABSTIME,SEC) { \ + GetSystemTimeAsFileTime(&((ABSTIME).start.ft)); \ + (ABSTIME).timeout_msec= (long)((SEC)*1000); \ +} +#define set_timespec_nsec(ABSTIME,NSEC) { \ + GetSystemTimeAsFileTime(&((ABSTIME).start.ft)); \ + (ABSTIME).timeout_msec= (long)((NSEC)/1000000); \ +} + void win_pthread_init(void); int win_pthread_setspecific(void *A,void *B,uint length); int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *); @@ -141,8 +169,6 @@ void pthread_exit(void *a); /* was #define pthread_exit(A) ExitThread(A)*/ #define pthread_condattr_init(A) #define pthread_condattr_destroy(A) -/*Irena: compiler does not like this: */ -/*#define my_pthread_getprio(pthread_t thread_id) pthread_dummy(0) */ #define my_pthread_getprio(thread_id) pthread_dummy(0) #else /* Normal threads */ @@ -367,6 +393,47 @@ void my_pthread_attr_getstacksize(pthread_attr_t *attrib, size_t *size); int my_pthread_mutex_trylock(pthread_mutex_t *mutex); #endif +/* + The defines set_timespec and set_timespec_nsec should be used + for calculating an absolute time at which + pthread_cond_timedwait should timeout +*/ +#ifdef HAVE_TIMESPEC_TS_SEC +#ifndef set_timespec +#define set_timespec(ABSTIME,SEC) \ +{ \ + (ABSTIME).ts_sec=time(0) + (time_t) (SEC); \ + (ABSTIME).ts_nsec=0; \ +} +#endif /* !set_timespec */ +#ifndef set_timespec_nsec +#define set_timespec_nsec(ABSTIME,NSEC) \ +{ \ + ulonglong now= my_getsystime() + (NSEC/100); \ + (ABSTIME).ts_sec= (now / ULL(10000000)); \ + (ABSTIME).ts_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ +} +#endif /* !set_timespec_nsec */ +#else +#ifndef set_timespec +#define set_timespec(ABSTIME,SEC) \ +{\ + struct timeval tv;\ + gettimeofday(&tv,0);\ + (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\ + (ABSTIME).tv_nsec=tv.tv_usec*1000;\ +} +#endif /* !set_timespec */ +#ifndef set_timespec_nsec +#define set_timespec_nsec(ABSTIME,NSEC) \ +{\ + ulonglong now= my_getsystime() + (NSEC/100); \ + (ABSTIME).tv_sec= (time_t) (now / ULL(10000000)); \ + (ABSTIME).tv_nsec= (long) (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ +} +#endif /* !set_timespec_nsec */ +#endif /* HAVE_TIMESPEC_TS_SEC */ + /* safe_mutex adds checking to mutex for easier debugging */ #if defined(__NETWARE__) && !defined(SAFE_MUTEX_DETECT_DESTROY) From eb3b8c3cb7857cf174cf2983997fa59034223d42 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 00:09:56 +0100 Subject: [PATCH 29/88] Add support for loading example plugin and add plugin.test mysql-test/r/have_dynamic_loading.require: Rename: mysql-test/r/have_udf.require -> mysql-test/r/have_dynamic_loading.require mysql-test/include/have_udf.inc: Rename have_udf.require to hqave_dynamic_loading.require mysql-test/mysql-test-run.pl: Add support for ha_example plugin mysql-test/include/have_example_plugin.inc: New BitKeeper file ``mysql-test/include/have_example_plugin.inc'' mysql-test/r/have_example_plugin.require: New BitKeeper file ``mysql-test/r/have_example_plugin.require'' mysql-test/r/plugin.result: New BitKeeper file ``mysql-test/r/plugin.result'' mysql-test/t/plugin.test: New BitKeeper file ``mysql-test/t/plugin.test'' --- mysql-test/include/have_example_plugin.inc | 16 ++++++++++ mysql-test/include/have_udf.inc | 2 +- mysql-test/mysql-test-run.pl | 30 +++++++++++++++---- ...f.require => have_dynamic_loading.require} | 0 mysql-test/r/have_example_plugin.require | 2 ++ mysql-test/r/plugin.result | 15 ++++++++++ mysql-test/t/plugin.test | 26 ++++++++++++++++ 7 files changed, 85 insertions(+), 6 deletions(-) create mode 100644 mysql-test/include/have_example_plugin.inc rename mysql-test/r/{have_udf.require => have_dynamic_loading.require} (100%) create mode 100644 mysql-test/r/have_example_plugin.require create mode 100644 mysql-test/r/plugin.result create mode 100644 mysql-test/t/plugin.test diff --git a/mysql-test/include/have_example_plugin.inc b/mysql-test/include/have_example_plugin.inc new file mode 100644 index 00000000000..b84f6d2f161 --- /dev/null +++ b/mysql-test/include/have_example_plugin.inc @@ -0,0 +1,16 @@ +# +# Check if server has support for loading udf's +# i.e it will support dlopen +# +--require r/have_dynamic_loading.require +disable_query_log; +show variables like "have_dynamic_loading"; +enable_query_log; + +# +# Check if the variable EXAMPLE_PLUGIN is set +# +--require r/have_example_plugin.require +disable_query_log; +eval select LENGTH("$EXAMPLE_PLUGIN") > 0 as "have_example_plugin"; +enable_query_log; diff --git a/mysql-test/include/have_udf.inc b/mysql-test/include/have_udf.inc index 42b9942f74d..068ce9026e0 100644 --- a/mysql-test/include/have_udf.inc +++ b/mysql-test/include/have_udf.inc @@ -2,7 +2,7 @@ # Check if server has support for loading udf's # i.e it will support dlopen # ---require r/have_udf.require +--require r/have_dynamic_loading.require disable_query_log; show variables like "have_dynamic_loading"; enable_query_log; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index c8ed0ecb6fb..0c5c0f2b3fa 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -159,6 +159,7 @@ our $exe_im; our $exe_my_print_defaults; our $exe_perror; our $lib_udf_example; +our $lib_example_plugin; our $exe_libtool; our $opt_bench= 0; @@ -1493,6 +1494,11 @@ sub executable_setup () { mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'), "$glob_basedir/sql/.libs/udf_example.so",); + # Look for the ha_example library + $lib_example_plugin= + mtr_file_exists(vs_config_dirs('storage/example', 'ha_example.dll'), + "$glob_basedir/storage/example/.libs/ha_example.so",); + # Look for mysqltest executable if ( $glob_use_embedded_server ) { @@ -1648,6 +1654,14 @@ sub environment_setup () { push(@ld_library_paths, dirname($lib_udf_example)); } + # -------------------------------------------------------------------------- + # Add the path where mysqld will find ha_example.so + # -------------------------------------------------------------------------- + if ( $lib_example_plugin ) + { + push(@ld_library_paths, dirname($lib_example_plugin)); + } + # -------------------------------------------------------------------------- # Valgrind need to be run with debug libraries otherwise it's almost # impossible to add correct supressions, that means if "/usr/lib/debug" @@ -1922,10 +1936,11 @@ sub environment_setup () { $ENV{'UDF_EXAMPLE_LIB'}= ($lib_udf_example ? basename($lib_udf_example) : ""); - $ENV{'LD_LIBRARY_PATH'}= - ($lib_udf_example ? dirname($lib_udf_example) : "") . - ($ENV{'LD_LIBRARY_PATH'} ? ":$ENV{'LD_LIBRARY_PATH'}" : ""); - + # ---------------------------------------------------- + # Add the path where mysqld will find ha_example.so + # ---------------------------------------------------- + $ENV{'EXAMPLE_PLUGIN'}= + ($lib_example_plugin ? basename($lib_example_plugin) : ""); # ---------------------------------------------------- # We are nice and report a bit about our settings @@ -3609,6 +3624,9 @@ sub mysqld_arguments ($$$$$) { # Turn on logging, will be sent to tables mtr_add_arg($args, "%s--log=", $prefix); } + + mtr_add_arg($args, "%s--plugin_dir=%s", $prefix, + dirname($lib_example_plugin)); } if ( $type eq 'slave' ) @@ -4480,7 +4498,9 @@ sub run_mysqltest ($) { } else # component_id == mysqld { - mtr_add_arg($args, "--socket=%s", $master->[0]->{'path_sock'}); +# mtr_add_arg($args, "--socket=%s", $master->[0]->{'path_sock'}); +mtr_add_arg($args, "--host=127.0.0.1"); + mtr_add_arg($args, "--port=%d", $master->[0]->{'port'}); mtr_add_arg($args, "--database=test"); mtr_add_arg($args, "--user=%s", $opt_user); diff --git a/mysql-test/r/have_udf.require b/mysql-test/r/have_dynamic_loading.require similarity index 100% rename from mysql-test/r/have_udf.require rename to mysql-test/r/have_dynamic_loading.require diff --git a/mysql-test/r/have_example_plugin.require b/mysql-test/r/have_example_plugin.require new file mode 100644 index 00000000000..291b8231cbb --- /dev/null +++ b/mysql-test/r/have_example_plugin.require @@ -0,0 +1,2 @@ +have_example_plugin +1 diff --git a/mysql-test/r/plugin.result b/mysql-test/r/plugin.result new file mode 100644 index 00000000000..44641858fca --- /dev/null +++ b/mysql-test/r/plugin.result @@ -0,0 +1,15 @@ +CREATE TABLE t1(a int) ENGINE=EXAMPLE; +Warnings: +Error 1286 Unknown table engine 'EXAMPLE' +DROP TABLE t1; +INSTALL PLUGIN example SONAME 'ha_example.so'; +INSTALL PLUGIN EXAMPLE SONAME 'ha_example.so'; +ERROR HY000: Function 'EXAMPLE' already exists +UNINSTALL PLUGIN example; +INSTALL PLUGIN example SONAME 'ha_example.so'; +CREATE TABLE t1(a int) ENGINE=EXAMPLE; +SELECT * FROM t1; +a +DROP TABLE t1; +UNINSTALL PLUGIN non_exist; +ERROR 42000: PLUGIN non_exist does not exist diff --git a/mysql-test/t/plugin.test b/mysql-test/t/plugin.test new file mode 100644 index 00000000000..80c1de00b8e --- /dev/null +++ b/mysql-test/t/plugin.test @@ -0,0 +1,26 @@ +--source include/have_example_plugin.inc + +CREATE TABLE t1(a int) ENGINE=EXAMPLE; +DROP TABLE t1; + +INSTALL PLUGIN example SONAME 'ha_example.so'; +--error 1125 +INSTALL PLUGIN EXAMPLE SONAME 'ha_example.so'; + +UNINSTALL PLUGIN example; + +INSTALL PLUGIN example SONAME 'ha_example.so'; + +CREATE TABLE t1(a int) ENGINE=EXAMPLE; + +# Let's do some advanced ops with the example engine :) +SELECT * FROM t1; + +DROP TABLE t1; + +# Waiting for fix to BUG#22694 +#UNINSTALL PLUGIN example; +#UNINSTALL PLUGIN EXAMPLE; + +--error 1305 +UNINSTALL PLUGIN non_exist; From a6f4c958cae1f75db34f371a4939d94d67348e98 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Dec 2006 16:23:54 -0700 Subject: [PATCH 30/88] myisam.result: a test was moved from the .test file, but the results were not updated. mysql-test/r/myisam.result: Fix results file - a test was moved from the .test file, but the results were not updated. mysql-test/r/symlink.result: echo End of 4.1 tests while I'm here mysql-test/t/myisam.test: echo End of 4.1 tests while I'm here mysql-test/t/symlink.test: echo End of 4.1 tests while I'm here --- mysql-test/r/myisam.result | 22 +--------------------- mysql-test/r/symlink.result | 1 + mysql-test/t/myisam.test | 3 ++- mysql-test/t/symlink.test | 2 +- 4 files changed, 5 insertions(+), 23 deletions(-) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index b34c127595f..0fd14b08a41 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -923,24 +923,4 @@ SET @@myisam_repair_threads=1; SHOW VARIABLES LIKE 'myisam_repair%'; Variable_name Value myisam_repair_threads 1 -show create table t1; -Table Create Table -t1 CREATE TEMPORARY TABLE `t1` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TEST_DIR/var/log/' -show create table t1; -Table Create Table -t1 CREATE TEMPORARY TABLE `t1` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TEST_DIR/var/log/' -create table t1 (a int) engine=myisam select 42 a; -select * from t1; -a -9 -select * from t1; -a -99 -select * from t1; -a -42 -drop table t1; +End of 4.1 tests diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index b104ce50a56..bc7d3275754 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -123,3 +123,4 @@ select * from t1; a 42 drop table t1; +End of 4.1 tests diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 89ace0ee838..082f9c1f844 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -854,4 +854,5 @@ DROP TABLE t1; # SET @@myisam_repair_threads=1; SHOW VARIABLES LIKE 'myisam_repair%'; -# End of 4.1 tests + +--echo End of 4.1 tests diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test index 201a2866c4f..23fd779ee13 100644 --- a/mysql-test/t/symlink.test +++ b/mysql-test/t/symlink.test @@ -170,4 +170,4 @@ connection default; select * from t1; drop table t1; -# End of 4.1 tests +--echo End of 4.1 tests From 588a8e0b87fc428b55afd3af6d3a95f789e34c55 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Dec 2006 17:47:55 -0700 Subject: [PATCH 31/88] Post-merge fix to symlink.result --- mysql-test/r/symlink.result | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index a85f14782ef..1589f98a8af 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -133,3 +133,4 @@ a 42 drop table t1; End of 4.1 tests +End of 5.0 tests From af38c456a2f82d63ca97d58eee8fc23832b75e3c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 07:56:01 +0100 Subject: [PATCH 32/88] Bug#17498 failed to put data file in custom directory use "data directory" option - Result file was not properly committed. - Update result file to match the new test case. mysql-test/r/myisam.result: Bug#17498 failed to put data file in custom directory use "data directory" option - Update result file to match the new test case. --- mysql-test/r/myisam.result | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index b34c127595f..1af927d32f0 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -923,24 +923,3 @@ SET @@myisam_repair_threads=1; SHOW VARIABLES LIKE 'myisam_repair%'; Variable_name Value myisam_repair_threads 1 -show create table t1; -Table Create Table -t1 CREATE TEMPORARY TABLE `t1` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TEST_DIR/var/log/' -show create table t1; -Table Create Table -t1 CREATE TEMPORARY TABLE `t1` ( - `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TEST_DIR/var/log/' -create table t1 (a int) engine=myisam select 42 a; -select * from t1; -a -9 -select * from t1; -a -99 -select * from t1; -a -42 -drop table t1; From eca724f45c0ec272bed53eed94616bc723391d0e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 10:41:24 +0100 Subject: [PATCH 33/88] Add macro for retrieving sec part of "struct timespec" Use macros for working with "struct timespec" in event_queue.cc Fix merge problem include/my_pthread.h: Remove merge problem causing "struct timespec" to be declared twice Add macro "get_timespec_sec" used for retrieving the time in seconds sql/event_queue.cc: Use macros for working with "struct timespec" sql/log_event.cc: Add casts from "byte*" to "char*" --- include/my_pthread.h | 12 +++++++----- sql/event_queue.cc | 9 ++++----- sql/log_event.cc | 14 +++++++------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/include/my_pthread.h b/include/my_pthread.h index d44fd97c318..98072c304fa 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -56,11 +56,6 @@ typedef struct { } pthread_cond_t; -struct timespec { /* For pthread_cond_timedwait() */ - time_t tv_sec; - long tv_nsec; -}; - typedef int pthread_mutexattr_t; #define win_pthread_self my_thread_var->pthread_self #define pthread_handler_t EXTERNC void * __cdecl @@ -93,6 +88,7 @@ struct timespec { GetSystemTimeAsFileTime(&((ABSTIME).start.ft)); \ (ABSTIME).timeout_msec= (long)((NSEC)/1000000); \ } +#define get_timespec_sec(ABSTIME) ((((ABSTIME).start.i64 / 10000) + (ABSTIME).timeout_msec ) / 1000) void win_pthread_init(void); int win_pthread_setspecific(void *A,void *B,uint length); @@ -414,6 +410,9 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex); (ABSTIME).ts_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ } #endif /* !set_timespec_nsec */ +#ifndef get_timespec_sec +#define get_timespec_sec(ABSTIME) (ABSTIME).ts_sec +#endif /* !get_timespec_sec */ #else #ifndef set_timespec #define set_timespec(ABSTIME,SEC) \ @@ -432,6 +431,9 @@ int my_pthread_mutex_trylock(pthread_mutex_t *mutex); (ABSTIME).tv_nsec= (long) (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ } #endif /* !set_timespec_nsec */ +#ifndef get_timespec_sec +#define get_timespec_sec(ABSTIME) (ABSTIME).tv_sec +#endif /* !get_timespec_sec */ #endif /* HAVE_TIMESPEC_TS_SEC */ /* safe_mutex adds checking to mutex for easier debugging */ diff --git a/sql/event_queue.cc b/sql/event_queue.cc index 7ec665fcd5f..879235c3e49 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -719,7 +719,6 @@ Event_queue::get_top_for_execution_if_time(THD *thd, Event_job_data **job_data) *job_data= NULL; DBUG_ENTER("Event_queue::get_top_for_execution_if_time"); - top_time.tv_nsec= 0; LOCK_QUEUE_DATA(); for (;;) { @@ -732,12 +731,12 @@ Event_queue::get_top_for_execution_if_time(THD *thd, Event_job_data **job_data) if (queue.elements) { top= ((Event_queue_element*) queue_element(&queue, 0)); - top_time.tv_sec= sec_since_epoch_TIME(&top->execute_at); + set_timespec(top_time, sec_since_epoch_TIME(&top->execute_at)); abstime= &top_time; } - if (!abstime || abstime->tv_sec > now) + if (!abstime || get_timespec_sec(*abstime) > now) { const char *msg; if (abstime) @@ -816,8 +815,8 @@ end: if (to_free) delete top; - DBUG_PRINT("info", ("returning %d et_new: 0x%lx abstime.tv_sec: %ld ", - ret, (long) *job_data, abstime ? abstime->tv_sec : 0)); + DBUG_PRINT("info", ("returning %d et_new: 0x%lx get_timespec_sec(abstime): %ld ", + ret, (long) *job_data, abstime ? get_timespec_sec(*abstime) : 0)); if (*job_data) DBUG_PRINT("info", ("db: %s name: %s definer=%s", (*job_data)->dbname.str, diff --git a/sql/log_event.cc b/sql/log_event.cc index 44cba324a02..8fc65c1a717 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -5558,9 +5558,9 @@ unpack_row(RELAY_LOG_INFO *rli, if (bitmap_is_set(cols, field_ptr - begin_ptr)) { - DBUG_ASSERT(table->record[0] <= f->ptr); - DBUG_ASSERT(f->ptr < (table->record[0] + table->s->reclength + - (f->pack_length_in_rec() == 0))); + DBUG_ASSERT((char*)table->record[0] <= f->ptr); + DBUG_ASSERT(f->ptr < (char*)(table->record[0] + table->s->reclength + + (f->pack_length_in_rec() == 0))); DBUG_PRINT("info", ("unpacking column '%s' to 0x%lx", f->field_name, (long) f->ptr)); @@ -6843,8 +6843,8 @@ static int find_and_fetch_row(TABLE *table, byte *key) trigger false warnings. */ #ifndef HAVE_purify - DBUG_DUMP("table->record[0]", table->record[0], table->s->reclength); - DBUG_DUMP("table->record[1]", table->record[1], table->s->reclength); + DBUG_DUMP("table->record[0]", (const char*)table->record[0], table->s->reclength); + DBUG_DUMP("table->record[1]", (const char*)table->record[1], table->s->reclength); #endif /* @@ -6870,8 +6870,8 @@ static int find_and_fetch_row(TABLE *table, byte *key) trigger false warnings. */ #ifndef HAVE_purify - DBUG_DUMP("table->record[0]", table->record[0], table->s->reclength); - DBUG_DUMP("table->record[1]", table->record[1], table->s->reclength); + DBUG_DUMP("table->record[0]", (const char*)table->record[0], table->s->reclength); + DBUG_DUMP("table->record[1]", (const char*)table->record[1], table->s->reclength); #endif /* Below is a minor "optimization". If the key (i.e., key number From 5d0798395ad6a3822a42ede47a1fcf4849833347 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 10:45:25 +0100 Subject: [PATCH 34/88] Fix VC++ warning about extra ; delimiter --- storage/federated/ha_federated.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 7330a19b791..3a15837fe65 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -2808,7 +2808,7 @@ static int federated_commit(handlerton *hton, THD *thd, bool all) if (old) old->trx_next= NULL; error= ptr->connection_commit(); - if (error && !return_val); + if (error && !return_val) return_val= error; } thd->ha_data[hton->slot]= NULL; From b34ceb8254bccf3676be83abe5417d99ba465826 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 12:54:40 +0100 Subject: [PATCH 35/88] Remove junk --- mysql-test/mysql-test-run.pl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 0c5c0f2b3fa..88de5398619 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -4498,9 +4498,7 @@ sub run_mysqltest ($) { } else # component_id == mysqld { -# mtr_add_arg($args, "--socket=%s", $master->[0]->{'path_sock'}); -mtr_add_arg($args, "--host=127.0.0.1"); - + mtr_add_arg($args, "--socket=%s", $master->[0]->{'path_sock'}); mtr_add_arg($args, "--port=%d", $master->[0]->{'port'}); mtr_add_arg($args, "--database=test"); mtr_add_arg($args, "--user=%s", $opt_user); From acecd1caf6758d2a9c2db84554043b32c1353c8b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 13:23:45 +0100 Subject: [PATCH 36/88] Bug#19209 Test 'rpl_openssl' hangs on Windows - Remove check not to run on windows. mysql-test/t/rpl_openssl.test: Remove check not to run on windows --- mysql-test/t/rpl_openssl.test | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mysql-test/t/rpl_openssl.test b/mysql-test/t/rpl_openssl.test index af70a1a9453..7d769ad448e 100644 --- a/mysql-test/t/rpl_openssl.test +++ b/mysql-test/t/rpl_openssl.test @@ -1,7 +1,3 @@ -# TODO: THIS TEST DOES NOT WORK ON WINDOWS -# This should be fixed. ---source include/not_windows.inc - source include/have_openssl.inc; source include/master-slave.inc; From a6933a63c5550c4a5061dd9d8906c9adf7d3a0da Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 15:05:50 +0100 Subject: [PATCH 37/88] Bug#24997 warnings test case failure - Move the specific test case to a separate file that is run only if we have a disabled handler. mysql-test/r/warnings.result: Move the test for warning that table type is changed to separate file as it only occurs when engine is disabled. mysql-test/t/warnings.test: Move the test for warning that table type is changed to separate file as it only occurs when engine is disabled. mysql-test/r/warnings_engine_disabled.result: Move the test for warning that table type is changed to separate file as it only occurs when engine is disabled. mysql-test/t/warnings_engine_disabled-master.opt: New BitKeeper file ``mysql-test/t/warnings_engine_disabled-master.opt'' mysql-test/t/warnings_engine_disabled.test: Move the test for warning that table type is changed to separate file as it only occurs when engine is disabled. --- mysql-test/r/warnings.result | 7 ------- mysql-test/r/warnings_engine_disabled.result | 7 +++++++ mysql-test/t/warnings.test | 6 ------ .../t/warnings_engine_disabled-master.opt | 1 + mysql-test/t/warnings_engine_disabled.test | 19 +++++++++++++++++++ 5 files changed, 27 insertions(+), 13 deletions(-) create mode 100644 mysql-test/r/warnings_engine_disabled.result create mode 100644 mysql-test/t/warnings_engine_disabled-master.opt create mode 100644 mysql-test/t/warnings_engine_disabled.test diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result index d03c5ed2f54..88341c2f0b8 100644 --- a/mysql-test/r/warnings.result +++ b/mysql-test/r/warnings.result @@ -166,13 +166,6 @@ show variables like 'max_error_count'; Variable_name Value max_error_count 10 drop table t1; -create table t1 (id int) engine=NDB; -Warnings: -Warning 1266 Using storage engine MyISAM for table 't1' -alter table t1 engine=NDB; -Warnings: -Warning 1266 Using storage engine MyISAM for table 't1' -drop table t1; set table_type=MYISAM; Warnings: Warning 1541 The syntax 'table_type' is deprecated and will be removed in MySQL 5.2. Please use 'storage_engine' instead diff --git a/mysql-test/r/warnings_engine_disabled.result b/mysql-test/r/warnings_engine_disabled.result new file mode 100644 index 00000000000..aa6170a60a7 --- /dev/null +++ b/mysql-test/r/warnings_engine_disabled.result @@ -0,0 +1,7 @@ +create table t1 (id int) engine=NDB; +Warnings: +Warning 1266 Using storage engine MyISAM for table 't1' +alter table t1 engine=NDB; +Warnings: +Warning 1266 Using storage engine MyISAM for table 't1' +drop table t1; diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test index eb5a24a8604..18ca0c96eb8 100644 --- a/mysql-test/t/warnings.test +++ b/mysql-test/t/warnings.test @@ -109,12 +109,6 @@ show variables like 'max_error_count'; set max_error_count=10; show variables like 'max_error_count'; -# -# Test for handler type -# -drop table t1; -create table t1 (id int) engine=NDB; -alter table t1 engine=NDB; drop table t1; # diff --git a/mysql-test/t/warnings_engine_disabled-master.opt b/mysql-test/t/warnings_engine_disabled-master.opt new file mode 100644 index 00000000000..99837e4a4cb --- /dev/null +++ b/mysql-test/t/warnings_engine_disabled-master.opt @@ -0,0 +1 @@ +--loose-skip-ndb diff --git a/mysql-test/t/warnings_engine_disabled.test b/mysql-test/t/warnings_engine_disabled.test new file mode 100644 index 00000000000..0b09cff7b1e --- /dev/null +++ b/mysql-test/t/warnings_engine_disabled.test @@ -0,0 +1,19 @@ +# +# Only run this test with a compiled in but disabled +# engine +# +disable_query_log; +--require r/true.require +select support = 'Disabled' as `TRUE` from information_schema.engines where engine = 'ndbcluster'; +enable_query_log; + + +# +# Test for handler type, will select MyISAM and print a warning +# about that - since NDB is disabled +# +create table t1 (id int) engine=NDB; +alter table t1 engine=NDB; +drop table t1; + + From 8cad8f9bce859f229fd63ac2a4b37dadcc01aaf5 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 17:47:20 +0100 Subject: [PATCH 38/88] Calculate offset for wait time passed to set_timespec Pass different msg if waiting on empty queue sql/event_queue.cc: Calculate offset for wait time passed to set_timespec instead of the "absolute time" from execute_at Pass different msg if waiting on empty queue --- sql/event_queue.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/event_queue.cc b/sql/event_queue.cc index 879235c3e49..53fa4f6b5cd 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -731,7 +731,8 @@ Event_queue::get_top_for_execution_if_time(THD *thd, Event_job_data **job_data) if (queue.elements) { top= ((Event_queue_element*) queue_element(&queue, 0)); - set_timespec(top_time, sec_since_epoch_TIME(&top->execute_at)); + set_timespec(top_time, + sec_since_epoch_TIME(&top->execute_at) - now); abstime= &top_time; } @@ -747,7 +748,7 @@ Event_queue::get_top_for_execution_if_time(THD *thd, Event_job_data **job_data) else { set_zero_time(&next_activation_at, MYSQL_TIMESTAMP_DATETIME); - msg= queue_wait_msg; + msg= queue_empty_msg; } cond_wait(thd, abstime, msg, SCHED_FUNC, __LINE__); From c8046801348bb981b2eeeb61910e1ea6ee526b56 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 10:57:58 -0800 Subject: [PATCH 39/88] Added support for sensible-editor from Debian, instead of emacs. --- scripts/mysqlbug.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/mysqlbug.sh b/scripts/mysqlbug.sh index 6aed140b79d..880ab248a90 100644 --- a/scripts/mysqlbug.sh +++ b/scripts/mysqlbug.sh @@ -132,7 +132,13 @@ if test -z "$VISUAL" then if test -z "$EDITOR" then - EDIT=emacs + # Honor debian sensible-editor + if test -x "/usr/bin/sensible-editor" + then + EDIT=/usr/bin/sensible-editor + else + EDIT=emacs + fi else EDIT="$EDITOR" fi From 449450804b27e42a7dc8c7927445d0c4a3d01bc3 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 12:25:09 -0800 Subject: [PATCH 40/88] Added support for /etc/mysql after /etc in the search path for my.cnf bug #25104 mysys/default.c: Added support for /etc/mysql after /etc in the search path for my.cnf --- mysys/default.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mysys/default.c b/mysys/default.c index 6e40c48d82a..1d71399ef71 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -49,6 +49,7 @@ const char *default_directories[]= { "sys:/etc/", #else "/etc/", +"/etc/mysql/", #endif #ifdef DATADIR DATADIR, From 8257db67f3836ce8fbab314c3c2b775127585e86 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 12:34:36 -0800 Subject: [PATCH 41/88] Added /etc/mysql to my.cnf search path after /etc. bug #25104 mysys/default.c: Added /etc/mysql to the search path after /etc. scripts/mysqld_multi.sh: Added /etc/mysql to the my.cnf search path. Changed chop to chomp - since it's smarter. --- mysys/default.c | 10 ++++++---- scripts/mysqld_multi.sh | 10 +++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/mysys/default.c b/mysys/default.c index d93f4135e73..a147163e938 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -979,10 +979,11 @@ static uint my_get_system_windows_directory(char *buffer, uint size) Everywhere else, this is: 1. /etc/ - 2. getenv(DEFAULT_HOME_ENV) - 3. "" - 4. "~/" - 5. --sysconfdir= + 2. /etc/mysql/ + 3. getenv(DEFAULT_HOME_ENV) + 4. "" + 5. "~/" + 6. --sysconfdir= */ @@ -1008,6 +1009,7 @@ static void init_default_directories() *ptr++= env; #endif *ptr++= "/etc/"; + *ptr++= "/etc/mysql/"; #endif if ((env= getenv(STRINGIFY_ARG(DEFAULT_HOME_ENV)))) *ptr++= env; diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 2dcc8dc7bc4..6ac31a00c75 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -472,6 +472,14 @@ sub find_groups { $data[$i] = $line; } + if (-f "/etc/mysql/my.cnf" && -r "/etc/mysql/my.cnf") + { + open(MY_CNF, ") && close(MY_CNF); + } + for (; ($line = shift @tmp); $i++) + { + $data[$i] = $line; + } if (defined($ENV{MYSQL_HOME}) && -f "$ENV{MYSQL_HOME}/my.cnf" && -r "$ENV{MYSQL_HOME}/my.cnf") { @@ -491,7 +499,7 @@ sub find_groups $data[$i] = $line; } } - chop @data; + chomp @data; # Make a list of the wanted group ids if (defined($raw_gids)) { From 3c04f839b9326a9eb3090a74128d7466af9827dd Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 16:17:10 -0800 Subject: [PATCH 42/88] support /etc/mysql/my.cnf in mysqld_multi as well. --- scripts/mysqld_multi.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/mysqld_multi.sh b/scripts/mysqld_multi.sh index 4a6f380494f..b11dc7394bf 100644 --- a/scripts/mysqld_multi.sh +++ b/scripts/mysqld_multi.sh @@ -437,6 +437,14 @@ sub find_groups { $data[$i] = $line; } + if (-f "/etc/mysql/my.cnf" && -r "/etc/mysql/my.cnf") + { + open(MY_CNF, ") && close(MY_CNF); + } + for (; ($line = shift @tmp); $i++) + { + $data[$i] = $line; + } if (-f "$homedir/.my.cnf" && -r "$homedir/.my.cnf") { open(MY_CNF, "<$homedir/.my.cnf") && (@tmp=) && close(MY_CNF); @@ -446,7 +454,7 @@ sub find_groups $data[$i] = $line; } } - chop @data; + chomp @data; # Make a list of the wanted group ids if (defined($raw_gids)) { From 9416fe5c885b451d561a32fb90d9dedb436ac29d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Dec 2006 18:04:09 -0800 Subject: [PATCH 43/88] Changed config of mysqlmanager to use my.cnf search path. --- server-tools/instance-manager/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server-tools/instance-manager/Makefile.am b/server-tools/instance-manager/Makefile.am index 2d2365caa44..59447e8d369 100644 --- a/server-tools/instance-manager/Makefile.am +++ b/server-tools/instance-manager/Makefile.am @@ -33,7 +33,7 @@ liboptions_la_CXXFLAGS= $(CXXFLAGS) \ -DDEFAULT_SOCKET_FILE_NAME="/tmp/mysqlmanager.sock" \ -DDEFAULT_PASSWORD_FILE_NAME="/etc/mysqlmanager.passwd" \ -DDEFAULT_MYSQLD_PATH="$(libexecdir)/mysqld$(EXEEXT)" \ - -DDEFAULT_CONFIG_FILE="/etc/my.cnf" \ + -DDEFAULT_CONFIG_FILE="my.cnf" \ -DPROTOCOL_VERSION=@PROTOCOL_VERSION@ liboptions_la_SOURCES= options.h options.cc priv.h priv.cc From 1aad903b710c2dc8452cfa64fcda43e5906cfa83 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Dec 2006 10:22:48 +0100 Subject: [PATCH 44/88] Use MYSQLTEST_VARDIR variable --- mysql-test/r/symlink.result | 4 ++-- mysql-test/t/symlink.test | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index 1589f98a8af..4725bcc0ac9 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -115,12 +115,12 @@ show create table t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TEST_DIR/var/log/' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/log/' show create table t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TEST_DIR/var/log/' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/log/' create table t1 (a int) engine=myisam select 42 a; select * from t1; a diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test index 7924f00a9c8..d79b6905224 100644 --- a/mysql-test/t/symlink.test +++ b/mysql-test/t/symlink.test @@ -147,20 +147,20 @@ connect (session2,localhost,root,,); connection session1; disable_query_log; -eval create temporary table t1 (a int) engine=myisam data directory="$MYSQL_TEST_DIR/var/log" select 9 a; +eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/log" select 9 a; enable_query_log; # If running test suite with a non standard tmp dir, the "show create table" # will print "DATA_DIRECTORY=". Use replace_result to mask it out ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR show create table t1; connection session2; disable_query_log; -eval create temporary table t1 (a int) engine=myisam data directory="$MYSQL_TEST_DIR/var/log" select 99 a; +eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/log" select 99 a; enable_query_log; # If running test suite with a non standard tmp dir, the "show create table" # will print "DATA_DIRECTORY=". Use replace_result to mask it out ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR show create table t1; connection default; From 43a251011cf7413c3d6728d6f447b78344259c1d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Dec 2006 11:09:47 +0100 Subject: [PATCH 45/88] Change windows pthread_cond_timedwait to use an absolute time value include/my_pthread.h: Calculate absolute time value int set_timespec_* mysys/my_wincond.c: Use absolute timevalue in pthread_cond_timedwwait --- include/my_pthread.h | 14 ++++++++------ mysys/my_wincond.c | 19 ++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/include/my_pthread.h b/include/my_pthread.h index ebba0ab32e1..631ca1d7c03 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -94,17 +94,19 @@ typedef void * (__cdecl *pthread_handler)(void *); __int64 i64; }; struct timespec { - union ft64 start; + union ft64 tv; /* The max timeout value in millisecond for pthread_cond_timedwait */ - long timeout_msec; + long max_timeout_msec; }; #define set_timespec(ABSTIME,SEC) { \ - GetSystemTimeAsFileTime(&((ABSTIME).start.ft)); \ - (ABSTIME).timeout_msec= (long)((SEC)*1000); \ + GetSystemTimeAsFileTime(&((ABSTIME).tv.ft)); \ + (ABSTIME).tv.i64+= (__int64)(SEC)*10000000; \ + (ABSTIME).max_timeout_msec= (long)((SEC)*1000); \ } #define set_timespec_nsec(ABSTIME,NSEC) { \ - GetSystemTimeAsFileTime(&((ABSTIME).start.ft)); \ - (ABSTIME).timeout_msec= (long)((NSEC)/1000000); \ + GetSystemTimeAsFileTime(&((ABSTIME).tv.ft)); \ + (ABSTIME).tv.i64+= (__int64)(NSEC)/100; \ + (ABSTIME).max_timeout_msec= (long)((NSEC)/1000000); \ } void win_pthread_init(void); diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c index 327addff2cc..b56dacc135a 100644 --- a/mysys/my_wincond.c +++ b/mysys/my_wincond.c @@ -37,7 +37,7 @@ int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) int pthread_cond_destroy(pthread_cond_t *cond) { - return CloseHandle(cond->semaphore) ? 0 : EINVAL; + return CloseHandle(cond->semaphore) ? 0 : EINVAL; } @@ -51,6 +51,7 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) return 0 ; } + int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, struct timespec *abstime) { @@ -61,26 +62,26 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, GetSystemTimeAsFileTime(&now.ft); /* - - subtract start time from current time(values are in 100ns units + Calculate time left to abstime + - subtract start time from current time(values are in 100ns units) - convert to millisec by dividing with 10000 - - subtract time since start from max timeout */ - timeout= abstime->timeout_msec - (long)((now.i64 - abstime->start.i64) / 10000); + timeout= (long)((abstime->tv.i64 - now.i64) / 10000); /* Don't allow the timeout to be negative */ if (timeout < 0) - timeout = 0L; + timeout= 0L; /* - Make sure the calucated time does not exceed original timeout + Make sure the calucated timeout does not exceed original timeout value which could cause "wait for ever" if system time changes */ - if (timeout > abstime->timeout_msec) - timeout= abstime->timeout_msec; + if (timeout > abstime->max_timeout_msec) + timeout= abstime->max_timeout_msec; InterlockedIncrement(&cond->waiting); LeaveCriticalSection(mutex); - result=WaitForSingleObject(cond->semaphore,timeout); + result= WaitForSingleObject(cond->semaphore,timeout); InterlockedDecrement(&cond->waiting); EnterCriticalSection(mutex); From b52f52224a204199fe87ddbb3f85ab3c730bff0c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Dec 2006 12:00:35 +0100 Subject: [PATCH 46/88] Reorganize the wait for event to be scheduled loop Only use "set_timespec" when there is a need to use it --- sql/event_queue.cc | 68 ++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/sql/event_queue.cc b/sql/event_queue.cc index 879235c3e49..14a6a0dfa93 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -699,10 +699,7 @@ static const char *queue_wait_msg= "Waiting for next activation"; RETURN VALUE FALSE No error. If *job_data==NULL then top not elligible for execution. - Could be that there is no top. If abstime->tv_sec is set to value - greater than zero then use abstime with pthread_cond_timedwait(). - If abstime->tv_sec is zero then sleep with pthread_cond_wait(). - abstime->tv_nsec is always zero. + Could be that there is no top. TRUE Error */ @@ -712,7 +709,6 @@ Event_queue::get_top_for_execution_if_time(THD *thd, Event_job_data **job_data) { bool ret= FALSE; struct timespec top_time; - struct timespec *abstime; Event_queue_element *top= NULL; bool to_free= FALSE; bool to_drop= FALSE; @@ -724,43 +720,40 @@ Event_queue::get_top_for_execution_if_time(THD *thd, Event_job_data **job_data) { int res; - thd->end_time(); - time_t now= thd->query_start(); - abstime= NULL; - - if (queue.elements) + /* Break loop if thd has been killed */ + if (thd->killed) { - top= ((Event_queue_element*) queue_element(&queue, 0)); - set_timespec(top_time, sec_since_epoch_TIME(&top->execute_at)); - - abstime= &top_time; + DBUG_PRINT("info", ("thd->killed=%d", thd->killed)); + goto end; } - if (!abstime || get_timespec_sec(*abstime) > now) + if (!queue.elements) { - const char *msg; - if (abstime) - { - next_activation_at= top->execute_at; - msg= queue_wait_msg; - } - else - { - set_zero_time(&next_activation_at, MYSQL_TIMESTAMP_DATETIME); - msg= queue_wait_msg; - } + /* There are no events in the queue */ + set_zero_time(&next_activation_at, MYSQL_TIMESTAMP_DATETIME); - cond_wait(thd, abstime, msg, SCHED_FUNC, __LINE__); - if (thd->killed) - { - DBUG_PRINT("info", ("thd->killed=%d", thd->killed)); - goto end; - } + /* Wait on condition until signaled. Release LOCK_queue while waiting. */ + cond_wait(thd, NULL, queue_empty_msg, SCHED_FUNC, __LINE__); + + continue; + } + + top= ((Event_queue_element*) queue_element(&queue, 0)); + + thd->end_time(); /* Get current time */ + + time_t seconds_to_next_event= + sec_since_epoch_TIME(&top->execute_at) - thd->query_start(); + next_activation_at= top->execute_at; + if (seconds_to_next_event > 0) + { /* - The queue could have been emptied. Therefore it's safe to start from - the beginning. Moreover, this way we will get also the new top, if - the element at the top has been changed. + Not yet time for top event, wait on condition with + time or until signaled. Release LOCK_queue while waiting. */ + set_timespec(top_time, seconds_to_next_event); + cond_wait(thd, &top_time, queue_wait_msg, SCHED_FUNC, __LINE__); + continue; } @@ -802,7 +795,7 @@ Event_queue::get_top_for_execution_if_time(THD *thd, Event_job_data **job_data) else queue_replaced(&queue); - dbug_dump_queue(now); + dbug_dump_queue(thd->query_start()); break; } end: @@ -815,8 +808,7 @@ end: if (to_free) delete top; - DBUG_PRINT("info", ("returning %d et_new: 0x%lx get_timespec_sec(abstime): %ld ", - ret, (long) *job_data, abstime ? get_timespec_sec(*abstime) : 0)); + DBUG_PRINT("info", ("returning %d et_new: 0x%lx ", ret, (long) *job_data)); if (*job_data) DBUG_PRINT("info", ("db: %s name: %s definer=%s", (*job_data)->dbname.str, From 9121fa507fb109866ffe7c3c5ff5ceca3447da04 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Dec 2006 14:12:19 +0100 Subject: [PATCH 47/88] Update function description for Event_queue::get_top_for_execution_if_time --- sql/event_queue.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/sql/event_queue.cc b/sql/event_queue.cc index 14a6a0dfa93..efd309e30e2 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -693,9 +693,7 @@ static const char *queue_wait_msg= "Waiting for next activation"; SYNOPSIS Event_queue::get_top_for_execution_if_time() thd [in] Thread - now [in] Current timestamp job_data [out] The object to execute - abstime [out] Time to sleep RETURN VALUE FALSE No error. If *job_data==NULL then top not elligible for execution. From f07393ab852963248823e137d6ba3199790401db Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Dec 2006 14:38:12 +0100 Subject: [PATCH 48/88] Merge fix of updated test result --- mysql-test/r/symlink.result | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index a4e010705a6..8ffe88acfa4 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -114,12 +114,12 @@ drop table t1; show create table t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( - `a` int(11) default NULL + `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/log/' show create table t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( - `a` int(11) default NULL + `a` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/log/' create table t1 (a int) engine=myisam select 42 a; select * from t1; From 76daa59fc8252afa4c374a1be725fdc4827561e7 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Dec 2006 21:12:01 -0800 Subject: [PATCH 49/88] Search through options to find where the slow query log actually is. --- scripts/mysqldumpslow.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/mysqldumpslow.sh b/scripts/mysqldumpslow.sh index ccb006f692d..ff82a35ec3f 100644 --- a/scripts/mysqldumpslow.sh +++ b/scripts/mysqldumpslow.sh @@ -40,6 +40,7 @@ unless (@ARGV) { warn "basedir=$basedir\n" if $opt{v}; my $datadir = ($defaults =~ m/--datadir=(.*)/)[0]; + my $slowlog = ($defaults =~ m/--log-slow-queries=(.*)/)[0]; if (!$datadir or $opt{i}) { # determine the datadir from the instances section of /etc/my.cnf, if any my $instances = `my_print_defaults instances`; @@ -55,8 +56,13 @@ unless (@ARGV) { warn "datadir=$datadir\n" if $opt{v}; } - @ARGV = <$datadir/$opt{h}-slow.log>; - die "Can't find '$datadir/$opt{h}-slow.log'\n" unless @ARGV; + if ( -f $slowlog ) { + @ARGV = ($slowlog); + die "Can't find '$slowlog'\n" unless @ARGV; + } else { + @ARGV = <$datadir/$opt{h}-slow.log>; + die "Can't find '$datadir/$opt{h}-slow.log'\n" unless @ARGV; + } } warn "\nReading mysql slow query log from @ARGV\n"; From 6cf0571a97b9d9381c650b96e039c0c0aba955a5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 19 Dec 2006 11:21:14 +0300 Subject: [PATCH 50/88] Added copy_typelib() declaration to make ABI compatibility test happy --- include/mysql_h.ic | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/include/mysql_h.ic b/include/mysql_h.ic index 0e546acef92..7aec1e8a627 100644 --- a/include/mysql_h.ic +++ b/include/mysql_h.ic @@ -36,6 +36,8 @@ enum mysql_status; typedef struct st_mysql_rows MYSQL_ROWS; # 24 "my_list.h" typedef struct st_list LIST; +# 35 "my_alloc.h" +typedef struct st_mem_root MEM_ROOT; # 251 "mysql.h" typedef struct st_mysql MYSQL; # 653 "mysql.h" @@ -60,7 +62,7 @@ typedef struct st_mysql_stmt MYSQL_STMT; typedef struct character_set MY_CHARSET_INFO; # 180 "mysql_com.h" typedef struct st_net NET; -# 21 "typelib.h" +# 23 "typelib.h" typedef struct st_typelib TYPELIB; # 170 "mysql_com.h" typedef struct st_vio Vio; @@ -76,8 +78,6 @@ typedef int my_socket; typedef unsigned long long int my_ulonglong; # 144 "mysql.h" typedef struct embedded_query_result EMBEDDED_QUERY_RESULT; -# 35 "my_alloc.h" -typedef struct st_mem_root MEM_ROOT; # 145 "mysql.h" typedef struct st_mysql_data MYSQL_DATA; # 750 "mysql.h" @@ -419,7 +419,7 @@ struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned my_bool report_error; my_bool return_errno; }; -# 21 "typelib.h" +# 23 "typelib.h" struct __attribute__((aligned(__alignof__(unsigned int)), aligned(__alignof__(void *)))) st_typelib { unsigned int count; @@ -630,9 +630,11 @@ enum mysql_status extern my_bool check_scramble(char const * reply, char const * message, unsigned char const * hash_stage2); # 416 "mysql_com.h" extern my_bool check_scramble_323(char const *, char const * message, unsigned long int * salt); +# 33 "typelib.h" +extern TYPELIB * copy_typelib(MEM_ROOT * root, TYPELIB * from); # 411 "mysql_com.h" extern void create_random_string(char * to, unsigned int, struct rand_struct * rand_st); -# 28 "typelib.h" +# 30 "typelib.h" extern int find_type(char * x, TYPELIB * typelib, unsigned int); # 425 "mysql_com.h" extern void get_salt_from_password(unsigned char * res, char const * password); @@ -640,7 +642,7 @@ extern void get_salt_from_password(unsigned char * res, char const * password); extern void get_salt_from_password_323(unsigned long int * res, char const * password); # 431 "mysql_com.h" extern char * get_tty_password(char * opt_message); -# 30 "typelib.h" +# 32 "typelib.h" extern char const * get_type(TYPELIB * typelib, unsigned int); # 413 "mysql_com.h" extern void hash_password(unsigned long int * to, char const * password, unsigned int); @@ -668,7 +670,7 @@ extern void make_password_from_salt_323(char * to, unsigned long int const * sal extern void make_scrambled_password(char * to, char const * password); # 414 "mysql_com.h" extern void make_scrambled_password_323(char * to, char const * password); -# 29 "typelib.h" +# 31 "typelib.h" extern void make_type(char * to, unsigned int, TYPELIB * typelib); # 437 "mysql_com.h" extern int modify_defaults_file(char const * file_location, char const * option, char const * option_value, char const * section_name, int); @@ -962,5 +964,5 @@ extern void randominit(struct rand_struct *, unsigned long int, unsigned long in extern void scramble(char * to, char const * message, char const * password); # 415 "mysql_com.h" extern void scramble_323(char * to, char const * message, char const * password); -# 32 "typelib.h" +# 35 "typelib.h" extern TYPELIB sql_protocol_typelib; From 1b879d0c2c25ae8422b9fe699efd6a09e6a0d9a5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 19 Dec 2006 12:21:41 +0300 Subject: [PATCH 51/88] Added copy_typelib() declaration to make ABI compatibility test happy --- include/mysql_h.ic | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/include/mysql_h.ic b/include/mysql_h.ic index 51cbb1fb7eb..a4149e74b56 100644 --- a/include/mysql_h.ic +++ b/include/mysql_h.ic @@ -36,6 +36,8 @@ enum mysql_status; typedef struct st_mysql_rows MYSQL_ROWS; # 24 "my_list.h" typedef struct st_list LIST; +# 35 "my_alloc.h" +typedef struct st_mem_root MEM_ROOT; # 251 "mysql.h" typedef struct st_mysql MYSQL; # 653 "mysql.h" @@ -60,7 +62,7 @@ typedef struct st_mysql_stmt MYSQL_STMT; typedef struct character_set MY_CHARSET_INFO; # 184 "mysql_com.h" typedef struct st_net NET; -# 21 "typelib.h" +# 23 "typelib.h" typedef struct st_typelib TYPELIB; # 174 "mysql_com.h" typedef struct st_vio Vio; @@ -76,8 +78,6 @@ typedef int my_socket; typedef unsigned long long int my_ulonglong; # 144 "mysql.h" typedef struct embedded_query_result EMBEDDED_QUERY_RESULT; -# 35 "my_alloc.h" -typedef struct st_mem_root MEM_ROOT; # 145 "mysql.h" typedef struct st_mysql_data MYSQL_DATA; # 750 "mysql.h" @@ -172,6 +172,7 @@ struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned struct st_mysql_methods const * methods; void * thd; my_bool * unbuffered_fetch_owner; + char * info_buffer; }; # 653 "mysql.h" struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_bind @@ -419,7 +420,7 @@ struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned my_bool report_error; my_bool return_errno; }; -# 21 "typelib.h" +# 23 "typelib.h" struct __attribute__((aligned(__alignof__(unsigned int)), aligned(__alignof__(void *)))) st_typelib { unsigned int count; @@ -631,9 +632,11 @@ enum mysql_status extern my_bool check_scramble(char const * reply, char const * message, unsigned char const * hash_stage2); # 420 "mysql_com.h" extern my_bool check_scramble_323(char const *, char const * message, unsigned long int * salt); +# 33 "typelib.h" +extern TYPELIB * copy_typelib(MEM_ROOT * root, TYPELIB * from); # 415 "mysql_com.h" extern void create_random_string(char * to, unsigned int, struct rand_struct * rand_st); -# 28 "typelib.h" +# 30 "typelib.h" extern int find_type(char * x, TYPELIB * typelib, unsigned int); # 429 "mysql_com.h" extern void get_salt_from_password(unsigned char * res, char const * password); @@ -641,7 +644,7 @@ extern void get_salt_from_password(unsigned char * res, char const * password); extern void get_salt_from_password_323(unsigned long int * res, char const * password); # 435 "mysql_com.h" extern char * get_tty_password(char const * opt_message); -# 30 "typelib.h" +# 32 "typelib.h" extern char const * get_type(TYPELIB * typelib, unsigned int); # 417 "mysql_com.h" extern void hash_password(unsigned long int * to, char const * password, unsigned int); @@ -667,7 +670,7 @@ extern void make_password_from_salt_323(char * to, unsigned long int const * sal extern void make_scrambled_password(char * to, char const * password); # 418 "mysql_com.h" extern void make_scrambled_password_323(char * to, char const * password); -# 29 "typelib.h" +# 31 "typelib.h" extern void make_type(char * to, unsigned int, TYPELIB * typelib); # 358 "mysql_com.h" extern int my_connect(my_socket, struct sockaddr const * name, unsigned int, unsigned int); @@ -957,5 +960,5 @@ extern void randominit(struct rand_struct *, unsigned long int, unsigned long in extern void scramble(char * to, char const * message, char const * password); # 419 "mysql_com.h" extern void scramble_323(char * to, char const * message, char const * password); -# 32 "typelib.h" +# 35 "typelib.h" extern TYPELIB sql_protocol_typelib; From baabcb290f9217655ee4ec8c6abd0b815e04a488 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Dec 2006 16:53:06 +0100 Subject: [PATCH 52/88] Add possibility to activate --mark-progress of mysqltest --- mysql-test/mysql-test-run.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index bfc5fc36b32..cf7e819809b 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -222,6 +222,7 @@ our $opt_ndbconnectstring_slave; our $opt_record; our $opt_report_features; our $opt_check_testcases; +our $opt_mark_progress; our $opt_skip; our $opt_skip_rpl; @@ -555,6 +556,7 @@ sub command_line_setup () { # Test case authoring 'record' => \$opt_record, 'check-testcases' => \$opt_check_testcases, + 'mark-progress' => \$opt_mark_progress, # Extra options used when starting mysqld 'mysqld=s' => \@opt_extra_mysqld_opt, @@ -4375,6 +4377,10 @@ sub run_mysqltest ($) { mtr_add_arg($args, "--tmpdir=%s", $opt_tmpdir); mtr_add_arg($args, "--character-sets-dir=%s", $path_charsetsdir); + # Log line number and time for each line in .test file + mtr_add_arg($args, "--mark-progress") + if $opt_mark_progress; + if ($tinfo->{'component_id'} eq 'im') { mtr_add_arg($args, "--socket=%s", $instance_manager->{'path_sock'}); @@ -4828,6 +4834,7 @@ Options for test case authoring record TESTNAME (Re)genereate the result file for TESTNAME check-testcases Check testcases for sideeffects + mark-progress Log line number and elapsed time to .progress Options that pass on options From 6914a6b322310bd2181b79627c8a258b382cbd2c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Dec 2006 16:54:37 +0100 Subject: [PATCH 53/88] When running with --valgrind and --debug send all the output from mysqld and valgrind to tracefile. --- mysql-test/mysql-test-run.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index cf7e819809b..a866030bdf8 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1217,6 +1217,19 @@ sub command_line_setup () { $path_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log"; $path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/"; + + if ( $opt_valgrind and $opt_debug ) + { + # When both --valgrind and --debug is selected, send + # all output to the trace file, making it possible to + # see the exact location where valgrind complains + foreach my $mysqld (@{$master}, @{$slave}) + { + my $sidx= $mysqld->{idx} ? "$mysqld->{idx}" : ""; + $mysqld->{path_myerr}= + "$opt_vardir/log/" . $mysqld->{type} . "$sidx.trace"; + } + } } sub datadir_list_setup () { From ace654d685df83db023ee4c5783ed8e7d2cd10b4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Dec 2006 23:44:53 +0100 Subject: [PATCH 54/88] Count number of masters the test is actually using and only start as many as neeeded --- mysql-test/lib/mtr_cases.pl | 7 ++----- mysql-test/mysql-test-run.pl | 26 ++++++++++++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index 9e943fec9ef..a00d06d2e60 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -288,6 +288,7 @@ sub collect_one_test_case($$$$$$$) { $tinfo->{'timezone'}= "GMT-3"; # for UNIX_TIMESTAMP tests to work $tinfo->{'slave_num'}= 0; # Default, no slave + $tinfo->{'master_num'}= 1; # Default, 1 master if ( defined mtr_match_prefix($tname,"rpl") ) { if ( $::opt_skip_rpl ) @@ -297,13 +298,8 @@ sub collect_one_test_case($$$$$$$) { return; } - $tinfo->{'slave_num'}= 1; # Default for rpl* tests, use one slave - if ( $tname eq 'rpl_failsafe' or $tname eq 'rpl_chain_temp_table' ) - { - # $tinfo->{'slave_num'}= 3; # Not 3 ? Check old code, strange - } } if ( defined mtr_match_prefix($tname,"federated") ) @@ -582,6 +578,7 @@ our @tags= ["include/have_debug.inc", "need_debug", 1], ["include/have_ndb.inc", "ndb_test", 1], ["include/have_ndb_extra.inc", "ndb_extra", 1], + ["include/have_multi_ndb.inc", "master_num", 2], ["require_manager", "require_manager", 1], ); diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index a866030bdf8..b3a7427c359 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -227,6 +227,7 @@ our $opt_mark_progress; our $opt_skip; our $opt_skip_rpl; our $max_slave_num= 0; +our $max_master_num= 0; our $use_innodb; our $opt_skip_test; our $opt_skip_im; @@ -404,6 +405,15 @@ sub main () { $max_slave_num= $test->{slave_num}; mtr_error("Too many slaves") if $max_slave_num > 3; } + + # Count max number of masters used by a test case + if ( $test->{master_num} > $max_master_num) + { + $max_master_num= $test->{master_num}; + mtr_error("Too many masters") if $max_master_num > 2; + mtr_error("Too few masters") if $max_master_num < 1; + } + $use_innodb||= $test->{'innodb_test'}; } @@ -1235,9 +1245,10 @@ sub command_line_setup () { sub datadir_list_setup () { # Make a list of all data_dirs - @data_dir_lst = ( - $master->[0]->{'path_myddir'}, - $master->[1]->{'path_myddir'}); + for (my $idx= 0; $idx < $max_master_num; $idx++) + { + push(@data_dir_lst, $master->[$idx]->{'path_myddir'}); + } for (my $idx= 0; $idx < $max_slave_num; $idx++) { @@ -2644,8 +2655,10 @@ sub mysql_install_db () { install_db('master', $master->[0]->{'path_myddir'}); - # FIXME check if testcase really is using second master - copy_install_db('master', $master->[1]->{'path_myddir'}); + if ($max_master_num) + { + copy_install_db('master', $master->[1]->{'path_myddir'}); + } # Install the number of slave databses needed for (my $idx= 0; $idx < $max_slave_num; $idx++) @@ -4179,7 +4192,8 @@ sub run_testcase_start_servers($) { } - if ( $clusters->[0]->{'pid'} and ! $master->[1]->{'pid'} ) + if ( $clusters->[0]->{'pid'} and ! $master->[1]->{'pid'} and + $tinfo->{'master_num'} > 1 ) { # Test needs cluster, start an extra mysqld connected to cluster From fd988f5b9aeb75d177544c9f525bfbac10ee1901 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Dec 2006 00:05:40 +0100 Subject: [PATCH 55/88] Bug#24148 regression tests hang with SSL enabled - Don't call SSL_shutdown a second time vio/viossl.c: SSL_shutdown might return 0 indicating that it should be called once again for a graceful shutdown. Since the socket are going to be closed anyway ther is no need for the second call. --- vio/viossl.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/vio/viossl.c b/vio/viossl.c index f436262a3ce..806f6fc356a 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -126,12 +126,16 @@ int vio_ssl_close(Vio *vio) { switch ((r= SSL_shutdown(ssl))) { - case 1: /* Shutdown successful */ + case 1: + /* Shutdown successful */ + break; + case 0: + /* + Shutdown not yet finished - since the socket is going to + be closed there is no need to call SSL_shutdown() a second + time to wait for the other side to respond + */ break; - case 0: /* Shutdown not yet finished, call it again */ - if ((r= SSL_shutdown(ssl) >= 0)) - break; - /* Fallthrough */ default: /* Shutdown failed */ DBUG_PRINT("vio_error", ("SSL_shutdown() failed, error: %d", SSL_get_error(ssl, r))); From b461c41cd3f2b6ff6a5ce757b5d708916be85959 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Dec 2006 00:38:34 +0100 Subject: [PATCH 56/88] Bug #23125 [patch] trigger test fails when run as root - Skip tests using chmod when running as root mysql-test/t/information_schema_chmod.test: Use mysqltest builtin "chmode" mysql-test/t/mysqltest.test: Dont run as root - test chmod mysql-test/t/rpl_rotate_logs.test: Use mysqltest builtin "chmode" Use 'write_file' and 'chmod' instead of system mysql-test/t/trigger.test: Don't run as root Use 'write_file' and 'chmod' mysql-test/t/varbinary.test: Don't run as root --- mysql-test/t/information_schema_chmod.test | 4 ++-- mysql-test/t/mysqltest.test | 3 +++ mysql-test/t/rpl_rotate_logs.test | 8 +++++--- mysql-test/t/trigger.test | 14 ++++++++++---- mysql-test/t/varbinary.test | 4 ++++ 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/mysql-test/t/information_schema_chmod.test b/mysql-test/t/information_schema_chmod.test index c7ea2b03890..38586ab8b67 100644 --- a/mysql-test/t/information_schema_chmod.test +++ b/mysql-test/t/information_schema_chmod.test @@ -17,7 +17,7 @@ # create database mysqltest; create table mysqltest.t1(a int); ---exec chmod -r $MYSQLTEST_VARDIR/master-data/mysqltest +chmod 0000 $MYSQLTEST_VARDIR/master-data/mysqltest; select table_schema from information_schema.tables where table_schema='mysqltest'; ---exec chmod +r $MYSQLTEST_VARDIR/master-data/mysqltest +exec chmod 0777 $MYSQLTEST_VARDIR/master-data/mysqltest; drop database mysqltest; diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index c06d51d9d49..7da84543e6d 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1,6 +1,9 @@ # This test should work in embedded server after mysqltest is fixed -- source include/not_embedded.inc +# This test uses chmod, can't be run with root permissions +-- source include/not_as_root.inc + # ============================================================================ # # Test of mysqltest itself diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test index ee49f92910a..39a810aa021 100644 --- a/mysql-test/t/rpl_rotate_logs.test +++ b/mysql-test/t/rpl_rotate_logs.test @@ -17,8 +17,10 @@ connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); drop table if exists t1, t2, t3, t4; --enable_warnings connect (slave,localhost,root,,test,$SLAVE_MYPORT,slave.sock); -system cat /dev/null > $MYSQLTEST_VARDIR/slave-data/master.info; -system chmod 000 $MYSQLTEST_VARDIR/slave-data/master.info; +# Create empty file +write_file $MYSQLTEST_VARDIR/slave-data/master.info; +EOF +chmod 0000 $MYSQLTEST_VARDIR/slave-data/master.info; connection slave; --disable_warnings drop table if exists t1, t2, t3, t4; @@ -29,7 +31,7 @@ drop table if exists t1, t2, t3, t4; --replace_result $MYSQL_TEST_DIR TESTDIR --error 1105,1105,29 start slave; -system chmod 600 $MYSQLTEST_VARDIR/slave-data/master.info; +chmod 0600 $MYSQLTEST_VARDIR/slave-data/master.info; # It will fail again because the file is empty so the slave cannot get valuable # info about how to connect to the master from it (failure in # init_strvar_from_file() in init_master_info()). diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index a9395c12a63..2bb2292e5b8 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -1,3 +1,7 @@ +# This test uses chmod, can't be run with root permissions +-- source include/not_as_root.inc + + # # Basic triggers test # @@ -1138,8 +1142,10 @@ select trigger_schema, trigger_name, event_object_schema, event_object_table, action_statement from information_schema.triggers where event_object_schema = 'test'; # Trick which makes update of second .TRN file impossible -system echo dummy >$MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~; -system chmod 000 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~; +write_file $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~; +dummy +EOF +chmod 0000 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~; --error 1 rename table t1 to t2; # 't1' should be still there and triggers should work correctly @@ -1148,8 +1154,8 @@ select @a, @b; select trigger_schema, trigger_name, event_object_schema, event_object_table, action_statement from information_schema.triggers where event_object_schema = 'test'; -system chmod 600 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~; -system rm $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~; +chmod 0600 $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~; +remove_file $MYSQLTEST_VARDIR/master-data/test/t1_ai.TRN~; # Let us check that updates to .TRN files were rolled back too drop trigger t1_bi; drop trigger t1_ai; diff --git a/mysql-test/t/varbinary.test b/mysql-test/t/varbinary.test index 0e45bfb5e1b..2f0c1c83e84 100644 --- a/mysql-test/t/varbinary.test +++ b/mysql-test/t/varbinary.test @@ -1,3 +1,7 @@ +# This test uses chmod, can't be run with root permissions +-- source include/not_as_root.inc + + # Initialise --disable_warnings drop table if exists t1; From c537bbf8ef0c242a55d3c6c961ffaf38bb269a50 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Dec 2006 09:59:41 +0100 Subject: [PATCH 57/88] Set default number of masters to 1 --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index b3a7427c359..eb4a07b1efa 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -227,7 +227,7 @@ our $opt_mark_progress; our $opt_skip; our $opt_skip_rpl; our $max_slave_num= 0; -our $max_master_num= 0; +our $max_master_num= 1; our $use_innodb; our $opt_skip_test; our $opt_skip_im; From d84b651e34f5fdb29efd2a2c4bbca7911497431c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Dec 2006 10:20:20 +0100 Subject: [PATCH 58/88] Cset exclude: msvensson@neptunus.(none)|ChangeSet|20061215122345|24188 mysql-test/t/rpl_openssl.test: Exclude --- mysql-test/t/rpl_openssl.test | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mysql-test/t/rpl_openssl.test b/mysql-test/t/rpl_openssl.test index 7d769ad448e..af70a1a9453 100644 --- a/mysql-test/t/rpl_openssl.test +++ b/mysql-test/t/rpl_openssl.test @@ -1,3 +1,7 @@ +# TODO: THIS TEST DOES NOT WORK ON WINDOWS +# This should be fixed. +--source include/not_windows.inc + source include/have_openssl.inc; source include/master-slave.inc; From 5feb49e167e9d7837caac33a64d1d3a97461e3cf Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Dec 2006 12:35:06 +0100 Subject: [PATCH 59/88] Potential use of NULL pointer in 'plugin_for_each_with_mask', check pointer before referencing it. sql/sql_plugin.cc: Make sure the plugin being refernced in the plugins array has not been set to NULL already. --- sql/sql_plugin.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 9ff88b2054a..0b203002dec 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -985,7 +985,7 @@ my_bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func, { rw_rdlock(&THR_LOCK_plugin); for (uint i=idx; i < total; i++) - if (plugins[i]->state & state_mask) + if (plugins[i] && plugins[i]->state & state_mask) plugins[i]=0; rw_unlock(&THR_LOCK_plugin); } From ee37cf0bb9fcb420227dac009324d355d19bd22e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Dec 2006 15:30:37 +0300 Subject: [PATCH 60/88] Fix for the bug #24037 "Lossy Hebrew to Unicode conversion". Added definitions for the following Hebrew characters as specified by the ISO/IEC 8859-8:1999: LEFT-TO-RIGHT MARK (LRM) RIGHT-TO-LEFT MARK (RLM) sql/share/charsets/hebrew.xml: Added definitions for the following Hebrew characters as specified by the ISO/IEC 8859-8:1999: LEFT-TO-RIGHT MARK (LRM) RIGHT-TO-LEFT MARK (RLM) strings/conf_to_src.c: Added a warning comment in the generated C source file. strings/ctype-extra.c: Re-generated from sql/share/charsets/hebrew.xml mysql-test/r/ctype_hebrew.result: Added the test case for bug #24037 "Lossy Hebrew to Unicode conversion" mysql-test/t/ctype_hebrew.test: Added the test case for bug #24037 "Lossy Hebrew to Unicode conversion" --- mysql-test/r/ctype_hebrew.result | 11 +++++++++++ mysql-test/t/ctype_hebrew.test | 16 ++++++++++++++++ sql/share/charsets/hebrew.xml | 4 ++-- strings/conf_to_src.c | 9 ++++++++- strings/ctype-extra.c | 16 ++++++++++++---- 5 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 mysql-test/r/ctype_hebrew.result create mode 100644 mysql-test/t/ctype_hebrew.test diff --git a/mysql-test/r/ctype_hebrew.result b/mysql-test/r/ctype_hebrew.result new file mode 100644 index 00000000000..d938b2e47f3 --- /dev/null +++ b/mysql-test/r/ctype_hebrew.result @@ -0,0 +1,11 @@ +DROP TABLE IF EXISTS t1; +SET NAMES hebrew; +CREATE TABLE t1 (a char(1)) DEFAULT CHARSET=hebrew; +INSERT INTO t1 VALUES (0xFD),(0xFE); +ALTER TABLE t1 CONVERT TO CHARACTER SET utf8; +SELECT HEX(a) FROM t1; +HEX(a) +E2808E +E2808F +DROP TABLE t1; +End of 4.1 tests diff --git a/mysql-test/t/ctype_hebrew.test b/mysql-test/t/ctype_hebrew.test new file mode 100644 index 00000000000..f786d05141d --- /dev/null +++ b/mysql-test/t/ctype_hebrew.test @@ -0,0 +1,16 @@ +# +# BUG #24037: Lossy Hebrew to Unicode conversion +# +# Test if LRM and RLM characters are correctly converted to UTF-8 +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +SET NAMES hebrew; +CREATE TABLE t1 (a char(1)) DEFAULT CHARSET=hebrew; +INSERT INTO t1 VALUES (0xFD),(0xFE); +ALTER TABLE t1 CONVERT TO CHARACTER SET utf8; +SELECT HEX(a) FROM t1; +DROP TABLE t1; + +--echo End of 4.1 tests diff --git a/sql/share/charsets/hebrew.xml b/sql/share/charsets/hebrew.xml index 5bcf222a728..981f308bfb5 100644 --- a/sql/share/charsets/hebrew.xml +++ b/sql/share/charsets/hebrew.xml @@ -40,7 +40,7 @@ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 - 02 02 02 02 02 02 02 02 02 02 02 00 00 00 00 00 + 02 02 02 02 02 02 02 02 02 02 02 00 00 20 20 00 @@ -106,7 +106,7 @@ 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 2017 05D0 05D1 05D2 05D3 05D4 05D5 05D6 05D7 05D8 05D9 05DA 05DB 05DC 05DD 05DE 05DF -05E0 05E1 05E2 05E3 05E4 05E5 05E6 05E7 05E8 05E9 05EA 0000 0000 0000 0000 0000 +05E0 05E1 05E2 05E3 05E4 05E5 05E6 05E7 05E8 05E9 05EA 0000 0000 200E 200F 0000 diff --git a/strings/conf_to_src.c b/strings/conf_to_src.c index 505bf154bec..b0b943df02a 100644 --- a/strings/conf_to_src.c +++ b/strings/conf_to_src.c @@ -270,7 +270,14 @@ main(int argc, char **argv __attribute__((unused))) } } - + fprintf(f, "/*\n"); + fprintf(f, " This file was generated by the conf_to_src utility. " + "Do not edit it directly,\n"); + fprintf(f, " edit the XML definitions in sql/share/charsets/ instead.\n\n"); + fprintf(f, " To re-generate, run the following in the strings/ " + "directory:\n"); + fprintf(f, " ./conf_to_src ../sql/share/charsets/ > FILE\n"); + fprintf(f, "*/\n\n"); fprintf(f,"#include \n"); fprintf(f,"#include \n\n"); diff --git a/strings/ctype-extra.c b/strings/ctype-extra.c index b680b69028c..63d33086a2e 100644 --- a/strings/ctype-extra.c +++ b/strings/ctype-extra.c @@ -1,3 +1,11 @@ +/* + This file was generated by the conf_to_src utility. Do not edit it directly, + edit the XML definitions in sql/share/charsets/ instead. + + To re-generate, run the following in the strings/ directory: + ./conf_to_src ../sql/share/charsets/ > FILE +*/ + #include #include @@ -1169,7 +1177,7 @@ uchar ctype_hebrew_general_ci[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, -0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00 +0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x20,0x20,0x00 }; uchar to_lower_hebrew_general_ci[] = { @@ -1261,7 +1269,7 @@ uint16 to_uni_hebrew_general_ci[] = { 0x05D0,0x05D1,0x05D2,0x05D3,0x05D4,0x05D5,0x05D6,0x05D7, 0x05D8,0x05D9,0x05DA,0x05DB,0x05DC,0x05DD,0x05DE,0x05DF, 0x05E0,0x05E1,0x05E2,0x05E3,0x05E4,0x05E5,0x05E6,0x05E7, -0x05E8,0x05E9,0x05EA,0x0000,0x0000,0x0000,0x0000,0x0000 +0x05E8,0x05E9,0x05EA,0x0000,0x0000,0x200E,0x200F,0x0000 }; #endif @@ -5100,7 +5108,7 @@ uchar ctype_hebrew_bin[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, -0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00,0x00,0x00 +0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x20,0x20,0x00 }; uchar to_lower_hebrew_bin[] = { @@ -5173,7 +5181,7 @@ uint16 to_uni_hebrew_bin[] = { 0x05D0,0x05D1,0x05D2,0x05D3,0x05D4,0x05D5,0x05D6,0x05D7, 0x05D8,0x05D9,0x05DA,0x05DB,0x05DC,0x05DD,0x05DE,0x05DF, 0x05E0,0x05E1,0x05E2,0x05E3,0x05E4,0x05E5,0x05E6,0x05E7, -0x05E8,0x05E9,0x05EA,0x0000,0x0000,0x0000,0x0000,0x0000 +0x05E8,0x05E9,0x05EA,0x0000,0x0000,0x200E,0x200F,0x0000 }; #endif From 0fb90c7f63ff7e5ff7f39bc622c51aecab620bd1 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Dec 2006 13:34:23 +0100 Subject: [PATCH 61/88] Wait for mysqld connected to NDB to come out of read only mode --- mysql-test/include/have_multi_ndb.inc | 4 ++++ mysql-test/include/have_ndb.inc | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/mysql-test/include/have_multi_ndb.inc b/mysql-test/include/have_multi_ndb.inc index 218a6852c41..819518b2674 100644 --- a/mysql-test/include/have_multi_ndb.inc +++ b/mysql-test/include/have_multi_ndb.inc @@ -24,5 +24,9 @@ flush tables; select support = 'Enabled' as `TRUE` from information_schema.engines where engine = 'ndbcluster'; enable_query_log; +# Check should be here as well... +# # Check that second master mysqld has come out of redonly mode +# --source include/ndb_not_readonly.inc + # Set the default connection to 'server1' connection server1; diff --git a/mysql-test/include/have_ndb.inc b/mysql-test/include/have_ndb.inc index 8cbeab07a4f..77857106488 100644 --- a/mysql-test/include/have_ndb.inc +++ b/mysql-test/include/have_ndb.inc @@ -4,4 +4,8 @@ disable_query_log; select support = 'Enabled' as `TRUE` from information_schema.engines where engine = 'ndbcluster'; enable_query_log; +# Check that master mysqld has come out of redonly mode +--source include/ndb_not_readonly.inc + + From 7d4a5869e945c11e7c9c004e490155308a4a6145 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Dec 2006 13:57:33 +0100 Subject: [PATCH 62/88] Add the missing file mysql-test/include/ndb_not_readonly.inc: New BitKeeper file ``mysql-test/include/ndb_not_readonly.inc'' --- mysql-test/include/ndb_not_readonly.inc | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 mysql-test/include/ndb_not_readonly.inc diff --git a/mysql-test/include/ndb_not_readonly.inc b/mysql-test/include/ndb_not_readonly.inc new file mode 100644 index 00000000000..df67dced8ab --- /dev/null +++ b/mysql-test/include/ndb_not_readonly.inc @@ -0,0 +1,31 @@ +# Check that server has come out ot readonly mode +--disable_query_log +let $counter= 100; +let $mysql_errno= 1; +while ($mysql_errno) +{ + --error 0, 1005 + create table check_read_only(a int) engine=NDB; + sleep 0.1; + if (!$counter) + { + die("Failed while waiting for mysqld to come out of readonly mode"); + } + dec $counter; +} + +let $counter= 100; +let $mysql_errno= 1; +while ($mysql_errno) +{ + --error 0, 1036 + insert into check_read_only values(1); + sleep 0.1; + if (!$counter) + { + die("Failed while waiting for mysqld to come out of readonly mode"); + } + dec $counter; +} +drop table check_read_only; +--enable_query_log From 82bd9b6b61f14b227f0fe9169f0a8754694d1924 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Dec 2006 15:37:37 -0500 Subject: [PATCH 63/88] Bug#22555: STDDEV yields positive result for groups with only one row When only one row was present, the subtraction of nearly the same number resulted in catastropic cancellation, introducing an error in the VARIANCE calculation near 1e-15. That was sqrt()ed to get STDDEV, the error was escallated to near 1e-8. The simple fix of testing for a row count of 1 and forcing that to yield 0.0 is insufficient, as two rows of the same value should also have a variance of 0.0, yet the error would be about the same. So, this patch changes the formula that computes the VARIANCE to be one that is not subject to catastrophic cancellation. In addition, it now uses only (faster-than-decimal) floating point numbers to calculate, and renders that to other types on demand. mysql-test/r/func_group.result: Test that the bug is fixed, and that no unexpected behavior arises from the changes. mysql-test/t/func_group.test: Test that the bug is fixed, and that no unexpected behavior arises from the changes. sql/item_sum.cc: Serg's suggestion: Force all VARIANCE calculations to be done with floating- point types. It's faster, and the SQL standard says we may implement these functions any way we want. Additionally, use a form of variance calculation that is not subject to catastrophic cancellation. http://static.flickr.com/108/311308512_5c4e1c0c3d_b.jpg sql/item_sum.h: Remove unused members and add a comment describing the recurrence relation. --- BitKeeper/etc/collapsed | 1 + mysql-test/r/func_group.result | 268 ++++++++++++++++++++++++ mysql-test/t/func_group.test | 92 +++++++++ sql/item_sum.cc | 360 +++++++++++---------------------- sql/item_sum.h | 20 +- 5 files changed, 496 insertions(+), 245 deletions(-) diff --git a/BitKeeper/etc/collapsed b/BitKeeper/etc/collapsed index ddaafba882c..837a8997495 100644 --- a/BitKeeper/etc/collapsed +++ b/BitKeeper/etc/collapsed @@ -19,3 +19,4 @@ 454f8960jsVT_kMKJtZ9OCgXoba0xQ 4554a95d7txO1DuO9G3nAizI3SkFAA 4554b3722d71SbPiI2Gx-RhbZjmuIQ +45771031yRCoM_ZfONdYchPvVEgLRg diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index c6117053a60..53ca15200da 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1029,3 +1029,271 @@ t1 CREATE TABLE `t1` ( `stddev(0)` double(8,4) default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +create table bug22555 (i smallint primary key auto_increment, s1 smallint, s2 smallint, e decimal(30,10), o double); +insert into bug22555 (s1, s2, e, o) values (53, 78, 11.4276528, 6.828112), (17, 78, 5.916793, 1.8502951), (18, 76, 2.679231, 9.17975591), (31, 62, 6.07831, 0.1), (19, 41, 5.37463, 15.1), (83, 73, 14.567426, 7.959222), (92, 53, 6.10151, 13.1856852), (7, 12, 13.92272, 3.442007), (92, 35, 11.95358909, 6.01376678), (38, 84, 2.572, 7.904571); +select std(s1/s2) from bug22555 group by i; +std(s1/s2) +0.00000000 +0.00000000 +0.00000000 +0.00000000 +0.00000000 +0.00000000 +0.00000000 +0.00000000 +0.00000000 +0.00000000 +select std(e) from bug22555 group by i; +std(e) +0.00000000000000 +0.00000000000000 +0.00000000000000 +0.00000000000000 +0.00000000000000 +0.00000000000000 +0.00000000000000 +0.00000000000000 +0.00000000000000 +0.00000000000000 +select std(o) from bug22555 group by i; +std(o) +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +drop table bug22555; +create table bug22555 (i smallint, s1 smallint, s2 smallint, o1 double, o2 double, e1 decimal, e2 decimal); +insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76); +select i, count(*) from bug22555 group by i; +i count(*) +1 1 +2 1 +3 1 +select std(s1/s2) from bug22555 where i=1; +std(s1/s2) +0.00000000 +select std(s1/s2) from bug22555 where i=2; +std(s1/s2) +0.00000000 +select std(s1/s2) from bug22555 where i=3; +std(s1/s2) +0.00000000 +select std(s1/s2) from bug22555 where i=1 group by i; +std(s1/s2) +0.00000000 +select std(s1/s2) from bug22555 where i=2 group by i; +std(s1/s2) +0.00000000 +select std(s1/s2) from bug22555 where i=3 group by i; +std(s1/s2) +0.00000000 +select std(s1/s2) from bug22555 group by i order by i; +std(s1/s2) +0.00000000 +0.00000000 +0.00000000 +select i, count(*), std(o1/o2) from bug22555 group by i order by i; +i count(*) std(o1/o2) +1 1 0 +2 1 0 +3 1 0 +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +i count(*) std(e1/e2) +1 1 0.00000000 +2 1 0.00000000 +3 1 0.00000000 +set @saved_div_precision_increment=@@div_precision_increment; +set div_precision_increment=19; +select i, count(*), variance(s1/s2) from bug22555 group by i order by i; +i count(*) variance(s1/s2) +1 1 0.000000000000000000000000000000 +2 1 0.000000000000000000000000000000 +3 1 0.000000000000000000000000000000 +select i, count(*), variance(o1/o2) from bug22555 group by i order by i; +i count(*) variance(o1/o2) +1 1 0 +2 1 0 +3 1 0 +select i, count(*), variance(e1/e2) from bug22555 group by i order by i; +i count(*) variance(e1/e2) +1 1 0.000000000000000000000000000000 +2 1 0.000000000000000000000000000000 +3 1 0.000000000000000000000000000000 +select i, count(*), std(s1/s2) from bug22555 group by i order by i; +i count(*) std(s1/s2) +1 1 0.000000000000000000000000000000 +2 1 0.000000000000000000000000000000 +3 1 0.000000000000000000000000000000 +select i, count(*), std(o1/o2) from bug22555 group by i order by i; +i count(*) std(o1/o2) +1 1 0 +2 1 0 +3 1 0 +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +i count(*) std(e1/e2) +1 1 0.000000000000000000000000000000 +2 1 0.000000000000000000000000000000 +3 1 0.000000000000000000000000000000 +set div_precision_increment=20; +select i, count(*), variance(s1/s2) from bug22555 group by i order by i; +i count(*) variance(s1/s2) +1 1 0.000000000000000000000000000000 +2 1 0.000000000000000000000000000000 +3 1 0.000000000000000000000000000000 +select i, count(*), variance(o1/o2) from bug22555 group by i order by i; +i count(*) variance(o1/o2) +1 1 0 +2 1 0 +3 1 0 +select i, count(*), variance(e1/e2) from bug22555 group by i order by i; +i count(*) variance(e1/e2) +1 1 0.000000000000000000000000000000 +2 1 0.000000000000000000000000000000 +3 1 0.000000000000000000000000000000 +select i, count(*), std(s1/s2) from bug22555 group by i order by i; +i count(*) std(s1/s2) +1 1 0.000000000000000000000000000000 +2 1 0.000000000000000000000000000000 +3 1 0.000000000000000000000000000000 +select i, count(*), std(o1/o2) from bug22555 group by i order by i; +i count(*) std(o1/o2) +1 1 0 +2 1 0 +3 1 0 +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +i count(*) std(e1/e2) +1 1 0.000000000000000000000000000000 +2 1 0.000000000000000000000000000000 +3 1 0.000000000000000000000000000000 +set @@div_precision_increment=@saved_div_precision_increment; +insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76); +insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76); +insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76); +select i, count(*), std(s1/s2) from bug22555 group by i order by i; +i count(*) std(s1/s2) +1 4 0.00000000 +2 4 0.00000000 +3 4 0.00000000 +select i, count(*), std(o1/o2) from bug22555 group by i order by i; +i count(*) std(o1/o2) +1 4 0 +2 4 0 +3 4 0 +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +i count(*) std(e1/e2) +1 4 0.00000000 +2 4 0.00000000 +3 4 0.00000000 +select std(s1/s2) from bug22555; +std(s1/s2) +0.21325764 +select std(o1/o2) from bug22555; +std(o1/o2) +0.21325763586649 +select std(e1/e2) from bug22555; +std(e1/e2) +0.21325764 +set @saved_div_precision_increment=@@div_precision_increment; +set div_precision_increment=19; +select i, count(*), std(s1/s2) from bug22555 group by i order by i; +i count(*) std(s1/s2) +1 4 0.000000000000000000000000000000 +2 4 0.000000000000000000000000000000 +3 4 0.000000000000000000000000000000 +select i, count(*), std(o1/o2) from bug22555 group by i order by i; +i count(*) std(o1/o2) +1 4 0 +2 4 0 +3 4 0 +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +i count(*) std(e1/e2) +1 4 0.000000000000000000000000000000 +2 4 0.000000000000000000000000000000 +3 4 0.000000000000000000000000000000 +select std(s1/s2) from bug22555; +std(s1/s2) +0.213257635866493405751853629226 +select std(o1/o2) from bug22555; +std(o1/o2) +0.21325763586649 +select std(e1/e2) from bug22555; +std(e1/e2) +0.213257635866493405751853629226 +set div_precision_increment=20; +select i, count(*), std(s1/s2) from bug22555 group by i order by i; +i count(*) std(s1/s2) +1 4 0.000000000000000000000000000000 +2 4 0.000000000000000000000000000000 +3 4 0.000000000000000000000000000000 +select i, count(*), std(o1/o2) from bug22555 group by i order by i; +i count(*) std(o1/o2) +1 4 0 +2 4 0 +3 4 0 +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +i count(*) std(e1/e2) +1 4 0.000000000000000000000000000000 +2 4 0.000000000000000000000000000000 +3 4 0.000000000000000000000000000000 +select std(s1/s2) from bug22555; +std(s1/s2) +0.213257635866493405751853629226 +select std(o1/o2) from bug22555; +std(o1/o2) +0.21325763586649 +select std(e1/e2) from bug22555; +std(e1/e2) +0.213257635866493405751853629226 +set @@div_precision_increment=@saved_div_precision_increment; +drop table bug22555; +create table bug22555 (s smallint, o double, e decimal); +insert into bug22555 values (1,1,1),(2,2,2),(3,3,3),(6,6,6),(7,7,7); +select var_samp(s), var_pop(s) from bug22555; +var_samp(s) var_pop(s) +6.7000 5.3600 +select var_samp(o), var_pop(o) from bug22555; +var_samp(o) var_pop(o) +6.7 5.36 +select var_samp(e), var_pop(e) from bug22555; +var_samp(e) var_pop(e) +6.7000 5.3600 +drop table bug22555; +create table bug22555 (s smallint, o double, e decimal); +insert into bug22555 values (null,null,null),(null,null,null); +select var_samp(s) as 'null', var_pop(s) as 'null' from bug22555; +null null +NULL NULL +select var_samp(o) as 'null', var_pop(o) as 'null' from bug22555; +null null +NULL NULL +select var_samp(e) as 'null', var_pop(e) as 'null' from bug22555; +null null +NULL NULL +insert into bug22555 values (1,1,1); +select var_samp(s) as 'null', var_pop(s) as '0' from bug22555; +null 0 +NULL 0.0000 +select var_samp(o) as 'null', var_pop(o) as '0' from bug22555; +null 0 +NULL 0 +select var_samp(e) as 'null', var_pop(e) as '0' from bug22555; +null 0 +NULL 0.0000 +insert into bug22555 values (2,2,2); +select var_samp(s) as '0.5', var_pop(s) as '0.25' from bug22555; +0.5 0.25 +0.5000 0.2500 +select var_samp(o) as '0.5', var_pop(o) as '0.25' from bug22555; +0.5 0.25 +0.5 0.25 +select var_samp(e) as '0.5', var_pop(e) as '0.25' from bug22555; +0.5 0.25 +0.5000 0.2500 +drop table bug22555; +End 5.0 tests. diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 079d107fad8..e54da7341a3 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -700,3 +700,95 @@ create table t1 select stddev(0); show create table t1; drop table t1; + +# +# Bug#22555: STDDEV yields positive result for groups with only one row +# + +create table bug22555 (i smallint primary key auto_increment, s1 smallint, s2 smallint, e decimal(30,10), o double); +insert into bug22555 (s1, s2, e, o) values (53, 78, 11.4276528, 6.828112), (17, 78, 5.916793, 1.8502951), (18, 76, 2.679231, 9.17975591), (31, 62, 6.07831, 0.1), (19, 41, 5.37463, 15.1), (83, 73, 14.567426, 7.959222), (92, 53, 6.10151, 13.1856852), (7, 12, 13.92272, 3.442007), (92, 35, 11.95358909, 6.01376678), (38, 84, 2.572, 7.904571); +select std(s1/s2) from bug22555 group by i; +select std(e) from bug22555 group by i; +select std(o) from bug22555 group by i; +drop table bug22555; + +create table bug22555 (i smallint, s1 smallint, s2 smallint, o1 double, o2 double, e1 decimal, e2 decimal); +insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76); +select i, count(*) from bug22555 group by i; +select std(s1/s2) from bug22555 where i=1; +select std(s1/s2) from bug22555 where i=2; +select std(s1/s2) from bug22555 where i=3; +select std(s1/s2) from bug22555 where i=1 group by i; +select std(s1/s2) from bug22555 where i=2 group by i; +select std(s1/s2) from bug22555 where i=3 group by i; +select std(s1/s2) from bug22555 group by i order by i; +select i, count(*), std(o1/o2) from bug22555 group by i order by i; +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +set @saved_div_precision_increment=@@div_precision_increment; +set div_precision_increment=19; +select i, count(*), variance(s1/s2) from bug22555 group by i order by i; +select i, count(*), variance(o1/o2) from bug22555 group by i order by i; +select i, count(*), variance(e1/e2) from bug22555 group by i order by i; +select i, count(*), std(s1/s2) from bug22555 group by i order by i; +select i, count(*), std(o1/o2) from bug22555 group by i order by i; +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +set div_precision_increment=20; +select i, count(*), variance(s1/s2) from bug22555 group by i order by i; +select i, count(*), variance(o1/o2) from bug22555 group by i order by i; +select i, count(*), variance(e1/e2) from bug22555 group by i order by i; +select i, count(*), std(s1/s2) from bug22555 group by i order by i; +select i, count(*), std(o1/o2) from bug22555 group by i order by i; +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +set @@div_precision_increment=@saved_div_precision_increment; +insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76); +insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76); +insert into bug22555 values (1,53,78,53,78,53,78),(2,17,78,17,78,17,78),(3,18,76,18,76,18,76); + +select i, count(*), std(s1/s2) from bug22555 group by i order by i; +select i, count(*), std(o1/o2) from bug22555 group by i order by i; +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +select std(s1/s2) from bug22555; +select std(o1/o2) from bug22555; +select std(e1/e2) from bug22555; +set @saved_div_precision_increment=@@div_precision_increment; +set div_precision_increment=19; +select i, count(*), std(s1/s2) from bug22555 group by i order by i; +select i, count(*), std(o1/o2) from bug22555 group by i order by i; +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +select std(s1/s2) from bug22555; +select std(o1/o2) from bug22555; +select std(e1/e2) from bug22555; +set div_precision_increment=20; +select i, count(*), std(s1/s2) from bug22555 group by i order by i; +select i, count(*), std(o1/o2) from bug22555 group by i order by i; +select i, count(*), std(e1/e2) from bug22555 group by i order by i; +select std(s1/s2) from bug22555; +select std(o1/o2) from bug22555; +select std(e1/e2) from bug22555; +set @@div_precision_increment=@saved_div_precision_increment; +drop table bug22555; + +create table bug22555 (s smallint, o double, e decimal); +insert into bug22555 values (1,1,1),(2,2,2),(3,3,3),(6,6,6),(7,7,7); +select var_samp(s), var_pop(s) from bug22555; +select var_samp(o), var_pop(o) from bug22555; +select var_samp(e), var_pop(e) from bug22555; +drop table bug22555; + +create table bug22555 (s smallint, o double, e decimal); +insert into bug22555 values (null,null,null),(null,null,null); +select var_samp(s) as 'null', var_pop(s) as 'null' from bug22555; +select var_samp(o) as 'null', var_pop(o) as 'null' from bug22555; +select var_samp(e) as 'null', var_pop(e) as 'null' from bug22555; +insert into bug22555 values (1,1,1); +select var_samp(s) as 'null', var_pop(s) as '0' from bug22555; +select var_samp(o) as 'null', var_pop(o) as '0' from bug22555; +select var_samp(e) as 'null', var_pop(e) as '0' from bug22555; +insert into bug22555 values (2,2,2); +select var_samp(s) as '0.5', var_pop(s) as '0.25' from bug22555; +select var_samp(o) as '0.5', var_pop(o) as '0.25' from bug22555; +select var_samp(e) as '0.5', var_pop(e) as '0.25' from bug22555; +drop table bug22555; + +### +--echo End 5.0 tests. diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 77c6e17607f..3b2a10ad666 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1098,7 +1098,7 @@ Field *Item_sum_avg::create_tmp_field(bool group, TABLE *table, { /* We must store both value and counter in the temporary table in one field. - The easyest way is to do this is to store both value in a string + The easiest way is to do this is to store both value in a string and unpack on access. */ return new Field_string(((hybrid_type == DECIMAL_RESULT) ? @@ -1172,8 +1172,9 @@ String *Item_sum_avg::val_str(String *str) double Item_sum_std::val_real() { DBUG_ASSERT(fixed == 1); - double tmp= Item_sum_variance::val_real(); - return tmp <= 0.0 ? 0.0 : sqrt(tmp); + double nr= Item_sum_variance::val_real(); + DBUG_ASSERT(nr >= 0.0); + return sqrt(nr); } Item *Item_sum_std::copy_or_same(THD* thd) @@ -1187,40 +1188,77 @@ Item *Item_sum_std::copy_or_same(THD* thd) */ -Item_sum_variance::Item_sum_variance(THD *thd, Item_sum_variance *item): - Item_sum_num(thd, item), hybrid_type(item->hybrid_type), - cur_dec(item->cur_dec), count(item->count), sample(item->sample), - prec_increment(item->prec_increment) +/** + Variance implementation for floating-point implementations, without + catastrophic cancellation, from Knuth's _TAoCP_, 3rd ed, volume 2, pg232. + This alters the value at m, s, and increments count. +*/ + +/* + These two functions are used by the Item_sum_variance and the + Item_variance_field classes, which are unrelated, and each need to calculate + variance. The difference between the two classes is that the first is used + for a mundane SELECT, while the latter is used in a GROUPing SELECT. +*/ +static void variance_fp_recurrence_next(double *m, double *s, ulonglong *count, double nr) { - if (hybrid_type == DECIMAL_RESULT) + *count += 1; + + if (*count == 1) { - memcpy(dec_sum, item->dec_sum, sizeof(item->dec_sum)); - memcpy(dec_sqr, item->dec_sqr, sizeof(item->dec_sqr)); - for (int i=0; i<2; i++) - { - dec_sum[i].fix_buffer_pointer(); - dec_sqr[i].fix_buffer_pointer(); - } + *m= nr; + *s= 0; } else { - sum= item->sum; - sum_sqr= item->sum_sqr; + double m_kminusone= *m; + *m= m_kminusone + (nr - m_kminusone) / (double) *count; + *s= *s + (nr - m_kminusone) * (nr - *m); } } +static double variance_fp_recurrence_result(double s, ulonglong count, bool is_sample_variance) +{ + if (count == 1) + return 0.0; + + if (is_sample_variance) + return s / (count - 1); + + /* else, is a population variance */ + return s / count; +} + + +Item_sum_variance::Item_sum_variance(THD *thd, Item_sum_variance *item): + Item_sum_num(thd, item), hybrid_type(item->hybrid_type), + count(item->count), sample(item->sample), + prec_increment(item->prec_increment) +{ + recurrence_m= item->recurrence_m; + recurrence_s= item->recurrence_s; +} + + void Item_sum_variance::fix_length_and_dec() { DBUG_ENTER("Item_sum_variance::fix_length_and_dec"); maybe_null= null_value= 1; prec_increment= current_thd->variables.div_precincrement; + + /* + According to the SQL2003 standard (Part 2, Foundations; sec 10.9, + aggregate function; paragraph 7h of Syntax Rules), "the declared + type of the result is an implementation-defined aproximate numeric + type. + */ + hybrid_type= REAL_RESULT; + switch (args[0]->result_type()) { case REAL_RESULT: case STRING_RESULT: decimals= min(args[0]->decimals + 4, NOT_FIXED_DEC); - hybrid_type= REAL_RESULT; - sum= 0.0; break; case INT_RESULT: case DECIMAL_RESULT: @@ -1229,37 +1267,14 @@ void Item_sum_variance::fix_length_and_dec() decimals= min(args[0]->decimals + prec_increment, DECIMAL_MAX_SCALE); max_length= my_decimal_precision_to_length(precision, decimals, unsigned_flag); - cur_dec= 0; - hybrid_type= DECIMAL_RESULT; - my_decimal_set_zero(dec_sum); - my_decimal_set_zero(dec_sqr); - /* - The maxium value to usable for variance is DECIMAL_MAX_LENGTH/2 - becasue we need to be able to calculate in dec_bin_size1 - column_value * column_value - */ - f_scale0= args[0]->decimals; - f_precision0= min(args[0]->decimal_precision() + DECIMAL_LONGLONG_DIGITS, - DECIMAL_MAX_PRECISION); - f_scale1= min(args[0]->decimals * 2, DECIMAL_MAX_SCALE); - f_precision1= min(args[0]->decimal_precision()*2 + DECIMAL_LONGLONG_DIGITS, - DECIMAL_MAX_PRECISION); - dec_bin_size0= my_decimal_get_binary_size(f_precision0, f_scale0); - dec_bin_size1= my_decimal_get_binary_size(f_precision1, f_scale1); break; } case ROW_RESULT: default: DBUG_ASSERT(0); } - DBUG_PRINT("info", ("Type: %s (%d, %d)", - (hybrid_type == REAL_RESULT ? "REAL_RESULT" : - hybrid_type == DECIMAL_RESULT ? "DECIMAL_RESULT" : - hybrid_type == INT_RESULT ? "INT_RESULT" : - "--ILLEGAL!!!--"), - max_length, - (int)decimals)); + DBUG_PRINT("info", ("Type: REAL_RESULT (%d, %d)", max_length, (int)decimals)); DBUG_VOID_RETURN; } @@ -1270,6 +1285,11 @@ Item *Item_sum_variance::copy_or_same(THD* thd) } +/** + Create a new field to match the type of value we're expected to yield. + If we're grouping, then we need some space to serialize variables into, to + pass around. +*/ Field *Item_sum_variance::create_tmp_field(bool group, TABLE *table, uint convert_blob_len) { @@ -1277,13 +1297,10 @@ Field *Item_sum_variance::create_tmp_field(bool group, TABLE *table, { /* We must store both value and counter in the temporary table in one field. - The easyest way is to do this is to store both value in a string + The easiest way is to do this is to store both value in a string and unpack on access. */ - return new Field_string(((hybrid_type == DECIMAL_RESULT) ? - dec_bin_size0 + dec_bin_size1 : - sizeof(double)*2) + sizeof(longlong), - 0, name, table, &my_charset_bin); + return new Field_string(sizeof(double)*2 + sizeof(longlong), 0, name, table, &my_charset_bin); } return new Field_double(max_length, maybe_null,name,table,decimals); } @@ -1291,90 +1308,51 @@ Field *Item_sum_variance::create_tmp_field(bool group, TABLE *table, void Item_sum_variance::clear() { - if (hybrid_type == DECIMAL_RESULT) - { - my_decimal_set_zero(dec_sum); - my_decimal_set_zero(dec_sqr); - cur_dec= 0; - } - else - sum=sum_sqr=0.0; - count=0; + count= 0; } bool Item_sum_variance::add() { - if (hybrid_type == DECIMAL_RESULT) - { - my_decimal dec_buf, *dec= args[0]->val_decimal(&dec_buf); - my_decimal sqr_buf; - if (!args[0]->null_value) - { - count++; - int next_dec= cur_dec ^ 1; - my_decimal_mul(E_DEC_FATAL_ERROR, &sqr_buf, dec, dec); - my_decimal_add(E_DEC_FATAL_ERROR, dec_sqr+next_dec, - dec_sqr+cur_dec, &sqr_buf); - my_decimal_add(E_DEC_FATAL_ERROR, dec_sum+next_dec, - dec_sum+cur_dec, dec); - cur_dec= next_dec; - } - } - else - { - double nr= args[0]->val_real(); - if (!args[0]->null_value) - { - sum+=nr; - sum_sqr+=nr*nr; - count++; - } - } + /* + Why use a temporary variable? We don't know if it is null until we + evaluate it, which has the side-effect of setting null_value . + */ + double nr= args[0]->val_real(); + + if (!args[0]->null_value) + variance_fp_recurrence_next(&recurrence_m, &recurrence_s, &count, nr); return 0; } double Item_sum_variance::val_real() { DBUG_ASSERT(fixed == 1); - if (hybrid_type == DECIMAL_RESULT) - return val_real_from_decimal(); + /* + 'sample' is a 1/0 boolean value. If it is 1/true, id est this is a sample + variance call, then we should set nullness when the count of the items + is one or zero. If it's zero, i.e. a population variance, then we only + set nullness when the count is zero. + + Another way to read it is that 'sample' is the numerical threshhold, at and + below which a 'count' number of items is called NULL. + */ + DBUG_ASSERT((sample == 0) || (sample == 1)); if (count <= sample) { null_value=1; return 0.0; } + null_value=0; - /* Avoid problems when the precision isn't good enough */ - double tmp=ulonglong2double(count); - double tmp2= (sum_sqr - sum*sum/tmp)/(tmp - (double)sample); - return tmp2 <= 0.0 ? 0.0 : tmp2; + return variance_fp_recurrence_result(recurrence_s, count, sample); } my_decimal *Item_sum_variance::val_decimal(my_decimal *dec_buf) { - my_decimal count_buf, count1_buf, sum_sqr_buf; - DBUG_ASSERT(fixed ==1 ); - if (hybrid_type == REAL_RESULT) - return val_decimal_from_real(dec_buf); - - if (count <= sample) - { - null_value= 1; - return 0; - } - null_value= 0; - int2my_decimal(E_DEC_FATAL_ERROR, count, 0, &count_buf); - int2my_decimal(E_DEC_FATAL_ERROR, count-sample, 0, &count1_buf); - my_decimal_mul(E_DEC_FATAL_ERROR, &sum_sqr_buf, - dec_sum+cur_dec, dec_sum+cur_dec); - my_decimal_div(E_DEC_FATAL_ERROR, dec_buf, - &sum_sqr_buf, &count_buf, prec_increment); - my_decimal_sub(E_DEC_FATAL_ERROR, &sum_sqr_buf, dec_sqr+cur_dec, dec_buf); - my_decimal_div(E_DEC_FATAL_ERROR, dec_buf, - &sum_sqr_buf, &count1_buf, prec_increment); - return dec_buf; + DBUG_ASSERT(fixed == 1); + return val_decimal_from_real(dec_buf); } @@ -1383,89 +1361,44 @@ void Item_sum_variance::reset_field() double nr; char *res= result_field->ptr; - if (hybrid_type == DECIMAL_RESULT) - { - my_decimal value, *arg_dec, *arg2_dec; - longlong tmp; - - arg_dec= args[0]->val_decimal(&value); - if (args[0]->null_value) - { - arg_dec= arg2_dec= &decimal_zero; - tmp= 0; - } - else - { - my_decimal_mul(E_DEC_FATAL_ERROR, dec_sum, arg_dec, arg_dec); - arg2_dec= dec_sum; - tmp= 1; - } - my_decimal2binary(E_DEC_FATAL_ERROR, arg_dec, - res, f_precision0, f_scale0); - my_decimal2binary(E_DEC_FATAL_ERROR, arg2_dec, - res+dec_bin_size0, f_precision1, f_scale1); - res+= dec_bin_size0 + dec_bin_size1; - int8store(res,tmp); - return; - } - nr= args[0]->val_real(); + nr= args[0]->val_real(); /* sets null_value as side-effect */ if (args[0]->null_value) bzero(res,sizeof(double)*2+sizeof(longlong)); else { - longlong tmp; - float8store(res,nr); - nr*=nr; - float8store(res+sizeof(double),nr); - tmp= 1; - int8store(res+sizeof(double)*2,tmp); + /* Serialize format is (double)m, (double)s, (longlong)count */ + ulonglong tmp_count; + double tmp_s; + float8store(res, nr); /* recurrence variable m */ + tmp_s= 0.0; + float8store(res + sizeof(double), tmp_s); + tmp_count= 1; + int8store(res + sizeof(double)*2, tmp_count); } } void Item_sum_variance::update_field() { - longlong field_count; + ulonglong field_count; char *res=result_field->ptr; - if (hybrid_type == DECIMAL_RESULT) - { - my_decimal value, *arg_val= args[0]->val_decimal(&value); - if (!args[0]->null_value) - { - binary2my_decimal(E_DEC_FATAL_ERROR, res, - dec_sum+1, f_precision0, f_scale0); - binary2my_decimal(E_DEC_FATAL_ERROR, res+dec_bin_size0, - dec_sqr+1, f_precision1, f_scale1); - field_count= sint8korr(res + (dec_bin_size0 + dec_bin_size1)); - my_decimal_add(E_DEC_FATAL_ERROR, dec_sum, arg_val, dec_sum+1); - my_decimal_mul(E_DEC_FATAL_ERROR, dec_sum+1, arg_val, arg_val); - my_decimal_add(E_DEC_FATAL_ERROR, dec_sqr, dec_sqr+1, dec_sum+1); - field_count++; - my_decimal2binary(E_DEC_FATAL_ERROR, dec_sum, - res, f_precision0, f_scale0); - my_decimal2binary(E_DEC_FATAL_ERROR, dec_sqr, - res+dec_bin_size0, f_precision1, f_scale1); - res+= dec_bin_size0 + dec_bin_size1; - int8store(res, field_count); - } - return; - } - double nr,old_nr,old_sqr; - float8get(old_nr, res); - float8get(old_sqr, res+sizeof(double)); + double nr= args[0]->val_real(); /* sets null_value as side-effect */ + + if (args[0]->null_value) + return; + + /* Serialize format is (double)m, (double)s, (longlong)count */ + double field_recurrence_m, field_recurrence_s; + float8get(field_recurrence_m, res); + float8get(field_recurrence_s, res + sizeof(double)); field_count=sint8korr(res+sizeof(double)*2); - nr= args[0]->val_real(); - if (!args[0]->null_value) - { - old_nr+=nr; - old_sqr+=nr*nr; - field_count++; - } - float8store(res,old_nr); - float8store(res+sizeof(double),old_sqr); + variance_fp_recurrence_next(&field_recurrence_m, &field_recurrence_s, &field_count, nr); + + float8store(res, field_recurrence_m); + float8store(res + sizeof(double), field_recurrence_s); res+= sizeof(double)*2; int8store(res,field_count); } @@ -2295,25 +2228,9 @@ double Item_std_field::val_real() { double nr; // fix_fields() never calls for this Item - if (hybrid_type == REAL_RESULT) - { - /* - We can't call Item_variance_field::val_real() on a DECIMAL_RESULT - as this would call Item_std_field::val_decimal() and we would - calculate sqrt() twice - */ - nr= Item_variance_field::val_real(); - } - else - { - my_decimal dec_buf,*dec; - dec= Item_variance_field::val_decimal(&dec_buf); - if (!dec) - nr= 0.0; // NULL; Return 0.0 - else - my_decimal2double(E_DEC_FATAL_ERROR, dec, &nr); - } - return nr <= 0.0 ? 0.0 : sqrt(nr); + nr= Item_variance_field::val_real(); + DBUG_ASSERT(nr >= 0.0); + return sqrt(nr); } @@ -2327,11 +2244,13 @@ my_decimal *Item_std_field::val_decimal(my_decimal *dec_buf) double nr; if (hybrid_type == REAL_RESULT) return val_decimal_from_real(dec_buf); + dec= Item_variance_field::val_decimal(dec_buf); if (!dec) return 0; my_decimal2double(E_DEC_FATAL_ERROR, dec, &nr); - nr= nr <= 0.0 ? 0.0 : sqrt(nr); + DBUG_ASSERT(nr >= 0.0); + nr= sqrt(nr); double2my_decimal(E_DEC_FATAL_ERROR, nr, &tmp_dec); my_decimal_round(E_DEC_FATAL_ERROR, &tmp_dec, decimals, FALSE, dec_buf); return dec_buf; @@ -2366,52 +2285,15 @@ double Item_variance_field::val_real() if (hybrid_type == DECIMAL_RESULT) return val_real_from_decimal(); - double sum,sum_sqr; - longlong count; - float8get(sum,field->ptr); - float8get(sum_sqr,(field->ptr+sizeof(double))); + double recurrence_s; + ulonglong count; + float8get(recurrence_s, (field->ptr + sizeof(double))); count=sint8korr(field->ptr+sizeof(double)*2); if ((null_value= (count <= sample))) return 0.0; - double tmp= (double) count; - double tmp2= (sum_sqr - sum*sum/tmp)/(tmp - (double)sample); - return tmp2 <= 0.0 ? 0.0 : tmp2; -} - - -String *Item_variance_field::val_str(String *str) -{ - if (hybrid_type == DECIMAL_RESULT) - return val_string_from_decimal(str); - return val_string_from_real(str); -} - - -my_decimal *Item_variance_field::val_decimal(my_decimal *dec_buf) -{ - // fix_fields() never calls for this Item - if (hybrid_type == REAL_RESULT) - return val_decimal_from_real(dec_buf); - - longlong count= sint8korr(field->ptr+dec_bin_size0+dec_bin_size1); - if ((null_value= (count <= sample))) - return 0; - - my_decimal dec_count, dec1_count, dec_sum, dec_sqr, tmp; - int2my_decimal(E_DEC_FATAL_ERROR, count, 0, &dec_count); - int2my_decimal(E_DEC_FATAL_ERROR, count-sample, 0, &dec1_count); - binary2my_decimal(E_DEC_FATAL_ERROR, field->ptr, - &dec_sum, f_precision0, f_scale0); - binary2my_decimal(E_DEC_FATAL_ERROR, field->ptr+dec_bin_size0, - &dec_sqr, f_precision1, f_scale1); - my_decimal_mul(E_DEC_FATAL_ERROR, &tmp, &dec_sum, &dec_sum); - my_decimal_div(E_DEC_FATAL_ERROR, dec_buf, &tmp, &dec_count, prec_increment); - my_decimal_sub(E_DEC_FATAL_ERROR, &dec_sum, &dec_sqr, dec_buf); - my_decimal_div(E_DEC_FATAL_ERROR, dec_buf, - &dec_sum, &dec1_count, prec_increment); - return dec_buf; + return variance_fp_recurrence_result(recurrence_s, count, sample); } diff --git a/sql/item_sum.h b/sql/item_sum.h index fe7edd76ecf..989e72654fe 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -665,8 +665,10 @@ public: double val_real(); longlong val_int() { /* can't be fix_fields()ed */ return (longlong) rint(val_real()); } - String *val_str(String*); - my_decimal *val_decimal(my_decimal *); + String *val_str(String *str) + { return val_string_from_real(str); } + my_decimal *val_decimal(my_decimal *dec_buf) + { return val_decimal_from_real(dec_buf); } bool is_null() { (void) val_int(); return null_value; } enum_field_types field_type() const { @@ -688,6 +690,14 @@ public: = (sum(ai^2) - 2*sum(a)*sum(a)/count(a) + count(a)*sum(a)^2/count(a)^2 )/count(a) = = (sum(ai^2) - 2*sum(a)^2/count(a) + sum(a)^2/count(a) )/count(a) = = (sum(ai^2) - sum(a)^2/count(a))/count(a) + +But, this falls prey to catastrophic cancellation. Instead, use the recurrence formulas + + M_{1} = x_{1}, ~ M_{k} = M_{k-1} + (x_{k} - M_{k-1}) / k newline + S_{1} = 0, ~ S_{k} = S_{k-1} + (x_{k} - M_{k-1}) times (x_{k} - M_{k}) newline + for 2 <= k <= n newline + ital variance = S_{n} / (n-1) + */ class Item_sum_variance : public Item_sum_num @@ -696,9 +706,8 @@ class Item_sum_variance : public Item_sum_num public: Item_result hybrid_type; - double sum, sum_sqr; - my_decimal dec_sum[2], dec_sqr[2]; int cur_dec; + double recurrence_m, recurrence_s; /* Used in recurrence relation. */ ulonglong count; uint f_precision0, f_scale0; uint f_precision1, f_scale1; @@ -707,7 +716,7 @@ public: uint prec_increment; Item_sum_variance(Item *item_par, uint sample_arg) :Item_sum_num(item_par), - hybrid_type(REAL_RESULT), cur_dec(0), count(0), sample(sample_arg) + hybrid_type(REAL_RESULT), count(0), sample(sample_arg) {} Item_sum_variance(THD *thd, Item_sum_variance *item); enum Sumfunctype sum_func () const { return VARIANCE_FUNC; } @@ -727,7 +736,6 @@ public: enum Item_result result_type () const { return REAL_RESULT; } void cleanup() { - cur_dec= 0; count= 0; Item_sum_num::cleanup(); } From e05764a3b2010d50cfcd14683828b21f557c8b99 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Dec 2006 21:35:40 -0500 Subject: [PATCH 64/88] Fixed error in merge. --- sql/item_sum.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 714ccbf99f0..6c791cdd1f4 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1338,7 +1338,7 @@ Field *Item_sum_variance::create_tmp_field(bool group, TABLE *table, field= new Field_double(max_length, maybe_null, name, decimals); if (field != NULL) - field->init(table) + field->init(table); return field; } From 1fdda68914a7a3ccb9527177100fff5b07972e69 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Dec 2006 12:42:54 -0700 Subject: [PATCH 65/88] In func_group.test, round the results of std() for some calls, because Windows' sqrt() function appears to return fewer "significant" digits than the Unix implementations. This is for bug #22555. mysql-test/r/func_group.result: Round the results of std() for some calls, because Windows' sqrt() function appears to return fewer "significant" digits than the Unix implementations. This is for bug #22555. mysql-test/t/func_group.test: Round the results of std() for some calls, because Windows' sqrt() function appears to return fewer "significant" digits than the Unix implementations. This is for bug #22555. --- mysql-test/r/func_group.result | 24 ++++++++++++------------ mysql-test/t/func_group.test | 8 ++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 9ae031fe600..d18837aed41 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1216,15 +1216,15 @@ i count(*) std(e1/e2) 1 4 0.000000000000000000000000000000 2 4 0.000000000000000000000000000000 3 4 0.000000000000000000000000000000 -select std(s1/s2) from bug22555; -std(s1/s2) -0.213257635866493405751853629226 +select round(std(s1/s2), 17) from bug22555; +round(std(s1/s2), 17) +0.21325763586649341 select std(o1/o2) from bug22555; std(o1/o2) 0.21325763586649 -select std(e1/e2) from bug22555; -std(e1/e2) -0.213257635866493405751853629226 +select round(std(e1/e2), 17) from bug22555; +round(std(e1/e2), 17) +0.21325763586649341 set div_precision_increment=20; select i, count(*), std(s1/s2) from bug22555 group by i order by i; i count(*) std(s1/s2) @@ -1241,15 +1241,15 @@ i count(*) std(e1/e2) 1 4 0.000000000000000000000000000000 2 4 0.000000000000000000000000000000 3 4 0.000000000000000000000000000000 -select std(s1/s2) from bug22555; -std(s1/s2) -0.213257635866493405751853629226 +select round(std(s1/s2), 17) from bug22555; +round(std(s1/s2), 17) +0.21325763586649341 select std(o1/o2) from bug22555; std(o1/o2) 0.21325763586649 -select std(e1/e2) from bug22555; -std(e1/e2) -0.213257635866493405751853629226 +select round(std(e1/e2), 17) from bug22555; +round(std(e1/e2), 17) +0.21325763586649341 set @@div_precision_increment=@saved_div_precision_increment; drop table bug22555; create table bug22555 (s smallint, o double, e decimal); diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 49fab85d894..a3b3fceaec5 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -757,16 +757,16 @@ set div_precision_increment=19; select i, count(*), std(s1/s2) from bug22555 group by i order by i; select i, count(*), std(o1/o2) from bug22555 group by i order by i; select i, count(*), std(e1/e2) from bug22555 group by i order by i; -select std(s1/s2) from bug22555; +select round(std(s1/s2), 17) from bug22555; select std(o1/o2) from bug22555; -select std(e1/e2) from bug22555; +select round(std(e1/e2), 17) from bug22555; set div_precision_increment=20; select i, count(*), std(s1/s2) from bug22555 group by i order by i; select i, count(*), std(o1/o2) from bug22555 group by i order by i; select i, count(*), std(e1/e2) from bug22555 group by i order by i; -select std(s1/s2) from bug22555; +select round(std(s1/s2), 17) from bug22555; select std(o1/o2) from bug22555; -select std(e1/e2) from bug22555; +select round(std(e1/e2), 17) from bug22555; set @@div_precision_increment=@saved_div_precision_increment; drop table bug22555; From d200e8eb19f1d0e7c36d3d37a5db22e41f457f9d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 29 Dec 2006 16:07:33 -0500 Subject: [PATCH 66/88] Bug#23950: misplaced code in mysqld.cc, main() Moved MY_INIT() to top of main(), where it should be. sql/mysqld.cc: Nothing should come before MY_INIT(). --- sql/mysqld.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d6031504799..eb344f852e2 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3476,6 +3476,9 @@ int win_main(int argc, char **argv) int main(int argc, char **argv) #endif { + MY_INIT(argv[0]); // init my_sys library & pthreads + /* nothing should come before this line ^^^ */ + rpl_filter= new Rpl_filter; binlog_filter= new Rpl_filter; if (!rpl_filter || !binlog_filter) @@ -3484,8 +3487,6 @@ int main(int argc, char **argv) exit(1); } - MY_INIT(argv[0]); // init my_sys library & pthreads - /* Perform basic logger initialization logger. Should be called after MY_INIT, as it initializes mutexes. Log tables are inited later. From e9f6b35391d569c43a4ea37f1fee559b4145db43 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 2 Jan 2007 12:56:48 -0500 Subject: [PATCH 67/88] Bug#23950: misplaced code in mysqld.cc, main() We should initialize before anything else. sql/mysqld.cc: Move MY_INIT to the top of main(). --- sql/mysqld.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 95de1f91ecf..bcae6fd2ec8 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3339,8 +3339,10 @@ int win_main(int argc, char **argv) int main(int argc, char **argv) #endif { - DEBUGGER_OFF; MY_INIT(argv[0]); // init my_sys library & pthreads + /* ^^^ Nothing should be before this line! */ + + DEBUGGER_OFF; #ifdef _CUSTOMSTARTUPCONFIG_ if (_cust_check_startup()) From b3138ef74c38926520a9458676dfccc12cdac6fc Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 6 Jan 2007 12:34:16 -0500 Subject: [PATCH 68/88] A writability test in a prereq file polluted the binlog. Reset the info after using those files. mysql-test/t/ndb_binlog_ignore_db.test: Reset the binlog after we include several files that have little to do with this test. --- mysql-test/t/ndb_binlog_ignore_db.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/t/ndb_binlog_ignore_db.test b/mysql-test/t/ndb_binlog_ignore_db.test index a4090bbb62b..a99dfd940ad 100644 --- a/mysql-test/t/ndb_binlog_ignore_db.test +++ b/mysql-test/t/ndb_binlog_ignore_db.test @@ -1,5 +1,6 @@ -- source include/have_ndb.inc -- source include/have_binlog_format_row.inc +reset master; --disable_warnings drop table if exists t1; From 539c4da16d0e3c68005cbc196f6f474803653fa5 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 6 Jan 2007 18:32:55 -0500 Subject: [PATCH 69/88] Use relative dates so that the tests don't fail when the year changes. --- mysql-test/r/view.result | 6 +++--- mysql-test/t/view.test | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 4bc122cc97b..794274e1927 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2675,9 +2675,9 @@ lName varchar(25) NOT NULL, DOB date NOT NULL, uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY); INSERT INTO t1(fName, lName, DOB) VALUES -('Hank', 'Hill', '1964-09-29'), -('Tom', 'Adams', '1908-02-14'), -('Homer', 'Simpson', '1968-03-05'); +('Alice', 'Hill', date_sub(curdate(), interval 15271 day)), +('Bob', 'Adams', date_sub(curdate(), interval 33600 day)), +('Carol', 'Simpson', date_sub(curdate(), interval 13700 day)); CREATE VIEW v1 AS SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 7175db1db4e..6e3c01b66b5 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -2544,9 +2544,9 @@ CREATE TABLE t1( uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY); INSERT INTO t1(fName, lName, DOB) VALUES - ('Hank', 'Hill', '1964-09-29'), - ('Tom', 'Adams', '1908-02-14'), - ('Homer', 'Simpson', '1968-03-05'); + ('Alice', 'Hill', date_sub(curdate(), interval 15271 day)), + ('Bob', 'Adams', date_sub(curdate(), interval 33600 day)), + ('Carol', 'Simpson', date_sub(curdate(), interval 13700 day)); CREATE VIEW v1 AS SELECT (year(now())-year(DOB)) AS Age From ead6b1055767c1f590e66ef8e42ac4b5796ef421 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 6 Jan 2007 18:40:43 -0500 Subject: [PATCH 70/88] Forgot to add result file to changeset. :( --- mysql-test/r/ndb_binlog_ignore_db.result | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/r/ndb_binlog_ignore_db.result b/mysql-test/r/ndb_binlog_ignore_db.result index 8dc2c1ff1f8..952d048ad8d 100644 --- a/mysql-test/r/ndb_binlog_ignore_db.result +++ b/mysql-test/r/ndb_binlog_ignore_db.result @@ -1,3 +1,4 @@ +reset master; drop table if exists t1; drop database if exists mysqltest; create database mysqltest; From 4d106e4c986b51a7c843ead2370ebb4885dadd1d Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 7 Jan 2007 12:21:42 -0500 Subject: [PATCH 71/88] Post-merge cleanup and fix minor BUILD/... "="-equality syntax error. BUILD/SETUP.sh: Use POSIX "=" equality shell test. mysql-test/r/view.result: Revert year drift. --- BUILD/SETUP.sh | 2 +- mysql-test/r/view.result | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index dfbf1547517..1f62ffe7c26 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -183,7 +183,7 @@ fi # (http://samba.org/ccache) is installed, use it. # We use 'grep' and hope 'grep' will work as expected # (returns 0 if finds lines) -if ccache -V > /dev/null 2>&1 && test "$CCACHE_GCOV_VERSION_ENABLED" == "1" +if ccache -V > /dev/null 2>&1 && test "$CCACHE_GCOV_VERSION_ENABLED" = "1" then echo "$CC" | grep "ccache" > /dev/null || CC="ccache $CC" echo "$CXX" | grep "ccache" > /dev/null || CXX="ccache $CXX" diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 5773c51803d..794274e1927 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2686,12 +2686,12 @@ View Create View v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (year(now()) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75) SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75; Age -43 -39 +42 +38 SELECT * FROM v1; Age -43 -39 +42 +38 DROP VIEW v1; DROP TABLE t1; CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a char(6) DEFAULT 'xxx'); From be32c011617ac89e2a865a4a32658c22c02e2ed3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 9 Jan 2007 20:23:12 +0100 Subject: [PATCH 72/88] Bug#24660: "enum" field type definition problem ENUMs weren't allowed to have character 0xff, a perfectly good character in many locales. This was circumvented by mapping 0xff in ENUMs to ',', thereby prevent actual commas from being used (because they too would get converted to 0xff on load). Now if 0xff makes an appearance, we find a character not used in the enum and use that as a separator. If no such character exists, we throw an error. Any solution would have broken some sort of existing behaviour. This solution should serve both fractions (those with 0xff and those with ',' in their enums), but WILL REQUIRE A DUMP/RESTORE CYCLE FROM THOSE WITH 0xff IN THEIR ENUMS. :-/ That is, mysqldump with their current server, and restore when upgrading to one with this patch. (port of the original 4.1 patch. incorporates some suggestions by kaamos.) mysql-test/r/type_enum.result: Bug#24660: "enum" field type definition problem Show that enums can now contain NAMES_SEP_CHAR (0xff, which is a perfectly respectable char in some locales), or ',', or both. mysql-test/t/type_enum.test: Bug#24660: "enum" field type definition problem Show that enums can now contain NAMES_SEP_CHAR (0xff, which is a perfectly respectable char in some locales), or ',', or both. sql/table.cc: Bug#24660: "enum" field type definition problem Revert fix for Bug#20922. sql/unireg.cc: Bug#24660: "enum" field type definition problem Use a field-separator for ENUM-values that is not part of those values. If impossible, throw error. --- mysql-test/r/type_enum.result | 26 +++++++++++++++ mysql-test/t/type_enum.test | 24 +++++++++++++- sql/table.cc | 11 ------- sql/unireg.cc | 61 +++++++++++++++++++++++------------ 4 files changed, 89 insertions(+), 33 deletions(-) diff --git a/mysql-test/r/type_enum.result b/mysql-test/r/type_enum.result index b7db1d95587..70ef98af420 100644 --- a/mysql-test/r/type_enum.result +++ b/mysql-test/r/type_enum.result @@ -1754,3 +1754,29 @@ t1 CREATE TABLE `t1` ( `f2` enum('') DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +End of 4.1 tests +create table t1(russian enum('E','F','EF','FE') NOT NULL DEFAULT'E'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `russian` enum('E','F','EF','FE') NOT NULL DEFAULT 'E' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1(denormal enum('E','F','E,F','F,E') NOT NULL DEFAULT'E'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `denormal` enum('E','F','E,F','F,E') NOT NULL DEFAULT 'E' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1(russian_deviant enum('E','F','EF','F,E') NOT NULL DEFAULT'E'); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `russian_deviant` enum('E','F','EF','F,E') NOT NULL DEFAULT 'E' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1(exhausting_charset enum('ABCDEFGHIJKLMNOPQRSTUVWXYZ',' +  !"','#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~','xx\','yy\','zz')); +ERROR 42000: Field separator argument is not what is expected; check the manual +End of 5.1 tests diff --git a/mysql-test/t/type_enum.test b/mysql-test/t/type_enum.test index 68f5664c36d..9be1b7fa10f 100644 --- a/mysql-test/t/type_enum.test +++ b/mysql-test/t/type_enum.test @@ -136,4 +136,26 @@ alter table t1 add f2 enum(0xFFFF); show create table t1; drop table t1; -# End of 4.1 tests +--echo End of 4.1 tests + +# +# Bug#24660 "enum" field type definition problem +# +create table t1(russian enum('E','F','EF','FE') NOT NULL DEFAULT'E'); +show create table t1; +drop table t1; + +create table t1(denormal enum('E','F','E,F','F,E') NOT NULL DEFAULT'E'); +show create table t1; +drop table t1; + +create table t1(russian_deviant enum('E','F','EF','F,E') NOT NULL DEFAULT'E'); +show create table t1; +drop table t1; + +# ER_WRONG_FIELD_TERMINATORS +--error 1083 +create table t1(exhausting_charset enum('ABCDEFGHIJKLMNOPQRSTUVWXYZ',' +  !"','#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~','xx\','yy\','zz')); + +--echo End of 5.1 tests diff --git a/sql/table.cc b/sql/table.cc index e4e087b0e64..4896645c140 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -803,17 +803,6 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, { char *val= (char*) interval->type_names[count]; interval->type_lengths[count]= strlen(val); - /* - Replace all ',' symbols with NAMES_SEP_CHAR. - See the comment in unireg.cc, pack_fields() function - for details. - */ - for (uint cnt= 0 ; cnt < interval->type_lengths[count] ; cnt++) - { - char c= val[cnt]; - if (c == ',') - val[cnt]= NAMES_SEP_CHAR; - } } interval->type_lengths[count]= 0; } diff --git a/sql/unireg.cc b/sql/unireg.cc index 2699cafa7b7..10741240940 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -788,29 +788,48 @@ static bool pack_fields(File file, List &create_fields, { if (field->interval_id > int_count) { - int_count=field->interval_id; - tmp.append(NAMES_SEP_CHAR); - for (const char **pos=field->interval->type_names ; *pos ; pos++) - { - char *val= (char*) *pos; - uint str_len= strlen(val); - /* - Note, hack: in old frm NAMES_SEP_CHAR is used to separate - names in the interval (ENUM/SET). To allow names to contain - NAMES_SEP_CHAR, we replace it with a comma before writing frm. - Backward conversion is done during frm file opening, - See table.cc, openfrm() function - */ - for (uint cnt= 0 ; cnt < str_len ; cnt++) + unsigned char sep= 0; + unsigned char occ[256]; + uint i; + unsigned char *val= NULL; + + bzero(occ, sizeof(occ)); + + for (i=0; (val= (unsigned char*) field->interval->type_names[i]); i++) + for (uint j = 0; j < field->interval->type_lengths[i]; j++) + occ[(unsigned int) (val[j])]= 1; + + if (!occ[(unsigned char)NAMES_SEP_CHAR]) + sep= (unsigned char) NAMES_SEP_CHAR; + else if (!occ[(unsigned int)',']) + sep= ','; + else + { + for (uint i=1; i<256; i++) { - char c= val[cnt]; - if (c == NAMES_SEP_CHAR) - val[cnt]= ','; + if(!occ[i]) + { + sep= i; + break; + } } - tmp.append(*pos); - tmp.append(NAMES_SEP_CHAR); - } - tmp.append('\0'); // End of intervall + + if(!sep) /* disaster, enum uses all characters, none left as separator */ + { + my_message(ER_WRONG_FIELD_TERMINATORS,ER(ER_WRONG_FIELD_TERMINATORS), + MYF(0)); + DBUG_RETURN(1); + } + } + + int_count= field->interval_id; + tmp.append(sep); + for (const char **pos=field->interval->type_names ; *pos ; pos++) + { + tmp.append(*pos); + tmp.append(sep); + } + tmp.append('\0'); // End of intervall } } if (my_write(file,(byte*) tmp.ptr(),tmp.length(),MYF_RW)) From 2cbccbfb0cdcc880ab57bc24a17df473d5b1bdcd Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 11 Jan 2007 09:40:17 +0100 Subject: [PATCH 73/88] Bug#24751 - Possible infinit loop in init_io_cache() when insufficient memory - When cache memory can't be allocated size is recaclulated using 3/4 of the requested memory. This number is rounded up to the nearest min_cache step. However with the previous implementation the new cache size might become bigger than requested because of this rounding and thus we get an infinit loop. - This patch fixes this problem by ensuring that the new cache size always will be smaller on the second and subsequent iterations until we reach min_cache. mysys/mf_iocache.c: - Added mask to cachesize to ensure that algorithm always produce a smaller cache size than current, until we reach 'min_cache' size. --- mysys/mf_iocache.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index b17df3da260..a91002d3b4c 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -199,11 +199,11 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, if (type != READ_NET && type != WRITE_NET) { /* Retry allocating memory in smaller blocks until we get one */ + cachesize=(uint) ((ulong) (cachesize + min_cache-1) & + (ulong) ~(min_cache-1)); for (;;) { uint buffer_block; - cachesize=(uint) ((ulong) (cachesize + min_cache-1) & - (ulong) ~(min_cache-1)); if (cachesize < min_cache) cachesize = min_cache; buffer_block = cachesize; @@ -222,7 +222,8 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, } if (cachesize == min_cache) DBUG_RETURN(2); /* Can't alloc cache */ - cachesize= (uint) ((long) cachesize*3/4); /* Try with less memory */ + /* Try with less memory */ + cachesize= (uint) ((ulong) cachesize*3/4 & (ulong)~(min_cache-1)); } } From a6df406fdc21ef2088cb9c02e7f06ee248c4e951 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 11 Jan 2007 14:54:03 -0500 Subject: [PATCH 74/88] Revert to old behavior. Including code to verify that a cluster is not readonly seems like a good idea, but the test suite isn't expecting those statements in some places. Figure out how we want to use this code later. mysql-test/include/have_ndb.inc: Revert to old behavior. --- mysql-test/include/have_ndb.inc | 5 ----- 1 file changed, 5 deletions(-) diff --git a/mysql-test/include/have_ndb.inc b/mysql-test/include/have_ndb.inc index 77857106488..adb8a657c6c 100644 --- a/mysql-test/include/have_ndb.inc +++ b/mysql-test/include/have_ndb.inc @@ -4,8 +4,3 @@ disable_query_log; select support = 'Enabled' as `TRUE` from information_schema.engines where engine = 'ndbcluster'; enable_query_log; -# Check that master mysqld has come out of redonly mode ---source include/ndb_not_readonly.inc - - - From 6f65e1bc5de37f76f696d9e448ac402536cf0b9f Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 Jan 2007 10:00:29 -0500 Subject: [PATCH 75/88] Bug#19424 InnoDB: Possibly a memory overrun of the buffer being freed (Win64) - Re-enabling optimization on all except innodb/mem/*. --- innobase/CMakeLists.txt | 38 ++------------------------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/innobase/CMakeLists.txt b/innobase/CMakeLists.txt index c244364a800..ae6f1bf21e5 100755 --- a/innobase/CMakeLists.txt +++ b/innobase/CMakeLists.txt @@ -3,39 +3,9 @@ ADD_DEFINITIONS(-DMYSQL_SERVER -D_WIN32 -DWIN32 -D_LIB) # Bug#19424 - InnoDB: Possibly a memory overrun of the buffer being freed (64-bit Visual C) -# Removing Win64 compiler optimizations for all innodb files. +# Removing Win64 compiler optimizations for all innodb/mem/* files. IF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64") - SET_SOURCE_FILES_PROPERTIES(btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c - buf/buf0buf.c buf/buf0flu.c buf/buf0lru.c buf/buf0rea.c - data/data0data.c data/data0type.c - dict/dict0boot.c dict/dict0crea.c dict/dict0dict.c dict/dict0load.c dict/dict0mem.c - dyn/dyn0dyn.c - eval/eval0eval.c eval/eval0proc.c - fil/fil0fil.c - fsp/fsp0fsp.c - fut/fut0fut.c fut/fut0lst.c - ha/ha0ha.c ha/hash0hash.c - ibuf/ibuf0ibuf.c - pars/lexyy.c pars/pars0grm.c pars/pars0opt.c pars/pars0pars.c pars/pars0sym.c - lock/lock0lock.c - log/log0log.c log/log0recv.c - mach/mach0data.c - mem/mem0mem.c mem/mem0pool.c - mtr/mtr0log.c mtr/mtr0mtr.c - os/os0file.c os/os0proc.c os/os0sync.c os/os0thread.c - page/page0cur.c page/page0page.c - que/que0que.c - read/read0read.c - rem/rem0cmp.c rem/rem0rec.c - row/row0ins.c row/row0mysql.c row/row0purge.c row/row0row.c row/row0sel.c row/row0uins.c - row/row0umod.c row/row0undo.c row/row0upd.c row/row0vers.c - srv/srv0que.c srv/srv0srv.c srv/srv0start.c - sync/sync0arr.c sync/sync0rw.c sync/sync0sync.c - thr/thr0loc.c - trx/trx0purge.c trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c - trx/trx0sys.c trx/trx0trx.c trx/trx0undo.c - usr/usr0sess.c - ut/ut0byte.c ut/ut0dbg.c ut/ut0mem.c ut/ut0rnd.c ut/ut0ut.c + SET_SOURCE_FILES_PROPERTIES(mem/mem0mem.c mem/mem0pool.c PROPERTIES COMPILE_FLAGS -Od) ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64") @@ -71,7 +41,3 @@ ADD_LIBRARY(innobase btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c usr/usr0sess.c ut/ut0byte.c ut/ut0dbg.c ut/ut0mem.c ut/ut0rnd.c ut/ut0ut.c ) -# (Bug#19424) Removing Win64 compiler optimizations innobase project. -IF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64") - SET_TARGET_PROPERTIES(innobase PROPERTIES COMPILE_FLAGS "/Od") -ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64") From 68f493a1be1c289e8cad7c91c809c37f6348499d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 Jan 2007 21:50:31 +0100 Subject: [PATCH 76/88] Cset exclude: cmiller@221.54.57.10.in-addr.arpa.cmiller/221.54.57.10.in-addr.arpa|ChangeSet|20070111195403|30218 mysql-test/include/have_ndb.inc: Exclude --- mysql-test/include/have_ndb.inc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mysql-test/include/have_ndb.inc b/mysql-test/include/have_ndb.inc index adb8a657c6c..77857106488 100644 --- a/mysql-test/include/have_ndb.inc +++ b/mysql-test/include/have_ndb.inc @@ -4,3 +4,8 @@ disable_query_log; select support = 'Enabled' as `TRUE` from information_schema.engines where engine = 'ndbcluster'; enable_query_log; +# Check that master mysqld has come out of redonly mode +--source include/ndb_not_readonly.inc + + + From 80818def47aac3ee693477f3782a02c1adab01a9 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 Jan 2007 09:35:14 +0100 Subject: [PATCH 77/88] Always use two masters for ndb tests --- mysql-test/lib/mtr_cases.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index a00d06d2e60..8c2dbdec804 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -537,6 +537,8 @@ sub collect_one_test_case($$$$$$$) { $tinfo->{'comment'}= "No ndbcluster tests(--skip-ndbcluster)"; return; } + # Ndb tests run with two mysqld masters + $tinfo->{'master_num'}= 2; } else { @@ -552,7 +554,7 @@ sub collect_one_test_case($$$$$$$) { if ( $tinfo->{'innodb_test'} ) { - # This is a test that need inndob + # This is a test that need innodb if ( $::mysqld_variables{'innodb'} eq "FALSE" ) { # innodb is not supported, skip it @@ -578,7 +580,6 @@ our @tags= ["include/have_debug.inc", "need_debug", 1], ["include/have_ndb.inc", "ndb_test", 1], ["include/have_ndb_extra.inc", "ndb_extra", 1], - ["include/have_multi_ndb.inc", "master_num", 2], ["require_manager", "require_manager", 1], ); From af218c9f492a81fdb8175f1e6a9a309278d825dd Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 Jan 2007 09:38:09 +0100 Subject: [PATCH 78/88] Remove wait until not readonly --- mysql-test/include/have_ndb.inc | 2 -- 1 file changed, 2 deletions(-) diff --git a/mysql-test/include/have_ndb.inc b/mysql-test/include/have_ndb.inc index 77857106488..c9603634508 100644 --- a/mysql-test/include/have_ndb.inc +++ b/mysql-test/include/have_ndb.inc @@ -4,8 +4,6 @@ disable_query_log; select support = 'Enabled' as `TRUE` from information_schema.engines where engine = 'ndbcluster'; enable_query_log; -# Check that master mysqld has come out of redonly mode ---source include/ndb_not_readonly.inc From ec12404f1e45018ef454f9e64a8d31eedd76fe23 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 Jan 2007 09:47:03 +0100 Subject: [PATCH 79/88] Always use two masters for ndb tests Abandon attempt to only use one for some tests that don't use the second master mysql-test/lib/mtr_cases.pl: Always use two masters for ndb tests --- mysql-test/lib/mtr_cases.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index 5d051422c4c..22290a88d39 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -551,6 +551,8 @@ sub collect_one_test_case($$$$$$$) { $tinfo->{'comment'}= "No ndbcluster tests(--skip-ndbcluster)"; return; } + # Ndb tests run with two mysqld masters + $tinfo->{'master_num'}= 2; } else { @@ -566,7 +568,7 @@ sub collect_one_test_case($$$$$$$) { if ( $tinfo->{'innodb_test'} ) { - # This is a test that need inndob + # This is a test that need innodb if ( $::mysqld_variables{'innodb'} eq "FALSE" ) { # innodb is not supported, skip it @@ -592,7 +594,6 @@ our @tags= ["include/have_debug.inc", "need_debug", 1], ["include/have_ndb.inc", "ndb_test", 1], ["include/have_ndb_extra.inc", "ndb_extra", 1], - ["include/have_multi_ndb.inc", "master_num", 2], ["require_manager", "require_manager", 1], ); From 7b965030418e9460c9f0324cdea0f0decd9686ee Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 Jan 2007 13:39:42 +0100 Subject: [PATCH 80/88] Bug#15518 Reusing a stmt that has failed during prepare does not clear error - Always reset error when calling mysql_stmt_prepare a second time - Set stmt->state to MYSQL_STMT_INIT_DONE before closing prepared stmt in server. - Add test to mysql_client_test - Remove mysql_stmt_close in mysqltest after each query - Close all open statements in mysqltest if disable_ps_protocol is called. client/mysqltest.c: Don't close the statement after each query - reprepare it in next query. When "disable_ps_protocol" is issued make sure to close all open statements. Otherwise the test for @@max_prepared_statements fails. But we also get a test that the statements that are open can be closed and reopened in the middle of the tests. libmysql/libmysql.c: Reset the last error every time mysql_stmt_prepare is called. Set state to MYSQL_STMT_INIT_DONE befoe closing it in the server. That way we will always have right status regardless of wheter close fails or not. tests/mysql_client_test.c: Add testcase for bug15518, re-prepare a previously prepare statement that has failed to prepare. Test also when connection to server has been lost inbetween. Change all assert to DIE_UNLESS so we get printout of line and an error message if it fails. --- client/mysqltest.c | 25 +++++++++-- libmysql/libmysql.c | 14 ++++-- tests/mysql_client_test.c | 93 +++++++++++++++++++++++++++++++++++---- 3 files changed, 117 insertions(+), 15 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 005f204d571..b163b5887e4 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -719,6 +719,20 @@ void close_connections() } +void close_statements() +{ + struct st_connection *con; + DBUG_ENTER("close_statements"); + for (con= connections; con < next_con; con++) + { + if (con->stmt) + mysql_stmt_close(con->stmt); + con->stmt= 0; + } + DBUG_VOID_RETURN; +} + + void close_files() { DBUG_ENTER("close_files"); @@ -2855,6 +2869,10 @@ void do_close_connection(struct st_command *command) } } #endif + if (next_con->stmt) + mysql_stmt_close(next_con->stmt); + next_con->stmt= 0; + mysql_close(&con->mysql); if (con->util_mysql) mysql_close(con->util_mysql); @@ -5050,10 +5068,7 @@ end: */ var_set_errno(mysql_stmt_errno(stmt)); -#ifndef BUG15518_FIXED - mysql_stmt_close(stmt); - cur_con->stmt= NULL; -#endif + DBUG_VOID_RETURN; } @@ -5838,6 +5853,8 @@ int main(int argc, char **argv) break; case Q_DISABLE_PS_PROTOCOL: ps_protocol_enabled= 0; + /* Close any open statements */ + close_statements(); break; case Q_ENABLE_PS_PROTOCOL: ps_protocol_enabled= ps_protocol; diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 6a592f64e49..a5dcb66f002 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2038,6 +2038,13 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length) DBUG_RETURN(1); } + /* + Reset the last error in any case: that would clear the statement + if the previous prepare failed. + */ + stmt->last_errno= 0; + stmt->last_error[0]= '\0'; + if ((int) stmt->state > (int) MYSQL_STMT_INIT_DONE) { /* This is second prepare with another statement */ @@ -2051,23 +2058,24 @@ mysql_stmt_prepare(MYSQL_STMT *stmt, const char *query, ulong length) */ stmt->bind_param_done= stmt->bind_result_done= FALSE; stmt->param_count= stmt->field_count= 0; - stmt->last_errno= 0; - stmt->last_error[0]= '\0'; free_root(&stmt->mem_root, MYF(MY_KEEP_PREALLOC)); int4store(buff, stmt->stmt_id); + /* + Close statement in server + If there was a 'use' result from another statement, or from mysql_use_result it won't be freed in mysql_stmt_free_result and we should get 'Commands out of sync' here. */ + stmt->state= MYSQL_STMT_INIT_DONE; if (stmt_command(mysql, COM_STMT_CLOSE, buff, 4, stmt)) { set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, mysql->net.sqlstate); DBUG_RETURN(1); } - stmt->state= MYSQL_STMT_INIT_DONE; } if (stmt_command(mysql, COM_STMT_PREPARE, query, length, stmt)) diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index aa993230a7f..22aa1e6ef21 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -11014,7 +11014,7 @@ static void test_view() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); rc= my_process_stmt_result(stmt); - assert(1 == rc); + DIE_UNLESS(1 == rc); } mysql_stmt_close(stmt); @@ -11057,7 +11057,7 @@ static void test_view_where() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); rc= my_process_stmt_result(stmt); - assert(4 == rc); + DIE_UNLESS(4 == rc); } mysql_stmt_close(stmt); @@ -11140,7 +11140,7 @@ static void test_view_2where() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); rc= my_process_stmt_result(stmt); - assert(0 == rc); + DIE_UNLESS(0 == rc); mysql_stmt_close(stmt); @@ -11193,7 +11193,7 @@ static void test_view_star() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); rc= my_process_stmt_result(stmt); - assert(0 == rc); + DIE_UNLESS(0 == rc); } mysql_stmt_close(stmt); @@ -11256,7 +11256,7 @@ static void test_view_insert() rc= mysql_stmt_execute(select_stmt); check_execute(select_stmt, rc); rowcount= (int)my_process_stmt_result(select_stmt); - assert((i+1) == rowcount); + DIE_UNLESS((i+1) == rowcount); } mysql_stmt_close(insert_stmt); mysql_stmt_close(select_stmt); @@ -11297,7 +11297,7 @@ static void test_left_join_view() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); rc= my_process_stmt_result(stmt); - assert(3 == rc); + DIE_UNLESS(3 == rc); } mysql_stmt_close(stmt); @@ -11373,7 +11373,7 @@ static void test_view_insert_fields() rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); rc= my_process_stmt_result(stmt); - assert(1 == rc); + DIE_UNLESS(1 == rc); mysql_stmt_close(stmt); rc= mysql_query(mysql, "DROP VIEW v1"); @@ -12851,6 +12851,82 @@ static void test_bug7990() DIE_UNLESS(!mysql_errno(mysql)); } +/* + Bug #15518 - Reusing a stmt that has failed during prepare + does not clear error +*/ + +static void test_bug15518() +{ + MYSQL_STMT *stmt; + MYSQL* mysql1; + int rc; + myheader("test_bug15518"); + + mysql1= mysql_init(NULL); + + if (!mysql_real_connect(mysql1, opt_host, opt_user, opt_password, + opt_db ? opt_db : "test", opt_port, opt_unix_socket, + CLIENT_MULTI_STATEMENTS)) + { + fprintf(stderr, "Failed to connect to the database\n"); + DIE_UNLESS(0); + } + + stmt= mysql_stmt_init(mysql1); + + /* + The prepare of foo should fail with errno 1064 since + it's not a valid query + */ + rc= mysql_stmt_prepare(stmt, "foo", 3); + if (!opt_silent) + fprintf(stdout, "rc: %d, mysql_stmt_errno: %d, mysql_errno: %d\n", + rc, mysql_stmt_errno(stmt), mysql_errno(mysql1)); + DIE_UNLESS(rc && mysql_stmt_errno(stmt) && mysql_errno(mysql1)); + + /* + Use the same stmt and reprepare with another query that + suceeds + */ + rc= mysql_stmt_prepare(stmt, "SHOW STATUS", 12); + if (!opt_silent) + fprintf(stdout, "rc: %d, mysql_stmt_errno: %d, mysql_errno: %d\n", + rc, mysql_stmt_errno(stmt), mysql_errno(mysql1)); + DIE_UNLESS(!rc || mysql_stmt_errno(stmt) || mysql_errno(mysql1)); + + mysql_stmt_close(stmt); + DIE_UNLESS(!mysql_errno(mysql1)); + + /* + part2, when connection to server has been closed + after first prepare + */ + stmt= mysql_stmt_init(mysql1); + rc= mysql_stmt_prepare(stmt, "foo", 3); + if (!opt_silent) + fprintf(stdout, "rc: %d, mysql_stmt_errno: %d, mysql_errno: %d\n", + rc, mysql_stmt_errno(stmt), mysql_errno(mysql1)); + DIE_UNLESS(rc && mysql_stmt_errno(stmt) && mysql_errno(mysql1)); + + /* Close connection to server */ + mysql_close(mysql1); + + /* + Use the same stmt and reprepare with another query that + suceeds. The prepare should fail with error 2013 since + connection to server has been closed. + */ + rc= mysql_stmt_prepare(stmt, "SHOW STATUS", 12); + if (!opt_silent) + fprintf(stdout, "rc: %d, mysql_stmt_errno: %d\n", + rc, mysql_stmt_errno(stmt)); + DIE_UNLESS(rc && mysql_stmt_errno(stmt)); + + mysql_stmt_close(stmt); + DIE_UNLESS(mysql_errno(mysql1)); +} + static void test_view_sp_list_fields() { @@ -15009,7 +15085,7 @@ static void test_bug17667() } else { - assert(0==1); + DIE_UNLESS(0==1); } } @@ -15588,6 +15664,7 @@ static struct my_tests_st my_tests[]= { { "test_bug15752", test_bug15752 }, { "test_bug21206", test_bug21206 }, { "test_bug21726", test_bug21726 }, + { "test_bug15518", test_bug15518 }, { 0, 0 } }; From adff49d95cc7909448bd702ebc020cacf22acf89 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 Jan 2007 17:47:41 +0100 Subject: [PATCH 81/88] Don't reuse prepared statements if running with reconnect enabled --- client/mysqltest.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client/mysqltest.c b/client/mysqltest.c index b163b5887e4..266c21d7880 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -5061,6 +5061,14 @@ end: dynstr_free(&ds_execute_warnings); } + + /* Close the statement if - no reconnect, need new prepare */ + if (mysql->reconnect) + { + mysql_stmt_close(stmt); + cur_con->stmt= NULL; + } + /* We save the return code (mysql_stmt_errno(stmt)) from the last call sent to the server into the mysqltest builtin variable $mysql_errno. This @@ -5864,6 +5872,8 @@ int main(int argc, char **argv) break; case Q_ENABLE_RECONNECT: set_reconnect(&cur_con->mysql, 1); + /* Close any open statements - no reconnect, need new prepare */ + close_statements(); break; case Q_DISABLE_PARSING: if (parsing_disabled == 0) From b461810d632e7c52f36e102bdb160a0aefe43b21 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 Jan 2007 17:52:17 +0100 Subject: [PATCH 82/88] Update xid's as an effect of not closing the prepared statements all the time --- mysql-test/t/mix_innodb_myisam_binlog.test | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mysql-test/t/mix_innodb_myisam_binlog.test b/mysql-test/t/mix_innodb_myisam_binlog.test index 66440f1236e..73b59409a90 100644 --- a/mysql-test/t/mix_innodb_myisam_binlog.test +++ b/mysql-test/t/mix_innodb_myisam_binlog.test @@ -29,7 +29,7 @@ insert into t2 select * from t1; commit; --replace_column 5 # ---replace_result "xid=15" "xid=8" +--replace_result "xid=14" "xid=8" show binlog events from 98; delete from t1; @@ -58,7 +58,7 @@ rollback to savepoint my_savepoint; commit; --replace_column 5 # ---replace_result "xid=48" "xid=25" +--replace_result "xid=47" "xid=25" show binlog events from 98; delete from t1; @@ -76,7 +76,7 @@ commit; select a from t1 order by a; # check that savepoints work :) --replace_column 5 # ---replace_result "xid=70" "xid=37" +--replace_result "xid=69" "xid=37" show binlog events from 98; # and when ROLLBACK is not explicit? @@ -109,7 +109,7 @@ insert into t1 values(9); insert into t2 select * from t1; --replace_column 5 # ---replace_result "xid=119" "xid=60" +--replace_result "xid=117" "xid=60" show binlog events from 98; # Check that when the query updat1ng the MyISAM table is the first in the @@ -122,13 +122,13 @@ insert into t1 values(10); # first make t1 non-empty begin; insert into t2 select * from t1; --replace_column 5 # ---replace_result "xid=133" "xid=66" +--replace_result "xid=131" "xid=66" show binlog events from 98; insert into t1 values(11); commit; --replace_column 5 # ---replace_result "xid=133" "xid=66" "xid=136" "xid=68" +--replace_result "xid=131" "xid=66" "xid=134" "xid=68" show binlog events from 98; @@ -147,7 +147,7 @@ insert into t2 select * from t1; commit; --replace_column 5 # ---replace_result "xid=155" "xid=78" +--replace_result "xid=153" "xid=78" show binlog events from 98; delete from t1; @@ -175,7 +175,7 @@ rollback to savepoint my_savepoint; commit; --replace_column 5 # ---replace_result "xid=187" "xid=94" +--replace_result "xid=185" "xid=94" show binlog events from 98; delete from t1; @@ -193,7 +193,7 @@ commit; select a from t1 order by a; # check that savepoints work :) --replace_column 5 # ---replace_result "xid=208" "xid=105" +--replace_result "xid=206" "xid=105" show binlog events from 98; # Test for BUG#5714, where a MyISAM update in the transaction used to @@ -254,7 +254,7 @@ disconnect con2; connection con3; select get_lock("lock1",60); --replace_column 5 # ---replace_result "xid=208" "xid=105" "xid=227" "xid=114" "xid=230" "xid=115" "xid=234" "xid=117" "xid=261" "xid=132" +--replace_result "xid=206" "xid=105" "xid=224" "xid=114" "xid=227" "xid=115" "xid=231" "xid=117" "xid=258" "xid=132" show binlog events from 98; do release_lock("lock1"); drop table t0,t2; From ef1940c9ff2ba04ffdfbd3dd7685a38490be5d33 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 Jan 2007 19:17:17 -0500 Subject: [PATCH 83/88] Disabled "plugin". Very minor memory leak keeping tree red. --- mysql-test/t/disabled.def | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index ce7bb345aad..8c2c4740f5e 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -38,4 +38,5 @@ synchronization : Bug#24529 Test 'synchronization' fails on Mac pushb flush2 : Bug#24805 Pushbuild can't handle test with --disable-log-bin mysql_upgrade : Bug#25074 mysql_upgrade gives inconsisten results +plugin : Bug#25659 memory leak via "plugins" test From b95f107371606a6771e28447750372e172513d95 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Jan 2007 11:51:52 +0100 Subject: [PATCH 84/88] Bug#25505 Myisam library compiler error on Windows myisam/mi_packrec.c: Combine the declaration of variable and assignment into one line since that is allowed befgore declaring another variable in C. --- myisam/mi_packrec.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/myisam/mi_packrec.c b/myisam/mi_packrec.c index 5363a3ecf23..51b0222e876 100644 --- a/myisam/mi_packrec.c +++ b/myisam/mi_packrec.c @@ -590,8 +590,7 @@ static void fill_quick_table(uint16 *table, uint bits, uint max_bits, static uint copy_decode_table(uint16 *to_pos, uint offset, uint16 *decode_table) { - uint prev_offset; - prev_offset= offset; + uint prev_offset= offset; DBUG_ENTER("copy_decode_table"); /* Descent on the left side. */ From f8e02a29cdffb333773bb93c84ad054491dffef3 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Jan 2007 13:43:03 +0100 Subject: [PATCH 85/88] Replace the --exec in a while loop that causes 3400 executions of cygwin/bash on windows with a small perl script that does exactly the same. --- mysql-test/t/mysql.test | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 3d022eb27e4..829be665e09 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -145,21 +145,24 @@ drop table t1; # # Bug #19216: Client crashes on long SELECT # ---exec echo "select" > $MYSQLTEST_VARDIR/tmp/b19216.tmp -# 3400 * 20 makes 68000 columns that is more than the max number that can fit -# in a 16 bit number. -let $i= 3400; -while ($i) -{ - --exec echo "'a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a'," >> $MYSQLTEST_VARDIR/tmp/b19216.tmp - dec $i; -} +# Create large SELECT +# - 3400 * 20 makes 68000 columns that is more than the +# max number that can fit in a 16 bit number. + +--perl +open(FILE,">","$ENV{'MYSQLTEST_VARDIR'}/tmp/b19216.tmp") or die; +print FILE "select\n"; +print FILE "'a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a',\n" x 3400; +print FILE "'b';\n"; +close FILE; +EOF ---exec echo "'b';" >> $MYSQLTEST_VARDIR/tmp/b19216.tmp --disable_query_log --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/b19216.tmp >/dev/null --enable_query_log +--remove_file $MYSQLTEST_VARDIR/tmp/b19216.tmp + # # Bug #20103: Escaping with backslash does not work # From 63cb7acee22997ae19c169979316791f5777ba7d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Jan 2007 13:22:50 -0500 Subject: [PATCH 86/88] Bug#23721: compile fails: check-cpu mishandles cpu flags with \ hyphen in it (like ds-cpl). convert illegal chars in cpu flags to '_' for variable assignment BUILD/check-cpu: convert illegal chars in cpu flags to '_' for variable assignment --- BUILD/check-cpu | 2 +- BitKeeper/etc/collapsed | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/BUILD/check-cpu b/BUILD/check-cpu index e207d12d972..5d8c9ef2df4 100755 --- a/BUILD/check-cpu +++ b/BUILD/check-cpu @@ -28,7 +28,7 @@ check_cpu () { fi # parse CPU flags - for flag in `$cpuinfo | grep '^flags' | sed -e 's/^flags.*: //'`; do + for flag in `$cpuinfo | grep '^flags' | sed -e 's/^flags.*: //' -e 's/[^a-zA-Z0-9_ ]/_/g'`; do eval cpu_flag_$flag=yes done else diff --git a/BitKeeper/etc/collapsed b/BitKeeper/etc/collapsed index 3b45bb4f30c..457d909ef74 100644 --- a/BitKeeper/etc/collapsed +++ b/BitKeeper/etc/collapsed @@ -3,3 +3,4 @@ 454f8960jsVT_kMKJtZ9OCgXoba0xQ 4554a95d7txO1DuO9G3nAizI3SkFAA 4554b3722d71SbPiI2Gx-RhbZjmuIQ +45ae6628gqKTsUFfnoNExadETVIkbA From efa5ba55a52366c5196bdd81ec7cc5605893cf86 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Jan 2007 15:01:28 -0500 Subject: [PATCH 87/88] errmsg update from Stefan. --- sql/share/errmsg.txt | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 1b9e1aa96ec..0f1c38973fa 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -950,7 +950,7 @@ ER_CON_COUNT_ERROR 08004 eng "Too many connections" jps "ڑ܂", est "Liiga palju samaaegseid hendusi" - fre "Trop de connections" + fre "Trop de connexions" ger "Zu viele Verbindungen" greek " ..." hun "Tul sok kapcsolat" @@ -1827,7 +1827,7 @@ ER_READY eng "%s: ready for connections.\nVersion: '%s' socket: '%s' port: %d" jps "%s: ", est "%s: ootab hendusi" - fre "%s: Prt pour des connections" + fre "%s: Prt pour des connexions" ger "%-.64s: Bereit fr Verbindungen.\nVersion: '%2' Socket: '%s' Port: %d" greek "%s: " hun "%s: kapcsolatra kesz" @@ -1950,7 +1950,7 @@ ER_IPSOCK_ERROR 08S01 eng "Can't create IP socket" jps "IP socket ܂", est "Ei suuda luua IP socketit" - fre "Ne peut crer la connection IP (socket)" + fre "Ne peut crer la connexion IP (socket)" ger "Kann IP-Socket nicht erzeugen" greek " IP socket" hun "Az IP socket nem hozhato letre" @@ -3031,7 +3031,7 @@ ER_HOST_IS_BLOCKED eng "Host '%-.64s' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'" jps "Host '%-.64s' many connection error ̂߁Aۂ܂. 'mysqladmin flush-hosts' ʼnĂ", est "Masin '%-.64s' on blokeeritud hulgaliste hendusvigade tttu. Blokeeringu saab thistada 'mysqladmin flush-hosts' ksuga" - fre "L'hte '%-.64s' est bloqu cause d'un trop grand nombre d'erreur de connection. Dbloquer le par 'mysqladmin flush-hosts'" + fre "L'hte '%-.64s' est bloqu cause d'un trop grand nombre d'erreur de connexion. Dbloquer le par 'mysqladmin flush-hosts'" ger "Host '%-.64s' blockiert wegen zu vieler Verbindungsfehler. Aufheben der Blockierung mit 'mysqladmin flush-hosts'" greek " . 'mysqladmin flush-hosts'" hun "A '%-.64s' host blokkolodott, tul sok kapcsolodasi hiba miatt. Hasznalja a 'mysqladmin flush-hosts' parancsot" @@ -3533,7 +3533,7 @@ ER_NET_READ_ERROR_FROM_PIPE 08S01 nla "Kreeg leesfout van de verbindings pipe" eng "Got a read error from the connection pipe" est "Viga hendustoru lugemisel" - fre "Erreur de lecture reue du pipe de connection" + fre "Erreur de lecture reue du pipe de connexion" ger "Lese-Fehler bei einer Verbindungs-Pipe" hun "Olvasasi hiba a kapcsolat soran" ita "Rilevato un errore di lettura dalla pipe di connessione" @@ -4331,7 +4331,7 @@ ER_TOO_MANY_USER_CONNECTIONS 42000 nla "Gebruiker %-.64s heeft reeds meer dan 'max_user_connections' actieve verbindingen" eng "User %-.64s already has more than 'max_user_connections' active connections" est "Kasutajal %-.64s on juba rohkem hendusi kui lubatud 'max_user_connections' muutujaga" - fre "L'utilisateur %-.64s possde dj plus de 'max_user_connections' connections actives" + fre "L'utilisateur %-.64s possde dj plus de 'max_user_connections' connexions actives" ger "Benutzer '%-.64s' hat mehr als 'max_user_connections' aktive Verbindungen" ita "L'utente %-.64s ha gia' piu' di 'max_user_connections' connessioni attive" por "Usurio '%-.64s' j possui mais que o valor mximo de conexes (max_user_connections) ativas" @@ -6009,15 +6009,22 @@ ER_BAD_LOG_STATEMENT ger "Sie knnen eine Logtabelle nicht '%s', wenn Loggen angeschaltet ist" ER_NON_INSERTABLE_TABLE eng "The target table %-.100s of the %s is not insertable-into" + ger "Die Zieltabelle %-.100s von %s ist nicht einfgbar" ER_CANT_RENAME_LOG_TABLE eng "Cannot rename '%s'. When logging enabled, rename to/from log table must rename two tables: the log table to an archive table and another table back to '%s'" + ger "Kann '%s' nicht umbenennen. Wenn Loggen angeschaltet ist, mssen beim Umbenennen zu/von einer Logtabelle zwei Tabellen angegeben werden: die Logtabelle zu einer Archivtabelle und eine weitere Tabelle zurck zu '%s'" ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT 42000 eng "Incorrect parameter count in the call to native function '%-.64s'" + ger "Falsche Anzahl von Parametern beim Aufruf der nativen Funktion '%-.64s'" ER_WRONG_PARAMETERS_TO_NATIVE_FCT 42000 eng "Incorrect parameters in the call to native function '%-.64s'" + ger "Falscher Parameter beim Aufruf der nativen Funktion '%-.64s'" ER_WRONG_PARAMETERS_TO_STORED_FCT 42000 eng "Incorrect parameters in the call to stored function '%-.64s'" + ger "Falsche Parameter beim Aufruf der gespeicherten Funktion '%-.64s'" ER_NATIVE_FCT_NAME_COLLISION - eng "This function '%-.64s' has the same name as a native function." + eng "This function '%-.64s' has the same name as a native function" + ger "Die Funktion '%-.64s' hat denselben Namen wie eine native Funktion" ER_BINLOG_PURGE_EMFILE eng "Too many files opened, please execute the command again" + ger "Zu viele offene Dateien, bitte fhren Sie den Befehl noch einmal aus" From 1a0bd37c4d5741e7297f318da07d77767a537ca7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Jan 2007 18:15:35 -0500 Subject: [PATCH 88/88] errmsg change --- mysql-test/r/sp.result | 8 ++++---- mysql-test/r/sp_gis.result | 4 ++-- mysql-test/r/udf.result | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 82a333bfa4a..c2d86ebc42d 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -5633,7 +5633,7 @@ drop function if exists pi; create function pi() returns varchar(50) return "pie, my favorite desert."; Warnings: -Note 1581 This function 'pi' has the same name as a native function. +Note 1581 This function 'pi' has the same name as a native function SET @save_sql_mode=@@sql_mode; SET SQL_MODE='IGNORE_SPACE'; select pi(), pi (); @@ -5682,15 +5682,15 @@ use test; create function `database`() returns varchar(50) return "Stored function database"; Warnings: -Note 1581 This function 'database' has the same name as a native function. +Note 1581 This function 'database' has the same name as a native function create function `current_user`() returns varchar(50) return "Stored function current_user"; Warnings: -Note 1581 This function 'current_user' has the same name as a native function. +Note 1581 This function 'current_user' has the same name as a native function create function md5(x varchar(50)) returns varchar(50) return "Stored function md5"; Warnings: -Note 1581 This function 'md5' has the same name as a native function. +Note 1581 This function 'md5' has the same name as a native function SET SQL_MODE='IGNORE_SPACE'; select database(), database (); database() database () diff --git a/mysql-test/r/sp_gis.result b/mysql-test/r/sp_gis.result index f46bcc90308..fddf2a6bc18 100644 --- a/mysql-test/r/sp_gis.result +++ b/mysql-test/r/sp_gis.result @@ -7,11 +7,11 @@ return 1; create function x() returns int return 2; Warnings: -Note 1581 This function 'x' has the same name as a native function. +Note 1581 This function 'x' has the same name as a native function create function y() returns int return 3; Warnings: -Note 1581 This function 'y' has the same name as a native function. +Note 1581 This function 'y' has the same name as a native function select a(); a() 1 diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result index abc654c4b74..a55e69526ae 100644 --- a/mysql-test/r/udf.result +++ b/mysql-test/r/udf.result @@ -209,7 +209,7 @@ select abs(myfunc_double(3) AS wrong); ERROR 42000: Incorrect parameters in the call to native function 'abs' drop function if exists pi; CREATE FUNCTION pi RETURNS STRING SONAME "should_not_parse.so"; -ERROR HY000: This function 'pi' has the same name as a native function. +ERROR HY000: This function 'pi' has the same name as a native function DROP FUNCTION IF EXISTS metaphon; CREATE FUNCTION metaphon(a int) RETURNS int return 0;