2017-03-15 21:08:58 +08:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-19 21:52:20 +08:00
|
|
|
#include "utils/exceptions.hpp"
|
2017-03-15 21:08:58 +08:00
|
|
|
|
2017-03-22 16:42:43 +08:00
|
|
|
#include <fmt/format.h>
|
|
|
|
|
2017-03-15 21:08:58 +08:00
|
|
|
namespace query {
|
|
|
|
|
2017-10-09 22:09:17 +08:00
|
|
|
/**
|
|
|
|
* @brief Base class of all query language related exceptions. All exceptions
|
|
|
|
* derived from this one will be interpreted as ClientError-s, i. e. if client
|
|
|
|
* executes same query again without making modifications to the database data,
|
|
|
|
* query will fail again.
|
2017-04-12 20:38:22 +08:00
|
|
|
*/
|
2017-04-19 21:52:20 +08:00
|
|
|
class QueryException : public utils::BasicException {
|
|
|
|
using utils::BasicException::BasicException;
|
2017-04-12 20:38:22 +08:00
|
|
|
};
|
|
|
|
|
2017-06-21 22:10:52 +08:00
|
|
|
class LexingException : public QueryException {
|
|
|
|
public:
|
|
|
|
using QueryException::QueryException;
|
|
|
|
LexingException() : QueryException("") {}
|
|
|
|
};
|
|
|
|
|
2017-04-12 20:38:22 +08:00
|
|
|
class SyntaxException : public QueryException {
|
|
|
|
public:
|
|
|
|
using QueryException::QueryException;
|
|
|
|
SyntaxException() : QueryException("") {}
|
2017-03-15 21:08:58 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
// TODO: Figure out what information to put in exception.
|
|
|
|
// Error reporting is tricky since we get stripped query and position of error
|
|
|
|
// in original query is not same as position of error in stripped query. Most
|
|
|
|
// correct approach would be to do semantic analysis with original query even
|
|
|
|
// for already hashed queries, but that has obvious performance issues. Other
|
|
|
|
// approach would be to report some of the semantic errors in runtime of the
|
|
|
|
// query and only report line numbers of semantic errors (not position in the
|
|
|
|
// line) if multiple line strings are not allowed by grammar. We could also
|
|
|
|
// print whole line that contains error instead of specifying line number.
|
2017-04-12 20:38:22 +08:00
|
|
|
class SemanticException : public QueryException {
|
2017-03-15 21:08:58 +08:00
|
|
|
public:
|
2017-04-12 20:38:22 +08:00
|
|
|
using QueryException::QueryException;
|
|
|
|
SemanticException() : QueryException("") {}
|
2017-03-15 21:08:58 +08:00
|
|
|
};
|
|
|
|
|
2017-03-17 16:57:20 +08:00
|
|
|
class UnboundVariableError : public SemanticException {
|
|
|
|
public:
|
2021-02-18 22:32:43 +08:00
|
|
|
explicit UnboundVariableError(const std::string &name) : SemanticException("Unbound variable: " + name + ".") {}
|
2017-03-17 16:57:20 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class RedeclareVariableError : public SemanticException {
|
|
|
|
public:
|
2021-02-18 22:32:43 +08:00
|
|
|
explicit RedeclareVariableError(const std::string &name) : SemanticException("Redeclaring variable: " + name + ".") {}
|
2017-03-17 16:57:20 +08:00
|
|
|
};
|
|
|
|
|
2017-03-22 16:42:43 +08:00
|
|
|
class TypeMismatchError : public SemanticException {
|
|
|
|
public:
|
2021-02-18 22:32:43 +08:00
|
|
|
TypeMismatchError(const std::string &name, const std::string &datum, const std::string &expected)
|
|
|
|
: SemanticException(fmt::format("Type mismatch: {} already defined as {}, expected {}.", name, datum, expected)) {
|
|
|
|
}
|
2017-03-22 16:42:43 +08:00
|
|
|
};
|
|
|
|
|
2017-07-20 00:14:59 +08:00
|
|
|
class UnprovidedParameterError : public QueryException {
|
|
|
|
public:
|
|
|
|
using QueryException::QueryException;
|
|
|
|
};
|
|
|
|
|
2019-01-15 18:11:06 +08:00
|
|
|
class ProfileInMulticommandTxException : public QueryException {
|
|
|
|
public:
|
|
|
|
using QueryException::QueryException;
|
2021-02-18 22:32:43 +08:00
|
|
|
ProfileInMulticommandTxException() : QueryException("PROFILE not allowed in multicommand transactions.") {}
|
2019-01-15 18:11:06 +08:00
|
|
|
};
|
|
|
|
|
2017-10-10 00:09:28 +08:00
|
|
|
class IndexInMulticommandTxException : public QueryException {
|
|
|
|
public:
|
|
|
|
using QueryException::QueryException;
|
2021-02-18 22:32:43 +08:00
|
|
|
IndexInMulticommandTxException() : QueryException("Index manipulation not allowed in multicommand transactions.") {}
|
2017-10-10 00:09:28 +08:00
|
|
|
};
|
|
|
|
|
2020-06-10 17:26:13 +08:00
|
|
|
class ConstraintInMulticommandTxException : public QueryException {
|
|
|
|
public:
|
|
|
|
using QueryException::QueryException;
|
|
|
|
ConstraintInMulticommandTxException()
|
|
|
|
: QueryException(
|
|
|
|
"Constraint manipulation not allowed in multicommand "
|
|
|
|
"transactions.") {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class InfoInMulticommandTxException : public QueryException {
|
|
|
|
public:
|
|
|
|
using QueryException::QueryException;
|
2021-02-18 22:32:43 +08:00
|
|
|
InfoInMulticommandTxException() : QueryException("Info reporting not allowed in multicommand transactions.") {}
|
2020-06-10 17:26:13 +08:00
|
|
|
};
|
|
|
|
|
2017-03-27 19:09:14 +08:00
|
|
|
/**
|
|
|
|
* An exception for an illegal operation that can not be detected
|
|
|
|
* before the query starts executing over data.
|
|
|
|
*/
|
2017-04-12 20:38:22 +08:00
|
|
|
class QueryRuntimeException : public QueryException {
|
2017-03-15 21:08:58 +08:00
|
|
|
public:
|
2017-04-13 19:45:46 +08:00
|
|
|
using QueryException::QueryException;
|
2017-03-15 21:08:58 +08:00
|
|
|
};
|
|
|
|
|
2017-10-09 22:09:17 +08:00
|
|
|
// This one is inherited from BasicException and will be treated as
|
|
|
|
// TransientError, i. e. client will be encouraged to retry execution because it
|
|
|
|
// could succeed if executed again.
|
|
|
|
class HintedAbortError : public utils::BasicException {
|
2017-03-15 21:08:58 +08:00
|
|
|
public:
|
2017-10-09 22:09:17 +08:00
|
|
|
using utils::BasicException::BasicException;
|
|
|
|
HintedAbortError()
|
|
|
|
: utils::BasicException(
|
|
|
|
"Transaction was asked to abort, most likely because it was "
|
|
|
|
"executing longer than time specified by "
|
2019-11-25 22:08:16 +08:00
|
|
|
"--query-execution-timeout-sec flag.") {}
|
2017-03-15 21:08:58 +08:00
|
|
|
};
|
|
|
|
|
2019-10-30 21:05:47 +08:00
|
|
|
class ExplicitTransactionUsageException : public QueryRuntimeException {
|
|
|
|
public:
|
|
|
|
using QueryRuntimeException::QueryRuntimeException;
|
|
|
|
};
|
|
|
|
|
2018-02-08 20:27:07 +08:00
|
|
|
class ReconstructionException : public QueryException {
|
|
|
|
public:
|
|
|
|
ReconstructionException()
|
|
|
|
: QueryException(
|
|
|
|
"Record invalid after WITH clause. Most likely deleted by a "
|
|
|
|
"preceeding DELETE.") {}
|
|
|
|
};
|
|
|
|
|
2018-02-28 17:36:48 +08:00
|
|
|
class RemoveAttachedVertexException : public QueryRuntimeException {
|
|
|
|
public:
|
|
|
|
RemoveAttachedVertexException()
|
|
|
|
: QueryRuntimeException(
|
2018-08-29 17:05:34 +08:00
|
|
|
"Failed to remove node because of it's existing "
|
2018-02-28 17:36:48 +08:00
|
|
|
"connections. Consider using DETACH DELETE.") {}
|
|
|
|
};
|
|
|
|
|
2018-06-14 22:02:27 +08:00
|
|
|
class UserModificationInMulticommandTxException : public QueryException {
|
|
|
|
public:
|
|
|
|
UserModificationInMulticommandTxException()
|
2021-02-18 22:32:43 +08:00
|
|
|
: QueryException("Authentication clause not allowed in multicommand transactions.") {}
|
2018-06-14 22:02:27 +08:00
|
|
|
};
|
|
|
|
|
2018-06-15 22:12:44 +08:00
|
|
|
class StreamClauseInMulticommandTxException : public QueryException {
|
|
|
|
public:
|
2021-02-18 22:32:43 +08:00
|
|
|
StreamClauseInMulticommandTxException() : QueryException("Stream clause not allowed in multicommand transactions.") {}
|
2018-06-15 22:12:44 +08:00
|
|
|
};
|
|
|
|
|
2020-10-16 18:49:33 +08:00
|
|
|
class InvalidArgumentsException : public QueryException {
|
|
|
|
public:
|
2021-02-18 22:32:43 +08:00
|
|
|
InvalidArgumentsException(const std::string &argument_name, const std::string &message)
|
|
|
|
: QueryException(fmt::format("Invalid arguments sent: {} - {}", argument_name, message)) {}
|
2020-10-16 18:49:33 +08:00
|
|
|
};
|
|
|
|
|
2020-10-01 19:58:25 +08:00
|
|
|
class ReplicationModificationInMulticommandTxException : public QueryException {
|
|
|
|
public:
|
|
|
|
ReplicationModificationInMulticommandTxException()
|
2021-02-18 22:32:43 +08:00
|
|
|
: QueryException("Replication clause not allowed in multicommand transactions.") {}
|
2020-10-01 19:58:25 +08:00
|
|
|
};
|
|
|
|
|
2021-01-19 19:10:06 +08:00
|
|
|
class LockPathModificationInMulticommandTxException : public QueryException {
|
|
|
|
public:
|
|
|
|
LockPathModificationInMulticommandTxException()
|
2021-05-14 21:38:59 +08:00
|
|
|
: QueryException("Lock path query not allowed in multicommand transactions.") {}
|
2021-01-19 19:10:06 +08:00
|
|
|
};
|
|
|
|
|
2021-03-04 19:20:11 +08:00
|
|
|
class FreeMemoryModificationInMulticommandTxException : public QueryException {
|
|
|
|
public:
|
|
|
|
FreeMemoryModificationInMulticommandTxException()
|
2021-05-14 21:38:59 +08:00
|
|
|
: QueryException("Free memory query not allowed in multicommand transactions.") {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class TriggerModificationInMulticommandTxException : public QueryException {
|
|
|
|
public:
|
|
|
|
TriggerModificationInMulticommandTxException()
|
|
|
|
: QueryException("Trigger queries not allowed in multicommand transactions.") {}
|
2021-03-04 19:20:11 +08:00
|
|
|
};
|
2021-06-14 21:47:57 +08:00
|
|
|
|
|
|
|
class IsolationLevelModificationInMulticommandTxException : public QueryException {
|
|
|
|
public:
|
|
|
|
IsolationLevelModificationInMulticommandTxException()
|
|
|
|
: QueryException("Isolation level cannot be modified in multicommand transactions.") {}
|
|
|
|
};
|
2017-04-13 19:45:46 +08:00
|
|
|
} // namespace query
|