ID: 48270
User updated by: VJTD3 at VJTD3 dot com
Reported By: VJTD3 at VJTD3 dot com
Status: Bogus
Bug Type: DBM/DBA related
Operating System: linux redhat fedora 10
PHP Version: 5.2.9
New Comment:
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)
Previous Comments:
------------------------------------------------------------------------
[2009-05-19 15:02:45] [email protected]
.
------------------------------------------------------------------------
[2009-05-19 15:02:12] [email protected]
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-14 01:11:48] 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.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48270&edit=1