IBM Support

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

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

  • 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 11.5.6 or later                                   *
    ****************************************************************
    

Problem conclusion

  • Upgrade to 11.5.6 or later
    

Temporary fix

Comments

APAR Information

  • APAR number

    IT35685

  • 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-01-25

  • Closed date

    2021-01-26

  • 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:

    IT35689

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