NULL values in field records are not supported #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue analysis
p1_mysql_bin.erl:
Obviously, this code is wrong since it could be 1 for Column 0 only, but any column could have a "NULL" value...
We had the below crash because a record of a table had a last column with a "NULL" value,
resulting in a correct decoding of all columns but the last column since
a string value decoding is attempted but fails (due to lack of data, see <<>>).
This column is erroneously not considered having a "NULL" value due to a "NULL bitmap" handling issue.
The issue is due to a wrong decoding of the "NULL" bitmap.
The spec https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_binary_resultset.html
describes a "NULL bitmap" with a bit for each column index and with 2 leading bits that should be ignored.
Those 2 bits are not taken into account in the current source code which causes a 2 bits shift
in the bitmap integer value.
Patch
We tried a table with records having "NULL" values at position 0, 3 and the last column 5 and the resultset
is correctly decoded once the provided patch has been applied.
Some unit tests of the binary protocol would be helpful ;-)