# The cmake option -DWITH_PROTECT_STATEMENT_MEMROOT is used only
# The cmake option -DWITH_PROTECT_STATEMENT_MEMROOT is used only
# for debug build
# for debug build
--sourceinclude/have_debug.inc
--sourceinclude/have_debug.inc
--sourceinclude/have_partition.inc
--echo#
--echo#
--echo# MDEV-32369: Memory leak when executing PS for query with IN subquery
--echo# MDEV-32369: Memory leak when executing PS for query with IN subquery
...
@@ -111,6 +112,219 @@ DROP TABLE t1;
...
@@ -111,6 +112,219 @@ DROP TABLE t1;
--echo# End of 10.4 tests
--echo# End of 10.4 tests
--echo#
--echo# MDEV-34447: Memory leakage is detected on running the test main.ps against the server 11.1
--echo#
CREATETABLEt1(idINT,valueINT);
CREATETABLEt2(idINT);
PREPAREstmtFROM'UPDATE t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id)';
EXECUTEstmt;
INSERTINTOt1VALUES(1,10),(2,10),(3,10);
INSERTINTOt2VALUES(1),(2);
EXECUTEstmt;
SELECT*FROMt1;
DEALLOCATEPREPAREstmt;
DROPTABLEt1,t2;
--echo# Memory leak also could take place on running the DELETE statement
--echo# with the LIMIT clause. Check it.
CREATETABLEt1(c1INT);
INSERTINTOt1(c1)VALUES(1),(2),(3);
CREATEPROCEDUREp1(p1INT)
DELETEFROMt1LIMITp1;
CALLp1(0);
CALLp1(1);
CALLp1(2);
--echo# Clean up
DROPTABLEt1;
DROPPROCEDUREp1;
--echo#
--echo# MDEV-34757: assertion of (mem_root->flags & 4) == 0 fails in 2nd ps execution with partition pruning
--echo#
# same as the first MDEV-34444 testcase but with explain
CREATETABLEt1(idINT,valueINT);
CREATETABLEt2(idINT);
PREPAREstmtFROM'EXPLAIN UPDATE t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id)';
# we are testing 2nd ps assertion failure, not explain output, which
# may vary from version to version
--disable_result_log
EXECUTEstmt;
--enable_result_log
INSERTINTOt1VALUES(1,10),(2,10),(3,10);
INSERTINTOt2VALUES(1),(2);
--disable_result_log
EXECUTEstmt;
--enable_result_log
SELECT*FROMt1;
DEALLOCATEPREPAREstmt;
DROPTABLEt1,t2;
# 2nd ps mem leak; partition pruning
set@var1=5;
set@var2=4;
createtablet1(aint)partitionbylist(a)(
partitionp0valuesin(null,1,2),
partitionp1valuesin(3,4)
);
createtablet2(aint);
insertintot1values(1),(2),(3),(4);
insertintot2values(4);
PREPAREstmtFROM'UPDATE t1 t1 SET a = (SELECT 1 FROM t2 WHERE a = t1.a) where a = ?';
executestmtusing@var1;
select*fromt1;
executestmtusing@var2;
select*fromt1;
deallocatepreparestmt;
droptablet1,t2;
# same but with explain
set@var1=5;
set@var2=4;
createtablet1(aint)partitionbylist(a)(
partitionp0valuesin(null,1,2),
partitionp1valuesin(3,4)
);
createtablet2(aint);
insertintot1values(1),(2),(3),(4);
insertintot2values(4);
PREPAREstmtFROM'EXPLAIN UPDATE t1 t1 SET a = (SELECT 1 FROM t2 WHERE a = t1.a) where a = ?';
executestmtusing@var1;
select*fromt1;
executestmtusing@var2;
select*fromt1;
deallocatepreparestmt;
droptablet1,t2;
# top level impossible where
set@var1=1;
set@var2=2;
CREATETABLEt1(idINT(10),valueINT(10));
CREATETABLEt2(idINT(10));
insertintot1values(1,10),(2,10),(3,10);
insertintot2values(1),(2);
PREPAREstmtFROM'UPDATE t1 t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id) WHERE ?=?';
executestmtusing@var1,@var2;
executestmtusing@var1,@var1;
deallocatepreparestmt;
DROPTABLEt1,t2;
# top level impossible where, with explain
set@var1=1;
set@var2=2;
CREATETABLEt1(idINT(10),valueINT(10));
CREATETABLEt2(idINT(10));
insertintot1values(1,10),(2,10),(3,10);
insertintot2values(1),(2);
PREPAREstmtFROM'EXPLAIN UPDATE t1 t1 SET value = (SELECT 1 FROM t2 WHERE id = t1.id) WHERE ?=?';
executestmtusing@var1,@var2;
executestmtusing@var1,@var1;
deallocatepreparestmt;
DROPTABLEt1,t2;
# Now we do delete instead of update
# same as the second MDEV-34447 testcase but with explain
CREATETABLEt1(c1INT);
INSERTINTOt1(c1)VALUES(1),(2),(3);
CREATEPROCEDUREp1(p1INT)
EXPLAINDELETEFROMt1LIMITp1;
CALLp1(0);
CALLp1(1);
CALLp1(2);
--echo# Clean up
DROPTABLEt1;
DROPPROCEDUREp1;
# partition pruning
set@var1=5;
set@var2=4;
createtablet1(aint)partitionbylist(a)(
partitionp0valuesin(1,2),
partitionp1valuesin(3,4)
);
createtablet2(aint);
insertintot1values(1),(2),(3),(4);
insertintot2values(4);
PREPAREstmtFROM'DELETE FROM t1 where a = ?';
executestmtusing@var1;
select*fromt1;
executestmtusing@var2;
select*fromt1;
deallocatepreparestmt;
droptablet1,t2;
# same but with explain
set@var1=5;
set@var2=4;
createtablet1(aint)partitionbylist(a)(
partitionp0valuesin(1,2),
partitionp1valuesin(3,4)
);
createtablet2(aint);
insertintot1values(1),(2),(3),(4);
insertintot2values(4);
PREPAREstmtFROM'EXPLAIN DELETE FROM t1 where a = ?';
executestmtusing@var1;
select*fromt1;
executestmtusing@var2;
select*fromt1;
deallocatepreparestmt;
droptablet1,t2;
# top level impossible where
set@var1=1;
set@var2=2;
CREATETABLEt1(idINT(10),valueINT(10));
CREATETABLEt2(idINT(10));
insertintot1values(1,10),(2,10),(3,10);
insertintot2values(1),(2);
PREPAREstmtFROM'DELETE FROM t1 WHERE ?=?';
executestmtusing@var1,@var2;
executestmtusing@var1,@var1;
deallocatepreparestmt;
DROPTABLEt1,t2;
# top level impossible where, with explain
set@var1=1;
set@var2=2;
CREATETABLEt1(idINT(10),valueINT(10));
CREATETABLEt2(idINT(10));
insertintot1values(1,10),(2,10),(3,10);
insertintot2values(1),(2);
PREPAREstmtFROM'EXPLAIN DELETE FROM t1 WHERE ?=?';
executestmtusing@var1,@var2;
executestmtusing@var1,@var1;
deallocatepreparestmt;
DROPTABLEt1,t2;
--echo#
--echo# MDEV-33858: Assertion `(mem_root->flags & 4) == 0' fails on 2nd execution of PS with -DWITH_PROTECT_STATEMENT_MEMROOT=ON
--echo#
CREATETABLEt(aINT);
INSERTINTOtVALUES(1),(2);# Optional, fails either way
PREPAREstmtFROM"UPDATE t SET a = 0 LIMIT ?";
EXECUTEstmtUSING0;
EXECUTEstmtUSING1;
# CLeanup
DROPTABLEt;
--echo# End of 10.5 tests
--echo#
--echo#
--echo# MDEV-33769: Memory leak found in the test main.rownum run with --ps-protocol against a server built with the option -DWITH_PROTECT_STATEMENT_MEMROOT
--echo# MDEV-33769: Memory leak found in the test main.rownum run with --ps-protocol against a server built with the option -DWITH_PROTECT_STATEMENT_MEMROOT