pingcap / pingcap/tidb

results of prepare is incosistent with mysql

Open
#61,516 1 comment 0 reactions 1 assignee Claimed by @hawkingrei View on GitHub
severity/moderate sig/planner type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

```
PREPARE stmt1 FROM 'SELECT ? WHERE ? ORDER BY ? LIMIT ?';
SET @a=1,@b='string',@c=0,@d=18446744073709551615;
EXECUTE stmt1 USING @a,@b,@c,@d;
```

### 2. What did you expect to see? (Required)
results from mysql:
```
MySQL [fuzztest]>
MySQL [fuzztest]> PREPARE stmt1 FROM 'SELECT ? WHERE ? ORDER BY ? LIMIT ?';
Query OK, 0 rows affected (0.00 sec)
Statement prepared

MySQL [fuzztest]> SET @a=1,@b='string',@c=0,@d=18446744073709551615;
Query OK, 0 rows affected (0.00 sec)

MySQL [fuzztest]> EXECUTE stmt1 USING @a,@b,@c,@d;
Empty set, 1 warning (0.00 sec)
```

### 3. What did you see instead (Required)
results from tidb:
```
MySQL [test1]> PREPARE stmt1 FROM 'SELECT ? WHERE ? ORDER BY ? LIMIT ?';
Query OK, 0 rows affected, 1 warning (0.01 sec)

MySQL [test1]> SET @a=1,@b='string',@c=0,@d=18446744073709551615;
Query OK, 0 rows affected (0.00 sec)

MySQL [test1]> EXECUTE stmt1 USING @a,@b,@c,@d;
ERROR 1054 (42S22): Unknown column '?' in 'order clause'
```

### 4. What is your TiDB version? (Required)
```
MySQL [test1]> select tidb_version();
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v7.5.6
Edition: Community
Git Commit Hash: 1ad553d6de2cb0c9b2f3cfdb760aaae109b2c466
Git Branch: HEAD
UTC Build Time: 2025-03-12 10:49:51
GoVersion: go1.21.13
Race Enabled: false
Check Table Before Drop: false
Store: tikv |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.