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

The result of executing prepare is wrong #23304

Closed
wan1y opened this issue Mar 15, 2021 · 2 comments · Fixed by #23238
Closed

The result of executing prepare is wrong #23304

wan1y opened this issue Mar 15, 2021 · 2 comments · Fixed by #23238
Labels
severity/critical sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@wan1y
Copy link

wan1y commented Mar 15, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> CREATE TABLE t1(col102 bigint(20),col1 bigint(20) GENERATED ALWAYS AS (col102 ^ 10) STORED NOT NULL,PRIMARY KEY (col1) USING BTREE);
Query OK, 0 rows affected (0.10 sec)

mysql> INSERT INTO `t1` VALUES (11111, DEFAULT);
INSERT INTO `t1` VALUES (22222, DEFAULT);
INSERT INTO `t1` VALUES (33333, DEFAULT);
Query OK, 1 row affected (0.01 sec)

Query OK, 1 row affected (0.10 sec)

Query OK, 1 row affected (0.00 sec)

mysql> select * from t1;
+--------+-------+
| col102 | col1  |
+--------+-------+
|  11111 | 11117 |
|  22222 | 22212 |
|  33333 | 33343 |
+--------+-------+
3 rows in set (0.04 sec)

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

mysql> prepare stmt from 'select col1 from t1 where col1 in (?, ?, ?);';
Query OK, 0 rows affected (0.00 sec)

mysql> set @a=11117, @b=11117, @c=11117;
Query OK, 0 rows affected (0.00 sec)

mysql> execute stmt using@a,@b,@c;
+-------+
| col1  |
+-------+
| 11117 |
+-------+
1 row in set (0.05 sec)

mysql> set @a=11117, @b=22212, @c=33343;
Query OK, 0 rows affected (0.00 sec)

mysql> execute stmt using@a,@b,@c;
+-------+
| col1  |
+-------+
| 11117 |
| 22212 |
| 33343 |
+-------+
3 rows in set (0.04 sec)

3. What did you see instead (Required)

mysql> prepare stmt from 'select col1 from t1 where col1 in (?, ?, ?);';
Query OK, 0 rows affected (0.00 sec)

mysql> set @a=11117, @b=11117, @c=11117;
Query OK, 0 rows affected (0.00 sec)

mysql> execute stmt using@a,@b,@c;
+-------+
| col1  |
+-------+
| 11117 |
+-------+
1 row in set (0.05 sec)

mysql> set @a=11117, @b=22212, @c=33343;
Query OK, 0 rows affected (0.00 sec)

mysql> execute stmt using@a,@b,@c;
+--------+
| col102 |
+--------+
|  11117 |
+--------+
1 row in set (0.05 sec)

4. What is your TiDB version? (Required)

Release Version: v4.0.0-beta.2-2302-gb42a6f449-dirty
Edition: Community
Git Commit Hash: b42a6f449a49e6a68360b607a5de497a2f64faa8
Git Branch: master
UTC Build Time: 2021-03-08 12:03:16
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
@wan1y wan1y added the type/bug The issue is confirmed as a bug. label Mar 15, 2021
@blacktear23
Copy link
Contributor

/pick-up

@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/critical sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
4 participants