summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2015-08-31 18:40:24 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2015-08-31 18:40:24 +0200
commit4b41e3c7f33714186c97a6cc2e6d3bb93b050c61 (patch)
treefdc312b7d2f3ed8f12af293f8f724c5148d91227 /sql
parentb66455f67da9b0bbe7fb7862c23a8283d766e149 (diff)
downloadmariadb-git-4b41e3c7f33714186c97a6cc2e6d3bb93b050c61.tar.gz
MDEV-6219: Server crashes in Bitmap<64u>::merge (this=0x180, map2=...) on 2nd execution of PS with INSERT .. SELECT, derived_merge
Problem: Not all permanent Item_direct_view_ref was in permanent list of used items of the view. Solution: Detect creating permenent view/derived table reference and put them in the permanent list at once.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_base.cc13
-rw-r--r--sql/table.cc7
2 files changed, 7 insertions, 13 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 12cd999d130..7e2fe7b1b63 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -7380,14 +7380,6 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
*/
result= FALSE;
- /*
- Save the lists made during natural join matching (because
- the matching done only once but we need the list in case
- of prepared statements).
- */
- table_ref_1->persistent_used_items= table_ref_1->used_items;
- table_ref_2->persistent_used_items= table_ref_2->used_items;
-
err:
if (arena)
thd->restore_active_arena(arena, &backup);
@@ -8434,11 +8426,6 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
}
}
#endif
- /*
- field_iterator.create_item() builds used_items which we
- have to save because changes made once and they are persistent
- */
- tables->persistent_used_items= tables->used_items;
if ((field= field_iterator.field()))
{
diff --git a/sql/table.cc b/sql/table.cc
index cdc7b4381cd..da6c4ccf42f 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -5335,6 +5335,12 @@ Item *create_view_field(THD *thd, TABLE_LIST *view, Item **field_ref,
item->maybe_null= TRUE;
/* Save item in case we will need to fall back to materialization. */
view->used_items.push_front(item);
+ /*
+ If we create this reference on persistent memory then it should be
+ present in persistent list
+ */
+ if (thd->mem_root == thd->stmt_arena->mem_root)
+ view->persistent_used_items.push_front(item);
DBUG_RETURN(item);
}
@@ -6912,6 +6918,7 @@ bool TABLE_LIST::handle_derived(LEX *lex, uint phases)
{
SELECT_LEX_UNIT *unit;
DBUG_ENTER("handle_derived");
+ DBUG_PRINT("enter", ("phases: 0x%x", phases));
if ((unit= get_unit()))
{
for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select())