Proposal to Create a MariaDB Alias for the MySQL PDO Driver

php.internals

Arvids Godjuks

2 years ago
Hello, I'm splitting this discussion from https://externals.io/message/123183, see details at https://externals.io/message/123183#123234 and https://externals.io/message/123183#123236 to keep the original thread clean. There's a clear divergence in functionality between MySQL and MariaDB. As PDO evolves to accommodate database-specific drivers, it's sensible to introduce a MariaDB alias for the MySQL driver. Although the mysqlnd library handles networking protocols for both, practical higher level usage increasingly demands differentiation at the database layer, much like Doctrine's recent updates requiring distinct identification of MariaDB vs. MySQL. I propose establishing a MariaDB namespace. This would allow for explicit implementation of database-specific functions and help in correctly mapping methods and queries to the respective database. Thoughts? Questions?
-- Arvīds Godjuks +371 26 851 664 arvids.godjuks@gmail.com Telegram: @psihius https://t.me/psihius

Larry Garfield

2 years ago
On Tue, Apr 30, 2024, at 4:50 PM, Arvids Godjuks wrote:
> Hello, > > I'm splitting this discussion from https://externals.io/message/123183, > see details at https://externals.io/message/123183#123234 and > https://externals.io/message/123183#123236 to keep the original thread > clean. > > There's a clear divergence in functionality between MySQL and MariaDB. > As PDO evolves to accommodate database-specific drivers, it's sensible > to introduce a MariaDB alias for the MySQL driver. Although the mysqlnd > library handles networking protocols for both, practical higher level > usage increasingly demands differentiation at the database layer, much > like Doctrine's recent updates requiring distinct identification of > MariaDB vs. MySQL. > > I propose establishing a MariaDB namespace. This would allow for > explicit implementation of database-specific functions and help in > correctly mapping methods and queries to the respective database. > > Thoughts? Questions?
I agree with this. Even if the wire protocol isn't different right now, the SQL syntax is. Giving a "native" hook point for people to vary their DB is useful, and sets us up for when there are wire or parser differences later. Bear in mind that MySQL now also has the mysqlx protocol, which is basically a native query builder that bypasses an SQL string entirely. MariaDB has no such thing. I don't know how that would play into PDO at all, but this sort of split would give us a natural starting point to figure that out in the future. --Larry Garfield

Matteo Beccati

2 years ago
Hi Arvids, Il 30/04/2024 18:50, Arvids Godjuks ha scritto:
> Hello, > > I'm splitting this discussion from https://externals.io/message/123183 > <https://externals.io/message/123183>, see details at > https://externals.io/message/123183#123234 > <https://externals.io/message/123183#123234> and > https://externals.io/message/123183#123236 > <https://externals.io/message/123183#123236> to keep the original thread > clean. > > There's a clear divergence in functionality between MySQL and MariaDB. > As PDO evolves to accommodate database-specific drivers, it's sensible > to introduce a MariaDB alias for the MySQL driver. Although the mysqlnd > library handles networking protocols for both, practical higher level > usage increasingly demands differentiation at the database layer, much > like Doctrine's recent updates requiring distinct identification of > MariaDB vs. MySQL. > > I propose establishing a MariaDB namespace. This would allow for > explicit implementation of database-specific functions and help in > correctly mapping methods and queries to the respective database. > > Thoughts? Questions?
It's not clear to me what divergences need to be addressed at the PDO level at this point. Could you please shed some light? Is it just identification? If so, I think the best place to do it is some user-land configuration. Cheers
-- Matteo Beccati Development & Consulting - http://www.beccati.com/

Arvids Godjuks

2 years ago
On Tue, 30 Apr 2024 at 21:32, Matteo Beccati <php@beccati.com> wrote:
> Hi Arvids, > > <snip> > > It's not clear to me what divergences need to be addressed at the PDO > level at this point. Could you please shed some light? > > Is it just identification? If so, I think the best place to do it is > some user-land configuration. >
I'm no expert in the matter, but here's some stuff I found: https://aws.amazon.com/compare/the-difference-between-mariadb-vs-mysql/#summary-of-differences-mysql-mariadb https://www.cloudways.com/blog/mariadb-vs-mysql/#mariadb-vs-mysql One thing that comes to mind that I run into is that both have a different set of functions they support to work with JSON objects and they store them differently. As time goes on, there are more and more database specific differences. Again, this is about giving people ability to develop stuff based on PDO driver subclass, clearly delineating what is supported for what database. You will not have to look at the code and try to figure out if this works in MySQL or MariaDB or both - you will be able to see that it uses either MySQL driver or MariaDB driver. As far as PDO development goes, it's more of an organisational change. Larry has given a pretty clear explanation why it's good to have this.
-- Arvīds Godjuks +371 26 851 664 arvids.godjuks@gmail.com Telegram: @psihius https://t.me/psihius

Kamil Tekiela

2 years ago
I see absolutely no reason to do this. There is no difference between MySQL and MariaDB in terms of PDO. Sure, the actual RDBMSs have differences, but they play no role when it comes to PDO. If MariaDB decides to change the protocol some day then we would need a new driver to replace mysqlnd. Only then it would make sense to have PDO_mariadb extension. But that is unlikely to happen any time soon. The purpose of PDO subclasses is to offer driver specific functionality and differentiate SQL syntax flavours. MariaDB and MySQL use the same driver so they offer the same functionality and they use the same SQL syntax (at least the parts that matter). And we must remember that MariaDB is not the only MySQL-like DB out there. We are not going to create a name alias for every possible fork of MySQL that ever exists. It would be pointless.

Gina P. Banyard

2 years ago
On Tuesday, 30 April 2024 at 22:33, Kamil Tekiela <tekiela246@gmail.com> wrote:
> I see absolutely no reason to do this. There is no difference between > MySQL and MariaDB in terms of PDO. Sure, the actual RDBMSs have > differences, but they play no role when it comes to PDO. > If MariaDB decides to change the protocol some day then we would need > a new driver to replace mysqlnd. Only then it would make sense to have > PDO_mariadb extension. But that is unlikely to happen any time soon. > The purpose of PDO subclasses is to offer driver specific > functionality and differentiate SQL syntax flavours. MariaDB and MySQL > use the same driver so they offer the same functionality and they use > the same SQL syntax (at least the parts that matter). And we must > remember that MariaDB is not the only MySQL-like DB out there. We are > not going to create a name alias for every possible fork of MySQL that > ever exists. It would be pointless.
I agree with Kamil, MariaDB wanting to be incompatible with MySQL is their choice. If we introduce an "alias" and the MariaDB behaviour doesn't work, then we are on the hook to "fix" a database driver where we don't have the expertise. The MySQL driver is intended to only be used with a MySQL database, that it works with MariaDB is just a consequence of them forking from MySQL. And a user that uses a driver of a different DB than the one they run should expect incompatibilities. If there is a need for a MariaDB driver, then it should live outside the php-src repo, IMHO. We already have database drivers that are badly maintained because we don't have the expertise, or only recently acquired people that want to work on them. We removed the interbase and OCI8 extensions from php-src to PECL for this exact reason. Thus adding, effectively, a new database driver makes no sense to me. Best regards, Gina P. Banyard