|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-08-01 23:10 UTC] svn@php.net
[2009-08-02 00:24 UTC] jani@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 05:00:02 2025 UTC |
Description: ------------ Using dba_exists with a file opened with dba_popen and the db4 handler will result in an error. Notice: dba_exists(): DB_THREAD mandates memory allocation flag on DBT data I found a similar problem was reported before for dba_fetch. Since dba_fetch and dba_exists share common code it was clear to see how this error could be fixed. Here is a simple diff between the original file and the fixed version. *** dba_db4.c 2009-07-31 13:24:14.000000000 -0400 --- dba_db4.c.fixed 2009-07-31 13:27:49.000000000 -0400 *************** *** 175,181 **** --- 175,187 ---- DB4_GKEY; memset(&gval, 0, sizeof(gval)); + if (info->flags & DBA_PERSISTENT) { + gval.flags |= DB_DBT_MALLOC; + } if (!dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { + if (info->flags & DBA_PERSISTENT) { + free(gval.data); + } return SUCCESS; } return FAILURE; I checked an the error still exists in the 5.2 snapshot. Reproduce code: --------------- Test #1 <?PHP $db = dba_popen('test.db4', 'c', 'db4'); dba_insert('b0rk', 'b0rk', $db); if (dba_exists('b0rk', $db) == true) { echo 'Yes, we have b0rk!' . PHP_EOL; } ?> Test #2 <?PHP error_reporting(E_ALL); $db = dba_popen('test.db4', 'c', 'db4'); dba_insert('b0rk', 'b0rk', $db); if (dba_exists('b0rk', $db) == true) { echo 'Yes, we have b0rk!' . PHP_EOL; } ?> Expected result: ---------------- Yes, we have b0rk! Actual result: -------------- Test #1 Nothing. Test #2 Notice: dba_exists(): DB_THREAD mandates memory allocation flag on DBT data in /tmp/test2.php on line 8