summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKentoku SHIBA <kentokushiba@gmail.com>2015-10-29 07:34:53 +0900
committerKentoku SHIBA <kentokushiba@gmail.com>2015-10-29 07:34:53 +0900
commit14eea2f8c25078dcb8d803d9fc6b67e92f065d38 (patch)
tree231c856af438dcc93bb6c7f89fdac14ef8dc69f1
parentd4dd936bd75b1c46f2868a963bb07549d783d9f0 (diff)
downloadmariadb-git-14eea2f8c25078dcb8d803d9fc6b67e92f065d38.tar.gz
merge spider-3.2.37
-rw-r--r--storage/spider/ha_spider.cc151
-rw-r--r--storage/spider/ha_spider.h3
-rw-r--r--storage/spider/spd_conn.cc49
-rw-r--r--storage/spider/spd_conn.h6
-rw-r--r--storage/spider/spd_copy_tables.cc73
-rw-r--r--storage/spider/spd_db_conn.cc177
-rw-r--r--storage/spider/spd_db_conn.h37
-rw-r--r--storage/spider/spd_db_handlersocket.cc155
-rw-r--r--storage/spider/spd_db_include.h8
-rw-r--r--storage/spider/spd_db_mysql.cc199
-rw-r--r--storage/spider/spd_db_oracle.cc176
-rw-r--r--storage/spider/spd_direct_sql.cc13
-rw-r--r--storage/spider/spd_err.h2
-rw-r--r--storage/spider/spd_include.h36
-rw-r--r--storage/spider/spd_malloc.cc14
-rw-r--r--storage/spider/spd_param.cc26
-rw-r--r--storage/spider/spd_param.h3
-rw-r--r--storage/spider/spd_ping_table.cc127
-rw-r--r--storage/spider/spd_ping_table.h1
-rw-r--r--storage/spider/spd_sys_table.cc24
-rw-r--r--storage/spider/spd_table.cc361
-rw-r--r--storage/spider/spd_table.h7
-rw-r--r--storage/spider/spd_trx.cc100
23 files changed, 1462 insertions, 286 deletions
diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc
index b4602e5aa4f..877e2621f5f 100644
--- a/storage/spider/ha_spider.cc
+++ b/storage/spider/ha_spider.cc
@@ -1315,6 +1315,7 @@ int ha_spider::external_lock(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -1367,6 +1368,7 @@ int ha_spider::external_lock(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -1398,6 +1400,7 @@ int ha_spider::external_lock(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -1432,6 +1435,7 @@ int ha_spider::external_lock(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -1586,6 +1590,13 @@ int ha_spider::reset()
{
delete direct_aggregate_item_current->item;
direct_aggregate_item_current->item = NULL;
+#ifdef SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY_AND_THDPTR
+ if (direct_aggregate_item_current->init_mem_root)
+ {
+ free_root(&direct_aggregate_item_current->mem_root, MYF(0));
+ direct_aggregate_item_current->init_mem_root = FALSE;
+ }
+#endif
}
direct_aggregate_item_current = direct_aggregate_item_current->next;
}
@@ -1681,6 +1692,7 @@ int ha_spider::reset()
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -2215,6 +2227,7 @@ int ha_spider::index_read_map_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -2297,6 +2310,7 @@ int ha_spider::index_read_map_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -2329,6 +2343,7 @@ int ha_spider::index_read_map_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -2358,6 +2373,7 @@ int ha_spider::index_read_map_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -2702,6 +2718,7 @@ int ha_spider::index_read_last_map_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -2781,6 +2798,7 @@ int ha_spider::index_read_last_map_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -2813,6 +2831,7 @@ int ha_spider::index_read_last_map_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -2842,6 +2861,7 @@ int ha_spider::index_read_last_map_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -3163,6 +3183,7 @@ int ha_spider::index_first_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -3243,6 +3264,7 @@ int ha_spider::index_first_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -3275,6 +3297,7 @@ int ha_spider::index_first_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -3304,6 +3327,7 @@ int ha_spider::index_first_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -3542,6 +3566,7 @@ int ha_spider::index_last_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -3622,6 +3647,7 @@ int ha_spider::index_last_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -3654,6 +3680,7 @@ int ha_spider::index_last_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -3683,6 +3710,7 @@ int ha_spider::index_last_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -3981,6 +4009,7 @@ int ha_spider::read_range_first_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -4060,6 +4089,7 @@ int ha_spider::read_range_first_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -4092,6 +4122,7 @@ int ha_spider::read_range_first_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -4121,6 +4152,7 @@ int ha_spider::read_range_first_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -4605,6 +4637,7 @@ int ha_spider::read_multi_range_first_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -4689,6 +4722,7 @@ int ha_spider::read_multi_range_first_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -4722,6 +4756,7 @@ int ha_spider::read_multi_range_first_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -4753,6 +4788,7 @@ int ha_spider::read_multi_range_first_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -4787,6 +4823,8 @@ int ha_spider::read_multi_range_first_internal(
DBUG_PRINT("info",
("spider result_list.current->finish_flg = FALSE"));
result_list.current->finish_flg = FALSE;
+ spider_db_free_one_result(&result_list,
+ (SPIDER_RESULT *) result_list.current);
if (result_list.current == result_list.first)
result_list.current = NULL;
else
@@ -4821,6 +4859,8 @@ int ha_spider::read_multi_range_first_internal(
DBUG_PRINT("info",
("spider result_list.current->finish_flg = FALSE"));
result_list.current->finish_flg = FALSE;
+ spider_db_free_one_result(&result_list,
+ (SPIDER_RESULT *) result_list.current);
if (result_list.current == result_list.first)
result_list.current = NULL;
else
@@ -5388,6 +5428,7 @@ int ha_spider::read_multi_range_first_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -5475,6 +5516,7 @@ int ha_spider::read_multi_range_first_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -5514,6 +5556,7 @@ int ha_spider::read_multi_range_first_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -5548,6 +5591,7 @@ int ha_spider::read_multi_range_first_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -5577,6 +5621,7 @@ int ha_spider::read_multi_range_first_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -5632,6 +5677,8 @@ int ha_spider::read_multi_range_first_internal(
DBUG_PRINT("info",
("spider result_list.current->finish_flg = FALSE"));
result_list.current->finish_flg = FALSE;
+ spider_db_free_one_result(&result_list,
+ (SPIDER_RESULT *) result_list.current);
if (result_list.current == result_list.first)
result_list.current = NULL;
else
@@ -5691,6 +5738,8 @@ int ha_spider::read_multi_range_first_internal(
DBUG_PRINT("info",
("spider result_list.current->finish_flg = FALSE"));
result_list.current->finish_flg = FALSE;
+ spider_db_free_one_result(&result_list,
+ (SPIDER_RESULT *) result_list.current);
if (result_list.current == result_list.first)
result_list.current = NULL;
else
@@ -6028,6 +6077,7 @@ int ha_spider::read_multi_range_next(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -6112,6 +6162,7 @@ int ha_spider::read_multi_range_next(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -6145,6 +6196,7 @@ int ha_spider::read_multi_range_next(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -6176,6 +6228,7 @@ int ha_spider::read_multi_range_next(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -6212,6 +6265,8 @@ int ha_spider::read_multi_range_next(
DBUG_PRINT("info",
("spider result_list.current->finish_flg = FALSE"));
result_list.current->finish_flg = FALSE;
+ spider_db_free_one_result(&result_list,
+ (SPIDER_RESULT *) result_list.current);
result_list.current = result_list.current->prev;
}
} else
@@ -6241,6 +6296,8 @@ int ha_spider::read_multi_range_next(
DBUG_PRINT("info",
("spider result_list.current->finish_flg = FALSE"));
result_list.current->finish_flg = FALSE;
+ spider_db_free_one_result(&result_list,
+ (SPIDER_RESULT *) result_list.current);
result_list.current = result_list.current->prev;
}
} else
@@ -6815,6 +6872,7 @@ int ha_spider::read_multi_range_next(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -6902,6 +6960,7 @@ int ha_spider::read_multi_range_next(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -6941,6 +7000,7 @@ int ha_spider::read_multi_range_next(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -6975,6 +7035,7 @@ int ha_spider::read_multi_range_next(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7004,6 +7065,7 @@ int ha_spider::read_multi_range_next(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7059,6 +7121,8 @@ int ha_spider::read_multi_range_next(
DBUG_PRINT("info",
("spider result_list.current->finish_flg = FALSE"));
result_list.current->finish_flg = FALSE;
+ spider_db_free_one_result(&result_list,
+ (SPIDER_RESULT *) result_list.current);
if (result_list.current == result_list.first)
result_list.current = NULL;
else
@@ -7112,6 +7176,8 @@ int ha_spider::read_multi_range_next(
DBUG_PRINT("info",
("spider result_list.current->finish_flg = FALSE"));
result_list.current->finish_flg = FALSE;
+ spider_db_free_one_result(&result_list,
+ (SPIDER_RESULT *) result_list.current);
if (result_list.current == result_list.first)
result_list.current = NULL;
else
@@ -7436,6 +7502,7 @@ int ha_spider::rnd_next_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7494,6 +7561,7 @@ int ha_spider::rnd_next_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7526,6 +7594,7 @@ int ha_spider::rnd_next_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7555,6 +7624,7 @@ int ha_spider::rnd_next_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7663,6 +7733,15 @@ int ha_spider::rnd_pos(
) {
DBUG_ENTER("ha_spider::rnd_pos");
DBUG_PRINT("info",("spider this=%p", this));
+#ifndef DBUG_OFF
+ for (uint roop_count = 0; roop_count < ((table->s->fields + 7) / 8);
+ roop_count++)
+ {
+ DBUG_PRINT("info",("spider roop_count=%d", roop_count));
+ DBUG_PRINT("info",("spider read_set=%d",
+ ((uchar *) table->read_set->bitmap)[roop_count]));
+ }
+#endif
if (trx->thd->killed)
{
my_error(ER_QUERY_INTERRUPTED, MYF(0));
@@ -8021,6 +8100,7 @@ int ha_spider::ft_read_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -8073,6 +8153,7 @@ int ha_spider::ft_read_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -8104,6 +8185,7 @@ int ha_spider::ft_read_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -8133,6 +8215,7 @@ int ha_spider::ft_read_internal(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -8337,6 +8420,7 @@ int ha_spider::info(
if ((error_num = spider_check_trx_and_get_conn(ha_thd(), this,
FALSE)))
{
+ pthread_mutex_unlock(&share->sts_mutex);
if (!share->sts_init)
{
if (
@@ -8391,6 +8475,7 @@ int ha_spider::info(
0,
share->monitoring_kind[search_link_idx],
share->monitoring_limit[search_link_idx],
+ share->monitoring_flag[search_link_idx],
TRUE
);
}
@@ -8660,6 +8745,7 @@ ha_rows ha_spider::records_in_range(
0,
share->monitoring_kind[search_link_idx],
share->monitoring_limit[search_link_idx],
+ share->monitoring_flag[search_link_idx],
TRUE
);
}
@@ -8950,6 +9036,7 @@ int ha_spider::check_crd()
0,
share->monitoring_kind[search_link_idx],
share->monitoring_limit[search_link_idx],
+ share->monitoring_flag[search_link_idx],
TRUE
);
}
@@ -9100,6 +9187,9 @@ ulonglong ha_spider::table_flags() const
HA_BINLOG_ROW_CAPABLE |
HA_BINLOG_STMT_CAPABLE |
HA_PARTIAL_COLUMN_READ |
+#ifdef SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON
+ HA_CAN_TABLE_CONDITION_PUSHDOWN |
+#endif
#ifdef HA_CAN_BULK_ACCESS
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
(support_bulk_access_hs() ? HA_CAN_BULK_ACCESS : 0) |
@@ -9535,7 +9625,12 @@ int ha_spider::write_row(
DBUG_RETURN(check_error_mode(error_num));
if (bulk_insert)
bulk_size =
- insert_with_update || (!direct_dup_insert && ignore_dup_key) ?
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
+ (insert_with_update && !result_list.insert_dup_update_pushdown) ||
+#else
+ insert_with_update ||
+#endif
+ (!direct_dup_insert && ignore_dup_key) ?
0 : spider_param_bulk_size(trx->thd, share->bulk_size);
else
bulk_size = 0;
@@ -9809,9 +9904,12 @@ int ha_spider::direct_update_rows_init(
#if MYSQL_VERSION_ID < 50500
!thd->variables.engine_condition_pushdown ||
#else
+#ifdef SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON
+#else
!(thd->variables.optimizer_switch &
OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) ||
#endif
+#endif
!select_lex ||
select_lex->table_list.elements != 1 ||
check_update_columns_sql_part() ||
@@ -10101,9 +10199,12 @@ int ha_spider::direct_delete_rows_init(
#if MYSQL_VERSION_ID < 50500
!thd->variables.engine_condition_pushdown ||
#else
+#ifdef SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON
+#else
!(thd->variables.optimizer_switch &
OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) ||
#endif
+#endif
!select_lex ||
select_lex->table_list.elements != 1 ||
spider_db_append_condition(this, NULL, 0, TRUE)
@@ -10769,8 +10870,15 @@ int ha_spider::rename_table(
{
if (alter_table_from->tmp_link_statuses[roop_count] <=
SPIDER_LINK_STATUS_NO_CHANGE)
+ {
+ DBUG_PRINT("info",("spider copy %d", roop_count));
alter_table_from->tmp_link_statuses[roop_count] =
alter_table_to->tmp_link_statuses[roop_count];
+ }
+ DBUG_PRINT("info",("spider link_status_from[%d]=%ld", roop_count,
+ alter_table_from->tmp_link_statuses[roop_count]));
+ DBUG_PRINT("info",("spider link_status_to[%d]=%ld", roop_count,
+ alter_table_to->tmp_link_statuses[roop_count]));
}
}
@@ -11668,6 +11776,38 @@ void ha_spider::set_clone_searched_bitmap()
DBUG_VOID_RETURN;
}
+void ha_spider::set_searched_bitmap_from_item_list()
+{
+ DBUG_ENTER("ha_spider::set_searched_bitmap_from_item_list");
+ Field *field;
+ Item *item, *item_next;
+ THD *thd = ha_thd();
+ Statement *stmt = thd->stmt_map.find(thd->id);
+ if (stmt && stmt->free_list)
+ {
+ DBUG_PRINT("info",("spider item from stmt"));
+ item_next = stmt->free_list;
+ } else {
+ DBUG_PRINT("info",("spider item from thd"));
+ item_next = thd->free_list;
+ }
+ while ((item = item_next))
+ {
+ DBUG_PRINT("info",("spider item=%p", item));
+ DBUG_PRINT("info",("spider itemtype=%u", item->type()));
+ item_next = item->next;
+ if (item->type() != Item::FIELD_ITEM)
+ continue;
+ field = ((Item_field *) item)->field;
+ DBUG_PRINT("info",("spider field=%p", field));
+ if (!field || !(field = field_exchange(field)))
+ continue;
+ DBUG_PRINT("info",("spider field_index=%u", field->field_index));
+ spider_set_bit(searched_bitmap, field->field_index);
+ }
+ DBUG_VOID_RETURN;
+}
+
void ha_spider::set_select_column_mode()
{
int roop_count;
@@ -11687,6 +11827,7 @@ void ha_spider::set_select_column_mode()
share->select_column_mode);
if (select_column_mode)
{
+ DBUG_PRINT("info",("spider searched_bitmap=%p", searched_bitmap));
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (
partition_handler_share &&
@@ -11704,6 +11845,7 @@ void ha_spider::set_select_column_mode()
} else {
#endif
set_searched_bitmap();
+ set_searched_bitmap_from_item_list();
if (result_list.lock_type == F_WRLCK && sql_command != SQLCOM_SELECT)
{
#ifdef WITH_PARTITION_STORAGE_ENGINE
@@ -12040,6 +12182,7 @@ int ha_spider::drop_tmp_tables()
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -12074,6 +12217,7 @@ int ha_spider::drop_tmp_tables()
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -12192,6 +12336,7 @@ int ha_spider::close_opened_handler(
0,
share->monitoring_kind[link_idx],
share->monitoring_limit[link_idx],
+ share->monitoring_flag[link_idx],
TRUE
);
}
@@ -12226,6 +12371,7 @@ int ha_spider::close_opened_handler(
0,
share->monitoring_kind[link_idx],
share->monitoring_limit[link_idx],
+ share->monitoring_flag[link_idx],
TRUE
);
}
@@ -12266,6 +12412,7 @@ int ha_spider::close_opened_handler(
0,
share->monitoring_kind[link_idx],
share->monitoring_limit[link_idx],
+ share->monitoring_flag[link_idx],
TRUE
);
}
@@ -12366,6 +12513,7 @@ int ha_spider::index_handler_init()
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -12471,6 +12619,7 @@ int ha_spider::rnd_handler_init()
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h
index 0c81bef1773..e528b0e8a91 100644
--- a/storage/spider/ha_spider.h
+++ b/storage/spider/ha_spider.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2014 Kentoku Shiba
+/* Copyright (C) 2008-2015 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -738,6 +738,7 @@ public:
void set_ft_discard_bitmap();
void set_searched_bitmap();
void set_clone_searched_bitmap();
+ void set_searched_bitmap_from_item_list();
void set_select_column_mode();
#ifdef WITH_PARTITION_STORAGE_ENGINE
void check_select_column(bool rnd);
diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc
index e19222c99f6..293a209ac68 100644
--- a/storage/spider/spd_conn.cc
+++ b/storage/spider/spd_conn.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2014 Kentoku Shiba
+/* Copyright (C) 2008-2015 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -662,6 +662,7 @@ SPIDER_CONN *spider_create_conn(
spider_conn_queue_connect(share, conn, link_idx);
conn->ping_time = (time_t) time((time_t*) 0);
+ conn->connect_error_time = conn->ping_time;
pthread_mutex_lock(&spider_conn_id_mutex);
conn->conn_id = spider_conn_id;
++spider_conn_id;
@@ -1085,6 +1086,17 @@ SPIDER_CONN *spider_get_conn(
}
conn->link_idx = base_link_idx;
+ if (conn->queued_connect)
+ spider_conn_queue_connect_rewrite(share, conn, link_idx);
+
+ if (conn->queued_ping)
+ {
+ if (spider)
+ spider_conn_queue_ping_rewrite(spider, conn, base_link_idx);
+ else
+ conn->queued_ping = FALSE;
+ }
+
DBUG_PRINT("info",("spider conn=%p", conn));
DBUG_RETURN(conn);
@@ -1195,8 +1207,10 @@ void spider_conn_queue_connect(
DBUG_ENTER("spider_conn_queue_connect");
DBUG_PRINT("info", ("spider conn=%p", conn));
conn->queued_connect = TRUE;
+/*
conn->queued_connect_share = share;
conn->queued_connect_link_idx = link_idx;
+*/
DBUG_VOID_RETURN;
}
@@ -1225,6 +1239,18 @@ void spider_conn_queue_ping(
DBUG_VOID_RETURN;
}
+void spider_conn_queue_ping_rewrite(
+ ha_spider *spider,
+ SPIDER_CONN *conn,
+ int link_idx
+) {
+ DBUG_ENTER("spider_conn_queue_ping_rewrite");
+ DBUG_PRINT("info", ("spider conn=%p", conn));
+ conn->queued_ping_spider = spider;
+ conn->queued_ping_link_idx = link_idx;
+ DBUG_VOID_RETURN;
+}
+
void spider_conn_queue_trx_isolation(
SPIDER_CONN *conn,
int trx_isolation
@@ -1285,6 +1311,7 @@ void spider_conn_queue_start_transaction(
) {
DBUG_ENTER("spider_conn_queue_start_transaction");
DBUG_PRINT("info", ("spider conn=%p", conn));
+ DBUG_ASSERT(!conn->trx_start);
conn->queued_trx_start = TRUE;
conn->trx_start = TRUE;
DBUG_VOID_RETURN;
@@ -1325,7 +1352,11 @@ void spider_conn_clear_queue_at_commit(
) {
DBUG_ENTER("spider_conn_clear_queue_at_commit");
DBUG_PRINT("info", ("spider conn=%p", conn));
- conn->queued_trx_start = FALSE;
+ if (conn->queued_trx_start)
+ {
+ conn->queued_trx_start = FALSE;
+ conn->trx_start = FALSE;
+ }
conn->queued_xa_start = FALSE;
DBUG_VOID_RETURN;
}
@@ -2280,6 +2311,13 @@ void *spider_bg_conn_action(
thd->clear_error();
pthread_cond_wait(&conn->bg_conn_cond, &conn->bg_conn_mutex);
DBUG_PRINT("info",("spider bg roop start"));
+#ifndef DBUG_OFF
+ DBUG_PRINT("info",("spider conn->thd=%p", conn->thd));
+ if (conn->thd)
+ {
+ DBUG_PRINT("info",("spider query_id=%lld", conn->thd->query_id));
+ }
+#endif
if (conn->bg_caller_sync_wait)
{
pthread_mutex_lock(&conn->bg_conn_sync_mutex);
@@ -2925,6 +2963,7 @@ void *spider_bg_sts_action(
0,
share->monitoring_kind[spider.search_link_idx],
share->monitoring_limit[spider.search_link_idx],
+ share->monitoring_flag[spider.search_link_idx],
TRUE
);
lex_end(thd->lex);
@@ -2934,6 +2973,7 @@ void *spider_bg_sts_action(
}
if (spider.search_link_idx != -1 && conns[spider.search_link_idx])
{
+ DBUG_ASSERT(!conns[spider.search_link_idx]->thd);
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (spider_get_sts(share, spider.search_link_idx,
share->bg_sts_try_time, &spider,
@@ -2965,6 +3005,7 @@ void *spider_bg_sts_action(
0,
share->monitoring_kind[spider.search_link_idx],
share->monitoring_limit[spider.search_link_idx],
+ share->monitoring_flag[spider.search_link_idx],
TRUE
);
lex_end(thd->lex);
@@ -3317,6 +3358,7 @@ void *spider_bg_crd_action(
0,
share->monitoring_kind[spider.search_link_idx],
share->monitoring_limit[spider.search_link_idx],
+ share->monitoring_flag[spider.search_link_idx],
TRUE
);
lex_end(thd->lex);
@@ -3326,6 +3368,7 @@ void *spider_bg_crd_action(
}
if (spider.search_link_idx != -1 && conns[spider.search_link_idx])
{
+ DBUG_ASSERT(!conns[spider.search_link_idx]->thd);
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (spider_get_crd(share, spider.search_link_idx,
share->bg_crd_try_time, &spider, &table,
@@ -3357,6 +3400,7 @@ void *spider_bg_crd_action(
0,
share->monitoring_kind[spider.search_link_idx],
share->monitoring_limit[spider.search_link_idx],
+ share->monitoring_flag[spider.search_link_idx],
TRUE
);
lex_end(thd->lex);
@@ -3714,6 +3758,7 @@ void *spider_bg_mon_action(
0,
share->monitoring_bg_kind[link_idx],
share->monitoring_limit[link_idx],
+ share->monitoring_bg_flag[link_idx],
TRUE
);
lex_end(thd->lex);
diff --git a/storage/spider/spd_conn.h b/storage/spider/spd_conn.h
index 99a6f1a48e8..610a0359378 100644
--- a/storage/spider/spd_conn.h
+++ b/storage/spider/spd_conn.h
@@ -100,6 +100,12 @@ void spider_conn_queue_ping(
int link_idx
);
+void spider_conn_queue_ping_rewrite(
+ ha_spider *spider,
+ SPIDER_CONN *conn,
+ int link_idx
+);
+
void spider_conn_queue_trx_isolation(
SPIDER_CONN *conn,
int trx_isolation
diff --git a/storage/spider/spd_copy_tables.cc b/storage/spider/spd_copy_tables.cc
index 10fed696134..c01549f8e99 100644
--- a/storage/spider/spd_copy_tables.cc
+++ b/storage/spider/spd_copy_tables.cc
@@ -1032,36 +1032,47 @@ long long spider_copy_tables_body(
else
copy_tables->access_charset = system_charset_info;
- src_tbl_conn = copy_tables->table_conn[0];
- select_ct = src_tbl_conn->copy_table;
- src_tbl_conn->share->access_charset = copy_tables->access_charset;
- select_ct->set_sql_charset(copy_tables->access_charset);
- if (
- select_ct->append_select_str() ||
- select_ct->append_table_columns(table_share)
- ) {
- my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
- goto error;
- }
+ bulk_insert_rows = spider_param_udf_ct_bulk_insert_rows(
+ copy_tables->bulk_insert_rows);
+ for (src_tbl_conn = copy_tables->table_conn[0]; src_tbl_conn;
+ src_tbl_conn = src_tbl_conn->next)
+ {
+ select_ct = src_tbl_conn->copy_table;
+ src_tbl_conn->share->access_charset = copy_tables->access_charset;
+ select_ct->set_sql_charset(copy_tables->access_charset);
+ if (
+ select_ct->append_select_str() ||
+ select_ct->append_table_columns(table_share)
+ ) {
+ my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
+ goto error;
+ }
- if (
- select_ct->append_from_str() ||
- select_ct->append_table_name(0)
- ) {
- my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
- goto error;
- }
+ if (
+ select_ct->append_from_str() ||
+ select_ct->append_table_name(0)
+ ) {
+ my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
+ goto error;
+ }
- select_ct->set_sql_pos();
+ select_ct->set_sql_pos();
- bulk_insert_rows = spider_param_udf_ct_bulk_insert_rows(
- copy_tables->bulk_insert_rows);
- if (
- select_ct->append_key_order_str(key_info, 0, FALSE) ||
- select_ct->append_limit(0, bulk_insert_rows)
- ) {
- my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
- goto error;
+ if (
+ select_ct->append_key_order_str(key_info, 0, FALSE) ||
+ select_ct->append_limit(0, bulk_insert_rows)
+ ) {
+ my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
+ goto error;
+ }
+
+ if (
+ copy_tables->use_transaction &&
+ select_ct->append_select_lock_str(SPIDER_LOCK_MODE_SHARED)
+ ) {
+ my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
+ goto error;
+ }
}
for (dst_tbl_conn = copy_tables->table_conn[1]; dst_tbl_conn;
@@ -1188,14 +1199,6 @@ long long spider_copy_tables_body(
table_conn->spider = tmp_spider;
}
- if (
- copy_tables->use_transaction &&
- select_ct->append_select_lock_str(SPIDER_LOCK_MODE_SHARED)
- ) {
- my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
- goto error;
- }
-
if ((error_num = spider_db_udf_copy_tables(copy_tables, spider, table,
bulk_insert_rows)))
goto error_db_udf_copy_tables;
diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc
index 30ad38eceb0..9f46e55ca09 100644
--- a/storage/spider/spd_db_conn.cc
+++ b/storage/spider/spd_db_conn.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2014 Kentoku Shiba
+/* Copyright (C) 2008-2015 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -85,6 +85,30 @@ int spider_db_connect(
DBUG_ENTER("spider_db_connect");
DBUG_ASSERT(conn->conn_kind != SPIDER_CONN_KIND_MYSQL || conn->need_mon);
DBUG_PRINT("info",("spider link_idx=%d", link_idx));
+ DBUG_PRINT("info",("spider conn=%p", conn));
+
+ if (conn->connect_error)
+ {
+ time_t tmp_time = (time_t) time((time_t*) 0);
+ DBUG_PRINT("info",("spider diff=%f",
+ difftime(tmp_time, conn->connect_error_time)));
+ if (
+ (
+ conn->thd &&
+ conn->thd == conn->connect_error_thd &&
+ conn->thd->query_id == conn->connect_error_query_id
+ ) ||
+ (
+ difftime(tmp_time, conn->connect_error_time) <
+ spider_param_connect_error_interval()
+ )
+ ) {
+ DBUG_PRINT("info",("spider set same error"));
+ if (conn->connect_error_with_message)
+ my_message(conn->connect_error, conn->connect_error_msg, MYF(0));
+ DBUG_RETURN(conn->connect_error);
+ }
+ }
if (thd)
{
@@ -151,8 +175,18 @@ int spider_db_connect(
share->server_names[link_idx],
connect_retry_count, connect_retry_interval)))
{
+ if (conn->thd)
+ {
+ conn->connect_error_thd = conn->thd;
+ conn->connect_error_query_id = conn->thd->query_id;
+ conn->connect_error_time = (time_t) time((time_t*) 0);
+ conn->connect_error = error_num;
+ if ((conn->connect_error_with_message = thd->is_error()))
+ strmov(conn->connect_error_msg, spider_stmt_da_message(thd));
+ }
DBUG_RETURN(error_num);
}
+ conn->connect_error = 0;
conn->opened_handlers = 0;
conn->db_conn->reset_opened_handler();
++conn->connection_id;
@@ -924,6 +958,7 @@ int spider_db_query_with_set_names(
0,
share->monitoring_kind[link_idx],
share->monitoring_limit[link_idx],
+ share->monitoring_flag[link_idx],
TRUE
);
}
@@ -956,6 +991,7 @@ int spider_db_query_with_set_names(
0,
share->monitoring_kind[link_idx],
share->monitoring_limit[link_idx],
+ share->monitoring_flag[link_idx],
TRUE
);
}
@@ -1007,6 +1043,7 @@ int spider_db_query_for_bulk_update(
0,
share->monitoring_kind[link_idx],
share->monitoring_limit[link_idx],
+ share->monitoring_flag[link_idx],
TRUE
);
}
@@ -1043,6 +1080,7 @@ int spider_db_query_for_bulk_update(
0,
share->monitoring_kind[link_idx],
share->monitoring_limit[link_idx],
+ share->monitoring_flag[link_idx],
TRUE
);
}
@@ -1086,6 +1124,7 @@ int spider_db_query_for_bulk_update(
0,
share->monitoring_kind[link_idx],
share->monitoring_limit[link_idx],
+ share->monitoring_flag[link_idx],
TRUE
);
}
@@ -1599,8 +1638,9 @@ int spider_db_append_key_where_internal(
full_key_part_map = 0;
if (start_key)
+ {
start_key_part_map = start_key->keypart_map & full_key_part_map;
- else {
+ } else {
start_key_part_map = 0;
use_both = FALSE;
}
@@ -1635,8 +1675,10 @@ int spider_db_append_key_where_internal(
DBUG_RETURN(error_num);
}
dbton_hdl->set_order_pos(SPIDER_SQL_TYPE_HANDLER);
- if (start_key_part_map || end_key_part_map)
- {
+ if (
+ (start_key_part_map || end_key_part_map) &&
+ !(use_both && (!start_key_part_map || !end_key_part_map))
+ ) {
if (str_part->reserve(SPIDER_SQL_OPEN_PAREN_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str_part->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
@@ -1655,8 +1697,14 @@ int spider_db_append_key_where_internal(
}
}
if (!start_key_part_map && !end_key_part_map)
+ {
+ result_list->key_order = 0;
+ goto end;
+ } else if (use_both && (!start_key_part_map || !end_key_part_map))
+ {
+ result_list->key_order = 0;
goto end;
- else if (start_key_part_map >= end_key_part_map)
+ } else if (start_key_part_map >= end_key_part_map)
{
use_key = start_key;
another_key = end_key;
@@ -2544,6 +2592,9 @@ int spider_db_fetch_for_item_sum_func(
spider->direct_aggregate_item_first->next = NULL;
spider->direct_aggregate_item_first->item = NULL;
spider->direct_aggregate_item_first->tgt_num = 0;
+#ifdef SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY_AND_THDPTR
+ spider->direct_aggregate_item_first->init_mem_root = FALSE;
+#endif
}
spider->direct_aggregate_item_current =
spider->direct_aggregate_item_first;
@@ -2560,16 +2611,33 @@ int spider_db_fetch_for_item_sum_func(
spider->direct_aggregate_item_current->next->item = NULL;
spider->direct_aggregate_item_current->next->tgt_num =
spider->direct_aggregate_item_current->tgt_num + 1;
+#ifdef SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY_AND_THDPTR
+ spider->direct_aggregate_item_current->next->init_mem_root = FALSE;
+#endif
}
spider->direct_aggregate_item_current =
spider->direct_aggregate_item_current->next;
}
if (!spider->direct_aggregate_item_current->item)
{
+#ifdef SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY_AND_THDPTR
+ if (!spider->direct_aggregate_item_current->init_mem_root)
+ {
+ SPD_INIT_ALLOC_ROOT(
+ &spider->direct_aggregate_item_current->mem_root,
+ 4096, 0, MYF(MY_WME));
+ spider->direct_aggregate_item_current->init_mem_root = TRUE;
+ }
+#endif
Item *free_list = thd->free_list;
spider->direct_aggregate_item_current->item =
#ifdef SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY
+#ifdef SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY_AND_THDPTR
+ new (&spider->direct_aggregate_item_current->mem_root)
+ Item_string(thd, "", 0, share->access_charset);
+#else
new Item_string("", 0, share->access_charset);
+#endif
#else
new Item_string(share->access_charset);
#endif
@@ -4330,6 +4398,7 @@ int spider_db_seek_next(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -4363,6 +4432,7 @@ int spider_db_seek_next(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -4394,6 +4464,7 @@ int spider_db_seek_next(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -4575,6 +4646,7 @@ int spider_db_seek_last(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -4607,6 +4679,7 @@ int spider_db_seek_last(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -4636,6 +4709,7 @@ int spider_db_seek_last(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -4772,6 +4846,7 @@ int spider_db_seek_last(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -4804,6 +4879,7 @@ int spider_db_seek_last(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -4833,6 +4909,7 @@ int spider_db_seek_last(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -5434,6 +5511,7 @@ int spider_db_bulk_insert_init(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -5603,6 +5681,7 @@ int spider_db_bulk_insert(
0,
share->monitoring_kind[roop_count2],
share->monitoring_limit[roop_count2],
+ share->monitoring_flag[roop_count2],
TRUE
);
}
@@ -5651,6 +5730,7 @@ int spider_db_bulk_insert(
0,
share->monitoring_kind[roop_count2],
share->monitoring_limit[roop_count2],
+ share->monitoring_flag[roop_count2],
TRUE
);
}
@@ -6296,6 +6376,7 @@ int spider_db_update(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -6331,6 +6412,7 @@ int spider_db_update(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -6382,6 +6464,7 @@ int spider_db_update(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -6622,6 +6705,7 @@ int spider_db_direct_update(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -6660,6 +6744,7 @@ int spider_db_direct_update(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7048,6 +7133,7 @@ int spider_db_direct_delete(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7080,6 +7166,7 @@ int spider_db_direct_delete(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7237,6 +7324,7 @@ int spider_db_delete_all_rows(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7264,6 +7352,7 @@ int spider_db_delete_all_rows(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7296,6 +7385,7 @@ int spider_db_delete_all_rows(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7322,6 +7412,7 @@ int spider_db_delete_all_rows(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7379,6 +7470,7 @@ int spider_db_disable_keys(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7430,6 +7522,7 @@ int spider_db_enable_keys(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7482,6 +7575,7 @@ int spider_db_check_table(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7534,6 +7628,7 @@ int spider_db_repair_table(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7585,6 +7680,7 @@ int spider_db_analyze_table(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7636,6 +7732,7 @@ int spider_db_optimize_table(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7684,6 +7781,7 @@ int spider_db_flush_tables(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7730,6 +7828,7 @@ int spider_db_flush_logs(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -7782,8 +7881,14 @@ int spider_db_print_item_type(
case Item::CACHE_ITEM:
DBUG_RETURN(spider_db_open_item_cache((Item_cache *)item, spider, str,
alias, alias_length, dbton_id));
+ case Item::INSERT_VALUE_ITEM:
+ DBUG_RETURN(spider_db_open_item_insert_value((Item_insert_value *)item, spider, str,
+ alias, alias_length, dbton_id));
case Item::SUBSELECT_ITEM:
case Item::TRIGGER_FIELD_ITEM:
+#ifdef SPIDER_HAS_EXPR_CACHE_ITEM
+ case Item::EXPR_CACHE_ITEM:
+#endif
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
default:
THD *thd = spider->trx->thd;
@@ -8129,8 +8234,8 @@ int spider_db_open_item_string(
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
tmp_str.mem_calc();
str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
+ str->append_escape_string(tmp_str2->ptr(), tmp_str2->length());
if (
- str->append_for_single_quote(tmp_str2) ||
str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN)
)
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
@@ -8246,6 +8351,38 @@ int spider_db_open_item_cache(
alias, alias_length, dbton_id));
}
+int spider_db_open_item_insert_value(
+ Item_insert_value *item_insert_value,
+ ha_spider *spider,
+ spider_string *str,
+ const char *alias,
+ uint alias_length,
+ uint dbton_id
+) {
+ int error_num;
+ DBUG_ENTER("spider_db_open_item_insert_value");
+ if (item_insert_value->arg)
+ {
+ if (str)
+ {
+ if (str->reserve(SPIDER_SQL_VALUES_LEN + SPIDER_SQL_OPEN_PAREN_LEN))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(SPIDER_SQL_VALUES_STR, SPIDER_SQL_VALUES_LEN);
+ str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
+ }
+ if ((error_num = spider_db_print_item_type(item_insert_value->arg, spider,
+ str, alias, alias_length, dbton_id)))
+ DBUG_RETURN(error_num);
+ if (str)
+ {
+ if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN);
+ }
+ }
+ DBUG_RETURN(0);
+}
+
int spider_db_append_condition(
ha_spider *spider,
const char *alias,
@@ -8288,6 +8425,7 @@ int spider_db_append_update_columns(
uint dbton_id
) {
int error_num;
+ bool add_comma = FALSE;
List_iterator_fast<Item> fi(*spider->direct_update_fields),
vi(*spider->direct_update_values);
Item *field, *value;
@@ -8302,8 +8440,10 @@ int spider_db_append_update_columns(
error_num == ER_SPIDER_COND_SKIP_NUM &&
field->type() == Item::FIELD_ITEM &&
((Item_field *) field)->field
- )
+ ) {
+ DBUG_PRINT("info",("spider no match field(ex. vp child table)"));
continue;
+ }
DBUG_RETURN(error_num);
}
if (str)
@@ -8320,9 +8460,10 @@ int spider_db_append_update_columns(
if (str->reserve(SPIDER_SQL_COMMA_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
+ add_comma = TRUE;
}
}
- if (str)
+ if (str && add_comma)
str->length(str->length() - SPIDER_SQL_COMMA_LEN);
DBUG_RETURN(0);
}
@@ -9136,6 +9277,11 @@ int spider_db_udf_ping_table(
pthread_mutex_unlock(&conn->mta_conn_mutex);
table_mon_list->last_mon_result = error_num;
pthread_mutex_unlock(&table_mon_list->monitor_mutex);
+ if (error_num == ER_CON_COUNT_ERROR)
+ {
+ my_error(ER_CON_COUNT_ERROR, MYF(0));
+ DBUG_RETURN(ER_CON_COUNT_ERROR);
+ }
my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0),
share->server_names[0]);
DBUG_RETURN(ER_CONNECT_TO_FOREIGN_DATA_SOURCE);
@@ -9277,7 +9423,7 @@ int spider_db_udf_ping_table_append_mon_next(
str->q_append(SPIDER_SQL_SELECT_STR, SPIDER_SQL_SELECT_LEN);
str->q_append(SPIDER_SQL_PING_TABLE_STR, SPIDER_SQL_PING_TABLE_LEN);
str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
- str->append_for_single_quote(child_table_name_str.get_str());
+ str->append_escape_string(child_table_name_str.ptr(), child_table_name_str.length());
str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
str->qs_append(link_id);
@@ -9287,7 +9433,7 @@ int spider_db_udf_ping_table_append_mon_next(
str->q_append(limit_str, limit_str_length);
str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
- str->append_for_single_quote(where_clause_str.get_str());
+ str->append_escape_string(where_clause_str.ptr(), where_clause_str.length());
str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
str->q_append(sid_str, sid_str_length);
@@ -9338,11 +9484,10 @@ int spider_db_udf_ping_table_append_select(
SPIDER_SQL_LIMIT_LEN + limit_str_length
))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
- if (
- use_where &&
- str->append_for_single_quote(where_str->get_str())
- )
- DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ if (use_where)
+ {
+ str->append_escape_string(where_str->ptr(), where_str->length());
+ }
str->q_append(SPIDER_SQL_LIMIT_STR, SPIDER_SQL_LIMIT_LEN);
str->q_append(limit_str, limit_str_length);
DBUG_RETURN(0);
@@ -9730,7 +9875,7 @@ int spider_db_udf_copy_tables(
}
}
- if (!error_num)
+ if (!error_num && roop_count)
{
/*
dst_tbl_conn = copy_tables->table_conn[1];
diff --git a/storage/spider/spd_db_conn.h b/storage/spider/spd_db_conn.h
index 3f77c96b99f..8626d6a47ec 100644
--- a/storage/spider/spd_db_conn.h
+++ b/storage/spider/spd_db_conn.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2014 Kentoku Shiba
+/* Copyright (C) 2008-2015 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -93,7 +93,7 @@
#define SPIDER_SQL_LIMIT_LEN (sizeof(SPIDER_SQL_LIMIT_STR) - 1)
#define SPIDER_SQL_INTO_STR "into "
#define SPIDER_SQL_INTO_LEN (sizeof(SPIDER_SQL_INTO_STR) - 1)
-#define SPIDER_SQL_VALUES_STR ")values"
+#define SPIDER_SQL_VALUES_STR "values"
#define SPIDER_SQL_VALUES_LEN (sizeof(SPIDER_SQL_VALUES_STR) - 1)
#define SPIDER_SQL_SHARED_LOCK_STR " lock in share mode"
#define SPIDER_SQL_SHARED_LOCK_LEN (sizeof(SPIDER_SQL_SHARED_LOCK_STR) - 1)
@@ -197,6 +197,25 @@
#define SPIDER_SQL_MINUS_STR " - "
#define SPIDER_SQL_MINUS_LEN (sizeof(SPIDER_SQL_MINUS_STR) - 1)
+#define SPIDER_SQL_YEAR_STR "year"
+#define SPIDER_SQL_YEAR_LEN (sizeof(SPIDER_SQL_YEAR_STR) - 1)
+#define SPIDER_SQL_QUARTER_STR "quarter"
+#define SPIDER_SQL_QUARTER_LEN (sizeof(SPIDER_SQL_QUARTER_STR) - 1)
+#define SPIDER_SQL_MONTH_STR "month"
+#define SPIDER_SQL_MONTH_LEN (sizeof(SPIDER_SQL_MONTH_STR) - 1)
+#define SPIDER_SQL_WEEK_STR "week"
+#define SPIDER_SQL_WEEK_LEN (sizeof(SPIDER_SQL_WEEK_STR) - 1)
+#define SPIDER_SQL_DAY_STR "day"
+#define SPIDER_SQL_DAY_LEN (sizeof(SPIDER_SQL_DAY_STR) - 1)
+#define SPIDER_SQL_HOUR_STR "hour"
+#define SPIDER_SQL_HOUR_LEN (sizeof(SPIDER_SQL_HOUR_STR) - 1)
+#define SPIDER_SQL_MINUTE_STR "minute"
+#define SPIDER_SQL_MINUTE_LEN (sizeof(SPIDER_SQL_MINUTE_STR) - 1)
+#define SPIDER_SQL_SECOND_STR "second"
+#define SPIDER_SQL_SECOND_LEN (sizeof(SPIDER_SQL_SECOND_STR) - 1)
+#define SPIDER_SQL_MICROSECOND_STR "microsecond"
+#define SPIDER_SQL_MICROSECOND_LEN (sizeof(SPIDER_SQL_MICROSECOND_STR) - 1)
+
#define SPIDER_SQL_SHOW_RECORDS_STR "select count(*) from "
#define SPIDER_SQL_SHOW_RECORDS_LEN sizeof(SPIDER_SQL_SHOW_RECORDS_STR) - 1
#define SPIDER_SQL_SHOW_INDEX_STR "show index from "
@@ -234,8 +253,9 @@
#define SPIDER_SQL_INT_LEN 20
#define SPIDER_SQL_HANDLER_CID_LEN 6
#define SPIDER_SQL_HANDLER_CID_FORMAT "t%05u"
-#define SPIDER_UDF_PING_TABLE_PING_ONLY (1 << 0)
-#define SPIDER_UDF_PING_TABLE_USE_WHERE (1 << 1)
+#define SPIDER_UDF_PING_TABLE_PING_ONLY (1 << 0)
+#define SPIDER_UDF_PING_TABLE_USE_WHERE (1 << 1)
+#define SPIDER_UDF_PING_TABLE_USE_ALL_MONITORING_NODES (1 << 2)
int spider_db_connect(
const SPIDER_SHARE *share,
@@ -887,6 +907,15 @@ int spider_db_open_item_cache(
uint dbton_id
);
+int spider_db_open_item_insert_value(
+ Item_insert_value *item_insert_value,
+ ha_spider *spider,
+ spider_string *str,
+ const char *alias,
+ uint alias_length,
+ uint dbton_id
+);
+
int spider_db_append_condition(
ha_spider *spider,
const char *alias,
diff --git a/storage/spider/spd_db_handlersocket.cc b/storage/spider/spd_db_handlersocket.cc
index 9d0b05855d5..2ae84499aff 100644
--- a/storage/spider/spd_db_handlersocket.cc
+++ b/storage/spider/spd_db_handlersocket.cc
@@ -2786,7 +2786,11 @@ int spider_db_handlersocket_util::open_item_func(
{
if (
!strncasecmp("rand", func_name, func_name_length) &&
+#ifdef SPIDER_Item_args_arg_count_IS_PROTECTED
+ !item_func->argument_count()
+#else
!item_func->arg_count
+#endif
) {
if (str)
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
@@ -2946,13 +2950,99 @@ int spider_db_handlersocket_util::open_item_func(
last_str_length = SPIDER_SQL_AS_TIME_LEN;
break;
}
- } else if (func_name_length == 13 &&
- !strncasecmp("utc_timestamp", func_name, func_name_length)
- ) {
- if (str)
- str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
- DBUG_RETURN(spider_db_open_item_string(item_func, spider, str,
- alias, alias_length, dbton_id));
+ } else if (func_name_length == 13)
+ {
+ if (!strncasecmp("utc_timestamp", func_name, func_name_length))
+ {
+ if (str)
+ str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
+ DBUG_RETURN(spider_db_open_item_string(item_func, spider, str,
+ alias, alias_length, dbton_id));
+ } else if (!strncasecmp("timestampdiff", func_name, func_name_length))
+ {
+#ifdef ITEM_FUNC_TIMESTAMPDIFF_ARE_PUBLIC
+ Item_func_timestamp_diff *item_func_timestamp_diff =
+ (Item_func_timestamp_diff *) item_func;
+ if (str)
+ {
+ const char *interval_str;
+ uint interval_len;
+ switch (item_func_timestamp_diff->int_type)
+ {
+ case INTERVAL_YEAR:
+ interval_str = SPIDER_SQL_YEAR_STR;
+ interval_len = SPIDER_SQL_YEAR_LEN;
+ break;
+ case INTERVAL_QUARTER:
+ interval_str = SPIDER_SQL_QUARTER_STR;
+ interval_len = SPIDER_SQL_QUARTER_LEN;
+ break;
+ case INTERVAL_MONTH:
+ interval_str = SPIDER_SQL_MONTH_STR;
+ interval_len = SPIDER_SQL_MONTH_LEN;
+ break;
+ case INTERVAL_WEEK:
+ interval_str = SPIDER_SQL_WEEK_STR;
+ interval_len = SPIDER_SQL_WEEK_LEN;
+ break;
+ case INTERVAL_DAY:
+ interval_str = SPIDER_SQL_DAY_STR;
+ interval_len = SPIDER_SQL_DAY_LEN;
+ break;
+ case INTERVAL_HOUR:
+ interval_str = SPIDER_SQL_HOUR_STR;
+ interval_len = SPIDER_SQL_HOUR_LEN;
+ break;
+ case INTERVAL_MINUTE:
+ interval_str = SPIDER_SQL_MINUTE_STR;
+ interval_len = SPIDER_SQL_MINUTE_LEN;
+ break;
+ case INTERVAL_SECOND:
+ interval_str = SPIDER_SQL_SECOND_STR;
+ interval_len = SPIDER_SQL_SECOND_LEN;
+ break;
+ case INTERVAL_MICROSECOND:
+ interval_str = SPIDER_SQL_MICROSECOND_STR;
+ interval_len = SPIDER_SQL_MICROSECOND_LEN;
+ break;
+ default:
+ interval_str = "";
+ interval_len = 0;
+ break;
+ }
+ str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
+ if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN +
+ interval_len + SPIDER_SQL_COMMA_LEN))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(func_name, func_name_length);
+ str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
+ str->q_append(interval_str, interval_len);
+ str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
+ }
+ if ((error_num = spider_db_print_item_type(item_list[0], spider,
+ str, alias, alias_length, dbton_id)))
+ DBUG_RETURN(error_num);
+ if (str)
+ {
+ if (str->reserve(SPIDER_SQL_COMMA_LEN))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
+ }
+ if ((error_num = spider_db_print_item_type(item_list[1], spider,
+ str, alias, alias_length, dbton_id)))
+ DBUG_RETURN(error_num);
+ if (str)
+ {
+ if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(SPIDER_SQL_CLOSE_PAREN_STR,
+ SPIDER_SQL_CLOSE_PAREN_LEN);
+ }
+ DBUG_RETURN(0);
+#else
+ DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
+#endif
+ }
} else if (func_name_length == 14)
{
if (!strncasecmp("cast_as_binary", func_name, func_name_length))
@@ -3142,6 +3232,54 @@ int spider_db_handlersocket_util::open_item_func(
}
break;
case Item_func::NOT_FUNC:
+ DBUG_PRINT("info",("spider NOT_FUNC"));
+ if (item_list[0]->type() == Item::COND_ITEM)
+ {
+ DBUG_PRINT("info",("spider item_list[0] is COND_ITEM"));
+ Item_cond *item_cond = (Item_cond *) item_list[0];
+ if (item_cond->functype() == Item_func::COND_AND_FUNC)
+ {
+ DBUG_PRINT("info",("spider item_cond is COND_AND_FUNC"));
+ List_iterator_fast<Item> lif(*(item_cond->argument_list()));
+ bool has_expr_cache_item = FALSE;
+ bool has_isnotnull_func = FALSE;
+ bool has_other_item = FALSE;
+ while((item = lif++))
+ {
+ if (
+ item->type() == Item::EXPR_CACHE_ITEM
+ ) {
+ DBUG_PRINT("info",("spider EXPR_CACHE_ITEM"));
+ has_expr_cache_item = TRUE;
+ } else if (
+ item->type() == Item::FUNC_ITEM &&
+ ((Item_func *) item)->functype() == Item_func::ISNOTNULL_FUNC
+ ) {
+ DBUG_PRINT("info",("spider ISNOTNULL_FUNC"));
+ has_isnotnull_func = TRUE;
+ } else {
+ DBUG_PRINT("info",("spider has other item"));
+ DBUG_PRINT("info",("spider COND type=%d", item->type()));
+ has_other_item = TRUE;
+ }
+ }
+ if (has_expr_cache_item && has_isnotnull_func && !has_other_item)
+ {
+ DBUG_PRINT("info",("spider NOT EXISTS skip"));
+ DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
+ }
+ }
+ }
+ if (str)
+ {
+ func_name = (char*) item_func->func_name();
+ func_name_length = strlen(func_name);
+ if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(func_name, func_name_length);
+ str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN);
+ }
+ break;
case Item_func::NEG_FUNC:
if (str)
{
@@ -3494,8 +3632,7 @@ int spider_db_handlersocket_util::append_escaped_util(
) {
DBUG_ENTER("spider_db_handlersocket_util::append_escaped_util");
DBUG_PRINT("info",("spider this=%p", this));
- if (to->append_for_single_quote(from))
- DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ to->append_escape_string(from->ptr(), from->length());
DBUG_RETURN(0);
}
diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h
index c70995ec007..56dbc9ce0dc 100644
--- a/storage/spider/spd_db_include.h
+++ b/storage/spider/spd_db_include.h
@@ -25,6 +25,7 @@
#define SPIDER_HAS_APPEND_FOR_SINGLE_QUOTE
#define SPIDER_HAS_SHOW_SIMPLE_FUNC
#define SPIDER_HAS_JT_HASH_INDEX_MERGE
+#define SPIDER_HAS_EXPR_CACHE_ITEM
#else
#define SPIDER_NEED_CHECK_CONDITION_AT_CHECKING_DIRECT_ORDER_LIMIT
#endif
@@ -41,6 +42,9 @@
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100014
#define SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100100
+#define SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY_AND_THDPTR
+#endif
#endif
#if defined(MARIADB_BASE_VERSION)
@@ -501,6 +505,10 @@ public:
uint32 arg_length,
uint32 step_alloc
);
+ void append_escape_string(
+ const char *st,
+ uint len
+ );
bool append_for_single_quote(
const char *st,
uint len
diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc
index 1b40265e9b6..22aef83c7d4 100644
--- a/storage/spider/spd_db_mysql.cc
+++ b/storage/spider/spd_db_mysql.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2012-2014 Kentoku Shiba
+/* Copyright (C) 2012-2015 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1596,6 +1596,12 @@ int spider_db_mysql::connect(
) ||
!connect_retry_count
) {
+ if (error_num == ER_CON_COUNT_ERROR)
+ {
+ *conn->need_mon = 0;
+ my_error(ER_CON_COUNT_ERROR, MYF(0));
+ DBUG_RETURN(ER_CON_COUNT_ERROR);
+ }
*conn->need_mon = ER_CONNECT_TO_FOREIGN_DATA_SOURCE;
my_error(ER_CONNECT_TO_FOREIGN_DATA_SOURCE, MYF(0),
server_name ? server_name : tgt_host);
@@ -3289,7 +3295,11 @@ int spider_db_mysql_util::open_item_func(
{
if (
!strncasecmp("rand", func_name, func_name_length) &&
+#ifdef SPIDER_Item_args_arg_count_IS_PROTECTED
+ !item_func->argument_count()
+#else
!item_func->arg_count
+#endif
) {
if (str)
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
@@ -3449,13 +3459,99 @@ int spider_db_mysql_util::open_item_func(
last_str_length = SPIDER_SQL_AS_TIME_LEN;
break;
}
- } else if (func_name_length == 13 &&
- !strncasecmp("utc_timestamp", func_name, func_name_length)
- ) {
- if (str)
- str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
- DBUG_RETURN(spider_db_open_item_string(item_func, spider, str,
- alias, alias_length, dbton_id));
+ } else if (func_name_length == 13)
+ {
+ if (!strncasecmp("utc_timestamp", func_name, func_name_length))
+ {
+ if (str)
+ str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
+ DBUG_RETURN(spider_db_open_item_string(item_func, spider, str,
+ alias, alias_length, dbton_id));
+ } else if (!strncasecmp("timestampdiff", func_name, func_name_length))
+ {
+#ifdef ITEM_FUNC_TIMESTAMPDIFF_ARE_PUBLIC
+ Item_func_timestamp_diff *item_func_timestamp_diff =
+ (Item_func_timestamp_diff *) item_func;
+ if (str)
+ {
+ const char *interval_str;
+ uint interval_len;
+ switch (item_func_timestamp_diff->int_type)
+ {
+ case INTERVAL_YEAR:
+ interval_str = SPIDER_SQL_YEAR_STR;
+ interval_len = SPIDER_SQL_YEAR_LEN;
+ break;
+ case INTERVAL_QUARTER:
+ interval_str = SPIDER_SQL_QUARTER_STR;
+ interval_len = SPIDER_SQL_QUARTER_LEN;
+ break;
+ case INTERVAL_MONTH:
+ interval_str = SPIDER_SQL_MONTH_STR;
+ interval_len = SPIDER_SQL_MONTH_LEN;
+ break;
+ case INTERVAL_WEEK:
+ interval_str = SPIDER_SQL_WEEK_STR;
+ interval_len = SPIDER_SQL_WEEK_LEN;
+ break;
+ case INTERVAL_DAY:
+ interval_str = SPIDER_SQL_DAY_STR;
+ interval_len = SPIDER_SQL_DAY_LEN;
+ break;
+ case INTERVAL_HOUR:
+ interval_str = SPIDER_SQL_HOUR_STR;
+ interval_len = SPIDER_SQL_HOUR_LEN;
+ break;
+ case INTERVAL_MINUTE:
+ interval_str = SPIDER_SQL_MINUTE_STR;
+ interval_len = SPIDER_SQL_MINUTE_LEN;
+ break;
+ case INTERVAL_SECOND:
+ interval_str = SPIDER_SQL_SECOND_STR;
+ interval_len = SPIDER_SQL_SECOND_LEN;
+ break;
+ case INTERVAL_MICROSECOND:
+ interval_str = SPIDER_SQL_MICROSECOND_STR;
+ interval_len = SPIDER_SQL_MICROSECOND_LEN;
+ break;
+ default:
+ interval_str = "";
+ interval_len = 0;
+ break;
+ }
+ str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
+ if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN +
+ interval_len + SPIDER_SQL_COMMA_LEN))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(func_name, func_name_length);
+ str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
+ str->q_append(interval_str, interval_len);
+ str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
+ }
+ if ((error_num = spider_db_print_item_type(item_list[0], spider,
+ str, alias, alias_length, dbton_id)))
+ DBUG_RETURN(error_num);
+ if (str)
+ {
+ if (str->reserve(SPIDER_SQL_COMMA_LEN))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
+ }
+ if ((error_num = spider_db_print_item_type(item_list[1], spider,
+ str, alias, alias_length, dbton_id)))
+ DBUG_RETURN(error_num);
+ if (str)
+ {
+ if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(SPIDER_SQL_CLOSE_PAREN_STR,
+ SPIDER_SQL_CLOSE_PAREN_LEN);
+ }
+ DBUG_RETURN(0);
+#else
+ DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
+#endif
+ }
} else if (func_name_length == 14)
{
if (!strncasecmp("cast_as_binary", func_name, func_name_length))
@@ -3645,6 +3741,54 @@ int spider_db_mysql_util::open_item_func(
}
break;
case Item_func::NOT_FUNC:
+ DBUG_PRINT("info",("spider NOT_FUNC"));
+ if (item_list[0]->type() == Item::COND_ITEM)
+ {
+ DBUG_PRINT("info",("spider item_list[0] is COND_ITEM"));
+ Item_cond *item_cond = (Item_cond *) item_list[0];
+ if (item_cond->functype() == Item_func::COND_AND_FUNC)
+ {
+ DBUG_PRINT("info",("spider item_cond is COND_AND_FUNC"));
+ List_iterator_fast<Item> lif(*(item_cond->argument_list()));
+ bool has_expr_cache_item = FALSE;
+ bool has_isnotnull_func = FALSE;
+ bool has_other_item = FALSE;
+ while((item = lif++))
+ {
+ if (
+ item->type() == Item::EXPR_CACHE_ITEM
+ ) {
+ DBUG_PRINT("info",("spider EXPR_CACHE_ITEM"));
+ has_expr_cache_item = TRUE;
+ } else if (
+ item->type() == Item::FUNC_ITEM &&
+ ((Item_func *) item)->functype() == Item_func::ISNOTNULL_FUNC
+ ) {
+ DBUG_PRINT("info",("spider ISNOTNULL_FUNC"));
+ has_isnotnull_func = TRUE;
+ } else {
+ DBUG_PRINT("info",("spider has other item"));
+ DBUG_PRINT("info",("spider COND type=%d", item->type()));
+ has_other_item = TRUE;
+ }
+ }
+ if (has_expr_cache_item && has_isnotnull_func && !has_other_item)
+ {
+ DBUG_PRINT("info",("spider NOT EXISTS skip"));
+ DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
+ }
+ }
+ }
+ if (str)
+ {
+ func_name = (char*) item_func->func_name();
+ func_name_length = strlen(func_name);
+ if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(func_name, func_name_length);
+ str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN);
+ }
+ break;
case Item_func::NEG_FUNC:
if (str)
{
@@ -3997,8 +4141,9 @@ int spider_db_mysql_util::append_escaped_util(
) {
DBUG_ENTER("spider_db_mysql_util::append_escaped_util");
DBUG_PRINT("info",("spider this=%p", this));
- if (to->append_for_single_quote(from))
- DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ DBUG_PRINT("info",("spider from=%s", from->charset()->csname));
+ DBUG_PRINT("info",("spider to=%s", to->charset()->csname));
+ to->append_escape_string(from->ptr(), from->length());
DBUG_RETURN(0);
}
@@ -4834,7 +4979,6 @@ int spider_mysql_share::discover_table_structure(
conn->need_mon = &need_mon;
conn->mta_conn_mutex_lock_already = TRUE;
conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_queue_connect_rewrite(spider_share, conn, roop_count);
spider_conn_set_timeout_from_share(conn, roop_count, trx->thd,
spider_share);
if (
@@ -5513,8 +5657,10 @@ int spider_mysql_handler::append_insert_tmp_bka_table(
str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
if ((error_num = spider_db_append_key_columns(start_key, spider, str)))
DBUG_RETURN(error_num);
- if (str->reserve(SPIDER_SQL_VALUES_LEN + SPIDER_SQL_OPEN_PAREN_LEN))
+ if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN + SPIDER_SQL_VALUES_LEN +
+ SPIDER_SQL_OPEN_PAREN_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN);
str->q_append(SPIDER_SQL_VALUES_STR, SPIDER_SQL_VALUES_LEN);
str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
DBUG_RETURN(0);
@@ -5663,8 +5809,10 @@ int spider_mysql_handler::append_insert_for_recovery(
}
if (field_name_length)
insert_sql->length(insert_sql->length() - SPIDER_SQL_COMMA_LEN);
- if (insert_sql->reserve(SPIDER_SQL_VALUES_LEN + SPIDER_SQL_OPEN_PAREN_LEN))
+ if (insert_sql->reserve(SPIDER_SQL_CLOSE_PAREN_LEN + SPIDER_SQL_VALUES_LEN +
+ SPIDER_SQL_OPEN_PAREN_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ insert_sql->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN);
insert_sql->q_append(SPIDER_SQL_VALUES_STR, SPIDER_SQL_VALUES_LEN);
insert_sql->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
for (field = table->field; *field; field++)
@@ -5879,7 +6027,11 @@ int spider_mysql_handler::append_insert(
spider->ignore_dup_key &&
spider->direct_dup_insert &&
!spider->write_can_replace &&
+#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
+ (!spider->insert_with_update || !dup_update_sql.length()) &&
+#else
!spider->insert_with_update &&
+#endif
/* for direct_dup_insert without patch for partition */
spider->sql_command != SQLCOM_REPLACE &&
spider->sql_command != SQLCOM_REPLACE_SELECT
@@ -8653,8 +8805,11 @@ int spider_mysql_handler::append_insert_terminator(
) {
DBUG_ENTER("spider_mysql_handler::append_insert_terminator");
DBUG_PRINT("info",("spider this=%p", this));
- if (spider->result_list.insert_dup_update_pushdown)
- {
+ DBUG_PRINT("info",("spider dup_update_sql.length=%u", dup_update_sql.length()));
+ if (
+ spider->result_list.insert_dup_update_pushdown &&
+ dup_update_sql.length()
+ ) {
DBUG_PRINT("info",("spider add duplicate key update"));
str->length(str->length() - SPIDER_SQL_COMMA_LEN);
if (str->reserve(SPIDER_SQL_DUPLICATE_KEY_UPDATE_LEN +
@@ -8829,8 +8984,9 @@ int spider_mysql_handler::append_into(
}
if (field_name_length)
str->length(str->length() - SPIDER_SQL_COMMA_LEN);
- if (str->reserve(SPIDER_SQL_VALUES_LEN))
+ if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN + SPIDER_SQL_VALUES_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN);
str->q_append(SPIDER_SQL_VALUES_STR, SPIDER_SQL_VALUES_LEN);
insert_pos = str->length();
DBUG_RETURN(0);
@@ -10122,7 +10278,6 @@ int spider_mysql_handler::show_table_status(
conn->need_mon = &spider->need_mons[link_idx];
conn->mta_conn_mutex_lock_already = TRUE;
conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_queue_connect_rewrite(share, conn, link_idx);
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
share);
if (
@@ -10255,7 +10410,6 @@ int spider_mysql_handler::show_table_status(
conn->need_mon = &spider->need_mons[link_idx];
conn->mta_conn_mutex_lock_already = TRUE;
conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_queue_connect_rewrite(share, conn, link_idx);
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
share);
if (
@@ -10423,7 +10577,6 @@ int spider_mysql_handler::show_index(
conn->need_mon = &spider->need_mons[link_idx];
conn->mta_conn_mutex_lock_already = TRUE;
conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_queue_connect_rewrite(share, conn, link_idx);
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
share);
if (
@@ -10557,7 +10710,6 @@ int spider_mysql_handler::show_index(
conn->need_mon = &spider->need_mons[link_idx];
conn->mta_conn_mutex_lock_already = TRUE;
conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_queue_connect_rewrite(share, conn, link_idx);
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
share);
if (
@@ -10703,7 +10855,6 @@ int spider_mysql_handler::show_records(
conn->need_mon = &spider->need_mons[link_idx];
conn->mta_conn_mutex_lock_already = TRUE;
conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_queue_connect_rewrite(share, conn, link_idx);
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
share);
if (
@@ -10838,7 +10989,6 @@ ha_rows spider_mysql_handler::explain_select(
conn->need_mon = &spider->need_mons[link_idx];
conn->mta_conn_mutex_lock_already = TRUE;
conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_queue_connect_rewrite(spider->share, conn, link_idx);
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
spider->share);
if (
@@ -11498,6 +11648,7 @@ void spider_mysql_handler::minimum_select_bitmap_create()
}
}
}
+ DBUG_PRINT("info",("spider searched_bitmap=%p", spider->searched_bitmap));
for (field_p = table->field; *field_p; field_p++)
{
uint field_index = (*field_p)->field_index;
@@ -11965,8 +12116,10 @@ int spider_mysql_copy_table::append_values_str()
{
DBUG_ENTER("spider_mysql_copy_table::append_values_str");
DBUG_PRINT("info",("spider this=%p", this));
- if (sql.reserve(SPIDER_SQL_VALUES_LEN + SPIDER_SQL_OPEN_PAREN_LEN))
+ if (sql.reserve(SPIDER_SQL_CLOSE_PAREN_LEN + SPIDER_SQL_VALUES_LEN +
+ SPIDER_SQL_OPEN_PAREN_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ sql.q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN);
sql.q_append(SPIDER_SQL_VALUES_STR, SPIDER_SQL_VALUES_LEN);
sql.q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
DBUG_RETURN(0);
diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc
index d86da799bee..872a2880f7c 100644
--- a/storage/spider/spd_db_oracle.cc
+++ b/storage/spider/spd_db_oracle.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2012-2014 Kentoku Shiba
+/* Copyright (C) 2012-2015 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -2939,7 +2939,11 @@ int spider_db_oracle_util::open_item_func(
{
if (
!strncasecmp("rand", func_name, func_name_length) &&
+#ifdef SPIDER_Item_args_arg_count_IS_PROTECTED
+ !item_func->argument_count()
+#else
!item_func->arg_count
+#endif
) {
if (str)
str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
@@ -3099,13 +3103,99 @@ int spider_db_oracle_util::open_item_func(
last_str_length = SPIDER_SQL_AS_TIME_LEN;
break;
}
- } else if (func_name_length == 13 &&
- !strncasecmp("utc_timestamp", func_name, func_name_length)
- ) {
- if (str)
- str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
- DBUG_RETURN(spider_db_open_item_string(item_func, spider, str,
- alias, alias_length, dbton_id));
+ } else if (func_name_length == 13)
+ {
+ if (!strncasecmp("utc_timestamp", func_name, func_name_length))
+ {
+ if (str)
+ str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
+ DBUG_RETURN(spider_db_open_item_string(item_func, spider, str,
+ alias, alias_length, dbton_id));
+ } else if (!strncasecmp("timestampdiff", func_name, func_name_length))
+ {
+#ifdef ITEM_FUNC_TIMESTAMPDIFF_ARE_PUBLIC
+ Item_func_timestamp_diff *item_func_timestamp_diff =
+ (Item_func_timestamp_diff *) item_func;
+ if (str)
+ {
+ const char *interval_str;
+ uint interval_len;
+ switch (item_func_timestamp_diff->int_type)
+ {
+ case INTERVAL_YEAR:
+ interval_str = SPIDER_SQL_YEAR_STR;
+ interval_len = SPIDER_SQL_YEAR_LEN;
+ break;
+ case INTERVAL_QUARTER:
+ interval_str = SPIDER_SQL_QUARTER_STR;
+ interval_len = SPIDER_SQL_QUARTER_LEN;
+ break;
+ case INTERVAL_MONTH:
+ interval_str = SPIDER_SQL_MONTH_STR;
+ interval_len = SPIDER_SQL_MONTH_LEN;
+ break;
+ case INTERVAL_WEEK:
+ interval_str = SPIDER_SQL_WEEK_STR;
+ interval_len = SPIDER_SQL_WEEK_LEN;
+ break;
+ case INTERVAL_DAY:
+ interval_str = SPIDER_SQL_DAY_STR;
+ interval_len = SPIDER_SQL_DAY_LEN;
+ break;
+ case INTERVAL_HOUR:
+ interval_str = SPIDER_SQL_HOUR_STR;
+ interval_len = SPIDER_SQL_HOUR_LEN;
+ break;
+ case INTERVAL_MINUTE:
+ interval_str = SPIDER_SQL_MINUTE_STR;
+ interval_len = SPIDER_SQL_MINUTE_LEN;
+ break;
+ case INTERVAL_SECOND:
+ interval_str = SPIDER_SQL_SECOND_STR;
+ interval_len = SPIDER_SQL_SECOND_LEN;
+ break;
+ case INTERVAL_MICROSECOND:
+ interval_str = SPIDER_SQL_MICROSECOND_STR;
+ interval_len = SPIDER_SQL_MICROSECOND_LEN;
+ break;
+ default:
+ interval_str = "";
+ interval_len = 0;
+ break;
+ }
+ str->length(str->length() - SPIDER_SQL_OPEN_PAREN_LEN);
+ if (str->reserve(func_name_length + SPIDER_SQL_OPEN_PAREN_LEN +
+ interval_len + SPIDER_SQL_COMMA_LEN))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(func_name, func_name_length);
+ str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
+ str->q_append(interval_str, interval_len);
+ str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
+ }
+ if ((error_num = spider_db_print_item_type(item_list[0], spider,
+ str, alias, alias_length, dbton_id)))
+ DBUG_RETURN(error_num);
+ if (str)
+ {
+ if (str->reserve(SPIDER_SQL_COMMA_LEN))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
+ }
+ if ((error_num = spider_db_print_item_type(item_list[1], spider,
+ str, alias, alias_length, dbton_id)))
+ DBUG_RETURN(error_num);
+ if (str)
+ {
+ if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(SPIDER_SQL_CLOSE_PAREN_STR,
+ SPIDER_SQL_CLOSE_PAREN_LEN);
+ }
+ DBUG_RETURN(0);
+#else
+ DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
+#endif
+ }
} else if (func_name_length == 14)
{
if (!strncasecmp("cast_as_binary", func_name, func_name_length))
@@ -3427,6 +3517,54 @@ int spider_db_oracle_util::open_item_func(
}
break;
case Item_func::NOT_FUNC:
+ DBUG_PRINT("info",("spider NOT_FUNC"));
+ if (item_list[0]->type() == Item::COND_ITEM)
+ {
+ DBUG_PRINT("info",("spider item_list[0] is COND_ITEM"));
+ Item_cond *item_cond = (Item_cond *) item_list[0];
+ if (item_cond->functype() == Item_func::COND_AND_FUNC)
+ {
+ DBUG_PRINT("info",("spider item_cond is COND_AND_FUNC"));
+ List_iterator_fast<Item> lif(*(item_cond->argument_list()));
+ bool has_expr_cache_item = FALSE;
+ bool has_isnotnull_func = FALSE;
+ bool has_other_item = FALSE;
+ while((item = lif++))
+ {
+ if (
+ item->type() == Item::EXPR_CACHE_ITEM
+ ) {
+ DBUG_PRINT("info",("spider EXPR_CACHE_ITEM"));
+ has_expr_cache_item = TRUE;
+ } else if (
+ item->type() == Item::FUNC_ITEM &&
+ ((Item_func *) item)->functype() == Item_func::ISNOTNULL_FUNC
+ ) {
+ DBUG_PRINT("info",("spider ISNOTNULL_FUNC"));
+ has_isnotnull_func = TRUE;
+ } else {
+ DBUG_PRINT("info",("spider has other item"));
+ DBUG_PRINT("info",("spider COND type=%d", item->type()));
+ has_other_item = TRUE;
+ }
+ }
+ if (has_expr_cache_item && has_isnotnull_func && !has_other_item)
+ {
+ DBUG_PRINT("info",("spider NOT EXISTS skip"));
+ DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
+ }
+ }
+ }
+ if (str)
+ {
+ func_name = (char*) item_func->func_name();
+ func_name_length = strlen(func_name);
+ if (str->reserve(func_name_length + SPIDER_SQL_SPACE_LEN))
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(func_name, func_name_length);
+ str->q_append(SPIDER_SQL_SPACE_STR, SPIDER_SQL_SPACE_LEN);
+ }
+ break;
case Item_func::NEG_FUNC:
if (str)
{
@@ -5228,8 +5366,10 @@ int spider_oracle_handler::append_insert_tmp_bka_table(
str->q_append(SPIDER_SQL_COMMA_STR, SPIDER_SQL_COMMA_LEN);
if ((error_num = spider_db_append_key_columns(start_key, spider, str)))
DBUG_RETURN(error_num);
- if (str->reserve(SPIDER_SQL_VALUES_LEN + SPIDER_SQL_OPEN_PAREN_LEN))
+ if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN + SPIDER_SQL_VALUES_LEN +
+ SPIDER_SQL_OPEN_PAREN_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN);
str->q_append(SPIDER_SQL_VALUES_STR, SPIDER_SQL_VALUES_LEN);
str->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
DBUG_RETURN(0);
@@ -5376,8 +5516,10 @@ int spider_oracle_handler::append_insert_for_recovery(
}
if (field_name_length)
insert_sql->length(insert_sql->length() - SPIDER_SQL_COMMA_LEN);
- if (insert_sql->reserve(SPIDER_SQL_VALUES_LEN + SPIDER_SQL_OPEN_PAREN_LEN))
+ if (insert_sql->reserve(SPIDER_SQL_CLOSE_PAREN_LEN + SPIDER_SQL_VALUES_LEN +
+ SPIDER_SQL_OPEN_PAREN_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ insert_sql->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN);
insert_sql->q_append(SPIDER_SQL_VALUES_STR, SPIDER_SQL_VALUES_LEN);
insert_sql->q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
for (field = table->field; *field; field++)
@@ -8897,8 +9039,9 @@ int spider_oracle_handler::append_into(
}
if (field_name_length)
str->length(str->length() - SPIDER_SQL_COMMA_LEN);
- if (str->reserve(SPIDER_SQL_VALUES_LEN))
+ if (str->reserve(SPIDER_SQL_CLOSE_PAREN_LEN + SPIDER_SQL_VALUES_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ str->q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN);
str->q_append(SPIDER_SQL_VALUES_STR, SPIDER_SQL_VALUES_LEN);
insert_pos = str->length();
DBUG_RETURN(0);
@@ -10249,7 +10392,6 @@ int spider_oracle_handler::show_table_status(
conn->need_mon = &spider->need_mons[link_idx];
conn->mta_conn_mutex_lock_already = TRUE;
conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_queue_connect_rewrite(share, conn, link_idx);
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
share);
if (
@@ -10365,7 +10507,6 @@ int spider_oracle_handler::show_table_status(
conn->need_mon = &spider->need_mons[link_idx];
conn->mta_conn_mutex_lock_already = TRUE;
conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_queue_connect_rewrite(share, conn, link_idx);
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
share);
if (
@@ -10497,7 +10638,6 @@ int spider_oracle_handler::show_index(
conn->need_mon = &spider->need_mons[link_idx];
conn->mta_conn_mutex_lock_already = TRUE;
conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_queue_connect_rewrite(share, conn, link_idx);
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
share);
if (
@@ -10617,7 +10757,6 @@ int spider_oracle_handler::show_index(
conn->need_mon = &spider->need_mons[link_idx];
conn->mta_conn_mutex_lock_already = TRUE;
conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_queue_connect_rewrite(share, conn, link_idx);
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
share);
if (
@@ -10742,7 +10881,6 @@ int spider_oracle_handler::show_records(
conn->need_mon = &spider->need_mons[link_idx];
conn->mta_conn_mutex_lock_already = TRUE;
conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_queue_connect_rewrite(share, conn, link_idx);
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
share);
if (
@@ -10860,7 +10998,6 @@ int spider_oracle_handler::show_autoinc(
conn->need_mon = &spider->need_mons[link_idx];
conn->mta_conn_mutex_lock_already = TRUE;
conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_queue_connect_rewrite(share, conn, link_idx);
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
share);
if (
@@ -11055,7 +11192,6 @@ ha_rows spider_oracle_handler::explain_select(
conn->need_mon = &spider->need_mons[link_idx];
conn->mta_conn_mutex_lock_already = TRUE;
conn->mta_conn_mutex_unlock_later = TRUE;
- spider_conn_queue_connect_rewrite(spider->share, conn, link_idx);
spider_conn_set_timeout_from_share(conn, link_idx, spider->trx->thd,
spider->share);
if (
@@ -12265,8 +12401,10 @@ int spider_oracle_copy_table::append_values_str()
{
DBUG_ENTER("spider_oracle_copy_table::append_values_str");
DBUG_PRINT("info",("spider this=%p", this));
- if (sql.reserve(SPIDER_SQL_VALUES_LEN + SPIDER_SQL_OPEN_PAREN_LEN))
+ if (sql.reserve(SPIDER_SQL_CLOSE_PAREN_LEN + SPIDER_SQL_VALUES_LEN +
+ SPIDER_SQL_OPEN_PAREN_LEN))
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ sql.q_append(SPIDER_SQL_CLOSE_PAREN_STR, SPIDER_SQL_CLOSE_PAREN_LEN);
sql.q_append(SPIDER_SQL_VALUES_STR, SPIDER_SQL_VALUES_LEN);
sql.q_append(SPIDER_SQL_OPEN_PAREN_STR, SPIDER_SQL_OPEN_PAREN_LEN);
DBUG_RETURN(0);
diff --git a/storage/spider/spd_direct_sql.cc b/storage/spider/spd_direct_sql.cc
index 27041790d63..7de31e34e94 100644
--- a/storage/spider/spd_direct_sql.cc
+++ b/storage/spider/spd_direct_sql.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2009-2014 Kentoku Shiba
+/* Copyright (C) 2009-2015 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -557,6 +557,7 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
if ((*error_num = spider_db_udf_direct_sql_connect(direct_sql, conn)))
goto error;
conn->ping_time = (time_t) time((time_t*) 0);
+ conn->connect_error_time = conn->ping_time;
DBUG_RETURN(conn);
@@ -761,6 +762,16 @@ SPIDER_CONN *spider_udf_direct_sql_get_conn(
#endif
}
+ if (conn->queued_connect)
+ {
+ if ((*error_num = spider_db_udf_direct_sql_connect(direct_sql, conn)))
+ goto error;
+ conn->queued_connect = FALSE;
+ }
+
+ if (conn->queued_ping)
+ conn->queued_ping = FALSE;
+
DBUG_PRINT("info",("spider conn=%p", conn));
DBUG_PRINT("info",("spider conn->conn_kind=%u", conn->conn_kind));
DBUG_RETURN(conn);
diff --git a/storage/spider/spd_err.h b/storage/spider/spd_err.h
index 13605d16481..35f90ad8a94 100644
--- a/storage/spider/spd_err.h
+++ b/storage/spider/spd_err.h
@@ -63,6 +63,8 @@
#define ER_SPIDER_REQUEST_KEY_STR "Request key not found"
#define ER_SPIDER_CANT_OPEN_SYS_TABLE_NUM 12524
#define ER_SPIDER_CANT_OPEN_SYS_TABLE_STR "Can't open system table %s.%s"
+#define ER_SPIDER_LINK_MON_JUST_NG_NUM 12525
+#define ER_SPIDER_LINK_MON_JUST_NG_STR "Table '%s.%s' just got a problem"
#define ER_SPIDER_CANT_USE_BOTH_INNER_XA_AND_SNAPSHOT_NUM 12601
#define ER_SPIDER_CANT_USE_BOTH_INNER_XA_AND_SNAPSHOT_STR "Can't use both spider_use_consistent_snapshot = 1 and spider_internal_xa = 1"
diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h
index 9f27bd6acf8..5c922d3a7ad 100644
--- a/storage/spider/spd_include.h
+++ b/storage/spider/spd_include.h
@@ -13,7 +13,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-#define SPIDER_DETAIL_VERSION "3.2.21"
+#define SPIDER_DETAIL_VERSION "3.2.37"
#define SPIDER_HEX_VERSION 0x0302
#if MYSQL_VERSION_ID < 50500
@@ -117,6 +117,18 @@
#define SPIDER_TEST(A) test(A)
#endif
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100100
+#define SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR
+#define SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON
+#define SPIDER_XID_USES_xid_cache_iterate
+#else
+#define SPIDER_XID_STATE_HAS_in_thd
+#endif
+
+#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100108
+#define SPIDER_Item_args_arg_count_IS_PROTECTED
+#endif
+
#if MYSQL_VERSION_ID >= 50500
#define SPIDER_HAS_HASH_VALUE_TYPE
#endif
@@ -141,7 +153,7 @@
#define SPIDER_TMP_SHARE_CHAR_PTR_COUNT 19
#define SPIDER_TMP_SHARE_UINT_COUNT 17
-#define SPIDER_TMP_SHARE_LONG_COUNT 16
+#define SPIDER_TMP_SHARE_LONG_COUNT 18
#define SPIDER_TMP_SHARE_LONGLONG_COUNT 3
#define SPIDER_MEM_CALC_LIST_NUM 247
@@ -436,6 +448,13 @@ typedef struct st_spider_conn
int bulk_access_error_num;
st_spider_conn *bulk_access_next;
#endif
+
+ bool connect_error_with_message;
+ char connect_error_msg[MYSQL_ERRMSG_SIZE];
+ int connect_error;
+ THD *connect_error_thd;
+ query_id_t connect_error_query_id;
+ time_t connect_error_time;
} SPIDER_CONN;
typedef struct st_spider_lgtm_tblhnd_share
@@ -656,6 +675,7 @@ typedef struct st_spider_share
volatile bool init_error;
volatile time_t init_error_time;
volatile bool link_status_init;
+ uchar *table_mon_mutex_bitmap;
volatile bool sts_init;
volatile time_t sts_get_time;
#ifndef WITHOUT_SPIDER_BG_SEARCH
@@ -844,8 +864,10 @@ typedef struct st_spider_share
long *tgt_ssl_vscs;
long *link_statuses;
#ifndef WITHOUT_SPIDER_BG_SEARCH
+ long *monitoring_bg_flag;
long *monitoring_bg_kind;
#endif
+ long *monitoring_flag;
long *monitoring_kind;
#ifndef WITHOUT_SPIDER_BG_SEARCH
longlong *monitoring_bg_interval;
@@ -948,8 +970,10 @@ typedef struct st_spider_share
uint tgt_ssl_vscs_length;
uint link_statuses_length;
#ifndef WITHOUT_SPIDER_BG_SEARCH
+ uint monitoring_bg_flag_length;
uint monitoring_bg_kind_length;
#endif
+ uint monitoring_flag_length;
uint monitoring_kind_length;
#ifndef WITHOUT_SPIDER_BG_SEARCH
uint monitoring_bg_interval_length;
@@ -1239,8 +1263,12 @@ typedef struct st_spider_int_hld
typedef struct st_spider_item_hld
{
- uint tgt_num;
- Item *item;
+ uint tgt_num;
+ Item *item;
+#ifdef SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY_AND_THDPTR
+ bool init_mem_root;
+ MEM_ROOT mem_root;
+#endif
st_spider_item_hld *next;
} SPIDER_ITEM_HLD;
diff --git a/storage/spider/spd_malloc.cc b/storage/spider/spd_malloc.cc
index 4a033c1e7cf..ec71f9631bc 100644
--- a/storage/spider/spd_malloc.cc
+++ b/storage/spider/spd_malloc.cc
@@ -1222,6 +1222,20 @@ bool spider_string::append(
DBUG_RETURN(res);
}
+void spider_string::append_escape_string(
+ const char *st,
+ uint len
+) {
+ DBUG_ENTER("spider_string::append_escape_string");
+ DBUG_PRINT("info",("spider this=%p", this));
+ DBUG_ASSERT(mem_calc_inited);
+ DBUG_ASSERT((!current_alloc_mem && !str.is_alloced()) ||
+ current_alloc_mem == str.alloced_length());
+ str.length(str.length() + escape_string_for_mysql(
+ str.charset(), (char *) str.ptr() + str.length(), 0, st, len));
+ DBUG_VOID_RETURN;
+}
+
bool spider_string::append_for_single_quote(
const char *st,
uint len
diff --git a/storage/spider/spd_param.cc b/storage/spider/spd_param.cc
index 7376bfc0499..5105c1e52f4 100644
--- a/storage/spider/spd_param.cc
+++ b/storage/spider/spd_param.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2014 Kentoku Shiba
+/* Copyright (C) 2008-2015 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -178,6 +178,29 @@ my_bool spider_param_connect_mutex()
DBUG_RETURN(spider_connect_mutex);
}
+static uint spider_connect_error_interval;
+/*
+ 0-: interval
+ */
+static MYSQL_SYSVAR_UINT(
+ connect_error_interval,
+ spider_connect_error_interval,
+ PLUGIN_VAR_RQCMDARG,
+ "Return same error code until interval passes if connection is failed",
+ NULL,
+ NULL,
+ 1,
+ 0,
+ 4294967295U,
+ 0
+);
+
+uint spider_param_connect_error_interval()
+{
+ DBUG_ENTER("spider_param_connect_error_interval");
+ DBUG_RETURN(spider_connect_error_interval);
+}
+
static uint spider_table_init_error_interval;
/*
0-: interval
@@ -3120,6 +3143,7 @@ static struct st_mysql_sys_var* spider_system_variables[] = {
MYSQL_SYSVAR(dry_access),
MYSQL_SYSVAR(delete_all_rows_type),
MYSQL_SYSVAR(bka_table_name_type),
+ MYSQL_SYSVAR(connect_error_interval),
NULL
};
diff --git a/storage/spider/spd_param.h b/storage/spider/spd_param.h
index 32db0403159..c8eb5d0d417 100644
--- a/storage/spider/spd_param.h
+++ b/storage/spider/spd_param.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2014 Kentoku Shiba
+/* Copyright (C) 2008-2015 Kentoku Shiba
This program is free software); you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,6 +15,7 @@
my_bool spider_param_support_xa();
my_bool spider_param_connect_mutex();
+uint spider_param_connect_error_interval();
uint spider_param_table_init_error_interval();
int spider_param_use_table_charset(
int use_table_charset
diff --git a/storage/spider/spd_ping_table.cc b/storage/spider/spd_ping_table.cc
index d32dbec2421..41c5c240dd3 100644
--- a/storage/spider/spd_ping_table.cc
+++ b/storage/spider/spd_ping_table.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2009-2014 Kentoku Shiba
+/* Copyright (C) 2009-2015 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -626,6 +626,17 @@ SPIDER_CONN *spider_get_ping_table_tgt_conn(
*error_num = ER_CONNECT_TO_FOREIGN_DATA_SOURCE;
goto error;
}
+#ifndef DBUG_OFF
+ if (trx == spider_global_trx)
+ {
+ DBUG_ASSERT(!conn->thd);
+ }
+ DBUG_PRINT("info",("spider conn->thd=%p", conn->thd));
+ if (conn->thd)
+ {
+ DBUG_PRINT("info",("spider query_id=%lld", conn->thd->query_id));
+ }
+#endif
conn->error_mode = 0;
#ifndef WITHOUT_SPIDER_BG_SEARCH
if (trx == spider_global_trx)
@@ -992,37 +1003,56 @@ long long spider_ping_table_body(
limit
))
) {
+ DBUG_PRINT("info",("spider table_mon_list->mon_status == SPIDER_LINK_MON_NG:%s",
+ table_mon_list->mon_status == SPIDER_LINK_MON_NG ? "TRUE" : "FALSE"));
+ DBUG_PRINT("info",("spider error_num=%d", error_num));
+ DBUG_PRINT("info",("spider tmp_error_num=%d", tmp_error_num));
if (tmp_error_num == HA_ERR_OUT_OF_MEM)
goto error_with_free_table_mon_list;
else if(tmp_error_num)
thd->clear_error();
- fault_count++;
- error_num = 0;
- if (fault_count > full_mon_count / 2)
+ if (tmp_error_num != ER_CON_COUNT_ERROR)
{
- mon_table_result->result_status = SPIDER_LINK_MON_NG;
- DBUG_PRINT("info",("spider mon_table_result->result_status=SPIDER_LINK_MON_NG 2"));
- if (table_mon_list->mon_status != SPIDER_LINK_MON_NG)
- {
- pthread_mutex_lock(&table_mon_list->update_status_mutex);
+ fault_count++;
+ error_num = 0;
+ if (
+ !(flags & SPIDER_UDF_PING_TABLE_USE_ALL_MONITORING_NODES) &&
+ fault_count > full_mon_count / 2
+ ) {
+ mon_table_result->result_status = SPIDER_LINK_MON_NG;
+ DBUG_PRINT("info",("spider mon_table_result->result_status=SPIDER_LINK_MON_NG 2"));
if (table_mon_list->mon_status != SPIDER_LINK_MON_NG)
{
- table_mon_list->mon_status = SPIDER_LINK_MON_NG;
- table_mon_list->share->link_statuses[0] = SPIDER_LINK_STATUS_NG;
- spider_sys_update_tables_link_status(trx->thd,
- conv_name.c_ptr(), conv_name_length, link_idx,
- SPIDER_LINK_STATUS_NG, TRUE);
- spider_sys_log_tables_link_failed(trx->thd,
- conv_name.c_ptr(), conv_name_length, link_idx, TRUE);
+/*
+ pthread_mutex_lock(&table_mon_list->update_status_mutex);
+*/
+ pthread_mutex_lock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]);
+ if (table_mon_list->mon_status != SPIDER_LINK_MON_NG)
+ {
+ table_mon_list->mon_status = SPIDER_LINK_MON_NG;
+ table_mon_list->share->link_statuses[0] = SPIDER_LINK_STATUS_NG;
+ spider_update_link_status_for_share(conv_name.c_ptr(),
+ conv_name_length, link_idx, SPIDER_LINK_STATUS_NG);
+ spider_sys_update_tables_link_status(trx->thd,
+ conv_name.c_ptr(), conv_name_length, link_idx,
+ SPIDER_LINK_STATUS_NG, TRUE);
+ spider_sys_log_tables_link_failed(trx->thd,
+ conv_name.c_ptr(), conv_name_length, link_idx, TRUE);
+ }
+/*
+ pthread_mutex_unlock(&table_mon_list->update_status_mutex);
+*/
+ pthread_mutex_unlock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]);
}
- pthread_mutex_unlock(&table_mon_list->update_status_mutex);
+ goto end;
}
- goto end;
}
} else {
success_count++;
- if (success_count > full_mon_count / 2)
- {
+ if (
+ !(flags & SPIDER_UDF_PING_TABLE_USE_ALL_MONITORING_NODES) &&
+ success_count > full_mon_count / 2
+ ) {
mon_table_result->result_status = SPIDER_LINK_MON_OK;
DBUG_PRINT("info",("spider mon_table_result->result_status=SPIDER_LINK_MON_OK 1"));
goto end;
@@ -1048,7 +1078,42 @@ long long spider_ping_table_body(
table_mon->server_id == first_sid ||
current_mon_count > full_mon_count
) {
- if (success_count + fault_count > full_mon_count / 2)
+ if (
+ (flags & SPIDER_UDF_PING_TABLE_USE_ALL_MONITORING_NODES) &&
+ fault_count > full_mon_count / 2
+ ) {
+ mon_table_result->result_status = SPIDER_LINK_MON_NG;
+ DBUG_PRINT("info",("spider mon_table_result->result_status=SPIDER_LINK_MON_NG 3"));
+ if (table_mon_list->mon_status != SPIDER_LINK_MON_NG)
+ {
+/*
+ pthread_mutex_lock(&table_mon_list->update_status_mutex);
+*/
+ pthread_mutex_lock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]);
+ if (table_mon_list->mon_status != SPIDER_LINK_MON_NG)
+ {
+ table_mon_list->mon_status = SPIDER_LINK_MON_NG;
+ table_mon_list->share->link_statuses[0] = SPIDER_LINK_STATUS_NG;
+ spider_update_link_status_for_share(conv_name.c_ptr(),
+ conv_name_length, link_idx, SPIDER_LINK_STATUS_NG);
+ spider_sys_update_tables_link_status(trx->thd,
+ conv_name.c_ptr(), conv_name_length, link_idx,
+ SPIDER_LINK_STATUS_NG, TRUE);
+ spider_sys_log_tables_link_failed(trx->thd,
+ conv_name.c_ptr(), conv_name_length, link_idx, TRUE);
+ }
+/*
+ pthread_mutex_unlock(&table_mon_list->update_status_mutex);
+*/
+ pthread_mutex_unlock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]);
+ }
+ } else if (
+ (flags & SPIDER_UDF_PING_TABLE_USE_ALL_MONITORING_NODES) &&
+ success_count > full_mon_count / 2
+ ) {
+ mon_table_result->result_status = SPIDER_LINK_MON_OK;
+ DBUG_PRINT("info",("spider mon_table_result->result_status=SPIDER_LINK_MON_OK 2"));
+ } else if (success_count + fault_count > full_mon_count / 2)
{
mon_table_result->result_status = SPIDER_LINK_MON_DRAW;
DBUG_PRINT("info",(
@@ -1074,18 +1139,26 @@ long long spider_ping_table_body(
mon_table_result->result_status == SPIDER_LINK_MON_NG &&
table_mon_list->mon_status != SPIDER_LINK_MON_NG
) {
+/*
pthread_mutex_lock(&table_mon_list->update_status_mutex);
+*/
+ pthread_mutex_lock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]);
if (table_mon_list->mon_status != SPIDER_LINK_MON_NG)
{
table_mon_list->mon_status = SPIDER_LINK_MON_NG;
table_mon_list->share->link_statuses[0] = SPIDER_LINK_STATUS_NG;
+ spider_update_link_status_for_share(conv_name.c_ptr(),
+ conv_name_length, link_idx, SPIDER_LINK_STATUS_NG);
spider_sys_update_tables_link_status(trx->thd,
conv_name.c_ptr(), conv_name_length, link_idx,
SPIDER_LINK_STATUS_NG, TRUE);
spider_sys_log_tables_link_failed(trx->thd,
conv_name.c_ptr(), conv_name_length, link_idx, TRUE);
}
+/*
pthread_mutex_unlock(&table_mon_list->update_status_mutex);
+*/
+ pthread_mutex_unlock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]);
}
table_mon_list->last_receptor_result =
mon_table_result->result_status;
@@ -1245,6 +1318,7 @@ int spider_ping_table_mon_from_table(
uint where_clause_length,
long monitoring_kind,
longlong monitoring_limit,
+ long monitoring_flag,
bool need_lock
) {
int error_num = 0, current_mon_count, flags;
@@ -1312,6 +1386,9 @@ int spider_ping_table_mon_from_table(
else
flags = 0;
+ if (monitoring_flag & 1)
+ flags |= SPIDER_UDF_PING_TABLE_USE_ALL_MONITORING_NODES;
+
if (!(table_mon_list = spider_get_ping_table_mon_list(trx, thd,
&conv_name_str, conv_name_length, link_idx, server_id, need_lock,
&error_num)))
@@ -1321,7 +1398,9 @@ int spider_ping_table_mon_from_table(
{
DBUG_PRINT("info",
("spider share->link_statuses[%d]=SPIDER_LINK_STATUS_NG", link_idx));
+ pthread_mutex_lock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]);
share->link_statuses[link_idx] = SPIDER_LINK_STATUS_NG;
+ pthread_mutex_unlock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]);
error_num = ER_SPIDER_LINK_MON_NG_NUM;
my_printf_error(error_num,
ER_SPIDER_LINK_MON_NG_STR, MYF(0),
@@ -1386,7 +1465,10 @@ int spider_ping_table_mon_from_table(
mon_table_result.result_status == SPIDER_LINK_MON_NG &&
table_mon_list->mon_status != SPIDER_LINK_MON_NG
) {
+/*
pthread_mutex_lock(&table_mon_list->update_status_mutex);
+*/
+ pthread_mutex_lock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]);
if (table_mon_list->mon_status != SPIDER_LINK_MON_NG)
{
table_mon_list->mon_status = SPIDER_LINK_MON_NG;
@@ -1400,7 +1482,10 @@ int spider_ping_table_mon_from_table(
spider_sys_log_tables_link_failed(thd, conv_name,
conv_name_length, link_idx, need_lock);
}
+/*
pthread_mutex_unlock(&table_mon_list->update_status_mutex);
+*/
+ pthread_mutex_unlock(&spider_udf_table_mon_mutexes[table_mon_list->mutex_hash]);
}
table_mon_list->last_caller_result = mon_table_result.result_status;
if (mon_table_result.result_status == SPIDER_LINK_MON_OK)
diff --git a/storage/spider/spd_ping_table.h b/storage/spider/spd_ping_table.h
index d9c5648b6b3..836a050c185 100644
--- a/storage/spider/spd_ping_table.h
+++ b/storage/spider/spd_ping_table.h
@@ -98,5 +98,6 @@ int spider_ping_table_mon_from_table(
uint where_clause_length,
long monitoring_kind,
longlong monitoring_limit,
+ long monitoring_flag,
bool need_lock
);
diff --git a/storage/spider/spd_sys_table.cc b/storage/spider/spd_sys_table.cc
index 1ff3496d83e..56f9e131be5 100644
--- a/storage/spider/spd_sys_table.cc
+++ b/storage/spider/spd_sys_table.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2014 Kentoku Shiba
+/* Copyright (C) 2008-2015 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -2280,7 +2280,9 @@ int spider_get_link_statuses(
if (
(error_num == HA_ERR_KEY_NOT_FOUND || error_num == HA_ERR_END_OF_FILE)
) {
+/*
table->file->print_error(error_num, MYF(0));
+*/
DBUG_RETURN(error_num);
}
} else if ((error_num =
@@ -2390,8 +2392,13 @@ TABLE *spider_mk_sys_tmp_table(
goto error_alloc_field;
field->init(table);
+#ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR
+ if (!(i_field = new (thd->mem_root) Item_field(thd, (Field *) field)))
+ goto error_alloc_item_field;
+#else
if (!(i_field = new Item_field((Field *) field)))
goto error_alloc_item_field;
+#endif
if (i_list.push_back(i_field))
goto error_push_item;
@@ -2443,8 +2450,13 @@ TABLE *spider_mk_sys_tmp_table_for_result(
goto error_alloc_field1;
field1->init(table);
+#ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR
+ if (!(i_field1 = new (thd->mem_root) Item_field(thd, (Field *) field1)))
+ goto error_alloc_item_field1;
+#else
if (!(i_field1 = new Item_field((Field *) field1)))
goto error_alloc_item_field1;
+#endif
if (i_list.push_back(i_field1))
goto error_push_item1;
@@ -2454,8 +2466,13 @@ TABLE *spider_mk_sys_tmp_table_for_result(
goto error_alloc_field2;
field2->init(table);
+#ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR
+ if (!(i_field2 = new (thd->mem_root) Item_field(thd, (Field *) field2)))
+ goto error_alloc_item_field2;
+#else
if (!(i_field2 = new Item_field((Field *) field2)))
goto error_alloc_item_field2;
+#endif
if (i_list.push_back(i_field2))
goto error_push_item2;
@@ -2465,8 +2482,13 @@ TABLE *spider_mk_sys_tmp_table_for_result(
goto error_alloc_field3;
field3->init(table);
+#ifdef SPIDER_FIELD_FIELDPTR_REQUIRES_THDPTR
+ if (!(i_field3 = new (thd->mem_root) Item_field(thd, (Field *) field3)))
+ goto error_alloc_item_field3;
+#else
if (!(i_field3 = new Item_field((Field *) field3)))
goto error_alloc_item_field3;
+#endif
if (i_list.push_back(i_field3))
goto error_push_item3;
diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc
index bece31d4603..a20598969ee 100644
--- a/storage/spider/spd_table.cc
+++ b/storage/spider/spd_table.cc
@@ -38,14 +38,18 @@
#include "spd_table.h"
#include "spd_conn.h"
#include "spd_ping_table.h"
+#include "spd_direct_sql.h"
#include "spd_malloc.h"
ulong *spd_db_att_thread_id;
+#ifdef SPIDER_XID_USES_xid_cache_iterate
+#else
#ifdef XID_CACHE_IS_SPLITTED
uint *spd_db_att_xid_cache_split_num;
#endif
pthread_mutex_t *spd_db_att_LOCK_xid_cache;
HASH *spd_db_att_xid_cache;
+#endif
struct charset_info_st *spd_charset_utf8_bin;
const char **spd_defaults_extra_file;
const char **spd_defaults_file;
@@ -744,9 +748,13 @@ int spider_free_share_alloc(
if (share->link_statuses)
spider_free(spider_current_trx, share->link_statuses, MYF(0));
#ifndef WITHOUT_SPIDER_BG_SEARCH
+ if (share->monitoring_bg_flag)
+ spider_free(spider_current_trx, share->monitoring_bg_flag, MYF(0));
if (share->monitoring_bg_kind)
spider_free(spider_current_trx, share->monitoring_bg_kind, MYF(0));
#endif
+ if (share->monitoring_flag)
+ spider_free(spider_current_trx, share->monitoring_flag, MYF(0));
if (share->monitoring_kind)
spider_free(spider_current_trx, share->monitoring_kind, MYF(0));
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
@@ -2040,10 +2048,12 @@ int spider_parse_connect_info(
SPIDER_PARAM_INT_WITH_MAX("lmr", low_mem_read, 0, 1);
SPIDER_PARAM_LONG_LIST_WITH_MAX("lst", link_statuses, 0, 3);
#ifndef WITHOUT_SPIDER_BG_SEARCH
+ SPIDER_PARAM_LONG_LIST_WITH_MAX("mbf", monitoring_bg_flag, 0, 1);
SPIDER_PARAM_LONGLONG_LIST_WITH_MAX(
"mbi", monitoring_bg_interval, 0, 4294967295LL);
SPIDER_PARAM_LONG_LIST_WITH_MAX("mbk", monitoring_bg_kind, 0, 3);
#endif
+ SPIDER_PARAM_LONG_LIST_WITH_MAX("mfg", monitoring_flag, 0, 1);
SPIDER_PARAM_LONG_LIST_WITH_MAX("mkd", monitoring_kind, 0, 3);
SPIDER_PARAM_LONGLONG_LIST_WITH_MAX(
"mlt", monitoring_limit, 0, 9223372036854775807LL);
@@ -2250,6 +2260,7 @@ int spider_parse_connect_info(
#ifndef WITHOUT_SPIDER_BG_SEARCH
SPIDER_PARAM_LONGLONG("bgs_second_read", bgs_second_read, 0);
#endif
+ SPIDER_PARAM_LONG_LIST_WITH_MAX("monitoring_flag", monitoring_flag, 0, 1);
SPIDER_PARAM_LONG_LIST_WITH_MAX("monitoring_kind", monitoring_kind, 0, 3);
SPIDER_PARAM_DOUBLE("semi_split_read", semi_split_read, 0);
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
@@ -2324,6 +2335,8 @@ int spider_parse_connect_info(
"select_column_mode", select_column_mode, 0, 1);
#ifndef WITHOUT_SPIDER_BG_SEARCH
SPIDER_PARAM_LONG_LIST_WITH_MAX(
+ "monitoring_bg_flag", monitoring_bg_flag, 0, 1);
+ SPIDER_PARAM_LONG_LIST_WITH_MAX(
"monitoring_bg_kind", monitoring_bg_kind, 0, 3);
#endif
SPIDER_PARAM_LONGLONG(
@@ -2450,6 +2463,8 @@ int spider_parse_connect_info(
share->all_link_count = share->tgt_ssl_vscs_length;
if (share->all_link_count < share->link_statuses_length)
share->all_link_count = share->link_statuses_length;
+ if (share->all_link_count < share->monitoring_flag_length)
+ share->all_link_count = share->monitoring_flag_length;
if (share->all_link_count < share->monitoring_kind_length)
share->all_link_count = share->monitoring_kind_length;
if (share->all_link_count < share->monitoring_limit_length)
@@ -2457,6 +2472,8 @@ int spider_parse_connect_info(
if (share->all_link_count < share->monitoring_sid_length)
share->all_link_count = share->monitoring_sid_length;
#ifndef WITHOUT_SPIDER_BG_SEARCH
+ if (share->all_link_count < share->monitoring_bg_flag_length)
+ share->all_link_count = share->monitoring_bg_flag_length;
if (share->all_link_count < share->monitoring_bg_kind_length)
share->all_link_count = share->monitoring_bg_kind_length;
if (share->all_link_count < share->monitoring_bg_interval_length)
@@ -2626,12 +2643,22 @@ int spider_parse_connect_info(
goto error;
#ifndef WITHOUT_SPIDER_BG_SEARCH
if ((error_num = spider_increase_long_list(
+ &share->monitoring_bg_flag,
+ &share->monitoring_bg_flag_length,
+ share->all_link_count)))
+ goto error;
+ if ((error_num = spider_increase_long_list(
&share->monitoring_bg_kind,
&share->monitoring_bg_kind_length,
share->all_link_count)))
goto error;
#endif
if ((error_num = spider_increase_long_list(
+ &share->monitoring_flag,
+ &share->monitoring_flag_length,
+ share->all_link_count)))
+ goto error;
+ if ((error_num = spider_increase_long_list(
&share->monitoring_kind,
&share->monitoring_kind_length,
share->all_link_count)))
@@ -3349,9 +3376,13 @@ int spider_set_connect_info_default(
share->link_statuses[roop_count] = SPIDER_LINK_STATUS_NO_CHANGE;
#ifndef WITHOUT_SPIDER_BG_SEARCH
+ if (share->monitoring_bg_flag[roop_count] == -1)
+ share->monitoring_bg_flag[roop_count] = 0;
if (share->monitoring_bg_kind[roop_count] == -1)
share->monitoring_bg_kind[roop_count] = 0;
#endif
+ if (share->monitoring_flag[roop_count] == -1)
+ share->monitoring_flag[roop_count] = 0;
if (share->monitoring_kind[roop_count] == -1)
share->monitoring_kind[roop_count] = 0;
#ifndef WITHOUT_SPIDER_BG_SEARCH
@@ -4042,7 +4073,9 @@ SPIDER_SHARE *spider_create_share(
SPIDER_SHARE *share;
char *tmp_name;
longlong *tmp_cardinality, *tmp_static_key_cardinality;
- uchar *tmp_cardinality_upd;
+ uchar *tmp_cardinality_upd, *tmp_table_mon_mutex_bitmap;
+ char buf[MAX_FIELD_WIDTH], *buf_pos;
+ char link_idx_str[SPIDER_SQL_INT_LEN];
DBUG_ENTER("spider_create_share");
length = (uint) strlen(table_name);
bitmap_size = spider_bitmap_size(table_share->fields);
@@ -4053,6 +4086,8 @@ SPIDER_SHARE *spider_create_share(
&tmp_static_key_cardinality, sizeof(*tmp_static_key_cardinality) * table_share->keys,
&tmp_cardinality, sizeof(*tmp_cardinality) * table_share->fields,
&tmp_cardinality_upd, sizeof(*tmp_cardinality_upd) * bitmap_size,
+ &tmp_table_mon_mutex_bitmap, sizeof(*tmp_table_mon_mutex_bitmap) *
+ ((spider_param_udf_table_mon_mutex_count() + 7) / 8),
NullS))
) {
*error_num = HA_ERR_OUT_OF_MEM;
@@ -4070,6 +4105,7 @@ SPIDER_SHARE *spider_create_share(
share->static_key_cardinality = tmp_static_key_cardinality;
share->cardinality = tmp_cardinality;
share->cardinality_upd = tmp_cardinality_upd;
+ share->table_mon_mutex_bitmap = tmp_table_mon_mutex_bitmap;
share->bitmap_size = bitmap_size;
share->table_share = table_share;
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
@@ -4097,6 +4133,18 @@ SPIDER_SHARE *spider_create_share(
0)))
goto error_parse_connect_string;
+ for (roop_count = 0; roop_count < (int) share->all_link_count;
+ roop_count++)
+ {
+ my_sprintf(link_idx_str, (link_idx_str, "%010d", roop_count));
+ buf_pos = strmov(buf, share->table_name);
+ buf_pos = strmov(buf_pos, link_idx_str);
+ *buf_pos = '\0';
+ spider_set_bit(tmp_table_mon_mutex_bitmap,
+ spider_udf_calc_hash(buf, spider_param_udf_table_mon_mutex_count())
+ );
+ }
+
use_table_charset = spider_param_use_table_charset(
share->use_table_charset);
if (table_share->table_charset && use_table_charset)
@@ -4315,13 +4363,23 @@ SPIDER_SHARE *spider_get_share(
if (!share->link_status_init)
{
pthread_mutex_lock(&share->mutex);
+ for (roop_count = 0;
+ roop_count < (int) spider_param_udf_table_mon_mutex_count();
+ roop_count++
+ ) {
+ if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
+ pthread_mutex_lock(&spider_udf_table_mon_mutexes[roop_count]);
+ }
if (!share->link_status_init)
{
if (
- table_share->tmp_table == NO_TMP_TABLE &&
- sql_command != SQLCOM_DROP_TABLE &&
- sql_command != SQLCOM_ALTER_TABLE &&
- sql_command != SQLCOM_SHOW_CREATE
+ (
+ table_share->tmp_table == NO_TMP_TABLE &&
+ sql_command != SQLCOM_DROP_TABLE &&
+ sql_command != SQLCOM_SHOW_CREATE
+ ) ||
+ /* for alter change link status */
+ sql_command == SQLCOM_ALTER_TABLE
) {
SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME));
init_mem_root = TRUE;
@@ -4331,6 +4389,13 @@ SPIDER_SHARE *spider_get_share(
SPIDER_SYS_TABLES_TABLE_NAME_LEN, FALSE, &open_tables_backup,
FALSE, error_num))
) {
+ for (roop_count = 0;
+ roop_count < (int) spider_param_udf_table_mon_mutex_count();
+ roop_count++
+ ) {
+ if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
+ pthread_mutex_unlock(&spider_udf_table_mon_mutexes[roop_count]);
+ }
pthread_mutex_unlock(&share->mutex);
spider_free_share(share);
goto error_open_sys_table;
@@ -4339,9 +4404,25 @@ SPIDER_SHARE *spider_get_share(
&mem_root);
if (*error_num)
{
- pthread_mutex_unlock(&share->mutex);
- spider_free_share(share);
- goto error_get_link_statuses;
+ if (
+ *error_num != HA_ERR_KEY_NOT_FOUND &&
+ *error_num != HA_ERR_END_OF_FILE
+ ) {
+ for (roop_count = 0;
+ roop_count < (int) spider_param_udf_table_mon_mutex_count();
+ roop_count++
+ ) {
+ if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
+ pthread_mutex_unlock(&spider_udf_table_mon_mutexes[roop_count]);
+ }
+ pthread_mutex_unlock(&share->mutex);
+ spider_free_share(share);
+ goto error_get_link_statuses;
+ }
+ } else {
+ memcpy(share->alter_table.tmp_link_statuses, share->link_statuses,
+ sizeof(long) * share->all_link_count);
+ share->link_status_init = TRUE;
}
}
share->have_recovery_link = spider_conn_check_recovery_link(share);
@@ -4357,6 +4438,13 @@ SPIDER_SHARE *spider_get_share(
init_mem_root = FALSE;
}
}
+ for (roop_count = 0;
+ roop_count < (int) spider_param_udf_table_mon_mutex_count();
+ roop_count++
+ ) {
+ if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
+ pthread_mutex_unlock(&spider_udf_table_mon_mutexes[roop_count]);
+ }
pthread_mutex_unlock(&share->mutex);
}
@@ -4570,6 +4658,7 @@ SPIDER_SHARE *spider_get_share(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
FALSE
);
}
@@ -4692,59 +4781,6 @@ SPIDER_SHARE *spider_get_share(
{
thd->clear_error();
}
-/*
- if (
- (*error_num = spider_get_sts(share, spider->search_link_idx, tmp_time,
- spider, sts_interval, sts_mode,
-#ifdef WITH_PARTITION_STORAGE_ENGINE
- sts_sync,
-#endif
- 1)) ||
- (*error_num = spider_get_crd(share, spider->search_link_idx, tmp_time,
- spider, table, crd_interval, crd_mode,
-#ifdef WITH_PARTITION_STORAGE_ENGINE
- crd_sync,
-#endif
- 1))
- ) {
- if (
- share->monitoring_kind[spider->search_link_idx] &&
- spider->need_mons[spider->search_link_idx]
- ) {
- *error_num = spider_ping_table_mon_from_table(
- spider->trx,
- spider->trx->thd,
- share,
- share->monitoring_sid[spider->search_link_idx],
- share->table_name,
- share->table_name_length,
- spider->conn_link_idx[spider->search_link_idx],
- NULL,
- 0,
- share->monitoring_kind[spider->search_link_idx],
- share->monitoring_limit[spider->search_link_idx],
- FALSE
- );
- }
- if (
- spider_init_error_table ||
- (spider_init_error_table =
- spider_get_init_error_table(spider->trx, share, TRUE))
- ) {
- spider_init_error_table->init_error = *error_num;
- if ((spider_init_error_table->init_error_with_message =
- thd->is_error()))
- strmov(spider_init_error_table->init_error_msg,
- spider_stmt_da_message(thd));
- spider_init_error_table->init_error_time =
- (time_t) time((time_t*) 0);
- }
- share->init_error = TRUE;
- share->init = TRUE;
- spider_free_share(share);
- goto error_but_no_delete;
- }
-*/
pthread_mutex_unlock(&share->crd_mutex);
pthread_mutex_unlock(&share->sts_mutex);
}
@@ -4762,13 +4798,23 @@ SPIDER_SHARE *spider_get_share(
if (!share->link_status_init)
{
pthread_mutex_lock(&share->mutex);
+ for (roop_count = 0;
+ roop_count < (int) spider_param_udf_table_mon_mutex_count();
+ roop_count++
+ ) {
+ if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
+ pthread_mutex_lock(&spider_udf_table_mon_mutexes[roop_count]);
+ }
if (!share->link_status_init)
{
if (
- table_share->tmp_table == NO_TMP_TABLE &&
- sql_command != SQLCOM_DROP_TABLE &&
- sql_command != SQLCOM_ALTER_TABLE &&
- sql_command != SQLCOM_SHOW_CREATE
+ (
+ table_share->tmp_table == NO_TMP_TABLE &&
+ sql_command != SQLCOM_DROP_TABLE &&
+ sql_command != SQLCOM_SHOW_CREATE
+ ) ||
+ /* for alter change link status */
+ sql_command == SQLCOM_ALTER_TABLE
) {
SPD_INIT_ALLOC_ROOT(&mem_root, 4096, 0, MYF(MY_WME));
init_mem_root = TRUE;
@@ -4778,6 +4824,13 @@ SPIDER_SHARE *spider_get_share(
SPIDER_SYS_TABLES_TABLE_NAME_LEN, FALSE, &open_tables_backup,
FALSE, error_num))
) {
+ for (roop_count = 0;
+ roop_count < (int) spider_param_udf_table_mon_mutex_count();
+ roop_count++
+ ) {
+ if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
+ pthread_mutex_unlock(&spider_udf_table_mon_mutexes[roop_count]);
+ }
pthread_mutex_unlock(&share->mutex);
spider_free_share(share);
goto error_open_sys_table;
@@ -4786,9 +4839,25 @@ SPIDER_SHARE *spider_get_share(
&mem_root);
if (*error_num)
{
- pthread_mutex_unlock(&share->mutex);
- spider_free_share(share);
- goto error_get_link_statuses;
+ if (
+ *error_num != HA_ERR_KEY_NOT_FOUND &&
+ *error_num != HA_ERR_END_OF_FILE
+ ) {
+ for (roop_count = 0;
+ roop_count < (int) spider_param_udf_table_mon_mutex_count();
+ roop_count++
+ ) {
+ if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
+ pthread_mutex_unlock(&spider_udf_table_mon_mutexes[roop_count]);
+ }
+ pthread_mutex_unlock(&share->mutex);
+ spider_free_share(share);
+ goto error_get_link_statuses;
+ }
+ } else {
+ memcpy(share->alter_table.tmp_link_statuses, share->link_statuses,
+ sizeof(long) * share->all_link_count);
+ share->link_status_init = TRUE;
}
}
share->have_recovery_link = spider_conn_check_recovery_link(share);
@@ -4804,6 +4873,13 @@ SPIDER_SHARE *spider_get_share(
init_mem_root = FALSE;
}
}
+ for (roop_count = 0;
+ roop_count < (int) spider_param_udf_table_mon_mutex_count();
+ roop_count++
+ ) {
+ if (spider_bit_is_set(share->table_mon_mutex_bitmap, roop_count))
+ pthread_mutex_unlock(&spider_udf_table_mon_mutexes[roop_count]);
+ }
pthread_mutex_unlock(&share->mutex);
}
@@ -5009,6 +5085,7 @@ SPIDER_SHARE *spider_get_share(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
FALSE
);
}
@@ -5124,59 +5201,6 @@ SPIDER_SHARE *spider_get_share(
{
thd->clear_error();
}
-/*
- if (
- (*error_num = spider_get_sts(share, spider->search_link_idx,
- tmp_time, spider, sts_interval, sts_mode,
-#ifdef WITH_PARTITION_STORAGE_ENGINE
- sts_sync,
-#endif
- 1)) ||
- (*error_num = spider_get_crd(share, spider->search_link_idx,
- tmp_time, spider, table, crd_interval, crd_mode,
-#ifdef WITH_PARTITION_STORAGE_ENGINE
- crd_sync,
-#endif
- 1))
- ) {
- if (
- share->monitoring_kind[spider->search_link_idx] &&
- spider->need_mons[spider->search_link_idx]
- ) {
- *error_num = spider_ping_table_mon_from_table(
- spider->trx,
- spider->trx->thd,
- share,
- share->monitoring_sid[spider->search_link_idx],
- share->table_name,
- share->table_name_length,
- spider->conn_link_idx[spider->search_link_idx],
- NULL,
- 0,
- share->monitoring_kind[spider->search_link_idx],
- share->monitoring_limit[spider->search_link_idx],
- FALSE
- );
- }
- if (
- spider_init_error_table ||
- (spider_init_error_table =
- spider_get_init_error_table(spider->trx, share, TRUE))
- ) {
- spider_init_error_table->init_error = *error_num;
- if ((spider_init_error_table->init_error_with_message =
- thd->is_error()))
- strmov(spider_init_error_table->init_error_msg,
- spider_stmt_da_message(thd));
- spider_init_error_table->init_error_time =
- (time_t) time((time_t*) 0);
- }
- pthread_mutex_unlock(&share->crd_mutex);
- pthread_mutex_unlock(&share->sts_mutex);
- spider_free_share(share);
- goto error_but_no_delete;
- }
-*/
}
share->init_error = FALSE;
}
@@ -5251,6 +5275,42 @@ int spider_free_share(
DBUG_RETURN(0);
}
+void spider_update_link_status_for_share(
+ const char *table_name,
+ uint table_name_length,
+ int link_idx,
+ long link_status
+) {
+ SPIDER_SHARE *share;
+ DBUG_ENTER("spider_update_link_status_for_share");
+
+#ifdef SPIDER_HAS_HASH_VALUE_TYPE
+ my_hash_value_type hash_value = my_calc_hash(&spider_open_tables,
+ (uchar*) table_name, table_name_length);
+#endif
+ pthread_mutex_lock(&spider_tbl_mutex);
+#ifdef SPIDER_HAS_HASH_VALUE_TYPE
+ if ((share = (SPIDER_SHARE*) my_hash_search_using_hash_value(
+ &spider_open_tables, hash_value, (uchar*) table_name,
+ table_name_length)))
+#else
+ if ((share = (SPIDER_SHARE*) my_hash_search(&spider_open_tables,
+ (uchar*) table_name, table_name_length)))
+#endif
+ {
+ DBUG_PRINT("info", ("spider share->link_status_init=%s",
+ share->link_status_init ? "TRUE" : "FALSE"));
+ if (share->link_status_init)
+ {
+ DBUG_PRINT("info", ("spider share->link_statuses[%d]=%ld",
+ link_idx, link_status));
+ share->link_statuses[link_idx] = link_status;
+ }
+ }
+ pthread_mutex_unlock(&spider_tbl_mutex);
+ DBUG_VOID_RETURN;
+}
+
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
SPIDER_LGTM_TBLHND_SHARE *spider_get_lgtm_tblhnd_share(
const char *table_name,
@@ -6269,6 +6329,8 @@ int spider_db_init(
HMODULE current_module = GetModuleHandle(NULL);
spd_db_att_thread_id = (ulong *)
GetProcAddress(current_module, "?thread_id@@3KA");
+#ifdef SPIDER_XID_USES_xid_cache_iterate
+#else
#ifdef XID_CACHE_IS_SPLITTED
spd_db_att_xid_cache_split_num = (uint *)
GetProcAddress(current_module,
@@ -6290,6 +6352,7 @@ int spider_db_init(
spd_db_att_xid_cache = (HASH *)
GetProcAddress(current_module, "?xid_cache@@3Ust_hash@@A");
#endif
+#endif
spd_charset_utf8_bin = (struct charset_info_st *)
GetProcAddress(current_module, "my_charset_utf8_bin");
spd_defaults_extra_file = (const char **)
@@ -6300,6 +6363,8 @@ int spider_db_init(
GetProcAddress(current_module, "?abort_loop@@3_NC");
#else
spd_db_att_thread_id = &thread_id;
+#ifdef SPIDER_XID_USES_xid_cache_iterate
+#else
#ifdef XID_CACHE_IS_SPLITTED
spd_db_att_xid_cache_split_num = &opt_xid_cache_split_num;
spd_db_att_LOCK_xid_cache = LOCK_xid_cache;
@@ -6308,6 +6373,7 @@ int spider_db_init(
spd_db_att_LOCK_xid_cache = &LOCK_xid_cache;
spd_db_att_xid_cache = &xid_cache;
#endif
+#endif
spd_charset_utf8_bin = &my_charset_utf8_bin;
spd_defaults_extra_file = &my_defaults_extra_file;
spd_defaults_file = &my_defaults_file;
@@ -7490,26 +7556,28 @@ void spider_set_tmp_share_pointer(
tmp_share->tgt_ports = &tmp_long[0];
tmp_share->tgt_ssl_vscs = &tmp_long[1];
tmp_share->link_statuses = &tmp_long[2];
- tmp_share->monitoring_kind = &tmp_long[3];
+ tmp_share->monitoring_flag = &tmp_long[3];
+ tmp_share->monitoring_kind = &tmp_long[4];
#ifndef WITHOUT_SPIDER_BG_SEARCH
- tmp_share->monitoring_bg_kind = &tmp_long[4];
+ tmp_share->monitoring_bg_flag = &tmp_long[5];
+ tmp_share->monitoring_bg_kind = &tmp_long[6];
#endif
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
- tmp_share->use_hs_reads = &tmp_long[5];
- tmp_share->use_hs_writes = &tmp_long[6];
- tmp_share->hs_read_ports = &tmp_long[7];
- tmp_share->hs_write_ports = &tmp_long[8];
- tmp_share->hs_write_to_reads = &tmp_long[9];
-#endif
- tmp_share->use_handlers = &tmp_long[10];
- tmp_share->connect_timeouts = &tmp_long[11];
- tmp_long[11] = -1;
- tmp_share->net_read_timeouts = &tmp_long[12];
- tmp_long[12] = -1;
- tmp_share->net_write_timeouts = &tmp_long[13];
+ tmp_share->use_hs_reads = &tmp_long[7];
+ tmp_share->use_hs_writes = &tmp_long[8];
+ tmp_share->hs_read_ports = &tmp_long[9];
+ tmp_share->hs_write_ports = &tmp_long[10];
+ tmp_share->hs_write_to_reads = &tmp_long[11];
+#endif
+ tmp_share->use_handlers = &tmp_long[12];
+ tmp_share->connect_timeouts = &tmp_long[13];
tmp_long[13] = -1;
- tmp_share->access_balances = &tmp_long[14];
- tmp_share->bka_table_name_types = &tmp_long[15];
+ tmp_share->net_read_timeouts = &tmp_long[14];
+ tmp_long[14] = -1;
+ tmp_share->net_write_timeouts = &tmp_long[15];
+ tmp_long[15] = -1;
+ tmp_share->access_balances = &tmp_long[16];
+ tmp_share->bka_table_name_types = &tmp_long[17];
tmp_share->monitoring_limit = &tmp_longlong[0];
tmp_share->monitoring_sid = &tmp_longlong[1];
#ifndef WITHOUT_SPIDER_BG_SEARCH
@@ -7556,8 +7624,10 @@ void spider_set_tmp_share_pointer(
tmp_share->tgt_ports_length = 1;
tmp_share->tgt_ssl_vscs_length = 1;
tmp_share->link_statuses_length = 1;
+ tmp_share->monitoring_flag_length = 1;
tmp_share->monitoring_kind_length = 1;
#ifndef WITHOUT_SPIDER_BG_SEARCH
+ tmp_share->monitoring_bg_flag_length = 1;
tmp_share->monitoring_bg_kind_length = 1;
#endif
tmp_share->monitoring_limit_length = 1;
@@ -7582,8 +7652,10 @@ void spider_set_tmp_share_pointer(
tmp_share->bka_table_name_types_length = 1;
#ifndef WITHOUT_SPIDER_BG_SEARCH
+ tmp_share->monitoring_bg_flag[0] = -1;
tmp_share->monitoring_bg_kind[0] = -1;
#endif
+ tmp_share->monitoring_flag[0] = -1;
tmp_share->monitoring_kind[0] = -1;
#ifndef WITHOUT_SPIDER_BG_SEARCH
tmp_share->monitoring_bg_interval[0] = -1;
@@ -8009,9 +8081,12 @@ bool spider_check_direct_order_limit(
#if MYSQL_VERSION_ID < 50500
!thd->variables.engine_condition_pushdown ||
#else
+#ifdef SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON
+#else
!(thd->variables.optimizer_switch &
OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) ||
#endif
+#endif
#ifdef SPIDER_NEED_CHECK_CONDITION_AT_CHECKING_DIRECT_ORDER_LIMIT
!spider->condition ||
#endif
@@ -8461,10 +8536,7 @@ int spider_discover_table_structure(
str.q_append(table_charset->name, collatelen);
str.q_append(SPIDER_SQL_COMMENT_STR, SPIDER_SQL_COMMENT_LEN);
str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
- if (str.append_for_single_quote(share->comment.str, share->comment.length))
- {
- DBUG_RETURN(HA_ERR_OUT_OF_MEM);
- }
+ str.append_escape_string(share->comment.str, share->comment.length);
if (str.reserve(SPIDER_SQL_CONNECTION_LEN +
(SPIDER_SQL_VALUE_QUOTE_LEN * 2)))
{
@@ -8473,11 +8545,8 @@ int spider_discover_table_structure(
str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
str.q_append(SPIDER_SQL_CONNECTION_STR, SPIDER_SQL_CONNECTION_LEN);
str.q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
- if (str.append_for_single_quote(share->connect_string.str,
- share->connect_string.length))
- {
- DBUG_RETURN(HA_ERR_OUT_OF_MEM);
- }
+ str.append_escape_string(share->connect_string.str,
+ share->connect_string.length);
if (str.reserve(SPIDER_SQL_VALUE_QUOTE_LEN))
{
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
diff --git a/storage/spider/spd_table.h b/storage/spider/spd_table.h
index e9d1d5c61c2..c2f17417dc6 100644
--- a/storage/spider/spd_table.h
+++ b/storage/spider/spd_table.h
@@ -204,6 +204,13 @@ int spider_free_share(
SPIDER_SHARE *share
);
+void spider_update_link_status_for_share(
+ const char *table_name,
+ uint table_name_length,
+ int link_idx,
+ long link_status
+);
+
#ifdef WITH_PARTITION_STORAGE_ENGINE
SPIDER_PARTITION_SHARE *spider_get_pt_share(
SPIDER_SHARE *share,
diff --git a/storage/spider/spd_trx.cc b/storage/spider/spd_trx.cc
index a66fa5a7f5d..d7127fa0084 100644
--- a/storage/spider/spd_trx.cc
+++ b/storage/spider/spd_trx.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2014 Kentoku Shiba
+/* Copyright (C) 2008-2015 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -38,11 +38,14 @@
#include "spd_ping_table.h"
#include "spd_malloc.h"
+#ifdef SPIDER_XID_USES_xid_cache_iterate
+#else
#ifdef XID_CACHE_IS_SPLITTED
extern uint *spd_db_att_xid_cache_split_num;
#endif
extern pthread_mutex_t *spd_db_att_LOCK_xid_cache;
extern HASH *spd_db_att_xid_cache;
+#endif
extern struct charset_info_st *spd_charset_utf8_bin;
extern handlerton *spider_hton_ptr;
@@ -1641,6 +1644,8 @@ int spider_xa_lock(
int error_num;
const char *old_proc_info;
DBUG_ENTER("spider_xa_lock");
+#ifdef SPIDER_XID_USES_xid_cache_iterate
+#else
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
my_hash_value_type hash_value = my_calc_hash(spd_db_att_xid_cache,
(uchar*) xid_state->xid.key(), xid_state->xid.key_length());
@@ -1648,7 +1653,15 @@ int spider_xa_lock(
uint idx = hash_value % *spd_db_att_xid_cache_split_num;
#endif
#endif
+#endif
old_proc_info = thd_proc_info(thd, "Locking xid by Spider");
+#ifdef SPIDER_XID_USES_xid_cache_iterate
+ if (xid_cache_insert(thd, xid_state))
+ {
+ error_num = my_errno;
+ goto error;
+ }
+#else
#ifdef XID_CACHE_IS_SPLITTED
pthread_mutex_lock(&spd_db_att_LOCK_xid_cache[idx]);
#else
@@ -1690,15 +1703,19 @@ int spider_xa_lock(
#else
pthread_mutex_unlock(spd_db_att_LOCK_xid_cache);
#endif
+#endif
thd_proc_info(thd, old_proc_info);
DBUG_RETURN(0);
error:
+#ifdef SPIDER_XID_USES_xid_cache_iterate
+#else
#ifdef XID_CACHE_IS_SPLITTED
pthread_mutex_unlock(&spd_db_att_LOCK_xid_cache[idx]);
#else
pthread_mutex_unlock(spd_db_att_LOCK_xid_cache);
#endif
+#endif
thd_proc_info(thd, old_proc_info);
DBUG_RETURN(error_num);
}
@@ -1709,6 +1726,8 @@ int spider_xa_unlock(
THD *thd = current_thd;
const char *old_proc_info;
DBUG_ENTER("spider_xa_unlock");
+#ifdef SPIDER_XID_USES_xid_cache_iterate
+#else
#if defined(SPIDER_HAS_HASH_VALUE_TYPE) && defined(HASH_UPDATE_WITH_HASH_VALUE)
my_hash_value_type hash_value = my_calc_hash(spd_db_att_xid_cache,
(uchar*) xid_state->xid.key(), xid_state->xid.key_length());
@@ -1716,7 +1735,11 @@ int spider_xa_unlock(
uint idx = hash_value % *spd_db_att_xid_cache_split_num;
#endif
#endif
+#endif
old_proc_info = thd_proc_info(thd, "Unlocking xid by Spider");
+#ifdef SPIDER_XID_USES_xid_cache_iterate
+ xid_cache_delete(thd, xid_state);
+#else
#ifdef XID_CACHE_IS_SPLITTED
pthread_mutex_lock(&spd_db_att_LOCK_xid_cache[idx]);
#else
@@ -1738,6 +1761,7 @@ int spider_xa_unlock(
#else
pthread_mutex_unlock(spd_db_att_LOCK_xid_cache);
#endif
+#endif
thd_proc_info(thd, old_proc_info);
DBUG_RETURN(0);
}
@@ -1857,7 +1881,9 @@ int spider_internal_start_trx(
trx->internal_xid_state.xa_state = XA_ACTIVE;
trx->internal_xid_state.xid.set(&trx->xid);
+#ifdef SPIDER_XID_STATE_HAS_in_thd
trx->internal_xid_state.in_thd = 1;
+#endif
if ((error_num = spider_xa_lock(&trx->internal_xid_state)))
{
if (error_num == ER_SPIDER_XA_LOCKED_NUM)
@@ -3729,6 +3755,7 @@ int spider_check_trx_and_get_conn(
spider->hs_w_conns[roop_count] = NULL;
#endif
}
+ bool search_link_idx_is_checked = FALSE;
for (
roop_count = spider_conn_link_idx_next(share->link_statuses,
spider->conn_link_idx, -1, share->link_count,
@@ -3740,6 +3767,8 @@ int spider_check_trx_and_get_conn(
) {
uint tgt_conn_kind = (use_conn_kind ? spider->conn_kind[roop_count] :
SPIDER_CONN_KIND_MYSQL);
+ if (roop_count == spider->search_link_idx)
+ search_link_idx_is_checked = TRUE;
if (
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
(
@@ -3780,6 +3809,7 @@ int spider_check_trx_and_get_conn(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -3821,6 +3851,7 @@ int spider_check_trx_and_get_conn(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -3834,9 +3865,41 @@ int spider_check_trx_and_get_conn(
#endif
#endif
}
+ if (!search_link_idx_is_checked)
+ {
+ TABLE *table = spider->get_table();
+ TABLE_SHARE *table_share = table->s;
+#ifdef _MSC_VER
+ char *db, *table_name;
+ if (!(db = (char *)
+ spider_bulk_malloc(spider_current_trx, 57, MYF(MY_WME),
+ &db, table_share->db.length + 1,
+ &table_name, table_share->table_name.length + 1,
+ NullS))
+ ) {
+ my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+#else
+ char db[table_share->db.length + 1],
+ table_name[table_share->table_name.length + 1];
+#endif
+ memcpy(db, table_share->db.str, table_share->db.length);
+ db[table_share->db.length] = '\0';
+ memcpy(table_name, table_share->table_name.str,
+ table_share->table_name.length);
+ table_name[table_share->table_name.length] = '\0';
+ my_printf_error(ER_SPIDER_LINK_MON_JUST_NG_NUM,
+ ER_SPIDER_LINK_MON_JUST_NG_STR, MYF(0), db, table_name);
+#ifdef _MSC_VER
+ spider_free(trx, db, MYF(MY_WME));
+#endif
+ DBUG_RETURN(ER_SPIDER_LINK_MON_JUST_NG_NUM);
+ }
} else {
DBUG_PRINT("info",("spider link_status = %ld",
share->link_statuses[spider->conn_link_idx[spider->search_link_idx]]));
+ bool search_link_idx_is_checked = FALSE;
for (
roop_count = spider_conn_link_idx_next(share->link_statuses,
spider->conn_link_idx, -1, share->link_count,
@@ -3846,6 +3909,8 @@ int spider_check_trx_and_get_conn(
spider->conn_link_idx, roop_count, share->link_count,
SPIDER_LINK_STATUS_RECOVERY)
) {
+ if (roop_count == spider->search_link_idx)
+ search_link_idx_is_checked = TRUE;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
if (
!use_conn_kind ||
@@ -3890,6 +3955,7 @@ int spider_check_trx_and_get_conn(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -3932,6 +3998,7 @@ int spider_check_trx_and_get_conn(
0,
share->monitoring_kind[roop_count],
share->monitoring_limit[roop_count],
+ share->monitoring_flag[roop_count],
TRUE
);
}
@@ -3944,6 +4011,37 @@ int spider_check_trx_and_get_conn(
#endif
#endif
}
+ if (!search_link_idx_is_checked)
+ {
+ TABLE *table = spider->get_table();
+ TABLE_SHARE *table_share = table->s;
+#ifdef _MSC_VER
+ char *db, *table_name;
+ if (!(db = (char *)
+ spider_bulk_malloc(spider_current_trx, 57, MYF(MY_WME),
+ &db, table_share->db.length + 1,
+ &table_name, table_share->table_name.length + 1,
+ NullS))
+ ) {
+ my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
+ DBUG_RETURN(HA_ERR_OUT_OF_MEM);
+ }
+#else
+ char db[table_share->db.length + 1],
+ table_name[table_share->table_name.length + 1];
+#endif
+ memcpy(db, table_share->db.str, table_share->db.length);
+ db[table_share->db.length] = '\0';
+ memcpy(table_name, table_share->table_name.str,
+ table_share->table_name.length);
+ table_name[table_share->table_name.length] = '\0';
+ my_printf_error(ER_SPIDER_LINK_MON_JUST_NG_NUM,
+ ER_SPIDER_LINK_MON_JUST_NG_STR, MYF(0), db, table_name);
+#ifdef _MSC_VER
+ spider_free(trx, db, MYF(MY_WME));
+#endif
+ DBUG_RETURN(ER_SPIDER_LINK_MON_JUST_NG_NUM);
+ }
}
spider->set_first_link_idx();
DBUG_RETURN(spider_create_trx_ha(trx, spider, trx_ha));