Functionality added or changed:
Incompatible Change:
A change has been made to the way that the server handles
prepared statements. This affects prepared statements processed
at the SQL level (using the PREPARE
statement) and those processed using the binary client-server
protocol (using the
mysql_stmt_prepare() C API
function).
Previously, changes to metadata of tables or views referred to in a prepared statement could cause a server crash when the statement was next executed, or perhaps an error at execute time with a crash occurring later. For example, this could happen after dropping a table and recreating it with a different definition.
Now metadata changes to tables or views referred to by prepared
statements are detected and cause automatic repreparation of the
statement when it is next executed. Metadata changes occur for
DDL statements such as those that create, drop, alter, rename,
or truncate tables, or that analyze, optimize, or repair tables.
Repreparation also occurs after referenced tables or views are
flushed from the table definition cache, either implicitly to
make room for new entries in the cache, or explicitly due to
FLUSH TABLES.
Repreparation is automatic, but to the extent that it occurs, performance of prepared statements is diminished.
Table content changes (for example, with
INSERT or UPDATE) do not
cause repreparation, nor do SELECT
statements.
An incompatibility with previous versions of MySQL is that a
prepared statement may now return a different set of columns or
different column types from one execution to the next. For
example, if the prepared statement is SELECT * FROM
t1, altering t1 to contain a
different number of columns causes the next execution to return
a number of columns different from the previous execution.
Older versions of the client library cannot handle this change in behavior. For applications that use prepared statements with the new server, an upgrade to the new client library is strongly recommended.
Along with this change to statement repreparation, the default
value of the table_definition_cache system
variable has been increased from 128 to 256. The purpose of this
increase is to lessen the chance that prepared statements will
need repreparation due to referred-to tables/views having been
flushed from the cache to make room for new entries.
A new status variable, Com_stmt_reprepare,
has been introduced to track the number of repreparations.
(Bug#27420, Bug#27430, Bug#27690)
