diff --git a/db/executor.go b/db/executor.go index 6459f4e2..0947000d 100644 --- a/db/executor.go +++ b/db/executor.go @@ -165,7 +165,7 @@ func (e *executor) execute(ctx context.Context, ast *sql.Query) { if err == nil { res, err = e.operate(ctx, stm) } else { - res, err = []interface{}{}, queryNotExecuted + res, err = []interface{}{}, errQueryNotExecuted } rsp = &Response{ diff --git a/db/fetch.go b/db/fetch.go index 177bd4a6..43e71d42 100644 --- a/db/fetch.go +++ b/db/fetch.go @@ -279,11 +279,11 @@ func (e *executor) fetchPaths(ctx context.Context, doc *data.Doc, exprs ...sql.E case sql.DOT: return e.fetchPaths(ctx, doc, exprs...) case sql.OEDGE: - return nil, featureNotImplemented + return nil, errFeatureNotImplemented case sql.IEDGE: - return nil, featureNotImplemented + return nil, errFeatureNotImplemented case sql.BEDGE: - return nil, featureNotImplemented + return nil, errFeatureNotImplemented } case *sql.PartExpression: switch val := val.Part.(type) { diff --git a/db/table.go b/db/table.go index 3af792cc..9f3b98d2 100644 --- a/db/table.go +++ b/db/table.go @@ -61,7 +61,7 @@ func (d *document) table(ctx context.Context, when method) (err error) { // If there are GROUP BY clauses then // let's calculate the - return featureNotImplemented + return errFeatureNotImplemented ats := make([]interface{}, len(ft.Group)) diff --git a/db/vars.go b/db/vars.go index f52bd360..5b2f1a85 100644 --- a/db/vars.go +++ b/db/vars.go @@ -63,9 +63,31 @@ const ( ) var ( - workerCount = runtime.NumCPU() * 2 - queryNotExecuted = errors.New("Query not executed") - queryIdentFailed = errors.New("Found ident but no doc available") - featureNotImplemented = errors.New("Feature is not yet implemented") - paramSearchKeys = []string{ctxKeySpec, ctxKeySubs, ctxKeyVars, ctxKeyKeep} + // workerCount specifies how many workers should be used + // to process each query statement concurrently. + workerCount = runtime.NumCPU() * 2 + + // 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") + + // 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} )