[MDEV-16930] Crash when VALUES in derived table contains expressions Created: 2018-08-09 Updated: 2018-08-27 Resolved: 2018-08-27 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Subquery, Server |
| Affects Version/s: | 10.3.7, 10.3.8 |
| Fix Version/s: | 10.3.10 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Markus Winand | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Linux (Ubuntu) |
||
| Description |
| Comments |
| Comment by Elena Stepanova [ 2018-08-09 ] | ||||||||||||||||||||||||||||||||||||
|
Thanks for the report! Reproducible as described.
| ||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2018-08-11 ] | ||||||||||||||||||||||||||||||||||||
|
We also have a problem here:
| ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2018-08-11 ] | ||||||||||||||||||||||||||||||||||||
|
I suspect that the last example is fine, or, at least, perfectly standard compliant. Not a problem. | ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2018-08-12 ] | ||||||||||||||||||||||||||||||||||||
|
Re commit 226138774a, I think VALUES(1,2,3) should produce the same result as SELECT 1,2,3. Same column names too. In particular:
| ||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2018-08-13 ] | ||||||||||||||||||||||||||||||||||||
|
Ok, the following
| ||||||||||||||||||||||||||||||||||||
| Comment by Markus Winand [ 2018-08-13 ] | ||||||||||||||||||||||||||||||||||||
|
I think the field names of table value constructors are implementation-dependent (I guess SQL-2:2016, 7.1, SR 5b applies). However, not accepting that query is a poor choice IMHO: SELECT * FROM (VALUES(2,2)) t; All other databases I tested accept it (if they support VALUES at all). Implementing E051-09 “Rename columns in the FROM clause” would, of course, also help here. That's anyway a gap to MySQL 8.0 | ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2018-08-13 ] | ||||||||||||||||||||||||||||||||||||
|
I've tried this on sqlfiddle. Both SELECT * FROM (SELECT 1,1) x and SELECT * FROM (VALUES(1,1)) x.
couldn't make this to work in Oracle ☹ So the conclusion so far is that SELECT 1,1 and VALUES (1,1) indeed behave identically. I'm not saying there should be a "Duplicate column" error, and you are right, names are implementation-dependent. I'm saying that SELECT 1,1 and VALUES (1,1) should behave identically. Perhaps both should automatically give different names to columns? | ||||||||||||||||||||||||||||||||||||
| Comment by Markus Winand [ 2018-08-13 ] | ||||||||||||||||||||||||||||||||||||
|
Oracle 18:
MySQL 8.0:
But.....
I think the "same behaviour" argument is also a bad one because you can work around the problem for the SELECT by naming the columns.
But VALUES itself doesn't offer a possibility to rename the implementation-defined column names. That's why feature E051-09 is super useful here, because then it would be easy to work around the problem if someone faces it. As of now, the only way (I can think of) to get it working in MariaDB is to use an WITH clause to assign column names:
I find that an overkill just for renaming system-assigned column names.
That would be in spec and useful. But probably an incompatible change. IMHO, the problem boils down to the fact that VALUES does not allow user-defined column names. Thus there is feature E051-09 — a mandatory one, btw. Adding that feature doesn't bring the risk of incompatible changes, allows to cope with that problem in a pretty easy way, closes a gap to MySQL 8.0, and, above all, is a perfect compliment to VALUES because it is the easiest way to rename the columns from a VALUES clause. | ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2018-08-14 ] | ||||||||||||||||||||||||||||||||||||
|
VALUES does not allow user-defined column names, indeed. Still, using
should work, right? Wouldn't that be a good solution that consistently works in all cases? At least until we'll implement better "implementation dependent" names that don't conflict automatically. | ||||||||||||||||||||||||||||||||||||
| Comment by Markus Winand [ 2018-08-15 ] | ||||||||||||||||||||||||||||||||||||
That's what I was trying to say all time long. It's E051-09 “Rename columns in the FROM clause”. | ||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2018-08-15 ] | ||||||||||||||||||||||||||||||||||||
|
Ah, I see. Then this is MDEV-16901 (which was originally reported only for VALUES as | ||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2018-08-16 ] | ||||||||||||||||||||||||||||||||||||
|
OK to push. | ||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2018-08-16 ] | ||||||||||||||||||||||||||||||||||||
|
Serg give gut idea about names from parser, will check it (do not push). | ||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2018-08-16 ] | ||||||||||||||||||||||||||||||||||||
|
revision-id: adaafcf5184375369c0c4b3ccb1e82e846024ef8 (mariadb-10.3.7-137-gadaafcf5184)
Give names to the value constructor columns as in SELECT-list. — | ||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2018-08-16 ] | ||||||||||||||||||||||||||||||||||||
|
Igor, please review my solution. | ||||||||||||||||||||||||||||||||||||
| Comment by Igor Babaev [ 2018-08-27 ] | ||||||||||||||||||||||||||||||||||||
|
This bug ultimately was fixed in 10.3 |