mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
secondary indexes: fail attempts to create a CUSTOM INDEX
Cassandra supports a "CREATE CUSTOM INDEX" to create a secondary index
with a custom implementation. The only custom implementation that Cassandra
supports is SASI. But Scylla doesn't support this, or any other custom
index implementation. If a CREATE CUSTOM INDEX statement is used, we
shouldn't silently ignore the "CUSTOM" tag, we should generate an error.
This patch also includes a regression test that "CREATE CUSTOM INDEX"
statements with valid syntax fail (before this patch, they succeeded).
Fixes #3977
Signed-off-by: Nadav Har'El <nyh@scylladb.com>
Message-Id: <20181211224545.18349-2-nyh@scylladb.com>
(cherry picked from commit a0379209e6)
This commit is contained in:
committed by
Duarte Nunes
parent
b18e9e115d
commit
e91c741ef5
@@ -64,6 +64,16 @@ void cql3::statements::index_prop_defs::validate() {
|
||||
sprint("Cannot specify %s as a CUSTOM option",
|
||||
db::index::secondary_index::custom_index_option_name));
|
||||
}
|
||||
|
||||
// Currently, Scylla does not support *any* class of custom index
|
||||
// implementation. If in the future we do (e.g., SASI, or something
|
||||
// new), we'll need to check for valid values here.
|
||||
if (is_custom && custom_class) {
|
||||
throw exceptions::invalid_request_exception(
|
||||
format("Unsupported CUSTOM INDEX class {}. Note that currently, Scylla does not support SASI or any other CUSTOM INDEX class.",
|
||||
*custom_class));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
index_options_map
|
||||
|
||||
@@ -503,3 +503,34 @@ SEASTAR_TEST_CASE(test_secondary_index_collections) {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Test for issue #3977 - we do not support SASI, nor any other types of
|
||||
// custom index implementations, so "create custom index" commands should
|
||||
// fail, rather than be silently ignored. Also check that various improper
|
||||
// combination of parameters related to custom indexes are rejected as well.
|
||||
SEASTAR_TEST_CASE(test_secondary_index_create_custom_index) {
|
||||
return do_with_cql_env_thread([] (cql_test_env& e) {
|
||||
e.execute_cql("create table cf (p int primary key, a int)").get();
|
||||
// Creating an index on column a works, obviously.
|
||||
e.execute_cql("create index on cf (a)").get();
|
||||
// The following is legal syntax on Cassandra, to create a SASI index.
|
||||
// However, we don't support SASI, so this should fail. Not be silently
|
||||
// ignored as it was before #3977 was fixed.
|
||||
assert_that_failed(e.execute_cql("create custom index on cf (a) using 'org.apache.cassandra.index.sasi.SASIIndex'"));
|
||||
// Even if we ever support SASI (and the above check should be
|
||||
// changed to expect success), we'll never support a custom index
|
||||
// class with the following ridiculous name, so the following should
|
||||
// continue to fail.
|
||||
assert_that_failed(e.execute_cql("create custom index on cf (a) using 'a.ridiculous.name'"));
|
||||
// It's a syntax error to try to create a "custom index" without
|
||||
// specifying a class name in "USING". We expect exception:
|
||||
// "exceptions::invalid_request_exception: CUSTOM index requires
|
||||
// specifying the index class"
|
||||
assert_that_failed(e.execute_cql("create custom index on cf (a)"));
|
||||
// It's also a syntax error to try to specify a "USING" without
|
||||
// specifying CUSTOM. We expect the exception:
|
||||
// "exceptions::invalid_request_exception: Cannot specify index class
|
||||
// for a non-CUSTOM index"
|
||||
assert_that_failed(e.execute_cql("create index on cf (a) using 'org.apache.cassandra.index.sasi.SASIIndex'"));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user