mirror of https://github.com/apache/cassandra
Merge branch 'cassandra-1.2' into cassandra-2.0
Conflicts: src/java/org/apache/cassandra/cql3/QueryProcessor.java src/java/org/apache/cassandra/cql3/statements/BatchStatement.java src/java/org/apache/cassandra/cql3/statements/CreateTableStatement.java src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java src/java/org/apache/cassandra/cql3/statements/ParsedStatement.java src/java/org/apache/cassandra/cql3/statements/SelectStatement.java src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java
This commit is contained in:
commit
b1435ffd1d
|
|
@ -27,7 +27,7 @@ public interface CQLStatement
|
|||
/**
|
||||
* Returns the number of bound terms in this statement.
|
||||
*/
|
||||
public int getBoundsTerms();
|
||||
public int getBoundTerms();
|
||||
|
||||
/**
|
||||
* Perform any access verification necessary for the statement.
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ public class QueryProcessor
|
|||
throws RequestExecutionException, RequestValidationException
|
||||
{
|
||||
CQLStatement prepared = getStatement(queryString, queryState.getClientState()).statement;
|
||||
if (prepared.getBoundsTerms() != options.getValues().size())
|
||||
if (prepared.getBoundTerms() != options.getValues().size())
|
||||
throw new InvalidRequestException("Invalid amount of bind variables");
|
||||
|
||||
return processStatement(prepared, queryState, options, queryString);
|
||||
|
|
@ -286,10 +286,10 @@ public class QueryProcessor
|
|||
throws RequestValidationException
|
||||
{
|
||||
ParsedStatement.Prepared prepared = getStatement(queryString, clientState);
|
||||
int bountTerms = prepared.statement.getBoundsTerms();
|
||||
if (bountTerms > FBUtilities.MAX_UNSIGNED_SHORT)
|
||||
throw new InvalidRequestException(String.format("Too many markers(?). %d markers exceed the allowed maximum of %d", bountTerms, FBUtilities.MAX_UNSIGNED_SHORT));
|
||||
assert bountTerms == prepared.boundNames.size();
|
||||
int boundTerms = prepared.statement.getBoundTerms();
|
||||
if (boundTerms > FBUtilities.MAX_UNSIGNED_SHORT)
|
||||
throw new InvalidRequestException(String.format("Too many markers(?). %d markers exceed the allowed maximum of %d", boundTerms, FBUtilities.MAX_UNSIGNED_SHORT));
|
||||
assert boundTerms == prepared.boundNames.size();
|
||||
|
||||
ResultMessage.Prepared msg = storePreparedStatement(queryString, clientState.getRawKeyspace(), prepared, forThrift);
|
||||
|
||||
|
|
@ -322,7 +322,7 @@ public class QueryProcessor
|
|||
thriftPreparedStatements.put(statementId, prepared.statement);
|
||||
logger.trace(String.format("Stored prepared statement #%d with %d bind markers",
|
||||
statementId,
|
||||
prepared.statement.getBoundsTerms()));
|
||||
prepared.statement.getBoundTerms()));
|
||||
return ResultMessage.Prepared.forThrift(statementId, prepared.boundNames);
|
||||
}
|
||||
else
|
||||
|
|
@ -331,7 +331,7 @@ public class QueryProcessor
|
|||
preparedStatements.put(statementId, prepared.statement);
|
||||
logger.trace(String.format("Stored prepared statement %s with %d bind markers",
|
||||
statementId,
|
||||
prepared.statement.getBoundsTerms()));
|
||||
prepared.statement.getBoundTerms()));
|
||||
return new ResultMessage.Prepared(statementId, prepared);
|
||||
}
|
||||
}
|
||||
|
|
@ -341,11 +341,11 @@ public class QueryProcessor
|
|||
{
|
||||
List<ByteBuffer> variables = options.getValues();
|
||||
// Check to see if there are any bound variables to verify
|
||||
if (!(variables.isEmpty() && (statement.getBoundsTerms() == 0)))
|
||||
if (!(variables.isEmpty() && (statement.getBoundTerms() == 0)))
|
||||
{
|
||||
if (variables.size() != statement.getBoundsTerms())
|
||||
if (variables.size() != statement.getBoundTerms())
|
||||
throw new InvalidRequestException(String.format("there were %d markers(?) in CQL but %d bound variables",
|
||||
statement.getBoundsTerms(),
|
||||
statement.getBoundTerms(),
|
||||
variables.size()));
|
||||
|
||||
// at this point there is a match in count between markers and variables that is non-zero
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public abstract class AuthenticationStatement extends ParsedStatement implements
|
|||
return new Prepared(this);
|
||||
}
|
||||
|
||||
public int getBoundsTerms()
|
||||
public int getBoundTerms()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public abstract class AuthorizationStatement extends ParsedStatement implements
|
|||
return new Prepared(this);
|
||||
}
|
||||
|
||||
public int getBoundsTerms()
|
||||
public int getBoundTerms()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public class BatchStatement implements CQLStatement, MeasurableForPreparedCache
|
|||
return size;
|
||||
}
|
||||
|
||||
public int getBoundsTerms()
|
||||
public int getBoundTerms()
|
||||
{
|
||||
return boundTerms;
|
||||
}
|
||||
|
|
@ -206,7 +206,7 @@ public class BatchStatement implements CQLStatement, MeasurableForPreparedCache
|
|||
|
||||
public ParsedStatement.Prepared prepare() throws InvalidRequestException
|
||||
{
|
||||
VariableSpecifications boundNames = getBoundsVariables();
|
||||
VariableSpecifications boundNames = getBoundVariables();
|
||||
|
||||
List<ModificationStatement> statements = new ArrayList<ModificationStatement>(parsedStatements.size());
|
||||
for (ModificationStatement.Parsed parsed : parsedStatements)
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public abstract class ModificationStatement implements CQLStatement, MeasurableF
|
|||
public abstract boolean requireFullClusteringKey();
|
||||
public abstract ColumnFamily updateForKey(ByteBuffer key, ColumnNameBuilder builder, UpdateParameters params) throws InvalidRequestException;
|
||||
|
||||
public int getBoundsTerms()
|
||||
public int getBoundTerms()
|
||||
{
|
||||
return boundTerms;
|
||||
}
|
||||
|
|
@ -578,7 +578,7 @@ public abstract class ModificationStatement implements CQLStatement, MeasurableF
|
|||
|
||||
public ParsedStatement.Prepared prepare() throws InvalidRequestException
|
||||
{
|
||||
VariableSpecifications boundNames = getBoundsVariables();
|
||||
VariableSpecifications boundNames = getBoundVariables();
|
||||
ModificationStatement statement = prepare(boundNames);
|
||||
return new ParsedStatement.Prepared(statement, boundNames);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public abstract class ParsedStatement
|
|||
{
|
||||
private VariableSpecifications variables;
|
||||
|
||||
public VariableSpecifications getBoundsVariables()
|
||||
public VariableSpecifications getBoundVariables()
|
||||
{
|
||||
return variables;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public abstract class SchemaAlteringStatement extends CFStatement implements CQL
|
|||
this.isColumnFamilyLevel = true;
|
||||
}
|
||||
|
||||
public int getBoundsTerms()
|
||||
public int getBoundTerms()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public class SelectStatement implements CQLStatement, MeasurableForPreparedCache
|
|||
return meter.measureDeep(this) - meter.measureDeep(cfDef);
|
||||
}
|
||||
|
||||
public int getBoundsTerms()
|
||||
public int getBoundTerms()
|
||||
{
|
||||
return boundTerms;
|
||||
}
|
||||
|
|
@ -1069,7 +1069,7 @@ public class SelectStatement implements CQLStatement, MeasurableForPreparedCache
|
|||
|
||||
CFDefinition cfDef = cfm.getCfDef();
|
||||
|
||||
VariableSpecifications names = getBoundsVariables();
|
||||
VariableSpecifications names = getBoundVariables();
|
||||
|
||||
// Select clause
|
||||
if (parameters.isCount && !selectClause.isEmpty())
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class TruncateStatement extends CFStatement implements CQLStatement
|
|||
super(name);
|
||||
}
|
||||
|
||||
public int getBoundsTerms()
|
||||
public int getBoundTerms()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class UseStatement extends ParsedStatement implements CQLStatement
|
|||
this.keyspace = keyspace;
|
||||
}
|
||||
|
||||
public int getBoundsTerms()
|
||||
public int getBoundTerms()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2077,7 +2077,7 @@ public class CassandraServer implements Cassandra.Iface
|
|||
" (either the query was not prepared on this host (maybe the host has been restarted?)" +
|
||||
" or you have prepared too many queries and it has been evicted from the internal cache)",
|
||||
itemId));
|
||||
logger.trace("Retrieved prepared statement #{} with {} bind markers", itemId, statement.getBoundsTerms());
|
||||
logger.trace("Retrieved prepared statement #{} with {} bind markers", itemId, statement.getBoundTerms());
|
||||
|
||||
return org.apache.cassandra.cql3.QueryProcessor.processPrepared(statement,
|
||||
cState.getQueryState(),
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.buffer.ChannelBuffers;
|
||||
|
||||
import org.apache.cassandra.cql3.Attributes;
|
||||
import org.apache.cassandra.cql3.CQLStatement;
|
||||
|
|
@ -180,9 +179,9 @@ public class BatchMessage extends Message.Request
|
|||
}
|
||||
|
||||
List<ByteBuffer> queryValues = values.get(i);
|
||||
if (queryValues.size() != statement.getBoundsTerms())
|
||||
if (queryValues.size() != statement.getBoundTerms())
|
||||
throw new InvalidRequestException(String.format("There were %d markers(?) in CQL but %d bound variables",
|
||||
statement.getBoundsTerms(),
|
||||
statement.getBoundTerms(),
|
||||
queryValues.size()));
|
||||
if (!(statement instanceof ModificationStatement))
|
||||
throw new InvalidRequestException("Invalid statement in batch: only UPDATE, INSERT and DELETE statements are allowed.");
|
||||
|
|
|
|||
Loading…
Reference in New Issue