Connector 8.0 - Stored Procedure Error in MySqlDataReader
Posted by: Zachary Graham
Date: April 21, 2018 10:09AM

Not sure if this is proper forums, I have issue with MySql.Data.MySqlClient .Net Core Class Library v8.0.11. Using visual studio 2017 nuget package manager

I have an environment with a fresh install of MySQL Community Server v8.0.11 and an ASP.NET Core 2.0 Web API project that uses the MySql.Data.MySqlClient v8.0.11 for standard ADO.NET calls to stored procedures.

I'm getting a general 'Data Is Null' error thrown whenever I connect with a user other that 'root' in my connection string (if I connect as 'root' the error is not thrown and I can call all my stored procedures without error, they return data etc).

I was using MySQL DB v5.7.20 and Connector 6.10.6 without issue, I have all my stored procedures defined with a DEFINER 'root'@'localhost', and SQL SECURITY DEFINER attribute. I connect with a separate account (example 'web_user'@'%') and I give this account EXECUTE privilege on the stored procedures it should be able to run.

Also my db is using encrypted connections and application connection string uses SslMode=Required (not sure if this matters).

I'm able to run the stored procedures using mysql.exe as the less privilege user account ('web_user', not 'root'), so I don't think it's a permission issue, and if I enter a bad username or password in my connection string I get 'Access is denied' error thrown as expected, so I think I'm being authenticated properly just something internally with the datareader is throwing an exception.

Reproduce by creating a simple stored procedure as root user, with DEFINER 'root'@'localhost', then give a less privilege user account EXECUTE permission to the stored procedure. In application connection string, connect as less privilege user and attempt to run stored procedure, doing simple MySqlDataAdapter.Fill() or using MySqlDataReader (I tried both methods and both throw same error).

Let me know if need more information and thank you!

System.Data.SqlTypes.SqlNullValueException
HResult=0x80131931
Message=Data is Null. This method or property cannot be called on Null values.
Source=MySql.Data
StackTrace:
at MySql.Data.MySqlClient.MySqlDataReader.GetFieldValue(Int32 index, Boolean checkNull)
at MySql.Data.MySqlClient.MySqlDataReader.GetString(Int32 i)
at MySql.Data.MySqlClient.SchemaProvider.GetProcedures(String[] restrictions)
at MySql.Data.MySqlClient.ISSchemaProvider.GetProcedures(String[] restrictions)
at MySql.Data.MySqlClient.SchemaProvider.GetSchema(String collection, String[] restrictions)
at MySql.Data.MySqlClient.ProcedureCache.GetProcData(MySqlConnection connection, String spName)
at MySql.Data.MySqlClient.ProcedureCache.AddNew(MySqlConnection connection, String spName)
at MySql.Data.MySqlClient.ProcedureCache.GetProcedure(MySqlConnection conn, String spName, String cacheKey)
at MySql.Data.MySqlClient.StoredProcedure.CheckParameters(String spName)
at MySql.Data.MySqlClient.StoredProcedure.Resolve(Boolean preparing)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)

Options: ReplyQuote


Subject
Written By
Posted
Connector 8.0 - Stored Procedure Error in MySqlDataReader
April 21, 2018 10:09AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.