Merge branch 'cassandra-3.0' into cassandra-3.11

This commit is contained in:
Aleksey Yeschenko 2017-08-03 14:15:36 +01:00
commit 2fd33ba9d7
3 changed files with 23 additions and 0 deletions

View File

@ -4,6 +4,7 @@
* Duplicate the buffer before passing it to analyser in SASI operation (CASSANDRA-13512)
* Properly evict pstmts from prepared statements cache (CASSANDRA-13641)
Merged from 3.0:
* Drop table should remove corresponding entries in dropped_columns table (CASSANDRA-13730)
* Log warn message until legacy auth tables have been migrated (CASSANDRA-13371)
* Fix incorrect [2.1 <- 3.0] serialization of counter cells created in 2.0 (CASSANDRA-13691)
* Fix invalid writetime for null cells (CASSANDRA-13711)

View File

@ -31,6 +31,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.cassandra.config.*;
import org.apache.cassandra.config.CFMetaData.DroppedColumn;
import org.apache.cassandra.config.ColumnDefinition.ClusteringOrder;
import org.apache.cassandra.cql3.*;
import org.apache.cassandra.cql3.functions.*;
@ -656,6 +657,9 @@ public final class SchemaKeyspace
for (ColumnDefinition column : table.allColumns())
dropColumnFromSchemaMutation(table, column, builder);
for (CFMetaData.DroppedColumn column : table.getDroppedColumns().values())
dropDroppedColumnFromSchemaMutation(table, column, timestamp, builder);
for (TriggerMetadata trigger : table.getTriggers())
dropTriggerFromSchemaMutation(table, trigger, builder);
@ -694,6 +698,11 @@ public final class SchemaKeyspace
.add("type", expandUserTypes(column.type).asCQL3Type().toString());
}
private static void dropDroppedColumnFromSchemaMutation(CFMetaData table, DroppedColumn column, long timestamp, Mutation.SimpleBuilder builder)
{
builder.update(DroppedColumns).row(table.cfName, column.name).delete();
}
private static void addTriggerToSchemaMutation(CFMetaData table, TriggerMetadata trigger, Mutation.SimpleBuilder builder)
{
builder.update(Triggers)

View File

@ -34,4 +34,17 @@ public class DropTest extends CQLTester
execute("DROP TABLE IF EXISTS keyspace_does_not_exist.table_does_not_exist");
}
@Test
public void testDropTableWithDroppedColumns() throws Throwable
{
// CASSANDRA-13730: entry should be removed from dropped_columns table when table is dropped
String cf = createTable("CREATE TABLE %s (k1 int, c1 int , v1 int, v2 int, PRIMARY KEY (k1, c1))");
execute("ALTER TABLE %s DROP v2");
execute("DROP TABLE %s");
assertRowsIgnoringOrder(execute("select * from system_schema.dropped_columns where keyspace_name = '"
+ keyspace()
+ "' and table_name = '" + cf + "'"));
}
}