|
18 | 18 | #endif
|
19 | 19 |
|
20 | 20 | #define MYSQL_SERVER 1
|
21 |
| -#include <my_global.h> |
22 | 21 | #include "mysql_version.h"
|
23 | 22 | #if MYSQL_VERSION_ID < 50500
|
24 | 23 | #include "mysql_priv.h"
|
|
28 | 27 | #include "probes_mysql.h"
|
29 | 28 | #include "sql_class.h"
|
30 | 29 | #include "key.h"
|
| 30 | +#ifdef HANDLER_HAS_DIRECT_AGGREGATE |
| 31 | +#include "sql_select.h" |
| 32 | +#endif |
31 | 33 | #endif
|
32 | 34 | #include "ha_partition.h"
|
33 | 35 | #include "spd_param.h"
|
@@ -92,7 +94,7 @@ ha_spider::ha_spider(
|
92 | 94 | mrr_key_buff = NULL;
|
93 | 95 | #endif
|
94 | 96 | append_tblnm_alias = NULL;
|
95 |
| - has_clone_for_merge = FALSE; |
| 97 | + use_index_merge = FALSE; |
96 | 98 | is_clone = FALSE;
|
97 | 99 | clone_bitmap_init = FALSE;
|
98 | 100 | pt_clone_source_handler = NULL;
|
@@ -162,6 +164,7 @@ ha_spider::ha_spider(
|
162 | 164 | result_list.direct_distinct = FALSE;
|
163 | 165 | result_list.casual_read = NULL;
|
164 | 166 | result_list.use_both_key = FALSE;
|
| 167 | + result_list.in_cmp_ref = FALSE; |
165 | 168 | DBUG_VOID_RETURN;
|
166 | 169 | }
|
167 | 170 |
|
@@ -199,7 +202,7 @@ ha_spider::ha_spider(
|
199 | 202 | mrr_key_buff = NULL;
|
200 | 203 | #endif
|
201 | 204 | append_tblnm_alias = NULL;
|
202 |
| - has_clone_for_merge = FALSE; |
| 205 | + use_index_merge = FALSE; |
203 | 206 | is_clone = FALSE;
|
204 | 207 | clone_bitmap_init = FALSE;
|
205 | 208 | pt_clone_source_handler = NULL;
|
@@ -269,6 +272,7 @@ ha_spider::ha_spider(
|
269 | 272 | result_list.direct_distinct = FALSE;
|
270 | 273 | result_list.casual_read = NULL;
|
271 | 274 | result_list.use_both_key = FALSE;
|
| 275 | + result_list.in_cmp_ref = FALSE; |
272 | 276 | ref_length = sizeof(SPIDER_POSITION);
|
273 | 277 | DBUG_VOID_RETURN;
|
274 | 278 | }
|
@@ -300,7 +304,7 @@ handler *ha_spider::clone(
|
300 | 304 | HA_OPEN_IGNORE_IF_LOCKED))
|
301 | 305 | DBUG_RETURN(NULL);
|
302 | 306 | spider->sync_from_clone_source_base(this);
|
303 |
| - has_clone_for_merge = TRUE; |
| 307 | + use_index_merge = TRUE; |
304 | 308 |
|
305 | 309 | DBUG_RETURN((handler *) spider);
|
306 | 310 | }
|
@@ -1735,7 +1739,8 @@ int ha_spider::reset()
|
1735 | 1739 | result_list.use_both_key = FALSE;
|
1736 | 1740 | pt_clone_last_searcher = NULL;
|
1737 | 1741 | conn_kinds = SPIDER_CONN_KIND_MYSQL;
|
1738 |
| - has_clone_for_merge = FALSE; |
| 1742 | + use_index_merge = FALSE; |
| 1743 | + init_rnd_handler = FALSE; |
1739 | 1744 | while (condition)
|
1740 | 1745 | {
|
1741 | 1746 | tmp_cond = condition->next;
|
@@ -1853,6 +1858,35 @@ int ha_spider::extra(
|
1853 | 1858 | if (!(trx = spider_get_trx(ha_thd(), TRUE, &error_num)))
|
1854 | 1859 | DBUG_RETURN(error_num);
|
1855 | 1860 | break;
|
| 1861 | +#endif |
| 1862 | +#ifdef HA_EXTRA_HAS_HA_EXTRA_USE_CMP_REF |
| 1863 | + case HA_EXTRA_USE_CMP_REF: |
| 1864 | + DBUG_PRINT("info",("spider HA_EXTRA_USE_CMP_REF")); |
| 1865 | + if (table_share->primary_key != MAX_KEY) |
| 1866 | + { |
| 1867 | + DBUG_PRINT("info",("spider need primary key columns")); |
| 1868 | + KEY *key_info = &table->key_info[table->s->primary_key]; |
| 1869 | + KEY_PART_INFO *key_part; |
| 1870 | + uint part_num; |
| 1871 | + for ( |
| 1872 | + key_part = key_info->key_part, part_num = 0; |
| 1873 | + part_num < spider_user_defined_key_parts(key_info); |
| 1874 | + key_part++, part_num++ |
| 1875 | + ) { |
| 1876 | + spider_set_bit(searched_bitmap, key_part->field->field_index); |
| 1877 | + } |
| 1878 | + } else { |
| 1879 | + DBUG_PRINT("info",("spider need all columns")); |
| 1880 | + Field **field; |
| 1881 | + for ( |
| 1882 | + field = table->field; |
| 1883 | + *field; |
| 1884 | + field++ |
| 1885 | + ) { |
| 1886 | + spider_set_bit(searched_bitmap, (*field)->field_index); |
| 1887 | + } |
| 1888 | + } |
| 1889 | + break; |
1856 | 1890 | #endif
|
1857 | 1891 | default:
|
1858 | 1892 | break;
|
@@ -4437,6 +4471,7 @@ int ha_spider::read_multi_range_first_internal(
|
4437 | 4471 | result_list.keyread = TRUE;
|
4438 | 4472 | else
|
4439 | 4473 | result_list.keyread = FALSE;
|
| 4474 | + mrr_with_cnt = FALSE; |
4440 | 4475 | if (
|
4441 | 4476 | (error_num = spider_db_append_select(this)) ||
|
4442 | 4477 | (error_num = spider_db_append_select_columns(this))
|
@@ -7649,6 +7684,7 @@ int ha_spider::cmp_ref(
|
7649 | 7684 | DBUG_PRINT("info",("spider this=%p", this));
|
7650 | 7685 | DBUG_PRINT("info",("spider ref1=%p", ref1));
|
7651 | 7686 | DBUG_PRINT("info",("spider ref2=%p", ref2));
|
| 7687 | + result_list.in_cmp_ref = TRUE; |
7652 | 7688 | if (table_share->primary_key < MAX_KEY)
|
7653 | 7689 | {
|
7654 | 7690 | uchar table_key[MAX_KEY_LENGTH];
|
@@ -7680,6 +7716,7 @@ int ha_spider::cmp_ref(
|
7680 | 7716 | }
|
7681 | 7717 | }
|
7682 | 7718 | }
|
| 7719 | + result_list.in_cmp_ref = FALSE; |
7683 | 7720 | DBUG_PRINT("info",("spider ret=%d", ret));
|
7684 | 7721 | DBUG_RETURN(ret);
|
7685 | 7722 | }
|
@@ -8685,7 +8722,7 @@ ha_rows ha_spider::records_in_range(
|
8685 | 8722 | key_part_map end_key_part_map;
|
8686 | 8723 | key_part_map tgt_key_part_map;
|
8687 | 8724 | KEY_PART_INFO *key_part;
|
8688 |
| - Field *field; |
| 8725 | + Field *field = NULL; |
8689 | 8726 | double rows = (double) share->records;
|
8690 | 8727 | double weight, rate;
|
8691 | 8728 | DBUG_PRINT("info",("spider rows1=%f", rows));
|
@@ -10967,7 +11004,11 @@ bool ha_spider::is_crashed() const
|
10967 | 11004 | DBUG_RETURN(FALSE);
|
10968 | 11005 | }
|
10969 | 11006 |
|
| 11007 | +#ifdef SPIDER_HANDLER_AUTO_REPAIR_HAS_ERROR |
| 11008 | +bool ha_spider::auto_repair(int error) const |
| 11009 | +#else |
10970 | 11010 | bool ha_spider::auto_repair() const
|
| 11011 | +#endif |
10971 | 11012 | {
|
10972 | 11013 | DBUG_ENTER("ha_spider::auto_repair");
|
10973 | 11014 | DBUG_PRINT("info",("spider this=%p", this));
|
@@ -11452,6 +11493,16 @@ TABLE *ha_spider::get_table()
|
11452 | 11493 | DBUG_RETURN(table);
|
11453 | 11494 | }
|
11454 | 11495 |
|
| 11496 | +TABLE *ha_spider::get_top_table() |
| 11497 | +{ |
| 11498 | + DBUG_ENTER("ha_spider::get_top_table"); |
| 11499 | +#ifdef HANDLER_HAS_TOP_TABLE_FIELDS |
| 11500 | + if (set_top_table_fields) |
| 11501 | + DBUG_RETURN(top_table); |
| 11502 | +#endif |
| 11503 | + DBUG_RETURN(table); |
| 11504 | +} |
| 11505 | + |
11455 | 11506 | void ha_spider::set_ft_discard_bitmap()
|
11456 | 11507 | {
|
11457 | 11508 | DBUG_ENTER("ha_spider::set_ft_discard_bitmap");
|
@@ -13819,6 +13870,18 @@ int ha_spider::append_key_order_for_merge_with_alias_sql_part(
|
13819 | 13870 | uint roop_count, dbton_id;
|
13820 | 13871 | spider_db_handler *dbton_hdl;
|
13821 | 13872 | DBUG_ENTER("ha_spider::append_key_order_for_merge_with_alias_sql_part");
|
| 13873 | +#ifdef HANDLER_HAS_DIRECT_AGGREGATE |
| 13874 | + if (result_list.direct_aggregate) |
| 13875 | + { |
| 13876 | + st_select_lex *select_lex = spider_get_select_lex(this); |
| 13877 | + ORDER *group = (ORDER *) select_lex->group_list.first; |
| 13878 | + if (!group && *(select_lex->join->sum_funcs)) |
| 13879 | + { |
| 13880 | + DBUG_PRINT("info",("spider skip order by")); |
| 13881 | + DBUG_RETURN(0); |
| 13882 | + } |
| 13883 | + } |
| 13884 | +#endif |
13822 | 13885 | for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++)
|
13823 | 13886 | {
|
13824 | 13887 | dbton_id = share->use_sql_dbton_ids[roop_count];
|
@@ -13868,6 +13931,18 @@ int ha_spider::append_key_order_with_alias_sql_part(
|
13868 | 13931 | uint roop_count, dbton_id;
|
13869 | 13932 | spider_db_handler *dbton_hdl;
|
13870 | 13933 | DBUG_ENTER("ha_spider::append_key_order_with_alias_sql_part");
|
| 13934 | +#ifdef HANDLER_HAS_DIRECT_AGGREGATE |
| 13935 | + if (result_list.direct_aggregate) |
| 13936 | + { |
| 13937 | + st_select_lex *select_lex = spider_get_select_lex(this); |
| 13938 | + ORDER *group = (ORDER *) select_lex->group_list.first; |
| 13939 | + if (!group && *(select_lex->join->sum_funcs)) |
| 13940 | + { |
| 13941 | + DBUG_PRINT("info",("spider skip order by")); |
| 13942 | + DBUG_RETURN(0); |
| 13943 | + } |
| 13944 | + } |
| 13945 | +#endif |
13871 | 13946 | for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++)
|
13872 | 13947 | {
|
13873 | 13948 | dbton_id = share->use_sql_dbton_ids[roop_count];
|
|
0 commit comments