Commit 98fa98ce authored by Kirill Smelkov's avatar Kirill Smelkov

X fs1: Fix empty file iteration

parent cd186bf8
...@@ -215,7 +215,7 @@ func (fs *FileStorage) _Load(dh *DataHeader, xid zodb.Xid) (*zodb.Buf, zodb.Tid, ...@@ -215,7 +215,7 @@ func (fs *FileStorage) _Load(dh *DataHeader, xid zodb.Xid) (*zodb.Buf, zodb.Tid,
type zIter struct { type zIter struct {
iter Iter iter Iter
TidStop zodb.Tid // iterate up to tid <= tidStop | tid >= tidStop depending on iter.dir tidStop zodb.Tid // iterate up to tid <= tidStop | tid >= tidStop depending on iter.dir
zFlags zIterFlags zFlags zIterFlags
...@@ -258,8 +258,8 @@ func (zi *zIter) NextTxn(_ context.Context) (*zodb.TxnInfo, zodb.IDataIterator, ...@@ -258,8 +258,8 @@ func (zi *zIter) NextTxn(_ context.Context) (*zodb.TxnInfo, zodb.IDataIterator,
} }
// XXX how to make sure last good txnh is preserved? // XXX how to make sure last good txnh is preserved?
if (zi.iter.Dir == IterForward && zi.iter.Txnh.Tid > zi.TidStop) || if (zi.iter.Dir == IterForward && zi.iter.Txnh.Tid > zi.tidStop) ||
(zi.iter.Dir == IterBackward && zi.iter.Txnh.Tid < zi.TidStop) { (zi.iter.Dir == IterBackward && zi.iter.Txnh.Tid < zi.tidStop) {
//println("-> EOF") //println("-> EOF")
zi.zFlags |= zIterEOF zi.zFlags |= zIterEOF
return nil, nil, io.EOF return nil, nil, io.EOF
...@@ -321,16 +321,17 @@ func (fs *FileStorage) findTxnRecord(r io.ReaderAt, tid zodb.Tid) (TxnHeader, er ...@@ -321,16 +321,17 @@ func (fs *FileStorage) findTxnRecord(r io.ReaderAt, tid zodb.Tid) (TxnHeader, er
//fmt.Printf("findTxn %v\n", tid) //fmt.Printf("findTxn %v\n", tid)
// XXX read snapshot under lock // XXX read snapshot under lock
// NOTE cloning to unalias strings memory
var tmin, tmax TxnHeader
tmin.CloneFrom(&fs.txnhMin)
tmax.CloneFrom(&fs.txnhMax)
if tmax.Pos == 0 { // XXX -> tmax.Valid() ? if fs.txnhMin.Len == 0 {
// empty database - no such record // empty database - no such record
return TxnHeader{}, nil return TxnHeader{}, nil
} }
// NOTE cloning to unalias strings memory
var tmin, tmax TxnHeader
tmin.CloneFrom(&fs.txnhMin)
tmax.CloneFrom(&fs.txnhMax)
// now we know the database is not empty and thus tmin & tmax are valid // now we know the database is not empty and thus tmin & tmax are valid
if tmax.Tid < tid { if tmax.Tid < tid {
...@@ -417,10 +418,10 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.ITxnIterator { ...@@ -417,10 +418,10 @@ func (fs *FileStorage) Iterate(tidMin, tidMax zodb.Tid) zodb.ITxnIterator {
iter.Datah.Pos = txnh.DataPos() // XXX dup wrt Iter.NextTxn iter.Datah.Pos = txnh.DataPos() // XXX dup wrt Iter.NextTxn
iter.Datah.DataLen = -DataHeaderSize // first iteration will go to first data record iter.Datah.DataLen = -DataHeaderSize // first iteration will go to first data record
iter.Dir = IterForward // XXX allow both ways iteration at ZODB level iter.Dir = IterForward // TODO allow both ways iteration at ZODB level
ziter.zFlags |= zIterPreloaded ziter.zFlags |= zIterPreloaded
ziter.TidStop = tidMax ziter.tidStop = tidMax
return ziter return ziter
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment