diff options
| author | foobar <sniper@php.net> | 2003-07-11 02:08:14 +0000 | 
|---|---|---|
| committer | foobar <sniper@php.net> | 2003-07-11 02:08:14 +0000 | 
| commit | 5aeedb4c88717e50ee362b2d36c560ee0cff63c2 (patch) | |
| tree | d193cbc45c6ae14e48a50c25cc3c0ed1086060c5 /ext/sybase/php_sybase_db.c | |
| parent | d3bde360a79fd1db0e2979fe5cd14e3bb08e95a6 (diff) | |
| download | php-git-5aeedb4c88717e50ee362b2d36c560ee0cff63c2.tar.gz | |
Fixed bug #17291 (mssql_query does not update get_last_message) (patch by: mgruetzner at rw3 dot com)
Diffstat (limited to 'ext/sybase/php_sybase_db.c')
| -rw-r--r-- | ext/sybase/php_sybase_db.c | 41 | 
1 files changed, 40 insertions, 1 deletions
| diff --git a/ext/sybase/php_sybase_db.c b/ext/sybase/php_sybase_db.c index 8f2a76b1c7..96ac666234 100644 --- a/ext/sybase/php_sybase_db.c +++ b/ext/sybase/php_sybase_db.c @@ -766,6 +766,7 @@ PHP_FUNCTION(sybase_query)  	int blocks_initialized=1;  	int i,j;  	int *column_types; +	RETCODE dbresults_retval;  	switch(ZEND_NUM_ARGS()) {  		case 1: @@ -797,7 +798,14 @@ PHP_FUNCTION(sybase_query)  		/*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 @@ PHP_FUNCTION(sybase_query)  	efree(column_types);  	Z_LVAL_P(return_value) = zend_list_insert(result,php_sybase_module.le_result);  	Z_TYPE_P(return_value) = IS_LONG; + +	/** +	 * mgruetzner@rw3.com -- 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."); +		} +	}  }  /* }}} */ | 
