Skip to content

fix(json): reject wildcard and range paths in JSON_KEYS - #28328

Merged
XuPeng-SH merged 10 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-28041-json-keys-wildcard
Oct 15, 2026
Merged

XuPeng-SH merged 10 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-28041-json-keys-wildcard

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Sep 7, 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 #28041

What this PR does / why we need it:

JSON_KEYS(json_doc, path) rejects typed wildcard, recursive-descent and array-range paths with MySQL error 3149 / SQLSTATE 42000 and the exact message:

In this situation, path expressions may not contain the * and ** tokens or an array range.

Document validation precedes a NULL path, while a SQL NULL document returns NULL without evaluating its path. Quoted literal * keys remain valid. Simple-path lookup disables non-array auto-wrapping, so object $[0] and $[last] return NULL while real array indexes continue to work. The shared parser accepts tab/newline/carriage-return range separators and rejects reversed same-origin ranges before JSON_KEYS path classification. JSON_EXTRACT and JSON_LENGTH retain valid-range behavior; JSON_SET, JSON_REMOVE and JSON_CONTAINS retain their range rejection.

Dependency and merge order

Retain #27990 -> #28328 merge order. The foreign prerequisite remains OPEN/Draft at 1a9ade8f4d114f7982dd8cd11efd1a2c36e89e92, owned by Lundomn. Its 20338/20339 allocation was compared with current main; this PR now uses unique internal code 20340 and does not import or call unmerged digest implementation. Recheck allocation and any actual integration delta when the dependency lands. Its unmerged status alone is not a missing JSON_KEYS implementation or developer-test gate.

Validation

Final candidate: 6cdf281ca4aee8115ea1be5c6790a648f0a427d1; integrated base: c4a210802d8aca10b51d8c9dd184b123a9d7771d. Inspected latest main: a53390c57de48ac280249ff0e88831e502e20fb0; its later changes do not intersect this nine-file change or JSON path/error contracts.

  • Focused regression: PASS, 78 named RUN entries / 5 top-level PASS results, count=1. Owning moerr/bytejson/function packages: PASS, 11,196 RUN entries / 2,254 top-level PASS results. Incremental lint: PASS. CGo-native execution retained.
  • Formal make build-with-prebuilt-native: PASS using actual Go 1.27.1 on darwin/arm64, CGo and default SIMD. Binary producer is 786d307ac6641b5629c300984f55415ac4da3a85, SHA256 7562579e99734a937e89eefd9130ce630b231be4184b8e1b2b932d79fc5a539e. Final commit only removes four blank result-file lines; all production/build inputs are identical. Native provenance and actual loaded library are bound to the execution.
  • Canonical test/distributed/cases/function/func_json_keys.test / .result: PASS twice on the same freshly started test-owned instance, each 38/38 statements, zero failed/ignored/abnormal. Normal expected-result comparison was used. The first attempt's 37/38 fixture-format failure remains recorded; its extra expected blank row was removed without changing SQL, headers, NULL values or errors.
  • Public SQL: 76/76 PASS, including wire errno/state/exact message, typed JSON, malformed inputs and precedence, simple/no-match/no-wrap controls, selected and masked CASE/IF rows, constant NULL paths, same prepared statement success/error/success reuse, and shared-parser JSON_EXTRACT/LENGTH/SET/REMOVE/CONTAINS controls. This is SQL PREPARE over the text protocol, not COM_STMT protocol coverage.
  • Cleanup: test tables and temporary database absent; service and all child process groups absent. git diff --check: PASS.
  • Compatibility oracle: original MySQL 8.0.45 source at 666701570c392a6052341b6ddb9c21869bb1d733 and paired official regression inputs/results. No live MySQL execution is claimed. Existing generic MO invalid-document/path diagnostics remain unchanged; this PR does not claim complete JSON error-number parity.

Earlier disk exhaustion, Go bootstrap/SIMD selector failure and occupied-default-port admission failure were preserved and resolved through environment/configuration changes. No skipped or zero-selection run is counted as a pass. Post-push CI remains a separate gate and will be checked on the published head.

QA required: yes — user-visible SQL/path/error compatibility. Developer automation covers the terminal results listed above; independent formal QA on its own version/environment remains pending. Keep issue #28041 open until explicit QA acceptance. Independent review is complete for this scope; Ready opens maintainer review and does not mean merge approval or formal QA completion.

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

Reviewed the full six-file change. No blocking finding in this scoped JSON_KEYS repair.

The IsSimple check is placed after existing document/path parsing and before Query. It rejects wildcard, recursive descent and range paths without changing the shared parser or treating a quoted "*" member name as a wildcard. The tests cover constant/row paths, text/native JSON, masked rows, SQL NULL, missing/non-object controls, error precedence and the typed 3149/42000 error including serialization. The execution change is a bounded path-classification check and introduces no new retained resources.

Approval is scoped to the implementation at this SHA, not a waiver of the documented Draft/merge ordering. Recheck the error-code allocation after #27990 lands and rerun the declared package/error-contract/canonical BVT checks on the integrated head. Existing focused and real-client probe evidence is reused; no fresh native/mo-tester run is claimed. Keep #28041 open through QA.

@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 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-15 07:19 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-15 07:26 UTC · at 8e38508da22c8d6e6273d2f7d53905510a1be02e

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

Reason

Pull request #28328 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
ci — 8e38508d Deployed Oct 15, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued kind/bug Something isn't working 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