[MDEV-27086] "No database selected" when using UNION of CTEs to define table Created: 2021-11-19 Updated: 2022-02-24 Resolved: 2021-11-21 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer - CTE |
| Affects Version/s: | 10.3.31, 10.3.33, 10.2, 10.3 |
| Fix Version/s: | 10.2.42, 10.3.33 |
| Type: | Bug | Priority: | Major |
| Reporter: | Valerii Kravchuk | Assignee: | Igor Babaev |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | regression | ||
| Description |
|
Looks like we get unexpected "ERROR 1046 (3D000): No database selected" when we refer to CTEs in SELECT with UNION clause used to define the table with CREATE OR REPLACE TEMPORARY TABLE AS. Consider the following test case:
So, we have simple SELECT referring to CTEs in UNION that works and produced expected result. Now if we try to define a table based on it, we get the error:
Surely we can hide UNION in yet another CTE as a workaround:
and everything works as expected. But older 10.3.x versions (like 10.3.23) do NOT have this problem, and so I think we have a regression bug here. |
| Comments |
| Comment by Igor Babaev [ 2021-11-19 ] | ||
|
In a general case CREATE TABLE ... AS has the same problem in 10.2, 10.3:
| ||
| Comment by Oleksandr Byelkin [ 2021-11-20 ] | ||
|
8388a825ccd6c5ce093c79108e1111e1139cef4a OK to push | ||
| Comment by Igor Babaev [ 2021-11-21 ] | ||
|
A fix of this bug was pushed into 10.2. It is to be merged to 10.3 only. |