Bug #33834 | FRAC_SECOND: Applicability not clear in documentation | ||
---|---|---|---|
Submitted: | 12 Jan 2008 15:43 | Modified: | 2 Apr 2008 17:39 |
Reporter: | Paul DuBois | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: General | Severity: | S3 (Non-critical) |
Version: | 5.0 and up | OS: | Any |
Assigned to: | Alexey Kopytov | CPU Architecture: | Any |
[12 Jan 2008 15:43]
Paul DuBois
[12 Jan 2008 15:47]
Paul DuBois
The grammar appears to allow FRAC_SECOND as a synonym for MICROSECOND: interval: interval_time_st {} | DAY_HOUR_SYM { $$=INTERVAL_DAY_HOUR; } | DAY_MICROSECOND_SYM { $$=INTERVAL_DAY_MICROSECOND; } | DAY_MINUTE_SYM { $$=INTERVAL_DAY_MINUTE; } | DAY_SECOND_SYM { $$=INTERVAL_DAY_SECOND; } | HOUR_MICROSECOND_SYM { $$=INTERVAL_HOUR_MICROSECOND; } | HOUR_MINUTE_SYM { $$=INTERVAL_HOUR_MINUTE; } | HOUR_SECOND_SYM { $$=INTERVAL_HOUR_SECOND; } | MICROSECOND_SYM { $$=INTERVAL_MICROSECOND; } | MINUTE_MICROSECOND_SYM { $$=INTERVAL_MINUTE_MICROSECOND; } | MINUTE_SECOND_SYM { $$=INTERVAL_MINUTE_SECOND; } | SECOND_MICROSECOND_SYM { $$=INTERVAL_SECOND_MICROSECOND; } | YEAR_MONTH_SYM { $$=INTERVAL_YEAR_MONTH; }; interval_time_st: DAY_SYM { $$=INTERVAL_DAY; } | WEEK_SYM { $$=INTERVAL_WEEK; } | HOUR_SYM { $$=INTERVAL_HOUR; } | FRAC_SECOND_SYM { $$=INTERVAL_MICROSECOND; } | MINUTE_SYM { $$=INTERVAL_MINUTE; } | MONTH_SYM { $$=INTERVAL_MONTH; } | QUARTER_SYM { $$=INTERVAL_QUARTER; } | SECOND_SYM { $$=INTERVAL_SECOND; } | YEAR_SYM { $$=INTERVAL_YEAR; } ; If that's so, the documentation needs updating. But I want that confirmed by a developer first.
[12 Jan 2008 16:11]
MySQL Verification Team
Thank you for the bug report.
[15 Feb 2008 11:50]
Alexey Kopytov
Currently the server accepts FRAC_SECOND as a synonym for MICROSECONDS in DATE_ADD(), DATE_SUB() and +/-INTERVAL. However, using MICROSECONDS in TIMESTAMPADD() is not allowed: mysql> SELECT TIMESTAMPADD(MICROSECOND,1,'2003-01-02'); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MICROSECOND,1,'2003-01-02')' at line 1 It would be easy to make FRAC_SECONDS and MICROSECONDS synonyms, i.e. to make it possible to use them in all context interchangeably. I don't see any reasons why it cannot be done, but it looks like a question for PeterG.
[15 Feb 2008 17:13]
Peter Gulutzan
MySQL tries to copy some ODBC functions including TIMESTAMPADD http://msdn2.microsoft.com/en-us/library/ms714639(VS.85).aspx but (a) in ODBC's TIMESTAMPADD, SQL_TSI_FRAC_SECOND is not a synonym for MICROSECOND, it is "billionths of a second". (b) SQL Server allows MICROSECOND and NANOSECOND for "date adding" http://msdn2.microsoft.com/en-us/library/ms186819(SQL.100).aspx (This is new in SQL Server 2008.) (c) In a DB2 "labeled duration" it's MICROSECOND or MICROSECONDS http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.s... ... therefore it appears that MySQL's FRAC_SECOND is a mistake, and the way of the future is to use MICROSECOND. I suggest that the use of FRAC_SECOND, for anything other than TIMESTAMPADD / TIMESTAMPDIFF, is a server error. It could be fixed by making FRAC_SECOND a synonym for MICROSECOND, and that would not be a violation of SQL standard requirements, but that would be a change to an existing feature. Let's not encourage FRAC_SECOND use by increasing its applicability.
[18 Feb 2008 13:41]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/42493 ChangeSet@1.2607, 2008-02-18 16:41:34+03:00, kaa@kaamos.(none) +3 -0 Fix for bug #33834: FRAC_SECOND: Applicability not clear in documentation While the manual mentions FRAC_SECOND only for the TIMESTAMPADD() function, it was also possible to use FRAC_SECOND with DATE_ADD(), DATE_SUB() and +/- INTERVAL. Fixed the parser to match the manual, i.e. using FRAC_SECOND for anything other than TIMESTAMPADD()/TIMESTAMPDIFF() now produces a syntax error.
[20 Feb 2008 14:25]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/42659 ChangeSet@1.2607, 2008-02-20 17:25:25+03:00, kaa@kaamos.(none) +3 -0 Fix for bug #33834: FRAC_SECOND: Applicability not clear in documentation While the manual mentions FRAC_SECOND only for the TIMESTAMPADD() function, it was also possible to use FRAC_SECOND with DATE_ADD(), DATE_SUB() and +/- INTERVAL. Fixed the parser to match the manual, i.e. using FRAC_SECOND for anything other than TIMESTAMPADD()/TIMESTAMPDIFF() now produces a syntax error.
[22 Feb 2008 9:22]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/42807 ChangeSet@1.2607, 2008-02-22 12:22:07+03:00, kaa@kaamos.(none) +3 -0 Fix for bug #33834: FRAC_SECOND: Applicability not clear in documentation While the manual mentions FRAC_SECOND only for the TIMESTAMPADD() function, it was also possible to use FRAC_SECOND with DATE_ADD(), DATE_SUB() and +/- INTERVAL. Fixed the parser to match the manual, i.e. using FRAC_SECOND for anything other than TIMESTAMPADD()/TIMESTAMPDIFF() now produces a syntax error. Additionally, the patch allows MICROSECOND to be used in TIMESTAMPADD/ TIMESTAMPDIFF and marks FRAC_SECOND as deprecated.
[25 Feb 2008 10:26]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/42926 ChangeSet@1.2607, 2008-02-25 13:25:57+03:00, kaa@kaamos.(none) +3 -0 Fix for bug #33834: FRAC_SECOND: Applicability not clear in documentation While the manual mentions FRAC_SECOND only for the TIMESTAMPADD() function, it was also possible to use FRAC_SECOND with DATE_ADD(), DATE_SUB() and +/- INTERVAL. Fixed the parser to match the manual, i.e. using FRAC_SECOND for anything other than TIMESTAMPADD()/TIMESTAMPDIFF() now produces a syntax error. Additionally, the patch allows MICROSECOND to be used in TIMESTAMPADD/ TIMESTAMPDIFF and marks FRAC_SECOND as deprecated.
[25 Feb 2008 13:03]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/42931 ChangeSet@1.2668, 2008-02-25 16:03:28+03:00, kaa@kaamos.(none) +2 -0 Post-merge fixes for bug #33834.
[26 Feb 2008 13:07]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/42985 ChangeSet@1.2810, 2008-02-26 16:06:58+03:00, kaa@kaamos.(none) +1 -0 Post-merge fixes for bug #33834.
[27 Feb 2008 15:12]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/43068 ChangeSet@1.2608, 2008-02-27 18:12:08+03:00, kaa@kaamos.(none) +1 -0 Fixed test suite failures with --ps-protocol introduced in PB by the patch for bug #33834.
[13 Mar 2008 19:29]
Bugs System
Pushed into 6.0.5-alpha
[13 Mar 2008 19:36]
Bugs System
Pushed into 5.1.24-rc
[13 Mar 2008 19:43]
Bugs System
Pushed into 5.0.60
[2 Apr 2008 17:39]
Jon Stephens
Documented in the 5.0.60, 5.1.23-ndb-6.3.11, 5.1.24, and 6.0.5 changelogs as follows: It was possible to use FRAC_SECOND as a synonym for MICROSECOND with DATE_ADD(), DATE_SUB(), and INTERVAL; now, using FRAC_SECOND with anything other than TIMESTAMPADD() or TIMESTAMPDIFF() produces a syntax error. In addition, FRAC_SECOND is now deprecated.
[4 Mar 2012 12:10]
MySQL Verification Team
And since 5.5.3, TIMESTAMPDIFF will not work with FRAC_SECOND anymore.