summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2020-10-16 14:32:14 +0200
committerSergei Golubchik <serg@mariadb.org>2020-10-23 15:53:41 +0200
commit8c83e6eadf496267762313d577653d56bf98d945 (patch)
tree6ebebf46804b0398b37238f9698d5fce95f60869
parent9ad4e0d6d8952b861848da95778e35cf3abc1b93 (diff)
downloadmariadb-git-8c83e6eadf496267762313d577653d56bf98d945.tar.gz
cleanup: remove redundant ADDINTERVAL_PRECEDENCE
expression between INTERVAL and the unit doesns not need any precedence rules, there's no ambiguity there
-rw-r--r--sql/item.h3
-rw-r--r--sql/item_timefunc.cc4
-rw-r--r--sql/item_timefunc.h2
3 files changed, 4 insertions, 5 deletions
diff --git a/sql/item.h b/sql/item.h
index 6c48d570203..604f656aa7a 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -87,7 +87,7 @@ enum precedence {
BITOR_PRECEDENCE, // |
BITAND_PRECEDENCE, // &
SHIFT_PRECEDENCE, // <<, >>
- ADDINTERVAL_PRECEDENCE, // first argument in +INTERVAL
+ INTERVAL_PRECEDENCE, // first argument in +INTERVAL
ADD_PRECEDENCE, // +, -
MUL_PRECEDENCE, // *, /, DIV, %, MOD
BITXOR_PRECEDENCE, // ^
@@ -95,7 +95,6 @@ enum precedence {
NEG_PRECEDENCE, // unary -, ~
BANG_PRECEDENCE, // !, NOT (if HIGH_NOT_PRECEDENCE)
COLLATE_PRECEDENCE, // BINARY, COLLATE
- INTERVAL_PRECEDENCE, // INTERVAL
DEFAULT_PRECEDENCE,
HIGHEST_PRECEDENCE
};
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 194933a4c54..a40c2e18b91 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -2250,9 +2250,9 @@ static const char *interval_names[]=
void Item_date_add_interval::print(String *str, enum_query_type query_type)
{
- args[0]->print_parenthesised(str, query_type, ADDINTERVAL_PRECEDENCE);
+ args[0]->print_parenthesised(str, query_type, INTERVAL_PRECEDENCE);
str->append(date_sub_interval?" - interval ":" + interval ");
- args[1]->print_parenthesised(str, query_type, INTERVAL_PRECEDENCE);
+ args[1]->print(str, query_type);
str->append(' ');
str->append(interval_names[int_type]);
}
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index f25fe3a551f..5c2c2ebe1ac 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -942,7 +942,7 @@ public:
bool get_date(MYSQL_TIME *res, ulonglong fuzzy_date);
bool eq(const Item *item, bool binary_cmp) const;
void print(String *str, enum_query_type query_type);
- enum precedence precedence() const { return ADDINTERVAL_PRECEDENCE; }
+ enum precedence precedence() const { return INTERVAL_PRECEDENCE; }
bool need_parentheses_in_default() { return true; }
Item *get_copy(THD *thd, MEM_ROOT *mem_root)
{ return get_item_copy<Item_date_add_interval>(thd, mem_root, this); }