Hi hackers, A partitioned unique index can be marked valid while one partition has no index. That partition then accepts duplicate keys.
create table t (a int) partition by list (a); create table p1 partition of t for values in (1); create table p2 partition of t for values in (2); create table p3 partition of t for values in (3); create unique index ti on only t (a); create unique index p1_a on p1 (a); create unique index p2_a on p2 (a); alter index ti attach partition p1_a; In another session, open a transaction and read from t. Run "alter table t detach partition p1 concurrently". It waits for that transaction. Cancel it, and p1 stays pending detach. Then: alter index ti attach partition p2_a; Now ti is valid, but p3 has no index. Root cause: validatePartitionedIndex() marks ti valid once it has as many valid child indexes as t has partitions. It sees two child indexes, p1_a and p2_a. It also sees two partitions, p2 and p3. It skips p1 because p1 is pending detach. So two equals two and ti becomes valid, even though p3 has no index. So we just need a one liner fix which is use false to count all partitions. 0001 is the fix and 0002 is the test on the existing detach test. This need to go back to 14 Thanks, Shihao
v1-0002-Test-partitioned-index-validity-while-a-partition-is.patch
Description: Binary data
v1-0001-Count-partitions-pending-detach-when-validating-a-pa.patch
Description: Binary data
