From cf3b51b1d54f2daf7ca5dc6891be2832d8e9d3a1 Mon Sep 17 00:00:00 2001 From: Kentoku SHIBA Date: Fri, 20 Feb 2015 00:41:26 +0900 Subject: Merge Spider 3.2.18 --- storage/spider/ha_spider.cc | 87 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 81 insertions(+), 6 deletions(-) (limited to 'storage/spider/ha_spider.cc') diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 2944e750b88..40d5c0e8450 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -18,7 +18,6 @@ #endif #define MYSQL_SERVER 1 -#include #include "mysql_version.h" #if MYSQL_VERSION_ID < 50500 #include "mysql_priv.h" @@ -28,6 +27,9 @@ #include "probes_mysql.h" #include "sql_class.h" #include "key.h" +#ifdef HANDLER_HAS_DIRECT_AGGREGATE +#include "sql_select.h" +#endif #endif #include "ha_partition.h" #include "spd_param.h" @@ -92,7 +94,7 @@ ha_spider::ha_spider( mrr_key_buff = NULL; #endif append_tblnm_alias = NULL; - has_clone_for_merge = FALSE; + use_index_merge = FALSE; is_clone = FALSE; clone_bitmap_init = FALSE; pt_clone_source_handler = NULL; @@ -162,6 +164,7 @@ ha_spider::ha_spider( result_list.direct_distinct = FALSE; result_list.casual_read = NULL; result_list.use_both_key = FALSE; + result_list.in_cmp_ref = FALSE; DBUG_VOID_RETURN; } @@ -199,7 +202,7 @@ ha_spider::ha_spider( mrr_key_buff = NULL; #endif append_tblnm_alias = NULL; - has_clone_for_merge = FALSE; + use_index_merge = FALSE; is_clone = FALSE; clone_bitmap_init = FALSE; pt_clone_source_handler = NULL; @@ -269,6 +272,7 @@ ha_spider::ha_spider( result_list.direct_distinct = FALSE; result_list.casual_read = NULL; result_list.use_both_key = FALSE; + result_list.in_cmp_ref = FALSE; ref_length = sizeof(SPIDER_POSITION); DBUG_VOID_RETURN; } @@ -300,7 +304,7 @@ handler *ha_spider::clone( HA_OPEN_IGNORE_IF_LOCKED)) DBUG_RETURN(NULL); spider->sync_from_clone_source_base(this); - has_clone_for_merge = TRUE; + use_index_merge = TRUE; DBUG_RETURN((handler *) spider); } @@ -1735,7 +1739,8 @@ int ha_spider::reset() result_list.use_both_key = FALSE; pt_clone_last_searcher = NULL; conn_kinds = SPIDER_CONN_KIND_MYSQL; - has_clone_for_merge = FALSE; + use_index_merge = FALSE; + init_rnd_handler = FALSE; while (condition) { tmp_cond = condition->next; @@ -1853,6 +1858,35 @@ int ha_spider::extra( if (!(trx = spider_get_trx(ha_thd(), TRUE, &error_num))) DBUG_RETURN(error_num); break; +#endif +#ifdef HA_EXTRA_HAS_HA_EXTRA_USE_CMP_REF + case HA_EXTRA_USE_CMP_REF: + DBUG_PRINT("info",("spider HA_EXTRA_USE_CMP_REF")); + if (table_share->primary_key != MAX_KEY) + { + DBUG_PRINT("info",("spider need primary key columns")); + KEY *key_info = &table->key_info[table->s->primary_key]; + KEY_PART_INFO *key_part; + uint part_num; + for ( + key_part = key_info->key_part, part_num = 0; + part_num < spider_user_defined_key_parts(key_info); + key_part++, part_num++ + ) { + spider_set_bit(searched_bitmap, key_part->field->field_index); + } + } else { + DBUG_PRINT("info",("spider need all columns")); + Field **field; + for ( + field = table->field; + *field; + field++ + ) { + spider_set_bit(searched_bitmap, (*field)->field_index); + } + } + break; #endif default: break; @@ -4437,6 +4471,7 @@ int ha_spider::read_multi_range_first_internal( result_list.keyread = TRUE; else result_list.keyread = FALSE; + mrr_with_cnt = FALSE; if ( (error_num = spider_db_append_select(this)) || (error_num = spider_db_append_select_columns(this)) @@ -7649,6 +7684,7 @@ int ha_spider::cmp_ref( DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider ref1=%p", ref1)); DBUG_PRINT("info",("spider ref2=%p", ref2)); + result_list.in_cmp_ref = TRUE; if (table_share->primary_key < MAX_KEY) { uchar table_key[MAX_KEY_LENGTH]; @@ -7680,6 +7716,7 @@ int ha_spider::cmp_ref( } } } + result_list.in_cmp_ref = FALSE; DBUG_PRINT("info",("spider ret=%d", ret)); DBUG_RETURN(ret); } @@ -8685,7 +8722,7 @@ ha_rows ha_spider::records_in_range( key_part_map end_key_part_map; key_part_map tgt_key_part_map; KEY_PART_INFO *key_part; - Field *field; + Field *field = NULL; double rows = (double) share->records; double weight, rate; DBUG_PRINT("info",("spider rows1=%f", rows)); @@ -10967,7 +11004,11 @@ bool ha_spider::is_crashed() const DBUG_RETURN(FALSE); } +#ifdef SPIDER_HANDLER_AUTO_REPAIR_HAS_ERROR +bool ha_spider::auto_repair(int error) const +#else bool ha_spider::auto_repair() const +#endif { DBUG_ENTER("ha_spider::auto_repair"); DBUG_PRINT("info",("spider this=%p", this)); @@ -11452,6 +11493,16 @@ TABLE *ha_spider::get_table() DBUG_RETURN(table); } +TABLE *ha_spider::get_top_table() +{ + DBUG_ENTER("ha_spider::get_top_table"); +#ifdef HANDLER_HAS_TOP_TABLE_FIELDS + if (set_top_table_fields) + DBUG_RETURN(top_table); +#endif + DBUG_RETURN(table); +} + void ha_spider::set_ft_discard_bitmap() { DBUG_ENTER("ha_spider::set_ft_discard_bitmap"); @@ -13819,6 +13870,18 @@ int ha_spider::append_key_order_for_merge_with_alias_sql_part( uint roop_count, dbton_id; spider_db_handler *dbton_hdl; DBUG_ENTER("ha_spider::append_key_order_for_merge_with_alias_sql_part"); +#ifdef HANDLER_HAS_DIRECT_AGGREGATE + if (result_list.direct_aggregate) + { + st_select_lex *select_lex = spider_get_select_lex(this); + ORDER *group = (ORDER *) select_lex->group_list.first; + if (!group && *(select_lex->join->sum_funcs)) + { + DBUG_PRINT("info",("spider skip order by")); + DBUG_RETURN(0); + } + } +#endif for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) { dbton_id = share->use_sql_dbton_ids[roop_count]; @@ -13868,6 +13931,18 @@ int ha_spider::append_key_order_with_alias_sql_part( uint roop_count, dbton_id; spider_db_handler *dbton_hdl; DBUG_ENTER("ha_spider::append_key_order_with_alias_sql_part"); +#ifdef HANDLER_HAS_DIRECT_AGGREGATE + if (result_list.direct_aggregate) + { + st_select_lex *select_lex = spider_get_select_lex(this); + ORDER *group = (ORDER *) select_lex->group_list.first; + if (!group && *(select_lex->join->sum_funcs)) + { + DBUG_PRINT("info",("spider skip order by")); + DBUG_RETURN(0); + } + } +#endif for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++) { dbton_id = share->use_sql_dbton_ids[roop_count]; -- cgit v1.2.1