MXS-1688 Handle ...INTERVAL N <unit>

"INTERVAL N <unit>" is now handled as an expression in itself and
as asuch will cause both statements such as

  "SELECT '2008-12-31 23:59:59' + INTERVAL 1 SECOND;"

and

  "select id from db2.t1 where DATE_ADD("2017-06-15", INTERVAL 10 DAY) < "2017-06-15";"

to be handled correctly. The compare test program contains some
heuristic checking, as the the embedded parser will in all cases
report date manipulation as the use of the add_date_interval()
function.
This commit is contained in:
Johan Wikman
2018-02-27 02:55:05 +02:00
parent b7cc793c40
commit 0c206ff428
2 changed files with 61 additions and 3 deletions

View File

@ -1948,10 +1948,10 @@ expr(A) ::= expr(X) BITAND|BITOR|LSHIFT|RSHIFT(OP) expr(Y).
expr(A) ::= expr(X) PLUS|MINUS(OP) expr(Y).
{spanBinaryExpr(&A,pParse,@OP,&X,&Y);}
%ifdef MAXSCALE
expr(A) ::= expr(X) PLUS|MINUS INTERVAL INTEGER id. {
expr(A) ::= INTERVAL INTEGER(X) id. {
// Here we could check that id is one of MICROSECOND, SECOND, MINUTE
// HOUR, DAY, WEEK, etc.
A=X;
spanExpr(&A, pParse, @X, &X);
}
%endif
expr(A) ::= expr(X) STAR|SLASH|REM(OP) expr(Y).