mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Bug#28494: Grouping by Item_func_set_user_var produces incorrect result.
This is an additional fix. Item::val_xxx methods are supposed to use original data source and Item::val_xxx_result methods to use the item's result field. But for the Item_func_set_user_var class val_xxx_result methods were mapped to val_xxx methods. This leads, in particular, to producing bad sort keys and thus wrong order of the result set of queries with group by/order by clauses. The set of val_xxx_result methods is added to the Item_func_set_user_var class. It's the same as the val_xxx set of method but uses the result_field to return a value.
This commit is contained in:
@@ -318,9 +318,17 @@ SHOW COUNT(*) ERRORS;
|
||||
@@session.error_count
|
||||
1
|
||||
create table t1(f1 int);
|
||||
insert into t1 values(1),(1),(2);
|
||||
select @a:=f1, count(f1) from t1 group by 1;
|
||||
insert into t1 values(1),(1),(2),(3),(4),(1),(3),(1);
|
||||
select @a:=f1, count(f1) from t1 group by 1 desc;
|
||||
@a:=f1 count(f1)
|
||||
1 2
|
||||
4 1
|
||||
3 2
|
||||
2 1
|
||||
1 4
|
||||
select @a:=f1, count(f1) from t1 group by 1 asc;
|
||||
@a:=f1 count(f1)
|
||||
1 4
|
||||
2 1
|
||||
3 2
|
||||
4 1
|
||||
drop table t1;
|
||||
|
||||
Reference in New Issue
Block a user