summaryrefslogtreecommitdiff
path: root/sql/sql_yacc_ora.yy
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2018-05-14 11:36:22 +0400
committerAlexander Barkov <bar@mariadb.com>2018-05-14 11:36:22 +0400
commit4a5e23e257e229b548599133dbed5162af9df6d9 (patch)
tree0ea325f770c1c67b4162ef1702a9606b21528a67 /sql/sql_yacc_ora.yy
parent1cb4caa66d5fd2a9bc095d68988324b7b358d70f (diff)
downloadmariadb-git-4a5e23e257e229b548599133dbed5162af9df6d9.tar.gz
MDEV-16152 Expressions with INTERVAL return bad results in some cases
Diffstat (limited to 'sql/sql_yacc_ora.yy')
-rw-r--r--sql/sql_yacc_ora.yy26
1 files changed, 19 insertions, 7 deletions
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index a3e76c6b80a..18e1e5e9771 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -9526,6 +9526,25 @@ bit_expr:
if (unlikely($$ == NULL))
MYSQL_YYABORT;
}
+ | INTERVAL_SYM expr interval '+' expr %prec INTERVAL_SYM
+ /* we cannot put interval before - */
+ {
+ $$= new (thd->mem_root) Item_date_add_interval(thd, $5, $2, $3, 0);
+ if (unlikely($$ == NULL))
+ MYSQL_YYABORT;
+ }
+ | '+' INTERVAL_SYM expr interval '+' expr %prec NEG
+ {
+ $$= new (thd->mem_root) Item_date_add_interval(thd, $6, $3, $4, 0);
+ if (unlikely($$ == NULL))
+ MYSQL_YYABORT;
+ }
+ | '-' INTERVAL_SYM expr interval '+' expr %prec NEG
+ {
+ $$= new (thd->mem_root) Item_date_add_interval(thd, $6, $3, $4, 1);
+ if (unlikely($$ == NULL))
+ MYSQL_YYABORT;
+ }
| bit_expr '*' bit_expr %prec '*'
{
$$= new (thd->mem_root) Item_func_mul(thd, $1, $3);
@@ -9935,13 +9954,6 @@ simple_expr:
if (unlikely($$ == NULL))
MYSQL_YYABORT;
}
- | INTERVAL_SYM expr interval '+' expr %prec INTERVAL_SYM
- /* we cannot put interval before - */
- {
- $$= new (thd->mem_root) Item_date_add_interval(thd, $5, $2, $3, 0);
- if (unlikely($$ == NULL))
- MYSQL_YYABORT;
- }
;
/*