Bug #15301 | Server mode to reject UDF calls with type mismatched arguments | ||
---|---|---|---|
Submitted: | 29 Nov 2005 0:10 | Modified: | 27 Sep 2008 12:41 |
Reporter: | Roland Bouman | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: User-defined functions ( UDF ) | Severity: | S3 (Non-critical) |
Version: | 5.0.15 | OS: | Windows (WinXP pro) |
Assigned to: | CPU Architecture: | Any |
[29 Nov 2005 0:10]
Roland Bouman
[29 Nov 2005 12:13]
Sergei Golubchik
if you'd try it in INSERT INSERT t1 VALUES (udf('a')); in the strict mode, will be a warning too ?
[29 Nov 2005 14:03]
Roland Bouman
I tried that, and this does fail with an error: mysql> insert into nums (i) values (bin_to_num('a')) -> // ERROR 1292 (22007): Truncated incorrect INTEGER value: 'a' ("bin_to_num()" is my UDF, wich coerces it's arguments into my_ulonglong 's and "nums" is a base table with a single int column "i") So, it works there, like you expected. However, if i was to use this UDF in a stored procedure, it would execute without error, just a warning: mysql> create procedure pppp() -> begin -> declare v int; -> set v:=bin_to_num('a'); -> insert into nums (i) values (v); -> end -> // Query OK, 0 rows affected (0.00 sec) mysql> call pppp() -> // Query OK, 1 row affected, 1 warning (0.03 sec) I would want to set the sqlmode so that just the invokation of the UDF would fail.
[30 Nov 2005 12:22]
Sergei Golubchik
Ok, then it's in todo. Same issue with division by zero, for example - it's an error in INSERT, but a warning in SELECT. The reason is that when strict mode was added it was fairly easy to abort an INSERT (or UPDATE), but to abort a SELECT rather big changes were required, that would destabilize 5.0. Thus it was moved to a later version.
[30 Nov 2005 17:55]
Roland Bouman
Ok, fair enough. Thanks for your time!
[9 Dec 2005 11:47]
Matthias Leich
Please have also a look on Bug#15600 which is declared as a duplicate of this one. There is also a simple testcase attached.