summaryrefslogtreecommitdiff
path: root/mysql-test/t/sp.test
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-12-07 15:54:27 +0400
committerAlexander Barkov <bar@mariadb.org>2017-12-07 15:54:27 +0400
commit08dae447118b49b99499ccc456c9a72afa651f24 (patch)
treef77698fa7b5a4978f0efbe98a28667771a5d4d99 /mysql-test/t/sp.test
parent6d4b0958dc5a6a2d44dcccf083ec9e136bb4a38e (diff)
downloadmariadb-git-08dae447118b49b99499ccc456c9a72afa651f24.tar.gz
MDEV-14228 MariaDB crashes with function
Diffstat (limited to 'mysql-test/t/sp.test')
-rw-r--r--mysql-test/t/sp.test80
1 files changed, 80 insertions, 0 deletions
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 08aa70df03e..82ad655593a 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -9771,3 +9771,83 @@ $$
DELIMITER ;$$
CALL p1();
DROP PROCEDURE p1;
+
+
+--echo #
+--echo # MDEV-14228 MariaDB crashes with function
+--echo #
+
+CREATE TABLE t1 (c VARCHAR(16), KEY(c));
+INSERT INTO t1 VALUES ('foo');
+
+DELIMITER $$;
+CREATE FUNCTION f1() RETURNS VARCHAR(16)
+BEGIN
+ DECLARE v VARCHAR(16);
+ FOR v IN (SELECT DISTINCT c FROM t1)
+ DO
+ IF (v = 'bar') THEN
+ SELECT 1 INTO @a;
+ END IF;
+ END FOR;
+ RETURN 'qux';
+END $$
+DELIMITER ;$$
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT f1();
+DROP FUNCTION f1;
+
+DELIMITER $$;
+CREATE FUNCTION f1() RETURNS VARCHAR(16)
+BEGIN
+ DECLARE v ROW TYPE OF t1;
+ IF v = 'bar' THEN
+ RETURN 'eq';
+ END IF;
+ RETURN 'ne';
+END $$
+DELIMITER ;$$
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT f1();
+DROP FUNCTION f1;
+
+DELIMITER $$;
+CREATE FUNCTION f1() RETURNS VARCHAR(16)
+BEGIN
+ DECLARE v ROW(a INT);
+ IF v = 'bar' THEN
+ RETURN 'eq';
+ END IF;
+ RETURN 'ne';
+END $$
+DELIMITER ;$$
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+SELECT f1();
+DROP FUNCTION f1;
+
+DROP TABLE t1;
+
+
+DELIMITER $$;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+BEGIN NOT ATOMIC
+ DECLARE v ROW(a INT);
+ SELECT v IN ('a','b');
+END $$
+DELIMITER ;$$
+
+DELIMITER $$;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+BEGIN NOT ATOMIC
+DECLARE v ROW(a INT);
+ SELECT 'a' IN (v,'b');
+END $$
+DELIMITER ;$$
+
+DELIMITER $$;
+--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
+BEGIN NOT ATOMIC
+ DECLARE v ROW(a INT);
+ SELECT 'a' IN ('b',v);
+END $$
+DELIMITER ;$$