summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-01-14 15:23:10 +0400
committerAlexander Barkov <bar@mariadb.com>2019-01-14 15:23:10 +0400
commitd97a26a67dca82d166e9edefe5f950ea8a110dfd (patch)
tree5f03eb7a6d55d781ca9c2adab60c99b2f0bfb3bf
parentac9b818c241cf59adbe3e9bd8d252736d23c671f (diff)
downloadmariadb-git-d97a26a67dca82d166e9edefe5f950ea8a110dfd.tar.gz
MDEV-18145 Assertion `0' failed in Item::val_native upon SELECT subquery with timestamp
-rw-r--r--mysql-test/main/type_timestamp.result12
-rw-r--r--mysql-test/main/type_timestamp.test11
-rw-r--r--sql/item_subselect.cc4
3 files changed, 25 insertions, 2 deletions
diff --git a/mysql-test/main/type_timestamp.result b/mysql-test/main/type_timestamp.result
index 70e55f2d595..c2af8952f4f 100644
--- a/mysql-test/main/type_timestamp.result
+++ b/mysql-test/main/type_timestamp.result
@@ -1152,5 +1152,17 @@ f
NULL
DROP TABLE t1;
#
+# MDEV-18145 Assertion `0' failed in Item::val_native upon SELECT subquery with timestamp
+#
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+CREATE TABLE t2 (pk INT PRIMARY KEY) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1),(2);
+CREATE TABLE t3 (pk INT PRIMARY KEY, b TIMESTAMP) ENGINE=MyISAM;
+SELECT ( SELECT b FROM t1 LIMIT 1 ) AS sq FROM t2 LEFT JOIN t3 USING (pk);
+sq
+NULL
+NULL
+DROP TABLE t1, t2, t3;
+#
# End of 10.4 tests
#
diff --git a/mysql-test/main/type_timestamp.test b/mysql-test/main/type_timestamp.test
index c4eef11279f..8b64fe0bfc3 100644
--- a/mysql-test/main/type_timestamp.test
+++ b/mysql-test/main/type_timestamp.test
@@ -749,6 +749,17 @@ INSERT INTO t1 () VALUES (),();
SELECT IF(0,t,NULL) AS f FROM t1 GROUP BY 'foo';
DROP TABLE t1;
+--echo #
+--echo # MDEV-18145 Assertion `0' failed in Item::val_native upon SELECT subquery with timestamp
+--echo #
+
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+CREATE TABLE t2 (pk INT PRIMARY KEY) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1),(2);
+CREATE TABLE t3 (pk INT PRIMARY KEY, b TIMESTAMP) ENGINE=MyISAM;
+SELECT ( SELECT b FROM t1 LIMIT 1 ) AS sq FROM t2 LEFT JOIN t3 USING (pk);
+DROP TABLE t1, t2, t3;
+
--echo #
--echo # End of 10.4 tests
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 9c0fd057d0f..0ace59fd2fc 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -1084,7 +1084,7 @@ void Item_maxmin_subselect::no_rows_in_result()
*/
if (parsing_place != SELECT_LIST || const_item())
return;
- value= (new (thd->mem_root) Item_null(thd))->get_cache(thd);
+ value= get_cache(thd);
null_value= 0;
was_values= 0;
make_const();
@@ -1102,7 +1102,7 @@ void Item_singlerow_subselect::no_rows_in_result()
*/
if (parsing_place != SELECT_LIST || const_item())
return;
- value= (new (thd->mem_root) Item_null(thd))->get_cache(thd);
+ value= get_cache(thd);
reset();
make_const();
}