mirror of
https://github.com/MariaDB/server.git
synced 2025-08-09 22:24:09 +03:00
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.
This commit is contained in:
@@ -567,7 +567,31 @@ insert into t1 (accountId,balance) values
|
||||
update t1 set balance=(select sum(balance) from (SELECT balance FROM t1 where accountId like 'dealer%') AS copied) where accountId = 'OPERATOR';
|
||||
set optimizer_switch=@save_derived_optimizer_switch_bug;
|
||||
drop table t1;
|
||||
set optimizer_switch=@save_derived_optimizer_switch;
|
||||
#
|
||||
# MDEV-6219:Server crashes in Bitmap<64u>::merge
|
||||
# (this=0x180, map2=...) on 2nd execution of PS with INSERT .. SELECT,
|
||||
# derived_merge
|
||||
#
|
||||
CREATE TABLE t1 (a VARCHAR(8)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('foo'),('bar');
|
||||
create procedure p1()
|
||||
INSERT INTO t1 SELECT * FROM (
|
||||
SELECT * FROM t1
|
||||
) AS sq
|
||||
WHERE sq.a IN ( SELECT 'baz' FROM DUAL );
|
||||
call p1();
|
||||
call p1();
|
||||
drop procedure p1;
|
||||
PREPARE stmt FROM "
|
||||
INSERT INTO t1 SELECT * FROM (
|
||||
SELECT * FROM t1
|
||||
) AS sq
|
||||
WHERE sq.a IN ( SELECT 'baz' FROM DUAL )
|
||||
";
|
||||
EXECUTE stmt;
|
||||
EXECUTE stmt;
|
||||
deallocate prepare stmt;
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-6892: WHERE does not apply
|
||||
#
|
||||
@@ -580,3 +604,4 @@ select x.id, message from (select id from t1) x left join
|
||||
where coalesce(message,0) <> 0;
|
||||
id message
|
||||
drop table t1,t2;
|
||||
set optimizer_switch=@save_derived_optimizer_switch;
|
||||
|
@@ -492,7 +492,38 @@ update t1 set balance=(select sum(balance) from (SELECT balance FROM t1 where ac
|
||||
set optimizer_switch=@save_derived_optimizer_switch_bug;
|
||||
drop table t1;
|
||||
|
||||
set optimizer_switch=@save_derived_optimizer_switch;
|
||||
--echo #
|
||||
--echo # MDEV-6219:Server crashes in Bitmap<64u>::merge
|
||||
--echo # (this=0x180, map2=...) on 2nd execution of PS with INSERT .. SELECT,
|
||||
--echo # derived_merge
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a VARCHAR(8)) ENGINE=MyISAM;
|
||||
INSERT INTO t1 VALUES ('foo'),('bar');
|
||||
|
||||
create procedure p1()
|
||||
INSERT INTO t1 SELECT * FROM (
|
||||
SELECT * FROM t1
|
||||
) AS sq
|
||||
WHERE sq.a IN ( SELECT 'baz' FROM DUAL );
|
||||
|
||||
call p1();
|
||||
call p1();
|
||||
drop procedure p1;
|
||||
|
||||
PREPARE stmt FROM "
|
||||
INSERT INTO t1 SELECT * FROM (
|
||||
SELECT * FROM t1
|
||||
) AS sq
|
||||
WHERE sq.a IN ( SELECT 'baz' FROM DUAL )
|
||||
";
|
||||
|
||||
EXECUTE stmt;
|
||||
EXECUTE stmt;
|
||||
|
||||
deallocate prepare stmt;
|
||||
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-6892: WHERE does not apply
|
||||
@@ -506,3 +537,5 @@ select x.id, message from (select id from t1) x left join
|
||||
(select id, 1 as message from t2) y on x.id=y.id
|
||||
where coalesce(message,0) <> 0;
|
||||
drop table t1,t2;
|
||||
|
||||
set optimizer_switch=@save_derived_optimizer_switch;
|
||||
|
@@ -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()))
|
||||
{
|
||||
|
@@ -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())
|
||||
|
Reference in New Issue
Block a user