| Bug #69208 | A typo in sql_yacc.yy leads to possibility of creation valid nonsense queries | ||
|---|---|---|---|
| Submitted: | 13 May 2013 5:22 | Modified: | 20 May 2013 7:55 |
| Reporter: | Ivan Kurnosov | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: Parser | Severity: | S3 (Non-critical) |
| Version: | any | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[13 May 2013 6:07]
Valeriy Kravchuk
Even more complex expressions still work: mysql> select (1 between 1 and 2) between (1 between 1 and 5) and (5 between 5 and 10); +--------------------------------------------------------------------------+ | (1 between 1 and 2) between (1 between 1 and 5) and (5 between 5 and 10) | +--------------------------------------------------------------------------+ | 1 | +--------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> select (1 between 2 and 3) between (1 between 1 and 5) and (5 between 5 and 10); +--------------------------------------------------------------------------+ | (1 between 2 and 3) between (1 between 1 and 5) and (5 between 5 and 10) | +--------------------------------------------------------------------------+ | 0 | +--------------------------------------------------------------------------+ 1 row in set (0.00 sec) I wonder why do you consider them nonsense and (based on the above) I am not sure suggested change will help in any way.
[13 May 2013 6:57]
Ivan Kurnosov
@Valeriy Kravchuk oh right, didn't notice that. Indeed the proposed change wouldn't change the behaviour but will make a code and a grammar on the documentation page more clear and obvious (at least it won't . PS: now I'm finding it less nonsense, I agree it may be used in some weird and unreadable queries.
[20 May 2013 7:55]
MySQL Verification Team
Thank you for the report.

Description: On the expressions syntax documentation page (and in the sql_yacc.yy) the `predicate` definition for `BETWEEN` operator contains a typo. It should be bit_expr [NOT] BETWEEN bit_expr AND bit_expr instead of bit_expr [NOT] BETWEEN bit_expr AND predicate How to repeat: Run select 1 between 1 and 5 between 5 and 10; Suggested fix: | bit_expr BETWEEN_SYM bit_expr AND_SYM predicate perhaps needs to be replaced with | bit_expr BETWEEN_SYM bit_expr AND_SYM bit_expr The same for `not BETWEEN_SYM`