Remove unique index from query execution
Summary: Remove leftover unique index code from query execution. Reviewers: teon.banek, mtomic Reviewed By: teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2078
This commit is contained in:
parent
b57e50865e
commit
e4fd49a530
@ -7,6 +7,7 @@
|
||||
* `indexInfo()` function replaced with `SHOW INDEX INFO` syntax.
|
||||
* Write-ahead log format changed (not backward compatible).
|
||||
* Snapshot format changed (not backward compatible).
|
||||
* Removed support for unique index. Use unique constraints instead.
|
||||
|
||||
### Major Features and Improvements
|
||||
|
||||
|
@ -1540,7 +1540,7 @@ cpp<#
|
||||
:clone (clone-name-ix-vector "Property")))
|
||||
(:public
|
||||
(lcp:define-enum action
|
||||
(create create-unique drop)
|
||||
(create drop)
|
||||
(:serialize))
|
||||
|
||||
#>cpp
|
||||
|
@ -159,19 +159,6 @@ antlrcpp::Any CypherMainVisitor::visitCreateIndex(
|
||||
return index_query;
|
||||
}
|
||||
|
||||
antlrcpp::Any CypherMainVisitor::visitCreateUniqueIndex(
|
||||
MemgraphCypher::CreateUniqueIndexContext *ctx) {
|
||||
auto *index_query = storage_->Create<IndexQuery>();
|
||||
index_query->action_ = IndexQuery::Action::CREATE_UNIQUE;
|
||||
index_query->label_ = AddLabel(ctx->labelName()->accept(this));
|
||||
index_query->properties_.reserve(ctx->propertyKeyName().size());
|
||||
for (const auto &prop_name : ctx->propertyKeyName()) {
|
||||
PropertyIx name_key = prop_name->accept(this);
|
||||
index_query->properties_.push_back(name_key);
|
||||
}
|
||||
return index_query;
|
||||
}
|
||||
|
||||
antlrcpp::Any CypherMainVisitor::visitDropIndex(
|
||||
MemgraphCypher::DropIndexContext *ctx) {
|
||||
auto *index_query = storage_->Create<IndexQuery>();
|
||||
|
@ -243,12 +243,6 @@ class CypherMainVisitor : public antlropencypher::MemgraphCypherBaseVisitor {
|
||||
antlrcpp::Any visitCreateIndex(
|
||||
MemgraphCypher::CreateIndexContext *ctx) override;
|
||||
|
||||
/**
|
||||
* @return CreateUniqueIndex*
|
||||
*/
|
||||
antlrcpp::Any visitCreateUniqueIndex(
|
||||
MemgraphCypher::CreateUniqueIndexContext *ctx) override;
|
||||
|
||||
/**
|
||||
* @return DropIndex*
|
||||
*/
|
||||
|
@ -56,7 +56,7 @@ profileQuery : PROFILE cypherQuery ;
|
||||
|
||||
cypherQuery : singleQuery ( cypherUnion )* ;
|
||||
|
||||
indexQuery : createIndex | createUniqueIndex | dropIndex;
|
||||
indexQuery : createIndex | dropIndex;
|
||||
|
||||
singleQuery : clause ( clause )* ;
|
||||
|
||||
@ -299,8 +299,6 @@ integerLiteral : DecimalLiteral
|
||||
|
||||
createIndex : CREATE INDEX ON ':' labelName '(' propertyKeyName ')' ;
|
||||
|
||||
createUniqueIndex : CREATE UNIQUE INDEX ON ':' labelName '(' propertyKeyName ( ',' propertyKeyName )* ')' ;
|
||||
|
||||
dropIndex : DROP INDEX ON ':' labelName '(' propertyKeyName ')' ;
|
||||
|
||||
doubleLiteral : FloatingLiteral ;
|
||||
|
@ -533,7 +533,6 @@ Callback HandleStreamQuery(StreamQuery *stream_query,
|
||||
Callback HandleIndexQuery(IndexQuery *index_query,
|
||||
std::function<void()> invalidate_plan_cache,
|
||||
database::GraphDbAccessor *db_accessor) {
|
||||
auto action = index_query->action_;
|
||||
auto label = db_accessor->Label(index_query->label_.name);
|
||||
std::vector<storage::Property> properties;
|
||||
properties.reserve(index_query->properties_.size());
|
||||
@ -547,15 +546,8 @@ Callback HandleIndexQuery(IndexQuery *index_query,
|
||||
|
||||
Callback callback;
|
||||
switch (index_query->action_) {
|
||||
case IndexQuery::Action::CREATE_UNIQUE:
|
||||
#ifdef MG_SINGLE_NODE
|
||||
throw QueryRuntimeException(
|
||||
"Unique index is not supported, use unique constraint instead ");
|
||||
#else
|
||||
throw QueryRuntimeException("Unique index is not supported");
|
||||
#endif
|
||||
case IndexQuery::Action::CREATE:
|
||||
callback.fn = [action, label, properties, db_accessor,
|
||||
callback.fn = [label, properties, db_accessor,
|
||||
invalidate_plan_cache] {
|
||||
try {
|
||||
CHECK(properties.size() == 1);
|
||||
|
@ -1662,35 +1662,6 @@ TEST_P(CypherMainVisitorTest, CreateIndex) {
|
||||
EXPECT_EQ(index_query->properties_, expected_properties);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, CreateUniqueIndex) {
|
||||
auto &ast_generator = *GetParam();
|
||||
auto *index_query = dynamic_cast<IndexQuery *>(
|
||||
ast_generator.ParseQuery("Create unIqUe InDeX oN :mirko(slavko, pero)"));
|
||||
ASSERT_TRUE(index_query);
|
||||
EXPECT_EQ(index_query->action_, IndexQuery::Action::CREATE_UNIQUE);
|
||||
EXPECT_EQ(index_query->label_, ast_generator.Label("mirko"));
|
||||
std::vector<PropertyIx> expected_properties{ast_generator.Prop("slavko"),
|
||||
ast_generator.Prop("pero")};
|
||||
ASSERT_EQ(index_query->properties_, expected_properties);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, CreateUniqueIndexWithoutProperties) {
|
||||
auto &ast_generator = *GetParam();
|
||||
EXPECT_THROW(ast_generator.ParseQuery("Create unIqUe InDeX oN :mirko()"),
|
||||
SyntaxException);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, CreateUniqueIndexWithSingleProperty) {
|
||||
auto &ast_generator = *GetParam();
|
||||
auto *index_query = dynamic_cast<IndexQuery *>(
|
||||
ast_generator.ParseQuery("Create unIqUe InDeX oN :mirko(slavko)"));
|
||||
ASSERT_TRUE(index_query);
|
||||
EXPECT_EQ(index_query->action_, IndexQuery::Action::CREATE_UNIQUE);
|
||||
EXPECT_EQ(index_query->label_, ast_generator.Label("mirko"));
|
||||
std::vector<PropertyIx> expected_properties{ast_generator.Prop("slavko")};
|
||||
ASSERT_EQ(index_query->properties_, expected_properties);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, DropIndex) {
|
||||
auto &ast_generator = *GetParam();
|
||||
auto *index_query = dynamic_cast<IndexQuery *>(
|
||||
|
@ -1766,35 +1766,6 @@ TEST_P(CypherMainVisitorTest, CreateIndex) {
|
||||
EXPECT_EQ(index_query->properties_, expected_properties);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, CreateUniqueIndex) {
|
||||
auto &ast_generator = *GetParam();
|
||||
auto *index_query = dynamic_cast<IndexQuery *>(
|
||||
ast_generator.ParseQuery("Create unIqUe InDeX oN :mirko(slavko, pero)"));
|
||||
ASSERT_TRUE(index_query);
|
||||
EXPECT_EQ(index_query->action_, IndexQuery::Action::CREATE_UNIQUE);
|
||||
EXPECT_EQ(index_query->label_, ast_generator.Label("mirko"));
|
||||
std::vector<PropertyIx> expected_properties{ast_generator.Prop("slavko"),
|
||||
ast_generator.Prop("pero")};
|
||||
ASSERT_EQ(index_query->properties_, expected_properties);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, CreateUniqueIndexWithoutProperties) {
|
||||
auto &ast_generator = *GetParam();
|
||||
EXPECT_THROW(ast_generator.ParseQuery("Create unIqUe InDeX oN :mirko()"),
|
||||
SyntaxException);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, CreateUniqueIndexWithSingleProperty) {
|
||||
auto &ast_generator = *GetParam();
|
||||
auto *index_query = dynamic_cast<IndexQuery *>(
|
||||
ast_generator.ParseQuery("Create unIqUe InDeX oN :mirko(slavko)"));
|
||||
ASSERT_TRUE(index_query);
|
||||
EXPECT_EQ(index_query->action_, IndexQuery::Action::CREATE_UNIQUE);
|
||||
EXPECT_EQ(index_query->label_, ast_generator.Label("mirko"));
|
||||
std::vector<PropertyIx> expected_properties{ast_generator.Prop("slavko")};
|
||||
ASSERT_EQ(index_query->properties_, expected_properties);
|
||||
}
|
||||
|
||||
TEST_P(CypherMainVisitorTest, DropIndex) {
|
||||
auto &ast_generator = *GetParam();
|
||||
auto *index_query = dynamic_cast<IndexQuery *>(
|
||||
|
Loading…
Reference in New Issue
Block a user