summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/sql_lex.cc6
-rw-r--r--sql/sql_lex.h5
-rw-r--r--sql/sql_parse.cc9
3 files changed, 12 insertions, 8 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 95b9a77d411..ecdbb654ffd 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -122,7 +122,8 @@ Lex_input_stream::Lex_input_stream(THD *thd,
tok_start_prev(NULL),
buf(buffer),
next_state(MY_LEX_START),
- found_semicolon(NULL)
+ found_semicolon(NULL),
+ ignore_space(test(thd->variables.sql_mode & MODE_IGNORE_SPACE))
{
}
@@ -192,7 +193,6 @@ void lex_start(THD *thd)
lex->select_lex.udf_list.empty();
lex->current_select= &lex->select_lex;
lex->yacc_yyss=lex->yacc_yyvs=0;
- lex->ignore_space=test(thd->variables.sql_mode & MODE_IGNORE_SPACE);
lex->sql_command= lex->orig_sql_command= SQLCOM_END;
lex->duplicates= DUP_ERROR;
lex->ignore= 0;
@@ -656,7 +656,7 @@ int MYSQLlex(void *arg, void *yythd)
}
length= (uint) (lip->ptr - lip->tok_start)-1;
start= lip->ptr;
- if (lex->ignore_space)
+ if (lip->ignore_space)
{
/*
If we find a space then this can't be an identifier. We notice this
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index d580b2016ae..d07de73d5b9 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -951,6 +951,9 @@ public:
/** Position of ';' in the stream, to delimit multiple queries. */
const char* found_semicolon;
+
+ /** SQL_MODE = IGNORE_SPACE. */
+ bool ignore_space;
};
@@ -1069,7 +1072,7 @@ typedef struct st_lex : public Query_tables_list
uint8 create_view_algorithm;
uint8 create_view_check;
bool drop_if_exists, drop_temporary, local_file, one_shot_set;
- bool in_comment, ignore_space, verbose, no_write_to_binlog;
+ bool in_comment, verbose, no_write_to_binlog;
bool tx_chain, tx_release;
/*
Special JOIN::prepare mode: changing of query is prohibited.
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 0505f0d3574..22689a3dfa1 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -5990,16 +5990,14 @@ void mysql_parse(THD *thd, const char *inBuf, uint length,
- first, call query_cache_send_result_to_client,
- second, if caching failed, initialise the lexical and syntactic parser.
The problem is that the query cache depends on a clean initialization
- of the thd and thd->lex structures, which happen to be implemented
- by:
+ of (among others) lex->safe_to_cache_query and thd->server_status,
+ which are reset respectively in
- lex_start()
- mysql_reset_thd_for_next_command()
So, initializing the lexical analyser *before* using the query cache
is required for the cache to work properly.
FIXME: cleanup the dependencies in the code to simplify this.
*/
- Lex_input_stream lip(thd, inBuf, length);
- thd->m_lip= &lip;
lex_start(thd);
mysql_reset_thd_for_next_command(thd);
@@ -6010,6 +6008,9 @@ void mysql_parse(THD *thd, const char *inBuf, uint length,
sp_cache_flush_obsolete(&thd->sp_proc_cache);
sp_cache_flush_obsolete(&thd->sp_func_cache);
+ Lex_input_stream lip(thd, inBuf, length);
+ thd->m_lip= &lip;
+
int err= MYSQLparse(thd);
*found_semicolon= lip.found_semicolon;