NAME

DBIO::MySQL::EV::ConnectInfo - MySQL/MariaDB connection-info utilities for DBIO async driver

VERSION

version 0.900007

METHODS

dbi_to_conninfo

my $async_info = dbi_to_conninfo([ 'dbi:MariaDB:database=test;host=localhost', $user, $pass, \%attrs ]);
my $async_info = dbi_to_conninfo([ $dsn, $user, $pass, \%attrs, \%extra_attributes ]);

Translate a DBI-style connect-info arrayref ([$dsn, $user, $pass, \%attrs, \%extra_attributes], as produced by the sync DBIO::MySQL::Storage) into the async [ \%conninfo, \%opts ] shape consumed by DBIO::MySQL::EV::Storage.

The dbi:mysql: / dbi:MariaDB: DSN is parsed into named EV::MariaDB parameters (host, port, database, ...); dbname is normalised to database (EV::MariaDB's spelling). A $user / $pass that is given is user / password whatever the DSN says: the arguments, a broker's rotated credentials among them, beat a user= or password= written into the DSN, which stands only when no argument is given. Dies unless the DSN is in a dbi:mysql:-family form, since EV::MariaDB does not understand the DSN string. The message quotes the DSN with its passwords shown as *** (DBIO::Util::mask_connect_secrets): the value of a password, passwd, pwd or pass key, DBI's Password attribute, the password of a URI, and the password beside the DSN wherever the DSN repeats it. The driver and the rest of the DSN stay, so the message still shows what was given -- another driver's DSN, or one with DBI attributes in front (dbi:mysql(RaiseError=>1):...), which is not read here.

The DSN's keys are read as follows. What EV::MariaDB takes is passed on under its own name: host (hostname), port, database (dbname, db), user, password, unix_socket, connect_timeout, read_timeout, write_timeout, compress, multi_statements, charset, init_command, ssl_key, ssl_cert, ssl_ca, ssl_capath, ssl_cipher, ssl_verify_server_cert, utf8, found_rows. The keys DBD::mysql and DBD::MariaDB read out of the DSN under their prefix (mysql_ or mariadb_, both are read) and for which EV::MariaDB has a parameter are translated:

socket                  -> unix_socket
connect_timeout         -> connect_timeout
read_timeout            -> read_timeout
write_timeout           -> write_timeout
compression             -> compress
init_command            -> init_command
multi_statements        -> multi_statements
client_found_rows       -> found_rows
ssl_ca_file             -> ssl_ca
ssl_ca_path             -> ssl_capath
ssl_client_key          -> ssl_key
ssl_client_cert         -> ssl_cert
ssl_cipher              -> ssl_cipher
ssl_verify_server_cert  -> ssl_verify_server_cert

mysql_ssl (mariadb_ssl) has no parameter of its own: EV::MariaDB turns SSL on by any of the ssl_* parameters above, so a true mysql_ssl stands only beside one of them and is refused without -- the connection would be opened without SSL.

mysql_enable_utf8mb4 and mysql_enable_utf8 (DBD::mysql's; DBD::MariaDB has neither -- it is always utf8mb4, and its DSN refuses them as an unknown attribute, measured with 1.24) are two parameters at once: a true mysql_enable_utf8mb4 is charset => 'utf8mb4', a true mysql_enable_utf8 is charset => 'utf8', utf8mb4 winning when both are true as in DBD::mysql, and either is also utf8 => 1, so the strings come back as characters (EV::MariaDB flags the columns whose character set is UTF-8) the way they do from the DBD with the switch. A false value asks for nothing. A charset in the same DSN or attribute hash must say the same, or it is refused as given twice; an explicit utf8 stays. DBD::mysql 4.055 itself ignores the switch in the DSN (only the attribute hash turns it on, measured); this transport honours both places. Measured live (MySQL 8.0 and MariaDB 11) against DBD::mysql with mysql_enable_utf8mb4 => 1 and DBD::MariaDB (t/55-utf8-found-rows-live.t): umlauts, CJK and a 4-byte emoji sent as bind values and selected back are the same characters, the session character set and the bytes the server stores are the same. Deviations: without the switch this transport hands back byte strings (as DBD::mysql does without mysql_enable_utf8mb4, unlike DBD::MariaDB, which always decodes), and mysql_enable_utf8 gives the utf8 session, whose 3-byte character set cannot hold the emoji -- the same as under DBD::mysql. Every other key is refused, naming the keys and no value: the other attributes of the DBDs (mariadb_enable_utf8mb4, mysql_server_prepare, mysql_ssl_optional, mysql_read_default_file, ...) have nothing in EV::MariaDB to be translated into, and EV::MariaDB croaks on an argument it does not know. mysql_auto_reconnect and mariadb_auto_reconnect are refused only with a true value, a reconnect the transport does not do; set to 0 (or empty), in the DSN or among the attributes, they ask for nothing, are let through and leave no key in the conninfo. The same parameter under two names (mysql_connect_timeout and connect_timeout) is refused as well. A DSN without a = is the positional form database[:host[:port]], read as both DBDs and DBIO::MySQL::Storage read it (dbio-mysql): an empty part names nothing, [...] around an IPv6 host is taken off. A positional part beside a semicolon or beside key=value parts, and more than three, are refused.

Of the two attribute hashes only pool_size is read, and carried into the conninfo hash; given in both, \%extra_attributes wins, as the sync storage merges the two ("connect_info" in DBIO::Storage::DBI). The DBI attributes (AutoCommit, ...) and the owning storage's own (async, on_connect_do, quote_names, ...) are dropped, there being no DBD here to apply them. The DBD attributes (mysql_*, mariadb_*, by their prefix) are not dropped: those EV::MariaDB has a parameter for are read exactly like the same keys of the DSN (above, mysql_enable_utf8mb4 and mysql_client_found_rows among them), and any other (mysql_server_prepare, mariadb_auto_reconnect with a true value, ...) is refused, naming the attribute and no value -- also with a false value (except *_auto_reconnect, below), and not when it is undef. The same parameter in the DSN and among the attributes must have the same name and value, or it is refused as given twice; the two attribute hashes override each other as for pool_size. A connection parameter among the attributes -- charset, utf8, connect_timeout and the like, any other lowercase key set to a value -- is refused, naming the keys and no value: it would not reach EV::MariaDB, and belongs in the DSN. The same line as beside an AccessBroker ("connect_info" in DBIO::MySQL::EV::Storage). The refusal dies with MySQL ev refuses the connect info: ....

AUTHOR

DBIO Authors

COPYRIGHT AND LICENSE

Copyright (C) 2026 DBIO Authors

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