• konstantin@mysql.com's avatar
    A fix and a test case for Bug#16365 "Prepared Statements: DoS with · 51899331
    konstantin@mysql.com authored
    too many open statements". The patch adds a new global variable
    @@max_prepared_stmt_count. This variable limits the total number
    of prepared statements in the server. The default value of
    @@max_prepared_stmt_count is 16382. 16382 small statements
    (a select against 3 tables with GROUP, ORDER and LIMIT) consume 
    100MB of RAM. Once this limit has been reached, the server will 
    refuse to prepare a new statement and return ER_UNKNOWN_ERROR 
    (unfortunately, we can't add new errors to 4.1 without breaking 5.0). The limit is changeable after startup
    and can accept any value from 0 to 1 million. In case
    the new value of the limit is less than the current
    statement count, no new statements can be added, while the old
    still can be used. Additionally, the current count of prepared 
    statements is now available through a global read-only variable 
    @@prepared_stmt_count.
    51899331
set_var.cc 102 KB