summaryrefslogtreecommitdiff
path: root/mysql-test/t
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t')
-rw-r--r--mysql-test/t/cte_nonrecursive.test47
-rw-r--r--mysql-test/t/cte_recursive.test48
-rw-r--r--mysql-test/t/delimiter_case_mdev_10728.sql3
-rw-r--r--mysql-test/t/delimiter_command_case_sensitivity.test4
-rw-r--r--mysql-test/t/derived_cond_pushdown.test18
-rw-r--r--mysql-test/t/errors.test11
-rw-r--r--mysql-test/t/func_misc.test17
-rw-r--r--mysql-test/t/having.test80
-rw-r--r--mysql-test/t/show_check.test4
-rw-r--r--mysql-test/t/subselect_exists2in.test40
-rw-r--r--mysql-test/t/type_bit.test19
-rw-r--r--mysql-test/t/type_date.test9
-rw-r--r--mysql-test/t/type_time.test11
-rw-r--r--mysql-test/t/view.test1
14 files changed, 310 insertions, 2 deletions
diff --git a/mysql-test/t/cte_nonrecursive.test b/mysql-test/t/cte_nonrecursive.test
index 57b7ae1658f..742e8f6e4d7 100644
--- a/mysql-test/t/cte_nonrecursive.test
+++ b/mysql-test/t/cte_nonrecursive.test
@@ -743,3 +743,50 @@ eval $q;
eval explain $q;
DROP TABLE t1,t2;
+
+--echo #
+--echo # MDEV-13780: tower of embedding CTEs with multiple usage of them
+--echo #
+
+create table t1 (a int);
+insert into t1 values (3), (2), (4), (7), (1), (2), (5);
+
+let $q=
+with cte_e as
+(
+ with cte_o as
+ (
+ with cte_i as (select * from t1 where a < 7)
+ select * from cte_i where a > 1
+ )
+ select * from cte_o as cto_o1 where a < 3
+ union
+ select * from cte_o as cto_o2 where a > 4
+)
+select * from cte_e as cte_e1 where a > 1
+union
+select * from cte_e as cte_e2;
+
+eval $q;
+eval explain extended $q;
+
+drop table t1;
+
+--echo #
+--echo # MDEV-13753: embedded CTE in a VIEW created in prepared statement
+--echo #
+
+SET @sql_query = "
+ CREATE OR REPLACE VIEW cte_test AS
+ WITH cte1 AS ( SELECT 1 as a from dual )
+ , cte2 AS ( SELECT * FROM cte1 )
+ SELECT * FROM cte2;
+";
+PREPARE stmt FROM @sql_query;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+
+SHOW CREATE VIEW cte_test;
+SELECT * FROM cte_test;
+
+DROP VIEW cte_test;
diff --git a/mysql-test/t/cte_recursive.test b/mysql-test/t/cte_recursive.test
index 5701ee896cb..7d7600f0e88 100644
--- a/mysql-test/t/cte_recursive.test
+++ b/mysql-test/t/cte_recursive.test
@@ -1928,3 +1928,51 @@ set standard_compliant_cte=default;
DROP TABLE t;
+--echo #
+--echo # mdev-14184: recursive CTE embedded into CTE with multiple references
+--echo #
+
+WITH
+cte1 AS (
+ SELECT n FROM (
+ WITH RECURSIVE rec_cte(n) AS (
+ SELECT 1 as n1
+ UNION ALL
+ SELECT n+1 as n2 FROM rec_cte WHERE n < 3
+ ) SELECT n FROM rec_cte
+ ) AS X
+),
+cte2 as (
+ SELECT 2 FROM cte1
+)
+SELECT *
+FROM cte1;
+
+--echo #
+--echo # MDEV-14217 [db crash] Recursive CTE when SELECT includes new field
+--echo #
+
+CREATE TEMPORARY TABLE a_tbl (
+ a VARCHAR(33) PRIMARY KEY,
+ b VARCHAR(33)
+);
+
+INSERT INTO a_tbl VALUES ('block0', 'block0'), ('block1', NULL);
+
+--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
+WITH RECURSIVE Q0 AS (
+ SELECT T0.a, T0.b, 5
+ FROM a_tbl T0
+ WHERE b IS NULL
+ UNION ALL
+ SELECT T1.a, T1.b
+ FROM Q0
+ JOIN a_tbl T1
+ ON T1.a=Q0.a
+) SELECT distinct(Q0.a), Q0.b
+ FROM Q0;
+DROP TABLE a_tbl;
+
+--error ER_WRONG_NUMBER_OF_COLUMNS_IN_SELECT
+WITH RECURSIVE x AS (SELECT 1,2 UNION ALL SELECT 1 FROM x) SELECT * FROM x;
+
diff --git a/mysql-test/t/delimiter_case_mdev_10728.sql b/mysql-test/t/delimiter_case_mdev_10728.sql
new file mode 100644
index 00000000000..72a1dcd9a9e
--- /dev/null
+++ b/mysql-test/t/delimiter_case_mdev_10728.sql
@@ -0,0 +1,3 @@
+DeLiMiTeR A;
+SELECT 1 A;
+delimiter ;
diff --git a/mysql-test/t/delimiter_command_case_sensitivity.test b/mysql-test/t/delimiter_command_case_sensitivity.test
new file mode 100644
index 00000000000..11d1cf75aa0
--- /dev/null
+++ b/mysql-test/t/delimiter_command_case_sensitivity.test
@@ -0,0 +1,4 @@
+source include/not_embedded.inc;
+
+# MDEV-10728
+--exec $MYSQL --default-character-set=binary < "t/delimiter_case_mdev_10728.sql"
diff --git a/mysql-test/t/derived_cond_pushdown.test b/mysql-test/t/derived_cond_pushdown.test
index c4f1ee7d734..a9bb998bc33 100644
--- a/mysql-test/t/derived_cond_pushdown.test
+++ b/mysql-test/t/derived_cond_pushdown.test
@@ -1550,6 +1550,23 @@ DROP VIEW v2;
DROP TABLE t1,t2;
--echo #
+--echo # MDEV-14237: derived with regexp_substr() in select list
+--echo #
+
+create table t1 (a char(8));
+insert into t1 values ('b'), ('a'), ('xx');
+
+let $q=
+select *
+from ( select distinct regexp_substr(t1.a,'^[A-Za-z]+') as f from t1) as t
+where t.f = 'a' or t.f = 'b';
+
+eval $q;
+eval explain format=json $q;
+
+drop table t1;
+
+--echo #
--echo # MDEV-10855: Pushdown into derived with window functions
--echo #
@@ -1834,3 +1851,4 @@ SELECT * FROM v3 JOIN t1 ON (bmax = b);
DROP VIEW v1,v2,v3;
DROP TABLE t1,t2;
+
diff --git a/mysql-test/t/errors.test b/mysql-test/t/errors.test
index 6836fc5803c..73d94d10382 100644
--- a/mysql-test/t/errors.test
+++ b/mysql-test/t/errors.test
@@ -213,3 +213,14 @@ select * from seq_1_to_1000;
--enable_result_log
# We may not be able to execute any more queries with this connection
# because of too little memory#
+
+
+--echo #
+--echo # MDEV-14269 errors.test fails with valgrind (Conditional jump or move depends on uninitialised value)
+--echo #
+
+SET NAMES utf8;
+--error ER_DATA_OUT_OF_RANGE
+SELECT UPDATEXML(-73 * -2465717823867977728,@@global.auto_increment_increment,null);
+--error ER_DATA_OUT_OF_RANGE
+SELECT UPDATEXML(-73 * -2465717823867977728,@@global.long_query_time,null);
diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test
index ebfdced802b..91ee449a7ff 100644
--- a/mysql-test/t/func_misc.test
+++ b/mysql-test/t/func_misc.test
@@ -1104,6 +1104,23 @@ SELECT CONCAT(NAME_CONST('name',15),'오');
SET NAMES latin1;
--echo #
+--echo # MDEV-14116 INET6_NTOA output is set as null to varchar(39) variable
+--echo #
+
+DELIMITER $$;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE ip_full_addr varchar(39) DEFAULT "";
+ SELECT INET6_NTOA(UNHEX('20000000000000000000000000000000')) into ip_full_addr;
+ SELECT ip_full_addr;
+END;
+$$
+DELIMITER ;$$
+CALL p1();
+DROP PROCEDURE p1;
+
+
+--echo #
--echo # Start of 10.2 tests
--echo #
diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test
index 160b347f870..3d8f7dc42b7 100644
--- a/mysql-test/t/having.test
+++ b/mysql-test/t/having.test
@@ -758,3 +758,83 @@ DROP VIEW v1;
DROP TABLE t1;
--echo End of 10.1 tests
+
+--echo #
+--echo # MDEV-14093: GROUP BY with HAVING over function + ORDER BY
+--echo #
+
+CREATE TABLE _authors (
+ id MEDIUMINT(8) UNSIGNED AUTO_INCREMENT,
+ name VARCHAR(100),
+ some_field MEDIUMINT(8) UNSIGNED,
+ PRIMARY KEY (id),
+ index(some_field)
+);
+
+CREATE TABLE _books (
+ id MEDIUMINT(8) UNSIGNED AUTO_INCREMENT,
+ title VARCHAR(100),
+ PRIMARY KEY (id)
+);
+CREATE TABLE _books2authors (
+ author_id MEDIUMINT(8) DEFAULT 0,
+ book_id MEDIUMINT(8) DEFAULT 0,
+ index(author_id),
+ index(book_id)
+);
+
+INSERT INTO _authors (name, some_field) VALUES
+('author1', 1),('author2', 2),('author3', 3);
+
+INSERT INTO _books (title) VALUES
+('book1'),('book2'),('book3');
+
+INSERT INTO _books2authors (author_id, book_id) VALUES
+(2,1),(3,2),(3,3);
+
+SELECT A.id,
+ GROUP_CONCAT(B.title ORDER BY B.title DESC SEPARATOR ',') AS books,
+ some_field-1 AS having_field
+FROM _authors A
+ LEFT JOIN _books2authors B2A FORCE INDEX(author_id)
+ ON B2A.author_id = A.id
+ LEFT JOIN
+ _books B ON B.id = B2A.book_id
+GROUP BY A.id
+HAVING having_field < 1
+ORDER BY having_field ASC;
+
+DROP TABLE _authors, _books, _books2authors;
+
+--echo #
+--echo # Bug#17055185: WRONG RESULTS WHEN RUNNING A SELECT THAT INCLUDE
+--echo # A HAVING BASED ON A FUNCTION.
+--echo #
+
+# Generate series 1, 0, 1, 0....
+CREATE TABLE series (
+ val INT(10) UNSIGNED NOT NULL
+);
+INSERT INTO series VALUES(1);
+
+DELIMITER |;
+CREATE FUNCTION next_seq_value() RETURNS INT
+BEGIN
+ DECLARE next_val INT;
+ SELECT val INTO next_val FROM series;
+ UPDATE series SET val=mod(val + 1, 2);
+ RETURN next_val;
+END;
+|
+DELIMITER ;|
+
+CREATE TABLE t1 (t INT, u INT, KEY(t));
+INSERT INTO t1 VALUES(10, 10), (11, 11), (12, 12), (12, 13),(14, 15), (15, 16),
+ (16, 17), (17, 17);
+ANALYZE TABLE t1;
+SELECT t, next_seq_value() r FROM t1 FORCE INDEX(t)
+ GROUP BY t HAVING r = 1 ORDER BY t1.u;
+
+DROP TABLE t1;
+DROP FUNCTION next_seq_value;
+DROP TABLE series;
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index 262013e0d2c..d84226460f2 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -423,7 +423,7 @@ create table t1 (
SHOW CREATE TABLE t1;
DROP TABLE t1;
-# Test for Bug#93 4.1 protocl crash on corupted frm and SHOW TABLE STATUS
+# Test for Bug#93 4.1 protocol crash on corrupted frm and SHOW TABLE STATUS
flush tables;
@@ -437,7 +437,7 @@ show create table t1;
--disable_warnings
drop table if exists t1;
--enable_warnings
---error 1,0
+--error 0,1
--remove_file $MYSQLD_DATADIR/test/t1.frm
#
diff --git a/mysql-test/t/subselect_exists2in.test b/mysql-test/t/subselect_exists2in.test
index a4fdbe5c50b..5a8ddb3612f 100644
--- a/mysql-test/t/subselect_exists2in.test
+++ b/mysql-test/t/subselect_exists2in.test
@@ -786,6 +786,46 @@ set optimizer_switch= @optimizer_switch_save;
DROP TABLE t1;
+--echo #
+--echo # MDEV-14164: Unknown column error when adding aggregate to function
+--echo # in oracle style procedure FOR loop
+--echo #
+
+CREATE TABLE t1(id INT, val INT);
+DELIMITER //;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE cur1 CURSOR FOR SELECT * FROM (
+ SELECT DISTINCT id FROM t1) a
+ WHERE NOT EXISTS (SELECT * FROM ( SELECT id FROM t1) b
+ WHERE a.id=b.id);
+ OPEN cur1;
+ CLOSE cur1;
+ OPEN cur1;
+ CLOSE cur1;
+END;
+//
+DELIMITER ;//
+CALL p1();
+DROP PROCEDURE p1;
+DROP TABLE t1;
+
+CREATE TABLE t1(id INT, val INT);
+DELIMITER //;
+CREATE PROCEDURE p1()
+BEGIN
+ SELECT * FROM (SELECT DISTINCT id FROM t1) a
+ WHERE NOT a.id IN (SELECT b.id FROM t1 b);
+ SELECT * FROM (SELECT DISTINCT id FROM t1) a
+ WHERE NOT EXISTS (SELECT * FROM t1 b WHERE a.id=b.id);
+END;
+//
+DELIMITER ;//
+CALL p1();
+CALL p1();
+DROP PROCEDURE p1;
+DROP TABLE t1;
+
--echo # End of 10.0 tests
#restore defaults
diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test
index 761f200fe0c..bb282fc15e5 100644
--- a/mysql-test/t/type_bit.test
+++ b/mysql-test/t/type_bit.test
@@ -439,3 +439,22 @@ SELECT SUM(a) FROM t1 GROUP BY c, b, a;
DROP TABLE t1;
--echo End of 5.1 tests
+
+--echo #
+--echo # Start of 10.1 tests
+--echo #
+
+--echo #
+--echo # MDEV-8867 Wrong field type or metadata for COALESCE(bit_column, 1)
+--echo #
+
+CREATE TABLE t1 (val bit(1));
+INSERT INTO t1 VALUES (0);
+CREATE TABLE t2 AS SELECT COALESCE(val, 1) AS c FROM t1;
+SELECT * FROM t2;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+--enable_metadata
+SELECT COALESCE(val, 1) FROM t1;
+--disable_metadata
+DROP TABLE t1;
diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test
index 7c4af618c23..8d29a54a26c 100644
--- a/mysql-test/t/type_date.test
+++ b/mysql-test/t/type_date.test
@@ -582,6 +582,15 @@ SELECT DATE(a), DATE(b), DATE(c) FROM t1;
SELECT DATE(COALESCE(a)), DATE(COALESCE(b)), DATE(COALESCE(c)) FROM t1;
DROP TABLE t1;
+--echo #
+--echo # MDEV-14221 Assertion `0' failed in Item::field_type_for_temporal_comparison
+--echo #
+
+CREATE TABLE t1 (d DATE);
+INSERT INTO t1 VALUES ('1985-05-13'),('1989-12-24');
+SELECT d, COUNT(*) FROM t1 GROUP BY d WITH ROLLUP HAVING CASE d WHEN '2017-05-25' THEN 0 ELSE 1 END;
+DROP TABLE t1;
+
--echo #
--echo # End of 10.1 tests
diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test
index 6662a3d9bb0..5f3f58df166 100644
--- a/mysql-test/t/type_time.test
+++ b/mysql-test/t/type_time.test
@@ -747,6 +747,17 @@ DROP TABLE t1,t2;
--echo #
+--echo # MDEV-10817 CAST(MAX(DATE'2001-01-01') AS TIME) returns a wrong result
+--echo #
+
+SELECT CAST(DATE'2001-01-01' AS TIME);
+SELECT CAST(MAX(DATE'2001-01-01') AS TIME);
+CREATE FUNCTION f1() RETURNS DATE RETURN DATE'2001-01-01';
+SELECT CAST(f1() AS TIME);
+DROP FUNCTION f1;
+
+
+--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index 4850b6c06cb..847fb843ec8 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -1,3 +1,4 @@
+--source include/have_partition.inc
# Save the initial number of concurrent sessions.
--source include/count_sessions.inc