summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2017-04-04 11:00:25 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2017-04-07 13:22:21 +0200
commit2d670d26dea98b35dddb6690de31b98080a3e424 (patch)
tree819f9967f6f950843ea7191d0173b4810116dd68
parent85da56bf2dc983b346089f463f2cce1552b0d3bf (diff)
downloadmariadb-git-bb-10.2-MDEV-12379.tar.gz
MDEV-12379: Server crashes in TABLE_LIST::is_with_table on SHOW CREATE VIEWbb-10.2-MDEV-12379
In case of error on opening VIEW (absent table for example) it is still possible to print its definition but some variable is not set (table_list->derived->derived) so it is better do not try to test it when there is safer alternative (table_list itself).
-rw-r--r--mysql-test/r/view.result13
-rw-r--r--mysql-test/t/view.test12
-rw-r--r--sql/sql_select.cc2
3 files changed, 26 insertions, 1 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 4119c11c67b..bd0ebb54ee7 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -6466,5 +6466,18 @@ ERROR HY000: Can not modify more than one base table through a join view 'test.v
drop view v;
drop table t1,t2,t3;
#
+# MDEV-12379: Server crashes in TABLE_LIST::is_with_table on
+# SHOW CREATE VIEW
+#
+CREATE TABLE t (i INT);
+CREATE VIEW v AS SELECT * FROM ( SELECT * FROM t ) sq;
+DROP TABLE IF EXISTS t;
+SHOW CREATE VIEW v;
+View Create View character_set_client collation_connection
+v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `sq`.`i` AS `i` from (select `test`.`t`.`i` AS `i` from `test`.`t`) `sq` latin1 latin1_swedish_ci
+Warnings:
+Warning 1356 View 'test.v' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
+DROP VIEW v;
+#
# End of 10.2 tests
#
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index cb658b5146f..bab640e1371 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -6186,6 +6186,18 @@ REPLACE INTO v (f1,f2) VALUES (1,1);
drop view v;
drop table t1,t2,t3;
+
+--echo #
+--echo # MDEV-12379: Server crashes in TABLE_LIST::is_with_table on
+--echo # SHOW CREATE VIEW
+--echo #
+
+CREATE TABLE t (i INT);
+CREATE VIEW v AS SELECT * FROM ( SELECT * FROM t ) sq;
+DROP TABLE IF EXISTS t;
+SHOW CREATE VIEW v;
+DROP VIEW v;
+
--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 6e355ef58f5..ecbac041dc4 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -25077,7 +25077,7 @@ void TABLE_LIST::print(THD *thd, table_map eliminated_tables, String *str,
}
else if (derived)
{
- if (!derived->derived->is_with_table())
+ if (!is_with_table())
{
// A derived table
str->append('(');