File tree Expand file tree Collapse file tree 4 files changed +77
-0
lines changed Expand file tree Collapse file tree 4 files changed +77
-0
lines changed Original file line number Diff line number Diff line change @@ -4352,3 +4352,27 @@ row_number() OVER (order by a)
4352
4352
2
4353
4353
3
4354
4354
drop table t1;
4355
+ #
4356
+ # MDEV-28206 SIGSEGV in Item_field::fix_fields when using LEAD...OVER
4357
+ #
4358
+ CREATE TABLE t(c1 INT);
4359
+ CREATE FUNCTION f() RETURNS INT READS SQL DATA BEGIN
4360
+ DECLARE v INT;
4361
+ SELECT 1 INTO v FROM (SELECT c1,COALESCE(LEAD(a2.c1) OVER (PARTITION BY a2.c1 ORDER BY a2.c1),a2.c1) AS a1 FROM (t a2 JOIN t a3 USING (c1))) a4;
4362
+ RETURN 1;
4363
+ END//
4364
+ SELECT f(),f();
4365
+ f() f()
4366
+ 1 1
4367
+ EXECUTE IMMEDIATE "SELECT LEAD(c1) OVER (ORDER BY c1) FROM t NATURAL JOIN t AS a;";
4368
+ LEAD(c1) OVER (ORDER BY c1)
4369
+ EXECUTE IMMEDIATE "SELECT SUM(c1) OVER (ORDER BY c1) FROM t NATURAL JOIN t AS a;";
4370
+ SUM(c1) OVER (ORDER BY c1)
4371
+ EXECUTE IMMEDIATE "SELECT LEAD(c) OVER (ORDER BY c) FROM (SELECT 1 AS c) AS a NATURAL JOIN (SELECT 1 AS c) AS b;";
4372
+ LEAD(c) OVER (ORDER BY c)
4373
+ NULL
4374
+ DROP FUNCTION f;
4375
+ DROP TABLE t;
4376
+ #
4377
+ # End of 10.6 tests
4378
+ #
Original file line number Diff line number Diff line change @@ -2829,3 +2829,31 @@ create table t1 (a int);
2829
2829
insert into t1 values (1),(2),(3);
2830
2830
SELECT row_number() OVER (order by a) FROM t1 order by NAME_CONST('myname',NULL);
2831
2831
drop table t1;
2832
+
2833
+ --echo #
2834
+ --echo # MDEV-28206 SIGSEGV in Item_field::fix_fields when using LEAD...OVER
2835
+ --echo #
2836
+
2837
+ CREATE TABLE t(c1 INT);
2838
+
2839
+ DELIMITER //;
2840
+ CREATE FUNCTION f() RETURNS INT READS SQL DATA BEGIN
2841
+ DECLARE v INT;
2842
+ SELECT 1 INTO v FROM (SELECT c1,COALESCE(LEAD(a2.c1) OVER (PARTITION BY a2.c1 ORDER BY a2.c1),a2.c1) AS a1 FROM (t a2 JOIN t a3 USING (c1))) a4;
2843
+ RETURN 1;
2844
+ END//
2845
+ DELIMITER ;//
2846
+
2847
+ SELECT f(),f();
2848
+
2849
+ EXECUTE IMMEDIATE "SELECT LEAD(c1) OVER (ORDER BY c1) FROM t NATURAL JOIN t AS a;";
2850
+ EXECUTE IMMEDIATE "SELECT SUM(c1) OVER (ORDER BY c1) FROM t NATURAL JOIN t AS a;";
2851
+
2852
+ EXECUTE IMMEDIATE "SELECT LEAD(c) OVER (ORDER BY c) FROM (SELECT 1 AS c) AS a NATURAL JOIN (SELECT 1 AS c) AS b;";
2853
+
2854
+ DROP FUNCTION f;
2855
+ DROP TABLE t;
2856
+
2857
+ --echo #
2858
+ --echo # End of 10.6 tests
2859
+ --echo #
Original file line number Diff line number Diff line change @@ -4359,6 +4359,30 @@ row_number() OVER (order by a)
4359
4359
3
4360
4360
drop table t1;
4361
4361
#
4362
+ # MDEV-28206 SIGSEGV in Item_field::fix_fields when using LEAD...OVER
4363
+ #
4364
+ CREATE TABLE t(c1 INT);
4365
+ CREATE FUNCTION f() RETURNS INT READS SQL DATA BEGIN
4366
+ DECLARE v INT;
4367
+ SELECT 1 INTO v FROM (SELECT c1,COALESCE(LEAD(a2.c1) OVER (PARTITION BY a2.c1 ORDER BY a2.c1),a2.c1) AS a1 FROM (t a2 JOIN t a3 USING (c1))) a4;
4368
+ RETURN 1;
4369
+ END//
4370
+ SELECT f(),f();
4371
+ f() f()
4372
+ 1 1
4373
+ EXECUTE IMMEDIATE "SELECT LEAD(c1) OVER (ORDER BY c1) FROM t NATURAL JOIN t AS a;";
4374
+ LEAD(c1) OVER (ORDER BY c1)
4375
+ EXECUTE IMMEDIATE "SELECT SUM(c1) OVER (ORDER BY c1) FROM t NATURAL JOIN t AS a;";
4376
+ SUM(c1) OVER (ORDER BY c1)
4377
+ EXECUTE IMMEDIATE "SELECT LEAD(c) OVER (ORDER BY c) FROM (SELECT 1 AS c) AS a NATURAL JOIN (SELECT 1 AS c) AS b;";
4378
+ LEAD(c) OVER (ORDER BY c)
4379
+ NULL
4380
+ DROP FUNCTION f;
4381
+ DROP TABLE t;
4382
+ #
4383
+ # End of 10.6 tests
4384
+ #
4385
+ #
4362
4386
# MDEV-23867: select crash in compute_window_func
4363
4387
#
4364
4388
set @save_sort_buffer_size=@@sort_buffer_size;
Original file line number Diff line number Diff line change @@ -6114,6 +6114,7 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
6114
6114
6115
6115
if (!thd->lex ->current_select ->no_wrap_view_item &&
6116
6116
thd->lex ->in_sum_func &&
6117
+ select &&
6117
6118
thd->lex == select->parent_lex &&
6118
6119
thd->lex ->in_sum_func ->nest_level ==
6119
6120
select->nest_level )
You can’t perform that action at this time.
0 commit comments