mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Merge branch '10.11' into 11.0
This commit is contained in:
@@ -1193,7 +1193,7 @@ int spider_db_mbase_result::fetch_table_cardinality(
|
||||
uint num_fields = this->num_fields();
|
||||
if (num_fields < 12 || num_fields > 14)
|
||||
{
|
||||
DBUG_PRINT("info",("spider num_fields < 12 || num_fields > 13"));
|
||||
DBUG_PRINT("info",("spider num_fields < 12 || num_fields > 14"));
|
||||
DBUG_RETURN(ER_SPIDER_INVALID_REMOTE_TABLE_INFO_NUM);
|
||||
}
|
||||
|
||||
@@ -5410,14 +5410,6 @@ int spider_db_mbase_util::open_item_func(
|
||||
alias_length, use_fields, fields));
|
||||
}
|
||||
|
||||
static bool item_func_is_timestampdiff(
|
||||
const char *func_name,
|
||||
int func_name_length
|
||||
) {
|
||||
return func_name_length == 13 &&
|
||||
!strncasecmp("timestampdiff", func_name, func_name_length);
|
||||
}
|
||||
|
||||
static bool not_func_should_be_skipped(
|
||||
Item_func *item_func
|
||||
){
|
||||
@@ -5487,16 +5479,10 @@ int spider_db_mbase_util::check_item_func(
|
||||
Item_func::Functype func_type = item_func->functype();
|
||||
DBUG_PRINT("info",("spider functype = %d", func_type));
|
||||
|
||||
const char *func_name = (char*) item_func->func_name();
|
||||
int func_name_length = strlen(func_name);
|
||||
DBUG_PRINT("info",("spider func_name = %s", func_name));
|
||||
|
||||
/* The blacklist of the functions that cannot be pushed down */
|
||||
switch (func_type)
|
||||
{
|
||||
case Item_func::TRIG_COND_FUNC:
|
||||
case Item_func::CASE_SEARCHED_FUNC:
|
||||
case Item_func::CASE_SIMPLE_FUNC:
|
||||
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
|
||||
case Item_func::NOT_FUNC:
|
||||
/* Why the following check is necessary? */
|
||||
@@ -5505,13 +5491,6 @@ int spider_db_mbase_util::check_item_func(
|
||||
break;
|
||||
case Item_func::FUNC_SP:
|
||||
case Item_func::UDF_FUNC:
|
||||
/* Notes on merging regarding MDEV-29447: please refer to the
|
||||
following commits for build error or merge conflicts:
|
||||
10.6: 1ed20b993b0dd4e95450cab2e8347e5bf4617a69
|
||||
10.9: dd316b6e20265cfd832bb5585cb4c96e716387c8
|
||||
10.10-11: 3f67f110ba1b23a89c5ede0fbeeb203cf5e164f4
|
||||
11.0-1: 17ba6748afa8834df5658361088e6c8e65aca16f
|
||||
Please remove this comment after merging. */
|
||||
use_pushdown_udf= spider_param_use_pushdown_udf(
|
||||
spider->wide_handler->trx->thd, spider->share->use_pushdown_udf);
|
||||
if (!use_pushdown_udf)
|
||||
@@ -5521,12 +5500,18 @@ int spider_db_mbase_util::check_item_func(
|
||||
if (spider_db_check_ft_idx(item_func, spider) == MAX_KEY)
|
||||
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
|
||||
break;
|
||||
#ifndef ITEM_FUNC_TIMESTAMPDIFF_ARE_PUBLIC
|
||||
case Item_func::UNKNOWN_FUNC:
|
||||
if (item_func_is_timestampdiff(func_name, func_name_length))
|
||||
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
|
||||
break;
|
||||
#endif
|
||||
case Item_func::MULT_EQUAL_FUNC:
|
||||
/* If there is still Item_equal by the time of
|
||||
JOIN::make_aggr_tables_info() where the spider group by handler
|
||||
is created, it indicates a bug in the optimizer, because there
|
||||
shouldn't be any. */
|
||||
push_warning_printf(
|
||||
spider->wide_handler->trx->thd, SPIDER_WARN_LEVEL_WARN,
|
||||
ER_INTERNAL_ERROR,
|
||||
ER_THD(spider->wide_handler->trx->thd, ER_INTERNAL_ERROR),
|
||||
"Spider group by handler: Encountered multiple equalities, likely "
|
||||
"an optimizer bug");
|
||||
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -5568,7 +5553,7 @@ int spider_db_mbase_util::print_item_func(
|
||||
Item *item, **item_list = item_func->arguments();
|
||||
Field *field;
|
||||
spider_string tmp_str;
|
||||
uint roop_count, item_count = item_func->argument_count(), start_item = 0;
|
||||
uint i, item_count = item_func->argument_count(), start_item = 0;
|
||||
LEX_CSTRING org_func_name= {SPIDER_SQL_NULL_CHAR_STR,
|
||||
SPIDER_SQL_NULL_CHAR_LEN};
|
||||
const char *func_name = SPIDER_SQL_NULL_CHAR_STR,
|
||||
@@ -5577,8 +5562,8 @@ int spider_db_mbase_util::print_item_func(
|
||||
int func_name_length = SPIDER_SQL_NULL_CHAR_LEN,
|
||||
separator_str_length = SPIDER_SQL_NULL_CHAR_LEN,
|
||||
last_str_length = SPIDER_SQL_NULL_CHAR_LEN;
|
||||
int use_pushdown_udf;
|
||||
bool merge_func = FALSE;
|
||||
int use_pushdown_udf, case_when_start, case_when_count;
|
||||
bool merge_func = FALSE, case_with_else;
|
||||
DBUG_ENTER("spider_db_mbase_util::print_item_func");
|
||||
DBUG_ASSERT(!check_item_func(item_func, spider, alias, alias_length,
|
||||
use_fields, fields));
|
||||
@@ -5896,7 +5881,82 @@ int spider_db_mbase_util::print_item_func(
|
||||
alias, alias_length, dbton_id, use_fields, fields));
|
||||
} else if (!strncasecmp("timestampdiff", func_name, func_name_length))
|
||||
{
|
||||
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
|
||||
Item_func_timestamp_diff *item_func_timestamp_diff =
|
||||
(Item_func_timestamp_diff *) item_func;
|
||||
const char *interval_str;
|
||||
uint interval_len;
|
||||
switch (item_func_timestamp_diff->get_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], NULL, spider,
|
||||
str, alias, alias_length, dbton_id, use_fields, fields)))
|
||||
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], NULL, spider,
|
||||
str, alias, alias_length, dbton_id, use_fields, fields)))
|
||||
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 if (func_name_length == 14)
|
||||
{
|
||||
@@ -6390,7 +6450,83 @@ int spider_db_mbase_util::print_item_func(
|
||||
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
|
||||
case Item_func::CASE_SEARCHED_FUNC:
|
||||
case Item_func::CASE_SIMPLE_FUNC:
|
||||
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
|
||||
/*
|
||||
Arrangement of arguments:
|
||||
- Item_func_case_searched:
|
||||
when1 when2 ... whenk then1 then2 .. thenk [else]
|
||||
- Item_func_case_simple:
|
||||
value when1 when2 ... whenk then1 then2 .. thenk [else]
|
||||
*/
|
||||
if (item_func->functype() == Item_func::CASE_SEARCHED_FUNC)
|
||||
{
|
||||
case_when_start= 0;
|
||||
case_when_count= item_count / 2;
|
||||
case_with_else= item_count % 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
case_when_start= 1;
|
||||
case_when_count= (item_count - 1) / 2;
|
||||
case_with_else= item_count % 2 == 0;
|
||||
}
|
||||
if (str)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_CASE_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_CASE_STR, SPIDER_SQL_CASE_LEN);
|
||||
}
|
||||
if (case_when_start > 0)
|
||||
{
|
||||
if ((error_num = spider_db_print_item_type(
|
||||
item_list[0], NULL, spider, str,
|
||||
alias, alias_length, dbton_id, use_fields, fields)))
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
for (i = 0; i < (uint) case_when_count; i++)
|
||||
{
|
||||
if (str)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_WHEN_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_WHEN_STR, SPIDER_SQL_WHEN_LEN);
|
||||
}
|
||||
if ((error_num = spider_db_print_item_type(
|
||||
item_list[i + case_when_start], NULL, spider, str,
|
||||
alias, alias_length, dbton_id, use_fields, fields)))
|
||||
DBUG_RETURN(error_num);
|
||||
if (str)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_THEN_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_THEN_STR, SPIDER_SQL_THEN_LEN);
|
||||
}
|
||||
if ((error_num = spider_db_print_item_type(
|
||||
item_list[i + case_when_start + case_when_count], NULL, spider, str,
|
||||
alias, alias_length, dbton_id, use_fields, fields)))
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
if (case_with_else)
|
||||
{
|
||||
if (str)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_ELSE_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_ELSE_STR, SPIDER_SQL_ELSE_LEN);
|
||||
}
|
||||
if ((error_num = spider_db_print_item_type(
|
||||
item_list[item_count - 1], NULL, spider, str,
|
||||
alias, alias_length, dbton_id, use_fields, fields)))
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
if (str)
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_END_LEN + SPIDER_SQL_CLOSE_PAREN_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_END_STR, SPIDER_SQL_END_LEN);
|
||||
str->q_append(SPIDER_SQL_CLOSE_PAREN_STR,
|
||||
SPIDER_SQL_CLOSE_PAREN_LEN);
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
case Item_func::JSON_EXTRACT_FUNC:
|
||||
func_name = (char*) item_func->func_name();
|
||||
func_name_length = strlen(func_name);
|
||||
@@ -6405,6 +6541,18 @@ int spider_db_mbase_util::print_item_func(
|
||||
last_str = SPIDER_SQL_CLOSE_PAREN_STR;
|
||||
last_str_length = SPIDER_SQL_CLOSE_PAREN_LEN;
|
||||
break;
|
||||
case Item_func::MULT_EQUAL_FUNC:
|
||||
/* If there is still Item_equal by the time of
|
||||
JOIN::make_aggr_tables_info() where the spider group by handler
|
||||
is created, it indicates a bug in the optimizer, because there
|
||||
shouldn't be any. */
|
||||
push_warning_printf(
|
||||
spider->wide_handler->trx->thd,
|
||||
SPIDER_WARN_LEVEL_WARN, ER_INTERNAL_ERROR,
|
||||
ER_THD(spider->wide_handler->trx->thd, ER_INTERNAL_ERROR),
|
||||
"Spider group by handler: Encountered multiple equalities, likely "
|
||||
"an optimizer bug");
|
||||
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
|
||||
default:
|
||||
THD *thd = spider->wide_handler->trx->thd;
|
||||
SPIDER_SHARE *share = spider->share;
|
||||
@@ -6434,13 +6582,13 @@ int spider_db_mbase_util::print_item_func(
|
||||
Loop through the items of the current function expression to
|
||||
print its portion of the statement
|
||||
*/
|
||||
for (roop_count = start_item; roop_count < item_count; roop_count++)
|
||||
for (i = start_item; i < item_count; i++)
|
||||
{
|
||||
item = item_list[roop_count];
|
||||
item = item_list[i];
|
||||
if ((error_num = spider_db_print_item_type(item, field, spider, str,
|
||||
alias, alias_length, dbton_id, use_fields, fields)))
|
||||
DBUG_RETURN(error_num);
|
||||
if (roop_count == 1)
|
||||
if (i == 1)
|
||||
{
|
||||
/* Remaining operands need to be preceded by the separator */
|
||||
func_name = separator_str;
|
||||
@@ -6454,7 +6602,7 @@ int spider_db_mbase_util::print_item_func(
|
||||
}
|
||||
|
||||
/* Print the last operand value */
|
||||
item = item_list[roop_count];
|
||||
item = item_list[i];
|
||||
if ((error_num = spider_db_print_item_type(item, field, spider, str,
|
||||
alias, alias_length, dbton_id, use_fields, fields)))
|
||||
DBUG_RETURN(error_num);
|
||||
@@ -7087,11 +7235,9 @@ int spider_mbase_share::init()
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
}
|
||||
|
||||
if (keys > 0 &&
|
||||
!(key_hint = new spider_string[keys])
|
||||
) {
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
}
|
||||
if (keys > 0)
|
||||
if (!(key_hint = new spider_string[keys]))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
for (roop_count = 0; roop_count < keys; roop_count++)
|
||||
{
|
||||
key_hint[roop_count].init_calc_mem(SPD_MID_MBASE_SHARE_INIT_2);
|
||||
@@ -7099,12 +7245,12 @@ int spider_mbase_share::init()
|
||||
}
|
||||
DBUG_PRINT("info",("spider key_hint=%p", key_hint));
|
||||
|
||||
if (
|
||||
!(table_select = new spider_string[1]) ||
|
||||
(keys > 0 &&
|
||||
!(key_select = new spider_string[keys])
|
||||
) ||
|
||||
(error_num = create_table_names_str()) ||
|
||||
if (!(table_select = new spider_string[1]))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
if (keys > 0)
|
||||
if (!(key_select = new spider_string[keys]))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
if ((error_num = create_table_names_str()) ||
|
||||
(table_share &&
|
||||
(
|
||||
(error_num = create_column_name_str()) ||
|
||||
@@ -7255,11 +7401,18 @@ int spider_mbase_share::create_table_names_str()
|
||||
table_names_str = NULL;
|
||||
db_names_str = NULL;
|
||||
db_table_str = NULL;
|
||||
if (
|
||||
!(table_names_str = new spider_string[spider_share->all_link_count]) ||
|
||||
!(db_names_str = new spider_string[spider_share->all_link_count]) ||
|
||||
!(db_table_str = new spider_string[spider_share->all_link_count])
|
||||
) {
|
||||
if (!(table_names_str = new spider_string[spider_share->all_link_count]))
|
||||
{
|
||||
error_num = HA_ERR_OUT_OF_MEM;
|
||||
goto error;
|
||||
}
|
||||
if (!(db_names_str = new spider_string[spider_share->all_link_count]))
|
||||
{
|
||||
error_num = HA_ERR_OUT_OF_MEM;
|
||||
goto error;
|
||||
}
|
||||
if (!(db_table_str = new spider_string[spider_share->all_link_count]))
|
||||
{
|
||||
error_num = HA_ERR_OUT_OF_MEM;
|
||||
goto error;
|
||||
}
|
||||
@@ -7408,11 +7561,9 @@ int spider_mbase_share::create_column_name_str()
|
||||
Field **field;
|
||||
TABLE_SHARE *table_share = spider_share->table_share;
|
||||
DBUG_ENTER("spider_mbase_share::create_column_name_str");
|
||||
if (
|
||||
table_share->fields &&
|
||||
!(column_name_str = new spider_string[table_share->fields])
|
||||
)
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
if (table_share->fields)
|
||||
if (!(column_name_str = new spider_string[table_share->fields]))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
for (field = table_share->field, str = column_name_str;
|
||||
*field; field++, str++)
|
||||
{
|
||||
|
Reference in New Issue
Block a user