$NetBSD: patch-aa,v 1.2 2012/11/10 14:24:45 pettai Exp $

--- bdb/bdb_stubs.c.orig	2012-10-07 19:59:39.000000000 +0000
+++ bdb/bdb_stubs.c
@@ -33,7 +33,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <limits.h>
-#include <db.h>
+#include <db4/db.h>
 /* O_CREAT and others are not defined in db.h */
 #include <fcntl.h>
 
@@ -1272,7 +1272,7 @@ value caml_txn_begin(value dbenv, value 
 
   err = UW_dbenv(dbenv)->txn_begin(UW_dbenv(dbenv), parent, &newtxn, flags);
   if (err != 0) {
-    if (err == ENOMEM) {
+    if (err == DB_BUFFER_SMALL) {
       failwith("Maximum # of concurrent transactions reached");
     } else {
       UW_dbenv(dbenv)->err(UW_dbenv(dbenv), err,"caml_txn_begin");
