Skip to content

feat(json): implement JSON_DEPTH (#28033) - #28962

Merged
XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-28033-json-depth-20260916
Sep 28, 2026
Merged

XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-28033-json-depth-20260916

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #28033 (JSON_DEPTH only; JSON_ARRAY_INSERT and JSON_SEARCH remain separate follow-ups)

What this PR does / why we need it:

Implements MySQL-compatible JSON_DEPTH for text and typed JSON, preserving SQL NULL versus JSON null, rejecting unsupported/binary and malformed inputs, enforcing the existing nesting limit, and using iterative traversal with bounded auxiliary space.

The review repair adds a permanent real COM_STMT regression on one connection and statement ID. It checks new and cached text/integer/BLOB types, NULL with cached BLOB metadata, repeated rejection, and malformed-text recovery to a different depth. The test verifies actual new-parameters-bound flags instead of assuming driver reuse. The SQL BVT covers user-variable category transitions, checks both created tables are removed, and includes the JDBC Data truncation prefix demonstrated by the failing CI report.

Validation

Candidate: 9f651141db88995584c4e173c1f153be6f9427b6 (test-only review repair on 2e9caab3a5bbf9ce501596430a4787aff9e8473a). Product/native sources are identical to the service built and tested for this repair.

  • PASS: real COM_STMT regression, all ten steps, one connection/statement; 16.51s including fixture startup, pkg/embed command completed successfully.
  • PASS: all six selected TestJsonDepth unit tests; matching local native build; go vet all for pkg/embed; gofmt and git diff --check.
  • PASS: canonical test/distributed/cases/function/func_json_depth.sql normal mo-tester comparison twice on the same local single-CN instance: 42/42 each, both exit 0, no restart or intervening cleanup.
  • PASS: fresh independent mysql connection after each round found zero rows for both exact table names in information_schema.tables, before the next round could run entry cleanup. The test-owned instance was stopped normally afterward.
  • Environment: macOS arm64, Go 1.26.4, JDK 17. The canonical SQL/result pair was copied byte-for-byte to a temporary path because the local runner misparses dotted parent directory names; no result-generation mode was used.
  • BLOCKED_ENVIRONMENT: local golangci-lint was built with Go 1.24 and refuses target Go 1.26.4. No local lint PASS is claimed; fresh CI SCA remains required.
  • Prior exact-head PESSIMISTIC CI failed this case because Connector/J returned the binary charset error with a Data truncation prefix. The expectation now matches that observed output. Prior Coverage was blocked by incomplete producer coverage, not a calculated coverage verdict.
  • New-head CI, reviewer approval and deployed QA are pending; historical CI is not relabeled as current-head PASS.

Dependencies and acceptance

No public API or wire-format change is introduced by the review repair. This PR covers only JSON_DEPTH and must not close the parent issue. Preserve Ready status; it does not imply CI, reviewer, deployment, or QA acceptance.

QA required: yes — deployed SQL text/typed inputs, NULL, limits, errors and prepared reuse remain product acceptance scope. Two same-instance canonical BVT runs and independent teardown evidence are tracked separately from CI and reviewer approval.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added kind/bug Something isn't working kind/test-ci labels Sep 16, 2026
@matrix-meow matrix-meow added the size/L Denotes a PR that changes [500,999] lines label Sep 16, 2026
@VioletQwQ-0
VioletQwQ-0 force-pushed the codex/issue-28033-json-depth-20260916 branch from 5205e49 to fb5fa69 Compare September 18, 2026 08:26
Add PREPARE/EXECUTE coverage for valid text, numeric and binary
parameter rejection, SQL NULL, malformed JSON recovery, and statement
reuse after a binary parameter. Assert independent teardown residue
with information_schema after DROP TABLE.
Local MO returns Invalid JSON charset for CAST(... AS BINARY) parameters
rather than the generic invalid JSON argument type error.
@VioletQwQ-0

Copy link
Copy Markdown
Collaborator Author

Addressed both items from XuPeng-SH's review in 9f651141db88995584c4e173c1f153be6f9427b6:

  1. Prepared provenance / recovery: added permanent TestPreparedJsonDepthOverMySQLProtocol. A real connection and one statement ID execute ten steps: new/reused text, rejected new/reused integer, rejected new/reused BLOB, NULL with cached BLOB type, BLOB rejection after NULL, malformed text, and flag=0 text recovery to depth 4. The test observes/constructs the actual EXECUTE type-cache flag and verifies matching cached types; SQL BINARY-variable reuse is no longer presented as binary wire type reuse. The full protocol regression and selected JSON_DEPTH unit tests passed. No production change was needed.

  2. Two BVT runs / independent cleanup: the final canonical SQL/result pair passed normal comparison twice on the same test-owned single-CN instance, 42/42 statements each, exit 0 both times. After each run, a fresh independent mysql connection queried information_schema.tables for both t_json_depth and t_json_depth_teardown and returned residue=0, before any next-run DROP IF EXISTS. No service restart or extra cleanup occurred between rounds. The owned instance then stopped normally.

Also corrected the binary prepared error expectation to include Connector/J's Data truncation: prefix, confirmed in the failing PESSIMISTIC CI job 107022177282. The two normal comparison runs validate that correction.

Validation: protocol regression, focused JSON_DEPTH UT, matching native/service builds, go vet all, gofmt and diff whitespace checks passed. Local golangci-lint is BLOCKED_ENVIRONMENT (built with Go 1.24, target Go 1.26.4); fresh CI is pending. Ready status remains unchanged.

Please re-review the current head. This does not claim CI completion or deployed QA acceptance.
Reproducible selection: mo-cgo-test -p=1 -v -run '^(TestPreparedJsonDepthOverMySQLProtocol|TestJsonDepth.*)$' -count=1 -timeout=240s ./pkg/embed ./pkg/sql/plan/function; BVT normal mode run.sh -n -g -o -p <canonical-case.sql>. Independent oracle after each round: SELECT COUNT(*) FROM information_schema.tables WHERE table_name IN ('t_json_depth','t_json_depth_teardown') -> 0. Round durations were 0.343s and 0.156s.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep review at exact head 9f651141db88995584c4e173c1f153be6f9427b6: APPROVE. The two prior blockers are closed: the real COM_STMT regression uses one connection and statement ID, asserts transmitted type-vector/cache reuse rather than assuming driver behavior, and exercises text → integer rejection → BLOB rejection/reuse → NULL with cached BLOB metadata → malformed JSON → valid recovery. The BVT repeats on one service instance and independently checks both test tables are absent after each run. I found no new correctness, cleanup, limit, or complexity issue in the iterative depth traversal or typed/text validation boundary. Focused unit/embed tests and the same-instance SQL BVT evidence are recorded in the PR description; exact-head required CI, SCA, coverage, PROXY and pessimistic BVT are green. Scope remains JSON_DEPTH only; it does not close the broader parent issue.

@mergify

mergify Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-28 09:33 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-28 09:37 UTC · at 555b2d3d4c242249eb74b66f8c508cb9cb199e7d

This pull request spent 3 minutes 50 seconds in the queue, with no time running CI.

Reason

Pull request #28962 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/test-ci size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants