IBM Support

IC83578: XQUERY MIGHT RETURN INCORRECT RESULTS WHEN BOTH 'AND' AND 'OR' P REDICATES EXIST AND ALL PREDICATES CAN BE APPLIED TO XML INDEXES

Subscribe

You can track all active APARs for this component.

 

APAR status

  • Closed as program error.

Error description

  • XQuery might return incorrect result when both 'AND' and 'OR'
    predicates exist, and all predicate can be applied to XML
    indexes.
    
    The following example shows a sample XQuery:
    ----- a.sql ----------------------
    select count(*) from xxxxx.xxxxxxx
    where xmlexists('
    declare namespace xxxx = "xxxxxxxxx";
    $data/ap:User
      [ap:sex = "male"]
      [ap:address = "tokyo"]
      [ap:status = "10" or ap:status = "40"]
    ' passing data as "data")
    @
    ----------------------------------
    
    In this example, there are no explicit AND
    predicates. However, the three filters in the XQuery statement
    get combined
    to be:
    [ap:sex = "male" and ap:address = "tokyo" and  (ap:status = "10"
    or ap:status = "40")]
    The DB2 database might incorrectly
    decide that navigation is not needed and might lead to incorrect
    results when the following conditions are satisfied:
    
    - There are both AND and OR terms in the XQuery
    - All subterms are applicable to XML indexes
    - There is no extraction of data from the XML document, for
    example using XMLEXISTS
    
    The problem can affect both, SQL/XML and XQuery statements.
    SQL/XML statements that are simple and do not apply
    predicates to XML indexes are not affected by this problem.
    

Local fix

  • Adding an 'or fn:false()' term to the OR predicates will prevent
    this from occuring.
    .
    Here is an example work around for the above:
    ----- a.sql ----------------------
    select count(*) from xxxxx.xxxxxxx
    where xmlexists('
    declare namespace xxxx = "xxxxxxxxx";
    $data/ap:User
      [ap:sex = "male"]
      [ap:address = "tokyo"]
      [ap:status = "10" or ap:status = "40" or fn:false()]
    ' passing data as "data")
    
    @
    ----------------------------------
    

Problem summary

  • ****************************************************************
    * USERS AFFECTED:                                              *
    * All users                                                    *
    ****************************************************************
    * PROBLEM DESCRIPTION:                                         *
    * See Error Description                                        *
    ****************************************************************
    * RECOMMENDATION:                                              *
    * Upgrade to DB2 version 9.7.0.7.                              *
    ****************************************************************
    

Problem conclusion

  • The problem is first fixed in DB2 version 9.7.0.7.
    

Temporary fix

Comments

APAR Information

  • APAR number

    IC83578

  • Reported component name

    DB2 FOR LUW

  • Reported component ID

    DB2FORLUW

  • Reported release

    970

  • Status

    CLOSED PER

  • PE

    NoPE

  • HIPER

    YesHIPER

  • Special Attention

    NoSpecatt

  • Submitted date

    2012-05-17

  • Closed date

    2012-10-18

  • Last modified date

    2012-12-07

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

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

    IC85608 IC85834

Fix information

  • Fixed component name

    DB2 FOR LUW

  • Fixed component ID

    DB2FORLUW

Applicable component levels

  • R970 PSN

       UP

[{"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSEPGG","label":"DB2 for Linux, UNIX and Windows"},"Component":"","ARM Category":[],"Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"9.7","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
07 December 2012