Skip to content

[Bug]: functional index on JSON_EXTRACT expression rejected #32313

Closed as duplicate

Description

@Ariznawlll

Bug

Creating a functional (expression) index over a JSON extraction — the standard MySQL 8 pattern for indexing JSON fields — is rejected with a misleading error claiming the expression is not session-independent, although JSON_EXTRACT + CAST is fully deterministic.

Repro

CREATE TABLE jc (id INT PRIMARY KEY, j JSON,
  KEY idx_g ((CAST(JSON_EXTRACT(j,'$.g') AS INT))));
-- ERROR 20105 (HY000): not supported: functional index expression
--   must have session-independent semantics

MySQL 8.0 supports this natively (both via functional index on (CAST(...)) and via the generated-column + index pattern), and it is the canonical way to index into JSON documents.

The error message is also misleading: the expression is session-independent — the rejection is really "functional indexes on this expression are not implemented", which makes users think they wrote something semantically wrong.

Workarounds checked

None within DDL; the only option is maintaining a duplicated plain column + index at the application level.

Version

8.0.30-MatrixOne-v1.3.0 (standalone local cluster, macOS)

Activity

  1. added
    kind/bug
    on Nov 6, 2026
  2. added this to the MO-202611 milestone on Nov 6, 2026
  3. added theissue type on Nov 6, 2026
  4. XuPeng-SH commented on Nov 9, 2026

    @XuPeng-SH
    Contributor

    Consolidated into #31448, which tracks deterministic functional-index expressions rejected by the shared eligibility whitelist. Your JSON_EXTRACT + CAST DDL repro is preserved as a distinct acceptance case. Generated-column index matching (#32113) and unique functional-index support (#31442) remain separate; this administrative closure does not mean the JSON expression is supported.

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

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions