mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Fixed issues with partitions and create temporary table SELECT ...
Merged all ddl_logging code. Merged sql_partition.cc innodb_mysql_lock2.test and partition_cache.test now works. Changed interface to strconvert() to make it easier to use with not \0 terminated strings. sql/sql_partition.cc: Full merge with 5.6 sql/sql_table.cc: Merged all ddl_logging code sql/strfunc.cc: Added from_length argument to strconvert() to make it possible to use without end terminated strings. sql/strfunc.h: Added from_length argument to strconvert() to make it possible to use without end terminated strings.
This commit is contained in:
120
sql/sql_cache.cc
120
sql/sql_cache.cc
@ -336,6 +336,7 @@ TODO list:
|
||||
#include "sql_acl.h" // SELECT_ACL
|
||||
#include "sql_base.h" // TMP_TABLE_KEY_EXTRA
|
||||
#include "debug_sync.h" // DEBUG_SYNC
|
||||
#include "sql_table.h"
|
||||
#ifdef HAVE_QUERY_CACHE
|
||||
#include <m_ctype.h>
|
||||
#include <my_dir.h>
|
||||
@ -345,6 +346,7 @@ TODO list:
|
||||
#include "probes_mysql.h"
|
||||
#include "log_slow.h"
|
||||
#include "transaction.h"
|
||||
#include "strfunc.h"
|
||||
|
||||
const uchar *query_state_map;
|
||||
|
||||
@ -1636,6 +1638,41 @@ send_data_in_chunks(NET *net, const uchar *packet, ulong len)
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
Build a normalized table name suitable for query cache engine callback
|
||||
|
||||
This consist of normalized directory '/' normalized_file_name
|
||||
followed by suffix.
|
||||
Suffix is needed for partitioned tables.
|
||||
*/
|
||||
|
||||
size_t build_normalized_name(char *buff, size_t bufflen,
|
||||
const char *db, size_t db_len,
|
||||
const char *table_name, size_t table_len,
|
||||
size_t suffix_len)
|
||||
{
|
||||
uint errors;
|
||||
size_t length;
|
||||
char *pos= buff, *end= buff+bufflen;
|
||||
DBUG_ENTER("build_normalized_name");
|
||||
|
||||
(*pos++)= FN_LIBCHAR;
|
||||
length= strconvert(system_charset_info, db, db_len,
|
||||
&my_charset_filename, pos, bufflen - 3,
|
||||
&errors);
|
||||
pos+= length;
|
||||
(*pos++)= FN_LIBCHAR;
|
||||
length= strconvert(system_charset_info, table_name, table_len,
|
||||
&my_charset_filename, pos, (uint) (end - pos),
|
||||
&errors);
|
||||
pos+= length;
|
||||
if (pos + suffix_len < end)
|
||||
pos= strmake(pos, table_name + table_len, suffix_len);
|
||||
|
||||
DBUG_RETURN((size_t) (pos - buff));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Check if the query is in the cache. If it was cached, send it
|
||||
to the user.
|
||||
@ -2011,35 +2048,50 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
|
||||
}
|
||||
#endif /*!NO_EMBEDDED_ACCESS_CHECKS*/
|
||||
engine_data= table->engine_data();
|
||||
if (table->callback() &&
|
||||
!(*table->callback())(thd, table->db(),
|
||||
table->key_length(),
|
||||
&engine_data))
|
||||
if (table->callback())
|
||||
{
|
||||
DBUG_PRINT("qcache", ("Handler does not allow caching for %s.%s",
|
||||
table_list.db, table_list.alias));
|
||||
BLOCK_UNLOCK_RD(query_block);
|
||||
if (engine_data != table->engine_data())
|
||||
char qcache_se_key_name[FN_REFLEN + 10];
|
||||
uint qcache_se_key_len, db_length= strlen(table->db());
|
||||
engine_data= table->engine_data();
|
||||
|
||||
qcache_se_key_len= build_normalized_name(qcache_se_key_name,
|
||||
sizeof(qcache_se_key_name),
|
||||
table->db(),
|
||||
db_length,
|
||||
table->table(),
|
||||
table->key_length() -
|
||||
db_length - 2 -
|
||||
table->suffix_length(),
|
||||
table->suffix_length());
|
||||
|
||||
if (!(*table->callback())(thd, qcache_se_key_name,
|
||||
qcache_se_key_len, &engine_data))
|
||||
{
|
||||
DBUG_PRINT("qcache",
|
||||
("Handler require invalidation queries of %s.%s %lu-%lu",
|
||||
table_list.db, table_list.alias,
|
||||
(ulong) engine_data, (ulong) table->engine_data()));
|
||||
invalidate_table_internal(thd,
|
||||
(uchar *) table->db(),
|
||||
table->key_length());
|
||||
DBUG_PRINT("qcache", ("Handler does not allow caching for %.*s",
|
||||
qcache_se_key_len, qcache_se_key_name));
|
||||
BLOCK_UNLOCK_RD(query_block);
|
||||
if (engine_data != table->engine_data())
|
||||
{
|
||||
DBUG_PRINT("qcache",
|
||||
("Handler require invalidation queries of %.*s %lu-%lu",
|
||||
qcache_se_key_len, qcache_se_key_name,
|
||||
(ulong) engine_data, (ulong) table->engine_data()));
|
||||
invalidate_table_internal(thd,
|
||||
(uchar *) table->db(),
|
||||
table->key_length());
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
As this can change from call to call, don't reset set
|
||||
thd->lex->safe_to_cache_query
|
||||
*/
|
||||
thd->query_cache_is_applicable= 0; // Query can't be cached
|
||||
}
|
||||
/* End the statement transaction potentially started by engine. */
|
||||
trans_rollback_stmt(thd);
|
||||
goto err_unlock; // Parse query
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
As this can change from call to call, don't reset set
|
||||
thd->lex->safe_to_cache_query
|
||||
*/
|
||||
thd->query_cache_is_applicable= 0; // Query can't be cached
|
||||
}
|
||||
/* End the statement transaction potentially started by engine. */
|
||||
trans_rollback_stmt(thd);
|
||||
goto err_unlock; // Parse query
|
||||
}
|
||||
else
|
||||
DBUG_PRINT("qcache", ("handler allow caching %s,%s",
|
||||
@ -3257,7 +3309,7 @@ Query_cache::register_tables_from_list(THD *thd, TABLE_LIST *tables_used,
|
||||
There are not callback function for for VIEWs
|
||||
*/
|
||||
if (!insert_table(key_length, key, (*block_table),
|
||||
tables_used->view_db.length + 1,
|
||||
tables_used->view_db.length + 1, 0,
|
||||
HA_CACHE_TBL_NONTRANSACT, 0, 0, TRUE))
|
||||
DBUG_RETURN(0);
|
||||
/*
|
||||
@ -3278,7 +3330,7 @@ Query_cache::register_tables_from_list(THD *thd, TABLE_LIST *tables_used,
|
||||
if (!insert_table(tables_used->table->s->table_cache_key.length,
|
||||
tables_used->table->s->table_cache_key.str,
|
||||
(*block_table),
|
||||
tables_used->db_length,
|
||||
tables_used->db_length, 0,
|
||||
tables_used->table->file->table_cache_type(),
|
||||
tables_used->callback_func,
|
||||
tables_used->engine_data,
|
||||
@ -3343,7 +3395,8 @@ my_bool Query_cache::register_all_tables(THD *thd,
|
||||
my_bool
|
||||
Query_cache::insert_table(uint key_len, char *key,
|
||||
Query_cache_block_table *node,
|
||||
uint32 db_length, uint8 cache_type,
|
||||
uint32 db_length, uint8 suffix_length_arg,
|
||||
uint8 cache_type,
|
||||
qc_engine_callback callback,
|
||||
ulonglong engine_data,
|
||||
my_bool hash)
|
||||
@ -3418,6 +3471,7 @@ Query_cache::insert_table(uint key_len, char *key,
|
||||
char *db= header->db();
|
||||
header->table(db + db_length + 1);
|
||||
header->key_length(key_len);
|
||||
header->suffix_length(suffix_length_arg);
|
||||
header->type(cache_type);
|
||||
header->callback(callback);
|
||||
header->engine_data(engine_data);
|
||||
@ -4041,13 +4095,13 @@ my_bool Query_cache::ask_handler_allowance(THD *thd,
|
||||
continue;
|
||||
handler= table->file;
|
||||
if (!handler->register_query_cache_table(thd,
|
||||
table->s->table_cache_key.str,
|
||||
table->s->table_cache_key.length,
|
||||
table->s->normalized_path.str,
|
||||
table->s->normalized_path.length,
|
||||
&tables_used->callback_func,
|
||||
&tables_used->engine_data))
|
||||
{
|
||||
DBUG_PRINT("qcache", ("Handler does not allow caching for %s.%s",
|
||||
tables_used->db, tables_used->alias));
|
||||
DBUG_PRINT("qcache", ("Handler does not allow caching for %s",
|
||||
table->s->normalized_path.str));
|
||||
/*
|
||||
As this can change from call to call, don't reset set
|
||||
thd->lex->safe_to_cache_query
|
||||
|
Reference in New Issue
Block a user