there may be something I'm missing in the executor side of things.
"For those curious, I found the issue: in ExecEvalJsonExprPath, I
had misplaced the check for jsexpr->on_mismatch.
I wasn't setting jsestate->escontext.details_wanted = true early enough.
Without this, the soft error context wasn't capturing the specific SQL error code needed to identify the mismatch.
Attaching a v2 that implements ON MISMATCH for JSON_QUERY and JSON_TABLE too.
That said, the semantics of ON ERROR / MISMATCH / EMPTY are complex.
I expect someone with access to and detailed knowledge of the standard might be able to poke holes in certain edge cases, particularly regarding precedence.