Skip to content

branch-4.1: [fix](be) Avoid unsigned underflow in JSON modify path #63579#64191

Merged
yiguolei merged 1 commit into
branch-4.1from
auto-pick-63579-branch-4.1
Jun 8, 2026
Merged

branch-4.1: [fix](be) Avoid unsigned underflow in JSON modify path #63579#64191
yiguolei merged 1 commit into
branch-4.1from
auto-pick-63579-branch-4.1

Conversation

@github-actions

@github-actions github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Cherry-picked from #63579

### What problem does this PR solve?

Issue Number: None

Problem Summary: JSON modify functions build a parent path by iterating
to the element before the last JSON path leg. The loop used
`get_leg_vector_size() - 1` on an unsigned size, which can underflow for
an empty path expression even though normal root-path execution resolves
to the root value before that branch. This patch caches the leg count
once, asserts the non-empty invariant for the insert-parent branch, and
uses `j + 1 < legs_count` to avoid unsigned subtraction while preserving
behavior.

The patch also adds BE unit coverage for missing-path JSONB modify cases
where the parent path has to be rebuilt, including single-leg object
insertion, nested object insertion, and array append behavior for both
`jsonb_insert` and `jsonb_set`.

### Release note

None

### Check List (For Author)

- Test:
    - Unit Test: added `FunctionJsonbTEST.JsonbModifyMissingPathParent`
- Build check: `DORIS_HOME=/mnt/disk7/hushenggang/doris-fix-spill ninja
-C be/ut_build_ASAN
test/CMakeFiles/doris_be_test.dir/exprs/function/function_jsonb_test.cpp.o`
- Format check: `build-support/clang-format.sh`;
`build-support/check-format.sh`; `git diff --check`
- Behavior changed: No
- Does this need documentation: No
@github-actions
github-actions Bot requested a review from yiguolei as a code owner June 8, 2026 01:11
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@hello-stephen

Copy link
Copy Markdown
Contributor

run buildall

@yiguolei yiguolei closed this Jun 8, 2026
@yiguolei yiguolei reopened this Jun 8, 2026
@yiguolei
yiguolei merged commit d622978 into branch-4.1 Jun 8, 2026
28 of 31 checks passed
@morningman
morningman deleted the auto-pick-63579-branch-4.1 branch July 8, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants