Skip to content

Add DBD::mysql compatibility shim backed by JDBC #1106

Description

@fglock

Summary

Add a PerlOnJava DBD::mysql compatibility shim backed by the existing
DBD::JDBC infrastructure and MySQL Connector/J.

Motivation

PerlOnJava already provides DBI through JDBC and has a working DBD::JDBC
base driver plus a DBD::SQLite DSN-translation shim. However, CPAN modules
that use the conventional dbi:mysql: DSN or declare DBD::mysql currently
cannot load or connect.

MetaCPAN lists dozens of reverse dependents, including:

  • Mojo::mysql
  • PApp
  • DBIx::Class::Storage::DBI::mysql::Retryable
  • Tapper::Schema
  • DBIx::TxnPool
  • Mojolicious::Command::migration
  • Wiki::Toolkit
  • Coro::Mysql
  • DBIx::MysqlCoroAnyEvent
  • DBIx::SecureCGI
  • MySQL::Util
  • App::Prove::Plugin::MySQLPool

The current CPAN failure that prompted this request is
MySQL::TableInfo-1.01, whose pure-Perl implementation depends on
DBD::mysql and a live MySQL database.

Reverse-dependency evidence:
https://metacpan.org/dist/DBD-mysql/requires

Proposed scope

  • Add src/main/perl/lib/DBD/mysql.pm as a PerlOnJava compatibility driver.
  • Inherit the common handle implementation from DBD::JDBC.
  • Translate common DSNs such as:
    • dbi:mysql:database=name
    • dbi:mysql:database=name;host=host;port=3306
    • dbi:mysql:name;mysql_socket=/path/to/socket
      into Connector/J URLs.
  • Preserve standard DBI operations: connect, prepare, execute, fetch,
    transactions, metadata, quoting, and error handling.
  • Provide common MySQL compatibility fields such as mysql_insertid where
    JDBC exposes an equivalent.
  • Keep Connector/J optional and use the existing Configure.pl/classpath
    driver configuration path.
  • Add focused DSN and handle tests without requiring a live server, plus an
    optional integration suite against MySQL/MariaDB when a JDBC driver and
    server are available.

Compatibility boundaries

This should not perform broad SQL rewriting. MySQL SQL semantics should be
provided by MySQL/MariaDB through Connector/J. MySQL-specific attributes and
methods such as mysql_auto_reconnect, mysql_enable_utf8, and
mysql_server_prepare need explicit mapping, documented no-op behavior, or a
clear unsupported-feature error.

The shim must not claim to replace the native driver for code that depends on
native client-library behavior or undocumented DBD::mysql internals.

Acceptance criteria

  • use DBD::mysql succeeds under PerlOnJava without XS loading.
  • Standard DBI->connect('dbi:mysql:...', ...) reaches Connector/J.
  • A MySQL-backed smoke test exercises schema introspection, prepared
    statements, transactions, generated IDs, and error propagation.
  • MySQL::TableInfo can run its upstream test when supplied with a MySQL
    server and Connector/J.
  • JVM and interpreter backends have equivalent behavior for the shim.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions