Skip to content

Commit

Permalink
Merge branch 'cassandra-4.1' into cassandra-5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
smiklosovic committed Aug 23, 2023
2 parents 62cb03c + 8666265 commit 5101894
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
5.0-alpha2
Merged from 4.1:
Merged from 4.0:
Merged from 3.11:
Merged from 3.0:
* Make alternation of a user type validate the same way as creation of a user type does (CASSANDRA-18585)

5.0-alpha1
* Expose bootstrap failure state via JMX and nodetool info (CASSANDRA-18749)
* Reduce size of per-SSTable index components for SAI (CASSANDRA-18673)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ public void validate(ClientState state)

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ public void testInvalidUDTStatements() throws Throwable
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",
Expand Down Expand Up @@ -530,6 +534,20 @@ public void testUserTypes() throws Throwable
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()
Expand Down

0 comments on commit 5101894

Please sign in to comment.