Skip to content

MDEV-40174: Remove unnecessary double parsing JSON document#5405

Open
VasuBhakt wants to merge 1 commit into
MariaDB:10.11from
VasuBhakt:MDEV-40174-json-normalize-json-equal-fix
Open

MDEV-40174: Remove unnecessary double parsing JSON document#5405
VasuBhakt wants to merge 1 commit into
MariaDB:10.11from
VasuBhakt:MDEV-40174-json-normalize-json-equal-fix

Conversation

@VasuBhakt

@VasuBhakt VasuBhakt commented Jul 17, 2026

Copy link
Copy Markdown

Fixes MDEV-40174

Problem

The json_normalize_engine function, used by json_normalize, calls json_valid_engine before processing. The processing reparses the same JSON document that json_valid already processed.

Solution

Removed the redundant json_valid_engine pre-check to eliminate double-parsing, and integrated error handling directly into the normalization engine:

  1. Catch Empty Strings: Removed DBUG_ASSERT(0) for uninitialized values and instead return an error directly in json_normalize_engine if root.type == JSON_VALUE_UNINITIALIZED.

  2. Catch Trailing Garbage on Scalars: Updated json_norm_build to enforce a full scan to the end of the document for scalar values (like numbers/strings) using while (json_scan_next(je) == 0). This ensures that trailing garbage correctly triggers a syntax error, matching the strict validation previously handled by json_valid_engine.

  3. Propagate Syntax Errors: Updated json_normalize_engine to explicitly check and fail if je->s.error is set during the build phase.

Version

The change is directed at versions 10.11, 11.4, 11.8, and should also fix 12.3. The PR is based on branch 10.11, being the lowest affected branch.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@CLAassistant

CLAassistant commented Jul 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

…ormalize

Signed-off-by: VasuBhakt <cpswastik31@gmail.com>
@VasuBhakt
VasuBhakt force-pushed the MDEV-40174-json-normalize-json-equal-fix branch from 8c432fc to f1ee4c5 Compare July 17, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants