MDEV-40143: st_isvalid() does not clear NULL state between rows#5313
MDEV-40143: st_isvalid() does not clear NULL state between rows#5313DaveGosselin-MariaDB wants to merge 1 commit into
Conversation
The st_isvalid() function evaluates nullability on every row. Previously, it would preserve potentially stale null state between rows, so the first row yielding a null result for st_isvalid() would propagate to the results for the remaining rows. Implementation-wise, this patch changes the Item_func_isvalid::val_int method implementation to work like Item_func_validate::val_str in that it assumes that the method will indicate a null result for the row unless it returns a non-null result, at which point it clears the null_value flag.
There was a problem hiding this comment.
Code Review
This pull request fixes the handling of the null_value flag in Item_func_isvalid::val_int() by initializing it to 1 and only resetting it to 0 upon a successful validity check. It also adds corresponding test cases to verify this behavior. The review feedback correctly identifies a potential null pointer dereference if args[0]->val_str() returns NULL, suggesting a defensive check to prevent a server crash.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
The st_isvalid() function evaluates nullability on every row. Previously, it would preserve potentially stale null state between rows, so the first row yielding a null result for st_isvalid() would propagate to the results for the remaining rows.
Implementation-wise, this patch changes the Item_func_isvalid::val_int method implementation to work like Item_func_validate::val_str in that it assumes that the method will indicate a null result for the row unless it returns a non-null result, at which point it clears the null_value flag.