Skip to content

Commit cf3b51b

Browse files
committed
Merge Spider 3.2.18
1 parent 865b83e commit cf3b51b

20 files changed

+275
-65
lines changed

storage/spider/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_HANDLERSOCKET")
22
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_HANDLERSOCKET")
33

4+
IF(HAVE_WVLA)
5+
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-vla")
6+
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wno-vla")
7+
ENDIF()
8+
49
SET(SPIDER_SOURCES
510
spd_param.cc spd_sys_table.cc spd_trx.cc spd_db_conn.cc spd_conn.cc
611
spd_table.cc spd_direct_sql.cc spd_udf.cc spd_ping_table.cc

storage/spider/ha_spider.cc

Lines changed: 81 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#endif
1919

2020
#define MYSQL_SERVER 1
21-
#include <my_global.h>
2221
#include "mysql_version.h"
2322
#if MYSQL_VERSION_ID < 50500
2423
#include "mysql_priv.h"
@@ -28,6 +27,9 @@
2827
#include "probes_mysql.h"
2928
#include "sql_class.h"
3029
#include "key.h"
30+
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
31+
#include "sql_select.h"
32+
#endif
3133
#endif
3234
#include "ha_partition.h"
3335
#include "spd_param.h"
@@ -92,7 +94,7 @@ ha_spider::ha_spider(
9294
mrr_key_buff = NULL;
9395
#endif
9496
append_tblnm_alias = NULL;
95-
has_clone_for_merge = FALSE;
97+
use_index_merge = FALSE;
9698
is_clone = FALSE;
9799
clone_bitmap_init = FALSE;
98100
pt_clone_source_handler = NULL;
@@ -162,6 +164,7 @@ ha_spider::ha_spider(
162164
result_list.direct_distinct = FALSE;
163165
result_list.casual_read = NULL;
164166
result_list.use_both_key = FALSE;
167+
result_list.in_cmp_ref = FALSE;
165168
DBUG_VOID_RETURN;
166169
}
167170

@@ -199,7 +202,7 @@ ha_spider::ha_spider(
199202
mrr_key_buff = NULL;
200203
#endif
201204
append_tblnm_alias = NULL;
202-
has_clone_for_merge = FALSE;
205+
use_index_merge = FALSE;
203206
is_clone = FALSE;
204207
clone_bitmap_init = FALSE;
205208
pt_clone_source_handler = NULL;
@@ -269,6 +272,7 @@ ha_spider::ha_spider(
269272
result_list.direct_distinct = FALSE;
270273
result_list.casual_read = NULL;
271274
result_list.use_both_key = FALSE;
275+
result_list.in_cmp_ref = FALSE;
272276
ref_length = sizeof(SPIDER_POSITION);
273277
DBUG_VOID_RETURN;
274278
}
@@ -300,7 +304,7 @@ handler *ha_spider::clone(
300304
HA_OPEN_IGNORE_IF_LOCKED))
301305
DBUG_RETURN(NULL);
302306
spider->sync_from_clone_source_base(this);
303-
has_clone_for_merge = TRUE;
307+
use_index_merge = TRUE;
304308

305309
DBUG_RETURN((handler *) spider);
306310
}
@@ -1735,7 +1739,8 @@ int ha_spider::reset()
17351739
result_list.use_both_key = FALSE;
17361740
pt_clone_last_searcher = NULL;
17371741
conn_kinds = SPIDER_CONN_KIND_MYSQL;
1738-
has_clone_for_merge = FALSE;
1742+
use_index_merge = FALSE;
1743+
init_rnd_handler = FALSE;
17391744
while (condition)
17401745
{
17411746
tmp_cond = condition->next;
@@ -1853,6 +1858,35 @@ int ha_spider::extra(
18531858
if (!(trx = spider_get_trx(ha_thd(), TRUE, &error_num)))
18541859
DBUG_RETURN(error_num);
18551860
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;
18561890
#endif
18571891
default:
18581892
break;
@@ -4437,6 +4471,7 @@ int ha_spider::read_multi_range_first_internal(
44374471
result_list.keyread = TRUE;
44384472
else
44394473
result_list.keyread = FALSE;
4474+
mrr_with_cnt = FALSE;
44404475
if (
44414476
(error_num = spider_db_append_select(this)) ||
44424477
(error_num = spider_db_append_select_columns(this))
@@ -7649,6 +7684,7 @@ int ha_spider::cmp_ref(
76497684
DBUG_PRINT("info",("spider this=%p", this));
76507685
DBUG_PRINT("info",("spider ref1=%p", ref1));
76517686
DBUG_PRINT("info",("spider ref2=%p", ref2));
7687+
result_list.in_cmp_ref = TRUE;
76527688
if (table_share->primary_key < MAX_KEY)
76537689
{
76547690
uchar table_key[MAX_KEY_LENGTH];
@@ -7680,6 +7716,7 @@ int ha_spider::cmp_ref(
76807716
}
76817717
}
76827718
}
7719+
result_list.in_cmp_ref = FALSE;
76837720
DBUG_PRINT("info",("spider ret=%d", ret));
76847721
DBUG_RETURN(ret);
76857722
}
@@ -8685,7 +8722,7 @@ ha_rows ha_spider::records_in_range(
86858722
key_part_map end_key_part_map;
86868723
key_part_map tgt_key_part_map;
86878724
KEY_PART_INFO *key_part;
8688-
Field *field;
8725+
Field *field = NULL;
86898726
double rows = (double) share->records;
86908727
double weight, rate;
86918728
DBUG_PRINT("info",("spider rows1=%f", rows));
@@ -10967,7 +11004,11 @@ bool ha_spider::is_crashed() const
1096711004
DBUG_RETURN(FALSE);
1096811005
}
1096911006

11007+
#ifdef SPIDER_HANDLER_AUTO_REPAIR_HAS_ERROR
11008+
bool ha_spider::auto_repair(int error) const
11009+
#else
1097011010
bool ha_spider::auto_repair() const
11011+
#endif
1097111012
{
1097211013
DBUG_ENTER("ha_spider::auto_repair");
1097311014
DBUG_PRINT("info",("spider this=%p", this));
@@ -11452,6 +11493,16 @@ TABLE *ha_spider::get_table()
1145211493
DBUG_RETURN(table);
1145311494
}
1145411495

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+
1145511506
void ha_spider::set_ft_discard_bitmap()
1145611507
{
1145711508
DBUG_ENTER("ha_spider::set_ft_discard_bitmap");
@@ -13819,6 +13870,18 @@ int ha_spider::append_key_order_for_merge_with_alias_sql_part(
1381913870
uint roop_count, dbton_id;
1382013871
spider_db_handler *dbton_hdl;
1382113872
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
1382213885
for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++)
1382313886
{
1382413887
dbton_id = share->use_sql_dbton_ids[roop_count];
@@ -13868,6 +13931,18 @@ int ha_spider::append_key_order_with_alias_sql_part(
1386813931
uint roop_count, dbton_id;
1386913932
spider_db_handler *dbton_hdl;
1387013933
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
1387113946
for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++)
1387213947
{
1387313948
dbton_id = share->use_sql_dbton_ids[roop_count];

storage/spider/ha_spider.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class ha_spider: public handler
125125
bool clone_bitmap_init;
126126
ha_spider *pt_clone_source_handler;
127127
ha_spider *pt_clone_last_searcher;
128-
bool has_clone_for_merge;
128+
bool use_index_merge;
129129

130130
bool init_index_handler;
131131
bool init_rnd_handler;
@@ -682,7 +682,11 @@ class ha_spider: public handler
682682
const char *name
683683
);
684684
bool is_crashed() const;
685+
#ifdef SPIDER_HANDLER_AUTO_REPAIR_HAS_ERROR
686+
bool auto_repair(int error) const;
687+
#else
685688
bool auto_repair() const;
689+
#endif
686690
int disable_indexes(
687691
uint mode
688692
);
@@ -730,6 +734,7 @@ class ha_spider: public handler
730734
void return_record_by_parent();
731735
#endif
732736
TABLE *get_table();
737+
TABLE *get_top_table();
733738
void set_ft_discard_bitmap();
734739
void set_searched_bitmap();
735740
void set_clone_searched_bitmap();

storage/spider/spd_conn.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
1515

1616
#define MYSQL_SERVER 1
17-
#include <my_global.h>
1817
#include "mysql_version.h"
1918
#if MYSQL_VERSION_ID < 50500
2019
#include "mysql_priv.h"

storage/spider/spd_copy_tables.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
1515

1616
#define MYSQL_SERVER 1
17-
#include <my_global.h>
1817
#include "mysql_version.h"
1918
#if MYSQL_VERSION_ID < 50500
2019
#include "mysql_priv.h"

0 commit comments

Comments
 (0)