Skip to content

Optimizer: invalid hint addition renders other hints in the hint set ineffective #49308

@m0390

Description

@m0390

Bug Report

When there is an invalid hint in a hint set, the behaviour in TiDB is different than MySQL. MySQL respects the other valid hints while TiDB ignore all the hints in the set.

1. Minimal reproduce step (Required)

mysql> SELECT /*+ MAX_EXECUTION_TIME(10) */ SLEEP(5);
mysql> SELECT /*+ MAX_EXECUTION_TIME(10), dtc(name=tt) */ SLEEP(5);

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

Result from MySQL : Server version: 5.7.44 MySQL Community Server (GPL)

mysql> SELECT /*+ MAX_EXECUTION_TIME(10) */ SLEEP(5);
+----------+
| SLEEP(5) |
+----------+
|        1 |
+----------+
1 row in set (0.01 sec)

mysql> SELECT /*+ MAX_EXECUTION_TIME(10), dtc(name=tt) */ SLEEP(5);
+----------+
| SLEEP(5) |
+----------+
|        1 |
+----------+
1 row in set, 1 warning (0.01 sec) <-  hint MAX_EXECUTION_TIME(5) was respected

3. What did you see instead (Required)

Result from TiDB v6.5.4

mysql> SELECT /*+ MAX_EXECUTION_TIME(5) */ SLEEP(5);
--------------
SELECT /*+ MAX_EXECUTION_TIME(5) */ SLEEP(5)
--------------

+----------+
| SLEEP(5) |
+----------+
|        1 |
+----------+
1 row in set (0.07 sec)

mysql> SELECT /*+ MAX_EXECUTION_TIME(5), dtc(name=tt) */ SLEEP(5);
--------------
SELECT /*+ MAX_EXECUTION_TIME(5), dtc(name=tt) */ SLEEP(5)
--------------

+----------+
| SLEEP(5) |
+----------+
|        0 |
+----------+
1 row in set, 1 warning (5.00 sec)  <-- hint MAX_EXECUTION_TIME(5) was ignored

4. What is your TiDB version? (Required)

6.5.4

Metadata

Metadata

Labels

affects-5.4This bug affects the 5.4.x(LTS) versions.affects-6.1This bug affects the 6.1.x(LTS) versions.affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.epic/hintseverity/moderatesig/plannerSIG: Plannertype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions