Commit 5eac204
committed
Fix decoding large json arrays
Without the fix, the included test fails with
```
AssertionError: Result length not requested length:
Expected=2. Actual=0. Position: 500079. Data Length: 500079
```
But I suspect (and have seen) also other errors, depending on specific contents
of the byte stream, e.g. ("Json type $random is not handled").
Int32/UInt32 values in json arrays are encoded inline in the "large" encoding
mode, but they are stored using 4 bytes, not 8. So the `read_uint64()` calls
are wrong here, `read_uint32()` works. Also the check for `large` in that case
is redundant, as `large` is always True for inlined int32/uint32 values.
Relevant parts in mysql server code are functions `serialize_json_array`,
`should_inline_value` and `insert_offset_or_size` in `sql/json_binary.cc` [1].
I believe this fixes issue #311.
[1] https://github.com/mysql/mysql-server/blob/5.7/sql/json_binary.cc1 parent 1376c6b commit 5eac204
2 files changed
+12
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
405 | | - | |
| 405 | + | |
406 | 406 | | |
407 | | - | |
| 407 | + | |
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
516 | 526 | | |
517 | 527 | | |
518 | 528 | | |
| |||
0 commit comments