Conversation
190c5c5 to
21761be
Compare
gkodinov
left a comment
There was a problem hiding this comment.
Thank you for your contribution! This is a preliminary review.
Please squash the two commits into a single one. Also, please fix the failing tests in the buildbot run.
Some optional (mostly personal opinion really) hints below. These should help you with the final review.
|
|
||
| static void store_json_in_field(Field *f, const json_engine_t *je) | ||
| static void store_json_in_field(Field *f, const json_engine_t *je, | ||
| int *store_error) |
There was a problem hiding this comment.
you do not need to pass up different errors. error is an error.
There was a problem hiding this comment.
Thank you for the suggestion. I changed store_json_in_field() to return a boolean failure status and removed the extra output parameter. The caller only needs to know whether conversion failed; it selects the appropriate JSON_TABLE diagnostic.
| error= store_json_in_json(*f, &je); | ||
| thd->pop_internal_handler(); | ||
| if (!error) | ||
| error= error_handler.errors; |
There was a problem hiding this comment.
the error should be the union of all errors IMHO.
There was a problem hiding this comment.
Thanks for pointing this out. The conversion status is now combined unconditionally with the handler's error flag using logical OR. The existing Counting_error_handler is scoped to each column conversion, and the regression coverage checks that a handled failure does not affect another column or the next row.
| if (rt == INT_RESULT || rt == DECIMAL_RESULT || rt == REAL_RESULT) | ||
| { | ||
| f->store(je->value_type == JSON_VALUE_TRUE, false); | ||
| *store_error= f->store(je->value_type == JSON_VALUE_TRUE, false); |
There was a problem hiding this comment.
this is the actual fix: the code now processes the conversion error instead of dropping it onto the floor.
There was a problem hiding this comment.
Thank you for identifying the core fix. The revised code directly propagates the nonzero Field::store() result to ON ERROR. The tests cover NULL, DEFAULT and ERROR responses, including invalid integers and overflow, while successful decimal rounding still returns the rounded value.
| } | ||
|
|
||
|
|
||
| class Json_table_conversion_error_handler : public Internal_error_handler |
There was a problem hiding this comment.
I believe this is redundant and needs to go.
There was a problem hiding this comment.
Thank you for the review. I removed the custom conversion-error handler and reused Counting_error_handler. Normal warnings and notes are preserved, and a rounding note alone does not trigger ON ERROR when Field::store() succeeds.
Propagate Field::store() failures to the column's ON ERROR response. Combine conversion status with per-column error tracking, using the existing handler and preserving warnings and successful rounding. Cover NULL, DEFAULT and ERROR responses, row/column isolation, ON EMPTY, JSON null and booleans, structural errors and strict SQL mode. Update existing JSON_TABLE expectations for the changed conversion policy.
09388da to
8682522
Compare
|
Thank you for taking the time to review this PR and for the detailed suggestions. I have simplified the error propagation, removed the custom conversion-error handler, and consolidated the changes into a single commit: 8682522. I have also addressed each inline comment. The five failing Buildbot configurations all reported Validation on the final patch: the incremental Release build passed, and all 10 selected tests passed both normally and with The new upstream CI results are still pending. The Windows ARM64 workflow is awaiting maintainer approval and has not run any jobs; could you please approve it when appropriate? The local results do not replace the upstream Debug, Embedded, MSan or Windows builds. |
JSON_TABLE discards the return status from scalar Field::store() calls. For example, converting {"a":"str"} to an INT column can return zero even with NULL ON ERROR. This change propagates conversion failures so the column applies its NULL, DEFAULT or ERROR response.
Bug report: https://jira.mariadb.org/browse/MDEV-40972
The helper now returns a boolean failure status. Its result is combined with per-column error tracking using the existing Counting_error_handler. The custom conversion handler is removed; warnings and successful rounding remain visible, and arrays/objects retain their existing diagnostic.
Regression coverage includes invalid integers, overflow, NULL/DEFAULT/ERROR policies, column and row isolation, ON EMPTY, JSON null and booleans, structural errors, rounding and strict SQL mode. The existing JSON_TABLE assertions are updated for the conversion policy, with deterministic ordering for tied values.
Validation on the final patch:
The changes are consolidated into one commit. The full regression suite and upstream Debug/Embedded/MSan/Windows configurations were not run locally; their CI results remain pending.