|
Key points in PR:
- Excessively verbose about syntax error, but not where.
- "to use near" is vague, "starting at" would be closer to being accurate (most of the time)
- it should also say "at position N" (or "character N), N being the index of the character where the error was found within the line, because what if the string that it has quoted appears more than once in the query?
- anything else to meaningfully clarity context
- URLs probably too erroneous attempting to resolve to exact syntax page
Examination of possibilities:
|
parser state observation in two syntax errors
|
(gdb) p *m_parser_state
|
$2 = {m_lip = {lookahead_token = -1, lookahead_yylval = 0x0, m_thd = 0x7f0018000c58, m_ptr = 0x7f0018013026 "", m_tok_start = 0x7f0018013025 ")", m_tok_end = 0x7f0018013025 ")", m_end_of_query = 0x7f0018013026 "", m_tok_start_prev = 0x7f0018013022 "dog)", m_buf = 0x7f0018013010 "create table bob (dog)", m_buf_length = 22, m_echo = true, m_echo_saved = false, m_cpp_buf = 0x7f0018013080 "create table bob (dog)", m_cpp_ptr = 0x7f0018013096 "", m_cpp_tok_start = 0x7f0018013095 ")", m_cpp_tok_start_prev = 0x7f0018013092 "dog)", m_cpp_tok_end = 0x7f0018013095 ")", m_body_utf8 = 0x0, m_body_utf8_ptr = 0x0, m_cpp_utf8_processed_ptr = 0x0, next_state = MY_LEX_OPERATOR_OR_IDENT, found_semicolon = 0x0, ignore_space = false, stmt_prepare_mode = false, multi_statements = true, yylineno = 1, m_digest = 0x0, in_comment = NO_COMMENT, in_comment_saved = NO_COMMENT, m_cpp_text_start = 0x7f0018013092 "dog)", m_cpp_text_end = 0x7f0018013095 ")", m_underscore_cs = 0x0}, m_yacc = {yacc_yyss = 0x0, yacc_yyvs = 0x0, m_set_signal_info = {m_item = {0x0 <repeats 13 times>}}, m_lock_type = TL_READ_DEFAULT, m_mdl_type = MDL_SHARED_READ}, m_digest_psi = 0x0}
|
(gdb) c
|
Continuing.
|
[New Thread 0x7f003affd640 (LWP 64690)]
|
[Thread 0x7f0078def640 (LWP 63299) exited]
|
|
Thread 25 "mysqld" hit Breakpoint 2, THD::parse_error (this=0x7f0018000c58, err_text=0x1011079 "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use", yytext=0x0) at /home/dan/repos/mariadb-server-10.8/sql/sql_class.h:4768
|
4768 Lex_input_stream *lip= &m_parser_state->m_lip;
|
(gdb) p *m_parser_state
|
$3 = {m_lip = {lookahead_token = -1, lookahead_yylval = 0x0, m_thd = 0x7f0018000c58, m_ptr = 0x7f0018013034 " seqno", m_tok_start = 0x7f0018013031 "not seqno", m_tok_end = 0x7f0018013030 " not seqno", m_end_of_query = 0x7f001801303a "", m_tok_start_prev = 0x7f001801302b "order not seqno", m_buf = 0x7f0018013010 "select * from seq_1_to_300 order not seqno", m_buf_length = 42, m_echo = true, m_echo_saved = false, m_cpp_buf = 0x7f0018013098 "select * from seq_1_to_300 order not \177", m_cpp_ptr = 0x7f00180130bc " \177", m_cpp_tok_start = 0x7f00180130b9 "not \177", m_cpp_tok_start_prev = 0x7f00180130b3 "order not \177", m_cpp_tok_end = 0x7f00180130b8 " not \177", m_body_utf8 = 0x0, m_body_utf8_ptr = 0x0, m_cpp_utf8_processed_ptr = 0x0, next_state = MY_LEX_START, found_semicolon = 0x0, ignore_space = false, stmt_prepare_mode = false, multi_statements = true, yylineno = 1, m_digest = 0x0, in_comment = NO_COMMENT, in_comment_saved = NO_COMMENT, m_cpp_text_start = 0x7f00180130a6 "seq_1_to_300 order not \177", m_cpp_text_end = 0x7f00180130b2 " order not \177", m_underscore_cs = 0x0}, m_yacc = {yacc_yyss = 0x0, yacc_yyvs = 0x0, m_set_signal_info = {m_item = {0x0 <repeats 13 times>}}, m_lock_type = TL_READ_DEFAULT, m_mdl_type = MDL_SHARED_READ}, m_digest_psi = 0x0}
|
(gdb) c
|
m_tok_start_prev might provide some useful context as to where the parsing starts.
next_state has a minimal set of values https://github.com/MariaDB/server/blob/10.5/include/m_ctype.h#L310-L325
Also ref: https://www.gnu.org/software/bison/manual/html_node/Actions-and-Locations.html (currently unused)
|