Xenos Xenos - 22 days ago 9
MySQL Question

PHP - PDO: MySQL's logged prepared statements include PS data

I use MySQL prepared statements in PHP through PDO to separate the query and the data, like:

CALL `celestial_object_view`(?, ?)


But the MySQL log shows

CALL `celestial_object_view`('1', '1')


Hence, I guess the data are actually merged into the query before being send to MySQL? It's not an issue for short data, but when inserting 10Mo of Blob data, the MySQL server screams about the exceeded
max_allowed_packet
.

How can I make PDO/PHP/MySQL consider the data separately from the PS so I can execute a short PS with tons of data, without reaching
max_allowed_packet
?

Answer

There are two possible explanations for what you are seeing in the log.

  • an obvious one, by default PDO just emulates prepared statements, sending the regular SQL query to the server.
  • in case the real prepared statement has been used, the log entry you are seeing has been artificially conjured especially for the logging purposes, while prepared statement has been executed properly, with data sent separately.

So, just make sure that emulation mode is turned off, that you are binding your LOBs properly, and don't worry