mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 19:37:16 +02:00
Fix for bug #32260: User variables in query cause server crash
Problem: there's no guarantee that the user variable item's result_field is assigned when we're adjusting its table read map. Fix: check the result_field before using it. mysql-test/r/user_var.result: Fix for bug #32260: User variables in query cause server crash - test result. mysql-test/t/user_var.test: Fix for bug #32260: User variables in query cause server crash - test case. sql/item_func.cc: Fix for bug #32260: User variables in query cause server crash - using the result_field ensure it is set.
This commit is contained in:
parent
c8450b278d
commit
011eb3dffe
3 changed files with 34 additions and 1 deletions
|
|
@ -237,3 +237,24 @@ select @a:=f2, count(f2) from t1 group by 1 desc;
|
|||
select @a:=f3, count(f3) from t1 group by 1 desc;
|
||||
select @a:=f4, count(f4) from t1 group by 1 desc;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Bug #32260: User variables in query cause server crash
|
||||
#
|
||||
create table t1(a int);
|
||||
insert into t1 values(5),(4),(4),(3),(2),(2),(2),(1);
|
||||
set @rownum := 0;
|
||||
set @rank := 0;
|
||||
set @prev_score := NULL;
|
||||
# Disable the result log as we assign a value to a user variable in one part
|
||||
# of a statement and use the same variable in other part of the same statement,
|
||||
# so we can get unexpected results.
|
||||
--disable_result_log
|
||||
select @rownum := @rownum + 1 as row,
|
||||
@rank := IF(@prev_score!=a, @rownum, @rank) as rank,
|
||||
@prev_score := a as score
|
||||
from t1 order by score desc;
|
||||
--enable_result_log
|
||||
drop table t1;
|
||||
|
||||
--echo End of 5.1 tests
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue