summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJouni Ahto <jah@php.net>2000-06-27 21:36:26 +0000
committerJouni Ahto <jah@php.net>2000-06-27 21:36:26 +0000
commit1dfe76f5f6bfb7b866fd0ff88fff0d47ab7251b5 (patch)
treeb6d19e2cab2fc0be1cccea6543fc31bd33b043da
parentc860633741a1931d9f9e5298b21a8dc8efbc0fad (diff)
downloadphp-git-1dfe76f5f6bfb7b866fd0ff88fff0d47ab7251b5.tar.gz
- dba_[p]open accepts now a new parameter, which kind of database to create
(DBA_BTREE or DBA_HASH), if the handler is either 'db2' or 'db3' and mode 'c' or 'n'. It is ignored if mode is 'c' and the db already exists. # Asked on the list 4 1/2 hours ago if anyone's got to say something to this, # no response, so I'm assuming it's ok. And yes, I did test this.
-rw-r--r--NEWS4
-rw-r--r--ext/dba/dba.c3
-rw-r--r--ext/dba/dba_db2.c15
-rw-r--r--ext/dba/dba_db3.c15
-rw-r--r--ext/dba/php_dba.h6
5 files changed, 43 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index d9f922e920..d372addc6a 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ PHP 4.0 NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
28 Jun 2000, Version 4.0.1
+- Added a new (fifth) parameter to dba_[p]open(), which kind of database to
+ create (DBA_BTREE or DBA_HASH), if the handler is either 'db2' or 'db3' and
+ mode 'c' or 'n'. It is ignored if mode is 'c' and the db already exists.
+ (Jouni)
- Fixed a bug in opendir(), which prevented readdir() from working properly if
the $dir argument wasn't explicitly specified (Zeev)
- Made --enable-discard-path work again. (Andi)
diff --git a/ext/dba/dba.c b/ext/dba/dba.c
index b84de998c9..934b801e7e 100644
--- a/ext/dba/dba.c
+++ b/ext/dba/dba.c
@@ -191,6 +191,9 @@ static PHP_MINIT_FUNCTION(dba)
zend_hash_init(&ht_keys, 0, NULL, NULL, 1);
GLOBAL(le_db) = register_list_destructors(dba_close, NULL);
GLOBAL(le_pdb) = register_list_destructors(NULL, dba_close);
+ REGISTER_LONG_CONSTANT("DBA_BTREE", DBA_BTREE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("DBA_HASH", DBA_HASH, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("DBA_RECNO", DBA_RECNO, CONST_CS | CONST_PERSISTENT);
return SUCCESS;
}
diff --git a/ext/dba/dba_db2.c b/ext/dba/dba_db2.c
index de68974358..67eb366c60 100644
--- a/ext/dba/dba_db2.c
+++ b/ext/dba/dba_db2.c
@@ -76,6 +76,21 @@ DBA_OPEN_FUNC(db2)
filemode = (*info->argv[0])->value.lval;
}
+ if(info->argc > 1
+ && ((info->mode == DBA_CREAT && type != DB_UNKNOWN)
+ || info->mode == DBA_TRUNC)) {
+ convert_to_long_ex(info->argv[1]);
+ switch ((*info->argv[1])->value.lval) {
+ case DBA_HASH:
+ type = DB_HASH;
+ break;
+ case DBA_BTREE:
+ default:
+ type = DB_BTREE;
+ break;
+ }
+ }
+
if(!db_open(info->path, type, gmode, filemode, NULL, NULL, &dbp)) {
info->dbf = malloc(sizeof(dba_db2_data));
memset(info->dbf, 0, sizeof(dba_db2_data));
diff --git a/ext/dba/dba_db3.c b/ext/dba/dba_db3.c
index ae1405705d..809c5408eb 100644
--- a/ext/dba/dba_db3.c
+++ b/ext/dba/dba_db3.c
@@ -76,6 +76,21 @@ DBA_OPEN_FUNC(db3)
filemode = (*info->argv[0])->value.lval;
}
+ if(info->argc > 1
+ && ((info->mode == DBA_CREAT && type != DB_UNKNOWN)
+ || info->mode == DBA_TRUNC)) {
+ convert_to_long_ex(info->argv[1]);
+ switch ((*info->argv[1])->value.lval) {
+ case DBA_HASH:
+ type = DB_HASH;
+ break;
+ case DBA_BTREE:
+ default:
+ type = DB_BTREE;
+ break;
+ }
+ }
+
if (db_create(&dbp, NULL, 0) == 0 &&
dbp->open(dbp, info->path, NULL, type, gmode, filemode) == 0) {
dba_db3_data *data;
diff --git a/ext/dba/php_dba.h b/ext/dba/php_dba.h
index a504e972d1..0eeb38c027 100644
--- a/ext/dba/php_dba.h
+++ b/ext/dba/php_dba.h
@@ -41,6 +41,12 @@ typedef enum {
DBA_CREAT
} dba_mode_t;
+typedef enum {
+ DBA_BTREE = 1,
+ DBA_HASH,
+ DBA_RECNO
+} dba_type_t;
+
typedef struct dba_info {
/* public */
void *dbf; /* ptr to private data or whatever */