You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by al...@apache.org on 2015/01/14 17:20:42 UTC

[1/2] cassandra git commit: Fix NPE when passing wrong argument in ALTER TABLE statement

Repository: cassandra
Updated Branches:
  refs/heads/trunk 7a4752843 -> 270a05d63


Fix NPE when passing wrong argument in ALTER TABLE statement

patch by Benjamin Lerer; reviewed by Robert Stupp for CASSANDRA-8355


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

Branch: refs/heads/trunk
Commit: 25d4a13d5621f11290af83b81b0be1588ffc87db
Parents: cf07fc2
Author: Benjamin Lerer <b_...@hotmail.com>
Authored: Wed Jan 14 19:18:49 2015 +0300
Committer: Aleksey Yeschenko <al...@apache.org>
Committed: Wed Jan 14 19:18:49 2015 +0300

----------------------------------------------------------------------
 CHANGES.txt                                          |  1 +
 src/java/org/apache/cassandra/cql3/Cql.g             | 15 +++++++++------
 .../org/apache/cassandra/cql3/AlterTableTest.java    | 11 +++++++++--
 3 files changed, 19 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/25d4a13d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 175a78a..8f312a7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.3
+ * Fix NPE when passing wrong argument in ALTER TABLE statement (CASSANDRA-8355)
  * Pig: Refactor and deprecate CqlStorage (CASSANDRA-8599)
  * Don't reuse the same cleanup strategy for all sstables (CASSANDRA-8537)
  * Fix case-sensitivity of index name on CREATE and DROP INDEX

http://git-wip-us.apache.org/repos/asf/cassandra/blob/25d4a13d/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 eda0529..9067fc4 100644
--- a/src/java/org/apache/cassandra/cql3/Cql.g
+++ b/src/java/org/apache/cassandra/cql3/Cql.g
@@ -942,16 +942,19 @@ functionName returns [String s]
     | K_TOKEN                       { $s = "token"; }
     ;
 
-functionArgs returns [List<Term.Raw> a]
-    : '(' ')' { $a = Collections.emptyList(); }
-    | '(' t1=term { List<Term.Raw> args = new ArrayList<Term.Raw>(); args.add(t1); }
-          ( ',' tn=term { args.add(tn); } )*
-       ')' { $a = args; }
+function returns [Term.Raw t]
+    : f=functionName '(' ')'                   { $t = new FunctionCall.Raw(f, Collections.<Term.Raw>emptyList()); }
+    | f=functionName '(' args=functionArgs ')' { $t = new FunctionCall.Raw(f, args); }
+    ;
+
+functionArgs returns [List<Term.Raw> args]
+    @init{ $args = new ArrayList<Term.Raw>(); }
+    : t1=term {args.add(t1); } ( ',' tn=term { args.add(tn); } )*
     ;
 
 term returns [Term.Raw term]
     : v=value                          { $term = v; }
-    | f=functionName args=functionArgs { $term = new FunctionCall.Raw(f, args); }
+    | f=function                       { $term = f; }
     | '(' c=comparatorType ')' t=term  { $term = new TypeCast(c, t); }
     ;
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/25d4a13d/test/unit/org/apache/cassandra/cql3/AlterTableTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/AlterTableTest.java b/test/unit/org/apache/cassandra/cql3/AlterTableTest.java
index f5747ed..9668a41 100644
--- a/test/unit/org/apache/cassandra/cql3/AlterTableTest.java
+++ b/test/unit/org/apache/cassandra/cql3/AlterTableTest.java
@@ -19,8 +19,6 @@ package org.apache.cassandra.cql3;
 
 import org.junit.Test;
 
-import org.apache.cassandra.exceptions.InvalidRequestException;
-
 public class AlterTableTest extends CQLTester
 {
     @Test
@@ -83,4 +81,13 @@ public class AlterTableTest extends CQLTester
 
         assertInvalid("ALTER TABLE %s ADD myCollection map<int, int>;");
     }
+
+    @Test
+    public void testChangeStrategyWithUnquotedAgrument() throws Throwable
+    {
+        createTable("CREATE TABLE %s (id text PRIMARY KEY);");
+
+        assertInvalidSyntaxMessage("no viable alternative at input '}'",
+                                   "ALTER TABLE %s WITH caching = {'keys' : 'all', 'rows_per_partition' : ALL};");
+    }
 }


[2/2] cassandra git commit: Merge branch 'cassandra-2.1' into trunk

Posted by al...@apache.org.
Merge branch 'cassandra-2.1' into trunk


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

Branch: refs/heads/trunk
Commit: 270a05d63fb4fb6425b3f01abbdd63243dd955e8
Parents: 7a47528 25d4a13
Author: Aleksey Yeschenko <al...@apache.org>
Authored: Wed Jan 14 19:20:32 2015 +0300
Committer: Aleksey Yeschenko <al...@apache.org>
Committed: Wed Jan 14 19:20:32 2015 +0300

