IBM Support

IT35689: Query with 'ORDER BY' and referencing a common subexpression over column-organized tables may return rows in the wrong order

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • If a query:
    - contains a common subexpression ("CSE") over column-organized
    tables
    - SELECTs the same column from different references to that CSE
    - orders the output on one copy of that column using ORDER BY
    
    and the structure of the query is such that same column from the
    different CSE references can have different values by the time
    the data streams from those references join together, the output
    might be ordered on the wrong copy of the column - the one from
    the other CSE reference - rather than the specified one.
    
    Example:
    
    CREATE TABLE "FOJ "."TABLE6" (
    "CD_DEMO_SK" INTEGER NOT NULL )
    DISTRIBUTE BY HASH("CD_DEMO_SK")
    IN "USERSPACE1"
    ORGANIZE BY COLUMN;
    ALTER TABLE "FOJ "."TABLE6" ADD PRIMARY KEY ("CD_DEMO_SK") NOT
    ENFORCED;
    
    CREATE TABLE "FOJ "."TABLE10" (
    "C_CUSTOMER_SK" INTEGER NOT NULL ,
    "C_BIRTH_DAY" INTEGER ,
    "C_BIRTH_MONTH" INTEGER ,
    "C_BIRTH_YEAR" INTEGER )
    DISTRIBUTE BY HASH("C_CUSTOMER_SK")
    IN "USERSPACE1"
    ORGANIZE BY COLUMN;
    
    ALTER TABLE "FOJ "."TABLE10" ADD PRIMARY KEY ("C_CUSTOMER_SK")
    NOT ENFORCED;
    insert into "FOJ "."TABLE6" values 1,2,3,4;
    insert into "FOJ "."TABLE10" values
    (1,1,1,1),(1,2,3,4),(2,3,4,5) ;
    
    with v(c1, c2, c3) as
    (select C_BIRTH_DAY, C_BIRTH_YEAR, count(C_BIRTH_MONTH) from
    FOJ.TABLE10 group by C_BIRTH_DAY, C_BIRTH_YEAR)
    select v1.c1 as w, v1.c2+v1.c3 as x, v2.c1, v2.c2+v2.c3 as z
    from v v2 right join v v1 on v1.c2=v2.c3
    order by v2.c1, x
    
    W           X           C1          Z
    ----------- ----------- ----------- -----------
              1           2           3           6
              1           2           2           5
              1           2           1           2
              2           5           -           -
              3           6           -           -
    
      5 record(s) selected.
    
    The rows should be in the order of C1.
    

Local fix

Problem summary

  • ****************************************************************
    * USERS AFFECTED:                                              *
    * All                                                          *
    ****************************************************************
    * PROBLEM DESCRIPTION:                                         *
    * See Error Description                                        *
    ****************************************************************
    * RECOMMENDATION:                                              *
    * Upgrade to db2_v111m4fp7 or later                            *
    ****************************************************************
    

Problem conclusion

  • Upgrade to db2_v111m4fp7 or later
    

Temporary fix

Comments

APAR Information

  • APAR number

    IT35689

  • 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

    2021-01-25

  • Closed date

    2022-04-17

  • Last modified date

    2022-04-20

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

    IT35685

  • 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

  • RB10 PSY

       UP

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"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:
04 May 2022