Skip to content

MDEV-42246 Assertion `0' failed in Protocol::end_statement() on SELECT TO_NUMBER(NULL, NULL) - #6150

Open
mehul-raj5 wants to merge 1 commit into
MariaDB:12.3from
mehul-raj5:MDEV-42246
Open

mehul-raj5 wants to merge 1 commit into
MariaDB:12.3from
mehul-raj5:MDEV-42246

Conversation

@mehul-raj5

Copy link
Copy Markdown

Description

When the format argument of TO_NUMBER() is a constant NULL, set_func_handler_for_const_format() makes fix_length_and_dec() fail without raising an error. The statement is aborted with an empty diagnostics area, which hits DBUG_ASSERT(0) in Protocol::end_statement(). Release builds send an OK packet with no result set instead.

SELECT TO_NUMBER(NULL, NULL);   -- debug: assertion, release: no result
SELECT TO_NUMBER('1', NULL);    -- same
Query Before (debug build) Before (release build) After
SELECT TO_NUMBER(NULL, NULL) Assertion failure OK, no result set NULL
SELECT TO_NUMBER('1', NULL) Assertion failure OK, no result set NULL
SELECT TO_NUMBER(NULL, '9') NULL NULL NULL (unchanged)

A NULL format is not an error. The fix uses the per-row format handler for it, which already returns NULL when the format is NULL. Both queries now return NULL, and the result column is a nullable DOUBLE.

The out-of-memory case keeps returning an error, as before.

…T TO_NUMBER(NULL, NULL)

When the format argument of TO_NUMBER() was a constant NULL,
set_func_handler_for_const_format() made fix_length_and_dec() fail
without raising an error. The statement was aborted with an empty
diagnostics area, which hit the assertion in
Protocol::end_statement(). Release builds sent an OK packet with no
result set instead.

A NULL format is not an error. Use the per-row format handler for
it, which already returns NULL when the format is NULL.
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