Skip to content

Commit 9ef6a73

Browse files
committed
Add Berkeley DB 5 support. (An outstanding issue with BDB 4.8 related to 51086 that also affects BDB 5 is not yet resolved)
1 parent 8454cca commit 9ef6a73

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ PHP NEWS
1919
- Added FastCGI Process Manager (FPM) SAPI. (Tony)
2020
- Added recent Windows versions to php_uname and fix undefined windows
2121
version support. (Pierre)
22+
- Added Berkeley DB 5 support to the DBA extension (Johannes, Chris Jones)
2223

2324
- Changed namespaced classes so that the ctor can only be named
2425
__construct now. (Stas)

ext/dba/config.m4

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ PHP_ARG_WITH(ndbm,,
8383
[ --with-ndbm[=DIR] DBA: NDBM support], no, no)
8484

8585
PHP_ARG_WITH(db4,,
86-
[ --with-db4[=DIR] DBA: Berkeley DB4 support], no, no)
86+
[ --with-db4[=DIR] DBA: Oracle Berkeley DB 4.x or 5.x support], no, no)
8787

8888
PHP_ARG_WITH(db3,,
89-
[ --with-db3[=DIR] DBA: Berkeley DB3 support], no, no)
89+
[ --with-db3[=DIR] DBA: Oracle Berkeley DB 3.x support], no, no)
9090

9191
PHP_ARG_WITH(db2,,
92-
[ --with-db2[=DIR] DBA: Berkeley DB2 support], no, no)
92+
[ --with-db2[=DIR] DBA: Oracle Berkeley DB 2.x support], no, no)
9393

9494
PHP_ARG_WITH(db1,,
95-
[ --with-db1[=DIR] DBA: Berkeley DB1 support/emulation], no, no)
95+
[ --with-db1[=DIR] DBA: Oracle Berkeley DB 1.x support/emulation], no, no)
9696

9797
PHP_ARG_WITH(dbm,,
9898
[ --with-dbm[=DIR] DBA: DBM support], no, no)
@@ -210,7 +210,7 @@ AC_DEFUN([PHP_DBA_DB_CHECK],[
210210
],[
211211
AC_EGREP_CPP(yes,[
212212
#include "$THIS_INCLUDE"
213-
#if DB_VERSION_MAJOR == $1
213+
#if DB_VERSION_MAJOR == $1 || ($1 == 4 && DB_VERSION_MAJOR == 5)
214214
yes
215215
#endif
216216
],[
@@ -233,7 +233,7 @@ AC_DEFUN([PHP_DBA_DB_CHECK],[
233233
AC_MSG_CHECKING([for DB4 minor version and patch level])
234234
AC_EGREP_CPP(yes,[
235235
#include "$THIS_INCLUDE"
236-
#if DB_VERSION_MINOR != 1 || DB_VERSION_PATCH >= 25
236+
#if DB_VERSION_MINOR != 1 || (DB_VERSION_MINOR == 1 && DB_VERSION_PATCH >= 25)
237237
yes
238238
#endif
239239
],[
@@ -274,12 +274,21 @@ AC_DEFUN([PHP_DBA_DB_CHECK],[
274274
# DB4
275275
if test "$PHP_DB4" != "no"; then
276276
PHP_DBA_STD_BEGIN
277-
dbdp="/usr/local/BerkeleyDB.4."
278-
for i in $PHP_DB4 ${dbdp}8 ${dbdp}7 ${dbdp}6 ${dbdp}5 ${dbdp}4 ${dbdp}3 ${dbdp}2 ${dbdp}1 ${dbdp}0 /usr/local /usr; do
279-
if test -f "$i/db4/db.h"; then
277+
dbdp4="/usr/local/BerkeleyDB.4."
278+
dbdp5="/usr/local/BerkeleyDB.5."
279+
for i in $PHP_DB4 ${dbdp5}0 ${dbdp4}8 ${dbdp4}7 ${dbdp4}6 ${dbdp4}5 ${dbdp4}4 ${dbdp4}3 ${dbdp4}2 ${dbdp4}1 ${dbdp}0 /usr/local /usr; do
280+
if test -f "$i/db5/db.h"; then
281+
THIS_PREFIX=$i
282+
THIS_INCLUDE=$i/db5/db.h
283+
break
284+
elif test -f "$i/db4/db.h"; then
280285
THIS_PREFIX=$i
281286
THIS_INCLUDE=$i/db4/db.h
282287
break
288+
elif test -f "$i/include/db5.0/db.h"; then
289+
THIS_PREFIX=$i
290+
THIS_INCLUDE=$i/include/db5.0/db.h
291+
break
283292
elif test -f "$i/include/db4.8/db.h"; then
284293
THIS_PREFIX=$i
285294
THIS_INCLUDE=$i/include/db4.8/db.h

ext/dba/dba_db4.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@
3737
#endif
3838

3939
static void php_dba_db4_errcall_fcn(
40-
#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)
40+
#if (DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3))
4141
const DB_ENV *dbenv,
4242
#endif
4343
const char *errpfx, const char *msg)
4444
{
4545
TSRMLS_FETCH();
4646

47-
#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8 && DB_VERSION_PATCH <= 26)
47+
#if (DB_VERSION_MAJOR == 5 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8))
4848
/* Bug 51086, Berkeley DB 4.8.26 */
4949
/* This code suppresses a BDB 4.8 error message that BDB incorrectly emits */
5050
{
@@ -124,7 +124,7 @@ DBA_OPEN_FUNC(db4)
124124
if ((err=db_create(&dbp, NULL, 0)) == 0) {
125125
dbp->set_errcall(dbp, php_dba_db4_errcall_fcn);
126126
if (
127-
#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
127+
#if (DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1))
128128
(err=dbp->open(dbp, 0, info->path, NULL, type, gmode, filemode)) == 0) {
129129
#else
130130
(err=dbp->open(dbp, info->path, NULL, type, gmode, filemode)) == 0) {

ext/dba/tests/dba_db4_handlers.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ database handler: db4
4747
Test 1
4848
Success: db4 enabled
4949
Test 2 - full info
50-
.*Berkeley DB 4.*
50+
.*Berkeley DB (4|5).*

0 commit comments

Comments
 (0)