helly           Wed Nov  6 06:18:00 2002 EDT

  Modified files:              
    /php4/ext/dba/tests dba_cdb.phpt dba_db2.phpt dba_db3.phpt 
                        dba_dbm.phpt dba_flatfile.phpt dba_gdbm.phpt 
                        dba_handler.inc dba_ndbm.phpt test.inc 
  Log:
  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.
  
  
Index: php4/ext/dba/tests/dba_cdb.phpt
diff -u php4/ext/dba/tests/dba_cdb.phpt:1.3 php4/ext/dba/tests/dba_cdb.phpt:1.4
--- php4/ext/dba/tests/dba_cdb.phpt:1.3 Mon Nov  4 12:53:04 2002
+++ php4/ext/dba/tests/dba_cdb.phpt     Wed Nov  6 06:18:00 2002
@@ -17,3 +17,14 @@
 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
Index: php4/ext/dba/tests/dba_db2.phpt
diff -u php4/ext/dba/tests/dba_db2.phpt:1.1 php4/ext/dba/tests/dba_db2.phpt:1.2
--- php4/ext/dba/tests/dba_db2.phpt:1.1 Fri Nov  1 09:23:23 2002
+++ php4/ext/dba/tests/dba_db2.phpt     Wed Nov  6 06:18:00 2002
@@ -16,3 +16,14 @@
 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
Index: php4/ext/dba/tests/dba_db3.phpt
diff -u php4/ext/dba/tests/dba_db3.phpt:1.1 php4/ext/dba/tests/dba_db3.phpt:1.2
--- php4/ext/dba/tests/dba_db3.phpt:1.1 Fri Nov  1 09:23:23 2002
+++ php4/ext/dba/tests/dba_db3.phpt     Wed Nov  6 06:18:00 2002
@@ -16,3 +16,14 @@
 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
Index: php4/ext/dba/tests/dba_dbm.phpt
diff -u php4/ext/dba/tests/dba_dbm.phpt:1.1 php4/ext/dba/tests/dba_dbm.phpt:1.2
--- php4/ext/dba/tests/dba_dbm.phpt:1.1 Sun Nov  3 15:17:00 2002
+++ php4/ext/dba/tests/dba_dbm.phpt     Wed Nov  6 06:18:00 2002
@@ -16,3 +16,14 @@
 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"
+}
Index: php4/ext/dba/tests/dba_flatfile.phpt
diff -u php4/ext/dba/tests/dba_flatfile.phpt:1.1 
php4/ext/dba/tests/dba_flatfile.phpt:1.2
--- php4/ext/dba/tests/dba_flatfile.phpt:1.1    Tue Nov  5 23:16:18 2002
+++ php4/ext/dba/tests/dba_flatfile.phpt        Wed Nov  6 06:18:00 2002
@@ -16,3 +16,14 @@
 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
Index: php4/ext/dba/tests/dba_gdbm.phpt
diff -u php4/ext/dba/tests/dba_gdbm.phpt:1.1 php4/ext/dba/tests/dba_gdbm.phpt:1.2
--- php4/ext/dba/tests/dba_gdbm.phpt:1.1        Fri Nov  1 09:23:23 2002
+++ php4/ext/dba/tests/dba_gdbm.phpt    Wed Nov  6 06:18:00 2002
@@ -16,3 +16,14 @@
 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
Index: php4/ext/dba/tests/dba_handler.inc
diff -u php4/ext/dba/tests/dba_handler.inc:1.1 php4/ext/dba/tests/dba_handler.inc:1.2
--- php4/ext/dba/tests/dba_handler.inc:1.1      Fri Nov  1 09:23:23 2002
+++ php4/ext/dba/tests/dba_handler.inc  Wed Nov  6 06:18:00 2002
@@ -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);
@@ -25,5 +25,37 @@
                dba_close($db_file);
        } 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);
        }
 ?>
Index: php4/ext/dba/tests/dba_ndbm.phpt
diff -u php4/ext/dba/tests/dba_ndbm.phpt:1.1 php4/ext/dba/tests/dba_ndbm.phpt:1.2
--- php4/ext/dba/tests/dba_ndbm.phpt:1.1        Fri Nov  1 09:23:23 2002
+++ php4/ext/dba/tests/dba_ndbm.phpt    Wed Nov  6 06:18:00 2002
@@ -16,3 +16,14 @@
 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
Index: php4/ext/dba/tests/test.inc
diff -u php4/ext/dba/tests/test.inc:1.3 php4/ext/dba/tests/test.inc:1.4
--- php4/ext/dba/tests/test.inc:1.3     Sun Nov  3 10:22:32 2002
+++ php4/ext/dba/tests/test.inc Wed Nov  6 06:18:00 2002
@@ -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') {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to