|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #49352 Support DB4 DB_HASH format for dba_open()
Submitted: 2009-08-25 00:33 UTC Modified: 2016-08-25 13:08 UTC
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:2 (66.7%)
From: VJTD3 at VJTD3 dot com Assigned:
Status: Open Package: DBM/DBA related
PHP Version: 5.3.0 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-08-25 00:33 UTC] VJTD3 at VJTD3 dot com
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

 echo (defined('DB_HASH') ? 1 : 0);

there are 2 types of database structures, hash and btree.
typedef enum {

is from the source files...

by default php uses btree to create but hash is needed too. there is no way to change the flags to use hash.
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 :

php-5.2.9/dba_db4.c line 100 - 104
			(err=dbp->open(dbp, 0, info->path, NULL, type, gmode, filemode)) == 0) {
			(err=dbp->open(dbp, info->path, NULL, type, gmode, filemode)) == 0)

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

(btree example, hash would be DB_HASH)

Reproduce code:
 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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-11 16:19 UTC] 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.
 [2016-07-10 14:06 UTC]
-Package: dBase related +Package: DBM/DBA related
 [2016-08-25 13:08 UTC]
-Summary: dba_open DB4 DB_HASH format can not be chosen to create a database +Summary: Support DB4 DB_HASH format for dba_open() -Type: Bug +Type: Feature/Change Request
 [2016-08-25 13:08 UTC]
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] <>
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 18 14:01:29 2024 UTC