Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.2.7, 10.2(EOL)
-
Windows 2008R2 64 Bit und Windows 7 64 Bit
Description
In some cases (see attached files for two simple examples) an SQL query with PREPARE gives me an error message instead of a result set. I think this queries should work and if I execute the exact same queries on MySQL 5.7.18 (subselect example) or MySQL 8.0.2 (subselect and CTE examples) it is working fine and as excepted. So I think there may be an Bug with MariaDB?
This occurs only with PREPARE. If I'm running this directly (without PREPARE) it is working fine too with MariaDB.
If I change the "max(1)" to "ceil(1)" in my subselect example it is working fine altogether (PREPARE and MariaDB).
The error messages are included in the examples.
It would be nice if you can double check my examples and maybe fix it in a future version?
Attachments
Issue Links
- relates to
-
MDEV-13753 CTE is not visible during view creation
-
- Closed
-
Thanks for the report and test cases.
With 10.1, neither of the queries is expected to work anyway, so I'm removing it from the affected versions; but with 10.2, both should work, so it appears to be a bug indeed.
Here are the test cases from the attachments (for convenience):
Subquery with MAX
CREATE OR REPLACE VIEW testview AS
SELECT * FROM (
SELECT CASE WHEN 1 IN (SELECT MAX(1)) THEN TRUE END AS testcase
) testalias
MariaDB [test]> SELECT * FROM testview;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '<in_optimizer>(1,<exists>(select max(1))) then 1 end AS `testcase`) `testalias`' at line 1
CTE
CREATE OR REPLACE VIEW cte_test AS
WITH cte1 AS ( SELECT 1 )
, cte2 AS ( SELECT * FROM cte1 )
SELECT * FROM cte2;
MariaDB [test]> PREPARE stmt FROM @sql_query;
ERROR 1146 (42S02): Table 'test.cte1' doesn't exist