Don’t pass txn around, but use executor txn
This commit is contained in:
parent
6807d4c338
commit
a5dc358e4e
11 changed files with 162 additions and 150 deletions
11
db/create.go
11
db/create.go
|
@ -16,14 +16,13 @@ package db
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/abcum/surreal/kvs"
|
||||
"github.com/abcum/surreal/sql"
|
||||
"github.com/abcum/surreal/util/item"
|
||||
"github.com/abcum/surreal/util/keys"
|
||||
"github.com/abcum/surreal/util/uuid"
|
||||
)
|
||||
|
||||
func (e *executor) executeCreateStatement(txn kvs.TX, ast *sql.CreateStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeCreateStatement(ast *sql.CreateStatement) (out []interface{}, err error) {
|
||||
|
||||
for k, w := range ast.What {
|
||||
if what, ok := w.(*sql.Param); ok {
|
||||
|
@ -40,8 +39,8 @@ func (e *executor) executeCreateStatement(txn kvs.TX, ast *sql.CreateStatement)
|
|||
|
||||
case *sql.Thing:
|
||||
key := &keys.Thing{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: what.TB, ID: what.ID}
|
||||
kv, _ := txn.Get(0, key.Encode())
|
||||
doc := item.New(kv, txn, key, e.ctx)
|
||||
kv, _ := e.txn.Get(0, key.Encode())
|
||||
doc := item.New(kv, e.txn, key, e.ctx)
|
||||
if ret, err := create(doc, ast); err != nil {
|
||||
return nil, err
|
||||
} else if ret != nil {
|
||||
|
@ -50,8 +49,8 @@ func (e *executor) executeCreateStatement(txn kvs.TX, ast *sql.CreateStatement)
|
|||
|
||||
case *sql.Table:
|
||||
key := &keys.Thing{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: what.TB, ID: uuid.NewV5(uuid.NewV4().UUID, ast.KV).String()}
|
||||
kv, _ := txn.Get(0, key.Encode())
|
||||
doc := item.New(kv, txn, key, e.ctx)
|
||||
kv, _ := e.txn.Get(0, key.Encode())
|
||||
doc := item.New(kv, e.txn, key, e.ctx)
|
||||
if ret, err := create(doc, ast); err != nil {
|
||||
return nil, err
|
||||
} else if ret != nil {
|
||||
|
|
130
db/db.go
130
db/db.go
|
@ -168,7 +168,6 @@ func Process(ctx *fibre.Context, ast *sql.Query, vars map[string]interface{}) (o
|
|||
func (e *executor) execute(quit <-chan bool, send chan<- *Response) {
|
||||
|
||||
var err error
|
||||
var txn kvs.TX
|
||||
var rsp *Response
|
||||
var buf []*Response
|
||||
var res []interface{}
|
||||
|
@ -184,8 +183,8 @@ func (e *executor) execute(quit <-chan bool, send chan<- *Response) {
|
|||
// query set, then cancel the transaction.
|
||||
|
||||
defer func() {
|
||||
if txn != nil {
|
||||
txn.Cancel()
|
||||
if e.txn != nil {
|
||||
e.txn.Cancel()
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -239,7 +238,7 @@ func (e *executor) execute(quit <-chan bool, send chan<- *Response) {
|
|||
// then reset the error to nil so that the
|
||||
// next statement is not ignored.
|
||||
|
||||
if txn == nil {
|
||||
if e.txn == nil {
|
||||
err = nil
|
||||
}
|
||||
|
||||
|
@ -249,13 +248,13 @@ func (e *executor) execute(quit <-chan bool, send chan<- *Response) {
|
|||
|
||||
switch stm.(type) {
|
||||
case *sql.BeginStatement:
|
||||
txn, err = begin(txn)
|
||||
err = e.begin()
|
||||
continue
|
||||
case *sql.CancelStatement:
|
||||
txn, err, buf = cancel(txn, buf, err, send)
|
||||
err, buf = e.cancel(buf, err, send)
|
||||
continue
|
||||
case *sql.CommitStatement:
|
||||
txn, err, buf = commit(txn, buf, err, send)
|
||||
err, buf = e.commit(buf, err, send)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -270,7 +269,7 @@ func (e *executor) execute(quit <-chan bool, send chan<- *Response) {
|
|||
// subsequent statements in the transaction.
|
||||
|
||||
if err == nil {
|
||||
res, err = e.operate(txn, stm)
|
||||
res, err = e.operate(stm)
|
||||
} else {
|
||||
res, err = []interface{}{}, fmt.Errorf("Query not executed")
|
||||
}
|
||||
|
@ -286,7 +285,7 @@ func (e *executor) execute(quit <-chan bool, send chan<- *Response) {
|
|||
// then we can output the statement response
|
||||
// immediately to the channel.
|
||||
|
||||
if txn == nil {
|
||||
if e.txn == nil {
|
||||
send <- rsp
|
||||
continue
|
||||
}
|
||||
|
@ -295,7 +294,7 @@ func (e *executor) execute(quit <-chan bool, send chan<- *Response) {
|
|||
// must buffer the responses for output at
|
||||
// the end of the transaction.
|
||||
|
||||
if txn != nil {
|
||||
if e.txn != nil {
|
||||
switch stm.(type) {
|
||||
case *sql.ReturnStatement:
|
||||
buf = clear(buf, rsp)
|
||||
|
@ -311,7 +310,7 @@ func (e *executor) execute(quit <-chan bool, send chan<- *Response) {
|
|||
|
||||
}
|
||||
|
||||
func (e *executor) operate(txn kvs.TX, ast sql.Statement) (res []interface{}, err error) {
|
||||
func (e *executor) operate(ast sql.Statement) (res []interface{}, err error) {
|
||||
|
||||
var loc bool
|
||||
|
||||
|
@ -319,22 +318,22 @@ func (e *executor) operate(txn kvs.TX, ast sql.Statement) (res []interface{}, er
|
|||
// then grab a new transaction, ensuring that
|
||||
// it is closed at the end.
|
||||
|
||||
if txn == nil {
|
||||
if e.txn == nil {
|
||||
|
||||
loc = true
|
||||
|
||||
switch ast.(type) {
|
||||
case *sql.InfoStatement:
|
||||
txn, err = readable()
|
||||
e.txn, err = readable()
|
||||
default:
|
||||
txn, err = writable()
|
||||
e.txn, err = writable()
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
defer txn.Close()
|
||||
defer e.txn.Cancel()
|
||||
|
||||
}
|
||||
|
||||
|
@ -345,48 +344,63 @@ func (e *executor) operate(txn kvs.TX, ast sql.Statement) (res []interface{}, er
|
|||
switch stm := ast.(type) {
|
||||
|
||||
case *sql.InfoStatement:
|
||||
res, err = e.executeInfoStatement(txn, stm)
|
||||
res, err = e.executeInfoStatement(stm)
|
||||
|
||||
case *sql.LetStatement:
|
||||
res, err = e.executeLetStatement(txn, stm)
|
||||
res, err = e.executeLetStatement(stm)
|
||||
case *sql.ReturnStatement:
|
||||
res, err = e.executeReturnStatement(txn, stm)
|
||||
res, err = e.executeReturnStatement(stm)
|
||||
|
||||
case *sql.SelectStatement:
|
||||
res, err = e.executeSelectStatement(txn, stm)
|
||||
res, err = e.executeSelectStatement(stm)
|
||||
case *sql.CreateStatement:
|
||||
res, err = e.executeCreateStatement(txn, stm)
|
||||
res, err = e.executeCreateStatement(stm)
|
||||
case *sql.UpdateStatement:
|
||||
res, err = e.executeUpdateStatement(txn, stm)
|
||||
res, err = e.executeUpdateStatement(stm)
|
||||
case *sql.DeleteStatement:
|
||||
res, err = e.executeDeleteStatement(txn, stm)
|
||||
res, err = e.executeDeleteStatement(stm)
|
||||
case *sql.RelateStatement:
|
||||
res, err = e.executeRelateStatement(txn, stm)
|
||||
res, err = e.executeRelateStatement(stm)
|
||||
|
||||
case *sql.DefineNamespaceStatement:
|
||||
res, err = e.executeDefineNamespaceStatement(stm)
|
||||
case *sql.RemoveNamespaceStatement:
|
||||
res, err = e.executeRemoveNamespaceStatement(stm)
|
||||
|
||||
case *sql.DefineDatabaseStatement:
|
||||
res, err = e.executeDefineDatabaseStatement(stm)
|
||||
case *sql.RemoveDatabaseStatement:
|
||||
res, err = e.executeRemoveDatabaseStatement(stm)
|
||||
|
||||
case *sql.DefineLoginStatement:
|
||||
res, err = e.executeDefineLoginStatement(stm)
|
||||
case *sql.RemoveLoginStatement:
|
||||
res, err = e.executeRemoveLoginStatement(stm)
|
||||
|
||||
case *sql.DefineTokenStatement:
|
||||
res, err = e.executeDefineTokenStatement(stm)
|
||||
case *sql.RemoveTokenStatement:
|
||||
res, err = e.executeRemoveTokenStatement(stm)
|
||||
|
||||
case *sql.DefineScopeStatement:
|
||||
res, err = e.executeDefineScopeStatement(txn, stm)
|
||||
res, err = e.executeDefineScopeStatement(stm)
|
||||
case *sql.RemoveScopeStatement:
|
||||
res, err = e.executeRemoveScopeStatement(txn, stm)
|
||||
res, err = e.executeRemoveScopeStatement(stm)
|
||||
|
||||
case *sql.DefineTableStatement:
|
||||
res, err = e.executeDefineTableStatement(txn, stm)
|
||||
res, err = e.executeDefineTableStatement(stm)
|
||||
case *sql.RemoveTableStatement:
|
||||
res, err = e.executeRemoveTableStatement(txn, stm)
|
||||
|
||||
case *sql.DefineRulesStatement:
|
||||
res, err = e.executeDefineRulesStatement(txn, stm)
|
||||
case *sql.RemoveRulesStatement:
|
||||
res, err = e.executeRemoveRulesStatement(txn, stm)
|
||||
res, err = e.executeRemoveTableStatement(stm)
|
||||
|
||||
case *sql.DefineFieldStatement:
|
||||
res, err = e.executeDefineFieldStatement(txn, stm)
|
||||
res, err = e.executeDefineFieldStatement(stm)
|
||||
case *sql.RemoveFieldStatement:
|
||||
res, err = e.executeRemoveFieldStatement(txn, stm)
|
||||
res, err = e.executeRemoveFieldStatement(stm)
|
||||
|
||||
case *sql.DefineIndexStatement:
|
||||
res, err = e.executeDefineIndexStatement(txn, stm)
|
||||
res, err = e.executeDefineIndexStatement(stm)
|
||||
case *sql.RemoveIndexStatement:
|
||||
res, err = e.executeRemoveIndexStatement(txn, stm)
|
||||
res, err = e.executeRemoveIndexStatement(stm)
|
||||
|
||||
}
|
||||
|
||||
|
@ -394,11 +408,11 @@ func (e *executor) operate(txn kvs.TX, ast sql.Statement) (res []interface{}, er
|
|||
// current statement, then commit or cancel
|
||||
// depending on the result error.
|
||||
|
||||
if loc {
|
||||
if loc && !e.txn.Closed() {
|
||||
if err != nil {
|
||||
txn.Cancel()
|
||||
e.txn, err = nil, e.txn.Cancel()
|
||||
} else {
|
||||
txn.Commit()
|
||||
e.txn, err = nil, e.txn.Commit()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -440,20 +454,20 @@ func clear(buf []*Response, rsp *Response) []*Response {
|
|||
return append(buf, rsp)
|
||||
}
|
||||
|
||||
func begin(txn kvs.TX) (tmp kvs.TX, err error) {
|
||||
if txn == nil {
|
||||
txn, err = writable()
|
||||
func (e *executor) begin() (err error) {
|
||||
if e.txn == nil {
|
||||
e.txn, err = writable()
|
||||
}
|
||||
return txn, err
|
||||
return
|
||||
}
|
||||
|
||||
func cancel(txn kvs.TX, buf []*Response, err error, chn chan<- *Response) (kvs.TX, error, []*Response) {
|
||||
func (e *executor) cancel(buf []*Response, err error, chn chan<- *Response) (error, []*Response) {
|
||||
|
||||
if txn == nil {
|
||||
return nil, nil, buf
|
||||
if e.txn == nil {
|
||||
return nil, buf
|
||||
}
|
||||
|
||||
txn.Cancel()
|
||||
e.txn.Cancel()
|
||||
|
||||
for _, v := range buf {
|
||||
v.Status = "ERR"
|
||||
|
@ -465,20 +479,22 @@ func cancel(txn kvs.TX, buf []*Response, err error, chn chan<- *Response) (kvs.T
|
|||
buf = buf[:len(buf)-1]
|
||||
}
|
||||
|
||||
return nil, nil, buf
|
||||
e.txn = nil
|
||||
|
||||
return nil, buf
|
||||
|
||||
}
|
||||
|
||||
func commit(txn kvs.TX, buf []*Response, err error, chn chan<- *Response) (kvs.TX, error, []*Response) {
|
||||
func (e *executor) commit(buf []*Response, err error, chn chan<- *Response) (error, []*Response) {
|
||||
|
||||
if txn == nil {
|
||||
return nil, nil, buf
|
||||
if e.txn == nil {
|
||||
return nil, buf
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
txn.Cancel()
|
||||
e.txn.Cancel()
|
||||
} else {
|
||||
txn.Commit()
|
||||
e.txn.Commit()
|
||||
}
|
||||
|
||||
for _, v := range buf {
|
||||
|
@ -493,14 +509,16 @@ func commit(txn kvs.TX, buf []*Response, err error, chn chan<- *Response) (kvs.T
|
|||
buf = buf[:len(buf)-1]
|
||||
}
|
||||
|
||||
return nil, nil, buf
|
||||
e.txn = nil
|
||||
|
||||
return nil, buf
|
||||
|
||||
}
|
||||
|
||||
func writable() (txn kvs.TX, err error) {
|
||||
return db.Txn(true)
|
||||
return db.Begin(true)
|
||||
}
|
||||
|
||||
func readable() (txn kvs.TX, err error) {
|
||||
return db.Txn(false)
|
||||
return db.Begin(false)
|
||||
}
|
||||
|
|
81
db/define.go
81
db/define.go
|
@ -15,50 +15,49 @@
|
|||
package db
|
||||
|
||||
import (
|
||||
"github.com/abcum/surreal/kvs"
|
||||
"github.com/abcum/surreal/sql"
|
||||
"github.com/abcum/surreal/util/item"
|
||||
"github.com/abcum/surreal/util/keys"
|
||||
"github.com/abcum/surreal/util/pack"
|
||||
)
|
||||
|
||||
func (e *executor) executeDefineNamespaceStatement(txn kvs.TX, ast *sql.DefineNamespaceStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeDefineNamespaceStatement(ast *sql.DefineNamespaceStatement) (out []interface{}, err error) {
|
||||
|
||||
// Set the namespace
|
||||
nkey := &keys.NS{KV: ast.KV, NS: ast.Name}
|
||||
_, err = txn.Put(0, nkey.Encode(), ast.Encode())
|
||||
_, err = e.txn.Put(0, nkey.Encode(), ast.Encode())
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
func (e *executor) executeDefineDatabaseStatement(txn kvs.TX, ast *sql.DefineDatabaseStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeDefineDatabaseStatement(ast *sql.DefineDatabaseStatement) (out []interface{}, err error) {
|
||||
|
||||
// Set the namespace
|
||||
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
||||
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
||||
txn.PutC(0, nkey.Encode(), nval.Encode(), nil)
|
||||
e.txn.PutC(0, nkey.Encode(), nval.Encode(), nil)
|
||||
|
||||
// Set the database
|
||||
dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.Name}
|
||||
_, err = txn.Put(0, dkey.Encode(), ast.Encode())
|
||||
_, err = e.txn.Put(0, dkey.Encode(), ast.Encode())
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
func (e *executor) executeDefineLoginStatement(txn kvs.TX, ast *sql.DefineLoginStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeDefineLoginStatement(ast *sql.DefineLoginStatement) (out []interface{}, err error) {
|
||||
|
||||
if ast.Kind == sql.NAMESPACE {
|
||||
|
||||
// Set the namespace
|
||||
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
||||
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
||||
txn.PutC(0, nkey.Encode(), nval.Encode(), nil)
|
||||
e.txn.PutC(0, nkey.Encode(), nval.Encode(), nil)
|
||||
|
||||
// Set the login
|
||||
ukey := &keys.NU{KV: ast.KV, NS: ast.NS, US: ast.User}
|
||||
_, err = txn.Put(0, ukey.Encode(), ast.Encode())
|
||||
_, err = e.txn.Put(0, ukey.Encode(), ast.Encode())
|
||||
|
||||
}
|
||||
|
||||
|
@ -67,16 +66,16 @@ func (e *executor) executeDefineLoginStatement(txn kvs.TX, ast *sql.DefineLoginS
|
|||
// Set the namespace
|
||||
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
||||
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
||||
txn.PutC(0, nkey.Encode(), nval.Encode(), nil)
|
||||
e.txn.PutC(0, nkey.Encode(), nval.Encode(), nil)
|
||||
|
||||
// Set the database
|
||||
dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.DB}
|
||||
dval := &sql.DefineDatabaseStatement{Name: ast.DB}
|
||||
txn.PutC(0, dkey.Encode(), dval.Encode(), nil)
|
||||
e.txn.PutC(0, dkey.Encode(), dval.Encode(), nil)
|
||||
|
||||
// Set the login
|
||||
ukey := &keys.DU{KV: ast.KV, NS: ast.NS, DB: ast.DB, US: ast.User}
|
||||
_, err = txn.Put(0, ukey.Encode(), ast.Encode())
|
||||
_, err = e.txn.Put(0, ukey.Encode(), ast.Encode())
|
||||
|
||||
}
|
||||
|
||||
|
@ -84,18 +83,18 @@ func (e *executor) executeDefineLoginStatement(txn kvs.TX, ast *sql.DefineLoginS
|
|||
|
||||
}
|
||||
|
||||
func (e *executor) executeDefineTokenStatement(txn kvs.TX, ast *sql.DefineTokenStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeDefineTokenStatement(ast *sql.DefineTokenStatement) (out []interface{}, err error) {
|
||||
|
||||
if ast.Kind == sql.NAMESPACE {
|
||||
|
||||
// Set the namespace
|
||||
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
||||
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
||||
txn.PutC(0, nkey.Encode(), nval.Encode(), nil)
|
||||
e.txn.PutC(0, nkey.Encode(), nval.Encode(), nil)
|
||||
|
||||
// Set the token
|
||||
tkey := &keys.NT{KV: ast.KV, NS: ast.NS, TK: ast.Name}
|
||||
_, err = txn.Put(0, tkey.Encode(), ast.Encode())
|
||||
_, err = e.txn.Put(0, tkey.Encode(), ast.Encode())
|
||||
|
||||
}
|
||||
|
||||
|
@ -104,16 +103,16 @@ func (e *executor) executeDefineTokenStatement(txn kvs.TX, ast *sql.DefineTokenS
|
|||
// Set the namespace
|
||||
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
||||
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
||||
txn.PutC(0, nkey.Encode(), nval.Encode(), nil)
|
||||
e.txn.PutC(0, nkey.Encode(), nval.Encode(), nil)
|
||||
|
||||
// Set the database
|
||||
dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.DB}
|
||||
dval := &sql.DefineDatabaseStatement{Name: ast.DB}
|
||||
txn.PutC(0, dkey.Encode(), dval.Encode(), nil)
|
||||
e.txn.PutC(0, dkey.Encode(), dval.Encode(), nil)
|
||||
|
||||
// Set the token
|
||||
tkey := &keys.DT{KV: ast.KV, NS: ast.NS, DB: ast.DB, TK: ast.Name}
|
||||
_, err = txn.Put(0, tkey.Encode(), ast.Encode())
|
||||
_, err = e.txn.Put(0, tkey.Encode(), ast.Encode())
|
||||
|
||||
}
|
||||
|
||||
|
@ -121,43 +120,43 @@ func (e *executor) executeDefineTokenStatement(txn kvs.TX, ast *sql.DefineTokenS
|
|||
|
||||
}
|
||||
|
||||
func (e *executor) executeDefineScopeStatement(txn kvs.TX, ast *sql.DefineScopeStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeDefineScopeStatement(ast *sql.DefineScopeStatement) (out []interface{}, err error) {
|
||||
|
||||
// Set the namespace
|
||||
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
||||
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
||||
txn.PutC(0, nkey.Encode(), nval.Encode(), nil)
|
||||
e.txn.PutC(0, nkey.Encode(), nval.Encode(), nil)
|
||||
|
||||
// Set the database
|
||||
dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.DB}
|
||||
dval := &sql.DefineDatabaseStatement{Name: ast.DB}
|
||||
txn.PutC(0, dkey.Encode(), dval.Encode(), nil)
|
||||
e.txn.PutC(0, dkey.Encode(), dval.Encode(), nil)
|
||||
|
||||
// Set the scope
|
||||
skey := &keys.SC{KV: ast.KV, NS: ast.NS, DB: ast.DB, SC: ast.Name}
|
||||
_, err = txn.Put(0, skey.Encode(), ast.Encode())
|
||||
_, err = e.txn.Put(0, skey.Encode(), ast.Encode())
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
func (e *executor) executeDefineTableStatement(txn kvs.TX, ast *sql.DefineTableStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeDefineTableStatement(ast *sql.DefineTableStatement) (out []interface{}, err error) {
|
||||
|
||||
// Set the namespace
|
||||
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
||||
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
||||
txn.PutC(0, nkey.Encode(), nval.Encode(), nil)
|
||||
e.txn.PutC(0, nkey.Encode(), nval.Encode(), nil)
|
||||
|
||||
// Set the database
|
||||
dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.DB}
|
||||
dval := &sql.DefineDatabaseStatement{Name: ast.DB}
|
||||
txn.PutC(0, dkey.Encode(), dval.Encode(), nil)
|
||||
e.txn.PutC(0, dkey.Encode(), dval.Encode(), nil)
|
||||
|
||||
for _, TB := range ast.What {
|
||||
|
||||
// Set the table
|
||||
tkey := &keys.TB{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB}
|
||||
if _, err = txn.Put(0, tkey.Encode(), ast.Encode()); err != nil {
|
||||
if _, err = e.txn.Put(0, tkey.Encode(), ast.Encode()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -167,26 +166,28 @@ func (e *executor) executeDefineTableStatement(txn kvs.TX, ast *sql.DefineTableS
|
|||
|
||||
}
|
||||
|
||||
func (e *executor) executeDefineFieldStatement(txn kvs.TX, ast *sql.DefineFieldStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeDefineFieldStatement(ast *sql.DefineFieldStatement) (out []interface{}, err error) {
|
||||
|
||||
// Set the namespace
|
||||
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
||||
txn.Put(0, nkey.Encode(), nil)
|
||||
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
||||
e.txn.PutC(0, nkey.Encode(), nval.Encode(), nil)
|
||||
|
||||
// Set the database
|
||||
dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.DB}
|
||||
txn.Put(0, dkey.Encode(), nil)
|
||||
dval := &sql.DefineDatabaseStatement{Name: ast.DB}
|
||||
e.txn.PutC(0, dkey.Encode(), dval.Encode(), nil)
|
||||
|
||||
for _, TB := range ast.What {
|
||||
|
||||
// Set the table
|
||||
tkey := &keys.TB{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB}
|
||||
tval := &sql.DefineTableStatement{What: ast.What}
|
||||
txn.PutC(0, tkey.Encode(), tval.Encode(), nil)
|
||||
e.txn.PutC(0, tkey.Encode(), tval.Encode(), nil)
|
||||
|
||||
// Set the field
|
||||
fkey := &keys.FD{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB, FD: ast.Name}
|
||||
if _, err = txn.Put(0, fkey.Encode(), pack.Encode(ast)); err != nil {
|
||||
if _, err = e.txn.Put(0, fkey.Encode(), pack.Encode(ast)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -196,42 +197,44 @@ func (e *executor) executeDefineFieldStatement(txn kvs.TX, ast *sql.DefineFieldS
|
|||
|
||||
}
|
||||
|
||||
func (e *executor) executeDefineIndexStatement(txn kvs.TX, ast *sql.DefineIndexStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeDefineIndexStatement(ast *sql.DefineIndexStatement) (out []interface{}, err error) {
|
||||
|
||||
// Set the namespace
|
||||
nkey := &keys.NS{KV: ast.KV, NS: ast.NS}
|
||||
txn.Put(0, nkey.Encode(), nil)
|
||||
nval := &sql.DefineNamespaceStatement{Name: ast.NS}
|
||||
e.txn.PutC(0, nkey.Encode(), nval.Encode(), nil)
|
||||
|
||||
// Set the database
|
||||
dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.DB}
|
||||
txn.Put(0, dkey.Encode(), nil)
|
||||
dval := &sql.DefineDatabaseStatement{Name: ast.DB}
|
||||
e.txn.PutC(0, dkey.Encode(), dval.Encode(), nil)
|
||||
|
||||
for _, TB := range ast.What {
|
||||
|
||||
// Set the table
|
||||
tkey := &keys.TB{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB}
|
||||
tval := &sql.DefineTableStatement{What: ast.What}
|
||||
txn.PutC(0, tkey.Encode(), tval.Encode(), nil)
|
||||
e.txn.PutC(0, tkey.Encode(), tval.Encode(), nil)
|
||||
|
||||
// Set the index
|
||||
ikey := &keys.IX{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB, IX: ast.Name}
|
||||
if _, err = txn.Put(0, ikey.Encode(), ast.Encode()); err != nil {
|
||||
if _, err = e.txn.Put(0, ikey.Encode(), ast.Encode()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Remove all index data
|
||||
dbeg := &keys.Index{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB, IX: keys.Prefix, FD: keys.Ignore}
|
||||
dend := &keys.Index{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB, IX: keys.Suffix, FD: keys.Ignore}
|
||||
if _, err = txn.DelR(0, dbeg.Encode(), dend.Encode(), 0); err != nil {
|
||||
if _, err = e.txn.DelR(0, dbeg.Encode(), dend.Encode(), 0); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Fetch the items
|
||||
ibeg := &keys.Thing{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB, ID: keys.Prefix}
|
||||
iend := &keys.Thing{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB, ID: keys.Suffix}
|
||||
kvs, _ := txn.GetR(0, ibeg.Encode(), iend.Encode(), 0)
|
||||
kvs, _ := e.txn.GetR(0, ibeg.Encode(), iend.Encode(), 0)
|
||||
for _, kv := range kvs {
|
||||
doc := item.New(kv, txn, nil, e.ctx)
|
||||
doc := item.New(kv, e.txn, nil, e.ctx)
|
||||
if err := doc.StoreIndex(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -16,13 +16,12 @@ package db
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/abcum/surreal/kvs"
|
||||
"github.com/abcum/surreal/sql"
|
||||
"github.com/abcum/surreal/util/item"
|
||||
"github.com/abcum/surreal/util/keys"
|
||||
)
|
||||
|
||||
func (e *executor) executeDeleteStatement(txn kvs.TX, ast *sql.DeleteStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeDeleteStatement(ast *sql.DeleteStatement) (out []interface{}, err error) {
|
||||
|
||||
for k, w := range ast.What {
|
||||
if what, ok := w.(*sql.Param); ok {
|
||||
|
@ -39,7 +38,7 @@ func (e *executor) executeDeleteStatement(txn kvs.TX, ast *sql.DeleteStatement)
|
|||
|
||||
case *sql.Thing:
|
||||
key := &keys.Thing{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: what.TB, ID: what.ID}
|
||||
kv, _ := txn.Get(0, key.Encode())
|
||||
kv, _ := e.txn.Get(0, key.Encode())
|
||||
doc := item.New(kv, e.txn, key, e.ctx)
|
||||
if ret, err := delete(doc, ast); err != nil {
|
||||
return nil, err
|
||||
|
@ -49,9 +48,9 @@ func (e *executor) executeDeleteStatement(txn kvs.TX, ast *sql.DeleteStatement)
|
|||
|
||||
case *sql.Table:
|
||||
key := &keys.Table{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: what.TB}
|
||||
kvs, _ := txn.GetL(0, key.Encode())
|
||||
kvs, _ := e.txn.GetL(0, key.Encode())
|
||||
for _, kv := range kvs {
|
||||
doc := item.New(kv, txn, nil, e.ctx)
|
||||
doc := item.New(kv, e.txn, nil, e.ctx)
|
||||
if ret, err := delete(doc, ast); err != nil {
|
||||
return nil, err
|
||||
} else if ret != nil {
|
||||
|
|
15
db/info.go
15
db/info.go
|
@ -15,28 +15,27 @@
|
|||
package db
|
||||
|
||||
import (
|
||||
"github.com/abcum/surreal/kvs"
|
||||
"github.com/abcum/surreal/mem"
|
||||
"github.com/abcum/surreal/sql"
|
||||
"github.com/abcum/surreal/util/data"
|
||||
)
|
||||
|
||||
func (e *executor) executeInfoStatement(txn kvs.TX, ast *sql.InfoStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeInfoStatement(ast *sql.InfoStatement) (out []interface{}, err error) {
|
||||
|
||||
switch ast.Kind {
|
||||
case sql.NAMESPACE:
|
||||
return e.executeInfoNSStatement(txn, ast)
|
||||
return e.executeInfoNSStatement(ast)
|
||||
case sql.DATABASE:
|
||||
return e.executeInfoDBStatement(txn, ast)
|
||||
return e.executeInfoDBStatement(ast)
|
||||
case sql.TABLE:
|
||||
return e.executeInfoTBStatement(txn, ast)
|
||||
return e.executeInfoTBStatement(ast)
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
func (e *executor) executeInfoNSStatement(txn kvs.TX, ast *sql.InfoStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeInfoNSStatement(ast *sql.InfoStatement) (out []interface{}, err error) {
|
||||
|
||||
res := data.New()
|
||||
res.Array("logins")
|
||||
|
@ -69,7 +68,7 @@ func (e *executor) executeInfoNSStatement(txn kvs.TX, ast *sql.InfoStatement) (o
|
|||
|
||||
}
|
||||
|
||||
func (e *executor) executeInfoDBStatement(txn kvs.TX, ast *sql.InfoStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeInfoDBStatement(ast *sql.InfoStatement) (out []interface{}, err error) {
|
||||
|
||||
res := data.New()
|
||||
res.Array("logins")
|
||||
|
@ -107,7 +106,7 @@ func (e *executor) executeInfoDBStatement(txn kvs.TX, ast *sql.InfoStatement) (o
|
|||
|
||||
}
|
||||
|
||||
func (e *executor) executeInfoTBStatement(txn kvs.TX, ast *sql.InfoStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeInfoTBStatement(ast *sql.InfoStatement) (out []interface{}, err error) {
|
||||
|
||||
res := data.New()
|
||||
res.Array("fields")
|
||||
|
|
|
@ -15,11 +15,10 @@
|
|||
package db
|
||||
|
||||
import (
|
||||
"github.com/abcum/surreal/kvs"
|
||||
"github.com/abcum/surreal/sql"
|
||||
)
|
||||
|
||||
func (e *executor) executeLetStatement(txn kvs.TX, ast *sql.LetStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeLetStatement(ast *sql.LetStatement) (out []interface{}, err error) {
|
||||
|
||||
switch what := ast.What.(type) {
|
||||
default:
|
||||
|
|
|
@ -15,10 +15,9 @@
|
|||
package db
|
||||
|
||||
import (
|
||||
"github.com/abcum/surreal/kvs"
|
||||
"github.com/abcum/surreal/sql"
|
||||
)
|
||||
|
||||
func (e *executor) executeRelateStatement(txn kvs.TX, ast *sql.RelateStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeRelateStatement(ast *sql.RelateStatement) (out []interface{}, err error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
39
db/remove.go
39
db/remove.go
|
@ -15,38 +15,37 @@
|
|||
package db
|
||||
|
||||
import (
|
||||
"github.com/abcum/surreal/kvs"
|
||||
"github.com/abcum/surreal/sql"
|
||||
"github.com/abcum/surreal/util/keys"
|
||||
)
|
||||
|
||||
func (e *executor) executeRemoveNamespaceStatement(txn kvs.TX, ast *sql.RemoveNamespaceStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeRemoveNamespaceStatement(ast *sql.RemoveNamespaceStatement) (out []interface{}, err error) {
|
||||
|
||||
// Remove the namespace
|
||||
nkey := &keys.NS{KV: ast.KV, NS: ast.Name}
|
||||
_, err = txn.DelP(0, nkey.Encode(), 0)
|
||||
_, err = e.txn.DelP(0, nkey.Encode(), 0)
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
func (e *executor) executeRemoveDatabaseStatement(txn kvs.TX, ast *sql.RemoveDatabaseStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeRemoveDatabaseStatement(ast *sql.RemoveDatabaseStatement) (out []interface{}, err error) {
|
||||
|
||||
// Remove the database
|
||||
dkey := &keys.DB{KV: ast.KV, NS: ast.NS, DB: ast.Name}
|
||||
_, err = txn.DelP(0, dkey.Encode(), 0)
|
||||
_, err = e.txn.DelP(0, dkey.Encode(), 0)
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
func (e *executor) executeRemoveLoginStatement(txn kvs.TX, ast *sql.RemoveLoginStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeRemoveLoginStatement(ast *sql.RemoveLoginStatement) (out []interface{}, err error) {
|
||||
|
||||
if ast.Kind == sql.NAMESPACE {
|
||||
|
||||
// Remove the login
|
||||
ukey := &keys.NU{KV: ast.KV, NS: ast.NS, US: ast.User}
|
||||
_, err = txn.DelP(0, ukey.Encode(), 0)
|
||||
_, err = e.txn.DelP(0, ukey.Encode(), 0)
|
||||
|
||||
}
|
||||
|
||||
|
@ -54,7 +53,7 @@ func (e *executor) executeRemoveLoginStatement(txn kvs.TX, ast *sql.RemoveLoginS
|
|||
|
||||
// Remove the login
|
||||
ukey := &keys.DU{KV: ast.KV, NS: ast.NS, DB: ast.DB, US: ast.User}
|
||||
_, err = txn.DelP(0, ukey.Encode(), 0)
|
||||
_, err = e.txn.DelP(0, ukey.Encode(), 0)
|
||||
|
||||
}
|
||||
|
||||
|
@ -62,13 +61,13 @@ func (e *executor) executeRemoveLoginStatement(txn kvs.TX, ast *sql.RemoveLoginS
|
|||
|
||||
}
|
||||
|
||||
func (e *executor) executeRemoveTokenStatement(txn kvs.TX, ast *sql.RemoveTokenStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeRemoveTokenStatement(ast *sql.RemoveTokenStatement) (out []interface{}, err error) {
|
||||
|
||||
if ast.Kind == sql.NAMESPACE {
|
||||
|
||||
// Remove the token
|
||||
tkey := &keys.NT{KV: ast.KV, NS: ast.NS, TK: ast.Name}
|
||||
_, err = txn.DelP(0, tkey.Encode(), 0)
|
||||
_, err = e.txn.DelP(0, tkey.Encode(), 0)
|
||||
|
||||
}
|
||||
|
||||
|
@ -76,7 +75,7 @@ func (e *executor) executeRemoveTokenStatement(txn kvs.TX, ast *sql.RemoveTokenS
|
|||
|
||||
// Remove the token
|
||||
tkey := &keys.DT{KV: ast.KV, NS: ast.NS, DB: ast.DB, TK: ast.Name}
|
||||
_, err = txn.DelP(0, tkey.Encode(), 0)
|
||||
_, err = e.txn.DelP(0, tkey.Encode(), 0)
|
||||
|
||||
}
|
||||
|
||||
|
@ -84,23 +83,23 @@ func (e *executor) executeRemoveTokenStatement(txn kvs.TX, ast *sql.RemoveTokenS
|
|||
|
||||
}
|
||||
|
||||
func (e *executor) executeRemoveScopeStatement(txn kvs.TX, ast *sql.RemoveScopeStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeRemoveScopeStatement(ast *sql.RemoveScopeStatement) (out []interface{}, err error) {
|
||||
|
||||
// Remove the scope
|
||||
skey := &keys.SC{KV: ast.KV, NS: ast.NS, DB: ast.DB, SC: ast.Name}
|
||||
_, err = txn.DelP(0, skey.Encode(), 0)
|
||||
_, err = e.txn.DelP(0, skey.Encode(), 0)
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
func (e *executor) executeRemoveTableStatement(txn kvs.TX, ast *sql.RemoveTableStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeRemoveTableStatement(ast *sql.RemoveTableStatement) (out []interface{}, err error) {
|
||||
|
||||
for _, TB := range ast.What {
|
||||
|
||||
// Remove the table
|
||||
tkey := &keys.TB{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB}
|
||||
_, err = txn.DelP(0, tkey.Encode(), 0)
|
||||
_, err = e.txn.DelP(0, tkey.Encode(), 0)
|
||||
|
||||
}
|
||||
|
||||
|
@ -108,13 +107,13 @@ func (e *executor) executeRemoveTableStatement(txn kvs.TX, ast *sql.RemoveTableS
|
|||
|
||||
}
|
||||
|
||||
func (e *executor) executeRemoveFieldStatement(txn kvs.TX, ast *sql.RemoveFieldStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeRemoveFieldStatement(ast *sql.RemoveFieldStatement) (out []interface{}, err error) {
|
||||
|
||||
for _, TB := range ast.What {
|
||||
|
||||
// Remove the field
|
||||
fkey := &keys.FD{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB, FD: ast.Name}
|
||||
_, err = txn.DelP(0, fkey.Encode(), 0)
|
||||
_, err = e.txn.DelP(0, fkey.Encode(), 0)
|
||||
|
||||
}
|
||||
|
||||
|
@ -122,17 +121,17 @@ func (e *executor) executeRemoveFieldStatement(txn kvs.TX, ast *sql.RemoveFieldS
|
|||
|
||||
}
|
||||
|
||||
func (e *executor) executeRemoveIndexStatement(txn kvs.TX, ast *sql.RemoveIndexStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeRemoveIndexStatement(ast *sql.RemoveIndexStatement) (out []interface{}, err error) {
|
||||
|
||||
for _, TB := range ast.What {
|
||||
|
||||
// Remove the index
|
||||
ikey := &keys.IX{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB, IX: ast.Name}
|
||||
_, err = txn.DelP(0, ikey.Encode(), 0)
|
||||
_, err = e.txn.DelP(0, ikey.Encode(), 0)
|
||||
|
||||
// Remove the index
|
||||
dkey := &keys.Index{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: TB, IX: ast.Name, FD: keys.Ignore}
|
||||
_, err = txn.DelP(0, dkey.Encode(), 0)
|
||||
_, err = e.txn.DelP(0, dkey.Encode(), 0)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -15,11 +15,10 @@
|
|||
package db
|
||||
|
||||
import (
|
||||
"github.com/abcum/surreal/kvs"
|
||||
"github.com/abcum/surreal/sql"
|
||||
)
|
||||
|
||||
func (e *executor) executeReturnStatement(txn kvs.TX, ast *sql.ReturnStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeReturnStatement(ast *sql.ReturnStatement) (out []interface{}, err error) {
|
||||
|
||||
switch what := ast.What.(type) {
|
||||
default:
|
||||
|
|
|
@ -15,13 +15,12 @@
|
|||
package db
|
||||
|
||||
import (
|
||||
"github.com/abcum/surreal/kvs"
|
||||
"github.com/abcum/surreal/sql"
|
||||
"github.com/abcum/surreal/util/item"
|
||||
"github.com/abcum/surreal/util/keys"
|
||||
)
|
||||
|
||||
func (e *executor) executeSelectStatement(txn kvs.TX, ast *sql.SelectStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeSelectStatement(ast *sql.SelectStatement) (out []interface{}, err error) {
|
||||
|
||||
for k, w := range ast.What {
|
||||
if what, ok := w.(*sql.Param); ok {
|
||||
|
@ -33,7 +32,7 @@ func (e *executor) executeSelectStatement(txn kvs.TX, ast *sql.SelectStatement)
|
|||
|
||||
if what, ok := w.(*sql.Thing); ok {
|
||||
key := &keys.Thing{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: what.TB, ID: what.ID}
|
||||
kv, _ := txn.Get(0, key.Encode())
|
||||
kv, _ := e.txn.Get(0, key.Encode())
|
||||
doc := item.New(kv, e.txn, key, e.ctx)
|
||||
if ret, err := detect(doc, ast); err != nil {
|
||||
return nil, err
|
||||
|
@ -44,9 +43,9 @@ func (e *executor) executeSelectStatement(txn kvs.TX, ast *sql.SelectStatement)
|
|||
|
||||
if what, ok := w.(*sql.Table); ok {
|
||||
key := &keys.Table{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: what.TB}
|
||||
kvs, _ := txn.GetL(0, key.Encode())
|
||||
kvs, _ := e.txn.GetL(0, key.Encode())
|
||||
for _, kv := range kvs {
|
||||
doc := item.New(kv, txn, nil, e.ctx)
|
||||
doc := item.New(kv, e.txn, nil, e.ctx)
|
||||
if ret, err := detect(doc, ast); err != nil {
|
||||
return nil, err
|
||||
} else if ret != nil {
|
||||
|
|
|
@ -16,13 +16,12 @@ package db
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/abcum/surreal/kvs"
|
||||
"github.com/abcum/surreal/sql"
|
||||
"github.com/abcum/surreal/util/item"
|
||||
"github.com/abcum/surreal/util/keys"
|
||||
)
|
||||
|
||||
func (e *executor) executeUpdateStatement(txn kvs.TX, ast *sql.UpdateStatement) (out []interface{}, err error) {
|
||||
func (e *executor) executeUpdateStatement(ast *sql.UpdateStatement) (out []interface{}, err error) {
|
||||
|
||||
for k, w := range ast.What {
|
||||
if what, ok := w.(*sql.Param); ok {
|
||||
|
@ -39,7 +38,7 @@ func (e *executor) executeUpdateStatement(txn kvs.TX, ast *sql.UpdateStatement)
|
|||
|
||||
case *sql.Thing:
|
||||
key := &keys.Thing{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: what.TB, ID: what.ID}
|
||||
kv, _ := txn.Get(0, key.Encode())
|
||||
kv, _ := e.txn.Get(0, key.Encode())
|
||||
doc := item.New(kv, e.txn, key, e.ctx)
|
||||
if ret, err := update(doc, ast); err != nil {
|
||||
return nil, err
|
||||
|
@ -49,9 +48,9 @@ func (e *executor) executeUpdateStatement(txn kvs.TX, ast *sql.UpdateStatement)
|
|||
|
||||
case *sql.Table:
|
||||
key := &keys.Table{KV: ast.KV, NS: ast.NS, DB: ast.DB, TB: what.TB}
|
||||
kvs, _ := txn.GetL(0, key.Encode())
|
||||
kvs, _ := e.txn.GetL(0, key.Encode())
|
||||
for _, kv := range kvs {
|
||||
doc := item.New(kv, txn, nil, e.ctx)
|
||||
doc := item.New(kv, e.txn, nil, e.ctx)
|
||||
if ret, err := update(doc, ast); err != nil {
|
||||
return nil, err
|
||||
} else if ret != nil {
|
||||
|
|
Loading…
Reference in a new issue