Bug #38454 Precendence of INTERVAL expr unit is not documented
Submitted: 30 Jul 2008 11:54 Modified: 25 Apr 2012 8:36
Reporter: Kay Roepke Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Documentation Severity:S4 (Feature request)
Version:5.1 OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: Docs, parser, precedence

[30 Jul 2008 11:54] Kay Roepke
Description:
The documentation for DATE_ADD() [1] mentions that `INTERVAL expr unit` can be used in a plain expression.
Looking at the precedence table [2] there is no indication of the precedence of that expression, leaving the user to guess the precedence.

The YACC source file lists the precedence of the INTERVAL keyword as being the highest (with the associativity being LEFT). [3]

It's not entirely clear if you can nest `INTERVAL expr unit` expressions, even though the parser source seems to indicate it, this is an open question.

[1] http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add
[2] http://dev.mysql.com/doc/refman/5.1/en/operator-precedence.html
[3] relevant portion is:
"
%left   NEG '~'
%right  NOT_SYM NOT2_SYM
%right  BINARY COLLATE_SYM
%left  INTERVAL_SYM
"

How to repeat:
.

Suggested fix:
Add INTERVAL to the precedence table.
Figure out what the syntax for nesting INTERVAL expressions is, and if it is possible at all. If possible, give an example in DATE_ADD, if not note that as well.