cvs: php4 / NEWS /ext/dba dba.c dba_db2.c dba_db3.c php_dba.h
| From: | Jouni Ahto | Date: | Tue, 27 Jun 2000 21:36:26 +0000 |
| Subject: | cvs: php4 / NEWS /ext/dba dba.c dba_db2.c dba_db3.c php_dba.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-517@lists.php.net to get a copy of this message | ||
jah Tue Jun 27 14:36:26 2000 EDT
Modified files:
/php4 NEWS
/php4/ext/dba dba.c dba_db2.c dba_db3.c php_dba.h
Log:
- 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.
Index: php4/NEWS
diff -u php4/NEWS:1.328 php4/NEWS:1.329
--- php4/NEWS:1.328 Tue Jun 27 11:44:30 2000
+++ php4/NEWS Tue Jun 27 14:36:25 2000
@@ -2,6 +2,10 @@
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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)
Index: php4/ext/dba/dba.c
diff -u php4/ext/dba/dba.c:1.17 php4/ext/dba/dba.c:1.18
--- php4/ext/dba/dba.c:1.17 Mon Jun 5 12:47:40 2000
+++ php4/ext/dba/dba.c Tue Jun 27 14:36:25 2000
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba.c,v 1.17 2000/06/05 19:47:40 andi Exp $ */
+/* $Id: dba.c,v 1.18 2000/06/27 21:36:25 jah Exp $ */
#include "php.h"
@@ -191,6 +191,9 @@
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;
}
@@ -206,7 +209,7 @@
dba_handler *hptr;
php_info_print_box_start(0);
- PUTS("V1 ($Id: dba.c,v 1.17 2000/06/05 19:47:40 andi Exp $)");
+ PUTS("V1 ($Id: dba.c,v 1.18 2000/06/27 21:36:25 jah Exp $)");
for(hptr = handler; hptr->name; hptr++) {
PUTS(" ");
PUTS(hptr->name);
Index: php4/ext/dba/dba_db2.c
diff -u php4/ext/dba/dba_db2.c:1.6 php4/ext/dba/dba_db2.c:1.7
--- php4/ext/dba/dba_db2.c:1.6 Thu Apr 20 10:23:59 2000
+++ php4/ext/dba/dba_db2.c Tue Jun 27 14:36:25 2000
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba_db2.c,v 1.6 2000/04/20 17:23:59 zeev Exp $ */
+/* $Id: dba_db2.c,v 1.7 2000/06/27 21:36:25 jah Exp $ */
#include "php.h"
@@ -74,6 +74,21 @@
if(info->argc > 0) {
convert_to_long_ex(info->argv[0]);
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)) {
Index: php4/ext/dba/dba_db3.c
diff -u php4/ext/dba/dba_db3.c:1.4 php4/ext/dba/dba_db3.c:1.5
--- php4/ext/dba/dba_db3.c:1.4 Thu Apr 20 10:23:59 2000
+++ php4/ext/dba/dba_db3.c Tue Jun 27 14:36:26 2000
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba_db3.c,v 1.4 2000/04/20 17:23:59 zeev Exp $ */
+/* $Id: dba_db3.c,v 1.5 2000/06/27 21:36:26 jah Exp $ */
#include "php.h"
@@ -74,6 +74,21 @@
if (info->argc > 0) {
convert_to_long_ex(info->argv[0]);
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 &&
Index: php4/ext/dba/php_dba.h
diff -u php4/ext/dba/php_dba.h:1.2 php4/ext/dba/php_dba.h:1.3
--- php4/ext/dba/php_dba.h:1.2 Fri Dec 17 12:54:51 1999
+++ php4/ext/dba/php_dba.h Tue Jun 27 14:36:26 2000
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_dba.h,v 1.2 1999/12/17 20:54:51 zeev Exp $ */
+/* $Id: php_dba.h,v 1.3 2000/06/27 21:36:26 jah Exp $ */
#ifndef _DBA_H
#define _DBA_H
@@ -40,6 +40,12 @@
DBA_TRUNC,
DBA_CREAT
} dba_mode_t;
+
+typedef enum {
+ DBA_BTREE = 1,
+ DBA_HASH,
+ DBA_RECNO
+} dba_type_t;
typedef struct dba_info {
/* public */