From 72bb9b7acbacc20172512184dc2724fccbc7a741 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Wed, 7 Jul 2010 10:00:46 +0400 Subject: [PATCH] Bug#52159 returning time type from function and empty left join causes debug assertion Problem: Item_copy did not set "fixed", which resulted in DBUG_ASSERT in some cases. Fix: adding initialization of the "fixed" member Adding tests: mysql-test/include/ctype_numconv.inc mysql-test/r/ctype_binary.result mysql-test/r/ctype_cp1251.result mysql-test/r/ctype_latin1.result mysql-test/r/ctype_ucs.result Adding initialization of the "fixed" member: sql/item.h --- mysql-test/include/ctype_numconv.inc | 19 +++++++++++++++++++ mysql-test/r/ctype_binary.result | 20 ++++++++++++++++++++ mysql-test/r/ctype_cp1251.result | 20 ++++++++++++++++++++ mysql-test/r/ctype_latin1.result | 20 ++++++++++++++++++++ mysql-test/r/ctype_ucs.result | 20 ++++++++++++++++++++ sql/item.h | 1 + 6 files changed, 100 insertions(+) diff --git a/mysql-test/include/ctype_numconv.inc b/mysql-test/include/ctype_numconv.inc index be82f67b9f8..d6bfa23017e 100644 --- a/mysql-test/include/ctype_numconv.inc +++ b/mysql-test/include/ctype_numconv.inc @@ -1606,3 +1606,22 @@ drop function f1; --echo # End of WL#2649 Number-to-string conversions --echo # +--echo # +--echo # Bug#52159 returning time type from function and empty left join causes debug assertion +--echo # +CREATE FUNCTION f1() RETURNS TIME RETURN 1; +CREATE TABLE t1 (b INT); +INSERT INTO t1 VALUES (0); +SELECT f1() FROM t1 LEFT JOIN (SELECT 1 AS a FROM t1 LIMIT 0) AS d ON 1 GROUP BY a; +DROP FUNCTION f1; +DROP TABLE t1; + +SET NAMES latin1; +SET sql_mode=''; +CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a)); +INSERT INTO t1 VALUES (); +--disable_warnings +SELECT maketime(`a`,`a`,`a`) FROM t1 GROUP BY 1; +--enable_warnings +DROP TABLE t1; +SET sql_mode=default; diff --git a/mysql-test/r/ctype_binary.result b/mysql-test/r/ctype_binary.result index 3ffb087c1d3..4b93e6533d7 100644 --- a/mysql-test/r/ctype_binary.result +++ b/mysql-test/r/ctype_binary.result @@ -2567,5 +2567,25 @@ drop function f1; # End of WL#2649 Number-to-string conversions # # +# Bug#52159 returning time type from function and empty left join causes debug assertion +# +CREATE FUNCTION f1() RETURNS TIME RETURN 1; +CREATE TABLE t1 (b INT); +INSERT INTO t1 VALUES (0); +SELECT f1() FROM t1 LEFT JOIN (SELECT 1 AS a FROM t1 LIMIT 0) AS d ON 1 GROUP BY a; +f1() +00:00:01 +DROP FUNCTION f1; +DROP TABLE t1; +SET NAMES latin1; +SET sql_mode=''; +CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a)); +INSERT INTO t1 VALUES (); +SELECT maketime(`a`,`a`,`a`) FROM t1 GROUP BY 1; +maketime(`a`,`a`,`a`) +00:00:00 +DROP TABLE t1; +SET sql_mode=default; +# # End of 5.5 tests # diff --git a/mysql-test/r/ctype_cp1251.result b/mysql-test/r/ctype_cp1251.result index e0339ee2109..869a84a34c9 100644 --- a/mysql-test/r/ctype_cp1251.result +++ b/mysql-test/r/ctype_cp1251.result @@ -2649,5 +2649,25 @@ drop function f1; # End of WL#2649 Number-to-string conversions # # +# Bug#52159 returning time type from function and empty left join causes debug assertion +# +CREATE FUNCTION f1() RETURNS TIME RETURN 1; +CREATE TABLE t1 (b INT); +INSERT INTO t1 VALUES (0); +SELECT f1() FROM t1 LEFT JOIN (SELECT 1 AS a FROM t1 LIMIT 0) AS d ON 1 GROUP BY a; +f1() +00:00:01 +DROP FUNCTION f1; +DROP TABLE t1; +SET NAMES latin1; +SET sql_mode=''; +CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a)); +INSERT INTO t1 VALUES (); +SELECT maketime(`a`,`a`,`a`) FROM t1 GROUP BY 1; +maketime(`a`,`a`,`a`) +00:00:00 +DROP TABLE t1; +SET sql_mode=default; +# # End of 5.5 tests # diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result index 4f0e863bfca..8dbd09741ff 100644 --- a/mysql-test/r/ctype_latin1.result +++ b/mysql-test/r/ctype_latin1.result @@ -2977,5 +2977,25 @@ drop function f1; # End of WL#2649 Number-to-string conversions # # +# Bug#52159 returning time type from function and empty left join causes debug assertion +# +CREATE FUNCTION f1() RETURNS TIME RETURN 1; +CREATE TABLE t1 (b INT); +INSERT INTO t1 VALUES (0); +SELECT f1() FROM t1 LEFT JOIN (SELECT 1 AS a FROM t1 LIMIT 0) AS d ON 1 GROUP BY a; +f1() +00:00:01 +DROP FUNCTION f1; +DROP TABLE t1; +SET NAMES latin1; +SET sql_mode=''; +CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a)); +INSERT INTO t1 VALUES (); +SELECT maketime(`a`,`a`,`a`) FROM t1 GROUP BY 1; +maketime(`a`,`a`,`a`) +00:00:00 +DROP TABLE t1; +SET sql_mode=default; +# # End of 5.5 tests # diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 4f033d54043..892e893db4d 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -3808,6 +3808,26 @@ drop function f1; # # End of WL#2649 Number-to-string conversions # +# +# Bug#52159 returning time type from function and empty left join causes debug assertion +# +CREATE FUNCTION f1() RETURNS TIME RETURN 1; +CREATE TABLE t1 (b INT); +INSERT INTO t1 VALUES (0); +SELECT f1() FROM t1 LEFT JOIN (SELECT 1 AS a FROM t1 LIMIT 0) AS d ON 1 GROUP BY a; +f1() +00:00:01 +DROP FUNCTION f1; +DROP TABLE t1; +SET NAMES latin1; +SET sql_mode=''; +CREATE TABLE t1(a char(215) CHARACTER SET utf8 NOT NULL DEFAULT '', KEY(a)); +INSERT INTO t1 VALUES (); +SELECT maketime(`a`,`a`,`a`) FROM t1 GROUP BY 1; +maketime(`a`,`a`,`a`) +00:00:00 +DROP TABLE t1; +SET sql_mode=default; SET NAMES latin1; # # End of 5.5 tests diff --git a/sql/item.h b/sql/item.h index e18fa43037a..35a0e8373f2 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2791,6 +2791,7 @@ protected: cached_field_type= item->field_type(); cached_result_type= item->result_type(); unsigned_flag= item->unsigned_flag; + fixed= item->fixed; } public: