diff options
author | Gavin Sherry <swm@php.net> | 2002-01-12 07:22:27 +0000 |
---|---|---|
committer | Gavin Sherry <swm@php.net> | 2002-01-12 07:22:27 +0000 |
commit | 8f30e5f61972cd85ecba9b242cde64e0ca837c61 (patch) | |
tree | a565a58749711d4aeff4129ad11f5a2e018be815 /ext/dba/dba_db3.c | |
parent | 8df03e2814aed732c0fbe3d45143433495533608 (diff) | |
download | php-git-8f30e5f61972cd85ecba9b242cde64e0ca837c61.tar.gz |
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.
Diffstat (limited to 'ext/dba/dba_db3.c')
-rw-r--r-- | ext/dba/dba_db3.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ext/dba/dba_db3.c b/ext/dba/dba_db3.c index 57505b255f..abe3b514ed 100644 --- a/ext/dba/dba_db3.c +++ b/ext/dba/dba_db3.c @@ -49,13 +49,15 @@ DBA_OPEN_FUNC(db3) 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; |