| Bug #89850 | Throwing exception if access to granted for table | ||
|---|---|---|---|
| Submitted: | 28 Feb 2018 14:54 | Modified: | 1 Apr 2018 7:25 |
| Reporter: | Ekh KH | Email Updates: | |
| Status: | No Feedback | Impact on me: | |
| Category: | Connector / NET | Severity: | S2 (Serious) |
| Version: | OS: | Any | |
| Assigned to: | Assigned Account | CPU Architecture: | Any |
| Tags: | bogus table access exception | ||
[1 Mar 2018 7:25]
Chiranjeevi Battula
Hello Ekh, Thank you for the bug report. Could you please provide repeatable steps (exact steps/sample project, C/Net,MySQl version, full stack trace etc. - please make it as private if you prefer) to confirm this issue at our end? Thanks, Chiranjeevi.
[2 Apr 2018 1:00]
Bugs System
No feedback was provided for this bug for over a month, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open".
[12 Nov 2020 20:11]
Stanislav Revin
This issue still needs to be fixed.
Here is an example to reproduce it:
var query = "SELECT * FROM INFORMATION_SCHEMA.tables";
using (var cmd = new MySqlCommand(query))
{
cmd.Connection = connection;
cmd.CommandTimeout = 1800;
int limit = 10;
int count = 0;
using (var reader = cmd.ExecuteReader())
{
if (reader.HasRows)
{
while (reader.Read() && count < limit)
{
Console.WriteLine(reader.GetString(0));
count += 1;
}
}
cmd.Cancel();
}
}
Here is the stack trace:
at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
at MySql.Data.MySqlClient.Driver.GetResult(Int32 statementId, Int32& affectedRows, Int64& insertedId)
at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
at MySql.Data.MySqlClient.MySqlDataReader.ClearKillFlag()
at MySql.Data.MySqlClient.MySqlDataReader.Close()
at MySql.Data.MySqlClient.MySqlDataReader.Dispose()
at UserQuery
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
[12 Nov 2020 20:18]
Stanislav Revin
I got error code 1109 "Unknown table 'BOGUS_TABLE' in information_schema", not 1146 (MySqlErrorCode.NoSuchTable) like what is caught in the source code.

Description: Exception thrown after query when user does not have right for select from bogus_table. How to repeat: Just turn off user rights for select in mysql sever. Example of code : using (IDbConnection c = new MySqlConnection(value)) { List<PushMetaData> pmd = c.Query<PushMetaData>("select * from ios_push").ToList(); // here exception } Suggested fix: Just replace function ClearKillFlag in datareader.cs with this code private void ClearKillFlag() { // This query will silently crash because of the Kill call that happened before. string dummyStatement = "SELECT * FROM bogus_table LIMIT 0"; /* dummy query used to clear kill flag */ MySqlCommand dummyCommand = new MySqlCommand(dummyStatement, _connection) {InternallyCreated = true}; try { dummyCommand.ExecuteReader(); // ExecuteReader catches the exception and returns null, which is expected. } catch (MySqlException ex) { int[] errors = { (int)MySqlErrorCode.NoSuchTable, (int)MySqlErrorCode.TableAccessDenied}; if (Array.IndexOf(errors, (int)ex.Number) < 0) throw; } }