summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2018-04-28 14:18:02 +0300
committerSergei Golubchik <serg@mariadb.org>2018-05-12 10:16:46 +0200
commitce2cf855bfc0d9c8adb64f02a7b32ddd81f9948a (patch)
tree2c68efc046ca8a4c2de8f1e10d4b1c09fe8a4cb2
parent8b2fa0ab25976bceb88a949ef1cc2c0b62de3df0 (diff)
downloadmariadb-git-ce2cf855bfc0d9c8adb64f02a7b32ddd81f9948a.tar.gz
MDEV-16043 Assertion thd->Item_change_list::is_empty() failed in mysql_parse upon SELECT from a view reading from a versioned table
Lost restore_active_arena(). Using of Query_arena_stmt is suggested instead.
-rw-r--r--mysql-test/suite/versioning/r/select2.result8
-rw-r--r--mysql-test/suite/versioning/t/select2.test8
-rw-r--r--sql/sql_select.cc8
3 files changed, 21 insertions, 3 deletions
diff --git a/mysql-test/suite/versioning/r/select2.result b/mysql-test/suite/versioning/r/select2.result
index 9267ab8c913..bb5c82ee444 100644
--- a/mysql-test/suite/versioning/r/select2.result
+++ b/mysql-test/suite/versioning/r/select2.result
@@ -332,5 +332,13 @@ select * from (select * from t1 for system_time all, t2 for system_time all) for
ERROR HY000: Table `t` is not system-versioned
select * from (t1 for system_time all join t2 for system_time all) for system_time all;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
+# MDEV-16043 Assertion thd->Item_change_list::is_empty() failed in mysql_parse upon SELECT from a view reading from a versioned table
+create or replace table t1 (a int) with system versioning;
+create or replace view v1 as select * from t1;
+prepare stmt from "select * from t1 where exp( '20010609211642053929' )";
+execute stmt;
+ERROR 22003: DOUBLE value is out of range in 'exp('20010609211642053929')'
+select a from v1;
+a
drop view v1;
drop table t1, t2;
diff --git a/mysql-test/suite/versioning/t/select2.test b/mysql-test/suite/versioning/t/select2.test
index 7caec784e27..d1b73fa799b 100644
--- a/mysql-test/suite/versioning/t/select2.test
+++ b/mysql-test/suite/versioning/t/select2.test
@@ -202,6 +202,14 @@ select * from (select * from t1 for system_time all, t2 for system_time all) for
--error ER_PARSE_ERROR
select * from (t1 for system_time all join t2 for system_time all) for system_time all;
+--echo # MDEV-16043 Assertion thd->Item_change_list::is_empty() failed in mysql_parse upon SELECT from a view reading from a versioned table
+create or replace table t1 (a int) with system versioning;
+create or replace view v1 as select * from t1;
+prepare stmt from "select * from t1 where exp( '20010609211642053929' )";
+--error ER_DATA_OUT_OF_RANGE
+execute stmt;
+select a from v1;
+
drop view v1;
drop table t1, t2;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index f46f96bf47b..7bb019f30ff 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1602,10 +1602,12 @@ JOIN::optimize_inner()
/* Convert all outer joins to inner joins if possible */
conds= simplify_joins(this, join_list, conds, TRUE, FALSE);
- if (thd->is_error())
- DBUG_RETURN(1);
- if (select_lex->save_leaf_tables(thd))
+ if (thd->is_error() || select_lex->save_leaf_tables(thd))
+ {
+ if (arena)
+ thd->restore_active_arena(arena, &backup);
DBUG_RETURN(1);
+ }
build_bitmap_for_nested_joins(join_list, 0);
sel->prep_where= conds ? conds->copy_andor_structure(thd) : 0;