diff options
author | Ondřej Surý <ondrej@sury.org> | 2013-02-19 13:28:10 +0100 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2013-02-19 13:28:10 +0100 |
commit | 54098cf044025ec5965b8ea9c84750f9631d85b6 (patch) | |
tree | ed0ef32b379c0cdfe20fcafc5b27c4488732fe90 /ext/dba | |
parent | 8572aeb0703107705fc7dde35961cd6a5f89c0c8 (diff) | |
download | php-54098cf044025ec5965b8ea9c84750f9631d85b6.tar.gz |
Imported Upstream version 5.5.0~alpha4upstream/5.5.0_alpha4
Diffstat (limited to 'ext/dba')
-rw-r--r-- | ext/dba/dba_flatfile.c | 19 | ||||
-rw-r--r-- | ext/dba/dba_gdbm.c | 17 | ||||
-rw-r--r-- | ext/dba/dba_inifile.c | 1 | ||||
-rw-r--r-- | ext/dba/dba_qdbm.c | 10 | ||||
-rw-r--r-- | ext/dba/tests/dba_db1.phpt | 4 | ||||
-rw-r--r-- | ext/dba/tests/dba_db2.phpt | 4 | ||||
-rw-r--r-- | ext/dba/tests/dba_db3.phpt | 4 | ||||
-rw-r--r-- | ext/dba/tests/dba_db4_000.phpt | 4 | ||||
-rw-r--r-- | ext/dba/tests/dba_dbm.phpt | 4 | ||||
-rw-r--r-- | ext/dba/tests/dba_flatfile.phpt | 4 | ||||
-rw-r--r-- | ext/dba/tests/dba_gdbm.phpt | 2 | ||||
-rw-r--r-- | ext/dba/tests/dba_handler.inc | 12 | ||||
-rw-r--r-- | ext/dba/tests/dba_inifile.phpt | 4 | ||||
-rw-r--r-- | ext/dba/tests/dba_ndbm.phpt | 4 | ||||
-rw-r--r-- | ext/dba/tests/dba_qdbm.phpt | 2 | ||||
-rw-r--r-- | ext/dba/tests/dba_tcadb.phpt | 4 |
16 files changed, 78 insertions, 21 deletions
diff --git a/ext/dba/dba_flatfile.c b/ext/dba/dba_flatfile.c index 082aa5cdb..34aa635a5 100644 --- a/ext/dba/dba_flatfile.c +++ b/ext/dba/dba_flatfile.c @@ -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; } } diff --git a/ext/dba/dba_gdbm.c b/ext/dba/dba_gdbm.c index 7534568d3..47dd57649 100644 --- a/ext/dba/dba_gdbm.c +++ b/ext/dba/dba_gdbm.c @@ -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) diff --git a/ext/dba/dba_inifile.c b/ext/dba/dba_inifile.c index e1359b65e..05ee95c0e 100644 --- a/ext/dba/dba_inifile.c +++ b/ext/dba/dba_inifile.c @@ -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; } } diff --git a/ext/dba/dba_qdbm.c b/ext/dba/dba_qdbm.c index 485b1997e..eeece5701 100644 --- a/ext/dba/dba_qdbm.c +++ b/ext/dba/dba_qdbm.c @@ -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) + if (dpput(dba->dbf, key, keylen, val, vallen, mode == 1 ? DP_DKEEP : DP_DOVER)) { return SUCCESS; + } + + if (dpecode != DP_EKEEP) { + php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "%s", dperrmsg(dpecode)); + } - php_error_docref2(NULL TSRMLS_CC, key, val, E_WARNING, "%s", dperrmsg(dpecode)); return FAILURE; } diff --git a/ext/dba/tests/dba_db1.phpt b/ext/dba/tests/dba_db1.phpt index a24600350..d0e530e02 100644 --- a/ext/dba/tests/dba_db1.phpt +++ b/ext/dba/tests/dba_db1.phpt @@ -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) { @@ -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) { diff --git a/ext/dba/tests/dba_db2.phpt b/ext/dba/tests/dba_db2.phpt index 89d8a926e..1cfbb3e34 100644 --- a/ext/dba/tests/dba_db2.phpt +++ b/ext/dba/tests/dba_db2.phpt @@ -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) { @@ -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) { diff --git a/ext/dba/tests/dba_db3.phpt b/ext/dba/tests/dba_db3.phpt index 257c88217..5de7e5a04 100644 --- a/ext/dba/tests/dba_db3.phpt +++ b/ext/dba/tests/dba_db3.phpt @@ -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) { @@ -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) { diff --git a/ext/dba/tests/dba_db4_000.phpt b/ext/dba/tests/dba_db4_000.phpt index bbbc52c9f..17db4bb62 100644 --- a/ext/dba/tests/dba_db4_000.phpt +++ b/ext/dba/tests/dba_db4_000.phpt @@ -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) { @@ -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) { diff --git a/ext/dba/tests/dba_dbm.phpt b/ext/dba/tests/dba_dbm.phpt index dd1fe1e31..8bea8463d 100644 --- a/ext/dba/tests/dba_dbm.phpt +++ b/ext/dba/tests/dba_dbm.phpt @@ -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) { @@ -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) { diff --git a/ext/dba/tests/dba_flatfile.phpt b/ext/dba/tests/dba_flatfile.phpt index 8e1ca6a93..ac7f86ebd 100644 --- a/ext/dba/tests/dba_flatfile.phpt +++ b/ext/dba/tests/dba_flatfile.phpt @@ -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) { @@ -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) { diff --git a/ext/dba/tests/dba_gdbm.phpt b/ext/dba/tests/dba_gdbm.phpt index 33d7d2061..e68e8b740 100644 --- a/ext/dba/tests/dba_gdbm.phpt +++ b/ext/dba/tests/dba_gdbm.phpt @@ -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) { diff --git a/ext/dba/tests/dba_handler.inc b/ext/dba/tests/dba_handler.inc index 1c3f5127e..a950e903a 100644 --- a/ext/dba/tests/dba_handler.inc +++ b/ext/dba/tests/dba_handler.inc @@ -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"; diff --git a/ext/dba/tests/dba_inifile.phpt b/ext/dba/tests/dba_inifile.phpt index 81ab73879..5975d25f4 100644 --- a/ext/dba/tests/dba_inifile.phpt +++ b/ext/dba/tests/dba_inifile.phpt @@ -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) { @@ -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) { diff --git a/ext/dba/tests/dba_ndbm.phpt b/ext/dba/tests/dba_ndbm.phpt index b0f5542de..193db6f94 100644 --- a/ext/dba/tests/dba_ndbm.phpt +++ b/ext/dba/tests/dba_ndbm.phpt @@ -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) { @@ -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) { diff --git a/ext/dba/tests/dba_qdbm.phpt b/ext/dba/tests/dba_qdbm.phpt index ef216d925..e2205baa2 100644 --- a/ext/dba/tests/dba_qdbm.phpt +++ b/ext/dba/tests/dba_qdbm.phpt @@ -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) { diff --git a/ext/dba/tests/dba_tcadb.phpt b/ext/dba/tests/dba_tcadb.phpt index 52dd4de33..28b6dd8f0 100644 --- a/ext/dba/tests/dba_tcadb.phpt +++ b/ext/dba/tests/dba_tcadb.phpt @@ -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) { @@ -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) { |