diff options
-rw-r--r-- | mysql-test/r/type_date.result | 21 | ||||
-rw-r--r-- | mysql-test/t/type_date.test | 20 | ||||
-rw-r--r-- | sql/item.h | 5 |
3 files changed, 46 insertions, 0 deletions
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index f96e07b0c5e..dab1d78ba27 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -275,4 +275,25 @@ select * from t1 where a between '0000-00-01' and '0000-00-02'; a 0000-00-01 drop table t1; +# +# Bug#50918: Date columns treated differently in Views than in Base +# Tables +# +CREATE TABLE t1 ( the_date DATE, the_time TIME ); +INSERT INTO t1 VALUES ( '2010-01-01', '01:01:01' ); +SELECT * FROM t1 t11 JOIN t1 t12 ON addtime( t11.the_date, t11.the_time ) = +addtime( t12.the_date, t12.the_time ); +the_date the_time the_date the_time +2010-01-01 01:01:01 2010-01-01 01:01:01 +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM t1 JOIN v1 ON addtime( t1.the_date, t1.the_time ) = +addtime( v1.the_date, v1.the_time ); +the_date the_time the_date the_time +2010-01-01 01:01:01 2010-01-01 01:01:01 +SELECT * FROM t1 JOIN v1 ON addtime( t1.the_date, t1.the_time ) = +addtime( cast(v1.the_date AS DATETIME), v1.the_time ); +the_date the_time the_date the_time +2010-01-01 01:01:01 2010-01-01 01:01:01 +DROP TABLE t1; +DROP VIEW v1; End of 5.1 tests diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index aec60bc2dee..899f912a5a5 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -246,4 +246,24 @@ insert into t1 values ('0000-01-01'), ('0000-00-01'), ('0001-01-01'); select * from t1 where a between '0000-00-01' and '0000-00-02'; drop table t1; +--echo # +--echo # Bug#50918: Date columns treated differently in Views than in Base +--echo # Tables +--echo # +CREATE TABLE t1 ( the_date DATE, the_time TIME ); +INSERT INTO t1 VALUES ( '2010-01-01', '01:01:01' ); + +SELECT * FROM t1 t11 JOIN t1 t12 ON addtime( t11.the_date, t11.the_time ) = + addtime( t12.the_date, t12.the_time ); + +CREATE VIEW v1 AS SELECT * FROM t1; +SELECT * FROM t1 JOIN v1 ON addtime( t1.the_date, t1.the_time ) = + addtime( v1.the_date, v1.the_time ); + +SELECT * FROM t1 JOIN v1 ON addtime( t1.the_date, t1.the_time ) = + addtime( cast(v1.the_date AS DATETIME), v1.the_time ); + +DROP TABLE t1; +DROP VIEW v1; + --echo End of 5.1 tests diff --git a/sql/item.h b/sql/item.h index 34416feeb21..d2303853743 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2320,6 +2320,11 @@ public: if (ref && result_type() == ROW_RESULT) (*ref)->bring_value(); } + bool get_time(MYSQL_TIME *ltime) + { + DBUG_ASSERT(fixed); + return (*ref)->get_time(ltime); + } }; |