-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for redundant calls to SQLNumResultCols and SQLRowCount #972
Fix for redundant calls to SQLNumResultCols and SQLRowCount #972
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #972 +/- ##
=========================================
- Coverage 81.38% 81.3% -0.08%
=========================================
Files 25 25
Lines 7758 7790 +32
=========================================
+ Hits 6314 6334 +20
- Misses 1444 1456 +12
Continue to review full report at Codecov.
|
source/sqlsrv/util.cpp
Outdated
@@ -196,7 +196,7 @@ ss_error SS_ERRORS[] = { | |||
|
|||
{ | |||
SQLSRV_ERROR_NO_FIELDS, | |||
{ IMSSP, (SQLCHAR*)"The active result for the query contains no fields.", -28, false } | |||
{ IMSSP, (SQLCHAR*)"The active result for the query contains no fields, so no result set was created.", -28, false } | |||
}, | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest not to change the existing error message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please excuse my multiple comments. I forgot to start a review.
if (stmt->columns_rows_obtained == false) { | ||
num_cols = core::SQLNumResultCols(stmt TSRMLS_CC); | ||
} else { | ||
num_cols = stmt->column_count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, see my earlier comment about setting stmt->column_count after calling SQLNumResultCols
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but please see my comments
@@ -828,7 +826,7 @@ bool core_sqlsrv_fetch( _Inout_ sqlsrv_stmt* stmt, _In_ SQLSMALLINT fetch_orient | |||
// First time only | |||
if ( !stmt->fetch_called ) { | |||
SQLSMALLINT has_fields; | |||
if (stmt->columns_rows_obtained) { | |||
if (stmt->column_count != ACTIVE_NUM_COLS_INVALID) { | |||
has_fields = stmt->column_count; | |||
} else { | |||
has_fields = core::SQLNumResultCols( stmt TSRMLS_CC ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After calling SQLNumResultCols, do you set stmt->column_count? If not, when?
if (stmt->columns_rows_obtained == false) { | ||
num_cols = core::SQLNumResultCols(stmt TSRMLS_CC); | ||
} else { | ||
num_cols = stmt->column_count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, see my earlier comment about setting stmt->column_count after calling SQLNumResultCols
https://docs.microsoft.com/sql/odbc/reference/develop-app/was-a-result-set-created