Bug #31014 | NOW()+0 and CURTIME()+0 casts to a DOUBLE with 6 decimals | ||
---|---|---|---|
Submitted: | 14 Sep 2007 4:12 | Modified: | 30 Nov 2007 16:46 |
Reporter: | Tobias Asplund | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Documentation | Severity: | S3 (Non-critical) |
Version: | 5.0.45 | OS: | MacOS |
Assigned to: | Paul DuBois | CPU Architecture: | Any |
[14 Sep 2007 4:12]
Tobias Asplund
[14 Sep 2007 4:50]
Valeriy Kravchuk
Thank you for a bug report. Verified just as described: mysql> create view cd as select curdate()+0 a, now()+0 as b; Query OK, 0 rows affected (0.03 sec) mysql> desc cd; +-------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+-------+ | a | double(17,0) | NO | | 0 | | | b | double(23,6) | YES | | NULL | | +-------+--------------+------+-----+---------+-------+ 2 rows in set (0.00 sec) mysql> select now()+0; +-----------------------+ | now()+0 | +-----------------------+ | 20070914074732.000000 | +-----------------------+ 1 row in set (0.00 sec) Note that above is not only inconsistent, but also clearly contradictory to the manual (http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_now): "Returns the current date and time as a value in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context. The value is expressed in the current time zone. mysql> SELECT NOW(); -> '1997-12-15 23:50:26' mysql> SELECT NOW() + 0; -> 19971215235026"
[22 Oct 2007 14:44]
Timour Katchaounov
According to Joro this is not a bug because the manual says that arithmetic operations between non-integer types convert their arguments to double. I only found this: "If you are using a string in an arithmetic operation, this is converted to a floating-point number." here: http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html
[20 Nov 2007 14:31]
Martin Hansson
After discussion with Tobias Asplund, I believe that this is not a bug but the manual needs updating.
[30 Nov 2007 16:46]
Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.