IBM Support

IT35943: WRONG RESULT: QUERIES REFERENCING AN EXISTS SUB-QUERY WITH FETCHFIRST 1 ROW REFERENCED IN A CASE STATEMENT IN THE SELECT LIST

Subscribe to this APAR

By subscribing, you receive periodic emails alerting you to the status of the APAR, along with a link to the fix after it becomes available. You can track this item individually or track all items by product.

Notify me when this APAR changes.

Notify me when an APAR for this component changes.

 

APAR status

  • Closed as program error.

Error description

  • Queries referencing an EXISTS sub-query with FETCH FIRST 1 ROW
    referenced in a CASE statement in the SELECT list may result in
    incorrect results.
    
    
    Steps  to reproduce
    create table tab2 ( col1 integer );
    create table tab3 ( col2 integer );
    insert into tab2 values ( 123 );
    insert into tab2 values ( 234 );
    insert into tab2 values ( 345 );
    insert into tab2 values ( NULL );
    insert into tab3 values ( 234 );
    insert into tab3 values ( 345 );
    insert into tab3 values ( NULL );
    
    select  a.col1 , case when exists ( select 1 from tab3 b where
    a.col1  = b.col2 fetch first 1 rows only )  then 1 else 0 end C
    from tab2 a where col1 is not null
    
    
    
    Expected output
    COL1        C
    ----------- -----------
            123           0
            234           1
            345           1
    
    With tables organized by column, we get this incorrect result
    COL1        C
    ----------- -----------
            123           0
            234           1
            345           0
    
    
    
    
    
    1) Remove FETCH FIRST 1 ROW as it is not required in an
    existential sub-query
    
    
    
    2) In DPF environment, apply the following guideline to the
    query:
    
      /*<OPTGUIDELINES> <REGISTRY> <OPTION
    NAME='DB2_EXTENDED_OPTIMIZATION' VALUE='REORD_SSQ_THRO_OJ OFF'/>
    </REGISTRY> </OPTGUIDELINES>*/
    
    
    
    3) In non-DPF, apply the following guideline:
    
       /*<OPTGUIDELINES> <REGISTRY> <OPTION
    NAME='DB2_EXTENDED_OPTIMIZATION'
    VALUE='NONDPF_DECORR_COLTBL_OFF'/> </REGISTRY>
    </OPTGUIDELINES>*/
    

Local fix

Problem summary

  • ****************************************************************
    * USERS AFFECTED:                                              *
    * All                                                          *
    ****************************************************************
    * PROBLEM DESCRIPTION:                                         *
    * See Error Description                                        *
    ****************************************************************
    * RECOMMENDATION:                                              *
    * Upgrade to 11.5.6                                            *
    ****************************************************************
    

Problem conclusion

  • Upgrade to 11.5.6
    

Temporary fix

Comments

APAR Information

  • APAR number

    IT35943

  • Reported component name

    DB2 FOR LUW

  • Reported component ID

    DB2FORLUW

  • Reported release

    B50

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    YesHIPER

  • Special Attention

    NoSpecatt / Xsystem

  • Submitted date

    2021-02-17

  • Closed date

    2021-06-11

  • Last modified date

    2021-06-23

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

  • 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

[{"Line of Business":{"code":"LOB10","label":"Data and AI"},"Business Unit":{"code":"BU029","label":"Software"},"Product":{"code":"SSEPGG","label":"DB2 for Linux- UNIX and Windows"},"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"11.5"}]

Document Information

Modified date:
24 June 2021