New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Procedure name is not escaped when using CommandType.StoredProcedure #1029
Comments
Yes, this is intentional. The user is expected to handle the escaping for stored procedure names; this allows multipart names to be provided if desired:
Connector/NET tries to quote the stored procedure names sometimes, but its logic is faulty and leads to multiple bugs (e.g., 84220, 91123. The MySqlConnector documentation should be updated to clarify this. (And it could be added to the migration page.) |
Ok, thanks for the clarification! I agree this could be added to the docs/migration page. However, I also noticed that quoting the stored procedure name doesn't seem to work correctly for the query to
delimiter //
CREATE PROCEDURE `test spaces3.x ``2` (IN myVarStr VARCHAR(2000), OUT myVarStrOut VARCHAR(2000))
BEGIN
SELECT CONCAT('Test: ', myVarStr) INTO myVarStrOut;
END//
delimiter ;
using var cmd = con.CreateCommand();
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.CommandText = "`test spaces3.x ``2`"; // Use escaped procedure name
var output = cmd.Parameters.Add("myVarStrOut", MySqlDbType.VarChar);
output.Direction = System.Data.ParameterDirection.Output;
cmd.Parameters.AddWithValue("myVarStr", "Test");
object result = cmd.ExecuteScalar();
SELECT COUNT(*)
FROM information_schema.routines
WHERE ROUTINE_SCHEMA = 'mydb' AND ROUTINE_NAME = 'test spaces3.x ``2';
SELECT ORDINAL_POSITION, PARAMETER_MODE, PARAMETER_NAME, DTD_IDENTIFIER
FROM information_schema.parameters
WHERE SPECIFIC_SCHEMA = 'mydb' AND SPECIFIC_NAME = 'test spaces3.x ``2'
ORDER BY ORDINAL_POSITION; CALL `test spaces3.x ``2`(@outParam0, 'Test');SELECT '�����' AS '�����', @outParam0; Notice that the query specifies Can this be fixed? |
Fixed in 1.3.12. Documentation updated here: https://mysqlconnector.net/tutorials/migrating-from-connector-net/#mysqlcommand |
Hi,
I noticed that when using MySqlConnector to call a stored procedure by specifying
DbCommand.CommandType = CommandType.StoredProcedure
, the procedure name set inDbCommand.CommandText
is not automatically escaped. However, MySQL Connector/NET seems to do this. For example:test spaces1
:MySql.Data 8.0.26
):MySqlConnector 1.4.0-beta.2
. Executing the program throw the following exception:Is this intended behavior?
Thank you!
The text was updated successfully, but these errors were encountered: