Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions mysql-test/main/func_equal.result
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,17 @@ c1
0
DROP TABLE t0;
# End of 10.5 tests
#
# MDEV-36964: Stack looping, SIGSEGVs in `Item_hybrid_func::type_handler` and `Item::check_cols` on SELECT when using a function
#
CREATE FUNCTION f() RETURNS ROW TYPE OF t RETURN 1;
CREATE TABLE t (c INT KEY,c2 INT,UNIQUE (c2));
SELECT ROW(COALESCE(f()),1)=ROW(1,1) AS eq;
ERROR HY000: Illegal parameter data type row for operation 'coalesce'
SELECT ROW(COALESCE(f()),1)=ROW(COALESCE(f()),1) AS eq;
ERROR HY000: Illegal parameter data type row for operation 'coalesce'
SELECT ROW(1, COALESCE(f()), 1)=ROW(1, COALESCE(f()), 1) AS eq;
ERROR HY000: Illegal parameter data type row for operation 'coalesce'
DROP FUNCTION f;
DROP TABLE t;
#
21 changes: 21 additions & 0 deletions mysql-test/main/func_equal.test
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,24 @@ DROP TABLE t0;


--echo # End of 10.5 tests

--echo #
--echo # MDEV-36964: Stack looping, SIGSEGVs in `Item_hybrid_func::type_handler` and `Item::check_cols` on SELECT when using a function
--echo #

CREATE FUNCTION f() RETURNS ROW TYPE OF t RETURN 1;
CREATE TABLE t (c INT KEY,c2 INT,UNIQUE (c2));

--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT ROW(COALESCE(f()),1)=ROW(1,1) AS eq;

--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT ROW(COALESCE(f()),1)=ROW(COALESCE(f()),1) AS eq;

--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT ROW(1, COALESCE(f()), 1)=ROW(1, COALESCE(f()), 1) AS eq;

DROP FUNCTION f;
DROP TABLE t;

--echo #
14 changes: 10 additions & 4 deletions sql/item_cmpfunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,16 @@ static int cmp_row_type(Item* item1, Item* item2)
return 1;
for (uint i=0; i<n; i++)
{
if (item2->element_index(i)->check_cols(item1->element_index(i)->cols()) ||
(item1->element_index(i)->result_type() == ROW_RESULT &&
cmp_row_type(item1->element_index(i), item2->element_index(i))))
Item *left_item= item1->element_index(i);
Item *right_item= item2->element_index(i);

if (right_item->check_cols(left_item->cols()))
return 1;

if (!(left_item->cmp_type() == ROW_RESULT &&
right_item->cmp_type() == ROW_RESULT) ||
(item1 == left_item || item2 == right_item) ||
cmp_row_type(left_item, right_item))
return 1;
}
return 0;
Expand Down Expand Up @@ -8129,4 +8136,3 @@ Item *Item_equal::multiple_equality_transformer(THD *thd, uchar *arg)
break;
}
}

Loading