Bug #21791 BC break (SELECT now()+0)
Submitted: 23 Aug 2006 6:08 Modified: 23 Aug 2006 17:29
Reporter: Georg Richter Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.25, 4.1, 5.1 OS:Linux (Linux, WIndows)
Assigned to: Assigned Account CPU Architecture:Any

[23 Aug 2006 6:08] Georg Richter
Description:
In 5.0.19 select now+0 returned a number without decimal digits, while in 5.0.25 it returns a decimal point and decimal digits.

This breaks BC and applications which fetch the result via prepared statements will get a truncation error.

How to repeat:
root@(none)>select version();
+-----------+
| version() |
+-----------+
| 5.0.19    |
+-----------+
1 row in set (0.00 sec)

root@(none)>select cast(now()+0 as char);
+-----------------------+
| cast(now()+0 as char) |
+-----------------------+
| 20060823080600        |
+-----------------------+
1 row in set (0.00 sec)

----------------------------------------------
mysql> select version();
+------------+
| version()  |
+------------+
| 5.0.25-log |
+------------+
1 row in set (0.45 sec)

mysql> select cast(now()+0 as char);
+-----------------------+
| cast(now()+0 as char) |
+-----------------------+
| 20060823080139.000000 |
+-----------------------+
1 row in set (0.09 sec)
[23 Aug 2006 10:01] Sveta Smirnova
Verified as described since 5.0.23, 5.1.12:

$bin/mysql --socket=/tmp/mysql.sock -uroot
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.23-max

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>
mysql> select cast(now()+0 as char);
+-----------------------+
| cast(now()+0 as char) |
+-----------------------+
| 20060823114507.000000 |
+-----------------------+
1 row in set (0.01 sec)

mysql> \q
Bye
[23 Aug 2006 17:16] Peter Laursen
This is a dublicate I think:
http://bugs.mysql.com/bug.php?id=16546
[23 Aug 2006 17:29] Sveta Smirnova
Marked as duplicate of bug #16546 as Peter Laursen pointed me.
[23 Aug 2006 17:31] Sveta Smirnova
Thank you, Peter, for the point. I think you are right.