Merge branch 'master' into Implement-constant-time-label-and-edge-type-retrieval
This commit is contained in:
commit
eeb9671bac
@ -234,11 +234,55 @@ std::pair<std::vector<std::string>, std::optional<int>> SessionHL::Interpret(
|
||||
throw memgraph::communication::bolt::ClientError(e.what());
|
||||
}
|
||||
}
|
||||
void SessionHL::RollbackTransaction() { interpreter_.RollbackTransaction(); }
|
||||
void SessionHL::CommitTransaction() { interpreter_.CommitTransaction(); }
|
||||
void SessionHL::BeginTransaction(const std::map<std::string, memgraph::communication::bolt::Value> &extra) {
|
||||
interpreter_.BeginTransaction(ToQueryExtras(extra));
|
||||
|
||||
void SessionHL::RollbackTransaction() {
|
||||
try {
|
||||
interpreter_.RollbackTransaction();
|
||||
} catch (const memgraph::query::QueryException &e) {
|
||||
// Count the number of specific exceptions thrown
|
||||
metrics::IncrementCounter(GetExceptionName(e));
|
||||
// Wrap QueryException into ClientError, because we want to allow the
|
||||
// client to fix their query.
|
||||
throw memgraph::communication::bolt::ClientError(e.what());
|
||||
} catch (const memgraph::query::ReplicationException &e) {
|
||||
// Count the number of specific exceptions thrown
|
||||
metrics::IncrementCounter(GetExceptionName(e));
|
||||
throw memgraph::communication::bolt::ClientError(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void SessionHL::CommitTransaction() {
|
||||
try {
|
||||
interpreter_.CommitTransaction();
|
||||
} catch (const memgraph::query::QueryException &e) {
|
||||
// Count the number of specific exceptions thrown
|
||||
metrics::IncrementCounter(GetExceptionName(e));
|
||||
// Wrap QueryException into ClientError, because we want to allow the
|
||||
// client to fix their query.
|
||||
throw memgraph::communication::bolt::ClientError(e.what());
|
||||
} catch (const memgraph::query::ReplicationException &e) {
|
||||
// Count the number of specific exceptions thrown
|
||||
metrics::IncrementCounter(GetExceptionName(e));
|
||||
throw memgraph::communication::bolt::ClientError(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void SessionHL::BeginTransaction(const std::map<std::string, memgraph::communication::bolt::Value> &extra) {
|
||||
try {
|
||||
interpreter_.BeginTransaction(ToQueryExtras(extra));
|
||||
} catch (const memgraph::query::QueryException &e) {
|
||||
// Count the number of specific exceptions thrown
|
||||
metrics::IncrementCounter(GetExceptionName(e));
|
||||
// Wrap QueryException into ClientError, because we want to allow the
|
||||
// client to fix their query.
|
||||
throw memgraph::communication::bolt::ClientError(e.what());
|
||||
} catch (const memgraph::query::ReplicationException &e) {
|
||||
// Count the number of specific exceptions thrown
|
||||
metrics::IncrementCounter(GetExceptionName(e));
|
||||
throw memgraph::communication::bolt::ClientError(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void SessionHL::Configure(const std::map<std::string, memgraph::communication::bolt::Value> &run_time_info) {
|
||||
#ifdef MG_ENTERPRISE
|
||||
std::string db;
|
||||
|
@ -96,12 +96,12 @@ def clear_db(session):
|
||||
with GraphDatabase.driver("bolt://localhost:7687", auth=None, encrypted=False) as driver:
|
||||
with driver.session() as session:
|
||||
# Clear the DB
|
||||
session.run("MATCH (n) DETACH DELETE n;")
|
||||
session.run("MATCH (n) DETACH DELETE n;").consume()
|
||||
|
||||
# Add constraints
|
||||
session.run("CREATE CONSTRAINT ON (n:Person) ASSERT n.id IS UNIQUE;")
|
||||
session.run("CREATE CONSTRAINT ON (n:Employee) ASSERT n.id IS UNIQUE;")
|
||||
session.run("CREATE CONSTRAINT ON (n:Employee) ASSERT EXISTS (n.id);")
|
||||
session.run("CREATE CONSTRAINT ON (n:Person) ASSERT n.id IS UNIQUE;").consume()
|
||||
session.run("CREATE CONSTRAINT ON (n:Employee) ASSERT n.id IS UNIQUE;").consume()
|
||||
session.run("CREATE CONSTRAINT ON (n:Employee) ASSERT EXISTS (n.id);").consume()
|
||||
|
||||
# Set the initial graph state
|
||||
session.execute_write(lambda tx: tx.run("CREATE (n:Employee:Person {id: '123', alt_id: '100'}) RETURN n;"))
|
||||
@ -109,18 +109,18 @@ with GraphDatabase.driver("bolt://localhost:7687", auth=None, encrypted=False) a
|
||||
# Run a transaction that violates a constraint
|
||||
try:
|
||||
session.execute_write(violate_constraint)
|
||||
except TransientError:
|
||||
except ClientError:
|
||||
pass
|
||||
else:
|
||||
clear_db(session)
|
||||
raise Exception("neo4j.exceptions.TransientError should have been thrown!")
|
||||
raise Exception("neo4j.exceptions.ClientError should have been thrown!")
|
||||
|
||||
# Run a transaction that violates no constraints even though an intermediate result does
|
||||
try:
|
||||
session.execute_write(violate_constraint_on_intermediate_result)
|
||||
except TransientError:
|
||||
except ClientError:
|
||||
clear_db(session)
|
||||
raise Exception("neo4j.exceptions.TransientError should not have been thrown!")
|
||||
raise Exception("neo4j.exceptions.ClientError should not have been thrown!")
|
||||
|
||||
clear_db(session)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user