Repository navigation
Conversation
Value entries are fixed width: 1 type byte plus 2 bytes (small) or 4
bytes (large, documents > 64 KiB). Only INT16/UINT16 skipped the unused
slot bytes; an inlined literal (true/false/null) in a large document left
2 bytes unread, so every following entry was read off by two. On MySQL
8.4.8 '{"a":true, ... 70 KB ...}' threw a LengthException, and other
layouts can decode wrong values. Skip whatever the scalar left of the
slot, for every inlined type.
cyppe
marked this pull request as ready for review
November 14, 2026 13:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
In the binary JSON format, value entries have a fixed width: 1 type byte plus 2 bytes in the small format, or 4 bytes in the large format, which is used for documents over 64 KiB (
sql-common/json_binary.cc). A literal or a 16-bit integer is inlined in its entry and is shorter than a large entry.parseArrayOrObject()skipped the unused bytes only forINT16/UINT16. An inlinedtrue,falseornullin a large document left 2 bytes unread, so every later entry was read from the wrong position. On MySQL 8.4,'{"a":true, ..., "f":"<70 KB>"}'throwsLengthException: The offset for the value in the JSON binary document is 132096, which is larger than the binary form of the JSON document. Other layouts can decode wrong values instead.The fix measures how far the scalar moved the cursor and skips the rest of the entry, for every inlined type.
Tests:
JsonBinaryDecoderServiceTest::testShouldSkipTheWholeInlinedSlotInLargeArraysand...InLargeObjectsdecode a hand-built large array[true, 7, null]and object{"a":true,"b":7}.TypesTest::testShouldDecodeLiteralsAndShortIntsInsideLargeJsonDocumentsdecodes a large object and a large array with literals and small integers.Both fail on
masterand pass with the fix. The full suite passes locally against MySQL 8.4.13 and MariaDB 11.4 (PHP 8.4). The PHP 8.2 CI cells fail onmastertoo (PHPUnit 12 needs PHP 8.3, see #159).This is the third of a few small, independent decoder fixes, after #161 and #162; it touches only the JSON decoder.