mirror of https://github.com/apache/cassandra
Merge branch 'cassandra-5.0' into trunk
This commit is contained in:
commit
2df8875502
|
|
@ -13,6 +13,7 @@ Merged from 4.0:
|
|||
Merged from 3.11:
|
||||
* Fix NPE when using udfContext in UDF after a restart of a node (CASSANDRA-18739)
|
||||
Merged from 3.0:
|
||||
* Make alternation of a user type validate the same way as creation of a user type does (CASSANDRA-18585)
|
||||
* Fix missing speculative retries in tablestats (CASSANDRA-18767)
|
||||
* Fix Requires for Java for RPM package (CASSANDRA-18751)
|
||||
* Fix CQLSH online help topic link (CASSANDRA-17534)
|
||||
|
|
|
|||
|
|
@ -127,6 +127,12 @@ public abstract class AlterTypeStatement extends AlterSchemaStatement
|
|||
|
||||
UserType apply(KeyspaceMetadata keyspace, UserType userType)
|
||||
{
|
||||
if (type.isCounter())
|
||||
throw ire("A user type cannot contain counters");
|
||||
|
||||
if (type.isUDT() && !type.isFrozen())
|
||||
throw ire("A user type cannot contain non-frozen UDTs");
|
||||
|
||||
if (userType.fieldPosition(fieldName) >= 0)
|
||||
{
|
||||
if (!ifFieldNotExists)
|
||||
|
|
|
|||
|
|
@ -136,6 +136,10 @@ public class UserTypesTest extends CQLTester
|
|||
assertInvalidMessage("A user type cannot contain non-frozen UDTs",
|
||||
"CREATE TYPE " + KEYSPACE + ".wrong (a int, b " + myType + ")");
|
||||
|
||||
String ut1 = createType(KEYSPACE, "CREATE TYPE %s (a int)");
|
||||
assertInvalidMessage("A user type cannot contain non-frozen UDTs",
|
||||
"ALTER TYPE " + KEYSPACE + "." + ut1 + " ADD b " + myType);
|
||||
|
||||
// referencing a UDT in another keyspace
|
||||
assertInvalidMessage("Statement on keyspace " + KEYSPACE + " cannot refer to a user type in keyspace otherkeyspace;" +
|
||||
" user types can only be used in the keyspace they are defined in",
|
||||
|
|
@ -530,6 +534,20 @@ public class UserTypesTest extends CQLTester
|
|||
execute("SELECT addresses FROM %s WHERE id = ? ", userID_1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateTypeWithUndesiredFieldType() throws Throwable
|
||||
{
|
||||
String typeName = createTypeName();
|
||||
assertInvalidMessage("A user type cannot contain counters", "CREATE TYPE " + typeWithKs(typeName) + " (f counter)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAlterTypeWithUndesiredFieldType() throws Throwable
|
||||
{
|
||||
String typeName = createType("CREATE TYPE %s (a int)");
|
||||
assertInvalidMessage("A user type cannot contain counters", "ALTER TYPE " + typeWithKs(typeName) + " ADD f counter");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test user type test that does a little more nesting,
|
||||
* migrated from cql_tests.py:TestCQL.more_user_types_test()
|
||||
|
|
|
|||
Loading…
Reference in New Issue