MySQL Forums
Forum List  »  Optimizer & Parser

Re: Need help with tracing how identifiers are parsed; dot-reserved vs dot-space-reserved
Posted by: Justin Ng
Date: May 25, 2021 06:21AM

I think I just figured it out.

The important bits are,
+ https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_lex.cc#L1610-L1612
+ `MY_LEX_IDENT_START` does not call `find_keyword()`
+ `MY_LEX_START` calls `find_keyword()`

In `.SELECT`, we go to `MY_LEX_IDENT_START`, never call `find_keyword()` and treat `SELECT` as an identifier.

In `. SELECT`, we see a space, which is not a valid identifier character. So, we go to `MY_LEX_IDENT`, call `find_keyword()` and treat `SELECT` as a keyword.

And `ident_map` is populated here, https://github.com/mysql/mysql-server/blob/3e90d07c3578e4da39dc1bce73559bbdf655c28c/mysys/sql_chars.cc#L120

`ident_map` is basically an array of booleans, mapping each character to true/false, depending on whether it could plausibly be an identifier character.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Need help with tracing how identifiers are parsed; dot-reserved vs dot-space-reserved
46
May 25, 2021 06:21AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.