DB2 - Problem description
| Problem IC85608 | Status: Closed |
XQUERY MIGHT RETURN INCORRECT RESULTS WHEN BOTH 'AND' AND 'OR' P REDICATES EXIST AND ALL PREDICATES CAN BE APPLIED TO XML INDEXES | |
| product: | |
DB2 FOR LUW / DB2FORLUW / A10 - DB2 | |
| Problem 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. | |
| Problem Summary: | |
**************************************************************** * USERS AFFECTED: * * All users * **************************************************************** * PROBLEM DESCRIPTION: * * See Error Description * **************************************************************** * RECOMMENDATION: * * Upgrade to DB2 version 10.1.0.2. * **************************************************************** | |
| 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")
@
---------------------------------- | |
| available fix packs: | |
DB2 Version 10.1 Fix Pack 2 for Linux, UNIX, and Windows | |
| Solution | |
The problem is first fixed in DB2 version 10.1.0.2. | |
| Workaround | |
not known / see Local fix | |
| Timestamps | |
Date - problem reported : Date - problem closed : Date - last modified : | 30.07.2012 07.12.2012 07.12.2012 |
| Problem solved at the following versions (IBM BugInfos) | |
| Problem solved according to the fixlist(s) of the following version(s) | |
| 10.1.0.2 |
|
| 10.5.0.2 |
|