diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2016-12-31 15:33:26 +0000 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2017-05-05 20:36:25 +0300 |
commit | 26a3ff0a22e931e44edf97b37c41db395eee6553 (patch) | |
tree | cd48d2a6c8a3f8ba2bbb2d8cf9f38a73e992ea2e /sql/partition_element.h | |
parent | e069de7d9da69dd0aed3147a493402cbdeca2c12 (diff) | |
download | mariadb-git-26a3ff0a22e931e44edf97b37c41db395eee6553.tar.gz |
SQL: (0.6) Pruning for VERSIONING partitions [closes #97]
* based on RANGE pruning by COLUMNS (sys_trx_end) condition
* removed DEFAULT; AS OF NOW is always last; current VERSIONING as last non-empty (or first empty)
* Min/Max stats in TABLE_SHARE
* ALTER TABLE ADD PARTITION adds before AS OF NOW partition
Diffstat (limited to 'sql/partition_element.h')
-rw-r--r-- | sql/partition_element.h | 65 |
1 files changed, 49 insertions, 16 deletions
diff --git a/sql/partition_element.h b/sql/partition_element.h index e76558bf7ae..18276ef713e 100644 --- a/sql/partition_element.h +++ b/sql/partition_element.h @@ -90,38 +90,64 @@ typedef struct p_elem_val struct st_ddl_log_memory_entry; -class Stat_timestampf : public Sql_alloc +class Vers_field_stats : public Sql_alloc { static const uint buf_size= 4 + (TIME_SECOND_PART_DIGITS + 1) / 2; uchar min_buf[buf_size]; uchar max_buf[buf_size]; Field_timestampf min_value; Field_timestampf max_value; + mysql_rwlock_t lock; public: - Stat_timestampf(const char *field_name, TABLE_SHARE *share) : + Vers_field_stats(const char *field_name, TABLE_SHARE *share) : min_value(min_buf, NULL, 0, Field::NONE, field_name, share, 6), max_value(max_buf, NULL, 0, Field::NONE, field_name, share, 6) { min_value.set_max(); memset(max_buf, 0, buf_size); + mysql_rwlock_init(key_rwlock_LOCK_vers_stats, &lock); } - void update(Field *from) + ~Vers_field_stats() { - from->update_min(&min_value, false); - from->update_max(&max_value, false); + mysql_rwlock_destroy(&lock); + } + bool update_unguarded(Field *from) + { + return + from->update_min(&min_value, false) + + from->update_max(&max_value, false); + } + bool update(Field *from) + { + mysql_rwlock_wrlock(&lock); + bool res= update_unguarded(from); + mysql_rwlock_unlock(&lock); + return res; } my_time_t min_time() { - return min_value.get_timestamp(); + mysql_rwlock_rdlock(&lock); + my_time_t res= min_value.get_timestamp(); + mysql_rwlock_unlock(&lock); + return res; } my_time_t max_time() { - return max_value.get_timestamp(); + mysql_rwlock_rdlock(&lock); + my_time_t res= max_value.get_timestamp(); + mysql_rwlock_unlock(&lock); + return res; } }; -class partition_element :public Sql_alloc { +enum stat_trx_field +{ + STAT_TRX_END= 0 +}; + +class partition_element :public Sql_alloc +{ public: List<partition_element> subpartitions; List<part_elem_value> list_val_list; @@ -142,6 +168,7 @@ public: bool signed_flag; // Range value signed bool max_value; // MAXVALUE range uint32 id; + bool empty; enum elem_type { @@ -151,7 +178,6 @@ public: }; elem_type type; - Stat_timestampf *stat_trx_end; partition_element() : part_max_rows(0), part_min_rows(0), range_value(0), @@ -162,10 +188,9 @@ public: nodegroup_id(UNDEF_NODEGROUP), has_null_value(FALSE), signed_flag(FALSE), max_value(FALSE), id(UINT32_MAX), - type(CONVENTIONAL), - stat_trx_end(NULL) - { - } + empty(true), + type(CONVENTIONAL) + {} partition_element(partition_element *part_elem) : part_max_rows(part_elem->part_max_rows), part_min_rows(part_elem->part_min_rows), @@ -180,11 +205,19 @@ public: nodegroup_id(part_elem->nodegroup_id), has_null_value(FALSE), id(part_elem->id), - type(part_elem->type), - stat_trx_end(NULL) + empty(part_elem->empty), + type(part_elem->type) + {} + ~partition_element() {} + + part_column_list_val& get_col_val(uint idx) { + DBUG_ASSERT(type != CONVENTIONAL); + DBUG_ASSERT(list_val_list.elements == 1); + part_elem_value *ev= static_cast<part_elem_value*>(list_val_list.first_node()->info); + DBUG_ASSERT(ev && ev->col_val_array); + return ev->col_val_array[idx]; } - ~partition_element() {} }; #endif /* PARTITION_ELEMENT_INCLUDED */ |