Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 6b5b7f519 -> 2269adba6


Preserves CQL metadata when updating table from thrift

patch by mishail; reviewed by iamaleksey & slebresne for CASSANDRA-6831


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

Branch: refs/heads/cassandra-2.1
Commit: 10527498a340feb7333b3c2b0252029fe6a840c7
Parents: 7f01980
Author: Sylvain Lebresne <sylv...@datastax.com>
Authored: Wed Apr 30 11:19:57 2014 +0200
Committer: Sylvain Lebresne <sylv...@datastax.com>
Committed: Wed Apr 30 11:19:57 2014 +0200

----------------------------------------------------------------------
 CHANGES.txt                                              |  1 +
 src/java/org/apache/cassandra/config/CFMetaData.java     | 11 -----------
 .../org/apache/cassandra/thrift/CassandraServer.java     | 10 ++++++++++
 3 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/10527498/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index e8d6a8d..fa9a156 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -14,6 +14,7 @@
  * Don't shut MessagingService down when replacing a node (CASSANDRA-6476)
  * Always clean up references in SerializingCache (CASSANDRA-6994)
  * fix npe when doing -Dcassandra.fd_initial_value_ms (CASSANDRA-6751)
+ * Preserves CQL metadata when updating table from thrift (CASSANDRA-6831)
 
 
 1.2.16

http://git-wip-us.apache.org/repos/asf/cassandra/blob/10527498/src/java/org/apache/cassandra/config/CFMetaData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/CFMetaData.java 
b/src/java/org/apache/cassandra/config/CFMetaData.java
index 85c3dcb..9e3ceb7 100644
--- a/src/java/org/apache/cassandra/config/CFMetaData.java
+++ b/src/java/org/apache/cassandra/config/CFMetaData.java
@@ -802,17 +802,6 @@ public final class CFMetaData
         minCompactionThreshold = cfm.minCompactionThreshold;
         maxCompactionThreshold = cfm.maxCompactionThreshold;
 
-        /*
-         * Because thrift updates don't know about aliases, we should ignore
-         * the case where the new aliases are empty.
-         */
-        if (!cfm.keyAliases.isEmpty())
-            keyAliases = cfm.keyAliases;
-        if (!cfm.columnAliases.isEmpty())
-            columnAliases = cfm.columnAliases;
-        if (cfm.valueAlias != null)
-            valueAlias = cfm.valueAlias;
-
         bloomFilterFpChance = cfm.bloomFilterFpChance;
         caching = cfm.caching;
         populateIoCacheOnFlush = cfm.populateIoCacheOnFlush;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/10527498/src/java/org/apache/cassandra/thrift/CassandraServer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/CassandraServer.java 
b/src/java/org/apache/cassandra/thrift/CassandraServer.java
index ec7a37d..588f732 100644
--- a/src/java/org/apache/cassandra/thrift/CassandraServer.java
+++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java
@@ -1427,6 +1427,16 @@ public class CassandraServer implements Cassandra.Iface
 
             CFMetaData.applyImplicitDefaults(cf_def);
             CFMetaData cfm = CFMetaData.fromThrift(cf_def);
+
+            /*
+             * CASSANDRA-6831: Because thrift updates don't know about aliases,
+             * we should copy them from the original CFM
+             */
+            if (!cf_def.isSetKey_alias())
+                cfm.keyAliases(oldCfm.getKeyAliases());
+            cfm.columnAliases(oldCfm.getColumnAliases());
+            cfm.valueAlias(oldCfm.getValueAlias());
+
             CFMetaData.validateCompactionOptions(cfm.compactionStrategyClass, 
cfm.compactionStrategyOptions, false);
             cfm.addDefaultIndexNames();
             MigrationManager.announceColumnFamilyUpdate(cfm);

Reply via email to