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 procedure: temp table created in procedure not visible #8762

Open
zachmu opened this issue Jan 16, 2025 · 1 comment
Open

Stored procedure: temp table created in procedure not visible #8762

zachmu opened this issue Jan 16, 2025 · 1 comment
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

Temporary tables created during stored procedure execution are not visible in the session in later statements.

Repro:

DROP PROCEDURE IF EXISTS CreateTemporaryTable;
DELIMITER //
CREATE PROCEDURE CreateTemporaryTable()
BEGIN
  DROP TEMPORARY TABLE IF EXISTS TEMP_TABLE;
  CREATE TEMPORARY TABLE TEMP_TABLE (NAME TEXT);
  INSERT INTO TEMP_TABLE VALUES ('A'),('B');

  SELECT * FROM TEMP_TABLE;
END //
DELIMITER ;

CALL CreateTemporaryTable();

Related bug: DROP TEMPORARY TABLE does not parse correctly.

@timsehn timsehn added bug Something isn't working correctness We don't return the same result as MySQL labels Jan 22, 2025
@jycor
Copy link
Contributor

jycor commented Jan 23, 2025

Did some digging.

While it is true that both temporary and durable tables are not visible within the procedure body, we don't actually support creating temporary or durable tables within procedures. The insert and select statements just trigger an error before we validate the stored procedure.

I will move some analyzer rules around to return the more appropriate error

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

3 participants