diff options
author | unknown <konstantin@mysql.com> | 2004-10-14 02:53:59 +0400 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2004-10-14 02:53:59 +0400 |
commit | 54b00f5453b49047142d59da21e19d607f4b208e (patch) | |
tree | 27ce02a5ecb8610d69b81dc15a3d96a62126e80a /sql/sql_lex.h | |
parent | d007600b9b83818b27e916457e166dccdf7c729c (diff) | |
download | mariadb-git-54b00f5453b49047142d59da21e19d607f4b208e.tar.gz |
A fix and test case for Bug#5985 ""prepare stmt from "select rand(?)"
crashes server." The fix makes Item_func_rand prepared-statements
aware plus it fixes the case when RAND is used in prepared
statements and replication is on (as well as several similar issues).
Until now we did not reset THD before every execution of a prepared
statement, so if some execution had set thd->time_zone_used
or thd->rand_used they would not be reset until next mysql_parse.
Some of post-review fixes done.
mysql-test/r/ps.result:
A test case for Bug#5985: test results fixed.
mysql-test/t/ps.test:
A test case for Bug#5985 "prepare stmt from "select rand(?)" crashes
server."
sql/item_func.cc:
Actual fix for Bug#5985: Item_func_rand rewritten to be
prepared statements aware.
sql/item_func.h:
Actual fix for Bug#5985: Item_func_rand rewritten to be
prepared statements aware.
sql/mysql_priv.h:
We need a separate call to reset THD state before every execute of
a prepared statement. Otherwise things like THD->user_var_events
are never cleaned up and bloat binary log (as the list of events
grows from execution to execution).
sql/sql_class.cc:
Statement::end_statement -> THD::end_statement()
(a leftover from some design change which is not to pushed now, but the
leftover is to be pushed).
sql/sql_class.h:
Statement::end_statement -> THD::end_statement()
(a leftover from some design change which is not to pushed now, but the
leftover is to be pushed).
sql/sql_lex.cc:
Move the part responsible for initializing LEX from mysql_init_query
to lex_start.
sql/sql_lex.h:
All lex-related initialization is now in lex_start.
Move thd->select_number to lex->select_number to be able to use it
easily in lex_start.
sql/sql_parse.cc:
Split mysql_init_query into two functions: mysql_reset_thd_for_next_query,
which is used in PS and conventional execution, and lex_start, used only
when we want to parse something.
Fix init_connect to use initialized THD.
sql/sql_prepare.cc:
Deploy mysql_reset_thd_for_next_query to reset THD state before
execution of a prepared statement.
Normally this should have been added to just one place, but
we have to reset thd before assigning placeholders from variables,
thus we can't do that in execute_stmt (yuck).
Diffstat (limited to 'sql/sql_lex.h')
-rw-r--r-- | sql/sql_lex.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sql/sql_lex.h b/sql/sql_lex.h index d198855a2d3..38cdde019ff 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -369,7 +369,7 @@ public: ulong init_prepare_fake_select_lex(THD *thd); int change_result(select_subselect *result, select_subselect *old_result); - friend void mysql_init_query(THD *thd, uchar *buf, uint length); + friend void lex_start(THD *thd, uchar *buf, uint length); friend int subselect_union_engine::exec(); private: bool create_total_list_n_last_return(THD *thd, st_lex *lex, @@ -508,7 +508,7 @@ public: bool test_limit(); - friend void mysql_init_query(THD *thd, uchar *buf, uint length); + friend void lex_start(THD *thd, uchar *buf, uint length); st_select_lex() {} void make_empty_select() { |