mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
5e6c122427
A memory leak happens on the second execution of a query that run in PS mode and uses the function ROWNUM(). A memory leak took place on allocation of an instance of the class Item_int for storing a limit value that is performed at the function set_limit_for_unit indirectly called from JOIN::optimize_inner. Typical trace to the place where the memory leak occurred is below: JOIN::optimize_inner optimize_rownum process_direct_rownum_comparison set_limit_for_unit new (thd->mem_root) Item_int(thd, lim, MAX_BIGINT_WIDTH); To fix this memory leak, calling of the function optimize_rownum() has to be performed only once on first execution and never called after that. To control it, the new data member first_rownum_optimization added into the structure st_select_lex.
120 lines
2.8 KiB
Text
120 lines
2.8 KiB
Text
#
|
|
# MDEV-32369: Memory leak when executing PS for query with IN subquery
|
|
#
|
|
CREATE TABLE t1 (a VARCHAR(10)) ENGINE=MYISAM;
|
|
CREATE TABLE t2 (b VARCHAR(10) CHARACTER SET utf8) ENGINE=MYISAM;
|
|
INSERT INTO t1 VALUES ('b'), ('a'), ('c');
|
|
INSERT INTO t2 VALUES ('c'), ('d'), ('b');
|
|
PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
|
|
EXECUTE stmt;
|
|
a
|
|
c
|
|
b
|
|
EXECUTE stmt;
|
|
a
|
|
c
|
|
b
|
|
DEALLOCATE PREPARE stmt;
|
|
DELETE FROM t1;
|
|
DELETE FROM t2;
|
|
INSERT INTO t1 VALUES ('b');
|
|
INSERT INTO t2 VALUES ('b');
|
|
PREPARE stmt FROM "SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
|
|
EXECUTE stmt;
|
|
a
|
|
b
|
|
EXECUTE stmt;
|
|
a
|
|
b
|
|
DEALLOCATE PREPARE stmt;
|
|
DROP TABLE t1, t2;
|
|
#
|
|
# MDEV-32569: Failure when executing PS for query using IN subquery
|
|
#
|
|
CREATE TABLE t1 (a varchar(10)) ENGINE=MYISAM;
|
|
CREATE TABLE t2 (b varchar(10) CHARACTER SET utf8) ENGINE=MYISAM;
|
|
INSERT INTO t1 VALUES ('b');
|
|
INSERT INTO t2 VALUES ('b');
|
|
PREPARE stmt FROM
|
|
"SELECT STRAIGHT_JOIN t1.a FROM t1 WHERE t1.a IN (SELECT t2.b FROM t2)";
|
|
EXECUTE stmt;
|
|
a
|
|
b
|
|
EXECUTE stmt;
|
|
a
|
|
b
|
|
DEALLOCATE PREPARE stmt;
|
|
DROP TABLE t1,t2;
|
|
#
|
|
# MDEV-32733: Two JSON related tests running in PS mode fail on server
|
|
# built with -DWITH_PROTECT_STATEMENT_MEMROOT=YES
|
|
#
|
|
PREPARE stmt FROM "select json_contains_path('{\"key1\":1}', 'oNE', '$.key2[1]') as exp";
|
|
EXECUTE stmt;
|
|
exp
|
|
0
|
|
EXECUTE stmt;
|
|
exp
|
|
0
|
|
DEALLOCATE PREPARE stmt;
|
|
#
|
|
# MDEV-32466: Potential memory leak on execuing of create view statement
|
|
#
|
|
CREATE FUNCTION f1 () RETURNS VARCHAR(1)
|
|
BEGIN
|
|
DECLARE rec1 ROW TYPE OF v1;
|
|
SELECT z INTO rec1 FROM v1;
|
|
RETURN 1;
|
|
END|
|
|
CREATE FUNCTION f2 () RETURNS VARCHAR(1) RETURN '!';
|
|
CREATE VIEW v1 AS SELECT f2() z;
|
|
PREPARE stmt FROM "SELECT f1()";
|
|
EXECUTE stmt;
|
|
f1()
|
|
1
|
|
EXECUTE stmt;
|
|
f1()
|
|
1
|
|
DEALLOCATE PREPARE stmt;
|
|
DROP FUNCTION f1;
|
|
DROP VIEW v1;
|
|
DROP FUNCTION f2;
|
|
#
|
|
# MDEV-32867: ASAN errors in Item_func_json_contains_path::val_int upon PS execution
|
|
#
|
|
CREATE TABLE t1 (f BLOB) ENGINE=MyISAM;
|
|
PREPARE stmt FROM "SELECT * FROM t1 WHERE JSON_EXISTS(JSON_ARRAY('[true,1234567890]'), '$**.*') != JSON_CONTAINS_PATH(JSON_INSERT('{}', '$[1]', NULL), 'all', '$[1]')";
|
|
EXECUTE stmt;
|
|
f
|
|
DEALLOCATE PREPARE stmt;
|
|
DROP TABLE t1;
|
|
# End of 10.4 tests
|
|
#
|
|
# 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
|
|
#
|
|
CREATE OR REPLACE TABLE t1(a INT);
|
|
PREPARE stmt FROM 'SELECT 1 FROM t1 WHERE ROWNUM() < 2';
|
|
EXECUTE stmt;
|
|
1
|
|
EXECUTE stmt;
|
|
1
|
|
INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
|
|
PREPARE stmt FROM 'SELECT * FROM t1 WHERE ROWNUM() < ?';
|
|
# Expected output is two rows (1), (2)
|
|
EXECUTE stmt USING 3;
|
|
a
|
|
1
|
|
2
|
|
# Expected output is one row (1)
|
|
EXECUTE stmt USING 2;
|
|
a
|
|
1
|
|
# Expected output is three rows (1), (2), (3)
|
|
EXECUTE stmt USING 4;
|
|
a
|
|
1
|
|
2
|
|
# Clean up
|
|
DEALLOCATE PREPARE stmt;
|
|
DROP TABLE t1;
|
|
# End of 10.6 tests
|