sniper          Thu Jul 10 22:08:12 2003 EDT

  Modified files:              
    /php-src/ext/sybase php_sybase_db.c 
  Log:
  Fixed bug #17291 (mssql_query does not update get_last_message) (patch by: 
mgruetzner at rw3 dot com)
  
Index: php-src/ext/sybase/php_sybase_db.c
diff -u php-src/ext/sybase/php_sybase_db.c:1.49 php-src/ext/sybase/php_sybase_db.c:1.50
--- php-src/ext/sybase/php_sybase_db.c:1.49     Tue Jun 10 16:03:39 2003
+++ php-src/ext/sybase/php_sybase_db.c  Thu Jul 10 22:08:12 2003
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: php_sybase_db.c,v 1.49 2003/06/10 20:03:39 imajes Exp $ */
+/* $Id: php_sybase_db.c,v 1.50 2003/07/11 02:08:12 sniper Exp $ */
 
 
 #ifdef HAVE_CONFIG_H
@@ -766,6 +766,7 @@
        int blocks_initialized=1;
        int i,j;
        int *column_types;
+       RETCODE dbresults_retval;
 
        switch(ZEND_NUM_ARGS()) {
                case 1:
@@ -797,7 +798,14 @@
                /*php_error_docref(NULL TSRMLS_CC, E_WARNING,"Sybase:  Unable to set 
query");*/
                RETURN_FALSE;
        }
-       if (dbsqlexec(sybase_ptr->link)==FAIL || dbresults(sybase_ptr->link)==FAIL) {
+
+       if (dbsqlexec(sybase_ptr->link)==FAIL) {
+               /*php_error(E_WARNING,"Sybase:  Query failed");*/
+               RETURN_FALSE;
+       }
+
+       dbresults_retval = dbresults(sybase_ptr->link);
+       if (dbresults_retval==FAIL) {
                /*php_error_docref(NULL TSRMLS_CC, E_WARNING,"Sybase:  Query 
failed");*/
                RETURN_FALSE;
        }
@@ -895,6 +903,37 @@
        efree(column_types);
        Z_LVAL_P(return_value) = zend_list_insert(result,php_sybase_module.le_result);
        Z_TYPE_P(return_value) = IS_LONG;
+
+       /**
+        * [EMAIL PROTECTED] -- 3-6/2003
+        *
+        * If you do a query that calls a stored procedure which returns
+        * data AND calls raiserror to generated a user-defined error message,
+        * then after retrieving the first set of results above, the call
+        * to dbresults will have returned SUCCESS, instead of NO_MORE_RESULTS
+        * which indicates that the message generated by raiserror is still 
+        * waiting to be read.  If this is the case, then call dbresults
+        * again to force the reading of the message.  This will ensure the 
+        * get_last_message call will return the message properly if called
+        * after mssql_query, like it should.
+        *
+        * One thing to note, we are assuming that no more data should follow
+        * in this case--only the message will be read.  To make sure, I have
+        * added a call to dbnextrow.  The assumption is that it will return
+        * NO_MORE_ROWS in this case.  If the assumption is false, generate
+        * a PHP error so we can debug this case.
+        *
+        */
+       if (dbresults_retval != NO_MORE_RESULTS) {
+               /* Call dbresults again to read message */
+               dbresults_retval = dbresults(sybase_ptr->link);
+
+               /* Check assumption that dbnextrow returns NO_MORE_ROWS */
+               retvalue = dbnextrow(sybase_ptr->link);
+               if (retvalue != NO_MORE_ROWS) {
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"Expected 
dbnextrow() to return NO_MORE_ROWS.");
+               }
+       }
 }
 /* }}} */
 



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

Reply via email to