Internal error on UNION with CTE and ORDER BY FALSE
Details
| Detail name | Value |
|---|---|
| Changelog Number | 26960 |
| Type | Bug |
| Status | Resolved |
| Affected Versions | Exasol 7.1.0, Exasol 8.0.0, Exasol 8.29.0, Exasol 2025.1.0, Exasol 2025.2.0 |
| Fix Versions | Exasol 2026.1.0, Exasol 2025.2.1 |
| Resolution Date | 2026-03-20 |
Description
A query with the following conditions can crash:
- There is a UNION or UNION ALL.
- The first table operand has parentheses and a Common Table Expression (CTE, WITH clause).
- The last table operand has ORDER BY FALSE.
Example
-- Observed: The query fails with "Internal server error" ( WITH cte AS ( SELECT 1 AS c ) SELECT 1 ) UNION SELECT 1 ORDER BY FALSE;
Workaround
Wrap a select around the first table operand.
Before Improvement CHANGELOG: ORDER BY FALSE with table operators ORDER BY FALSE in table operators (UNION, UNION ALL, INTERSECT, EXCEPT) wasn’t allowed, so the original query shouldn’t have been crashing (“Internal Server Error”), but failing with error "order by object not found".
-- Observed: The query fails with the error "order by object not found".
SELECT *
FROM ( WITH cte AS ( SELECT 1 AS c )
SELECT 1 )
UNION
SELECT 1 ORDER BY FALSE;
Fix
The query succeeds.