I have this situation for example:
id value
1 data_1
2 20
3 data_3
4 15
5 data_4
6 data_6
and the following stored procedure:
DELIMITER $$
CREATE PROCEDURE `test_2`.`test_procedure` (val int(9))
BEGIN
select * from `test` where `value` = val;
END
if I call the procedure like that
call test_procedure(20);
I have the following result:
id value
2 20
Everything is ok until now.
But the thing I cannot understand is that when I call the procedure like that:
call test_procedure("abc");
I have the following result:
id value
1 data_1
3 data_3
5 data_4
6 data_6
Is this a normal behavior of the MySQL database?
If I declare the variable “val” as integer, doesn’t this prevent MySQL injection?
I expect to have a warning or something that tells me that the input value is not an integer and the procedure to stop, not to reveal all the values in the tables that are not numbers.