Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stored procedures: stored procedure with recursive call does not terminate #8763

Open
zachmu opened this issue Jan 16, 2025 · 1 comment
Open
Labels
bug Something isn't working correctness We don't return the same result as MySQL customer issue

Comments

@zachmu
Copy link
Member

zachmu commented Jan 16, 2025

Repro:

SET max_sp_recursion_depth=255;
DROP TABLE IF EXISTS PEOPLE;
CREATE TABLE PEOPLE (NAME VARCHAR(30));

DROP PROCEDURE IF EXISTS RECURSIVE_PROCEDURE;
DELIMITER //
CREATE PROCEDURE RECURSIVE_PROCEDURE(IN counter INT)
BEGIN

  SET counter := counter + 1;
    IF counter > 3 THEN
      SELECT CONCAT('Ended with value ', counter) AS RESULT;
    ELSE
      CALL RECURSIVE_PROCEDURE(counter);
    END IF;

END //
DELIMITER ;

CALL RECURSIVE_PROCEDURE(1);
@zachmu
Copy link
Member Author

zachmu commented Jan 16, 2025

Another repro with two stored procedures that call eachother, same behavior:

SET max_sp_recursion_depth=255;
DROP TABLE IF EXISTS PEOPLE;
CREATE TABLE PEOPLE (NAME VARCHAR(30));

DROP PROCEDURE IF EXISTS PROC_A;
DELIMITER //
CREATE PROCEDURE PROC_A(IN counter INT)
BEGIN

  SET counter := counter + 1;
    IF counter > 3 THEN
      SELECT CONCAT('Ended in PROC_A with value ', counter) AS RESULT;
    ELSE
      CALL PROC_B(counter);
    END IF;

END //
DELIMITER ;


DROP PROCEDURE IF EXISTS PROC_B;
DELIMITER //
CREATE PROCEDURE PROC_B(IN counter INT)
BEGIN

  SET counter := counter + 1;
    IF counter > 3 THEN
      SELECT CONCAT('Ended in PROC_B with value ', counter) AS RESULT;
    ELSE
      CALL PROC_A(counter);
    END IF;

END //
DELIMITER ;

CALL PROC_A(1);

@timsehn timsehn added bug Something isn't working correctness We don't return the same result as MySQL labels Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctness We don't return the same result as MySQL customer issue
Projects
None yet
Development

No branches or pull requests

2 participants