[MDEV-16981] INSERT INTO td SELECT now() WHERE 1=1 Works in 10.1, Fails in 10.2 and 10.3 Created: 2018-08-14 Updated: 2020-08-25 Resolved: 2018-09-12 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Parser |
| Affects Version/s: | 10.2.17, 10.3.8 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Chris Calender (Inactive) | Assignee: | Alexander Barkov |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Queries of the following type (auto-generated) work in MariaDB 10.1.33, but fail in 10.2.17 and 10.3.8:
It is common for the code to auto add the "WHERE 0=1" or "WHERE 1=1". 10.1:
In both 10.2 and 10.3, we see:
One strange thing about 10.1 is that the sub-query ("select now() where 1=1;") fails when issued by itself, but works when it is part of the INSERT INTO:
|
| Comments |
| Comment by Elena Stepanova [ 2018-08-24 ] | ||||||||
|
serg, | ||||||||
| Comment by Sergei Golubchik [ 2018-08-30 ] | ||||||||
|
WHERE without FROM never worked in SELECT. By some unintended parser glitch it worked in INSERT ... SELECT, in 10.2 in the course of parser refactoring or some bug fix this part of the grammar was unified, duplicated rules were removed and INSERT ... SELECT now uses the same grammar as SELECT. That's why WHERE without FROM stopped working. It was never supposed to work in the first place. But, really, I don't see a reason why it shouldn't work. So we'll try to allow this syntax if it won't negatively affect the rest of the grammar. | ||||||||
| Comment by Alexander Barkov [ 2018-09-12 ] | ||||||||
|
Discussed with Sergei again. According to the SQL standard, <where clause> is a part of <table expression>.
WHERE is not possible without FROM. We won't fix this. As a workaround, one can use LIMIT 1 and LIMIT 0 in auto-generated queries. |