NAME

DBIx::QuickORM::Dialect::MySQL - MySQL dialect, and base for MariaDB.

DESCRIPTION

MySQL through DBD::MariaDB, the only supported driver for the MySQL family. Backtick quoting, no RETURNING, native error codes, and async queries through the driver. The namespace is DATABASE().

Which dialect a handle gets is a server fact: a server whose version names MariaDB gets DBIx::QuickORM::Dialect::MariaDB. Any other server (MySQL Community, Percona) gets this one.

SYNOPSIS

# this class or MariaDB for DBD::MariaDB
my $dialect = DBIx::QuickORM::Dialect->for_dbh($dbh);

PUBLIC METHODS

$char = $dialect->quote_char

A backtick.

$bool = $dialect->supports_returning_insert
$bool = $dialect->supports_returning_update
$bool = $dialect->supports_returning_delete

All false: MySQL has no RETURNING.

$bool = $dialect->supports_isolation

True.

@sql = $dialect->begin_sql($level)

SET TRANSACTION ISOLATION LEVEL $level then BEGIN when given a level, otherwise BEGIN. Without SESSION, the level applies to the next transaction only.

$bool = $dialect->having_uses_alias

True: the server resolves the alias in HAVING and computes the column once, but it computes a repeated expression a second time.

$n = $dialect->bind_limit

65535, the most placeholders a prepared statement may hold.

($parser, $formatter, \%instants) = $dialect->datetime_format

DateTime::Format::MySQL for both. TIMESTAMP stores an instant: the server converts it from and to the session time zone. DATETIME does not.

$bool = $dialect->supports_async

True.

$attrs = $dialect->async_prepare_attrs

{mariadb_async => 1}.

$bool = $dialect->async_ready($dbh, $sth)
$dialect->async_result($dbh, $sth)

mariadb_async_ready and mariadb_async_result on the statement. The mariadb_ prefix names the driver, but they work against every server of the family.

$dialect->cancel_async($dbh, $sth)

Waits for the result and discards it: the driver cannot cancel a query on its own connection.

$class = $dialect->dialect_for_dbh($dbh)

DBIx::QuickORM::Dialect::MariaDB when SELECT version() names MariaDB, otherwise this class.

\%kinds = $dialect->native_error_kinds

The native codes, since MySQL reports a generic SQLSTATE for most errors:

1205                    lock_timeout           (lock wait timeout)
1213                    deadlock
1062, 1169, 1586        unique_violation       (duplicate key)
1216, 1217, 1451, 1452  foreign_key_violation  (missing or still-referenced parent row)
1048, 1364              not_null_violation     (NULL, or no value and no default)
3819                    check_violation        (failed CHECK)
$ns = $dialect->namespace($dbh)

DATABASE(), or undef when the connection has no database selected.

$key = $dialect->scan_cache_key($dbh, $namespace)

The base key, plus what else decides what the scan sees: the server's host name, port, and socket (connection attributes outside the DSN can pick the server), the account the session resolved to, its sql_select_limit (which truncates the catalog queries), its active roles where the server has roles (they can change which tables the catalog shows), and, on MySQL 8.0.30 and later, whether the catalog shows generated invisible primary keys.

@sql = $dialect->_scan_key_columns

The server-specific session values scan_cache_key adds: CURRENT_ROLE() from MySQL 8.0, and the generated invisible primary key setting from 8.0.30.

$dialect->init_session($dbh, $time_zone)

SET NAMES utf8mb4, then SET time_zone. Also records the pid that owns the handle, for release_inherited.

UTC is sent as +00:00, which works without the server's time zone tables. Any other zone name needs them.

$dialect->release_inherited($dbh)

Points the child's copy of the handle's socket at /dev/null, then disconnects, so the parent's session is untouched. Does nothing for an inactive handle.

DBD::MariaDB closes every handle it holds when a process exits, InactiveDestroy or not, so a forked child that exits normally would otherwise end the parent's session. At exit this runs for every still-active handle whose recorded pid is not this process.

$sql = $dialect->tables_sql
$sql = $dialect->fields_sql
$sql = $dialect->pk_sql
$sql = $dialect->unique_sql
$sql = $dialect->fk_sql

The scan queries (see scan), over information_schema for base tables in DATABASE().

Field types are COLUMN_TYPE.

A column the database fills is auto-increment, generated, or has a default. Generated columns refuse values.

MariaDB reports the default of a nullable column without one as the text NULL, which is not a default. On MySQL that text is also how a string default 'NULL' appears, so such a nullable column misses db_fills. Key columns are never nullable.

A unique index over a column prefix or an expression is left out.

\%field = $dialect->field_facts($db_type)

As inherited, but a type whose name ends in int has no size: int(11) is a display width.

SOURCE

The source code repository for DBIx-QuickORM can be found at https://github.com/exodist/DBIx-QuickORM.

MAINTAINERS

Chad Granum <exodist7@gmail.com>

AUTHORS

Chad Granum <exodist7@gmail.com>

COPYRIGHT

Copyright Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See https://dev.perl.org/licenses/