1. mirror
  2. Cassandra

Commits

pcmanus  committed be36736

Fix bug in compact storage metadata handling

patch by slebresne; reviewed by jasobrown for CASSANDRA-5189

  • Participants
  • Parent commits 4feb87d
  • Branches trunk

Comments (0)

Files changed (2)

File CHANGES.txt

View file
 1.2.2
  * fix symlinks under data dir not working (CASSANDRA-5185)
+ * fix bug in compact storage metadata handling (CASSANDRA-5189)
 
 1.2.1
  * stream undelivered hints on decommission (CASSANDRA-5128)

File src/java/org/apache/cassandra/cql3/statements/CreateColumnFamilyStatement.java

View file
                 }
             }
 
-            if (useCompactStorage && stmt.columns.size() <= 1)
+            if (useCompactStorage && !stmt.columnAliases.isEmpty())
             {
                 if (stmt.columns.isEmpty())
                 {
-                    if (columnAliases.isEmpty())
-                        throw new InvalidRequestException(String.format("COMPACT STORAGE with non-composite PRIMARY KEY require one column not part of the PRIMARY KEY (got: %s)", StringUtils.join(stmt.columns.keySet(), ", ")));
-
                     // The only value we'll insert will be the empty one, so the default validator don't matter
                     stmt.defaultValidator = BytesType.instance;
                     // We need to distinguish between
                 }
                 else
                 {
+                    if (stmt.columns.size() > 1)
+                        throw new InvalidRequestException(String.format("COMPACT STORAGE with composite PRIMARY KEY allows no more than one column not part of the PRIMARY KEY (got: %s)", StringUtils.join(stmt.columns.keySet(), ", ")));
+
                     Map.Entry<ColumnIdentifier, AbstractType> lastEntry = stmt.columns.entrySet().iterator().next();
                     stmt.defaultValidator = lastEntry.getValue();
                     stmt.valueAlias = lastEntry.getKey().key;
             }
             else
             {
-                if (useCompactStorage && !columnAliases.isEmpty())
-                    throw new InvalidRequestException(String.format("COMPACT STORAGE with composite PRIMARY KEY allows no more than one column not part of the PRIMARY KEY (got: %s)", StringUtils.join(stmt.columns.keySet(), ", ")));
+                // For compact, we are in the "static" case, so we need at least one column defined. For non-compact however, having
+                // just the PK is fine since we have CQL3 row marker.
+                if (useCompactStorage && stmt.columns.isEmpty())
+                    throw new InvalidRequestException("COMPACT STORAGE with non-composite PRIMARY KEY require one column not part of the PRIMARY KEY, none given");
 
                 // There is no way to insert/access a column that is not defined for non-compact storage, so
                 // the actual validator don't matter much (except that we want to recognize counter CF as limitation apply to them).