Add unique constraint to label property index

Summary:
LabelPropertyIndex now has the ability to enforce unique constraint.

This doesn't lock the tx engine.

Reviewers: teon.banek, mferencevic

Reviewed By: teon.banek

Subscribers: pullbot, vkasljevic, buda

Differential Revision: https://phabricator.memgraph.io/D1660
This commit is contained in:
Matija Santl
2018-10-15 16:12:02 +02:00
parent cdaf7581bf
commit fb6284cb99
23 changed files with 249 additions and 91 deletions

View File

@@ -966,20 +966,17 @@ TEST(QueryPlan, CreateIndex) {
}
TEST(QueryPlan, CreateUniqueIndex) {
// CREATE UNIQUE INDEX ON :Label(prop1, prop2)
// CREATE UNIQUE INDEX ON :Label(prop1)
database::GraphDb db;
auto dba = db.Access();
auto label = dba->Label("label");
auto prop1 = dba->Property("prop1");
auto prop2 = dba->Property("prop2");
std::vector<storage::Property> properties{prop1, prop2};
std::vector<storage::Property> properties{prop1};
auto create_index =
std::make_shared<plan::CreateIndex>(label, properties, true);
SymbolTable symbol_table;
EXPECT_THROW(PullAll(create_index, *dba, symbol_table),
utils::NotYetImplemented);
// TODO: Check unique index created
// EXPECT_EQ(PullAll(create_index, *dba, symbol_table), 1);
EXPECT_EQ(PullAll(create_index, *dba, symbol_table), 1);
EXPECT_TRUE(dba->LabelPropertyIndexExists(label, prop1));
}
TEST(QueryPlan, DeleteSetProperty) {