Wrong results from UNION ALL with LIMIT and the first operand has WHERE FALSE

Details

Detail name Value
Changelog Number 27528
Type Bug
Status Resolved
Affected Versions Exasol 7.1.0, Exasol 8.0.0, Exasol 8.29.0, Exasol 2025.1.0
Fix Versions Exasol 2026.1.0, Exasol 2025.2.1
Resolution Date 2026-03-20

Description

If the first branch of a UNION ALL is a SELECT with a WHERE FALSE predicate and the UNION ALL has a LIMIT clause then the database can return wrong results.

Example

-- Setup
create table A as values between 10 and 20;
create table B as values between 10 and 20;
create table EMPTY as values between 1 and 0;

-- Expected/Observed: 5 rows returned
select * from A where RANGE_VALUE < 0 union all select * from B limit 5;

-- Expected/Observed: 5 rows returned 
select * from EMPTY union all select * from B limit 5;

-- Expected: 5 rows returned 
-- Observed: 10 rows returned
select * from A where false union all select * from B limit 5;

Workaround

Wrapping the first operand in a SELECT fixes the problem:

select * from (select * from A where false) union all select * from B limit 5;

Fix

Such queries return the correct result.