cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [6/6] git commit: CQL support for altering key_validation_class in ALTER TABLE
Date Wed, 08 Feb 2012 14:39:45 GMT
CQL support for altering key_validation_class in ALTER TABLE

patch by slebresne; reviewed by thepaul for CASSANDRA-3781


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

Branch: refs/heads/trunk
Commit: 7108f3ed318f3be0afaf4bed109226d3373215c2
Parents: a277fbe
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Wed Feb 8 10:21:30 2012 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Wed Feb 8 10:21:30 2012 +0100

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../apache/cassandra/cql/AlterTableStatement.java  |   31 +++++++++------
 .../cql3/statements/AlterTableStatement.java       |    2 +
 3 files changed, 22 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7108f3ed/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9768867..390526b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -66,6 +66,7 @@
  * respect not only row cache capacity but caching mode when
    trying to read data (CASSANDRA-3812)
  * fix system tests (CASSANDRA-3827)
+ * CQL support for altering key_validation_class in ALTER TABLE (CASSANDRA-3781)
 
 
 1.0.8

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7108f3ed/src/java/org/apache/cassandra/cql/AlterTableStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql/AlterTableStatement.java b/src/java/org/apache/cassandra/cql/AlterTableStatement.java
index 73112e7..5ca92bb 100644
--- a/src/java/org/apache/cassandra/cql/AlterTableStatement.java
+++ b/src/java/org/apache/cassandra/cql/AlterTableStatement.java
@@ -92,23 +92,30 @@ public class AlterTableStatement
                 break;
 
             case ALTER:
-                ColumnDef toUpdate = null;
-
-                for (ColumnDef columnDef : cfDef.column_metadata)
+                if (cfDef.key_alias != null && cfDef.key_alias.equals(columnName))
                 {
-                    if (columnDef.name.equals(columnName))
+                    cfDef.setKey_validation_class(TypeParser.parse(validator).toString());
+                }
+                else
+                {
+                    ColumnDef toUpdate = null;
+
+                    for (ColumnDef columnDef : cfDef.column_metadata)
                     {
-                        toUpdate = columnDef;
-                        break;
+                        if (columnDef.name.equals(columnName))
+                        {
+                            toUpdate = columnDef;
+                            break;
+                        }
                     }
-                }
 
-                if (toUpdate == null)
-                    throw new InvalidRequestException(String.format("Column '%s' was not
found in CF '%s'",
-                                                                    this.columnName,
-                                                                    columnFamily));
+                    if (toUpdate == null)
+                        throw new InvalidRequestException(String.format("Column '%s' was
not found in CF '%s'",
+                                    this.columnName,
+                                    columnFamily));
 
-                toUpdate.setValidation_class(TypeParser.parse(validator).toString());
+                    toUpdate.setValidation_class(TypeParser.parse(validator).toString());
+                }
                 break;
 
             case DROP:

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7108f3ed/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java b/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
index 8a1ab42..4114773 100644
--- a/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/AlterTableStatement.java
@@ -90,6 +90,8 @@ public class AlterTableStatement extends SchemaAlteringStatement
                     switch (name.kind)
                     {
                         case KEY_ALIAS:
+                            thriftDef.key_validation_class = CFPropDefs.parseType(validator).toString();
+                            break;
                         case COLUMN_ALIAS:
                             throw new InvalidRequestException(String.format("Cannot alter
PRIMARY KEY part %s", columnName));
                         case VALUE_ALIAS:


Mime
View raw message