Commit 33209350 authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

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.
parent 02eda36e
...@@ -3214,3 +3214,51 @@ SELECT * FROM fv_result; ...@@ -3214,3 +3214,51 @@ SELECT * FROM fv_result;
somedate somedate
2017-07-20 12:47:56 2017-07-20 12:47:56
DROP TABLE fv_test, fv_result; 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; ...@@ -1993,3 +1993,35 @@ SHOW CREATE TABLE fv_result;
SELECT * FROM fv_result; SELECT * FROM fv_result;
DROP TABLE fv_test, 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) ...@@ -4635,11 +4635,11 @@ Item_cond::fix_fields(THD *thd, Item **ref)
const_item_cache= FALSE; const_item_cache= FALSE;
} }
with_sum_func= with_sum_func || item->with_sum_func; with_sum_func|= item->with_sum_func;
with_field= with_field || item->with_field; with_field|= item->with_field;
with_subselect|= item->has_subquery(); with_subselect|= item->has_subquery();
if (item->maybe_null) with_window_func|= item->with_window_func;
maybe_null=1; maybe_null|= item->maybe_null;
} }
fix_length_and_dec(); fix_length_and_dec();
fixed= 1; fixed= 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment