Browse Source

- Fixed bug #36436 (DBA problem with Berkeley DB4).

PHP-5.1
Marcus Boerger 21 years ago
parent
commit
78516c7905
  1. 1
      NEWS
  2. 18
      ext/dba/dba_db4.c
  3. 34
      ext/dba/tests/bug36436.phpt

1
NEWS

@ -22,6 +22,7 @@ PHP NEWS
- Added ReflectionClass::newInstanceArgs($args). (Marcus)
- Added imap_savebody() that allows message body to be written to a file.
(Mike)
- Fixed bug #36436 (DBA problem with Berkeley DB4). (Marcus)
- Fixed bug #36420 (segfault when access result->num_rows after calling
result->close()). (Ilia)
- Fixed bug #36403 (oci_execute() no longer supports OCI_DESCRIBE_ONLY).

18
ext/dba/dba_db4.c

@ -139,9 +139,15 @@ DBA_FETCH_FUNC(db4)
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 (newlen) *newlen = gval.size;
new = estrndup(gval.data, gval.size);
if (info->flags & DBA_PERSISTENT) {
free(gval.data);
}
}
return new;
}
@ -210,11 +216,23 @@ DBA_NEXTKEY_FUNC(db4)
memset(&gkey, 0, sizeof(gkey));
memset(&gval, 0, sizeof(gval));
if (info->flags & DBA_PERSISTENT) {
gkey.flags |= DB_DBT_MALLOC;
gval.flags |= DB_DBT_MALLOC;
}
if (dba->cursor->c_get(dba->cursor, &gkey, &gval, DB_NEXT) == 0) {
if (gkey.data) {
nkey = estrndup(gkey.data, gkey.size);
if (newlen) *newlen = gkey.size;
}
if (info->flags & DBA_PERSISTENT) {
if (gkey.data) {
free(gkey.data);
}
if (gval.data) {
free(gval.data);
}
}
}
return nkey;

34
ext/dba/tests/bug36436.phpt

@ -0,0 +1,34 @@
--TEST--
Bug #36436 DBA problem with Berkeley DB4
--SKIPIF--
<?php
$handler = 'db4';
require_once('skipif.inc');
?>
--FILE--
<?php
$handler = 'db4';
require_once('test.inc');
$db = dba_popen($db_filename, 'c', 'db4');
dba_insert('X', 'XYZ', $db);
dba_insert('Y', '123', $db);
var_dump($db, dba_fetch('X', $db));
var_dump(dba_firstkey($db));
var_dump(dba_nextkey($db));
dba_close($db);
unlink($db_filename);
?>
===DONE===
--EXPECTF--
resource(%d) of type (dba persistent)
string(3) "XYZ"
string(1) "X"
string(1) "Y"
===DONE===
Loading…
Cancel
Save