MariaDB version prefix `5.5.5-` is not stripped
Description
The version from SQL (from select version()) should match the version reported by php mysqli/pdo_mysql drivers.
The following code:
var_dump(...->expr('select version()')->getOne()); // raw version from SQL
var_dump(...->getWrappedConnection()->getServerVersion()); // version from DBAL/mysqli
Resulted in this output:
string(35) "10.6.5-MariaDB-1:10.6.5+maria~focal"
string(41) "5.5.5-10.6.5-MariaDB-1:10.6.5+maria~focal"
But I expected this output instead:
string(35) "10.6.5-MariaDB-1:10.6.5+maria~focal"
string(41) "10.6.5-MariaDB-1:10.6.5+maria~focal"
PHP Version
8.0
Operating System
any
This "most unfortunate" MariaDB version prefix broke compatibility with transactions (and likely more); therefore we fixed https://bugs.php.net/78179 by stripping that prefix. Anyway, I'm not sure what you're requesting here. Can you please clarify whether you want the prefix stripped, or retained? In the former case, that doesn't look like a php-src issue at all.
in https://github.com/php/php-src/blob/72cdb0af5500b57e4a83c6eeb64faf5bb3a917e7/ext/mysqlnd/mysqlnd_connection.c#L1281 there is a fix to parse the version correctly, however
mysqli::get_server_info method still returns the unfixed/prefixed version because of https://jira.mariadb.org/browse/MDEV-4088 protocol fix for replication
the version returned by mysqli::get_server_info should be fixed and should match version returned by select version()
We can't do any stripping. We follow what the C API does in this case, which is to return the string verbatim. Any stripping would be against the specification. If the value returned by mysqli_get_server_info() needs to be stripped of any characters, it can be done in userland. I don't see any mention in any documentation that the value returned by mysql_get_server_info should match the one returned by SQL select version().
If the issue is that MariaDB is prefixing this value in the first place, then this should be reported to MariaDB.
I believe the current behaviour of PHP/mysqlnd is correct and I don't see any buggy behaviour.
mysqli_get_server_version() is fixed (in php-src) - is there any support to get the numerical version also from PDO?
We follow what the C API does in this case, which is to return the string verbatim.
The stripping is actually official for MariaDB client, see one related MariaDB issue https://jira.mariadb.org/browse/MDEV-4575 . As the prefixing is known and introduced only as a fix for replication protocol, it is safe to be removed also for mysqlnd.
$mysql = new mysqli($host, $user, $password, $db);
$res = $mysql->query("select version()");
var_dump(
$mysql->server_info,
$res->fetch_array()[0],
$mysql->server_version,
mysqli_get_server_version($mysql),
);
outputs for me
string(21) "5.5.5-10.5.13-MariaDB"
string(15) "10.5.13-MariaDB"
int(100513)
int(100513)
This inconsistency is certainly a bug.
This inconsistency is certainly a bug.
Do you mean a bug in mysqlnd? How so? This is exactly the information that mysqlnd receives from MariaDB.
This is exactly the information that mysqlnd receives from MariaDB.
No. We already strip the version prefix for ::$server_info and ::$server_version, but not when setting the conn->server_version in MYSQLND_METHOD(mysqlnd_command, handshake). Either we strip it everywhere, or never.
After some further discussion on php/php-src#7963, we decided to keep the behavior as is, but to document it.