Icon View Incident Report

Serious Serious
Reported By: Jose Eduardo Helminsky
Reported On: 3/26/2004
For: Version 4.05 Build 1
# 1630 Using Filter Conditions in SQL JOIN Clause When Joins Can Be Optimized Can Produce Incorrect Results

The following SQL statement doesn't work anymore on v4. In version 3 and earlier it works fine. Now it results an empty dataset with any error.

It 
doesn't work:

select dat, emp, num, pro, sum(qtd) as qtd, sum(qtd*pre) as tot from hive
inner join hpev on (emp=hpev.emp and num=hpev.num and
hpev.sit='Encerrado' and hpev.ope='Venda' and
hive.dat >='2004-02-01' and hive.dat
<='2004-02-28')
group by emp,num,pro
order by dat

It works:
select dat, emp, num, pro, sum(qtd) as qtd, sum(qtd*pre) as tot from hive
inner join hpev on (emp=hpev.emp and num=hpev.num)
where hpev.sit='Encerrado' and hpev.ope='Venda' and
hive.dat >='2004-02-01' and hive.dat <='2004-02-28'
group by emp,num,pro
order by dat



Comments Comments and Workarounds
The problem was related to the way the conditions on the Hive table were handled in relation to the join optimization process. Basically the joins were re-arranged to be optimized when they shouldn't have been because of the non-join Hive conditions in the JOIN clause.


Resolution Resolution
Fixed Problem on 3/26/2004 in version 4.06 build 1
Image