Bug #121294 mysql_query_attribute_string accepts numeric argument without diagnostic
Submitted: 16 Sep 10:22
Reporter: QiFan Liu Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server: Components / Services Severity:S3 (Non-critical)
Version:9.7.2, 26.7.0 OS:Any
Assigned to: CPU Architecture:Any

[16 Sep 10:22] QiFan Liu
Description:
After component_query_attributes is installed, mysql_query_attribute_string accepts a numeric argument even though the function requires a string argument. The function executes, returns SQL NULL, and produces no warning.

Actual result:
mysql_query_attribute_string(12345)
NULL

SHOW WARNINGS returns no rows.

Expected result:
The SELECT should fail during UDF initialization with the component's “expects a string argument” diagnostic because 12345 is numeric.

Impact:
Applications can pass an invalid argument type without receiving an error or warning. The resulting NULL is indistinguishable from an ordinary NULL result and can mask query defects.

Tested versions:
MySQL Community Server 9.7.2 and 26.7.0. The behavior reproduced on both versions.

Environment and configuration:
Linux x86-64. Source commit e174239c5b3c2bcf164649042ab8a7fc972ce88d. component_query_attributes was installed before invoking the function.

How to repeat:
INSTALL COMPONENT 'file://component_query_attributes';
SELECT mysql_query_attribute_string(12345);
SHOW WARNINGS;

Suggested fix:
Return the UDF initialization failure value when a non-string argument is detected so execution is rejected.
[17 Sep 10:48] Shane Bester
also: https://bugs.mysql.com/bug.php?id=121305