Path: redb-route/tests/redb.Route.Tests.Sql/E2E/Infrastructure/MySqlFamilyE2EProvider.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/tests/redb.Route.Tests.Sql/E2E/Infrastructure/MySqlFamilyE2EProvider.cs
----
using System.Data.Common;
using MySqlConnector;
namespace redb.Route.Tests.Sql.E2E.Infrastructure;
///
/// MySQL and MariaDB through MySqlConnector (tier 2): the same driver, the same statements and the same measured facts. The
/// connector reaches both with the default placeholderStyle=At.
///
public abstract class MySqlFamilyE2EProvider : SqlE2EProvider
{
public override DbProviderFactory Factory => MySqlConnectorFactory.Instance;
/// Environment variable that overrides .
protected abstract string EnvironmentVariable { get; }
/// Connection to the temporary container.
protected abstract string DefaultConnectionString { get; }
public override string ConnectionString =>
Environment.GetEnvironmentVariable(EnvironmentVariable)?.Trim() is { Length: > 0 } cs ? cs : DefaultConnectionString;
public override string StartHint =>
$"Tier 2, temporary: '{(global::redb.Route.Tests.Shared.TestStand.Up(Name))}' (container route-{Name}), " +
$"and 'docker compose -f redb.Route/docker-compose.tests.yml --profile {Name} down -v' after the run; override the connection with {EnvironmentVariable}.";
// Strict sql_mode (the default of both servers) turns a text that is not a number into error 1366 instead of a warning.
public override string TransactionKillingLiteral(string table) =>
$"INSERT INTO {table} (id, val) VALUES ('abc', 'x')";
public override string TransactionKillingBatchSql(string table) =>
$"INSERT INTO {table} (id, val) VALUES (:#id, :#val)";
public override List> TransactionKillingItems() =>
[
new() { ["id"] = "1", ["val"] = "a" },
new() { ["id"] = "abc", ["val"] = "x" },
new() { ["id"] = "3", ["val"] = "c" },
];
// Measured 2026-09-15 (MySqlE2ETests, MariaDbE2ETests): InnoDB rolls back the failed statement only and the transaction
// goes on; MySqlConnector 2.6 has DbBatch, does not name the failed command of a batch, and reports no savepoint support
// although Save / Rollback(name) work.
public override int[] LoopContinueDuplicateKeyRows => [1, 3];
public override int[] LoopContinueTransactionKillingRows => [1, 3];
public override bool DuplicateKeyDestroysTransaction => false;
public override bool TransactionKillingErrorDestroysTransaction => false;
public override bool ReportsSavepointSupport => false;
public override bool CommandAfterTransactionKillingErrorIsRejected => false;
public override bool CanCreateBatch => true;
public override bool PrepareRejectsUntypedParameters => false;
}