Merge branch 'cassandra-3.11' into cassandra-4.0

This commit is contained in:
Bereng 2021-09-20 09:44:02 +02:00
commit e98be8e3ec
2 changed files with 13 additions and 3 deletions

View File

@ -65,9 +65,10 @@ public final class AlterViewStatement extends AlterSchemaStatement
if (params.defaultTimeToLive > 0)
{
throw ire("Cannot set or alter default_time_to_live for a materialized view. " +
throw ire("Forbidden default_time_to_live detected for a materialized view. " +
"Data in a materialized view always expire at the same time than " +
"the corresponding data in the parent table.");
"the corresponding data in the parent table. default_time_to_live " +
"must be set to zero, see CASSANDRA-12868 for more information");
}
ViewMetadata newView = view.copy(view.metadata.withSwapped(params));

View File

@ -29,6 +29,8 @@ import com.datastax.driver.core.Row;
import org.apache.cassandra.db.Keyspace;
import org.apache.cassandra.utils.FBUtilities;
import static org.junit.Assert.assertEquals;
/*
* This test class was too large and used to timeout CASSANDRA-16777. We're splitting it into:
* - ViewTest
@ -285,16 +287,23 @@ public class ViewTimesTest extends ViewAbstractTest
"c int, " +
"val int) WITH default_time_to_live = 60");
execute("USE " + keyspace());
executeNet("USE " + keyspace());
createView("mv_ttl2", "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s WHERE k IS NOT NULL AND c IS NOT NULL PRIMARY KEY (k,c)");
// Must NOT include "default_time_to_live" on alter Materialized View
try
{
executeNet("ALTER MATERIALIZED VIEW %s WITH default_time_to_live = 30");
executeNet("ALTER MATERIALIZED VIEW " + keyspace()+ ".mv_ttl2 WITH default_time_to_live = 30");
Assert.fail("Should fail if TTL is provided while altering materialized view");
}
catch (Exception e)
{
// Make sure the message is clear. See CASSANDRA-16960
assertEquals("Forbidden default_time_to_live detected for a materialized view. Data in a materialized view always expire at the same time than the corresponding "
+ "data in the parent table. default_time_to_live must be set to zero, see CASSANDRA-12868 for more information",
e.getMessage());
}
}
}