2

Closed

Query against a new database throws errors in WAHBitArray2 and ViewHandler

description

So I'm just playing with some sample code, and I tried to run some queries even though I hadn't inserted any data yet. An edge case, for sure, but not that unlikely. I'm not sure if the same happens if you query an empty table that has previously had data in it, but I suspect it does.

Call
var _db = RaptorDB.RaptorDB.Open( _dbPath );
_db.Query<T>( String.Empty ); // to get all rows
and then
In WAHBitArray::Fill(int count)
// count == 0 as there is no data in the table
int c = count >> 5; // c == 0
...
ints[c-1] = 0xffffffff << (32 - r); // fails - IndexOutOfRange
I guarded that with
if ( c != 0 ) 
but it's hard to tell whether that has any side-effects.

Call
var _db = RaptorDB.RaptorDB.Open( _dbPath );
Expression<Predicate<T>> filter = ( T ) => T.IsTruthyValue;
_db.Query<T>( filter ); // to get some rows using filter
and then
In ViewHandler::Query2<T>(Expression<Predicate<T>> filter, int start, int count, string orderby)
ba = ((WAHBitArray)qv._bitmap.Pop()).AndNot(delbits); //qv._bitmap has a Count of 0, fails - InvalidOperationException (Stack is empty)
I guarded that with
if ( qv._bitmap.Count != 0 ) 
but, again, it's hard to tell whether that has any side-effects.
Closed Jan 24, 2015 at 7:12 AM by MGholam

comments

MGholam wrote Dec 13, 2013 at 8:59 AM

Thanks Richard!

I will put these fixes in the next release.