perl5-dbi / DBD-MariaDB

Perl MariaDB driver

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

support for mysql_enable_utf8

adavesar7 opened this issue · comments

DBD::mysql has mysql_enable_utf8 but missing for mariadb which causing issues in backward compatibility.

This behavior is enabled by default in DBD::MariaDB and cannot be disabled. The purpose of the DBD::MariaDB fork was to fix the flaws in mysql_enable_utf8 without backwards compatibility. See https://metacpan.org/pod/DBD::MariaDB#UNICODE-SUPPORT

Note that both DBD::mysql and DBD::MariaDB can be used for either database, despite the names.

This behavior is enabled by default in DBD::MariaDB and cannot be disabled. The purpose of the DBD::MariaDB fork was to fix the flaws in mysql_enable_utf8 without backwards compatibility. See https://metacpan.org/pod/DBD::MariaDB#UNICODE-SUPPORT

We thought same and started using DBD::MariaDB but it's not supporting. After removing mysql_enable_utf8 from DSN, previous functionality breaks.

What DSN are you using? If you are actually using DBD::MariaDB, then mysql_enable_utf8 will not be accepted as a parameter.

If you have encountered a difference in behavior from dbi:mysql with mysql_enable_utf8, and dbi:MariaDB, then you were likely suffering from a bug due to the problematic DBD::mysql implementation and need to correct your code.

See https://github.com/perl5-dbi/DBD-mysql/pull/119/files for information on how to work around this difference. Where it refers to "DBD::mysql >= 4.042" this actually became DBD::MariaDB, and this documentation was never released.

The primary compatibility difference is that without this problematic behavior, you must bind your BLOB parameters with a type such as DBI::SQL_BINARY, as described here: https://metacpan.org/pod/DBD::MariaDB#Binary-parameters

If you need additional assistance debugging the problem, you can try the irc channel #perl on freenode or the dbi-users mailing list, and provide them as much information as possible about what you are doing that results in the issue.

Thanks for the reply. So by default DBD::MariaDB settings utf8mb4. Can we set it back to utf8 by default for backward compatibility? Because the code was working fine with DBI::MySQL with 'set names utf8' and mysql_enable_utf8 to true.

No, it cannot be changed. However, this only affects the connection charset, so there should be no compatibility issue in that particular difference as anything that the utf8 charset can interchange can also be interchanged by utf8mb4.

No, it cannot be changed. However, this only affects the connection charset, so there should be no compatibility issue in that particular difference as anything that the utf8 charset can interchange can also be interchanged by utf8mb4.

Thanks, it works with DBI::SQL_BINARY