mirror of https://github.com/apache/cassandra
Merge branch 'cassandra-2.0' into cassandra-2.1
Conflicts: CHANGES.txt
This commit is contained in:
commit
7fa034136a
|
|
@ -18,6 +18,8 @@
|
|||
* Improve JBOD disk utilization (CASSANDRA-7386)
|
||||
* Log failed host when preparing incremental repair (CASSANDRA-8228)
|
||||
Merged from 2.0:
|
||||
* Throw correct exception when trying to bind a keyspace or table
|
||||
name (CASSANDRA-6952)
|
||||
* Make HHOM.compact synchronized (CASSANDRA-8416)
|
||||
* cancel latency-sampling task when CF is dropped (CASSANDRA-8401)
|
||||
* don't block SocketThread for MessagingService (CASSANDRA-8188)
|
||||
|
|
|
|||
|
|
@ -859,6 +859,7 @@ cfOrKsName[CFName name, boolean isKs]
|
|||
: t=IDENT { if (isKs) $name.setKeyspace($t.text, false); else $name.setColumnFamily($t.text, false); }
|
||||
| t=QUOTED_NAME { if (isKs) $name.setKeyspace($t.text, true); else $name.setColumnFamily($t.text, true); }
|
||||
| k=unreserved_keyword { if (isKs) $name.setKeyspace(k, false); else $name.setColumnFamily(k, false); }
|
||||
| QMARK {addRecognitionError("Bind variables cannot be used for keyspace or table names");}
|
||||
;
|
||||
|
||||
constant returns [Constants.Literal constant]
|
||||
|
|
|
|||
|
|
@ -384,13 +384,17 @@ public abstract class CQLTester
|
|||
{
|
||||
if (errorMessage != null)
|
||||
{
|
||||
Assert.assertTrue("Expected error message to contain '" + errorMessage + "', but got '" + e.getMessage() + "'",
|
||||
e.getMessage().contains(errorMessage));
|
||||
assertMessageContains(errorMessage, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void assertInvalidSyntax(String query, Object... values) throws Throwable
|
||||
{
|
||||
assertInvalidSyntaxMessage(null, query, values);
|
||||
}
|
||||
|
||||
protected void assertInvalidSyntaxMessage(String errorMessage, String query, Object... values) throws Throwable
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -402,10 +406,25 @@ public abstract class CQLTester
|
|||
}
|
||||
catch (SyntaxException e)
|
||||
{
|
||||
// This is what we expect
|
||||
if (errorMessage != null)
|
||||
{
|
||||
assertMessageContains(errorMessage, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the message of the specified exception contains the specified text.
|
||||
*
|
||||
* @param text the text that the exception message must contains
|
||||
* @param e the exception to check
|
||||
*/
|
||||
private static void assertMessageContains(String text, Exception e)
|
||||
{
|
||||
Assert.assertTrue("Expected error message to contain '" + text + "', but got '" + e.getMessage() + "'",
|
||||
e.getMessage().contains(text));
|
||||
}
|
||||
|
||||
private static String replaceValues(String query, Object[] values)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.cassandra.cql3;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class UseStatementTest extends CQLTester
|
||||
{
|
||||
@Test
|
||||
public void testUseStatementWithBindVariable() throws Throwable
|
||||
{
|
||||
assertInvalidSyntaxMessage("Bind variables cannot be used for keyspace or table names", "USE ?");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue