package DBIx::Fast::Profile::mysql;

use v5.38;
use Object::Pad 0.807;
use DBIx::Fast::Profile::MariaDB;

# MySQL (Oracle) diagnostics. MySQL 8.x retains the entire surface the
# MariaDB profile is built on - SET profiling, information_schema.profiling,
# information_schema.processlist and SHOW GLOBAL STATUS - deprecated upstream
# in favour of performance_schema, but present and functional (verified
# against MySQL 8.4). Until that changes, the MariaDB implementation applies
# verbatim; this subclass exists so $db->profiler on a mysql:// connection
# resolves natively instead of warning and falling back to the Base stub.

class DBIx::Fast::Profile::mysql :isa(DBIx::Fast::Profile::MariaDB) {

    # The one real divergence: MySQL 8.0 REMOVED "EXPLAIN EXTENDED" (plain
    # EXPLAIN carries the extended columns since 5.7); MariaDB keeps it.
    method explain_query ($sql, @params) {
        my $safe = $self->_validate_explainable_sql($sql);
        return unless $safe;
        return $self->dbix->all( "EXPLAIN $safe", @params );
    }
}

1;

__END__

=head1 NAME

DBIx::Fast::Profile::mysql - MySQL profiling and diagnostics

=head1 SYNOPSIS

    my $db = DBIx::Fast->new( dsn => 'mysql://user:pass@host/db' );

    my $plan  = $db->profiler->explain_query('SELECT * FROM t WHERE id = ?', 1);
    my $slow  = $db->profiler->get_slow_queries;
    my $stats = $db->profiler->get_stats;
    my $conns = $db->profiler->get_current_connections;

=head1 DESCRIPTION

MySQL implementation of the driver diagnostics interface. MySQL 8.x still
ships everything the MariaDB profile uses (C<SET profiling>,
C<information_schema.profiling>, C<information_schema.processlist>,
C<SHOW GLOBAL STATUS>) - deprecated in favour of C<performance_schema>, but
functional - so this class inherits L<DBIx::Fast::Profile::MariaDB>
unchanged. See that module for the full method reference; events emitted
through L<DBIx::Fast::Output> carry C<driver: "mysql">.

If a future MySQL release drops the deprecated surface, the affected
methods will be overridden here with C<performance_schema> equivalents.

=head1 AUTHOR

SeHarrys

=head1 LICENSE

This is free software under the Artistic License 2.0.

=cut
