Skip to content

MDEV-13594: Implement -> and ->> JSON path operators#4899

Open
kjarir wants to merge 1 commit intoMariaDB:mainfrom
kjarir:MDEV-13594
Open

MDEV-13594: Implement -> and ->> JSON path operators#4899
kjarir wants to merge 1 commit intoMariaDB:mainfrom
kjarir:MDEV-13594

Conversation

@kjarir
Copy link
Copy Markdown
Contributor

@kjarir kjarir commented Apr 3, 2026

[MDEV-13594] Implement JSON -> and ->> Operators

Summary

This PR implements MySQL-compatible JSON shorthand operators in the MariaDB server. These operators provide a more concise syntax for extracting and unquoting JSON data:

  • column->'$.path' is equivalent to JSON_EXTRACT(column, '$.path')
  • column->>'$.path' is equivalent to JSON_UNQUOTE(JSON_EXTRACT(column, '$.path'))

Details

  • Lexer: Lookahead added to the - character state to identify -> and ->> sequences in sql/sql_lex.cc.
  • Parser: Grammar rules added to sql/sql_yacc.yy under primary_expr. To resolve shift/reduce ambiguities, the Left-Hand Side (LHS) has been restricted to primary_base_expr (non-recursive).
  • Precedence: Correctly configured as left-associative with higher precedence than arithmetic operations.
  • Conflicts: Bison conflicts updated from 70/71 to 72/73 to allow for the new JSON operator rules.

Performance & Quality

  • ASAN/UBSAN: Verified with an ASAN-enabled build on macOS.
  • MTR: Successfully added and passed a new test suite: json.mdev13594.
./mariadb-test-run.pl json.mdev13594

Status: [ pass ]

@kjarir
Copy link
Copy Markdown
Contributor Author

kjarir commented Apr 3, 2026

@gkodinov @grooverdan There was a huge mistake from my side, so i moved the PR to this.

@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Apr 6, 2026
Copy link
Copy Markdown
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

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

Since this is a new pull request on the same change, please reply to all the questions in the closed pull request.

%expect 72
%else
%expect 71
%expect 73
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In the interest of more consistent processing, can you please answer all questions from the previous pull request? E.g. I had a question on this line. And I see that it's still unaddressed.

@gkodinov
Copy link
Copy Markdown
Member

gkodinov commented Apr 6, 2026

Also, if you need help with github and pull requests management, please reach out to us on Zulip.

@kjarir
Copy link
Copy Markdown
Contributor Author

kjarir commented Apr 6, 2026

@gkodinov , I sincerely apologize for the mismanagement. My previous PR branch was accidentally deleted due to a mistake on my end, which forced me to open this new PR. I should have reached out for help on Zulip instead of handling it this way.

I will make sure this does not happen again. I will also be responding to every review question from the previously closed PR (#4711) shortly.

@kjarir kjarir requested a review from gkodinov April 6, 2026 13:05
Copy link
Copy Markdown
Member

@gkodinov gkodinov left a comment

Choose a reason for hiding this comment

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

LGTM. Please stand by for the final review.

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

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

3 participants