thekid          Sun Feb 15 05:55:56 2004 EDT

  Modified files:              (Branch: PHP_4_3)
    /php-src/ext/sybase_ct      php_sybase_ct.c 
  Log:
  - Fixed bug #26407 (Result set fetching broken around transactions)
  
http://cvs.php.net/diff.php/php-src/ext/sybase_ct/php_sybase_ct.c?r1=1.73.2.10&r2=1.73.2.11&ty=u
Index: php-src/ext/sybase_ct/php_sybase_ct.c
diff -u php-src/ext/sybase_ct/php_sybase_ct.c:1.73.2.10 
php-src/ext/sybase_ct/php_sybase_ct.c:1.73.2.11
--- php-src/ext/sybase_ct/php_sybase_ct.c:1.73.2.10     Sun Feb 15 05:38:57 2004
+++ php-src/ext/sybase_ct/php_sybase_ct.c       Sun Feb 15 05:55:55 2004
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: php_sybase_ct.c,v 1.73.2.10 2004/02/15 10:38:57 thekid Exp $ */
+/* $Id: php_sybase_ct.c,v 1.73.2.11 2004/02/15 10:55:55 thekid Exp $ */
 
 
 #ifdef HAVE_CONFIG_H
@@ -1091,8 +1091,8 @@
        CS_INT retcode;
        
        /* We've already fetched everything */
-       if (result->last_retcode == CS_END_DATA) {
-               return CS_END_DATA;
+       if (result->last_retcode == CS_END_DATA || result->last_retcode == 
CS_END_RESULTS) {
+               return result->last_retcode;
        }
        
        if (numrows!=-1) numrows+= result->num_rows;
@@ -1143,7 +1143,6 @@
        }
        
        result->last_retcode= retcode;
-       
        switch (retcode) {
                case CS_END_DATA:
                        retcode = php_sybase_finish_results(result);
@@ -1278,12 +1277,13 @@
                result->fields[i].numeric = result->numerics[i];
                Z_TYPE(result->fields[i]) = result->types[i];
        }
-
+       
        retcode= php_sybase_fetch_result_row(result, buffered ? 1 : -1);
        if (retcode == CS_FAIL) {
                return NULL;
        }
 
+       result->last_retcode = retcode;
        return result;
 }
 
@@ -1412,7 +1412,6 @@
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Sybase:  Cannot 
read results");
                        RETURN_FALSE;
                }
-
                switch ((int) restype) {
                        case CS_CMD_FAIL:
                        default:
@@ -1450,6 +1449,7 @@
                /* Check for left-over results */
                if (!buffered && status != Q_RESULT) {
                        while ((retcode = ct_results(sybase_ptr->cmd, 
&restype))==CS_SUCCEED) {
+
                                switch ((int) restype) {
                                        case CS_CMD_SUCCEED:
                                        case CS_CMD_DONE:
@@ -1471,6 +1471,7 @@
                                                                RETURN_FALSE;
                                                        }
                                                        status = Q_RESULT;
+                                                       retcode = 
result->last_retcode; 
                                                } else {
                                                        /* Unexpected results, cancel 
them. */
                                                        ct_cancel(NULL, 
sybase_ptr->cmd, CS_CANCEL_CURRENT);
@@ -1488,8 +1489,10 @@
                                if (status == Q_FAILURE) {
                                        ct_cancel(NULL, sybase_ptr->cmd, 
CS_CANCEL_ALL);
                                }
+                               if (retcode == CS_END_RESULTS) {
+                                       break;
+                               }
                        }
-
                        switch (retcode) {
                                case CS_END_RESULTS:
                                        /* Normal. */
@@ -1513,7 +1516,7 @@
                                        break;
                        }
                }
-               
+
                /* Retry deadlocks up until deadlock_retry_count times */              
 
                if (sybase_ptr->deadlock && SybCtG(deadlock_retry_count) != -1 && 
++deadlock_count > SybCtG(deadlock_retry_count)) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Sybase:  Retried 
deadlock %d times [max: %ld], giving up\n", deadlock_count- 1, 
SybCtG(deadlock_retry_count));
@@ -1667,7 +1670,7 @@
        ZEND_FETCH_RESOURCE(result, sybase_result *, sybase_result_index, -1, "Sybase 
result", le_result);
 
        /* Unbuffered? */
-       if (result->last_retcode != CS_END_DATA) {
+       if (result->last_retcode != CS_END_DATA && result->last_retcode != 
CS_END_RESULTS) {
                php_sybase_fetch_result_row(result, 1);
        }
        
@@ -1704,7 +1707,7 @@
        ZEND_FETCH_RESOURCE(result, sybase_result *, sybase_result_index, -1, "Sybase 
result", le_result);
 
        /* Unbuffered ? Fetch next row */
-       if (result->last_retcode != CS_END_DATA) {
+       if (result->last_retcode != CS_END_DATA && result->last_retcode != 
CS_END_RESULTS) {
                php_sybase_fetch_result_row(result, 1);
        }
 
@@ -1817,7 +1820,7 @@
        convert_to_long_ex(offset);
 
        /* Unbuffered ? */
-       if (result->last_retcode != CS_END_DATA && 
Z_LVAL_PP(offset)>=result->num_rows) {
+       if (result->last_retcode != CS_END_DATA && result->last_retcode != 
CS_END_RESULTS && Z_LVAL_PP(offset)>=result->num_rows) {
                php_sybase_fetch_result_row(result, Z_LVAL_PP(offset));
        }
        
@@ -1945,7 +1948,7 @@
        field_offset = Z_LVAL_PP(offset);
        
        /* Unbuffered ? */
-       if (result->last_retcode != CS_END_DATA && field_offset>=result->num_rows) {
+       if (result->last_retcode != CS_END_DATA && result->last_retcode != 
CS_END_RESULTS && field_offset>=result->num_rows) {
                php_sybase_fetch_result_row(result, field_offset);
        }
 
@@ -1978,7 +1981,7 @@
        convert_to_long_ex(row);
        
        /* Unbuffered ? */
-       if (result->last_retcode != CS_END_DATA && Z_LVAL_PP(row) >= result->num_rows) 
{
+       if (result->last_retcode != CS_END_DATA && result->last_retcode != 
CS_END_RESULTS && Z_LVAL_PP(row) >= result->num_rows) {
                php_sybase_fetch_result_row(result, Z_LVAL_PP(row));
        }
 

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

Reply via email to