summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-12-08 14:40:27 +0400
committerAlexander Barkov <bar@mariadb.org>2017-12-08 14:40:27 +0400
commit20089f5a39fa8f6f08113f12ed87c34e844c4fc6 (patch)
treedddecc6d443acd90e265b57c132cb5eb011b5767
parentac61a575dfff6b9510576be920a522c710732c0d (diff)
downloadmariadb-git-20089f5a39fa8f6f08113f12ed87c34e844c4fc6.tar.gz
MDEV-14596 Crash in INTERVAL(ROW(..),ROW(..))
-rw-r--r--mysql-test/r/func_set.result9
-rw-r--r--mysql-test/t/func_set.test11
-rw-r--r--sql/item_cmpfunc.cc13
-rw-r--r--sql/item_cmpfunc.h1
4 files changed, 34 insertions, 0 deletions
diff --git a/mysql-test/r/func_set.result b/mysql-test/r/func_set.result
index 9c4976d46db..ca1ccd71c90 100644
--- a/mysql-test/r/func_set.result
+++ b/mysql-test/r/func_set.result
@@ -220,3 +220,12 @@ NULL
1,2,3,4,5,6,7
DROP TABLE t1;
+#
+# MDEV-14596 Crash in INTERVAL(ROW(..),ROW(..))
+#
+SELECT INTERVAL(ROW(1,1),ROW(1,2));
+ERROR 21000: Operand should contain 1 column(s)
+SELECT INTERVAL(1,ROW(1,2));
+ERROR 21000: Operand should contain 1 column(s)
+SELECT INTERVAL(ROW(1,2),1);
+ERROR 21000: Operand should contain 1 column(s)
diff --git a/mysql-test/t/func_set.test b/mysql-test/t/func_set.test
index ba984113fd7..887b1948498 100644
--- a/mysql-test/t/func_set.test
+++ b/mysql-test/t/func_set.test
@@ -136,3 +136,14 @@ SELECT * FROM t1 WHERE FIND_IN_SET(NULL, NULL) IS UNKNOWN;
--echo
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-14596 Crash in INTERVAL(ROW(..),ROW(..))
+--echo #
+
+--error ER_OPERAND_COLUMNS
+SELECT INTERVAL(ROW(1,1),ROW(1,2));
+--error ER_OPERAND_COLUMNS
+SELECT INTERVAL(1,ROW(1,2));
+--error ER_OPERAND_COLUMNS
+SELECT INTERVAL(ROW(1,2),1);
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index ebe088e5092..62e76922c0e 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -2001,6 +2001,19 @@ bool Item_func_opt_neg::eq(const Item *item, bool binary_cmp) const
}
+bool Item_func_interval::fix_fields(THD *thd, Item **ref)
+{
+ if (Item_int_func::fix_fields(thd, ref))
+ return true;
+ for (uint i= 0 ; i < row->cols(); i++)
+ {
+ if (row->element_index(i)->check_cols(1))
+ return true;
+ }
+ return false;
+}
+
+
void Item_func_interval::fix_length_and_dec()
{
uint rows= row->cols();
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index a8befa47b95..7b7ca9223fd 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -728,6 +728,7 @@ public:
{
allowed_arg_cols= 0; // Fetch this value from first argument
}
+ bool fix_fields(THD *, Item **);
longlong val_int();
void fix_length_and_dec();
const char *func_name() const { return "interval"; }