Skip to content

Syntax error in optimizer hints should not invalidate the entire hint #341

@kennytm

Description

@kennytm

On MySQL 8, all optimizer hints parsed before a syntax error will be accepted:

$ echo 'SELECT SLEEP(1);' | mysql -u root
SLEEP(1)
0

$ echo 'SELECT /*+ max_execution_time(2) */ SLEEP(1);' | mysql -u root
SLEEP(1)
1

$ echo 'SELECT /*+ max_execution_time(2) (error) */ SLEEP(1);' | mysql -u root
SLEEP(1)
1

$ echo 'SELECT /*+ (error) max_execution_time(2) */ SLEEP(1);' | mysql -u root
SLEEP(1)
0

(returning 0 means hint is ignored, returning 1 means hint is used)

On TiDB Parser, however, once an error is encountered the entire list of hints are thrown out, different from MySQL's behavior.

(TiDB Parser version = 89ae120)

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions