diff options
author | Marcus Boerger <helly@php.net> | 2002-12-29 15:32:38 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2002-12-29 15:32:38 +0000 |
commit | c69d034a876333863b3942db4651bfd1484970df (patch) | |
tree | 834dc37a936d147c6e8c505465ebdea6093b3169 /ext/dba/dba_db4.c | |
parent | 9b22813c4dd803f527b385a196250e8db37a989a (diff) | |
download | php-git-c69d034a876333863b3942db4651bfd1484970df.tar.gz |
Added support for db3/db4 error handling/information
Diffstat (limited to 'ext/dba/dba_db4.c')
-rw-r--r-- | ext/dba/dba_db4.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/ext/dba/dba_db4.c b/ext/dba/dba_db4.c index 6cb2debcd7..5de50df2c7 100644 --- a/ext/dba/dba_db4.c +++ b/ext/dba/dba_db4.c @@ -35,6 +35,13 @@ #include <db.h> #endif +static void php_dba_db4_errcall_fcn(const char *errpfx, char *msg) +{ + TSRMLS_FETCH(); + + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s%s", errpfx?errpfx:"", msg); +} + #define DB4_DATA dba_db4_data *dba = info->dbf #define DB4_GKEY \ DBT gkey; \ @@ -50,7 +57,7 @@ DBA_OPEN_FUNC(db4) { DB *dbp = NULL; DBTYPE type; - int gmode = 0; + int gmode = 0, err; int filemode = 0644; struct stat check_stat; int s = VCWD_STAT(info->path, &check_stat); @@ -73,22 +80,28 @@ DBA_OPEN_FUNC(db4) filemode = Z_LVAL_PP(info->argv[0]); } - if (db_create(&dbp, NULL, 0) == 0 && + 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) - dbp->open(dbp, 0, info->path, NULL, type, gmode, filemode) == 0) { + (err=dbp->open(dbp, 0, info->path, NULL, type, gmode, filemode)) == 0) { #else - dbp->open(dbp, info->path, NULL, type, gmode, filemode) == 0) { + (err=dbp->open(dbp, info->path, NULL, type, gmode, filemode)) == 0) { #endif - dba_db4_data *data; + dba_db4_data *data; - data = pemalloc(sizeof(*data), info->flags&DBA_PERSISTENT); - data->dbp = dbp; - data->cursor = NULL; - info->dbf = data; + data = pemalloc(sizeof(*data), info->flags&DBA_PERSISTENT); + data->dbp = dbp; + data->cursor = NULL; + info->dbf = data; - return SUCCESS; - } else if (dbp != NULL) { - dbp->close(dbp, 0); + return SUCCESS; + } else { + dbp->close(dbp, 0); + *error = db_strerror(err); + } + } else { + *error = db_strerror(err); } return FAILURE; |