Skip to content
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

pointing latest version to MariaDB 10.9 or 10.11 gives Unknown column 'SRS_ID' in 'field list' #1258

Closed
Elrinth opened this issue Dec 16, 2022 · 3 comments
Assignees
Labels

Comments

@Elrinth
Copy link

Elrinth commented Dec 16, 2022

Software versions
MySqlConnector version:
The version currently on git (2022-12-16 01:00:00 GMT+1)

Server type (MySQL, MariaDB, Aurora, etc.) and version:
MariaDB 10.9 and also tried with 10.11

.NET version:
4.7.2
(Optional) ORM NuGet packages and versions:

Describe the bug
Getting a MySqlException on a column which I don't have in any of my tables: 'SRS_ID'

Exception

 ERROR: MySqlConnector.MySqlException (0x80004005): Unknown column 'SRS_ID' in 'field list'
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable`1.ConfiguredValueTaskAwaiter.GetResult()
   at MySqlConnector.Core.ResultSet.<ReadResultSetHeaderAsync>d__2.MoveNext() in C:\dev\.net\valiweb\trunk\MySqlConnector\Core\ResultSet.cs:line 43
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at MySqlConnector.MySqlDataReader.ActivateResultSet(CancellationToken cancellationToken) in C:\dev\.net\valiweb\trunk\MySqlConnector\MySqlDataReader.cs:line 130
   at MySqlConnector.MySqlDataReader.<CreateAsync>d__107.MoveNext() in C:\dev\.net\valiweb\trunk\MySqlConnector\MySqlDataReader.cs:line 489
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at MySqlConnector.Core.CommandExecutor.<ExecuteReaderAsync>d__0.MoveNext() in C:\dev\.net\valiweb\trunk\MySqlConnector\Core\CommandExecutor.cs:line 56
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at MySqlConnector.MySqlCommand.<ExecuteReaderAsync>d__84.MoveNext() in C:\dev\.net\valiweb\trunk\MySqlConnector\MySqlCommand.cs:line 344
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at MySqlConnector.Core.SchemaProvider.<FillDataTableAsync>d__4.MoveNext() in C:\dev\.net\valiweb\trunk\MySqlConnector\Core\SchemaProvider.cs:line 421
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at MySqlConnector.Core.SchemaProvider.<FillColumnsAsync>d__11.MoveNext() in C:\dev\.net\valiweb\trunk\MySqlConnector\Core\SchemaProvider.g.cs:line 216
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
   at MySqlConnector.Core.SchemaProvider.<GetSchemaAsync>d__6.MoveNext() in C:\dev\.net\valiweb\trunk\MySqlConnector\Core\SchemaProvider.g.cs:line 25
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult()
   at MySqlConnector.MySqlConnection.GetSchema(String collectionName, String[] restrictionValues) in C:\dev\.net\valiweb\trunk\MySqlConnector\MySqlConnection.cs:line 601
   at SubSonic.SqlGeneration.Schema.ANSISchemaGenerator.GetTableFromDB(IDataProvider provider, String tableName) in C:\dev\.net\lib\subsonic\trunk\3.0\SubSonic.Core\SQLGeneration\Schema\ANSISchemaGenerator.cs:line 205
   at SubSonic.DataProviders.DbDataProvider.GetTableFromDB(String tableName) in C:\dev\.net\lib\subsonic\trunk\3.0\SubSonic.Core\DataProviders\DbDataProvider.cs:line 395
   at SubSonic.Schema.Migrator.MigrateFromModel(Type type, IDataProvider provider) in C:\dev\.net\lib\subsonic\trunk\3.0\SubSonic.Core\Schema\Migrator.cs:line 95
   at Tim.Migrator.Form1.AddT(Migrator m, Type t, IDataProvider provider, IDataProvider providerRevisions, BatchQuery queryTimDB, BatchQuery queryTimRevisionsDB, List`1 result, String SpecificClass) in C:\dev\.net\valiweb\trunk\Tim.Migrator\Form1.cs:line 163
   at Tim.Migrator.Form1.ReadThread1() in C:\dev\.net\valiweb\trunk\Tim.Migrator\Form1.cs:line 121, provider: server=localhost;Port=3306;database=skellec_vw2017;user id=skellec_user; password=valibali16; Convert Zero Datetime=True;
using(var scope = new AutomaticConnectionScope(provider))
            {
                var restrictions = new string[4] {null, scope.Connection.Database, tableName, null};
                schema = scope.Connection.GetSchema("COLUMNS", restrictions);
            }

Expected behavior
To work the same as with a MySQL database but with a MariaDB

Additional context
So the exact same code works vs a MySQL database, but not vs a MariaDB with identical tables etc.

@Elrinth
Copy link
Author

Elrinth commented Dec 16, 2022

dataTable.TableName which gets sent in is called "COLUMNS"

Line 394 in MySqlConnector/Core/SchemaProvider.cs:
// remove columns that the server doesn't support
if (dataTable.TableName == "Columns")
{
using (var command = new MySqlCommand("SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = 'information_schema' AND table_name = 'COLUMNS' AND column_name = 'GENERATION_EXPRESSION';", m_connection))
{
if (await command.ExecuteScalarAsync(ioBehavior, cancellationToken).ConfigureAwait(false) is null)
dataTable.Columns.Remove("GENERATION_EXPRESSION");
}

		using (var command = new MySqlCommand("SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = 'information_schema' AND table_name = 'COLUMNS' AND column_name = 'SRS_ID';", m_connection))
		{
			if (await command.ExecuteScalarAsync(ioBehavior, cancellationToken).ConfigureAwait(false) is null)
				dataTable.Columns.Remove("SRS_ID");
		}
	}

Suggested to be:
if (dataTable.TableName.Equals("Columns", StringComparison.OrdinalIgnoreCase))

@bgrainger bgrainger added the bug label Dec 16, 2022
@bgrainger bgrainger self-assigned this Dec 16, 2022
@bgrainger
Copy link
Member

Thanks; looks like this was a bug introduced in a63a915 (in 2.2.0).

@bgrainger
Copy link
Member

Fixed in 2.2.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants