Berkeley DB 1.86: Getting this older, free version to run properly on Windows

Click here to download BDB 1.86 for Windows

Why Berkeley DB 1.86?

First of all, it's free - because it's under the BSD license, unlike the more recent Sleepycat releases, it can be used without paying the high fees for commercial use. Secondly, it supports databases that are many megabytes in size. Finally, it's fast, has a reasonable memory footprint (being written in the early 90's), lets you use a .DB file as an on-disk hash database, and it's quite portable.

Berkely DB 1.85 is slightly outdated and has bugs, so 1.86 is the next free version before the non-BSD license.

What's wrong with the current versions?

The only version of BDB 1.86 that is available, has a bug in the implementation. It assumes a Unix environment, and so unless specifically asked not to do so, opens all binary files in text mode (fopen with parameter of 'r' instead of 'rb', and 'w' instead of 'wb')! This results in a problem. If you fill the DB file to a size of around 300kb, in one case, it refuses to let you write any more data to it. This makes you think that the database size limit is 300kb. Not so! It's just that a sequence of 0Dh and 0Ah is being messed up to become 0Ah (or something like that).

How can I fix the file-size-limit bug?

When you call dbopen, the flags in the 2nd parameter should include: "O_BINARY", or 0x8000. Add this to the normal flags, and your DB will be opened properly.