cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1072123 - in /cassandra/branches/cassandra-0.7: CHANGES.txt src/java/org/apache/cassandra/db/migration/AddColumnFamily.java src/java/org/apache/cassandra/db/migration/UpdateColumnFamily.java
Date Fri, 18 Feb 2011 20:11:23 GMT
Author: jbellis
Date: Fri Feb 18 20:11:23 2011
New Revision: 1072123

URL: http://svn.apache.org/viewvc?rev=1072123&view=rev
Log:
validate index namesfor \w+
patch by jbellis; reviewed by gdusbabek for CASSANDRA-2196

Modified:
    cassandra/branches/cassandra-0.7/CHANGES.txt
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/AddColumnFamily.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/UpdateColumnFamily.java

Modified: cassandra/branches/cassandra-0.7/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1072123&r1=1072122&r2=1072123&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.7/CHANGES.txt Fri Feb 18 20:11:23 2011
@@ -9,8 +9,10 @@
    -Dcompaction_preheat_key_cache=true (CASSANDRA-2175)
  * refactor stress.py to have only one copy of the format string 
    used for creating row keys (CASSANDRA-2108)
+ * validate index names for \w+ (CASSANDRA-2196)
  * Fix Cassandra cli to respect timeout if schema does not settle (CASSANDRA-2187)
 
+
 0.7.2
  * copy DecoratedKey.key when inserting into caches to avoid retaining
    a reference to the underlying buffer (CASSANDRA-2102)

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/AddColumnFamily.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/AddColumnFamily.java?rev=1072123&r1=1072122&r2=1072123&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/AddColumnFamily.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/AddColumnFamily.java
Fri Feb 18 20:11:23 2011
@@ -1,13 +1,12 @@
 package org.apache.cassandra.db.migration;
 
 import java.io.IOException;
+import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
-import org.apache.cassandra.config.CFMetaData;
-import org.apache.cassandra.config.ConfigurationException;
-import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.config.KSMetaData;
+import org.apache.cassandra.config.*;
 import org.apache.cassandra.db.Table;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.UUIDGen;
@@ -50,7 +49,13 @@ public class AddColumnFamily extends Mig
             throw new ConfigurationException("CF is already defined in that keyspace.");
         else if (!Migration.isLegalName(cfm.cfName))
             throw new ConfigurationException("Invalid column family name: " + cfm.cfName);
-        
+        for (Map.Entry<ByteBuffer, ColumnDefinition> entry : cfm.getColumn_metadata().entrySet())
+        {
+            String indexName = entry.getValue().getIndexName();
+            if (indexName != null && !Migration.isLegalName(indexName))
+                throw new ConfigurationException("Invalid index name: " + indexName);
+        }
+
         // clone ksm but include the new cf def.
         KSMetaData newKsm = makeNewKeyspaceDefinition(ksm);
         

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/UpdateColumnFamily.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/UpdateColumnFamily.java?rev=1072123&r1=1072122&r2=1072123&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/UpdateColumnFamily.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/db/migration/UpdateColumnFamily.java
Fri Feb 18 20:11:23 2011
@@ -1,11 +1,11 @@
 package org.apache.cassandra.db.migration;
 
 import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Map;
 
-import org.apache.cassandra.config.CFMetaData;
-import org.apache.cassandra.config.ConfigurationException;
-import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.config.KSMetaData;
+import org.apache.cassandra.avro.ColumnDef;
+import org.apache.cassandra.config.*;
 import org.apache.cassandra.db.ColumnFamilyStore;
 import org.apache.cassandra.db.Table;
 import org.apache.cassandra.utils.FBUtilities;
@@ -45,7 +45,15 @@ public class UpdateColumnFamily extends 
         KSMetaData ksm = DatabaseDescriptor.getTableDefinition(cf_def.keyspace.toString());
         if (ksm == null)
             throw new ConfigurationException("Keyspace does not already exist.");
-        
+        if (cf_def.column_metadata != null)
+        {
+            for (ColumnDef entry : cf_def.column_metadata)
+            {
+                if (entry.index_name != null && !Migration.isLegalName((String) entry.index_name))
+                    throw new ConfigurationException("Invalid index name: " + entry.index_name);
+            }
+        }
+
         CFMetaData oldCfm = DatabaseDescriptor.getCFMetaData(CFMetaData.getId(cf_def.keyspace.toString(),
cf_def.name.toString()));
         
         // create a copy of the old CF meta data. Apply new settings on top of it.



Mime
View raw message