feat(sql): MySql provider over MySqlConnector, one shared provider map (lmxopcua#753)

SqlProvider.MySql is now a constructed backend instead of a reserved name.

- MySqlDialect (Driver.Sql.Dialect): MySqlConnector 2.6.2 (MIT, fully managed,
  no vulnerable packages), backtick quoting with MySQL's 64-char / no-trailing-
  space rules, information_schema catalog SQL with the database as the schema
  (system databases excluded, aliases pinned), trailing LIMIT, a type map that
  also reads the reader-side spellings (INT UNSIGNED -> UInt32, BOOL -> Boolean).
- SqlDialects: the one provider -> dialect map. The factory, the Test Connect
  probe and the browse picker each carried their own switch (and drifted once);
  they now all read this, and their refusals list the supported/reserved sets
  from it.
- AdminUI driver form offers MySql.
- Tests: MySqlDialectTests (golden quoting/catalog/type map/planner SQL); the
  provider-gate tests in factory, probe, browser and form now treat MySql as
  supported and Odbc as the reserved control. MySqlReadTests + Docker/mysql
  (throwaway mysql:8.4, SELECT-only login): liveness, KV/wide-row/topByTimestamp,
  INT keys vs authored text, case folding against case-sensitive table names,
  catalog rejection, browse walk, factory+probe, named query with a bound
  parameter, and a writing stored function whose effect the rolled-back
  transaction discards.

(lmxopcua#753)

Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
This commit is contained in:
Joseph Doherty
2026-11-09 17:07:05 -05:00
parent a68593e714
commit 63372e757a
17 changed files with 1076 additions and 83 deletions
@@ -206,29 +206,15 @@ public static class SqlDriverFactoryExtensions
}
/// <summary>
/// Selects the provider seam.
/// <para>This build constructs <see cref="SqlProvider.SqlServer"/>, <see cref="SqlProvider.Postgres"/>
/// and <see cref="SqlProvider.Oracle"/>. <see cref="SqlProvider.MySql"/> and
/// <see cref="SqlProvider.Odbc"/> remain reserved names on the shipped enum; authoring one is a config
/// mistake that must fail at construction with a message that says so, rather than silently degrading
/// to another backend's SQL dialect against a database that does not speak it.</para>
/// <para><b>Every arm returns that provider's OWN dialect — there is no fallback arm.</b> A default
/// that resolved to <see cref="SqlServerDialect"/> would construct happily and then emit T-SQL
/// (<c>INFORMATION_SCHEMA</c>, <c>TOP 1</c>, <c>@</c> markers) at a Postgres or Oracle server, which
/// fails at poll time as an unintelligible provider error rather than here as a config error.</para>
/// Selects the provider seam through <see cref="SqlDialects.TryCreate"/> — the one map the probe and the
/// browser use too. A provider this build does not construct is a config mistake that must fail here
/// with a message saying so, rather than silently degrading to another backend's SQL dialect.
/// </summary>
private static ISqlDialect CreateDialect(SqlProvider provider, string driverInstanceId)
=> provider switch
{
SqlProvider.SqlServer => new SqlServerDialect(),
SqlProvider.Postgres => new PostgresDialect(),
SqlProvider.Oracle => new OracleDialect(),
_ => throw new InvalidOperationException(
$"Sql driver config for '{driverInstanceId}' names provider '{provider}', which is not " +
$"available in this build. Supported: '{nameof(SqlProvider.SqlServer)}', " +
$"'{nameof(SqlProvider.Postgres)}', '{nameof(SqlProvider.Oracle)}'. Reserved (declared on " +
$"the enum but not implemented): '{nameof(SqlProvider.MySql)}', '{nameof(SqlProvider.Odbc)}'."),
};
=> SqlDialects.TryCreate(provider)
?? throw new InvalidOperationException(
$"Sql driver config for '{driverInstanceId}' names provider '{provider}', which is not " +
$"available in this build. {SqlDialects.DescribeAvailability()}");
/// <summary>
/// Applies the documented defaults and validates every knob (design §5.1 / §8.3).
@@ -188,25 +188,13 @@ public sealed class SqlDriverProbe : IDriverProbe
internal static ISqlDialect DefaultDialectForTest(SqlProvider provider) => DefaultDialectFor(provider);
/// <summary>
/// Constructs the production dialect for a provider — <b>the same set
/// <see cref="SqlDriverFactoryExtensions"/> constructs</b>, because Test Connect must exercise the
/// backend a Deploy would actually use. This build constructs <see cref="SqlProvider.SqlServer"/>,
/// <see cref="SqlProvider.Postgres"/> and <see cref="SqlProvider.Oracle"/>;
/// <see cref="SqlProvider.MySql"/> and <see cref="SqlProvider.Odbc"/> stay reserved.
/// <para><b>Keep this arm-for-arm with the factory's <c>CreateDialect</c>.</b> When the factory and the
/// browser were widened to Postgres + Oracle this switch was left SqlServer-only, so a config that
/// deployed and browsed fine failed Test Connect with an <see cref="InvalidOperationException"/> — and
/// no test noticed, because every probe test injects its dialect through <see cref="ForTest"/>.</para>
/// Constructs the production dialect for a provider through <see cref="SqlDialects.TryCreate"/> — <b>the
/// same map <see cref="SqlDriverFactoryExtensions"/> uses</b>, because Test Connect must exercise the
/// backend a Deploy would actually use. (This switch once stayed SqlServer-only after the factory and
/// browser were widened, so a config that deployed fine failed Test Connect; sharing the map ends that.)
/// </summary>
private static ISqlDialect DefaultDialectFor(SqlProvider provider) => provider switch
{
SqlProvider.SqlServer => new SqlServerDialect(),
SqlProvider.Postgres => new PostgresDialect(),
SqlProvider.Oracle => new OracleDialect(),
_ => throw new InvalidOperationException(
$"provider '{provider}' is not available in this build. Supported: " +
$"'{nameof(SqlProvider.SqlServer)}', '{nameof(SqlProvider.Postgres)}', " +
$"'{nameof(SqlProvider.Oracle)}'. Reserved (declared on the enum but not implemented): " +
$"'{nameof(SqlProvider.MySql)}', '{nameof(SqlProvider.Odbc)}'."),
};
private static ISqlDialect DefaultDialectFor(SqlProvider provider)
=> SqlDialects.TryCreate(provider)
?? throw new InvalidOperationException(
$"provider '{provider}' is not available in this build. {SqlDialects.DescribeAvailability()}");
}