Icon View Incident Report

Serious Serious
Reported By: Mike Feran [Infortix Inc.]
Reported On: 7/29/2011
For: Version 2.05 Build 10
# 3479 INNER JOINs On Row Values That Contain Constants Can Cause Incorrect Results

I believe you have a serious problem returning incomplete/incorrect data sets when two inner joins are used.

The problem only appears when the server is configured with "Enable standard NULL behavior" checked. If this checkbox is not checked the return sets are correct. However, no tables in this example have any NULL values, so the result set returned should be identical checked or unchecked (at least the way I understand it).

After running the three steps described below, the result set for step three should contain 18 rows, but only contains 9. Interestingly, if you change t2.f1 to t1.f1 on the second INNER JOIN of step 3, 18 rows are returned as expected.

1) Create new database called dbtest
2) Run this script:

BEGIN

  declare  i integer;
  DECLARE   my_crs        CURSOR FOR my_stmt;
  DECLARE   my_crs2       CURSOR FOR my_stmt2;

  execute immediate 'CREATE TABLE "t1" (f1 integer, f2 integer)';
  execute immediate 'CREATE TABLE "t2" (f1 integer, f2 integer)';

  execute immediate '
CREATE TABLE "t_future_groups" ("f_group_number" integer ,"f_item_number" integer,
      CONSTRAINT "ix_mainkey" PRIMARY KEY ("f_group_number", "f_item_number")
) ';

  execute immediate '
     insert into dbtest.t_future_groups (f_group_number,f_item_number) values (1,5),(1,10)  
,(1,15),(1,20),(1,25),(1,30),(1,35),(1,40),(1,45),(1,50),(1,55),(1,60),(1,65),(1,70),(1,75),(1,80)
,(1,85),(1,90),(1,95),(1,100)     ';


   PREPARE my_stmt FROM  'insert into dbtest.t1 (f1,f2) values (?,?) ';
   PREPARE my_stmt2 FROM  'insert into dbtest.t2 (f1,f2) values (?,?) ';
   set i=1;
   repeat      
      EXECUTE my_stmt USING i,i;
      if i mod 50 <>0 then 
         EXECUTE my_stmt2 USING i,i;
      end if;
      set i=i+1;
   until i=501 end repeat;

END

3) Run this SQL statement:

select * from dbtest.t1 t1

INNER JOIN dbtest.t2 t2 ON  (t1.f1 = t2.f1)
  
inner JOIN dbtest.t_future_groups tfg ON
    ((tfg.f_group_number, tfg.f_item_number) = (1,t2.f1))

order by f1


   



Comments Comments and Workarounds
The problem was caused by the "1" constant in the row value used in the join. ElevateDB was not handling such a row value properly, and this was causing the incorrect results. The workaround is to use an ANDed set of conditions instead of row values for the join.


Resolution Resolution
Fixed Problem on 7/30/2011 in version 2.05 build 11


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 PHP Standard
ElevateDB PHP Standard with Source
ElevateDB PHP Trial
ElevateDB VCL Client-Server
ElevateDB VCL Client-Server with Source
ElevateDB VCL Standard
ElevateDB VCL Standard with Source
ElevateDB VCL Trial

Image