diff --git a/kvs/boltdb/ds.go b/kvs/boltdb/ds.go index a49eb9d8..6a8ba689 100644 --- a/kvs/boltdb/ds.go +++ b/kvs/boltdb/ds.go @@ -29,7 +29,7 @@ func (ds *DS) Txn(writable bool) (txn kvs.TX, err error) { tx, err := ds.db.Begin(writable) if err != nil { - err = &kvs.DSError{err} + err = &kvs.DSError{Err: err} if tx != nil { tx.Rollback() } diff --git a/kvs/boltdb/tx.go b/kvs/boltdb/tx.go index 82b0d3c6..65eab515 100644 --- a/kvs/boltdb/tx.go +++ b/kvs/boltdb/tx.go @@ -150,22 +150,22 @@ func (tx *TX) RGet(beg, end []byte, max uint64) (kvs []kvs.KV, err error) { func (tx *TX) Put(key, val []byte) (err error) { if !tx.tx.Writable() { - err = &kvs.TXError{err} + err = &kvs.TXError{Err: err} return } if val, err = snap.Encode(val); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } if val, err = cryp.Encrypt(tx.ds.ck, val); err != nil { - err = &kvs.CKError{err} + err = &kvs.CKError{Err: err} return } if err = tx.bu.Put(key, val); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } @@ -179,7 +179,7 @@ func (tx *TX) Put(key, val []byte) (err error) { func (tx *TX) CPut(key, val, exp []byte) (err error) { if !tx.tx.Writable() { - err = &kvs.TXError{err} + err = &kvs.TXError{Err: err} return } @@ -187,22 +187,22 @@ func (tx *TX) CPut(key, val, exp []byte) (err error) { act := now.(*KV).val if !bytes.Equal(act, exp) { - err = &kvs.KVError{err, key, act, exp} + err = &kvs.KVError{Err: err, Key: key, Val: act, Exp: exp} return } if val, err = snap.Encode(val); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } if val, err = cryp.Encrypt(tx.ds.ck, val); err != nil { - err = &kvs.CKError{err} + err = &kvs.CKError{Err: err} return } if err = tx.bu.Put(key, val); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } @@ -214,12 +214,12 @@ func (tx *TX) CPut(key, val, exp []byte) (err error) { func (tx *TX) Del(key []byte) (err error) { if !tx.tx.Writable() { - err = &kvs.TXError{err} + err = &kvs.TXError{Err: err} return } if err = tx.bu.Delete(key); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } @@ -232,7 +232,7 @@ func (tx *TX) Del(key []byte) (err error) { func (tx *TX) CDel(key, exp []byte) (err error) { if !tx.tx.Writable() { - err = &kvs.TXError{err} + err = &kvs.TXError{Err: err} return } @@ -240,12 +240,12 @@ func (tx *TX) CDel(key, exp []byte) (err error) { act := now.(*KV).val if !bytes.Equal(act, exp) { - err = &kvs.KVError{err, key, act, exp} + err = &kvs.KVError{Err: err, Key: key, Val: act, Exp: exp} return } if err = tx.bu.Delete(key); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } @@ -257,14 +257,14 @@ func (tx *TX) CDel(key, exp []byte) (err error) { func (tx *TX) MDel(keys ...[]byte) (err error) { if !tx.tx.Writable() { - err = &kvs.TXError{err} + err = &kvs.TXError{Err: err} return } for _, key := range keys { if err = tx.bu.Delete(key); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } @@ -281,7 +281,7 @@ func (tx *TX) PDel(pre []byte) (err error) { for key, _ := cu.Seek(pre); bytes.HasPrefix(key, pre); key, _ = cu.Seek(pre) { if err = tx.bu.Delete(key); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } } @@ -300,7 +300,7 @@ func (tx *TX) RDel(beg, end []byte, max uint64) (err error) { } if !tx.tx.Writable() { - err = &kvs.TXError{err} + err = &kvs.TXError{Err: err} return } @@ -309,7 +309,7 @@ func (tx *TX) RDel(beg, end []byte, max uint64) (err error) { if bytes.Compare(beg, end) < 1 { for key, _ := cu.Seek(beg); key != nil && max > 0 && bytes.Compare(key, end) < 0; key, _ = cu.Seek(beg) { if err = tx.bu.Delete(key); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } max-- @@ -319,7 +319,7 @@ func (tx *TX) RDel(beg, end []byte, max uint64) (err error) { if bytes.Compare(beg, end) > 1 { for key, _ := cu.Seek(end); key != nil && max > 0 && bytes.Compare(beg, key) < 0; key, _ = cu.Seek(end) { if err = tx.bu.Delete(key); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } max-- @@ -365,13 +365,13 @@ func get(tx *TX, key, val []byte) (kv *KV, err error) { kv.val, err = cryp.Decrypt(tx.ds.ck, kv.val) if err != nil { - err = &kvs.CKError{err} + err = &kvs.CKError{Err: err} return } kv.val, err = snap.Decode(kv.val) if err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } diff --git a/kvs/mysql/ds.go b/kvs/mysql/ds.go index eeb3d34a..f515852e 100644 --- a/kvs/mysql/ds.go +++ b/kvs/mysql/ds.go @@ -29,7 +29,7 @@ func (ds *DS) Txn(writable bool) (txn kvs.TX, err error) { tx, err := ds.db.Begin() if err != nil { - err = &kvs.DSError{err} + err = &kvs.DSError{Err: err} if tx != nil { tx.Rollback() } diff --git a/kvs/mysql/tx.go b/kvs/mysql/tx.go index 0d106ed3..15b5c9ed 100644 --- a/kvs/mysql/tx.go +++ b/kvs/mysql/tx.go @@ -183,17 +183,17 @@ func (tx *TX) RGet(beg, end []byte, max uint64) (kvs []kvs.KV, err error) { func (tx *TX) Put(key, val []byte) (err error) { if val, err = snap.Encode(val); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } if val, err = cryp.Encrypt(tx.ds.ck, val); err != nil { - err = &kvs.CKError{err} + err = &kvs.CKError{Err: err} return } if _, err = tx.tx.Exec("INSERT INTO kv (`key`, `val`) VALUES (?, ?) ON DUPLICATE KEY UPDATE `val` = ?", key, val, val); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } @@ -210,22 +210,22 @@ func (tx *TX) CPut(key, val, exp []byte) (err error) { act := now.(*KV).val if !bytes.Equal(act, exp) { - err = &kvs.KVError{err, key, act, exp} + err = &kvs.KVError{Err: err, Key: key, Val: act, Exp: exp} return } if val, err = snap.Encode(val); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } if val, err = cryp.Encrypt(tx.ds.ck, val); err != nil { - err = &kvs.CKError{err} + err = &kvs.CKError{Err: err} return } if _, err = tx.tx.Exec("INSERT INTO kv (`key`, `val`) VALUES (?, ?) ON DUPLICATE KEY UPDATE `val` = ?", key, val, val); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } @@ -237,7 +237,7 @@ func (tx *TX) CPut(key, val, exp []byte) (err error) { func (tx *TX) Del(key []byte) (err error) { if _, err = tx.tx.Exec("DELETE FROM kv WHERE `key` = ?", key); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } @@ -253,12 +253,12 @@ func (tx *TX) CDel(key, exp []byte) (err error) { act := now.(*KV).val if !bytes.Equal(act, exp) { - err = &kvs.KVError{err, key, act, exp} + err = &kvs.KVError{Err: err, Key: key, Val: act, Exp: exp} return } if _, err = tx.tx.Exec("DELETE FROM kv WHERE `key` = ?", key); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } @@ -271,7 +271,7 @@ func (tx *TX) MDel(keys ...[]byte) (err error) { /* if _, err = tx.tx.Exec("DELETE FROM kv WHERE `key` IN (?)", keys); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err:err} return } */ @@ -303,7 +303,7 @@ func (tx *TX) RDel(beg, end []byte, max uint64) (err error) { } if _, err = tx.tx.Exec("DELETE FROM kv WHERE `key` BETWEEN ? AND ? ORDER BY `key` ASC LIMIT ?", beg, end, max); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } @@ -343,13 +343,13 @@ func get(tx *TX, key, val []byte) (kv *KV, err error) { kv.val, err = cryp.Decrypt(tx.ds.ck, kv.val) if err != nil { - err = &kvs.CKError{err} + err = &kvs.CKError{Err: err} return } kv.val, err = snap.Decode(kv.val) if err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } diff --git a/kvs/pgsql/ds.go b/kvs/pgsql/ds.go index d0c327c5..1a285598 100644 --- a/kvs/pgsql/ds.go +++ b/kvs/pgsql/ds.go @@ -29,7 +29,7 @@ func (ds *DS) Txn(writable bool) (txn kvs.TX, err error) { tx, err := ds.db.Begin() if err != nil { - err = &kvs.DSError{err} + err = &kvs.DSError{Err: err} if tx != nil { tx.Rollback() } diff --git a/kvs/pgsql/tx.go b/kvs/pgsql/tx.go index 1f2d48b3..a6e40111 100644 --- a/kvs/pgsql/tx.go +++ b/kvs/pgsql/tx.go @@ -151,7 +151,7 @@ func (tx *TX) RGet(beg, end []byte, max uint64) (items []kvs.KV, err error) { res, err := tx.tx.Query("SELECT key, val FROM kv WHERE key BETWEEN $1 AND $2 ORDER BY key ASC LIMIT $3", beg, end, max) if err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return nil, err } @@ -188,17 +188,17 @@ func (tx *TX) RGet(beg, end []byte, max uint64) (items []kvs.KV, err error) { func (tx *TX) Put(key, val []byte) (err error) { if val, err = snap.Encode(val); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } if val, err = cryp.Encrypt(tx.ds.ck, val); err != nil { - err = &kvs.CKError{err} + err = &kvs.CKError{Err: err} return } if _, err = tx.tx.Exec("INSERT INTO kv (key, val) VALUES ($1, $2) ON CONFLICT (key) DO UPDATE SET val = $2", key, val); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } @@ -215,22 +215,22 @@ func (tx *TX) CPut(key, val, exp []byte) (err error) { act := now.(*KV).val if !bytes.Equal(act, exp) { - err = &kvs.KVError{err, key, act, exp} + err = &kvs.KVError{Err: err, Key: key, Val: act, Exp: exp} return } if val, err = snap.Encode(val); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } if val, err = cryp.Encrypt(tx.ds.ck, val); err != nil { - err = &kvs.CKError{err} + err = &kvs.CKError{Err: err} return } if _, err = tx.tx.Exec("INSERT INTO kv (key, val) VALUES ($1, $2) ON CONFLICT (key) DO UPDATE SET val = $2", key, val); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } @@ -242,7 +242,7 @@ func (tx *TX) CPut(key, val, exp []byte) (err error) { func (tx *TX) Del(key []byte) (err error) { if _, err = tx.tx.Exec("DELETE FROM kv WHERE key = $1", key); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } @@ -258,12 +258,12 @@ func (tx *TX) CDel(key, exp []byte) (err error) { act := now.(*KV).val if !bytes.Equal(act, exp) { - err = &kvs.KVError{err, key, act, exp} + err = &kvs.KVError{Err: err, Key: key, Val: act, Exp: exp} return } if _, err = tx.tx.Exec("DELETE FROM kv WHERE key = $1", key); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } @@ -276,7 +276,7 @@ func (tx *TX) MDel(keys ...[]byte) (err error) { /* if _, err = tx.tx.Exec("DELETE FROM kv WHERE key IN ($1)", keys); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err:err} return } */ @@ -312,7 +312,7 @@ func (tx *TX) RDel(beg, end []byte, max uint64) (err error) { } if _, err = tx.tx.Exec("DELETE FROM kv WHERE key BETWEEN $1 AND $2 ORDER BY key ASC LIMIT $3", beg, end, max); err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } @@ -352,13 +352,13 @@ func get(tx *TX, key, val []byte) (kv *KV, err error) { kv.val, err = cryp.Decrypt(tx.ds.ck, kv.val) if err != nil { - err = &kvs.CKError{err} + err = &kvs.CKError{Err: err} return } kv.val, err = snap.Decode(kv.val) if err != nil { - err = &kvs.DBError{err} + err = &kvs.DBError{Err: err} return } diff --git a/web/signin.go b/web/signin.go index 374ffa0b..894b9bad 100644 --- a/web/signin.go +++ b/web/signin.go @@ -60,7 +60,7 @@ func signin(c *fibre.Context) (err error) { // Process the scope signin statement. - res, err = db.Process(c, &sql.Query{[]sql.Statement{scp.Signin}}, vars) + res, err = db.Process(c, &sql.Query{Statements: []sql.Statement{scp.Signin}}, vars) if err != nil { return fibre.NewHTTPError(403) } diff --git a/web/signup.go b/web/signup.go index 14c59915..6a01111a 100644 --- a/web/signup.go +++ b/web/signup.go @@ -54,7 +54,7 @@ func signup(c *fibre.Context) (err error) { // Process the scope signup statement. - res, err = db.Process(c, &sql.Query{[]sql.Statement{scp.Signup}}, vars) + res, err = db.Process(c, &sql.Query{Statements: []sql.Statement{scp.Signup}}, vars) if err != nil { return fibre.NewHTTPError(403) }