summaryrefslogtreecommitdiff
path: root/mysql-test/t/view.test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/t/view.test')
-rw-r--r--mysql-test/t/view.test44
1 files changed, 44 insertions, 0 deletions
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index ca70cd1efa7..fe04cdfecec 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -4741,6 +4741,50 @@ SHOW CREATE VIEW v4;
DROP VIEW v1, v2, v3, v4, v5;
+
+--echo #
+--echo # BUG#19886430: VIEW CREATION WITH NAMED COLUMNS, OVER UNION,
+--echo # IS REJECTED
+
+--echo # Without the patch, reports an error.
+CREATE VIEW v1 (fld1, fld2) AS
+ SELECT 1 AS a, 2 AS b
+ UNION ALL
+ SELECT 1 AS a, 1 AS a;
+
+--echo # The column names are explicitly specified and not duplicates, hence
+--echo # succeeds.
+CREATE VIEW v2 (fld1, fld2) AS
+ SELECT 1 AS a, 2 AS a
+ UNION ALL
+ SELECT 1 AS a, 1 AS a;
+
+--echo # The column name in the first SELECT are not duplicates, hence succeeds.
+CREATE VIEW v3 AS
+ SELECT 1 AS a, 2 AS b
+ UNION ALL
+ SELECT 1 AS a, 1 AS a;
+
+--echo # Should report an error, since the explicitly specified column names are
+--echo # duplicates.
+--error ER_DUP_FIELDNAME
+CREATE VIEW v4 (fld1, fld1) AS
+ SELECT 1 AS a, 2 AS b
+ UNION ALL
+ SELECT 1 AS a, 1 AS a;
+
+--echo # Should report an error, since duplicate column name is specified in the
+--echo # First SELECT.
+--error ER_DUP_FIELDNAME
+CREATE VIEW v4 AS
+ SELECT 1 AS a, 2 AS a
+ UNION ALL
+ SELECT 1 AS a, 1 AS a;
+
+--echo # Cleanup
+DROP VIEW v1, v2, v3;
+
+
# 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