Bug->Req #49352 [Opn]: Support DB4 DB_HASH format for dba_open()

From: Date: Thu, 25 Aug 2016 13:08:20 +0000
Subject: Bug->Req #49352 [Opn]: Support DB4 DB_HASH format for dba_open()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203543@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=49352&edit=1

 ID:                 49352
 Updated by:         cmb@php.net
 Reported by:        VJTD3 at VJTD3 dot com
-Summary:            dba_open DB4 DB_HASH format can not be chosen to
                     create a database
+Summary:            Support DB4 DB_HASH format for dba_open()
 Status:             Open
-Type:               Bug
+Type:               Feature/Change Request
 Package:            DBM/DBA related
 Operating System:   Linux
 PHP Version:        5.3.0
 Block user comment: N
 Private report:     N

 New Comment:

The documentation states[1]:

| The database is created in BTree mode, other modes (like Hash or
| Queue) are not supported.

So I'm reclassifying this as feature request.

[1] <http://php.net/manual/en/function.dba-open.php>


Previous Comments:
------------------------------------------------------------------------
[2010-01-11 16:19:59] chey dot smith at gmail dot com

I am having trouble with this as well when trying to modify an existing HASH type database.

What happens is that the file is modified but when the application that owns the DB tries to read
when you wrote it doesn't see the new data since it is compiled to read a BTREE type in my
case.

So there is a need to be able to specify the type from within PHP's dba_open function.

------------------------------------------------------------------------
[2009-08-25 00:33:32] VJTD3 at VJTD3 dot com

Description:
------------
dba_open DB4 DB_HASH format can not be choosen to create a database


dba_open when used with the "driver" db4 defaults to btree but hash is also needed.
DB_HASH is not defined and isn't passed when defined to the creation environment.

example showing DB_HASH not defined

<?php
 echo (defined('DB_HASH') ? 1 : 0);
?>

there are 2 types of database structures, hash and btree.
db.h
typedef enum {
	DB_BTREE=1,
	DB_HASH=2,
	DB_RECNO=3,
	DB_QUEUE=4,
	DB_UNKNOWN=5
} DBTYPE;


is from the source files...

http://download.oracle.com/berkeley-db/db-4.7.25.NC.tar.gz
db-4.7.25.NC/build_brew/db.h

by default php uses btree to create but hash is needed too. there is no way to change the flags to
use hash.

http://us3.php.net/manual/en/function.dba-open.php
resource dba_open  ( string $path  , string $mode  [, string $handler [, mixed $...  ]] )

php-5.2.9/dba_db4.c line 74-76
	type = info->mode == DBA_READER ? DB_UNKNOWN :
		info->mode == DBA_TRUNC ? DB_BTREE :
		s ? DB_BTREE : DB_UNKNOWN;

php-5.2.9/dba_db4.c line 100 - 104
#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
			(err=dbp->open(dbp, 0, info->path, NULL, type, gmode, filemode)) == 0) {
#else
			(err=dbp->open(dbp, info->path, NULL, type, gmode, filemode)) == 0)
{
#endif

http://www.oracle.com/technology/documentation/berkeley-db/db/ref/upgrade.4.1/fop.html

if ((ret = dbp->open(dbp, "file", NULL, DB_BTREE, DB_CREATE, 0664)) != 0) {
	(void)dbp->close(dbp);
	goto err_handler;
}

(btree example, hash would be DB_HASH)

Reproduce code:
---------------
<?php
 echo (defined('DB_HASH') ? 1 : 0);
?>


Expected result:
----------------
1 and databases to be created in hash format

Actual result:
--------------
0 and database format is only btree with no way to change to hash


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=49352&edit=1


Thread (3 messages)

« previous php.bugs (#203543) next »