First of all, great job on the package. We've been looking for something exactly like this.
We're running into issues with BdBTreeCursor.GetRecNo. We created a database with the RECNUM flag and as far as we can tell everything else works but we end up with a memory access violation when we call the GetRecNo method. Also trying to Get a record by a RecNo also results in null DbEntry outputs.
Is this a pending issue or am I doing it wrong?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I put a fix for the access violation into CVS, it affects DBC_Wrap.cs.
Please check it out and test your code.
Striktly speaking this is a documentation bug in BDB, as the docs claim that the key parameter passed to DBC->Get is ignored, but it isn't actually, so I have to pass a dummy key.
Btw, about the code you posted: I would not use code that could potentially change the cursor position while looping over the cursor.
Even if the key is the same as in the loop, it could move the cursor if the key has duplicate entries.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am still new to BerkeleyDb. Is it because if you use the RecNum flag your key must be a UINT32? I had assumed that it will apply record numbers to a database even if the key is something different.. ie a string.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
First of all, great job on the package. We've been looking for something exactly like this.
We're running into issues with BdBTreeCursor.GetRecNo. We created a database with the RECNUM flag and as far as we can tell everything else works but we end up with a memory access violation when we call the GetRecNo method. Also trying to Get a record by a RecNo also results in null DbEntry outputs.
Is this a pending issue or am I doing it wrong?
I am not aware of an open issue.
Could you please post the code you are using?
Also, make sure you are using BDB 4.3.29 or BDB4.5.20.
I'm using BDB 4.5.20.
Using your example project:
Db db = new Db(DbCreateFlags.None);
db.ErrorPrefix = appName;
db.ErrorStream = errStream;
db.SetFlags(DbFlags.RecNum);
vendorDb = (DbBTree)db.Open(null, VendorDbName, null, DbType.BTree, Db.OpenFlags.Create, 0);
Databases dbs = Databases.Instance;
List<Vendor> vendors = new List<Vendor>();
DbBTreeCursor cursor = dbs.VendorDb.OpenCursor(null, DbFileCursor.CreateFlags.None);
foreach (KeyDataPair entry in cursor) {
Vendor vendor = null;
dbs.Fmt.FromDbEntry<Vendor>(ref vendor, ref entry.Data);
vendors.Add(vendor);
cursor.GetAt(ref entry.Key, ref entry.Data, DbFileCursor.GetAtMode.Set, DbFileCursor.ReadFlags.None);
int boo = cursor.GetRecNo(DbFileCursor.ReadFlags.None); // Results in access violation!
}
I put a fix for the access violation into CVS, it affects DBC_Wrap.cs.
Please check it out and test your code.
Striktly speaking this is a documentation bug in BDB, as the docs claim that the key parameter passed to DBC->Get is ignored, but it isn't actually, so I have to pass a dummy key.
Btw, about the code you posted: I would not use code that could potentially change the cursor position while looping over the cursor.
Even if the key is the same as in the loop, it could move the cursor if the key has duplicate entries.
I am still new to BerkeleyDb. Is it because if you use the RecNum flag your key must be a UINT32? I had assumed that it will apply record numbers to a database even if the key is something different.. ie a string.
No, the key does not have to be UInt32.
Works great now. Thanks.