From 63cbb59bae3c99feec401bfe1ee6d3fc8bfed42b Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Mon, 2 Dec 2019 23:29:18 +0000 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20ignore=20transaction=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- txn/db.go | 6 +++++- txn/ns.go | 6 +++++- txn/tb.go | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/txn/db.go b/txn/db.go index e2bc26ac..4a19f180 100644 --- a/txn/db.go +++ b/txn/db.go @@ -84,7 +84,11 @@ func (t *TX) AddDB(ctx context.Context, ns, db string) (val *sql.DefineDatabaseS key := &keys.DB{KV: cnf.Settings.DB.Base, NS: ns, DB: db} - if kv, _ = t.Get(ctx, 0, key.Encode()); kv.Exi() { + if kv, err = t.Get(ctx, 0, key.Encode()); err != nil { + return + } + + if kv != nil && kv.Exi() { val = &sql.DefineDatabaseStatement{} val.Decode(kv.Val()) t.set(_db, db, val) diff --git a/txn/ns.go b/txn/ns.go index b1dd797c..acbc4cd5 100644 --- a/txn/ns.go +++ b/txn/ns.go @@ -80,7 +80,11 @@ func (t *TX) AddNS(ctx context.Context, ns string) (val *sql.DefineNamespaceStat key := &keys.NS{KV: cnf.Settings.DB.Base, NS: ns} - if kv, _ = t.Get(ctx, 0, key.Encode()); kv.Exi() { + if kv, err = t.Get(ctx, 0, key.Encode()); err != nil { + return + } + + if kv != nil && kv.Exi() { val = &sql.DefineNamespaceStatement{} val.Decode(kv.Val()) t.set(_ns, ns, val) diff --git a/txn/tb.go b/txn/tb.go index ad687ad1..34d0333a 100644 --- a/txn/tb.go +++ b/txn/tb.go @@ -84,7 +84,11 @@ func (t *TX) AddTB(ctx context.Context, ns, db, tb string) (val *sql.DefineTable key := &keys.TB{KV: cnf.Settings.DB.Base, NS: ns, DB: db, TB: tb} - if kv, _ = t.Get(ctx, 0, key.Encode()); kv.Exi() { + if kv, err = t.Get(ctx, 0, key.Encode()); err != nil { + return + } + + if kv != nil && kv.Exi() { val = &sql.DefineTableStatement{} val.Decode(kv.Val()) t.set(_tb, tb, val)