daniela         Sat Jun 14 13:46:33 2003 EDT

  Modified files:              (Branch: PHP_4_3)
    /php4/ext/interbase interbase.c php_interbase.h 
    /php4/ext/interbase/tests   interbase.inc 005.phpt 
  Log:
  MFH: Added IBASE_REC_VERSION/IBASE_REC_NO_VERSION transaction constants
  
  
Index: php4/ext/interbase/interbase.c
diff -u php4/ext/interbase/interbase.c:1.91.2.8 php4/ext/interbase/interbase.c:1.91.2.9
--- php4/ext/interbase/interbase.c:1.91.2.8     Thu Jun 12 07:34:31 2003
+++ php4/ext/interbase/interbase.c      Sat Jun 14 13:46:33 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: interbase.c,v 1.91.2.8 2003/06/12 11:34:31 andrey Exp $ */
+/* $Id: interbase.c,v 1.91.2.9 2003/06/14 17:46:33 daniela Exp $ */
   
 
 /* TODO: Arrays, roles?
@@ -550,13 +550,19 @@
        REGISTER_LONG_CONSTANT("IBASE_DEFAULT", PHP_IBASE_DEFAULT, CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("IBASE_TEXT", PHP_IBASE_TEXT, CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("IBASE_UNIXTIME", PHP_IBASE_UNIXTIME, CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("IBASE_TIMESTAMP", PHP_IBASE_TIMESTAMP, 
CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("IBASE_DATE", PHP_IBASE_DATE, CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("IBASE_TIME", PHP_IBASE_TIME, CONST_PERSISTENT);
+       /* transactions */
+       REGISTER_LONG_CONSTANT("IBASE_WRITE", PHP_IBASE_WRITE, CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("IBASE_READ", PHP_IBASE_READ, CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("IBASE_COMMITTED", PHP_IBASE_COMMITTED, 
CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("IBASE_CONSISTENCY", PHP_IBASE_CONSISTENCY, 
CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("IBASE_CONCURRENCY", PHP_IBASE_CONCURRENCY, 
CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("IBASE_REC_VERSION", PHP_IBASE_REC_VERSION, 
CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("IBASE_REC_NO_VERSION", PHP_IBASE_REC_NO_VERSION, 
CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("IBASE_NOWAIT", PHP_IBASE_NOWAIT, CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("IBASE_TIMESTAMP", PHP_IBASE_TIMESTAMP, 
CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("IBASE_DATE", PHP_IBASE_DATE, CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("IBASE_TIME", PHP_IBASE_TIME, CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("IBASE_WAIT", PHP_IBASE_WAIT, CONST_PERSISTENT);
        
        return SUCCESS;
 }
@@ -622,7 +628,7 @@
 
        php_info_print_table_start();
        php_info_print_table_row(2, "Interbase Support", "enabled");    
-       php_info_print_table_row(2, "Revision", "$Revision: 1.91.2.8 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.91.2.9 $");
 #ifdef COMPILE_DL_INTERBASE
        php_info_print_table_row(2, "Dynamic Module", "yes");
 #endif
@@ -1541,27 +1547,34 @@
                ZEND_FETCH_RESOURCE2(ib_link, ibase_db_link *, NULL, link_id, 
"InterBase link", le_link, le_plink);
        }
 
-       if (trans_argl ) {
+       if (trans_argl) {
                tpb[tpb_len++] = isc_tpb_version3;
                tpbp = tpb;
                /* access mode */
-               if (trans_argl & PHP_IBASE_READ) /* READ ONLY TRANSACTION */
+               if (trans_argl & PHP_IBASE_READ) { /* READ ONLY TRANSACTION */
                        tpb[tpb_len++] = isc_tpb_read;
-               else
-                       tpb[tpb_len++] = isc_tpb_write;
+               } else {
+                       tpb[tpb_len++] = isc_tpb_write;  /* default  access mode */
+               }
                /* isolation level */
                if (trans_argl & PHP_IBASE_COMMITTED) {
                        tpb[tpb_len++] = isc_tpb_read_committed;
-               } else if (trans_argl & PHP_IBASE_CONSISTENCY)
+                       if (trans_argl & PHP_IBASE_REC_VERSION) {
+                               tpb[tpb_len++] = isc_tpb_rec_version;
+                       }else{
+                               tpb[tpb_len++] = isc_tpb_no_rec_version; /* default in 
read_committed  */ 
+                       }       
+               } else if (trans_argl & PHP_IBASE_CONSISTENCY) {
                        tpb[tpb_len++] = isc_tpb_consistency;
-               else 
-                       tpb[tpb_len++] = isc_tpb_concurrency;
+               } else {
+                       tpb[tpb_len++] = isc_tpb_concurrency;   /* default isolation 
level */ 
+               }
                /* lock resolution */
-               if (trans_argl & PHP_IBASE_NOWAIT)
+               if (trans_argl & PHP_IBASE_NOWAIT) {
                        tpb[tpb_len++] = isc_tpb_nowait;
-               else 
-                       tpb[tpb_len++] = isc_tpb_wait;
-
+               } else {
+                       tpb[tpb_len++] = isc_tpb_wait;  /* default lock resolution */
+               }
        }
 
        /* find empty transaction slot */
Index: php4/ext/interbase/php_interbase.h
diff -u php4/ext/interbase/php_interbase.h:1.28.2.2 
php4/ext/interbase/php_interbase.h:1.28.2.3
--- php4/ext/interbase/php_interbase.h:1.28.2.2 Wed May 14 04:26:34 2003
+++ php4/ext/interbase/php_interbase.h  Sat Jun 14 13:46:33 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_interbase.h,v 1.28.2.2 2003/05/14 08:26:34 daniela Exp $ */
+/* $Id: php_interbase.h,v 1.28.2.3 2003/06/14 17:46:33 daniela Exp $ */
 
 #ifndef PHP_INTERBASE_H
 #define PHP_INTERBASE_H
@@ -160,16 +160,22 @@
 /* extern ibase_module php_ibase_module; */
 
 enum php_interbase_option {
-       PHP_IBASE_DEFAULT = 0,
-       PHP_IBASE_TEXT = 1,
-       PHP_IBASE_UNIXTIME = 2,
-       PHP_IBASE_READ = 4,
-       PHP_IBASE_COMMITTED = 8,
-       PHP_IBASE_CONSISTENCY = 16,
-       PHP_IBASE_NOWAIT = 32,
-       PHP_IBASE_TIMESTAMP = 64,
-       PHP_IBASE_DATE = 128,
-       PHP_IBASE_TIME = 256
+       PHP_IBASE_DEFAULT                       = 0,
+       PHP_IBASE_TEXT                          = 1,
+       PHP_IBASE_UNIXTIME                      = 2,
+       PHP_IBASE_TIMESTAMP                     = 4,
+       PHP_IBASE_DATE                          = 8,
+       PHP_IBASE_TIME                          = 16,
+       /* transactions  */     
+       PHP_IBASE_WRITE                                 = 2,
+       PHP_IBASE_READ                          = 4,
+       PHP_IBASE_COMMITTED                     = 8,
+       PHP_IBASE_CONSISTENCY           = 16,
+       PHP_IBASE_CONCURRENCY           = 32,
+       PHP_IBASE_REC_VERSION           = 64,
+       PHP_IBASE_REC_NO_VERSION        = 128,
+       PHP_IBASE_NOWAIT                                = 256,
+       PHP_IBASE_WAIT                          = 512
 };
 
 #ifdef ZTS
Index: php4/ext/interbase/tests/interbase.inc
diff -u php4/ext/interbase/tests/interbase.inc:1.1.16.2 
php4/ext/interbase/tests/interbase.inc:1.1.16.3
--- php4/ext/interbase/tests/interbase.inc:1.1.16.2     Wed Apr 30 06:42:37 2003
+++ php4/ext/interbase/tests/interbase.inc      Sat Jun 14 13:46:33 2003
@@ -1,6 +1,6 @@
 <?php
 
-/* $Id: interbase.inc,v 1.1.16.2 2003/04/30 10:42:37 sniper Exp $ */
+/* $Id: interbase.inc,v 1.1.16.3 2003/06/14 17:46:33 daniela Exp $ */
 /* used in tests */
 
 srand((double)microtime()*1000000);
@@ -57,6 +57,19 @@
        }
        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()
Index: php4/ext/interbase/tests/005.phpt
diff -u php4/ext/interbase/tests/005.phpt:1.2.4.1 
php4/ext/interbase/tests/005.phpt:1.2.4.2
--- php4/ext/interbase/tests/005.phpt:1.2.4.1   Fri Apr 25 11:43:35 2003
+++ php4/ext/interbase/tests/005.phpt   Sat Jun 14 13:46:33 2003
@@ -108,7 +108,8 @@
     
        $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 @@
     
     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 @@
 
     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 @@
 
     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
@@ -246,6 +261,13 @@
 2      
 3      
 4      
+---
+three rows in fourth transaction with deadlock
+--- test5 ---
+2      
+3      
+4      
+errmsg [lock conflict on no wait transaction deadlock ]        
 ---
 three rows
 --- test5 ---



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

Reply via email to