Use query version time from executor not document
This commit is contained in:
parent
add47a5ada
commit
fa1061b3a5
2 changed files with 11 additions and 7 deletions
|
@ -15,7 +15,6 @@
|
||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
@ -36,7 +35,6 @@ type document struct {
|
||||||
id *sql.Thing
|
id *sql.Thing
|
||||||
key *keys.Thing
|
key *keys.Thing
|
||||||
val kvs.KV
|
val kvs.KV
|
||||||
now int64
|
|
||||||
doc *data.Doc
|
doc *data.Doc
|
||||||
initial *data.Doc
|
initial *data.Doc
|
||||||
current *data.Doc
|
current *data.Doc
|
||||||
|
@ -69,7 +67,6 @@ func newDocument(i *iterator, key *keys.Thing, val kvs.KV, doc *data.Doc) (d *do
|
||||||
d.val = val
|
d.val = val
|
||||||
d.doc = doc
|
d.doc = doc
|
||||||
|
|
||||||
d.now = time.Now().UnixNano()
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -316,7 +313,7 @@ func (d *document) storeThing() (err error) {
|
||||||
// Write the value to the data
|
// Write the value to the data
|
||||||
// layer and return any errors.
|
// layer and return any errors.
|
||||||
|
|
||||||
_, err = d.i.e.dbo.Put(d.now, d.key.Encode(), d.current.Encode())
|
_, err = d.i.e.dbo.Put(d.i.e.time, d.key.Encode(), d.current.Encode())
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -334,7 +331,7 @@ func (d *document) purgeThing() (err error) {
|
||||||
// Reset the item by writing a
|
// Reset the item by writing a
|
||||||
// nil value to the storage.
|
// nil value to the storage.
|
||||||
|
|
||||||
_, err = d.i.e.dbo.Put(d.now, d.key.Encode(), nil)
|
_, err = d.i.e.dbo.Put(d.i.e.time, d.key.Encode(), nil)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -400,7 +397,7 @@ func (d *document) storeIndex() (err error) {
|
||||||
if ix.Uniq == true {
|
if ix.Uniq == true {
|
||||||
for _, v := range del {
|
for _, v := range del {
|
||||||
didx := &keys.Index{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.ID, FD: v}
|
didx := &keys.Index{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.ID, FD: v}
|
||||||
d.i.e.dbo.DelC(d.now, didx.Encode(), d.id.Bytes())
|
d.i.e.dbo.DelC(d.i.e.time, didx.Encode(), d.id.Bytes())
|
||||||
}
|
}
|
||||||
for _, v := range add {
|
for _, v := range add {
|
||||||
aidx := &keys.Index{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.ID, FD: v}
|
aidx := &keys.Index{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.ID, FD: v}
|
||||||
|
@ -413,7 +410,7 @@ func (d *document) storeIndex() (err error) {
|
||||||
if ix.Uniq == false {
|
if ix.Uniq == false {
|
||||||
for _, v := range del {
|
for _, v := range del {
|
||||||
didx := &keys.Point{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.ID, FD: v, ID: d.key.ID}
|
didx := &keys.Point{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.ID, FD: v, ID: d.key.ID}
|
||||||
d.i.e.dbo.DelC(d.now, didx.Encode(), d.id.Bytes())
|
d.i.e.dbo.DelC(d.i.e.time, didx.Encode(), d.id.Bytes())
|
||||||
}
|
}
|
||||||
for _, v := range add {
|
for _, v := range add {
|
||||||
aidx := &keys.Point{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.ID, FD: v, ID: d.key.ID}
|
aidx := &keys.Point{KV: d.key.KV, NS: d.key.NS, DB: d.key.DB, TB: d.key.TB, IX: ix.Name.ID, FD: v, ID: d.key.ID}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import (
|
||||||
|
|
||||||
type executor struct {
|
type executor struct {
|
||||||
dbo *mem.Cache
|
dbo *mem.Cache
|
||||||
|
time int64
|
||||||
send chan *Response
|
send chan *Response
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,6 +257,12 @@ func (e *executor) operate(ctx context.Context, stm sql.Statement) (res []interf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Specify a new time for the current executor
|
||||||
|
// iteration, so that all subqueries and async
|
||||||
|
// events are saved with the same version time.
|
||||||
|
|
||||||
|
e.time = time.Now().UnixNano()
|
||||||
|
|
||||||
// Get the fibre context ID so that we can use
|
// Get the fibre context ID so that we can use
|
||||||
// it to clear or flush websocket notification
|
// it to clear or flush websocket notification
|
||||||
// changes linked to this context.
|
// changes linked to this context.
|
||||||
|
|
Loading…
Reference in a new issue