Skip to content

Commit 20089f5

Browse files
author
Alexander Barkov
committed
MDEV-14596 Crash in INTERVAL(ROW(..),ROW(..))
1 parent ac61a57 commit 20089f5

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

mysql-test/r/func_set.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,12 @@ NULL
220220
1,2,3,4,5,6,7
221221

222222
DROP TABLE t1;
223+
#
224+
# MDEV-14596 Crash in INTERVAL(ROW(..),ROW(..))
225+
#
226+
SELECT INTERVAL(ROW(1,1),ROW(1,2));
227+
ERROR 21000: Operand should contain 1 column(s)
228+
SELECT INTERVAL(1,ROW(1,2));
229+
ERROR 21000: Operand should contain 1 column(s)
230+
SELECT INTERVAL(ROW(1,2),1);
231+
ERROR 21000: Operand should contain 1 column(s)

mysql-test/t/func_set.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,14 @@ SELECT * FROM t1 WHERE FIND_IN_SET(NULL, NULL) IS UNKNOWN;
136136

137137
--echo
138138
DROP TABLE t1;
139+
140+
--echo #
141+
--echo # MDEV-14596 Crash in INTERVAL(ROW(..),ROW(..))
142+
--echo #
143+
144+
--error ER_OPERAND_COLUMNS
145+
SELECT INTERVAL(ROW(1,1),ROW(1,2));
146+
--error ER_OPERAND_COLUMNS
147+
SELECT INTERVAL(1,ROW(1,2));
148+
--error ER_OPERAND_COLUMNS
149+
SELECT INTERVAL(ROW(1,2),1);

sql/item_cmpfunc.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,6 +2001,19 @@ bool Item_func_opt_neg::eq(const Item *item, bool binary_cmp) const
20012001
}
20022002

20032003

2004+
bool Item_func_interval::fix_fields(THD *thd, Item **ref)
2005+
{
2006+
if (Item_int_func::fix_fields(thd, ref))
2007+
return true;
2008+
for (uint i= 0 ; i < row->cols(); i++)
2009+
{
2010+
if (row->element_index(i)->check_cols(1))
2011+
return true;
2012+
}
2013+
return false;
2014+
}
2015+
2016+
20042017
void Item_func_interval::fix_length_and_dec()
20052018
{
20062019
uint rows= row->cols();

sql/item_cmpfunc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ class Item_func_interval :public Item_int_func
728728
{
729729
allowed_arg_cols= 0; // Fetch this value from first argument
730730
}
731+
bool fix_fields(THD *, Item **);
731732
longlong val_int();
732733
void fix_length_and_dec();
733734
const char *func_name() const { return "interval"; }

0 commit comments

Comments
 (0)