Details
Description
Reproducer query:
SELECT * |
FROM ( |
SELECT * FROM my_table |
UNION ALL |
SELECT * FROM my_table |
) q
|
WHERE q.column_with_index = ?; |
I am using PHP to execute this query. Everything works fine when using PDO's emulated parameter bindings. The execution is fast and "EXPLAIN SELECT ..." reveals that the index on column "column_with_index" is being used.
Things change when I set "PDO::ATTR_EMULATE_PREPARES" to "false": When using MariaDB's native parameter binding protocol, the index is not being used.
This behavior changes again, depending on the exact parameter binding protocol + charset + database API combination.
I've posted my question to StackOverflow and somebody suspected this to be a bug in MariaDB.
The post can be found here: https://stackoverflow.com/q/79245146/1529133
I've also prepared a reproducer here:
https://phpize.online/sql/mariadb115/a1c61a1321ba2adfc689bd9e87e75ad9/php/php82/c602157f683d216f384ec3e56833df9b/