cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mish...@apache.org
Subject [6/8] git commit: Allow triggers' names to be quoted identifiers
Date Mon, 01 Sep 2014 19:21:20 GMT
Allow triggers' names to be quoted identifiers

patch by Mikhail Stepura; reviewed by Sylvain Lebresne for CASSANDRA-7847


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e0d7c77f
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e0d7c77f
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e0d7c77f

Branch: refs/heads/trunk
Commit: e0d7c77f32140adeb51d0316179b95e33fb5834c
Parents: 7504964
Author: Mikhail Stepura <mishail@apache.org>
Authored: Thu Aug 28 17:04:13 2014 -0700
Committer: Mikhail Stepura <mishail@apache.org>
Committed: Mon Sep 1 12:19:17 2014 -0700

----------------------------------------------------------------------
 NEWS.txt                                                     | 3 +++
 src/java/org/apache/cassandra/cql3/Cql.g                     | 8 ++++----
 .../apache/cassandra/cql3/CreateTriggerStatementTest.java    | 8 ++++++++
 3 files changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0d7c77f/NEWS.txt
----------------------------------------------------------------------
diff --git a/NEWS.txt b/NEWS.txt
index 9b521e4..db34fd3 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -47,6 +47,9 @@ New features
      longer a responsible for that range of keys.  
      If you want the old behavior (due to a lost node perhaps)
      you can set the following property (-Dcassandra.consistent.rangemovement=false)
+   - It is now possible to use quoted identifiers in triggers' names. 
+     WARNING: if you previously used triggers with capital letters in their 
+     names, then you must quote them from now on.
 
 Upgrading
 ---------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0d7c77f/src/java/org/apache/cassandra/cql3/Cql.g
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/Cql.g b/src/java/org/apache/cassandra/cql3/Cql.g
index 93df1b4..6bfda15 100644
--- a/src/java/org/apache/cassandra/cql3/Cql.g
+++ b/src/java/org/apache/cassandra/cql3/Cql.g
@@ -587,9 +587,9 @@ createTriggerStatement returns [CreateTriggerStatement expr]
     @init {
         boolean ifNotExists = false;
     }
-    : K_CREATE K_TRIGGER (K_IF K_NOT K_EXISTS { ifNotExists = true; } )? (name=IDENT)
+    : K_CREATE K_TRIGGER (K_IF K_NOT K_EXISTS { ifNotExists = true; } )? (name=cident)
         K_ON cf=columnFamilyName K_USING cls=STRING_LITERAL
-      { $expr = new CreateTriggerStatement(cf, $name.text, $cls.text, ifNotExists); }
+      { $expr = new CreateTriggerStatement(cf, name.toString(), $cls.text, ifNotExists);
}
     ;
 
 /**
@@ -597,8 +597,8 @@ createTriggerStatement returns [CreateTriggerStatement expr]
  */
 dropTriggerStatement returns [DropTriggerStatement expr]
      @init { boolean ifExists = false; }
-    : K_DROP K_TRIGGER (K_IF K_EXISTS { ifExists = true; } )? (name=IDENT) K_ON cf=columnFamilyName
-      { $expr = new DropTriggerStatement(cf, $name.text, ifExists); }
+    : K_DROP K_TRIGGER (K_IF K_EXISTS { ifExists = true; } )? (name=cident) K_ON cf=columnFamilyName
+      { $expr = new DropTriggerStatement(cf, name.toString(), ifExists); }
     ;
 
 /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0d7c77f/test/unit/org/apache/cassandra/cql3/CreateTriggerStatementTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/CreateTriggerStatementTest.java b/test/unit/org/apache/cassandra/cql3/CreateTriggerStatementTest.java
index 39703cc..6557c16 100644
--- a/test/unit/org/apache/cassandra/cql3/CreateTriggerStatementTest.java
+++ b/test/unit/org/apache/cassandra/cql3/CreateTriggerStatementTest.java
@@ -43,6 +43,8 @@ public class CreateTriggerStatementTest extends CQLTester
         execute("CREATE TRIGGER trigger_2 ON %s USING '" + TestTrigger.class.getName() +
"'");
         assertTriggerExists("trigger_2", TestTrigger.class);
         assertInvalid("CREATE TRIGGER trigger_1 ON %s USING '" + TestTrigger.class.getName()
+ "'");
+        execute("CREATE TRIGGER \"Trigger 3\" ON %s USING '" + TestTrigger.class.getName()
+ "'");
+        assertTriggerExists("Trigger 3", TestTrigger.class);
     }
 
     @Test
@@ -72,6 +74,12 @@ public class CreateTriggerStatementTest extends CQLTester
         assertTriggerExists("trigger_1", TestTrigger.class);
 
         assertInvalid("DROP TRIGGER trigger_2 ON %s");
+        
+        execute("CREATE TRIGGER \"Trigger 3\" ON %s USING '" + TestTrigger.class.getName()
+ "'");
+        assertTriggerExists("Trigger 3", TestTrigger.class);
+
+        execute("DROP TRIGGER \"Trigger 3\" ON %s");
+        assertTriggerDoesNotExists("Trigger 3", TestTrigger.class);
     }
 
     @Test


Mime
View raw message