cvs: php4 /ext/dba dba_db3.c
| From: | Gavin Sherry | Date: | Sat, 12 Jan 2002 07:22:28 +0000 |
| Subject: | cvs: php4 /ext/dba dba_db3.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-9044@lists.php.net to get a copy of this message | ||
swm Sat Jan 12 02:22:28 2002 EDT
Modified files:
/php4/ext/dba dba_db3.c
Log:
This fixes the notorious "mode 'c' fails" bug (see bugs - 10380, 10798,
11732). The bug originates from the fact that mode "c" for db3 sets 'type' to
DB_UNKNOWN and mode DB_CREATE when the database already exists. The underlying library raises an
error at this logical discrepancy: obviously one cannot create a database of unknown type.
Index: php4/ext/dba/dba_db3.c
diff -u php4/ext/dba/dba_db3.c:1.14 php4/ext/dba/dba_db3.c:1.15
--- php4/ext/dba/dba_db3.c:1.14 Tue Dec 11 10:29:02 2001
+++ php4/ext/dba/dba_db3.c Sat Jan 12 02:22:27 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba_db3.c,v 1.14 2001/12/11 15:29:02 sebastian Exp $ */
+/* $Id: dba_db3.c,v 1.15 2002/01/12 07:22:27 swm Exp $ */
#include "php.h"
@@ -49,13 +49,15 @@
int gmode = 0;
int filemode = 0644;
struct stat check_stat;
+ int s = VCWD_STAT(info->path, &check_stat);
type = info->mode == DBA_READER ? DB_UNKNOWN :
info->mode == DBA_TRUNC ? DB_BTREE :
- VCWD_STAT(info->path, &check_stat) ? DB_BTREE : DB_UNKNOWN;
+ s? DB_BTREE : DB_UNKNOWN;
gmode = info->mode == DBA_READER ? DB_RDONLY :
- info->mode == DBA_CREAT ? DB_CREATE :
+ (info->mode == DBA_CREAT && s) ? DB_CREATE :
+ (info->mode == DBA_CREAT && !s) ? 0 :
info->mode == DBA_WRITER ? 0 :
info->mode == DBA_TRUNC ? DB_CREATE | DB_TRUNCATE : -1;