Merge Spider 3.2.11
This commit is contained in:
parent
c338772a59
commit
391fddf660
@ -33,9 +33,7 @@ IF(EXISTS ${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake)
|
||||
|
||||
MYSQL_STORAGE_ENGINE(SPIDER)
|
||||
ELSE()
|
||||
INCLUDE_DIRECTORIES(
|
||||
${CMAKE_SOURCE_DIR}/storage/spider/hs_client
|
||||
${ORACLE_INCLUDE_DIR})
|
||||
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/spider/hs_client)
|
||||
|
||||
INSTALL(FILES
|
||||
${CMAKE_SOURCE_DIR}/storage/spider/scripts/install_spider.sql
|
||||
@ -46,7 +44,11 @@ ELSE()
|
||||
ENDIF()
|
||||
|
||||
IF(ORACLE_INCLUDE_DIR AND ORACLE_OCI_LIBRARY)
|
||||
SET(SPIDER_WITH_ORACLE_OCI OFF CACHE BOOL "Spider is compiled with Oracle OCI library.")
|
||||
IF(SPIDER_WITH_ORACLE_OCI)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_ORACLE_OCI -DLINUX -D_GNU_SOURCE -D_REENTRANT")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_ORACLE_OCI -DLINUX -D_GNU_SOURCE -D_REENTRANT")
|
||||
INCLUDE_DIRECTORIES(${ORACLE_INCLUDE_DIR})
|
||||
TARGET_LINK_LIBRARIES (spider ${ORACLE_OCI_LIBRARY})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
@ -158,6 +158,7 @@ ha_spider::ha_spider(
|
||||
result_list.direct_aggregate = FALSE;
|
||||
result_list.snap_direct_aggregate = FALSE;
|
||||
#endif
|
||||
result_list.direct_distinct = FALSE;
|
||||
result_list.casual_read = NULL;
|
||||
result_list.use_both_key = FALSE;
|
||||
DBUG_VOID_RETURN;
|
||||
@ -264,6 +265,7 @@ ha_spider::ha_spider(
|
||||
result_list.direct_aggregate = FALSE;
|
||||
result_list.snap_direct_aggregate = FALSE;
|
||||
#endif
|
||||
result_list.direct_distinct = FALSE;
|
||||
result_list.casual_read = NULL;
|
||||
result_list.use_both_key = FALSE;
|
||||
ref_length = sizeof(SPIDER_POSITION);
|
||||
@ -1585,6 +1587,7 @@ int ha_spider::reset()
|
||||
result_list.direct_aggregate = FALSE;
|
||||
result_list.snap_direct_aggregate = FALSE;
|
||||
#endif
|
||||
result_list.direct_distinct = FALSE;
|
||||
store_error_num = 0;
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
if (
|
||||
@ -7765,9 +7768,6 @@ void ha_spider::ft_end()
|
||||
{
|
||||
DBUG_ENTER("ha_spider::ft_end");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
ft_handler = NULL;
|
||||
ft_current = NULL;
|
||||
ft_count = 0;
|
||||
if (ft_init_without_index_init)
|
||||
{
|
||||
if (ft_init_idx == MAX_KEY)
|
||||
@ -8183,15 +8183,13 @@ int ha_spider::info(
|
||||
auto_inc_temporary = FALSE;
|
||||
#endif
|
||||
sql_command = thd_sql_command(thd);
|
||||
if (
|
||||
/*
|
||||
if (
|
||||
sql_command == SQLCOM_DROP_TABLE ||
|
||||
sql_command == SQLCOM_ALTER_TABLE ||
|
||||
sql_command == SQLCOM_SHOW_CREATE
|
||||
*/
|
||||
sql_command == SQLCOM_DROP_TABLE ||
|
||||
sql_command == SQLCOM_ALTER_TABLE
|
||||
) {
|
||||
*/
|
||||
if (flag & HA_STATUS_AUTO)
|
||||
{
|
||||
if (share->lgtm_tblhnd_share->auto_increment_value)
|
||||
@ -8204,8 +8202,14 @@ int ha_spider::info(
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (
|
||||
sql_command == SQLCOM_DROP_TABLE ||
|
||||
sql_command == SQLCOM_ALTER_TABLE
|
||||
)
|
||||
DBUG_RETURN(0);
|
||||
/*
|
||||
}
|
||||
*/
|
||||
|
||||
if (flag &
|
||||
(HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE | HA_STATUS_AUTO))
|
||||
@ -8240,6 +8244,15 @@ int ha_spider::info(
|
||||
spider_param_table_init_error_interval())
|
||||
{
|
||||
pthread_mutex_unlock(&share->sts_mutex);
|
||||
if (sql_command == SQLCOM_SHOW_CREATE)
|
||||
{
|
||||
if (thd->is_error())
|
||||
{
|
||||
DBUG_PRINT("info", ("spider clear_error"));
|
||||
thd->clear_error();
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
if (spider_init_error_table->init_error_with_message)
|
||||
my_message(spider_init_error_table->init_error,
|
||||
spider_init_error_table->init_error_msg, MYF(0));
|
||||
@ -8304,6 +8317,15 @@ int ha_spider::info(
|
||||
share->init_error = TRUE;
|
||||
share->init = TRUE;
|
||||
}
|
||||
if (sql_command == SQLCOM_SHOW_CREATE)
|
||||
{
|
||||
if (thd->is_error())
|
||||
{
|
||||
DBUG_PRINT("info", ("spider clear_error"));
|
||||
thd->clear_error();
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
DBUG_RETURN(check_error_mode(error_num));
|
||||
}
|
||||
if ((error_num = spider_get_sts(share, search_link_idx, tmp_time,
|
||||
@ -8356,6 +8378,15 @@ int ha_spider::info(
|
||||
share->init_error = TRUE;
|
||||
share->init = TRUE;
|
||||
}
|
||||
if (sql_command == SQLCOM_SHOW_CREATE)
|
||||
{
|
||||
if (thd->is_error())
|
||||
{
|
||||
DBUG_PRINT("info", ("spider clear_error"));
|
||||
thd->clear_error();
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
DBUG_RETURN(check_error_mode(error_num));
|
||||
}
|
||||
}
|
||||
@ -8376,6 +8407,15 @@ int ha_spider::info(
|
||||
if ((error_num = spider_create_sts_thread(share)))
|
||||
{
|
||||
pthread_mutex_unlock(&share->sts_mutex);
|
||||
if (sql_command == SQLCOM_SHOW_CREATE)
|
||||
{
|
||||
if (thd->is_error())
|
||||
{
|
||||
DBUG_PRINT("info", ("spider clear_error"));
|
||||
thd->clear_error();
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
} else
|
||||
@ -8389,7 +8429,18 @@ int ha_spider::info(
|
||||
if (flag & HA_STATUS_CONST)
|
||||
{
|
||||
if ((error_num = check_crd()))
|
||||
{
|
||||
if (sql_command == SQLCOM_SHOW_CREATE)
|
||||
{
|
||||
if (thd->is_error())
|
||||
{
|
||||
DBUG_PRINT("info", ("spider clear_error"));
|
||||
thd->clear_error();
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
spider_db_set_cardinarity(this, table);
|
||||
}
|
||||
|
||||
@ -8413,6 +8464,9 @@ int ha_spider::info(
|
||||
}
|
||||
if (flag & HA_STATUS_AUTO)
|
||||
{
|
||||
#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT
|
||||
auto_inc_temporary = FALSE;
|
||||
#endif
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
if (share->partition_share && table->next_number_field)
|
||||
{
|
||||
@ -8481,6 +8535,7 @@ ha_rows ha_spider::records_in_range(
|
||||
spider_db_handler *dbton_hdl;
|
||||
DBUG_ENTER("ha_spider::records_in_range");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
DBUG_PRINT("info",("spider inx=%u", inx));
|
||||
time_t tmp_time = (time_t) time((time_t*) 0);
|
||||
if (!share->crd_init)
|
||||
{
|
||||
@ -8517,12 +8572,16 @@ ha_rows ha_spider::records_in_range(
|
||||
crd_mode = dbton_hdl->crd_mode_exchange(crd_mode);
|
||||
if (crd_mode == 1 || crd_mode == 2)
|
||||
{
|
||||
DBUG_PRINT("info", ("spider static_key_cardinality[%u]=%lld", inx,
|
||||
share->static_key_cardinality[inx]));
|
||||
DBUG_PRINT("info",
|
||||
("spider difftime=%f", difftime(tmp_time, share->crd_get_time)));
|
||||
DBUG_PRINT("info",
|
||||
("spider crd_interval=%f", crd_interval));
|
||||
if (difftime(tmp_time, share->crd_get_time) >= crd_interval)
|
||||
{
|
||||
if (
|
||||
share->static_key_cardinality[inx] == -1 &&
|
||||
difftime(tmp_time, share->crd_get_time) >= crd_interval
|
||||
) {
|
||||
if (
|
||||
crd_interval == 0 ||
|
||||
!pthread_mutex_trylock(&share->crd_mutex)
|
||||
@ -8654,6 +8713,8 @@ ha_rows ha_spider::records_in_range(
|
||||
else
|
||||
weight = 1;
|
||||
|
||||
if (share->static_key_cardinality[inx] == -1)
|
||||
{
|
||||
for (
|
||||
key_part = key_info->key_part;
|
||||
tgt_key_part_map > 1;
|
||||
@ -8661,6 +8722,17 @@ ha_rows ha_spider::records_in_range(
|
||||
key_part++
|
||||
) {
|
||||
field = key_part->field;
|
||||
DBUG_PRINT("info",
|
||||
("spider field_index=%u",
|
||||
field->field_index));
|
||||
DBUG_PRINT("info",
|
||||
("spider cardinality=%lld", share->cardinality[field->field_index]));
|
||||
if (share->cardinality[field->field_index] == -1)
|
||||
{
|
||||
DBUG_PRINT("info",
|
||||
("spider uninitialized column cardinality"));
|
||||
DBUG_RETURN(HA_POS_ERROR);
|
||||
}
|
||||
if ((rate =
|
||||
((double) share->cardinality[field->field_index]) / weight) >= 1
|
||||
) {
|
||||
@ -8676,22 +8748,54 @@ ha_rows ha_spider::records_in_range(
|
||||
weight *= spider_param_crd_weight(thd, share->crd_weight);
|
||||
}
|
||||
field = key_part->field;
|
||||
DBUG_PRINT("info",
|
||||
("spider field_index=%u",
|
||||
field->field_index));
|
||||
DBUG_PRINT("info",
|
||||
("spider cardinality=%lld", share->cardinality[field->field_index]));
|
||||
if (share->cardinality[field->field_index] == -1)
|
||||
{
|
||||
DBUG_PRINT("info",
|
||||
("spider uninitialized column cardinality"));
|
||||
DBUG_RETURN(HA_POS_ERROR);
|
||||
}
|
||||
}
|
||||
if (
|
||||
start_key_part_map >= end_key_part_map &&
|
||||
start_key->flag == HA_READ_KEY_EXACT
|
||||
) {
|
||||
if (share->static_key_cardinality[inx] == -1)
|
||||
{
|
||||
if ((rate =
|
||||
((double) share->cardinality[field->field_index]) / weight) >= 1)
|
||||
rows = rows / rate;
|
||||
} else {
|
||||
rate = ((double) share->static_key_cardinality[inx]);
|
||||
rows = rows / rate;
|
||||
}
|
||||
} else if (start_key_part_map == end_key_part_map)
|
||||
{
|
||||
if (share->static_key_cardinality[inx] == -1)
|
||||
{
|
||||
if ((rate =
|
||||
((double) share->cardinality[field->field_index]) / weight / 4) >= 1)
|
||||
rows = rows / rate;
|
||||
} else {
|
||||
if ((rate =
|
||||
((double) share->static_key_cardinality[inx]) / 4) >= 1)
|
||||
rows = rows / rate;
|
||||
}
|
||||
} else {
|
||||
if (share->static_key_cardinality[inx] == -1)
|
||||
{
|
||||
if ((rate =
|
||||
((double) share->cardinality[field->field_index]) / weight / 16) >= 1)
|
||||
rows = rows / rate;
|
||||
} else {
|
||||
if ((rate =
|
||||
((double) share->static_key_cardinality[inx]) / 16) >= 1)
|
||||
rows = rows / rate;
|
||||
}
|
||||
}
|
||||
if (rows < 2)
|
||||
{
|
||||
@ -10270,6 +10374,17 @@ ha_rows ha_spider::estimate_rows_upper_bound()
|
||||
DBUG_RETURN(HA_POS_ERROR);
|
||||
}
|
||||
|
||||
void ha_spider::print_error(
|
||||
int error,
|
||||
myf errflag
|
||||
) {
|
||||
DBUG_ENTER("ha_spider::print_error");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
if (!current_thd->is_error())
|
||||
handler::print_error(error, errflag);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
bool ha_spider::get_error_message(
|
||||
int error,
|
||||
String *buf
|
||||
@ -10350,12 +10465,23 @@ int ha_spider::create(
|
||||
{
|
||||
goto error;
|
||||
}
|
||||
if (form->s->keys > 0 &&
|
||||
!(tmp_share.key_hint = new spider_string[form->s->keys])
|
||||
if (form->s->keys > 0)
|
||||
{
|
||||
if (!(tmp_share.static_key_cardinality = (longlong *)
|
||||
spider_bulk_malloc(spider_current_trx, 246, MYF(MY_WME),
|
||||
&tmp_share.static_key_cardinality,
|
||||
sizeof(*tmp_share.static_key_cardinality) * form->s->keys,
|
||||
NullS))
|
||||
) {
|
||||
error_num = HA_ERR_OUT_OF_MEM;
|
||||
goto error;
|
||||
}
|
||||
if (!(tmp_share.key_hint = new spider_string[form->s->keys]))
|
||||
{
|
||||
error_num = HA_ERR_OUT_OF_MEM;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
for (roop_count = 0; roop_count < form->s->keys; roop_count++)
|
||||
tmp_share.key_hint[roop_count].init_calc_mem(85);
|
||||
DBUG_PRINT("info",("spider tmp_share.key_hint=%p", tmp_share.key_hint));
|
||||
@ -10460,6 +10586,8 @@ int ha_spider::create(
|
||||
pthread_mutex_unlock(&tmp_share.lgtm_tblhnd_share->auto_increment_mutex);
|
||||
}
|
||||
|
||||
if (tmp_share.static_key_cardinality)
|
||||
spider_free(spider_current_trx, tmp_share.static_key_cardinality, MYF(0));
|
||||
spider_free_share_alloc(&tmp_share);
|
||||
DBUG_RETURN(0);
|
||||
|
||||
@ -10469,6 +10597,8 @@ error:
|
||||
&open_tables_backup, need_lock);
|
||||
if (tmp_share.lgtm_tblhnd_share)
|
||||
spider_free_lgtm_tblhnd_share_alloc(tmp_share.lgtm_tblhnd_share, FALSE);
|
||||
if (tmp_share.static_key_cardinality)
|
||||
spider_free(spider_current_trx, tmp_share.static_key_cardinality, MYF(0));
|
||||
spider_free_share_alloc(&tmp_share);
|
||||
error_alter_before_unlock:
|
||||
error_get_trx:
|
||||
@ -10478,7 +10608,6 @@ error_get_trx:
|
||||
void ha_spider::update_create_info(
|
||||
HA_CREATE_INFO* create_info
|
||||
) {
|
||||
THD *thd = ha_thd();
|
||||
DBUG_ENTER("ha_spider::update_create_info");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
if (!create_info->connect_string.str)
|
||||
@ -10495,13 +10624,6 @@ void ha_spider::update_create_info(
|
||||
info(HA_STATUS_AUTO);
|
||||
create_info->auto_increment_value = stats.auto_increment_value;
|
||||
}
|
||||
if (
|
||||
thd->is_error() &&
|
||||
thd_sql_command(thd) == SQLCOM_SHOW_CREATE
|
||||
) {
|
||||
DBUG_PRINT("info", ("spider clear_error"));
|
||||
thd->clear_error();
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
@ -11363,10 +11485,20 @@ void ha_spider::set_ft_discard_bitmap()
|
||||
}
|
||||
}
|
||||
}
|
||||
item_next = ha_thd()->free_list;
|
||||
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;
|
||||
|
@ -658,6 +658,10 @@ public:
|
||||
#endif
|
||||
const key_map *keys_to_use_for_scanning();
|
||||
ha_rows estimate_rows_upper_bound();
|
||||
void print_error(
|
||||
int error,
|
||||
myf errflag
|
||||
);
|
||||
bool get_error_message(
|
||||
int error,
|
||||
String *buf
|
||||
|
@ -2505,6 +2505,12 @@ void *spider_bg_conn_action(
|
||||
) {
|
||||
if (thd->is_error())
|
||||
{
|
||||
if (
|
||||
direct_sql->error_rw_mode &&
|
||||
spider_db_conn_is_network_error(error_num)
|
||||
) {
|
||||
thd->clear_error();
|
||||
} else {
|
||||
SPIDER_BG_DIRECT_SQL *bg_direct_sql =
|
||||
(SPIDER_BG_DIRECT_SQL *) direct_sql->parent;
|
||||
pthread_mutex_lock(direct_sql->bg_mutex);
|
||||
@ -2515,6 +2521,7 @@ void *spider_bg_conn_action(
|
||||
is_error = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (direct_sql->modified_non_trans_table)
|
||||
{
|
||||
SPIDER_BG_DIRECT_SQL *bg_direct_sql =
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "sql_analyse.h"
|
||||
#include "sql_base.h"
|
||||
#include "tztime.h"
|
||||
#include "errmsg.h"
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
#include "sql_select.h"
|
||||
#endif
|
||||
@ -637,8 +638,11 @@ int spider_db_errorno(
|
||||
if (conn->server_lost)
|
||||
{
|
||||
*conn->need_mon = ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM;
|
||||
if (!current_thd->is_error())
|
||||
{
|
||||
my_message(ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM,
|
||||
ER_SPIDER_REMOTE_SERVER_GONE_AWAY_STR, MYF(0));
|
||||
}
|
||||
if (!conn->mta_conn_mutex_unlock_later)
|
||||
{
|
||||
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
|
||||
@ -3199,7 +3203,8 @@ void spider_db_free_one_result_for_start_next(
|
||||
result = (SPIDER_RESULT *) result_list->current;
|
||||
if (
|
||||
!result->result &&
|
||||
!result->first_position
|
||||
!result->first_position &&
|
||||
!result->tmp_tbl_use_position
|
||||
)
|
||||
result_list->current = result->prev;
|
||||
}
|
||||
@ -3263,6 +3268,35 @@ void spider_db_free_one_result(
|
||||
position[roop_count].row = NULL;
|
||||
}
|
||||
}
|
||||
if (result_list->quick_mode == 3)
|
||||
{
|
||||
if (!result->first_pos_use_position)
|
||||
{
|
||||
spider_free(spider_current_trx, position, MYF(0));
|
||||
result->first_position = NULL;
|
||||
}
|
||||
if (result->result)
|
||||
{
|
||||
result->result->free_result();
|
||||
delete result->result;
|
||||
result->result = NULL;
|
||||
}
|
||||
if (!result->tmp_tbl_use_position)
|
||||
{
|
||||
if (result->result_tmp_tbl)
|
||||
{
|
||||
if (result->result_tmp_tbl_inited)
|
||||
{
|
||||
result->result_tmp_tbl->file->ha_rnd_end();
|
||||
result->result_tmp_tbl_inited = 0;
|
||||
}
|
||||
spider_rm_sys_tmp_table_for_result(result->result_tmp_tbl_thd,
|
||||
result->result_tmp_tbl, &result->result_tmp_tbl_prm);
|
||||
result->result_tmp_tbl = NULL;
|
||||
result->result_tmp_tbl_thd = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DBUG_VOID_RETURN;
|
||||
@ -3472,6 +3506,8 @@ int spider_db_free_result(
|
||||
result->record_num = 0;
|
||||
DBUG_PRINT("info",("spider result->finish_flg = FALSE"));
|
||||
result->finish_flg = FALSE;
|
||||
result->first_pos_use_position = FALSE;
|
||||
result->tmp_tbl_use_position = FALSE;
|
||||
result->use_position = FALSE;
|
||||
result = (SPIDER_RESULT*) result->next;
|
||||
}
|
||||
@ -3872,8 +3908,10 @@ int spider_db_store_result(
|
||||
DBUG_PRINT("info", ("spider conn[%p]->quick_target=NULL", conn));
|
||||
conn->quick_target = NULL;
|
||||
spider->quick_targets[link_idx] = NULL;
|
||||
} else if (result_list->limit_num == roop_count)
|
||||
{
|
||||
} else if (
|
||||
result_list->quick_mode == 3 ||
|
||||
result_list->limit_num == roop_count
|
||||
) {
|
||||
current->result->free_result();
|
||||
if (!current->result_tmp_tbl)
|
||||
{
|
||||
@ -4176,6 +4214,7 @@ int spider_db_seek_next(
|
||||
spider_next_split_read_param(spider);
|
||||
if (
|
||||
result_list->quick_mode == 0 ||
|
||||
result_list->quick_mode == 3 ||
|
||||
!result_list->current->result
|
||||
) {
|
||||
result_list->limit_num =
|
||||
@ -4839,6 +4878,7 @@ void spider_db_create_position(
|
||||
tmp_pos->use_position = TRUE;
|
||||
tmp_pos->pos_mode = 0;
|
||||
pos->pos_mode = 0;
|
||||
current->first_pos_use_position = TRUE;
|
||||
} else {
|
||||
TABLE *tmp_tbl = current->result_tmp_tbl;
|
||||
pos->row = NULL;
|
||||
@ -4848,6 +4888,7 @@ void spider_db_create_position(
|
||||
DBUG_PRINT("info",("spider tmp_tbl->file->ref=%p", tmp_tbl->file->ref));
|
||||
tmp_tbl->file->ref = (uchar *) &pos->tmp_tbl_pos;
|
||||
tmp_tbl->file->position(tmp_tbl->record[0]);
|
||||
current->tmp_tbl_use_position = TRUE;
|
||||
}
|
||||
}
|
||||
current->use_position = TRUE;
|
||||
@ -10256,3 +10297,20 @@ void spider_db_hs_request_buf_reset(
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool spider_db_conn_is_network_error(
|
||||
int error_num
|
||||
) {
|
||||
DBUG_ENTER("spider_db_conn_is_network_error");
|
||||
if (
|
||||
error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM ||
|
||||
error_num == ER_CONNECT_TO_FOREIGN_DATA_SOURCE ||
|
||||
(
|
||||
error_num >= CR_MIN_ERROR &&
|
||||
error_num <= CR_MAX_ERROR
|
||||
)
|
||||
) {
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
@ -69,6 +69,8 @@
|
||||
#define SPIDER_SQL_UPDATE_LEN (sizeof(SPIDER_SQL_UPDATE_STR) - 1)
|
||||
#define SPIDER_SQL_DELETE_STR "delete "
|
||||
#define SPIDER_SQL_DELETE_LEN (sizeof(SPIDER_SQL_DELETE_STR) - 1)
|
||||
#define SPIDER_SQL_DISTINCT_STR "distinct "
|
||||
#define SPIDER_SQL_DISTINCT_LEN (sizeof(SPIDER_SQL_DISTINCT_STR) - 1)
|
||||
#define SPIDER_SQL_HIGH_PRIORITY_STR "high_priority "
|
||||
#define SPIDER_SQL_HIGH_PRIORITY_LEN (sizeof(SPIDER_SQL_HIGH_PRIORITY_STR) - 1)
|
||||
#define SPIDER_SQL_LOW_PRIORITY_STR "low_priority "
|
||||
@ -1049,3 +1051,7 @@ void spider_db_hs_request_buf_reset(
|
||||
SPIDER_CONN *conn
|
||||
);
|
||||
#endif
|
||||
|
||||
bool spider_db_conn_is_network_error(
|
||||
int error_num
|
||||
);
|
||||
|
@ -493,7 +493,6 @@ public:
|
||||
uint32 arg_length,
|
||||
uint32 step_alloc
|
||||
);
|
||||
#ifdef SPIDER_HAS_APPEND_FOR_SINGLE_QUOTE
|
||||
bool append_for_single_quote(
|
||||
const char *st,
|
||||
uint len
|
||||
@ -504,7 +503,6 @@ public:
|
||||
bool append_for_single_quote(
|
||||
const char *st
|
||||
);
|
||||
#endif
|
||||
void print(
|
||||
String *print
|
||||
);
|
||||
@ -1566,6 +1564,8 @@ typedef struct st_spider_result
|
||||
longlong record_num;
|
||||
bool finish_flg;
|
||||
bool use_position;
|
||||
bool first_pos_use_position;
|
||||
bool tmp_tbl_use_position;
|
||||
uint field_count; /* for quick mode */
|
||||
TABLE *result_tmp_tbl;
|
||||
TMP_TABLE_PARAM result_tmp_tbl_prm;
|
||||
@ -1642,6 +1642,7 @@ typedef struct st_spider_result_list
|
||||
spider_bulk_upd_start bulk_update_start;
|
||||
bool check_direct_order_limit;
|
||||
bool direct_order_limit;
|
||||
bool direct_distinct;
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
bool direct_aggregate;
|
||||
bool snap_mrr_with_cnt;
|
||||
|
@ -919,13 +919,13 @@ int spider_db_mysql_result::fetch_table_cardinality(
|
||||
Field *field;
|
||||
DBUG_ENTER("spider_db_mysql_result::fetch_table_cardinality");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
memset((uchar *) cardinality_upd, 0, sizeof(uchar) * bitmap_size);
|
||||
if (!(mysql_row = mysql_fetch_row(db_result)))
|
||||
{
|
||||
DBUG_PRINT("info",("spider fetch row is null"));
|
||||
/* no index */
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
memset((uchar *) cardinality_upd, 0, sizeof(uchar) * bitmap_size);
|
||||
if (mode == 1)
|
||||
{
|
||||
uint num_fields = this->num_fields();
|
||||
@ -2096,6 +2096,7 @@ int spider_db_mysql::rollback(
|
||||
int error_num;
|
||||
DBUG_ENTER("spider_db_mysql::rollback");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
conn->mta_conn_mutex_unlock_later = TRUE;
|
||||
if (spider_db_query(
|
||||
conn,
|
||||
SPIDER_SQL_ROLLBACK_STR,
|
||||
@ -2104,7 +2105,6 @@ int spider_db_mysql::rollback(
|
||||
need_mon)
|
||||
) {
|
||||
is_error = conn->thd->is_error();
|
||||
conn->mta_conn_mutex_unlock_later = TRUE;
|
||||
error_num = spider_db_errorno(conn);
|
||||
if (
|
||||
error_num == ER_SPIDER_REMOTE_SERVER_GONE_AWAY_NUM &&
|
||||
@ -4814,6 +4814,21 @@ int spider_mysql_share::discover_table_structure(
|
||||
) {
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
if (!conn->disable_reconnect)
|
||||
{
|
||||
ha_spider tmp_spider;
|
||||
int need_mon = 0;
|
||||
uint tmp_conn_link_idx = 0;
|
||||
tmp_spider.trx = trx;
|
||||
tmp_spider.share = spider_share;
|
||||
tmp_spider.need_mons = &need_mon;
|
||||
tmp_spider.conn_link_idx = &tmp_conn_link_idx;
|
||||
if ((error_num = spider_db_ping(&tmp_spider, conn, 0)))
|
||||
{
|
||||
DBUG_PRINT("info",("spider spider_db_ping error"));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
pthread_mutex_lock(&conn->mta_conn_mutex);
|
||||
SPIDER_SET_FILE_POS(&conn->mta_conn_mutex_file_pos);
|
||||
conn->need_mon = &need_mon;
|
||||
@ -4879,6 +4894,11 @@ int spider_mysql_share::discover_table_structure(
|
||||
conn->mta_conn_mutex_unlock_later = FALSE;
|
||||
SPIDER_CLEAR_FILE_POS(&conn->mta_conn_mutex_file_pos);
|
||||
pthread_mutex_unlock(&conn->mta_conn_mutex);
|
||||
my_printf_error(ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM,
|
||||
ER_SPIDER_REMOTE_TABLE_NOT_FOUND_STR, MYF(0),
|
||||
db_names_str[roop_count].ptr(),
|
||||
table_names_str[roop_count].ptr());
|
||||
error_num = ER_SPIDER_REMOTE_TABLE_NOT_FOUND_NUM;
|
||||
continue;
|
||||
}
|
||||
res->free_result();
|
||||
@ -6238,6 +6258,12 @@ int spider_mysql_handler::append_select(
|
||||
if (str->reserve(SPIDER_SQL_SELECT_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_SELECT_STR, SPIDER_SQL_SELECT_LEN);
|
||||
if (result_list->direct_distinct)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_DISTINCT_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_DISTINCT_STR, SPIDER_SQL_DISTINCT_LEN);
|
||||
}
|
||||
if (result_list->lock_type != F_WRLCK && spider->lock_mode < 1)
|
||||
{
|
||||
/* no lock */
|
||||
@ -10328,6 +10354,14 @@ int spider_mysql_handler::show_table_status(
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
}
|
||||
if (share->static_records_for_status != -1)
|
||||
{
|
||||
share->records = (ha_rows) share->static_records_for_status;
|
||||
}
|
||||
if (share->static_mean_rec_length != -1)
|
||||
{
|
||||
share->mean_rec_length = (ulong) share->static_mean_rec_length;
|
||||
}
|
||||
if (auto_increment_value > share->lgtm_tblhnd_share->auto_increment_value)
|
||||
{
|
||||
share->lgtm_tblhnd_share->auto_increment_value = auto_increment_value;
|
||||
@ -10462,8 +10496,8 @@ int spider_mysql_handler::show_index(
|
||||
if (!spider_bit_is_set(share->cardinality_upd, roop_count))
|
||||
{
|
||||
DBUG_PRINT("info",
|
||||
("spider init column cardinality id=%d", roop_count));
|
||||
*tmp_cardinality = 1;
|
||||
("spider uninitialized column cardinality id=%d", roop_count));
|
||||
*tmp_cardinality = -1;
|
||||
}
|
||||
}
|
||||
if (res)
|
||||
@ -10596,8 +10630,8 @@ int spider_mysql_handler::show_index(
|
||||
if (!spider_bit_is_set(share->cardinality_upd, roop_count))
|
||||
{
|
||||
DBUG_PRINT("info",
|
||||
("spider init column cardinality id=%d", roop_count));
|
||||
*tmp_cardinality = 1;
|
||||
("spider uninitialized column cardinality id=%d", roop_count));
|
||||
*tmp_cardinality = -1;
|
||||
}
|
||||
}
|
||||
if (res)
|
||||
|
@ -5935,6 +5935,12 @@ int spider_oracle_handler::append_select(
|
||||
if (str->reserve(SPIDER_SQL_SELECT_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_SELECT_STR, SPIDER_SQL_SELECT_LEN);
|
||||
if (spider->result_list.direct_distinct)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_DISTINCT_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_DISTINCT_STR, SPIDER_SQL_DISTINCT_LEN);
|
||||
}
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
@ -1045,6 +1045,7 @@ int spider_udf_parse_direct_sql_param(
|
||||
#else
|
||||
direct_sql->use_real_table = -1;
|
||||
#endif
|
||||
direct_sql->error_rw_mode = -1;
|
||||
for (roop_count = 0; roop_count < direct_sql->table_count; roop_count++)
|
||||
direct_sql->iop[roop_count] = -1;
|
||||
|
||||
@ -1123,9 +1124,10 @@ int spider_udf_parse_direct_sql_param(
|
||||
MYF(0), tmp_ptr);
|
||||
goto error;
|
||||
case 4:
|
||||
SPIDER_PARAM_INT_WITH_MAX("erwm", error_rw_mode, 0, 1);
|
||||
SPIDER_PARAM_STR("host", tgt_host);
|
||||
SPIDER_PARAM_STR("user", tgt_username);
|
||||
SPIDER_PARAM_INT_WITH_MAX("port", tgt_port, 0, 65535);
|
||||
SPIDER_PARAM_STR("user", tgt_username);
|
||||
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM;
|
||||
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
|
||||
MYF(0), tmp_ptr);
|
||||
@ -1178,6 +1180,7 @@ int spider_udf_parse_direct_sql_param(
|
||||
goto error;
|
||||
case 13:
|
||||
SPIDER_PARAM_STR("default_group", tgt_default_group);
|
||||
SPIDER_PARAM_INT_WITH_MAX("error_rw_mode", error_rw_mode, 0, 1);
|
||||
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM;
|
||||
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
|
||||
MYF(0), tmp_ptr);
|
||||
@ -1400,6 +1403,8 @@ int spider_udf_set_direct_sql_param_default(
|
||||
if (direct_sql->use_real_table == -1)
|
||||
direct_sql->use_real_table = 0;
|
||||
#endif
|
||||
if (direct_sql->error_rw_mode == -1)
|
||||
direct_sql->error_rw_mode = 0;
|
||||
for (roop_count = 0; roop_count < direct_sql->table_count; roop_count++)
|
||||
{
|
||||
if (direct_sql->iop[roop_count] == -1)
|
||||
@ -1526,12 +1531,14 @@ long long spider_direct_sql_body(
|
||||
uint use_real_table = 0;
|
||||
#endif
|
||||
DBUG_ENTER("spider_direct_sql_body");
|
||||
SPIDER_BACKUP_DASTATUS;
|
||||
if (!(direct_sql = (SPIDER_DIRECT_SQL *)
|
||||
spider_bulk_malloc(spider_current_trx, 34, MYF(MY_WME | MY_ZEROFILL),
|
||||
&direct_sql, sizeof(SPIDER_DIRECT_SQL),
|
||||
&sql, sizeof(char) * args->lengths[0],
|
||||
NullS))
|
||||
) {
|
||||
error_num = HA_ERR_OUT_OF_MEM;
|
||||
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
|
||||
goto error;
|
||||
}
|
||||
@ -1556,6 +1563,7 @@ long long spider_direct_sql_body(
|
||||
#endif
|
||||
if (!(trx = spider_get_trx(thd, TRUE, &error_num)))
|
||||
{
|
||||
if (error_num == HA_ERR_OUT_OF_MEM)
|
||||
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
|
||||
goto error;
|
||||
}
|
||||
@ -1563,41 +1571,43 @@ long long spider_direct_sql_body(
|
||||
|
||||
if (args->args[1])
|
||||
{
|
||||
if (spider_udf_direct_sql_create_table_list(
|
||||
if ((error_num = spider_udf_direct_sql_create_table_list(
|
||||
direct_sql,
|
||||
args->args[1],
|
||||
args->lengths[1]
|
||||
)) {
|
||||
))) {
|
||||
if (error_num == HA_ERR_OUT_OF_MEM)
|
||||
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
if (spider_udf_direct_sql_create_table_list(
|
||||
if ((error_num = spider_udf_direct_sql_create_table_list(
|
||||
direct_sql,
|
||||
(char *) "",
|
||||
0
|
||||
)) {
|
||||
))) {
|
||||
if (error_num == HA_ERR_OUT_OF_MEM)
|
||||
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
if (args->args[2])
|
||||
{
|
||||
if (spider_udf_parse_direct_sql_param(
|
||||
if ((error_num = spider_udf_parse_direct_sql_param(
|
||||
trx,
|
||||
direct_sql,
|
||||
args->args[2],
|
||||
args->lengths[2]
|
||||
)) {
|
||||
))) {
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
if (spider_udf_parse_direct_sql_param(
|
||||
if ((error_num = spider_udf_parse_direct_sql_param(
|
||||
trx,
|
||||
direct_sql,
|
||||
"",
|
||||
0
|
||||
)) {
|
||||
))) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@ -1626,6 +1636,7 @@ long long spider_direct_sql_body(
|
||||
if (!use_real_table)
|
||||
{
|
||||
#endif
|
||||
error_num = ER_SPIDER_UDF_TMP_TABLE_NOT_FOUND_NUM;
|
||||
my_printf_error(ER_SPIDER_UDF_TMP_TABLE_NOT_FOUND_NUM,
|
||||
ER_SPIDER_UDF_TMP_TABLE_NOT_FOUND_STR,
|
||||
MYF(0), table_list.db, table_list.table_name);
|
||||
@ -1651,19 +1662,23 @@ long long spider_direct_sql_body(
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (spider_udf_direct_sql_create_conn_key(direct_sql))
|
||||
if ((error_num = spider_udf_direct_sql_create_conn_key(direct_sql)))
|
||||
{
|
||||
if (error_num == HA_ERR_OUT_OF_MEM)
|
||||
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
|
||||
goto error;
|
||||
}
|
||||
if (!(conn = spider_udf_direct_sql_get_conn(direct_sql, trx, &error_num)))
|
||||
{
|
||||
if (error_num == HA_ERR_OUT_OF_MEM)
|
||||
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
|
||||
goto error;
|
||||
}
|
||||
conn->error_mode = 0;
|
||||
direct_sql->conn = conn;
|
||||
if (spider_db_udf_check_and_set_set_names(trx))
|
||||
if ((error_num = spider_db_udf_check_and_set_set_names(trx)))
|
||||
{
|
||||
if (error_num == HA_ERR_OUT_OF_MEM)
|
||||
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
|
||||
goto error;
|
||||
}
|
||||
@ -1678,8 +1693,9 @@ long long spider_direct_sql_body(
|
||||
#ifndef WITHOUT_SPIDER_BG_SEARCH
|
||||
if (bg)
|
||||
{
|
||||
if (spider_udf_bg_direct_sql(direct_sql))
|
||||
if ((error_num = spider_udf_bg_direct_sql(direct_sql)))
|
||||
{
|
||||
if (error_num == HA_ERR_OUT_OF_MEM)
|
||||
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
|
||||
goto error;
|
||||
}
|
||||
@ -1687,12 +1703,14 @@ long long spider_direct_sql_body(
|
||||
#endif
|
||||
if (conn->bg_init)
|
||||
pthread_mutex_lock(&conn->bg_conn_mutex);
|
||||
if (spider_db_udf_direct_sql(direct_sql))
|
||||
if ((error_num = spider_db_udf_direct_sql(direct_sql)))
|
||||
{
|
||||
if (conn->bg_init)
|
||||
pthread_mutex_unlock(&conn->bg_conn_mutex);
|
||||
if (direct_sql->modified_non_trans_table)
|
||||
thd->transaction.stmt.modified_non_trans_table = TRUE;
|
||||
if (error_num == HA_ERR_OUT_OF_MEM)
|
||||
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
|
||||
goto error;
|
||||
}
|
||||
if (conn->bg_init)
|
||||
@ -1712,7 +1730,17 @@ long long spider_direct_sql_body(
|
||||
|
||||
error:
|
||||
if (direct_sql)
|
||||
{
|
||||
if (
|
||||
direct_sql->error_rw_mode &&
|
||||
spider_db_conn_is_network_error(error_num)
|
||||
) {
|
||||
SPIDER_RESTORE_DASTATUS;
|
||||
spider_udf_free_direct_sql_alloc(direct_sql, bg);
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
spider_udf_free_direct_sql_alloc(direct_sql, bg);
|
||||
}
|
||||
*error = 1;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
@ -1790,6 +1818,15 @@ void spider_direct_sql_deinit_body(
|
||||
DBUG_ENTER("spider_direct_sql_deinit_body");
|
||||
if (bg_direct_sql)
|
||||
{
|
||||
pthread_mutex_lock(&bg_direct_sql->bg_mutex);
|
||||
while (bg_direct_sql->direct_sql)
|
||||
pthread_cond_wait(&bg_direct_sql->bg_cond, &bg_direct_sql->bg_mutex);
|
||||
pthread_mutex_unlock(&bg_direct_sql->bg_mutex);
|
||||
if (bg_direct_sql->modified_non_trans_table)
|
||||
{
|
||||
THD *thd = current_thd;
|
||||
thd->transaction.stmt.modified_non_trans_table = TRUE;
|
||||
}
|
||||
pthread_cond_destroy(&bg_direct_sql->bg_cond);
|
||||
pthread_mutex_destroy(&bg_direct_sql->bg_mutex);
|
||||
spider_free(spider_current_trx, bg_direct_sql, MYF(0));
|
||||
|
@ -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.4"
|
||||
#define SPIDER_DETAIL_VERSION "3.2.11"
|
||||
#define SPIDER_HEX_VERSION 0x0302
|
||||
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
@ -138,7 +138,7 @@
|
||||
#define SPIDER_TMP_SHARE_LONG_COUNT 15
|
||||
#define SPIDER_TMP_SHARE_LONGLONG_COUNT 3
|
||||
|
||||
#define SPIDER_MEM_CALC_LIST_NUM 246
|
||||
#define SPIDER_MEM_CALC_LIST_NUM 247
|
||||
|
||||
#define SPIDER_BACKUP_DASTATUS \
|
||||
bool da_status; if (thd) da_status = thd->is_error(); else da_status = FALSE;
|
||||
@ -709,9 +709,13 @@ typedef struct st_spider_share
|
||||
time_t create_time;
|
||||
time_t update_time;
|
||||
|
||||
longlong static_records_for_status;
|
||||
longlong static_mean_rec_length;
|
||||
|
||||
int bitmap_size;
|
||||
spider_string *key_hint;
|
||||
CHARSET_INFO *access_charset;
|
||||
longlong *static_key_cardinality;
|
||||
longlong *cardinality;
|
||||
uchar *cardinality_upd;
|
||||
longlong additional_table_flags;
|
||||
@ -1039,6 +1043,7 @@ typedef struct st_spider_direct_sql
|
||||
#else
|
||||
int use_real_table;
|
||||
#endif
|
||||
int error_rw_mode;
|
||||
|
||||
char *server_name;
|
||||
char *tgt_default_db_name;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "sql_priv.h"
|
||||
#include "probes_mysql.h"
|
||||
#include "sql_class.h"
|
||||
#include "sql_analyse.h"
|
||||
#endif
|
||||
#include "spd_db_include.h"
|
||||
#include "spd_include.h"
|
||||
@ -1251,7 +1252,7 @@ bool spider_string::append_for_single_quote(
|
||||
#ifdef SPIDER_HAS_APPEND_FOR_SINGLE_QUOTE
|
||||
bool res = str.append_for_single_quote(s);
|
||||
#else
|
||||
bool res = append_escaped(&str, s);
|
||||
bool res = append_escaped(&str, (String *) s);
|
||||
#endif
|
||||
SPIDER_STRING_CALC_MEM;
|
||||
DBUG_RETURN(res);
|
||||
|
@ -25,10 +25,8 @@
|
||||
#include "sql_class.h"
|
||||
#include "sql_partition.h"
|
||||
#include "sql_servers.h"
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
#include "sql_select.h"
|
||||
#endif
|
||||
#endif
|
||||
#include "spd_err.h"
|
||||
#include "spd_param.h"
|
||||
#include "spd_db_include.h"
|
||||
@ -907,6 +905,8 @@ void spider_free_tmp_share_alloc(
|
||||
spider_free(spider_current_trx, share->conn_keys, MYF(0));
|
||||
share->conn_keys = NULL;
|
||||
}
|
||||
if (share->static_key_cardinality)
|
||||
spider_free(spider_current_trx, share->static_key_cardinality, MYF(0));
|
||||
if (share->key_hint)
|
||||
{
|
||||
delete [] share->key_hint;
|
||||
@ -1476,6 +1476,16 @@ int spider_increase_longlong_list(
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
static int spider_set_ll_value(
|
||||
longlong *value,
|
||||
char *str
|
||||
) {
|
||||
int error_num = 0;
|
||||
DBUG_ENTER("spider_set_ll_value");
|
||||
*value = my_strtoll10(str, (char**) NULL, &error_num);
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
|
||||
#define SPIDER_PARAM_STR_LEN(name) name ## _length
|
||||
#define SPIDER_PARAM_STR(title_name, param_name) \
|
||||
if (!strncasecmp(tmp_ptr, title_name, title_length)) \
|
||||
@ -1556,6 +1566,38 @@ int spider_increase_longlong_list(
|
||||
} \
|
||||
break; \
|
||||
}
|
||||
#define SPIDER_PARAM_NUMHINT(title_name, param_name, check_length, max_size, append_method) \
|
||||
if (!strncasecmp(tmp_ptr, title_name, check_length)) \
|
||||
{ \
|
||||
DBUG_PRINT("info",("spider "title_name" start")); \
|
||||
DBUG_PRINT("info",("spider max_size=%d", max_size)); \
|
||||
int hint_num = atoi(tmp_ptr + check_length); \
|
||||
DBUG_PRINT("info",("spider hint_num=%d", hint_num)); \
|
||||
DBUG_PRINT("info",("spider share->param_name=%p", share->param_name)); \
|
||||
if (share->param_name) \
|
||||
{ \
|
||||
if (hint_num < 0 || hint_num >= max_size) \
|
||||
{ \
|
||||
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \
|
||||
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
|
||||
MYF(0), tmp_ptr); \
|
||||
goto error; \
|
||||
} else if (share->param_name[hint_num] != -1) \
|
||||
break; \
|
||||
char *hint_str = spider_get_string_between_quote(start_ptr, FALSE); \
|
||||
if ((error_num = \
|
||||
append_method(&share->param_name[hint_num], hint_str))) \
|
||||
goto error; \
|
||||
DBUG_PRINT("info",("spider "title_name"[%d]=%lld", hint_num, \
|
||||
share->param_name[hint_num])); \
|
||||
} else { \
|
||||
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \
|
||||
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
|
||||
MYF(0), tmp_ptr); \
|
||||
goto error; \
|
||||
} \
|
||||
break; \
|
||||
}
|
||||
#define SPIDER_PARAM_LONG_LEN(name) name ## _length
|
||||
#define SPIDER_PARAM_LONG_LIST_WITH_MAX(title_name, param_name, \
|
||||
min_val, max_val) \
|
||||
@ -1817,6 +1859,12 @@ int spider_parse_connect_info(
|
||||
#endif
|
||||
share->casual_read = -1;
|
||||
share->delete_all_rows_type = -1;
|
||||
share->static_records_for_status = -1;
|
||||
share->static_mean_rec_length = -1;
|
||||
for (roop_count = 0; roop_count < (int) table_share->keys; roop_count++)
|
||||
{
|
||||
share->static_key_cardinality[roop_count] = -1;
|
||||
}
|
||||
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
for (roop_count = 4; roop_count > 0; roop_count--)
|
||||
@ -2025,6 +2073,7 @@ int spider_parse_connect_info(
|
||||
SPIDER_PARAM_STR_LIST("sky", tgt_ssl_keys);
|
||||
SPIDER_PARAM_INT_WITH_MAX("slm", selupd_lock_mode, 0, 2);
|
||||
SPIDER_PARAM_INT_WITH_MAX("smd", sts_mode, 1, 2);
|
||||
SPIDER_PARAM_LONGLONG("smr", static_mean_rec_length, 0);
|
||||
SPIDER_PARAM_LONGLONG("spr", split_read, 0);
|
||||
SPIDER_PARAM_STR_LIST("sqn", tgt_sequence_names);
|
||||
SPIDER_PARAM_LONGLONG("srd", second_read, 0);
|
||||
@ -2037,6 +2086,7 @@ int spider_parse_connect_info(
|
||||
#endif
|
||||
SPIDER_PARAM_INT_WITH_MAX("stc", semi_table_lock_conn, 0, 1);
|
||||
SPIDER_PARAM_INT_WITH_MAX("stl", semi_table_lock, 0, 1);
|
||||
SPIDER_PARAM_LONGLONG("srs", static_records_for_status, 0);
|
||||
SPIDER_PARAM_LONG_LIST_WITH_MAX("svc", tgt_ssl_vscs, 0, 1);
|
||||
SPIDER_PARAM_STR_LIST("tbl", tgt_table_names);
|
||||
SPIDER_PARAM_INT_WITH_MAX("tcm", table_count_mode, 0, 3);
|
||||
@ -2073,6 +2123,8 @@ int spider_parse_connect_info(
|
||||
SPIDER_PARAM_HINT("idx", key_hint, 3, (int) table_share->keys,
|
||||
spider_db_append_key_hint);
|
||||
SPIDER_PARAM_STR_LIST("ssl_ca", tgt_ssl_cas);
|
||||
SPIDER_PARAM_NUMHINT("skc", static_key_cardinality, 3,
|
||||
(int) table_share->keys, spider_set_ll_value);
|
||||
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM;
|
||||
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
|
||||
MYF(0), tmp_ptr);
|
||||
@ -2312,6 +2364,8 @@ int spider_parse_connect_info(
|
||||
#endif
|
||||
SPIDER_PARAM_INT_WITH_MAX(
|
||||
"skip_default_condition", skip_default_condition, 0, 1);
|
||||
SPIDER_PARAM_LONGLONG(
|
||||
"static_mean_rec_length", static_mean_rec_length, 0);
|
||||
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM;
|
||||
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
|
||||
MYF(0), tmp_ptr);
|
||||
@ -2323,6 +2377,15 @@ int spider_parse_connect_info(
|
||||
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
|
||||
MYF(0), tmp_ptr);
|
||||
goto error;
|
||||
case 25:
|
||||
SPIDER_PARAM_LONGLONG("static_records_for_status",
|
||||
static_records_for_status, 0);
|
||||
SPIDER_PARAM_NUMHINT("static_key_cardinality", static_key_cardinality,
|
||||
3, (int) table_share->keys, spider_set_ll_value);
|
||||
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM;
|
||||
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
|
||||
MYF(0), tmp_ptr);
|
||||
goto error;
|
||||
case 26:
|
||||
SPIDER_PARAM_INT_WITH_MAX(
|
||||
"semi_table_lock_connection", semi_table_lock_conn, 0, 1);
|
||||
@ -3963,7 +4026,7 @@ SPIDER_SHARE *spider_create_share(
|
||||
int use_table_charset;
|
||||
SPIDER_SHARE *share;
|
||||
char *tmp_name;
|
||||
longlong *tmp_cardinality;
|
||||
longlong *tmp_cardinality, *tmp_static_key_cardinality;
|
||||
uchar *tmp_cardinality_upd;
|
||||
DBUG_ENTER("spider_create_share");
|
||||
length = (uint) strlen(table_name);
|
||||
@ -3972,6 +4035,7 @@ SPIDER_SHARE *spider_create_share(
|
||||
spider_bulk_malloc(spider_current_trx, 46, MYF(MY_WME | MY_ZEROFILL),
|
||||
&share, sizeof(*share),
|
||||
&tmp_name, length + 1,
|
||||
&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,
|
||||
NullS))
|
||||
@ -3988,6 +4052,7 @@ SPIDER_SHARE *spider_create_share(
|
||||
share->table_name_length = length;
|
||||
share->table_name = tmp_name;
|
||||
strmov(share->table_name, table_name);
|
||||
share->static_key_cardinality = tmp_static_key_cardinality;
|
||||
share->cardinality = tmp_cardinality;
|
||||
share->cardinality_upd = tmp_cardinality_upd;
|
||||
share->bitmap_size = bitmap_size;
|
||||
@ -7737,12 +7802,42 @@ longlong spider_split_read_param(
|
||||
result_list->set_split_read = TRUE;
|
||||
DBUG_RETURN(9223372036854775807LL);
|
||||
}
|
||||
Explain_query *explain = thd->lex->explain;
|
||||
bool filesort = FALSE;
|
||||
if (explain)
|
||||
{
|
||||
DBUG_PRINT("info",("spider explain=%p", explain));
|
||||
Explain_select *explain_select = NULL;
|
||||
if (select_lex)
|
||||
{
|
||||
DBUG_PRINT("info",("spider select_lex=%p", select_lex));
|
||||
DBUG_PRINT("info",("spider select_number=%u",
|
||||
select_lex->select_number));
|
||||
explain_select =
|
||||
explain->get_select(select_lex->select_number);
|
||||
}
|
||||
if (explain_select)
|
||||
{
|
||||
DBUG_PRINT("info",("spider explain_select=%p", explain_select));
|
||||
if (explain_select->using_filesort)
|
||||
{
|
||||
DBUG_PRINT("info",("spider using filesort"));
|
||||
filesort = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
result_list->split_read_base =
|
||||
spider_param_split_read(thd, share->split_read);
|
||||
if (filesort)
|
||||
{
|
||||
result_list->semi_split_read = 0;
|
||||
result_list->semi_split_read_limit = 9223372036854775807LL;
|
||||
} else {
|
||||
result_list->semi_split_read =
|
||||
spider_param_semi_split_read(thd, share->semi_split_read);
|
||||
result_list->semi_split_read_limit =
|
||||
spider_param_semi_split_read_limit(thd, share->semi_split_read_limit);
|
||||
}
|
||||
result_list->first_read =
|
||||
spider_param_first_read(thd, share->first_read);
|
||||
result_list->second_read =
|
||||
@ -7864,6 +7959,12 @@ bool spider_check_direct_order_limit(
|
||||
DBUG_PRINT("info",("spider leaf_tables.elements=%u",
|
||||
select_lex->leaf_tables.elements));
|
||||
#endif
|
||||
|
||||
if (select_lex->options & SELECT_DISTINCT)
|
||||
{
|
||||
DBUG_PRINT("info",("spider with distinct"));
|
||||
spider->result_list.direct_distinct = TRUE;
|
||||
}
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
spider->result_list.direct_aggregate = TRUE;
|
||||
#endif
|
||||
@ -7884,6 +7985,7 @@ bool spider_check_direct_order_limit(
|
||||
) {
|
||||
DBUG_PRINT("info",("spider first_check is FALSE"));
|
||||
first_check = FALSE;
|
||||
spider->result_list.direct_distinct = FALSE;
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
spider->result_list.direct_aggregate = FALSE;
|
||||
#endif
|
||||
@ -7891,6 +7993,14 @@ bool spider_check_direct_order_limit(
|
||||
{
|
||||
DBUG_PRINT("info",("spider FALSE by condition"));
|
||||
first_check = FALSE;
|
||||
spider->result_list.direct_distinct = FALSE;
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
spider->result_list.direct_aggregate = FALSE;
|
||||
#endif
|
||||
} else if (spider->sql_kinds & SPIDER_SQL_KIND_HANDLER)
|
||||
{
|
||||
DBUG_PRINT("info",("spider sql_kinds with SPIDER_SQL_KIND_HANDLER"));
|
||||
spider->result_list.direct_distinct = FALSE;
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
spider->result_list.direct_aggregate = FALSE;
|
||||
} else if (
|
||||
@ -7899,10 +8009,6 @@ bool spider_check_direct_order_limit(
|
||||
) {
|
||||
DBUG_PRINT("info",("spider this SQL is not aggregate SQL"));
|
||||
spider->result_list.direct_aggregate = FALSE;
|
||||
} else if (spider->sql_kinds & SPIDER_SQL_KIND_HANDLER)
|
||||
{
|
||||
DBUG_PRINT("info",("spider sql_kinds with SPIDER_SQL_KIND_HANDLER"));
|
||||
spider->result_list.direct_aggregate = FALSE;
|
||||
} else {
|
||||
ORDER *group;
|
||||
for (group = (ORDER *) select_lex->group_list.first; group;
|
||||
|
Loading…
x
Reference in New Issue
Block a user