]> granicus.if.org Git - php/commitdiff
Added test for IBASE_REC_VERSION/IBASE_REC_NO_VERSION trans constants
authorDaniela Mariaschi <daniela@php.net>
Sat, 14 Jun 2003 16:45:38 +0000 (16:45 +0000)
committerDaniela Mariaschi <daniela@php.net>
Sat, 14 Jun 2003 16:45:38 +0000 (16:45 +0000)
ext/interbase/tests/005.phpt
ext/interbase/tests/interbase.inc

index cf86ca5c8a07384e487d0f4255c7298efa7f4b1f..988b7536ed6c5a4a5bfda4c18983f2c9f2c5e781 100644 (file)
@@ -108,7 +108,8 @@ three transaction on default link
     
        $tr_1 = ibase_trans();  /* this default transaction also */
        $tr_2 = ibase_trans(IBASE_READ);
-       $tr_3 = ibase_trans(IBASE_READ+IBASE_COMMITTED);
+       $tr_3 = ibase_trans(IBASE_READ+IBASE_COMMITTED+IBASE_REC_VERSION+IBASE_WAIT);    
+       $tr_4 = ibase_trans(IBASE_READ+IBASE_COMMITTED+IBASE_REC_NO_VERSION+IBASE_NOWAIT);      
     
        $res = ibase_query("select * from test5");
     
@@ -139,6 +140,10 @@ three transaction on default link
     
     ibase_commit($tr_1);
 
+       $tr_1 = ibase_trans();
+        ibase_query($tr_1, "insert into test5 (i) values (5)");
+       
+       /* tr_2 is IBASE_READ + IBASE_CONCURRENCY + IBASE_WAIT */
        $res = ibase_query($tr_2, "select * from test5");
     
     echo "one row in second transaction\n";
@@ -146,6 +151,7 @@ three transaction on default link
 
     ibase_free_result($res);
 
+       /* tr_3 is IBASE_COMMITTED + IBASE_REC_VERSION + IBASE_WAIT */
        $res = ibase_query($tr_3, "select * from test5");
     
     echo "three rows in third transaction\n";
@@ -153,6 +159,15 @@ three transaction on default link
 
     ibase_free_result($res);
 
+       /* tr_4 IBASE_COMMITED + IBASE_REC_NO_VERSION + IBASE_NOWAIT */
+       $res = ibase_query($tr_4, "select * from test5");
+   
+        echo "three rows in fourth transaction with deadlock\n";
+    out_result_trap_error($res,"test5");
+
+    ibase_free_result($res); 
+        ibase_rollback($tr_1);
     ibase_close();
 /*
 transactions on second link
@@ -247,6 +262,13 @@ three rows in third transaction
 3      
 4      
 ---
+three rows in fourth transaction with deadlock
+--- test5 ---
+2      
+3      
+4      
+errmsg [lock conflict on no wait transaction deadlock ]        
+---
 three rows
 --- test5 ---
 2      
index df708deca27d712db495a822d5cd904370c1ccba..260ef00622a7eeb834cee176370b81e7d506ec3d 100755 (executable)
@@ -58,6 +58,19 @@ function out_result($result, $table_name = "")
        echo "---\n";
 }
 
+function out_result_trap_error($result, $table_name = "")
+{  
+   echo "--- $table_name ---\n";
+   while ($r = @ibase_fetch_assoc($result)){
+      while (list($k, $v) = each($r) ){
+         echo "$r[$k]\t";
+      }
+      echo "\n";
+   }
+   echo "errmsg [" . ibase_errmsg() . "]\t\n";
+   echo "---\n";
+} 
+
 /* M/D/Y H:M:S */
 function rand_datetime()
 {