-
Notifications
You must be signed in to change notification settings - Fork 41
Put the string lengths in their proper place #165
Conversation
Answering my own question: the lengths haven't been there for too long. This looks like the commit. |
Likely, it slipped because most/all users have relied on the default Unfortunately, even our tests do not cover such use case that would hit the bug. Good catch! |
Actually, 3 of the four fixes in this PR deal with variable-length data. I might not have caught every case though. |
@mcg1969 would you like to take a crack at writing a tests to catch this based on the code you were writing that exposed this issue to you? |
I'll see what I can do! |
@mcg1969 I'd like to help and write some tests for this PR. Simply, did you reveal the problem by using If we agree, let's merge it and I will work on the tests straight away, so this is covered. |
Thanks for the offer, I'm afraid I've been swamped. The way to exercise the bug is to have at least two rows. The string in Row 2 should have a longer length than the string in Row 1. When that happens, Row 2 will get truncated, because it will use the length from the first row. |
So yes, you need a batch size of at least 2... |
@mcg1969 In #185 I have managed to create tests which reproduce the bug as you described:
testing value of second row fails:
memory corruption / buffer overrun happens in
I think the test covers the issue pretty well and I'm going to merge your PR. |
Love it. Thank you so much for doing this. |
Looks great y'all! |
Wow, I wonder how this one slipped through the cracks for so long!
The
cbdata_
vector is of lengthrowset_size_
. For strings, it contains either the string length, orSQL_NULL_DATA
. Obviously, the length of stringN
should be incbdata_[N]
. But for some reason, the code was expecting to see every string length in the zeroth position. This was causing me problems when reading data that had variable string lengths.