Skip to content

Commit 7865151

Browse files
committed
Bug#20035071: Out of range error in subselect lead to assertion failed
There is a missing error check during preparation of this query, so that we reach the regular function return in st_select_lex::prepare(). However, there has been an error when evaluating the LIKE predicate, which has gone unnoticed. The fix applies to Item_func_like::fix_fields(), check if the call to val_str() returns an error. However, the real fix should be to check for error in Item_real_func::val_str(). But since this function has no easily accessible THD reference, it's better to do it this way.
1 parent fc85236 commit 7865151

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

mysql-test/r/func_like.result

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,8 @@ SELECT * FROM t2 WHERE y LIKE 'abc%%' ESCAPE (SELECT 'c' FROM t1) ORDER BY y;
266266
x y
267267
2 ab%cde
268268
DROP TABLE t1, t2;
269+
# Bug#20035071: Out of range error in subselect lead to assertion failed
270+
CREATE TABLE t1(a INTEGER) engine=innodb;
271+
SELECT 1 FROM t1 HAVING (SELECT 1 FROM t1) LIKE EXP(NOW());
272+
ERROR 22003: DOUBLE value is out of range in 'exp(now())'
273+
DROP TABLE t1;

mysql-test/t/func_like.test

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,10 @@ eval EXPLAIN $query;
203203
eval $query;
204204

205205
DROP TABLE t1, t2;
206+
207+
--echo # Bug#20035071: Out of range error in subselect lead to assertion failed
208+
209+
CREATE TABLE t1(a INTEGER) engine=innodb;
210+
--error ER_DATA_OUT_OF_RANGE
211+
SELECT 1 FROM t1 HAVING (SELECT 1 FROM t1) LIKE EXP(NOW());
212+
DROP TABLE t1;

sql/item_cmpfunc.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6047,6 +6047,8 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref)
60476047
!(specialflag & SPECIAL_NO_NEW_FUNC))
60486048
{
60496049
String* res2 = args[1]->val_str(&cmp.value2);
6050+
if (thd->is_error())
6051+
return true;
60506052
if (!res2)
60516053
return false; // Null argument
60526054

0 commit comments

Comments
 (0)