mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
Merge 10.4 into 10.5
This commit is contained in:
@ -868,7 +868,6 @@ Item* period_get_condition(THD *thd, TABLE_LIST *table, SELECT_LEX *select,
|
||||
cond1= and_items(thd, cond3, cond1);
|
||||
}
|
||||
return cond1;
|
||||
#undef newx
|
||||
}
|
||||
|
||||
static
|
||||
@ -917,6 +916,19 @@ Item* SELECT_LEX::period_setup_conds(THD *thd, TABLE_LIST *tables, Item *where)
|
||||
DBUG_RETURN(result);
|
||||
}
|
||||
|
||||
/**
|
||||
Setup System Versioning conditions
|
||||
|
||||
Add WHERE condition according to FOR SYSTEM_TIME clause.
|
||||
|
||||
If the table is partitioned by SYSTEM_TIME and there is no FOR SYSTEM_TIME
|
||||
clause, then select now-partition instead of modifying WHERE condition.
|
||||
|
||||
@retval
|
||||
-1 on error
|
||||
@retval
|
||||
0 on success
|
||||
*/
|
||||
int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
|
||||
{
|
||||
DBUG_ENTER("SELECT_LEX::vers_setup_conds");
|
||||
@ -974,12 +986,13 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
|
||||
vers_select_conds_t &vers_conditions= table->vers_conditions;
|
||||
|
||||
#ifdef WITH_PARTITION_STORAGE_ENGINE
|
||||
/*
|
||||
if the history is stored in partitions, then partitions
|
||||
themselves are not versioned
|
||||
*/
|
||||
if (table->partition_names && table->table->part_info->vers_info)
|
||||
Vers_part_info *vers_info;
|
||||
if (table->table->part_info && (vers_info= table->table->part_info->vers_info))
|
||||
{
|
||||
if (table->partition_names)
|
||||
{
|
||||
/* If the history is stored in partitions, then partitions
|
||||
themselves are not versioned. */
|
||||
if (vers_conditions.is_set())
|
||||
{
|
||||
my_error(ER_VERS_QUERY_IN_PARTITION, MYF(0), table->alias.str);
|
||||
@ -988,6 +1001,19 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
|
||||
else
|
||||
vers_conditions.init(SYSTEM_TIME_ALL);
|
||||
}
|
||||
else if (!vers_conditions.is_set() &&
|
||||
/* We cannot optimize REPLACE .. SELECT because it may need
|
||||
to call vers_set_hist_part() to update history. */
|
||||
thd->lex->sql_command != SQLCOM_REPLACE_SELECT)
|
||||
{
|
||||
table->partition_names= newx List<String>;
|
||||
String *s= newx String(vers_info->now_part->partition_name,
|
||||
system_charset_info);
|
||||
table->partition_names->push_back(s);
|
||||
table->table->file->change_partitions_to_open(table->partition_names);
|
||||
vers_conditions.init(SYSTEM_TIME_ALL);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (outer_table && !vers_conditions.is_set())
|
||||
@ -1042,6 +1068,7 @@ int SELECT_LEX::vers_setup_conds(THD *thd, TABLE_LIST *tables)
|
||||
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
#undef newx
|
||||
|
||||
/*****************************************************************************
|
||||
Check fields, find best join, do the select and output fields.
|
||||
|
Reference in New Issue
Block a user