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.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant