When I connect to mariadb with different clients, cached query results are sometimes returned in the wrong format.
I have a mariadb 10.5.9 database, with the following clients connecting to it:
1. A php client that connects with an old mysqli driver. It sets client capability flags 0x1AA284 and charset latin1
2. A perl client that connects DBD::Mysql (using libmariadb 3.1.11 under the hood). It sets client capability flags 0xD00BFA20C and charset latin1
3. The mysql command line client that comes with Rocky mariadb package (statically compiled with libmariadb 3.1.12). It sets client capability flags 0xD00BFA20E and charset utf8.
If I run the same query in all 3 clients in the above order, php succeeds, perl gets "Unknown Error", and cli succeeds. After I do "FLUSH TABLES", perl client works fine.
It appears the query cache needs to key off the MARIADB_CLIENT_EXTENDED_METADATA flag. I believe the command line client succeeds because it connects with a different charset.
I have also tested with mariadb 10.5.13 RPM downloaded from mariadb.org.
Setting query_cache_size = 0 in my.cnf works around the issue.
How to reproduce:
Then in perl: