diff options
author | Ondřej Surý <ondrej@sury.org> | 2010-10-21 08:52:46 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2010-10-21 08:52:46 +0200 |
commit | 01fcdff3849c3691d9aaeaab735846ab6d8895ca (patch) | |
tree | 6460876d356113fa7053df36f2aa00baa7db24a9 /ext/dba/dba_db4.c | |
parent | 855a09f4eded707941180c9d90acd17c25e29447 (diff) | |
download | php-upstream/5.3.3.tar.gz |
Imported Upstream version 5.3.3upstream/5.3.3
Diffstat (limited to 'ext/dba/dba_db4.c')
-rw-r--r-- | ext/dba/dba_db4.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/ext/dba/dba_db4.c b/ext/dba/dba_db4.c index 7e500e09b..d6e3f1554 100644 --- a/ext/dba/dba_db4.c +++ b/ext/dba/dba_db4.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dba_db4.c 293036 2010-01-03 09:23:27Z sebastian $ */ +/* $Id: dba_db4.c 300151 2010-06-03 07:03:05Z sixd $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -37,13 +37,25 @@ #endif static void php_dba_db4_errcall_fcn( -#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3) +#if (DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)) const DB_ENV *dbenv, #endif const char *errpfx, const char *msg) { TSRMLS_FETCH(); - + +#if (DB_VERSION_MAJOR == 5 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8)) +/* Bug 51086, Berkeley DB 4.8.26 */ +/* This code suppresses a BDB 4.8 error message that BDB incorrectly emits */ + { + char *function = get_active_function_name(TSRMLS_C); + if (function && (!strcmp(function,"dba_popen") || !strcmp(function,"dba_open")) + && !strncmp(msg, "fop_read_meta", sizeof("fop_read_meta")-1)) { + return; + } + } +#endif + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s%s", errpfx?errpfx:"", msg); } @@ -67,6 +79,7 @@ DBA_OPEN_FUNC(db4) struct stat check_stat; int s = VCWD_STAT(info->path, &check_stat); +#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 7) /* Bug 51086 */ if (!s && !check_stat.st_size) { info->mode = DBA_TRUNC; /* force truncate */ } @@ -80,6 +93,20 @@ DBA_OPEN_FUNC(db4) (info->mode == DBA_CREAT && !s) ? 0 : info->mode == DBA_WRITER ? 0 : info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1; +#else + if (!s && !check_stat.st_size) { + info->mode = DBA_CREAT; /* force creation */ + } + + type = info->mode == DBA_READER ? DB_UNKNOWN : + (info->mode == DBA_TRUNC || info->mode == DBA_CREAT) ? DB_BTREE : + s ? DB_BTREE : DB_UNKNOWN; + + gmode = info->mode == DBA_READER ? DB_RDONLY : + info->mode == DBA_CREAT ? DB_CREATE : + info->mode == DBA_WRITER ? 0 : + info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1; +#endif if (gmode == -1) { return FAILURE; /* not possible */ @@ -97,7 +124,7 @@ DBA_OPEN_FUNC(db4) if ((err=db_create(&dbp, NULL, 0)) == 0) { dbp->set_errcall(dbp, php_dba_db4_errcall_fcn); if ( -#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1) +#if (DB_VERSION_MAJOR > 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)) (err=dbp->open(dbp, 0, info->path, NULL, type, gmode, filemode)) == 0) { #else (err=dbp->open(dbp, info->path, NULL, type, gmode, filemode)) == 0) { |