From 35a3f9d76c7f69dafbade6776d5ca3d96100992c Mon Sep 17 00:00:00 2001 From: Neeraj Bisht Date: Mon, 13 May 2013 17:15:25 +0530 Subject: Bug#12328597 - MULTIPLE COUNT(DISTINCT) IN SAME SELECT FALSE WITH COMPOSITE KEY COLUMNS Problem:- While running a SELECT query with several AGGR(DISTINCT) function and these are referring to different field of same composite key, Returned incorrect value. Analysis:- In a table, where we have composite key like (a,b,c) and when we give a query like select COUNT(DISTINCT b), SUM(DISTINCT a) from .... here, we first make a list of items in Aggr(distinct) function (which is a, b), where order of item doesn't matter. and then we see, whether we have a composite key where the prefix of index columns matches the items of the aggregation function. (in this case we have a,b,c). if yes, so we can use loose index scan and we need not perform duplicate removal to distinct in our aggregate function. In our table, we traverse column marked with <-- and get the result as (a,b,c) count(distinct b) sum(distinct a) treated as count b treated as sum(a) (1,1,2)<-- 1 1 (1,2,2)<-- 1++=2 1+1=2 (1,2,3) (2,1,2)<-- 2++=3 1+1+2=4 (2,2,2)<-- 3++=4 1+1+2+2=6 (2,2,3) result will be 4,6, but it should be (2,3) As in this case, our assumption is incorrect. If we have query like select count(distinct a,b), sum(distinct a,b)from .. then we can use loose index scan Solution:- In our query, when we have more then one aggr(distinct) function then they should refer to same fields like select count(distinct a,b), sum(distinct a,b) from .. -->we can use loose scan index as both aggr(distinct) refer to same fields a,b. If they are referring to different field like select count(distinct a), sum(distinct b) from .. -->will not use loose scan index as both aggr(distinct) refer to different fields. --- mysql-test/r/group_min_max.result | 5 +++-- mysql-test/t/group_min_max.test | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result index 07b4c71cbe3..7be0479a5a8 100644 --- a/mysql-test/r/group_min_max.result +++ b/mysql-test/r/group_min_max.result @@ -2858,9 +2858,10 @@ COUNT(DISTINCT a, b + 0) 16 EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range NULL a 10 NULL 9 Using index for group-by +1 SIMPLE t1 index NULL a 10 NULL 16 Using index SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT b) < 10; COUNT(DISTINCT a) +2 EXPLAIN SELECT COUNT(DISTINCT a) FROM t1 HAVING COUNT(DISTINCT c) < 10; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 16 @@ -2994,7 +2995,7 @@ WHERE b = 13 AND c = 42 GROUP BY a; a COUNT(DISTINCT a) SUM(DISTINCT a) EXPLAIN SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range NULL a 10 NULL 9 Using where; Using index for group-by +1 SIMPLE t2 index NULL a 15 NULL 16 Using where; Using index SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42; COUNT(DISTINCT a, b) SUM(DISTINCT a) 0 NULL diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test index fa52da63195..2b38b60ef3c 100644 --- a/mysql-test/t/group_min_max.test +++ b/mysql-test/t/group_min_max.test @@ -1207,6 +1207,8 @@ EXPLAIN SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2 SELECT a, COUNT(DISTINCT a), SUM(DISTINCT a) FROM t2 WHERE b = 13 AND c = 42 GROUP BY a; +# This query could have been resolved using loose index scan since the second +# part of count(..) is defined by a constant predicate EXPLAIN SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42; SELECT COUNT(DISTINCT a, b), SUM(DISTINCT a) FROM t2 WHERE b = 42; -- cgit v1.2.1 From 0bec3c414262f8de0518df19dfd762435c859ea4 Mon Sep 17 00:00:00 2001 From: sayantan dutta Date: Thu, 16 May 2013 14:18:04 +0530 Subject: Bug #16813007 - MTR IS NOT TAKING MYSQLTEST CLIENT USING THE ENV VARIABLE MYSQL_TEST --- mysql-test/mysql-test-run.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'mysql-test') diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index bcc43a97cdf..c8675b03e25 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1785,7 +1785,17 @@ sub executable_setup () { } else { - $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest"); + if ( defined $ENV{'MYSQL_TEST'} ) + { + $exe_mysqltest=$ENV{'MYSQL_TEST'}; + print "===========================================================\n"; + print "WARNING:The mysqltest binary is fetched from $exe_mysqltest\n"; + print "===========================================================\n"; + } + else + { + $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest"); + } } } -- cgit v1.2.1 From 40fbf8bc28c5db76ee5820707258470aff03dbf8 Mon Sep 17 00:00:00 2001 From: sayantan dutta Date: Thu, 16 May 2013 14:32:09 +0530 Subject: Bug #16813007 - MTR IS NOT TAKING MYSQLTEST CLIENT USING THE ENV VARIABLE MYSQL_TEST --- mysql-test/mysql-test-run.pl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'mysql-test') diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index bcc43a97cdf..c8675b03e25 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1785,7 +1785,17 @@ sub executable_setup () { } else { - $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest"); + if ( defined $ENV{'MYSQL_TEST'} ) + { + $exe_mysqltest=$ENV{'MYSQL_TEST'}; + print "===========================================================\n"; + print "WARNING:The mysqltest binary is fetched from $exe_mysqltest\n"; + print "===========================================================\n"; + } + else + { + $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest"); + } } } -- cgit v1.2.1 From 0c4f4ff015f7c4a06b9d4c9e8f22f44a57e2a318 Mon Sep 17 00:00:00 2001 From: Ashish Agarwal Date: Sun, 19 May 2013 23:38:06 +0530 Subject: Bug#16194302: SUPPORT FOR FLOATING-POINT SYSTEM VARIABLES USING THE PLUGIN INTERFACE. ISSUE: No support for floating-point plugin system variables. SOLUTION: Allowing plugins to define and expose floating-point system variables of type double. MYSQL_SYSVAR_DOUBLE and MYSQL_THDVAR_DOUBLE are added. ISSUE: Fractional part of the def, min, max values of system variables are ignored. SOLUTION: Adding functions that are used to store the raw representation of a double in the raw bits of unsigned longlong in a way that the binary representation remains the same. --- mysql-test/r/plugin.result | 82 +++++++++++++++++++++++++++++++++++++++++++++- mysql-test/t/plugin.test | 52 +++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 1 deletion(-) (limited to 'mysql-test') diff --git a/mysql-test/r/plugin.result b/mysql-test/r/plugin.result index 0d5bc29fc8c..2b96dc4f3ac 100644 --- a/mysql-test/r/plugin.result +++ b/mysql-test/r/plugin.result @@ -16,9 +16,11 @@ set global example_ulong_var=500; set global example_enum_var= e1; show status like 'example%'; Variable_name Value -example_func_example enum_var is 0, ulong_var is 500, really +example_func_example enum_var is 0, ulong_var is 500, double_var is 8.500000, really show variables like 'example%'; Variable_name Value +example_double_thdvar 8.500000 +example_double_var 8.500000 example_enum_var e1 example_ulong_var 500 UNINSTALL PLUGIN example; @@ -63,3 +65,81 @@ set session sql_mode=@old_sql_mode; set session old=bla; ERROR HY000: Variable 'old' is a read only variable UNINSTALL PLUGIN example; +# +# Bug #16194302 SUPPORT FOR FLOATING-POINT SYSTEM +# VARIABLES USING THE PLUGIN INTERFACE. +# +INSTALL PLUGIN example SONAME 'ha_example.so'; +SET GLOBAL example_double_var = -0.1; +Warnings: +Warning 1292 Truncated incorrect example_double_var value: '-0.1' +SELECT @@GLOBAL.example_double_var; +@@GLOBAL.example_double_var +0.500000 +SET GLOBAL example_double_var = 0.000001; +Warnings: +Warning 1292 Truncated incorrect example_double_var value: '0.000001' +SELECT @@GLOBAL.example_double_var; +@@GLOBAL.example_double_var +0.500000 +SET GLOBAL example_double_var = 0.4; +Warnings: +Warning 1292 Truncated incorrect example_double_var value: '0.4' +SELECT @@GLOBAL.example_double_var; +@@GLOBAL.example_double_var +0.500000 +SET GLOBAL example_double_var = 123.456789; +SELECT @@GLOBAL.example_double_var; +@@GLOBAL.example_double_var +123.456789 +SET GLOBAL example_double_var = 500; +SELECT @@GLOBAL.example_double_var; +@@GLOBAL.example_double_var +500.000000 +SET GLOBAL example_double_var = 999.999999; +SELECT @@GLOBAL.example_double_var; +@@GLOBAL.example_double_var +999.999999 +SET GLOBAL example_double_var = 1000.51; +Warnings: +Warning 1292 Truncated incorrect example_double_var value: '1000.51' +SELECT @@GLOBAL.example_double_var; +@@GLOBAL.example_double_var +1000.500000 +SET SESSION example_double_thdvar = -0.1; +Warnings: +Warning 1292 Truncated incorrect example_double_thdvar value: '-0.1' +SELECT @@SESSION.example_double_thdvar; +@@SESSION.example_double_thdvar +0.500000 +SET SESSION example_double_thdvar = 0.000001; +Warnings: +Warning 1292 Truncated incorrect example_double_thdvar value: '0.000001' +SELECT @@SESSION.example_double_thdvar; +@@SESSION.example_double_thdvar +0.500000 +SET SESSION example_double_thdvar = 0.4; +Warnings: +Warning 1292 Truncated incorrect example_double_thdvar value: '0.4' +SELECT @@SESSION.example_double_thdvar; +@@SESSION.example_double_thdvar +0.500000 +SET SESSION example_double_thdvar = 123.456789; +SELECT @@SESSION.example_double_thdvar; +@@SESSION.example_double_thdvar +123.456789 +SET SESSION example_double_thdvar = 500; +SELECT @@SESSION.example_double_thdvar; +@@SESSION.example_double_thdvar +500.000000 +SET SESSION example_double_thdvar = 999.999999; +SELECT @@SESSION.example_double_thdvar; +@@SESSION.example_double_thdvar +999.999999 +SET SESSION example_double_thdvar = 1000.51; +Warnings: +Warning 1292 Truncated incorrect example_double_thdvar value: '1000.51' +SELECT @@SESSION.example_double_thdvar; +@@SESSION.example_double_thdvar +1000.500000 +UNINSTALL PLUGIN example; diff --git a/mysql-test/t/plugin.test b/mysql-test/t/plugin.test index 117eaf1e19b..f3a3b0cc068 100644 --- a/mysql-test/t/plugin.test +++ b/mysql-test/t/plugin.test @@ -85,3 +85,55 @@ set session sql_mode=@old_sql_mode; set session old=bla; UNINSTALL PLUGIN example; + +--echo # +--echo # Bug #16194302 SUPPORT FOR FLOATING-POINT SYSTEM +--echo # VARIABLES USING THE PLUGIN INTERFACE. +--echo # + +--replace_regex /\.dll/.so/ +eval INSTALL PLUGIN example SONAME '$EXAMPLE_PLUGIN'; + +SET GLOBAL example_double_var = -0.1; +SELECT @@GLOBAL.example_double_var; + +SET GLOBAL example_double_var = 0.000001; +SELECT @@GLOBAL.example_double_var; + +SET GLOBAL example_double_var = 0.4; +SELECT @@GLOBAL.example_double_var; + +SET GLOBAL example_double_var = 123.456789; +SELECT @@GLOBAL.example_double_var; + +SET GLOBAL example_double_var = 500; +SELECT @@GLOBAL.example_double_var; + +SET GLOBAL example_double_var = 999.999999; +SELECT @@GLOBAL.example_double_var; + +SET GLOBAL example_double_var = 1000.51; +SELECT @@GLOBAL.example_double_var; + +SET SESSION example_double_thdvar = -0.1; +SELECT @@SESSION.example_double_thdvar; + +SET SESSION example_double_thdvar = 0.000001; +SELECT @@SESSION.example_double_thdvar; + +SET SESSION example_double_thdvar = 0.4; +SELECT @@SESSION.example_double_thdvar; + +SET SESSION example_double_thdvar = 123.456789; +SELECT @@SESSION.example_double_thdvar; + +SET SESSION example_double_thdvar = 500; +SELECT @@SESSION.example_double_thdvar; + +SET SESSION example_double_thdvar = 999.999999; +SELECT @@SESSION.example_double_thdvar; + +SET SESSION example_double_thdvar = 1000.51; +SELECT @@SESSION.example_double_thdvar; + +UNINSTALL PLUGIN example; -- cgit v1.2.1 From e8a0b9f943981f96b2b8d08bd543a0902b0d7ec3 Mon Sep 17 00:00:00 2001 From: Venkatesh Duggirala Date: Fri, 24 May 2013 14:25:00 +0530 Subject: Bug#16765278 DELETE SQL_LOAD_MB* FILE (TEMP FILE) CREATED BY BINLOG_KILLED_SIMULATE.TEST 'mysqbinlog' tool creates a temporary file while preparing LOAD DATA QUERY. These files needs to be deleted at the end of the test script otherwise these files are left out in the daily-run machines, causing "no space on device issues" Fix: Delete them at the end of these test scripts 1) execute mysqlbinlog with --local-load option to create these files in a specified tmpdir 2) delete the tmpdir at the end of the test script --- mysql-test/suite/binlog/t/binlog_killed_simulate.test | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/suite/binlog/t/binlog_killed_simulate.test b/mysql-test/suite/binlog/t/binlog_killed_simulate.test index b87d47559fe..fcedd884183 100644 --- a/mysql-test/suite/binlog/t/binlog_killed_simulate.test +++ b/mysql-test/suite/binlog/t/binlog_killed_simulate.test @@ -20,11 +20,9 @@ reset master; update t1 set a=2 /* will be "killed" after work has been done */; # a proof the query is binlogged with no error -#todo: introduce a suite private macro that provides numeric values -# for some constants like the offset of the first real event -# that is different between severs versions. +--let $binlog_load_data= query_get_value(SHOW BINLOG EVENTS, Pos, 2) let $MYSQLD_DATADIR= `select @@datadir`; ---exec $MYSQL_BINLOG --force-if-open --start-position=106 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog +--exec $MYSQL_BINLOG --force-if-open --start-position=$binlog_load_data $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval select (@a:=load_file("$MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog")) @@ -48,11 +46,12 @@ reset master; load data infile '../../std_data/rpl_loaddata.dat' into table t2 /* will be "killed" in the middle */; +--let $binlog_load_data= query_get_value(SHOW BINLOG EVENTS, Pos, 2) # a proof the query is binlogged with an error - source include/show_binlog_events.inc; ---exec $MYSQL_BINLOG --force-if-open --start-position=98 $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog +--mkdir $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571 +--exec $MYSQL_BINLOG --local-load=$MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571 --force-if-open --start-position=$binlog_load_data $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR eval select (@a:=load_file("$MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog")) @@ -64,6 +63,8 @@ eval select $error_code /* must return 0 to mean the killed query is in */; # cleanup for the sub-case remove_file $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog; +--remove_files_wildcard $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571 * +--rmdir $MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571 drop table t1,t2; -- cgit v1.2.1 From fdf54a0d3adf8824fc1ce3e6818ce1347ca930a2 Mon Sep 17 00:00:00 2001 From: sayantan dutta Date: Fri, 7 Jun 2013 19:29:56 +0530 Subject: Bug #16917425 -DBUILD_CONFIG=MYSQL_RELEASE -DWITH_DEBUG=ON FAILS 4 AND SKIPS 27 MTR TESTS --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mysql-test') diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 19f82303221..b0b7a0d9dd2 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2196,7 +2196,7 @@ sub read_plugin_defs($) mtr_error("Lines in $defs_file must have 3 or 4 items") unless $plug_var; # If running debug server, plugins will be in 'debug' subdirectory - $plug_file= "debug/$plug_file" if $running_debug; + $plug_file= "debug/$plug_file" if $running_debug && !source_dist; my ($plugin)= find_plugin($plug_file, $plug_loc); -- cgit v1.2.1 From 9516510f7fd0ef063872fa6c83dfbdb1fbdc6571 Mon Sep 17 00:00:00 2001 From: Olav Sandstaa Date: Fri, 7 Jun 2013 21:34:34 +0200 Subject: Bug #16917425 -DBUILD_CONFIG=MYSQL_RELEASE -DWITH_DEBUG=ON FAILS 4 AND SKIPS 27 MTR TESTS Revert fix since it caused mtr tests to not run in pushbuild. --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mysql-test') diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index b0b7a0d9dd2..19f82303221 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2196,7 +2196,7 @@ sub read_plugin_defs($) mtr_error("Lines in $defs_file must have 3 or 4 items") unless $plug_var; # If running debug server, plugins will be in 'debug' subdirectory - $plug_file= "debug/$plug_file" if $running_debug && !source_dist; + $plug_file= "debug/$plug_file" if $running_debug; my ($plugin)= find_plugin($plug_file, $plug_loc); -- cgit v1.2.1 From dfb6f63bcf379dcefda43808a2d9f0d80254e3ad Mon Sep 17 00:00:00 2001 From: Aditya A Date: Fri, 14 Jun 2013 11:22:05 +0530 Subject: Bug#13548704 ALGORITHM USED FOR DROPPING PARTITIONED TABLE CAN LEAD TO INCONSISTENCY PROBLEM -------- When we drop a partitoned table , we first gather the information about partitions in the table from the table_name.par file and store it in an internal data structure.Then we delete this file and the data in the table. If the server crashes after deleting the file,then after recovering we cannot access the table .Even we cannot drop the table ,because drop algorithm requires par file to read the partition information. FIX --- 1. We move the part of deleting par file after deleting all the table data from the storage egine. 2. During drop operation if we detect that the par file is missing then we delete the .frm file,since there is no way of recovering without par file. [Approved by Mattias rb#2576 ] --- mysql-test/r/partition_error.result | 4 ++-- mysql-test/t/partition_error.test | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result index 269b6875430..e5ac1371a9b 100644 --- a/mysql-test/r/partition_error.result +++ b/mysql-test/r/partition_error.result @@ -662,8 +662,8 @@ test.t1 check Error Incorrect information in file: './test/t1.frm' test.t1 check error Corrupt SELECT * FROM t1; ERROR HY000: Failed to read from the .par file -# Note that it is currently impossible to drop a partitioned table -# without the .par file +# Note that we will remove the frm file when we detect that +# .par file has been deleted. DROP TABLE t1; ERROR 42S02: Unknown table 't1' # diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index 7e574fd6a42..746e52bd623 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -698,11 +698,10 @@ FLUSH TABLES; CHECK TABLE t1; --error ER_UNKNOWN_ERROR SELECT * FROM t1; ---echo # Note that it is currently impossible to drop a partitioned table ---echo # without the .par file +--echo # Note that we will remove the frm file when we detect that +--echo # .par file has been deleted. --error ER_BAD_TABLE_ERROR DROP TABLE t1; ---remove_file $MYSQLD_DATADIR/test/t1.frm --remove_file $MYSQLD_DATADIR/test/t1#P#p0.MYI --remove_file $MYSQLD_DATADIR/test/t1#P#p0.MYD -- cgit v1.2.1 From 1827eb8a2a8afd73603dabb442e7375774578da0 Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 26 Jun 2013 12:19:02 +0300 Subject: Bug #16996656: UNIQUE OPTION PREFIXES NOT DEPRECATED IN 5.5+ Backported the deprecation warnings from WL#6978 to 5.5 --- mysql-test/include/default_mysqld.cnf | 4 ++-- mysql-test/r/mysqldump.result | 2 +- mysql-test/t/client_xml.test | 2 +- mysql-test/t/mysqldump.test | 22 +++++++++++----------- mysql-test/t/openssl_1.test | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/include/default_mysqld.cnf b/mysql-test/include/default_mysqld.cnf index 6a3fd881b9f..09aa9dafafd 100644 --- a/mysql-test/include/default_mysqld.cnf +++ b/mysql-test/include/default_mysqld.cnf @@ -1,4 +1,4 @@ -# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ connect-timeout= 60 log-bin-trust-function-creators=1 key_buffer_size= 1M -sort_buffer= 256K +sort_buffer_size= 256K max_heap_table_size= 1M loose-innodb_data_file_path= ibdata1:10M:autoextend diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 96ab16f113f..a31516d10d2 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -5111,7 +5111,7 @@ CREATE TABLE b12809202_db.t1 (c1 INT); CREATE TABLE b12809202_db.t2 (c1 INT); INSERT INTO b12809202_db.t1 VALUES (1), (2), (3); INSERT INTO b12809202_db.t2 VALUES (1), (2), (3); -# Starting mysqldump with --single-transaction & --flush-log options.. +# Starting mysqldump with --single-transaction & --flush-logs options.. # Note : In the following dump the transaction # should start only after the logs are # flushed, as 'flush logs' causes implicit diff --git a/mysql-test/t/client_xml.test b/mysql-test/t/client_xml.test index 0847e2b366b..86ca0a920ad 100644 --- a/mysql-test/t/client_xml.test +++ b/mysql-test/t/client_xml.test @@ -23,7 +23,7 @@ insert into t1 values (1, 2, 'a&b ab'); --source include/count_sessions.inc --exec $MYSQL --xml test -e "select * from t1" ---exec $MYSQL_DUMP --xml --skip-create test +--exec $MYSQL_DUMP --xml --skip-create-options test --exec $MYSQL --xml test -e "select count(*) from t1" --exec $MYSQL --xml test -e "select 1 < 2 from dual" diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index b6af97c6f41..478d8fb2863 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -30,7 +30,7 @@ drop view if exists v1, v2, v3; CREATE TABLE t1(a INT, KEY (a)) KEY_BLOCK_SIZE=1024; INSERT INTO t1 VALUES (1), (2); ---exec $MYSQL_DUMP --skip-create --skip-comments -X test t1 +--exec $MYSQL_DUMP --skip-create-options --skip-comments -X test t1 DROP TABLE t1; --echo # @@ -73,14 +73,14 @@ SET SQL_MODE=@OLD_SQL_MODE; # check how mysqldump make quoting --exec $MYSQL_DUMP --compact test t1 ---exec $MYSQL_DUMP --compact --skip-create test t1 ---exec $MYSQL_DUMP --skip-create --skip-comments test t1 +--exec $MYSQL_DUMP --compact --skip-create-options test t1 +--exec $MYSQL_DUMP --skip-create-options --skip-comments test t1 --exec $MYSQL_DUMP --skip-opt --extended-insert --skip-comments test t1 DROP TABLE t1; CREATE TABLE t1(a int, b text, c varchar(3)); INSERT INTO t1 VALUES (1, "test", "tes"), (2, "TEST", "TES"); ---exec $MYSQL_DUMP --skip-create --compact -X test t1 +--exec $MYSQL_DUMP --skip-create-options --compact -X test t1 DROP TABLE t1; --echo # @@ -89,7 +89,7 @@ DROP TABLE t1; CREATE TABLE t1 (`a"b"` char(2)); INSERT INTO t1 VALUES ("1\""), ("\"2"); ---exec $MYSQL_DUMP --compact --skip-create -X test t1 +--exec $MYSQL_DUMP --compact --skip-create-options -X test t1 DROP TABLE t1; --echo # @@ -576,8 +576,8 @@ INSERT INTO t1 VALUES (1), (2); INSERT INTO t2 VALUES (1), (2); --exec $MYSQL_DUMP --skip-comments --no-data mysqldump_test_db --exec $MYSQL_DUMP --skip-comments --no-data mysqldump_test_db t1 t2 ---exec $MYSQL_DUMP --skip-comments --skip-create --xml --no-data mysqldump_test_db ---exec $MYSQL_DUMP --skip-comments --skip-create --xml --no-data mysqldump_test_db t1 t2 +--exec $MYSQL_DUMP --skip-comments --skip-create-options --xml --no-data mysqldump_test_db +--exec $MYSQL_DUMP --skip-comments --skip-create-options --xml --no-data mysqldump_test_db t1 t2 DROP TABLE t1, t2; DROP DATABASE mysqldump_test_db; @@ -1599,7 +1599,7 @@ drop database mysqldump_test_db; CREATE TABLE t1 (c1 INT, c2 LONGBLOB); INSERT INTO t1 SET c1=11, c2=REPEAT('q',509); ---exec $MYSQL_DUMP --skip-create --compact --hex-blob test t1 +--exec $MYSQL_DUMP --skip-create-options --compact --hex-blob test t1 DROP TABLE t1; --echo # @@ -2175,7 +2175,7 @@ DROP TABLE t1, t2; --echo # CREATE TABLE `comment_table` (i INT COMMENT 'FIELD COMMENT') COMMENT = 'TABLE COMMENT'; ---exec $MYSQL_DUMP --compact --skip-create --xml test +--exec $MYSQL_DUMP --compact --skip-create-options --xml test DROP TABLE `comment_table`; --echo # @@ -2343,7 +2343,7 @@ CREATE TABLE b12809202_db.t2 (c1 INT); INSERT INTO b12809202_db.t1 VALUES (1), (2), (3); INSERT INTO b12809202_db.t2 VALUES (1), (2), (3); ---echo # Starting mysqldump with --single-transaction & --flush-log options.. +--echo # Starting mysqldump with --single-transaction & --flush-logs options.. --echo # Note : In the following dump the transaction --echo # should start only after the logs are --echo # flushed, as 'flush logs' causes implicit @@ -2354,7 +2354,7 @@ INSERT INTO b12809202_db.t2 VALUES (1), (2), (3); --echo --echo #### Dump starts here #### --replace_regex /-- Server version.*// /-- MySQL dump .*// /-- Dump completed on .*/-- Dump completed/ ---exec $MYSQL_DUMP --verbose --single-transaction --flush-log b12809202_db 2>$MYSQLTEST_VARDIR/tmp/b12809202_stderr.sql +--exec $MYSQL_DUMP --verbose --single-transaction --flush-logs b12809202_db 2>$MYSQLTEST_VARDIR/tmp/b12809202_stderr.sql --echo --echo ## stderr ## --cat_file $MYSQLTEST_VARDIR/tmp/b12809202_stderr.sql diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test index 3e907f196be..0993d0a52ed 100644 --- a/mysql-test/t/openssl_1.test +++ b/mysql-test/t/openssl_1.test @@ -192,16 +192,16 @@ CREATE TABLE t1(a int); INSERT INTO t1 VALUES (1), (2); # Run mysqldump ---exec $MYSQL_DUMP --skip-create --skip-comments --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test t1 +--exec $MYSQL_DUMP --skip-create-options --skip-comments --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test t1 ---exec $MYSQL_DUMP --skip-create --skip-comments --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test +--exec $MYSQL_DUMP --skip-create-options --skip-comments --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test ---exec $MYSQL_DUMP --skip-create --skip-comments --ssl --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test +--exec $MYSQL_DUMP --skip-create-options --skip-comments --ssl --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test # With wrong parameters --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --error 2 ---exec $MYSQL_DUMP --skip-create --skip-comments --ssl --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test 2>&1 +--exec $MYSQL_DUMP --skip-create-options --skip-comments --ssl --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test 2>&1 DROP TABLE t1; --remove_file $MYSQLTEST_VARDIR/tmp/test.sql -- cgit v1.2.1 From 977d58f6143a7227804367a41cd88da2da8cce7f Mon Sep 17 00:00:00 2001 From: Tor Didriksen Date: Mon, 1 Jul 2013 15:30:55 +0200 Subject: Bug#58165: "my_empty_string" gets modified and causes LOAD DATA to fail and Cleanup test case (left outfile in data dir) --- mysql-test/r/func_str.result | 4 ++-- mysql-test/t/func_str.test | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 8f4038e1239..0b08474693f 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -2617,13 +2617,13 @@ Warning 1292 Truncated incorrect DECIMAL value: '' # and other crashes # CREATE TABLE t1 ( a TEXT ); -SELECT 'aaaaaaaaaaaaaa' INTO OUTFILE 'bug58165.txt'; +SELECT 'aaaaaaaaaaaaaa' INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/bug58165.txt';; SELECT insert( substring_index( 'a', 'a', 'b' ), 1, 0, 'x' ); insert( substring_index( 'a', 'a', 'b' ), 1, 0, 'x' ) x Warnings: Warning 1292 Truncated incorrect INTEGER value: 'b' -LOAD DATA INFILE 'bug58165.txt' INTO TABLE t1; +LOAD DATA INFILE 'MYSQLTEST_VARDIR/tmp/bug58165.txt' INTO TABLE t1;; SELECT * FROM t1; a aaaaaaaaaaaaaa diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 92c4bae5327..09d27d07f49 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -1374,9 +1374,11 @@ SELECT CONVERT(('' IN (REVERSE(CAST(('') AS DECIMAL)), '')), CHAR(3)); --echo # and other crashes --echo # CREATE TABLE t1 ( a TEXT ); -SELECT 'aaaaaaaaaaaaaa' INTO OUTFILE 'bug58165.txt'; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval SELECT 'aaaaaaaaaaaaaa' INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug58165.txt'; SELECT insert( substring_index( 'a', 'a', 'b' ), 1, 0, 'x' ); -LOAD DATA INFILE 'bug58165.txt' INTO TABLE t1; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/bug58165.txt' INTO TABLE t1; SELECT * FROM t1; DROP TABLE t1; -- cgit v1.2.1 From edcae48734058eadd5ed29330b0a525544fa36ed Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Aug 2013 09:25:50 +0300 Subject: MDEV-4823: Server crashes in Item_func_not::fix_fields on creating a table with a virtual column using NOT fix_field() call protocol was brocken (zero pointer passed as link to item which is possible only if you are sure that there can not be Items which transforms). --- mysql-test/suite/vcol/r/vcol_misc.result | 7 +++++++ mysql-test/suite/vcol/t/vcol_misc.test | 8 ++++++++ 2 files changed, 15 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/suite/vcol/r/vcol_misc.result b/mysql-test/suite/vcol/r/vcol_misc.result index 4c301795f5c..bcded410856 100644 --- a/mysql-test/suite/vcol/r/vcol_misc.result +++ b/mysql-test/suite/vcol/r/vcol_misc.result @@ -193,3 +193,10 @@ SELECT COUNT(*) FROM t1; COUNT(*) 2 DROP TABLE t1; +# +# MDEV-4823 Server crashes in Item_func_not::fix_fields on +# creating a table with a virtual column using NOT +# +CREATE TABLE t1 ( f1 INT, v4 INT AS ( NOT f1 ) VIRTUAL ); +drop table t1; +# end of 5.2 tests diff --git a/mysql-test/suite/vcol/t/vcol_misc.test b/mysql-test/suite/vcol/t/vcol_misc.test index 0a689795b4c..ca88dedc0f4 100644 --- a/mysql-test/suite/vcol/t/vcol_misc.test +++ b/mysql-test/suite/vcol/t/vcol_misc.test @@ -198,3 +198,11 @@ SELECT COUNT(*) FROM t1; DROP TABLE t1; +--echo # +--echo # MDEV-4823 Server crashes in Item_func_not::fix_fields on +--echo # creating a table with a virtual column using NOT +--echo # +CREATE TABLE t1 ( f1 INT, v4 INT AS ( NOT f1 ) VIRTUAL ); +drop table t1; + +--echo # end of 5.2 tests -- cgit v1.2.1 From 6dd9f049ab2c8771feabec447cff66b703392046 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Tue, 13 Aug 2013 15:21:11 -0700 Subject: Fixed bug mdev-4894. This a an old legacy performance bug. When a very selective range scan existed for the second table in a join, and, at the same time, there was another range condition depending on the fields of the first table, the optimizer chose a plan with 'Range checked for each record'. This plan was extremely inefficient in comparison with the regular selective range scan. As a matter of fact the range scan chosen for each record was the same as that selective range scan. Changed the test case for bug 24776 to preserve the old output for explain. --- mysql-test/r/range.result | 44 ++++++++++++++++++++++++++++++++++++++++++-- mysql-test/t/range.test | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 78 insertions(+), 4 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 5a964baf2c2..579cb3bfb79 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -700,14 +700,14 @@ INSERT INTO t1 VALUES 'd8c4177d09f8b11f5.52725521'); EXPLAIN SELECT s.oxid FROM t1 v, t1 s -WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND +WHERE v.oxrootid ='d8c4177d09f8b11f5.52725521' AND s.oxleft > v.oxleft AND s.oxleft < v.oxright; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE v ref OXLEFT,OXRIGHT,OXROOTID OXROOTID 34 const 5 Using where 1 SIMPLE s ALL OXLEFT NULL NULL NULL 6 Range checked for each record (index map: 0x4) SELECT s.oxid FROM t1 v, t1 s -WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND +WHERE v.oxrootid ='d8c4177d09f8b11f5.52725521' AND s.oxleft > v.oxleft AND s.oxleft < v.oxright; oxid @@ -1884,4 +1884,44 @@ AAA AAA AAA AAAA AAAA AAAA AAAAA AAAAA AAAAA DROP TABLE t1; +# +# mdev-4894: Poor performance with unnecessary +# (bug#70021) 'Range checked for each record' +# +create table t1( key1 int not null, INDEX i1(key1) ); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8); +insert into t1 select key1+8 from t1; +insert into t1 select key1+16 from t1; +insert into t1 select key1+32 from t1; +insert into t1 select key1+64 from t1; +insert into t1 select key1+128 from t1; +insert into t1 select key1+256 from t1; +insert into t1 select key1+512 from t1; +alter table t1 add key2 int not null, add index i2(key2); +update t1 set key2=key1; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +create table t2 (a int); +insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8); +insert into t2 select a+16 from t2; +insert into t2 select a+32 from t2; +insert into t2 select a+64 from t2; +explain +select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < 1000; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 64 +1 SIMPLE t1 range i1,i2 i1 4 NULL 78 Using where +select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < 1000; +count(*) +128 +explain +select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < t2.a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 64 +1 SIMPLE t1 range i1,i2 i1 4 NULL 78 Using where +select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < t2.a; +count(*) +126 +drop table t1,t2; End of 5.1 tests diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 30d15798336..f781adcec50 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -557,12 +557,12 @@ INSERT INTO t1 VALUES EXPLAIN SELECT s.oxid FROM t1 v, t1 s - WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND + WHERE v.oxrootid ='d8c4177d09f8b11f5.52725521' AND s.oxleft > v.oxleft AND s.oxleft < v.oxright; SELECT s.oxid FROM t1 v, t1 s - WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND + WHERE v.oxrootid ='d8c4177d09f8b11f5.52725521' AND s.oxleft > v.oxleft AND s.oxleft < v.oxright; @@ -1468,4 +1468,38 @@ SELECT * FROM t1 IGNORE INDEX(PRIMARY) WHERE F1 BETWEEN 'A ' AND DROP TABLE t1; +--echo # +--echo # mdev-4894: Poor performance with unnecessary +--echo # (bug#70021) 'Range checked for each record' +--echo # + +create table t1( key1 int not null, INDEX i1(key1) ); +insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8); +insert into t1 select key1+8 from t1; +insert into t1 select key1+16 from t1; +insert into t1 select key1+32 from t1; +insert into t1 select key1+64 from t1; +insert into t1 select key1+128 from t1; +insert into t1 select key1+256 from t1; +insert into t1 select key1+512 from t1; + +alter table t1 add key2 int not null, add index i2(key2); +update t1 set key2=key1; +analyze table t1; + +create table t2 (a int); +insert into t2 values (1),(2),(3),(4),(5),(6),(7),(8); +insert into t2 select a+16 from t2; +insert into t2 select a+32 from t2; +insert into t2 select a+64 from t2; + +explain +select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < 1000; +select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < 1000; +explain +select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < t2.a; +select count(*) from t2 left join t1 on (t1.key1 < 3 or t1.key1 > 1020) and t1.key2 < t2.a; + +drop table t1,t2; + --echo End of 5.1 tests -- cgit v1.2.1 From fa7f677218ae5ed38ef37b7b61140a069c1f8a44 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Thu, 15 Aug 2013 14:16:16 -0700 Subject: Fixed bug mdev-4355. This patch almost totally revised the patch for bug mdev-4177. The latter had too many defects. In particular, it did not propagate multiple equalities formed when merging a degenerate disjunct into underlying AND formula. --- mysql-test/r/select.result | 52 ++++++++++++++++++++++++++++++++++- mysql-test/r/select_jcl6.result | 52 ++++++++++++++++++++++++++++++++++- mysql-test/r/select_pkeycache.result | 52 ++++++++++++++++++++++++++++++++++- mysql-test/r/subselect_sj2_mat.result | 2 +- mysql-test/t/select.test | 32 ++++++++++++++++++++- 5 files changed, 185 insertions(+), 5 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 953b1409827..dfc5236f794 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -5155,7 +5155,7 @@ a b c 8 8 8 DROP TABLE t1,t2; # -# Bug mdev-4413: another manifestations of bug mdev-2474 +# Bug mdev-4413: another manifestations of bug mdev-4274 # (valgrind complains) # CREATE TABLE t1 (a int, b int) ENGINE=MyISAM; @@ -5167,4 +5167,54 @@ WHERE c = a AND ( 0 OR ( b BETWEEN 45 AND 300 OR a > 45 AND a < 100 ) AND b = c ); a b c DROP TABLE t1, t2; +# +# Bug mdev-4355: equalities from the result of simplification of OR +# are not propagated to lower AND levels +# +CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,101),(2,102),(3,103),(4,104),(5,11); +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (1 != 1 OR a = 5) AND (b != 1 OR a = 1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1)) +SELECT * FROM t1 WHERE (1 != 1 OR a = 5) AND (b != 1 OR a = 1); +a b +5 11 +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (1 != 1 OR a = 5); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1)) +SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (1 != 1 OR a = 5); +a b +5 11 +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (a = 5 OR 1 != 1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1)) +SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (a = 5 OR 1 != 1); +a b +5 11 +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (b = 1 OR a = 1) AND (b = 5 AND a = 5 OR 1 != 1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where 0 +SELECT * FROM t1 WHERE (b = 1 OR a = 1) AND (b = 5 AND a = 5 OR 1 != 1); +a b +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 5) and (`test`.`t1`.`a` = 5)) +SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1); +a b +DROP TABLE t1; End of 5.3 tests diff --git a/mysql-test/r/select_jcl6.result b/mysql-test/r/select_jcl6.result index d2faa9e85e1..6eb0d65a72f 100644 --- a/mysql-test/r/select_jcl6.result +++ b/mysql-test/r/select_jcl6.result @@ -5166,7 +5166,7 @@ a b c 8 8 8 DROP TABLE t1,t2; # -# Bug mdev-4413: another manifestations of bug mdev-2474 +# Bug mdev-4413: another manifestations of bug mdev-4274 # (valgrind complains) # CREATE TABLE t1 (a int, b int) ENGINE=MyISAM; @@ -5178,6 +5178,56 @@ WHERE c = a AND ( 0 OR ( b BETWEEN 45 AND 300 OR a > 45 AND a < 100 ) AND b = c ); a b c DROP TABLE t1, t2; +# +# Bug mdev-4355: equalities from the result of simplification of OR +# are not propagated to lower AND levels +# +CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,101),(2,102),(3,103),(4,104),(5,11); +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (1 != 1 OR a = 5) AND (b != 1 OR a = 1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1)) +SELECT * FROM t1 WHERE (1 != 1 OR a = 5) AND (b != 1 OR a = 1); +a b +5 11 +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (1 != 1 OR a = 5); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1)) +SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (1 != 1 OR a = 5); +a b +5 11 +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (a = 5 OR 1 != 1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1)) +SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (a = 5 OR 1 != 1); +a b +5 11 +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (b = 1 OR a = 1) AND (b = 5 AND a = 5 OR 1 != 1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where 0 +SELECT * FROM t1 WHERE (b = 1 OR a = 1) AND (b = 5 AND a = 5 OR 1 != 1); +a b +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 5) and (`test`.`t1`.`a` = 5)) +SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1); +a b +DROP TABLE t1; End of 5.3 tests set join_cache_level=default; show variables like 'join_cache_level'; diff --git a/mysql-test/r/select_pkeycache.result b/mysql-test/r/select_pkeycache.result index 953b1409827..dfc5236f794 100644 --- a/mysql-test/r/select_pkeycache.result +++ b/mysql-test/r/select_pkeycache.result @@ -5155,7 +5155,7 @@ a b c 8 8 8 DROP TABLE t1,t2; # -# Bug mdev-4413: another manifestations of bug mdev-2474 +# Bug mdev-4413: another manifestations of bug mdev-4274 # (valgrind complains) # CREATE TABLE t1 (a int, b int) ENGINE=MyISAM; @@ -5167,4 +5167,54 @@ WHERE c = a AND ( 0 OR ( b BETWEEN 45 AND 300 OR a > 45 AND a < 100 ) AND b = c ); a b c DROP TABLE t1, t2; +# +# Bug mdev-4355: equalities from the result of simplification of OR +# are not propagated to lower AND levels +# +CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,101),(2,102),(3,103),(4,104),(5,11); +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (1 != 1 OR a = 5) AND (b != 1 OR a = 1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1)) +SELECT * FROM t1 WHERE (1 != 1 OR a = 5) AND (b != 1 OR a = 1); +a b +5 11 +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (1 != 1 OR a = 5); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1)) +SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (1 != 1 OR a = 5); +a b +5 11 +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (a = 5 OR 1 != 1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`a` = 5) and (`test`.`t1`.`b` <> 1)) +SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (a = 5 OR 1 != 1); +a b +5 11 +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (b = 1 OR a = 1) AND (b = 5 AND a = 5 OR 1 != 1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where 0 +SELECT * FROM t1 WHERE (b = 1 OR a = 1) AND (b = 5 AND a = 5 OR 1 != 1); +a b +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where ((`test`.`t1`.`b` = 5) and (`test`.`t1`.`a` = 5)) +SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1); +a b +DROP TABLE t1; End of 5.3 tests diff --git a/mysql-test/r/subselect_sj2_mat.result b/mysql-test/r/subselect_sj2_mat.result index 18e3f6ddd34..bf5b95d2d8f 100644 --- a/mysql-test/r/subselect_sj2_mat.result +++ b/mysql-test/r/subselect_sj2_mat.result @@ -1380,7 +1380,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00 Using where 2 MATERIALIZED t3 hash_ALL NULL #hash#$hj 5 test.t2.i2 3 100.00 Using where; Using join buffer (flat, BNLH join) Warnings: -Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i3` = `test`.`t2`.`i2`) and (`test`.`t1`.`i1` = `test`.`t2`.`i2`) and (`test`.`t2`.`i2` > 0)) +Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i3` = `test`.`t2`.`i2`) and (`test`.`t1`.`i1` = `test`.`t2`.`i2`) and (`test`.`t3`.`i3` > 0)) SELECT * FROM t1 WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 > 0 AND i3 = i2 OR 1=2); i1 diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 54168332664..94e169821e9 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -4326,7 +4326,7 @@ SELECT * FROM t1 INNER JOIN t2 ON ( c = a ) DROP TABLE t1,t2; --echo # ---echo # Bug mdev-4413: another manifestations of bug mdev-2474 +--echo # Bug mdev-4413: another manifestations of bug mdev-4274 --echo # (valgrind complains) --echo # @@ -4342,4 +4342,34 @@ SELECT * FROM t1, t2 DROP TABLE t1, t2; +--echo # +--echo # Bug mdev-4355: equalities from the result of simplification of OR +--echo # are not propagated to lower AND levels +--echo # + +CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,101),(2,102),(3,103),(4,104),(5,11); + +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (1 != 1 OR a = 5) AND (b != 1 OR a = 1); +SELECT * FROM t1 WHERE (1 != 1 OR a = 5) AND (b != 1 OR a = 1); + +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (1 != 1 OR a = 5); +SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (1 != 1 OR a = 5); + +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (a = 5 OR 1 != 1); +SELECT * FROM t1 WHERE (b != 1 OR a = 1) AND (a = 5 OR 1 != 1); + +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (b = 1 OR a = 1) AND (b = 5 AND a = 5 OR 1 != 1); +SELECT * FROM t1 WHERE (b = 1 OR a = 1) AND (b = 5 AND a = 5 OR 1 != 1); + +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1); +SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1); + +DROP TABLE t1; + --echo End of 5.3 tests -- cgit v1.2.1 From 25c152018dceae35bf0d45de46a33a214048128c Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Fri, 16 Aug 2013 22:01:47 -0700 Subject: Fixed bug mdev-4418. After single row substitutions there might appear new equalities. They should be properly propagated to all AND/OR levels the WHERE condition. It's done now with an additional call of remove_eq_conds(). --- mysql-test/r/join_outer.result | 2 +- mysql-test/r/join_outer_jcl6.result | 2 +- mysql-test/r/select.result | 18 ++++++++++++++++++ mysql-test/r/select_jcl6.result | 18 ++++++++++++++++++ mysql-test/r/select_pkeycache.result | 18 ++++++++++++++++++ mysql-test/r/subselect.result | 2 +- mysql-test/r/subselect_no_mat.result | 2 +- mysql-test/r/subselect_no_opts.result | 2 +- mysql-test/r/subselect_no_scache.result | 2 +- mysql-test/r/subselect_no_semijoin.result | 2 +- mysql-test/r/table_elim.result | 4 ++-- mysql-test/r/view.result | 2 +- mysql-test/t/select.test | 17 +++++++++++++++++ 13 files changed, 81 insertions(+), 10 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 723b2a88382..684bfb3836e 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -1649,7 +1649,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 100.00 Using where 2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((6,(select `test`.`t3`.`a` from `test`.`t3` where (6 = `test`.`t3`.`a`)))) where 1 +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((6,(select `test`.`t3`.`a` from `test`.`t3` where (6 = `test`.`t3`.`a`)))) DROP TABLE t1,t2,t3; # # LP bug #817384 Wrong result with outer join + subquery in ON diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index d063720836d..4f4c16199e9 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -1660,7 +1660,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 100.00 Using where 2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((6,(select `test`.`t3`.`a` from `test`.`t3` where (6 = `test`.`t3`.`a`)))) where 1 +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((6,(select `test`.`t3`.`a` from `test`.`t3` where (6 = `test`.`t3`.`a`)))) DROP TABLE t1,t2,t3; # # LP bug #817384 Wrong result with outer join + subquery in ON diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index dfc5236f794..56a4a8d2bdc 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -5217,4 +5217,22 @@ Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1); a b DROP TABLE t1; +# +# Bug mdev-4418: impossible multiple equality in OR formula +# after row substitution +# +CREATE TABLE t1 (a int, b varchar(1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (0,'j'), (8,'v'); +CREATE TABLE t2 (c varchar(1), d varchar(1)) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('k','k'); +EXPLAIN EXTENDED +SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00 +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'k' AS `c`,'k' AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = 'k') and (`test`.`t1`.`a` = 136)) +SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b)); +a b c d +DROP TABLE t1,t2; End of 5.3 tests diff --git a/mysql-test/r/select_jcl6.result b/mysql-test/r/select_jcl6.result index 6eb0d65a72f..1a735299e0e 100644 --- a/mysql-test/r/select_jcl6.result +++ b/mysql-test/r/select_jcl6.result @@ -5228,6 +5228,24 @@ Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1); a b DROP TABLE t1; +# +# Bug mdev-4418: impossible multiple equality in OR formula +# after row substitution +# +CREATE TABLE t1 (a int, b varchar(1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (0,'j'), (8,'v'); +CREATE TABLE t2 (c varchar(1), d varchar(1)) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('k','k'); +EXPLAIN EXTENDED +SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00 +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'k' AS `c`,'k' AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = 'k') and (`test`.`t1`.`a` = 136)) +SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b)); +a b c d +DROP TABLE t1,t2; End of 5.3 tests set join_cache_level=default; show variables like 'join_cache_level'; diff --git a/mysql-test/r/select_pkeycache.result b/mysql-test/r/select_pkeycache.result index dfc5236f794..56a4a8d2bdc 100644 --- a/mysql-test/r/select_pkeycache.result +++ b/mysql-test/r/select_pkeycache.result @@ -5217,4 +5217,22 @@ Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1); a b DROP TABLE t1; +# +# Bug mdev-4418: impossible multiple equality in OR formula +# after row substitution +# +CREATE TABLE t1 (a int, b varchar(1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (0,'j'), (8,'v'); +CREATE TABLE t2 (c varchar(1), d varchar(1)) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('k','k'); +EXPLAIN EXTENDED +SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b)); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00 +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'k' AS `c`,'k' AS `d` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`b` = 'k') and (`test`.`t1`.`a` = 136)) +SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b)); +a b c d +DROP TABLE t1,t2; End of 5.3 tests diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 8503164dde2..e4448d96657 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1322,7 +1322,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: -Note 1003 select (0,(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` +Note 1003 select (0,(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)` INSERT INTO t1 (pseudo) VALUES ('test1'); SELECT 0 IN (SELECT 1 FROM t1 a); 0 IN (SELECT 1 FROM t1 a) diff --git a/mysql-test/r/subselect_no_mat.result b/mysql-test/r/subselect_no_mat.result index d0c9555d976..df6b884fbe0 100644 --- a/mysql-test/r/subselect_no_mat.result +++ b/mysql-test/r/subselect_no_mat.result @@ -1329,7 +1329,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: -Note 1003 select (0,(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` +Note 1003 select (0,(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)` INSERT INTO t1 (pseudo) VALUES ('test1'); SELECT 0 IN (SELECT 1 FROM t1 a); 0 IN (SELECT 1 FROM t1 a) diff --git a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result index 47f6d3a0ed4..f9df463f6aa 100644 --- a/mysql-test/r/subselect_no_opts.result +++ b/mysql-test/r/subselect_no_opts.result @@ -1325,7 +1325,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: -Note 1003 select (0,(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` +Note 1003 select (0,(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)` INSERT INTO t1 (pseudo) VALUES ('test1'); SELECT 0 IN (SELECT 1 FROM t1 a); 0 IN (SELECT 1 FROM t1 a) diff --git a/mysql-test/r/subselect_no_scache.result b/mysql-test/r/subselect_no_scache.result index f3a01618eff..70de4b26743 100644 --- a/mysql-test/r/subselect_no_scache.result +++ b/mysql-test/r/subselect_no_scache.result @@ -1328,7 +1328,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: -Note 1003 select (0,(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` +Note 1003 select (0,(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)` INSERT INTO t1 (pseudo) VALUES ('test1'); SELECT 0 IN (SELECT 1 FROM t1 a); 0 IN (SELECT 1 FROM t1 a) diff --git a/mysql-test/r/subselect_no_semijoin.result b/mysql-test/r/subselect_no_semijoin.result index 964704e0695..91071c98777 100644 --- a/mysql-test/r/subselect_no_semijoin.result +++ b/mysql-test/r/subselect_no_semijoin.result @@ -1325,7 +1325,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: -Note 1003 select (0,(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` +Note 1003 select (0,(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)` INSERT INTO t1 (pseudo) VALUES ('test1'); SELECT 0 IN (SELECT 1 FROM t1 a); 0 IN (SELECT 1 FROM t1 a) diff --git a/mysql-test/r/table_elim.result b/mysql-test/r/table_elim.result index 35acd30d76d..86e5bbe0060 100644 --- a/mysql-test/r/table_elim.result +++ b/mysql-test/r/table_elim.result @@ -17,7 +17,7 @@ explain extended select t1.a from t1 left join t2 on t2.a=t1.a; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 1 +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` select t1.a from t1 left join t2 on t2.a=t1.a; a 0 @@ -62,7 +62,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 4 100.00 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: -Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t0` left join (`test`.`t1`) on((`test`.`t1`.`a` = `test`.`t0`.`a`)) where 1 +Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t0` left join (`test`.`t1`) on((`test`.`t1`.`a` = `test`.`t0`.`a`)) # Elimination with aggregate functions explain select count(*) from t1 left join t2 on t2.a=t1.a; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 0f666f0e708..2d89c66a226 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -4300,7 +4300,7 @@ WHERE f1<>0 OR f2<>0 AND f4='v' AND (f2<>0 OR f3<>0 AND f5<>0 OR f4 LIKE '%b%'); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 Warnings: -Note 1003 select 'r' AS `f4` from `test`.`t1` where ((20 <> 0) or 0) +Note 1003 select 'r' AS `f4` from `test`.`t1` where (20 <> 0) DROP VIEW v1; DROP TABLE t1; # diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 94e169821e9..c0e22cb8f4e 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -4372,4 +4372,21 @@ SELECT * FROM t1 WHERE (b = 1 OR a = 5) AND (b = 5 AND a = 5 OR 1 != 1); DROP TABLE t1; +--echo # +--echo # Bug mdev-4418: impossible multiple equality in OR formula +--echo # after row substitution +--echo # + +CREATE TABLE t1 (a int, b varchar(1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (0,'j'), (8,'v'); + +CREATE TABLE t2 (c varchar(1), d varchar(1)) ENGINE=MyISAM; +INSERT INTO t2 VALUES ('k','k'); + +EXPLAIN EXTENDED +SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b)); +SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b)); + +DROP TABLE t1,t2; + --echo End of 5.3 tests -- cgit v1.2.1 From 84a2fb48368064b47090b420794d475798f7b181 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Aug 2013 10:42:38 +0200 Subject: Backport from 10.0-base fix for tests failing when vardir has no execute permissions. --- mysql-test/include/have_dbi_dbd-mysql.inc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/include/have_dbi_dbd-mysql.inc b/mysql-test/include/have_dbi_dbd-mysql.inc index 212e36ac353..7c2113a8109 100644 --- a/mysql-test/include/have_dbi_dbd-mysql.inc +++ b/mysql-test/include/have_dbi_dbd-mysql.inc @@ -58,9 +58,7 @@ --let $perlChecker= $MYSQLTEST_VARDIR/std_data/checkDBI_DBD-mysql.pl --let $resultFile= $MYSQL_TMP_DIR/dbidbd-mysql.txt -# Make the script executable and execute it. ---chmod 0755 $perlChecker ---exec $perlChecker +--exec perl $perlChecker # Source the resulting temporary file and look for a variable being set. --source $resultFile -- cgit v1.2.1 From 5fdb531d77e025cdf1738c424207b13e0a7608f5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Aug 2013 17:08:03 +0300 Subject: Fix bug MDEV-4895 Valgrind warnings (Conditional jump or move depends on uninitialised value) in Field_datetime::get_date on GREATEST(..) IS NULL Analysis: The cause of the valgrind warning was an attempt to evaluate a Field that was not yet read. The reason was that on one hand Item_func_isnotnull was marked as constant by Item_func_isnotnull::update_used_tables, and this allowed eval_const_cond() to be called. On the other hand Item_func_isnotnull::val_int() evaluated its argument as if it was not constant. Solution: The fix make sure that Item_func_isnotnull::val_int() doesn't evaluate its argument when it is constant and cannot be NULL, because the result is known in this case. --- mysql-test/r/null.result | 30 ++++++++++++++++++++++++++++++ mysql-test/t/null.test | 28 ++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result index ac72e1e303e..647b943df1e 100644 --- a/mysql-test/r/null.result +++ b/mysql-test/r/null.result @@ -343,3 +343,33 @@ Field Type Null Key Default Extra IFNULL(NULL, b) decimal(1,0) YES NULL DROP TABLE t1, t2; # End of 5.0 tests +# +# MDEV-4895 Valgrind warnings (Conditional jump or move depends on uninitialised value) in Field_datetime::get_date on GREATEST(..) IS NULL +# +CREATE TABLE t1 (dt DATETIME NOT NULL); +INSERT INTO t1 VALUES (NOW()),(NOW()); +EXPLAIN +SELECT * FROM t1 WHERE concat( dt, '2012-12-21 12:12:12' ) IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +SELECT * FROM t1 WHERE concat( dt, '2012-12-21 12:12:12' ) IS NULL; +dt +drop table t1; +CREATE TABLE t1 (dt INT NOT NULL); +INSERT INTO t1 VALUES (1),(2); +EXPLAIN +SELECT * FROM t1 WHERE concat( dt, '1' ) IS NULL; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +SELECT * FROM t1 WHERE concat( dt, '1' ) IS NULL; +dt +drop table t1; +CREATE TABLE t1 (dt INT NOT NULL); +INSERT INTO t1 VALUES (1),(2); +EXPLAIN +SELECT * FROM t1 WHERE NOT (concat( dt, '1' ) IS NOT NULL); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +SELECT * FROM t1 WHERE NOT (concat( dt, '1' ) IS NOT NULL); +dt +drop table t1; diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test index 2878b54c357..4a45240ec68 100644 --- a/mysql-test/t/null.test +++ b/mysql-test/t/null.test @@ -255,3 +255,31 @@ DESCRIBE t2; DROP TABLE t1, t2; --echo # End of 5.0 tests + +--echo # +--echo # MDEV-4895 Valgrind warnings (Conditional jump or move depends on uninitialised value) in Field_datetime::get_date on GREATEST(..) IS NULL +--echo # + +CREATE TABLE t1 (dt DATETIME NOT NULL); +INSERT INTO t1 VALUES (NOW()),(NOW()); + +EXPLAIN +SELECT * FROM t1 WHERE concat( dt, '2012-12-21 12:12:12' ) IS NULL; +SELECT * FROM t1 WHERE concat( dt, '2012-12-21 12:12:12' ) IS NULL; + +DROP TABLE t1; +CREATE TABLE t1 (dt INT NOT NULL); +INSERT INTO t1 VALUES (1),(2); +EXPLAIN +SELECT * FROM t1 WHERE concat( dt, '1' ) IS NULL; +SELECT * FROM t1 WHERE concat( dt, '1' ) IS NULL; + +DROP TABLE t1; +CREATE TABLE t1 (dt INT NOT NULL); +INSERT INTO t1 VALUES (1),(2); + +EXPLAIN +SELECT * FROM t1 WHERE NOT (concat( dt, '1' ) IS NOT NULL); +SELECT * FROM t1 WHERE NOT (concat( dt, '1' ) IS NOT NULL); + +DROP TABLE t1; -- cgit v1.2.1 From 99992f6ec4600222fc4312f62287b1a42155ea4c Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Tue, 20 Aug 2013 13:47:13 -0700 Subject: Fixed a bug/typo in the patch for mdev-4355, noticed after the patch had been merged into 5.5. Corrected the result of the output from the test case for mdev 4895. --- mysql-test/r/null.result | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result index 647b943df1e..e62ba68c8f6 100644 --- a/mysql-test/r/null.result +++ b/mysql-test/r/null.result @@ -354,7 +354,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE SELECT * FROM t1 WHERE concat( dt, '2012-12-21 12:12:12' ) IS NULL; dt -drop table t1; +DROP TABLE t1; CREATE TABLE t1 (dt INT NOT NULL); INSERT INTO t1 VALUES (1),(2); EXPLAIN @@ -363,7 +363,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE SELECT * FROM t1 WHERE concat( dt, '1' ) IS NULL; dt -drop table t1; +DROP TABLE t1; CREATE TABLE t1 (dt INT NOT NULL); INSERT INTO t1 VALUES (1),(2); EXPLAIN @@ -372,4 +372,4 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE SELECT * FROM t1 WHERE NOT (concat( dt, '1' ) IS NOT NULL); dt -drop table t1; +DROP TABLE t1; -- cgit v1.2.1 From f8af4423b4bd9bb2978668b21506677f5dcac873 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Aug 2013 17:42:09 +0300 Subject: MDEV-4908: Assertion `((Item_cond *) cond)->functype() == ((Item_cond *) new_item)->functype()' fails on a query with IN and equal conditions, AND/OR, materialization+semijoin A new AND Item should be prepared (fix_field() call) before using. --- mysql-test/r/subselect_mat.result | 14 ++++++++++++++ mysql-test/r/subselect_sj_mat.result | 14 ++++++++++++++ mysql-test/t/subselect_sj_mat.test | 18 ++++++++++++++++++ 3 files changed, 46 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/subselect_mat.result b/mysql-test/r/subselect_mat.result index f3442b2018e..f5cce0e2d88 100644 --- a/mysql-test/r/subselect_mat.result +++ b/mysql-test/r/subselect_mat.result @@ -2002,6 +2002,20 @@ DROP TABLE t1,t2; # This must be at the end: set optimizer_switch=@subselect_sj_mat_tmp; set join_cache_level=@save_join_cache_level; +# +# MDEV-4908: Assertion `((Item_cond *) cond)->functype() == +# ((Item_cond *) new_item)->functype()' fails on a query with +# IN and equal conditions, AND/OR, materialization+semijoin +# +SET @save_optimizer_switch=@@optimizer_switch; +SET optimizer_switch = 'materialization=on,semijoin=on'; +CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,3,5),(2,4,6); +SELECT * FROM t1 WHERE 8 IN ( SELECT MIN(pk) FROM t1 ) AND ( pk = a OR pk = b ); +pk a b +drop table t1; +SET optimizer_switch=@save_optimizer_switch; +# End of 5.3 tests set @subselect_mat_test_optimizer_switch_value=null; set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off'; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; diff --git a/mysql-test/r/subselect_sj_mat.result b/mysql-test/r/subselect_sj_mat.result index 8368318ea3d..fb7fdb0e8f0 100644 --- a/mysql-test/r/subselect_sj_mat.result +++ b/mysql-test/r/subselect_sj_mat.result @@ -2042,3 +2042,17 @@ DROP TABLE t1,t2; # This must be at the end: set optimizer_switch=@subselect_sj_mat_tmp; set join_cache_level=@save_join_cache_level; +# +# MDEV-4908: Assertion `((Item_cond *) cond)->functype() == +# ((Item_cond *) new_item)->functype()' fails on a query with +# IN and equal conditions, AND/OR, materialization+semijoin +# +SET @save_optimizer_switch=@@optimizer_switch; +SET optimizer_switch = 'materialization=on,semijoin=on'; +CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,3,5),(2,4,6); +SELECT * FROM t1 WHERE 8 IN ( SELECT MIN(pk) FROM t1 ) AND ( pk = a OR pk = b ); +pk a b +drop table t1; +SET optimizer_switch=@save_optimizer_switch; +# End of 5.3 tests diff --git a/mysql-test/t/subselect_sj_mat.test b/mysql-test/t/subselect_sj_mat.test index 4c40b2b5487..d0ab2f5e300 100644 --- a/mysql-test/t/subselect_sj_mat.test +++ b/mysql-test/t/subselect_sj_mat.test @@ -1681,3 +1681,21 @@ DROP TABLE t1,t2; set optimizer_switch=@subselect_sj_mat_tmp; set join_cache_level=@save_join_cache_level; +--echo # +--echo # MDEV-4908: Assertion `((Item_cond *) cond)->functype() == +--echo # ((Item_cond *) new_item)->functype()' fails on a query with +--echo # IN and equal conditions, AND/OR, materialization+semijoin +--echo # + + +SET @save_optimizer_switch=@@optimizer_switch; +SET optimizer_switch = 'materialization=on,semijoin=on'; + +CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,3,5),(2,4,6); +SELECT * FROM t1 WHERE 8 IN ( SELECT MIN(pk) FROM t1 ) AND ( pk = a OR pk = b ); + +drop table t1; +SET optimizer_switch=@save_optimizer_switch; + +--echo # End of 5.3 tests -- cgit v1.2.1 From 37e9714c5e3c15b324348114cda9069574a8e92f Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Thu, 22 Aug 2013 14:12:10 +0400 Subject: MDEV-4840: Wrong result (missing rows) on LEFT JOIN with InnoDB tables Fix two problems in table elimination code: - Before marking a "value" as bound, check if it is already bound. Marking the same value as bound twice could confuse a module that depends on this value, because Dep_module_XXX use counters to know when they become bound. - When checking whether field is part of a key, ignore "extended keys" property. --- mysql-test/r/table_elim.result | 20 ++++++++++++++++++++ mysql-test/t/table_elim.test | 17 +++++++++++++++++ 2 files changed, 37 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/table_elim.result b/mysql-test/r/table_elim.result index aa1bed3d67d..8bb0bdda4e4 100644 --- a/mysql-test/r/table_elim.result +++ b/mysql-test/r/table_elim.result @@ -628,4 +628,24 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select `test`.`t2`.`b` AS `b` from `test`.`t2` where <`test`.`t2`.`b`>((`test`.`t2`.`b`,(select sum(1) from dual having ((`test`.`t2`.`b`) = (sum(1)))))) DROP TABLE t1,t2; +# +# MDEV-4840: Wrong result (missing rows) on LEFT JOIN with InnoDB tables +# +CREATE TABLE t1 (alpha3 VARCHAR(3)); +INSERT INTO t1 VALUES ('USA'),('CAN'); +CREATE TABLE t2 ( t3_code VARCHAR(3), name VARCHAR(64)); +INSERT INTO t2 VALUES ('USA','Austin'),('USA','Boston'); +CREATE TABLE t3 ( code VARCHAR(3), name VARCHAR(64), PRIMARY KEY (code), UNIQUE KEY (name)); +INSERT INTO t3 VALUES ('CAN','Canada'),('USA','United States'); +SELECT * FROM t1 LEFT JOIN ( t2 LEFT JOIN t3 ON t2.t3_code = t3.code ) ON t1.alpha3 = t3.code; +alpha3 t3_code name code name +USA USA Austin USA United States +USA USA Boston USA United States +CAN NULL NULL NULL NULL +SELECT t1.alpha3 FROM t1 LEFT JOIN ( t2 LEFT JOIN t3 ON t2.t3_code = t3.code ) ON t1.alpha3 = t3.code; +alpha3 +USA +USA +CAN +DROP TABLE t1, t2, t3; SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/t/table_elim.test b/mysql-test/t/table_elim.test index 2cca6f501f0..357953290c4 100644 --- a/mysql-test/t/table_elim.test +++ b/mysql-test/t/table_elim.test @@ -561,4 +561,21 @@ EXPLAIN EXTENDED DROP TABLE t1,t2; +--echo # +--echo # MDEV-4840: Wrong result (missing rows) on LEFT JOIN with InnoDB tables +--echo # +CREATE TABLE t1 (alpha3 VARCHAR(3)); +INSERT INTO t1 VALUES ('USA'),('CAN'); + +CREATE TABLE t2 ( t3_code VARCHAR(3), name VARCHAR(64)); +INSERT INTO t2 VALUES ('USA','Austin'),('USA','Boston'); + +CREATE TABLE t3 ( code VARCHAR(3), name VARCHAR(64), PRIMARY KEY (code), UNIQUE KEY (name)); +INSERT INTO t3 VALUES ('CAN','Canada'),('USA','United States'); + +SELECT * FROM t1 LEFT JOIN ( t2 LEFT JOIN t3 ON t2.t3_code = t3.code ) ON t1.alpha3 = t3.code; +SELECT t1.alpha3 FROM t1 LEFT JOIN ( t2 LEFT JOIN t3 ON t2.t3_code = t3.code ) ON t1.alpha3 = t3.code; + +DROP TABLE t1, t2, t3; + SET optimizer_switch=@save_optimizer_switch; -- cgit v1.2.1 From c40de1df363da0bc04118b4957c94fd52afe20b0 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 22 Aug 2013 15:20:27 +0400 Subject: MDEV-4804 Date comparing false result --- mysql-test/r/type_date.result | 38 ++++++++++++++++++++++++++++++++++++++ mysql-test/t/type_date.test | 22 ++++++++++++++++++++++ 2 files changed, 60 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index da38f8d9ef8..e452b3255ae 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -307,5 +307,43 @@ NULL Warnings: Warning 1292 Incorrect datetime value: '2022-00-00 00:00:00' # +# MDEV-4804 Date comparing false result +# +SET @h0="20111107"; +SET @h1="0"; +SET @@timestamp=UNIX_TIMESTAMP('2013-08-19 20:30:00'); +SELECT +COALESCE(DATE(@h0),DATE("1901-01-01")) AS h0d, +COALESCE(DATE(@h1),DATE(NOW())) AS h1d, +COALESCE(DATE(@h0),DATE("1901-01-01"))>COALESCE(DATE(@h1),DATE(NOW())) AS compare_h0_gt_h1; +h0d h1d compare_h0_gt_h1 +2011-11-07 2013-08-19 0 +Warnings: +Warning 1292 Incorrect datetime value: '0' +Warning 1292 Incorrect datetime value: '0' +SELECT +DATE('20011107'), +DATE('0'), +COALESCE(DATE('0'),CURRENT_DATE) AS d1, +DATE('20011107')>COALESCE(DATE('0'),CURRENT_DATE) AS cmp; +DATE('20011107') DATE('0') d1 cmp +2001-11-07 NULL 2013-08-19 0 +Warnings: +Warning 1292 Incorrect datetime value: '0' +Warning 1292 Incorrect datetime value: '0' +Warning 1292 Incorrect datetime value: '0' +SELECT +DATE('20011107'), +DATE('0'), +IFNULL(DATE('0'),CURRENT_DATE) AS d1, +DATE('20011107')>IFNULL(DATE('0'),CURRENT_DATE) AS cmp; +DATE('20011107') DATE('0') d1 cmp +2001-11-07 NULL 2013-08-19 0 +Warnings: +Warning 1292 Incorrect datetime value: '0' +Warning 1292 Incorrect datetime value: '0' +Warning 1292 Incorrect datetime value: '0' +SET @@timestamp=DEFAULT; +# # End of 5.3 tests # diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index 57b545f004b..8a47d324406 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -287,6 +287,28 @@ drop table t1; --echo # SELECT CONVERT_TZ(GREATEST(DATE('2021-00-00'),DATE('2022-00-00')),'+00:00','+7:5'); +--echo # +--echo # MDEV-4804 Date comparing false result +--echo # +SET @h0="20111107"; +SET @h1="0"; +SET @@timestamp=UNIX_TIMESTAMP('2013-08-19 20:30:00'); +SELECT + COALESCE(DATE(@h0),DATE("1901-01-01")) AS h0d, + COALESCE(DATE(@h1),DATE(NOW())) AS h1d, + COALESCE(DATE(@h0),DATE("1901-01-01"))>COALESCE(DATE(@h1),DATE(NOW())) AS compare_h0_gt_h1; +SELECT + DATE('20011107'), + DATE('0'), + COALESCE(DATE('0'),CURRENT_DATE) AS d1, + DATE('20011107')>COALESCE(DATE('0'),CURRENT_DATE) AS cmp; +SELECT + DATE('20011107'), + DATE('0'), + IFNULL(DATE('0'),CURRENT_DATE) AS d1, + DATE('20011107')>IFNULL(DATE('0'),CURRENT_DATE) AS cmp; +SET @@timestamp=DEFAULT; + --echo # --echo # End of 5.3 tests --echo # -- cgit v1.2.1 From 970542ec90951c3e9d68ff310cdf181465854aaa Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Fri, 23 Aug 2013 16:32:56 +0400 Subject: MDEV-4836: Wrong result on IS NULL (old documented hack stopped working) - When applying optimization introduced by MDEV-4817, ignore the conditions that have form "datetime_not_null_col IS NULL". --- mysql-test/r/join_outer.result | 12 ++++++++++++ mysql-test/r/join_outer_jcl6.result | 12 ++++++++++++ mysql-test/t/join_outer.test | 9 +++++++++ 3 files changed, 33 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 170c6f3eb05..5926307bf1d 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -2138,4 +2138,16 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where 1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 Using index drop table t0, t1; +# +# MDEV-4836: Wrong result on IS NULL (old documented hack stopped working) +# (this is a regression after fix for MDEV-4817) +# +CREATE TABLE t1 (id INT, d DATE NOT NULL); +INSERT INTO t1 VALUES (1,'0000-00-00'),(2,'0000-00-00'); +CREATE TABLE t2 (i INT); +SELECT * FROM t1 LEFT JOIN t2 ON (id=i) WHERE NULL OR d IS NULL; +id d i +1 0000-00-00 NULL +2 0000-00-00 NULL +DROP TABLE t1,t2; SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index 82805a883b3..874ca16c39c 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -2149,6 +2149,18 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 10 Using where 1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t0.a 1 Using index drop table t0, t1; +# +# MDEV-4836: Wrong result on IS NULL (old documented hack stopped working) +# (this is a regression after fix for MDEV-4817) +# +CREATE TABLE t1 (id INT, d DATE NOT NULL); +INSERT INTO t1 VALUES (1,'0000-00-00'),(2,'0000-00-00'); +CREATE TABLE t2 (i INT); +SELECT * FROM t1 LEFT JOIN t2 ON (id=i) WHERE NULL OR d IS NULL; +id d i +1 0000-00-00 NULL +2 0000-00-00 NULL +DROP TABLE t1,t2; SET optimizer_switch=@save_optimizer_switch; set join_cache_level=default; show variables like 'join_cache_level'; diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index b0000b2b943..7b26c9670ac 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -1686,5 +1686,14 @@ explain select * from t1 left join t0 on t0.a=t1.pk where t0.person_id='fooo' or drop table t0, t1; +--echo # +--echo # MDEV-4836: Wrong result on IS NULL (old documented hack stopped working) +--echo # (this is a regression after fix for MDEV-4817) +--echo # +CREATE TABLE t1 (id INT, d DATE NOT NULL); +INSERT INTO t1 VALUES (1,'0000-00-00'),(2,'0000-00-00'); +CREATE TABLE t2 (i INT); +SELECT * FROM t1 LEFT JOIN t2 ON (id=i) WHERE NULL OR d IS NULL; +DROP TABLE t1,t2; SET optimizer_switch=@save_optimizer_switch; -- cgit v1.2.1 From 540eeebbb053da2bec21567da2519cd40cedaf86 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Fri, 23 Aug 2013 07:25:45 -0700 Subject: Fixed bug mdev-4420. The code of JOIN::optimize that performed substitutions for the best equal field in all ref items did not take into account that a multiple equality could contain the result of the single-value subquery if the subquery is inexpensive. This code was corrected. Also made necessary corresponding corrections in the code of make_join_select(). --- mysql-test/r/join.result | 2 +- mysql-test/r/subselect2.result | 25 +++++++++++++++++++++++++ mysql-test/r/subselect_sj.result | 2 +- mysql-test/r/subselect_sj_jcl6.result | 2 +- mysql-test/t/subselect2.test | 20 ++++++++++++++++++++ 5 files changed, 48 insertions(+), 3 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index ae224fe0220..a1796d7fa3b 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -1460,7 +1460,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE D system PRIMARY NULL NULL NULL 1 1 SIMPLE DSAR system NULL NULL NULL NULL 1 1 SIMPLE DT range t_id t_id 2 NULL 2 Using where -1 SIMPLE DSA ref PRIMARY PRIMARY 8 const,test.DT.t_id,test.D.birthday 1 Using index +1 SIMPLE DSA ref PRIMARY PRIMARY 8 const,test.DT.t_id,func 1 Using index SELECT * FROM t5 DU, t1 D, t4 DT, t2 DSA, t3 DSAR WHERE DU.dog_id=D.dog_id AND D.dog_id=DT.dog_id AND D.birthday=DT.birthday AND DT.t_id=DSA.t_id AND DT.birthday=DSA.birthday AND DSA.dog_id=DSAR.dog_id; diff --git a/mysql-test/r/subselect2.result b/mysql-test/r/subselect2.result index 4fd303dfd44..e06d799845e 100644 --- a/mysql-test/r/subselect2.result +++ b/mysql-test/r/subselect2.result @@ -295,4 +295,29 @@ node_uid date mirror_date result 2084 2012-02-01 00:00:00 2013-01-01 00:00:00 0 set optimizer_switch=@tmp_mdev614; DROP TABLE t1; +# +# MDEV-4420: non-expensive single-value subquery used as +# used as an access key to join a table +# +create table t1 (a varchar(3)); +insert into t1 values ('USA'), ('FRA'); +create table t2 select * from t1; +insert into t2 values ('RUS'); +create table t3 select * from t2; +create index idx on t3(a); +explain extended +select * from t1, t2 left join t3 on ( t2.a = t3.a ) +where t1.a = t2.a and ( t1.a = ( select min(a) from t1 ) or 0 ); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t3 ref idx idx 6 func 2 100.00 Using where; Using index +2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a` from `test`.`t1` join `test`.`t2` left join `test`.`t3` on((`test`.`t3`.`a` = `test`.`t1`.`a`)) where ((`test`.`t1`.`a` = (select min(`test`.`t1`.`a`) from `test`.`t1`)) and (`test`.`t2`.`a` = (select min(`test`.`t1`.`a`) from `test`.`t1`))) +select * from t1, t2 left join t3 on ( t2.a = t3.a ) +where t1.a = t2.a and ( t1.a = ( select min(a) from t1 ) or 0 ); +a a a +FRA FRA FRA +drop table t1,t2,t3; set optimizer_switch=@subselect2_test_tmp; diff --git a/mysql-test/r/subselect_sj.result b/mysql-test/r/subselect_sj.result index 3fc91b452a5..2d229db9ec5 100644 --- a/mysql-test/r/subselect_sj.result +++ b/mysql-test/r/subselect_sj.result @@ -2485,7 +2485,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 system NULL NULL NULL NULL 1 1 PRIMARY ALL distinct_key NULL NULL NULL 1 1 PRIMARY t1 ref a a 5 const 1 Using index -1 PRIMARY t2 ref a a 5 test.t3.b 1 Using index +1 PRIMARY t2 ref a a 5 func 1 Using index 2 MATERIALIZED t4 ALL NULL NULL NULL NULL 0 SELECT * FROM t1, t2 WHERE t1.a = t2.a AND t2.a IN (SELECT b FROM t3 STRAIGHT_JOIN t4); diff --git a/mysql-test/r/subselect_sj_jcl6.result b/mysql-test/r/subselect_sj_jcl6.result index f18de3c4d0b..a0ebbb3305d 100644 --- a/mysql-test/r/subselect_sj_jcl6.result +++ b/mysql-test/r/subselect_sj_jcl6.result @@ -2499,7 +2499,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 system NULL NULL NULL NULL 1 1 PRIMARY ALL distinct_key NULL NULL NULL 1 1 PRIMARY t1 ref a a 5 const 1 Using index -1 PRIMARY t2 ref a a 5 test.t3.b 1 Using index +1 PRIMARY t2 ref a a 5 func 1 Using index 2 MATERIALIZED t4 ALL NULL NULL NULL NULL 0 SELECT * FROM t1, t2 WHERE t1.a = t2.a AND t2.a IN (SELECT b FROM t3 STRAIGHT_JOIN t4); diff --git a/mysql-test/t/subselect2.test b/mysql-test/t/subselect2.test index 68894ad18cb..e286c92285d 100644 --- a/mysql-test/t/subselect2.test +++ b/mysql-test/t/subselect2.test @@ -315,6 +315,26 @@ set optimizer_switch=@tmp_mdev614; DROP TABLE t1; +--echo # +--echo # MDEV-4420: non-expensive single-value subquery used as +--echo # used as an access key to join a table +--echo # + +create table t1 (a varchar(3)); +insert into t1 values ('USA'), ('FRA'); +create table t2 select * from t1; +insert into t2 values ('RUS'); +create table t3 select * from t2; +create index idx on t3(a); + +explain extended +select * from t1, t2 left join t3 on ( t2.a = t3.a ) +where t1.a = t2.a and ( t1.a = ( select min(a) from t1 ) or 0 ); + +select * from t1, t2 left join t3 on ( t2.a = t3.a ) +where t1.a = t2.a and ( t1.a = ( select min(a) from t1 ) or 0 ); + +drop table t1,t2,t3; set optimizer_switch=@subselect2_test_tmp; -- cgit v1.2.1 From dbc84ff96c021f9d8b5968812a416bc6890d015a Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Fri, 23 Aug 2013 22:17:02 -0700 Subject: Fixed bug mdev-4942. Made sure that degenerate conjunctions/disjunctions are obtained from AND/OR conditions. --- mysql-test/r/join_outer.result | 12 ++++++++++++ mysql-test/r/join_outer_jcl6.result | 12 ++++++++++++ mysql-test/t/join_outer.test | 16 ++++++++++++++++ 3 files changed, 40 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 684bfb3836e..b73edc8c52e 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -1836,4 +1836,16 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id WHERE a.modified > b.modified or b.modified IS NULL; id modified DROP TABLE t1; +# +# Bug mdev-4942: LEFT JOIN with conjunctive +# IS NULL in WHERE +# causes an assert failure +# +CREATE TABLE t1 ( i1 int, d1 date ); +INSERT INTO t1 VALUES (1,'2001-06-26'), (2,'2000-11-16'); +CREATE TABLE t2 ( i2 int, d2 date NOT NULL ); +INSERT INTO t2 VALUES (3,'2000-03-06'), (4,'2007-09-25'); +SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE d1 IS NULL AND d2 IS NULL; +i1 d1 i2 d2 +DROP TABLE t1,t2; SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index 4f4c16199e9..a588767d754 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -1847,6 +1847,18 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id WHERE a.modified > b.modified or b.modified IS NULL; id modified DROP TABLE t1; +# +# Bug mdev-4942: LEFT JOIN with conjunctive +# IS NULL in WHERE +# causes an assert failure +# +CREATE TABLE t1 ( i1 int, d1 date ); +INSERT INTO t1 VALUES (1,'2001-06-26'), (2,'2000-11-16'); +CREATE TABLE t2 ( i2 int, d2 date NOT NULL ); +INSERT INTO t2 VALUES (3,'2000-03-06'), (4,'2007-09-25'); +SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE d1 IS NULL AND d2 IS NULL; +i1 d1 i2 d2 +DROP TABLE t1,t2; SET optimizer_switch=@save_optimizer_switch; set join_cache_level=default; show variables like 'join_cache_level'; diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 8c0ee82e1fa..99f4b1e1315 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -1376,4 +1376,20 @@ SELECT a.* FROM t1 a LEFT JOIN t1 b ON a.id = b.id DROP TABLE t1; +--echo # +--echo # Bug mdev-4942: LEFT JOIN with conjunctive +--echo # IS NULL in WHERE +--echo # causes an assert failure +--echo # + +CREATE TABLE t1 ( i1 int, d1 date ); +INSERT INTO t1 VALUES (1,'2001-06-26'), (2,'2000-11-16'); + +CREATE TABLE t2 ( i2 int, d2 date NOT NULL ); +INSERT INTO t2 VALUES (3,'2000-03-06'), (4,'2007-09-25'); + +SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE d1 IS NULL AND d2 IS NULL; + +DROP TABLE t1,t2; + SET optimizer_switch=@save_optimizer_switch; -- cgit v1.2.1 From d126993404c46fe31f22f3c6398a5db44a48eb6b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 28 Aug 2013 07:49:53 +0200 Subject: MDEV-4951 drop user leaves privileges It's safe to delete from HASH when traversing it *backwards*, but not *forwards*. --- mysql-test/r/grant.result | 2 +- mysql-test/r/view_grant.result | 2 ++ mysql-test/t/view_grant.test | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'mysql-test') diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index 10caf4cd10f..f3910b67dd3 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -1615,8 +1615,8 @@ ERROR 42000: SELECT command denied to user 'mysqluser1'@'localhost' for table 't show grants for mysqluser10@localhost; Grants for mysqluser10@localhost GRANT USAGE ON *.* TO 'mysqluser10'@'localhost' -GRANT SELECT ON `mysqltest1`.`t22` TO 'mysqluser10'@'localhost' GRANT SELECT ON `mysqltest1`.`t11` TO 'mysqluser10'@'localhost' +GRANT SELECT ON `mysqltest1`.`t22` TO 'mysqluser10'@'localhost' GRANT EXECUTE ON PROCEDURE `mysqltest1`.`p1` TO 'mysqluser10'@'localhost' GRANT EXECUTE ON FUNCTION `mysqltest1`.`f1` TO 'mysqluser10'@'localhost' select db, routine_name, routine_type, proc_priv from mysql.procs_priv where user='mysqluser10' and host='localhost'; diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result index bfd09bfa9cd..ac09c19a4b4 100644 --- a/mysql-test/r/view_grant.result +++ b/mysql-test/r/view_grant.result @@ -1154,6 +1154,8 @@ drop user olga@localhost; drop user pjotr@localhost; drop user quintessa@localhost; drop database mysqltest1; +select * from information_schema.table_privileges; +GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE End of 5.0 tests. DROP VIEW IF EXISTS v1; DROP TABLE IF EXISTS t1; diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test index 663501a0a88..847153d19f4 100644 --- a/mysql-test/t/view_grant.test +++ b/mysql-test/t/view_grant.test @@ -1595,6 +1595,12 @@ disconnect root; connection default; +# +# MDEV-4951 drop user leaves privileges +# +#verify that no privileges were left after the above +select * from information_schema.table_privileges; + --echo End of 5.0 tests. -- cgit v1.2.1 From 38e2340a8e9f8292628450a7d34fc7c169dcd518 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 26 Aug 2013 21:14:01 +0400 Subject: mtr bug: files outside of both the suite dir and the overlay dir, were treated as coming from the overlay. --- mysql-test/lib/mtr_cases.pm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index 32ec24da492..a82e3ee10b7 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -968,6 +968,8 @@ sub get_tags_from_file($$) { } elsif ($over and $file =~ m@^$pdir/(.*)$@) { $suffix = $1; @prefix = map { "$_/" } $sdir, $pdir; + } else { + $over = 0; # file neither in $sdir nor in $pdir } while (my $line= <$F>) -- cgit v1.2.1 From edd980225a9895f46754d54677bd76327152c78b Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Mon, 26 Aug 2013 21:38:04 +0400 Subject: Fix for MDEV-4836 fix: take into account situation where "notnull_col IS NULL" is not a direct child of the WHERE clause item, but rather is embedded inside Item_cond_and or Item_cond_or. --- mysql-test/r/join_outer.result | 8 ++++++++ mysql-test/r/join_outer_jcl6.result | 8 ++++++++ mysql-test/t/join_outer.test | 11 +++++++++++ 3 files changed, 27 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 3cfe2b20a1a..d77f3df1cdf 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -2150,6 +2150,14 @@ id d i 1 0000-00-00 NULL 2 0000-00-00 NULL DROP TABLE t1,t2; +CREATE TABLE t1 (i1 INT, d1 DATE NOT NULL); +INSERT INTO t1 VALUES (1,'2012-12-21'),(2,'0000-00-00'); +CREATE TABLE t2 (i2 INT, j2 INT); +INSERT INTO t2 VALUES (1,10),(2,20); +SELECT * FROM t1 LEFT JOIN t2 ON i1 = j2 WHERE d1 IS NULL AND 1 OR i1 = i2; +i1 d1 i2 j2 +2 0000-00-00 NULL NULL +DROP TABLE t1,t2; # # Bug mdev-4942: LEFT JOIN with conjunctive # IS NULL in WHERE diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index 5c20a87f10c..59760470176 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -2161,6 +2161,14 @@ id d i 1 0000-00-00 NULL 2 0000-00-00 NULL DROP TABLE t1,t2; +CREATE TABLE t1 (i1 INT, d1 DATE NOT NULL); +INSERT INTO t1 VALUES (1,'2012-12-21'),(2,'0000-00-00'); +CREATE TABLE t2 (i2 INT, j2 INT); +INSERT INTO t2 VALUES (1,10),(2,20); +SELECT * FROM t1 LEFT JOIN t2 ON i1 = j2 WHERE d1 IS NULL AND 1 OR i1 = i2; +i1 d1 i2 j2 +2 0000-00-00 NULL NULL +DROP TABLE t1,t2; # # Bug mdev-4942: LEFT JOIN with conjunctive # IS NULL in WHERE diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 0ef1ea593a2..f85feb70ccb 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -1696,6 +1696,17 @@ CREATE TABLE t2 (i INT); SELECT * FROM t1 LEFT JOIN t2 ON (id=i) WHERE NULL OR d IS NULL; DROP TABLE t1,t2; + +CREATE TABLE t1 (i1 INT, d1 DATE NOT NULL); +INSERT INTO t1 VALUES (1,'2012-12-21'),(2,'0000-00-00'); + +CREATE TABLE t2 (i2 INT, j2 INT); +INSERT INTO t2 VALUES (1,10),(2,20); + +SELECT * FROM t1 LEFT JOIN t2 ON i1 = j2 WHERE d1 IS NULL AND 1 OR i1 = i2; +DROP TABLE t1,t2; + + --echo # --echo # Bug mdev-4942: LEFT JOIN with conjunctive --echo # IS NULL in WHERE -- cgit v1.2.1 From 901737c9782215e409ae6f7869f5d0adbe215ad6 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Mon, 26 Aug 2013 12:55:58 -0700 Subject: Fixed bug mdev-4944. The patch to fix mdev-4418 turned out to be incorrect. At the substitution of single row tables in make_join_statistics() the used multiple equalities may change and references to the new multiple equalities must be updated. The function remove_eq_conds() takes care of it and it should be called right after the substitution of single row tables. Calling it after the call of make_join_statistics was a mistake. --- mysql-test/r/join_outer.result | 2 +- mysql-test/r/join_outer_jcl6.result | 2 +- mysql-test/r/select.result | 19 +++++++++++++++++++ mysql-test/r/select_jcl6.result | 19 +++++++++++++++++++ mysql-test/r/select_pkeycache.result | 19 +++++++++++++++++++ mysql-test/r/subselect.result | 2 +- mysql-test/r/subselect_no_mat.result | 2 +- mysql-test/r/subselect_no_opts.result | 2 +- mysql-test/r/subselect_no_scache.result | 2 +- mysql-test/r/subselect_no_semijoin.result | 2 +- mysql-test/r/table_elim.result | 4 ++-- mysql-test/t/select.test | 19 +++++++++++++++++++ 12 files changed, 85 insertions(+), 9 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index b73edc8c52e..6e92d47a145 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -1649,7 +1649,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 100.00 Using where 2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((6,(select `test`.`t3`.`a` from `test`.`t3` where (6 = `test`.`t3`.`a`)))) +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((6,(select `test`.`t3`.`a` from `test`.`t3` where (6 = `test`.`t3`.`a`)))) where 1 DROP TABLE t1,t2,t3; # # LP bug #817384 Wrong result with outer join + subquery in ON diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index a588767d754..a78a7352f2d 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -1660,7 +1660,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 1 100.00 Using where 2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where Warnings: -Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((6,(select `test`.`t3`.`a` from `test`.`t3` where (6 = `test`.`t3`.`a`)))) +Note 1003 select `test`.`t2`.`a` AS `a` from `test`.`t1` left join `test`.`t2` on((6,(select `test`.`t3`.`a` from `test`.`t3` where (6 = `test`.`t3`.`a`)))) where 1 DROP TABLE t1,t2,t3; # # LP bug #817384 Wrong result with outer join + subquery in ON diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 56a4a8d2bdc..f5744c8e3d0 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -5235,4 +5235,23 @@ Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'k' AS `c`,'k' AS SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b)); a b c d DROP TABLE t1,t2; +# +# Bug mdev-4944: range conditition in OR formula with fields +# belonging to multiple equalities +# +CREATE TABLE t1 (i1 int, j1 int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,8); +CREATE TABLE t2 (i2 int, INDEX idx (i2)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (8), (9); +EXPLAIN EXTENDED +SELECT * FROM t1, t2 +WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 ); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +Warnings: +Note 1003 select 1 AS `i1`,8 AS `j1`,`test`.`t2`.`i2` AS `i2` from `test`.`t1` join `test`.`t2` where 0 +SELECT * FROM t1, t2 +WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 ); +i1 j1 i2 +DROP TABLE t1,t2; End of 5.3 tests diff --git a/mysql-test/r/select_jcl6.result b/mysql-test/r/select_jcl6.result index 1a735299e0e..eea9d318f04 100644 --- a/mysql-test/r/select_jcl6.result +++ b/mysql-test/r/select_jcl6.result @@ -5246,6 +5246,25 @@ Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'k' AS `c`,'k' AS SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b)); a b c d DROP TABLE t1,t2; +# +# Bug mdev-4944: range conditition in OR formula with fields +# belonging to multiple equalities +# +CREATE TABLE t1 (i1 int, j1 int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,8); +CREATE TABLE t2 (i2 int, INDEX idx (i2)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (8), (9); +EXPLAIN EXTENDED +SELECT * FROM t1, t2 +WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 ); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +Warnings: +Note 1003 select 1 AS `i1`,8 AS `j1`,`test`.`t2`.`i2` AS `i2` from `test`.`t1` join `test`.`t2` where 0 +SELECT * FROM t1, t2 +WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 ); +i1 j1 i2 +DROP TABLE t1,t2; End of 5.3 tests set join_cache_level=default; show variables like 'join_cache_level'; diff --git a/mysql-test/r/select_pkeycache.result b/mysql-test/r/select_pkeycache.result index 56a4a8d2bdc..f5744c8e3d0 100644 --- a/mysql-test/r/select_pkeycache.result +++ b/mysql-test/r/select_pkeycache.result @@ -5235,4 +5235,23 @@ Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,'k' AS `c`,'k' AS SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b)); a b c d DROP TABLE t1,t2; +# +# Bug mdev-4944: range conditition in OR formula with fields +# belonging to multiple equalities +# +CREATE TABLE t1 (i1 int, j1 int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,8); +CREATE TABLE t2 (i2 int, INDEX idx (i2)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (8), (9); +EXPLAIN EXTENDED +SELECT * FROM t1, t2 +WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 ); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +Warnings: +Note 1003 select 1 AS `i1`,8 AS `j1`,`test`.`t2`.`i2` AS `i2` from `test`.`t1` join `test`.`t2` where 0 +SELECT * FROM t1, t2 +WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 ); +i1 j1 i2 +DROP TABLE t1,t2; End of 5.3 tests diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index e4448d96657..8503164dde2 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1322,7 +1322,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: -Note 1003 select (0,(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)` +Note 1003 select (0,(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` INSERT INTO t1 (pseudo) VALUES ('test1'); SELECT 0 IN (SELECT 1 FROM t1 a); 0 IN (SELECT 1 FROM t1 a) diff --git a/mysql-test/r/subselect_no_mat.result b/mysql-test/r/subselect_no_mat.result index df6b884fbe0..d0c9555d976 100644 --- a/mysql-test/r/subselect_no_mat.result +++ b/mysql-test/r/subselect_no_mat.result @@ -1329,7 +1329,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: -Note 1003 select (0,(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)` +Note 1003 select (0,(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` INSERT INTO t1 (pseudo) VALUES ('test1'); SELECT 0 IN (SELECT 1 FROM t1 a); 0 IN (SELECT 1 FROM t1 a) diff --git a/mysql-test/r/subselect_no_opts.result b/mysql-test/r/subselect_no_opts.result index f9df463f6aa..47f6d3a0ed4 100644 --- a/mysql-test/r/subselect_no_opts.result +++ b/mysql-test/r/subselect_no_opts.result @@ -1325,7 +1325,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: -Note 1003 select (0,(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)` +Note 1003 select (0,(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` INSERT INTO t1 (pseudo) VALUES ('test1'); SELECT 0 IN (SELECT 1 FROM t1 a); 0 IN (SELECT 1 FROM t1 a) diff --git a/mysql-test/r/subselect_no_scache.result b/mysql-test/r/subselect_no_scache.result index 70de4b26743..f3a01618eff 100644 --- a/mysql-test/r/subselect_no_scache.result +++ b/mysql-test/r/subselect_no_scache.result @@ -1328,7 +1328,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: -Note 1003 select (0,(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)` +Note 1003 select (0,(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` INSERT INTO t1 (pseudo) VALUES ('test1'); SELECT 0 IN (SELECT 1 FROM t1 a); 0 IN (SELECT 1 FROM t1 a) diff --git a/mysql-test/r/subselect_no_semijoin.result b/mysql-test/r/subselect_no_semijoin.result index 91071c98777..964704e0695 100644 --- a/mysql-test/r/subselect_no_semijoin.result +++ b/mysql-test/r/subselect_no_semijoin.result @@ -1325,7 +1325,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL No tables used 2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables Warnings: -Note 1003 select (0,(select 1 from `test`.`t1` `a` where 0)) AS `0 IN (SELECT 1 FROM t1 a)` +Note 1003 select (0,(select 1 from `test`.`t1` `a` where (0 = 1))) AS `0 IN (SELECT 1 FROM t1 a)` INSERT INTO t1 (pseudo) VALUES ('test1'); SELECT 0 IN (SELECT 1 FROM t1 a); 0 IN (SELECT 1 FROM t1 a) diff --git a/mysql-test/r/table_elim.result b/mysql-test/r/table_elim.result index 86e5bbe0060..35acd30d76d 100644 --- a/mysql-test/r/table_elim.result +++ b/mysql-test/r/table_elim.result @@ -17,7 +17,7 @@ explain extended select t1.a from t1 left join t2 on t2.a=t1.a; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Warnings: -Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` +Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where 1 select t1.a from t1 left join t2 on t2.a=t1.a; a 0 @@ -62,7 +62,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 4 100.00 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 100.00 Using where Warnings: -Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t0` left join (`test`.`t1`) on((`test`.`t1`.`a` = `test`.`t0`.`a`)) +Note 1003 select `test`.`t0`.`a` AS `a` from `test`.`t0` left join (`test`.`t1`) on((`test`.`t1`.`a` = `test`.`t0`.`a`)) where 1 # Elimination with aggregate functions explain select count(*) from t1 left join t2 on t2.a=t1.a; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index c0e22cb8f4e..bb5a6b9c2fc 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -4389,4 +4389,23 @@ SELECT * FROM t1, t2 WHERE c=b AND (1=2 OR ((b='h' OR a=136) AND d=b)); DROP TABLE t1,t2; +--echo # +--echo # Bug mdev-4944: range conditition in OR formula with fields +--echo # belonging to multiple equalities +--echo # + +CREATE TABLE t1 (i1 int, j1 int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,8); + +CREATE TABLE t2 (i2 int, INDEX idx (i2)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (8), (9); + +EXPLAIN EXTENDED +SELECT * FROM t1, t2 + WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 ); +SELECT * FROM t1, t2 + WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 ); + +DROP TABLE t1,t2; + --echo End of 5.3 tests -- cgit v1.2.1 From 650d3266bb788552b9ac8dce6f5fed0cf53f480c Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Mon, 26 Aug 2013 15:51:47 -0700 Subject: Fixed bug mdev-4952 When in function remove_eq_conds() a sub-formula of the processed condition is replaced for another formula we should ensure that in the resulting formula AND/OR levels must alternate. --- mysql-test/r/join_outer.result | 14 ++++++++++++++ mysql-test/r/join_outer_jcl6.result | 14 ++++++++++++++ mysql-test/t/join_outer.test | 18 ++++++++++++++++++ 3 files changed, 46 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index 6e92d47a145..c30f1584607 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -1848,4 +1848,18 @@ INSERT INTO t2 VALUES (3,'2000-03-06'), (4,'2007-09-25'); SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE d1 IS NULL AND d2 IS NULL; i1 d1 i2 d2 DROP TABLE t1,t2; +# +# Bug mdev-4952: LEFT JOIN with disjunctive +# IS NULL in WHERE +# causes an assert failure +# +CREATE TABLE t1 (a1 int, b1 int NOT NULL) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1, 10), (2, 11); +CREATE TABLE t2 (dt datetime NOT NULL, a2 int, b2 int) ENGINE=MyISAM; +INSERT INTO t2 VALUES +('2006-10-08 09:34:54', 1, 100), ('2001-01-19 01:04:43', 2, 200); +SELECT * FROM t1 LEFT JOIN t2 ON a1 = a2 +WHERE ( dt IS NULL OR FALSE ) AND b2 IS NULL; +a1 b1 dt a2 b2 +DROP TABLE t1,t2; SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index a78a7352f2d..ccb402a642c 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -1859,6 +1859,20 @@ INSERT INTO t2 VALUES (3,'2000-03-06'), (4,'2007-09-25'); SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE d1 IS NULL AND d2 IS NULL; i1 d1 i2 d2 DROP TABLE t1,t2; +# +# Bug mdev-4952: LEFT JOIN with disjunctive +# IS NULL in WHERE +# causes an assert failure +# +CREATE TABLE t1 (a1 int, b1 int NOT NULL) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1, 10), (2, 11); +CREATE TABLE t2 (dt datetime NOT NULL, a2 int, b2 int) ENGINE=MyISAM; +INSERT INTO t2 VALUES +('2006-10-08 09:34:54', 1, 100), ('2001-01-19 01:04:43', 2, 200); +SELECT * FROM t1 LEFT JOIN t2 ON a1 = a2 +WHERE ( dt IS NULL OR FALSE ) AND b2 IS NULL; +a1 b1 dt a2 b2 +DROP TABLE t1,t2; SET optimizer_switch=@save_optimizer_switch; set join_cache_level=default; show variables like 'join_cache_level'; diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 99f4b1e1315..ec48818f57f 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -1392,4 +1392,22 @@ SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE d1 IS NULL AND d2 IS NULL; DROP TABLE t1,t2; +--echo # +--echo # Bug mdev-4952: LEFT JOIN with disjunctive +--echo # IS NULL in WHERE +--echo # causes an assert failure +--echo # + +CREATE TABLE t1 (a1 int, b1 int NOT NULL) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1, 10), (2, 11); + +CREATE TABLE t2 (dt datetime NOT NULL, a2 int, b2 int) ENGINE=MyISAM; +INSERT INTO t2 VALUES +('2006-10-08 09:34:54', 1, 100), ('2001-01-19 01:04:43', 2, 200); + +SELECT * FROM t1 LEFT JOIN t2 ON a1 = a2 + WHERE ( dt IS NULL OR FALSE ) AND b2 IS NULL; + +DROP TABLE t1,t2; + SET optimizer_switch=@save_optimizer_switch; -- cgit v1.2.1 From 112411b056ae16c4addcb9dc84ebf1992b719d59 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Tue, 27 Aug 2013 19:18:04 +0300 Subject: Fixed MySQL bug #69861 LAST_INSERT_ID is replicated incorrectly if replication filters are used mysql-test/suite/rpl/r/last_insert_id.result: Test case for last_insert_id mysql-test/suite/rpl/t/last_insert_id.cnf: Test case for last_insert_id mysql-test/suite/rpl/t/last_insert_id.test: Test case for last_insert_id sql/log_event.cc: Added DBUG_PRINT Set thd->first_successful_insert_id_in_prev_stmt_for_binlog when setting thd->first_successful_insert_id_in_prev_stmt. This is required to get last_insert_id() replicated. This is analog to how read_first_successful_insert_id_in_prev_stmt() works. sql/rpl_utility.cc: Added DBUG_PRINT --- mysql-test/suite/rpl/r/last_insert_id.result | 18 +++++++++++++++++ mysql-test/suite/rpl/t/last_insert_id.cnf | 20 +++++++++++++++++++ mysql-test/suite/rpl/t/last_insert_id.test | 30 ++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 mysql-test/suite/rpl/r/last_insert_id.result create mode 100644 mysql-test/suite/rpl/t/last_insert_id.cnf create mode 100644 mysql-test/suite/rpl/t/last_insert_id.test (limited to 'mysql-test') diff --git a/mysql-test/suite/rpl/r/last_insert_id.result b/mysql-test/suite/rpl/r/last_insert_id.result new file mode 100644 index 00000000000..ce64e9df41e --- /dev/null +++ b/mysql-test/suite/rpl/r/last_insert_id.result @@ -0,0 +1,18 @@ +include/rpl_init.inc [topology=1->2->3] +create table t1 (id int not null auto_increment primary key, i int) engine=InnoDB; +insert into t1 (i) values (-1); +insert into t1 (i) values (LAST_INSERT_ID()); +select * from t1; +id i +1 -1 +2 1 +select * from t1; +id i +1 -1 +2 1 +select * from t1; +id i +1 -1 +2 1 +drop table t1; +include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/last_insert_id.cnf b/mysql-test/suite/rpl/t/last_insert_id.cnf new file mode 100644 index 00000000000..1c229e4ac94 --- /dev/null +++ b/mysql-test/suite/rpl/t/last_insert_id.cnf @@ -0,0 +1,20 @@ +!include suite/rpl/my.cnf + +[mysqld.1] +log-slave-updates +loose-innodb + +[mysqld.2] +log-slave-updates +loose-innodb +replicate-ignore-table=db.t2 + +[mysqld.3] +log-slave-updates +loose-innodb + +[ENV] +SERVER_MYPORT_3= @mysqld.3.port +SERVER_MYSOCK_3= @mysqld.3.socket + + diff --git a/mysql-test/suite/rpl/t/last_insert_id.test b/mysql-test/suite/rpl/t/last_insert_id.test new file mode 100644 index 00000000000..f23cca405ac --- /dev/null +++ b/mysql-test/suite/rpl/t/last_insert_id.test @@ -0,0 +1,30 @@ +--source include/have_innodb.inc +--source include/have_binlog_format_mixed_or_statement.inc +--let $rpl_topology=1->2->3 +--source include/rpl_init.inc + +connection server_1; + +create table t1 (id int not null auto_increment primary key, i int) engine=InnoDB; +insert into t1 (i) values (-1); +insert into t1 (i) values (LAST_INSERT_ID()); +select * from t1; + +save_master_pos; + +connection server_2; + +sync_with_master; +select * from t1; +save_master_pos; + +connection server_3; + +sync_with_master; +select * from t1; + +connection server_1; +drop table t1; + +--source include/rpl_end.inc + -- cgit v1.2.1 From 1906f1388e4d13b8a3328b58489dae862c6c8595 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Wed, 28 Aug 2013 09:14:57 -0700 Subject: Fixed bug mdev-4959. The fix for mdev-4420 was not quite correct. This patch corrects it. --- mysql-test/r/join.result | 19 +++++++++++++++++++ mysql-test/t/join.test | 16 ++++++++++++++++ 2 files changed, 35 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index a1796d7fa3b..1e51d55f012 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -1477,4 +1477,23 @@ DROP TABLE t1,t2,t3,t4,t5; # SELECT * FROM t5 JOIN (t1 JOIN t2 UNION SELECT * FROM t3 JOIN t4); ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1 +# +# MDEV-4959: join of const table with NULL fields +# +CREATE TABLE t1 (i1 int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (NULL); +CREATE TABLE t2 (i2 int, a int, b int) ENGINE=MyISAM; +CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2; +INSERT INTO t2 VALUES (NULL,1,2),(NULL,2,3); +SELECT * FROM t1 JOIN v2 ON i1 = i2 WHERE a < b; +i1 i2 a b +EXPLAIN EXTENDED +SELECT * FROM t1 JOIN v2 ON i1 = i2 WHERE a < b; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +2 DERIVED t2 ALL NULL NULL NULL NULL 2 100.00 +Warnings: +Note 1003 select NULL AS `i1`,`v2`.`i2` AS `i2`,`v2`.`a` AS `a`,`v2`.`b` AS `b` from `test`.`v2` where ((`v2`.`i2` = NULL) and (`v2`.`a` < `v2`.`b`)) +DROP VIEW v2; +DROP TABLE t1,t2; SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index e42cbc82745..203a7d377a5 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -1141,5 +1141,21 @@ DROP TABLE t1,t2,t3,t4,t5; --error ER_PARSE_ERROR SELECT * FROM t5 JOIN (t1 JOIN t2 UNION SELECT * FROM t3 JOIN t4); +--echo # +--echo # MDEV-4959: join of const table with NULL fields +--echo # + +CREATE TABLE t1 (i1 int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (NULL); +CREATE TABLE t2 (i2 int, a int, b int) ENGINE=MyISAM; +CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2; +INSERT INTO t2 VALUES (NULL,1,2),(NULL,2,3); + +SELECT * FROM t1 JOIN v2 ON i1 = i2 WHERE a < b; +EXPLAIN EXTENDED +SELECT * FROM t1 JOIN v2 ON i1 = i2 WHERE a < b; + +DROP VIEW v2; +DROP TABLE t1,t2; SET optimizer_switch=@save_optimizer_switch; -- cgit v1.2.1 From d6f7649d3c7f2e055a77ef9432c245928675ef4c Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 28 Aug 2013 21:21:12 +0400 Subject: mdev-4942: Add another testcase after merging with other fixes. --- mysql-test/r/join_outer.result | 12 ++++++++++++ mysql-test/r/join_outer_jcl6.result | 12 ++++++++++++ mysql-test/t/join_outer.test | 13 +++++++++++++ 3 files changed, 37 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index cc0d7572a92..b193bf057eb 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -2158,6 +2158,18 @@ SELECT * FROM t1 LEFT JOIN t2 ON i1 = j2 WHERE d1 IS NULL AND 1 OR i1 = i2; i1 d1 i2 j2 2 0000-00-00 NULL NULL DROP TABLE t1,t2; +# Another testcase +CREATE TABLE t1 (i1 INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (NULL); +CREATE TABLE t2 (i2 INT, a INT, b INT) ENGINE=MyISAM; +CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2; +INSERT INTO t2 VALUES (NULL,1,2),(NULL,2,3); +SELECT * FROM t1 LEFT JOIN v2 ON i1 = i2 WHERE a < b; +i1 i2 a b +SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE a < b; +i1 i2 a b +drop view v2; +drop table t1,t2; # # Bug mdev-4942: LEFT JOIN with conjunctive # IS NULL in WHERE diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index 6c9a0237f35..313ea67c156 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -2169,6 +2169,18 @@ SELECT * FROM t1 LEFT JOIN t2 ON i1 = j2 WHERE d1 IS NULL AND 1 OR i1 = i2; i1 d1 i2 j2 2 0000-00-00 NULL NULL DROP TABLE t1,t2; +# Another testcase +CREATE TABLE t1 (i1 INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (NULL); +CREATE TABLE t2 (i2 INT, a INT, b INT) ENGINE=MyISAM; +CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2; +INSERT INTO t2 VALUES (NULL,1,2),(NULL,2,3); +SELECT * FROM t1 LEFT JOIN v2 ON i1 = i2 WHERE a < b; +i1 i2 a b +SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE a < b; +i1 i2 a b +drop view v2; +drop table t1,t2; # # Bug mdev-4942: LEFT JOIN with conjunctive # IS NULL in WHERE diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 765118d4775..7452e81ca23 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -1706,6 +1706,19 @@ INSERT INTO t2 VALUES (1,10),(2,20); SELECT * FROM t1 LEFT JOIN t2 ON i1 = j2 WHERE d1 IS NULL AND 1 OR i1 = i2; DROP TABLE t1,t2; +--echo # Another testcase +CREATE TABLE t1 (i1 INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (NULL); + +CREATE TABLE t2 (i2 INT, a INT, b INT) ENGINE=MyISAM; +CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2; + +INSERT INTO t2 VALUES (NULL,1,2),(NULL,2,3); +SELECT * FROM t1 LEFT JOIN v2 ON i1 = i2 WHERE a < b; +SELECT * FROM t1 LEFT JOIN t2 ON i1 = i2 WHERE a < b; + +drop view v2; +drop table t1,t2; --echo # --echo # Bug mdev-4942: LEFT JOIN with conjunctive -- cgit v1.2.1 From 68325b6a12dbe8fc2e95ba69b4537e1d4d52e204 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 28 Aug 2013 22:16:03 +0200 Subject: Test case for MyISAM and OPTIMIZE TABLE that requires MDL_SHARED_NO_READ_WRITE. --- mysql-test/r/myisam_optimize.result | 23 ++++++++++++++++++ mysql-test/t/myisam_optimize.test | 47 +++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 mysql-test/r/myisam_optimize.result create mode 100644 mysql-test/t/myisam_optimize.test (limited to 'mysql-test') diff --git a/mysql-test/r/myisam_optimize.result b/mysql-test/r/myisam_optimize.result new file mode 100644 index 00000000000..185d49e6391 --- /dev/null +++ b/mysql-test/r/myisam_optimize.result @@ -0,0 +1,23 @@ +call mtr.add_suppression(" marked as crashed and should be repaired"); +create table t1 (a int auto_increment primary key, b text); +insert t1 (b) select repeat("A", 100); +insert t1 (b) select repeat("B", 200) from t1; +insert t1 (b) select repeat("C", 300) from t1; +delete from t1 where a < 3; +explain select a, left(b,10) from t1 order by a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using filesort +select left(b,10), a from t1 order by a; +left(b,10) a +CCCCCCCCCC 3 +CCCCCCCCCC 4 +set debug_sync='myisam_after_repair_by_sort wait_for go'; +optimize table t1; +select a, left(b,10) from t1 order by a; +set debug_sync='now signal go'; +Table Op Msg_type Msg_text +test.t1 optimize status OK +a left(b,10) +3 CCCCCCCCCC +4 CCCCCCCCCC +drop table t1; diff --git a/mysql-test/t/myisam_optimize.test b/mysql-test/t/myisam_optimize.test new file mode 100644 index 00000000000..da47a7a4127 --- /dev/null +++ b/mysql-test/t/myisam_optimize.test @@ -0,0 +1,47 @@ +# +# test OPTIMIZE and a concurrent SELECT of a MyISAM table +# +source include/have_debug_sync.inc; + +call mtr.add_suppression(" marked as crashed and should be repaired"); + +create table t1 (a int auto_increment primary key, b text); +insert t1 (b) select repeat("A", 100); +insert t1 (b) select repeat("B", 200) from t1; +insert t1 (b) select repeat("C", 300) from t1; + +delete from t1 where a < 3; +explain select a, left(b,10) from t1 order by a; +select left(b,10), a from t1 order by a; + +set debug_sync='myisam_after_repair_by_sort wait_for go'; +send optimize table t1; + +connect (con1,localhost,root,,); +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state like "%myisam_after_repair_by_sort%"; +--source include/wait_condition.inc + +send select a, left(b,10) from t1 order by a; + +connect (con2,localhost,root,,); +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table metadata lock"; +--source include/wait_condition.inc + +set debug_sync='now signal go'; + +connection default; +reap; + +connection con1; +reap; + +disconnect con1; +disconnect con2; +connection default; + +drop table t1; + -- cgit v1.2.1 From 28a9fea122e40bdb9f199f053cc70299656b7018 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 28 Aug 2013 22:16:13 +0200 Subject: fix an old bug where dd_frm_type() could incorrectly determine the table type for dynamic engines (because it only looked at the one-byte code, not at the full engine name). --- mysql-test/r/drop_bad_db_type.result | 12 ++++++++++++ mysql-test/t/drop_bad_db_type.test | 25 +++++++++++++++++++++++++ mysql-test/t/func_str.test | 4 ++++ 3 files changed, 41 insertions(+) create mode 100644 mysql-test/r/drop_bad_db_type.result create mode 100644 mysql-test/t/drop_bad_db_type.test (limited to 'mysql-test') diff --git a/mysql-test/r/drop_bad_db_type.result b/mysql-test/r/drop_bad_db_type.result new file mode 100644 index 00000000000..6a125cdccf5 --- /dev/null +++ b/mysql-test/r/drop_bad_db_type.result @@ -0,0 +1,12 @@ +set debug_dbug='+d,unstable_db_type'; +install soname 'ha_archive'; +create table t1 (a int) engine=archive; +insert t1 values (1),(2),(3); +flush tables; +uninstall soname 'ha_archive'; +install soname 'ha_archive'; +t1.ARZ +t1.frm +drop table t1; +uninstall soname 'ha_archive'; +set debug_dbug='-d,unstable_db_type'; diff --git a/mysql-test/t/drop_bad_db_type.test b/mysql-test/t/drop_bad_db_type.test new file mode 100644 index 00000000000..69e1a889b18 --- /dev/null +++ b/mysql-test/t/drop_bad_db_type.test @@ -0,0 +1,25 @@ + +--source include/have_debug.inc + +if (!$HA_ARCHIVE_SO) { + skip Needs Archive plugin; +} + +let $mysqld_datadir= `select @@datadir`; + +set debug_dbug='+d,unstable_db_type'; + +install soname 'ha_archive'; +create table t1 (a int) engine=archive; +insert t1 values (1),(2),(3); +flush tables; +uninstall soname 'ha_archive'; + +install soname 'ha_archive'; +--list_files $mysqld_datadir/test +drop table t1; +--list_files $mysqld_datadir/test +uninstall soname 'ha_archive'; + +set debug_dbug='-d,unstable_db_type'; + diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 1a60b0c222a..239317ae717 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -6,6 +6,8 @@ drop table if exists t1,t2; --enable_warnings +let $mysqld_datadir= `select @@datadir`; + set names latin1; select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo'; @@ -1385,6 +1387,8 @@ LOAD DATA INFILE 'bug58165.txt' INTO TABLE t1; SELECT * FROM t1; DROP TABLE t1; +--remove_file $mysqld_datadir/test/bug58165.txt + # # MDEV-759 lp:998340 - Valgrind complains on simple selects containing expression DAY(FROM_UNIXTIME(-1)) # -- cgit v1.2.1 From 37f18d2318c966b84a5e91a31c0985a9b2d0d9fd Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Thu, 29 Aug 2013 10:56:12 -0700 Subject: Fixed bug mdev-4962. When a non-nullable datetime field is used under an IS NULL predicate of the WHERE condition in a query with outer joins the remove_eq_conds function should check whether this field belongs to an inner table of any outer join that can be, in a general case, a nested outer join. --- mysql-test/r/join_outer.result | 26 ++++++++++++++++++++++++++ mysql-test/r/join_outer_jcl6.result | 26 ++++++++++++++++++++++++++ mysql-test/t/join_outer.test | 23 +++++++++++++++++++++++ 3 files changed, 75 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index c30f1584607..284a285dbe3 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -1862,4 +1862,30 @@ SELECT * FROM t1 LEFT JOIN t2 ON a1 = a2 WHERE ( dt IS NULL OR FALSE ) AND b2 IS NULL; a1 b1 dt a2 b2 DROP TABLE t1,t2; +# +# Bug mdev-4962: nested outer join with +# IS NULL in WHERE +# causes an assert failure +# +CREATE TABLE t1 (i1 int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (i2 int) ENGINE=MyISAM; +INSERT INTO t2 VALUES (10),(20); +CREATE TABLE t3 (i3 int, d3 datetime NOT NULL) ENGINE=MyISAM; +INSERT INTO t3 VALUES (8,'2008-12-04 17:53:42'),(9,'2012-12-21 12:12:12'); +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON i2 = i3 ON i1 = i3 +WHERE d3 IS NULL; +i1 i2 i3 d3 +1 NULL NULL NULL +2 NULL NULL NULL +EXPLAIN EXTENDED +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON i2 = i3 ON i1 = i3 +WHERE d3 IS NULL; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where +1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`i1` AS `i1`,`test`.`t2`.`i2` AS `i2`,`test`.`t3`.`i3` AS `i3`,`test`.`t3`.`d3` AS `d3` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`i2` = `test`.`t1`.`i1`) and (`test`.`t3`.`i3` = `test`.`t1`.`i1`))) where ((`test`.`t3`.`d3` = 0) or isnull(`test`.`t3`.`d3`)) +DROP TABLE t1,t2,t3; SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/r/join_outer_jcl6.result b/mysql-test/r/join_outer_jcl6.result index ccb402a642c..69fe7cbd6b9 100644 --- a/mysql-test/r/join_outer_jcl6.result +++ b/mysql-test/r/join_outer_jcl6.result @@ -1873,6 +1873,32 @@ SELECT * FROM t1 LEFT JOIN t2 ON a1 = a2 WHERE ( dt IS NULL OR FALSE ) AND b2 IS NULL; a1 b1 dt a2 b2 DROP TABLE t1,t2; +# +# Bug mdev-4962: nested outer join with +# IS NULL in WHERE +# causes an assert failure +# +CREATE TABLE t1 (i1 int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (i2 int) ENGINE=MyISAM; +INSERT INTO t2 VALUES (10),(20); +CREATE TABLE t3 (i3 int, d3 datetime NOT NULL) ENGINE=MyISAM; +INSERT INTO t3 VALUES (8,'2008-12-04 17:53:42'),(9,'2012-12-21 12:12:12'); +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON i2 = i3 ON i1 = i3 +WHERE d3 IS NULL; +i1 i2 i3 d3 +1 NULL NULL NULL +2 NULL NULL NULL +EXPLAIN EXTENDED +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON i2 = i3 ON i1 = i3 +WHERE d3 IS NULL; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) +Warnings: +Note 1003 select `test`.`t1`.`i1` AS `i1`,`test`.`t2`.`i2` AS `i2`,`test`.`t3`.`i3` AS `i3`,`test`.`t3`.`d3` AS `d3` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t2`.`i2` = `test`.`t1`.`i1`) and (`test`.`t3`.`i3` = `test`.`t1`.`i1`))) where ((`test`.`t3`.`d3` = 0) or isnull(`test`.`t3`.`d3`)) +DROP TABLE t1,t2,t3; SET optimizer_switch=@save_optimizer_switch; set join_cache_level=default; show variables like 'join_cache_level'; diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index ec48818f57f..6a1dac66967 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -1410,4 +1410,27 @@ SELECT * FROM t1 LEFT JOIN t2 ON a1 = a2 DROP TABLE t1,t2; +--echo # +--echo # Bug mdev-4962: nested outer join with +--echo # IS NULL in WHERE +--echo # causes an assert failure +--echo # + +CREATE TABLE t1 (i1 int) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1),(2); + +CREATE TABLE t2 (i2 int) ENGINE=MyISAM; +INSERT INTO t2 VALUES (10),(20); + +CREATE TABLE t3 (i3 int, d3 datetime NOT NULL) ENGINE=MyISAM; +INSERT INTO t3 VALUES (8,'2008-12-04 17:53:42'),(9,'2012-12-21 12:12:12'); + +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON i2 = i3 ON i1 = i3 + WHERE d3 IS NULL; +EXPLAIN EXTENDED +SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON i2 = i3 ON i1 = i3 + WHERE d3 IS NULL; + +DROP TABLE t1,t2,t3; + SET optimizer_switch=@save_optimizer_switch; -- cgit v1.2.1 From 576a2b153320ab1fbfd4df06a30bf1f52e569cba Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Thu, 29 Aug 2013 21:02:42 -0700 Subject: Fixed bug mdev-4971. The function propagate_new_equalities() did not updated properly the references to inherited multiple equalities. --- mysql-test/r/select.result | 25 +++++++++++++++++++++++++ mysql-test/r/select_jcl6.result | 25 +++++++++++++++++++++++++ mysql-test/r/select_pkeycache.result | 25 +++++++++++++++++++++++++ mysql-test/r/subselect_sj2_mat.result | 2 +- mysql-test/t/select.test | 23 +++++++++++++++++++++++ 5 files changed, 99 insertions(+), 1 deletion(-) (limited to 'mysql-test') diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index f5744c8e3d0..f0de9622368 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -5254,4 +5254,29 @@ SELECT * FROM t1, t2 WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 ); i1 j1 i2 DROP TABLE t1,t2; +# +# Bug mdev-4971: equality propagation after merging degenerate +# disjunction into embedding AND level +# +CREATE TABLE t1 (pk1 int, a1 int, b1 int, PRIMARY KEY(pk1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,10,100), (2,20,200) ; +CREATE TABLE t2 (pk2 int, a2 int, PRIMARY KEY(pk2)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1,1); +SELECT * FROM t1, t2 +WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); +pk1 a1 b1 pk2 a2 +EXPLAIN EXTENDED +SELECT * FROM t1, t2 +WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 system PRIMARY NULL NULL NULL 1 100.00 +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a1` = 1) and ((`test`.`t1`.`b1` = 6) or (1 > 4))) +INSERT INTO t1 VALUES (3,1,6); +SELECT * FROM t1, t2 +WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); +pk1 a1 b1 pk2 a2 +3 1 6 1 1 +DROP TABLE t1,t2; End of 5.3 tests diff --git a/mysql-test/r/select_jcl6.result b/mysql-test/r/select_jcl6.result index eea9d318f04..3c3d6188301 100644 --- a/mysql-test/r/select_jcl6.result +++ b/mysql-test/r/select_jcl6.result @@ -5265,6 +5265,31 @@ SELECT * FROM t1, t2 WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 ); i1 j1 i2 DROP TABLE t1,t2; +# +# Bug mdev-4971: equality propagation after merging degenerate +# disjunction into embedding AND level +# +CREATE TABLE t1 (pk1 int, a1 int, b1 int, PRIMARY KEY(pk1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,10,100), (2,20,200) ; +CREATE TABLE t2 (pk2 int, a2 int, PRIMARY KEY(pk2)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1,1); +SELECT * FROM t1, t2 +WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); +pk1 a1 b1 pk2 a2 +EXPLAIN EXTENDED +SELECT * FROM t1, t2 +WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 system PRIMARY NULL NULL NULL 1 100.00 +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a1` = 1) and ((`test`.`t1`.`b1` = 6) or (1 > 4))) +INSERT INTO t1 VALUES (3,1,6); +SELECT * FROM t1, t2 +WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); +pk1 a1 b1 pk2 a2 +3 1 6 1 1 +DROP TABLE t1,t2; End of 5.3 tests set join_cache_level=default; show variables like 'join_cache_level'; diff --git a/mysql-test/r/select_pkeycache.result b/mysql-test/r/select_pkeycache.result index f5744c8e3d0..f0de9622368 100644 --- a/mysql-test/r/select_pkeycache.result +++ b/mysql-test/r/select_pkeycache.result @@ -5254,4 +5254,29 @@ SELECT * FROM t1, t2 WHERE i1 = i2 AND ( FALSE OR ( j1 > 27 AND j1 < 100 OR j1 <= 3 ) AND j1 = i2 ); i1 j1 i2 DROP TABLE t1,t2; +# +# Bug mdev-4971: equality propagation after merging degenerate +# disjunction into embedding AND level +# +CREATE TABLE t1 (pk1 int, a1 int, b1 int, PRIMARY KEY(pk1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,10,100), (2,20,200) ; +CREATE TABLE t2 (pk2 int, a2 int, PRIMARY KEY(pk2)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1,1); +SELECT * FROM t1, t2 +WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); +pk1 a1 b1 pk2 a2 +EXPLAIN EXTENDED +SELECT * FROM t1, t2 +WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 system PRIMARY NULL NULL NULL 1 100.00 +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`pk1` AS `pk1`,`test`.`t1`.`a1` AS `a1`,`test`.`t1`.`b1` AS `b1`,1 AS `pk2`,1 AS `a2` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`a1` = 1) and ((`test`.`t1`.`b1` = 6) or (1 > 4))) +INSERT INTO t1 VALUES (3,1,6); +SELECT * FROM t1, t2 +WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); +pk1 a1 b1 pk2 a2 +3 1 6 1 1 +DROP TABLE t1,t2; End of 5.3 tests diff --git a/mysql-test/r/subselect_sj2_mat.result b/mysql-test/r/subselect_sj2_mat.result index bf5b95d2d8f..18e3f6ddd34 100644 --- a/mysql-test/r/subselect_sj2_mat.result +++ b/mysql-test/r/subselect_sj2_mat.result @@ -1380,7 +1380,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00 Using where 2 MATERIALIZED t3 hash_ALL NULL #hash#$hj 5 test.t2.i2 3 100.00 Using where; Using join buffer (flat, BNLH join) Warnings: -Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i3` = `test`.`t2`.`i2`) and (`test`.`t1`.`i1` = `test`.`t2`.`i2`) and (`test`.`t3`.`i3` > 0)) +Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i3` = `test`.`t2`.`i2`) and (`test`.`t1`.`i1` = `test`.`t2`.`i2`) and (`test`.`t2`.`i2` > 0)) SELECT * FROM t1 WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 > 0 AND i3 = i2 OR 1=2); i1 diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index bb5a6b9c2fc..9081b93dbf8 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -4408,4 +4408,27 @@ SELECT * FROM t1, t2 DROP TABLE t1,t2; +--echo # +--echo # Bug mdev-4971: equality propagation after merging degenerate +--echo # disjunction into embedding AND level +--echo # + +CREATE TABLE t1 (pk1 int, a1 int, b1 int, PRIMARY KEY(pk1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,10,100), (2,20,200) ; + +CREATE TABLE t2 (pk2 int, a2 int, PRIMARY KEY(pk2)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1,1); + +SELECT * FROM t1, t2 + WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); +EXPLAIN EXTENDED +SELECT * FROM t1, t2 + WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); + +INSERT INTO t1 VALUES (3,1,6); +SELECT * FROM t1, t2 + WHERE a1 = pk2 AND ( ( b1 = 6 OR a2 > 4 ) AND pk2 = a2 OR pk1 IS NULL ); + +DROP TABLE t1,t2; + --echo End of 5.3 tests -- cgit v1.2.1 From 6755944d0876e15aab0d2d33e1d7db1327f0ef8f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 30 Aug 2013 11:25:49 +0200 Subject: remove PBXT --- mysql-test/include/have_pbxt.opt | 1 - mysql-test/r/information_schema.result | 2 +- mysql-test/std_data/pbxt_load_unique_error1.inc | 5 ----- .../engines/rr_trx/include/check_repeatable_read_all_columns.inc | 2 -- mysql-test/suite/engines/rr_trx/include/rr_init.test | 8 -------- mysql-test/suite/funcs_1/r/is_columns_is_embedded.result | 5 ----- mysql-test/suite/funcs_1/r/is_tables_is.result | 4 ++-- mysql-test/suite/funcs_1/r/is_tables_is_embedded.result | 4 ++-- mysql-test/suite/funcs_1/t/is_columns_is_embedded.test | 3 +-- mysql-test/suite/funcs_1/t/is_tables_is.test | 2 +- mysql-test/suite/funcs_1/t/is_tables_is_embedded.test | 2 +- mysql-test/t/information_schema.test | 2 +- mysql-test/t/mysqld--help.test | 2 +- 13 files changed, 10 insertions(+), 32 deletions(-) delete mode 100644 mysql-test/include/have_pbxt.opt delete mode 100644 mysql-test/std_data/pbxt_load_unique_error1.inc (limited to 'mysql-test') diff --git a/mysql-test/include/have_pbxt.opt b/mysql-test/include/have_pbxt.opt deleted file mode 100644 index 54ba9495053..00000000000 --- a/mysql-test/include/have_pbxt.opt +++ /dev/null @@ -1 +0,0 @@ ---loose-pbxt diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 98d16bf713c..93fc70caa2c 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -43,7 +43,7 @@ create view v1 (c) as SELECT table_name FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND table_name not like 'ndb_%' AND table_name not like 'innodb_%' AND -table_name not like 'pbxt_%' AND table_name not like 'xtradb_%'; +table_name not like 'xtradb_%'; select * from v1; c CHARACTER_SETS diff --git a/mysql-test/std_data/pbxt_load_unique_error1.inc b/mysql-test/std_data/pbxt_load_unique_error1.inc deleted file mode 100644 index 998daad4144..00000000000 --- a/mysql-test/std_data/pbxt_load_unique_error1.inc +++ /dev/null @@ -1,5 +0,0 @@ -1,abc -2,def -3,ghi -3,jkl -4,opq diff --git a/mysql-test/suite/engines/rr_trx/include/check_repeatable_read_all_columns.inc b/mysql-test/suite/engines/rr_trx/include/check_repeatable_read_all_columns.inc index 95bbc35de72..e8e21a6be7b 100644 --- a/mysql-test/suite/engines/rr_trx/include/check_repeatable_read_all_columns.inc +++ b/mysql-test/suite/engines/rr_trx/include/check_repeatable_read_all_columns.inc @@ -104,8 +104,6 @@ if (`SELECT IF($query_count > 1, 1, 0)`) # Detect extra rows: # Allow phantoms in some configurations: # - InnoDB default settings - # - Falcon's falcon_consistent_read=0 (non-default setting) - # (TODO: What about PBXT?) # ########################### # TODO: Execute a query against tmp1 and tmp2 which selects new rows (rows diff --git a/mysql-test/suite/engines/rr_trx/include/rr_init.test b/mysql-test/suite/engines/rr_trx/include/rr_init.test index b98905791b0..05769bf70eb 100644 --- a/mysql-test/suite/engines/rr_trx/include/rr_init.test +++ b/mysql-test/suite/engines/rr_trx/include/rr_init.test @@ -13,14 +13,6 @@ if (`SELECT @@storage_engine LIKE 'InnoDB' AND @@version LIKE '%6.%'`) --enable_query_log } -if (`SELECT @@storage_engine LIKE 'PBXT' AND @@version LIKE '%5.1%'`) -{ - --disable_query_log - SET SESSION binlog_format = 'MIXED'; - SET GLOBAL binlog_format = 'MIXED'; - --enable_query_log -} - # Verify default storage engine. SHOW VARIABLES LIKE 'storage_engine'; diff --git a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result index f4ffdc6f4d8..b4cb99a6163 100644 --- a/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_columns_is_embedded.result @@ -1,7 +1,6 @@ SELECT * FROM information_schema.columns WHERE table_schema = 'information_schema' AND table_name <> 'profiling' AND table_name not like 'innodb_%' -AND table_name not like 'pbxt_%' ORDER BY table_schema, table_name, column_name; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION COLUMN_DEFAULT IS_NULLABLE DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH NUMERIC_PRECISION NUMERIC_SCALE DATETIME_PRECISION CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT def information_schema CHARACTER_SETS CHARACTER_SET_NAME 1 NO varchar 32 96 NULL NULL NULL utf8 utf8_general_ci varchar(32) @@ -422,7 +421,6 @@ COLLATION_NAME FROM information_schema.columns WHERE table_schema = 'information_schema' AND table_name <> 'profiling' AND table_name not like 'innodb_%' -AND table_name not like 'pbxt_%' AND CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH = 1 ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML; COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME @@ -435,7 +433,6 @@ COLLATION_NAME FROM information_schema.columns WHERE table_schema = 'information_schema' AND table_name <> 'profiling' AND table_name not like 'innodb_%' -AND table_name not like 'pbxt_%' AND CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH <> 1 ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML; COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME @@ -448,7 +445,6 @@ COLLATION_NAME FROM information_schema.columns WHERE table_schema = 'information_schema' AND table_name <> 'profiling' AND table_name not like 'innodb_%' -AND table_name not like 'pbxt_%' AND CHARACTER_OCTET_LENGTH / CHARACTER_MAXIMUM_LENGTH IS NULL ORDER BY CHARACTER_SET_NAME, COLLATION_NAME, COL_CML; COL_CML DATA_TYPE CHARACTER_SET_NAME COLLATION_NAME @@ -473,7 +469,6 @@ COLUMN_TYPE FROM information_schema.columns WHERE table_schema = 'information_schema' AND table_name <> 'profiling' AND table_name not like 'innodb_%' -AND table_name not like 'pbxt_%' ORDER BY TABLE_SCHEMA, TABLE_NAME, ORDINAL_POSITION; COL_CML TABLE_SCHEMA TABLE_NAME COLUMN_NAME DATA_TYPE CHARACTER_MAXIMUM_LENGTH CHARACTER_OCTET_LENGTH CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE 3.0000 information_schema CHARACTER_SETS CHARACTER_SET_NAME varchar 32 96 utf8 utf8_general_ci varchar(32) diff --git a/mysql-test/suite/funcs_1/r/is_tables_is.result b/mysql-test/suite/funcs_1/r/is_tables_is.result index 6aa2e3bb93d..6862260eaf5 100644 --- a/mysql-test/suite/funcs_1/r/is_tables_is.result +++ b/mysql-test/suite/funcs_1/r/is_tables_is.result @@ -12,7 +12,7 @@ AS "user_comment", FROM information_schema.tables WHERE table_schema = 'information_schema' AND table_name <> 'profiling' AND table_name not like 'innodb_%' -AND table_name not like 'pbxt_%' AND table_name not like 'xtradb_%' +AND table_name not like 'xtradb_%' ORDER BY table_schema,table_name; TABLE_CATALOG def TABLE_SCHEMA information_schema @@ -812,7 +812,7 @@ AS "user_comment", FROM information_schema.tables WHERE table_schema = 'information_schema' AND table_name <> 'profiling' AND table_name not like 'innodb_%' -AND table_name not like 'pbxt_%' AND table_name not like 'xtradb_%' +AND table_name not like 'xtradb_%' ORDER BY table_schema,table_name; TABLE_CATALOG def TABLE_SCHEMA information_schema diff --git a/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result b/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result index 6aa2e3bb93d..6862260eaf5 100644 --- a/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result +++ b/mysql-test/suite/funcs_1/r/is_tables_is_embedded.result @@ -12,7 +12,7 @@ AS "user_comment", FROM information_schema.tables WHERE table_schema = 'information_schema' AND table_name <> 'profiling' AND table_name not like 'innodb_%' -AND table_name not like 'pbxt_%' AND table_name not like 'xtradb_%' +AND table_name not like 'xtradb_%' ORDER BY table_schema,table_name; TABLE_CATALOG def TABLE_SCHEMA information_schema @@ -812,7 +812,7 @@ AS "user_comment", FROM information_schema.tables WHERE table_schema = 'information_schema' AND table_name <> 'profiling' AND table_name not like 'innodb_%' -AND table_name not like 'pbxt_%' AND table_name not like 'xtradb_%' +AND table_name not like 'xtradb_%' ORDER BY table_schema,table_name; TABLE_CATALOG def TABLE_SCHEMA information_schema diff --git a/mysql-test/suite/funcs_1/t/is_columns_is_embedded.test b/mysql-test/suite/funcs_1/t/is_columns_is_embedded.test index 330dfa20629..c0829ab2636 100644 --- a/mysql-test/suite/funcs_1/t/is_columns_is_embedded.test +++ b/mysql-test/suite/funcs_1/t/is_columns_is_embedded.test @@ -21,6 +21,5 @@ if (`SELECT VERSION() NOT LIKE '%embedded%'`) } let $my_where = WHERE table_schema = 'information_schema' -AND table_name <> 'profiling' AND table_name not like 'innodb_%' -AND table_name not like 'pbxt_%'; +AND table_name <> 'profiling' AND table_name not like 'innodb_%'; --source suite/funcs_1/datadict/columns.inc diff --git a/mysql-test/suite/funcs_1/t/is_tables_is.test b/mysql-test/suite/funcs_1/t/is_tables_is.test index 36a47047bb3..09f257ed11e 100644 --- a/mysql-test/suite/funcs_1/t/is_tables_is.test +++ b/mysql-test/suite/funcs_1/t/is_tables_is.test @@ -15,5 +15,5 @@ --source include/not_embedded.inc let $my_where = WHERE table_schema = 'information_schema' AND table_name <> 'profiling' AND table_name not like 'innodb_%' -AND table_name not like 'pbxt_%' AND table_name not like 'xtradb_%'; +AND table_name not like 'xtradb_%'; --source suite/funcs_1/datadict/tables1.inc diff --git a/mysql-test/suite/funcs_1/t/is_tables_is_embedded.test b/mysql-test/suite/funcs_1/t/is_tables_is_embedded.test index cb828a91f82..1d2a7d67602 100644 --- a/mysql-test/suite/funcs_1/t/is_tables_is_embedded.test +++ b/mysql-test/suite/funcs_1/t/is_tables_is_embedded.test @@ -19,5 +19,5 @@ if (`SELECT VERSION() NOT LIKE '%embedded%'`) } let $my_where = WHERE table_schema = 'information_schema' AND table_name <> 'profiling' AND table_name not like 'innodb_%' -AND table_name not like 'pbxt_%' AND table_name not like 'xtradb_%'; +AND table_name not like 'xtradb_%'; --source suite/funcs_1/datadict/tables1.inc diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index b6ee712ec28..8c88be5c603 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -51,7 +51,7 @@ create view v1 (c) as SELECT table_name FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND table_name not like 'ndb_%' AND table_name not like 'innodb_%' AND - table_name not like 'pbxt_%' AND table_name not like 'xtradb_%'; + table_name not like 'xtradb_%'; --sorted_result select * from v1; diff --git a/mysql-test/t/mysqld--help.test b/mysql-test/t/mysqld--help.test index 4b5572c2bbe..a41d79fa145 100644 --- a/mysql-test/t/mysqld--help.test +++ b/mysql-test/t/mysqld--help.test @@ -26,7 +26,7 @@ perl; @plugins=qw/innodb ndb archive blackhole federated partition ndbcluster feedback debug temp-pool ssl des-key-file xtradb thread-concurrency super-large-pages - mutex-deadlock-detector null-audit maria aria pbxt oqgraph + mutex-deadlock-detector null-audit maria aria oqgraph sphinx thread-handling thread-pool query-cache-info/; # And substitute the content some environment variables with their -- cgit v1.2.1 From bbc9e57981d8aa420d7bcf58e3fb2d7c1bf25ca9 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 6 Sep 2013 15:59:19 +0400 Subject: MDEV-4978 - Server cursor is broken with blobs in the select list, ORDER BY does not work Use "dynamic" row format (instead of "block") for MARIA internal temporary tables created for cursors. With "block" row format MARIA may shuffle rows, with "dynamic" row format records are inserted sequentially (there are no gaps in data file while we fill temporary tables). This is needed to preserve row order when scanning materialized cursors. --- mysql-test/r/sp.result | 39 +++++++++++++++++++++++++++++++++++++++ mysql-test/t/sp.test | 31 +++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index a0f21b434d1..962b834e4ac 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -7977,4 +7977,43 @@ Warning 1329 No data - zero rows fetched, selected, or processed drop procedure p1; drop procedure p2; drop table t1; +# +# MDEV-4978 - Server cursor is broken with blobs in the select list, +# ORDER BY does not work +# +CREATE TABLE t1(a INT, b BLOB); +INSERT INTO t1 VALUES(1,REPEAT('a',4835)),(2,'b'),(3,'c'),(4,'d'),(5,REPEAT('e',805)),(6,'f'); +CREATE PROCEDURE p1() +BEGIN +DECLARE done INT DEFAULT 0; +DECLARE v1 INT; +DECLARE v2 BLOB; +DECLARE c1 CURSOR FOR SELECT * FROM t1 ORDER BY a; +DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done=1; +OPEN c1; +REPEAT +FETCH c1 INTO v1, v2; +IF NOT done THEN +SELECT v1; +END IF; +UNTIL done END REPEAT; +CLOSE c1; +END| +CALL p1; +v1 +1 +v1 +2 +v1 +3 +v1 +4 +v1 +5 +v1 +6 +Warnings: +Error 1329 No data - zero rows fetched, selected, or processed +DROP PROCEDURE p1; +DROP TABLE t1; # End of 5.5 test diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 3590dc66187..ecb12408654 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -9271,4 +9271,35 @@ drop procedure p2; drop table t1; +--echo # +--echo # MDEV-4978 - Server cursor is broken with blobs in the select list, +--echo # ORDER BY does not work +--echo # +CREATE TABLE t1(a INT, b BLOB); +INSERT INTO t1 VALUES(1,REPEAT('a',4835)),(2,'b'),(3,'c'),(4,'d'),(5,REPEAT('e',805)),(6,'f'); + +DELIMITER |; +CREATE PROCEDURE p1() +BEGIN + DECLARE done INT DEFAULT 0; + DECLARE v1 INT; + DECLARE v2 BLOB; + DECLARE c1 CURSOR FOR SELECT * FROM t1 ORDER BY a; + DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done=1; + OPEN c1; + REPEAT + FETCH c1 INTO v1, v2; + IF NOT done THEN + SELECT v1; + END IF; + UNTIL done END REPEAT; + CLOSE c1; +END| +DELIMITER ;| + +CALL p1; + +DROP PROCEDURE p1; +DROP TABLE t1; + --echo # End of 5.5 test -- cgit v1.2.1 From 02338228dd48752a48d611b03ce35efd35d143d7 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Fri, 6 Sep 2013 09:55:32 -0700 Subject: Fixed bug mdev-4996. The fix for bug mdev-4971 not always correctly set the pointers to inherited multiple equalities in objects of the Item_equal class. --- mysql-test/r/subselect2.result | 28 ++++++++++++++++++++++++++++ mysql-test/r/subselect_sj2_mat.result | 2 +- mysql-test/t/subselect2.test | 23 +++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) (limited to 'mysql-test') diff --git a/mysql-test/r/subselect2.result b/mysql-test/r/subselect2.result index a7689c37a0a..2c482408c2b 100644 --- a/mysql-test/r/subselect2.result +++ b/mysql-test/r/subselect2.result @@ -198,4 +198,32 @@ a b 1 1 1 3 DROP TABLE t1, t2, t3; +# +# MDEV-4996: degenerate OR formula in WHERE of a subquery +# +CREATE TABLE t1 (a int, c1 varchar(1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (2,'x'), (8,'d'); +CREATE TABLE t2 (m int, n int, c2 varchar(1)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (0, 5, 'x'), (1, 4,'p'); +SELECT * FROM t1 WHERE c1 NOT IN ( +SELECT t2a.c2 FROM t2 AS t2a, t2 AS t2b, t2 AS t2c +WHERE t2c.c2 = t2b.c2 AND ( t2a.m = t2b.n OR 0 ) AND +( t2b.m != a OR t2b.m = t2a.m )); +a c1 +2 x +8 d +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE c1 NOT IN ( +SELECT t2a.c2 FROM t2 AS t2a, t2 AS t2b, t2 AS t2c +WHERE t2c.c2 = t2b.c2 AND ( t2a.m = t2b.n OR 0 ) AND +( t2b.m != a OR t2b.m = t2a.m )); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY t2a ALL NULL NULL NULL NULL 2 100.00 Using where +2 DEPENDENT SUBQUERY t2b ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY t2c ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where (not(<`test`.`t1`.`c1`,`test`.`t1`.`a`>((`test`.`t1`.`c1`,(select `test`.`t2a`.`c2` from `test`.`t2` `t2a` join `test`.`t2` `t2b` join `test`.`t2` `t2c` where (((`test`.`t2b`.`m` <> `test`.`t1`.`a`) or (`test`.`t2b`.`m` = `test`.`t2a`.`m`)) and trigcond((((`test`.`t1`.`c1`) = `test`.`t2a`.`c2`) or isnull(`test`.`t2a`.`c2`))) and (`test`.`t2c`.`c2` = `test`.`t2b`.`c2`) and (`test`.`t2b`.`n` = `test`.`t2a`.`m`)) having trigcond((`test`.`t2a`.`c2`))))))) +DROP TABLE t1,t2; set optimizer_switch=@subselect2_test_tmp; diff --git a/mysql-test/r/subselect_sj2_mat.result b/mysql-test/r/subselect_sj2_mat.result index 18e3f6ddd34..bf5b95d2d8f 100644 --- a/mysql-test/r/subselect_sj2_mat.result +++ b/mysql-test/r/subselect_sj2_mat.result @@ -1380,7 +1380,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00 Using where 2 MATERIALIZED t3 hash_ALL NULL #hash#$hj 5 test.t2.i2 3 100.00 Using where; Using join buffer (flat, BNLH join) Warnings: -Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i3` = `test`.`t2`.`i2`) and (`test`.`t1`.`i1` = `test`.`t2`.`i2`) and (`test`.`t2`.`i2` > 0)) +Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where ((`test`.`t3`.`i3` = `test`.`t2`.`i2`) and (`test`.`t1`.`i1` = `test`.`t2`.`i2`) and (`test`.`t3`.`i3` > 0)) SELECT * FROM t1 WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 > 0 AND i3 = i2 OR 1=2); i1 diff --git a/mysql-test/t/subselect2.test b/mysql-test/t/subselect2.test index 75cf842fbdb..5d39499d36b 100644 --- a/mysql-test/t/subselect2.test +++ b/mysql-test/t/subselect2.test @@ -222,5 +222,28 @@ SELECT * FROM t3 GROUP BY t1.b); DROP TABLE t1, t2, t3; +--echo # +--echo # MDEV-4996: degenerate OR formula in WHERE of a subquery +--echo # + +CREATE TABLE t1 (a int, c1 varchar(1)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (2,'x'), (8,'d'); + +CREATE TABLE t2 (m int, n int, c2 varchar(1)) ENGINE=MyISAM; +INSERT INTO t2 VALUES (0, 5, 'x'), (1, 4,'p'); + +SELECT * FROM t1 WHERE c1 NOT IN ( + SELECT t2a.c2 FROM t2 AS t2a, t2 AS t2b, t2 AS t2c + WHERE t2c.c2 = t2b.c2 AND ( t2a.m = t2b.n OR 0 ) AND + ( t2b.m != a OR t2b.m = t2a.m )); + +EXPLAIN EXTENDED +SELECT * FROM t1 WHERE c1 NOT IN ( + SELECT t2a.c2 FROM t2 AS t2a, t2 AS t2b, t2 AS t2c + WHERE t2c.c2 = t2b.c2 AND ( t2a.m = t2b.n OR 0 ) AND + ( t2b.m != a OR t2b.m = t2a.m )); + +DROP TABLE t1,t2; + set optimizer_switch=@subselect2_test_tmp; -- cgit v1.2.1 From c2b38529a9ca2ea09dfa73186d9350a0d6dcd6ac Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 9 Sep 2013 15:32:25 +0400 Subject: MDEV-4863 COALESCE(time_or_datetime) returns wrong results in numeric context --- mysql-test/r/func_time.result | 109 ++++++++++++++++++++++++++++++++++++++ mysql-test/r/type_datetime.result | 9 +--- mysql-test/t/func_time.test | 93 ++++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+), 7 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 88599b79a1f..8bbc692aa4a 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -1923,3 +1923,112 @@ NULL Warnings: Error 1411 Incorrect datetime value: '2020' for function str_to_date SET TIME_ZONE=DEFAULT; +# +# MDEV-4863 COALESCE(time_or_datetime) returns wrong results in numeric context +# +CREATE TABLE t1 (a TIMESTAMP(3)); +INSERT INTO t1 VALUES ('2001-01-01 10:20:30.999'); +SELECT CAST(COALESCE(a,a) AS SIGNED) AS c1, CAST(COALESCE(a,a) AS DECIMAL(25,3)) AS c2, ROUND(COALESCE(a,a)) AS c2 FROM t1; +c1 c2 c2 +20010101102030 20010101102030.999 20010101102031 +DROP TABLE t1; +CREATE TABLE t1 (a TIME(3)); +INSERT INTO t1 VALUES ('10:20:30.999'); +SELECT CAST(COALESCE(a,a) AS SIGNED) AS c1, CAST(COALESCE(a,a) AS DECIMAL(25,3)) AS c2, ROUND(COALESCE(a,a)) AS c2 FROM t1; +c1 c2 c2 +102030 102030.999 102031 +DROP TABLE t1; +SELECT +CAST(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1, +CAST(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2, +COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3, +CONCAT(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4, +TIME(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5, +DATE(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6, +TIMESTAMP(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7; +c1 c2 c3 c4 c5 c6 c7 +20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00.000000 00:00:00.000000 2001-01-01 2001-01-01 00:00:00.000000 +SELECT +CAST(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS SIGNED) AS c1, +CAST(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS DECIMAL(25,4)) AS c2, +COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))+0e0 AS c3, +CONCAT(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c4, +TIME(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c5, +DATE(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c6, +TIMESTAMP(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c7; +c1 c2 c3 c4 c5 c6 c7 +20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30.000000 10:20:30.000000 2001-01-02 2001-01-02 10:20:30.000000 +SELECT +CAST(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1, +CAST(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2, +IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3, +CONCAT(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4, +TIME(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5, +DATE(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6, +TIMESTAMP(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7; +c1 c2 c3 c4 c5 c6 c7 +20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00.000000 00:00:00.000000 2001-01-01 2001-01-01 00:00:00.000000 +SELECT +CAST(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS SIGNED) AS c1, +CAST(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS DECIMAL(25,4)) AS c2, +IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))+0e0 AS c3, +CONCAT(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c4, +TIME(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c5, +DATE(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c6, +TIMESTAMP(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c7; +c1 c2 c3 c4 c5 c6 c7 +20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30.000000 10:20:30.000000 2001-01-02 2001-01-02 10:20:30.000000 +SELECT +CAST(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1, +CAST(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2, +IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3, +CONCAT(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4, +TIME(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5, +DATE(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6, +TIMESTAMP(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7; +c1 c2 c3 c4 c5 c6 c7 +20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00.000000 00:00:00.000000 2001-01-01 2001-01-01 00:00:00.000000 +SELECT +CAST(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1, +CAST(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2, +IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3, +CONCAT(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4, +TIME(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5, +DATE(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6, +TIMESTAMP(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7; +c1 c2 c3 c4 c5 c6 c7 +20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30.000000 10:20:30.000000 2001-01-02 2001-01-02 10:20:30.000000 +SELECT +CAST(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS SIGNED) AS c1, +CAST(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS DECIMAL(25,4)) AS c2, +CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END+0e0 AS c3, +CONCAT(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c4, +TIME(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c5, +DATE(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c6, +TIMESTAMP(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c7; +c1 c2 c3 c4 c5 c6 c7 +20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00.000000 00:00:00.000000 2001-01-01 2001-01-01 00:00:00.000000 +SELECT +CAST(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS SIGNED) AS c1, +CAST(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS DECIMAL(25,4)) AS c2, +CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END+0e0 AS c3, +CONCAT(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c4, +TIME(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c5, +DATE(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c6, +TIMESTAMP(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c7; +c1 c2 c3 c4 c5 c6 c7 +20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30.000000 10:20:30.000000 2001-01-02 2001-01-02 10:20:30.000000 +CREATE TABLE t1 AS SELECT +CONCAT(COALESCE(TIME(101010),TIME(101010))) AS c1, +CONCAT(IF(0,TIME(101010),TIME(101010))) AS c2, +CONCAT(IFNULL(TIME(101010),TIME(101010))) AS c3, +CONCAT(CASE WHEN 1 THEN TIME(101010) ELSE TIME(101010) END) AS c4; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `c1` varbinary(10) DEFAULT NULL, + `c2` varbinary(10) DEFAULT NULL, + `c3` varbinary(10) DEFAULT NULL, + `c4` varbinary(10) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1; diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 286a84c56e7..de0bc2a0b80 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -657,13 +657,8 @@ create table t1 (d date, t time) engine=myisam; insert into t1 values ('2000-12-03','22:55:23'),('2008-05-03','10:19:31'); select case when d = '2012-12-12' then d else t end as cond, group_concat( d ) from t1 group by cond; cond group_concat( d ) -NULL 2000-12-03 -NULL 2008-05-03 -Warnings: -Warning 1292 Incorrect datetime value: '22:55:23' -Warning 1292 Incorrect datetime value: '10:19:31' -Warning 1292 Incorrect datetime value: '22:55:23' -Warning 1292 Incorrect datetime value: '10:19:31' +0000-00-00 10:19:31 2008-05-03 +0000-00-00 22:55:23 2000-12-03 drop table t1; # # Semantics of the condition IS NULL diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index ff2216802bf..6aedf3f55df 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1162,3 +1162,96 @@ SELECT 1 FROM DUAL WHERE SECOND(TIMEDIFF(NULL, '12:12:12')); SET TIME_ZONE='+02:00'; SELECT UNIX_TIMESTAMP(STR_TO_DATE('2020','%Y')); SET TIME_ZONE=DEFAULT; + + +--echo # +--echo # MDEV-4863 COALESCE(time_or_datetime) returns wrong results in numeric context +--echo # +CREATE TABLE t1 (a TIMESTAMP(3)); +INSERT INTO t1 VALUES ('2001-01-01 10:20:30.999'); +SELECT CAST(COALESCE(a,a) AS SIGNED) AS c1, CAST(COALESCE(a,a) AS DECIMAL(25,3)) AS c2, ROUND(COALESCE(a,a)) AS c2 FROM t1; +DROP TABLE t1; +CREATE TABLE t1 (a TIME(3)); +INSERT INTO t1 VALUES ('10:20:30.999'); +SELECT CAST(COALESCE(a,a) AS SIGNED) AS c1, CAST(COALESCE(a,a) AS DECIMAL(25,3)) AS c2, ROUND(COALESCE(a,a)) AS c2 FROM t1; +DROP TABLE t1; + +SELECT + CAST(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1, + CAST(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2, + COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3, + CONCAT(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4, + TIME(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5, + DATE(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6, + TIMESTAMP(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7; + +SELECT + CAST(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS SIGNED) AS c1, + CAST(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS DECIMAL(25,4)) AS c2, + COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))+0e0 AS c3, + CONCAT(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c4, + TIME(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c5, + DATE(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c6, + TIMESTAMP(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c7; + +SELECT + CAST(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1, + CAST(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2, + IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3, + CONCAT(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4, + TIME(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5, + DATE(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6, + TIMESTAMP(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7; + +SELECT + CAST(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS SIGNED) AS c1, + CAST(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS DECIMAL(25,4)) AS c2, + IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))+0e0 AS c3, + CONCAT(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c4, + TIME(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c5, + DATE(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c6, + TIMESTAMP(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c7; + +SELECT + CAST(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1, + CAST(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2, + IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3, + CONCAT(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4, + TIME(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5, + DATE(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6, + TIMESTAMP(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7; + +SELECT + CAST(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1, + CAST(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2, + IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))+0e0 AS c3, + CONCAT(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c4, + TIME(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5, + DATE(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6, + TIMESTAMP(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7; + +SELECT + CAST(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS SIGNED) AS c1, + CAST(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS DECIMAL(25,4)) AS c2, + CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END+0e0 AS c3, + CONCAT(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c4, + TIME(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c5, + DATE(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c6, + TIMESTAMP(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c7; + +SELECT + CAST(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS SIGNED) AS c1, + CAST(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS DECIMAL(25,4)) AS c2, + CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END+0e0 AS c3, + CONCAT(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c4, + TIME(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c5, + DATE(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c6, + TIMESTAMP(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c7; + +CREATE TABLE t1 AS SELECT + CONCAT(COALESCE(TIME(101010),TIME(101010))) AS c1, + CONCAT(IF(0,TIME(101010),TIME(101010))) AS c2, + CONCAT(IFNULL(TIME(101010),TIME(101010))) AS c3, + CONCAT(CASE WHEN 1 THEN TIME(101010) ELSE TIME(101010) END) AS c4; +SHOW CREATE TABLE t1; +DROP TABLE t1; -- cgit v1.2.1 From c03f0cf28c039414281547328a369a10728f2500 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 9 Sep 2013 14:00:40 +0200 Subject: fixes for out-of-source builds mysql-test/CMakeLists.txt: don't generate collection fules. we don't use them and they break out-of-source builds --- mysql-test/CMakeLists.txt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/CMakeLists.txt b/mysql-test/CMakeLists.txt index c0ee12fbd23..5ffbd78316c 100644 --- a/mysql-test/CMakeLists.txt +++ b/mysql-test/CMakeLists.txt @@ -151,13 +151,13 @@ MACRO(PROCESS_COLLECTION_INCLUDE collin collection) ENDFOREACH() ENDMACRO() -FILE(GLOB infiles "collections/*.in") -FOREACH(collin ${infiles}) - STRING(REPLACE ".in" "" collection ${collin}) - STRING(REPLACE ".in" ".done" colldone ${collin}) - # Only generate file once - IF(NOT EXISTS ${colldone}) - PROCESS_COLLECTION_INCLUDE(${collin} ${collection}) - FILE(APPEND ${colldone} "${collin}\n") - ENDIF() -ENDFOREACH() +#FILE(GLOB infiles "collections/*.in") +#FOREACH(collin ${infiles}) +# STRING(REPLACE ".in" "" collection ${collin}) +# STRING(REPLACE ".in" ".done" colldone ${collin}) +# # Only generate file once +# IF(NOT EXISTS ${colldone}) +# PROCESS_COLLECTION_INCLUDE(${collin} ${collection}) +# FILE(APPEND ${colldone} "${collin}\n") +# ENDIF() +#ENDFOREACH() -- cgit v1.2.1 From 0e1070125f8fb2ffeba985345b001b3ca436bd44 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 10 Sep 2013 11:04:14 +0200 Subject: fix insert.test in --ps-protocol. After MDEV-4817, WHERE clause may be evaluated early, in fix_fields. In ps-protocol fix_fields happens both for prepare and execute phase, generating double the number of warnings from the early WHERE clause executions. --- mysql-test/t/insert.test | 2 ++ 1 file changed, 2 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index 22b5ff9127c..f9b9fcf266d 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -518,7 +518,9 @@ set sql_mode='error_for_division_by_zero'; --echo # --enable_info insert t1 (data) values ('letter'), (1/0); +--disable_ps_protocol update t1 set data='envelope' where 1/0 or 1; +--enable_ps_protocol insert t1 (data) values (default), (1/0), ('dead beef'); --disable_info -- cgit v1.2.1 From 6ee207a515de8dd74cf071cac20abe13d7d83d88 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 11 Sep 2013 15:35:49 +0200 Subject: support ./mtr suite.test,com,bi,na,tions syntax --- mysql-test/lib/mtr_cases.pm | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/lib/mtr_cases.pm b/mysql-test/lib/mtr_cases.pm index a82e3ee10b7..1327afdb426 100644 --- a/mysql-test/lib/mtr_cases.pm +++ b/mysql-test/lib/mtr_cases.pm @@ -117,7 +117,7 @@ sub collect_test_cases ($$$$) { if ( @$opt_cases ) { # A list of tests was specified on the command line - # Check that the tests specified was found + # Check that the tests specified were found # in at least one suite foreach my $test_name_spec ( @$opt_cases ) { @@ -189,30 +189,33 @@ sub collect_test_cases ($$$$) { } -# Returns (suitename, testname) +# Returns (suitename, testname, combinations....) sub split_testname { my ($test_name)= @_; # If .test file name is used, get rid of directory part $test_name= basename($test_name) if $test_name =~ /\.test$/; + # Then, get the combinations: + my ($test_name, @combs) = split /,/, $test_name; + # Now split name on .'s my @parts= split(/\./, $test_name); if (@parts == 1){ # Only testname given, ex: alias - return (undef , $parts[0]); + return (undef , $parts[0], @combs); } elsif (@parts == 2) { # Either testname.test or suite.testname given # Ex. main.alias or alias.test if ($parts[1] eq "test") { - return (undef , $parts[0]); + return (undef , $parts[0], @combs); } else { - return ($parts[0], $parts[1]); + return ($parts[0], $parts[1], @combs); } } @@ -499,14 +502,14 @@ sub process_suite { # Collect in specified order foreach my $test_name_spec ( @$opt_cases ) { - my ($sname, $tname)= split_testname($test_name_spec); + my ($sname, $tname, @combs)= split_testname($test_name_spec); # Check correct suite if suitename is defined next if defined $sname and $sname ne $suitename and $sname ne "$basename-"; next unless $all_cases{$tname}; - push @cases, collect_one_test_case($suite, $all_cases{$tname}, $tname); + push @cases, collect_one_test_case($suite, $all_cases{$tname}, $tname, @combs); } } else { for (sort keys %all_cases) @@ -559,9 +562,9 @@ sub process_opts { } } -sub make_combinations($@) +sub make_combinations($$@) { - my ($test, @combinations) = @_; + my ($test, $test_combs, @combinations) = @_; return ($test) if $test->{'skip'} or not @combinations; if ($combinations[0]->{skip}) { @@ -578,11 +581,19 @@ sub make_combinations($@) if (My::Options::is_set($test->{master_opt}, $comb->{comb_opt}) && My::Options::is_set($test->{slave_opt}, $comb->{comb_opt}) ){ + delete $test_combs->{$comb->{name}}; + # Add combination name short name push @{$test->{combinations}}, $comb->{name}; return ($test); } + + # Skip all other combinations, if this combination is forced + if (delete $test_combs->{$comb->{name}}) { + @combinations = ($comb); # run the loop below only for this combination + last; + } } my @cases; @@ -635,6 +646,8 @@ sub collect_one_test_case { my $suite = shift; my $tpath = shift; my $tname = shift; + my %test_combs = map { $_ => 1 } @_; + my $suitename = $suite->{name}; my $name = "$suitename.$tname"; @@ -829,7 +842,11 @@ sub collect_one_test_case { my @cases = ($tinfo); for my $comb ($suite->{combinations}, @{$file_combinations{$filename}}) { - @cases = map make_combinations($_, @{$comb}), @cases; + @cases = map make_combinations($_, \%test_combs, @{$comb}), @cases; + } + if (keys %test_combs) { + mtr_error("Could not run $name with '".( + join(',', sort keys %test_combs))."' combination(s)"); } for $tinfo (@cases) { -- cgit v1.2.1 From 7e4845beea1a86dc53dc67908a2779ea2f0190a2 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Thu, 12 Sep 2013 13:53:13 +0400 Subject: MDEV-5011: ERROR Plugin 'MEMORY' has ref_count=1 after shutdown for SJM queries - Provide a special execution path for cleanup of degenerate non-merged semi-join children of degenerate selects. --- mysql-test/r/subselect_mat.result | 8 ++++++++ mysql-test/r/subselect_sj_mat.result | 8 ++++++++ mysql-test/t/subselect_sj_mat.test | 8 ++++++++ 3 files changed, 24 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/subselect_mat.result b/mysql-test/r/subselect_mat.result index f5cce0e2d88..66b94af5d44 100644 --- a/mysql-test/r/subselect_mat.result +++ b/mysql-test/r/subselect_mat.result @@ -2015,6 +2015,14 @@ SELECT * FROM t1 WHERE 8 IN ( SELECT MIN(pk) FROM t1 ) AND ( pk = a OR pk = b ); pk a b drop table t1; SET optimizer_switch=@save_optimizer_switch; +# +# MDEV-5011: ERROR Plugin 'MEMORY' has ref_count=1 after shutdown for SJM queries +# +CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,3,5),(2,4,6); +SELECT * FROM t1 WHERE 8 IN (SELECT MIN(pk) FROM t1) AND (pk = a OR pk = b); +pk a b +DROP TABLE t1; # End of 5.3 tests set @subselect_mat_test_optimizer_switch_value=null; set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off'; diff --git a/mysql-test/r/subselect_sj_mat.result b/mysql-test/r/subselect_sj_mat.result index fb7fdb0e8f0..61ebe3cf5c3 100644 --- a/mysql-test/r/subselect_sj_mat.result +++ b/mysql-test/r/subselect_sj_mat.result @@ -2055,4 +2055,12 @@ SELECT * FROM t1 WHERE 8 IN ( SELECT MIN(pk) FROM t1 ) AND ( pk = a OR pk = b ); pk a b drop table t1; SET optimizer_switch=@save_optimizer_switch; +# +# MDEV-5011: ERROR Plugin 'MEMORY' has ref_count=1 after shutdown for SJM queries +# +CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,3,5),(2,4,6); +SELECT * FROM t1 WHERE 8 IN (SELECT MIN(pk) FROM t1) AND (pk = a OR pk = b); +pk a b +DROP TABLE t1; # End of 5.3 tests diff --git a/mysql-test/t/subselect_sj_mat.test b/mysql-test/t/subselect_sj_mat.test index d0ab2f5e300..840e5436a56 100644 --- a/mysql-test/t/subselect_sj_mat.test +++ b/mysql-test/t/subselect_sj_mat.test @@ -1698,4 +1698,12 @@ SELECT * FROM t1 WHERE 8 IN ( SELECT MIN(pk) FROM t1 ) AND ( pk = a OR pk = b ); drop table t1; SET optimizer_switch=@save_optimizer_switch; +--echo # +--echo # MDEV-5011: ERROR Plugin 'MEMORY' has ref_count=1 after shutdown for SJM queries +--echo # +CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,3,5),(2,4,6); +SELECT * FROM t1 WHERE 8 IN (SELECT MIN(pk) FROM t1) AND (pk = a OR pk = b); +DROP TABLE t1; + --echo # End of 5.3 tests -- cgit v1.2.1 From 1a01e3b959102402de1547fb2c7b912269032882 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Sep 2013 17:05:29 +0300 Subject: MDEV-5005: Subquery in Procedure somehow affecting temporary table Removed unneeded set of TABLE_LIST::skip_temporary flag. --- mysql-test/r/derived.result | 23 +++++++++++++++++++++++ mysql-test/t/derived.test | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index a9247ff41bf..1042ee79e8c 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -416,4 +416,27 @@ MIN(i) 1 DROP TABLE t1; # End of 5.0 tests +# +# MDEV-5005: Subquery in Procedure somehow affecting temporary table +# +create temporary table if not exists t1 (id int not null); +select A.* from ( select tt.* from t1 tt ) A; +id +prepare stmt from "select A.* from ( select tt.* from t1 tt ) A "; +execute stmt; +id +deallocate prepare stmt; +drop temporary table t1; +CREATE PROCEDURE p () +BEGIN +select A.* from ( select tt.* from t1 tt ) A ; +END | +create temporary table if not exists t1 (id int not null); +CALL p(); +id +CALL p(); +id +drop procedure p; +drop temporary table t1; +# End of 5.3 tests set optimizer_switch=@save_derived_optimizer_switch; diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index 7defc55b473..b0db0e8100a 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -320,4 +320,36 @@ DROP TABLE t1; --echo # End of 5.0 tests +--echo # +--echo # MDEV-5005: Subquery in Procedure somehow affecting temporary table +--echo # + +create temporary table if not exists t1 (id int not null); + +select A.* from ( select tt.* from t1 tt ) A; + +prepare stmt from "select A.* from ( select tt.* from t1 tt ) A "; +execute stmt; +deallocate prepare stmt; + +drop temporary table t1; + +--delimiter | +CREATE PROCEDURE p () +BEGIN + select A.* from ( select tt.* from t1 tt ) A ; +END | +--delimiter ; + +create temporary table if not exists t1 (id int not null); + +CALL p(); +CALL p(); + +drop procedure p; + +drop temporary table t1; + +--echo # End of 5.3 tests + set optimizer_switch=@save_derived_optimizer_switch; -- cgit v1.2.1 From 499ddea5766d988adc858448c8eec549c7bedcc1 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 12 Sep 2013 21:31:14 +0400 Subject: MDEV-4724 Some temporal functions do not preserve microseconds --- mysql-test/r/date_formats.result | 108 +++++++++---------- mysql-test/r/func_sapdb.result | 6 +- mysql-test/r/func_time.result | 175 ++++++++++++++++++++++++++++--- mysql-test/r/func_time_hires.result | 20 ++-- mysql-test/r/ps_2myisam.result | 12 +-- mysql-test/r/ps_3innodb.result | 12 +-- mysql-test/r/ps_4heap.result | 12 +-- mysql-test/r/ps_5merge.result | 24 ++--- mysql-test/r/timezone.result | 4 +- mysql-test/r/timezone4.result | 2 +- mysql-test/r/type_time.result | 4 +- mysql-test/suite/maria/r/ps_maria.result | 12 +-- mysql-test/t/func_time.test | 66 ++++++++++++ 13 files changed, 334 insertions(+), 123 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index dd346cb94dc..88255a06adb 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -257,70 +257,70 @@ Tuesday 52 2001 %W %V %X 2002-01-01 15-2001-1 %d-%Y-%c 2001-01-15 select date,format,TIME(str_to_date(date, format)) as time from t1; date format time -2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12 -03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02 -0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02 -03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02 -2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12 +2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12.000000 +03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02.000000 +0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02.000000 +03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02.000000 +2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12.000000 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450 -2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12 -10:20:10 %H:%i:%s 10:20:10 -10:20:10 %h:%i:%s.%f 10:20:10 -10:20:10 %T 10:20:10 -10:20:10AM %h:%i:%s%p 10:20:10 -10:20:10AM %r 10:20:10 +2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12.000000 +10:20:10 %H:%i:%s 10:20:10.000000 +10:20:10 %h:%i:%s.%f 10:20:10.000000 +10:20:10 %T 10:20:10.000000 +10:20:10AM %h:%i:%s%p 10:20:10.000000 +10:20:10AM %r 10:20:10.000000 10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000 -15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58 -15 September 2001 %d %M %Y 00:00:00 -15 SEPTEMB 2001 %d %M %Y 00:00:00 -15 MAY 2001 %d %b %Y 00:00:00 -15th May 2001 %D %b %Y 00:00:00 -Sunday 15 MAY 2001 %W %d %b %Y 00:00:00 -Sund 15 MAY 2001 %W %d %b %Y 00:00:00 -Tuesday 00 2002 %W %U %Y 00:00:00 -Thursday 53 1998 %W %u %Y 00:00:00 -Sunday 01 2001 %W %v %x 00:00:00 -Tuesday 52 2001 %W %V %X 00:00:00 -060 2004 %j %Y 00:00:00 -4 53 1998 %w %u %Y 00:00:00 -15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00 -15-01-20 %d-%m-%y 00:00:00 -15-2001-1 %d-%Y-%c 00:00:00 +15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58.000000 +15 September 2001 %d %M %Y 00:00:00.000000 +15 SEPTEMB 2001 %d %M %Y 00:00:00.000000 +15 MAY 2001 %d %b %Y 00:00:00.000000 +15th May 2001 %D %b %Y 00:00:00.000000 +Sunday 15 MAY 2001 %W %d %b %Y 00:00:00.000000 +Sund 15 MAY 2001 %W %d %b %Y 00:00:00.000000 +Tuesday 00 2002 %W %U %Y 00:00:00.000000 +Thursday 53 1998 %W %u %Y 00:00:00.000000 +Sunday 01 2001 %W %v %x 00:00:00.000000 +Tuesday 52 2001 %W %V %X 00:00:00.000000 +060 2004 %j %Y 00:00:00.000000 +4 53 1998 %w %u %Y 00:00:00.000000 +15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00.000000 +15-01-20 %d-%m-%y 00:00:00.000000 +15-2001-1 %d-%Y-%c 00:00:00.000000 select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1; date format time2 -2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12 -03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02 -0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02 -03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02 -2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12 +2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12.000000 +03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02.000000 +0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02.000000 +03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02.000000 +2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12.000000 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450 -2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12 -10:20:10 %H:%i:%s 10:20:10 -10:20:10 %h:%i:%s.%f 10:20:10 -10:20:10 %T 10:20:10 -10:20:10AM %h:%i:%s%p 10:20:10 -10:20:10AM %r 10:20:10 +2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12.000000 +10:20:10 %H:%i:%s 10:20:10.000000 +10:20:10 %h:%i:%s.%f 10:20:10.000000 +10:20:10 %T 10:20:10.000000 +10:20:10AM %h:%i:%s%p 10:20:10.000000 +10:20:10AM %r 10:20:10.000000 10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000 -15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58 -15 September 2001 %d %M %Y 00:00:00 -15 SEPTEMB 2001 %d %M %Y 00:00:00 -15 MAY 2001 %d %b %Y 00:00:00 -15th May 2001 %D %b %Y 00:00:00 -Sunday 15 MAY 2001 %W %d %b %Y 00:00:00 -Sund 15 MAY 2001 %W %d %b %Y 00:00:00 -Tuesday 00 2002 %W %U %Y 00:00:00 -Thursday 53 1998 %W %u %Y 00:00:00 -Sunday 01 2001 %W %v %x 00:00:00 -Tuesday 52 2001 %W %V %X 00:00:00 -060 2004 %j %Y 00:00:00 -4 53 1998 %w %u %Y 00:00:00 -15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00 -15-01-20 %d-%m-%y 00:00:00 -15-2001-1 %d-%Y-%c 00:00:00 +15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58.000000 +15 September 2001 %d %M %Y 00:00:00.000000 +15 SEPTEMB 2001 %d %M %Y 00:00:00.000000 +15 MAY 2001 %d %b %Y 00:00:00.000000 +15th May 2001 %D %b %Y 00:00:00.000000 +Sunday 15 MAY 2001 %W %d %b %Y 00:00:00.000000 +Sund 15 MAY 2001 %W %d %b %Y 00:00:00.000000 +Tuesday 00 2002 %W %U %Y 00:00:00.000000 +Thursday 53 1998 %W %u %Y 00:00:00.000000 +Sunday 01 2001 %W %v %x 00:00:00.000000 +Tuesday 52 2001 %W %V %X 00:00:00.000000 +060 2004 %j %Y 00:00:00.000000 +4 53 1998 %w %u %Y 00:00:00.000000 +15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00.000000 +15-01-20 %d-%m-%y 00:00:00.000000 +15-2001-1 %d-%Y-%c 00:00:00.000000 select concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d')); concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d')) 2003-01-02 08:11:02.123456 diff --git a/mysql-test/r/func_sapdb.result b/mysql-test/r/func_sapdb.result index feb92da3321..138b1a99d97 100644 --- a/mysql-test/r/func_sapdb.result +++ b/mysql-test/r/func_sapdb.result @@ -156,7 +156,7 @@ timestamp("2001-12-01", "25:01:01") 2001-12-02 01:01:01 select timestamp("2001-12-01 01:01:01.000100"); timestamp("2001-12-01 01:01:01.000100") -2001-12-01 01:01:01.000100 +2001-12-01 01:01:01.0001 select timestamp("2001-12-01"); timestamp("2001-12-01") 2001-12-01 00:00:00 @@ -200,12 +200,12 @@ f3 time(6) YES NULL f4 time(6) YES NULL f5 time(6) YES NULL f6 time YES NULL -f7 datetime(6) YES NULL +f7 datetime YES NULL f8 date YES NULL f9 time(6) YES NULL select * from t1; f1 f2 f3 f4 f5 f6 f7 f8 f9 -1997-01-01 1998-01-02 01:01:00.000003 49:01:01.000001 46:58:57.999999 -24:00:00.000001 10:11:12 2001-12-01 01:01:01.000000 1997-12-31 23:59:59.000001 +1997-01-01 1998-01-02 01:01:00.000003 49:01:01.000001 46:58:57.999999 -24:00:00.000001 10:11:12 2001-12-01 01:01:01 1997-12-31 23:59:59.000001 create table test(t1 datetime, t2 time, t3 time, t4 datetime); insert into test values ('2001-01-01 01:01:01', '01:01:01', null, '2001-02-01 01:01:01'), diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 8bbc692aa4a..99104136f2b 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -11,17 +11,17 @@ now()-now() weekday(curdate())-weekday(now()) unix_timestamp()-unix_timestamp(no 0 0 0 select from_unixtime(unix_timestamp("1994-03-02 10:11:12")),from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s"),from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0; from_unixtime(unix_timestamp("1994-03-02 10:11:12")) from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s") from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0 -1994-03-02 10:11:12.000000 1994-03-02 10:11:12 19940302101112.000000 +1994-03-02 10:11:12 1994-03-02 10:11:12 19940302101112 select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"), sec_to_time(time_to_sec("0:30:47")/6.21); sec_to_time(9001) sec_to_time(9001)+0 time_to_sec("15:12:22") sec_to_time(time_to_sec("0:30:47")/6.21) -02:30:01 23001 54742.000000 00:04:57.423510 +02:30:01 23001 54742 00:04:57.4235 select sec_to_time(9001.1), time_to_sec('15:12:22.123456'), time_to_sec(15.5566778899); sec_to_time(9001.1) time_to_sec('15:12:22.123456') time_to_sec(15.5566778899) 02:30:01.1 54742.123456 15.556677 select sec_to_time(time_to_sec('-838:59:59')); sec_to_time(time_to_sec('-838:59:59')) --838:59:59.000000 +-838:59:59 select sec_to_time('9001.1'), sec_to_time('1234567890123.123'); sec_to_time('9001.1') sec_to_time('1234567890123.123') 02:30:01.100000 838:59:59.999999 @@ -77,7 +77,7 @@ HOUR("1997-03-03 23:03:22") MINUTE("23:03:22") SECOND(230322) 23 3 22 select TIME(230322), TIME(230322.33), TIME("230322.33"); TIME(230322) TIME(230322.33) TIME("230322.33") -23:03:22 23:03:22.33 23:03:22.330000 +23:03:22 23:03:22.33 23:03:22.33 select week(19980101),week(19970101),week(19980101,1),week(19970101,1); week(19980101) week(19970101) week(19980101,1) week(19970101,1) 0 0 1 1 @@ -569,7 +569,7 @@ select @a:=FROM_UNIXTIME(1); 1970-01-01 03:00:01 select unix_timestamp(@a); unix_timestamp(@a) -1.000000 +1 select unix_timestamp('1969-12-01 19:00:01'); unix_timestamp('1969-12-01 19:00:01') NULL @@ -611,10 +611,10 @@ unix_timestamp('1969-12-30 01:00:00') NULL select unix_timestamp('2038-01-17 12:00:00'); unix_timestamp('2038-01-17 12:00:00') -2147331600.000000 +2147331600 select unix_timestamp('1970-01-01 03:00:01'); unix_timestamp('1970-01-01 03:00:01') -1.000000 +1 select unix_timestamp('2038-01-19 07:14:07'); unix_timestamp('2038-01-19 07:14:07') NULL @@ -1947,7 +1947,7 @@ TIME(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5, DATE(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6, TIMESTAMP(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7; c1 c2 c3 c4 c5 c6 c7 -20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00.000000 00:00:00.000000 2001-01-01 2001-01-01 00:00:00.000000 +20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00 00:00:00 2001-01-01 2001-01-01 00:00:00 SELECT CAST(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS SIGNED) AS c1, CAST(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS DECIMAL(25,4)) AS c2, @@ -1957,7 +1957,7 @@ TIME(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c5, DATE(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c6, TIMESTAMP(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c7; c1 c2 c3 c4 c5 c6 c7 -20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30.000000 10:20:30.000000 2001-01-02 2001-01-02 10:20:30.000000 +20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30 10:20:30 2001-01-02 2001-01-02 10:20:30 SELECT CAST(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1, CAST(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2, @@ -1967,7 +1967,7 @@ TIME(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5, DATE(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6, TIMESTAMP(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7; c1 c2 c3 c4 c5 c6 c7 -20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00.000000 00:00:00.000000 2001-01-01 2001-01-01 00:00:00.000000 +20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00 00:00:00 2001-01-01 2001-01-01 00:00:00 SELECT CAST(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS SIGNED) AS c1, CAST(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS DECIMAL(25,4)) AS c2, @@ -1977,7 +1977,7 @@ TIME(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c5, DATE(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c6, TIMESTAMP(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c7; c1 c2 c3 c4 c5 c6 c7 -20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30.000000 10:20:30.000000 2001-01-02 2001-01-02 10:20:30.000000 +20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30 10:20:30 2001-01-02 2001-01-02 10:20:30 SELECT CAST(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1, CAST(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2, @@ -1987,7 +1987,7 @@ TIME(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5, DATE(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6, TIMESTAMP(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7; c1 c2 c3 c4 c5 c6 c7 -20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00.000000 00:00:00.000000 2001-01-01 2001-01-01 00:00:00.000000 +20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00 00:00:00 2001-01-01 2001-01-01 00:00:00 SELECT CAST(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1, CAST(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2, @@ -1997,7 +1997,7 @@ TIME(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5, DATE(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6, TIMESTAMP(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7; c1 c2 c3 c4 c5 c6 c7 -20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30.000000 10:20:30.000000 2001-01-02 2001-01-02 10:20:30.000000 +20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30 10:20:30 2001-01-02 2001-01-02 10:20:30 SELECT CAST(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS SIGNED) AS c1, CAST(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS DECIMAL(25,4)) AS c2, @@ -2007,7 +2007,7 @@ TIME(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') E DATE(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c6, TIMESTAMP(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c7; c1 c2 c3 c4 c5 c6 c7 -20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00.000000 00:00:00.000000 2001-01-01 2001-01-01 00:00:00.000000 +20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00 00:00:00 2001-01-01 2001-01-01 00:00:00 SELECT CAST(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS SIGNED) AS c1, CAST(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS DECIMAL(25,4)) AS c2, @@ -2017,7 +2017,7 @@ TIME(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') E DATE(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c6, TIMESTAMP(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c7; c1 c2 c3 c4 c5 c6 c7 -20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30.000000 10:20:30.000000 2001-01-02 2001-01-02 10:20:30.000000 +20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30 10:20:30 2001-01-02 2001-01-02 10:20:30 CREATE TABLE t1 AS SELECT CONCAT(COALESCE(TIME(101010),TIME(101010))) AS c1, CONCAT(IF(0,TIME(101010),TIME(101010))) AS c2, @@ -2032,3 +2032,148 @@ t1 CREATE TABLE `t1` ( `c4` varbinary(10) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; +# +# MDEV-4724 Some temporal functions do not preserve microseconds +# +SELECT MAKETIME(10,10,10.231); +MAKETIME(10,10,10.231) +10:10:10.231 +SELECT MAKETIME(0, 0, 59.9); +MAKETIME(0, 0, 59.9) +00:00:59.9 +CREATE TABLE t1 AS SELECT +MAKETIME(10,00,00), +MAKETIME(10,00,00.1), +MAKETIME(10,00,00.12), +MAKETIME(10,00,00.123), +MAKETIME(10,00,00.1234), +MAKETIME(10,00,00.12345), +MAKETIME(10,00,00.123456); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +MAKETIME(10,00,00) time YES NULL +MAKETIME(10,00,00.1) time(1) YES NULL +MAKETIME(10,00,00.12) time(2) YES NULL +MAKETIME(10,00,00.123) time(3) YES NULL +MAKETIME(10,00,00.1234) time(4) YES NULL +MAKETIME(10,00,00.12345) time(5) YES NULL +MAKETIME(10,00,00.123456) time(6) YES NULL +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +TIME('10:00:00'), +TIME('10:00:00.1'), +TIME('10:00:00.12'), +TIME('10:00:00.123'), +TIME('10:00:00.1234'), +TIME('10:00:00.12345'), +TIME('10:00:00.12346'); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +TIME('10:00:00') time YES NULL +TIME('10:00:00.1') time(1) YES NULL +TIME('10:00:00.12') time(2) YES NULL +TIME('10:00:00.123') time(3) YES NULL +TIME('10:00:00.1234') time(4) YES NULL +TIME('10:00:00.12345') time(5) YES NULL +TIME('10:00:00.12346') time(5) YES NULL +DROP TABLE t1; +SET TIME_ZONE='+00:00'; +SET TIMESTAMP=UNIX_TIMESTAMP('2012-10-16 22:46:17'); +SELECT NOW(), UNIX_TIMESTAMP(), UNIX_TIMESTAMP(NOW()),UNIX_TIMESTAMP('2012-10-16 22:46:17'); +NOW() UNIX_TIMESTAMP() UNIX_TIMESTAMP(NOW()) UNIX_TIMESTAMP('2012-10-16 22:46:17') +2012-10-16 22:46:17 1350427577 1350427577 1350427577 +SET TIMESTAMP=UNIX_TIMESTAMP('1970-01-02 03:04:05.123456'); +SELECT @@timestamp, FROM_UNIXTIME(@@timestamp); +@@timestamp FROM_UNIXTIME(@@timestamp) +97445.123456 1970-01-02 03:04:05.123456 +SET TIME_ZONE=DEFAULT; +SET TIMESTAMP=DEFAULT; +SELECT TIME('2012-10-16 15:54:16.12'); +TIME('2012-10-16 15:54:16.12') +15:54:16.12 +SELECT TIMESTAMP('2012-10-16 15:54:16.12'); +TIMESTAMP('2012-10-16 15:54:16.12') +2012-10-16 15:54:16.12 +SELECT TIMEDIFF('10:10:10.1','00:00:00'); +TIMEDIFF('10:10:10.1','00:00:00') +10:10:10.1 +SELECT TIME_TO_SEC('10:10:10'); +TIME_TO_SEC('10:10:10') +36610 +SELECT ADDTIME(TIME('10:10:10.1'),'10:10:10.12'); +ADDTIME(TIME('10:10:10.1'),'10:10:10.12') +20:20:20.22 +SELECT ADDTIME(TIMESTAMP('2001-01-01 10:10:10.1'),'10:10:10.12'); +ADDTIME(TIMESTAMP('2001-01-01 10:10:10.1'),'10:10:10.12') +2001-01-01 20:20:20.22 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND) +2001-01-01 00:00:01 +SELECT DATE_ADD('2001-01-01 00:00:00.1', INTERVAL 1 SECOND); +DATE_ADD('2001-01-01 00:00:00.1', INTERVAL 1 SECOND) +2001-01-01 00:00:01.1 +SELECT DATE_ADD('2001-01-01 00:00:00.12', INTERVAL 1 SECOND); +DATE_ADD('2001-01-01 00:00:00.12', INTERVAL 1 SECOND) +2001-01-01 00:00:01.12 +SELECT DATE_ADD('2001-01-01 00:00:00.123', INTERVAL 1 SECOND); +DATE_ADD('2001-01-01 00:00:00.123', INTERVAL 1 SECOND) +2001-01-01 00:00:01.123 +SELECT DATE_ADD('2001-01-01 00:00:00.1234', INTERVAL 1 SECOND); +DATE_ADD('2001-01-01 00:00:00.1234', INTERVAL 1 SECOND) +2001-01-01 00:00:01.1234 +SELECT DATE_ADD('2001-01-01 00:00:00.12345', INTERVAL 1 SECOND); +DATE_ADD('2001-01-01 00:00:00.12345', INTERVAL 1 SECOND) +2001-01-01 00:00:01.12345 +SELECT DATE_ADD('2001-01-01 00:00:00.123456', INTERVAL 1 SECOND); +DATE_ADD('2001-01-01 00:00:00.123456', INTERVAL 1 SECOND) +2001-01-01 00:00:01.123456 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND) +2001-01-01 00:00:01 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1 SECOND) +2001-01-01 00:00:01.1 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12 SECOND) +2001-01-01 00:00:01.12 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123 SECOND) +2001-01-01 00:00:01.123 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1234 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1234 SECOND) +2001-01-01 00:00:01.1234 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12345 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12345 SECOND) +2001-01-01 00:00:01.12345 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123456 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123456 SECOND) +2001-01-01 00:00:01.123456 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL -1 SECOND) +2000-12-31 23:59:59 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1 SECOND) +2000-12-31 23:59:58.9 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12 SECOND) +2000-12-31 23:59:58.88 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123 SECOND) +2000-12-31 23:59:58.877 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1234 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1234 SECOND) +2000-12-31 23:59:58.8766 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12345 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12345 SECOND) +2000-12-31 23:59:58.87655 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123456 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123456 SECOND) +2000-12-31 23:59:58.876544 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 'xxx' SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 'xxx' SECOND) +2001-01-01 00:00:00.000000 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'xxx' +SELECT CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00'); +CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00') +2001-01-01 11:20:30.12 diff --git a/mysql-test/r/func_time_hires.result b/mysql-test/r/func_time_hires.result index 4aa0333c4b4..1a736c89573 100644 --- a/mysql-test/r/func_time_hires.result +++ b/mysql-test/r/func_time_hires.result @@ -15,11 +15,11 @@ current_time(3) 01:01:01.123 current_timestamp(4) 2011-01-01 01:01:01.1234 localtime(5) 2011-01-01 01:01:01.12345 localtimestamp(6) 2011-01-01 01:01:01.123456 -time_to_sec('12:34:56') 45296.000000 -time_to_sec('12:34:56.789') 45296.789000 +time_to_sec('12:34:56') 45296 +time_to_sec('12:34:56.789') 45296.789 select sec_to_time(time_to_sec('1:2:3')), sec_to_time(time_to_sec('2:3:4.567890')); -sec_to_time(time_to_sec('1:2:3')) 01:02:03.000000 -sec_to_time(time_to_sec('2:3:4.567890')) 02:03:04.567890 +sec_to_time(time_to_sec('1:2:3')) 01:02:03 +sec_to_time(time_to_sec('2:3:4.567890')) 02:03:04.56789 select time_to_sec(sec_to_time(11111)), time_to_sec(sec_to_time(11111.22222)); time_to_sec(sec_to_time(11111)) 11111 time_to_sec(sec_to_time(11111.22222)) 11111.22222 @@ -48,7 +48,7 @@ t1 CREATE TABLE `t1` ( `localtime(5)` datetime(5) NOT NULL DEFAULT '0000-00-00 00:00:00.00000', `localtimestamp(6)` datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', `time_to_sec(123456)` bigint(17) DEFAULT NULL, - `time_to_sec('12:34:56.789')` decimal(22,6) DEFAULT NULL + `time_to_sec('12:34:56.789')` decimal(19,3) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 select * from t1; sec_to_time(12345) 03:25:45 @@ -63,15 +63,15 @@ current_timestamp(4) 2011-01-01 01:01:01.1234 localtime(5) 2011-01-01 01:01:01.12345 localtimestamp(6) 2011-01-01 01:01:01.123456 time_to_sec(123456) 45296 -time_to_sec('12:34:56.789') 45296.789000 +time_to_sec('12:34:56.789') 45296.789 drop table t1; select unix_timestamp('2011-01-01 01:01:01'), unix_timestamp('2011-01-01 01:01:01.123456'), unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(0))), unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(4)));; -unix_timestamp('2011-01-01 01:01:01') 1293832861.000000 +unix_timestamp('2011-01-01 01:01:01') 1293832861 unix_timestamp('2011-01-01 01:01:01.123456') 1293832861.123456 unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(0))) 1293832861 unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(4))) 1293832861.1234 select from_unixtime(unix_timestamp('2011/1/1 1:1:1')), from_unixtime(unix_timestamp('2011/1/1 1:1:1.123456')), from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(0)))), from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(4))));; -from_unixtime(unix_timestamp('2011/1/1 1:1:1')) 2011-01-01 01:01:01.000000 +from_unixtime(unix_timestamp('2011/1/1 1:1:1')) 2011-01-01 01:01:01 from_unixtime(unix_timestamp('2011/1/1 1:1:1.123456')) 2011-01-01 01:01:01.123456 from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(0)))) 2011-01-01 01:01:01 from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(4)))) 2011-01-01 01:01:01.1234 @@ -167,7 +167,7 @@ CONVERT_TZ('2011-01-02 12:00:00', '+00:00', '+03:00') 2011-01-02 15:00:00 SELECT CONVERT_TZ('2011-01-02 12:00:00.123', '+00:00', '+03:00'); CONVERT_TZ('2011-01-02 12:00:00.123', '+00:00', '+03:00') -2011-01-02 15:00:00.123000 +2011-01-02 15:00:00.123 SELECT CONVERT_TZ('2011-01-02 12:00:00.123456', '+00:00', '+03:00'); CONVERT_TZ('2011-01-02 12:00:00.123456', '+00:00', '+03:00') 2011-01-02 15:00:00.123456 @@ -200,7 +200,7 @@ time(f1) alter table t1 modify f1 varchar(100); select time(f1) from t1; time(f1) -21:00:00 +21:00:00.000000 select time(f1) from t1 union all select time(f1 + interval 1 second) from t1; time(f1) 21:00:00.000000 diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index cce5d6e9e2f..4b245edef09 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -1793,8 +1793,8 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) DEFAULT NULL, - `param10` decimal(65,30) DEFAULT NULL, + `const10` bigint(17) DEFAULT NULL, + `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, `const12` binary(0) DEFAULT NULL, @@ -1823,8 +1823,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 Y 0 6 63 -def test t5 t5 param10 param10 246 67 40 Y 0 30 63 +def test t5 t5 const10 const10 8 17 9 Y 32768 0 63 +def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 128 0 63 @@ -1850,8 +1850,8 @@ const08 1991-08-05 01:01:01 param08 1991-08-05 01:01:01 const09 1991-08-05 01:01:01 param09 1991-08-05 01:01:01 -const10 662680861.000000 -param10 662680861.000000000000000000000000000000 +const10 662680861 +param10 662680861 const11 1991 param11 1991 const12 NULL diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index 328df9e5978..4798d63b5e7 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -1776,8 +1776,8 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) DEFAULT NULL, - `param10` decimal(65,30) DEFAULT NULL, + `const10` bigint(17) DEFAULT NULL, + `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, `const12` binary(0) DEFAULT NULL, @@ -1806,8 +1806,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 Y 0 6 63 -def test t5 t5 param10 param10 246 67 40 Y 0 30 63 +def test t5 t5 const10 const10 8 17 9 Y 32768 0 63 +def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 128 0 63 @@ -1833,8 +1833,8 @@ const08 1991-08-05 01:01:01 param08 1991-08-05 01:01:01 const09 1991-08-05 01:01:01 param09 1991-08-05 01:01:01 -const10 662680861.000000 -param10 662680861.000000000000000000000000000000 +const10 662680861 +param10 662680861 const11 1991 param11 1991 const12 NULL diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index cc4330c57e4..f94273ea3ad 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -1777,8 +1777,8 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) DEFAULT NULL, - `param10` decimal(65,30) DEFAULT NULL, + `const10` bigint(17) DEFAULT NULL, + `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, `const12` binary(0) DEFAULT NULL, @@ -1807,8 +1807,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 Y 0 6 63 -def test t5 t5 param10 param10 246 67 40 Y 0 30 63 +def test t5 t5 const10 const10 8 17 9 Y 32768 0 63 +def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 128 0 63 @@ -1834,8 +1834,8 @@ const08 1991-08-05 01:01:01 param08 1991-08-05 01:01:01 const09 1991-08-05 01:01:01 param09 1991-08-05 01:01:01 -const10 662680861.000000 -param10 662680861.000000000000000000000000000000 +const10 662680861 +param10 662680861 const11 1991 param11 1991 const12 NULL diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index fe1665fc24e..eed82775d7b 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -1713,8 +1713,8 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) DEFAULT NULL, - `param10` decimal(65,30) DEFAULT NULL, + `const10` bigint(17) DEFAULT NULL, + `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, `const12` binary(0) DEFAULT NULL, @@ -1743,8 +1743,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 Y 0 6 63 -def test t5 t5 param10 param10 246 67 40 Y 0 30 63 +def test t5 t5 const10 const10 8 17 9 Y 32768 0 63 +def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 128 0 63 @@ -1770,8 +1770,8 @@ const08 1991-08-05 01:01:01 param08 1991-08-05 01:01:01 const09 1991-08-05 01:01:01 param09 1991-08-05 01:01:01 -const10 662680861.000000 -param10 662680861.000000000000000000000000000000 +const10 662680861 +param10 662680861 const11 1991 param11 1991 const12 NULL @@ -5067,8 +5067,8 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) DEFAULT NULL, - `param10` decimal(65,30) DEFAULT NULL, + `const10` bigint(17) DEFAULT NULL, + `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, `const12` binary(0) DEFAULT NULL, @@ -5097,8 +5097,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 Y 0 6 63 -def test t5 t5 param10 param10 246 67 40 Y 0 30 63 +def test t5 t5 const10 const10 8 17 9 Y 32768 0 63 +def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 128 0 63 @@ -5124,8 +5124,8 @@ const08 1991-08-05 01:01:01 param08 1991-08-05 01:01:01 const09 1991-08-05 01:01:01 param09 1991-08-05 01:01:01 -const10 662680861.000000 -param10 662680861.000000000000000000000000000000 +const10 662680861 +param10 662680861 const11 1991 param11 1991 const12 NULL diff --git a/mysql-test/r/timezone.result b/mysql-test/r/timezone.result index 5ae7e6f8117..d84fe54ba8c 100644 --- a/mysql-test/r/timezone.result +++ b/mysql-test/r/timezone.result @@ -7,7 +7,7 @@ select @a:=FROM_UNIXTIME(1); 1970-01-01 01:00:01 select unix_timestamp(@a); unix_timestamp(@a) -1.000000 +1 CREATE TABLE t1 (ts int); INSERT INTO t1 (ts) VALUES (Unix_timestamp('2002-10-27 01:00')); INSERT INTO t1 (ts) VALUES (Unix_timestamp('2002-10-27 02:00')); @@ -44,7 +44,7 @@ unix_timestamp('1970-01-01 01:00:01'), unix_timestamp('2038-01-19 04:14:07'), unix_timestamp('2038-01-19 04:14:08'); unix_timestamp('1970-01-01 01:00:00') unix_timestamp('1970-01-01 01:00:01') unix_timestamp('2038-01-19 04:14:07') unix_timestamp('2038-01-19 04:14:08') -0.000000 1.000000 2147483647.000000 NULL +0 1 2147483647 NULL select unix_timestamp('1969-12-31 23:59:59'), unix_timestamp('1970-01-01 00:00:00'), unix_timestamp('1970-01-01 00:59:59'); unix_timestamp('1969-12-31 23:59:59') unix_timestamp('1970-01-01 00:00:00') unix_timestamp('1970-01-01 00:59:59') NULL NULL NULL diff --git a/mysql-test/r/timezone4.result b/mysql-test/r/timezone4.result index ad0672890a2..28028bea657 100644 --- a/mysql-test/r/timezone4.result +++ b/mysql-test/r/timezone4.result @@ -3,4 +3,4 @@ from_unixtime(0) 1969-12-31 14:00:00 select unix_timestamp('1969-12-31 14:00:01'); unix_timestamp('1969-12-31 14:00:01') -1.000000 +1 diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result index 23943c3c848..c66f3f08e08 100644 --- a/mysql-test/r/type_time.result +++ b/mysql-test/r/type_time.result @@ -186,10 +186,10 @@ Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' # SELECT CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00'))); CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00'))) -00:00:01.000000 +00:00:01 SELECT CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00'))); CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00'))) -768:00:01.000000 +768:00:01 # # End of 5.3 tests # diff --git a/mysql-test/suite/maria/r/ps_maria.result b/mysql-test/suite/maria/r/ps_maria.result index 3546e78512c..207ae8a59db 100644 --- a/mysql-test/suite/maria/r/ps_maria.result +++ b/mysql-test/suite/maria/r/ps_maria.result @@ -1793,8 +1793,8 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) DEFAULT NULL, - `param10` decimal(65,30) DEFAULT NULL, + `const10` bigint(17) DEFAULT NULL, + `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, `const12` binary(0) DEFAULT NULL, @@ -1823,8 +1823,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 Y 0 6 63 -def test t5 t5 param10 param10 246 67 40 Y 0 30 63 +def test t5 t5 const10 const10 8 17 9 Y 32768 0 63 +def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 128 0 63 @@ -1850,8 +1850,8 @@ const08 1991-08-05 01:01:01 param08 1991-08-05 01:01:01 const09 1991-08-05 01:01:01 param09 1991-08-05 01:01:01 -const10 662680861.000000 -param10 662680861.000000000000000000000000000000 +const10 662680861 +param10 662680861 const11 1991 param11 1991 const12 NULL diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 6aedf3f55df..aba78b92c3e 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1255,3 +1255,69 @@ CREATE TABLE t1 AS SELECT CONCAT(CASE WHEN 1 THEN TIME(101010) ELSE TIME(101010) END) AS c4; SHOW CREATE TABLE t1; DROP TABLE t1; + + +--echo # +--echo # MDEV-4724 Some temporal functions do not preserve microseconds +--echo # +SELECT MAKETIME(10,10,10.231); +SELECT MAKETIME(0, 0, 59.9); +CREATE TABLE t1 AS SELECT + MAKETIME(10,00,00), + MAKETIME(10,00,00.1), + MAKETIME(10,00,00.12), + MAKETIME(10,00,00.123), + MAKETIME(10,00,00.1234), + MAKETIME(10,00,00.12345), + MAKETIME(10,00,00.123456); +SHOW COLUMNS FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 AS SELECT + TIME('10:00:00'), + TIME('10:00:00.1'), + TIME('10:00:00.12'), + TIME('10:00:00.123'), + TIME('10:00:00.1234'), + TIME('10:00:00.12345'), + TIME('10:00:00.12346'); +SHOW COLUMNS FROM t1; +DROP TABLE t1; + +SET TIME_ZONE='+00:00'; +SET TIMESTAMP=UNIX_TIMESTAMP('2012-10-16 22:46:17'); +SELECT NOW(), UNIX_TIMESTAMP(), UNIX_TIMESTAMP(NOW()),UNIX_TIMESTAMP('2012-10-16 22:46:17'); +SET TIMESTAMP=UNIX_TIMESTAMP('1970-01-02 03:04:05.123456'); +SELECT @@timestamp, FROM_UNIXTIME(@@timestamp); +SET TIME_ZONE=DEFAULT; +SET TIMESTAMP=DEFAULT; + +SELECT TIME('2012-10-16 15:54:16.12'); +SELECT TIMESTAMP('2012-10-16 15:54:16.12'); +SELECT TIMEDIFF('10:10:10.1','00:00:00'); +SELECT TIME_TO_SEC('10:10:10'); +SELECT ADDTIME(TIME('10:10:10.1'),'10:10:10.12'); +SELECT ADDTIME(TIMESTAMP('2001-01-01 10:10:10.1'),'10:10:10.12'); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00.1', INTERVAL 1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00.12', INTERVAL 1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00.123', INTERVAL 1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00.1234', INTERVAL 1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00.12345', INTERVAL 1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00.123456', INTERVAL 1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1234 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12345 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123456 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1234 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12345 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123456 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 'xxx' SECOND); +SELECT CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00'); -- cgit v1.2.1 From cf9cc19e910f3621661de6a9384a18aacf84a8dd Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 13 Sep 2013 14:43:10 +0400 Subject: MDEV-4724 Some temporal functions do not preserve microseconds --- mysql-test/r/date_formats.result | 108 +++++++++---------- mysql-test/r/func_sapdb.result | 6 +- mysql-test/r/func_time.result | 175 ++++++++++++++++++++++++++++--- mysql-test/r/func_time_hires.result | 20 ++-- mysql-test/r/ps_2myisam.result | 12 +-- mysql-test/r/ps_3innodb.result | 12 +-- mysql-test/r/ps_4heap.result | 12 +-- mysql-test/r/ps_5merge.result | 24 ++--- mysql-test/r/timezone.result | 4 +- mysql-test/r/timezone4.result | 2 +- mysql-test/r/type_time.result | 4 +- mysql-test/suite/maria/r/ps_maria.result | 12 +-- mysql-test/t/func_time.test | 66 ++++++++++++ 13 files changed, 334 insertions(+), 123 deletions(-) (limited to 'mysql-test') diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index dd346cb94dc..88255a06adb 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -257,70 +257,70 @@ Tuesday 52 2001 %W %V %X 2002-01-01 15-2001-1 %d-%Y-%c 2001-01-15 select date,format,TIME(str_to_date(date, format)) as time from t1; date format time -2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12 -03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02 -0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02 -03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02 -2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12 +2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12.000000 +03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02.000000 +0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02.000000 +03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02.000000 +2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12.000000 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450 -2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12 -10:20:10 %H:%i:%s 10:20:10 -10:20:10 %h:%i:%s.%f 10:20:10 -10:20:10 %T 10:20:10 -10:20:10AM %h:%i:%s%p 10:20:10 -10:20:10AM %r 10:20:10 +2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12.000000 +10:20:10 %H:%i:%s 10:20:10.000000 +10:20:10 %h:%i:%s.%f 10:20:10.000000 +10:20:10 %T 10:20:10.000000 +10:20:10AM %h:%i:%s%p 10:20:10.000000 +10:20:10AM %r 10:20:10.000000 10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000 -15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58 -15 September 2001 %d %M %Y 00:00:00 -15 SEPTEMB 2001 %d %M %Y 00:00:00 -15 MAY 2001 %d %b %Y 00:00:00 -15th May 2001 %D %b %Y 00:00:00 -Sunday 15 MAY 2001 %W %d %b %Y 00:00:00 -Sund 15 MAY 2001 %W %d %b %Y 00:00:00 -Tuesday 00 2002 %W %U %Y 00:00:00 -Thursday 53 1998 %W %u %Y 00:00:00 -Sunday 01 2001 %W %v %x 00:00:00 -Tuesday 52 2001 %W %V %X 00:00:00 -060 2004 %j %Y 00:00:00 -4 53 1998 %w %u %Y 00:00:00 -15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00 -15-01-20 %d-%m-%y 00:00:00 -15-2001-1 %d-%Y-%c 00:00:00 +15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58.000000 +15 September 2001 %d %M %Y 00:00:00.000000 +15 SEPTEMB 2001 %d %M %Y 00:00:00.000000 +15 MAY 2001 %d %b %Y 00:00:00.000000 +15th May 2001 %D %b %Y 00:00:00.000000 +Sunday 15 MAY 2001 %W %d %b %Y 00:00:00.000000 +Sund 15 MAY 2001 %W %d %b %Y 00:00:00.000000 +Tuesday 00 2002 %W %U %Y 00:00:00.000000 +Thursday 53 1998 %W %u %Y 00:00:00.000000 +Sunday 01 2001 %W %v %x 00:00:00.000000 +Tuesday 52 2001 %W %V %X 00:00:00.000000 +060 2004 %j %Y 00:00:00.000000 +4 53 1998 %w %u %Y 00:00:00.000000 +15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00.000000 +15-01-20 %d-%m-%y 00:00:00.000000 +15-2001-1 %d-%Y-%c 00:00:00.000000 select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1; date format time2 -2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12 -03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02 -0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02 -03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02 -2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12 +2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12.000000 +03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02.000000 +0003-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02.000000 +03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02.000000 +2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12.000000 2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.123450 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450 -2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12 -10:20:10 %H:%i:%s 10:20:10 -10:20:10 %h:%i:%s.%f 10:20:10 -10:20:10 %T 10:20:10 -10:20:10AM %h:%i:%s%p 10:20:10 -10:20:10AM %r 10:20:10 +2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12.000000 +10:20:10 %H:%i:%s 10:20:10.000000 +10:20:10 %h:%i:%s.%f 10:20:10.000000 +10:20:10 %T 10:20:10.000000 +10:20:10AM %h:%i:%s%p 10:20:10.000000 +10:20:10AM %r 10:20:10.000000 10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000 -15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58 -15 September 2001 %d %M %Y 00:00:00 -15 SEPTEMB 2001 %d %M %Y 00:00:00 -15 MAY 2001 %d %b %Y 00:00:00 -15th May 2001 %D %b %Y 00:00:00 -Sunday 15 MAY 2001 %W %d %b %Y 00:00:00 -Sund 15 MAY 2001 %W %d %b %Y 00:00:00 -Tuesday 00 2002 %W %U %Y 00:00:00 -Thursday 53 1998 %W %u %Y 00:00:00 -Sunday 01 2001 %W %v %x 00:00:00 -Tuesday 52 2001 %W %V %X 00:00:00 -060 2004 %j %Y 00:00:00 -4 53 1998 %w %u %Y 00:00:00 -15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00 -15-01-20 %d-%m-%y 00:00:00 -15-2001-1 %d-%Y-%c 00:00:00 +15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58.000000 +15 September 2001 %d %M %Y 00:00:00.000000 +15 SEPTEMB 2001 %d %M %Y 00:00:00.000000 +15 MAY 2001 %d %b %Y 00:00:00.000000 +15th May 2001 %D %b %Y 00:00:00.000000 +Sunday 15 MAY 2001 %W %d %b %Y 00:00:00.000000 +Sund 15 MAY 2001 %W %d %b %Y 00:00:00.000000 +Tuesday 00 2002 %W %U %Y 00:00:00.000000 +Thursday 53 1998 %W %u %Y 00:00:00.000000 +Sunday 01 2001 %W %v %x 00:00:00.000000 +Tuesday 52 2001 %W %V %X 00:00:00.000000 +060 2004 %j %Y 00:00:00.000000 +4 53 1998 %w %u %Y 00:00:00.000000 +15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00.000000 +15-01-20 %d-%m-%y 00:00:00.000000 +15-2001-1 %d-%Y-%c 00:00:00.000000 select concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d')); concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d')) 2003-01-02 08:11:02.123456 diff --git a/mysql-test/r/func_sapdb.result b/mysql-test/r/func_sapdb.result index feb92da3321..138b1a99d97 100644 --- a/mysql-test/r/func_sapdb.result +++ b/mysql-test/r/func_sapdb.result @@ -156,7 +156,7 @@ timestamp("2001-12-01", "25:01:01") 2001-12-02 01:01:01 select timestamp("2001-12-01 01:01:01.000100"); timestamp("2001-12-01 01:01:01.000100") -2001-12-01 01:01:01.000100 +2001-12-01 01:01:01.0001 select timestamp("2001-12-01"); timestamp("2001-12-01") 2001-12-01 00:00:00 @@ -200,12 +200,12 @@ f3 time(6) YES NULL f4 time(6) YES NULL f5 time(6) YES NULL f6 time YES NULL -f7 datetime(6) YES NULL +f7 datetime YES NULL f8 date YES NULL f9 time(6) YES NULL select * from t1; f1 f2 f3 f4 f5 f6 f7 f8 f9 -1997-01-01 1998-01-02 01:01:00.000003 49:01:01.000001 46:58:57.999999 -24:00:00.000001 10:11:12 2001-12-01 01:01:01.000000 1997-12-31 23:59:59.000001 +1997-01-01 1998-01-02 01:01:00.000003 49:01:01.000001 46:58:57.999999 -24:00:00.000001 10:11:12 2001-12-01 01:01:01 1997-12-31 23:59:59.000001 create table test(t1 datetime, t2 time, t3 time, t4 datetime); insert into test values ('2001-01-01 01:01:01', '01:01:01', null, '2001-02-01 01:01:01'), diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 8bbc692aa4a..99104136f2b 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -11,17 +11,17 @@ now()-now() weekday(curdate())-weekday(now()) unix_timestamp()-unix_timestamp(no 0 0 0 select from_unixtime(unix_timestamp("1994-03-02 10:11:12")),from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s"),from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0; from_unixtime(unix_timestamp("1994-03-02 10:11:12")) from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s") from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0 -1994-03-02 10:11:12.000000 1994-03-02 10:11:12 19940302101112.000000 +1994-03-02 10:11:12 1994-03-02 10:11:12 19940302101112 select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"), sec_to_time(time_to_sec("0:30:47")/6.21); sec_to_time(9001) sec_to_time(9001)+0 time_to_sec("15:12:22") sec_to_time(time_to_sec("0:30:47")/6.21) -02:30:01 23001 54742.000000 00:04:57.423510 +02:30:01 23001 54742 00:04:57.4235 select sec_to_time(9001.1), time_to_sec('15:12:22.123456'), time_to_sec(15.5566778899); sec_to_time(9001.1) time_to_sec('15:12:22.123456') time_to_sec(15.5566778899) 02:30:01.1 54742.123456 15.556677 select sec_to_time(time_to_sec('-838:59:59')); sec_to_time(time_to_sec('-838:59:59')) --838:59:59.000000 +-838:59:59 select sec_to_time('9001.1'), sec_to_time('1234567890123.123'); sec_to_time('9001.1') sec_to_time('1234567890123.123') 02:30:01.100000 838:59:59.999999 @@ -77,7 +77,7 @@ HOUR("1997-03-03 23:03:22") MINUTE("23:03:22") SECOND(230322) 23 3 22 select TIME(230322), TIME(230322.33), TIME("230322.33"); TIME(230322) TIME(230322.33) TIME("230322.33") -23:03:22 23:03:22.33 23:03:22.330000 +23:03:22 23:03:22.33 23:03:22.33 select week(19980101),week(19970101),week(19980101,1),week(19970101,1); week(19980101) week(19970101) week(19980101,1) week(19970101,1) 0 0 1 1 @@ -569,7 +569,7 @@ select @a:=FROM_UNIXTIME(1); 1970-01-01 03:00:01 select unix_timestamp(@a); unix_timestamp(@a) -1.000000 +1 select unix_timestamp('1969-12-01 19:00:01'); unix_timestamp('1969-12-01 19:00:01') NULL @@ -611,10 +611,10 @@ unix_timestamp('1969-12-30 01:00:00') NULL select unix_timestamp('2038-01-17 12:00:00'); unix_timestamp('2038-01-17 12:00:00') -2147331600.000000 +2147331600 select unix_timestamp('1970-01-01 03:00:01'); unix_timestamp('1970-01-01 03:00:01') -1.000000 +1 select unix_timestamp('2038-01-19 07:14:07'); unix_timestamp('2038-01-19 07:14:07') NULL @@ -1947,7 +1947,7 @@ TIME(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5, DATE(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6, TIMESTAMP(COALESCE(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7; c1 c2 c3 c4 c5 c6 c7 -20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00.000000 00:00:00.000000 2001-01-01 2001-01-01 00:00:00.000000 +20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00 00:00:00 2001-01-01 2001-01-01 00:00:00 SELECT CAST(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS SIGNED) AS c1, CAST(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS DECIMAL(25,4)) AS c2, @@ -1957,7 +1957,7 @@ TIME(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c5, DATE(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c6, TIMESTAMP(COALESCE(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c7; c1 c2 c3 c4 c5 c6 c7 -20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30.000000 10:20:30.000000 2001-01-02 2001-01-02 10:20:30.000000 +20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30 10:20:30 2001-01-02 2001-01-02 10:20:30 SELECT CAST(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1, CAST(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2, @@ -1967,7 +1967,7 @@ TIME(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5, DATE(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6, TIMESTAMP(IFNULL(DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7; c1 c2 c3 c4 c5 c6 c7 -20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00.000000 00:00:00.000000 2001-01-01 2001-01-01 00:00:00.000000 +20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00 00:00:00 2001-01-01 2001-01-01 00:00:00 SELECT CAST(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS SIGNED) AS c1, CAST(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01')) AS DECIMAL(25,4)) AS c2, @@ -1977,7 +1977,7 @@ TIME(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c5, DATE(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c6, TIMESTAMP(IFNULL(TIMESTAMP('2001-01-02 10:20:30'),DATE('2001-01-01'))) AS c7; c1 c2 c3 c4 c5 c6 c7 -20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30.000000 10:20:30.000000 2001-01-02 2001-01-02 10:20:30.000000 +20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30 10:20:30 2001-01-02 2001-01-02 10:20:30 SELECT CAST(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1, CAST(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2, @@ -1987,7 +1987,7 @@ TIME(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5, DATE(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6, TIMESTAMP(IF(1,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7; c1 c2 c3 c4 c5 c6 c7 -20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00.000000 00:00:00.000000 2001-01-01 2001-01-01 00:00:00.000000 +20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00 00:00:00 2001-01-01 2001-01-01 00:00:00 SELECT CAST(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS SIGNED) AS c1, CAST(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30')) AS DECIMAL(25,4)) AS c2, @@ -1997,7 +1997,7 @@ TIME(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c5, DATE(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c6, TIMESTAMP(IF(0,DATE('2001-01-01'),TIMESTAMP('2001-01-02 10:20:30'))) AS c7; c1 c2 c3 c4 c5 c6 c7 -20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30.000000 10:20:30.000000 2001-01-02 2001-01-02 10:20:30.000000 +20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30 10:20:30 2001-01-02 2001-01-02 10:20:30 SELECT CAST(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS SIGNED) AS c1, CAST(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS DECIMAL(25,4)) AS c2, @@ -2007,7 +2007,7 @@ TIME(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') E DATE(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c6, TIMESTAMP(CASE WHEN 1 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c7; c1 c2 c3 c4 c5 c6 c7 -20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00.000000 00:00:00.000000 2001-01-01 2001-01-01 00:00:00.000000 +20010101000000 20010101000000.0000 20010101000000 2001-01-01 00:00:00 00:00:00 2001-01-01 2001-01-01 00:00:00 SELECT CAST(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS SIGNED) AS c1, CAST(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END AS DECIMAL(25,4)) AS c2, @@ -2017,7 +2017,7 @@ TIME(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') E DATE(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c6, TIMESTAMP(CASE WHEN 0 THEN DATE('2001-01-01') ELSE TIMESTAMP('2001-01-02 10:20:30') END) AS c7; c1 c2 c3 c4 c5 c6 c7 -20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30.000000 10:20:30.000000 2001-01-02 2001-01-02 10:20:30.000000 +20010102102030 20010102102030.0000 20010102102030 2001-01-02 10:20:30 10:20:30 2001-01-02 2001-01-02 10:20:30 CREATE TABLE t1 AS SELECT CONCAT(COALESCE(TIME(101010),TIME(101010))) AS c1, CONCAT(IF(0,TIME(101010),TIME(101010))) AS c2, @@ -2032,3 +2032,148 @@ t1 CREATE TABLE `t1` ( `c4` varbinary(10) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; +# +# MDEV-4724 Some temporal functions do not preserve microseconds +# +SELECT MAKETIME(10,10,10.231); +MAKETIME(10,10,10.231) +10:10:10.231 +SELECT MAKETIME(0, 0, 59.9); +MAKETIME(0, 0, 59.9) +00:00:59.9 +CREATE TABLE t1 AS SELECT +MAKETIME(10,00,00), +MAKETIME(10,00,00.1), +MAKETIME(10,00,00.12), +MAKETIME(10,00,00.123), +MAKETIME(10,00,00.1234), +MAKETIME(10,00,00.12345), +MAKETIME(10,00,00.123456); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +MAKETIME(10,00,00) time YES NULL +MAKETIME(10,00,00.1) time(1) YES NULL +MAKETIME(10,00,00.12) time(2) YES NULL +MAKETIME(10,00,00.123) time(3) YES NULL +MAKETIME(10,00,00.1234) time(4) YES NULL +MAKETIME(10,00,00.12345) time(5) YES NULL +MAKETIME(10,00,00.123456) time(6) YES NULL +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +TIME('10:00:00'), +TIME('10:00:00.1'), +TIME('10:00:00.12'), +TIME('10:00:00.123'), +TIME('10:00:00.1234'), +TIME('10:00:00.12345'), +TIME('10:00:00.12346'); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +TIME('10:00:00') time YES NULL +TIME('10:00:00.1') time(1) YES NULL +TIME('10:00:00.12') time(2) YES NULL +TIME('10:00:00.123') time(3) YES NULL +TIME('10:00:00.1234') time(4) YES NULL +TIME('10:00:00.12345') time(5) YES NULL +TIME('10:00:00.12346') time(5) YES NULL +DROP TABLE t1; +SET TIME_ZONE='+00:00'; +SET TIMESTAMP=UNIX_TIMESTAMP('2012-10-16 22:46:17'); +SELECT NOW(), UNIX_TIMESTAMP(), UNIX_TIMESTAMP(NOW()),UNIX_TIMESTAMP('2012-10-16 22:46:17'); +NOW() UNIX_TIMESTAMP() UNIX_TIMESTAMP(NOW()) UNIX_TIMESTAMP('2012-10-16 22:46:17') +2012-10-16 22:46:17 1350427577 1350427577 1350427577 +SET TIMESTAMP=UNIX_TIMESTAMP('1970-01-02 03:04:05.123456'); +SELECT @@timestamp, FROM_UNIXTIME(@@timestamp); +@@timestamp FROM_UNIXTIME(@@timestamp) +97445.123456 1970-01-02 03:04:05.123456 +SET TIME_ZONE=DEFAULT; +SET TIMESTAMP=DEFAULT; +SELECT TIME('2012-10-16 15:54:16.12'); +TIME('2012-10-16 15:54:16.12') +15:54:16.12 +SELECT TIMESTAMP('2012-10-16 15:54:16.12'); +TIMESTAMP('2012-10-16 15:54:16.12') +2012-10-16 15:54:16.12 +SELECT TIMEDIFF('10:10:10.1','00:00:00'); +TIMEDIFF('10:10:10.1','00:00:00') +10:10:10.1 +SELECT TIME_TO_SEC('10:10:10'); +TIME_TO_SEC('10:10:10') +36610 +SELECT ADDTIME(TIME('10:10:10.1'),'10:10:10.12'); +ADDTIME(TIME('10:10:10.1'),'10:10:10.12') +20:20:20.22 +SELECT ADDTIME(TIMESTAMP('2001-01-01 10:10:10.1'),'10:10:10.12'); +ADDTIME(TIMESTAMP('2001-01-01 10:10:10.1'),'10:10:10.12') +2001-01-01 20:20:20.22 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND) +2001-01-01 00:00:01 +SELECT DATE_ADD('2001-01-01 00:00:00.1', INTERVAL 1 SECOND); +DATE_ADD('2001-01-01 00:00:00.1', INTERVAL 1 SECOND) +2001-01-01 00:00:01.1 +SELECT DATE_ADD('2001-01-01 00:00:00.12', INTERVAL 1 SECOND); +DATE_ADD('2001-01-01 00:00:00.12', INTERVAL 1 SECOND) +2001-01-01 00:00:01.12 +SELECT DATE_ADD('2001-01-01 00:00:00.123', INTERVAL 1 SECOND); +DATE_ADD('2001-01-01 00:00:00.123', INTERVAL 1 SECOND) +2001-01-01 00:00:01.123 +SELECT DATE_ADD('2001-01-01 00:00:00.1234', INTERVAL 1 SECOND); +DATE_ADD('2001-01-01 00:00:00.1234', INTERVAL 1 SECOND) +2001-01-01 00:00:01.1234 +SELECT DATE_ADD('2001-01-01 00:00:00.12345', INTERVAL 1 SECOND); +DATE_ADD('2001-01-01 00:00:00.12345', INTERVAL 1 SECOND) +2001-01-01 00:00:01.12345 +SELECT DATE_ADD('2001-01-01 00:00:00.123456', INTERVAL 1 SECOND); +DATE_ADD('2001-01-01 00:00:00.123456', INTERVAL 1 SECOND) +2001-01-01 00:00:01.123456 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND) +2001-01-01 00:00:01 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1 SECOND) +2001-01-01 00:00:01.1 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12 SECOND) +2001-01-01 00:00:01.12 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123 SECOND) +2001-01-01 00:00:01.123 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1234 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1234 SECOND) +2001-01-01 00:00:01.1234 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12345 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12345 SECOND) +2001-01-01 00:00:01.12345 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123456 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123456 SECOND) +2001-01-01 00:00:01.123456 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL -1 SECOND) +2000-12-31 23:59:59 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1 SECOND) +2000-12-31 23:59:58.9 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12 SECOND) +2000-12-31 23:59:58.88 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123 SECOND) +2000-12-31 23:59:58.877 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1234 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1234 SECOND) +2000-12-31 23:59:58.8766 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12345 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12345 SECOND) +2000-12-31 23:59:58.87655 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123456 SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123456 SECOND) +2000-12-31 23:59:58.876544 +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 'xxx' SECOND); +DATE_ADD('2001-01-01 00:00:00', INTERVAL 'xxx' SECOND) +2001-01-01 00:00:00.000000 +Warnings: +Warning 1292 Truncated incorrect DECIMAL value: 'xxx' +SELECT CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00'); +CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00') +2001-01-01 11:20:30.12 diff --git a/mysql-test/r/func_time_hires.result b/mysql-test/r/func_time_hires.result index 4aa0333c4b4..1a736c89573 100644 --- a/mysql-test/r/func_time_hires.result +++ b/mysql-test/r/func_time_hires.result @@ -15,11 +15,11 @@ current_time(3) 01:01:01.123 current_timestamp(4) 2011-01-01 01:01:01.1234 localtime(5) 2011-01-01 01:01:01.12345 localtimestamp(6) 2011-01-01 01:01:01.123456 -time_to_sec('12:34:56') 45296.000000 -time_to_sec('12:34:56.789') 45296.789000 +time_to_sec('12:34:56') 45296 +time_to_sec('12:34:56.789') 45296.789 select sec_to_time(time_to_sec('1:2:3')), sec_to_time(time_to_sec('2:3:4.567890')); -sec_to_time(time_to_sec('1:2:3')) 01:02:03.000000 -sec_to_time(time_to_sec('2:3:4.567890')) 02:03:04.567890 +sec_to_time(time_to_sec('1:2:3')) 01:02:03 +sec_to_time(time_to_sec('2:3:4.567890')) 02:03:04.56789 select time_to_sec(sec_to_time(11111)), time_to_sec(sec_to_time(11111.22222)); time_to_sec(sec_to_time(11111)) 11111 time_to_sec(sec_to_time(11111.22222)) 11111.22222 @@ -48,7 +48,7 @@ t1 CREATE TABLE `t1` ( `localtime(5)` datetime(5) NOT NULL DEFAULT '0000-00-00 00:00:00.00000', `localtimestamp(6)` datetime(6) NOT NULL DEFAULT '0000-00-00 00:00:00.000000', `time_to_sec(123456)` bigint(17) DEFAULT NULL, - `time_to_sec('12:34:56.789')` decimal(22,6) DEFAULT NULL + `time_to_sec('12:34:56.789')` decimal(19,3) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 select * from t1; sec_to_time(12345) 03:25:45 @@ -63,15 +63,15 @@ current_timestamp(4) 2011-01-01 01:01:01.1234 localtime(5) 2011-01-01 01:01:01.12345 localtimestamp(6) 2011-01-01 01:01:01.123456 time_to_sec(123456) 45296 -time_to_sec('12:34:56.789') 45296.789000 +time_to_sec('12:34:56.789') 45296.789 drop table t1; select unix_timestamp('2011-01-01 01:01:01'), unix_timestamp('2011-01-01 01:01:01.123456'), unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(0))), unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(4)));; -unix_timestamp('2011-01-01 01:01:01') 1293832861.000000 +unix_timestamp('2011-01-01 01:01:01') 1293832861 unix_timestamp('2011-01-01 01:01:01.123456') 1293832861.123456 unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(0))) 1293832861 unix_timestamp(cast('2011-01-01 01:01:01.123456' as datetime(4))) 1293832861.1234 select from_unixtime(unix_timestamp('2011/1/1 1:1:1')), from_unixtime(unix_timestamp('2011/1/1 1:1:1.123456')), from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(0)))), from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(4))));; -from_unixtime(unix_timestamp('2011/1/1 1:1:1')) 2011-01-01 01:01:01.000000 +from_unixtime(unix_timestamp('2011/1/1 1:1:1')) 2011-01-01 01:01:01 from_unixtime(unix_timestamp('2011/1/1 1:1:1.123456')) 2011-01-01 01:01:01.123456 from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(0)))) 2011-01-01 01:01:01 from_unixtime(unix_timestamp(cast('2011/1/1 1:1:1.123456' as datetime(4)))) 2011-01-01 01:01:01.1234 @@ -167,7 +167,7 @@ CONVERT_TZ('2011-01-02 12:00:00', '+00:00', '+03:00') 2011-01-02 15:00:00 SELECT CONVERT_TZ('2011-01-02 12:00:00.123', '+00:00', '+03:00'); CONVERT_TZ('2011-01-02 12:00:00.123', '+00:00', '+03:00') -2011-01-02 15:00:00.123000 +2011-01-02 15:00:00.123 SELECT CONVERT_TZ('2011-01-02 12:00:00.123456', '+00:00', '+03:00'); CONVERT_TZ('2011-01-02 12:00:00.123456', '+00:00', '+03:00') 2011-01-02 15:00:00.123456 @@ -200,7 +200,7 @@ time(f1) alter table t1 modify f1 varchar(100); select time(f1) from t1; time(f1) -21:00:00 +21:00:00.000000 select time(f1) from t1 union all select time(f1 + interval 1 second) from t1; time(f1) 21:00:00.000000 diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index cce5d6e9e2f..4b245edef09 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -1793,8 +1793,8 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) DEFAULT NULL, - `param10` decimal(65,30) DEFAULT NULL, + `const10` bigint(17) DEFAULT NULL, + `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, `const12` binary(0) DEFAULT NULL, @@ -1823,8 +1823,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 Y 0 6 63 -def test t5 t5 param10 param10 246 67 40 Y 0 30 63 +def test t5 t5 const10 const10 8 17 9 Y 32768 0 63 +def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 128 0 63 @@ -1850,8 +1850,8 @@ const08 1991-08-05 01:01:01 param08 1991-08-05 01:01:01 const09 1991-08-05 01:01:01 param09 1991-08-05 01:01:01 -const10 662680861.000000 -param10 662680861.000000000000000000000000000000 +const10 662680861 +param10 662680861 const11 1991 param11 1991 const12 NULL diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index 328df9e5978..4798d63b5e7 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -1776,8 +1776,8 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) DEFAULT NULL, - `param10` decimal(65,30) DEFAULT NULL, + `const10` bigint(17) DEFAULT NULL, + `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, `const12` binary(0) DEFAULT NULL, @@ -1806,8 +1806,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 Y 0 6 63 -def test t5 t5 param10 param10 246 67 40 Y 0 30 63 +def test t5 t5 const10 const10 8 17 9 Y 32768 0 63 +def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 128 0 63 @@ -1833,8 +1833,8 @@ const08 1991-08-05 01:01:01 param08 1991-08-05 01:01:01 const09 1991-08-05 01:01:01 param09 1991-08-05 01:01:01 -const10 662680861.000000 -param10 662680861.000000000000000000000000000000 +const10 662680861 +param10 662680861 const11 1991 param11 1991 const12 NULL diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index cc4330c57e4..f94273ea3ad 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -1777,8 +1777,8 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) DEFAULT NULL, - `param10` decimal(65,30) DEFAULT NULL, + `const10` bigint(17) DEFAULT NULL, + `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, `const12` binary(0) DEFAULT NULL, @@ -1807,8 +1807,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 Y 0 6 63 -def test t5 t5 param10 param10 246 67 40 Y 0 30 63 +def test t5 t5 const10 const10 8 17 9 Y 32768 0 63 +def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 128 0 63 @@ -1834,8 +1834,8 @@ const08 1991-08-05 01:01:01 param08 1991-08-05 01:01:01 const09 1991-08-05 01:01:01 param09 1991-08-05 01:01:01 -const10 662680861.000000 -param10 662680861.000000000000000000000000000000 +const10 662680861 +param10 662680861 const11 1991 param11 1991 const12 NULL diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index fe1665fc24e..eed82775d7b 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -1713,8 +1713,8 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) DEFAULT NULL, - `param10` decimal(65,30) DEFAULT NULL, + `const10` bigint(17) DEFAULT NULL, + `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, `const12` binary(0) DEFAULT NULL, @@ -1743,8 +1743,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 Y 0 6 63 -def test t5 t5 param10 param10 246 67 40 Y 0 30 63 +def test t5 t5 const10 const10 8 17 9 Y 32768 0 63 +def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 128 0 63 @@ -1770,8 +1770,8 @@ const08 1991-08-05 01:01:01 param08 1991-08-05 01:01:01 const09 1991-08-05 01:01:01 param09 1991-08-05 01:01:01 -const10 662680861.000000 -param10 662680861.000000000000000000000000000000 +const10 662680861 +param10 662680861 const11 1991 param11 1991 const12 NULL @@ -5067,8 +5067,8 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) DEFAULT NULL, - `param10` decimal(65,30) DEFAULT NULL, + `const10` bigint(17) DEFAULT NULL, + `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, `const12` binary(0) DEFAULT NULL, @@ -5097,8 +5097,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 Y 0 6 63 -def test t5 t5 param10 param10 246 67 40 Y 0 30 63 +def test t5 t5 const10 const10 8 17 9 Y 32768 0 63 +def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 128 0 63 @@ -5124,8 +5124,8 @@ const08 1991-08-05 01:01:01 param08 1991-08-05 01:01:01 const09 1991-08-05 01:01:01 param09 1991-08-05 01:01:01 -const10 662680861.000000 -param10 662680861.000000000000000000000000000000 +const10 662680861 +param10 662680861 const11 1991 param11 1991 const12 NULL diff --git a/mysql-test/r/timezone.result b/mysql-test/r/timezone.result index 5ae7e6f8117..d84fe54ba8c 100644 --- a/mysql-test/r/timezone.result +++ b/mysql-test/r/timezone.result @@ -7,7 +7,7 @@ select @a:=FROM_UNIXTIME(1); 1970-01-01 01:00:01 select unix_timestamp(@a); unix_timestamp(@a) -1.000000 +1 CREATE TABLE t1 (ts int); INSERT INTO t1 (ts) VALUES (Unix_timestamp('2002-10-27 01:00')); INSERT INTO t1 (ts) VALUES (Unix_timestamp('2002-10-27 02:00')); @@ -44,7 +44,7 @@ unix_timestamp('1970-01-01 01:00:01'), unix_timestamp('2038-01-19 04:14:07'), unix_timestamp('2038-01-19 04:14:08'); unix_timestamp('1970-01-01 01:00:00') unix_timestamp('1970-01-01 01:00:01') unix_timestamp('2038-01-19 04:14:07') unix_timestamp('2038-01-19 04:14:08') -0.000000 1.000000 2147483647.000000 NULL +0 1 2147483647 NULL select unix_timestamp('1969-12-31 23:59:59'), unix_timestamp('1970-01-01 00:00:00'), unix_timestamp('1970-01-01 00:59:59'); unix_timestamp('1969-12-31 23:59:59') unix_timestamp('1970-01-01 00:00:00') unix_timestamp('1970-01-01 00:59:59') NULL NULL NULL diff --git a/mysql-test/r/timezone4.result b/mysql-test/r/timezone4.result index ad0672890a2..28028bea657 100644 --- a/mysql-test/r/timezone4.result +++ b/mysql-test/r/timezone4.result @@ -3,4 +3,4 @@ from_unixtime(0) 1969-12-31 14:00:00 select unix_timestamp('1969-12-31 14:00:01'); unix_timestamp('1969-12-31 14:00:01') -1.000000 +1 diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result index 23943c3c848..c66f3f08e08 100644 --- a/mysql-test/r/type_time.result +++ b/mysql-test/r/type_time.result @@ -186,10 +186,10 @@ Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00' # SELECT CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00'))); CONCAT(GREATEST(TIME('00:00:01'),TIME('00:00:00'))) -00:00:01.000000 +00:00:01 SELECT CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00'))); CONCAT(GREATEST(TIME('32 00:00:01'),TIME('00:00:00'))) -768:00:01.000000 +768:00:01 # # End of 5.3 tests # diff --git a/mysql-test/suite/maria/r/ps_maria.result b/mysql-test/suite/maria/r/ps_maria.result index 3546e78512c..207ae8a59db 100644 --- a/mysql-test/suite/maria/r/ps_maria.result +++ b/mysql-test/suite/maria/r/ps_maria.result @@ -1793,8 +1793,8 @@ t5 CREATE TABLE `t5` ( `param08` longtext, `const09` datetime DEFAULT NULL, `param09` longblob, - `const10` decimal(22,6) DEFAULT NULL, - `param10` decimal(65,30) DEFAULT NULL, + `const10` bigint(17) DEFAULT NULL, + `param10` bigint(20) DEFAULT NULL, `const11` int(4) DEFAULT NULL, `param11` bigint(20) DEFAULT NULL, `const12` binary(0) DEFAULT NULL, @@ -1823,8 +1823,8 @@ def test t5 t5 const08 const08 253 19 19 N 1 0 8 def test t5 t5 param08 param08 252 4294967295 19 Y 16 0 8 def test t5 t5 const09 const09 12 19 19 Y 128 0 63 def test t5 t5 param09 param09 252 4294967295 19 Y 144 0 63 -def test t5 t5 const10 const10 246 24 16 Y 0 6 63 -def test t5 t5 param10 param10 246 67 40 Y 0 30 63 +def test t5 t5 const10 const10 8 17 9 Y 32768 0 63 +def test t5 t5 param10 param10 8 20 9 Y 32768 0 63 def test t5 t5 const11 const11 3 4 4 Y 32768 0 63 def test t5 t5 param11 param11 8 20 4 Y 32768 0 63 def test t5 t5 const12 const12 254 0 0 Y 128 0 63 @@ -1850,8 +1850,8 @@ const08 1991-08-05 01:01:01 param08 1991-08-05 01:01:01 const09 1991-08-05 01:01:01 param09 1991-08-05 01:01:01 -const10 662680861.000000 -param10 662680861.000000000000000000000000000000 +const10 662680861 +param10 662680861 const11 1991 param11 1991 const12 NULL diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 6aedf3f55df..aba78b92c3e 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1255,3 +1255,69 @@ CREATE TABLE t1 AS SELECT CONCAT(CASE WHEN 1 THEN TIME(101010) ELSE TIME(101010) END) AS c4; SHOW CREATE TABLE t1; DROP TABLE t1; + + +--echo # +--echo # MDEV-4724 Some temporal functions do not preserve microseconds +--echo # +SELECT MAKETIME(10,10,10.231); +SELECT MAKETIME(0, 0, 59.9); +CREATE TABLE t1 AS SELECT + MAKETIME(10,00,00), + MAKETIME(10,00,00.1), + MAKETIME(10,00,00.12), + MAKETIME(10,00,00.123), + MAKETIME(10,00,00.1234), + MAKETIME(10,00,00.12345), + MAKETIME(10,00,00.123456); +SHOW COLUMNS FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 AS SELECT + TIME('10:00:00'), + TIME('10:00:00.1'), + TIME('10:00:00.12'), + TIME('10:00:00.123'), + TIME('10:00:00.1234'), + TIME('10:00:00.12345'), + TIME('10:00:00.12346'); +SHOW COLUMNS FROM t1; +DROP TABLE t1; + +SET TIME_ZONE='+00:00'; +SET TIMESTAMP=UNIX_TIMESTAMP('2012-10-16 22:46:17'); +SELECT NOW(), UNIX_TIMESTAMP(), UNIX_TIMESTAMP(NOW()),UNIX_TIMESTAMP('2012-10-16 22:46:17'); +SET TIMESTAMP=UNIX_TIMESTAMP('1970-01-02 03:04:05.123456'); +SELECT @@timestamp, FROM_UNIXTIME(@@timestamp); +SET TIME_ZONE=DEFAULT; +SET TIMESTAMP=DEFAULT; + +SELECT TIME('2012-10-16 15:54:16.12'); +SELECT TIMESTAMP('2012-10-16 15:54:16.12'); +SELECT TIMEDIFF('10:10:10.1','00:00:00'); +SELECT TIME_TO_SEC('10:10:10'); +SELECT ADDTIME(TIME('10:10:10.1'),'10:10:10.12'); +SELECT ADDTIME(TIMESTAMP('2001-01-01 10:10:10.1'),'10:10:10.12'); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00.1', INTERVAL 1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00.12', INTERVAL 1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00.123', INTERVAL 1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00.1234', INTERVAL 1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00.12345', INTERVAL 1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00.123456', INTERVAL 1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.1234 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.12345 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 1.123456 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.1234 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12345 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123456 SECOND); +SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 'xxx' SECOND); +SELECT CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00'); -- cgit v1.2.1 From e7c4e6d8708378f4b501eec3576a3229136144e3 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 13 Sep 2013 23:42:00 +0200 Subject: MDEV-5012 Server crashes in Item_ref::real_item on EXPLAIN with select subqueries or views, constant table, derived_merge+derived_with_keys revert incorrect change, merged from mysql-5.5 --- mysql-test/r/derived.result | 14 ++++++++++++++ mysql-test/t/derived.test | 12 ++++++++++++ 2 files changed, 26 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index c94618a9497..685e8ddd6bc 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -476,4 +476,18 @@ n d1 d2 result 2085 2012-01-01 00:00:00 2013-01-01 00:00:00 0 2084 2012-02-01 00:00:00 2013-01-01 00:00:00 0 drop table t1; +SET optimizer_switch = 'derived_merge=on,derived_with_keys=on,in_to_exists=on'; +CREATE TABLE t1 (a INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (8); +CREATE TABLE t2 (b INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1),(7); +EXPLAIN SELECT * FROM (SELECT * FROM t1) AS table1, +(SELECT DISTINCT * FROM t2) AS table2 WHERE b = a AND a <> ANY (SELECT 9); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 system NULL NULL NULL NULL 1 +1 PRIMARY ref key0 key0 5 const 0 +3 DERIVED t2 ALL NULL NULL NULL NULL 2 Using temporary +Warnings: +Note 1249 Select 4 was reduced during optimization +DROP TABLE t1, t2; set optimizer_switch=@save_derived_optimizer_switch; diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index bcbe995341a..008af317aec 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -389,4 +389,16 @@ select * from ( ) as calculated_result; drop table t1; +# +# MDEV-5012 Server crashes in Item_ref::real_item on EXPLAIN with select subqueries or views, constant table, derived_merge+derived_with_keys +# +SET optimizer_switch = 'derived_merge=on,derived_with_keys=on,in_to_exists=on'; +CREATE TABLE t1 (a INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (8); +CREATE TABLE t2 (b INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1),(7); +EXPLAIN SELECT * FROM (SELECT * FROM t1) AS table1, + (SELECT DISTINCT * FROM t2) AS table2 WHERE b = a AND a <> ANY (SELECT 9); +DROP TABLE t1, t2; + set optimizer_switch=@save_derived_optimizer_switch; -- cgit v1.2.1 From 996f6194c69b556e37a143a6a175e60a9f57ab47 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Sun, 15 Sep 2013 12:38:22 -0700 Subject: Fixed bug mdev-5015. The patch for mdev-4355 had a defect: the cached values for bitmaps of used tables were not updated when processing degenerate OR formulas. --- mysql-test/r/func_group.result | 13 +++++++++++++ mysql-test/t/func_group.test | 20 ++++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 5fa37f577e9..ebb379dfd7e 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -2124,4 +2124,17 @@ select z from (select count(*) as z from t1) v group by 1; z 4 drop table t1; +CREATE TABLE t1 (i1 int, INDEX(i1)); +INSERT INTO t1 VALUES (9),(8); +CREATE TABLE t2 (i2 int); +INSERT INTO t2 VALUES (8),(4); +CREATE TABLE t3 (i3 int, INDEX(i3)); +INSERT INTO t3 VALUES (9),(8); +SELECT MAX(t3.i3) FROM t3, t2, t1 WHERE t1.i1 = t2.i2 AND ( 0 OR t3.i3 = t2.i2 ); +MAX(t3.i3) +8 +SELECT MAX(t3.i3) FROM t3, t2, t1 WHERE t1.i1 = t2.i2 AND t3.i3 = t2.i2; +MAX(t3.i3) +8 +DROP TABLE t1,t2,t3; # end of 5.3 tests diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 9f0d7e102da..e61962bc8a4 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -1403,4 +1403,24 @@ select z from (select count(*) as z from t1) v; select z from (select count(*) as z from t1) v group by 1; drop table t1; +# +# Bug mdev-5015: Degenerate OR condition in an aggregated join +# + +CREATE TABLE t1 (i1 int, INDEX(i1)); +INSERT INTO t1 VALUES (9),(8); + +CREATE TABLE t2 (i2 int); +INSERT INTO t2 VALUES (8),(4); + + +CREATE TABLE t3 (i3 int, INDEX(i3)); +INSERT INTO t3 VALUES (9),(8); + +SELECT MAX(t3.i3) FROM t3, t2, t1 WHERE t1.i1 = t2.i2 AND ( 0 OR t3.i3 = t2.i2 ); + +SELECT MAX(t3.i3) FROM t3, t2, t1 WHERE t1.i1 = t2.i2 AND t3.i3 = t2.i2; + +DROP TABLE t1,t2,t3; + --echo # end of 5.3 tests -- cgit v1.2.1 From 5d7b97b89ec2073bd8dffead6adb895cf1b15adc Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 16 Sep 2013 10:14:41 +0400 Subject: MDEV-4843 Wrong data type for TIMESTAMP('2001-01-01','10:10:10') --- mysql-test/r/func_time.result | 64 +++++++++++++++++++++++++++++++++++++++++++ mysql-test/t/func_time.test | 36 ++++++++++++++++++++++++ 2 files changed, 100 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 99104136f2b..c85002d93f0 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -2177,3 +2177,67 @@ Warning 1292 Truncated incorrect DECIMAL value: 'xxx' SELECT CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00'); CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00') 2001-01-01 11:20:30.12 +# +# MDEV-4843 Wrong data type for TIMESTAMP('2001-01-01','10:10:10') +# +CREATE TABLE t1 AS SELECT +TIMESTAMP('2001-01-01','10:10:10'), +TIMESTAMP('2001-01-01','10:10:10.1'), +TIMESTAMP('2001-01-01','10:10:10.12'), +TIMESTAMP('2001-01-01','10:10:10.123'), +TIMESTAMP('2001-01-01','10:10:10.1234'), +TIMESTAMP('2001-01-01','10:10:10.12345'), +TIMESTAMP('2001-01-01','10:10:10.123456'), +TIMESTAMP('2001-01-01','10:10:10.1234567'); +Warnings: +Warning 1292 Truncated incorrect time value: '10:10:10.1234567' +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +TIMESTAMP('2001-01-01','10:10:10') datetime YES NULL +TIMESTAMP('2001-01-01','10:10:10.1') datetime(1) YES NULL +TIMESTAMP('2001-01-01','10:10:10.12') datetime(2) YES NULL +TIMESTAMP('2001-01-01','10:10:10.123') datetime(3) YES NULL +TIMESTAMP('2001-01-01','10:10:10.1234') datetime(4) YES NULL +TIMESTAMP('2001-01-01','10:10:10.12345') datetime(5) YES NULL +TIMESTAMP('2001-01-01','10:10:10.123456') datetime(6) YES NULL +TIMESTAMP('2001-01-01','10:10:10.1234567') datetime(6) YES NULL +SELECT * FROM t1; +TIMESTAMP('2001-01-01','10:10:10') TIMESTAMP('2001-01-01','10:10:10.1') TIMESTAMP('2001-01-01','10:10:10.12') TIMESTAMP('2001-01-01','10:10:10.123') TIMESTAMP('2001-01-01','10:10:10.1234') TIMESTAMP('2001-01-01','10:10:10.12345') TIMESTAMP('2001-01-01','10:10:10.123456') TIMESTAMP('2001-01-01','10:10:10.1234567') +2001-01-01 10:10:10 2001-01-01 10:10:10.1 2001-01-01 10:10:10.12 2001-01-01 10:10:10.123 2001-01-01 10:10:10.1234 2001-01-01 10:10:10.12345 2001-01-01 10:10:10.123456 2001-01-01 10:10:10.123456 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +TIMESTAMP('2001-01-01 00:00:00','10:10:10'), +TIMESTAMP('2001-01-01 00:00:00.1','10:10:10'), +TIMESTAMP('2001-01-01 00:00:00.12','10:10:10'), +TIMESTAMP('2001-01-01 00:00:00.123','10:10:10'), +TIMESTAMP('2001-01-01 00:00:00.1234','10:10:10'), +TIMESTAMP('2001-01-01 00:00:00.12345','10:10:10'), +TIMESTAMP('2001-01-01 00:00:00.123456','10:10:10'), +TIMESTAMP('2001-01-01 00:00:00.1234567','10:10:10'); +Warnings: +Warning 1292 Truncated incorrect datetime value: '2001-01-01 00:00:00.1234567' +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +TIMESTAMP('2001-01-01 00:00:00','10:10:10') datetime YES NULL +TIMESTAMP('2001-01-01 00:00:00.1','10:10:10') datetime(1) YES NULL +TIMESTAMP('2001-01-01 00:00:00.12','10:10:10') datetime(2) YES NULL +TIMESTAMP('2001-01-01 00:00:00.123','10:10:10') datetime(3) YES NULL +TIMESTAMP('2001-01-01 00:00:00.1234','10:10:10') datetime(4) YES NULL +TIMESTAMP('2001-01-01 00:00:00.12345','10:10:10') datetime(5) YES NULL +TIMESTAMP('2001-01-01 00:00:00.123456','10:10:10') datetime(6) YES NULL +TIMESTAMP('2001-01-01 00:00:00.1234567','10:10:10') datetime(6) YES NULL +SELECT * FROM t1; +TIMESTAMP('2001-01-01 00:00:00','10:10:10') TIMESTAMP('2001-01-01 00:00:00.1','10:10:10') TIMESTAMP('2001-01-01 00:00:00.12','10:10:10') TIMESTAMP('2001-01-01 00:00:00.123','10:10:10') TIMESTAMP('2001-01-01 00:00:00.1234','10:10:10') TIMESTAMP('2001-01-01 00:00:00.12345','10:10:10') TIMESTAMP('2001-01-01 00:00:00.123456','10:10:10') TIMESTAMP('2001-01-01 00:00:00.1234567','10:10:10') +2001-01-01 10:10:10 2001-01-01 10:10:10.1 2001-01-01 10:10:10.12 2001-01-01 10:10:10.123 2001-01-01 10:10:10.1234 2001-01-01 10:10:10.12345 2001-01-01 10:10:10.123456 2001-01-01 10:10:10.123456 +DROP TABLE t1; +CREATE TABLE t1 AS SELECT +TIMESTAMP('00:00:00','10:10:10'), +TIMESTAMP(TIME('00:00:00'),'10:10:10'); +SHOW COLUMNS FROM t1; +Field Type Null Key Default Extra +TIMESTAMP('00:00:00','10:10:10') datetime YES NULL +TIMESTAMP(TIME('00:00:00'),'10:10:10') datetime YES NULL +SELECT * FROM t1; +TIMESTAMP('00:00:00','10:10:10') TIMESTAMP(TIME('00:00:00'),'10:10:10') +NULL NULL +DROP TABLE t1; diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index aba78b92c3e..4a3d74317c4 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1321,3 +1321,39 @@ SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.12345 SECOND); SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123456 SECOND); SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 'xxx' SECOND); SELECT CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00'); + +--echo # +--echo # MDEV-4843 Wrong data type for TIMESTAMP('2001-01-01','10:10:10') +--echo # +CREATE TABLE t1 AS SELECT + TIMESTAMP('2001-01-01','10:10:10'), + TIMESTAMP('2001-01-01','10:10:10.1'), + TIMESTAMP('2001-01-01','10:10:10.12'), + TIMESTAMP('2001-01-01','10:10:10.123'), + TIMESTAMP('2001-01-01','10:10:10.1234'), + TIMESTAMP('2001-01-01','10:10:10.12345'), + TIMESTAMP('2001-01-01','10:10:10.123456'), + TIMESTAMP('2001-01-01','10:10:10.1234567'); +SHOW COLUMNS FROM t1; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 AS SELECT + TIMESTAMP('2001-01-01 00:00:00','10:10:10'), + TIMESTAMP('2001-01-01 00:00:00.1','10:10:10'), + TIMESTAMP('2001-01-01 00:00:00.12','10:10:10'), + TIMESTAMP('2001-01-01 00:00:00.123','10:10:10'), + TIMESTAMP('2001-01-01 00:00:00.1234','10:10:10'), + TIMESTAMP('2001-01-01 00:00:00.12345','10:10:10'), + TIMESTAMP('2001-01-01 00:00:00.123456','10:10:10'), + TIMESTAMP('2001-01-01 00:00:00.1234567','10:10:10'); +SHOW COLUMNS FROM t1; +SELECT * FROM t1; +DROP TABLE t1; + +CREATE TABLE t1 AS SELECT + TIMESTAMP('00:00:00','10:10:10'), + TIMESTAMP(TIME('00:00:00'),'10:10:10'); +SHOW COLUMNS FROM t1; +SELECT * FROM t1; +DROP TABLE t1; -- cgit v1.2.1 From 6c9d98328716795bc9ce04d7c3e013de345ee784 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 16 Sep 2013 13:03:49 +0400 Subject: MDEV-4869 Wrong result of MAKETIME(0, 0, -0.1) Adding a test case only. The problem was fixed by: MDEV-4724 Some temporal functions do not preserve microseconds modified: mysql-test/r/func_time.result mysql-test/t/func_time.test --- mysql-test/r/func_time.result | 6 ++++++ mysql-test/t/func_time.test | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index c85002d93f0..eec9a4e7ea3 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -2241,3 +2241,9 @@ SELECT * FROM t1; TIMESTAMP('00:00:00','10:10:10') TIMESTAMP(TIME('00:00:00'),'10:10:10') NULL NULL DROP TABLE t1; +# +# MDEV-4869 Wrong result of MAKETIME(0, 0, -0.1) +# +SELECT MAKETIME(0, 0, -0.1); +MAKETIME(0, 0, -0.1) +NULL diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 4a3d74317c4..87be964cd7e 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1357,3 +1357,9 @@ CREATE TABLE t1 AS SELECT SHOW COLUMNS FROM t1; SELECT * FROM t1; DROP TABLE t1; + +--echo # +--echo # MDEV-4869 Wrong result of MAKETIME(0, 0, -0.1) +--echo # +SELECT MAKETIME(0, 0, -0.1); + -- cgit v1.2.1 From 22c4a2496171416960058b3c25d2bbee3f6fc6cf Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 16 Sep 2013 13:52:13 +0400 Subject: MDEV-4870 Wrong values of CASE, COALESCE, IFNULL on a combination of different temporal types Adding test cases from the bug report only. The problem was earlier fixed by: MDEV-4863 COALESCE(time_or_datetime) returns wrong results in numeric context modified: mysql-test/r/func_time.result mysql-test/t/func_time.test --- mysql-test/r/func_time.result | 50 +++++++++++++++++++++++++++++++++++++++++++ mysql-test/t/func_time.test | 24 +++++++++++++++++++++ 2 files changed, 74 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index eec9a4e7ea3..8aba949ad55 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -2033,6 +2033,56 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; # +# MDEV-4870 Wrong values of CASE, COALESCE, IFNULL on a combination of different temporal types +# +CREATE TABLE t1 (dt2 DATETIME(2), t3 TIME(3), d DATE); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.12', '00:00:00.567', '2002-01-01'); +SELECT CASE WHEN 0 THEN dt2 ELSE t3 END FROM t1; +CASE WHEN 0 THEN dt2 ELSE t3 END +0000-00-00 00:00:00.567 +CREATE TABLE t2 AS SELECT CASE WHEN 0 THEN dt2 ELSE t3 END FROM t1; +SELECT * FROM t2; +CASE WHEN 0 THEN dt2 ELSE t3 END +0000-00-00 00:00:00.567 +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +CASE WHEN 0 THEN dt2 ELSE t3 END datetime(3) YES NULL +DROP TABLE t2; +SELECT CASE WHEN 1 THEN dt2 ELSE t3 END FROM t1; +CASE WHEN 1 THEN dt2 ELSE t3 END +2001-01-01 00:00:00.120 +SELECT CONCAT(CASE WHEN 1 THEN dt2 ELSE t3 END) FROM t1; +CONCAT(CASE WHEN 1 THEN dt2 ELSE t3 END) +2001-01-01 00:00:00.120 +SELECT CONCAT(CASE WHEN 0 THEN t3 ELSE dt2 END) FROM t1; +CONCAT(CASE WHEN 0 THEN t3 ELSE dt2 END) +2001-01-01 00:00:00.120 +SELECT CONCAT(CASE WHEN 1 THEN d ELSE t3 END) FROM t1; +CONCAT(CASE WHEN 1 THEN d ELSE t3 END) +2002-01-01 00:00:00.000 +SELECT CASE WHEN 1 THEN t3 ELSE d END FROM t1; +CASE WHEN 1 THEN t3 ELSE d END +0000-00-00 00:00:00.567 +SELECT COALESCE(d, t3) FROM t1; +COALESCE(d, t3) +2002-01-01 00:00:00.000 +SELECT CONCAT(COALESCE(d, t3)) FROM t1; +CONCAT(COALESCE(d, t3)) +2002-01-01 00:00:00.000 +SELECT COALESCE(dt2, t3) FROM t1; +COALESCE(dt2, t3) +2001-01-01 00:00:00.120 +SELECT CONCAT(COALESCE(dt2, t3)) FROM t1; +CONCAT(COALESCE(dt2, t3)) +2001-01-01 00:00:00.120 +SELECT IFNULL(dt2, t3), CONCAT(IFNULL(dt2, t3)) FROM t1; +IFNULL(dt2, t3) CONCAT(IFNULL(dt2, t3)) +2001-01-01 00:00:00.120 2001-01-01 00:00:00.120 +SELECT IFNULL(d, t3), CONCAT(IFNULL(d, t3)) FROM t1; +IFNULL(d, t3) CONCAT(IFNULL(d, t3)) +2002-01-01 00:00:00.000 2002-01-01 00:00:00.000 +DROP TABLE t1; +# # MDEV-4724 Some temporal functions do not preserve microseconds # SELECT MAKETIME(10,10,10.231); diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 87be964cd7e..62df3221723 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1257,6 +1257,30 @@ SHOW CREATE TABLE t1; DROP TABLE t1; +--echo # +--echo # MDEV-4870 Wrong values of CASE, COALESCE, IFNULL on a combination of different temporal types +--echo # +CREATE TABLE t1 (dt2 DATETIME(2), t3 TIME(3), d DATE); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00.12', '00:00:00.567', '2002-01-01'); +SELECT CASE WHEN 0 THEN dt2 ELSE t3 END FROM t1; +CREATE TABLE t2 AS SELECT CASE WHEN 0 THEN dt2 ELSE t3 END FROM t1; +SELECT * FROM t2; +SHOW COLUMNS FROM t2; +DROP TABLE t2; +SELECT CASE WHEN 1 THEN dt2 ELSE t3 END FROM t1; +SELECT CONCAT(CASE WHEN 1 THEN dt2 ELSE t3 END) FROM t1; +SELECT CONCAT(CASE WHEN 0 THEN t3 ELSE dt2 END) FROM t1; +SELECT CONCAT(CASE WHEN 1 THEN d ELSE t3 END) FROM t1; +SELECT CASE WHEN 1 THEN t3 ELSE d END FROM t1; +SELECT COALESCE(d, t3) FROM t1; +SELECT CONCAT(COALESCE(d, t3)) FROM t1; +SELECT COALESCE(dt2, t3) FROM t1; +SELECT CONCAT(COALESCE(dt2, t3)) FROM t1; +SELECT IFNULL(dt2, t3), CONCAT(IFNULL(dt2, t3)) FROM t1; +SELECT IFNULL(d, t3), CONCAT(IFNULL(d, t3)) FROM t1; +DROP TABLE t1; + + --echo # --echo # MDEV-4724 Some temporal functions do not preserve microseconds --echo # -- cgit v1.2.1 From 5464e904b6db84cbbdc7aeb90fbb2115166d432f Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 16 Sep 2013 14:07:01 +0400 Subject: MDEV-4861 TIME/DATETIME arithmetics does not preserve INTERVAL precision Adding tests only. The problem was earlier fixed by MDEV-4724 Some temporal functions do not preserve microseconds --- mysql-test/r/func_time.result | 23 +++++++++++++++++++++++ mysql-test/t/func_time.test | 18 ++++++++++++++++++ 2 files changed, 41 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 8aba949ad55..645733a3dc0 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -2228,6 +2228,29 @@ SELECT CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00'); CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00') 2001-01-01 11:20:30.12 # +# MDEV-4861 TIME/DATETIME arithmetics does not preserve INTERVAL precision +# +CREATE TABLE t1 (t0 TIME); +INSERT INTO t1 VALUES ('00:00:00'); +SELECT t0 + INTERVAL 1.1 SECOND FROM t1; +t0 + INTERVAL 1.1 SECOND +00:00:01.1 +CREATE TABLE t2 AS SELECT t0 + INTERVAL 1.1 SECOND FROM t1; +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +t0 + INTERVAL 1.1 SECOND time(1) YES NULL +DROP TABLE t1,t2; +CREATE TABLE t1 (t0 DATETIME); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00'); +SELECT t0 + INTERVAL 1.1 SECOND FROM t1; +t0 + INTERVAL 1.1 SECOND +2001-01-01 00:00:01.1 +CREATE TABLE t2 AS SELECT t0 + INTERVAL 1.1 SECOND FROM t1; +SHOW COLUMNS FROM t2; +Field Type Null Key Default Extra +t0 + INTERVAL 1.1 SECOND datetime(1) YES NULL +DROP TABLE t1, t2; +# # MDEV-4843 Wrong data type for TIMESTAMP('2001-01-01','10:10:10') # CREATE TABLE t1 AS SELECT diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 62df3221723..72efff02699 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -1346,6 +1346,24 @@ SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL -1.123456 SECOND); SELECT DATE_ADD('2001-01-01 00:00:00', INTERVAL 'xxx' SECOND); SELECT CONVERT_TZ('2001-01-01 10:20:30.12','+00:00','+01:00'); +--echo # +--echo # MDEV-4861 TIME/DATETIME arithmetics does not preserve INTERVAL precision +--echo # +CREATE TABLE t1 (t0 TIME); +INSERT INTO t1 VALUES ('00:00:00'); +SELECT t0 + INTERVAL 1.1 SECOND FROM t1; +CREATE TABLE t2 AS SELECT t0 + INTERVAL 1.1 SECOND FROM t1; +SHOW COLUMNS FROM t2; +DROP TABLE t1,t2; + +CREATE TABLE t1 (t0 DATETIME); +INSERT INTO t1 VALUES ('2001-01-01 00:00:00'); +SELECT t0 + INTERVAL 1.1 SECOND FROM t1; +CREATE TABLE t2 AS SELECT t0 + INTERVAL 1.1 SECOND FROM t1; +SHOW COLUMNS FROM t2; +DROP TABLE t1, t2; + + --echo # --echo # MDEV-4843 Wrong data type for TIMESTAMP('2001-01-01','10:10:10') --echo # -- cgit v1.2.1 From 779003e18073332a73ed185410f95acc1ef85094 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Mon, 16 Sep 2013 16:03:55 +0400 Subject: backport from 10.0 mtr can crash occasionally. This happens when mtr sends to a child mtr process (or vice-versa) a packet, that gets truncated or, perhaps, split in two. Then the other side cannot deserialize it and fails as above. --- mysql-test/lib/My/Test.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mysql-test') diff --git a/mysql-test/lib/My/Test.pm b/mysql-test/lib/My/Test.pm index 012e5f6d81e..6fe169398ca 100644 --- a/mysql-test/lib/My/Test.pm +++ b/mysql-test/lib/My/Test.pm @@ -70,7 +70,7 @@ sub write_test { my $serialized= Storable::freeze($test); $serialized =~ s/([\x0d\x0a\\])/sprintf("\\%02x", ord($1))/eg; - print $sock $header, "\n", $serialized, "\n"; + send $sock,$header. "\n". $serialized. "\n", 0; } -- cgit v1.2.1 From a5d7e701196052f4a6605f465953098eba37a7aa Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 18 Sep 2013 09:09:27 +0200 Subject: MDEV-5029 Crash in MariaDB 5.5.33 with .frm from older MariaDB release don't set TABLE_SHARE::keys before TABLE_SHARE::key_info is set, otherwise an error might leave only the first property set and it will confuse TABLE_SHARE::destroy() --- mysql-test/r/bad_frm_crash_5029.result | 2 ++ mysql-test/std_data/mdev5029.frm | Bin 0 -> 8602 bytes mysql-test/t/bad_frm_crash_5029.test | 11 +++++++++++ 3 files changed, 13 insertions(+) create mode 100644 mysql-test/r/bad_frm_crash_5029.result create mode 100644 mysql-test/std_data/mdev5029.frm create mode 100644 mysql-test/t/bad_frm_crash_5029.test (limited to 'mysql-test') diff --git a/mysql-test/r/bad_frm_crash_5029.result b/mysql-test/r/bad_frm_crash_5029.result new file mode 100644 index 00000000000..7a829c8f6ba --- /dev/null +++ b/mysql-test/r/bad_frm_crash_5029.result @@ -0,0 +1,2 @@ +show create table t1; +ERROR 42000: Unknown storage engine 'InnoDB' diff --git a/mysql-test/std_data/mdev5029.frm b/mysql-test/std_data/mdev5029.frm new file mode 100644 index 00000000000..de169a20953 Binary files /dev/null and b/mysql-test/std_data/mdev5029.frm differ diff --git a/mysql-test/t/bad_frm_crash_5029.test b/mysql-test/t/bad_frm_crash_5029.test new file mode 100644 index 00000000000..b15c37fbc6d --- /dev/null +++ b/mysql-test/t/bad_frm_crash_5029.test @@ -0,0 +1,11 @@ +# +# MDEV-5029 Crash in MariaDB 5.5.33 with .frm from older MariaDB release +# +# a.k.a. fail to open an frm with indexes: + +let $datadir=`select @@datadir`; +copy_file std_data/mdev5029.frm $datadir/test/t1.frm; +--error ER_UNKNOWN_STORAGE_ENGINE +show create table t1; +remove_file $datadir/test/t1.frm; + -- cgit v1.2.1