[ 
https://issues.apache.org/jira/browse/CASSANDRA-11331?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15188955#comment-15188955
 ] 

Sam Tunnicliffe commented on CASSANDRA-11331:
---------------------------------------------

The IF NOT EXISTS check for indexes only validates that no other index *with 
the same name* exists and as you're not specifying a name for the index, a 
generated one will be used which is guaranteed to be unique, so the IF NOT 
EXISTS check passes. The creation then fails as observed because the index 
duplicates the existing one semantically (i.e. in everything but the name). 
This is new behaviour in 3.0 as previously the 1:1 relationship between indexes 
and columns prevented a duplicate indexes anyway.

So at the moment, this is behaving as expected but we can broaden the scope of 
the IF NOT EXISTS check to include duplicates in all but name.  

> Create Index IF NOT EXISTS throws error when index already exists
> -----------------------------------------------------------------
>
>                 Key: CASSANDRA-11331
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-11331
>             Project: Cassandra
>          Issue Type: Bug
>          Components: CQL
>            Reporter: Philip Thompson
>            Assignee: Sam Tunnicliffe
>             Fix For: 3.0.x, 3.x
>
>
> While testing with trunk, I see that issuing the following queries throws an 
> InvalidRequest, despite being valid.
> {code}
> CREATE KEYSPACE k WITH replication = {'class': 'SimpleStrategy', 
> 'replication_factor': '1'}  AND durable_writes = true;
> USE k;
> CREATE TABLE k.t (
>     id int PRIMARY KEY,
>     v int,
>     v2 int,
>     v3 text
> );
> CREATE INDEX IF NOT EXISTS ON t (v2);
> CREATE INDEX IF NOT EXISTS ON t (v2);
> InvalidRequest: code=2200 [Invalid query] message="Index t_v2_idx_1 is a 
> duplicate of existing index t_v2_idx"
> {code}
> The second {{CREATE INDEX IF NOT EXISTS}} should work fine.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to