Skip to content

MariaDB version prefix 5.5.5- is not stripped #7972

Closed

Description

@mvorisek

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

Activity

  1. cmb69 commented on Jan 11, 2022

    @cmb69
    Member

    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.

  2. mvorisek commented on Jan 11, 2022

    @mvorisek
    ContributorAuthor

    in

    #define MARIA_DB_VERSION_HACK_PREFIX "5.5.5-"
    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()

  3. kamil-tekiela commented on Jan 11, 2022

    @kamil-tekiela
    Member

    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.

  4. mvorisek commented on Jan 11, 2022

    @mvorisek
    ContributorAuthor

    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.

  5. self-assigned this
    on Jan 11, 2022
  6. cmb69 commented on Jan 18, 2022

    @cmb69
    Member
    $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.

  7. kamil-tekiela commented on Jan 18, 2022

    @kamil-tekiela
    Member

    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.

  8. cmb69 commented on Jan 18, 2022

    @cmb69
    Member

    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.

  9. cmb69 commented on Jan 18, 2022

    @cmb69
    Member

    After some further discussion on #7963, we decided to keep the behavior as is, but to document it.

  10. transferred this issue fromon Jan 18, 2022
  11. transferred this issue fromphp/doc-enon Jan 19, 2022
  12. added a commit that references this issue on Jan 19, 2022
    5fc0db9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions