php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48270 dba_open DB4 DB_HASH does not work
Submitted: 2009-05-14 01:11 UTC Modified: 2009-05-19 18:50 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: VJTD3 at VJTD3 dot com Assigned:
Status: Not a bug Package: DBM/DBA related
PHP Version: 5.2.9 OS: linux redhat fedora 10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: VJTD3 at VJTD3 dot com
New email:
PHP Version: OS:

 

 [2009-05-14 01:11 UTC] VJTD3 at VJTD3 dot com
Description:
------------
dba_open when used with the "driver" db4 defaults to btree but hash is needed. (system databases are in hash not btree.) DB_HASH is not defined and isn't passed when defined to the creation environment.

db.h
typedef enum {
	DB_BTREE=1,
	DB_HASH=2,
	DB_RECNO=3,
	DB_QUEUE=4,
	DB_UNKNOWN=5
} DBTYPE;

example showing DB_HASH not defined
<?php
 echo (defined(DB_HASH) ? 1 : 0);
?>

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

Expected result:
----------------
return the proper value and create a database in that format then using dba_open.

Actual result:
--------------
dba_open does not accept the constant and only uses btree then hash is needed by system files.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-19 15:02 UTC] kalle@php.net
DBA does not define any constants, and never had as far as I can see in userland. Plus your using constants incorrectly and your example (if valid) should have been:

echo (defined('DB_HASH') ? 1 : 0);
 [2009-05-19 18:50 UTC] VJTD3 at VJTD3 dot com
there are 2 types of database structures, hash and btree.

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

was what i ment i just forgot the ' in the example.

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

the default php uses to create is btree when system files are hash with no way to change the flags to use the other formats.

(reading auto detects between formats. creating defaults to whatever it was compiled to or set to in the code unless specified.)

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)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC