DB2 - Problem description
Problem IT28782 | Status: Closed |
ALTER TABLE DROP CONSTRAINT DOES NOT INVALIDATE THE DEPENDENT PACKAGE AND CAUSES WRONG RESULTS TO BE RETURNED | |
product: | |
DB2 FOR LUW / DB2FORLUW / B10 - DB2 | |
Problem description: | |
When there is a constraint defined on a table and a query makes use of the constraint for data partition elimination, a dependency on the constraint should be recorded for the query package. Db2 failed to record the dependency. The result is that a row inserted after dropping the constraint, that would have violated this constraint, may not be returned by the query. For example: CREATE TABLE T ( C1 INT NOT NULL, C2 INT NOT NULL ) PARTITION BY RANGE(C2) (PART "P01" STARTING(1) ENDING(10), PART "P02" STARTING(11) ENDING(20) ); CREATE INDEX I ON T ( C2 ASC, C1 ASC) PARTITIONED; ALTER TABLE T ADD CONSTRAINT C CHECK (C2 BETWEEN 1 AND 10) ENFORCED ENABLE QUERY OPTIMIZATION; -- Returns 0 rows as expected since table is empty. Query -- package is stored in the dynamic package cache SELECT * FROM T WHERE C1 = 99; C1 C2 ----------- ----------- 0 record(s) selected. -- Drop constraint, this should invalidate dynamic package ALTER TABLE T DROP CONSTRAINT C; -- Insert value outside of dropped constraint; INSERT INTO T VALUES ( 99, 11); -- Same query as before, now it should return the newly -- inserted row, but does not because Db2 failed to -- record dependency on the constraint SELECT * FROM T WHERE C1 = 99; C1 C2 ----------- ----------- 0 record(s) selected. | |
Problem Summary: | |
**************************************************************** * USERS AFFECTED: * * ALL * **************************************************************** * PROBLEM DESCRIPTION: * * See Error Description * **************************************************************** * RECOMMENDATION: * * Upgrade to Db2 11.1 Mod 4 Fixpack 5 or higher * **************************************************************** | |
Local Fix: | |
For static queries (e.g. embedded C or SQL procedures), manually rebind the corresponding package(s). For dynamic queries, either flush the dynamic package cache (FLUSH PACKAGE CACHE DYNAMIC), or close and re-establish database connection. | |
Solution | |
Workaround | |
not known / see Local fix | |
Timestamps | |
Date - problem reported : Date - problem closed : Date - last modified : | 12.04.2019 16.01.2020 16.01.2020 |
Problem solved at the following versions (IBM BugInfos) | |
Problem solved according to the fixlist(s) of the following version(s) |