diff options
author | unknown <gluh@eagle.(none)> | 2007-10-23 19:08:21 +0500 |
---|---|---|
committer | unknown <gluh@eagle.(none)> | 2007-10-23 19:08:21 +0500 |
commit | 95a8bb20fb0c43b95347a42f75f91b040ca1babc (patch) | |
tree | 6a0f011ed453ad26ca914c42a6e2e8e45ce6b3ce /mysql-test | |
parent | fc800ff76d0c1f47126645c7ec742ae07434056b (diff) | |
parent | 6e8919b00d42888bc2ff45cddedba1cf9853a7c5 (diff) | |
download | mariadb-git-95a8bb20fb0c43b95347a42f75f91b040ca1babc.tar.gz |
Merge mysql.com:/home/gluh/MySQL/Merge/5.1
into mysql.com:/home/gluh/MySQL/Merge/5.1-opt
client/client_priv.h:
Auto merged
client/mysqldump.c:
Auto merged
include/config-win.h:
Auto merged
libmysql/libmysql.c:
Auto merged
mysql-test/mysql-test-run.pl:
Auto merged
mysql-test/r/create.result:
Auto merged
mysql-test/r/func_sapdb.result:
Auto merged
mysql-test/r/information_schema.result:
Auto merged
mysql-test/r/variables.result:
Auto merged
mysql-test/t/information_schema.test:
Auto merged
mysql-test/t/variables.test:
Auto merged
sql/field.cc:
Auto merged
sql/ha_partition.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/item_func.h:
Auto merged
sql/item_sum.cc:
Auto merged
sql/item_timefunc.h:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/protocol.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_lex.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
sql/table.cc:
Auto merged
storage/innobase/handler/ha_innodb.cc:
Auto merged
storage/myisam/sort.c:
Auto merged
tests/mysql_client_test.c:
Auto merged
mysql-test/r/query_cache.result:
manual merge
mysql-test/include/mix1.inc:
manual merge
mysql-test/r/innodb_mysql.result:
manual merge
mysql-test/r/type_datetime.result:
manual merge
mysql-test/r/type_decimal.result:
manual merge
mysql-test/t/query_cache.test:
manual merge
mysql-test/t/type_datetime.test:
manual merge
mysql-test/t/type_decimal.test:
manual merge
sql/item.cc:
manual merge
Diffstat (limited to 'mysql-test')
82 files changed, 2329 insertions, 75 deletions
diff --git a/mysql-test/include/gis_keys.inc b/mysql-test/include/gis_keys.inc new file mode 100644 index 00000000000..295e0c48234 --- /dev/null +++ b/mysql-test/include/gis_keys.inc @@ -0,0 +1,46 @@ +--source include/have_geometry.inc + +# +# Spatial objects with keys +# + +# +# Bug #30825: Problems when putting a non-spatial index on a GIS column +# + +CREATE TABLE t1 (p POINT); +CREATE TABLE t2 (p POINT, INDEX(p)); +INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)')); +INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)')); + +-- no index, returns 1 as expected +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); + +-- with index, returns 1 as expected +-- EXPLAIN shows that the index is not used though +-- due to the "most rows covered anyway, so a scan is more effective" rule +EXPLAIN +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); + +-- adding another row to the table so that +-- the "most rows covered" rule doesn't kick in anymore +-- now EXPLAIN shows the index used on the table +-- and we're getting the wrong result again +INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)')); +INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)')); +EXPLAIN +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); + +EXPLAIN +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); + +EXPLAIN +SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)'); +SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)'); + +DROP TABLE t1, t2; + +--echo End of 5.0 tests diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index aee5613ff35..c8d3ba79e39 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -29,6 +29,7 @@ eval SET SESSION STORAGE_ENGINE = $engine_type; --disable_warnings drop table if exists t1,t2,t3,t1m,t1i,t2m,t2i,t4; +drop procedure if exists p1; --enable_warnings @@ -1147,6 +1148,129 @@ select if(@a=@b,"ok","wrong"); drop table t1; # +# Bug #31310: Locked rows silently skipped in read-committed isolation level. +# + +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); +SET SESSION AUTOCOMMIT = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +--echo # Switch to connection con1 +connection con1; + +eval +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256)) +ENGINE = $engine_type; +INSERT INTO t1 VALUES (1,2); + +--#echo 1. test for locking: + +BEGIN; +--enable_info +UPDATE t1 SET b = 12 WHERE a = 1; +--disable_info +SELECT * FROM t1; + +--echo # Switch to connection con2 +connection con2; + +--enable_info +--disable_abort_on_error +--error ER_LOCK_WAIT_TIMEOUT +UPDATE t1 SET b = 21 WHERE a = 1; +--disable_info + +--echo # Switch to connection con1 +connection con1; +SELECT * FROM t1; +ROLLBACK; + +--echo # 2. test for serialized update: + +CREATE TABLE t2 (a INT); + +TRUNCATE t1; +INSERT INTO t1 VALUES (1,'init'); + +DELIMITER |; +CREATE PROCEDURE p1() +BEGIN + UPDATE t1 SET b = CONCAT(b, '+con2') WHERE a = 1; + INSERT INTO t2 VALUES (); +END| +DELIMITER ;| + +BEGIN; +--enable_info +UPDATE t1 SET b = CONCAT(b, '+con1') WHERE a = 1; +--disable_info +SELECT * FROM t1; + +--echo # Switch to connection con2 +connection con2; + +--send CALL p1; + +--echo # Switch to connection con1 +connection con1; +SELECT * FROM t1; +COMMIT; + +let $bug31310 = 1; +while ($bug31310) +{ + let $bug31310= `SELECT 1 - COUNT(*) FROM t2`; +} + +SELECT * FROM t1; + +--echo # Switch to connection con2 +connection con2; +SELECT * FROM t1; + +--echo # Switch to connection con1 +connection con1; + +--echo # 3. test for updated key column: + +TRUNCATE t1; +TRUNCATE t2; + +INSERT INTO t1 VALUES (1,'init'); + +BEGIN; +--enable_info +UPDATE t1 SET a = 2, b = CONCAT(b, '+con1') WHERE a = 1; +--disable_info +SELECT * FROM t1; + +--echo # Switch to connection con2 +connection con2; + +--send CALL p1; + +--echo # Switch to connection con1 +connection con1; +SELECT * FROM t1; +COMMIT; + +let $bug31310 = 1; +while ($bug31310) +{ + let $bug31310= `SELECT 1 - COUNT(*) FROM t2`; +} + +SELECT * FROM t1; + +--echo # Switch to connection con2 +connection con2; +SELECT * FROM t1; + +connection default; +disconnect con1; +disconnect con2; +DROP PROCEDURE p1; +DROP TABLE t1, t2; # Bug#30747 Create table with identical constraint names behaves incorrectly # diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index e2ee11aa7e3..eda268bcedf 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1019,12 +1019,14 @@ sub command_line_setup () { { $opt_testcase_timeout= $default_testcase_timeout; $opt_testcase_timeout*= 10 if $opt_valgrind; + $opt_testcase_timeout*= 10 if ($opt_debug and $glob_win32); } if ( ! $opt_suite_timeout ) { $opt_suite_timeout= $default_suite_timeout; $opt_suite_timeout*= 6 if $opt_valgrind; + $opt_suite_timeout*= 6 if ($opt_debug and $glob_win32); } if ( ! $opt_user ) diff --git a/mysql-test/r/compress.result b/mysql-test/r/compress.result index 68206c0dc0e..a71d840d229 100644 --- a/mysql-test/r/compress.result +++ b/mysql-test/r/compress.result @@ -611,11 +611,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ref period period 4 test.t1.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using filesort +1 SIMPLE t3 index period period 4 NULL 1 1 SIMPLE t1 ref period period 4 test.t3.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort +1 SIMPLE t1 index period period 4 NULL 1 1 SIMPLE t3 ref period period 4 test.t1.period 4181 select period from t1; period diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index e79a255967b..ca3b344af53 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -438,7 +438,7 @@ explain t2; Field Type Null Key Default Extra a int(11) YES NULL b bigint(11) NO 0 -c bigint(11) NO 0 +c bigint(11) unsigned NO 0 d date YES NULL e varchar(1) NO f datetime YES NULL diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 1097486f185..a0a8455b496 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -922,4 +922,7 @@ ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_gen select * from t1 where a=if(b<10,_ucs2 0x0062,_ucs2 0x00C0); ERROR HY000: Illegal mix of collations (ascii_general_ci,IMPLICIT) and (ucs2_general_ci,COERCIBLE) for operation '=' drop table t1; +select hex(char(0x41 using ucs2)); +hex(char(0x41 using ucs2)) +0041 End of 5.0 tests diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 715dfb1b7d8..8243b2bc015 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -1538,12 +1538,12 @@ char(53647 using utf8) Ñ select char(0xff,0x8f using utf8); char(0xff,0x8f using utf8) -ÿ + Warnings: Warning 1300 Invalid utf8 character string: 'FF8F' select convert(char(0xff,0x8f) using utf8); convert(char(0xff,0x8f) using utf8) -ÿ + Warnings: Warning 1300 Invalid utf8 character string: 'FF8F' set sql_mode=traditional; @@ -1730,3 +1730,41 @@ i 1 н1234567890 DROP TABLE t1, t2; +set sql_mode=traditional; +select hex(char(0xFF using utf8)); +hex(char(0xFF using utf8)) +NULL +Warnings: +Error 1300 Invalid utf8 character string: 'FF' +select hex(convert(0xFF using utf8)); +hex(convert(0xFF using utf8)) +NULL +Warnings: +Error 1300 Invalid utf8 character string: 'FF' +select hex(_utf8 0x616263FF); +ERROR HY000: Invalid utf8 character string: 'FF' +select hex(_utf8 X'616263FF'); +ERROR HY000: Invalid utf8 character string: 'FF' +select hex(_utf8 B'001111111111'); +ERROR HY000: Invalid utf8 character string: 'FF' +select (_utf8 X'616263FF'); +ERROR HY000: Invalid utf8 character string: 'FF' +set sql_mode=default; +select hex(char(0xFF using utf8)); +hex(char(0xFF using utf8)) + +Warnings: +Warning 1300 Invalid utf8 character string: 'FF' +select hex(convert(0xFF using utf8)); +hex(convert(0xFF using utf8)) + +Warnings: +Warning 1300 Invalid utf8 character string: 'FF' +select hex(_utf8 0x616263FF); +ERROR HY000: Invalid utf8 character string: 'FF' +select hex(_utf8 X'616263FF'); +ERROR HY000: Invalid utf8 character string: 'FF' +select hex(_utf8 B'001111111111'); +ERROR HY000: Invalid utf8 character string: 'FF' +select (_utf8 X'616263FF'); +ERROR HY000: Invalid utf8 character string: 'FF' diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index c1c8b7b060e..fbe46e9fa21 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -478,7 +478,7 @@ str_to_date(a,b) create table t2 select str_to_date(a,b) from t1; describe t2; Field Type Null Key Default Extra -str_to_date(a,b) binary(29) YES NULL +str_to_date(a,b) datetime YES NULL select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f") as f1, str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S") as f2, str_to_date("2003-01-02", "%Y-%m-%d") as f3, diff --git a/mysql-test/r/ddl_i18n_koi8r.result b/mysql-test/r/ddl_i18n_koi8r.result index 3d38319df21..fbaf2f2fd4a 100644 --- a/mysql-test/r/ddl_i18n_koi8r.result +++ b/mysql-test/r/ddl_i18n_koi8r.result @@ -29,7 +29,8 @@ v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VI SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'| TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION -NULL mysqltest1 v1 SELECT 'ÔÅÓÔ' AS c1, ËÏÌ AS c2 NONE YES root@localhost DEFINER koi8r koi8r_general_ci +NULL mysqltest1 v1 SELECT 'ÔÅÓÔ' AS c1, ËÏÌ AS c2 +FROM t1 NONE YES root@localhost DEFINER koi8r koi8r_general_ci SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'| TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION @@ -68,7 +69,8 @@ v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VI SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'| TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION -NULL mysqltest1 v1 SELECT 'ÔÅÓÔ' AS c1, ËÏÌ AS c2 NONE YES root@localhost DEFINER koi8r koi8r_general_ci +NULL mysqltest1 v1 SELECT 'ÔÅÓÔ' AS c1, ËÏÌ AS c2 +FROM t1 NONE YES root@localhost DEFINER koi8r koi8r_general_ci SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'| TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION diff --git a/mysql-test/r/ddl_i18n_utf8.result b/mysql-test/r/ddl_i18n_utf8.result index b8e690bfeb7..d0f176c1985 100644 --- a/mysql-test/r/ddl_i18n_utf8.result +++ b/mysql-test/r/ddl_i18n_utf8.result @@ -29,7 +29,8 @@ v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VI SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'| TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION -NULL mysqltest1 v1 SELECT 'теÑÑ‚' AS c1, кол AS c2 NONE YES root@localhost DEFINER utf8 utf8_general_ci +NULL mysqltest1 v1 SELECT 'теÑÑ‚' AS c1, кол AS c2 +FROM t1 NONE YES root@localhost DEFINER utf8 utf8_general_ci SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'| TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION @@ -68,7 +69,8 @@ v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VI SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'| TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION -NULL mysqltest1 v1 SELECT 'теÑÑ‚' AS c1, кол AS c2 NONE YES root@localhost DEFINER utf8 utf8_general_ci +NULL mysqltest1 v1 SELECT 'теÑÑ‚' AS c1, кол AS c2 +FROM t1 NONE YES root@localhost DEFINER utf8 utf8_general_ci SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'| TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result index 5084498c01c..eb93c69d960 100644 --- a/mysql-test/r/delete.result +++ b/mysql-test/r/delete.result @@ -271,3 +271,11 @@ a DROP TABLE t1, t2; DROP DATABASE db1; DROP DATABASE db2; +CREATE FUNCTION f1() RETURNS INT RETURN 1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0); +DELETE FROM t1 ORDER BY (f1(10)) LIMIT 1; +ERROR 42000: Incorrect number of arguments for FUNCTION test.f1; expected 0, got 1 +DROP TABLE t1; +DROP FUNCTION f1; +End of 5.0 tests diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index 7da82ada121..306c51fb8cf 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -326,7 +326,8 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DERIVED t2 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index drop table t2; CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) NOT NULL default '', `vendor` int(11) NOT NULL default '0', `date_` date NOT NULL default '0000-00-00', `price` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`), KEY `itemid` (`itemid`,`vendor`), KEY `itemid_2` (`itemid`,`date_`)); -insert into t1 values (128, 'rozn', 2, now(), 10),(128, 'rozn', 1, now(), 10); +insert into t1 values (128, 'rozn', 2, curdate(), 10), +(128, 'rozn', 1, curdate(), 10); SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MAX(concat(date_,";",price)), 12) price FROM t1 WHERE itemid=128 AND grpid='rozn' GROUP BY itemid, grpid, vendor) lastprices; min max avg 10.00 10.00 10 diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index fce01ffd171..ce29d25b736 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1368,4 +1368,14 @@ SELECT MIN(a), MIN(b) FROM t5 WHERE a = 1 and b > 1; MIN(a) MIN(b) 1 2 DROP TABLE t1, t2, t3, t4, t5; +CREATE TABLE t1 (a INT); +INSERT INTO t1 values (),(),(); +SELECT (SELECT SLEEP(0) FROM t1 ORDER BY AVG(DISTINCT a) ) as x FROM t1 +GROUP BY x; +x +0 +SELECT 1 FROM t1 GROUP BY (SELECT SLEEP(0) FROM t1 ORDER BY AVG(DISTINCT a) ); +1 +1 +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result index 4f64d39ccc0..80fa8f17a2a 100644 --- a/mysql-test/r/func_in.result +++ b/mysql-test/r/func_in.result @@ -564,4 +564,9 @@ explain select f2 from t2 where f2 in (1,'b'); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index t2f2 t2f2 5 NULL 3 Using where; Using index drop table t1, t2; +create table t1 (a time, key(a)); +insert into t1 values (),(),(),(),(),(),(),(),(),(); +select a from t1 where a not in (a,a,a) group by a; +a +drop table t1; End of 5.1 tests diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index e2e93796afe..6a476d12896 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -369,4 +369,42 @@ mod(5, cast(-2 as unsigned)) mod(5, 18446744073709551614) mod(5, -2) select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5); pow(cast(-2 as unsigned), 5) pow(18446744073709551614, 5) pow(-2, 5) 2.1359870359209e+96 2.1359870359209e+96 -32 +CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1)); +INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0); +SELECT a DIV 900 y FROM t1 GROUP BY y; +y +22201025555 +22255916666 +SELECT DISTINCT a DIV 900 y FROM t1; +y +22201025555 +22255916666 +SELECT b DIV 900 y FROM t1 GROUP BY y; +y +0 +SELECT c DIV 900 y FROM t1 GROUP BY y; +y +0 +DROP TABLE t1; +CREATE TABLE t1(a LONGBLOB); +INSERT INTO t1 VALUES('1'),('2'),('3'); +SELECT DISTINCT (a DIV 254576881) FROM t1; +(a DIV 254576881) +0 +SELECT (a DIV 254576881) FROM t1 UNION ALL +SELECT (a DIV 254576881) FROM t1; +(a DIV 254576881) +0 +0 +0 +0 +0 +0 +DROP TABLE t1; +CREATE TABLE t1(a SET('a','b','c')); +INSERT INTO t1 VALUES ('a'); +SELECT a DIV 2 FROM t1 UNION SELECT a DIV 2 FROM t1; +a DIV 2 +0 +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 39bf1470afe..aa75cde0525 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -190,6 +190,28 @@ ERROR 21000: Operand should contain 1 column(s) drop table table_26093; drop function func_26093_a; drop function func_26093_b; +SELECT NAME_CONST('test', NOW()); +ERROR HY000: Incorrect arguments to NAME_CONST +SELECT NAME_CONST('test', UPPER('test')); +ERROR HY000: Incorrect arguments to NAME_CONST +SELECT NAME_CONST('test', NULL); +test +NULL +SELECT NAME_CONST('test', 1); +test +1 +SELECT NAME_CONST('test', -1); +test +-1 +SELECT NAME_CONST('test', 1.0); +test +1.0 +SELECT NAME_CONST('test', -1.0); +test +-1.0 +SELECT NAME_CONST('test', 'test'); +test +test End of 5.0 tests select connection_id() > 0; connection_id() > 0 diff --git a/mysql-test/r/func_regexp.result b/mysql-test/r/func_regexp.result index 4e35c2a1348..05e56f05457 100644 --- a/mysql-test/r/func_regexp.result +++ b/mysql-test/r/func_regexp.result @@ -98,3 +98,8 @@ R2 R3 deallocate prepare stmt1; drop table t1; +End of 4.1 tests +SELECT 1 REGEXP NULL; +1 REGEXP NULL +NULL +End of 5.0 tests diff --git a/mysql-test/r/func_sapdb.result b/mysql-test/r/func_sapdb.result index 5d7a564b187..942073e3fbd 100644 --- a/mysql-test/r/func_sapdb.result +++ b/mysql-test/r/func_sapdb.result @@ -199,7 +199,7 @@ f2 datetime YES NULL f3 time YES NULL f4 time YES NULL f5 time YES NULL -f6 time NO 00:00:00 +f6 time YES NULL f7 datetime YES NULL f8 date YES NULL f9 time YES NULL diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 6fbb9c811a7..78d86d3f342 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -726,7 +726,7 @@ t1 CREATE TABLE `t1` ( `oct(130)` varchar(64) NOT NULL DEFAULT '', `conv(130,16,10)` varchar(64) NOT NULL DEFAULT '', `hex(130)` varchar(6) NOT NULL DEFAULT '', - `char(130)` varbinary(1) NOT NULL DEFAULT '', + `char(130)` varbinary(4) NOT NULL DEFAULT '', `format(130,10)` varchar(4) NOT NULL DEFAULT '', `left(_latin2'a',1)` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '', `right(_latin2'a',1)` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '', @@ -2486,4 +2486,14 @@ SUBSTR(a,1,len) ba DROP TABLE t1; +CREATE TABLE t1 AS SELECT CHAR(0x414243) as c1; +SELECT HEX(c1) from t1; +HEX(c1) +414243 +DROP TABLE t1; +CREATE VIEW v1 AS SELECT CHAR(0x414243) as c1; +SELECT HEX(c1) from v1; +HEX(c1) +414243 +DROP VIEW v1; End of 5.0 tests diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 3105bc3b578..a355d7929b5 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -1027,6 +1027,15 @@ fmtddate field2 Sep-4 12:00AM abcd DROP TABLE testBug8868; SET NAMES DEFAULT; +CREATE TABLE t1 ( +a TIMESTAMP +); +INSERT INTO t1 VALUES (now()), (now()); +SELECT 1 FROM t1 ORDER BY MAKETIME(1, 1, a); +1 +1 +1 +DROP TABLE t1; (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H) union (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H); diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result index 6e3aebe8d47..f8e0085bf59 100644 --- a/mysql-test/r/gis-rtree.result +++ b/mysql-test/r/gis-rtree.result @@ -167,7 +167,7 @@ count(*) 150 EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))')); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range g g 32 NULL 8 Using where +1 SIMPLE t1 range g g 34 NULL 8 Using where SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))')); fid AsText(g) 1 LINESTRING(150 150,150 150) @@ -301,7 +301,7 @@ count(*) EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g, GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))')); id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range g g 32 NULL 4 Using where +1 SIMPLE t2 range g g 34 NULL 4 Using where SELECT fid, AsText(g) FROM t2 WHERE Within(g, GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))')); fid AsText(g) @@ -1425,6 +1425,37 @@ CHECK TABLE t1 EXTENDED; Table Op Msg_type Msg_text test.t1 check status OK DROP TABLE t1; +create table t1 (a geometry not null, spatial index(a)); +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 131072))); +insert into t1 values (PointFromWKB(POINT(9.1248812352444e+192, 2.9740338169556e+284))); +insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, -0))); +insert into t1 values (PointFromWKB(POINT(1.49166814624e-154, 2.0880974297595e-53))); +insert into t1 values (PointFromWKB(POINT(4.0917382598702e+149, 1.2024538023802e+111))); +insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 2.9993936277913e-241))); +insert into t1 values (PointFromWKB(POINT(2.5243548967072e-29, 1.2024538023802e+111))); +insert into t1 values (PointFromWKB(POINT(0, 6.9835074892995e-251))); +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 3.1050361846014e+231))); +insert into t1 values (PointFromWKB(POINT(2.8728483499323e-188, 2.4600631144627e+260))); +insert into t1 values (PointFromWKB(POINT(3.0517578125e-05, 2.0349165139404e+236))); +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 1.1818212630766e-125))); +insert into t1 values (PointFromWKB(POINT(2.481040258324e-265, 5.7766220027675e-275))); +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 2.5243548967072e-29))); +insert into t1 values (PointFromWKB(POINT(5.7766220027675e-275, 9.9464647281957e+86))); +insert into t1 values (PointFromWKB(POINT(2.2181357552967e+130, 3.7857669957337e-270))); +insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.6893488147419e+19))); +insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.7537584144024e+255))); +insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 1.8033161362863e-130))); +insert into t1 values (PointFromWKB(POINT(0, 5.8774717541114e-39))); +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 2.2761049594727e-159))); +insert into t1 values (PointFromWKB(POINT(6.243497100632e+144, 3.7857669957337e-270))); +insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 2.6355494858076e-82))); +insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 3.8518598887745e-34))); +insert into t1 values (PointFromWKB(POINT(4.6566128730774e-10, 2.0880974297595e-53))); +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 1.8827498946116e-183))); +insert into t1 values (PointFromWKB(POINT(1.8033161362863e-130, 9.1248812352444e+192))); +insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, 2.2761049594727e-159))); +insert into t1 values (PointFromWKB(POINT(1.94906280228e+289, 1.2338789709327e-178))); +drop table t1; CREATE TABLE t1(foo GEOMETRY NOT NULL, SPATIAL INDEX(foo) ); INSERT INTO t1(foo) VALUES (NULL); ERROR 23000: Column 'foo' cannot be null diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 7b4b02f3ff3..61394409947 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -736,6 +736,12 @@ SELECT * FROM t1; a NULL DROP TABLE t1; +CREATE TABLE `t1` ( `col9` set('a'), `col89` date); +INSERT INTO `t1` VALUES ('','0000-00-00'); +select geomfromtext(col9,col89) as a from t1; +a +NULL +DROP TABLE t1; End of 4.1 tests create table t1 (s1 geometry not null,s2 char(100)); create trigger t1_bu before update on t1 for each row set new.s1 = null; @@ -889,6 +895,45 @@ drop table t1, t2; SELECT 1; 1 1 +CREATE TABLE t1 (p POINT); +CREATE TABLE t2 (p POINT, INDEX(p)); +INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)')); +INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)')); +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +1 +EXPLAIN +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 system p NULL NULL NULL 1 +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +1 +INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)')); +INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)')); +EXPLAIN +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +2 +EXPLAIN +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref p p 28 const 1 Using where +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +2 +EXPLAIN +SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where +SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +2 +DROP TABLE t1, t2; +End of 5.0 tests End of 5.0 tests create table t1 (f1 tinyint(1), f2 char(1), f3 varchar(1), f4 geometry, f5 datetime); create view v1 as select * from t1; diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result index 21bad4fddcb..b94de265d0c 100644 --- a/mysql-test/r/grant2.result +++ b/mysql-test/r/grant2.result @@ -422,4 +422,22 @@ revoke all privileges, grant option from mysqltest_1@localhost; revoke all privileges, grant option from mysqltest_2@localhost; drop user mysqltest_1@localhost; drop user mysqltest_2@localhost; +CREATE DATABASE db1; +USE db1; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1),(2,2); +CREATE TABLE t2 (b INT, c INT); +INSERT INTO t2 VALUES (1,100),(2,200); +GRANT SELECT ON t1 TO mysqltest1@localhost; +GRANT SELECT (b) ON t2 TO mysqltest1@localhost; +USE db1; +SELECT c FROM t2; +ERROR 42000: SELECT command denied to user 'mysqltest1'@'localhost' for column 'c' in table 't2' +SELECT * FROM t2; +ERROR 42000: SELECT command denied to user 'mysqltest1'@'localhost' for column 'c' in table 't2' +SELECT * FROM t1 JOIN t2 USING (b); +ERROR 42000: SELECT command denied to user 'mysqltest1'@'localhost' for column 'c' in table 't2' +DROP TABLE db1.t1, db1.t2; +DROP USER mysqltest1@localhost; +DROP DATABASE db1; End of 5.0 tests diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 2faf7832aca..7498267c91d 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -1093,10 +1093,156 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 144 EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY,i2) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index; Using filesort +1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index; Using filesort +1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) IGNORE INDEX FOR GROUP BY (i2) GROUP BY a; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index d1120d24884..7693fe628ef 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -387,10 +387,14 @@ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_par select * from information_schema.views where TABLE_NAME like "v%"; TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION NULL test v0 select schema_name from information_schema.schemata NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL test v1 select table_name from information_schema.tables NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL test v2 select column_name from information_schema.columns NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL test v3 select CHARACTER_SET_NAME from information_schema.character_sets NONE NO root@localhost DEFINER latin1 latin1_swedish_ci -NULL test v4 select COLLATION_NAME from information_schema.collations NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL test v1 select table_name from information_schema.tables +where table_name="v1" NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL test v2 select column_name from information_schema.columns +where table_name="v2" NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL test v3 select CHARACTER_SET_NAME from information_schema.character_sets +where CHARACTER_SET_NAME like "latin1%" NONE NO root@localhost DEFINER latin1 latin1_swedish_ci +NULL test v4 select COLLATION_NAME from information_schema.collations +where COLLATION_NAME like "latin1%" NONE NO root@localhost DEFINER latin1 latin1_swedish_ci drop view v0, v1, v2, v3, v4; create table t1 (a int); grant select,update,insert on t1 to mysqltest_1@localhost; @@ -1466,6 +1470,10 @@ f7 datetime NO NULL f8 datetime YES 2006-01-01 00:00:00 drop table t1; End of 5.0 tests. +show fields from information_schema.table_names; +ERROR 42S02: Unknown table 'table_names' in information_schema +show keys from information_schema.table_names; +ERROR 42S02: Unknown table 'table_names' in information_schema select * from information_schema.engines WHERE ENGINE="MyISAM"; ENGINE SUPPORT COMMENT TRANSACTIONS XA SAVEPOINTS MyISAM DEFAULT Default engine as of MySQL 3.23 with great performance NO NO NO @@ -1540,4 +1548,60 @@ count(*) select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='' AND TABLE_NAME='nonexisting'; count(*) 0 +CREATE VIEW v1 +AS SELECT * +FROM INFORMATION_SCHEMA.TABLES; +SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS where TABLE_NAME = 'v1'; +VIEW_DEFINITION +SELECT * +FROM INFORMATION_SCHEMA.TABLES +DROP VIEW v1; +SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA +WHERE SCHEMA_NAME ='information_schema'; +SCHEMA_NAME +information_schema +SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES +WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db'; +TABLE_COLLATION +utf8_bin +select * from information_schema.columns where table_schema = NULL; +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 CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT +select * from `information_schema`.`COLUMNS` where `TABLE_NAME` = NULL; +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 CHARACTER_SET_NAME COLLATION_NAME COLUMN_TYPE COLUMN_KEY EXTRA PRIVILEGES COLUMN_COMMENT +select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_SCHEMA` = NULL; +CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME +select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_NAME` = NULL; +CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME +select * from `information_schema`.`PARTITIONS` where `TABLE_SCHEMA` = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +select * from `information_schema`.`PARTITIONS` where `TABLE_NAME` = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_ORDINAL_POSITION SUBPARTITION_ORDINAL_POSITION PARTITION_METHOD SUBPARTITION_METHOD PARTITION_EXPRESSION SUBPARTITION_EXPRESSION PARTITION_DESCRIPTION TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE CREATE_TIME UPDATE_TIME CHECK_TIME CHECKSUM PARTITION_COMMENT NODEGROUP TABLESPACE_NAME +select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `CONSTRAINT_SCHEMA` = NULL; +CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME UNIQUE_CONSTRAINT_CATALOG UNIQUE_CONSTRAINT_SCHEMA UNIQUE_CONSTRAINT_NAME MATCH_OPTION UPDATE_RULE DELETE_RULE TABLE_NAME REFERENCED_TABLE_NAME +select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `TABLE_NAME` = NULL; +CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME UNIQUE_CONSTRAINT_CATALOG UNIQUE_CONSTRAINT_SCHEMA UNIQUE_CONSTRAINT_NAME MATCH_OPTION UPDATE_RULE DELETE_RULE TABLE_NAME REFERENCED_TABLE_NAME +select * from information_schema.schemata where schema_name = NULL; +CATALOG_NAME SCHEMA_NAME DEFAULT_CHARACTER_SET_NAME DEFAULT_COLLATION_NAME SQL_PATH +select * from `information_schema`.`STATISTICS` where `TABLE_SCHEMA` = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT +select * from `information_schema`.`STATISTICS` where `TABLE_NAME` = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME NON_UNIQUE INDEX_SCHEMA INDEX_NAME SEQ_IN_INDEX COLUMN_NAME COLLATION CARDINALITY SUB_PART PACKED NULLABLE INDEX_TYPE COMMENT +select * from information_schema.tables where table_schema = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT +select * from information_schema.tables where table_catalog = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT +select * from information_schema.tables where table_name = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT +select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL; +CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE +select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL; +CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE +select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_SCHEMA` = NULL; +TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION +select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_TABLE` = NULL; +TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATALOG EVENT_OBJECT_SCHEMA EVENT_OBJECT_TABLE ACTION_ORDER ACTION_CONDITION ACTION_STATEMENT ACTION_ORIENTATION ACTION_TIMING ACTION_REFERENCE_OLD_TABLE ACTION_REFERENCE_NEW_TABLE ACTION_REFERENCE_OLD_ROW ACTION_REFERENCE_NEW_ROW CREATED SQL_MODE DEFINER CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION +select * from `information_schema`.`VIEWS` where `TABLE_SCHEMA` = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION +select * from `information_schema`.`VIEWS` where `TABLE_NAME` = NULL; +TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION End of 5.1 tests. diff --git a/mysql-test/r/innodb_gis.result b/mysql-test/r/innodb_gis.result index 7f54a78087b..ef8bdcc5f3e 100644 --- a/mysql-test/r/innodb_gis.result +++ b/mysql-test/r/innodb_gis.result @@ -546,5 +546,44 @@ Overlaps(@horiz1, @point2) 0 DROP TABLE t1; End of 5.0 tests +CREATE TABLE t1 (p POINT); +CREATE TABLE t2 (p POINT, INDEX(p)); +INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)')); +INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)')); +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +1 +EXPLAIN +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref p p 28 const 1 Using where +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +1 +INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)')); +INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)')); +EXPLAIN +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where +SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +2 +EXPLAIN +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ref p p 28 const 1 Using where +SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +2 +EXPLAIN +SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)'); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where +SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)'); +COUNT(*) +2 +DROP TABLE t1, t2; +End of 5.0 tests create table t1 (g geometry not null, spatial gk(g)) engine=innodb; ERROR HY000: The used table type doesn't support SPATIAL indexes diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result index 3a6758b38f4..44d874ef018 100644 --- a/mysql-test/r/innodb_mysql.result +++ b/mysql-test/r/innodb_mysql.result @@ -1,5 +1,6 @@ SET SESSION STORAGE_ENGINE = InnoDB; drop table if exists t1,t2,t3,t1m,t1i,t2m,t2i,t4; +drop procedure if exists p1; create table t1 ( c_id int(11) not null default '0', org_id int(11) default null, @@ -1419,6 +1420,85 @@ select if(@a=@b,"ok","wrong"); if(@a=@b,"ok","wrong") ok drop table t1; +SET SESSION AUTOCOMMIT = 0; +SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED; +# Switch to connection con1 +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(256)) +ENGINE = InnoDB; +INSERT INTO t1 VALUES (1,2); +BEGIN; +UPDATE t1 SET b = 12 WHERE a = 1; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +SELECT * FROM t1; +a b +1 12 +# Switch to connection con2 +UPDATE t1 SET b = 21 WHERE a = 1; +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +# Switch to connection con1 +SELECT * FROM t1; +a b +1 12 +ROLLBACK; +# 2. test for serialized update: +CREATE TABLE t2 (a INT); +TRUNCATE t1; +INSERT INTO t1 VALUES (1,'init'); +CREATE PROCEDURE p1() +BEGIN +UPDATE t1 SET b = CONCAT(b, '+con2') WHERE a = 1; +INSERT INTO t2 VALUES (); +END| +BEGIN; +UPDATE t1 SET b = CONCAT(b, '+con1') WHERE a = 1; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +SELECT * FROM t1; +a b +1 init+con1 +# Switch to connection con2 +CALL p1;; +# Switch to connection con1 +SELECT * FROM t1; +a b +1 init+con1 +COMMIT; +SELECT * FROM t1; +a b +1 init+con1 +# Switch to connection con2 +SELECT * FROM t1; +a b +1 init+con1+con2 +# Switch to connection con1 +# 3. test for updated key column: +TRUNCATE t1; +TRUNCATE t2; +INSERT INTO t1 VALUES (1,'init'); +BEGIN; +UPDATE t1 SET a = 2, b = CONCAT(b, '+con1') WHERE a = 1; +affected rows: 1 +info: Rows matched: 1 Changed: 1 Warnings: 0 +SELECT * FROM t1; +a b +2 init+con1 +# Switch to connection con2 +CALL p1;; +# Switch to connection con1 +SELECT * FROM t1; +a b +2 init+con1 +COMMIT; +SELECT * FROM t1; +a b +2 init+con1 +# Switch to connection con2 +SELECT * FROM t1; +a b +2 init+con1 +DROP PROCEDURE p1; +DROP TABLE t1, t2; CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL, PRIMARY KEY (a,b)) engine=innodb; CREATE TABLE t2 (c INT NOT NULL, d INT NOT NULL, PRIMARY KEY (c,d), CONSTRAINT c2 FOREIGN KEY f2 (c) REFERENCES t1 (a,b) ON UPDATE NO ACTION) engine=innodb; diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index 2604e4bf648..780e91ea73f 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -816,3 +816,15 @@ id prev_id join_id 3 2 0 4 3 0 DROP TABLE t1,t2; +# +# Bug#30384: Having SQL_BUFFER_RESULT option in the +# CREATE .. KEY(..) .. SELECT led to creating corrupted index. +# +create table t1(f1 int); +insert into t1 values(1),(2),(3); +create table t2 (key(f1)) engine=myisam select sql_buffer_result f1 from t1; +check table t2 extended; +Table Op Msg_type Msg_text +test.t2 check status OK +drop table t1,t2; +################################################################## diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result index fcb141a3510..9b799fccf06 100644 --- a/mysql-test/r/join.result +++ b/mysql-test/r/join.result @@ -897,4 +897,168 @@ select '^^: The above should be ~= 20 + cost(select * from t1). Value less than Z ^^: The above should be ~= 20 + cost(select * from t1). Value less than 20 is an error drop table t1, t2; +CREATE TABLE t1 (a INT PRIMARY KEY, b INT); +CREATE TABLE t2 (c INT PRIMARY KEY, d INT); +INSERT INTO t1 VALUES(1,NULL),(2,NULL),(3,NULL),(4,NULL); +INSERT INTO t1 SELECT a + 4, b FROM t1; +INSERT INTO t1 SELECT a + 8, b FROM t1; +INSERT INTO t1 SELECT a + 16, b FROM t1; +INSERT INTO t1 SELECT a + 32, b FROM t1; +INSERT INTO t1 SELECT a + 64, b FROM t1; +INSERT INTO t2 SELECT a, b FROM t1; +EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 +EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 +SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2; +a b c d +SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2; +a b c d +1 NULL 1 NULL +2 NULL 2 NULL +EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 128 Using filesort +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 +EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 128 Using filesort +1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 +SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a; +a b c d +SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a; +a b c d +1 NULL 1 NULL +2 NULL 2 NULL +3 NULL 3 NULL +4 NULL 4 NULL +5 NULL 5 NULL +6 NULL 6 NULL +7 NULL 7 NULL +8 NULL 8 NULL +9 NULL 9 NULL +10 NULL 10 NULL +11 NULL 11 NULL +12 NULL 12 NULL +13 NULL 13 NULL +14 NULL 14 NULL +15 NULL 15 NULL +16 NULL 16 NULL +17 NULL 17 NULL +18 NULL 18 NULL +19 NULL 19 NULL +20 NULL 20 NULL +21 NULL 21 NULL +22 NULL 22 NULL +23 NULL 23 NULL +24 NULL 24 NULL +25 NULL 25 NULL +26 NULL 26 NULL +27 NULL 27 NULL +28 NULL 28 NULL +29 NULL 29 NULL +30 NULL 30 NULL +31 NULL 31 NULL +32 NULL 32 NULL +33 NULL 33 NULL +34 NULL 34 NULL +35 NULL 35 NULL +36 NULL 36 NULL +37 NULL 37 NULL +38 NULL 38 NULL +39 NULL 39 NULL +40 NULL 40 NULL +41 NULL 41 NULL +42 NULL 42 NULL +43 NULL 43 NULL +44 NULL 44 NULL +45 NULL 45 NULL +46 NULL 46 NULL +47 NULL 47 NULL +48 NULL 48 NULL +49 NULL 49 NULL +50 NULL 50 NULL +51 NULL 51 NULL +52 NULL 52 NULL +53 NULL 53 NULL +54 NULL 54 NULL +55 NULL 55 NULL +56 NULL 56 NULL +57 NULL 57 NULL +58 NULL 58 NULL +59 NULL 59 NULL +60 NULL 60 NULL +61 NULL 61 NULL +62 NULL 62 NULL +63 NULL 63 NULL +64 NULL 64 NULL +65 NULL 65 NULL +66 NULL 66 NULL +67 NULL 67 NULL +68 NULL 68 NULL +69 NULL 69 NULL +70 NULL 70 NULL +71 NULL 71 NULL +72 NULL 72 NULL +73 NULL 73 NULL +74 NULL 74 NULL +75 NULL 75 NULL +76 NULL 76 NULL +77 NULL 77 NULL +78 NULL 78 NULL +79 NULL 79 NULL +80 NULL 80 NULL +81 NULL 81 NULL +82 NULL 82 NULL +83 NULL 83 NULL +84 NULL 84 NULL +85 NULL 85 NULL +86 NULL 86 NULL +87 NULL 87 NULL +88 NULL 88 NULL +89 NULL 89 NULL +90 NULL 90 NULL +91 NULL 91 NULL +92 NULL 92 NULL +93 NULL 93 NULL +94 NULL 94 NULL +95 NULL 95 NULL +96 NULL 96 NULL +97 NULL 97 NULL +98 NULL 98 NULL +99 NULL 99 NULL +100 NULL 100 NULL +101 NULL 101 NULL +102 NULL 102 NULL +103 NULL 103 NULL +104 NULL 104 NULL +105 NULL 105 NULL +106 NULL 106 NULL +107 NULL 107 NULL +108 NULL 108 NULL +109 NULL 109 NULL +110 NULL 110 NULL +111 NULL 111 NULL +112 NULL 112 NULL +113 NULL 113 NULL +114 NULL 114 NULL +115 NULL 115 NULL +116 NULL 116 NULL +117 NULL 117 NULL +118 NULL 118 NULL +119 NULL 119 NULL +120 NULL 120 NULL +121 NULL 121 NULL +122 NULL 122 NULL +123 NULL 123 NULL +124 NULL 124 NULL +125 NULL 125 NULL +126 NULL 126 NULL +127 NULL 127 NULL +128 NULL 128 NULL +DROP TABLE IF EXISTS t1,t2; End of 5.0 tests. diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index d8688ea5509..c0856314ba5 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -3805,6 +3805,28 @@ c1 2 DROP TABLE t1,t2; # +# Bug#29815: new option for suppressing last line of mysqldump: +# "Dump completed on" +# +# --skip-dump-date: +-- + + + +-- Dump completed +# --dump-date: +-- + + + +-- Dump completed on DATE +# --dump-date (default): +-- + + + +-- Dump completed on DATE +# # End of 5.0 tests # drop table if exists t1; diff --git a/mysql-test/r/mysqlslap.result b/mysql-test/r/mysqlslap.result index dfe721d10d2..9207dd48d0e 100644 --- a/mysql-test/r/mysqlslap.result +++ b/mysql-test/r/mysqlslap.result @@ -211,3 +211,9 @@ COMMIT; COMMIT; SHOW TABLES; DROP SCHEMA IF EXISTS `mysqlslap`; +# +# Bug #29985: mysqlslap -- improper handling of resultsets in SPROCs +# +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1() SELECT 1; +DROP PROCEDURE p1; diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result index bf9d9764db2..345c9b07b98 100644 --- a/mysql-test/r/null.result +++ b/mysql-test/r/null.result @@ -1,4 +1,4 @@ -drop table if exists t1; +drop table if exists t1, t2; select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null; NULL NULL isnull(null) isnull(1/0) isnull(1/0 = null) ifnull(null,1) ifnull(null,"TRUE") ifnull("TRUE","ERROR") 1/0 is null 1 is not null NULL NULL 1 1 1 1 TRUE TRUE 1 1 @@ -320,3 +320,26 @@ bug19145c CREATE TABLE `bug19145c` ( drop table bug19145a; drop table bug19145b; drop table bug19145c; +# End of 4.1 tests +# +# Bug #31471: decimal_bin_size: Assertion `scale >= 0 && +# precision > 0 && scale <= precision' +# +CREATE TABLE t1 (a DECIMAL (1, 0) ZEROFILL, b DECIMAL (1, 0) ZEROFILL); +INSERT INTO t1 (a, b) VALUES (0, 0); +CREATE TABLE t2 SELECT IFNULL(a, b) FROM t1; +DESCRIBE t2; +Field Type Null Key Default Extra +IFNULL(a, b) decimal(1,0) unsigned YES NULL +DROP TABLE t2; +CREATE TABLE t2 SELECT IFNULL(a, NULL) FROM t1; +DESCRIBE t2; +Field Type Null Key Default Extra +IFNULL(a, NULL) decimal(1,0) YES NULL +DROP TABLE t2; +CREATE TABLE t2 SELECT IFNULL(NULL, b) FROM t1; +DESCRIBE t2; +Field Type Null Key Default Extra +IFNULL(NULL, b) decimal(1,0) YES NULL +DROP TABLE t1, t2; +# End of 5.0 tests diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index 67c45b698ce..63c9590401c 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -715,3 +715,14 @@ a SUM(a) 4 4 NULL 14 DROP TABLE t1; +# +# Bug#31095: Unexpected NULL constant caused server crash. +# +create table t1(a int); +insert into t1 values (1),(2),(3); +select count(a) from t1 group by null with rollup; +count(a) +3 +3 +drop table t1; +############################################################## diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index ff4882d6cd8..3d0f4915d0a 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -1131,3 +1131,288 @@ id c3 186 14 196 14 DROP TABLE t1,t2; +CREATE TABLE t1 ( +a INT, +b INT, +PRIMARY KEY (a), +KEY ab(a, b) +); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4); +INSERT INTO t1 SELECT a + 4, b + 4 FROM t1; +INSERT INTO t1 SELECT a + 8, b + 8 FROM t1; +INSERT INTO t1 SELECT a +16, b +16 FROM t1; +INSERT INTO t1 SELECT a +32, b +32 FROM t1; +INSERT INTO t1 SELECT a +64, b +64 FROM t1; +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range NULL ab 4 NULL 10 Using index for group-by +SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a; +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +SELECT @tmp_tables_after = @tmp_tables_before ; +@tmp_tables_after = @tmp_tables_before +1 +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 4 NULL 128 Using index +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a; +a +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +SELECT @tmp_tables_after = @tmp_tables_before; +@tmp_tables_after = @tmp_tables_before +1 +DROP TABLE t1; diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index afc248c027e..6f0bad71f23 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -2973,11 +2973,13 @@ Warnings: Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Note 1265 Data truncated for column 'c13' at row 1 @@ -3011,7 +3013,6 @@ Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c17' at row 1 Warnings: -Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c17' at row 1 diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index e3f55cee898..85a109b0630 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -2956,11 +2956,13 @@ Warnings: Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Note 1265 Data truncated for column 'c13' at row 1 @@ -2994,7 +2996,6 @@ Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c17' at row 1 Warnings: -Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c17' at row 1 diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index fa33dcc395a..980b89ad504 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -2957,11 +2957,13 @@ Warnings: Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Note 1265 Data truncated for column 'c13' at row 1 @@ -2995,7 +2997,6 @@ Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c17' at row 1 Warnings: -Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c17' at row 1 diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index 968342c8a93..e95f8766a24 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -2893,11 +2893,13 @@ Warnings: Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Note 1265 Data truncated for column 'c13' at row 1 @@ -2931,7 +2933,6 @@ Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c17' at row 1 Warnings: -Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c17' at row 1 @@ -5914,11 +5915,13 @@ Warnings: Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Note 1265 Data truncated for column 'c13' at row 1 @@ -5952,7 +5955,6 @@ Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c17' at row 1 Warnings: -Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c17' at row 1 diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index 73436dc392f..142282486c4 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -1650,8 +1650,100 @@ a (select count(*) from t2) 3 0 4 0 drop table t1,t2; -End of 5.0 tests +DROP DATABASE IF EXISTS bug30269; +FLUSH STATUS; +CREATE DATABASE bug30269; +USE bug30269; +CREATE TABLE test1 (id int, name varchar(23)); +CREATE VIEW view1 AS SELECT * FROM test1; +INSERT INTO test1 VALUES (5, 'testit'); +GRANT SELECT (id) ON TABLE bug30269.test1 TO 'bug30269'@'localhost'; +GRANT SELECT ON TABLE bug30269.view1 TO 'bug30269'@'localhost'; +set global query_cache_size= 81920; +USE bug30269; +show status like 'Qcache_queries_in_cache'; +Variable_name Value +Qcache_queries_in_cache 0 +# Select statement not stored in query cache because of column privileges. +SELECT id FROM test1 WHERE id>2; +id +5 +show status like 'Qcache_queries_in_cache'; +Variable_name Value +Qcache_queries_in_cache 0 +SELECT id FROM view1 WHERE id>2; +id +5 +show status like 'Qcache_queries_in_cache'; +Variable_name Value +Qcache_queries_in_cache 1 +DROP DATABASE bug30269; +DROP USER 'bug30269'@'localhost'; set GLOBAL query_cache_type=default; set GLOBAL query_cache_limit=default; set GLOBAL query_cache_min_res_unit=default; set GLOBAL query_cache_size=default; +End of 5.0 tests +drop database if exists db1; +drop database if exists db2; +set GLOBAL query_cache_size=15*1024*1024; +create database db1; +use db1; +create table t1(c1 int)engine=myisam; +insert into t1(c1) values (1); +select * from db1.t1 f; +c1 +1 +show status like 'Qcache_queries_in_cache'; +Variable_name Value +Qcache_queries_in_cache 1 +rename schema db1 to db2; +show status like 'Qcache_queries_in_cache'; +Variable_name Value +Qcache_queries_in_cache 0 +drop database db2; +set global query_cache_size=default; +drop database if exists db1; +drop database if exists db3; +set GLOBAL query_cache_size=15*1024*1024; +create database db1; +create database db3; +use db1; +create table t1(c1 int) engine=myisam; +use db3; +create table t1(c1 int) engine=myisam; +use db1; +insert into t1(c1) values (1); +use mysql; +select * from db1.t1; +c1 +1 +select c1+1 from db1.t1; +c1+1 +2 +select * from db3.t1; +c1 +show status like 'Qcache_queries_in_cache'; +Variable_name Value +Qcache_queries_in_cache 3 +rename schema db1 to db2; +show status like 'Qcache_queries_in_cache'; +Variable_name Value +Qcache_queries_in_cache 1 +drop database db2; +drop database db3; +CREATE TABLE t1 (a ENUM('rainbow')); +INSERT INTO t1 VALUES (),(),(),(),(); +SELECT 1 FROM t1 GROUP BY (SELECT 1 FROM t1 ORDER BY AVG(LAST_INSERT_ID())); +1 +1 +DROP TABLE t1; +CREATE TABLE t1 (a LONGBLOB); +INSERT INTO t1 SET a = 'aaaa'; +INSERT INTO t1 SET a = 'aaaa'; +SELECT 1 FROM t1 GROUP BY +(SELECT LAST_INSERT_ID() FROM t1 ORDER BY MIN(a) ASC LIMIT 1); +1 +1 +DROP TABLE t1; +End of 5.1 tests diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index ed61cfffa6b..d1d85aef0ec 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -607,11 +607,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ref period period 4 test.t1.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using filesort +1 SIMPLE t3 index period period 4 NULL 1 1 SIMPLE t1 ref period period 4 test.t3.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort +1 SIMPLE t1 index period period 4 NULL 1 1 SIMPLE t3 ref period period 4 test.t1.period 4181 select period from t1; period diff --git a/mysql-test/r/ssl.result b/mysql-test/r/ssl.result index 1f1a6ec9e22..3622fb51c99 100644 --- a/mysql-test/r/ssl.result +++ b/mysql-test/r/ssl.result @@ -608,11 +608,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ref period period 4 test.t1.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using filesort +1 SIMPLE t3 index period period 4 NULL 1 1 SIMPLE t1 ref period period 4 test.t3.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort +1 SIMPLE t1 index period period 4 NULL 1 1 SIMPLE t3 ref period period 4 test.t1.period 4181 select period from t1; period diff --git a/mysql-test/r/ssl_compress.result b/mysql-test/r/ssl_compress.result index e77fcefeafd..3018fce5cad 100644 --- a/mysql-test/r/ssl_compress.result +++ b/mysql-test/r/ssl_compress.result @@ -611,11 +611,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t3 ref period period 4 test.t1.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 ALL period NULL NULL NULL 41810 Using filesort +1 SIMPLE t3 index period period 4 NULL 1 1 SIMPLE t1 ref period period 4 test.t3.period 4181 explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort +1 SIMPLE t1 index period period 4 NULL 1 1 SIMPLE t3 ref period period 4 test.t1.period 4181 select period from t1; period diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index d6a01727813..904db1a14d0 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -145,3 +145,82 @@ d dt ts 0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 2001-11-11 2001-11-11 00:00:00 2001-11-11 00:00:00 drop table t1; +CREATE TABLE t1 ( +a INT +); +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (NULL); +SELECT str_to_date( '', a ) FROM t1; +str_to_date( '', a ) +0000-00-00 00:00:00 +NULL +DROP TABLE t1; +CREATE TABLE t1 (a DATE, b int, PRIMARY KEY (a,b)); +INSERT INTO t1 VALUES (DATE(NOW()), 1); +SELECT COUNT(*) FROM t1 WHERE a = NOW(); +COUNT(*) +0 +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +INSERT INTO t1 VALUES (DATE(NOW()), 2); +SELECT COUNT(*) FROM t1 WHERE a = NOW(); +COUNT(*) +0 +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1; +COUNT(*) +0 +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +ALTER TABLE t1 DROP PRIMARY KEY; +SELECT COUNT(*) FROM t1 WHERE a = NOW(); +COUNT(*) +0 +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where +DROP TABLE t1; +CREATE TABLE t1 (a DATE); +CREATE TABLE t2 (a DATE); +CREATE INDEX i ON t1 (a); +INSERT INTO t1 VALUES ('0000-00-00'),('0000-00-00'); +INSERT INTO t2 VALUES ('0000-00-00'),('0000-00-00'); +SELECT * FROM t1 WHERE a = '0000-00-00'; +a +0000-00-00 +0000-00-00 +SELECT * FROM t2 WHERE a = '0000-00-00'; +a +0000-00-00 +0000-00-00 +SET SQL_MODE=TRADITIONAL; +EXPLAIN SELECT * FROM t1 WHERE a = '0000-00-00'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref i i 4 const 1 Using where; Using index +Warnings: +Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1 +SELECT * FROM t1 WHERE a = '0000-00-00'; +a +0000-00-00 +0000-00-00 +Warnings: +Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1 +SELECT * FROM t2 WHERE a = '0000-00-00'; +a +0000-00-00 +0000-00-00 +Warnings: +Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1 +Warning 1292 Incorrect date value: '0000-00-00' for column 'a' at row 1 +INSERT INTO t1 VALUES ('0000-00-00'); +ERROR 22007: Incorrect date value: '0000-00-00' for column 'a' at row 1 +SET SQL_MODE=DEFAULT; +DROP TABLE t1,t2; +End of 5.0 tests diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 432fe1e6c4a..c15deb8b1e5 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -59,6 +59,8 @@ t drop table t1; CREATE TABLE t1 (a timestamp, b date, c time, d datetime); insert into t1 (b,c,d) values(now(),curtime(),now()); +Warnings: +Note 1265 Data truncated for column 'b' at row 1 select date_format(a,"%Y-%m-%d")=b,right(a+0,6)=c+0,a=d+0 from t1; date_format(a,"%Y-%m-%d")=b right(a+0,6)=c+0 a=d+0 1 1 1 @@ -427,6 +429,67 @@ f1 Warnings: Warning 1292 Incorrect datetime value: '2007010100000' for column 'f1' at row 1 drop table t1; +# +# Bug#27216: functions with parameters of different date types may +# return wrong type of the result. +# +create table t1 (f1 date, f2 datetime, f3 varchar(20)); +create table t2 as select coalesce(f1,f1) as f4 from t1; +desc t2; +Field Type Null Key Default Extra +f4 date YES NULL +create table t3 as select coalesce(f1,f2) as f4 from t1; +desc t3; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t4 as select coalesce(f2,f2) as f4 from t1; +desc t4; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t5 as select coalesce(f1,f3) as f4 from t1; +desc t5; +Field Type Null Key Default Extra +f4 varbinary(20) YES NULL +create table t6 as select coalesce(f2,f3) as f4 from t1; +desc t6; +Field Type Null Key Default Extra +f4 varbinary(20) YES NULL +create table t7 as select coalesce(makedate(1997,1),f2) as f4 from t1; +desc t7; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t8 as select coalesce(cast('01-01-01' as datetime),f2) as f4 +from t1; +desc t8; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t9 as select case when 1 then cast('01-01-01' as date) +when 0 then cast('01-01-01' as date) end as f4 from t1; +desc t9; +Field Type Null Key Default Extra +f4 date YES NULL +create table t10 as select case when 1 then cast('01-01-01' as datetime) +when 0 then cast('01-01-01' as datetime) end as f4 from t1; +desc t10; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t11 as select if(1, cast('01-01-01' as datetime), +cast('01-01-01' as date)) as f4 from t1; +desc t11; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t12 as select least(cast('01-01-01' as datetime), +cast('01-01-01' as date)) as f4 from t1; +desc t12; +Field Type Null Key Default Extra +f4 datetime YES NULL +create table t13 as select ifnull(cast('01-01-01' as datetime), +cast('01-01-01' as date)) as f4 from t1; +desc t13; +Field Type Null Key Default Extra +f4 datetime YES NULL +drop tables t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13; +################################################################### create table t1 (f1 time); insert into t1 set f1 = '45:44:44'; insert into t1 set f1 = '15:44:44'; diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index fa7bf91b113..42276a004bb 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -800,6 +800,12 @@ SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1; ROUND(qty,3) dps ROUND(qty,dps) 1.133 3 1.133 DROP TABLE t1; +SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS '%'; +% +0.012345687012345687012345687012345687012345687012345687012345687012345687000000000 +SELECT MOD(1, .123456789123456789123456789123456789123456789123456789123456789123456789123456789) AS 'MOD()'; +MOD() +0.012345687012345687012345687012345687012345687012345687012345687012345687000000000 create table t1 (f1 decimal(6,6),f2 decimal(6,6) zerofill); insert into t1 values (-0.123456,0.123456); select group_concat(f1),group_concat(f2) from t1; diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 638d71c6940..bdaec70021b 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -799,6 +799,9 @@ set @@query_prealloc_size = @test; select @@query_prealloc_size = @test; @@query_prealloc_size = @test 1 +set global sql_mode=repeat('a',80); +ERROR 42000: Variable 'sql_mode' can't be set to the value of 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +End of 4.1 tests create table t1 (a int); select a into @x from t1; Warnings: diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 8a926d44f5f..60c3ff68e67 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -625,7 +625,7 @@ drop table t1; create table t1 (a int, b int); create view v1 as select a, sum(b) from t1 group by a; select b from v1 use index (some_index) where b=1; -ERROR 42000: Key 'some_index' doesn't exist in table 'v1' +ERROR HY000: Incorrect usage of index hints and VIEW drop view v1; drop table t1; create table t1 (col1 char(5),col2 char(5)); @@ -2701,27 +2701,26 @@ CREATE TABLE t1( fName varchar(25) NOT NULL, lName varchar(25) NOT NULL, DOB date NOT NULL, +test_date date NOT NULL, uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY); -INSERT INTO t1(fName, lName, DOB) VALUES -('Hank', 'Hill', '1964-09-29'), -('Tom', 'Adams', '1908-02-14'), -('Homer', 'Simpson', '1968-03-05'); +INSERT INTO t1(fName, lName, DOB, test_date) VALUES +('Hank', 'Hill', '1964-09-29', '2007-01-01'), +('Tom', 'Adams', '1908-02-14', '2007-01-01'), +('Homer', 'Simpson', '1968-03-05', '2007-01-01'); CREATE VIEW v1 AS -SELECT (year(now())-year(DOB)) AS Age +SELECT (year(test_date)-year(DOB)) AS Age FROM t1 HAVING Age < 75; SHOW CREATE VIEW v1; View Create View character_set_client collation_connection -v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (year(now()) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75) latin1 latin1_swedish_ci -set timestamp=1136066400; -SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75; +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (year(`t1`.`test_date`) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75) latin1 latin1_swedish_ci +SELECT (year(test_date)-year(DOB)) AS Age FROM t1 HAVING Age < 75; Age -42 -38 -set timestamp=1136066400; +43 +39 SELECT * FROM v1; Age -42 -38 +43 +39 DROP VIEW v1; DROP TABLE t1; CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a char(6) DEFAULT 'xxx'); @@ -3559,6 +3558,45 @@ table_name is_updatable v1 NO drop view v1; drop table t1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM v1 USE KEY(non_existant); +ERROR HY000: Incorrect usage of index hints and VIEW +SELECT * FROM v1 FORCE KEY(non_existant); +ERROR HY000: Incorrect usage of index hints and VIEW +SELECT * FROM v1 IGNORE KEY(non_existant); +ERROR HY000: Incorrect usage of index hints and VIEW +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL DEFAULT 0, +PRIMARY KEY(a), KEY (b)); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +CREATE VIEW v1 AS SELECT * FROM t1 FORCE KEY (PRIMARY,b) ORDER BY a; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` FORCE INDEX (PRIMARY) FORCE INDEX (`b`) order by `t1`.`a` latin1 latin1_swedish_ci +EXPLAIN SELECT * FROM v1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL PRIMARY 4 NULL 15 +CREATE VIEW v2 AS SELECT * FROM t1 USE KEY () ORDER BY a; +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` USE INDEX () order by `t1`.`a` latin1 latin1_swedish_ci +EXPLAIN SELECT * FROM v2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 15 Using filesort +CREATE VIEW v3 AS SELECT * FROM t1 IGNORE KEY (b) ORDER BY a; +SHOW CREATE VIEW v3; +View Create View character_set_client collation_connection +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`a` AS `a`,`t1`.`b` AS `b` from `t1` IGNORE INDEX (`b`) order by `t1`.`a` latin1 latin1_swedish_ci +EXPLAIN SELECT * FROM v3; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 15 Using filesort +DROP VIEW v1; +DROP VIEW v2; +DROP VIEW v3; +DROP TABLE t1; End of 5.0 tests. DROP DATABASE IF EXISTS `d-1`; CREATE DATABASE `d-1`; diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result index 49c98d8e03f..c301953f508 100644 --- a/mysql-test/r/view_grant.result +++ b/mysql-test/r/view_grant.result @@ -778,15 +778,60 @@ GRANT CREATE VIEW ON db26813.v2 TO u26813@localhost; GRANT DROP, CREATE VIEW ON db26813.v3 TO u26813@localhost; GRANT SELECT ON db26813.t1 TO u26813@localhost; ALTER VIEW v1 AS SELECT f2 FROM t1; -ERROR 42000: CREATE VIEW command denied to user 'u26813'@'localhost' for table 'v1' +ERROR 42000: Access denied; you need the SUPER privilege for this operation ALTER VIEW v2 AS SELECT f2 FROM t1; -ERROR 42000: DROP command denied to user 'u26813'@'localhost' for table 'v2' +ERROR 42000: Access denied; you need the SUPER privilege for this operation ALTER VIEW v3 AS SELECT f2 FROM t1; +ERROR 42000: Access denied; you need the SUPER privilege for this operation SHOW CREATE VIEW v3; View Create View character_set_client collation_connection -v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f2` AS `f2` from `t1` latin1 latin1_swedish_ci +v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v3` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci DROP USER u26813@localhost; DROP DATABASE db26813; +# +# Bug#29908: A user can gain additional access through the ALTER VIEW. +# +CREATE DATABASE mysqltest_29908; +USE mysqltest_29908; +CREATE TABLE t1(f1 INT, f2 INT); +CREATE USER u29908_1@localhost; +CREATE DEFINER = u29908_1@localhost VIEW v1 AS SELECT f1 FROM t1; +CREATE DEFINER = u29908_1@localhost SQL SECURITY INVOKER VIEW v2 AS +SELECT f1 FROM t1; +GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v1 TO u29908_1@localhost; +GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_1@localhost; +GRANT SELECT ON mysqltest_29908.t1 TO u29908_1@localhost; +CREATE USER u29908_2@localhost; +GRANT DROP, CREATE VIEW ON mysqltest_29908.v1 TO u29908_2@localhost; +GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_2@localhost; +GRANT SELECT ON mysqltest_29908.t1 TO u29908_2@localhost; +ALTER VIEW v1 AS SELECT f2 FROM t1; +ERROR 42000: Access denied; you need the SUPER privilege for this operation +ALTER VIEW v2 AS SELECT f2 FROM t1; +ERROR 42000: Access denied; you need the SUPER privilege for this operation +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci +ALTER VIEW v1 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f2` AS `f2` from `t1` latin1 latin1_swedish_ci +ALTER VIEW v2 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f2` AS `f2` from `t1` latin1 latin1_swedish_ci +ALTER VIEW v1 AS SELECT f1 FROM t1; +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci +ALTER VIEW v2 AS SELECT f1 FROM t1; +SHOW CREATE VIEW v2; +View Create View character_set_client collation_connection +v2 CREATE ALGORITHM=UNDEFINED DEFINER=`u29908_1`@`localhost` SQL SECURITY INVOKER VIEW `v2` AS select `t1`.`f1` AS `f1` from `t1` latin1 latin1_swedish_ci +DROP USER u29908_1@localhost; +DROP USER u29908_2@localhost; +DROP DATABASE mysqltest_29908; +####################################################################### DROP DATABASE IF EXISTS mysqltest1; DROP DATABASE IF EXISTS mysqltest2; CREATE DATABASE mysqltest1; @@ -893,6 +938,8 @@ v1 CREATE ALGORITHM=UNDEFINED DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VI Warnings: Warning 1356 View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them ALTER ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1; +Warnings: +Note 1449 There is no 'no_such'@'user_1' registered SHOW CREATE VIEW v1; View Create View character_set_client collation_connection v1 CREATE ALGORITHM=MERGE DEFINER=`no_such`@`user_1` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`i` AS `i` from `t1` latin1 latin1_swedish_ci diff --git a/mysql-test/suite/ndb/r/ps_7ndb.result b/mysql-test/suite/ndb/r/ps_7ndb.result index 82d2d14b075..e6bcb7f035e 100644 --- a/mysql-test/suite/ndb/r/ps_7ndb.result +++ b/mysql-test/suite/ndb/r/ps_7ndb.result @@ -2956,11 +2956,13 @@ Warnings: Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: +Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c17' at row 1 Warnings: Note 1265 Data truncated for column 'c13' at row 1 @@ -2994,7 +2996,6 @@ Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c17' at row 1 Warnings: -Note 1265 Data truncated for column 'c13' at row 1 Warning 1265 Data truncated for column 'c15' at row 1 Warning 1264 Out of range value for column 'c16' at row 1 Warning 1264 Out of range value for column 'c17' at row 1 diff --git a/mysql-test/suite/rpl/r/rpl_flushlog_loop.result b/mysql-test/suite/rpl/r/rpl_flushlog_loop.result index b47c262eb66..ca06a5a328c 100644 --- a/mysql-test/suite/rpl/r/rpl_flushlog_loop.result +++ b/mysql-test/suite/rpl/r/rpl_flushlog_loop.result @@ -4,6 +4,13 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; +show variables like 'relay_log%'; +Variable_name Value +relay_log MYSQLTEST_VARDIR/master-data/relay-log +relay_log_index +relay_log_info_file relay-log.info +relay_log_purge ON +relay_log_space_limit 0 stop slave; change master to master_host='127.0.0.1',master_user='root', master_password='',master_port=MASTER_PORT; diff --git a/mysql-test/suite/rpl/t/rpl_flushlog_loop.test b/mysql-test/suite/rpl/t/rpl_flushlog_loop.test index 7d92ba9c2f4..750b49f19a9 100644 --- a/mysql-test/suite/rpl/t/rpl_flushlog_loop.test +++ b/mysql-test/suite/rpl/t/rpl_flushlog_loop.test @@ -2,12 +2,9 @@ # in case of bi-directional replication -- source include/master-slave.inc -# -# Start replication master -> slave -# -# We have to sync with master, to ensure slave had time to start properly -# before we stop it. If not, we get errors about UNIX_TIMESTAMP() in the log. -sync_slave_with_master; +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +show variables like 'relay_log%'; + connection slave; --disable_warnings stop slave; diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index bca3a9c3a96..5525a5beb6f 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -651,4 +651,9 @@ select * from t1 where a=if(b<10,_ucs2 0x00C0,_ucs2 0x0062); select * from t1 where a=if(b<10,_ucs2 0x0062,_ucs2 0x00C0); drop table t1; +# +# Bug#30981 CHAR(0x41 USING ucs2) doesn't add leading zero +# +select hex(char(0x41 using ucs2)); + --echo End of 5.0 tests diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index b61bb1d53bf..5c35bf82343 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -1404,3 +1404,30 @@ SELECT b FROM t2 UNION SELECT c FROM t1; SELECT i FROM t2 UNION SELECT c FROM t1; DROP TABLE t1, t2; + +# +# Bug#30982: CHAR(..USING..) can return a not-well-formed string +# Bug #30986: Character set introducer followed by a HEX string can return bad result +# +set sql_mode=traditional; +select hex(char(0xFF using utf8)); +select hex(convert(0xFF using utf8)); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8 0x616263FF); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8 X'616263FF'); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8 B'001111111111'); +--error ER_INVALID_CHARACTER_STRING +select (_utf8 X'616263FF'); +set sql_mode=default; +select hex(char(0xFF using utf8)); +select hex(convert(0xFF using utf8)); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8 0x616263FF); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8 X'616263FF'); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8 B'001111111111'); +--error ER_INVALID_CHARACTER_STRING +select (_utf8 X'616263FF'); diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index 8a03cb6c715..602e30687c8 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -277,3 +277,18 @@ SELECT * FROM t1; DROP TABLE t1, t2; DROP DATABASE db1; DROP DATABASE db2; + +# +# Bug 31742: delete from ... order by function call that causes an error, +# asserts server +# + +CREATE FUNCTION f1() RETURNS INT RETURN 1; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (0); +--error 1318 +DELETE FROM t1 ORDER BY (f1(10)) LIMIT 1; +DROP TABLE t1; +DROP FUNCTION f1; + +--echo End of 5.0 tests diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index 4d8a8e3c3af..4e79fac584f 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -211,7 +211,8 @@ drop table t2; # select list counter # CREATE TABLE `t1` ( `itemid` int(11) NOT NULL default '0', `grpid` varchar(15) NOT NULL default '', `vendor` int(11) NOT NULL default '0', `date_` date NOT NULL default '0000-00-00', `price` decimal(12,2) NOT NULL default '0.00', PRIMARY KEY (`itemid`,`grpid`,`vendor`,`date_`), KEY `itemid` (`itemid`,`vendor`), KEY `itemid_2` (`itemid`,`date_`)); -insert into t1 values (128, 'rozn', 2, now(), 10),(128, 'rozn', 1, now(), 10); +insert into t1 values (128, 'rozn', 2, curdate(), 10), + (128, 'rozn', 1, curdate(), 10); SELECT MIN(price) min, MAX(price) max, AVG(price) avg FROM (SELECT SUBSTRING( MAX(concat(date_,";",price)), 12) price FROM t1 WHERE itemid=128 AND grpid='rozn' GROUP BY itemid, grpid, vendor) lastprices; DROP TABLE t1; diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index d1b4919c83e..e1ec6906cd6 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -867,5 +867,18 @@ SELECT MIN(a), MIN(b) FROM t5 WHERE a = 1 and b > 1; DROP TABLE t1, t2, t3, t4, t5; +# +# Bug #31156: mysqld: item_sum.cc:918: +# virtual bool Item_sum_distinct::setup(THD*): Assertion +# + +CREATE TABLE t1 (a INT); +INSERT INTO t1 values (),(),(); +SELECT (SELECT SLEEP(0) FROM t1 ORDER BY AVG(DISTINCT a) ) as x FROM t1 + GROUP BY x; +SELECT 1 FROM t1 GROUP BY (SELECT SLEEP(0) FROM t1 ORDER BY AVG(DISTINCT a) ); + +DROP TABLE t1; + ### --echo End of 5.0 tests diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index 2c5ed6a22d3..d8b0c89532e 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -408,5 +408,13 @@ select f2 from t2 where f2 in (1,'b'); explain select f2 from t2 where f2 in (1,'b'); drop table t1, t2; +# +# Bug #31075: crash in get_func_mm_tree +# + +create table t1 (a time, key(a)); +insert into t1 values (),(),(),(),(),(),(),(),(),(); +select a from t1 where a not in (a,a,a) group by a; +drop table t1; --echo End of 5.1 tests diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 668528b2e9b..274a953a314 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -224,4 +224,29 @@ select mod(cast(-2 as unsigned), 3), mod(18446744073709551614, 3), mod(-2, 3); select mod(5, cast(-2 as unsigned)), mod(5, 18446744073709551614), mod(5, -2); select pow(cast(-2 as unsigned), 5), pow(18446744073709551614, 5), pow(-2, 5); +# +# Bug #30587: mysql crashes when trying to group by TIME div NUMBER +# + +CREATE TABLE t1 (a timestamp, b varchar(20), c bit(1)); +INSERT INTO t1 VALUES('1998-09-23', 'str1', 1), ('2003-03-25', 'str2', 0); +SELECT a DIV 900 y FROM t1 GROUP BY y; +SELECT DISTINCT a DIV 900 y FROM t1; +SELECT b DIV 900 y FROM t1 GROUP BY y; +SELECT c DIV 900 y FROM t1 GROUP BY y; +DROP TABLE t1; + +CREATE TABLE t1(a LONGBLOB); +INSERT INTO t1 VALUES('1'),('2'),('3'); +SELECT DISTINCT (a DIV 254576881) FROM t1; +SELECT (a DIV 254576881) FROM t1 UNION ALL + SELECT (a DIV 254576881) FROM t1; +DROP TABLE t1; + +CREATE TABLE t1(a SET('a','b','c')); +INSERT INTO t1 VALUES ('a'); +SELECT a DIV 2 FROM t1 UNION SELECT a DIV 2 FROM t1; +DROP TABLE t1; + + --echo End of 5.0 tests diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 01eff55d1f6..4b7685c3633 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -198,6 +198,21 @@ drop table table_26093; drop function func_26093_a; drop function func_26093_b; +# +# Bug #30832: Assertion + crash with select name_const('test',now()); +# +--error ER_WRONG_ARGUMENTS +SELECT NAME_CONST('test', NOW()); +--error ER_WRONG_ARGUMENTS +SELECT NAME_CONST('test', UPPER('test')); + +SELECT NAME_CONST('test', NULL); +SELECT NAME_CONST('test', 1); +SELECT NAME_CONST('test', -1); +SELECT NAME_CONST('test', 1.0); +SELECT NAME_CONST('test', -1.0); +SELECT NAME_CONST('test', 'test'); + --echo End of 5.0 tests # diff --git a/mysql-test/t/func_regexp.test b/mysql-test/t/func_regexp.test index 23070c71fe9..5eff404bc0f 100644 --- a/mysql-test/t/func_regexp.test +++ b/mysql-test/t/func_regexp.test @@ -74,4 +74,13 @@ execute stmt1 using @a; deallocate prepare stmt1; drop table t1; -# End of 4.1 tests +--echo End of 4.1 tests + + +# +# Bug #31440: 'select 1 regex null' asserts debug server +# + +SELECT 1 REGEXP NULL; + +--echo End of 5.0 tests diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 945f5a050f4..0ba0ba30cd2 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -1231,4 +1231,16 @@ SELECT SUBSTR(a,1,len) FROM t1; DROP TABLE t1; +# +# Bug #28850: Potential bugs related to the return type of the CHAR function +# + +CREATE TABLE t1 AS SELECT CHAR(0x414243) as c1; +SELECT HEX(c1) from t1; +DROP TABLE t1; + +CREATE VIEW v1 AS SELECT CHAR(0x414243) as c1; +SELECT HEX(c1) from v1; +DROP VIEW v1; + --echo End of 5.0 tests diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index d3346bbb880..5c1a5c2200b 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -548,6 +548,16 @@ DROP TABLE testBug8868; SET NAMES DEFAULT; # +# Bug #31160: MAKETIME() crashes server when returning NULL in ORDER BY using +# filesort +# +CREATE TABLE t1 ( + a TIMESTAMP +); +INSERT INTO t1 VALUES (now()), (now()); +SELECT 1 FROM t1 ORDER BY MAKETIME(1, 1, a); +DROP TABLE t1; +# # Bug #19844 time_format in Union truncates values # diff --git a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test index 88f31143d93..dad22f42571 100644 --- a/mysql-test/t/gis-rtree.test +++ b/mysql-test/t/gis-rtree.test @@ -797,6 +797,42 @@ UPDATE t1 set spatial_point=GeomFromText('POINT(41 46)') where c1 like 'f%'; CHECK TABLE t1 EXTENDED; DROP TABLE t1; +# +# Bug #30286 spatial index cause corruption and server crash! +# + +create table t1 (a geometry not null, spatial index(a)); +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 131072))); +insert into t1 values (PointFromWKB(POINT(9.1248812352444e+192, 2.9740338169556e+284))); +insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, -0))); +insert into t1 values (PointFromWKB(POINT(1.49166814624e-154, 2.0880974297595e-53))); +insert into t1 values (PointFromWKB(POINT(4.0917382598702e+149, 1.2024538023802e+111))); +insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 2.9993936277913e-241))); +insert into t1 values (PointFromWKB(POINT(2.5243548967072e-29, 1.2024538023802e+111))); +insert into t1 values (PointFromWKB(POINT(0, 6.9835074892995e-251))); +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 3.1050361846014e+231))); +insert into t1 values (PointFromWKB(POINT(2.8728483499323e-188, 2.4600631144627e+260))); +insert into t1 values (PointFromWKB(POINT(3.0517578125e-05, 2.0349165139404e+236))); +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 1.1818212630766e-125))); +insert into t1 values (PointFromWKB(POINT(2.481040258324e-265, 5.7766220027675e-275))); +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 2.5243548967072e-29))); +insert into t1 values (PointFromWKB(POINT(5.7766220027675e-275, 9.9464647281957e+86))); +insert into t1 values (PointFromWKB(POINT(2.2181357552967e+130, 3.7857669957337e-270))); +insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.6893488147419e+19))); +insert into t1 values (PointFromWKB(POINT(4.5767114681874e-246, 3.7537584144024e+255))); +insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 1.8033161362863e-130))); +insert into t1 values (PointFromWKB(POINT(0, 5.8774717541114e-39))); +insert into t1 values (PointFromWKB(POINT(1.1517219314031e+164, 2.2761049594727e-159))); +insert into t1 values (PointFromWKB(POINT(6.243497100632e+144, 3.7857669957337e-270))); +insert into t1 values (PointFromWKB(POINT(3.7857669957337e-270, 2.6355494858076e-82))); +insert into t1 values (PointFromWKB(POINT(2.0349165139404e+236, 3.8518598887745e-34))); +insert into t1 values (PointFromWKB(POINT(4.6566128730774e-10, 2.0880974297595e-53))); +insert into t1 values (PointFromWKB(POINT(2.0880974297595e-53, 1.8827498946116e-183))); +insert into t1 values (PointFromWKB(POINT(1.8033161362863e-130, 9.1248812352444e+192))); +insert into t1 values (PointFromWKB(POINT(4.7783097267365e-299, 2.2761049594727e-159))); +insert into t1 values (PointFromWKB(POINT(1.94906280228e+289, 1.2338789709327e-178))); +drop table t1; + # End of 4.1 tests # diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index d7182e36e3a..b4c515d2e8c 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -432,6 +432,14 @@ INSERT INTO t1 VALUES (NULL); SELECT * FROM t1; DROP TABLE t1; +# +# Bug #30955 geomfromtext() crasher +# +CREATE TABLE `t1` ( `col9` set('a'), `col89` date); +INSERT INTO `t1` VALUES ('','0000-00-00'); +select geomfromtext(col9,col89) as a from t1; +DROP TABLE t1; + --echo End of 4.1 tests # @@ -591,6 +599,8 @@ SELECT AsText(GeometryFromText(CONCAT( --enable_query_log SELECT 1; +-- source include/gis_keys.inc + --echo End of 5.0 tests diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test index f6075ba2ee4..0f0c92e82eb 100644 --- a/mysql-test/t/grant2.test +++ b/mysql-test/t/grant2.test @@ -585,5 +585,37 @@ drop user mysqltest_1@localhost; drop user mysqltest_2@localhost; +# +# Bug #30468: column level privileges not respected when joining tables +# +CREATE DATABASE db1; + +USE db1; +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (1,1),(2,2); + +CREATE TABLE t2 (b INT, c INT); +INSERT INTO t2 VALUES (1,100),(2,200); + +GRANT SELECT ON t1 TO mysqltest1@localhost; +GRANT SELECT (b) ON t2 TO mysqltest1@localhost; + +connect (conn1,localhost,mysqltest1,,); +connection conn1; +USE db1; +--error ER_COLUMNACCESS_DENIED_ERROR +SELECT c FROM t2; +--error ER_COLUMNACCESS_DENIED_ERROR +SELECT * FROM t2; +--error ER_COLUMNACCESS_DENIED_ERROR +SELECT * FROM t1 JOIN t2 USING (b); + +connection default; +disconnect conn1; +DROP TABLE db1.t1, db1.t2; +DROP USER mysqltest1@localhost; +DROP DATABASE db1; + + --echo End of 5.0 tests diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index ae616df0dfd..2ea7aed6bd2 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -811,6 +811,7 @@ EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY,i2); EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR JOIN (PRIMARY,i2); EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY,i2) GROUP BY a; EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a; EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) IGNORE INDEX FOR GROUP BY (i2) GROUP BY a; EXPLAIN SELECT a FROM t1 IGNORE INDEX (PRIMARY) IGNORE INDEX FOR ORDER BY (i2); diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 9ad658645bd..1987d9d5773 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -1090,6 +1090,14 @@ show columns from t1; drop table t1; --echo End of 5.0 tests. + +# +# Bug#30079 A check for "hidden" I_S tables is flawed +# +--error 1109 +show fields from information_schema.table_names; +--error 1109 +show keys from information_schema.table_names; # # Show engines # @@ -1178,4 +1186,50 @@ select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysql' AND TA select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='mysql' AND TABLE_NAME=''; select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='' AND TABLE_NAME=''; select count(*) from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA='' AND TABLE_NAME='nonexisting'; + +# +# Bug#30689 Wrong content in I_S.VIEWS.VIEW_DEFINITION if VIEW is based on I_S +# +CREATE VIEW v1 +AS SELECT * +FROM INFORMATION_SCHEMA.TABLES; +SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS where TABLE_NAME = 'v1'; +DROP VIEW v1; + +# +# Bug#30795 Query on INFORMATION_SCHEMA.SCHEMATA, wrong result +# +SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA +WHERE SCHEMA_NAME ='information_schema'; + +# +# Bug#31381 Error in retrieving Data from INFORMATION_SCHEMA +# +SELECT TABLE_COLLATION FROM INFORMATION_SCHEMA.TABLES +WHERE TABLE_SCHEMA='mysql' and TABLE_NAME= 'db'; + +# +# Bug#31633 Information schema = NULL queries crash the server +# +select * from information_schema.columns where table_schema = NULL; +select * from `information_schema`.`COLUMNS` where `TABLE_NAME` = NULL; +select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_SCHEMA` = NULL; +select * from `information_schema`.`KEY_COLUMN_USAGE` where `TABLE_NAME` = NULL; +select * from `information_schema`.`PARTITIONS` where `TABLE_SCHEMA` = NULL; +select * from `information_schema`.`PARTITIONS` where `TABLE_NAME` = NULL; +select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `CONSTRAINT_SCHEMA` = NULL; +select * from `information_schema`.`REFERENTIAL_CONSTRAINTS` where `TABLE_NAME` = NULL; +select * from information_schema.schemata where schema_name = NULL; +select * from `information_schema`.`STATISTICS` where `TABLE_SCHEMA` = NULL; +select * from `information_schema`.`STATISTICS` where `TABLE_NAME` = NULL; +select * from information_schema.tables where table_schema = NULL; +select * from information_schema.tables where table_catalog = NULL; +select * from information_schema.tables where table_name = NULL; +select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_SCHEMA` = NULL; +select * from `information_schema`.`TABLE_CONSTRAINTS` where `TABLE_NAME` = NULL; +select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_SCHEMA` = NULL; +select * from `information_schema`.`TRIGGERS` where `EVENT_OBJECT_TABLE` = NULL; +select * from `information_schema`.`VIEWS` where `TABLE_SCHEMA` = NULL; +select * from `information_schema`.`VIEWS` where `TABLE_NAME` = NULL; + --echo End of 5.1 tests. diff --git a/mysql-test/t/innodb_gis.test b/mysql-test/t/innodb_gis.test index 9675b6b69dc..1adb14ea482 100644 --- a/mysql-test/t/innodb_gis.test +++ b/mysql-test/t/innodb_gis.test @@ -1,6 +1,7 @@ --source include/have_innodb.inc SET storage_engine=innodb; --source include/gis_generic.inc +--source include/gis_keys.inc # # Bug #15680 (SPATIAL key in innodb) diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index ace51ef61c7..499db086877 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -372,3 +372,15 @@ INSERT INTO t1 (prev_id) SELECT id SELECT * FROM t1; DROP TABLE t1,t2; + +--echo # +--echo # Bug#30384: Having SQL_BUFFER_RESULT option in the +--echo # CREATE .. KEY(..) .. SELECT led to creating corrupted index. +--echo # +create table t1(f1 int); +insert into t1 values(1),(2),(3); +create table t2 (key(f1)) engine=myisam select sql_buffer_result f1 from t1; +check table t2 extended; +drop table t1,t2; +--echo ################################################################## + diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index 14c98431970..ed1b84bb5ec 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -698,4 +698,33 @@ select '^^: The above should be ~= 20 + cost(select * from t1). Value less than drop table t1, t2; +# +# Bug #31094: Forcing index-based sort doesn't work anymore if joins are +# done +# + +CREATE TABLE t1 (a INT PRIMARY KEY, b INT); +CREATE TABLE t2 (c INT PRIMARY KEY, d INT); + +INSERT INTO t1 VALUES(1,NULL),(2,NULL),(3,NULL),(4,NULL); +INSERT INTO t1 SELECT a + 4, b FROM t1; +INSERT INTO t1 SELECT a + 8, b FROM t1; +INSERT INTO t1 SELECT a + 16, b FROM t1; +INSERT INTO t1 SELECT a + 32, b FROM t1; +INSERT INTO t1 SELECT a + 64, b FROM t1; +INSERT INTO t2 SELECT a, b FROM t1; + +#expect indexed ORDER BY +EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2; +EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2; +SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a LIMIT 2; +SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a LIMIT 2; + +#expect filesort +EXPLAIN SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a; +EXPLAIN SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a; +SELECT * FROM t1 JOIN t2 ON b=c ORDER BY a; +SELECT * FROM t1 JOIN t2 ON a=c ORDER BY a; + +DROP TABLE IF EXISTS t1,t2; --echo End of 5.0 tests. diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 0440b0fb63a..158e8a769bd 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1577,6 +1577,23 @@ SELECT * FROM t2; DROP TABLE t1,t2; --echo # +--echo # Bug#29815: new option for suppressing last line of mysqldump: +--echo # "Dump completed on" +--echo # + +--echo # --skip-dump-date: +--replace_regex /-- [^D][^u][^m][^p].*// /\/\*!.*// +--exec $MYSQL_DUMP --skip-dump-date test + +--echo # --dump-date: +--replace_regex /-- [^D][^u][^m][^p].*// /\/\*!.*// / on [0-9 :-]+/ on DATE/ +--exec $MYSQL_DUMP --dump-date test + +--echo # --dump-date (default): +--replace_regex /-- [^D][^u][^m][^p].*// /\/\*!.*// / on [0-9 :-]+/ on DATE/ +--exec $MYSQL_DUMP test + +--echo # --echo # End of 5.0 tests --echo # diff --git a/mysql-test/t/mysqlslap.test b/mysql-test/t/mysqlslap.test index dffa226d101..28042f62fe6 100644 --- a/mysql-test/t/mysqlslap.test +++ b/mysql-test/t/mysqlslap.test @@ -40,3 +40,16 @@ --exec $MYSQL_SLAP --only-print --delimiter=";" --query="select * from t1;select * from t2" --create="CREATE TABLE t1 (id int, name varchar(64)); create table t2(foo1 varchar(32), foo2 varchar(32)); INSERT INTO t1 VALUES (1, 'This is a test'); insert into t2 values ('test', 'test2')" --engine="heap,myisam" --post-query="SHOW TABLES" --pre-query="SHOW TABLES" --number-of-queries=6 --commit=1; --exec $MYSQL_SLAP --silent --concurrency=5 --iterations=1 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --auto-generate-sql-add-autoincrement --auto-generate-sql-load-type=write --detach=2 + +--echo # +--echo # Bug #29985: mysqlslap -- improper handling of resultsets in SPROCs +--echo # + +--disable_warnings +DROP PROCEDURE IF EXISTS p1; +--enable_warnings +CREATE PROCEDURE p1() SELECT 1; + +--exec $MYSQL_SLAP --create-schema=test --delimiter=";" --query="CALL p1; SELECT 1;" --silent 2>&1 + +DROP PROCEDURE p1; diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test index 65e09b006ec..2878b54c357 100644 --- a/mysql-test/t/null.test +++ b/mysql-test/t/null.test @@ -1,6 +1,6 @@ # Initialise --disable_warnings -drop table if exists t1; +drop table if exists t1, t2; --enable_warnings # @@ -231,4 +231,27 @@ drop table bug19145a; drop table bug19145b; drop table bug19145c; -# End of 4.1 tests +--echo # End of 4.1 tests + +--echo # +--echo # Bug #31471: decimal_bin_size: Assertion `scale >= 0 && +--echo # precision > 0 && scale <= precision' +--echo # + +CREATE TABLE t1 (a DECIMAL (1, 0) ZEROFILL, b DECIMAL (1, 0) ZEROFILL); +INSERT INTO t1 (a, b) VALUES (0, 0); + +CREATE TABLE t2 SELECT IFNULL(a, b) FROM t1; +DESCRIBE t2; +DROP TABLE t2; + +CREATE TABLE t2 SELECT IFNULL(a, NULL) FROM t1; +DESCRIBE t2; +DROP TABLE t2; + +CREATE TABLE t2 SELECT IFNULL(NULL, b) FROM t1; +DESCRIBE t2; + +DROP TABLE t1, t2; + +--echo # End of 5.0 tests diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test index 05934bff492..1ac99d9c39f 100644 --- a/mysql-test/t/olap.test +++ b/mysql-test/t/olap.test @@ -358,3 +358,12 @@ SELECT * FROM (SELECT a, SUM(a) FROM t1 GROUP BY a WITH ROLLUP) as t; DROP TABLE t1; +--echo # +--echo # Bug#31095: Unexpected NULL constant caused server crash. +--echo # +create table t1(a int); +insert into t1 values (1),(2),(3); +select count(a) from t1 group by null with rollup; +drop table t1; +--echo ############################################################## + diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 37398616299..71238504d36 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -779,3 +779,60 @@ EXPLAIN SELECT id,c3 FROM t2 WHERE c2 BETWEEN 20 AND 30 ORDER BY c3 LIMIT 4000; SELECT id,c3 FROM t2 WHERE c2=11 ORDER BY c3 LIMIT 20; DROP TABLE t1,t2; + +# +# Bug #30665: Inconsistent optimization of IGNORE INDEX FOR {ORDER BY|GROUP BY} +# +CREATE TABLE t1 ( + a INT, + b INT, + PRIMARY KEY (a), + KEY ab(a, b) +); +INSERT INTO t1 VALUES (1,1),(2,2),(3,3),(4,4); +INSERT INTO t1 SELECT a + 4, b + 4 FROM t1; +INSERT INTO t1 SELECT a + 8, b + 8 FROM t1; +INSERT INTO t1 SELECT a +16, b +16 FROM t1; +INSERT INTO t1 SELECT a +32, b +32 FROM t1; +INSERT INTO t1 SELECT a +64, b +64 FROM t1; + +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a; + +--disable_query_log +--let $q = `show status like 'Created_tmp_tables';` +eval set @tmp_tables_before = + CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED); +--enable_query_log + +SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a; + +# this query creates one temporary table in itself, which we are not +# interested in. + +--disable_query_log +--let $q = `show status like 'Created_tmp_tables';` +eval set @tmp_tables_after = + CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED); +--enable_query_log + +SELECT @tmp_tables_after = @tmp_tables_before ; + +EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a; + +--disable_query_log +--let $q = `show status like 'Created_tmp_tables';` +eval set @tmp_tables_before = + CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED); +--enable_query_log + +SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a; + +--disable_query_log +--let $q = `show status like 'Created_tmp_tables';` +eval set @tmp_tables_after = + CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED); +--enable_query_log + +SELECT @tmp_tables_after = @tmp_tables_before; + +DROP TABLE t1; diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index 7571e60859f..0f533cbece0 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -1254,6 +1254,7 @@ disconnect user3; # # Bug #28211 RENAME DATABASE and query cache don't play nicely together +# # TODO: enable these tests when RENAME DATABASE is implemented. # --disable_warnings # drop database if exists db1; @@ -1299,3 +1300,22 @@ set GLOBAL query_cache_limit=default; set GLOBAL query_cache_min_res_unit=default; set GLOBAL query_cache_size=default; +# +# Bug #31157: Crash when select+order by the avg of some field within the +# group by +# + +CREATE TABLE t1 (a ENUM('rainbow')); +INSERT INTO t1 VALUES (),(),(),(),(); +SELECT 1 FROM t1 GROUP BY (SELECT 1 FROM t1 ORDER BY AVG(LAST_INSERT_ID())); +DROP TABLE t1; +CREATE TABLE t1 (a LONGBLOB); +INSERT INTO t1 SET a = 'aaaa'; +INSERT INTO t1 SET a = 'aaaa'; +SELECT 1 FROM t1 GROUP BY + (SELECT LAST_INSERT_ID() FROM t1 ORDER BY MIN(a) ASC LIMIT 1); +DROP TABLE t1; + + +--echo End of 5.1 tests + diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index dcee4fd2ffc..b21f21d2f3d 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -139,3 +139,58 @@ insert into t1 values (9912101,9912101,9912101); insert into t1 values (11111,11111,11111); select * from t1; drop table t1; + +# +# Bug #30942: select str_to_date from derived table returns varying results +# +CREATE TABLE t1 ( + a INT +); + +INSERT INTO t1 VALUES (1); +INSERT INTO t1 VALUES (NULL); + +SELECT str_to_date( '', a ) FROM t1; +DROP TABLE t1; + + +# +# Bug #31221: Optimizer incorrectly identifies impossible WHERE clause +# + +CREATE TABLE t1 (a DATE, b int, PRIMARY KEY (a,b)); +INSERT INTO t1 VALUES (DATE(NOW()), 1); +SELECT COUNT(*) FROM t1 WHERE a = NOW(); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); +INSERT INTO t1 VALUES (DATE(NOW()), 2); +SELECT COUNT(*) FROM t1 WHERE a = NOW(); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); +SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1; +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW() AND b = 1; +ALTER TABLE t1 DROP PRIMARY KEY; +SELECT COUNT(*) FROM t1 WHERE a = NOW(); +EXPLAIN SELECT COUNT(*) FROM t1 WHERE a = NOW(); + +DROP TABLE t1; + +# +# Bug #28687: Search fails on '0000-00-00' date after sql_mode change +# + +CREATE TABLE t1 (a DATE); +CREATE TABLE t2 (a DATE); +CREATE INDEX i ON t1 (a); +INSERT INTO t1 VALUES ('0000-00-00'),('0000-00-00'); +INSERT INTO t2 VALUES ('0000-00-00'),('0000-00-00'); +SELECT * FROM t1 WHERE a = '0000-00-00'; +SELECT * FROM t2 WHERE a = '0000-00-00'; +SET SQL_MODE=TRADITIONAL; +EXPLAIN SELECT * FROM t1 WHERE a = '0000-00-00'; +SELECT * FROM t1 WHERE a = '0000-00-00'; +SELECT * FROM t2 WHERE a = '0000-00-00'; +--error ER_TRUNCATED_WRONG_VALUE +INSERT INTO t1 VALUES ('0000-00-00'); +SET SQL_MODE=DEFAULT; +DROP TABLE t1,t2; + +--echo End of 5.0 tests diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index 6aa6edd128e..fada7983c2c 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -283,6 +283,43 @@ select * from t1 where f1 between 2002010 and 20070101000000; select * from t1 where f1 between 20020101 and 2007010100000; drop table t1; +--echo # +--echo # Bug#27216: functions with parameters of different date types may +--echo # return wrong type of the result. +--echo # +create table t1 (f1 date, f2 datetime, f3 varchar(20)); +create table t2 as select coalesce(f1,f1) as f4 from t1; +desc t2; +create table t3 as select coalesce(f1,f2) as f4 from t1; +desc t3; +create table t4 as select coalesce(f2,f2) as f4 from t1; +desc t4; +create table t5 as select coalesce(f1,f3) as f4 from t1; +desc t5; +create table t6 as select coalesce(f2,f3) as f4 from t1; +desc t6; +create table t7 as select coalesce(makedate(1997,1),f2) as f4 from t1; +desc t7; +create table t8 as select coalesce(cast('01-01-01' as datetime),f2) as f4 + from t1; +desc t8; +create table t9 as select case when 1 then cast('01-01-01' as date) + when 0 then cast('01-01-01' as date) end as f4 from t1; +desc t9; +create table t10 as select case when 1 then cast('01-01-01' as datetime) + when 0 then cast('01-01-01' as datetime) end as f4 from t1; +desc t10; +create table t11 as select if(1, cast('01-01-01' as datetime), + cast('01-01-01' as date)) as f4 from t1; +desc t11; +create table t12 as select least(cast('01-01-01' as datetime), + cast('01-01-01' as date)) as f4 from t1; +desc t12; +create table t13 as select ifnull(cast('01-01-01' as datetime), + cast('01-01-01' as date)) as f4 from t1; +desc t13; +drop tables t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13; +--echo ################################################################### # # Bug #31253: crash comparing datetime to double # Should return 1st row only. Crashes if NULL propagation fails. @@ -302,7 +339,6 @@ select sum(a) from t1 group by convert(a, datetime); drop table t1; --echo End of 5.0 tests - # # Test of storing datetime into date fields # diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index 458583fca81..4d61350a613 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -410,6 +410,13 @@ SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1; DROP TABLE t1; # +# Bug#31019: MOD() function and operator crashes MySQL when +# divisor is very long and < 1 +# + +SELECT 1 % .123456789123456789123456789123456789123456789123456789123456789123456789123456789 AS '%'; +SELECT MOD(1, .123456789123456789123456789123456789123456789123456789123456789123456789123456789) AS 'MOD()'; + # Bug #31227: memory overrun with decimal (6,6) and zerofill and group_concat # valgrind will complain about this (the group_concat(f2)) on unpatched mysqld. # @@ -419,3 +426,4 @@ select group_concat(f1),group_concat(f2) from t1; drop table t1; --echo End of 5.0 tests + diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index f474d166fae..4a161ea3725 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -575,7 +575,14 @@ set @test = @@query_prealloc_size; set @@query_prealloc_size = @test; select @@query_prealloc_size = @test; -# End of 4.1 tests +# +# Bug#31588 buffer overrun when setting variables +# +# Buffer-size Off By One. Should throw valgrind-warning without fix #31588. +--error 1231 +set global sql_mode=repeat('a',80); + +--echo End of 4.1 tests # # Bug#6282 Packet error with SELECT INTO diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 67354c14cff..e388aa61803 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -510,7 +510,7 @@ drop table t1; # create table t1 (a int, b int); create view v1 as select a, sum(b) from t1 group by a; --- error 1176 +--error ER_WRONG_USAGE select b from v1 use index (some_index) where b=1; drop view v1; drop table t1; @@ -2549,21 +2549,20 @@ CREATE TABLE t1( fName varchar(25) NOT NULL, lName varchar(25) NOT NULL, DOB date NOT NULL, + test_date date NOT NULL, uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY); -INSERT INTO t1(fName, lName, DOB) VALUES - ('Hank', 'Hill', '1964-09-29'), - ('Tom', 'Adams', '1908-02-14'), - ('Homer', 'Simpson', '1968-03-05'); +INSERT INTO t1(fName, lName, DOB, test_date) VALUES + ('Hank', 'Hill', '1964-09-29', '2007-01-01'), + ('Tom', 'Adams', '1908-02-14', '2007-01-01'), + ('Homer', 'Simpson', '1968-03-05', '2007-01-01'); CREATE VIEW v1 AS - SELECT (year(now())-year(DOB)) AS Age + SELECT (year(test_date)-year(DOB)) AS Age FROM t1 HAVING Age < 75; SHOW CREATE VIEW v1; -set timestamp=1136066400; -SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75; -set timestamp=1136066400; +SELECT (year(test_date)-year(DOB)) AS Age FROM t1 HAVING Age < 75; SELECT * FROM v1; DROP VIEW v1; @@ -3415,6 +3414,46 @@ select table_name, is_updatable from information_schema.views drop view v1; drop table t1; +# +# Bug #28701: SELECTs from VIEWs completely ignore USE/FORCE KEY, allowing +# invalid statements +# + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE VIEW v1 AS SELECT * FROM t1; +--error ER_WRONG_USAGE +SELECT * FROM v1 USE KEY(non_existant); +--error ER_WRONG_USAGE +SELECT * FROM v1 FORCE KEY(non_existant); +--error ER_WRONG_USAGE +SELECT * FROM v1 IGNORE KEY(non_existant); + +DROP VIEW v1; +DROP TABLE t1; + +# +# Bug #28702: VIEWs defined with USE/FORCE KEY ignore that request +# +CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL DEFAULT 0, + PRIMARY KEY(a), KEY (b)); +INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +CREATE VIEW v1 AS SELECT * FROM t1 FORCE KEY (PRIMARY,b) ORDER BY a; +SHOW CREATE VIEW v1; +EXPLAIN SELECT * FROM v1; +CREATE VIEW v2 AS SELECT * FROM t1 USE KEY () ORDER BY a; +SHOW CREATE VIEW v2; +EXPLAIN SELECT * FROM v2; +CREATE VIEW v3 AS SELECT * FROM t1 IGNORE KEY (b) ORDER BY a; +SHOW CREATE VIEW v3; +EXPLAIN SELECT * FROM v3; + +DROP VIEW v1; +DROP VIEW v2; +DROP VIEW v3; +DROP TABLE t1; + + --echo End of 5.0 tests. # diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test index b3bfd1cf544..3be0148f765 100644 --- a/mysql-test/t/view_grant.test +++ b/mysql-test/t/view_grant.test @@ -1040,10 +1040,11 @@ GRANT SELECT ON db26813.t1 TO u26813@localhost; connect (u1,localhost,u26813,,db26813); connection u1; ---error 1142 +--error ER_SPECIFIC_ACCESS_DENIED_ERROR ALTER VIEW v1 AS SELECT f2 FROM t1; ---error 1142 +--error ER_SPECIFIC_ACCESS_DENIED_ERROR ALTER VIEW v2 AS SELECT f2 FROM t1; +--error ER_SPECIFIC_ACCESS_DENIED_ERROR ALTER VIEW v3 AS SELECT f2 FROM t1; connection root; @@ -1053,6 +1054,51 @@ DROP USER u26813@localhost; DROP DATABASE db26813; disconnect u1; +--echo # +--echo # Bug#29908: A user can gain additional access through the ALTER VIEW. +--echo # +connection root; +CREATE DATABASE mysqltest_29908; +USE mysqltest_29908; +CREATE TABLE t1(f1 INT, f2 INT); +CREATE USER u29908_1@localhost; +CREATE DEFINER = u29908_1@localhost VIEW v1 AS SELECT f1 FROM t1; +CREATE DEFINER = u29908_1@localhost SQL SECURITY INVOKER VIEW v2 AS + SELECT f1 FROM t1; +GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v1 TO u29908_1@localhost; +GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_1@localhost; +GRANT SELECT ON mysqltest_29908.t1 TO u29908_1@localhost; +CREATE USER u29908_2@localhost; +GRANT DROP, CREATE VIEW ON mysqltest_29908.v1 TO u29908_2@localhost; +GRANT DROP, CREATE VIEW, SHOW VIEW ON mysqltest_29908.v2 TO u29908_2@localhost; +GRANT SELECT ON mysqltest_29908.t1 TO u29908_2@localhost; + +connect (u2,localhost,u29908_2,,mysqltest_29908); +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +ALTER VIEW v1 AS SELECT f2 FROM t1; +--error ER_SPECIFIC_ACCESS_DENIED_ERROR +ALTER VIEW v2 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v2; + +connect (u1,localhost,u29908_1,,mysqltest_29908); +ALTER VIEW v1 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v1; +ALTER VIEW v2 AS SELECT f2 FROM t1; +SHOW CREATE VIEW v2; + +connection root; +ALTER VIEW v1 AS SELECT f1 FROM t1; +SHOW CREATE VIEW v1; +ALTER VIEW v2 AS SELECT f1 FROM t1; +SHOW CREATE VIEW v2; + +DROP USER u29908_1@localhost; +DROP USER u29908_2@localhost; +DROP DATABASE mysqltest_29908; +disconnect u1; +disconnect u2; +--echo ####################################################################### + # # BUG#24040: Create View don't succed with "all privileges" on a database. # |