Commit dc7b50c
authored
[fix](be) Avoid unsigned underflow in JSON modify path (#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: No1 parent 6ac210b commit dc7b50c
2 files changed
Lines changed: 27 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2048 | 2048 | | |
2049 | 2049 | | |
2050 | 2050 | | |
| 2051 | + | |
2051 | 2052 | | |
2052 | 2053 | | |
2053 | 2054 | | |
| |||
2058 | 2059 | | |
2059 | 2060 | | |
2060 | 2061 | | |
2061 | | - | |
| 2062 | + | |
| 2063 | + | |
2062 | 2064 | | |
2063 | 2065 | | |
2064 | 2066 | | |
| |||
2072 | 2074 | | |
2073 | 2075 | | |
2074 | 2076 | | |
2075 | | - | |
2076 | 2077 | | |
2077 | 2078 | | |
2078 | 2079 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
986 | 986 | | |
987 | 987 | | |
988 | 988 | | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
989 | 1013 | | |
0 commit comments