mirror of
https://github.com/MariaDB/server.git
synced 2025-01-27 17:33:44 +01:00
505b7127c9
The issue is caused by a logic error in Item_sum::get_tmp_table_item() method: it resets arguments of the item to point to the result fields during change_ref_to_tmp_fields() call. However, Item_sum arguments must not be modified. It is enough for Item_sum objects to call ancestor's implementation Item::get_tmp_table_item(). This fix is in accordance with MySQL commit 2e3dc09087c24798c90e05163ed3d931f6b93db3 Reviewer: Oleksandr Byelkin <sanja@mariadb.com>
70 lines
1.4 KiB
Text
70 lines
1.4 KiB
Text
create table t1 (
|
|
pk int primary key,
|
|
a int,
|
|
b int,
|
|
c real
|
|
);
|
|
|
|
|
|
insert into t1 values
|
|
(101 , 0, 10, 1.1),
|
|
(102 , 0, 10, 2.1),
|
|
(103 , 1, 10, 3.1),
|
|
(104 , 1, 10, 4.1),
|
|
(108 , 2, 10, 5.1),
|
|
(105 , 2, 20, 6.1),
|
|
(106 , 2, 20, 7.1),
|
|
(107 , 2, 20, 8.15),
|
|
(109 , 4, 20, 9.15),
|
|
(110 , 4, 20, 10.15),
|
|
(111 , 5, NULL, 11.15),
|
|
(112 , 5, 1, 12.25),
|
|
(113 , 5, NULL, 13.35),
|
|
(114 , 5, NULL, 14.50),
|
|
(115 , 5, NULL, 15.65),
|
|
(116 , 6, 1, NULL),
|
|
(117 , 6, 1, 10),
|
|
(118 , 6, 1, 1.1),
|
|
(119 , 6, 1, NULL),
|
|
(120 , 6, 1, NULL),
|
|
(121 , 6, 1, NULL),
|
|
(122 , 6, 1, 2.2),
|
|
(123 , 6, 1, 20.1),
|
|
(124 , 6, 1, -10.4),
|
|
(125 , 6, 1, NULL),
|
|
(126 , 6, 1, NULL),
|
|
(127 , 6, 1, NULL);
|
|
|
|
--sorted_result
|
|
select pk, a, b, sum(b) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) as sum
|
|
from t1;
|
|
|
|
--sorted_result
|
|
select pk, a, c, sum(c) over (partition by a order by pk ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) as sum
|
|
from t1;
|
|
|
|
drop table t1;
|
|
|
|
--echo #
|
|
--echo # End of 10.2 tests
|
|
--echo #
|
|
|
|
--echo #
|
|
--echo # MDEV-28094 Window function in expression in ORDER BY
|
|
--echo #
|
|
SELECT EXISTS (SELECT 1 ORDER BY 1+sum(2) OVER ());
|
|
|
|
--echo #
|
|
--echo # End of 10.4 tests
|
|
--echo #
|
|
|
|
--echo #
|
|
--echo # MDEV-32411 Item_sum arguments incorrectly reset to temp table fields which causes crash
|
|
--echo #
|
|
CREATE TABLE t1 (a INT NOT NULL) ;
|
|
INSERT INTO t1 VALUES (EXISTS(SELECT avg(3) OVER (ORDER BY COUNT(DISTINCT a, HEX(a)))));
|
|
DROP TABLE t1;
|
|
|
|
--echo #
|
|
--echo # End of 10.5 tests
|
|
--echo #
|