Skip to content

MDEV-40972 JSON_TABLE's ON ERROR / ON EMPTY / DEFAULT Clauses Are All Silently Ignored - #5714

Open
DerZc wants to merge 1 commit into
MariaDB:11.4from
DerZc:fix-mdev-40972
Open

DerZc wants to merge 1 commit into
MariaDB:11.4from
DerZc:fix-mdev-40972

Conversation

@DerZc

@DerZc DerZc commented Sep 21, 2026

Copy link
Copy Markdown

JSON_TABLE can return a converted zero for a nonnumeric JSON string even when the column specifies NULL ON ERROR. For example, converting the value in {"a":"str"} to an INT column should take the column's error response and return NULL.

Bug report: https://jira.mariadb.org/browse/MDEV-40972

Root cause

The scalar conversion helper discards Field::store()'s return value. A shared Counting_error_handler also fails to represent conversion warnings as a column-local conversion failure. As a result, the provisional converted value can be returned without invoking the column's ON ERROR response.

Changes

  • Return the scalar field-store status through an output argument.
  • Use a conversion-local error handler to capture warnings and errors while leaving notes visible.
  • Combine the store status and captured conversion failure before invoking the existing ON ERROR responder.
  • Scope the JSON-format counting handler to its individual conversion so diagnostics from one column do not become another column's conversion state.

Regression coverage

The regression converts a nonnumeric JSON string to INT with NULL ON ERROR and expects SQL NULL. The implementation uses the existing error responder for NULL, DEFAULT, and ERROR policies; the regression directly covers the NULL policy.

  • mysql-test/main/json_table_null_on_error.result
  • mysql-test/main/json_table_null_on_error.test

Validation

On 11.4 at d10e5d726799b1cd57cc866f40aad68c720803da:

  • The server build passed.
  • main.json_table_null_on_error failed on the unchanged target branch and passed with this fix.
  • Existing MTR tests passed: main.func_json, main.select, main.type_decimal, main.type_float.
  • MTR reported no test-state cleanup failures.
  • The full regression suite was not run.

@CLAassistant

CLAassistant commented Sep 21, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

… Silently Ignored

JSON_TABLE can return a converted zero for a nonnumeric JSON string even
when the column specifies NULL ON ERROR. For example, converting the
value in {"a":"str"} to an INT column should take the column's error
response and return NULL.

The scalar conversion helper discards Field::store()'s return value. A
shared Counting_error_handler also fails to represent conversion
warnings as a column-local conversion failure. As a result, the
provisional converted value can be returned without invoking the
column's ON ERROR response.

Return the scalar field-store status through an output argument. Use a
conversion-local error handler to capture warnings and errors while
leaving notes visible. Combine the store status and captured conversion
failure before invoking the existing ON ERROR responder. Scope the
JSON-format counting handler to its individual conversion so diagnostics
from one column do not become another column's conversion state.

The regression converts a nonnumeric JSON string to INT with NULL ON
ERROR and expects SQL NULL. The implementation uses the existing error
responder for NULL, DEFAULT, and ERROR policies; the regression directly
covers the NULL policy.

Bug report: https://jira.mariadb.org/browse/MDEV-40972
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.

2 participants