Open AnyhowStep opened 3 years ago
Seems like m_append_space
controls whether whitespace is allowed after the token
Given SELECT T . SELECT
,
MY_LEX_IDENT_SEP
state
https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_lex.cc#L2052MY_LEX_START
state
https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_lex.cc#L1612MY_LEX_IDENT
state
https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_lex.cc#L1411
https://github.com/mysql/mysql-server/blob/3e90d07c3578e4da39dc1bce73559bbdf655c28c/mysys/sql_chars.cc#L88bool function = false
https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_lex.cc#L1568
https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_lex.cc#L862SELECT
is found
https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_lex.cc#L866
https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_lex.cc#L892SELECT
is returned
https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_lex.cc#L1571No clue where ER_PARSE_ERROR
(1064) is thrown, though.
And given SELECT T.SELECT
, we must have roughly the same flow as above, but with no errors.
Okay, problem solved (I think).
MY_LEX_IDENT_SEP
stateMY_LEX_IDENT_START
state (this is different from MY_LEX_IDENT
!!!)
https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_lex.cc#L1610ident_map[lip->yyPeek()]
is true for .SELECT
, false for . SELECT
.
https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_lex.cc#L1611So,
.SELECT
is MY_LEX_IDENT_START
. SELECT
is MY_LEX_START
In the entirety of MY_LEX_IDENT_START
, we do not see it call find_keyword()
!
https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_lex.cc#L1671-L1712
It does, however, call it for MY_LEX_START
https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_lex.cc#L1568
ident_map
is referenced here.
It is populated here, https://github.com/mysql/mysql-server/blob/3e90d07c3578e4da39dc1bce73559bbdf655c28c/mysys/sql_chars.cc#L120
ident_map
is basically an array of booleans.
If the character is a valid identifier character, the value is true
. Otherwise, false
.
Whitespace is not a valid identifier character. So, the value is false
.
In the case of @@variable
,
MY_LEX_START
state = state_map[c]
, it is MY_LEX_USER_END
https://github.com/mysql/mysql-server/blob/3e90d07c3578e4da39dc1bce73559bbdf655c28c/mysys/sql_chars.cc#L112state_map[lip->yyPeek()]
and see it is MY_LEX_USER_END
again. We set state to MY_LEX_SYSTEM_VAR
https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_lex.cc#L2068MY_LEX_IDENT_OR_KEYWORD
https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_lex.cc#L2090length
is zero if we do not see an identifier
https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_lex.cc#L2106ABORT_SYM
This is why @@variable
is not allowed to have any whitespace between any of the three tokens.
https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/gen_lex_token.cc#L286