Skip to content
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 GH-9372: HY010 when binding overlong parameter #9541

Closed
wants to merge 4 commits into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Sep 14, 2022

If SQLPutData() fails, we should not call SQLParamData() again, because that yields the confusing HY010 (Function sequence error). Instead we properly handle SQLPutData() errors.

For the given case (paramter length > column length), some drivers let SQLPutData() fail, while others do not. Either behavior seems to conform to the ODBC specification. Anyhow, we do not want to silently truncate the given parameter, since that would break the behavior for drivers which do not fail, but still don't simply truncate the given parameter. So it is finally up to userland to avoid passing overlong parameters – with this patch they at least get useful information about the actual issue.

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I don't have ODBC set up so I haven't actually tested the code but I trust CI.

Maybe just add a comment that "22001" is the expected failure for trying to insert a value which doesn't fit? Took me a second to understand why the expected test output is blank.

@cmb69
Copy link
Member Author

cmb69 commented Sep 16, 2022

Maybe just add a comment that "22001" is the expected failure for trying to insert a value which doesn't fit?

Makes sense. Will do.

Given the recent discussion regarding BC breaks, I'm no longer convinced that this should target PHP-8.0. After all, some users might actually catch the exception and check only for the "HY010" code to handle the issue. Maybe we should be conservative here, and target PHP-8.2.

If `SQLPutData()` *fails*, we should not call `SQLParamData()` again,
because that yields the confusing `HY010` (Function sequence error).
Instead we properly handle `SQLPutData()` errors.

For the given case (paramter length > column length), some drivers let
`SQLPutData()` fail, while others do not.  Either behavior seems to
conform to the ODBC specification.  Anyhow, we do not want to silently
truncate the given parameter, since that would break the behavior for
drivers which do not fail, but still don't simply truncate the given
parameter.  So it is finally up to userland to avoid passing overlong
parameters – with this patch they at least get useful information about
the actual issue.
@cmb69 cmb69 changed the base branch from PHP-8.0 to PHP-8.2 October 18, 2022 14:08
@cmb69
Copy link
Member Author

cmb69 commented Oct 18, 2022

Makes sense. Will do.

Done.

Maybe we should be conservative here, and target PHP-8.2.

Also done.

@cmb69 cmb69 closed this in f5aaa8f Oct 19, 2022
@cmb69 cmb69 deleted the cmb/gh9372 branch October 19, 2022 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ODBC HY010 when binding parameter that is larger than the column definition
2 participants