Skip to content

MySqlCommandBuilder fail to create InsertCommand for columnStore #1470

@WonderGnagno

Description

@WonderGnagno

Software versions
MySqlConnector version:2.3.6
Server type (MySQL, MariaDB, Aurora, etc.) and version:
MariaDB11.3.2-1.el8
MariaDB-columnstore-cmapi.x86_64 23.10.0-1
MariaDB-columnstore-engine.x86_64 11.3.2_23.10.0-1.el8

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

Describe the bug
MySqlCommandBuilder.GetInsertCommand(); fails the execution in case the table is a ColumnStore

Exception
System.InvalidOperationException: Dynamic SQL generation is not supported against a SelectCommand that does not return any base table information.
at System.Data.Common.DbCommandBuilder.BuildInformation(DataTable schemaTable)
at System.Data.Common.DbCommandBuilder.BuildCache(Boolean closeConnection, Boolean useColumnsForParameterNames)
at System.Data.Common.DbCommandBuilder.GetInsertCommand(DataRow dataRow, Boolean useColumnsForParameterNames)
at MySqlConnector.MySqlCommandBuilder.GetInsertCommand() in /_/src/MySqlConnector/MySqlCommandBuilder.cs:line 66
at IssueMySql.Test.DoTest() in F:\butta\IssueMySql\IssueMySql\Test.cs:line 28
at IssueMySql.Test.Run() in F:\butta\IssueMySql\IssueMySql\Test.cs:line 39
at Program.

$(String[] args) in F:\butta\IssueMySql\IssueMySql\Program.cs:line 7

Code sample

using System.Data;
using MySqlConnector;

namespace IssueMySql;

public class Test
{
    private MySqlConnection conn;

    private string Store;
    public void DoTest()
    {
        MySqlCommand cmd = new MySqlCommand();
        cmd.Connection = conn;
        cmd.CommandText = " drop table if exists test";
        cmd.ExecuteNonQuery();
        cmd.CommandText =
            $" CREATE TABLE test ( id int,  message varchar(200)\n) ENGINE={Store} ";
        cmd.ExecuteNonQuery();


        MySqlDataAdapter adapter = new MySqlDataAdapter();

        adapter.SelectCommand = new MySqlCommand("select * from test", conn);
        MySqlCommandBuilder builder = new MySqlCommandBuilder(adapter);

        builder.GetInsertCommand();
    }


    public void Run()
    {
        conn = new MySqlConnection("server=devel;uid=DD_SIMULATOR;pwd=simulator;database=DD_SIMULATOR");
        conn.Open();
        Store = "InnoDb";
        DoTest();
        Store = "ColumnStore";
        DoTest();

    }
}

Expected behavior
Works as InnoDb

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions