Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ public static StatementRestrictions empty(StatementType type, TableMetadata tabl
return new StatementRestrictions(type, table, IndexHints.NONE, false);
}

private StatementRestrictions(StatementType type, TableMetadata table, IndexHints indexHints, boolean allowFiltering)
private StatementRestrictions(StatementType type, TableMetadata table, IndexHints indexHints, boolean allowFilteringOfPrimaryKeys)
{
this.type = type;
this.table = table;
this.indexHints = indexHints;
this.partitionKeyRestrictions = new PartitionKeyRestrictions(table.partitionKeyAsClusteringComparator());
this.clusteringColumnsRestrictions = new ClusteringColumnRestrictions(table, allowFiltering);
this.clusteringColumnsRestrictions = new ClusteringColumnRestrictions(table, allowFilteringOfPrimaryKeys);
this.nonPrimaryKeyRestrictions = RestrictionSet.empty();
this.notNullColumns = new HashSet<>();
}
Expand Down Expand Up @@ -370,7 +370,7 @@ else if (operator.requiresIndexing())
}
else
{
if (!allowFiltering && requiresAllowFilteringIfNotSpecified(table))
if (!allowFiltering && requiresAllowFilteringIfNotSpecified(table, false))
throw invalidRequest(allowFilteringMessage(state));
}

Expand All @@ -381,14 +381,14 @@ else if (operator.requiresIndexing())
validateSecondaryIndexSelections();
}

public static boolean requiresAllowFilteringIfNotSpecified(TableMetadata metadata)
public static boolean requiresAllowFilteringIfNotSpecified(TableMetadata metadata, boolean isPrimaryKey)
{
if (!metadata.isVirtual())
return true;

VirtualTable tableNullable = VirtualKeyspaceRegistry.instance.getTableNullable(metadata.id);
assert tableNullable != null;
return !tableNullable.allowFilteringImplicitly();
return isPrimaryKey ? !tableNullable.allowFilteringPrimaryKeysImplicitly() : !tableNullable.allowFilteringImplicitly();
}

private void addRestriction(Restriction restriction, IndexRegistry indexRegistry, IndexHints indexHints)
Expand Down Expand Up @@ -593,7 +593,7 @@ private void processPartitionKeyRestrictions(ClientState state, boolean hasQueri
// components must have a EQ. Only the last partition key component can be in IN relation.
if (partitionKeyRestrictions.needFiltering())
{
if (!allowFiltering && !forView && !hasQueriableIndex && requiresAllowFilteringIfNotSpecified(table))
if (!allowFiltering && !forView && !hasQueriableIndex && requiresAllowFilteringIfNotSpecified(table, true))
throw new InvalidRequestException(allowFilteringMessage(state));

isKeyRange = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,7 @@ private StatementRestrictions prepareRestrictions(ClientState state,
boundNames,
orderings,
selectsOnlyStaticColumns,
parameters.allowFiltering || !requiresAllowFilteringIfNotSpecified(metadata),
parameters.allowFiltering || !requiresAllowFilteringIfNotSpecified(metadata, true),
forView);
}

Expand Down Expand Up @@ -1700,7 +1700,7 @@ private void checkNeedsFiltering(TableMetadata table, StatementRestrictions rest
{
// We will potentially filter data if the row filter is not the identity and there isn't any index group
// supporting all the expressions in the filter.
if (requiresAllowFilteringIfNotSpecified(table))
if (requiresAllowFilteringIfNotSpecified(table, true))
checkFalse(restrictions.needFiltering(table), StatementRestrictions.REQUIRES_ALLOW_FILTERING_MESSAGE);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ public PartitionIterator execute(ConsistencyLevel consistency, ClientState state
public UnfilteredPartitionIterator executeLocally(ReadExecutionController executionController)
{
VirtualTable view = VirtualKeyspaceRegistry.instance.getTableNullable(metadata().id);
UnfilteredPartitionIterator resultIterator = view.select(dataRange, columnFilter(), rowFilter());
UnfilteredPartitionIterator resultIterator = view.select(dataRange, columnFilter(), rowFilter(), limits());
return limits().filter(rowFilter().filter(resultIterator, nowInSec()), nowInSec(), selectsFullPartition());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,7 @@ public PartitionIterator execute(ConsistencyLevel consistency, ClientState state
public UnfilteredPartitionIterator executeLocally(ReadExecutionController executionController)
{
VirtualTable view = VirtualKeyspaceRegistry.instance.getTableNullable(metadata().id);
UnfilteredPartitionIterator resultIterator = view.select(partitionKey, clusteringIndexFilter, columnFilter(), rowFilter());
UnfilteredPartitionIterator resultIterator = view.select(partitionKey, clusteringIndexFilter, columnFilter(), rowFilter(), limits());
return limits().filter(rowFilter().filter(resultIterator, nowInSec()), nowInSec(), selectsFullPartition());
}

Expand Down
8 changes: 7 additions & 1 deletion src/java/org/apache/cassandra/db/marshal/TxnIdUtf8Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public <V> void validate(V value, ValueAccessor<V> accessor) throws MarshalExcep
{
super.validate(value, accessor);
String str = deserialize(value, accessor);
if (null == TxnId.tryParse(str))
if (!str.isEmpty() && null == TxnId.tryParse(str))
throw new MarshalException("Invalid TxnId: " + str);
}
};
Expand All @@ -59,6 +59,12 @@ public <VL, VR> int compareCustom(VL left, ValueAccessor<VL> accessorL, VR right
{
String leftStr = UTF8Serializer.instance.deserialize(left, accessorL);
String rightStr = UTF8Serializer.instance.deserialize(right, accessorR);
if (leftStr.isEmpty() || rightStr.isEmpty())
{
if (leftStr.isEmpty() && rightStr.isEmpty())
return 0;
return leftStr.isEmpty() ? -1 : 1;
}
TxnId leftId = TxnId.parse(leftStr);
TxnId rightId = TxnId.parse(rightStr);
return leftId.compareTo(rightId);
Expand Down
Loading