Package: libdb5.1 Version: 5.1.25-11 Severity: important Berkeley DB creates a btree database even though hash is requested, and moreover, it does so silently.
Steps to reproduce: * gcc foo.c -ldb * rm -fr /tmp/db * ./a.out /tmp/db * db5.1_stat -d /tmp/db/openpgp | grep Btree The last command should say nothing, but instead it prints information about the database. file concurs that this is a btree database, not a hash database, even though the DB->open call clearly specifies DB_HASH. Berkeley DB is not only not creating a hash database, it's silently accepting a btree database for opening with DB_HASH when it's documented to fail in that case. My particular use case is a very large (~700 MB) database that I have reason to believe will perform much better with hash than with btree. -- System Information: Debian Release: wheezy/sid APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Kernel: Linux 3.0.0-1-amd64 (SMP w/2 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages libdb5.1 depends on: ii libc6 2.13-18 Embedded GNU C Library: Shared lib ii multiarch-support 2.13-18 Transitional package to ensure mul libdb5.1 recommends no packages. libdb5.1 suggests no packages. -- no debconf information -- brian m. carlson / brian with sandals: Houston, Texas, US +1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
#include <db.h> #include <stdio.h> #include <sys/stat.h> int main(int argc, char **argv) { int envflags = DB_CREATE | DB_RECOVER | DB_INIT_TXN | DB_INIT_MPOOL; int flags = (write ? DB_CREATE : DB_RDONLY) | DB_AUTO_COMMIT; DB_ENV *dbenv; DB *dbp; const char *filename = argv[1]; if (argc < 2) return 2; mkdir(filename, 0700); db_env_create(&dbenv, 0); dbenv->open(dbenv, filename, envflags, 0700); db_create(&dbp, dbenv, 0); dbp->open(dbp, NULL, "openpgp", "openpgp", DB_HASH, flags, 0600); dbp->close(dbp, 0); dbenv->close(dbenv, 0); return 0; }
signature.asc
Description: Digital signature