mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fixed BUG#8937: Stored Procedure: AVG() works as SUM() in SELECT ... INTO statement
mysql-test/r/sp.result: New test case for BUG#8937. mysql-test/t/sp.test: New test case for BUG#8937. sql/item_sum.h: Added val_int() method for Item_sum_avg for forced int types (in SPs for instance), otherwise Item_sum_sum::val_int() is used.
This commit is contained in:
@ -2736,4 +2736,23 @@ call bug8849()|
|
||||
call bug8849()|
|
||||
drop procedure bug8849|
|
||||
drop tables t3,t4,t5|
|
||||
drop procedure if exists bug8937|
|
||||
create procedure bug8937()
|
||||
begin
|
||||
declare s,x,y,z int;
|
||||
declare a float;
|
||||
select sum(data),avg(data),min(data),max(data) into s,x,y,z from t1;
|
||||
select s,x,y,z;
|
||||
select avg(data) into a from t1;
|
||||
select a;
|
||||
end|
|
||||
delete from t1|
|
||||
insert into t1 (data) values (1), (2), (3), (4), (6)|
|
||||
call bug8937()|
|
||||
s x y z
|
||||
16 3 1 6
|
||||
a
|
||||
3.2000
|
||||
drop procedure bug8937|
|
||||
delete from t1|
|
||||
drop table t1,t2;
|
||||
|
@ -3330,8 +3330,32 @@ call bug8849()|
|
||||
drop procedure bug8849|
|
||||
drop tables t3,t4,t5|
|
||||
|
||||
#
|
||||
# BUG#8937: Stored Procedure: AVG() works as SUM() in SELECT ... INTO statement
|
||||
#
|
||||
--disable_warnings
|
||||
drop procedure if exists bug8937|
|
||||
--enable_warnings
|
||||
create procedure bug8937()
|
||||
begin
|
||||
declare s,x,y,z int;
|
||||
declare a float;
|
||||
|
||||
# Add bug above this line. Use existing tables t1 and t2 when
|
||||
select sum(data),avg(data),min(data),max(data) into s,x,y,z from t1;
|
||||
select s,x,y,z;
|
||||
select avg(data) into a from t1;
|
||||
select a;
|
||||
end|
|
||||
|
||||
delete from t1|
|
||||
insert into t1 (data) values (1), (2), (3), (4), (6)|
|
||||
call bug8937()|
|
||||
|
||||
drop procedure bug8937|
|
||||
delete from t1|
|
||||
|
||||
|
||||
# Add bugs above this line. Use existing tables t1 and t2 when
|
||||
# practical, or create table t3, t3 etc temporarily (and drop them).
|
||||
delimiter ;|
|
||||
drop table t1,t2;
|
||||
|
Reference in New Issue
Block a user