src/java/org/apache/cassandra/cql/QueryProcessor.java
/* Test for SELECT-specific taboos */
Test for SELECT-specific taboos
Test for SELECT - specific taboos
private static void validateSelect(String keyspace, SelectStatement select, List<String> variables) throws InvalidRequestException
    {
        ThriftValidation.validateConsistencyLevel(keyspace, select.getConsistencyLevel(), RequestType.READ);
        if (!select.isKeyRange() && (select.getKeyFinish() != null))
            throw new InvalidRequestException("Key range clauses must include a start key (i.e. KEY > term)");
        if (select.isKeyRange() && select.getKeys().size() > 0)
            throw new InvalidRequestException("You cannot combine key range and by-key clauses in a SELECT");
        if (select.isKeyRange() && (select.getKeyFinish() != null) && (select.getColumnRelations().size() > 0))
            throw new InvalidRequestException("You cannot combine key range and by-column clauses in a SELECT");
        if (!select.isMultiKey() && select.getKeys().size() > 1)
            throw new InvalidRequestException("You cannot use more than one KEY = in a SELECT");
        if (select.getColumnRelations().size() > 0)
        {
            AbstractType<?> comparator = select.getComparator(keyspace);
            Set<ByteBuffer> indexed = Table.open(keyspace).getColumnFamilyStore(select.getColumnFamily()).indexManager.getIndexedColumns();
            for (Relation relation : select.getColumnRelations())
            {
                if ((relation.operator() == RelationType.EQ) && indexed.contains(relation.getEntity().getByteBuffer(comparator, variables)))
                    return;
            }
            throw new InvalidRequestException("No indexed columns present in by-columns clause with \"equals\" operator");
        }
    }
private static void validateSelect ( String keyspace , SelectStatement select , List < String > variables ) throws InvalidRequestException { ThriftValidation . validateConsistencyLevel ( keyspace , select . getConsistencyLevel ( ) , RequestType . READ ) ; if ( ! select . isKeyRange ( ) && ( select . getKeyFinish ( ) != null ) ) throw new InvalidRequestException ( "Key range clauses must include a start key (i.e. KEY > term)" ) ; if ( select . isKeyRange ( ) && select . getKeys ( ) . size ( ) > 0 ) throw new InvalidRequestException ( "You cannot combine key range and by-key clauses in a SELECT" ) ; if ( select . isKeyRange ( ) && ( select . getKeyFinish ( ) != null ) && ( select . getColumnRelations ( ) . size ( ) > 0 ) ) throw new InvalidRequestException ( "You cannot combine key range and by-column clauses in a SELECT" ) ; if ( ! select . isMultiKey ( ) && select . getKeys ( ) . size ( ) > 1 ) throw new InvalidRequestException ( "You cannot use more than one KEY = in a SELECT" ) ; if ( select . getColumnRelations ( ) . size ( ) > 0 ) { AbstractType < ? > comparator = select . getComparator ( keyspace ) ; Set < ByteBuffer > indexed = Table . open ( keyspace ) . getColumnFamilyStore ( select . getColumnFamily ( ) ) . indexManager . getIndexedColumns ( ) ; for ( Relation relation : select . getColumnRelations ( ) ) { if ( ( relation . operator ( ) == RelationType . EQ ) && indexed . contains ( relation . getEntity ( ) . getByteBuffer ( comparator , variables ) ) ) return ; } throw new InvalidRequestException ( "No indexed columns present in by-columns clause with \"equals\" operator" ) ; } }
Test for SELECT-specific taboos
Test for SELECT - specific taboos
// Finish key w/o start key (KEY < foo) // Key range and by-key(s) combined (KEY > foo AND KEY = bar) // Start and finish keys, *and* column relations (KEY > foo AND KEY < bar and name1 = value1). // Can't use more than one KEY =