mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
Nullability is decided in two stages- 1. Based on argument NULL-ness Problem: - COALESCE currently uses a generic logic- "Result of a function is nullable if any of the arguments is nullable", which is wrong. - IFNULL sets nullability using second argument alone, which incorrectly sets the result to NULL even when first argument is not null. Fix: - Result of COALESCE and IFNULL is set to NULL only if all arguments are NULL. 2. Based on type conversion safety of fallback value Problem: - The generic `Item_hybrid_func_fix_attributes` logic would mark the function's result as nullable if any argument involved a type conversion that could yield NULL. Fix: - For COALESCE and IFNULL, nullability is set to NOT NULL if the first non-null argument can be safely converted to function's target return type. - For other functions, if any argument's conversion to target type could result in NULL, the function is marked nullable. Tests included in `mysql-test/main/func_hybrid_type.test`