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

wrong result for query containing subquery when plan cache is enabled #8062

Closed
eurekaka opened this issue Oct 25, 2018 · 0 comments
Closed
Assignees
Labels
sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@eurekaka
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
  • start tidb-server with plan cache enabled;
  • create session 1, and execute:
mysql> create table t(a int, b int);
Query OK, 0 rows affected (0.05 sec)

mysql> prepare stmt from 'select * from t where a = (select a from t where a = ?)';
Query OK, 0 rows affected (0.01 sec)

mysql> set @param = 1;
Query OK, 0 rows affected (0.00 sec)

mysql> execute stmt using @param;
Empty set (0.00 sec)
  • keep session 1 connected, create session 2, and execute:
mysql> insert into t values(1,1);
Query OK, 1 row affected (0.00 sec)
  • back to session 1:
mysql> select * from t;
+------+------+
| a    | b    |
+------+------+
|    1 |    1 |
+------+------+
1 row in set (0.00 sec)

mysql> execute stmt using @param;
Empty set (0.00 sec)

mysql> select * from t where a = (select a from t where a = 1);
+------+------+
| a    | b    |
+------+------+
|    1 |    1 |
+------+------+
1 row in set (0.00 sec)
  1. What did you expect to see?

second execute stmt using @param; in session 1 should return one row.

  1. What did you see instead?

second execute stmt using @param; in session 1 returns empty result.

  1. What version of TiDB are you using (tidb-server -V or run select tidb_version(); on TiDB)?
mysql> select tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                                 |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: None
Git Commit Hash: a4cff40a18da37b146ad763a8f7cd6756fdf569d
Git Branch: master
UTC Build Time: 2018-10-24 06:46:18
GoVersion: go version go1.11rc1 linux/amd64
Race Enabled: false
TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
Check Table Before Drop: false |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
@eurekaka eurekaka added type/bug The issue is confirmed as a bug. sig/planner SIG: Planner labels Oct 25, 2018
@eurekaka eurekaka self-assigned this Oct 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

1 participant