Improve DB error message types
This commit is contained in:
parent
6fe4db6a58
commit
cf68ebffb1
4 changed files with 32 additions and 10 deletions
|
@ -165,7 +165,7 @@ func (e *executor) execute(ctx context.Context, ast *sql.Query) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
res, err = e.operate(ctx, stm)
|
res, err = e.operate(ctx, stm)
|
||||||
} else {
|
} else {
|
||||||
res, err = []interface{}{}, queryNotExecuted
|
res, err = []interface{}{}, errQueryNotExecuted
|
||||||
}
|
}
|
||||||
|
|
||||||
rsp = &Response{
|
rsp = &Response{
|
||||||
|
|
|
@ -279,11 +279,11 @@ func (e *executor) fetchPaths(ctx context.Context, doc *data.Doc, exprs ...sql.E
|
||||||
case sql.DOT:
|
case sql.DOT:
|
||||||
return e.fetchPaths(ctx, doc, exprs...)
|
return e.fetchPaths(ctx, doc, exprs...)
|
||||||
case sql.OEDGE:
|
case sql.OEDGE:
|
||||||
return nil, featureNotImplemented
|
return nil, errFeatureNotImplemented
|
||||||
case sql.IEDGE:
|
case sql.IEDGE:
|
||||||
return nil, featureNotImplemented
|
return nil, errFeatureNotImplemented
|
||||||
case sql.BEDGE:
|
case sql.BEDGE:
|
||||||
return nil, featureNotImplemented
|
return nil, errFeatureNotImplemented
|
||||||
}
|
}
|
||||||
case *sql.PartExpression:
|
case *sql.PartExpression:
|
||||||
switch val := val.Part.(type) {
|
switch val := val.Part.(type) {
|
||||||
|
|
|
@ -61,7 +61,7 @@ func (d *document) table(ctx context.Context, when method) (err error) {
|
||||||
// If there are GROUP BY clauses then
|
// If there are GROUP BY clauses then
|
||||||
// let's calculate the
|
// let's calculate the
|
||||||
|
|
||||||
return featureNotImplemented
|
return errFeatureNotImplemented
|
||||||
|
|
||||||
ats := make([]interface{}, len(ft.Group))
|
ats := make([]interface{}, len(ft.Group))
|
||||||
|
|
||||||
|
|
26
db/vars.go
26
db/vars.go
|
@ -63,9 +63,31 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// workerCount specifies how many workers should be used
|
||||||
|
// to process each query statement concurrently.
|
||||||
workerCount = runtime.NumCPU() * 2
|
workerCount = runtime.NumCPU() * 2
|
||||||
queryNotExecuted = errors.New("Query not executed")
|
|
||||||
|
// queryIdentFailed occurs when a permission query asks
|
||||||
|
// for a field, meaning a document has to be fetched.
|
||||||
queryIdentFailed = errors.New("Found ident but no doc available")
|
queryIdentFailed = errors.New("Found ident but no doc available")
|
||||||
featureNotImplemented = errors.New("Feature is not yet implemented")
|
|
||||||
|
// errQueryNotExecuted occurs when a transaction has
|
||||||
|
// failed, and the following queries are not executed.
|
||||||
|
errQueryNotExecuted = errors.New("Query not executed")
|
||||||
|
|
||||||
|
// errRaceCondition occurs when a record which is locked
|
||||||
|
// for editing, is updated from within a subquery.
|
||||||
|
errRaceCondition = errors.New("Failed to update the same document recursively")
|
||||||
|
|
||||||
|
// errRecursiveOverload occurs when too many subqueries
|
||||||
|
// are executed within one other, causing an endless loop.
|
||||||
|
errRecursiveOverload = errors.New("Infinite loop when running recursive subqueries")
|
||||||
|
|
||||||
|
// errFeatureNotImplemented occurs when a feature which
|
||||||
|
// has not yet been implemented, has been used in a query.
|
||||||
|
errFeatureNotImplemented = errors.New("Feature is not yet implemented")
|
||||||
|
|
||||||
|
// paramSearchKeys specifies the order in which context
|
||||||
|
// variables should be checked for any specified value.
|
||||||
paramSearchKeys = []string{ctxKeySpec, ctxKeySubs, ctxKeyVars, ctxKeyKeep}
|
paramSearchKeys = []string{ctxKeySpec, ctxKeySubs, ctxKeyVars, ctxKeyKeep}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue