suche 36x36
Latest versionsfixlist
11.1.0.7 FixList
10.5.0.9 FixList
10.1.0.6 FixList
9.8.0.5 FixList
9.7.0.11 FixList
9.5.0.10 FixList
9.1.0.12 FixList
Have problems? - contact us.
Register for free anmeldung-x26
Contact form kontakt-x26

DB2 - Problem description

Problem IT17587 Status: Closed

INCORRECTLY GENERATED DERIVED PREDICATES MIGHT CAUSE INCORRECT QUERY
RESULTS DUE TO TRAILING BLANKS

product:
DB2 FOR LUW / DB2FORLUW / 970 - DB2
Problem description:
A derived predicate based on a generated column that includes
the concatenation of a VARCHAR or VARGRAPHIC column to some
other column or expression, could result in incorrect results if
some of the data in the VARCHAR or VARGRAPHIC column has
trailing blanks.

For example:

drop table t1;
create table t1 (
c1 varchar(5) not null,
c2 varchar(5) not null,
c3 int,
mc1 varchar(10) generated always as (c1||c2));

create index t1_i1 on t1 (mc1);

insert into t1 (c1,c2,c3) values
('AAA','BBB',1),
('AAA ','BBB',2);

select * from t1 where c1 = 'AAA' and c2 = 'BBB';

Query results:

db2 => select * from t1 where c1 = 'AAA' and c2 = 'BBB';

C1    C2    C3          MC1
----- ----- ----------- ----------
AAA   BBB             1 AAABBB

  1 record(s) selected.

db2 => drop index t1_i1;
DB20000I  The SQL command completed successfully.
db2 => select * from t1 where c1 = 'AAA' and c2 = 'BBB';

C1    C2    C3          MC1
----- ----- ----------- ----------
AAA   BBB             1 AAABBB
AAA   BBB             2 AAA BBB

  2 record(s) selected.

The problem is that the derived predicate is: MC1='AAABBB' which
misses the C1 values with 'AAA' that have trailing blanks.

The problem occurs for an index scan using an index the includes
the generated column, where the derived predicate is applied as
a start or stop key. A table scan doesn't have this issue
because the original predicates are applied instead of the
derived predicate. However, it is possible for the problem to
occur for a table scan of a range partition table because
partitions could be incorrectly eliminated based on the derived
predicate, which could also lead to incorrectly missing rows.
Problem Summary:
****************************************************************
* USERS AFFECTED:                                              *
* All                                                          *
****************************************************************
* PROBLEM DESCRIPTION:                                         *
* See Error Description                                        *
****************************************************************
* RECOMMENDATION:                                              *
* Upgrade to DB2 version 10.1 fix pack 6 or higher             *
****************************************************************
Local Fix:
For tables that aren't range partitioned, drop the index that
includes the generated column. For range partitioned tables,
change the definition of the generated column to avoid
concatenating a VARCHAR or VARGRAPHIC column that might contain
duplicate values that differ only by the number of trailing
blanks.
Solution
Workaround
not known / see Local fix
BUG-Tracking
forerunner  : 
follow-up : IT18019 IT18020 IT18021 
Timestamps
Date  - problem reported    :
Date  - problem closed      :
Date  - last modified       :
19.10.2016
31.01.2017
31.07.2017
Problem solved at the following versions (IBM BugInfos)
Problem solved according to the fixlist(s) of the following version(s)