Details
Description
With WITH_PROTECT_STATEMENT_MEMROOT:BOOL=ON the following leads to "alloc_root: Assertion `(mem_root->flags & 4) == 0' failed" in both 10.5 b304ec30308a86d87f29e509b988d3120b940f58 and 11.6 72ab8bc990c50d3d3bbd0bb71e536e304b567e40.
--source include/have_partition.inc
|
|
# 2nd ps mem leak; partition pruning
|
set @var1=5; |
set @var2=4; |
create table t1 (a int) partition by list(a) ( |
partition p0 values in (null,1,2), |
partition p1 values in (3,4) |
);
|
create table t2 (a int); |
insert into t1 values (1),(2),(3),(4); |
insert into t2 values (4); |
PREPARE stmt FROM 'UPDATE t1 t1 SET a = (SELECT 1 FROM t2 WHERE a = t1.a) where a = ?'; |
/* 1 */ execute stmt using @var1; |
select * from t1; |
/* 2 */ execute stmt using @var2; |
select * from t1; |
deallocate prepare stmt; |
drop table t1, t2; |
Attachments
Issue Links
- relates to
-
MDEV-34447 Memory leakage is detected on running the test main.ps against the server 11.1
-
- Closed
-
-
MDEV-33858 Assertion `(mem_root->flags & 4) == 0' fails on 2nd execution of PS with -DWITH_PROTECT_STATEMENT_MEMROOT=ON
-
- Closed
-
In 11.6 it seems to be the same problem as the 2nd ps issues in
MDEV-25008in case of a impossible where, that is, early return in Sql_cmd_update::update_single_table() causes skipping something that shouldn't be skipped. InMDEV-25008it is JOIN::optimize_inner() for the subqueries, called via optimize_unflattened_subqueries(false). The counterpart in the present issue is st_select_lex::save_leaf_tables() for the outer select, and similar to the solution forMDEV-34447, the following patch fixes the testcase in the description:modified sql/sql_update.cc
@@ -458,6 +458,11 @@ bool Sql_cmd_update::update_single_table(THD *thd)
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (prune_partitions(thd, table, conds))
{
+ if (!thd->lex->current_select->leaf_tables_saved)
+ {
+ thd->lex->current_select->save_leaf_tables(thd);
+ thd->lex->current_select->leaf_tables_saved= true;
+ }
free_underlaid_joins(thd, select_lex);
CC psergei and shulga