#20294 [NEW]: dba_firstkey doesn't work at all with Berkeley DB3 files
From: [EMAIL PROTECTED] Operating system: Solaris 2.5.1 PHP version: 4.2.2 PHP Bug Type: DBM/DBA related Bug description: dba_firstkey doesn't work at all with Berkeley DB3 files Here is some sample source: ? // ** Write to database ** $dbh = dba_open(/tmp/test.db3,c,db3); for($x=0;$x500;$x++) { $key = strval($x); $value = test . $key; $res = dba_insert($key,$value,$dbh); // Debug if(!$res) echo Failed to add rec $xbr; } dba_close($dbh); echo Done addingbr; // ** Read back ** echo Read backbr; $dbh = dba_open(/tmp/test.db3,r,db3); if ($dbh == false) { echo Database failed to openBR; } $key = dba_firstkey($dbh); if ($key == false) { echo Unable to use dba_firstkey to find initial keyBR; } echo First key is $keyBR; $x=0; while($key != false) { $value = dba_fetch($key,$dbh); echo $key,$valuebr; $key = dba_nextkey($dbh); $x++; } dba_close($dbh); echo Finished ! ($x records read back)br; ? Berkeley-DB is version 3.3.11 C Compiler is GNU C 2.95.3 Apache HTTPD is V2.0.40 PHP configured by './configure' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-db3=/usr/local/BerkeleyDB.3.3' Basically, it's writing 500 records to the DB3 file (I can cat it and see the resultant output) and then trying to read them back. Not one record is read back because db_firstkey returns FALSE. Help appreciated Jason -- Edit bug report at http://bugs.php.net/?id=20294edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=20294r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=20294r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=20294r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=20294r=needtrace Try newer version: http://bugs.php.net/fix.php?id=20294r=oldversion Not developer issue:http://bugs.php.net/fix.php?id=20294r=support Expected behavior: http://bugs.php.net/fix.php?id=20294r=notwrong Not enough info:http://bugs.php.net/fix.php?id=20294r=notenoughinfo Submitted twice:http://bugs.php.net/fix.php?id=20294r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=20294r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20294r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=20294r=dst IIS Stability: http://bugs.php.net/fix.php?id=20294r=isapi
#20294 [Opn-Bgs]: dba_firstkey doesn't work at all with Berkeley DB3 files
ID: 20294 User updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Bogus Bug Type: DBM/DBA related Operating System: Solaris 2.5.1 PHP Version: 4.2.2 New Comment: Silly me, fancy using an initial key of zero (0). This is indistinguishable from the FALSE value (a real TRAP for new players like me !!!). Changing the bounds of the variable X ensured that it read back the key / value pairs correctly. Bogus !!! Previous Comments: [2002-11-06 22:04:10] [EMAIL PROTECTED] Here is some sample source: ? // ** Write to database ** $dbh = dba_open(/tmp/test.db3,c,db3); for($x=0;$x500;$x++) { $key = strval($x); $value = test . $key; $res = dba_insert($key,$value,$dbh); // Debug if(!$res) echo Failed to add rec $xbr; } dba_close($dbh); echo Done addingbr; // ** Read back ** echo Read backbr; $dbh = dba_open(/tmp/test.db3,r,db3); if ($dbh == false) { echo Database failed to openBR; } $key = dba_firstkey($dbh); if ($key == false) { echo Unable to use dba_firstkey to find initial keyBR; } echo First key is $keyBR; $x=0; while($key != false) { $value = dba_fetch($key,$dbh); echo $key,$valuebr; $key = dba_nextkey($dbh); $x++; } dba_close($dbh); echo Finished ! ($x records read back)br; ? Berkeley-DB is version 3.3.11 C Compiler is GNU C 2.95.3 Apache HTTPD is V2.0.40 PHP configured by './configure' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-db3=/usr/local/BerkeleyDB.3.3' Basically, it's writing 500 records to the DB3 file (I can cat it and see the resultant output) and then trying to read them back. Not one record is read back because db_firstkey returns FALSE. Help appreciated Jason -- Edit this bug report at http://bugs.php.net/?id=20294edit=1