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

MichaƂ Michalski updated CASSANDRA-2737:
----------------------------------------

    Attachment: 2737-concept-v1.txt

Here's my idea of implementing this feature (see attached file for details):

# Move the validate(), checkAccess() and execute() method calls from 
QueryProcessor into separate "wrapping" method (I called it 
validateCheckAccessAndExecute for now ;-) ) defined in CQLStatement interface. 
All the classes implementing this interface will just execute these three 
methods one by one, like QueryProcessor did (a bit non-DRY). By doing so  we 
can handle the exceptions thrown by these methods "internally" (in specific 
Statement classes), without adding any logic to QueryProcessor.
# Define two exceptions inheriting from InvalidRequestException so we can 
distinguish when we can (if IF [NOT] EXISTS was used in the query) just ignore 
a problem that occured - let's call them: MissingObject and ObjectExists. They 
are - obviously - thrown when we try to create existing object or drop the one 
that does not exist.
# Define two subclasses of SchemaAlteringStatement: DropStatement and 
CreateStatement - they require one additional parameter in constructor  
(indicating if IF [NOT] EXISTS statement was used) and override the 
validateCheckAccessAndExecute() method to check if any of the exceptions 
mentioned above was thrown and - if allowed - handle it by returning null 
(converted to Void message in QueryProcessor) or re-throw the exception.

I've implemented this solution for DROP INDEX statement as an example - see 
attachment. If you're OK with this implementation, I'll do the rest. 

For now there are no changes in cqlsh (so autocompletion does not work), but of 
course it's also in the scope of this task.

*Important* QueryProcessor code, obviously, is not going to look like this - it 
will call only validateCheckAccessAndExecute() method, like it happens for 
DropIndexStatement now, without any "if" or so.

                
> CQL: support IF EXISTS extension for DROP commands (table, keyspace, index)
> ---------------------------------------------------------------------------
>
>                 Key: CASSANDRA-2737
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-2737
>             Project: Cassandra
>          Issue Type: New Feature
>    Affects Versions: 0.8.0
>            Reporter: Cathy Daw
>            Priority: Trivial
>              Labels: cql
>             Fix For: 2.0
>
>         Attachments: 2737-concept-v1.txt
>
>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to