Skip to content

Commit 16d7fd9

Browse files
committed
implement support for LMDB in ext/dba
don't abort txn if cursor is active fix typos
1 parent 2058d8e commit 16d7fd9

File tree

7 files changed

+457
-0
lines changed

7 files changed

+457
-0
lines changed

ext/dba/config.m4

+34
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ PHP_ARG_WITH(dbm,,
100100
PHP_ARG_WITH(tcadb,,
101101
[ --with-tcadb[=DIR] DBA: Tokyo Cabinet abstract DB support], no, no)
102102

103+
PHP_ARG_WITH(lmdb,,
104+
[ --with-lmdb[=DIR] DBA: Lightning memory-mapped database support], no, no)
105+
103106

104107
dnl
105108
dnl Library checks
@@ -228,6 +231,37 @@ if test "$PHP_TCADB" != "no"; then
228231
fi
229232
PHP_DBA_STD_RESULT(tcadb)
230233

234+
dnl LMDB
235+
if test "$PHP_LMDB" != "no"; then
236+
PHP_DBA_STD_BEGIN
237+
for i in $PHP_LMDB /usr/local /usr; do
238+
if test -f "$i/include/lmdb.h"; then
239+
THIS_PREFIX=$i
240+
PHP_ADD_INCLUDE($THIS_PREFIX/include)
241+
THIS_INCLUDE=$i/include/lmdb.h
242+
break
243+
fi
244+
done
245+
246+
if test -n "$THIS_INCLUDE"; then
247+
for LIB in lmdb; do
248+
PHP_CHECK_LIBRARY($LIB, mdb_open, [
249+
AC_DEFINE_UNQUOTED(LMDB_INCLUDE_FILE, "$THIS_INCLUDE", [ ])
250+
AC_DEFINE(DBA_LMDB, 1, [ ])
251+
THIS_LIBS=$LIB
252+
], [], [-L$THIS_PREFIX/$PHP_LIBDIR])
253+
if test -n "$THIS_LIBS"; then
254+
break
255+
fi
256+
done
257+
fi
258+
259+
PHP_DBA_STD_ASSIGN
260+
PHP_DBA_STD_CHECK
261+
PHP_DBA_STD_ATTACH
262+
fi
263+
PHP_DBA_STD_RESULT(lmdb)
264+
231265
dnl Berkeley specific (library and version test)
232266
dnl parameters(version, library list, function)
233267
AC_DEFUN([PHP_DBA_DB_CHECK],[

ext/dba/config.w32

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
ARG_WITH("dba", "DBA support", "no");
55
ARG_WITH("qdbm", "DBA: QDBM support", "no");
66
ARG_WITH("db", "DBA: Berkeley DB support", "no");
7+
ARG_WITH("lmdb", "DBA: Lightning memory-mapped database support", "no");
78

89
if (PHP_DBA != "no") {
910
EXTENSION("dba", "dba.c dba_cdb.c dba_db1.c dba_db2.c dba_db3.c dba_dbm.c dba_flatfile.c dba_gdbm.c dba_ndbm.c dba_inifile.c");
@@ -32,4 +33,16 @@ if (PHP_DBA != "no") {
3233
WARNING("dba: qdbm handlers not enabled; libraries and headers not found");
3334
}
3435
}
36+
37+
if (PHP_QDBM != "no") {
38+
if (CHECK_LIB("liblmdb_a.lib", "dba", PHP_DBA) &&
39+
CHECK_HEADER_ADD_INCLUDE("lmdb.h", "CFLAGS_DBA") &&
40+
CHECK_LIB("ntdll.lib", "dba", PHP_DBA)) {
41+
ADD_SOURCES("ext/dba", "dba_lmdb.c", "dba");
42+
AC_DEFINE("LMDB_INCLUDE_FILE", "<lmdb.h>", "", false);
43+
AC_DEFINE("DBA_LMDB", 1, "");
44+
} else {
45+
WARNING("dba: lmdb handlers not enabled; libraries and headers not found");
46+
}
47+
}
3548
}

ext/dba/dba.c

+6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include "php_inifile.h"
5252
#include "php_qdbm.h"
5353
#include "php_tcadb.h"
54+
#include "php_lmdb.h"
5455

5556
/* {{{ arginfo */
5657
ZEND_BEGIN_ARG_INFO_EX(arginfo_dba_popen, 0, 0, 2)
@@ -362,6 +363,9 @@ static dba_handler handler[] = {
362363
#endif
363364
#if DBA_TCADB
364365
DBA_HND(tcadb, DBA_LOCK_ALL)
366+
#endif
367+
#if DBA_LMDB
368+
DBA_HND(lmdb, DBA_LOCK_EXT)
365369
#endif
366370
{ NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
367371
};
@@ -387,6 +391,8 @@ static dba_handler handler[] = {
387391
#elif DBA_TCADB
388392
#define DBA_DEFAULT "tcadb"
389393
#else
394+
#define DBA_DEFAULT "lmdb"
395+
#else
390396
#define DBA_DEFAULT ""
391397
#endif
392398
/* cdb/cdb_make and ini are no option here */

0 commit comments

Comments
 (0)