Casting dates and times into integers works differently in 5.1-micro

Bug #737458 reported by Philip Stoev
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MariaDB
Fix Released
Undecided
Sergei Golubchik

Bug Description

Casting and comparing dates and times into or to integers does not work in 5.1-micro as it works in mysql-5.1. For a timestamp "YYYY-MM-DD HH:MM:SS" , mysql-5.1 produces an integer YYYYMMDDHHMMSS whereas 5.1-micro produces just YYYY

test case

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (f1 TIME, f2 DATE, f3 DATETIME);
INSERT INTO t1 VALUES ('11:22:33','2011-12-13','2011-12-13 11:22:33');
SELECT CAST(f1 AS UNSIGNED), CAST(f2 AS UNSIGNED), CAST(f3 AS UNSIGNED) FROM t1;

5.1-micro returns:

+----------------------+----------------------+----------------------+
| CAST(f1 AS UNSIGNED) | CAST(f2 AS UNSIGNED) | CAST(f3 AS UNSIGNED) |
+----------------------+----------------------+----------------------+
| 11 | 2011 | 2011 |
+----------------------+----------------------+----------------------+

mysql-5.1 returns:

+----------------------+----------------------+----------------------+
| CAST(f1 AS UNSIGNED) | CAST(f2 AS UNSIGNED) | CAST(f3 AS UNSIGNED) |
+----------------------+----------------------+----------------------+
| 112233 | 20111213 | 20111213112233 |
+----------------------+----------------------+----------------------+

Related branches

Changed in maria:
milestone: none → 5.3
assignee: nobody → Sergei (sergii)
Changed in maria:
status: New → Fix Committed
Changed in maria:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.