1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Bug#35577 (CREATE PROCEDURE causes either crash or syntax error depending on

build)

The crash was caused by freeing the internal parser stack during the parser
execution.
This occured only for complex stored procedures, after reallocating the parser
stack using my_yyoverflow(), with the following C call stack:
- MYSQLparse()
- any rule calling sp_head::restore_lex()
- lex_end()
- x_free(lex->yacc_yyss), xfree(lex->yacc_yyvs)

The root cause is the implementation of stored procedures, which breaks the
assumption from 4.1 that there is only one LEX structure per parser call.

The solution is to separate the LEX structure into:
- attributes that represent a statement (the current LEX structure),
- attributes that relate to the syntax parser itself (Yacc_state),
so that parsing multiple statements in stored programs can create multiple
LEX structures while not changing the unique Yacc_state.

Now, Yacc_state and the existing Lex_input_stream are aggregated into
Parser_state, a structure that represent the complete state of the (Lexical +
Syntax) parser.
This commit is contained in:
Marc Alff
2008-07-14 15:41:30 -06:00
parent 8c249ba861
commit 0816ee6d34
13 changed files with 848 additions and 84 deletions

View File

@ -28,7 +28,7 @@ class Slave_log_event;
class Format_description_log_event;
class sp_rcontext;
class sp_cache;
class Lex_input_stream;
class Parser_state;
enum enum_enable_or_disable { LEAVE_AS_IS, ENABLE, DISABLE };
enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY, RNEXT_SAME };
@ -1575,13 +1575,11 @@ public:
} binlog_evt_union;
/**
Character input stream consumed by the lexical analyser,
used during parsing.
Note that since the parser is not re-entrant, we keep only one input
stream here. This member is valid only when executing code during parsing,
and may point to invalid memory after that.
Internal parser state.
Note that since the parser is not re-entrant, we keep only one parser
state here. This member is valid only when executing code during parsing.
*/
Lex_input_stream *m_lip;
Parser_state *m_parser_state;
THD();
~THD();