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

prepare/execute return a wrong result after changing parameter's type #28858

Closed
qw4990 opened this issue Oct 15, 2021 · 1 comment · Fixed by #28944
Closed

prepare/execute return a wrong result after changing parameter's type #28858

qw4990 opened this issue Oct 15, 2021 · 1 comment · Fixed by #28944
Assignees
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. epic/plan-cache severity/critical sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@qw4990
Copy link
Contributor

qw4990 commented Oct 15, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE t (
  id bigint(20) NOT NULL,
  audit_id bigint(20) NOT NULL,
  PRIMARY KEY (id) /*T![clustered_index] CLUSTERED */,
  KEY index_audit_id (audit_id)
);

insert into t values(1,9941971237863475);
insert into t values(2,9941971237863476);

prepare stmt from 'select * from t where audit_id=?';
set @a='9941971237863475';
execute stmt using @a;
set @a=9941971237863475;
execute stmt using @a;

select * from t where audit_id='9941971237863475';
select * from t where audit_id=9941971237863475;

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

All execute and select statement should return the same result.

3. What did you see instead (Required)

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

mysql> set @a='9941971237863475';
Query OK, 0 rows affected (0.00 sec)

mysql> execute stmt using @a;
+----+------------------+
| id | audit_id         |
+----+------------------+
|  1 | 9941971237863475 |
|  2 | 9941971237863476 |
+----+------------------+
2 rows in set (0.00 sec)

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

mysql> execute stmt using @a;
+----+------------------+
| id | audit_id         |
+----+------------------+
|  1 | 9941971237863475 |
+----+------------------+
1 row in set (0.00 sec)

mysql> 
mysql> 
mysql> select * from t where audit_id='9941971237863475';
+----+------------------+
| id | audit_id         |
+----+------------------+
|  1 | 9941971237863475 |
+----+------------------+
1 row in set (0.01 sec)

mysql> select * from t where audit_id=9941971237863475;
+----+------------------+
| id | audit_id         |
+----+------------------+
|  1 | 9941971237863475 |
+----+------------------+
1 row in set (0.00 sec)

4. What is your TiDB version? (Required)

+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                                                   |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v5.3.0-alpha-1114-g06cfd000c-dirty
Edition: Community
Git Commit Hash: 06cfd000cb481d30c92a5917fd2734b37a7caffe
Git Branch: master
UTC Build Time: 2021-10-15 07:06:51
GoVersion: go1.16.3
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
@github-actions
Copy link

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

@jebter jebter added the affects-5.2 This bug affects 5.2.x versions. label Nov 17, 2021
@qw4990 qw4990 added affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. labels Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. epic/plan-cache severity/critical sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
3 participants