-
Notifications
You must be signed in to change notification settings - Fork 0
Implement SQLGetDiagField #33
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
Conversation
alinaliBQ
left a comment
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.
LGTM
jduo
left a comment
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.
Will SQLGetDiagRec and SQLError be implemented in separate PRs? They are commonly used in applications.
| diagnostics = &connection->GetDiagnostics(); | ||
| break; | ||
| } | ||
|
|
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.
We can go ahead and add statement and descriptor cases now so we don't forget.
| // Retrieve record field data | ||
| switch (diagIdentifier) { | ||
| case SQL_DIAG_MESSAGE_TEXT: { | ||
| const std::string message = diagnostics->GetMessageText(recordIndex); |
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.
This can be a const std::string& right? That avoids a copy. Check throughout.
| } | ||
|
|
||
| case SQL_DIAG_SERVER_NAME: { | ||
| const std::string source = diagnostics->GetDataSourceComponent(); |
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.
This field is supposed to be the DSN if connecting via DSN (same as SQLGetInfo(DATA_SOURCE_NAME).
I do not remember if GetDataSourceComponent() returns the DSN, or if it returns the component name that is used for formatting the error message here: https://learn.microsoft.com/en-us/sql/odbc/reference/develop-app/diagnostic-messages?view=sql-server-ver16 . That's supposed to describe the internal component reporting the error.
| return SQL_INVALID_HANDLE; | ||
| } | ||
|
|
||
| if (!diagInfoPtr) { |
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.
It's legal to pass a NULL here if they just want the length. Same as for attributes.
| stringLengthPtr, *diagnostics); | ||
| } | ||
|
|
||
| default: |
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.
It might be a problem to throw an error for unrecognized, but standard diag types. (Like it breaks apps). Perhaps we just return dummy values for any valid, but not supported fields. For non-standard fields we can report error.
The spec says we should only return SQL_ERROR for when "The DiagIdentifier argument was not one of the valid values."
@jduo SQLError would be in milestone 3 |
Implementation of SQLGetDiagField.