From:             rcovell at rolet dot com
Operating system: FreeBSD 4.8
PHP version:      4.3.4RC1
PHP Bug Type:     DBM/DBA related
Bug description:  Cannot open existing hash db3 file with write

Description:
------------
Basically I cannot get php to open an existing (not created by php) db3
hash file when using either "w" or "c".  It seems that php is looking for
a btree format.  My database is a hash file.

More information:
Trying to read/write information to an existing db3 database (sendmail
aliases file).

I can read the file just fine.  But when I try to issue:

$id = dba_open ("aliases5.db", "w", "db3");

I get:
[Wed Oct  8 08:56:44 2003] [error] PHP Warning:  dba_open(aliases5.db,w):
Driver initialization failed for handler: db3: Invalid argument in
/usr/local/www/data/maillists/test3.php on line 3

After further testing I dumped the entire aliases db to a text file using
perl and recreated a copy of it with php:

$id = dba_open ("aliases5.db", "c", "db3");

This worked when creating a new file.  The file sizes where were different
from the original so performed a db3_dump on the newly created php db3
database.  It seems that php is defaulting to a btree format when trying
to open with either w or c.  My output from the db3_dump on the php
created db3:
VERSION=3
format=bytevalue
type=btree
HEADER=END

And from the one that sendmail created:
VERSION=3
format=bytevalue
type=hash
h_nelem=172
HEADER=END





Reproduce code:
---------------
//Note you need a hash database for this to fail
$id = dba_open ("aliases5.db", "w", "db3");
if (!$id) {
    echo "dba_open failed\n";
    exit;
}
dba_insert ("bkey", "bvalue", $id);

$key = dba_firstkey ($id);

while ($key != false)
{
    echo "<br>Key: " . $key . "->Value: " . dba_fetch ( $key, $id);
    $key = dba_nextkey ($id);
}

dba_close ($id);


Expected result:
----------------
To be able to insert into an existing (not created by php) db3 hash
database.

Actual result:
--------------
[Wed Oct  8 08:56:44 2003] [error] PHP Warning:  dba_open(aliases5.db,w):
Driver initialization failed for handler: db3: Invalid argument in
/usr/local/www/data/maillists/test3.php on line 3

-- 
Edit bug report at http://bugs.php.net/?id=25794&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25794&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25794&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=25794&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=25794&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=25794&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=25794&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=25794&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=25794&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=25794&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=25794&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=25794&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25794&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=25794&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=25794&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=25794&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=25794&r=float

Reply via email to