[MDEV-32584] stored procedure input parameter specified as an INT rounds when a DOUBLE is input by the caller Created: 2023-10-26  Updated: 2024-01-12

Status: Open
Project: MariaDB Server
Component/s: Data Definition - Procedure
Fix Version/s: None

Type: New Feature Priority: Major
Reporter: James Kevin O'Halloran Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

If i create a stored procedure with an input parameter specified as an INT, I expect the procedure to fail when a non-INT value is provided in a call.

Instead, if a user calls a procedure thus:

call my_db.my_sproc(5.47);

mariadb rounds 5.47 to 5.

I expect the stored procedure to throw an error. If the input procedure is VARCHAR(10) and the user inputs a VARCHAR(20) the procedure throws an error. It does not truncate the input parameter to 10 characters and silently move on.

Worse, I don't even have the opportunity to intercept the input variable and check it. By the time it is available in the body of the stored procedure it is already rounded to an INT.

The work around that I can do is specify the input parameter as a DOUBLE and then it is not rounded. I can then access it in the body of the stored procedure and see if it is actually an int or not. However this is not ideal. We have many stored procedures with input parameters specified as INTs.

I thought perhaps there would be a way to determine the treatment of INTs in sql_mode or some other setting, but was unable to find anything.

Thanks,
Kevin



 Comments   
Comment by James Kevin O'Halloran [ 2023-10-26 ]

10.6.14-MariaDB-1:10.6.14+maria~ubu2004

Comment by James Kevin O'Halloran [ 2023-12-11 ]

imagine you had a delete procedure, and someone called delete_row(5.9) when they meant 59.

Mariadb would round the input parameter (scoped as an int) to 6 and delete row 6 rather than row 59.

Comment by Sergei Golubchik [ 2023-12-11 ]

It's not a bug, but a documented and expected MariaDB behavior. I'll change it to be a feature request

Comment by James Kevin O'Halloran [ 2024-01-12 ]

It is hard for me to imagine why this is a feature, but granted that it is one, shouldn't there at least be a setting allowing us to guarantee an INT is treated strictly as an INT?

Generated at Thu Feb 08 10:32:27 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.