Wrong data returned if a sub-query or a computed field refers to the base table in the ORDER BY clause [CORE3806] #4149
Labels
affect-version: 2.0.5
affect-version: 2.0.6
affect-version: 2.1.0
affect-version: 2.1.1
affect-version: 2.1.2
affect-version: 2.1.3
affect-version: 2.1.4
affect-version: 2.5.0
affect-version: 2.5.1
affect-version: 3.0 Initial
component: engine
fix-version: 2.5.2
fix-version: 3.0 Alpha 1
priority: major
qa: done successfully
type: bug
Submitted by: @dyemanov
Is related to QA497
Simplified test case:
create table t (col1 int, col2 int, col3 int);
insert into t values (100, 200, 300);
insert into t values (101, 201, 301);
insert into t values (102, 202, 302);
commit;
alter table t drop col1;
-- at this point we have data stored in format 1 but the current format is 2
select col2, col3
from t as t1
-- correct results
select col2, col3
from t as t1
where exists (select * from t as t2 order by t1.col2 )
-- wrong results: both columns return the same data
Key points to see the issue:
- storage format should differ from the current one
- inner query should have ORDER BY referencing to the base table
- base table should not have SORT plan
Regardless of how stupid such an ORDER BY clause may look, the engine should not return garbage.
Commits: fe01201 cfe3bd7 FirebirdSQL/fbt-repository@945bad5
The text was updated successfully, but these errors were encountered: