mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
First stage of table definition cache
Split TABLE to TABLE and TABLE_SHARE (TABLE_SHARE is still allocated as part of table, will be fixed soon) Created Field::make_field() and made Field_num::make_field() to call this Added 'TABLE_SHARE->db' that points to database name; Changed all usage of table_cache_key as database name to use this instead Changed field->table_name to point to pointer to alias. This allows us to change alias for a table by just updating one pointer. Renamed TABLE_SHARE->real_name to table_name Renamed TABLE->table_name to alias Renamed TABLE_LIST->real_name to table_name include/myisam.h: Added const before names mysql-test/r/group_min_max.result: Make results repeatable mysql-test/t/group_min_max.test: Make results repeatable sql/field.cc: Created Field::make_field() and made Field_num::make_field() to call this Use TABLE_SHARE Use sql_strmake() instead of sql_memdup() to simplify code sql/field.h: Changed table_name to be pointer to table_name. This allows us to change alias for all fields by just changing one pointer. Use TABLE_SHARE sql/field_conv.cc: Use TABLE_SHARE sql/filesort.cc: Use TABLE_SHARE sql/ha_berkeley.cc: Use TABLE_SHARE sql/ha_heap.cc: Use TABLE_SHARE sql/ha_innodb.cc: Use TABLE_SHARE sql/ha_myisam.cc: Use TABLE_SHARE sql/ha_myisammrg.cc: Use TABLE_SHARE Change some pointer handling to use const char* sql/ha_ndbcluster.cc: Use TABLE_SHARE sql/handler.cc: Use TABLE_SHARE sql/item.cc: Use TABLE_SHARE sql/item_func.cc: Use TABLE_SHARE sql/item_subselect.cc: Use TABLE_SHARE sql/item_sum.cc: Use TABLE_SHARE sql/key.cc: Use TABLE_SHARE sql/lock.cc: Use TABLE_SHARE sql/log_event.cc: real_name -> table_name sql/mysql_priv.h: Use TABLE_SHARE sql/opt_range.cc: Use TABLE_SHARE sql/opt_sum.cc: Use TABLE_SHARE sql/records.cc: Use TABLE_SHARE sql/repl_failsafe.cc: real_name -> table_name sql/slave.cc: Use TABLE_SHARE sql/sp.cc: Use TABLE_SHARE sql/sp_head.cc: real_name -> table_name sql/sql_acl.cc: Use TABLE_SHARE removed unnecessary assert fixed indentation changed some char * -> const char* sql/sql_acl.h: changed some char* -> const char* sql/sql_base.cc: Use TABLE_SHARE sql/sql_cache.cc: Use TABLE_SHARE sql/sql_class.cc: Use TABLE_SHARE sql/sql_db.cc: real_name -> table_name sql/sql_delete.cc: Use TABLE_SHARE sql/sql_derived.cc: Use TABLE_SHARE sql/sql_handler.cc: Use TABLE_SHARE sql/sql_help.cc: Use TABLE_SHARE sql/sql_insert.cc: Use TABLE_SHARE sql/sql_load.cc: Use TABLE_SHARE sql/sql_parse.cc: Use TABLE_SHARE sql/sql_rename.cc: real_name -> table_name sql/sql_select.cc: Use TABLE_SHARE table->blob_fields now points to field offsets, not fields tmp_table->table_name now points to alias name sql/sql_show.cc: Use TABLE_SHARE sql/sql_table.cc: Use TABLE_SHARE sql/sql_test.cc: Use TABLE_SHARE sql/sql_trigger.cc: Use TABLE_SHARE sql/sql_udf.cc: Use TABLE_SHARE sql/sql_union.cc: real_name -> table_name sql/sql_update.cc: Use TABLE_SHARE sql/sql_view.cc: Use TABLE_SHARE sql/table.cc: Split TABLE to TABLE and TABLE_SHARE Changed blob_field to be field offsets instead of pointer to fields Only initialize table->s->default_values with default record (not all table->record[#]) Some indentation changes sql/table.h: Split TABLE to TABLE and TABLE_SHARE sql/tztime.cc: real_name -> table_name sql/unireg.cc: Use TABLE_SHARE sql/unireg.h: Use TABLE_SHARE
This commit is contained in:
@ -1031,7 +1031,6 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
|
||||
{
|
||||
TABLE_LIST table_list;
|
||||
TABLE *tmptable;
|
||||
|
||||
Query_cache_table *table = block_table->parent;
|
||||
|
||||
/*
|
||||
@ -1042,8 +1041,9 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
|
||||
*/
|
||||
for (tmptable= thd->temporary_tables; tmptable ; tmptable= tmptable->next)
|
||||
{
|
||||
if (tmptable->key_length - TMP_TABLE_KEY_EXTRA == table->key_length() &&
|
||||
!memcmp(tmptable->table_cache_key, table->data(),
|
||||
if (tmptable->s->key_length - TMP_TABLE_KEY_EXTRA ==
|
||||
table->key_length() &&
|
||||
!memcmp(tmptable->s->table_cache_key, table->data(),
|
||||
table->key_length()))
|
||||
{
|
||||
DBUG_PRINT("qcache",
|
||||
@ -1063,7 +1063,7 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
|
||||
|
||||
bzero((char*) &table_list,sizeof(table_list));
|
||||
table_list.db = table->db();
|
||||
table_list.alias= table_list.real_name= table->table();
|
||||
table_list.alias= table_list.table_name= table->table();
|
||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||
if (check_table_access(thd,SELECT_ACL,&table_list,1))
|
||||
{
|
||||
@ -2056,7 +2056,7 @@ void Query_cache::invalidate_table(TABLE_LIST *table_list)
|
||||
uint key_length;
|
||||
Query_cache_block *table_block;
|
||||
key_length=(uint) (strmov(strmov(key,table_list->db)+1,
|
||||
table_list->real_name) -key)+ 1;
|
||||
table_list->table_name) -key)+ 1;
|
||||
|
||||
// We don't store temporary tables => no key_length+=4 ...
|
||||
if ((table_block = (Query_cache_block*)
|
||||
@ -2067,7 +2067,7 @@ void Query_cache::invalidate_table(TABLE_LIST *table_list)
|
||||
|
||||
void Query_cache::invalidate_table(TABLE *table)
|
||||
{
|
||||
invalidate_table((byte*) table->table_cache_key, table->key_length);
|
||||
invalidate_table((byte*) table->s->table_cache_key, table->s->key_length);
|
||||
}
|
||||
|
||||
void Query_cache::invalidate_table(byte * key, uint32 key_length)
|
||||
@ -2116,18 +2116,18 @@ my_bool Query_cache::register_all_tables(Query_cache_block *block,
|
||||
{
|
||||
DBUG_PRINT("qcache",
|
||||
("table %s, db %s, openinfo at 0x%lx, keylen %u, key at 0x%lx",
|
||||
tables_used->real_name, tables_used->db,
|
||||
tables_used->table_name, tables_used->db,
|
||||
(ulong) tables_used->table,
|
||||
tables_used->table->key_length,
|
||||
(ulong) tables_used->table->table_cache_key));
|
||||
block_table->n=n;
|
||||
if (!insert_table(tables_used->table->key_length,
|
||||
tables_used->table->table_cache_key, block_table,
|
||||
tables_used->table->s->key_length,
|
||||
(ulong) tables_used->table->s->table_cache_key));
|
||||
block_table->n= n;
|
||||
if (!insert_table(tables_used->table->s->key_length,
|
||||
tables_used->table->s->table_cache_key, block_table,
|
||||
tables_used->db_length,
|
||||
tables_used->table->file->table_cache_type()))
|
||||
break;
|
||||
|
||||
if (tables_used->table->db_type == DB_TYPE_MRG_MYISAM)
|
||||
if (tables_used->table->s->db_type == DB_TYPE_MRG_MYISAM)
|
||||
{
|
||||
ha_myisammrg *handler = (ha_myisammrg *) tables_used->table->file;
|
||||
MYRG_INFO *file = handler->myrg_info();
|
||||
@ -2663,15 +2663,15 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len,
|
||||
{
|
||||
table_count++;
|
||||
DBUG_PRINT("qcache", ("table %s, db %s, type %u",
|
||||
tables_used->real_name,
|
||||
tables_used->db, tables_used->table->db_type));
|
||||
tables_used->table_name,
|
||||
tables_used->db, tables_used->table->s->db_type));
|
||||
*tables_type|= tables_used->table->file->table_cache_type();
|
||||
|
||||
/*
|
||||
table_alias_charset used here because it depends of
|
||||
lower_case_table_names variable
|
||||
*/
|
||||
if (tables_used->table->tmp_table != NO_TMP_TABLE ||
|
||||
if (tables_used->table->s->tmp_table != NO_TMP_TABLE ||
|
||||
(*tables_type & HA_CACHE_TBL_NOCACHE) ||
|
||||
(tables_used->db_length == 5 &&
|
||||
my_strnncoll(table_alias_charset, (uchar*)tables_used->db, 6,
|
||||
@ -2682,7 +2682,7 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len,
|
||||
other non-cacheable table(s)"));
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
if (tables_used->table->db_type == DB_TYPE_MRG_MYISAM)
|
||||
if (tables_used->table->s->db_type == DB_TYPE_MRG_MYISAM)
|
||||
{
|
||||
ha_myisammrg *handler = (ha_myisammrg *)tables_used->table->file;
|
||||
MYRG_INFO *file = handler->myrg_info();
|
||||
@ -2729,8 +2729,8 @@ my_bool Query_cache::ask_handler_allowance(THD *thd,
|
||||
for (; tables_used; tables_used= tables_used->next_global)
|
||||
{
|
||||
TABLE *table= tables_used->table;
|
||||
if (!ha_caching_allowed(thd, table->table_cache_key,
|
||||
table->key_length,
|
||||
if (!ha_caching_allowed(thd, table->s->table_cache_key,
|
||||
table->s->key_length,
|
||||
table->file->table_cache_type()))
|
||||
{
|
||||
DBUG_PRINT("qcache", ("Handler does not allow caching for %s.%s",
|
||||
|
Reference in New Issue
Block a user