diff options
Diffstat (limited to 'mysql-test/t/view.test')
-rw-r--r-- | mysql-test/t/view.test | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index d1d4b936aba..6029ad471f6 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -4700,6 +4700,47 @@ DROP DATABASE IF EXISTS nodb; --error ER_BAD_DB_ERROR CREATE VIEW nodb.a AS SELECT 1; + +--echo # +--echo # BUG#14117018 - MYSQL SERVER CREATES INVALID VIEW DEFINITION +--echo # BUG#18405221 - SHOW CREATE VIEW OUTPUT INCORRECT +--echo # + +CREATE VIEW v1 AS (SELECT '' FROM DUAL); +CREATE VIEW v2 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL + (SELECT '' FROM DUAL); +CREATE VIEW v3 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL + (SELECT '' FROM DUAL) UNION ALL + (SELECT '' FROM DUAL); +CREATE VIEW v4 AS (SELECT 'BUG#14117018' AS col1 FROM DUAL) UNION ALL + (SELECT '' AS col2 FROM DUAL) UNION ALL + (SELECT '' FROM DUAL); + +# In the second (and later) UNIONed queries, duplicate column names are allowed +CREATE VIEW v5 AS (SELECT 'buggy' AS col1, 'fix' as col2 FROM DUAL) UNION ALL + (SELECT 'buggy' as a, 'fix' as a FROM DUAL); + +--echo # Name for the column in select1 is set properly with or +--echo # without this fix. +SHOW CREATE VIEW v1; + +--echo # Name for the column in select2 is set with this fix. +--echo # Without this fix, name would not have set for the +--echo # columns in select2. +SHOW CREATE VIEW v2; + +--echo # Name for the field item in select2 & select3 is set with this fix. +--echo # Without this fix, name would not have set for the +--echo # columns in select2 & select3. +SHOW CREATE VIEW v3; + +--echo # Name for the field item in select3 is set with this fix. +--echo # Without this fix, name would not have set for the +--echo # columns in select3. +SHOW CREATE VIEW v4; + +DROP VIEW v1, v2, v3, v4, v5; + # Check that all connections opened by test cases in this file are really # gone so execution of other tests won't be affected by their presence. --source include/wait_until_count_sessions.inc @@ -5231,6 +5272,69 @@ drop view v1; drop table t1,t2,t3; SET optimizer_switch=@save_optimizer_switch_MDEV_3874; +# +# MDEV-5515: sub-bug test of 3rd execution crash +# + +CREATE TABLE `t1` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `f0` int(11) unsigned NOT NULL DEFAULT '0', + `f1` int(11) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`) +); + +CREATE TABLE `t2` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `f02` bigint(20) unsigned NOT NULL DEFAULT '0', + `f03` int(11) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`) +); + +CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `v1` AS + SELECT + `t1`.`f0` AS `f0`, + `t1`.`f1` AS `f1`, + `t2`.`f02` AS `f02`, + `t2`.`f03` AS `f03` + FROM + (`t1` LEFT JOIN `t2` ON((`t1`.`id` = `t2`.`f02`))); + +--delimiter | +CREATE FUNCTION `f1`( + p0 BIGINT(20) UNSIGNED + ) + RETURNS bigint(20) unsigned + DETERMINISTIC + CONTAINS SQL + SQL SECURITY DEFINER + COMMENT '' +BEGIN + +DECLARE k0 INTEGER UNSIGNED DEFAULT 0; +DECLARE lResult INTEGER UNSIGNED DEFAULT 0; + + SET k0 = 0; + WHILE k0 < 1 DO + SELECT COUNT(*) as `f00` INTO lResult FROM `v1` WHERE `v1`.`f0` = p0; -- BUG + SET k0 = k0 + 1; + END WHILE; + + RETURN(k0); +END| +--delimiter ; + + +SELECT `f1`(1); +SELECT `f1`(1); +SELECT `f1`(1); +SELECT `f1`(1); + +DROP FUNCTION f1; +DROP VIEW v1; +DROP TABLE t1, t2; + --echo # ----------------------------------------------------------------- --echo # -- End of 5.5 tests. --echo # ----------------------------------------------------------------- |