From 6b7b95637a1cbe2ddd76b87017a9bdd434650073 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 May 2007 09:37:50 +0200 Subject: [PATCH 01/33] BUG#24732 manifest file was not included in VS2005 amd64 builds CMakeLists.txt: BUG#24732 prevent VS2005 from overwriting our generated manifest --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5a1c0cfaba..890ee2676e8 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,6 +154,11 @@ IF(EMBED_MANIFESTS) # Disable automatic manifest generation. STRING(REPLACE "/MANIFEST" "/MANIFEST:NO" CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}) + # Explicitly disable it since it is the default for newer versions of VS + STRING(REGEX MATCH "MANIFEST:NO" tmp_manifest ${CMAKE_EXE_LINKER_FLAGS}) + IF(NOT tmp_manifest) + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") + ENDIF(tmp_manifest) # Set the processor architecture. IF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64") SET(PROCESSOR_ARCH "X64") From 22ae0985ea934023543b772401e2e99175706cf1 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 May 2007 09:42:46 +0200 Subject: [PATCH 02/33] BUG#24732 manifest file was not included in VS2005 amd64 builds (5.1 tree version) CMakeLists.txt: BUG#24732 prevent VS2005 from overwriting our generated manifest --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 02755c5d138..bb5e53be20e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,6 +153,11 @@ IF(EMBED_MANIFESTS) # Disable automatic manifest generation. STRING(REPLACE "/MANIFEST" "/MANIFEST:NO" CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}) + # Explicitly disable it since it is the default for newer versions of VS + STRING(REGEX MATCH "MANIFEST:NO" tmp_manifest ${CMAKE_EXE_LINKER_FLAGS}) + IF(NOT tmp_manifest) + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO") + ENDIF(tmp_manifest) # Set the processor architecture. IF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64") SET(PROCESSOR_ARCH "X64") From 115797cb1afe962d7604e689f22bde66c11823bb Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 May 2007 21:28:04 +0200 Subject: [PATCH 03/33] win/Makefile.am : No trailing blank after a continuation line marker ! win/Makefile.am: No trailing blank after a continuation line marker ! --- win/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/Makefile.am b/win/Makefile.am index 1bf7cce8396..279183480d8 100644 --- a/win/Makefile.am +++ b/win/Makefile.am @@ -14,7 +14,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ## Process this file with automake to create Makefile.in -EXTRA_DIST = build-vs71.bat build-vs8.bat build-vs8_x64.bat configure.js README \ +EXTRA_DIST = build-vs71.bat build-vs8.bat build-vs8_x64.bat configure.js README \ mysql_manifest.cmake create_manifest.js # Don't update the files from bitkeeper From 6c3efc5ac872cddc209bf69c5808ce2d4cce1e6f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 May 2007 16:38:34 -0700 Subject: [PATCH 04/33] Added additional QA functional test suites to the test-bt section in the Makefile.am file Makefile.am: Added additional QA functional test suites to the test-bt section --- Makefile.am | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile.am b/Makefile.am index cbca477fbf7..c212173eed1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -127,6 +127,12 @@ test-bt: @PERL@ ./mysql-test-run.pl --force --comment=funcs1_ps --ps-protocol --suite=funcs_1 -cd mysql-test ; MTR_BUILD_THREAD=auto \ @PERL@ ./mysql-test-run.pl --force --comment=funcs2 --suite=funcs_2 + -cd mysql-test ; MTR_BUILD_THREAD=auto \ + @PERL@ ./mysql-test-run.pl --force --comment=rpl --suite=rpl + -cd mysql-test ; MTR_BUILD_THREAD=auto \ + @PERL@ ./mysql-test-run.pl --force --comment=partitions --suite=partitions + -cd mysql-test ; MTR_BUILD_THREAD=auto \ + @PERL@ ./mysql-test-run.pl --force --comment=jp --suite=jp test-bt-debug: -cd mysql-test ; MTR_BUILD_THREAD=auto \ From 8385df7cf412e647142843f888781c66659c1ac2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 May 2007 07:58:35 -0700 Subject: [PATCH 05/33] Correcting the 'partitions' suite name to its 'short' version - 'parts' in the Makefile.am file Makefile.am: Correcting the 'partitions' suite name to its 'short' version - 'parts' --- Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index c212173eed1..41ddf026a63 100644 --- a/Makefile.am +++ b/Makefile.am @@ -130,7 +130,7 @@ test-bt: -cd mysql-test ; MTR_BUILD_THREAD=auto \ @PERL@ ./mysql-test-run.pl --force --comment=rpl --suite=rpl -cd mysql-test ; MTR_BUILD_THREAD=auto \ - @PERL@ ./mysql-test-run.pl --force --comment=partitions --suite=partitions + @PERL@ ./mysql-test-run.pl --force --comment=partitions --suite=parts -cd mysql-test ; MTR_BUILD_THREAD=auto \ @PERL@ ./mysql-test-run.pl --force --comment=jp --suite=jp @@ -157,7 +157,7 @@ test-ext-rpl: test-ext-partitions: cd mysql-test ; \ - @PERL@ ./mysql-test-run.pl --force --suite=partitions + @PERL@ ./mysql-test-run.pl --force --suite=parts test-ext-jp: cd mysql-test ; \ From 10be360ece3e148164aa9c83d45a2526c34262e7 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 May 2007 16:05:20 +0300 Subject: [PATCH 06/33] bug#28273: GROUP_CONCAT and ORDER BY: No warning when result gets truncated. When using GROUP_CONCAT with ORDER BY, a tree is used for the sorting, as opposed to normal nested loops join used when there is no ORDER BY. The tree traversal that generates the result counts the lines that have been cut down. (as they get cut down to the field's max_size) But the check of that count was before the tree traversal, so no warning was generated if the output is truncated. Fixed by moving the check to after the tree traversal. mysql-test/r/func_gconcat.result: bug#28273: correct result mysql-test/t/func_gconcat.test: bug#28273: test case sql/item_sum.cc: bug#28273: the fix Moved the code that outputs a warning to after temporary table (tree) is traversed. --- mysql-test/r/func_gconcat.result | 26 ++++++++++++++++++++++++++ mysql-test/t/func_gconcat.test | 14 ++++++++++++++ sql/item_sum.cc | 9 ++++----- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 71419b5b2c3..20df776ec1b 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -737,4 +737,30 @@ SELECT GROUP_CONCAT(DISTINCT UCASE(b)) FROM t1; GROUP_CONCAT(DISTINCT UCASE(b)) ONE.1,TWO.2,ONE.3 DROP TABLE t1; +CREATE TABLE t1( a VARCHAR( 10 ), b INT ); +INSERT INTO t1 VALUES ( repeat( 'a', 10 ), 1), +( repeat( 'b', 10 ), 2); +SET group_concat_max_len = 20; +SELECT GROUP_CONCAT( a ) FROM t1; +GROUP_CONCAT( a ) +aaaaaaaaaa,bbbbbbbbb +Warnings: +Warning 1260 1 line(s) were cut by GROUP_CONCAT() +SELECT GROUP_CONCAT( DISTINCT a ) FROM t1; +GROUP_CONCAT( DISTINCT a ) +aaaaaaaaaa,bbbbbbbbb +Warnings: +Warning 1260 1 line(s) were cut by GROUP_CONCAT() +SELECT GROUP_CONCAT( a ORDER BY b ) FROM t1; +GROUP_CONCAT( a ORDER BY b ) +aaaaaaaaaa,bbbbbbbbb +Warnings: +Warning 1260 1 line(s) were cut by GROUP_CONCAT() +SELECT GROUP_CONCAT( DISTINCT a ORDER BY b ) FROM t1; +GROUP_CONCAT( DISTINCT a ORDER BY b ) +aaaaaaaaaa,bbbbbbbbb +Warnings: +Warning 1260 1 line(s) were cut by GROUP_CONCAT() +SET group_concat_max_len = DEFAULT; +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 0dd82864520..7771f216f69 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -507,4 +507,18 @@ SELECT GROUP_CONCAT(DISTINCT UCASE(a)) FROM t1; SELECT GROUP_CONCAT(DISTINCT UCASE(b)) FROM t1; DROP TABLE t1; +# +# Bug #28273: GROUP_CONCAT and ORDER BY: No warning when result gets truncated. +# +CREATE TABLE t1( a VARCHAR( 10 ), b INT ); +INSERT INTO t1 VALUES ( repeat( 'a', 10 ), 1), + ( repeat( 'b', 10 ), 2); +SET group_concat_max_len = 20; +SELECT GROUP_CONCAT( a ) FROM t1; +SELECT GROUP_CONCAT( DISTINCT a ) FROM t1; +SELECT GROUP_CONCAT( a ORDER BY b ) FROM t1; +SELECT GROUP_CONCAT( DISTINCT a ORDER BY b ) FROM t1; +SET group_concat_max_len = DEFAULT; +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 4579ecd48ae..d6b31d43389 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3339,6 +3339,10 @@ String* Item_func_group_concat::val_str(String* str) DBUG_ASSERT(fixed == 1); if (null_value) return 0; + if (!result.length() && tree) + /* Tree is used for sorting as in ORDER BY */ + tree_walk(tree, (tree_walk_action)&dump_leaf_key, (void*)this, + left_root_right); if (count_cut_values && !warning) { /* @@ -3350,11 +3354,6 @@ String* Item_func_group_concat::val_str(String* str) ER_CUT_VALUE_GROUP_CONCAT, ER(ER_CUT_VALUE_GROUP_CONCAT)); } - if (result.length()) - return &result; - if (tree) - tree_walk(tree, (tree_walk_action)&dump_leaf_key, (void*)this, - left_root_right); return &result; } From 373ec1ef111319d67e5f53ce134d0c16bfbb0b11 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 May 2007 14:59:23 +0200 Subject: [PATCH 07/33] Raise version number after cloning 5.0.42 --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 1026c855bf2..a779ab80ced 100644 --- a/configure.in +++ b/configure.in @@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 5.0.42) +AM_INIT_AUTOMAKE(mysql, 5.0.44) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 @@ -23,7 +23,7 @@ NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0 # ndb version NDB_VERSION_MAJOR=5 NDB_VERSION_MINOR=0 -NDB_VERSION_BUILD=42 +NDB_VERSION_BUILD=44 NDB_VERSION_STATUS="" # Set all version vars based on $VERSION. How do we do this more elegant ? From fca58c95566c5a7bf8abf7386aa2b03890d85e05 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 May 2007 16:41:09 -0700 Subject: [PATCH 08/33] Fixed bug #27937: crash for the the second execution of a prepared statement from a UNION query with ORDER BY an expression containing RAND(). The crash happened because the global order by list in the union query was not re-initialized for execution. (Local order by lists were re-initialized though). mysql-test/r/ps.result: Added a test case for bug #27937. mysql-test/t/ps.test: Added a test case for bug #27937. sql/sql_union.cc: Fixed bug #27937: crash for the the second execution of a prepared statement from a UNION query with ORDER BY an expression containing RAND(). The crash happened because the global order by list in the union query was not re-initialized for execution. (Local order by lists were re-initialized though). Added re-initialization of the global order by list in the function st_select_lex_unit::init_prepare_fake_select_lex. --- mysql-test/r/ps.result | 22 ++++++++++++++++++++++ mysql-test/t/ps.test | 18 ++++++++++++++++++ sql/sql_union.cc | 5 +++++ 3 files changed, 45 insertions(+) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index d8a75737efc..49e4bf2f318 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -1087,4 +1087,26 @@ t2 CREATE TABLE `t2` ( drop database mysqltest; deallocate prepare stmt1; deallocate prepare stmt2; +CREATE TABLE t1(a int); +INSERT INTO t1 VALUES (2), (3), (1); +PREPARE st1 FROM +'(SELECT a FROM t1) UNION (SELECT a+10 FROM t1) ORDER BY RAND()*0+a'; +EXECUTE st1; +a +1 +2 +3 +11 +12 +13 +EXECUTE st1; +a +1 +2 +3 +11 +12 +13 +DEALLOCATE PREPARE st1; +DROP TABLE t1; End of 4.1 tests. diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index a0133897f50..5e5dcc36b19 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -1128,4 +1128,22 @@ drop database mysqltest; deallocate prepare stmt1; deallocate prepare stmt2; # + +# +# Bug #27937: crash on the second execution for prepared statement +# from UNION with ORDER BY an expression containing RAND() +# + +CREATE TABLE t1(a int); +INSERT INTO t1 VALUES (2), (3), (1); + +PREPARE st1 FROM + '(SELECT a FROM t1) UNION (SELECT a+10 FROM t1) ORDER BY RAND()*0+a'; + +EXECUTE st1; +EXECUTE st1; + +DEALLOCATE PREPARE st1; +DROP TABLE t1; + --echo End of 4.1 tests. diff --git a/sql/sql_union.cc b/sql/sql_union.cc index f3f814831f5..615d060a5a8 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -135,6 +135,11 @@ st_select_lex_unit::init_prepare_fake_select_lex(THD *thd) fake_select_lex->table_list.link_in_list((byte *)&result_table_list, (byte **) &result_table_list.next); + for (ORDER *order= (ORDER *) global_parameters->order_list.first; + order; + order= order->next) + order->item= &order->item_ptr; + return options_tmp; } From 963fae4b80d6ad96d495a9f187a1897ef0f88a07 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 May 2007 18:26:00 -0700 Subject: [PATCH 09/33] Post-merge fix. --- mysql-test/r/ps.result | 22 ++++++++++++++++++++++ mysql-test/t/ps.test | 18 ++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 20bff6bda1c..662386f468a 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -1114,6 +1114,28 @@ execute stmt; show create table t1; drop table t1; deallocate prepare stmt; +CREATE TABLE t1(a int); +INSERT INTO t1 VALUES (2), (3), (1); +PREPARE st1 FROM +'(SELECT a FROM t1) UNION (SELECT a+10 FROM t1) ORDER BY RAND()*0+a'; +EXECUTE st1; +a +1 +2 +3 +11 +12 +13 +EXECUTE st1; +a +1 +2 +3 +11 +12 +13 +DEALLOCATE PREPARE st1; +DROP TABLE t1; End of 4.1 tests. create table t1 (a varchar(20)); insert into t1 values ('foo'); diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 3fbcf84a1f9..d5290f4ee5c 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -1194,6 +1194,24 @@ show create table t1; --enable_warnings drop table t1; deallocate prepare stmt; +# + +# +# Bug #27937: crash on the second execution for prepared statement +# from UNION with ORDER BY an expression containing RAND() +# + +CREATE TABLE t1(a int); +INSERT INTO t1 VALUES (2), (3), (1); + +PREPARE st1 FROM + '(SELECT a FROM t1) UNION (SELECT a+10 FROM t1) ORDER BY RAND()*0+a'; + +EXECUTE st1; +EXECUTE st1; + +DEALLOCATE PREPARE st1; +DROP TABLE t1; --echo End of 4.1 tests. From 8762539d477d949a5bd4c2df8b03b28727e5ee98 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 May 2007 23:55:18 -0700 Subject: [PATCH 10/33] Fixed bug #28272: crash that occurs when running an EXPLAIN command for a query over an empty table right after its creation. The crash is the result of an attempt made by JOIN::optimize to evaluate the WHERE condition when no records have been actually read. The added test case can reproduce the crash only with InnoDB tables and only with 5.0.x. mysql-test/r/innodb_mysql.result: Added a test case for bug #28272. mysql-test/t/innodb_mysql.test: Added a test case for bug #28272. sql/sql_select.cc: Fixed bug #28272: crash that occurs when running an EXPLAIN command for a query over an empty table right after its creation. The crash is the result of an attempt made by JOIN::optimize to evaluate the WHERE condition when no records have been actually read. Such attempts could be observed only with EXPLAIN commands. Now at the optimization phase the WHERE condition is never evaluated if there is no record previously read from the table. --- mysql-test/r/innodb_mysql.result | 21 +++++++++++++++++++++ mysql-test/t/innodb_mysql.test | 25 +++++++++++++++++++++++++ sql/sql_select.cc | 6 ++++++ 3 files changed, 52 insertions(+) diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 12c8b414d2d..029f3768f9b 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -161,4 +161,25 @@ SELECT * FROM t1; c1 cnt 1a 2 DROP TABLE t1; +CREATE TABLE t1 ( +a1 decimal(10,0) DEFAULT NULL, +a2 blob, +a3 time DEFAULT NULL, +a4 blob, +a5 char(175) DEFAULT NULL, +a6 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', +a7 tinyblob, +INDEX idx (a6,a7(239),a5) +) ENGINE=InnoDB; +EXPLAIN SELECT a4 FROM t1 WHERE +a6=NULL AND +a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +EXPLAIN SELECT t1.a4 FROM t1, t1 t WHERE +t.a6=t.a6 AND t1.a6=NULL AND +t1.a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +DROP TABLE t1; End of 4.1 tests diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test index 0973385dc5b..b5e7fc6e405 100644 --- a/mysql-test/t/innodb_mysql.test +++ b/mysql-test/t/innodb_mysql.test @@ -191,4 +191,29 @@ INSERT INTO t1 (c1) VALUES ('1b') ON DUPLICATE KEY UPDATE cnt=cnt+1; SELECT * FROM t1; DROP TABLE t1; +# +# Bug #28272: EXPLAIN for SELECT from an empty InnoDB table +# + +CREATE TABLE t1 ( + a1 decimal(10,0) DEFAULT NULL, + a2 blob, + a3 time DEFAULT NULL, + a4 blob, + a5 char(175) DEFAULT NULL, + a6 timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + a7 tinyblob, + INDEX idx (a6,a7(239),a5) +) ENGINE=InnoDB; + +EXPLAIN SELECT a4 FROM t1 WHERE +a6=NULL AND +a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS'; + +EXPLAIN SELECT t1.a4 FROM t1, t1 t WHERE +t.a6=t.a6 AND t1.a6=NULL AND +t1.a4='UNcT5pIde4I6c2SheTo4gt92OV1jgJCVkXmzyf325R1DwLURkbYHwhydANIZMbKTgdcR5xS'; + +DROP TABLE t1; + --echo End of 4.1 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 656d1b5639a..8b5664a7f96 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -634,6 +634,12 @@ JOIN::optimize() DBUG_PRINT("error",("Error: make_select() failed")); DBUG_RETURN(1); } + if (conds &&!outer_join && const_table_map != found_const_table_map && + (select_options & SELECT_DESCRIBE) && + select_lex->master_unit() == &thd->lex->unit) // upper level SELECT + { + conds=new Item_int((longlong) 0,1); // Always false + } if (make_join_select(this, select, conds)) { zero_result_cause= From 9949755aeb029cf0728ceeead128467e60dd1551 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 May 2007 12:45:50 +0500 Subject: [PATCH 11/33] WL#3823 Modify VARIABLE_VALUE columns to VARCHAR within INFORMATION_SCHEMA STATUS tables mysql-test/r/compress.result: result fix mysql-test/r/information_schema.result: result fix mysql-test/r/openssl_1.result: result fix mysql-test/r/rpl_packet.result: result fix mysql-test/r/status.result: result fix --- mysql-test/r/compress.result | 2 +- mysql-test/r/information_schema.result | 2 - mysql-test/r/openssl_1.result | 4 +- mysql-test/r/rpl_packet.result | 2 +- mysql-test/r/status.result | 18 +- sql/sql_select.cc | 3 +- sql/sql_show.cc | 248 +++++-------------------- 7 files changed, 60 insertions(+), 219 deletions(-) diff --git a/mysql-test/r/compress.result b/mysql-test/r/compress.result index 2eced78b07a..e46b56f4215 100644 --- a/mysql-test/r/compress.result +++ b/mysql-test/r/compress.result @@ -3,7 +3,7 @@ Variable_name Value Compression ON select * from information_schema.session_status where variable_name= 'COMPRESSION'; VARIABLE_NAME VARIABLE_VALUE -COMPRESSION 1.0000000 +COMPRESSION ON drop table if exists t1,t2,t3,t4; CREATE TABLE t1 ( Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index fc7a45445a6..709246edcf1 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -761,7 +761,6 @@ information_schema COLUMNS COLUMN_DEFAULT information_schema COLUMNS COLUMN_TYPE information_schema EVENTS EVENT_DEFINITION information_schema EVENTS SQL_MODE -information_schema GLOBAL_VARIABLES VARIABLE_VALUE information_schema PARTITIONS PARTITION_EXPRESSION information_schema PARTITIONS SUBPARTITION_EXPRESSION information_schema PARTITIONS PARTITION_DESCRIPTION @@ -769,7 +768,6 @@ information_schema PLUGINS PLUGIN_DESCRIPTION information_schema PROCESSLIST INFO information_schema ROUTINES ROUTINE_DEFINITION information_schema ROUTINES SQL_MODE -information_schema SESSION_VARIABLES VARIABLE_VALUE information_schema TRIGGERS ACTION_CONDITION information_schema TRIGGERS ACTION_STATEMENT information_schema TRIGGERS SQL_MODE diff --git a/mysql-test/r/openssl_1.result b/mysql-test/r/openssl_1.result index c01a9643e8a..5e29e30732f 100644 --- a/mysql-test/r/openssl_1.result +++ b/mysql-test/r/openssl_1.result @@ -73,8 +73,8 @@ variable_name LIKE 'SSL_CALLBACK_CACHE_HITS'; END$$ SELECT variable_name, variable_value FROM thread_status; variable_name variable_value -SSL_ACCEPTS 0.0000000 -SSL_CALLBACK_CACHE_HITS 0.0000000 +SSL_ACCEPTS 0 +SSL_CALLBACK_CACHE_HITS 0 DROP TABLE thread_status; SET GLOBAL event_scheduler=0; End of 5.1 tests diff --git a/mysql-test/r/rpl_packet.result b/mysql-test/r/rpl_packet.result index 8f4a16341b6..981c234d380 100644 --- a/mysql-test/r/rpl_packet.result +++ b/mysql-test/r/rpl_packet.result @@ -19,7 +19,7 @@ Variable_name Value Slave_running ON select * from information_schema.session_status where variable_name= 'SLAVE_RUNNING'; VARIABLE_NAME VARIABLE_VALUE -SLAVE_RUNNING 1.0000000 +SLAVE_RUNNING ON drop database DB_NAME_OF_MAX_LENGTH_AKA_NAME_LEN_64_BYTES_____________________; SET @@global.max_allowed_packet=4096; SET @@global.net_buffer_length=4096; diff --git a/mysql-test/r/status.result b/mysql-test/r/status.result index e9891e4d495..b6dcbc251d7 100644 --- a/mysql-test/r/status.result +++ b/mysql-test/r/status.result @@ -5,8 +5,8 @@ Table_locks_immediate 0 Table_locks_waited 0 select * from information_schema.session_status where variable_name like 'Table_lock%'; VARIABLE_NAME VARIABLE_VALUE -TABLE_LOCKS_IMMEDIATE 0.0000000 -TABLE_LOCKS_WAITED 0.0000000 +TABLE_LOCKS_IMMEDIATE 0 +TABLE_LOCKS_WAITED 0 SET SQL_LOG_BIN=0; drop table if exists t1; create table t1(n int) engine=myisam; @@ -22,8 +22,8 @@ Table_locks_immediate 3 Table_locks_waited 1 select * from information_schema.session_status where variable_name like 'Table_lock%'; VARIABLE_NAME VARIABLE_VALUE -TABLE_LOCKS_IMMEDIATE 3.0000000 -TABLE_LOCKS_WAITED 1.0000000 +TABLE_LOCKS_IMMEDIATE 3 +TABLE_LOCKS_WAITED 1 drop table t1; select 1; 1 @@ -63,7 +63,7 @@ Variable_name Value Max_used_connections 1 SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections'; VARIABLE_NAME VARIABLE_VALUE -MAX_USED_CONNECTIONS 1.0000000 +MAX_USED_CONNECTIONS 1 SET @save_thread_cache_size=@@thread_cache_size; SET GLOBAL thread_cache_size=3; SHOW STATUS LIKE 'max_used_connections'; @@ -71,26 +71,26 @@ Variable_name Value Max_used_connections 3 SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections'; VARIABLE_NAME VARIABLE_VALUE -MAX_USED_CONNECTIONS 3.0000000 +MAX_USED_CONNECTIONS 3 FLUSH STATUS; SHOW STATUS LIKE 'max_used_connections'; Variable_name Value Max_used_connections 2 SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections'; VARIABLE_NAME VARIABLE_VALUE -MAX_USED_CONNECTIONS 2.0000000 +MAX_USED_CONNECTIONS 2 SHOW STATUS LIKE 'max_used_connections'; Variable_name Value Max_used_connections 3 SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections'; VARIABLE_NAME VARIABLE_VALUE -MAX_USED_CONNECTIONS 3.0000000 +MAX_USED_CONNECTIONS 3 SHOW STATUS LIKE 'max_used_connections'; Variable_name Value Max_used_connections 4 SELECT * FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections'; VARIABLE_NAME VARIABLE_VALUE -MAX_USED_CONNECTIONS 4.0000000 +MAX_USED_CONNECTIONS 4 SET GLOBAL thread_cache_size=@save_thread_cache_size; show status like 'com_show_status'; Variable_name Value diff --git a/sql/sql_select.cc b/sql/sql_select.cc index ea78e126d9c..8de3e041bfc 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9133,8 +9133,7 @@ Field *create_tmp_field_for_schema(THD *thd, Item *item, TABLE *table) if (item->field_type() == MYSQL_TYPE_VARCHAR) { Field *field; - if (item->max_length > MAX_FIELD_VARCHARLENGTH / - item->collation.collation->mbmaxlen) + if (item->max_length > MAX_FIELD_VARCHARLENGTH) field= new Field_blob(item->max_length, item->maybe_null, item->name, item->collation.collation); else diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 175588368b3..94442bad188 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -4516,9 +4516,19 @@ int fill_variables(THD *thd, TABLE_LIST *tables, COND *cond) int res= 0; LEX *lex= thd->lex; const char *wild= lex->wild ? lex->wild->ptr() : NullS; + enum enum_schema_tables schema_table_idx= + get_schema_table_idx(tables->schema_table); + enum enum_var_type option_type= OPT_SESSION; + bool upper_case_names= (schema_table_idx != SCH_VARIABLES); + bool sorted_vars= (schema_table_idx == SCH_VARIABLES); + + if (lex->option_type == OPT_GLOBAL || + schema_table_idx == SCH_GLOBAL_VARIABLES) + option_type= OPT_GLOBAL; + rw_rdlock(&LOCK_system_variables_hash); - res= show_status_array(thd, wild, enumerate_sys_vars(thd, TRUE), - lex->option_type, 0, "", tables->table, 0); + res= show_status_array(thd, wild, enumerate_sys_vars(thd, sorted_vars), + option_type, NULL, "", tables->table, upper_case_names); rw_unlock(&LOCK_system_variables_hash); DBUG_RETURN(res); } @@ -4530,16 +4540,34 @@ int fill_status(THD *thd, TABLE_LIST *tables, COND *cond) LEX *lex= thd->lex; const char *wild= lex->wild ? lex->wild->ptr() : NullS; int res= 0; - STATUS_VAR tmp; + STATUS_VAR *tmp1, tmp; + enum enum_schema_tables schema_table_idx= + get_schema_table_idx(tables->schema_table); + enum enum_var_type option_type; + bool upper_case_names= (schema_table_idx != SCH_STATUS); + + if (lex->option_type == OPT_GLOBAL || + schema_table_idx == SCH_GLOBAL_STATUS) + { + option_type= OPT_GLOBAL; + tmp1= &tmp; + } + else + { + option_type= OPT_SESSION; + if (schema_table_idx == SCH_SESSION_STATUS) + tmp1= &thd->status_var; + else + tmp1= thd->initial_status_var; + } + pthread_mutex_lock(&LOCK_status); - if (lex->option_type == OPT_GLOBAL) + if (option_type == OPT_GLOBAL) calc_sum_of_all_status(&tmp); res= show_status_array(thd, wild, (SHOW_VAR *)all_status_vars.buffer, - OPT_GLOBAL, - (lex->option_type == OPT_GLOBAL ? - &tmp: thd->initial_status_var), - "", tables->table, 0); + option_type, tmp1, "", tables->table, + upper_case_names); pthread_mutex_unlock(&LOCK_status); DBUG_RETURN(res); } @@ -4782,12 +4810,10 @@ TABLE *create_schema_table(THD *thd, TABLE_LIST *table_list) /* Don't let unimplemented types pass through. Could be a grave error. */ DBUG_ASSERT(fields_info->field_type == MYSQL_TYPE_STRING); - /* this should be changed when Item_empty_string is fixed(in 4.1) */ - if (!(item= new Item_empty_string("", 0, cs))) + if (!(item= new Item_empty_string("", fields_info->field_length, cs))) { DBUG_RETURN(0); } - item->max_length= fields_info->field_length * cs->mbmaxlen; item->set_name(fields_info->field_name, strlen(fields_info->field_name), cs); break; @@ -5228,172 +5254,6 @@ int fill_schema_files(THD *thd, TABLE_LIST *tables, COND *cond) DBUG_RETURN(0); } -int fill_schema_status(THD *thd, SHOW_VAR *variables, - struct system_status_var *status_var, - const char *prefix, TABLE *table) -{ - SHOW_VAR tmp, *var; - SHOW_TYPE show_type; - LEX_STRING null_lex_str; - char buff[SHOW_VAR_FUNC_BUFF_SIZE]; - char name_buf[64], *name_pos; - int name_len; - DBUG_ENTER("fill_schema_status"); - - null_lex_str.str= 0; - null_lex_str.length= 0; - - name_pos= strnmov(name_buf, prefix, sizeof(name_buf) - 1); - if (*prefix) - *name_pos++= '_'; - name_len= name_buf + sizeof(name_buf) - name_pos; - - for (; variables->name; variables++) - { - strnmov(name_pos, variables->name, name_len); - name_buf[sizeof(name_buf) - 1]= 0; - make_upper(name_buf); - - for (var= variables; var->type == SHOW_FUNC; var= &tmp) - ((mysql_show_var_func)(var->value))(thd, &tmp, buff); - - show_type= var->type; - - if (show_type == SHOW_ARRAY) - { - fill_schema_status(thd, (SHOW_VAR*) var->value, - status_var, name_buf, table); - } - else - { - char *value= var->value; - - restore_record(table, s->default_values); - table->field[0]->store(name_buf, strlen(name_buf), system_charset_info); - - if (show_type == SHOW_SYS) - { - show_type= ((sys_var*) value)->show_type(); - value= (char*) ((sys_var*) value)->value_ptr(thd, OPT_GLOBAL, - &null_lex_str); - } - - switch (show_type) - { - case SHOW_DOUBLE_STATUS: - value= (char*) status_var + (ulong) value; - table->field[1]->store(*(double*) value); - break; - case SHOW_LONG_STATUS: - value= (char*) status_var + (ulong) value; - /* fall through */ - case SHOW_LONG: - case SHOW_LONG_NOFLUSH: /* the difference lies in refresh_status() */ - table->field[1]->store((longlong) *(long*) value, false); - break; - case SHOW_LONGLONG: - table->field[1]->store(*(longlong*) value, false); - break; - case SHOW_HA_ROWS: - table->field[1]->store((longlong) *(ha_rows*) value, false); - break; - case SHOW_BOOL: - table->field[1]->store((longlong) *(bool*) value, false); - break; - case SHOW_MY_BOOL: - table->field[1]->store((longlong) *(my_bool*) value, false); - break; - case SHOW_INT: - table->field[1]->store((longlong) *(uint32*) value, false); - break; - case SHOW_HAVE: /* always displayed as 0 */ - table->field[1]->store((longlong) 0, false); - break; - case SHOW_CHAR_PTR: - value= *(char**) value; - /* fall through */ - case SHOW_CHAR: /* always displayed as 0 */ - table->field[1]->store((longlong) 0, false); - break; - case SHOW_KEY_CACHE_LONG: - value= (char*) dflt_key_cache + (ulong) value; - table->field[1]->store((longlong) *(long*) value, false); - break; - case SHOW_KEY_CACHE_LONGLONG: - value= (char*) dflt_key_cache + (ulong) value; - table->field[1]->store(*(longlong*) value, false); - break; - case SHOW_UNDEF: /* always displayed as 0 */ - table->field[1]->store((longlong) 0, false); - break; - case SHOW_SYS: /* cannot happen */ - default: - DBUG_ASSERT(0); - break; - } - - table->field[1]->set_notnull(); - if (schema_table_store_record(thd, table)) - DBUG_RETURN(1); - } - } - - DBUG_RETURN(0); -} - -int fill_schema_global_status(THD *thd, TABLE_LIST *tables, COND *cond) -{ - STATUS_VAR tmp; - int res= 0; - DBUG_ENTER("fill_schema_global_status"); - - pthread_mutex_lock(&LOCK_status); - calc_sum_of_all_status(&tmp); - res= fill_schema_status(thd, (SHOW_VAR*) all_status_vars.buffer, - &tmp, "", tables->table); - pthread_mutex_unlock(&LOCK_status); - - DBUG_RETURN(res); -} - -int fill_schema_session_status(THD *thd, TABLE_LIST *tables, COND *cond) -{ - int res= 0; - DBUG_ENTER("fill_schema_session_status"); - - pthread_mutex_lock(&LOCK_status); - res= fill_schema_status(thd, (SHOW_VAR*) all_status_vars.buffer, - &thd->status_var, "", tables->table); - pthread_mutex_unlock(&LOCK_status); - - DBUG_RETURN(res); -} - -int fill_schema_global_variables(THD *thd, TABLE_LIST *tables, COND *cond) -{ - int res= 0; - DBUG_ENTER("fill_schema_global_variables"); - - rw_rdlock(&LOCK_system_variables_hash); - res= show_status_array(thd, "", enumerate_sys_vars(thd, FALSE), OPT_GLOBAL, - NULL, "", tables->table, 1); - rw_unlock(&LOCK_system_variables_hash); - - DBUG_RETURN(res); -} - -int fill_schema_session_variables(THD *thd, TABLE_LIST *tables, COND *cond) -{ - int res= 0; - DBUG_ENTER("fill_schema_session_variables"); - - rw_rdlock(&LOCK_system_variables_hash); - res= show_status_array(thd, "", enumerate_sys_vars(thd, FALSE), OPT_SESSION, - NULL, "", tables->table, 1); - rw_unlock(&LOCK_system_variables_hash); - - DBUG_RETURN(res); -} ST_FIELD_INFO schema_fields_info[]= { @@ -5762,25 +5622,9 @@ ST_FIELD_INFO partitions_fields_info[]= ST_FIELD_INFO variables_fields_info[]= -{ - {"Variable_name", 80, MYSQL_TYPE_STRING, 0, 0, "Variable_name"}, - {"Value", FN_REFLEN, MYSQL_TYPE_STRING, 0, 0, "Value"}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} -}; - - -ST_FIELD_INFO status_fields_info[]= { {"VARIABLE_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Variable_name"}, - {"VARIABLE_VALUE", 2207, MYSQL_TYPE_DECIMAL, 0, 0, "Value"}, - {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} -}; - - -ST_FIELD_INFO system_variables_fields_info[]= -{ - {"VARIABLE_NAME", 64, MYSQL_TYPE_STRING, 0, 0, "Variable_name"}, - {"VARIABLE_VALUE", 65535, MYSQL_TYPE_STRING, 0, 1, "Value"}, + {"VARIABLE_VALUE", 20480, MYSQL_TYPE_STRING, 0, 1, "Value"}, {0, 0, MYSQL_TYPE_STRING, 0, 0, 0} }; @@ -5920,10 +5764,10 @@ ST_SCHEMA_TABLE schema_tables[]= Events::fill_schema_events, make_old_format, 0, -1, -1, 0}, {"FILES", files_fields_info, create_schema_table, fill_schema_files, 0, 0, -1, -1, 0}, - {"GLOBAL_STATUS", status_fields_info, create_schema_table, - fill_schema_global_status, make_old_format, 0, -1, -1, 0}, - {"GLOBAL_VARIABLES", system_variables_fields_info, create_schema_table, - fill_schema_global_variables, make_old_format, 0, -1, -1, 0}, + {"GLOBAL_STATUS", variables_fields_info, create_schema_table, + fill_status, make_old_format, 0, -1, -1, 0}, + {"GLOBAL_VARIABLES", variables_fields_info, create_schema_table, + fill_variables, make_old_format, 0, -1, -1, 0}, {"KEY_COLUMN_USAGE", key_column_usage_fields_info, create_schema_table, get_all_tables, 0, get_schema_key_column_usage_record, 4, 5, 0}, {"OPEN_TABLES", open_tables_fields_info, create_schema_table, @@ -5943,10 +5787,10 @@ ST_SCHEMA_TABLE schema_tables[]= fill_schema_shemata, make_schemata_old_format, 0, 1, -1, 0}, {"SCHEMA_PRIVILEGES", schema_privileges_fields_info, create_schema_table, fill_schema_schema_privileges, 0, 0, -1, -1, 0}, - {"SESSION_STATUS", status_fields_info, create_schema_table, - fill_schema_session_status, make_old_format, 0, -1, -1, 0}, - {"SESSION_VARIABLES", system_variables_fields_info, create_schema_table, - fill_schema_session_variables, make_old_format, 0, -1, -1, 0}, + {"SESSION_STATUS", variables_fields_info, create_schema_table, + fill_status, make_old_format, 0, -1, -1, 0}, + {"SESSION_VARIABLES", variables_fields_info, create_schema_table, + fill_variables, make_old_format, 0, -1, -1, 0}, {"STATISTICS", stat_fields_info, create_schema_table, get_all_tables, make_old_format, get_schema_stat_record, 1, 2, 0}, {"STATUS", variables_fields_info, create_schema_table, fill_status, From aaf6acae9be9b732c023a7d7ce94cb66f4a61de6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 May 2007 15:29:12 +0300 Subject: [PATCH 12/33] Bug#27573: MIN() on an indexed column which is always NULL sets _other_ results to NULL For queries of the form SELECT MIN(key_part_k) FROM t1 WHERE key_part_1 = const and ... and key_part_k-1 = const, the opt_sum_query optimization tries to use an index to substitute MIN/MAX functions with their values according to the following rules: 1) Insert the minimum non-null values where the WHERE clause still matches, or 3) A row of nulls However, the correct semantics requires that there is a third case 2) such that a NULL value is substituted if there are only NULL values for key_part_k. The patch modifies opt_sum_query() to handle this missing case. mysql-test/r/func_group.result: Bug #27573: Correct result mysql-test/t/func_group.test: Bug #27573: test case sql/opt_sum.cc: Bug #27573: Added code that will try to read the first non-null value for a given complete-field prefix, second choice is to read the null, and lastly set the error code if no row is found. --- mysql-test/r/bdb_notembedded.result | 35 ++++++++++++ mysql-test/r/func_group.result | 47 ++++++++++++++++ mysql-test/t/bdb_notembedded.test | 38 +++++++++++++ mysql-test/t/func_group.test | 33 +++++++++++ sql/opt_sum.cc | 86 +++++++++++++++++++++++++---- 5 files changed, 229 insertions(+), 10 deletions(-) create mode 100644 mysql-test/r/bdb_notembedded.result create mode 100644 mysql-test/t/bdb_notembedded.test diff --git a/mysql-test/r/bdb_notembedded.result b/mysql-test/r/bdb_notembedded.result new file mode 100644 index 00000000000..14cb5fad915 --- /dev/null +++ b/mysql-test/r/bdb_notembedded.result @@ -0,0 +1,35 @@ +set autocommit=1; +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; insert into bug16206 values(2) +drop table bug16206; +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb +f n Query 1 n use `test`; insert into bug16206 values(0) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; BEGIN +f n Query 1 n use `test`; insert into bug16206 values(2) +f n Query 1 n use `test`; COMMIT +f n Query 1 n use `test`; insert into bug16206 values(3) +drop table bug16206; +set autocommit=0; +End of 5.0 tests diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index e421da1c462..d3e5d586973 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1321,4 +1321,51 @@ SELECT a,AVG(DISTINCT b) AS average FROM t1 GROUP BY a HAVING average > 50; a average 1 32768.5000 DROP TABLE t1; +CREATE TABLE t1 ( a INT, b INT, KEY(a) ); +INSERT INTO t1 VALUES (NULL, 1), (NULL, 2); +EXPLAIN SELECT MIN(a), MIN(b) FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 +SELECT MIN(a), MIN(b) FROM t1; +MIN(a) MIN(b) +NULL 1 +CREATE TABLE t2( a INT, b INT, c INT, KEY(a, b) ); +INSERT INTO t2 ( a, b, c ) VALUES ( 1, NULL, 2 ), ( 1, 3, 4 ), ( 1, 4, 4 ); +EXPLAIN SELECT MIN(b), MIN(c) FROM t2 WHERE a = 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref a a 5 const 2 Using where +SELECT MIN(b), MIN(c) FROM t2 WHERE a = 1; +MIN(b) MIN(c) +3 2 +CREATE TABLE t3 (a INT, b INT, c int, KEY(a, b)); +INSERT INTO t3 VALUES (1, NULL, 1), (2, NULL, 2), (2, NULL, 2), (3, NULL, 3); +EXPLAIN SELECT MIN(a), MIN(b) FROM t3 where a = 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +SELECT MIN(a), MIN(b) FROM t3 where a = 2; +MIN(a) MIN(b) +2 NULL +CREATE TABLE t4 (a INT, b INT, c int, KEY(a, b)); +INSERT INTO t4 VALUES (1, 1, 1), (2, NULL, 2), (2, NULL, 2), (3, 1, 3); +EXPLAIN SELECT MIN(a), MIN(b) FROM t4 where a = 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +SELECT MIN(a), MIN(b) FROM t4 where a = 2; +MIN(a) MIN(b) +2 NULL +SELECT MIN(b), min(c) FROM t4 where a = 2; +MIN(b) min(c) +NULL 2 +CREATE TABLE t5( a INT, b INT, KEY( a, b) ); +INSERT INTO t5 VALUES( 1, 1 ), ( 1, 2 ); +EXPLAIN SELECT MIN(a), MIN(b) FROM t5 WHERE a = 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +SELECT MIN(a), MIN(b) FROM t5 WHERE a = 1; +MIN(a) MIN(b) +1 1 +SELECT MIN(a), MIN(b) FROM t5 WHERE a = 1 and b > 1; +MIN(a) MIN(b) +1 2 +DROP TABLE t1, t2, t3, t4, t5; End of 5.0 tests diff --git a/mysql-test/t/bdb_notembedded.test b/mysql-test/t/bdb_notembedded.test new file mode 100644 index 00000000000..24e64ebbfb2 --- /dev/null +++ b/mysql-test/t/bdb_notembedded.test @@ -0,0 +1,38 @@ +-- source include/not_embedded.inc +-- source include/have_bdb.inc + +# +# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode +# +set autocommit=1; + +let $VERSION=`select version()`; + +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +set autocommit=0; + + +--echo End of 5.0 tests diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index b102148472a..5ed017e2f74 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -817,5 +817,38 @@ SELECT a,AVG(DISTINCT b) AS average FROM t1 GROUP BY a HAVING average > 50; DROP TABLE t1; +# +# Bug #27573: MIN() on an indexed column which is always NULL sets _other_ +# results to NULL +# +CREATE TABLE t1 ( a INT, b INT, KEY(a) ); +INSERT INTO t1 VALUES (NULL, 1), (NULL, 2); +EXPLAIN SELECT MIN(a), MIN(b) FROM t1; +SELECT MIN(a), MIN(b) FROM t1; + +CREATE TABLE t2( a INT, b INT, c INT, KEY(a, b) ); +INSERT INTO t2 ( a, b, c ) VALUES ( 1, NULL, 2 ), ( 1, 3, 4 ), ( 1, 4, 4 ); +EXPLAIN SELECT MIN(b), MIN(c) FROM t2 WHERE a = 1; +SELECT MIN(b), MIN(c) FROM t2 WHERE a = 1; + +CREATE TABLE t3 (a INT, b INT, c int, KEY(a, b)); +INSERT INTO t3 VALUES (1, NULL, 1), (2, NULL, 2), (2, NULL, 2), (3, NULL, 3); +EXPLAIN SELECT MIN(a), MIN(b) FROM t3 where a = 2; +SELECT MIN(a), MIN(b) FROM t3 where a = 2; + +CREATE TABLE t4 (a INT, b INT, c int, KEY(a, b)); +INSERT INTO t4 VALUES (1, 1, 1), (2, NULL, 2), (2, NULL, 2), (3, 1, 3); +EXPLAIN SELECT MIN(a), MIN(b) FROM t4 where a = 2; +SELECT MIN(a), MIN(b) FROM t4 where a = 2; +SELECT MIN(b), min(c) FROM t4 where a = 2; + +CREATE TABLE t5( a INT, b INT, KEY( a, b) ); +INSERT INTO t5 VALUES( 1, 1 ), ( 1, 2 ); +EXPLAIN SELECT MIN(a), MIN(b) FROM t5 WHERE a = 1; +SELECT MIN(a), MIN(b) FROM t5 WHERE a = 1; +SELECT MIN(a), MIN(b) FROM t5 WHERE a = 1 and b > 1; + +DROP TABLE t1, t2, t3, t4, t5; + ### --echo End of 5.0 tests diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 9222e15ff91..b9de54dbf5c 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -206,12 +206,68 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) if (!ref.key_length) error= table->file->index_first(table->record[0]); - else - error= table->file->index_read(table->record[0],key_buff, - ref.key_length, - range_fl & NEAR_MIN ? - HA_READ_AFTER_KEY : - HA_READ_KEY_OR_NEXT); + else + { + /* + Use index to replace MIN/MAX functions with their values + according to the following rules: + + 1) Insert the minimum non-null values where the WHERE clause still + matches, or + 2) a NULL value if there are only NULL values for key_part_k. + 3) Fail, producing a row of nulls + + Implementation: Read the smallest value using the search key. If + the interval is open, read the next value after the search + key. If read fails, and we're looking for a MIN() value for a + nullable column, test if there is an exact match for the key. + */ + if (!(range_fl & NEAR_MIN)) + /* + Closed interval: Either The MIN argument is non-nullable, or + we have a >= predicate for the MIN argument. + */ + error= table->file->index_read(table->record[0], ref.key_buff, + ref.key_length, + HA_READ_KEY_OR_NEXT); + else + { + /* + Open interval: There are two cases: + 1) We have only MIN() and the argument column is nullable, or + 2) there is a > predicate on it, nullability is irrelevant. + We need to scan the next bigger record first. + */ + error= table->file->index_read(table->record[0], ref.key_buff, + ref.key_length, HA_READ_AFTER_KEY); + /* + If the found record is outside the group formed by the search + prefix, or there is no such record at all, check if all + records in that group have NULL in the MIN argument + column. If that is the case return that NULL. + + Check if case 1 from above holds. If it does, we should read + the skipped tuple. + */ + if (ref.key_buff[prefix_len] == 1 && + /* + Last keypart (i.e. the argument to MIN) is set to NULL by + find_key_for_maxmin only if all other keyparts are bound + to constants in a conjunction of equalities. Hence, we + can detect this by checking only if the last keypart is + NULL. + */ + (error == HA_ERR_KEY_NOT_FOUND || + key_cmp_if_same(table, ref.key_buff, ref.key, prefix_len))) + { + DBUG_ASSERT(item_field->field->real_maybe_null()); + error= table->file->index_read(table->record[0], ref.key_buff, + ref.key_length, + HA_READ_KEY_EXACT); + } + } + } + /* Verify that the read tuple indeed matches the search key */ if (!error && reckey_in_range(0, &ref, item_field->field, conds, range_fl, prefix_len)) error= HA_ERR_KEY_NOT_FOUND; @@ -739,14 +795,24 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref, if (!max_fl && key_part_used == key_part_to_use && part->null_bit) { /* - SELECT MIN(key_part2) FROM t1 WHERE key_part1=const - If key_part2 may be NULL, then we want to find the first row - that is not null + The query is on this form: + + SELECT MIN(key_part_k) + FROM t1 + WHERE key_part_1 = const and ... and key_part_k-1 = const + + If key_part_k is nullable, we want to find the first matching row + where key_part_k is not null. The key buffer is now {const, ..., + NULL}. This will be passed to the handler along with a flag + indicating open interval. If a tuple is read that does not match + these search criteria, an attempt will be made to read an exact + match for the key buffer. */ + /* Set the first byte of key_part_k to 1, that means NULL */ ref->key_buff[ref->key_length]= 1; ref->key_length+= part->store_length; *range_fl&= ~NO_MIN_RANGE; - *range_fl|= NEAR_MIN; // > NULL + *range_fl|= NEAR_MIN; // Open interval } /* The following test is false when the key in the key tree is From 09fb739b953354e5cf9f8bb95d36512461a65456 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 May 2007 18:19:18 +0200 Subject: [PATCH 13/33] Fix bug#27833 "Bourne shell string comparison issue in scripts/make_win_bin_dist": Several string comparisons could never yield true because they had an 'x' guard added to the variable but not to the constant value. Fix that by guarding both sides. scripts/make_win_bin_dist: Fix bug#27833 "Bourne shell string comparison issue in scripts/make_win_bin_dist": Several string comparisons could never yield true because they had an 'x' guard added to the variable but not to the constant value. Fix that by guarding both sides. Use this occasion to apply some corrections to the comments and the usage text. Also, ensure the ".pdb" file is always optional. --- scripts/make_win_bin_dist | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist index 87d35a0850b..30127b0043f 100755 --- a/scripts/make_win_bin_dist +++ b/scripts/make_win_bin_dist @@ -39,7 +39,7 @@ The "package-base-name" argument should be something like mysql-noinstall-5.0.25-win32 (or winx64) -and will be the name of the directory of the unpacked ZIP (stripping +and will become the name of the directory of the unpacked ZIP (stripping away the "noinstall" part of the ZIP file name if any) and the base for the resulting package name. @@ -51,6 +51,7 @@ Options are --no-embedded Don't pack the embedded server even if built --debug Pack the debug binaries and give error if not built. + The default is to pack them if they are built. --no-debug Don't pack the debug binaries even if built @@ -58,10 +59,10 @@ Options are want to replace the normal binaries with debug versions, i.e. no separate "debug" directories. - --exe-suffix=SUF Add a suffix to the "mysqld" binary. + --exe-suffix=SUF Add a suffix to the filename part of the "mysqld" binary. As you might want to include files of directories from other builds -(like a "mysqld-max.exe" server), you can instruct this script do copy +(like a "mysqld-max.exe" server), you can instruct this script to copy them in for you. This is the "copy-def" arguments, and they are of the form @@ -172,10 +173,10 @@ else BASENAME="mysqld" # New style CMake build fi -if [ x"$PACK_DEBUG" = "" -a -f "sql/debug/$BASENAME.exe" -o \ - x"$PACK_DEBUG" = "yes" ] ; then +if [ x"$PACK_DEBUG" = x"" -a -f "sql/debug/$BASENAME.exe" -o \ + x"$PACK_DEBUG" = x"yes" ] ; then cp sql/debug/$BASENAME.exe $DESTDIR/bin/mysqld-debug.exe - cp sql/debug/$BASENAME.pdb $DESTDIR/bin/mysqld-debug.pdb + cp sql/debug/$BASENAME.pdb $DESTDIR/bin/mysqld-debug.pdb || true cp sql/debug/$BASENAME.map $DESTDIR/bin/mysqld-debug.map || true fi @@ -221,8 +222,8 @@ copy_embedded() cp libmysqld/$TARGET/libmysqld.exp $DESTDIR/Embedded/DLL/release/ cp libmysqld/$TARGET/libmysqld.lib $DESTDIR/Embedded/DLL/release/ - if [ x"$PACK_DEBUG" = "" -a -f "libmysqld/debug/libmysqld.lib" -o \ - x"$PACK_DEBUG" = "yes" ] ; then + if [ x"$PACK_DEBUG" = x"" -a -f "libmysqld/debug/libmysqld.lib" -o \ + x"$PACK_DEBUG" = x"yes" ] ; then mkdir -p $DESTDIR/Embedded/DLL/debug cp libmysqld/debug/libmysqld.dll $DESTDIR/Embedded/DLL/debug/ cp libmysqld/debug/libmysqld.exp $DESTDIR/Embedded/DLL/debug/ @@ -230,10 +231,10 @@ copy_embedded() fi } -if [ x"$PACK_EMBEDDED" = "" -a \ +if [ x"$PACK_EMBEDDED" = x"" -a \ -f "libmysqld/$TARGET/mysqlserver.lib" -a \ -f "libmysqld/$TARGET/libmysqld.lib" -o \ - x"$PACK_EMBEDDED" = "yes" ] ; then + x"$PACK_EMBEDDED" = x"yes" ] ; then copy_embedded fi @@ -271,8 +272,8 @@ cp libmysql/$TARGET/libmysql.dll \ strings/$TARGET/strings.lib \ zlib/$TARGET/zlib.lib $DESTDIR/lib/opt/ -if [ x"$PACK_DEBUG" = "" -a -f "libmysql/debug/libmysql.lib" -o \ - x"$PACK_DEBUG" = "yes" ] ; then +if [ x"$PACK_DEBUG" = x"" -a -f "libmysql/debug/libmysql.lib" -o \ + x"$PACK_DEBUG" = x"yes" ] ; then mkdir -p $DESTDIR/lib/debug cp libmysql/debug/libmysql.dll \ libmysql/debug/libmysql.lib \ @@ -329,12 +330,11 @@ fi # ---------------------------------------------------------------------- # Copy what could be usable in the "scripts" directory. Currently -# only SQL files, others are bourne shell scripts or Perl scripts +# only SQL files, others are Bourne shell scripts or Perl scripts # not really usable on Windows. # # But to be nice to the few Cygwin users we might have in 5.0 we -# continue to copy the stuff, but don't include it include it in -# the WiX install. +# continue to copy the stuff, but don't include it in the WiX install. # ---------------------------------------------------------------------- mkdir -p $DESTDIR/scripts @@ -360,7 +360,7 @@ fi cp -pR sql-bench $DESTDIR/ rm -f $DESTDIR/sql-bench/*.sh $DESTDIR/sql-bench/Makefile* -# The SQL initiation code is really expected to be in "share" +# The SQL initialisation code is really expected to be in "share" mv $DESTDIR/scripts/*.sql $DESTDIR/share/ || true # ---------------------------------------------------------------------- @@ -381,7 +381,7 @@ for arg do done # ---------------------------------------------------------------------- -# Finally creat the ZIP archive +# Finally create the ZIP archive # ---------------------------------------------------------------------- rm -f $NOINST_NAME.zip From 9aa67a40962e87f9170c8c70a3dbe3689659322e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 May 2007 00:30:12 +0400 Subject: [PATCH 14/33] Bug#28208: Wrong result of a non-const STRING function with a const DATETIME function. A wrong condition was used to check that the Arg_comparator::can_compare_as_dates() function calculated the value of the string constant. When comparing a non-const STRING function with a constant DATETIME function it leads to saving an arbitrary value as a cached value of the DATETIME function. Now the Arg_comparator::set_cmp_func() function initializes the const_value variable to the impossible DATETIME value (-1) and this const_value is cached only if it was changed by the Arg_comparator::can_compare_as_dates() function. mysql-test/t/type_datetime.test: Added a test case for the bug#28208: Wrong result of a non-const STRING function with a const DATETIME function. mysql-test/r/type_datetime.result: Added a test case for the bug#28208: Wrong result of a non-const STRING function with a const DATETIME function. sql/item_cmpfunc.cc: Bug#28208: Wrong result of a non-const STRING function with a const DATETIME function. Now the Arg_comparator::set_cmp_func() function initializes the const_value variable to the impossible DATETIME value (-1) and this const_value is cached only if it was changed by the Arg_comparator::can_compare_as_dates() function. --- mysql-test/r/type_datetime.result | 6 ++++++ mysql-test/t/type_datetime.test | 9 +++++++++ sql/item_cmpfunc.cc | 5 ++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index b45ddd597c4..573139bed48 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -346,3 +346,9 @@ call test27759(); a b a_then_b b_then_a c_then_a 2007-04-10 2007-04-11 2007-04-10 2007-04-10 2004-04-09 00:00:00 drop procedure test27759; +create table t1 (f1 date); +insert into t1 values (curdate()); +select left(f1,10) = curdate() from t1; +left(f1,10) = curdate() +1 +drop table t1; diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index c111f2f02cf..4c2416000be 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -225,3 +225,12 @@ END;| DELIMITER ;| call test27759(); drop procedure test27759; + +# +# Bug#28208: Wrong result of a non-const STRING function with a const +# DATETIME function. +# +create table t1 (f1 date); +insert into t1 values (curdate()); +select left(f1,10) = curdate() from t1; +drop table t1; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 4f0347dd506..9a251312aca 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -661,7 +661,7 @@ int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg, Item_result type) { enum enum_date_cmp_type cmp_type; - ulonglong const_value; + ulonglong const_value= (ulonglong)-1; a= a1; b= a2; @@ -674,8 +674,7 @@ int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg, a_cache= 0; b_cache= 0; - if (cmp_type != CMP_DATE_WITH_DATE && - ((*b)->const_item() || (*a)->const_item())) + if (const_value != (ulonglong)-1) { Item_cache_int *cache= new Item_cache_int(); /* Mark the cache as non-const to prevent re-caching. */ From 1e33cfb36a84b477a468dbcfc1ccc3035a9efb81 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 May 2007 10:12:49 +0500 Subject: [PATCH 15/33] bug #8663 cant use bigint unsigned as input to cast in the case of the overflow in the decimal->integer conversion we didn't return the proper boundary value, but just the result of the conversion we calculated on the moment of the error mysql-test/r/bigint.result: bug #8663 cant use bigint unsigned as input to cast test result fixed mysql-test/t/bigint.test: bug #8663 cant use bigint unsigned as input to cast test case strings/decimal.c: bug #8663 cant use bigint unsigned as input to cast decimal->int conversion fixed to return proper boundary value in the case of overflow --- mysql-test/r/bigint.result | 10 ++++++++++ mysql-test/t/bigint.test | 6 ++++++ strings/decimal.c | 6 +++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index 541a15561e2..f18d1c9b583 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -352,3 +352,13 @@ select c1 mod 50 as result from t1; result 6 drop table t1; +select cast(19999999999999999999 as signed); +cast(19999999999999999999 as signed) +9223372036854775807 +Warnings: +Error 1292 Truncated incorrect DECIMAL value: '' +select cast(-19999999999999999999 as signed); +cast(-19999999999999999999 as signed) +-9223372036854775808 +Warnings: +Error 1292 Truncated incorrect DECIMAL value: '' diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index 6c1229db83f..9a5fb11229d 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -288,3 +288,9 @@ insert into t1 values (10000002383263201056); select c1 mod 50 as result from t1; drop table t1; +# +# Bug #8663 cant use bgint unsigned as input to cast +# + +select cast(19999999999999999999 as signed); +select cast(-19999999999999999999 as signed); diff --git a/strings/decimal.c b/strings/decimal.c index 65db68b1b59..1ae75167794 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -1083,7 +1083,11 @@ int decimal2longlong(decimal_t *from, longlong *to) x=x*DIG_BASE - *buf++; if (unlikely(y < (LONGLONG_MIN/DIG_BASE) || x > y)) { - *to= from->sign ? y : -y; + /* + the decimal is bigger than any possible integer + return border integer depending on the sign + */ + *to= from->sign ? LONGLONG_MIN : LONGLONG_MAX; return E_DEC_OVERFLOW; } } From b2b1629480033a40932948c4e7649428f8ed1586 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 May 2007 16:01:14 +0400 Subject: [PATCH 16/33] An attempt to fix event_bugs.test failure on Debian (Bug#26338 "events_bugs.test fail on Debian") mysql-test/r/events_bugs.result: Update results. mysql-test/t/events_bugs.test: Make a stab at fixing events_bugs.test failure on Debian. The problem is purely in the race inherent in the test case: an event that was started doesn't go away fast enough and clutters the processlist. This patch remove the part of the event that we can not wait on synchronously (there is no table 'hashed_num' referenced anywhere). --- mysql-test/r/events_bugs.result | 1 - mysql-test/t/events_bugs.test | 1 - 2 files changed, 2 deletions(-) diff --git a/mysql-test/r/events_bugs.result b/mysql-test/r/events_bugs.result index c4053bcfb47..5b48e3ea142 100644 --- a/mysql-test/r/events_bugs.result +++ b/mysql-test/r/events_bugs.result @@ -53,7 +53,6 @@ get_lock('test_bug16407', 60) create event e_16407 on schedule every 60 second do begin select get_lock('test_bug16407', 60); -drop table "hashed_num"; end| "Now if everything is fine the event has compiled and is locked" select /*1*/ user, host, db, info from information_schema.processlist where command!='Daemon' and (info is null or info not like '%processlist%') order by info; diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test index 8343c6b4bc6..b2c44da7f99 100644 --- a/mysql-test/t/events_bugs.test +++ b/mysql-test/t/events_bugs.test @@ -87,7 +87,6 @@ delimiter |; create event e_16407 on schedule every 60 second do begin select get_lock('test_bug16407', 60); - drop table "hashed_num"; end| delimiter ;| From 2480ec63747aa3d5558e1c38bbced4af9fff29a7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 May 2007 16:05:19 +0400 Subject: [PATCH 17/33] Fix a typo. sql/event_data_objects.cc: Fix typo. --- sql/event_data_objects.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc index 41f2f89db24..9394bdcdae5 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -1914,7 +1914,7 @@ Event_job_data::execute(THD *thd, bool drop) thd->variables.time_zone= time_zone; /* - Peculiar initialization order is a clutch to avoid races in SHOW + Peculiar initialization order is a crutch to avoid races in SHOW PROCESSLIST which reads thd->{query/query_length} without a mutex. */ thd->query_length= 0; @@ -1974,7 +1974,7 @@ end: else { /* - Peculiar initialization order is a clutch to avoid races in SHOW + Peculiar initialization order is a crutch to avoid races in SHOW PROCESSLIST which reads thd->{query/query_length} without a mutex. */ thd->query_length= 0; From d9ce3033f5cb1a3e75a46ffd17746b113a5ff97d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 May 2007 14:25:38 +0200 Subject: [PATCH 18/33] Bug#27415 Text Variables in stored procedures - Problem was reported as a SP variable using itself as right value inside SUBSTR caused corruption of data. - This bug could not be verified in either 5.0bk or 5.1bk - Added test case to prevent future regressions. mysql-test/r/sp-vars.result: Added test case for a reported regression which couldn't be verified. mysql-test/t/sp-vars.test: Added test case for a reported regression which couldn't be verified. --- mysql-test/r/sp-vars.result | 41 ++++++++++++++++++++++++++++++++++ mysql-test/t/sp-vars.test | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/mysql-test/r/sp-vars.result b/mysql-test/r/sp-vars.result index b112c6bece6..f3eb40b3d70 100644 --- a/mysql-test/r/sp-vars.result +++ b/mysql-test/r/sp-vars.result @@ -1161,3 +1161,44 @@ CALL p1(); v_text abc|def DROP PROCEDURE p1; +DROP PROCEDURE IF EXISTS bug27415_text_test| +DROP PROCEDURE IF EXISTS bug27415_text_test2| +CREATE PROCEDURE bug27415_text_test(entity_id_str_in text) +BEGIN +DECLARE str_remainder text; +SET str_remainder = entity_id_str_in; +select 'before substr', str_remainder; +SET str_remainder = SUBSTRING(str_remainder, 3); +select 'after substr', str_remainder; +END| +CREATE PROCEDURE bug27415_text_test2(entity_id_str_in text) +BEGIN +DECLARE str_remainder text; +DECLARE str_remainder2 text; +SET str_remainder2 = entity_id_str_in; +select 'before substr', str_remainder2; +SET str_remainder = SUBSTRING(str_remainder2, 3); +select 'after substr', str_remainder; +END| +CALL bug27415_text_test('a,b,c')| +before substr str_remainder +before substr a,b,c +after substr str_remainder +after substr b,c +CALL bug27415_text_test('a,b,c')| +before substr str_remainder +before substr a,b,c +after substr str_remainder +after substr b,c +CALL bug27415_text_test2('a,b,c')| +before substr str_remainder2 +before substr a,b,c +after substr str_remainder +after substr b,c +CALL bug27415_text_test('a,b,c')| +before substr str_remainder +before substr a,b,c +after substr str_remainder +after substr b,c +DROP PROCEDURE bug27415_text_test| +DROP PROCEDURE bug27415_text_test2| diff --git a/mysql-test/t/sp-vars.test b/mysql-test/t/sp-vars.test index 0014dc1f6af..2cc68b054d5 100644 --- a/mysql-test/t/sp-vars.test +++ b/mysql-test/t/sp-vars.test @@ -1367,4 +1367,48 @@ CALL p1(); DROP PROCEDURE p1; +# +# Bug #27415 Text Variables in stored procedures +# If the SP varible was also referenced on the right side +# the result was corrupted. +# +DELIMITER |; + +--disable_warnings +DROP PROCEDURE IF EXISTS bug27415_text_test| +DROP PROCEDURE IF EXISTS bug27415_text_test2| +--enable_warnings + +CREATE PROCEDURE bug27415_text_test(entity_id_str_in text) +BEGIN + DECLARE str_remainder text; + + SET str_remainder = entity_id_str_in; + + select 'before substr', str_remainder; + SET str_remainder = SUBSTRING(str_remainder, 3); + select 'after substr', str_remainder; +END| + +CREATE PROCEDURE bug27415_text_test2(entity_id_str_in text) +BEGIN + DECLARE str_remainder text; + DECLARE str_remainder2 text; + + SET str_remainder2 = entity_id_str_in; + select 'before substr', str_remainder2; + SET str_remainder = SUBSTRING(str_remainder2, 3); + select 'after substr', str_remainder; +END| + +CALL bug27415_text_test('a,b,c')| +CALL bug27415_text_test('a,b,c')| +CALL bug27415_text_test2('a,b,c')| +CALL bug27415_text_test('a,b,c')| + +DROP PROCEDURE bug27415_text_test| +DROP PROCEDURE bug27415_text_test2| + +DELIMITER ;| + # End of 5.0 tests. From d1c57f503f1cb082311ca371465332047854feea Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 May 2007 17:19:59 +0400 Subject: [PATCH 19/33] Comment fix. storage/ndb/include/mgmapi/mgmapi.h: A tiny fix to make sure MGM API does not clutter doxygen index page for the entire MySQL Server. --- storage/ndb/include/mgmapi/mgmapi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/ndb/include/mgmapi/mgmapi.h b/storage/ndb/include/mgmapi/mgmapi.h index 2bedba963e2..ffed44c7da1 100644 --- a/storage/ndb/include/mgmapi/mgmapi.h +++ b/storage/ndb/include/mgmapi/mgmapi.h @@ -23,7 +23,7 @@ #define NDB_MGM_MAX_LOGLEVEL 15 /** - * @mainpage MySQL Cluster Management API + * @section MySQL Cluster Management API * * The MySQL Cluster Management API (MGM API) is a C language API * that is used for: From b6be8fd0b8253b259c05fd6340b9c6fa89d28bda Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 May 2007 19:19:23 +0500 Subject: [PATCH 20/33] valgrind error fix --- sql/sql_show.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 94442bad188..e8107248c14 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -4546,19 +4546,23 @@ int fill_status(THD *thd, TABLE_LIST *tables, COND *cond) enum enum_var_type option_type; bool upper_case_names= (schema_table_idx != SCH_STATUS); - if (lex->option_type == OPT_GLOBAL || - schema_table_idx == SCH_GLOBAL_STATUS) + if (schema_table_idx == SCH_STATUS) + { + option_type= lex->option_type; + if (option_type == OPT_GLOBAL) + tmp1= &tmp; + else + tmp1= thd->initial_status_var; + } + else if (schema_table_idx == SCH_GLOBAL_STATUS) { option_type= OPT_GLOBAL; tmp1= &tmp; } else - { + { option_type= OPT_SESSION; - if (schema_table_idx == SCH_SESSION_STATUS) - tmp1= &thd->status_var; - else - tmp1= thd->initial_status_var; + tmp1= &thd->status_var; } pthread_mutex_lock(&LOCK_status); From 4a8fbb51a2319ec9edbb34498c23c8f915f3f013 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 May 2007 20:29:49 +0200 Subject: [PATCH 21/33] Ensure that the 5.1 version of "scripts/make_win_bin_dist" depends on 5.0, so that changes from 5.0 propagate (on merge) into the 5.1 version. BitKeeper/deleted/.del-make_win_bin_dist-HIDE: Delete: scripts/make_win_bin_dist-HIDE scripts/make_win_bin_dist: Transfer the current contents of the 5.1 version into this file. This is *no* contents change, its *only* purpose is to ensure that the 5.1 version of this file depends on the 5.0 version, and changes from 5.0 propagate properly into 5.1. From 80cb3cf44a4cdd70ff2368329d1a84d86d297cd1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 May 2007 21:00:35 +0200 Subject: [PATCH 22/33] After-merge fix in "scripts/make_win_bin_dist": Ensure the balanced use of 'x' guards in string comparisons also in the new 5.1 lines. scripts/make_win_bin_dist: After-merge fix: Ensure the balanced use of 'x' guards in string comparisons also in the new 5.1 lines. --- scripts/make_win_bin_dist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/make_win_bin_dist b/scripts/make_win_bin_dist index 2e6236ac6a8..6593e2c6039 100755 --- a/scripts/make_win_bin_dist +++ b/scripts/make_win_bin_dist @@ -238,8 +238,8 @@ cp libmysql/mytest.c libmysql/myTest.vcproj libmysql/$TARGET/myTest.exe \ $DESTDIR/examples/libmysqltest/ cp libmysql/$TARGET/myTest.exe $DESTDIR/examples/libmysqltest/release/ -if [ x"$PACK_DEBUG" = "" -a -f "libmysql/debug/myTest.exe" -o \ - x"$PACK_DEBUG" = "yes" ] ; then +if [ x"$PACK_DEBUG" = x"" -a -f "libmysql/debug/myTest.exe" -o \ + x"$PACK_DEBUG" = x"yes" ] ; then mkdir -p $DESTDIR/examples/libmysqltest/debug cp libmysql/debug/myTest.exe $DESTDIR/examples/libmysqltest/debug/ fi From dd1a11800027ab621479e1424963118b59a45e64 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 May 2007 23:42:10 -0700 Subject: [PATCH 23/33] Fixed bug #28337: wrong results for grouping queries with correlated subqueries in WHERE conditions. This bug was introduced by the patch for bug 27321. mysql-test/r/subselect.result: Added a test case for bug #28337. mysql-test/t/subselect.test: Added a test case for bug #28337. sql/item.cc: Fixed bug #28337: wrong results for grouping queries with correlated subqueries in WHERE conditions. This bug was introduced by the patch for bug 27321. Now in the Item_field::fix_outer_field function we create an Item_outer_ref object for an outer reference only if it is used in the SELECT list or in the HAVING clause of the subquery against which the reference is resolved. --- mysql-test/r/subselect.result | 30 ++++++++++++++++++++++++++++++ mysql-test/t/subselect.test | 24 ++++++++++++++++++++++++ sql/item.cc | 3 ++- 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 2e82d948edb..92a4a6f3f5a 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -4041,4 +4041,34 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ref a a 5 const 1 Using where; Using index 2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort DROP TABLE t1; +CREATE TABLE t1 (id int NOT NULL, st CHAR(2), INDEX idx(id)); +INSERT INTO t1 VALUES +(3,'FL'), (2,'GA'), (4,'FL'), (1,'GA'), (5,'NY'), (7,'FL'), (6,'NY'); +CREATE TABLE t2 (id int NOT NULL, INDEX idx(id)); +INSERT INTO t2 VALUES (7), (5), (1), (3); +SELECT id, st FROM t1 +WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id); +id st +3 FL +1 GA +7 FL +SELECT id, st FROM t1 +WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id) +GROUP BY id; +id st +1 GA +3 FL +7 FL +SELECT id, st FROM t1 +WHERE st IN ('GA','FL') AND NOT EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id); +id st +2 GA +4 FL +SELECT id, st FROM t1 +WHERE st IN ('GA','FL') AND NOT EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id) +GROUP BY id; +id st +2 GA +4 FL +DROP TABLE t1,t2; End of 5.0 tests. diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 64de2ada93c..5840e434b64 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -2882,4 +2882,28 @@ INSERT INTO t1 VALUES (1,1),(2,1); EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b); DROP TABLE t1; +# +# Bug #28377: grouping query with a correlated subquery in WHERE condition +# + +CREATE TABLE t1 (id int NOT NULL, st CHAR(2), INDEX idx(id)); +INSERT INTO t1 VALUES + (3,'FL'), (2,'GA'), (4,'FL'), (1,'GA'), (5,'NY'), (7,'FL'), (6,'NY'); +CREATE TABLE t2 (id int NOT NULL, INDEX idx(id)); +INSERT INTO t2 VALUES (7), (5), (1), (3); + +SELECT id, st FROM t1 + WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id); +SELECT id, st FROM t1 + WHERE st IN ('GA','FL') AND EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id) + GROUP BY id; + +SELECT id, st FROM t1 + WHERE st IN ('GA','FL') AND NOT EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id); +SELECT id, st FROM t1 + WHERE st IN ('GA','FL') AND NOT EXISTS(SELECT 1 FROM t2 WHERE t2.id=t1.id) + GROUP BY id; + +DROP TABLE t1,t2; + --echo End of 5.0 tests. diff --git a/sql/item.cc b/sql/item.cc index 30486e7559a..60c5b3b4a8c 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -3503,7 +3503,8 @@ Item_field::fix_outer_field(THD *thd, Field **from_field, Item **reference) prev_subselect_item->const_item_cache= 0; set_field(*from_field); if (!last_checked_context->select_lex->having_fix_field && - select->group_list.elements) + select->group_list.elements && + (place == SELECT_LIST || place == IN_HAVING)) { Item_outer_ref *rf; /* From d2250317bb9a931c272f4862fddc9d78162bc98d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 May 2007 13:27:39 +0500 Subject: [PATCH 24/33] valgrind error fix(addon) --- sql/sql_lex.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index bd81aa2d5c1..59bed09aa28 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1770,7 +1770,7 @@ void Query_tables_list::destroy_query_tables_list() st_lex::st_lex() :result(0), yacc_yyss(0), yacc_yyvs(0), - sql_command(SQLCOM_END) + sql_command(SQLCOM_END), option_type(OPT_DEFAULT) { /* Check that plugins_static_buffer is declared immediately after plugins */ compile_time_assert((&plugins + 1) == (DYNAMIC_ARRAY*)plugins_static_buffer); From c4a4df5aa40613377f27b2a10d6b114a9ec6df9e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 May 2007 23:09:45 +0400 Subject: [PATCH 25/33] Bug#28261: Wrong DATETIME comparison result when the GET_USER_VAR function is involved. The Arg_comparator::compare_datetime() comparator caches its arguments if they are constants i.e. const_item() returns true. The Item_func_get_user_var::const_item() returns true or false based on the current query_id and the query_id where the variable was created. Thus even if a query can change its value its const_item() still will return true. All this leads to a wrong comparison result when an object of the Item_func_get_user_var class is involved. Now the Arg_comparator::can_compare_as_dates() and the get_datetime_value() functions never cache result of the GET_USER_VAR() function (the Item_func_get_user_var class). mysql-test/t/type_datetime.test: A test case is added for the bug#28261: Wrong DATETIME comparison result when the GET_USER_VAR function is involved. mysql-test/r/type_datetime.result: A test case is added for the bug#28261: Wrong DATETIME comparison result when the GET_USER_VAR function is involved. sql/item_cmpfunc.cc: Bug#28261: Wrong DATETIME comparison result when the GET_USER_VAR function is involved. Now the Arg_comparator::can_compare_as_dates() and the get_datetime_value() functions never cache result of the GET_USER_VAR() function (the Item_func_get_user_var class). --- mysql-test/r/type_datetime.result | 24 ++++++++++++++++++++++++ mysql-test/t/type_datetime.test | 12 ++++++++++++ sql/item_cmpfunc.cc | 15 +++++++++++++-- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 573139bed48..48cc54fb3ef 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -352,3 +352,27 @@ select left(f1,10) = curdate() from t1; left(f1,10) = curdate() 1 drop table t1; +create table t1(f1 date); +insert into t1 values('01-01-01'),('02-02-02'),('01-01-01'),('02-02-02'); +set @bug28261=''; +select if(@bug28261 = f1, '', @bug28261:= f1) from t1; +if(@bug28261 = f1, '', @bug28261:= f1) +2001-01-01 +2002-02-02 +2001-01-01 +2002-02-02 +Warnings: +Warning 1292 Incorrect date value: '' for column 'f1' at row 1 +select if(@bug28261 = f1, '', @bug28261:= f1) from t1; +if(@bug28261 = f1, '', @bug28261:= f1) +2001-01-01 +2002-02-02 +2001-01-01 +2002-02-02 +select if(@bug28261 = f1, '', @bug28261:= f1) from t1; +if(@bug28261 = f1, '', @bug28261:= f1) +2001-01-01 +2002-02-02 +2001-01-01 +2002-02-02 +drop table t1; diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index 4c2416000be..cf512aa3649 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -234,3 +234,15 @@ create table t1 (f1 date); insert into t1 values (curdate()); select left(f1,10) = curdate() from t1; drop table t1; + +# +# Bug#28261: Wrong DATETIME comparison result when the GET_USER_VAR function +# is involved. +# +create table t1(f1 date); +insert into t1 values('01-01-01'),('02-02-02'),('01-01-01'),('02-02-02'); +set @bug28261=''; +select if(@bug28261 = f1, '', @bug28261:= f1) from t1; +select if(@bug28261 = f1, '', @bug28261:= f1) from t1; +select if(@bug28261 = f1, '', @bug28261:= f1) from t1; +drop table t1; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 9a251312aca..3a79940b571 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -633,7 +633,13 @@ Arg_comparator::can_compare_as_dates(Item *a, Item *b, ulonglong *const_value) if (cmp_type != CMP_DATE_DFLT) { - if (cmp_type != CMP_DATE_WITH_DATE && str_arg->const_item()) + /* + Do not cache GET_USER_VAR() function as its const_item() may return TRUE + for the current thread but it still may change during the execution. + */ + if (cmp_type != CMP_DATE_WITH_DATE && str_arg->const_item() && + (str_arg->type() != Item::FUNC_ITEM || + ((Item_func*)str_arg)->functype() != Item_func::GUSERVAR_FUNC)) { THD *thd= current_thd; ulonglong value; @@ -780,7 +786,12 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg, MYSQL_TYPE_DATE ? MYSQL_TIMESTAMP_DATE : MYSQL_TIMESTAMP_DATETIME; value= get_date_from_str(thd, str, t_type, warn_item->name, &error); } - if (item->const_item() && cache_arg) + /* + Do not cache GET_USER_VAR() function as its const_item() may return TRUE + for the current thread but it still may change during the execution. + */ + if (item->const_item() && cache_arg && (item->type() != Item::FUNC_ITEM || + ((Item_func*)item)->functype() != Item_func::GUSERVAR_FUNC)) { Item_cache_int *cache= new Item_cache_int(); /* Mark the cache as non-const to prevent re-caching. */ From 6249d57d4bc56a0213a152bae1a930fe45412111 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 May 2007 18:16:51 +0500 Subject: [PATCH 26/33] Fox for bug #28509: strange behaviour: passing a decimal value to PS Set parameter's type to Item::DECIMAL_ITEM assigning a decimal value. mysql-test/r/ps.result: Fox for bug #28509: strange behaviour: passing a decimal value to PS - test result. mysql-test/t/ps.test: Fox for bug #28509: strange behaviour: passing a decimal value to PS - test case. sql/item.cc: Fox for bug #28509: strange behaviour: passing a decimal value to PS - set Item_param::item_type to Item::DECIMAL_ITEM in case of DECIMAL_RESULT variable. - removed redundant item_result_type assignments as it's set before. --- mysql-test/r/ps.result | 9 +++++++++ mysql-test/t/ps.test | 8 ++++++++ sql/item.cc | 6 ++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 20bff6bda1c..0048c4ad6c5 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -1661,4 +1661,13 @@ execute stmt; ERROR 42S22: Unknown column 'y.value' in 'field list' deallocate prepare stmt; drop tables t1; +prepare stmt from "create table t1 select ?"; +set @a=1.0; +execute stmt using @a; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `?` decimal(2,1) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; End of 5.0 tests. diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 3fbcf84a1f9..08949bd8cff 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -1773,5 +1773,13 @@ execute stmt; deallocate prepare stmt; drop tables t1; +# +# Bug #28509: strange behaviour: passing a decimal value to PS +# +prepare stmt from "create table t1 select ?"; +set @a=1.0; +execute stmt using @a; +show create table t1; +drop table t1; --echo End of 5.0 tests. diff --git a/sql/item.cc b/sql/item.cc index 827c872adbc..cccbbdeb043 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2506,16 +2506,14 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry) if (entry && entry->value) { item_result_type= entry->type; - switch (entry->type) { + switch (item_result_type) { case REAL_RESULT: set_double(*(double*)entry->value); item_type= Item::REAL_ITEM; - item_result_type= REAL_RESULT; break; case INT_RESULT: set_int(*(longlong*)entry->value, MY_INT64_NUM_DECIMAL_DIGITS); item_type= Item::INT_ITEM; - item_result_type= INT_RESULT; break; case STRING_RESULT: { @@ -2537,7 +2535,6 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry) charset of connection, so we have to set it later. */ item_type= Item::STRING_ITEM; - item_result_type= STRING_RESULT; if (set_str((const char *)entry->value, entry->length)) DBUG_RETURN(1); @@ -2551,6 +2548,7 @@ bool Item_param::set_from_user_var(THD *thd, const user_var_entry *entry) decimals= ent_value->frac; max_length= my_decimal_precision_to_length(ent_value->precision(), decimals, unsigned_flag); + item_type= Item::DECIMAL_ITEM; break; } default: From f7434c4f93294d75b584d2160dd279e523d0a5b8 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 May 2007 17:48:44 +0200 Subject: [PATCH 27/33] added cleanup to some tests mysql-test/r/sp_trans.result: added cleanup mysql-test/r/strict.result: added cleanup mysql-test/t/sp_trans.test: added cleanup mysql-test/t/strict.test: added cleanup --- mysql-test/r/sp_trans.result | 3 +-- mysql-test/r/strict.result | 2 +- mysql-test/t/sp_trans.test | 9 +++------ mysql-test/t/strict.test | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result index f09645703ba..c74909e7e8f 100644 --- a/mysql-test/r/sp_trans.result +++ b/mysql-test/r/sp_trans.result @@ -530,8 +530,6 @@ count(*) drop table t3, t4| drop procedure bug14210| set @@session.max_heap_table_size=default| -drop function if exists bug23333| -drop table if exists t1,t2| CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM| CREATE TABLE t2 (a int NOT NULL auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB| insert into t2 values (1,1)| @@ -551,3 +549,4 @@ Log_name Pos Event_type Server_id End_log_pos Info select count(*),@a from t1 /* must be 1,1 */| count(*) @a 1 1 +drop table t1, t2| diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result index eecdc545be7..74bd2a171e3 100644 --- a/mysql-test/r/strict.result +++ b/mysql-test/r/strict.result @@ -3,7 +3,7 @@ set @@sql_mode='ansi,traditional'; select @@sql_mode; @@sql_mode REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER -DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t1, t2; CREATE TABLE t1 (col1 date); INSERT INTO t1 VALUES('2004-01-01'),('2004-02-29'); INSERT INTO t1 VALUES('0000-10-31'); diff --git a/mysql-test/t/sp_trans.test b/mysql-test/t/sp_trans.test index d9b34c303ae..8eccaafcf0e 100644 --- a/mysql-test/t/sp_trans.test +++ b/mysql-test/t/sp_trans.test @@ -559,12 +559,8 @@ set @@session.max_heap_table_size=default| # breaks stmt-based binlog # Bug #27395 OPTION_STATUS_NO_TRANS_UPDATE is not preserved at the end of SF() # ---disable_warnings -drop function if exists bug23333| -drop table if exists t1,t2| ---enable_warnings - CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM| - CREATE TABLE t2 (a int NOT NULL auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB| +CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM| +CREATE TABLE t2 (a int NOT NULL auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB| insert into t2 values (1,1)| @@ -583,6 +579,7 @@ insert into t2 values (bug23333(),1)| --replace_column 2 # 5 # 6 # show binlog events from 98 /* with fixes for #23333 will show there is the query */| select count(*),@a from t1 /* must be 1,1 */| +drop table t1, t2| # # BUG#NNNN: New bug synopsis diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test index faca9e7b080..fc663853174 100644 --- a/mysql-test/t/strict.test +++ b/mysql-test/t/strict.test @@ -7,7 +7,7 @@ set @@sql_mode='ansi,traditional'; select @@sql_mode; --disable_warnings -DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t1, t2; --enable_warnings # Test INSERT with DATE From 5d2075938a989d76a9662d9276cd83a7397023d5 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 May 2007 23:21:34 +0500 Subject: [PATCH 28/33] merging --- mysql-test/r/ps.result | 208 ----------------------------------- mysql-test/r/sp_trans.result | 20 ---- mysql-test/t/ps.test | 109 ------------------ mysql-test/t/sp_trans.test | 29 ----- sql/opt_sum.cc | 7 +- 5 files changed, 4 insertions(+), 369 deletions(-) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 10d4015925f..b811a27203c 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -1190,214 +1190,6 @@ EXECUTE b12651; DROP VIEW b12651_V1; DROP TABLE b12651_T1, b12651_T2; DEALLOCATE PREPARE b12651; -DROP TABLE IF EXISTS t1, t2; -CREATE TABLE t1 (i INT); -PREPARE st_19182 -FROM "CREATE TABLE t2 (i INT, j INT, KEY (i), KEY(j)) SELECT i FROM t1"; -EXECUTE st_19182; -DESC t2; -Field Type Null Key Default Extra -j int(11) YES MUL NULL -i int(11) YES MUL NULL -DROP TABLE t2; -EXECUTE st_19182; -DESC t2; -Field Type Null Key Default Extra -j int(11) YES MUL NULL -i int(11) YES MUL NULL -DEALLOCATE PREPARE st_19182; -DROP TABLE t2, t1; -drop database if exists mysqltest; -drop table if exists t1, t2; -create database mysqltest character set utf8; -prepare stmt1 from "create table mysqltest.t1 (c char(10))"; -prepare stmt2 from "create table mysqltest.t2 select 'test'"; -execute stmt1; -execute stmt2; -show create table mysqltest.t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `c` char(10) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=utf8 -show create table mysqltest.t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `test` varchar(4) character set latin1 NOT NULL default '' -) ENGINE=MyISAM DEFAULT CHARSET=utf8 -drop table mysqltest.t1; -drop table mysqltest.t2; -alter database mysqltest character set latin1; -execute stmt1; -execute stmt2; -show create table mysqltest.t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `c` char(10) character set utf8 default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -show create table mysqltest.t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `test` varchar(4) NOT NULL default '' -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -drop database mysqltest; -deallocate prepare stmt1; -deallocate prepare stmt2; -execute stmt; -show create table t1; -drop table t1; -execute stmt; -show create table t1; -drop table t1; -deallocate prepare stmt; -CREATE TABLE t1(a int); -INSERT INTO t1 VALUES (2), (3), (1); -PREPARE st1 FROM -'(SELECT a FROM t1) UNION (SELECT a+10 FROM t1) ORDER BY RAND()*0+a'; -EXECUTE st1; -a -1 -2 -3 -11 -12 -13 -EXECUTE st1; -a -1 -2 -3 -11 -12 -13 -DEALLOCATE PREPARE st1; -DROP TABLE t1; -End of 4.1 tests. -create table t1 (a varchar(20)); -insert into t1 values ('foo'); -prepare stmt FROM 'SELECT char_length (a) FROM t1'; -ERROR 42000: FUNCTION test.char_length does not exist -drop table t1; -create table t1 (a char(3) not null, b char(3) not null, -c char(3) not null, primary key (a, b, c)); -create table t2 like t1; -prepare stmt from -"select t1.a from (t1 left outer join t2 on t2.a=1 and t1.b=t2.b) - where t1.a=1"; -execute stmt; -a -execute stmt; -a -execute stmt; -a -prepare stmt from -"select t1.a, t1.b, t1.c, t2.a, t2.b, t2.c from -(t1 left outer join t2 on t2.a=? and t1.b=t2.b) -left outer join t2 t3 on t3.a=? where t1.a=?"; -set @a:=1, @b:=1, @c:=1; -execute stmt using @a, @b, @c; -a b c a b c -execute stmt using @a, @b, @c; -a b c a b c -execute stmt using @a, @b, @c; -a b c a b c -deallocate prepare stmt; -drop table t1,t2; -SET @aux= "SELECT COUNT(*) - FROM INFORMATION_SCHEMA.COLUMNS A, - INFORMATION_SCHEMA.COLUMNS B - WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA - AND A.TABLE_NAME = B.TABLE_NAME - AND A.COLUMN_NAME = B.COLUMN_NAME AND - A.TABLE_NAME = 'user'"; -prepare my_stmt from @aux; -execute my_stmt; -COUNT(*) -37 -execute my_stmt; -COUNT(*) -37 -execute my_stmt; -COUNT(*) -37 -deallocate prepare my_stmt; -drop procedure if exists p1| -drop table if exists t1| -create table t1 (id int)| -insert into t1 values(1)| -create procedure p1(a int, b int) -begin -declare c int; -select max(id)+1 into c from t1; -insert into t1 select a+b; -insert into t1 select a-b; -insert into t1 select a-c; -end| -set @a= 3, @b= 4| -prepare stmt from "call p1(?, ?)"| -execute stmt using @a, @b| -execute stmt using @a, @b| -select * from t1| -id -1 -7 --1 -1 -7 --1 --5 -deallocate prepare stmt| -drop procedure p1| -drop table t1| -create table t1 (a int); -insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); -prepare stmt from "select * from t1 limit ?, ?"; -set @offset=0, @limit=1; -execute stmt using @offset, @limit; -a -1 -select * from t1 limit 0, 1; -a -1 -set @offset=3, @limit=2; -execute stmt using @offset, @limit; -a -4 -5 -select * from t1 limit 3, 2; -a -4 -5 -prepare stmt from "select * from t1 limit ?"; -execute stmt using @limit; -a -1 -2 -prepare stmt from "select * from t1 where a in (select a from t1 limit ?)"; -ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' -prepare stmt from "select * from t1 union all select * from t1 limit ?, ?"; -set @offset=9; -set @limit=2; -execute stmt using @offset, @limit; -a -10 -1 -prepare stmt from "(select * from t1 limit ?, ?) union all - (select * from t1 limit ?, ?) order by a limit ?"; -execute stmt using @offset, @limit, @offset, @limit, @limit; -a -10 -10 -drop table t1; -deallocate prepare stmt; -CREATE TABLE b12651_T1(a int) ENGINE=MYISAM; -CREATE TABLE b12651_T2(b int) ENGINE=MYISAM; -CREATE VIEW b12651_V1 as SELECT b FROM b12651_T2; -PREPARE b12651 FROM 'SELECT 1 FROM b12651_T1 WHERE a IN (SELECT b FROM b12651_V1)'; -EXECUTE b12651; -1 -DROP VIEW b12651_V1; -DROP TABLE b12651_T1, b12651_T2; -DEALLOCATE PREPARE b12651; create table t1 (id int); prepare ins_call from "insert into t1 (id) values (1)"; execute ins_call; diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result index c81183029ca..a0d687e565b 100644 --- a/mysql-test/r/sp_trans.result +++ b/mysql-test/r/sp_trans.result @@ -530,26 +530,6 @@ count(*) drop table t3, t4| drop procedure bug14210| set @@session.max_heap_table_size=default| -CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM| -CREATE TABLE t2 (a int NOT NULL auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB| -insert into t2 values (1,1)| -create function bug23333() -RETURNS int(11) -DETERMINISTIC -begin -insert into t1 values (null); -select count(*) from t1 into @a; -return @a; -end| -reset master| -insert into t2 values (bug23333(),1)| -ERROR 23000: Duplicate entry '1' for key 1 -show binlog events from 98 /* with fixes for #23333 will show there is the query */| -Log_name Pos Event_type Server_id End_log_pos Info -select count(*),@a from t1 /* must be 1,1 */| -count(*) @a -1 1 -drop table t1, t2| CREATE DATABASE db_bug7787| use db_bug7787| CREATE PROCEDURE p1() diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 22eb51c6327..1fd1cc4a405 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -1120,115 +1120,6 @@ DROP TABLE t1; --echo End of 4.1 tests. -# -# Bug#19182: CREATE TABLE bar (m INT) SELECT n FROM foo; doesn't work -# from stored procedure. -# -# The cause of a bug was that cached LEX::create_list was modified, -# and then together with LEX::key_list was reset. -# ---disable_warnings -DROP TABLE IF EXISTS t1, t2; ---enable_warnings - -CREATE TABLE t1 (i INT); - -PREPARE st_19182 -FROM "CREATE TABLE t2 (i INT, j INT, KEY (i), KEY(j)) SELECT i FROM t1"; - -EXECUTE st_19182; -DESC t2; - -DROP TABLE t2; - -# Check that on second execution we don't loose 'j' column and the keys -# on 'i' and 'j' columns. -EXECUTE st_19182; -DESC t2; - -DEALLOCATE PREPARE st_19182; -DROP TABLE t2, t1; - -# -# Bug #22060 "ALTER TABLE x AUTO_INCREMENT=y in SP crashes server" -# -# Code which implemented CREATE/ALTER TABLE and CREATE DATABASE -# statement modified HA_CREATE_INFO structure in LEX, making these -# statements PS/SP-unsafe (their re-execution might have resulted -# in incorrect results). -# ---disable_warnings -drop database if exists mysqltest; -drop table if exists t1, t2; ---enable_warnings -# CREATE TABLE and CREATE TABLE ... SELECT -create database mysqltest character set utf8; -prepare stmt1 from "create table mysqltest.t1 (c char(10))"; -prepare stmt2 from "create table mysqltest.t2 select 'test'"; -execute stmt1; -execute stmt2; -show create table mysqltest.t1; -show create table mysqltest.t2; -drop table mysqltest.t1; -drop table mysqltest.t2; -alter database mysqltest character set latin1; -execute stmt1; -execute stmt2; -show create table mysqltest.t1; -show create table mysqltest.t2; -drop database mysqltest; -deallocate prepare stmt1; -deallocate prepare stmt2; -# -# CREATE TABLE with DATA DIRECTORY option -# -# Protect ourselves from data left in tmp/ by a previos possibly failed -# test ---system rm -f $MYSQLTEST_VARDIR/tmp/t1.* ---disable_warnings ---disable_query_log -eval prepare stmt from "create table t1 (c char(10)) data directory='$MYSQLTEST_VARDIR/tmp'"; ---enable_query_log -execute stmt; -# -# DATA DIRECTORY option does not always work: if the operating -# system does not support symlinks, have_symlinks option is automatically -# disabled. -# In this case DATA DIRECTORY is silently ignored when -# creating a table, and is not output by SHOW CREATE TABLE. -# ---disable_result_log -show create table t1; ---enable_result_log -drop table t1; -execute stmt; ---disable_result_log -show create table t1; ---enable_result_log ---enable_warnings -drop table t1; -deallocate prepare stmt; -# - -# -# Bug #27937: crash on the second execution for prepared statement -# from UNION with ORDER BY an expression containing RAND() -# - -CREATE TABLE t1(a int); -INSERT INTO t1 VALUES (2), (3), (1); - -PREPARE st1 FROM - '(SELECT a FROM t1) UNION (SELECT a+10 FROM t1) ORDER BY RAND()*0+a'; - -EXECUTE st1; -EXECUTE st1; - -DEALLOCATE PREPARE st1; -DROP TABLE t1; - ---echo End of 4.1 tests. - ############################# 5.0 tests start ################################ # # diff --git a/mysql-test/t/sp_trans.test b/mysql-test/t/sp_trans.test index 8a0265ea4e9..a79f6c7e7e0 100644 --- a/mysql-test/t/sp_trans.test +++ b/mysql-test/t/sp_trans.test @@ -592,35 +592,6 @@ drop function bug13575| drop table t3| -# -# -# Bug #13270 INSERT,UPDATE,etc that calls func with side-effect does not binlog -# Bug #23333 stored function + non-transac table + transac table = -# breaks stmt-based binlog -# Bug #27395 OPTION_STATUS_NO_TRANS_UPDATE is not preserved at the end of SF() -# -CREATE TABLE t1 (a int NOT NULL auto_increment primary key) ENGINE=MyISAM| -CREATE TABLE t2 (a int NOT NULL auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB| - -insert into t2 values (1,1)| - -create function bug23333() -RETURNS int(11) -DETERMINISTIC -begin - insert into t1 values (null); - select count(*) from t1 into @a; - return @a; -end| - -reset master| ---error ER_DUP_ENTRY -insert into t2 values (bug23333(),1)| ---replace_column 2 # 5 # 6 # -show binlog events from 98 /* with fixes for #23333 will show there is the query */| -select count(*),@a from t1 /* must be 1,1 */| -drop table t1, t2| - # # BUG#NNNN: New bug synopsis # diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index c020b9ab53e..60df49bd318 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -271,7 +271,7 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) we have a >= predicate for the MIN argument. */ error= table->file->index_read(table->record[0], ref.key_buff, - ref.key_length, + make_prev_keypart_map(ref.key_parts), HA_READ_KEY_OR_NEXT); else { @@ -282,7 +282,8 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) We need to scan the next bigger record first. */ error= table->file->index_read(table->record[0], ref.key_buff, - ref.key_length, HA_READ_AFTER_KEY); + make_prev_keypart_map(ref.key_parts), + HA_READ_AFTER_KEY); /* If the found record is outside the group formed by the search prefix, or there is no such record at all, check if all @@ -305,7 +306,7 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) { DBUG_ASSERT(item_field->field->real_maybe_null()); error= table->file->index_read(table->record[0], ref.key_buff, - ref.key_length, + make_prev_keypart_map(ref.key_parts), HA_READ_KEY_EXACT); } } From f0f783786df532ba900aab6dda5eaf28dbc2f23a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 21 May 2007 11:33:58 +0200 Subject: [PATCH 29/33] Bug#27438 rpl_rotate_logs fails on Windows - Fix test case to work also when filesystem time differs from mysqld' time. I.e when running with data files on a network share. mysql-test/r/rpl_rotate_logs.result: Update result file mysql-test/t/rpl_rotate_logs.test: Calculate time to use in "purge master logs before" by taking last modification time of t2 and adding 1 second This is done in order to handle the case where file system time differs from mysqld's time --- mysql-test/r/rpl_rotate_logs.result | 5 ++++- mysql-test/t/rpl_rotate_logs.test | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result index bf2ef98c87f..df42e76a0c8 100644 --- a/mysql-test/r/rpl_rotate_logs.result +++ b/mysql-test/r/rpl_rotate_logs.result @@ -50,7 +50,10 @@ show binary logs; Log_name File_size master-bin.000002 363 master-bin.000003 407 -purge master logs before now(); +select @time_for_purge:=DATE_ADD(UPDATE_TIME, INTERVAL 1 SECOND) +from information_schema.tables +where TABLE_SCHEMA="test" and TABLE_NAME="t2"; +purge master logs before (@time_for_purge); show binary logs; Log_name File_size master-bin.000003 407 diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test index 5d9f1c29fe2..01f556c3c8f 100644 --- a/mysql-test/t/rpl_rotate_logs.test +++ b/mysql-test/t/rpl_rotate_logs.test @@ -107,9 +107,18 @@ show master logs; # we just tests if synonyms are accepted purge binary logs to 'master-bin.000002'; show binary logs; -# sleeping 10 seconds or more would make the slave believe connection is down ---real_sleep 1 -purge master logs before now(); + +# Calculate time to use in "purge master logs before" by taking +# last modification time of t2 and adding 1 second +# This is donw in order to handle the case where file system +# time differs from mysqld's time +--disable_result_log +select @time_for_purge:=DATE_ADD(UPDATE_TIME, INTERVAL 1 SECOND) + from information_schema.tables + where TABLE_SCHEMA="test" and TABLE_NAME="t2"; +--enable_result_log + +purge master logs before (@time_for_purge); show binary logs; insert into t2 values (65); sync_slave_with_master; From 25da4154ce3d90b6f31918208124f942f6baa3c4 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 21 May 2007 20:24:34 +0200 Subject: [PATCH 30/33] Prevent the failing "jp" suite from causing havoc in release builds (28563). Makefile.am: This is *no* fix, it is just to avoid the failure of the "jp" test suite (28563 is the number of the bug) from causing havoc in release builds. --- Makefile.am | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 41ddf026a63..c69dd96f785 100644 --- a/Makefile.am +++ b/Makefile.am @@ -131,8 +131,10 @@ test-bt: @PERL@ ./mysql-test-run.pl --force --comment=rpl --suite=rpl -cd mysql-test ; MTR_BUILD_THREAD=auto \ @PERL@ ./mysql-test-run.pl --force --comment=partitions --suite=parts - -cd mysql-test ; MTR_BUILD_THREAD=auto \ - @PERL@ ./mysql-test-run.pl --force --comment=jp --suite=jp + +# Re-enable the "jp" suite when bug#28563 is fixed +# -cd mysql-test ; MTR_BUILD_THREAD=auto \ +# @PERL@ ./mysql-test-run.pl --force --comment=jp --suite=jp test-bt-debug: -cd mysql-test ; MTR_BUILD_THREAD=auto \ From d076bcbcc431061cbb668e81ab54281605ef9bbe Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 May 2007 11:16:29 +0500 Subject: [PATCH 31/33] Fix for bug #21476: stack overflow crashes server; error-message stack reservation too small Increase STACK_BUFF_ALLOC to avoid execution_constants test failure on the hpita2. sql/mysql_priv.h: Fix for bug #21476: stack overflow crashes server; error-message stack reservation too small - due to the failing execution_constants test on the hpita2, increase STACK_BUFF_ALLOC, that is used in the Item_func::fix_fields() to allocate on the stack a "dummy" buffer large enough for the corresponding exec. --- sql/mysql_priv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index ea472691760..853acd65584 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -179,7 +179,7 @@ MY_LOCALE *my_locale_by_number(uint number); #define STACK_MIN_SIZE 12000 // Abort if less stack during eval. #define STACK_MIN_SIZE_FOR_OPEN 1024*80 -#define STACK_BUFF_ALLOC 256 // For stack overrun checks +#define STACK_BUFF_ALLOC 352 // For stack overrun checks #ifndef MYSQLD_NET_RETRY_COUNT #define MYSQLD_NET_RETRY_COUNT 10 // Abort read after this many int. #endif From 8a56af76cf0961aeb7241a8c58005b4aa5fe882d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 May 2007 12:15:47 +0500 Subject: [PATCH 32/33] Fix for bug #23810: Server crashes on various "show status ..." commands We access some variable values using casts like *(long *) buff that may cause crashes on some platforms (e.g. solaris 64) if buff is not properly aligned. Fix: align the buffer used. include/my_global.h: Fix for bug #23810: Server crashes on various "show status ..." commands - MY_DIV_UP(A, B) macro introduced, which devides A then rounds up by B. - MY_ALIGNED_BYTE_ARRAY(N, S, T) macro introduced, which declares an S-byte long (aligned) N array of type T. sql/sql_show.cc: Fix for bug #23810: Server crashes on various "show status ..." commands - align the buffer used. --- include/my_global.h | 3 +++ sql/sql_show.cc | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/my_global.h b/include/my_global.h index 781524d7be7..9eebcac33c6 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -911,6 +911,9 @@ typedef unsigned long long my_size_t; #define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size) #define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B)) +#define MY_DIV_UP(A, B) (((A) + (B) - 1) / (B)) +#define MY_ALIGNED_BYTE_ARRAY(N, S, T) T N[MY_DIV_UP(S, sizeof(T))] + /* Custom version of standard offsetof() macro which can be used to get offsets of members in class for non-POD types (according to the current diff --git a/sql/sql_show.cc b/sql/sql_show.cc index e8107248c14..65506860e09 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2035,7 +2035,9 @@ static bool show_status_array(THD *thd, const char *wild, const char *prefix, TABLE *table, bool ucase_names) { - char buff[SHOW_VAR_FUNC_BUFF_SIZE], *prefix_end; + MY_ALIGNED_BYTE_ARRAY(buff_data, SHOW_VAR_FUNC_BUFF_SIZE, long); + char * const buff= (char *) &buff_data; + char *prefix_end; /* the variable name should not be longer than 64 characters */ char name_buffer[64]; int len; From 0197ee1d719fcab4e75d2bd929c8656699ce5a42 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 May 2007 15:49:17 +0500 Subject: [PATCH 33/33] after-merge fix: adjusted test results. --- mysql-test/r/ps.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 45cdc6a2101..371023200d9 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -1566,7 +1566,7 @@ execute stmt using @a; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `?` decimal(2,1) default NULL + `?` decimal(2,1) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; End of 5.0 tests.