I've encountered something which confuses me, but I'm not sure if it's a bug or just something I don't understand.
I'm looking at this file, https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_yacc.yy#L1169 https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_yacc.yy#L9300 https://github.com/mysql/mysql-server/blob/5c8c085ba96d30d697d0baa54d67b102c232116b/sql/sql_yacc.yy#L9582 Of note are, ``` %left EQ EQUAL_SYM GE GT_SYM LE LT NE IS LIKE REGEXP IN_SYM ... %left INTERVAL_SYM ... bool_pri: bool_pri IS NULL_SYM %prec IS ... simple_expr: | INTERVAL_SYM expr interval '+' expr %prec INTERVAL_SYM ``` >From the above snippet, it looks like the intention is for the `INTERVAL_SYM` >rule to have a higher precedence than the `IS NULL` rule. Given the input string `INTERVAL 0 DAY + NULL IS NULL`, there are two valid parse trees, ignoring precedence, + (INTERVAL 0 DAY + NULL) IS NULL + INTERVAL 0 DAY + (NULL IS NULL) If we include precedence, it seems we would want, + (INTERVAL 0 DAY + NULL) IS NULL The MySQL documentation seems to agree, https://dev.mysql.com/doc/refman/5.7/en/operator-precedence.html It shows that INTERVAL should have a higher precedence than IS. However, when I actually run this input against MySQL, ``` SELECT INTERVAL 0 DAY + NULL IS NULL, (INTERVAL 0 DAY + NULL) IS NULL, INTERVAL 0 DAY + (NULL IS NULL) ``` https://www.db-fiddle.com/f/cMPJfx5kZKoMeX4PKDrTWC/0 I find that IS NULL has higher precedence. Which is unexpected. Is this a bug with bison? Or am I misunderstanding something? I'm not sure what specific version of bison is being used but I found it should be 2.1+ https://dev.mysql.com/doc/refman/5.7/en/source-installation-prerequisites.html