From f3b4465de979916621a14535f7465282535cbe2d Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/myoffice.izhnet.ru" <> Date: Thu, 5 Oct 2006 17:29:50 +0500 Subject: [PATCH 01/81] 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 | 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 32d1ad79b098055af4f7af2836c7411fd3bc1f8e Mon Sep 17 00:00:00 2001 From: "kaa@polly.local" <> Date: Mon, 27 Nov 2006 19:12:10 +0300 Subject: [PATCH 02/81] 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 | 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 07ee2594e5ee739a3ee35347bbca7f56556427c8 Mon Sep 17 00:00:00 2001 From: "jpipes@shakedown.(none)" <> Date: Wed, 6 Dec 2006 19:13:00 -0500 Subject: [PATCH 03/81] 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 | 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 ecbb4eb987c50060e8f33be9857de35168035d65 Mon Sep 17 00:00:00 2001 From: "Kristofer.Pettersson@naruto." <> Date: Thu, 7 Dec 2006 17:01:00 +0100 Subject: [PATCH 04/81] 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 | 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 38346fa9da4256fe69452c4fd9b8c403025991bd Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Thu, 7 Dec 2006 12:53:32 -0500 Subject: [PATCH 05/81] 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 0b41593db60e0670f27a76b8144e42e70e1589a8 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 8 Dec 2006 12:13:43 +0100 Subject: [PATCH 06/81] Fix problems with "make dist" and running from "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 8b6e5d4dfae202a2ae9abb29496efc22656f38c8 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 8 Dec 2006 13:37:40 +0100 Subject: [PATCH 07/81] 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 40927c0cb2a84743957f431f28e4d1b0f4dd6d51 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 8 Dec 2006 16:08:54 +0100 Subject: [PATCH 08/81] Bug#24498 Stack overflow in mysqltest - Thanks to Vasil Dimov for the patch! --- 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 9064723d1b64e7ad806864831722783a8e3f7b8d Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 8 Dec 2006 16:43:50 +0100 Subject: [PATCH 09/81] 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 | 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 3e43b86329017a1d5b3c26a252bcfff619a8b219 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 8 Dec 2006 16:48:49 +0100 Subject: [PATCH 10/81] 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 9636ead18d64231a9f743baea3715889b6930f5e Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 8 Dec 2006 17:09:07 +0100 Subject: [PATCH 11/81] Bug#19410 Test 'kill' fails on Windows + SCO --- 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 a58d08513bc814fc2513a4d5c0ab6f7b3c82264b Mon Sep 17 00:00:00 2001 From: "tsmith/tim@siva.hindu.god" <> Date: Fri, 8 Dec 2006 16:17:46 -0700 Subject: [PATCH 12/81] 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 4e34f77c857e246df4a3c806bace6dcb60fc7a62 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 11 Dec 2006 11:25:45 +0100 Subject: [PATCH 13/81] 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 | 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 510c9627e15f99528b01e1d8e42c100e2d09a1d1 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 11 Dec 2006 12:06:12 +0100 Subject: [PATCH 14/81] Fix merge error in mysql-test/Makefile.am --- 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 ba6d2bbf64e68ec7a061cbb96bcd76df81be8d4b Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 11 Dec 2006 12:16:20 +0100 Subject: [PATCH 15/81] Pass --no-defaults to embedded server to avoid that it reads any defaults file --- 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 0068e13e2fae2e1e0121cebc06bc0262d978b433 Mon Sep 17 00:00:00 2001 From: "Kristofer.Pettersson@naruto." <> Date: Mon, 11 Dec 2006 12:33:42 +0100 Subject: [PATCH 16/81] 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 | 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 8a7ea3c744eff9f87095bd53a45aa1ecc2f6c94c Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 11 Dec 2006 15:39:15 +0100 Subject: [PATCH 17/81] 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 | 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 eb1c28014245e1e3bf6c8343780e2047250a7d61 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 11 Dec 2006 16:43:21 +0100 Subject: [PATCH 18/81] 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 8bc9d6dd41c4c718456700b3c4f24828ecc66ac9 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 12 Dec 2006 12:28:02 +0100 Subject: [PATCH 19/81] 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 9eb8a3fbeeb9ef8daaf5669facbe710c3fea7de7 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 13 Dec 2006 23:30:20 +0100 Subject: [PATCH 20/81] change all auto_ptr in yaSSL 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 29f72a0ba1b24ce48806753f44ff725896fbec19 Mon Sep 17 00:00:00 2001 From: "thek@kpdesk.mysql.com" <> Date: Thu, 14 Dec 2006 13:23:31 +0100 Subject: [PATCH 21/81] 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 | 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 7e60087441bddebab63f78d24006747365cf95fb Mon Sep 17 00:00:00 2001 From: "thek@kpdesk.mysql.com" <> Date: Thu, 14 Dec 2006 13:45:17 +0100 Subject: [PATCH 22/81] 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 | 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 c41e307d85ba9399eb219fa5718ba8ab5af847c3 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback." <> Date: Thu, 14 Dec 2006 15:23:44 +0100 Subject: [PATCH 23/81] 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 | 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 4162e009cb2fc4dc72f35c15bda34768bfaf2807 Mon Sep 17 00:00:00 2001 From: "kaa@polly.local" <> Date: Thu, 14 Dec 2006 20:58:07 +0300 Subject: [PATCH 24/81] 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 | 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 bad9af4f58a73124928d19df9031ba35a3d5923e Mon Sep 17 00:00:00 2001 From: "jpipes@shakedown.(none)" <> Date: Thu, 14 Dec 2006 14:54:59 -0500 Subject: [PATCH 25/81] 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 54e7d71477b673db69538219ab5419d1fda33283 Mon Sep 17 00:00:00 2001 From: "mtaylor@qualinost.(none)" <> Date: Thu, 14 Dec 2006 12:18:36 -0800 Subject: [PATCH 26/81] 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 110b8af30396ba92efad2d51eb4ed82914903332 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 14 Dec 2006 21:48:08 +0100 Subject: [PATCH 27/81] 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 1feb18872125f3b275ed35609a5fdcfceed7ac06 Mon Sep 17 00:00:00 2001 From: "tsmith/tim@siva.hindu.god" <> Date: Thu, 14 Dec 2006 15:36:45 -0700 Subject: [PATCH 28/81] 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 82db3278aa364a12beaacbe2d567e250edf02d6f Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 15 Dec 2006 00:09:56 +0100 Subject: [PATCH 29/81] Add support for loading example plugin and add 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 8e5be1ad976d7dccb529680c9b74703f898491b3 Mon Sep 17 00:00:00 2001 From: "tsmith/tim@siva.hindu.god" <> Date: Thu, 14 Dec 2006 16:23:54 -0700 Subject: [PATCH 30/81] myisam.result: a test was moved from the .test file, but the results were not updated. --- 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 17fb4c5cbda4b96e69653e58c2f7daeab204baa0 Mon Sep 17 00:00:00 2001 From: "tsmith/tim@siva.hindu.god" <> Date: Thu, 14 Dec 2006 17:47:55 -0700 Subject: [PATCH 31/81] 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 24dfe0b0b40304a2cc2619a4b3dbc846b5428929 Mon Sep 17 00:00:00 2001 From: "thek@kpdesk.mysql.com" <> Date: Fri, 15 Dec 2006 07:56:01 +0100 Subject: [PATCH 32/81] 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 | 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 fe341ad904493610bc6f698ec3999a091f4e7bfc Mon Sep 17 00:00:00 2001 From: "msvensson@shellback." <> Date: Fri, 15 Dec 2006 10:41:24 +0100 Subject: [PATCH 33/81] 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 | 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 5a31bff73dae1c73227a3439bde882246aa244eb Mon Sep 17 00:00:00 2001 From: "msvensson@shellback." <> Date: Fri, 15 Dec 2006 10:45:25 +0100 Subject: [PATCH 34/81] 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 8187397f8ef0c9ee724954847a98c958432fbd01 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 15 Dec 2006 12:54:40 +0100 Subject: [PATCH 35/81] 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 da5e006dda575aca3442d66f8949cf9f0a81b8c1 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 15 Dec 2006 13:23:45 +0100 Subject: [PATCH 36/81] Bug#19209 Test 'rpl_openssl' hangs on Windows - 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 a246eb39bb4699eb6ba12349fa1a5f70058e29f0 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 15 Dec 2006 15:05:50 +0100 Subject: [PATCH 37/81] 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 | 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 30deafa958e7e9e95abf5e70f54a2ceedd87b443 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 15 Dec 2006 17:47:20 +0100 Subject: [PATCH 38/81] Calculate offset for wait time passed to set_timespec 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 3da37d3fa2d1f5db00afbff25006821e19e7e2cd Mon Sep 17 00:00:00 2001 From: "mtaylor@qualinost.(none)" <> Date: Fri, 15 Dec 2006 10:57:58 -0800 Subject: [PATCH 39/81] 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 57baef9584dd30cc3e0cb6bb62a26c6b1726d0d4 Mon Sep 17 00:00:00 2001 From: "mtaylor@qualinost.(none)" <> Date: Fri, 15 Dec 2006 12:25:09 -0800 Subject: [PATCH 40/81] Added support for /etc/mysql after /etc in the search path for my.cnf bug #25104 --- 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 265370f5c3a324c7d063739d6c0b42c1a746dc1b Mon Sep 17 00:00:00 2001 From: "mtaylor@qualinost.(none)" <> Date: Fri, 15 Dec 2006 12:34:36 -0800 Subject: [PATCH 41/81] Added /etc/mysql to my.cnf search path after /etc. bug #25104 --- 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 373e280eb32cc78f9f5a55335d7a584832ffc1cd Mon Sep 17 00:00:00 2001 From: "mtaylor@qualinost.(none)" <> Date: Fri, 15 Dec 2006 16:17:10 -0800 Subject: [PATCH 42/81] 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 d194a83b970823407f11c414f17ed9c075e51489 Mon Sep 17 00:00:00 2001 From: "mtaylor@qualinost.(none)" <> Date: Fri, 15 Dec 2006 18:04:09 -0800 Subject: [PATCH 43/81] 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 6cd4a816bcba1787ba34fe700efc75f1259bc156 Mon Sep 17 00:00:00 2001 From: "msvensson@maint1.mysql.com" <> Date: Mon, 18 Dec 2006 10:22:48 +0100 Subject: [PATCH 44/81] 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 c3fb91b782816dc726217713afcfba97efd3a357 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback." <> Date: Mon, 18 Dec 2006 11:09:47 +0100 Subject: [PATCH 45/81] Change windows pthread_cond_timedwait to use an absolute time value --- 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 395a0167c188d41c0d4cbd082b502e8c34da4afd Mon Sep 17 00:00:00 2001 From: "msvensson@shellback." <> Date: Mon, 18 Dec 2006 12:00:35 +0100 Subject: [PATCH 46/81] 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 fc45754fb0095f7eb888ef773c862677ec42d3ef Mon Sep 17 00:00:00 2001 From: "msvensson@shellback." <> Date: Mon, 18 Dec 2006 14:12:19 +0100 Subject: [PATCH 47/81] 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 b1eeb52cdad6fb043f4e6da8601b26fb6474571e Mon Sep 17 00:00:00 2001 From: "msvensson@maint1.mysql.com" <> Date: Mon, 18 Dec 2006 14:38:12 +0100 Subject: [PATCH 48/81] 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 09591de344344d0aaf28e11d794ed2c2fda4c5a3 Mon Sep 17 00:00:00 2001 From: "mtaylor@qualinost.(none)" <> Date: Mon, 18 Dec 2006 21:12:01 -0800 Subject: [PATCH 49/81] 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 6a304f3fc19fd4dcde5bb9c0c580b8f0f77dd439 Mon Sep 17 00:00:00 2001 From: "kaa@polly.local" <> Date: Tue, 19 Dec 2006 11:21:14 +0300 Subject: [PATCH 50/81] 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 221be0084e02597b9f885673d9b5122199fbd9af Mon Sep 17 00:00:00 2001 From: "kaa@polly.local" <> Date: Tue, 19 Dec 2006 12:21:41 +0300 Subject: [PATCH 51/81] 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 be0368c230fc9eafe64745102e42a930e8bd40ce Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 20 Dec 2006 16:53:06 +0100 Subject: [PATCH 52/81] 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 5ccd3608d59e8a19978212337fb755b5c22d0631 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 20 Dec 2006 16:54:37 +0100 Subject: [PATCH 53/81] 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 da6773f97b1b7066680629178a8648095256afde Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 20 Dec 2006 23:44:53 +0100 Subject: [PATCH 54/81] 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 945c35eee9654f317c179d3ba9edbc72d604ff17 Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.mysql.com" <> Date: Fri, 22 Dec 2006 00:05:40 +0100 Subject: [PATCH 55/81] Bug#24148 regression tests hang with SSL enabled - Don't call SSL_shutdown a second time --- 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 2e744d564498345e7863afcac9fd9c05a1c58055 Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.mysql.com" <> Date: Fri, 22 Dec 2006 00:38:34 +0100 Subject: [PATCH 56/81] 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 | 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 73d82523a3862016589299d69de8271529d0338d Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.mysql.com" <> Date: Fri, 22 Dec 2006 09:59:41 +0100 Subject: [PATCH 57/81] 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 0af60de724dcab23ce6e5d052e8fa3210c1881ed Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.mysql.com" <> Date: Fri, 22 Dec 2006 10:20:20 +0100 Subject: [PATCH 58/81] Cset exclude: msvensson@neptunus.(none)|ChangeSet|20061215122345|24188 --- 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 c3b6f11091377595ee77f12cec4587bd0a8b803b Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.mysql.com" <> Date: Fri, 22 Dec 2006 12:35:06 +0100 Subject: [PATCH 59/81] Potential use of NULL pointer in 'plugin_for_each_with_mask', check pointer before referencing it. --- 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 86a9ad6883325e2034887984bc1dc0fcc9423092 Mon Sep 17 00:00:00 2001 From: "kaa@polly.local" <> Date: Fri, 22 Dec 2006 15:30:37 +0300 Subject: [PATCH 60/81] 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) --- 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 70b2f28f555de600931483e885398631043367fe Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.mysql.com" <> Date: Fri, 22 Dec 2006 13:34:23 +0100 Subject: [PATCH 61/81] 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 4563cb45f26de5856b1e0dd38cc1a09a83ae076e Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.mysql.com" <> Date: Fri, 22 Dec 2006 13:57:33 +0100 Subject: [PATCH 62/81] Add the missing file --- 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 50726b2322edac8e93489fcb5ef75a5634222d44 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Fri, 22 Dec 2006 15:37:37 -0500 Subject: [PATCH 63/81] 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. --- 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 1176caa58d2ee6bbbb6ebe6c0969317c5ae84055 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Fri, 22 Dec 2006 21:35:40 -0500 Subject: [PATCH 64/81] 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 828121bd6d3e2fc3fbbde554fbf5182517698bb8 Mon Sep 17 00:00:00 2001 From: "tsmith/tim@siva.hindu.god" <> Date: Tue, 26 Dec 2006 12:42:54 -0700 Subject: [PATCH 65/81] 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 | 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 ee120139ab34a8f4ed4105745afd1d4be0348aec Mon Sep 17 00:00:00 2001 From: "cmiller@calliope.local.cmiller/calliope.local" <> Date: Fri, 29 Dec 2006 16:07:33 -0500 Subject: [PATCH 66/81] Bug#23950: misplaced code in mysqld.cc, main() Moved MY_INIT() to top of main(), where it should be. --- 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 b54f20f865a1b396b778c99e2f05e359d00fe371 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Sat, 6 Jan 2007 12:34:16 -0500 Subject: [PATCH 67/81] 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 | 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 95e73e66f099e403c5ab79ac285eea910c8f4ed7 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Sat, 6 Jan 2007 18:32:55 -0500 Subject: [PATCH 68/81] 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 1942fd0a499736a9d56744a145bb246da5b955c3 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Sat, 6 Jan 2007 18:40:43 -0500 Subject: [PATCH 69/81] 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 993f325d378f96deb7aeae9279f8c01f60e59695 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Sun, 7 Jan 2007 12:21:42 -0500 Subject: [PATCH 70/81] Post-merge cleanup and fix minor BUILD/... "="-equality syntax error. --- 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 34122240cf5fbf4ddc86ff02cf2b7584d0ec81fa Mon Sep 17 00:00:00 2001 From: "tnurnberg@mysql.com/sin.azundris.com" <> Date: Tue, 9 Jan 2007 20:23:12 +0100 Subject: [PATCH 71/81] 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 | 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 270752654eaa57d759044484095a77a568c7e0cc Mon Sep 17 00:00:00 2001 From: "Kristofer.Pettersson@naruto." <> Date: Thu, 11 Jan 2007 09:40:17 +0100 Subject: [PATCH 72/81] 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 | 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 2706b3d7374c7a4db23a4078d0bf6ed7cc39fbd9 Mon Sep 17 00:00:00 2001 From: "cmiller@221.54.57.10.in-addr.arpa.cmiller/221.54.57.10.in-addr.arpa" <> Date: Thu, 11 Jan 2007 14:54:03 -0500 Subject: [PATCH 73/81] 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 | 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 f10a24314d61c011b8a7c99f1db0c6f4d2e763e0 Mon Sep 17 00:00:00 2001 From: "iggy@recycle.(none)" <> Date: Mon, 15 Jan 2007 10:00:29 -0500 Subject: [PATCH 74/81] 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 8540eac24aadccd9dd22e8a37ecdcaae8d350e66 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 15 Jan 2007 21:50:31 +0100 Subject: [PATCH 75/81] 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 | 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 52a19378d82f3e7c29759268902d6be54689006f Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 16 Jan 2007 09:38:09 +0100 Subject: [PATCH 76/81] 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 08cbe046707ce0b44ab042b2d718973a2c5d9ae1 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 16 Jan 2007 09:47:03 +0100 Subject: [PATCH 77/81] 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 | 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 eee98226e729c1a258f6b77078b2b7bdf39c21a9 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Tue, 16 Jan 2007 19:17:17 -0500 Subject: [PATCH 78/81] 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 332f9ff8b480fcec7259934b1a7b78f126bcaee1 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Wed, 17 Jan 2007 13:22:50 -0500 Subject: [PATCH 79/81] 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 | 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 abd057be56264aee6c9a6c399449d021571e18e4 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Wed, 17 Jan 2007 15:01:28 -0500 Subject: [PATCH 80/81] 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 f2d4988c37afa398cd73b087bc3274f175c4f5b3 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Wed, 17 Jan 2007 18:15:35 -0500 Subject: [PATCH 81/81] 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;