MCPcopy Create free account
hub / github.com/MariaDB/server / store_query

Method store_query

sql/sql_cache.cc:1363–1601  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1361
1362
1363void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used)
1364{
1365 TABLE_COUNTER_TYPE local_tables;
1366 size_t tot_length;
1367 const char *query;
1368 size_t query_length;
1369 uint8 tables_type;
1370 DBUG_ENTER("Query_cache::store_query");
1371 /*
1372 Testing 'query_cache_size' without a lock here is safe: the thing
1373 we may loose is that the query won't be cached, but we save on
1374 mutex locking in the case when query cache is disabled or the
1375 query is uncacheable.
1376
1377 See also a note on double-check locking usage above.
1378 */
1379 if (!thd->query_cache_is_applicable || query_cache_size == 0)
1380 {
1381 DBUG_PRINT("qcache", ("Query cache not ready"));
1382 DBUG_VOID_RETURN;
1383 }
1384 if (thd->lex->sql_command != SQLCOM_SELECT)
1385 {
1386 DBUG_PRINT("qcache", ("Ignoring not SELECT command"));
1387 DBUG_VOID_RETURN;
1388 }
1389
1390 /*
1391 Do not store queries while tracking transaction state.
1392 The tracker already flags queries that actually have
1393 transaction tracker items, but this will make behavior
1394 more straight forward.
1395 */
1396#ifndef EMBEDDED_LIBRARY
1397 if (thd->variables.session_track_transaction_info != TX_TRACK_NONE)
1398 {
1399 DBUG_PRINT("qcache", ("Do not work with transaction tracking"));
1400 DBUG_VOID_RETURN;
1401 }
1402#endif //EMBEDDED_LIBRARY
1403
1404
1405 /* The following assert fails if we haven't called send_result_to_client */
1406 DBUG_ASSERT(thd->base_query.is_alloced() ||
1407 thd->base_query.ptr() == thd->query());
1408
1409 tables_type= 0;
1410 if ((local_tables= is_cacheable(thd, thd->lex, tables_used,
1411 &tables_type)))
1412 {
1413 NET *net= &thd->net;
1414 Query_cache_query_flags flags;
1415 // fill all gaps between fields with 0 to get repeatable key
1416 bzero(&flags, QUERY_CACHE_FLAGS_SIZE);
1417 flags.client_long_flag= MY_TEST(thd->client_capabilities & CLIENT_LONG_FLAG);
1418 flags.client_protocol_41= MY_TEST(thd->client_capabilities &
1419 CLIENT_PROTOCOL_41);
1420 flags.client_extended_metadata= MY_TEST(thd->client_capabilities &

Callers

nothing calls this directly

Calls 13

my_hash_searchFunction · 0.85
my_hash_insertFunction · 0.85
my_hash_deleteFunction · 0.85
init_n_lockMethod · 0.80
unlock_n_destroyMethod · 0.80
writerMethod · 0.80
tables_typeMethod · 0.80
is_allocedMethod · 0.45
ptrMethod · 0.45
queryMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected