-
Notifications
You must be signed in to change notification settings - Fork 21
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: Binding parameters issues #157
Conversation
Resolves IBM#147 (comment) IBM#147 (comment) We now set `SQL_NTS` as the indicator instead of the string length. This helps in edge cases like empty string where indicator is set to 0. Also we now ensure the buffer size is at least the size of parameter or the size of the string.
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, just a couple small changes to be made.
src/db2ia/dbstmt.cc
Outdated
param[i].ind = param[i].paramSize; | ||
// CLI does not honor the buffer size parameter or the output size in the indicator | ||
// Make the buffer size is at least the size of parameter or the size of the string | ||
param[i].buf = (char *)calloc(std::max(static_cast<size_t>(param[i].paramSize) + 1, str_length), sizeof(char)); |
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.
str_length will be without the null terminator too
param[i].buf = (char *)calloc(std::max(static_cast<size_t>(param[i].paramSize) + 1, str_length), sizeof(char)); | |
param[i].buf = (char *)calloc(std::max(static_cast<size_t>(param[i].paramSize), str_length) + 1, sizeof(char)); | |
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.
Updated
src/db2ia/dbstmt.cc
Outdated
// Make the buffer size is at least the size of parameter or the size of the string | ||
param[i].buf = (char *)calloc(std::max(static_cast<size_t>(param[i].paramSize) + 1, str_length), sizeof(char)); | ||
// Set the indicator to be SQL_NTS | ||
// this helps in edge cases like empty string where indicator is set 0 |
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 helps in edge cases like empty string where indicator is set 0 | |
// this helps in edge cases like empty string where indicator is set 0 (which CLI doesn't like for some reason) |
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.
Updated
src/db2ia/dbstmt.cc
Outdated
param[i].buf = (char *)calloc(std::max(static_cast<size_t>(param[i].paramSize) + 1, str_length), sizeof(char)); | ||
// set the indicator to be SQL_NTS | ||
// this helps in edge cases like empty string where indicator is set 0 | ||
param[i].ind = SQL_NTS; | ||
// SQL_PARAM_INPUT_OUTPUT is always set so | ||
// copy the string to the buffer | ||
strcpy((char*)param[i].buf, cString); |
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.
Same changes as above need to be done here too
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.
Updated
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.
The changes make sense to me. It seems like a real headache that CLI doesn't respect these things it should..
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, I just had a couple grammar suggestions
Co-authored-by: Kevin Adler <kadler@us.ibm.com>
Co-authored-by: Kevin Adler <kadler@us.ibm.com>
Thanks for fixing this bug @abmusse |
Furthermore, I'd need to know when idb-pconnector will be upgraded to use the new version of idb-connector. That's the package we're actually using. |
I'm working on getting both packages released today. Thanks! |
Resolves #147 (comment)
#147 (comment)
We now set
SQL_NTS
as the indicator instead of the string length.This helps in edge cases like empty string where indicator is set to 0. Also we now ensure the buffer size is at least the size of parameter or the size of the string.