Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions ext/dba/dba_flatfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,16 @@ DBA_UPDATE_FUNC(flatfile)
gval.dsize = vallen;

switch(flatfile_store(dba, gkey, gval, mode==1 ? FLATFILE_INSERT : FLATFILE_REPLACE TSRMLS_CC)) {
case -1:
php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Operation not possible");
return FAILURE;
default:
case 0:
return SUCCESS;
case 1:
php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Key already exists");
return FAILURE;
case 0:
return SUCCESS;
case 1:
return FAILURE;
case -1:
php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Operation not possible");
return FAILURE;
default:
php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "Unknown return value");
return FAILURE;
}
}

Expand Down
17 changes: 12 additions & 5 deletions ext/dba/dba_gdbm.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,18 @@ DBA_UPDATE_FUNC(gdbm)
gval.dptr = (char *) val;
gval.dsize = vallen;

if(gdbm_store(dba->dbf, gkey, gval,
mode == 1 ? GDBM_INSERT : GDBM_REPLACE) == 0)
return SUCCESS;
php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "%s", gdbm_strerror(gdbm_errno));
return FAILURE;
switch (gdbm_store(dba->dbf, gkey, gval, mode == 1 ? GDBM_INSERT : GDBM_REPLACE)) {
case 0:
return SUCCESS;
case 1:
return FAILURE;
case -1:
php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "%s", gdbm_strerror(gdbm_errno));
return FAILURE;
default:
php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "Unknown return value");
return FAILURE;
}
}

DBA_EXISTS_FUNC(gdbm)
Expand Down
1 change: 0 additions & 1 deletion ext/dba/dba_inifile.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ DBA_UPDATE_FUNC(inifile)
case 0:
return SUCCESS;
case 1:
php_error_docref1(NULL TSRMLS_CC, key, E_WARNING, "Key already exists");
return FAILURE;
}
}
Expand Down
14 changes: 8 additions & 6 deletions ext/dba/dba_qdbm.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@ DBA_FETCH_FUNC(qdbm)
DBA_UPDATE_FUNC(qdbm)
{
QDBM_DATA;
int result;

result = dpput(dba->dbf, key, keylen, val, vallen, mode == 1 ? DP_DKEEP : DP_DOVER);
if (result)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing spaces

if (dpput(dba->dbf, key, keylen, val, vallen, mode == 1 ? DP_DKEEP : DP_DOVER)) {
return SUCCESS;

php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "%s", dperrmsg(dpecode));
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing spaces

if (dpecode != DP_EKEEP) {
php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "%s", dperrmsg(dpecode));
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing spaces

return FAILURE;
}

Expand Down
4 changes: 4 additions & 0 deletions ext/dba/tests/dba_db1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ database handler: db1
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand All @@ -33,6 +35,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand Down
4 changes: 4 additions & 0 deletions ext/dba/tests/dba_db2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ database handler: db2
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand All @@ -33,6 +35,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand Down
4 changes: 4 additions & 0 deletions ext/dba/tests/dba_db3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ database handler: db3
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand All @@ -33,6 +35,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand Down
4 changes: 4 additions & 0 deletions ext/dba/tests/dba_db4_000.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ database handler: db4
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand All @@ -37,6 +39,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand Down
4 changes: 4 additions & 0 deletions ext/dba/tests/dba_dbm.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ database handler: dbm
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand All @@ -33,6 +35,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand Down
4 changes: 4 additions & 0 deletions ext/dba/tests/dba_flatfile.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ database handler: flatfile
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand All @@ -37,6 +39,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand Down
2 changes: 2 additions & 0 deletions ext/dba/tests/dba_gdbm.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ database handler: gdbm
Content String 2
Content 2 replaced
Read during write:%sallowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand Down
12 changes: 10 additions & 2 deletions ext/dba/tests/dba_handler.inc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,16 @@ do {
echo "Read during write: allowed\n";
}
if ($db_writer!==FALSE) {
dba_insert("key number 6", "The 6th value", $db_writer);
@dba_insert("key number 6", "The 6th value inserted again would be an error", $db_writer);
if (dba_insert("key number 6", "The 6th value", $db_writer)) {
echo '"key number 6" written' . "\n";
} else {
echo 'Failed to write "key number 6"' . "\n";
}
if (dba_insert("key number 6", "The 6th value inserted again would be an error", $db_writer)) {
echo '"key number 6" written 2nd time' . "\n";
} else {
echo 'Failed to write "key number 6" 2nd time' . "\n";
}
dba_replace("key2", "Content 2 replaced 2nd time", $db_writer);
dba_delete("key4", $db_writer);
echo dba_fetch("key2", $db_writer)."\n";
Expand Down
4 changes: 4 additions & 0 deletions ext/dba/tests/dba_inifile.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ database handler: inifile
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand All @@ -33,6 +35,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand Down
4 changes: 4 additions & 0 deletions ext/dba/tests/dba_ndbm.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ database handler: ndbm
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand All @@ -33,6 +35,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand Down
2 changes: 2 additions & 0 deletions ext/dba/tests/dba_qdbm.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ database handler: qdbm
Content String 2
Content 2 replaced
Read during write:%sallowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand Down
4 changes: 4 additions & 0 deletions ext/dba/tests/dba_tcadb.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ database handler: tcadb
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand All @@ -37,6 +39,8 @@ array(3) {
Content String 2
Content 2 replaced
Read during write: not allowed
"key number 6" written
Failed to write "key number 6" 2nd time
Content 2 replaced 2nd time
The 6th value
array(3) {
Expand Down