DB2 - Problem description
Problem IC63414 | Status: Closed |
Outer join operation may return incorrect results with a predicate with a subquery returning not more than one row | |
product: | |
DB2 FOR LUW / DB2FORLUW / 950 - DB2 | |
Problem description: | |
The problem occurs if all and each of the following conditions are met: 1. There is an OUTER JOIN operation. 2. There is a WHERE-clause applied to the OUTER JOIN. 3. The WHERE-clause contains a scalar subquery (subquery that is required to return not more than one row). 4. The subquery has an index or operation which will return either one or zero row. 5. The subquery is part of an OR operator. 6. The actual data results in the subquery returning zero row. 7. The other part of the OR operator returns not more than one row. This problem was first introduced in the following DB2 releases: Version 9.1 Fix Pack 7 Version 9.5 Fix Pack 4 Version 9.7 GA Example: create table T2(c1 int not null primary key, c2 int) create table T3(c1 int not null primary key) insert into T2 values(1,1) insert into T3 values(9) select t2.c1 from t2 left join t3 on t2.c2=t3.c1 where t2.c1 = 1 or t2.c1 = (select c1 from t2 where c1=11) The correct result should return one row. C1 ----------- 1 1 record(s) selected. The SQL statement meets all the conditions described above. It has an OUTER JOIN (1) and a WHERE-clause (2). The WHERE-clause contains a scalar subquery (3) which is a part of an OR operator (5). The presence of the PRIMARY key (or a unique index) on column T2.C1 ensures that the subquery will either return one row or zero row (4). In addition, the actual data set results in the subquery does not return any row (6) and the other part of the OR operator, t2.c1=1, returns one row (7). | |
Problem Summary: | |
**************************************************************** * USERS AFFECTED: * * Incorrect rows returned. * **************************************************************** * PROBLEM DESCRIPTION: * * See problem description. * **************************************************************** * RECOMMENDATION: * * Upgrade to DB2 UDB version 9.5 Fix Pack 5. * **************************************************************** | |
Local Fix: | |
Upgrade the DB2 Version to one of the following DB2 releases: Version 9.1 Fix Pack 9 Version 9.5 Fix Pack 5 Version 9.7 Fix Pack 1 | |
available fix packs: | |
DB2 Version 9.5 Fix Pack 5 for Linux, UNIX, and Windows | |
Solution | |
Problem was first fixed in Version 9.5 Fix Pack 5. | |
Workaround | |
not known / see Local fix | |
BUG-Tracking | |
forerunner : APAR is sysrouted TO one or more of the following: IC63415 IZ62236 follow-up : | |
Timestamps | |
Date - problem reported : Date - problem closed : Date - last modified : | 24.09.2009 09.02.2010 09.02.2010 |
Problem solved at the following versions (IBM BugInfos) | |
9.5.FP5 | |
Problem solved according to the fixlist(s) of the following version(s) | |
9.5.0.5 |