| 1294 | |
| 1295 | |
| 1296 | size_t Query_cache::resize(size_t query_cache_size_arg) |
| 1297 | { |
| 1298 | size_t new_query_cache_size; |
| 1299 | DBUG_ENTER("Query_cache::resize"); |
| 1300 | DBUG_PRINT("qcache", ("from %zu to %zu",query_cache_size, |
| 1301 | query_cache_size_arg)); |
| 1302 | DBUG_ASSERT(initialized); |
| 1303 | |
| 1304 | lock_and_suspend(); |
| 1305 | |
| 1306 | /* |
| 1307 | Wait for all readers and writers to exit. When the list of all queries |
| 1308 | is iterated over with a block level lock, we are done. |
| 1309 | */ |
| 1310 | Query_cache_block *block= queries_blocks; |
| 1311 | if (block) |
| 1312 | { |
| 1313 | do |
| 1314 | { |
| 1315 | BLOCK_LOCK_WR(block); |
| 1316 | Query_cache_query *query= block->query(); |
| 1317 | if (query->writer()) |
| 1318 | { |
| 1319 | /* |
| 1320 | Drop the writer; this will cancel any attempts to store |
| 1321 | the processed statement associated with this writer. |
| 1322 | */ |
| 1323 | query->writer()->first_query_block= NULL; |
| 1324 | query->writer(0); |
| 1325 | refused++; |
| 1326 | } |
| 1327 | query->unlock_n_destroy(); |
| 1328 | block= block->next; |
| 1329 | } while (block != queries_blocks); |
| 1330 | queries_blocks= NULL; // avoid second destroying by free_cache |
| 1331 | } |
| 1332 | free_cache(); |
| 1333 | |
| 1334 | query_cache_size= query_cache_size_arg; |
| 1335 | new_query_cache_size= init_cache(); |
| 1336 | |
| 1337 | /* |
| 1338 | m_cache_status is internal query cache switch so switching it on/off |
| 1339 | will not be reflected on global_system_variables.query_cache_type |
| 1340 | */ |
| 1341 | if (new_query_cache_size && global_system_variables.query_cache_type != 0) |
| 1342 | { |
| 1343 | DBUG_EXECUTE("check_querycache",check_integrity(1);); |
| 1344 | m_cache_status= OK; // size > 0 => enable cache |
| 1345 | } |
| 1346 | else |
| 1347 | m_cache_status= DISABLED; // size 0 means the cache disabled |
| 1348 | |
| 1349 | unlock(); |
| 1350 | DBUG_RETURN(new_query_cache_size); |
| 1351 | } |
| 1352 | |
| 1353 |
no test coverage detected