mirror of https://github.com/apache/cassandra
Correctly validate sparse composite cells
patch by Tyler Hobbs; reviewed by jbellis for CASSANDRA-5855
This commit is contained in:
parent
238139cda5
commit
eb884a582b
|
|
@ -1,5 +1,6 @@
|
||||||
1.1.next
|
1.1.next
|
||||||
* Backport compaction exception handling from 1.2
|
* Backport compaction exception handling from 1.2
|
||||||
|
* Correctly validate sparse composite cells in scrub (CASSANDRA-5855)
|
||||||
|
|
||||||
|
|
||||||
1.1.12
|
1.1.12
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import org.apache.cassandra.config.CFMetaData;
|
import org.apache.cassandra.config.CFMetaData;
|
||||||
|
import org.apache.cassandra.cql3.CFDefinition;
|
||||||
import org.apache.cassandra.db.marshal.*;
|
import org.apache.cassandra.db.marshal.*;
|
||||||
import org.apache.cassandra.io.util.DataOutputBuffer;
|
import org.apache.cassandra.io.util.DataOutputBuffer;
|
||||||
import org.apache.cassandra.utils.Allocator;
|
import org.apache.cassandra.utils.Allocator;
|
||||||
|
|
@ -277,7 +278,23 @@ public class Column implements IColumn
|
||||||
public void validateFields(CFMetaData metadata) throws MarshalException
|
public void validateFields(CFMetaData metadata) throws MarshalException
|
||||||
{
|
{
|
||||||
validateName(metadata);
|
validateName(metadata);
|
||||||
AbstractType<?> valueValidator = metadata.getValueValidator(name());
|
CFDefinition cfdef = metadata.getCfDef();
|
||||||
|
|
||||||
|
// If this is a CQL table, we need to pull out the CQL column name to look up the correct column type.
|
||||||
|
// (Note that COMPACT composites are handled by validateName, above.)
|
||||||
|
ByteBuffer internalName;
|
||||||
|
if (cfdef.isComposite && !cfdef.isCompact)
|
||||||
|
{
|
||||||
|
AbstractCompositeType comparator = (AbstractCompositeType) metadata.comparator;
|
||||||
|
List<AbstractCompositeType.CompositeComponent> components = comparator.deconstruct(name);
|
||||||
|
internalName = components.get(components.size() - 1).value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
internalName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractType<?> valueValidator = metadata.getValueValidator(internalName);
|
||||||
if (valueValidator != null)
|
if (valueValidator != null)
|
||||||
valueValidator.validate(value());
|
valueValidator.validate(value());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue