Icon View Incident Report

Serious Serious
Reported By: Piotr Front
Reported On: 8/24/2010
For: Version 2.04 Build 1
# 3300 Queries that Mix INNER and LEFT OUTER JOINs May Return Incorrect Results without NOJOINOPTIMIZE

We have one query which have different results depending on use NOJOINOPTIMIZE or not.


SELECT
   fx.FileId,             
   ax.ApplicationTemplateId,
   ftx.FileTemplateID,
   ax.ApplicationID,
   fdx."Name" fdxName,
   ftx."Name" ftxName,
   fdx."Version" fdxVer,
   ftx."Version" ftxVer,             
   fdx."Description" fdxDescr,
   ftx."Description" ftxDescr,
   cdx."Name" cdxName,
   ftx.Company ftxCompany,
   fdx.OriginalFileName fdxOFName,
   ftx.OriginalFileName ftxOFName
FROM
   File fx
LEFT JOIN
   FileDictionary fdx ON (fdx.FileDictionaryId = fx.FileDictionaryId)
LEFT JOIN
   CompanyDictionary cdx ON (fdx.CompanyDictionaryID = cdx.CompanyDictionaryId)
INNER JOIN
   Application ax ON (ax.NodeId = 2 AND ax.ApplicationId = fx.ApplicationId)
LEFT JOIN
   FileTemplate ftx ON (
       ftx.TemplateId = ax.ApplicationTemplateId AND
       (
         (ftx."Name"='*' OR (ftx."Name"<>'' AND fdx."Name" LIKE REPLACE('*' WITH '%' IN ftx."Name") )) OR
         (ftx."Version"='*' OR (ftx."Version"<>'' AND fdx."Version" LIKE REPLACE('*' WITH '%' IN ftx."Version") )) OR
         (ftx."Description"='*' OR (ftx."Description"<>'' AND fdx."Description" LIKE REPLACE('*' WITH '%' IN ftx."Description") )) OR
         (ftx.Company='*' OR (ftx.Company<>'' AND cdx."Name" LIKE REPLACE('*' WITH '%' IN ftx.Company) )) OR
         (ftx.OriginalFileName='*' OR (ftx.OriginalFileName<>'' AND fdx.OriginalFileName LIKE REPLACE('*' WITH '%' IN ftx.OriginalFileName) ))
       )
   )
WHERE
   fx.NodeId = 2
   AND fdx."Name" = 'Uninstall.exe'
   AND fx.Deleted = false
   AND ftx.FileTemplateId IS NOT NULL



Comments Comments
The problem was that the join optimization code in the query optimizer was not putting the table joins back in the exact same order after it tried to re-order the joins and didn't succeed in finding a more optimal join ordering. Normally this isn't an issue, but with mixed OUTER and INNER JOINs, this can pose a problem.


Resolution Resolution
Fixed Problem on 8/28/2010 in version 2.04 build 2


Products Affected Products Affected
ElevateDB Additional Software and Utilities
ElevateDB DAC Client-Server
ElevateDB DAC Client-Server with Source
ElevateDB DAC Standard
ElevateDB DAC Standard with Source
ElevateDB DAC Trial
ElevateDB LCL Standard with Source
ElevateDB VCL Client-Server
ElevateDB VCL Client-Server with Source
ElevateDB VCL Standard
ElevateDB VCL Standard with Source
ElevateDB VCL Trial

Image