mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
Fix bug #13180 thd->allow_sum_funcs wasn't reset before query processing.
thd->allow_sum_func was left 'true' after previous statement thus allowing sum funcs to be present in conditions. thd->allow_sum_func should be set to 0 for each query and each prepared statement reinitialization. This is done in lex_start() and reset_stmt_for_execute(). sql/sql_lex.cc: Fix bug#13180 thd->allow_sum_func wasn't reset obefore query processing. thd->allow_sum_func is set to 0 in lex_start(). sql/sql_prepare.cc: Fix bug#13180 thd->allow_sum_func wasn't reset obefore query processing. thd->allow_sum_func is set to 0 in reset_stmt_for_execute(). mysql-test/t/update.test: Test case for bug#13180 thd->allow_sum_funcs wasn't reset before query processing. mysql-test/r/update.result: Test case for bug#13180 thd->allow_sum_funcs wasn't reset before query processing.
This commit is contained in:
parent
2a5505c7f6
commit
1b02a815dd
4 changed files with 26 additions and 0 deletions
|
@ -251,3 +251,15 @@ f1 f2
|
|||
1 1
|
||||
2 2
|
||||
drop table t1,t2;
|
||||
create table t1(f1 int);
|
||||
select DATABASE();
|
||||
DATABASE()
|
||||
test
|
||||
update t1 set f1=1 where count(*)=1;
|
||||
ERROR HY000: Invalid use of group function
|
||||
select DATABASE();
|
||||
DATABASE()
|
||||
test
|
||||
delete from t1 where count(*)=1;
|
||||
ERROR HY000: Invalid use of group function
|
||||
drop table t1;
|
||||
|
|
|
@ -215,4 +215,16 @@ UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1);
|
|||
select * from t1;
|
||||
drop table t1,t2;
|
||||
|
||||
#
|
||||
# Bug #13180 sometimes server accepts sum func in update/delete where condition
|
||||
#
|
||||
create table t1(f1 int);
|
||||
select DATABASE();
|
||||
--error 1111
|
||||
update t1 set f1=1 where count(*)=1;
|
||||
select DATABASE();
|
||||
--error 1111
|
||||
delete from t1 where count(*)=1;
|
||||
drop table t1;
|
||||
|
||||
# End of 4.1 tests
|
||||
|
|
|
@ -160,6 +160,7 @@ void lex_start(THD *thd, uchar *buf,uint length)
|
|||
lex->duplicates= DUP_ERROR;
|
||||
lex->ignore= 0;
|
||||
lex->proc_list.first= 0;
|
||||
thd->allow_sum_func= 0;
|
||||
}
|
||||
|
||||
void lex_end(LEX *lex)
|
||||
|
|
|
@ -1738,6 +1738,7 @@ static void reset_stmt_for_execute(Prepared_statement *stmt)
|
|||
lex->current_select= &lex->select_lex;
|
||||
if (lex->result)
|
||||
lex->result->cleanup();
|
||||
thd->allow_sum_func= 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue