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

Prepared statements can't see temporary tables when the SQL involves multiple tables #29282

Closed
djshow832 opened this issue Oct 31, 2021 · 7 comments · Fixed by #29289
Closed
Assignees
Labels
severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@djshow832
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> create temporary table tmp(id int);
Query OK, 0 rows affected (0.00 sec)

mysql> prepare stmt from 'insert into t select * from tmp';
Query OK, 0 rows affected (0.01 sec)

mysql> execute stmt;
ERROR 1146 (42S02): Table 'tmpdb.tmp' doesn't exist

2. What did you expect to see? (Required)

mysql> create temporary table tmp(id int);
Query OK, 0 rows affected (0.03 sec)

mysql> prepare stmt from 'insert into t select * from tmp';
Query OK, 0 rows affected (0.00 sec)
Statement prepared

mysql> execute stmt;
Query OK, 0 rows affected (0.01 sec)
Records: 0  Duplicates: 0  Warnings: 0

3. What did you see instead (Required)

mysql> execute stmt;
ERROR 1146 (42S02): Table 'tmpdb.tmp' doesn't exist

4. What is your TiDB version? (Required)

master

@JayLZhou
Copy link
Contributor

/assign

@JayLZhou
Copy link
Contributor

its litte difficult for me, but i am trying to solve it.

@lcwangchao
Copy link
Collaborator

I think it is caused by this pr: #26759 . Here(https://github.com/pingcap/tidb/pull/26759/files#diff-0a0c95887230cee4dde6537c6be06ea308529b392c4c3303c242509f53bb8f1aR89-R93) is returning an infoschema without local temporary tables.

@JayLZhou
Copy link
Contributor

JayLZhou commented Nov 1, 2021

I think it is caused by this pr: #26759 . Here(https://github.com/pingcap/tidb/pull/26759/files#diff-0a0c95887230cee4dde6537c6be06ea308529b392c4c3303c242509f53bb8f1aR89-R93) is returning an infoschema without local temporary tables.

yes. so i modify here. but i am not confirm #29289

@aytrack aytrack added the sig/sql-infra SIG: SQL Infra label Nov 1, 2021
@tiancaiamao
Copy link
Contributor

@qw4990 Will prepared plan cache work in this case? and what happens when the temporary table is dropped?

@github-actions
Copy link

github-actions bot commented Nov 1, 2021

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

@tiancaiamao
Copy link
Contributor

@qw4990 Will prepared plan cache work in this case? and what happens when the temporary table is dropped?

OK, I tested, plan cached is not used in this case; drop table and execute stmt reports error table not exist...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
5 participants