Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-26605

Creating table with primary key constraint name fails when using C# connector

    XMLWordPrintable

Details

    Description

      I am using C# (.NET 5.0) and ADO.NET to execute statements on MariaDb. For this, I am using the MySql connector (current version: 8.0.26) to run statements on the database.
      I am trying to execute the following statement to create a table that has a primary key. The primary key has a constraint name.

      string sql = $@"CREATE TABLE `test` (
      `id` INT NOT NULL
      , CONSTRAINT `pk1` PRIMARY KEY (`id`)
      )";
      MySqlCommand cmd = new MySqlCommand(sql, conn);
      cmd.ExecuteNonQuery();

      Though the table is created, this code throws an exception with MariaDb 10.6.4:
      System.NotSupportedException: 'Character set 'utf8mb3' is not supported by .Net Framework.'

      It worked fine on MariaDb 10.5.12. When I create named unique and foreign key constraints I don't get an exception.

      I am guessing it is related to the switch to utf8mb4 as default collation introduced with 10.6.

      See attached file for the full example code in C#.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              andreas.lennartz Andreas Lennartz
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.