Skip to content

Commit 4cfda7f

Browse files
committed
Bug #49445: Assertion failed: 0, file .\item_row.cc, line 55 with
fulltext search and row op. The search for fulltext indexes is searching for some special predicate layouts. While doing so it's not checking for the number of columns of the expressions it tries to calculate. And since row expressions can't return a single scalar value there was a crash. Fixed by checking if the expressions are scalar (in addition to being constant) before calling Item::val_xxx() methods.
1 parent 632cf4c commit 4cfda7f

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

mysql-test/r/fulltext.result

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,4 +603,12 @@ WHERE t3.a=t1.a AND MATCH(b2) AGAINST('scargill' IN BOOLEAN MODE)
603603
count(*)
604604
0
605605
DROP TABLE t1,t2,t3;
606+
#
607+
# Bug #49445: Assertion failed: 0, file .\item_row.cc, line 55 with
608+
# fulltext search and row op
609+
#
610+
CREATE TABLE t1(a CHAR(1),FULLTEXT(a));
611+
SELECT 1 FROM t1 WHERE MATCH(a) AGAINST ('') AND ROW(a,a) > ROW(1,1);
612+
1
613+
DROP TABLE t1;
606614
End of 5.1 tests

mysql-test/t/fulltext.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,4 +545,14 @@ SELECT count(*) FROM t1 WHERE
545545
DROP TABLE t1,t2,t3;
546546

547547

548+
--echo #
549+
--echo # Bug #49445: Assertion failed: 0, file .\item_row.cc, line 55 with
550+
--echo # fulltext search and row op
551+
--echo #
552+
553+
CREATE TABLE t1(a CHAR(1),FULLTEXT(a));
554+
SELECT 1 FROM t1 WHERE MATCH(a) AGAINST ('') AND ROW(a,a) > ROW(1,1);
555+
DROP TABLE t1;
556+
557+
548558
--echo End of 5.1 tests

sql/sql_select.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3650,20 +3650,20 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
36503650
cond_func=(Item_func_match *)cond;
36513651
else if (func->arg_count == 2)
36523652
{
3653-
Item_func *arg0=(Item_func *)(func->arguments()[0]),
3654-
*arg1=(Item_func *)(func->arguments()[1]);
3655-
if (arg1->const_item() &&
3653+
Item *arg0= func->arguments()[0],
3654+
*arg1= func->arguments()[1];
3655+
if (arg1->const_item() && arg1->cols() == 1 &&
36563656
((functype == Item_func::GE_FUNC && arg1->val_real() > 0) ||
3657-
(functype == Item_func::GT_FUNC && arg1->val_real() >=0)) &&
3658-
arg0->type() == Item::FUNC_ITEM &&
3659-
arg0->functype() == Item_func::FT_FUNC)
3660-
cond_func=(Item_func_match *) arg0;
3661-
else if (arg0->const_item() &&
3657+
(functype == Item_func::GT_FUNC && arg1->val_real() >= 0)) &&
3658+
arg0->type() == Item::FUNC_ITEM &&
3659+
((Item_func *) arg0)->functype() == Item_func::FT_FUNC)
3660+
cond_func= (Item_func_match *) arg0;
3661+
else if (arg0->const_item() && arg0->cols() == 1 &&
36623662
((functype == Item_func::LE_FUNC && arg0->val_real() > 0) ||
3663-
(functype == Item_func::LT_FUNC && arg0->val_real() >=0)) &&
3664-
arg1->type() == Item::FUNC_ITEM &&
3665-
arg1->functype() == Item_func::FT_FUNC)
3666-
cond_func=(Item_func_match *) arg1;
3663+
(functype == Item_func::LT_FUNC && arg0->val_real() >= 0)) &&
3664+
arg1->type() == Item::FUNC_ITEM &&
3665+
((Item_func *) arg1)->functype() == Item_func::FT_FUNC)
3666+
cond_func= (Item_func_match *) arg1;
36673667
}
36683668
}
36693669
else if (cond->type() == Item::COND_ITEM)

0 commit comments

Comments
 (0)