Use core_sqlsrv_has_any_result to check for null results
This commit is contained in:
parent
be2be4bb27
commit
270f2b446e
|
@ -1067,12 +1067,16 @@ int pdo_sqlsrv_stmt_next_rowset( _Inout_ pdo_stmt_t *stmt TSRMLS_DC )
|
|||
|
||||
SQLSRV_ASSERT( driver_stmt != NULL, "pdo_sqlsrv_stmt_next_rowset: driver_data object was null" );
|
||||
|
||||
// Make sure that the result set is not null, i.e. SQLNumResultCols() does not
|
||||
// return 0. Normally this error is handled in core_sqlsrv_fetch, but if the
|
||||
// user calls nextRowset() before fetch() the error is never shown so we handle it here.
|
||||
SQLSMALLINT has_fields = core::SQLNumResultCols( driver_stmt TSRMLS_CC );
|
||||
CHECK_CUSTOM_ERROR( has_fields == 0, driver_stmt, SQLSRV_ERROR_NO_FIELDS ) {
|
||||
throw core::CoreException();
|
||||
// Make sure that the result set is not null. Null means SQLNumResultCols returns 0
|
||||
// and SQLRowCount is not > 0. Normally this error is handled in core_sqlsrv_fetch(),
|
||||
// but if the user calls nextRowset() before fetch() the error is never shown
|
||||
// so we handle it here.
|
||||
bool has_result = core_sqlsrv_has_any_result( driver_stmt );
|
||||
|
||||
if(!driver_stmt->fetch_called){
|
||||
CHECK_CUSTOM_ERROR( !has_result, driver_stmt, SQLSRV_ERROR_NO_FIELDS ) {
|
||||
throw core::CoreException();
|
||||
}
|
||||
}
|
||||
|
||||
core_sqlsrv_next_result( static_cast<sqlsrv_stmt*>( stmt->driver_data ) TSRMLS_CC );
|
||||
|
|
|
@ -561,6 +561,18 @@ PHP_FUNCTION( sqlsrv_next_result )
|
|||
|
||||
try {
|
||||
|
||||
// Make sure that the result set is not null. Null means SQLNumResultCols returns 0
|
||||
// and SQLRowCount is not > 0. Normally this error is handled in core_sqlsrv_fetch(),
|
||||
// but if the user calls sqlsrv_next_result() before fetch() the error is never shown
|
||||
// so we handle it here.
|
||||
bool has_result = core_sqlsrv_has_any_result( stmt );
|
||||
|
||||
if(!stmt->fetch_called){
|
||||
CHECK_CUSTOM_ERROR( !has_result, stmt, SQLSRV_ERROR_NO_FIELDS ) {
|
||||
throw core::CoreException();
|
||||
}
|
||||
}
|
||||
|
||||
core_sqlsrv_next_result( stmt TSRMLS_CC, true );
|
||||
|
||||
if( stmt->past_next_result_end ) {
|
||||
|
|
|
@ -56,7 +56,7 @@ print_r(sqlsrv_errors());
|
|||
|
||||
$stmt = sqlsrv_query($conn, "DROP TABLE TestEmptySetTable");
|
||||
$stmt = sqlsrv_query($conn, "DROP PROCEDURE TestEmptySetProc");
|
||||
sqlsrv_free($conn);
|
||||
sqlsrv_close($conn);
|
||||
?>
|
||||
--EXPECT--
|
||||
Return a nonempty result set:
|
||||
|
@ -68,16 +68,6 @@ Array
|
|||
Array
|
||||
(
|
||||
[0] => Array
|
||||
(
|
||||
[0] => IMSSP
|
||||
[SQLSTATE] => IMSSP
|
||||
[1] => -26
|
||||
[code] => -26
|
||||
[2] => There are no more results returned by the query.
|
||||
[message] => There are no more results returned by the query.
|
||||
)
|
||||
|
||||
[1] => Array
|
||||
(
|
||||
[0] => HY010
|
||||
[SQLSTATE] => HY010
|
||||
|
|
Loading…
Reference in a new issue