1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

Merge branch '10.6' into 10.11

This commit is contained in:
Sergei Golubchik
2024-04-22 11:00:03 +02:00
418 changed files with 7074 additions and 2930 deletions

View File

@@ -1191,7 +1191,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);
}
@@ -5399,14 +5399,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
){
@@ -5476,16 +5468,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? */
@@ -5494,13 +5480,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)
@@ -5510,12 +5489,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;
}
@@ -5557,7 +5542,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,
@@ -5566,8 +5551,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));
@@ -5885,12 +5870,11 @@ 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))
{
#ifdef ITEM_FUNC_TIMESTAMPDIFF_ARE_PUBLIC
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->int_type)
switch (item_func_timestamp_diff->get_int_type())
{
case INTERVAL_YEAR:
interval_str = SPIDER_SQL_YEAR_STR;
@@ -5941,7 +5925,7 @@ int spider_db_mbase_util::print_item_func(
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);
@@ -5962,9 +5946,6 @@ int spider_db_mbase_util::print_item_func(
SPIDER_SQL_CLOSE_PAREN_LEN);
}
DBUG_RETURN(0);
#else
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
#endif
}
} else if (func_name_length == 14)
{
@@ -6458,7 +6439,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);
@@ -6473,6 +6530,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;
@@ -6502,13 +6571,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;
@@ -6522,7 +6591,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);
@@ -7155,11 +7224,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);
@@ -7167,12 +7234,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()) ||
@@ -7323,11 +7390,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;
}
@@ -7476,11 +7550,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++)
{