• guilhem@gbichot3.local's avatar
    Fix for BUG#735 "Prepared Statements: there is no support for Query · eaf7728d
    guilhem@gbichot3.local authored
    Cache".
    WL#1569 "Prepared Statements: implement support of Query Cache".
    Prepared SELECTs did not look up in the query cache, and their results
    were not stored in the query cache. This made them slower than
    non-prepared SELECTs in some cases.
    The fix is to re-use the expanded query (the prepared query where
    "?" placeholders are replaced by their values, at execution time)
    for searching/storing in the query cache.
    It works fine for statements prepared via mysql_stmt_prepare(), which
    are the most commonly used and were the scope of this bugfix and WL.
    It works less fine for statements prepared via the SQL command
    PREPARE...FROM, which are still not using the query cache if they
    have at least one parameter (because then the expanded query contains
    names of user variables, and user variables don't work with the
    query cache, even in non-prepared queries).
    Note that results from prepared SELECTs, which are in the binary
    protocol, and results from normal SELECTs, which are in the text
    protocol, ignore each other in the query cache, because a result in the
    binary protocol should never be served to a SELECT expecting the text
    protocol and vice-versa.
    Note, after this patch, bug 25843 starts applying to query cache
    ("changing default database between PREPARE and EXECUTE of statement
    breaks binlog"), we need to fix it.
    eaf7728d
query_cache.result 55.1 KB