IBM Support

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

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error 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.
    

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.
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:                                              *
    * ALL                                                          *
    ****************************************************************
    * PROBLEM DESCRIPTION:                                         *
    * See Error Description                                        *
    ****************************************************************
    * RECOMMENDATION:                                              *
    * Upgrade to DB2 11.1 Mod 2 Fix Pack 2 or higher               *
    ****************************************************************
    

Problem conclusion

  • First fixed in DB2 11.1 Mod 2 Fix Pack 2
    

Temporary fix

Comments

APAR Information

  • APAR number

    IT18021

  • Reported component name

    DB2 FOR LUW

  • Reported component ID

    DB2FORLUW

  • Reported release

    B10

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    YesHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2016-11-17

  • Closed date

    2017-06-23

  • Last modified date

    2017-06-23

  • APAR is sysrouted FROM one or more of the following:

    IT17587

  • APAR is sysrouted TO one or more of the following:

Fix information

  • Fixed component name

    DB2 FOR LUW

  • Fixed component ID

    DB2FORLUW

Applicable component levels

[{"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"11.1","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
29 June 2020