mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
MDEV-13649: Server crashes in set_field_to_null_with_conversions or in Field::set_notnull
Item_cond did not correctly propagate with_window_func flag in the Item tree. Without it, we would not call Item::split_sum_func correctly and the window function's result_field would remain NULL.
This commit is contained in:
@@ -3214,3 +3214,51 @@ SELECT * FROM fv_result;
|
||||
somedate
|
||||
2017-07-20 12:47:56
|
||||
DROP TABLE fv_test, fv_result;
|
||||
#
|
||||
# MDEV-13649: Server crashes in set_field_to_null_with_conversions or in Field::set_notnull
|
||||
#
|
||||
CREATE TABLE t1 (a int);
|
||||
INSERT INTO t1 VALUES (0),(1),(2);
|
||||
SELECT LEAD(a) OVER (PARTITION BY a) as lead,
|
||||
a AND LEAD(a) OVER (PARTITION BY a) AS a_and_lead_part
|
||||
FROM t1;
|
||||
lead a_and_lead_part
|
||||
NULL 0
|
||||
NULL NULL
|
||||
NULL NULL
|
||||
SELECT a OR LEAD(a) OVER (ORDER BY a) AS a_or_lead_order
|
||||
FROM t1
|
||||
ORDER BY a;
|
||||
a_or_lead_order
|
||||
1
|
||||
1
|
||||
1
|
||||
SELECT a AND LEAD(a) OVER (ORDER BY a) AS a_and_lead_order
|
||||
FROM t1
|
||||
ORDER BY a;
|
||||
a_and_lead_order
|
||||
0
|
||||
1
|
||||
NULL
|
||||
SELECT a XOR LEAD(a) OVER (ORDER BY a) AS a_xor_lead_order
|
||||
FROM t1
|
||||
ORDER BY a;
|
||||
a_xor_lead_order
|
||||
1
|
||||
0
|
||||
NULL
|
||||
SELECT NOT LEAD(a) OVER (ORDER BY a) AS not_lead_order
|
||||
FROM t1
|
||||
ORDER BY a;
|
||||
not_lead_order
|
||||
0
|
||||
0
|
||||
NULL
|
||||
SELECT LEAD(a) OVER (ORDER BY a) is not null AS is_not_null_lead_order
|
||||
FROM t1
|
||||
ORDER BY a;
|
||||
is_not_null_lead_order
|
||||
1
|
||||
1
|
||||
0
|
||||
drop table t1;
|
||||
|
||||
@@ -1993,3 +1993,35 @@ SHOW CREATE TABLE fv_result;
|
||||
SELECT * FROM fv_result;
|
||||
|
||||
DROP TABLE fv_test, fv_result;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-13649: Server crashes in set_field_to_null_with_conversions or in Field::set_notnull
|
||||
--echo #
|
||||
|
||||
CREATE TABLE t1 (a int);
|
||||
INSERT INTO t1 VALUES (0),(1),(2);
|
||||
SELECT LEAD(a) OVER (PARTITION BY a) as lead,
|
||||
a AND LEAD(a) OVER (PARTITION BY a) AS a_and_lead_part
|
||||
FROM t1;
|
||||
|
||||
SELECT a OR LEAD(a) OVER (ORDER BY a) AS a_or_lead_order
|
||||
FROM t1
|
||||
ORDER BY a;
|
||||
|
||||
SELECT a AND LEAD(a) OVER (ORDER BY a) AS a_and_lead_order
|
||||
FROM t1
|
||||
ORDER BY a;
|
||||
|
||||
SELECT a XOR LEAD(a) OVER (ORDER BY a) AS a_xor_lead_order
|
||||
FROM t1
|
||||
ORDER BY a;
|
||||
|
||||
SELECT NOT LEAD(a) OVER (ORDER BY a) AS not_lead_order
|
||||
FROM t1
|
||||
ORDER BY a;
|
||||
|
||||
SELECT LEAD(a) OVER (ORDER BY a) is not null AS is_not_null_lead_order
|
||||
FROM t1
|
||||
ORDER BY a;
|
||||
|
||||
drop table t1;
|
||||
|
||||
@@ -4635,11 +4635,11 @@ Item_cond::fix_fields(THD *thd, Item **ref)
|
||||
const_item_cache= FALSE;
|
||||
}
|
||||
|
||||
with_sum_func= with_sum_func || item->with_sum_func;
|
||||
with_field= with_field || item->with_field;
|
||||
with_subselect|= item->has_subquery();
|
||||
if (item->maybe_null)
|
||||
maybe_null=1;
|
||||
with_sum_func|= item->with_sum_func;
|
||||
with_field|= item->with_field;
|
||||
with_subselect|= item->has_subquery();
|
||||
with_window_func|= item->with_window_func;
|
||||
maybe_null|= item->maybe_null;
|
||||
}
|
||||
fix_length_and_dec();
|
||||
fixed= 1;
|
||||
|
||||
Reference in New Issue
Block a user