summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorAleksey Midenkov <midenok@gmail.com>2019-12-05 23:45:57 +0300
committerAleksey Midenkov <midenok@gmail.com>2019-12-05 23:53:07 +0300
commitbe92dce61353952da593b32f3f52b81b89ee7219 (patch)
tree8457dde0f503e2bf2eb64d5154fddf34c5be4d24 /sql/sql_select.cc
parent1fbd9bb2c5d134209ac2aae073f7a78797c1c04e (diff)
downloadmariadb-git-be92dce61353952da593b32f3f52b81b89ee7219.tar.gz
MDEV-21234 Server crashes in in setup_on_expr upon 3rd execution of SP
Versioned conditions in on_expr can not be rebuilt at optimization stage on non-conventional arena.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 4c83c1d84e5..275c46141cd 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1713,7 +1713,20 @@ JOIN::optimize_inner()
}
}
- conds= optimize_cond(this, conds, join_list, FALSE,
+ bool ignore_on_expr= false;
+ /*
+ PS/SP note: on_expr of versioned table can not be reallocated
+ (see build_equal_items() below) because it can be not rebuilt
+ at second invocation.
+ */
+ if (!thd->stmt_arena->is_conventional() && thd->mem_root != thd->stmt_arena->mem_root)
+ for (TABLE_LIST *tbl= tables_list; tbl; tbl= tbl->next_local)
+ if (tbl->table && tbl->on_expr && tbl->table->versioned())
+ {
+ ignore_on_expr= true;
+ break;
+ }
+ conds= optimize_cond(this, conds, join_list, ignore_on_expr,
&cond_value, &cond_equal, OPT_LINK_EQUAL_FIELDS);
if (thd->is_error())