[ 
https://issues.apache.org/jira/browse/DERBY-3502?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Anurag Shekhar updated DERBY-3502:
----------------------------------

    Attachment: derby-3502v1.diff

Description of Derby-3502.diff
This patch fixes backing index related issues described in DERBY-3456. 
There were three problems

1. While creating backing index for unique constraint it was sharing existing
 non unique constraint. This happened because while determining the 
possibility of sharing an index the newly introduced attribute, 
UniqueWithDuplicateNulls was ignored.

2. While creating index descriptor for backing index when the index is shared 
with another unique index the newly introduced parameter was ignored. this 
resulted in creating of a non unique index when the unique index is dropped.


3. While checking for the need of creation of a new replacement index the new 
parameter was ignored. So while dropping the unique constraint a new index 
wasn't created instead the existing index was used if the sharing index was a 
non unique index, This resulted in wrongly enforced uniqueness on non null keys.

I have modified following files to fix these issues 
java/engine/org/apache/derby/impl/sql/execute/CreateIndexConstantAction.java

Modified to use  UniqueWithDuplicateNulls while deciding about sharing indexes.
Modified to pass UniqueWithDuplicateNulls attribute while creating descriptor 
for unique constraint even when there is no new index.

java/engine/org/apache/derby/iapi/sql/dictionary/ConglomerateDescriptor.java
In drop method added additional check using UniqueWithDuplicateNulls to see if 
a new index is required.

java/testing/org/apache/derbyTesting/functionTests/tests/lang/UniqueConstraintBackingIndexTest.java
Test case based on Army's descriptions.





> Unique Constraint's backing index when shared with existing indexes doesn't 
> behave as expected
> ----------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3502
>                 URL: https://issues.apache.org/jira/browse/DERBY-3502
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.4.0.0
>            Reporter: Anurag Shekhar
>            Assignee: Anurag Shekhar
>         Attachments: derby-3502v1.diff
>
>
> Unique Constraint now uses non unique backing indexes with new attribute 
> UniqueWithDuplicateNulls. This index has following sharing properties
> 1. Can use an existing unique index.
> 2. Non Unique indexes (and foreign key) can use this index.
> While dropping a unique index a new index for unique constraint should be 
> created.
> when a unique constraint is dropped a new index for a non unique index or 
> foreign key should be created. 
> Army has found several issues in actual behavior. This problems are listed in 
> DERBY-3456.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to