[MDEV-32754] Failure at second executon of PS for query using stored function Created: 2023-11-10  Updated: 2023-11-16  Resolved: 2023-11-15

Status: Closed
Project: MariaDB Server
Component/s: Prepared Statements, Stored routines
Affects Version/s: None
Fix Version/s: 10.4.33

Type: Bug Priority: Critical
Reporter: Igor Babaev Assignee: Dmitry Shulga
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-30073 Wrong result on 2nd execution of PS f... Stalled

 Description   

The following test case fails if the server is built with -DWITH_PROTECT_STATEMENT_MEMROOT:BOOL=ON

CREATE TABLE t1 (a INT,b INT);
INSERT INTO t1 VALUES (10,1),(20,2),(30,3),(40,4);
CREATE VIEW v1 AS
SELECT a,1 as b FROM t1 WHERE a>(SELECT AVG(a) FROM t1 t) AND b>(SELECT 1);
DELIMITER |;
CREATE FUNCTION f1() RETURNS INT
BEGIN
  DECLARE a TYPE OF v1.a DEFAULT 10;
  RETURN a+1;
END;
|
DELIMITER ;|
PREPARE stmt FROM "SELECT f1();";
EXECUTE stmt;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
DROP FUNCTION f1;
DROP VIEW v1;
DROP TABLE t1;



 Comments   
Comment by Igor Babaev [ 2023-11-10 ]

Some observations:
The list of global tables for the SF f1 is empty.
TABLE_LIST structures for v1, t1,t are allocated at each execution of PS. So it's a memory leak.

Comment by Dmitry Shulga [ 2023-11-15 ]

This bug report is duplicate of the task https://jira.mariadb.org/browse/MDEV-32466

Comment by Yuchen Pei [ 2023-11-15 ]

> This bug report is duplicate of the task https://jira.mariadb.org/browse/MDEV-32466

Does this mean MDEV-32466 blocks MDEV-30073?

Comment by Dmitry Shulga [ 2023-11-16 ]

Yes, that is.

Generated at Thu Feb 08 10:33:45 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.