summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2002-11-06 11:18:00 +0000
committerMarcus Boerger <helly@php.net>2002-11-06 11:18:00 +0000
commitc7b7cf17c2656d8ab169aa66291005a0b6b2aa08 (patch)
treec180e18acdb93cefa9b8c2674ce1290456aa05f4 /ext
parent7fb5e192fb8af851a12006bb2a72a6334a52e798 (diff)
downloadphp-git-c7b7cf17c2656d8ab169aa66291005a0b6b2aa08.tar.gz
check whether a written databse can be appended and if read during write
is permitted #i use ksort for the result here since some dbm libraries sort their result #but that is nothing to test here.
Diffstat (limited to 'ext')
-rw-r--r--ext/dba/tests/dba_cdb.phpt11
-rw-r--r--ext/dba/tests/dba_db2.phpt11
-rw-r--r--ext/dba/tests/dba_db3.phpt11
-rw-r--r--ext/dba/tests/dba_dbm.phpt11
-rw-r--r--ext/dba/tests/dba_flatfile.phpt11
-rw-r--r--ext/dba/tests/dba_gdbm.phpt11
-rw-r--r--ext/dba/tests/dba_handler.inc34
-rw-r--r--ext/dba/tests/dba_ndbm.phpt11
-rw-r--r--ext/dba/tests/test.inc2
9 files changed, 111 insertions, 2 deletions
diff --git a/ext/dba/tests/dba_cdb.phpt b/ext/dba/tests/dba_cdb.phpt
index 716773c2f6..a9afe916d8 100644
--- a/ext/dba/tests/dba_cdb.phpt
+++ b/ext/dba/tests/dba_cdb.phpt
@@ -17,3 +17,14 @@ database handler: cdb
3NYNYY
Content String 2
Content 2 replaced
+Read during write permitted
+Content 2 replaced 2nd time
+The 6th value
+array(3) {
+ ["key number 6"]=>
+ string(13) "The 6th value"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+} \ No newline at end of file
diff --git a/ext/dba/tests/dba_db2.phpt b/ext/dba/tests/dba_db2.phpt
index cfbdb7e4d7..d23700fbd6 100644
--- a/ext/dba/tests/dba_db2.phpt
+++ b/ext/dba/tests/dba_db2.phpt
@@ -16,3 +16,14 @@ database handler: db2
3NYNYY
Content String 2
Content 2 replaced
+Read during write permitted
+Content 2 replaced 2nd time
+The 6th value
+array(3) {
+ ["key number 6"]=>
+ string(13) "The 6th value"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+} \ No newline at end of file
diff --git a/ext/dba/tests/dba_db3.phpt b/ext/dba/tests/dba_db3.phpt
index 82a08c8fd3..eea48d1b2a 100644
--- a/ext/dba/tests/dba_db3.phpt
+++ b/ext/dba/tests/dba_db3.phpt
@@ -16,3 +16,14 @@ database handler: db3
3NYNYY
Content String 2
Content 2 replaced
+Read during write permitted
+Content 2 replaced 2nd time
+The 6th value
+array(3) {
+ ["key number 6"]=>
+ string(13) "The 6th value"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+} \ No newline at end of file
diff --git a/ext/dba/tests/dba_dbm.phpt b/ext/dba/tests/dba_dbm.phpt
index 59c1e4ffe0..3f4d0fcf42 100644
--- a/ext/dba/tests/dba_dbm.phpt
+++ b/ext/dba/tests/dba_dbm.phpt
@@ -16,3 +16,14 @@ database handler: dbm
3NYNYY
Content String 2
Content 2 replaced
+Read during write permitted
+Content 2 replaced 2nd time
+The 6th value
+array(3) {
+ ["key number 6"]=>
+ string(13) "The 6th value"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+}
diff --git a/ext/dba/tests/dba_flatfile.phpt b/ext/dba/tests/dba_flatfile.phpt
index 33304e72fb..33d01809cf 100644
--- a/ext/dba/tests/dba_flatfile.phpt
+++ b/ext/dba/tests/dba_flatfile.phpt
@@ -16,3 +16,14 @@ database handler: flatfile
3NYNYY
Content String 2
Content 2 replaced
+Read during write permitted
+Content 2 replaced 2nd time
+The 6th value
+array(3) {
+ ["key number 6"]=>
+ string(13) "The 6th value"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+} \ No newline at end of file
diff --git a/ext/dba/tests/dba_gdbm.phpt b/ext/dba/tests/dba_gdbm.phpt
index a45c1075c1..79b41dadea 100644
--- a/ext/dba/tests/dba_gdbm.phpt
+++ b/ext/dba/tests/dba_gdbm.phpt
@@ -16,3 +16,14 @@ database handler: gdbm
3NYNYY
Content String 2
Content 2 replaced
+Read during write permitted
+Content 2 replaced 2nd time
+The 6th value
+array(3) {
+ ["key number 6"]=>
+ string(13) "The 6th value"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+} \ No newline at end of file
diff --git a/ext/dba/tests/dba_handler.inc b/ext/dba/tests/dba_handler.inc
index 393ffef89b..e8bb97c1a0 100644
--- a/ext/dba/tests/dba_handler.inc
+++ b/ext/dba/tests/dba_handler.inc
@@ -1,6 +1,6 @@
<?php
echo "database handler: $handler\n";
- if (($db_file=dba_open($db_file, "n", $handler))!==FALSE) {
+ if (($db_file=dba_open($db_filename, "n", $handler))!==FALSE) {
dba_insert("key1", "Content String 1", $db_file);
dba_insert("key2", "Content String 2", $db_file);
dba_insert("key3", "Third Content String", $db_file);
@@ -26,4 +26,36 @@
} else {
echo "Error creating database\n";
}
+ $db_writer=dba_open($db_filename, "w", $handler);
+ if (($dba_reader=dba_open($db_filename, "r", $handler))===false) {
+ echo "Cannot read during write operation\n";
+ } else {
+ echo "Read during write permitted\n";
+ }
+ if ($db_writer!==FALSE) {
+ dba_insert("key number 6", "The 6th value", $db_writer);
+ dba_replace("key2", "Content 2 replaced 2nd time", $db_writer);
+ dba_delete("key4", $db_writer);
+ echo dba_fetch("key2", $db_writer)."\n";
+ echo dba_fetch("key number 6", $db_writer)."\n";
+ dba_close($db_writer); // when the writer is open at least db3 would fail because of buffered io.
+ } else {
+ die("Error reopening database\n");
+ }
+ if (($db_file=dba_open($db_filename, "r", $handler))!==FALSE) {
+ $key = dba_firstkey($db_file);
+ $res = array();
+ while($key) {
+ $res[$key] = dba_fetch($key, $db_file);
+ $key = dba_nextkey($db_file);
+ }
+ ksort($res);
+ var_dump($res);
+ dba_close($db_file);
+ } else {
+ echo "Error reading database\n";
+ }
+ if ($dba_reader) {
+ dba_close($dba_reader);
+ }
?> \ No newline at end of file
diff --git a/ext/dba/tests/dba_ndbm.phpt b/ext/dba/tests/dba_ndbm.phpt
index 8fb94048f3..04ddfa51d0 100644
--- a/ext/dba/tests/dba_ndbm.phpt
+++ b/ext/dba/tests/dba_ndbm.phpt
@@ -16,3 +16,14 @@ database handler: ndbm
3NYNYY
Content String 2
Content 2 replaced
+Read during write permitted
+Content 2 replaced 2nd time
+The 6th value
+array(3) {
+ ["key number 6"]=>
+ string(13) "The 6th value"
+ ["key2"]=>
+ string(27) "Content 2 replaced 2nd time"
+ ["key5"]=>
+ string(23) "The last content string"
+} \ No newline at end of file
diff --git a/ext/dba/tests/test.inc b/ext/dba/tests/test.inc
index 768fc8dac5..0f920838ce 100644
--- a/ext/dba/tests/test.inc
+++ b/ext/dba/tests/test.inc
@@ -1,5 +1,5 @@
<?php
- $db_file = dirname(__FILE__).'/test0.dbm';
+ $db_filename = $db_file = dirname(__FILE__).'/test0.dbm';
$handler = dba_handlers();
// CDB currently supports only reading
if ($handler[0]=='cdb') {