pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.28k stars 5.84k forks source link

ERROR 8066 when create binding for select statement with high_priority #57427

Open pcqz opened 2 hours ago

pcqz commented 2 hours ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> create table t(a int, b int, key `i_a`(a));
Query OK, 0 rows affected (0.03 sec)

mysql> explain select /*+ use_index(t, i_a) */ high_priority * from t;
+-------------------------------+----------+-----------+-----------------------+--------------------------------+
| id                            | estRows  | task      | access object         | operator info                  |
+-------------------------------+----------+-----------+-----------------------+--------------------------------+
| IndexLookUp_6                 | 10000.00 | root      |                       |                                |
| ├─IndexFullScan_4(Build)      | 10000.00 | cop[tikv] | table:t, index:i_a(a) | keep order:false, stats:pseudo |
| └─TableRowIDScan_5(Probe)     | 10000.00 | cop[tikv] | table:t               | keep order:false, stats:pseudo |
+-------------------------------+----------+-----------+-----------------------+--------------------------------+
3 rows in set (0.00 sec)

mysql> create binding for select high_priority * from t using select /*+ use_index(t, i_a) */ high_priority * from t;
ERROR 8066 (HY000): Optimizer hint can only be followed by certain keywords like SELECT, INSERT, etc.

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

NO ERROR

3. What did you see instead (Required)

ERROR 8066

4. What is your TiDB version? (Required)

v8.3.0

pcqz commented 2 hours ago

The binding can be created but can't work in v6.5.11.

mysql> create binding for select high_priority * from t using select /*+ use_index(t, i_a) */ high_priority * from t;
Query OK, 0 rows affected (0.00 sec)

mysql> explain select high_priority * from t;
+-----------------------+----------+-----------+---------------+--------------------------------+
| id                    | estRows  | task      | access object | operator info                  |
+-----------------------+----------+-----------+---------------+--------------------------------+
| TableReader_5         | 10000.00 | root      |               | data:TableFullScan_4           |
| └─TableFullScan_4     | 10000.00 | cop[tikv] | table:t       | keep order:false, stats:pseudo |
+-----------------------+----------+-----------+---------------+--------------------------------+
2 rows in set (0.00 sec)
pcqz commented 2 hours ago

/report customer