Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDEV-16043 Assertion `thd->Item_change_list::is_empty()' failed in mysql_parse upon SELECT from a view reading from a versioned table #489

Closed
midenok opened this issue Apr 28, 2018 · 3 comments
Assignees
Labels

Comments

@midenok
Copy link

midenok commented Apr 28, 2018

Reproduce

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;
select a from v1;

Result

#3  0x00007ffff5d9bfc2 in __GI___assert_fail (assertion=0x14ce8c2 "thd->Item_change_list::is_empty()", file=0x14e2e6e "/home/midenok/src/mariadb/trunk/src/sql/sql_parse.cc", line=8025, function=0x14e3d80 "void mysql_parse(THD *, char *, uint, Parser_state *, bool, bool)") at assert.c:101
#4  0x00000000007ab367 in mysql_parse (thd=0x7fff78000d50, rawbuf=0x7fff7803ade8 "select a from v1", length=16, parser_state=0x7fffe5116640, is_com_multi=false, is_next_command=false) at /home/midenok/src/mariadb/trunk/src/sql/sql_parse.cc:8025
8023        thd->end_statement();
8024        thd->cleanup_after_query();
8025        DBUG_ASSERT(thd->Item_change_list::is_empty());
@midenok midenok self-assigned this Apr 28, 2018
@midenok midenok added this to the 1.1: First priority tasks after merge milestone Apr 28, 2018
@midenok midenok added the bug label Apr 28, 2018
@midenok
Copy link
Author

midenok commented Apr 28, 2018

Bad commit

commit 9477a2a9ba17c0db362e2bb39d5048e369096f39 (HEAD)
Merge: e3fb8e95692 f033fbd9f23
Author: Marko Mäkelä <marko.makela@mariadb.com>
Date:   Wed Apr 25 07:58:46 2018 +0300

    Merge 10.2 into 10.3
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1605,6 +1605,8 @@ 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))
       DBUG_RETURN(1);
     build_bitmap_for_nested_joins(join_list, 0);

Fix

--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1605,10 +1605,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;

@midenok
Copy link
Author

midenok commented Apr 28, 2018

MDEV-16042 Server crash or ASAN use-after-poison in Query_arena::free_items after executing a failing PS which reads from versioned table

Reproduce

CREATE TABLE t1 (a INT) WITH SYSTEM VERSIONING;
PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE EXP(20010609211642053929)";
--error ER_DATA_OUT_OF_RANGE
EXECUTE stmt;
--connection default
DROP TABLE t1;

Fix

Same as above.

@midenok
Copy link
Author

midenok commented Apr 28, 2018

Closed by 71e7d68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant