SQL: partitioning misc fixes [closes #242]

* cleanup: *never* use assert(A && B)
* vers_setup_1() revisited
* vers_setup_2() renamed
* partition_element::type removed
* Copy ctor instead of memcpy()
* Handle return value from check_range_constants()
* Malloc error fix
* error, style, misc fixes
This commit is contained in:
Aleksey Midenkov 2017-09-07 15:49:11 +03:00 committed by GitHub
parent a734c2f0fb
commit 904b69cd9e
13 changed files with 124 additions and 106 deletions

View File

@ -93,13 +93,13 @@ create or replace table t1 (x int)
partition by system_time ( partition by system_time (
partition p0 versioning, partition p0 versioning,
partition pn as of now); partition pn as of now);
ERROR HY000: System Versioning required: `BY SYSTEM_TIME` partitioning ERROR HY000: System Versioning required: t1
create or replace table t1 (x int); create or replace table t1 (x int);
alter table t1 alter table t1
partition by system_time ( partition by system_time (
partition p0 versioning, partition p0 versioning,
partition pn as of now); partition pn as of now);
ERROR HY000: System Versioning required: `BY SYSTEM_TIME` partitioning Got one of the listed errors
create or replace table t1 (x int) create or replace table t1 (x int)
with system versioning with system versioning
partition by system_time ( partition by system_time (

View File

@ -29,7 +29,7 @@ partition by system_time (
partition pn as of now); partition pn as of now);
create or replace table t1 (x int); create or replace table t1 (x int);
--error ER_VERSIONING_REQUIRED --error ER_VERSIONING_REQUIRED,ER_VERSIONING_REQUIRED
alter table t1 alter table t1
partition by system_time ( partition by system_time (
partition p0 versioning, partition p0 versioning,

View File

@ -2022,15 +2022,12 @@ int ha_partition::copy_partitions(ulonglong * const copied,
else else
{ {
THD *thd= ha_thd(); THD *thd= ha_thd();
handler *new_file= m_new_file[new_part];
/* Copy record to new handler */ /* Copy record to new handler */
(*copied)++; (*copied)++;
if (new_file->ha_external_lock(thd, F_UNLCK) || new_file->ha_external_lock(thd, F_WRLCK))
goto error;
tmp_disable_binlog(thd); /* Do not replicate the low-level changes. */ tmp_disable_binlog(thd); /* Do not replicate the low-level changes. */
result= new_file->ha_write_row(m_rec0); result= m_new_file[new_part]->ha_write_row(m_rec0);
reenable_binlog(thd); reenable_binlog(thd);
if (new_file->ha_external_lock(thd, F_UNLCK) || new_file->ha_external_lock(thd, F_RDLCK) || result) if (result)
goto error; goto error;
} }
} }

View File

@ -1355,11 +1355,6 @@ public:
return h; return h;
} }
virtual bool versioned() const
{
return m_innodb;
}
virtual ha_rows part_records(void *_part_elem) virtual ha_rows part_records(void *_part_elem)
{ {
partition_element *part_elem= reinterpret_cast<partition_element *>(_part_elem); partition_element *part_elem= reinterpret_cast<partition_element *>(_part_elem);

View File

@ -4404,7 +4404,7 @@ public:
virtual int find_unique_row(uchar *record, uint unique_ref) virtual int find_unique_row(uchar *record, uint unique_ref)
{ return -1; /*unsupported */} { return -1; /*unsupported */}
virtual bool versioned() const bool native_versioned() const
{ DBUG_ASSERT(ht); return partition_ht()->flags & HTON_NATIVE_SYS_VERSIONING; } { DBUG_ASSERT(ht); return partition_ht()->flags & HTON_NATIVE_SYS_VERSIONING; }
virtual ha_rows part_records(void *_part_elem) virtual ha_rows part_records(void *_part_elem)
{ DBUG_ASSERT(0); return false; } { DBUG_ASSERT(0); return false; }

View File

@ -3455,9 +3455,11 @@ bool prune_partitions(THD *thd, TABLE *table, Item *pprune_cond)
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
if (part_info->part_type == VERSIONING_PARTITION) if (part_info->part_type == VERSIONING_PARTITION &&
part_info->vers_update_range_constants(thd))
{ {
part_info->vers_update_range_constants(thd); retval= TRUE;
goto end2;
} }
dbug_tmp_use_all_columns(table, old_sets, dbug_tmp_use_all_columns(table, old_sets,
@ -3559,6 +3561,7 @@ all_used:
mark_all_partitions_as_used(prune_param.part_info); mark_all_partitions_as_used(prune_param.part_info);
end: end:
dbug_tmp_restore_column_maps(table->read_set, table->write_set, old_sets); dbug_tmp_restore_column_maps(table->read_set, table->write_set, old_sets);
end2:
thd->no_errors=0; thd->no_errors=0;
thd->mem_root= range_par->old_root; thd->mem_root= range_par->old_root;
free_root(&alloc,MYF(0)); // Return memory & allocator free_root(&alloc,MYF(0)); // Return memory & allocator

View File

@ -151,6 +151,13 @@ enum stat_trx_field
class partition_element :public Sql_alloc class partition_element :public Sql_alloc
{ {
public: public:
enum elem_type
{
CONVENTIONAL= 0,
AS_OF_NOW,
VERSIONING
};
List<partition_element> subpartitions; List<partition_element> subpartitions;
List<part_elem_value> list_val_list; List<part_elem_value> list_val_list;
ha_rows part_max_rows; ha_rows part_max_rows;
@ -172,14 +179,18 @@ public:
uint32 id; uint32 id;
bool empty; bool empty;
enum elem_type // TODO: subclass partition_element by partitioning type to avoid such semantic
// mixup
elem_type type()
{ {
CONVENTIONAL= 0, return (elem_type)(signed_flag << 1 | max_value);
AS_OF_NOW, }
VERSIONING
};
elem_type type; void type(elem_type val)
{
max_value= val & 1;
signed_flag= val & 2;
}
partition_element() partition_element()
: part_max_rows(0), part_min_rows(0), range_value(0), : part_max_rows(0), part_min_rows(0), range_value(0),
@ -190,8 +201,7 @@ public:
nodegroup_id(UNDEF_NODEGROUP), has_null_value(FALSE), nodegroup_id(UNDEF_NODEGROUP), has_null_value(FALSE),
signed_flag(FALSE), max_value(FALSE), signed_flag(FALSE), max_value(FALSE),
id(UINT32_MAX), id(UINT32_MAX),
empty(true), empty(true)
type(CONVENTIONAL)
{} {}
partition_element(partition_element *part_elem) partition_element(partition_element *part_elem)
: part_max_rows(part_elem->part_max_rows), : part_max_rows(part_elem->part_max_rows),
@ -207,17 +217,16 @@ public:
nodegroup_id(part_elem->nodegroup_id), nodegroup_id(part_elem->nodegroup_id),
has_null_value(FALSE), has_null_value(FALSE),
id(part_elem->id), id(part_elem->id),
empty(part_elem->empty), empty(part_elem->empty)
type(part_elem->type)
{} {}
~partition_element() {} ~partition_element() {}
part_column_list_val& get_col_val(uint idx) part_column_list_val& get_col_val(uint idx)
{ {
DBUG_ASSERT(type != CONVENTIONAL); DBUG_ASSERT(type() == CONVENTIONAL || list_val_list.elements == 1);
DBUG_ASSERT(list_val_list.elements == 1); part_elem_value *ev= list_val_list.head();
part_elem_value *ev= static_cast<part_elem_value*>(list_val_list.first_node()->info); DBUG_ASSERT(ev);
DBUG_ASSERT(ev && ev->col_val_array); DBUG_ASSERT(ev->col_val_array);
return ev->col_val_array[idx]; return ev->col_val_array[idx];
} }
}; };

View File

@ -44,13 +44,12 @@ partition_info *partition_info::get_clone(THD *thd)
List_iterator<partition_element> part_it(partitions); List_iterator<partition_element> part_it(partitions);
partition_element *part; partition_element *part;
partition_info *clone= new (mem_root) partition_info(); partition_info *clone= new (mem_root) partition_info(*this);
if (!clone) if (!clone)
{ {
mem_alloc_error(sizeof(partition_info)); mem_alloc_error(sizeof(partition_info));
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
} }
memcpy(clone, this, sizeof(partition_info));
memset(&(clone->read_partitions), 0, sizeof(clone->read_partitions)); memset(&(clone->read_partitions), 0, sizeof(clone->read_partitions));
memset(&(clone->lock_partitions), 0, sizeof(clone->lock_partitions)); memset(&(clone->lock_partitions), 0, sizeof(clone->lock_partitions));
clone->bitmaps_are_initialized= FALSE; clone->bitmaps_are_initialized= FALSE;
@ -913,28 +912,59 @@ partition_info::vers_part_rotate(THD * thd)
return vers_info->hist_part; return vers_info->hist_part;
} }
bool partition_info::vers_setup_1(THD * thd, uint32 added) bool partition_info::vers_set_expression(THD *thd, partition_element *el, MYSQL_TIME& t)
{
curr_part_elem= el;
init_column_part(thd);
el->list_val_list.empty();
el->list_val_list.push_back(curr_list_val, thd->mem_root);
for (uint i= 0; i < num_columns; ++i)
{
part_column_list_val *col_val= add_column_value(thd);
if (el->type() == partition_element::AS_OF_NOW)
{
col_val->max_value= true;
col_val->item_expression= NULL;
col_val->column_value= NULL;
col_val->part_info= this;
col_val->fixed= 1;
continue;
}
Item *item_expression= new (thd->mem_root) Item_datetime_literal(thd, &t);
if (!item_expression)
return true;
/* We initialize col_val with bogus max value to make fix_partition_func() and check_range_constants() happy.
Later in vers_setup_stats() it is initialized with real stat value if there will be any. */
/* FIXME: TIME_RESULT in col_val is expensive. It should be INT_RESULT
(got to be fixed when InnoDB is supported). */
init_col_val(col_val, item_expression);
DBUG_ASSERT(item_expression == el->get_col_val(i).item_expression);
} // for (num_columns)
return false;
}
bool partition_info::vers_setup_expression(THD * thd, uint32 alter_add)
{ {
DBUG_ASSERT(part_type == VERSIONING_PARTITION); DBUG_ASSERT(part_type == VERSIONING_PARTITION);
if (!table->versioned()) if (!table->versioned())
{ {
my_error(ER_VERSIONING_REQUIRED, MYF(0), "`BY SYSTEM_TIME` partitioning"); my_error(ER_VERSIONING_REQUIRED, MYF(0), table->s->table_name);
return true; return true;
} }
if (added) if (alter_add)
{ {
DBUG_ASSERT(partitions.elements > added + 1); DBUG_ASSERT(partitions.elements > alter_add + 1);
Vers_min_max_stats** old_array= table->s->stat_trx; Vers_min_max_stats** old_array= table->s->stat_trx;
table->s->stat_trx= static_cast<Vers_min_max_stats**>( table->s->stat_trx= static_cast<Vers_min_max_stats**>(
alloc_root(&table->s->mem_root, sizeof(void *) * partitions.elements * num_columns)); alloc_root(&table->s->mem_root, sizeof(void *) * partitions.elements * num_columns));
memcpy(table->s->stat_trx, old_array, sizeof(void *) * (partitions.elements - added) * num_columns); memcpy(table->s->stat_trx, old_array, sizeof(void *) * (partitions.elements - alter_add) * num_columns);
} }
else else
{ {
/* Prepare part_field_list */
Field *sys_trx_end= table->vers_end_field(); Field *sys_trx_end= table->vers_end_field();
part_field_list.empty();
part_field_list.push_back(const_cast<char *>(sys_trx_end->field_name), thd->mem_root); part_field_list.push_back(const_cast<char *>(sys_trx_end->field_name), thd->mem_root);
DBUG_ASSERT(part_field_list.elements == num_columns); DBUG_ASSERT(part_field_list.elements == num_columns);
// needed in handle_list_of_fields() // needed in handle_list_of_fields()
@ -949,26 +979,29 @@ bool partition_info::vers_setup_1(THD * thd, uint32 added)
uint32 id= 0; uint32 id= 0;
while ((el= it++)) while ((el= it++))
{ {
DBUG_ASSERT(el->type != partition_element::CONVENTIONAL); DBUG_ASSERT(el->type() != partition_element::CONVENTIONAL);
++ts; ++ts;
if (added) if (alter_add)
{ {
if (el->type == partition_element::VERSIONING && !el->empty) /* Non-empty historical partitions are left as is. */
if (el->type() == partition_element::VERSIONING && !el->empty)
{ {
++id; ++id;
continue; continue;
} }
if (el->id == UINT32_MAX || el->type == partition_element::AS_OF_NOW) /* Newly added element is inserted before AS_OF_NOW. */
if (el->id == UINT32_MAX || el->type() == partition_element::AS_OF_NOW)
{ {
DBUG_ASSERT(table && table->s); DBUG_ASSERT(table && table->s);
Vers_min_max_stats *stat_trx_end= new (&table->s->mem_root) Vers_min_max_stats *stat_trx_end= new (&table->s->mem_root)
Vers_min_max_stats(table->s->vers_end_field()->field_name, table->s); Vers_min_max_stats(table->s->vers_end_field()->field_name, table->s);
table->s->stat_trx[id * num_columns + STAT_TRX_END]= stat_trx_end; table->s->stat_trx[id * num_columns + STAT_TRX_END]= stat_trx_end;
el->id= id++; el->id= id++;
if (el->type == partition_element::AS_OF_NOW) if (el->type() == partition_element::AS_OF_NOW)
break; break;
goto create_col_val; goto set_expression;
} }
/* Existing element expression is recalculated. */
thd->variables.time_zone->gmt_sec_to_TIME(&t, ts); thd->variables.time_zone->gmt_sec_to_TIME(&t, ts);
for (uint i= 0; i < num_columns; ++i) for (uint i= 0; i < num_columns; ++i)
{ {
@ -980,32 +1013,10 @@ bool partition_info::vers_setup_1(THD * thd, uint32 added)
continue; continue;
} }
create_col_val: set_expression:
curr_part_elem= el;
init_column_part(thd);
el->list_val_list.empty();
el->list_val_list.push_back(curr_list_val, thd->mem_root);
thd->variables.time_zone->gmt_sec_to_TIME(&t, ts); thd->variables.time_zone->gmt_sec_to_TIME(&t, ts);
for (uint i= 0; i < num_columns; ++i) if (vers_set_expression(thd, el, t))
{ return true;
part_column_list_val *col_val= add_column_value(thd);
if (el->type == partition_element::AS_OF_NOW)
{
col_val->max_value= true;
col_val->item_expression= NULL;
col_val->column_value= NULL;
col_val->part_info= this;
col_val->fixed= 1;
continue;
}
Item *item_expression= new (thd->mem_root) Item_datetime_literal(thd, &t);
/* We initialize col_val with bogus max value to make fix_partition_func() and check_range_constants() happy.
Later in vers_setup_2() it is initialized with real stat value if there will be any. */
/* FIXME: TIME_RESULT in col_val is expensive. It should be INT_RESULT
(got to be fixed when InnoDB is supported). */
init_col_val(col_val, item_expression);
DBUG_ASSERT(item_expression == el->get_col_val(i).item_expression);
}
} }
return false; return false;
} }
@ -1019,7 +1030,7 @@ bool partition_info::vers_scan_min_max(THD *thd, partition_element *part)
uint32 part_id= part->id * sub_factor; uint32 part_id= part->id * sub_factor;
uint32 part_id_end= part_id + sub_factor; uint32 part_id_end= part_id + sub_factor;
DBUG_ASSERT(part->empty); DBUG_ASSERT(part->empty);
DBUG_ASSERT(part->type == partition_element::VERSIONING); DBUG_ASSERT(part->type() == partition_element::VERSIONING);
DBUG_ASSERT(table->s->stat_trx); DBUG_ASSERT(table->s->stat_trx);
for (; part_id < part_id_end; ++part_id) for (; part_id < part_id_end; ++part_id)
{ {
@ -1141,8 +1152,8 @@ void partition_info::vers_update_col_vals(THD *thd, partition_element *el0, part
} }
// setup at open stage (TABLE_SHARE is initialized) // setup at open() phase (TABLE_SHARE is initialized)
bool partition_info::vers_setup_2(THD * thd, bool is_create_table_ind) bool partition_info::vers_setup_stats(THD * thd, bool is_create_table_ind)
{ {
DBUG_ASSERT(part_type == VERSIONING_PARTITION); DBUG_ASSERT(part_type == VERSIONING_PARTITION);
DBUG_ASSERT(vers_info && vers_info->initialized(false)); DBUG_ASSERT(vers_info && vers_info->initialized(false));
@ -1165,6 +1176,7 @@ bool partition_info::vers_setup_2(THD * thd, bool is_create_table_ind)
bool dont_stat= true; bool dont_stat= true;
bool col_val_updated= false; bool col_val_updated= false;
// initialize stat_trx
if (!table->s->stat_trx) if (!table->s->stat_trx)
{ {
DBUG_ASSERT(partitions.elements > 1); DBUG_ASSERT(partitions.elements > 1);
@ -1178,7 +1190,7 @@ bool partition_info::vers_setup_2(THD * thd, bool is_create_table_ind)
partition_element *el= NULL, *prev; partition_element *el= NULL, *prev;
while ((prev= el, el= it++)) while ((prev= el, el= it++))
{ {
if (el->type == partition_element::VERSIONING && dont_stat) if (el->type() == partition_element::VERSIONING && dont_stat)
{ {
if (el->id == table->s->hist_part_id) if (el->id == table->s->hist_part_id)
{ {
@ -1196,7 +1208,7 @@ bool partition_info::vers_setup_2(THD * thd, bool is_create_table_ind)
if (!is_create_table_ind) if (!is_create_table_ind)
{ {
if (el->type == partition_element::AS_OF_NOW) if (el->type() == partition_element::AS_OF_NOW)
{ {
uchar buf[8]; uchar buf[8];
Field_timestampf fld(buf, NULL, 0, Field::NONE, table->vers_end_field()->field_name, NULL, 6); Field_timestampf fld(buf, NULL, 0, Field::NONE, table->vers_end_field()->field_name, NULL, 6);
@ -1217,10 +1229,10 @@ bool partition_info::vers_setup_2(THD * thd, bool is_create_table_ind)
} }
} }
if (el->type == partition_element::AS_OF_NOW) if (el->type() == partition_element::AS_OF_NOW)
break; break;
DBUG_ASSERT(el->type == partition_element::VERSIONING); DBUG_ASSERT(el->type() == partition_element::VERSIONING);
if (vers_info->hist_part) if (vers_info->hist_part)
{ {
@ -1435,7 +1447,7 @@ error:
called for RANGE PARTITIONed tables. called for RANGE PARTITIONed tables.
*/ */
bool partition_info::check_range_constants(THD *thd, bool init) bool partition_info::check_range_constants(THD *thd, bool alloc)
{ {
partition_element* part_def; partition_element* part_def;
bool first= TRUE; bool first= TRUE;
@ -1452,7 +1464,7 @@ bool partition_info::check_range_constants(THD *thd, bool init)
part_column_list_val *UNINIT_VAR(current_largest_col_val); part_column_list_val *UNINIT_VAR(current_largest_col_val);
uint num_column_values= part_field_list.elements; uint num_column_values= part_field_list.elements;
uint size_entries= sizeof(part_column_list_val) * num_column_values; uint size_entries= sizeof(part_column_list_val) * num_column_values;
if (init) if (alloc)
{ {
range_col_array= (part_column_list_val*) thd->calloc(num_parts * range_col_array= (part_column_list_val*) thd->calloc(num_parts *
size_entries); size_entries);
@ -1493,7 +1505,7 @@ bool partition_info::check_range_constants(THD *thd, bool init)
longlong part_range_value; longlong part_range_value;
bool signed_flag= !part_expr->unsigned_flag; bool signed_flag= !part_expr->unsigned_flag;
if (init) if (alloc)
{ {
range_int_array= (longlong*) thd->alloc(num_parts * sizeof(longlong)); range_int_array= (longlong*) thd->alloc(num_parts * sizeof(longlong));
if (unlikely(range_int_array == NULL)) if (unlikely(range_int_array == NULL))
@ -2065,13 +2077,13 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type,
} }
if (part_type == VERSIONING_PARTITION) if (part_type == VERSIONING_PARTITION)
{ {
if (part_elem->type == partition_element::VERSIONING) if (part_elem->type() == partition_element::VERSIONING)
{ {
hist_parts++; hist_parts++;
} }
else else
{ {
DBUG_ASSERT(part_elem->type == partition_element::AS_OF_NOW); DBUG_ASSERT(part_elem->type() == partition_element::AS_OF_NOW);
now_parts++; now_parts++;
} }
} }

View File

@ -57,13 +57,12 @@ struct Vers_part_info : public Sql_alloc
{ {
if (now_part) if (now_part)
{ {
DBUG_ASSERT( DBUG_ASSERT(now_part->id != UINT32_MAX);
now_part->id != UINT32_MAX && DBUG_ASSERT(now_part->type() == partition_element::AS_OF_NOW);
now_part->type == partition_element::AS_OF_NOW && DBUG_ASSERT(!fully || (bool) hist_part);
(fully ? (bool) hist_part : true) && DBUG_ASSERT(!hist_part || (
(!hist_part || (
hist_part->id != UINT32_MAX && hist_part->id != UINT32_MAX &&
hist_part->type == partition_element::VERSIONING))); hist_part->type() == partition_element::VERSIONING));
return true; return true;
} }
return false; return false;
@ -352,7 +351,7 @@ public:
char *find_duplicate_field(); char *find_duplicate_field();
char *find_duplicate_name(); char *find_duplicate_name();
bool check_engine_mix(handlerton *engine_type, bool default_engine); bool check_engine_mix(handlerton *engine_type, bool default_engine);
bool check_range_constants(THD *thd, bool init= true); bool check_range_constants(THD *thd, bool alloc= true);
bool check_list_constants(THD *thd); bool check_list_constants(THD *thd);
bool check_partition_info(THD *thd, handlerton **eng_type, bool check_partition_info(THD *thd, handlerton **eng_type,
handler *file, HA_CREATE_INFO *info, handler *file, HA_CREATE_INFO *info,
@ -426,8 +425,9 @@ public:
bool vers_set_interval(const INTERVAL &i); bool vers_set_interval(const INTERVAL &i);
bool vers_set_limit(ulonglong limit); bool vers_set_limit(ulonglong limit);
partition_element* vers_part_rotate(THD *thd); partition_element* vers_part_rotate(THD *thd);
bool vers_setup_1(THD *thd, uint32 added= 0); bool vers_set_expression(THD *thd, partition_element *el, MYSQL_TIME &t);
bool vers_setup_2(THD *thd, bool is_create_table_ind); bool vers_setup_expression(THD *thd, uint32 alter_add= 0); /* Stage 1. */
bool vers_setup_stats(THD *thd, bool is_create_table_ind); /* Stage 2. */
bool vers_scan_min_max(THD *thd, partition_element *part); bool vers_scan_min_max(THD *thd, partition_element *part);
void vers_update_col_vals(THD *thd, partition_element *el0, partition_element *el1); void vers_update_col_vals(THD *thd, partition_element *el0, partition_element *el1);
@ -443,8 +443,8 @@ public:
partition_element *el; partition_element *el;
while ((el= it++)) while ((el= it++))
{ {
DBUG_ASSERT(el->type != partition_element::CONVENTIONAL); DBUG_ASSERT(el->type() != partition_element::CONVENTIONAL);
if (el->type == partition_element::VERSIONING && if (el->type() == partition_element::VERSIONING &&
el->id == table->s->hist_part_id) el->id == table->s->hist_part_id)
{ {
vers_info->hist_part= el; vers_info->hist_part= el;
@ -516,7 +516,7 @@ public:
{ {
DBUG_ASSERT(vers_info && vers_info->initialized()); DBUG_ASSERT(vers_info && vers_info->initialized());
DBUG_ASSERT(table && table->s); DBUG_ASSERT(table && table->s);
DBUG_ASSERT(el && el->type == partition_element::VERSIONING); DBUG_ASSERT(el && el->type() == partition_element::VERSIONING);
bool updated; bool updated;
mysql_rwlock_wrlock(&table->s->LOCK_stat_serial); mysql_rwlock_wrlock(&table->s->LOCK_stat_serial);
el->empty= false; el->empty= false;
@ -552,7 +552,7 @@ public:
if (part_id < vers_info->now_part->id) if (part_id < vers_info->now_part->id)
vers_update_stats(thd, get_partition(part_id)); vers_update_stats(thd, get_partition(part_id));
} }
void vers_update_range_constants(THD *thd) bool vers_update_range_constants(THD *thd)
{ {
DBUG_ASSERT(vers_info && vers_info->initialized()); DBUG_ASSERT(vers_info && vers_info->initialized());
DBUG_ASSERT(table && table->s); DBUG_ASSERT(table && table->s);
@ -561,17 +561,19 @@ public:
if (vers_info->stat_serial == table->s->stat_serial) if (vers_info->stat_serial == table->s->stat_serial)
{ {
mysql_rwlock_unlock(&table->s->LOCK_stat_serial); mysql_rwlock_unlock(&table->s->LOCK_stat_serial);
return; return false;
} }
bool result= false;
for (uint i= 0; i < num_columns; ++i) for (uint i= 0; i < num_columns; ++i)
{ {
Field *f= part_field_array[i]; Field *f= part_field_array[i];
bitmap_set_bit(f->table->write_set, f->field_index); bitmap_set_bit(f->table->write_set, f->field_index);
} }
check_range_constants(thd, false); result= check_range_constants(thd, false);
vers_info->stat_serial= table->s->stat_serial; vers_info->stat_serial= table->s->stat_serial;
mysql_rwlock_unlock(&table->s->LOCK_stat_serial); mysql_rwlock_unlock(&table->s->LOCK_stat_serial);
return result;
} }
}; };

View File

@ -1689,7 +1689,7 @@ bool fix_partition_func(THD *thd, TABLE *table,
if (part_info->column_list) if (part_info->column_list)
{ {
if (part_info->part_type == VERSIONING_PARTITION && if (part_info->part_type == VERSIONING_PARTITION &&
part_info->vers_setup_1(thd)) part_info->vers_setup_expression(thd))
goto end; goto end;
List_iterator<char> it(part_info->part_field_list); List_iterator<char> it(part_info->part_field_list);
if (unlikely(handle_list_of_fields(thd, it, table, part_info, FALSE))) if (unlikely(handle_list_of_fields(thd, it, table, part_info, FALSE)))
@ -2392,7 +2392,7 @@ static int add_partition_values(File fptr, partition_info *part_info,
} }
else if (part_info->part_type == VERSIONING_PARTITION) else if (part_info->part_type == VERSIONING_PARTITION)
{ {
switch (p_elem->type) switch (p_elem->type())
{ {
case partition_element::AS_OF_NOW: case partition_element::AS_OF_NOW:
err+= add_string(fptr, " AS OF NOW"); err+= add_string(fptr, " AS OF NOW");
@ -5300,7 +5300,7 @@ that are reorganised.
partition_element *el; partition_element *el;
while ((el= it++)) while ((el= it++))
{ {
if (el->type == partition_element::AS_OF_NOW) if (el->type() == partition_element::AS_OF_NOW)
{ {
DBUG_ASSERT(tab_part_info->vers_info && el == tab_part_info->vers_info->now_part); DBUG_ASSERT(tab_part_info->vers_info && el == tab_part_info->vers_info->now_part);
it.remove(); it.remove();
@ -5393,7 +5393,7 @@ that are reorganised.
if (is_name_in_list(part_elem->partition_name, if (is_name_in_list(part_elem->partition_name,
alter_info->partition_names)) alter_info->partition_names))
{ {
if (part_elem->type == partition_element::AS_OF_NOW) if (part_elem->type() == partition_element::AS_OF_NOW)
{ {
DBUG_ASSERT(table && table->s && table->s->table_name.str); DBUG_ASSERT(table && table->s && table->s->table_name.str);
my_error(ER_VERS_WRONG_PARTS, MYF(0), table->s->table_name.str); my_error(ER_VERS_WRONG_PARTS, MYF(0), table->s->table_name.str);
@ -5724,7 +5724,7 @@ the generated partition syntax in a correct manner.
if (alter_info->flags & Alter_info::ALTER_ADD_PARTITION && if (alter_info->flags & Alter_info::ALTER_ADD_PARTITION &&
tab_part_info->part_type == VERSIONING_PARTITION && tab_part_info->part_type == VERSIONING_PARTITION &&
tab_part_info->vers_setup_1(thd, alt_part_info->partitions.elements)) tab_part_info->vers_setup_expression(thd, alt_part_info->partitions.elements))
goto err; goto err;
if (tab_part_info->check_partition_info(thd, (handlerton**)NULL, if (tab_part_info->check_partition_info(thd, (handlerton**)NULL,

View File

@ -5212,7 +5212,7 @@ opt_part_values:
my_yyabort_error((ER_VERS_WRONG_PARTS, MYF(0), my_yyabort_error((ER_VERS_WRONG_PARTS, MYF(0),
Lex->create_last_non_select_table->table_name)); Lex->create_last_non_select_table->table_name));
} }
elem->type= partition_element::AS_OF_NOW; elem->type(partition_element::AS_OF_NOW);
DBUG_ASSERT(part_info->vers_info); DBUG_ASSERT(part_info->vers_info);
part_info->vers_info->now_part= elem; part_info->vers_info->now_part= elem;
if (part_info->init_column_part(thd)) if (part_info->init_column_part(thd))
@ -5243,7 +5243,7 @@ opt_part_values:
DBUG_ASSERT(Lex->create_last_non_select_table->table_name); DBUG_ASSERT(Lex->create_last_non_select_table->table_name);
my_yyabort_error((ER_VERS_WRONG_PARTS, MYF(0), Lex->create_last_non_select_table->table_name)); my_yyabort_error((ER_VERS_WRONG_PARTS, MYF(0), Lex->create_last_non_select_table->table_name));
} }
elem->type= partition_element::VERSIONING; elem->type(partition_element::VERSIONING);
if (part_info->init_column_part(thd)) if (part_info->init_column_part(thd))
{ {
MYSQL_YYABORT; MYSQL_YYABORT;

View File

@ -3455,7 +3455,7 @@ partititon_err:
thd->stmt_arena= &part_func_arena; thd->stmt_arena= &part_func_arena;
} }
bool err= outparam->part_info->vers_setup_2(thd, is_create_table); bool err= outparam->part_info->vers_setup_stats(thd, is_create_table);
if (!work_part_info_used) if (!work_part_info_used)
{ {

View File

@ -1521,13 +1521,13 @@ public:
bool versioned_by_sql() const bool versioned_by_sql() const
{ {
DBUG_ASSERT(s && file); DBUG_ASSERT(s && file);
return s->versioned && !file->versioned(); return s->versioned && !file->native_versioned();
} }
bool versioned_by_engine() const bool versioned_by_engine() const
{ {
DBUG_ASSERT(s && file); DBUG_ASSERT(s && file);
return s->versioned && file->versioned(); return s->versioned && file->native_versioned();
} }
Field *vers_start_field() const Field *vers_start_field() const