DB2 - Problembeschreibung
Problem IC82163 | Status: Geschlossen |
QUERY WITH CORRELATED SUBQUERY PREDICATE AND GROUP BY CLAUSE REFERENCING THE SAME COLUMNS MIGHT RETURN INCORRECT RESULTS | |
Produkt: | |
DB2 FOR LUW / DB2FORLUW / 950 - DB2 | |
Problembeschreibung: | |
If your query satisfies the following conditions, then the results returned might be incorrect: 1. There is a correlated subquery predicate that references the same column as the one correlated predicate within the subquery 2. There is a GROUP BY clause in the query that references the same column as in 1 For example, the following query could return incorrect results as it satisfies both conditions with respect to column T1.A select t1.a, count(*) from t1,t3 where t1.a=t3.a and t1.a = (select distinct t2.a from t2 where t2.a=t1.a) group by t1.a You can identify if the results are incorrect if the expected groups are collapsed into less groups than expected, or there are duplicates in the key columns in the result. For example, if the three tables from the example query above contained the following integer data: insert into t1 values (1,1),(2,2), (3,3), (4,4), (5,5), (6,6); insert into t2 values (1,1),(2,2), (3,3), (4,4), (5,5), (6,6); insert into t3 values (1,1),(2,2), (3,3), (4,4), (5,5), (6,6); the expected, correct result is to return 6 rows, each with a count of 1; however if you encounter this defect, executing the query will produce a single row with any one of the 6 integer values and a corresponding count of 6. | |
Problem-Zusammenfassung: | |
**************************************************************** * USERS AFFECTED: * * ALL * **************************************************************** * PROBLEM DESCRIPTION: * * See Error Description * **************************************************************** * RECOMMENDATION: * * Update to DB2 v9.5 Fix Pack 10 * **************************************************************** | |
Local-Fix: | |
You can workaround this defect by modifying the query to change the subquery predicate to an EXISTS predicate, under the assumption that the correlated subquery returns a single value for each correlation value. Using the example in the description, the following rewrite to an EXISTS predicate will produce correct results: select t1.a, count(*) from t1,t3 where t1.a=t3.a and exists (select 1 from t2 where t2.a=t1.a) group by t1.a | |
Lösung | |
Update to DB2 v9.5 Fix Pack 10 | |
Workaround | |
keiner bekannt / siehe Local-Fix | |
Weitere Daten | |
Datum - Problem gemeldet : Datum - Problem geschlossen : Datum - der letzten Änderung: | 21.03.2012 28.08.2012 28.08.2012 |
Problem behoben ab folgender Versionen (IBM BugInfos) | |
9.5.FP10 | |
Problem behoben lt. FixList in der Version | |
9.5.0.10 |