----------------------------------------------------------------------
 CHANGES.txt                                          |  1 +
 src/java/org/apache/cassandra/cql3/Cql.g             | 15 +++++++++------
 .../org/apache/cassandra/cql3/AlterTableTest.java    | 11 +++++++++--
 3 files changed, 19 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/270a05d6/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 937515e,8f312a7..714863f
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,54 -1,5 +1,55 @@@
 +3.0
 + * Group sstables for anticompaction correctly (CASSANDRA-8578)
 + * Add ReadFailureException to native protocol, respond
 +   immediately when replicas encounter errors while handling
 +   a read request (CASSANDRA-7886)
 + * Switch CommitLogSegment from RandomAccessFile to nio (CASSANDRA-8308)
 + * Allow mixing token and partition key restrictions (CASSANDRA-7016)
 + * Support index key/value entries on map collections (CASSANDRA-8473)
 + * Modernize schema tables (CASSANDRA-8261)
 + * Support for user-defined aggregation functions (CASSANDRA-8053)
 + * Fix NPE in SelectStatement with empty IN values (CASSANDRA-8419)
 + * Refactor SelectStatement, return IN results in natural order instead
 +   of IN value list order (CASSANDRA-7981)
 + * Support UDTs, tuples, and collections in user-defined
 +   functions (CASSANDRA-7563)
 + * Fix aggregate fn results on empty selection, result column name,
 +   and cqlsh parsing (CASSANDRA-8229)
 + * Mark sstables as repaired after full repair (CASSANDRA-7586)
 + * Extend Descriptor to include a format value and refactor reader/writer
 +   APIs (CASSANDRA-7443)
 + * Integrate JMH for microbenchmarks (CASSANDRA-8151)
 + * Keep sstable levels when bootstrapping (CASSANDRA-7460)
 + * Add Sigar library and perform basic OS settings check on startup (CASSANDRA-7838)
 + * Support for aggregation functions (CASSANDRA-4914)
 + * Remove cassandra-cli (CASSANDRA-7920)
 + * Accept dollar quoted strings in CQL (CASSANDRA-7769)
 + * Make assassinate a first class command (CASSANDRA-7935)
 + * Support IN clause on any clustering column (CASSANDRA-4762)
 + * Improve compaction logging (CASSANDRA-7818)
 + * Remove YamlFileNetworkTopologySnitch (CASSANDRA-7917)
 + * Do anticompaction in groups (CASSANDRA-6851)
 + * Support user-defined functions (CASSANDRA-7395, 7526, 7562, 7740, 7781, 7929,
 +   7924, 7812, 8063, 7813, 7708)
 + * Permit configurable timestamps with cassandra-stress (CASSANDRA-7416)
 + * Move sstable RandomAccessReader to nio2, which allows using the
 +   FILE_SHARE_DELETE flag on Windows (CASSANDRA-4050)
 + * Remove CQL2 (CASSANDRA-5918)
 + * Add Thrift get_multi_slice call (CASSANDRA-6757)
 + * Optimize fetching multiple cells by name (CASSANDRA-6933)
 + * Allow compilation in java 8 (CASSANDRA-7028)
 + * Make incremental repair default (CASSANDRA-7250)
 + * Enable code coverage thru JaCoCo (CASSANDRA-7226)
 + * Switch external naming of 'column families' to 'tables' (CASSANDRA-4369) 
 + * Shorten SSTable path (CASSANDRA-6962)
 + * Use unsafe mutations for most unit tests (CASSANDRA-6969)
 + * Fix race condition during calculation of pending ranges (CASSANDRA-7390)
 + * Fail on very large batch sizes (CASSANDRA-8011)
 + * Improve concurrency of repair (CASSANDRA-6455, 8208)
 +
 +
  2.1.3
+  * Fix NPE when passing wrong argument in ALTER TABLE statement (CASSANDRA-8355)
   * Pig: Refactor and deprecate CqlStorage (CASSANDRA-8599)
   * Don't reuse the same cleanup strategy for all sstables (CASSANDRA-8537)
   * Fix case-sensitivity of index name on CREATE and DROP INDEX

http://git-wip-us.apache.org/repos/asf/cassandra/blob/270a05d6/src/java/org/apache/cassandra/cql3/Cql.g
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/Cql.g
index d8496b1,9067fc4..d73dc28
--- a/src/java/org/apache/cassandra/cql3/Cql.g
+++ b/src/java/org/apache/cassandra/cql3/Cql.g
@@@ -1038,23 -936,20 +1038,26 @@@ intValue returns [Term.Raw value
      | QMARK         { $value = newBindVariables(null); }
      ;
  
 -functionName returns [String s]
 -    : f=IDENT                       { $s = $f.text; }
 +functionName returns [FunctionName s]
 +    : (ks=keyspaceName '.')? f=allowedFunctionName   { $s = new FunctionName(ks, f); }
 +    ;
 +
 +allowedFunctionName returns [String s]
 +    : f=IDENT                       { $s = $f.text.toLowerCase(); }
 +    | f=QUOTED_NAME                 { $s = $f.text; }
      | u=unreserved_function_keyword { $s = u; }
      | K_TOKEN                       { $s = "token"; }
 +    | K_COUNT                       { $s = "count"; }
      ;
  
- functionArgs returns [List<Term.Raw> a]
-     : '(' ')' { $a = Collections.emptyList(); }
-     | '(' t1=term { List<Term.Raw> args = new ArrayList<Term.Raw>(); args.add(t1); }
-           ( ',' tn=term { args.add(tn); } )*
-        ')' { $a = args; }
+ function returns [Term.Raw t]
+     : f=functionName '(' ')'                   { $t = new FunctionCall.Raw(f, Collections.<Term.Raw>emptyList()); }
+     | f=functionName '(' args=functionArgs ')' { $t = new FunctionCall.Raw(f, args); }
+     ;
+ 
+ functionArgs returns [List<Term.Raw> args]
+     @init{ $args = new ArrayList<Term.Raw>(); }
+     : t1=term {args.add(t1); } ( ',' tn=term { args.add(tn); } )*
      ;
  
  term returns [Term.Raw term]