Loading sql/ha_innodb.cc +2 −1 Original line number Diff line number Diff line Loading @@ -655,8 +655,9 @@ innobase_query_caching_of_table_permitted( char* full_name, /* in: concatenation of database name, the null character '\0', and the table name */ uint full_name_len) /* in: length of the full name, i.e. uint full_name_len, /* in: length of the full name, i.e. len(dbname) + len(tablename) + 1 */ ulonglong *unused) /* unused for this engine */ { ibool is_autocommit; trx_t* trx; Loading sql/ha_innodb.h +18 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,10 @@ typedef struct st_innobase_share { } INNOBASE_SHARE; my_bool innobase_query_caching_of_table_permitted(THD* thd, char* full_name, uint full_name_len, ulonglong *unused); /* The class defining a handle to an Innodb table */ class ha_innobase: public handler { Loading Loading @@ -168,6 +172,20 @@ class ha_innobase: public handler void init_table_handle_for_HANDLER(); longlong get_auto_increment(); uint8 table_cache_type() { return HA_CACHE_TBL_ASKTRANSACT; } /* ask handler about permission to cache table during query registration */ my_bool cached_table_registration(THD *thd, char *table_key, uint key_length, qc_engine_callback *call_back, ulonglong *engine_data) { *call_back= innobase_query_caching_of_table_permitted; *engine_data= 0; return innobase_query_caching_of_table_permitted(thd, table_key, key_length, engine_data); } static char *get_mysql_bin_log_name(); static ulonglong get_mysql_bin_log_pos(); Loading Loading @@ -233,8 +251,6 @@ int innobase_close_connection(THD *thd); int innobase_drop_database(char *path); int innodb_show_status(THD* thd); my_bool innobase_query_caching_of_table_permitted(THD* thd, char* full_name, uint full_name_len); void innobase_release_temporary_latches(void* innobase_tid); void innobase_store_binlog_offset_and_flush_log(char *binlog_name,longlong offset); Loading sql/ha_ndbcluster.cc +130 −4 Original line number Diff line number Diff line Loading @@ -4457,19 +4457,145 @@ const char* ha_ndbcluster::index_type(uint key_number) } uint8 ha_ndbcluster::table_cache_type() { DBUG_ENTER("ha_ndbcluster::table_cache_type"); switch (m_query_cache_type) { case 0: return HA_CACHE_TBL_NOCACHE; DBUG_PRINT("exit",("HA_CACHE_TBL_NOCACHE")); DBUG_RETURN(HA_CACHE_TBL_NOCACHE); case 1: return HA_CACHE_TBL_ASKTRANSACT; DBUG_PRINT("exit",("HA_CACHE_TBL_ASKTRANSACT")); DBUG_RETURN(HA_CACHE_TBL_ASKTRANSACT); case 2: return HA_CACHE_TBL_TRANSACT; DBUG_PRINT("exit",("HA_CACHE_TBL_TRANSACT")); DBUG_RETURN(HA_CACHE_TBL_TRANSACT); default: return HA_CACHE_TBL_NOCACHE; DBUG_PRINT("exit",("HA_CACHE_TBL_NOCACHE")); DBUG_RETURN(HA_CACHE_TBL_NOCACHE); } } static my_bool ndbcluster_cache_retrieval_allowed( /*======================================*/ /* out: TRUE if permitted, FALSE if not; note that the value FALSE means invalidation of query cache if *engine_data is changed */ THD* thd, /* in: thd of the user who is trying to store a result to the query cache or retrieve it */ char* full_name, /* in: concatenation of database name, the null character '\0', and the table name */ uint full_name_len, /* in: length of the full name, i.e. len(dbname) + len(tablename) + 1 */ ulonglong *engine_data) /* in: value set in call to ha_ndbcluster::cached_table_registration out: if return FALSE this is used to invalidate all cached queries with this table*/ { DBUG_ENTER("ndbcluster_cache_retrieval_allowed"); char tabname[128]; char *dbname= full_name; my_bool is_autocommit; { int dbname_len= strlen(full_name); int tabname_len= full_name_len-dbname_len-1; memcpy(tabname, full_name+dbname_len+1, tabname_len); tabname[tabname_len]= '\0'; } if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) is_autocommit = FALSE; else is_autocommit = TRUE; DBUG_PRINT("enter",("dbname=%s, tabname=%s, autocommit=%d", dbname,tabname,is_autocommit)); if (!is_autocommit) { DBUG_PRINT("info",("OPTION_NOT_AUTOCOMMIT=%d OPTION_BEGIN=%d", thd->options & OPTION_NOT_AUTOCOMMIT, thd->options & OPTION_BEGIN)); // ToDo enable cache inside a transaction // no need to invalidate though so leave *engine_data DBUG_RETURN(FALSE); } { Ndb *ndb; Uint64 commit_count; if (!(ndb= check_ndb_in_thd(thd))) { *engine_data= *engine_data+1; // invalidate DBUG_RETURN(FALSE); } ndb->setDatabaseName(dbname); if (ndb_get_table_statistics(ndb, tabname, 0, &commit_count)) { *engine_data= *engine_data+1; // invalidate DBUG_RETURN(FALSE); } if (*engine_data != commit_count) { *engine_data= commit_count; // invalidate DBUG_RETURN(FALSE); } } DBUG_PRINT("exit",("*engine_data=%d ok, use cache",*engine_data)); DBUG_RETURN(TRUE); } my_bool ha_ndbcluster::cached_table_registration( /*======================================*/ /* out: TRUE if permitted, FALSE if not; note that the value FALSE means invalidation of query cache if *engine_data is changed */ THD* thd, /* in: thd of the user who is trying to store a result to the query cache or retrieve it */ char* full_name, /* in: concatenation of database name, the null character '\0', and the table name */ uint full_name_len, /* in: length of the full name, i.e. len(dbname) + len(tablename) + 1 */ qc_engine_callback *engine_callback, /* out: function to be called before using cache on this table */ ulonglong *engine_data) /* out: if return FALSE this is used to invalidate all cached queries with this table*/ { DBUG_ENTER("ha_ndbcluster::cached_table_registration"); my_bool is_autocommit; if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) is_autocommit = FALSE; else is_autocommit = TRUE; DBUG_PRINT("enter",("dbname=%s, tabname=%s, is_autocommit=%d", m_dbname,m_tabname,is_autocommit)); if (!is_autocommit) { DBUG_PRINT("info",("OPTION_NOT_AUTOCOMMIT=%d OPTION_BEGIN=%d", thd->options & OPTION_NOT_AUTOCOMMIT, thd->options & OPTION_BEGIN)); // ToDo enable cache inside a transaction // no need to invalidate though so leave *engine_data DBUG_RETURN(FALSE); } { Uint64 commit_count; m_ndb->setDatabaseName(m_dbname); if (ndb_get_table_statistics(m_ndb, m_tabname, 0, &commit_count)) { *engine_data= 0; DBUG_RETURN(FALSE); } *engine_data= commit_count; } *engine_callback= ndbcluster_cache_retrieval_allowed; DBUG_PRINT("exit",("*engine_data=%d", *engine_data)); DBUG_RETURN(TRUE); } /* Handling the shared NDB_SHARE structure that is needed to provide table locking. Loading sql/ha_ndbcluster.h +4 −1 Original line number Diff line number Diff line Loading @@ -146,7 +146,10 @@ class ha_ndbcluster: public handler static Thd_ndb* seize_thd_ndb(); static void release_thd_ndb(Thd_ndb* thd_ndb); uint8 table_cache_type(); my_bool cached_table_registration(THD *thd, char *table_key, uint key_length, qc_engine_callback *engine_callback, ulonglong *engine_data); private: int alter_table_name(const char *from, const char *to); int drop_table(); Loading sql/handler.cc +0 −9 Original line number Diff line number Diff line Loading @@ -229,15 +229,6 @@ handler *get_new_handler(TABLE *table, enum db_type db_type) } } bool ha_caching_allowed(THD* thd, char* table_key, uint key_length, uint8 cache_type) { #ifdef HAVE_INNOBASE_DB if (cache_type == HA_CACHE_TBL_ASKTRANSACT) return innobase_query_caching_of_table_permitted(thd, table_key, key_length); #endif return 1; } int ha_init() { Loading Loading
sql/ha_innodb.cc +2 −1 Original line number Diff line number Diff line Loading @@ -655,8 +655,9 @@ innobase_query_caching_of_table_permitted( char* full_name, /* in: concatenation of database name, the null character '\0', and the table name */ uint full_name_len) /* in: length of the full name, i.e. uint full_name_len, /* in: length of the full name, i.e. len(dbname) + len(tablename) + 1 */ ulonglong *unused) /* unused for this engine */ { ibool is_autocommit; trx_t* trx; Loading
sql/ha_innodb.h +18 −2 Original line number Diff line number Diff line Loading @@ -33,6 +33,10 @@ typedef struct st_innobase_share { } INNOBASE_SHARE; my_bool innobase_query_caching_of_table_permitted(THD* thd, char* full_name, uint full_name_len, ulonglong *unused); /* The class defining a handle to an Innodb table */ class ha_innobase: public handler { Loading Loading @@ -168,6 +172,20 @@ class ha_innobase: public handler void init_table_handle_for_HANDLER(); longlong get_auto_increment(); uint8 table_cache_type() { return HA_CACHE_TBL_ASKTRANSACT; } /* ask handler about permission to cache table during query registration */ my_bool cached_table_registration(THD *thd, char *table_key, uint key_length, qc_engine_callback *call_back, ulonglong *engine_data) { *call_back= innobase_query_caching_of_table_permitted; *engine_data= 0; return innobase_query_caching_of_table_permitted(thd, table_key, key_length, engine_data); } static char *get_mysql_bin_log_name(); static ulonglong get_mysql_bin_log_pos(); Loading Loading @@ -233,8 +251,6 @@ int innobase_close_connection(THD *thd); int innobase_drop_database(char *path); int innodb_show_status(THD* thd); my_bool innobase_query_caching_of_table_permitted(THD* thd, char* full_name, uint full_name_len); void innobase_release_temporary_latches(void* innobase_tid); void innobase_store_binlog_offset_and_flush_log(char *binlog_name,longlong offset); Loading
sql/ha_ndbcluster.cc +130 −4 Original line number Diff line number Diff line Loading @@ -4457,19 +4457,145 @@ const char* ha_ndbcluster::index_type(uint key_number) } uint8 ha_ndbcluster::table_cache_type() { DBUG_ENTER("ha_ndbcluster::table_cache_type"); switch (m_query_cache_type) { case 0: return HA_CACHE_TBL_NOCACHE; DBUG_PRINT("exit",("HA_CACHE_TBL_NOCACHE")); DBUG_RETURN(HA_CACHE_TBL_NOCACHE); case 1: return HA_CACHE_TBL_ASKTRANSACT; DBUG_PRINT("exit",("HA_CACHE_TBL_ASKTRANSACT")); DBUG_RETURN(HA_CACHE_TBL_ASKTRANSACT); case 2: return HA_CACHE_TBL_TRANSACT; DBUG_PRINT("exit",("HA_CACHE_TBL_TRANSACT")); DBUG_RETURN(HA_CACHE_TBL_TRANSACT); default: return HA_CACHE_TBL_NOCACHE; DBUG_PRINT("exit",("HA_CACHE_TBL_NOCACHE")); DBUG_RETURN(HA_CACHE_TBL_NOCACHE); } } static my_bool ndbcluster_cache_retrieval_allowed( /*======================================*/ /* out: TRUE if permitted, FALSE if not; note that the value FALSE means invalidation of query cache if *engine_data is changed */ THD* thd, /* in: thd of the user who is trying to store a result to the query cache or retrieve it */ char* full_name, /* in: concatenation of database name, the null character '\0', and the table name */ uint full_name_len, /* in: length of the full name, i.e. len(dbname) + len(tablename) + 1 */ ulonglong *engine_data) /* in: value set in call to ha_ndbcluster::cached_table_registration out: if return FALSE this is used to invalidate all cached queries with this table*/ { DBUG_ENTER("ndbcluster_cache_retrieval_allowed"); char tabname[128]; char *dbname= full_name; my_bool is_autocommit; { int dbname_len= strlen(full_name); int tabname_len= full_name_len-dbname_len-1; memcpy(tabname, full_name+dbname_len+1, tabname_len); tabname[tabname_len]= '\0'; } if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) is_autocommit = FALSE; else is_autocommit = TRUE; DBUG_PRINT("enter",("dbname=%s, tabname=%s, autocommit=%d", dbname,tabname,is_autocommit)); if (!is_autocommit) { DBUG_PRINT("info",("OPTION_NOT_AUTOCOMMIT=%d OPTION_BEGIN=%d", thd->options & OPTION_NOT_AUTOCOMMIT, thd->options & OPTION_BEGIN)); // ToDo enable cache inside a transaction // no need to invalidate though so leave *engine_data DBUG_RETURN(FALSE); } { Ndb *ndb; Uint64 commit_count; if (!(ndb= check_ndb_in_thd(thd))) { *engine_data= *engine_data+1; // invalidate DBUG_RETURN(FALSE); } ndb->setDatabaseName(dbname); if (ndb_get_table_statistics(ndb, tabname, 0, &commit_count)) { *engine_data= *engine_data+1; // invalidate DBUG_RETURN(FALSE); } if (*engine_data != commit_count) { *engine_data= commit_count; // invalidate DBUG_RETURN(FALSE); } } DBUG_PRINT("exit",("*engine_data=%d ok, use cache",*engine_data)); DBUG_RETURN(TRUE); } my_bool ha_ndbcluster::cached_table_registration( /*======================================*/ /* out: TRUE if permitted, FALSE if not; note that the value FALSE means invalidation of query cache if *engine_data is changed */ THD* thd, /* in: thd of the user who is trying to store a result to the query cache or retrieve it */ char* full_name, /* in: concatenation of database name, the null character '\0', and the table name */ uint full_name_len, /* in: length of the full name, i.e. len(dbname) + len(tablename) + 1 */ qc_engine_callback *engine_callback, /* out: function to be called before using cache on this table */ ulonglong *engine_data) /* out: if return FALSE this is used to invalidate all cached queries with this table*/ { DBUG_ENTER("ha_ndbcluster::cached_table_registration"); my_bool is_autocommit; if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) is_autocommit = FALSE; else is_autocommit = TRUE; DBUG_PRINT("enter",("dbname=%s, tabname=%s, is_autocommit=%d", m_dbname,m_tabname,is_autocommit)); if (!is_autocommit) { DBUG_PRINT("info",("OPTION_NOT_AUTOCOMMIT=%d OPTION_BEGIN=%d", thd->options & OPTION_NOT_AUTOCOMMIT, thd->options & OPTION_BEGIN)); // ToDo enable cache inside a transaction // no need to invalidate though so leave *engine_data DBUG_RETURN(FALSE); } { Uint64 commit_count; m_ndb->setDatabaseName(m_dbname); if (ndb_get_table_statistics(m_ndb, m_tabname, 0, &commit_count)) { *engine_data= 0; DBUG_RETURN(FALSE); } *engine_data= commit_count; } *engine_callback= ndbcluster_cache_retrieval_allowed; DBUG_PRINT("exit",("*engine_data=%d", *engine_data)); DBUG_RETURN(TRUE); } /* Handling the shared NDB_SHARE structure that is needed to provide table locking. Loading
sql/ha_ndbcluster.h +4 −1 Original line number Diff line number Diff line Loading @@ -146,7 +146,10 @@ class ha_ndbcluster: public handler static Thd_ndb* seize_thd_ndb(); static void release_thd_ndb(Thd_ndb* thd_ndb); uint8 table_cache_type(); my_bool cached_table_registration(THD *thd, char *table_key, uint key_length, qc_engine_callback *engine_callback, ulonglong *engine_data); private: int alter_table_name(const char *from, const char *to); int drop_table(); Loading
sql/handler.cc +0 −9 Original line number Diff line number Diff line Loading @@ -229,15 +229,6 @@ handler *get_new_handler(TABLE *table, enum db_type db_type) } } bool ha_caching_allowed(THD* thd, char* table_key, uint key_length, uint8 cache_type) { #ifdef HAVE_INNOBASE_DB if (cache_type == HA_CACHE_TBL_ASKTRANSACT) return innobase_query_caching_of_table_permitted(thd, table_key, key_length); #endif return 1; } int ha_init() { Loading