summaryrefslogtreecommitdiff
path: root/sql/sp.cc
diff options
context:
space:
mode:
authorunknown <malff/marcsql@weblab.(none)>2007-04-24 09:24:21 -0600
committerunknown <malff/marcsql@weblab.(none)>2007-04-24 09:24:21 -0600
commit3eff7d4dd5bba598fe055808697d630622fa249b (patch)
tree03a6a80eee7a518f0f3fab0735e9514d4af88fe1 /sql/sp.cc
parent52b86a6e0a9be6f3c41f24b9c30d2b6f885ad94f (diff)
downloadmariadb-git-3eff7d4dd5bba598fe055808697d630622fa249b.tar.gz
Bug#25411 (trigger code truncated), PART I
The issue found with bug 25411 is due to the function skip_rear_comments() which damages the source code while implementing a work around. The root cause of the problem is in the lexical analyser, which does not process special comments properly. For special comments like : [1] aaa /*!50000 bbb */ ccc since 5.0 is a version older that the current code, the parser is in lining the content of the special comment, so that the query to process is [2] aaa bbb ccc However, the text of the query captured when processing a stored procedure, stored function or trigger (or event in 5.1), can be after rebuilding it: [3] aaa bbb */ ccc which is wrong. To fix bug 25411 properly, the lexical analyser needs to return [2] when in lining special comments. In order to implement this, some preliminary cleanup is required in the code, which is implemented by this patch. Before this change, the structure named LEX (or st_lex) contains attributes that belong to lexical analysis, as well as attributes that represents the abstract syntax tree (AST) of a statement. Creating a new LEX structure for each statements (which makes sense for the AST part) also re-initialized the lexical analysis phase each time, which is conceptually wrong. With this patch, the previous st_lex structure has been split in two: - st_lex represents the Abstract Syntax Tree for a statement. The name "lex" has not been changed to avoid a bigger impact in the code base. - class lex_input_stream represents the internal state of the lexical analyser, which by definition should *not* be reinitialized when parsing multiple statements from the same input stream. This change is a pre-requisite for bug 25411, since the implementation of lex_input_stream will later improve to deal properly with special comments, and this processing can not be done with the current implementation of sp_head::reset_lex and sp_head::restore_lex, which interfere with the lexer. This change set alone does not fix bug 25411. sql/item_func.cc: Refactoring, separate lex_input_stream from st_lex. sql/log_event.cc: Refactoring, separate lex_input_stream from st_lex. sql/mysql_priv.h: Refactoring, separate lex_input_stream from st_lex. sql/slave.cc: Refactoring, separate lex_input_stream from st_lex. sql/sp.cc: Refactoring, separate lex_input_stream from st_lex. sql/sp_head.cc: Refactoring, separate lex_input_stream from st_lex. sql/sp_head.h: Refactoring, separate lex_input_stream from st_lex. sql/sql_class.cc: Refactoring, separate lex_input_stream from st_lex. sql/sql_class.h: Refactoring, separate lex_input_stream from st_lex. sql/sql_lex.cc: Refactoring, separate lex_input_stream from st_lex. sql/sql_lex.h: Refactoring, separate lex_input_stream from st_lex. sql/sql_parse.cc: Refactoring, separate lex_input_stream from st_lex. sql/sql_prepare.cc: Refactoring, separate lex_input_stream from st_lex. sql/sql_trigger.cc: Refactoring, separate lex_input_stream from st_lex. sql/sql_view.cc: Refactoring, separate lex_input_stream from st_lex. sql/sql_yacc.yy: Refactoring, separate lex_input_stream from st_lex.
Diffstat (limited to 'sql/sp.cc')
-rw-r--r--sql/sp.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/sql/sp.cc b/sql/sp.cc
index c8701aa2c87..a17ac9f30aa 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -434,10 +434,15 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp,
if ((ret= sp_use_new_db(thd, name->m_db, &old_db, 1, &dbchanged)))
goto end;
- lex_start(thd, (uchar*)defstr.c_ptr(), defstr.length());
+ {
+ Lex_input_stream lip(thd, defstr.c_ptr(), defstr.length());
+ thd->m_lip= &lip;
+ lex_start(thd);
+ ret= MYSQLparse(thd);
+ }
thd->spcont= 0;
- if (MYSQLparse(thd) || thd->is_fatal_error || newlex.sphead == NULL)
+ if (ret || thd->is_fatal_error || newlex.sphead == NULL)
{
sp_head *sp= newlex.sphead;