Skip to content

test: preserve JSON_ARRAY_INSERT NULL compatibility - #29770

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-29764-json-array-insert-null
Oct 9, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-29764-json-array-insert-null

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Oct 9, 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 #29764

The reported premise is corrected rather than implemented: a NULL value is inserted as JSON null. A NULL document or path returns SQL NULL. The issue remains open for QA and clarification.

What this PR does / why we need it:

Preserve the existing JSON_ARRAY_INSERT NULL-value behavior and add regression coverage. The previous PR head introduced an incorrect SQL-NULL shortcut that also bypassed document/path validation and changed missing/non-array-parent no-ops. This update removes that shortcut and uses the existing value converter and bytejson insertion path. Relative to the target base, production code changes only an explanatory comment.

The independent expected result comes from version-pinned MySQL 8.0.40 ARRAY_INSERT implementation, its SQL NULL to JSON null conversion, and the official NULL MTR case: a nullable value column produces [[null, 1]], not SQL NULL. This contradicts the manual's blanket NULL wording. No live MySQL execution is claimed.

Coverage includes literal/column NULL, a later NULL path-value pair, adjacent non-NULL rows, typed JSON null, missing/non-array parents, invalid documents/paths, SQL-NULL document/path controls, and a JSON NOT NULL column. The canonical BVT also verifies that a failed UPDATE preserves the document and that the next statement works. Prepared binary parameter rebinding covers non-NULL -> NULL -> non-NULL and MORPC 51/52 without introducing a new protocol path. ARRAY_APPEND behavior is unchanged and outside this issue's scope.

Validation on the repaired content:

  • The corrected function tests fail with the previous NULL shortcut restored and pass after its removal.
  • CGO-enabled TestJsonArrayInsert: PASS; complete pkg/sql/plan/function: PASS.
  • TestInitExecuteStmtParamDirectBinaryConstructor: PASS.
  • make build: PASS.
  • test/distributed/cases/function/func_json_array_insert.sql: two normal mo-tester runs, each 45/45 successful, no ignored cases; table teardown confirmed. Generated expectations were separately checked against the pinned oracle and SQL contract before comparison runs.
  • git diff --check: PASS.
  • Complete pkg/frontend: FAIL in eight unrelated RETURNING spool tests due to allocation admission cap=1. The same eight failures reproduce with the original frontend test file; this is retained as a baseline validation limitation, not reported as PASS.

Self-review covers the complete final diff and affected conversion, path validation, prepared rebinding, SQL write/error and teardown paths. The former semantic PASS based on the incorrect NULL oracle is superseded; no new independent Astra review is claimed.

Dependency: PR #29519, already merged as d33bb6e8b926f150b78f97249ae73da7b2a98a4e and present in this branch; no outstanding merge-order dependency.

QA required: yes. Automated SQL tests cover the user-visible result, NOT NULL write and failed-statement recovery. Live MySQL cross-engine comparison and deployment QA remain NOT_RUN; CI and maintainer review remain separate from local validation.

@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 →

@VioletQwQ-0 VioletQwQ-0 changed the title fix: preserve SQL NULL in JSON_ARRAY_INSERT test: preserve JSON_ARRAY_INSERT NULL compatibility Oct 9, 2026
@mergify mergify Bot added the kind/test-ci label Oct 9, 2026
@matrix-meow matrix-meow added size/M Denotes a PR that changes [100,499] lines and removed size/S Denotes a PR that changes [10,99] lines labels Oct 9, 2026

@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 12bc48e84be75f0f432010c7716e6d476faba753 against merge-base b6fa8ccfc729105a31f61dbed0c97d7f21a2b86e: no blocking finding; approve.

Read every changed hunk. The final delta correctly preserves the existing JSON_ARRAY_INSERT implementation: production is a comment-only +2/-4 change; tests/expected results are +172/-10; no design/framework/state-machine change or production performance impact. The earlier incorrect SQL-NULL shortcut is absent.

Independently checked the version-pinned MySQL 8.0.40 official regression: a nullable value inserts JSON null. Traced the existing SQL/binary prepared entry, shared value converter, path validation and bytejson array insertion. SQL NULL values remain distinct from NULL document/path and typed JSON null. Checked adjacent rows, later value pairs, invalid document/path, missing/scalar parents and NOT NULL UPDATE failure recovery; the new expectations exercise those real behaviors rather than a duplicate implementation.

Tests reuse the existing fixtures and cleanup, with only three SQL rows and one table; no new heavyweight setup. Prepared 51/52 controls cover non-NULL → NULL → non-NULL and protocol errors through actual parameter parsing and expression execution. Existing earlier assertions are retained. ARRAY_APPEND semantics are intentionally unchanged by this test-only scope.

Reused author’s function-package, focused prepared test and two 45/45 canonical BVT receipts; the author’s eight baseline frontend spool failures remain disclosed and are not relabeled as PASS. Fresh exact-head CI Required is SUCCESS (run 37905005874). No additional broad local rerun or live MySQL execution is claimed. No prior inline/review findings were present in GitHub metadata.

@mergify mergify Bot added the queued label Oct 9, 2026
@mergify

mergify Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-09 11:57 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-09 12:12 UTC · at 46d8616b831748759f94e89602a35d942b5fa065

This pull request spent 15 minutes 1 second in the queue, with no time running CI.

Reason

Pull request #29770 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 had an error being deployed

1 failed deployment
ci — 46d8616b Deployed Oct 9, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants