Function is accepting varchar when input is set to INT I have a function that is suppose to have INT as input. However, when I pass any string, the input is accepted.

Why does the function not error out because of the input not matching the input type?

This is the function

DROP FUNCTION IF EXISTS erbaccess.canAdminIRB;

DELIMITER $$
CREATE FUNCTION erbaccess.canAdminIRB(_userID int) RETURNS int

BEGIN

set @canPerformAction = 0;

if (select count(*)
    from erbaccess.usersVsGroupsVsActions
    where (actionCode in ('ADMSYS', 'ADDIRB')   
            or privilegeGroupCode  in ('SYS', 'REG')    
    and userID = _userID) &gt; 0 then

    set @canPerformAction = 1;
end if;

RETURN @canPerformAction;

END $$


The RETURN for @canPerformAction is also returned as 1, when it should be 0. IF I run just the if statement outside of this function with a fake username (not INT, but VARCHAR) then the return is 0.
This is how MySQL liberally performs implicit type conversion. Seeing that the function wants an integer parameter, the server tries to convert whatever you supply (a character string) into an integer. If the string only contains digits, the conversion is trivial. If the string contains digits first and then some non-digits, those latter are truncated at the first non-digit, and the remainder is converted to an integer. If the string begins with non-digits, it is converted to a 0.

dbfiddle