-
Notifications
You must be signed in to change notification settings - Fork 141
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
Bugfix for #62 #63
base: master
Are you sure you want to change the base?
Bugfix for #62 #63
Conversation
This fixes it for me locally. (First had the second part of the slice set to the size of the buffer, but of course that's completely senseless...)
I would like to understand what the problem is that we're fixing here. Lets decide that first at issue #62. Alex |
please merge this! I was about to submit the same thing |
It has to do with how certain drivers report nulls. Sometimes they don't send back the SQL_NULL_DATA, I've noticed specifically with null dates. This adds an extra check to make sure we don't get the out of bounds error. |
c.Buffer size is passed to SQLBindCol, which returns c.Len. So unless SQLBindCol is broken, it cannot happen. Another possibility is that the column type you use here cannot be used with SQLBindCol. Then the change in this PR is not going to fix your problem. NewColumn function decides whether to use SQLBindCol or not. Maybe you can adjust it to make this work for you. Alternatively, if this PR works for you, you can always make this change in your own copy of this code, and keep it for yourself. Alex |
I did make the change in my own version, and have not had the problem since. It is a very specific issue, only with accessing a IBM iSeries DB2 from a 64-bit system. It seems the driver does not respond with a SQL_NULL_DATA in 64-bit, but rather in 32-bit, and therefore IsNull() is false, even though it should be true. I have found a little bit of information on the subject:
It is also mentioned here: https://bugs.php.net/bug.php?id=54007 I am not sure if this corresponds to a known issue with the IBM driver, mentioned here https://docs.oracle.com/en/database/oracle/oracle-database/18/odbcr/odbc-driver-release-notes.pdf I know very little about the internals of the DB interactions, so I'm kind of digging at this blindly. Obviously, the correct solution would be for IBM to fix their driver, but since this has been brought up many times over the last few years and they have done nothing, and for me this is affecting production applications, at least this will be here for others looking for a solution in the future. If anyone else is experiencing the same issue, they can use the fork I created. I have also prefixed all the fields in my queries with COALESCE() to not allow for NULL values anywhere I can. |
This fixes it for me locally. (First had the second part of the slice set to the size of the buffer, but of course that's completely senseless...)
Maybe check if this doesn't break anything.