diff options
author | Sergei Golubchik <serg@mariadb.org> | 2017-12-14 18:35:12 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-12-14 20:19:14 +0100 |
commit | 18405e5fd994c37698c6fbf0996ecc9e7d1af0f2 (patch) | |
tree | 243f7fdad5d603ca30ead2da414c787683eec2b9 /sql | |
parent | f149013393dcef06940cc82f11247ceafb935fae (diff) | |
download | mariadb-git-18405e5fd994c37698c6fbf0996ecc9e7d1af0f2.tar.gz |
Partitioning syntax for versioning
partition by system_time (
partition p0 history,
partition pn current
)
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_partition.cc | 2 | ||||
-rw-r--r-- | sql/lex.h | 1 | ||||
-rw-r--r-- | sql/partition_element.h | 4 | ||||
-rw-r--r-- | sql/partition_info.cc | 24 | ||||
-rw-r--r-- | sql/partition_info.h | 8 | ||||
-rw-r--r-- | sql/share/errmsg-utf8.txt | 4 | ||||
-rw-r--r-- | sql/sql_partition.cc | 12 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 10 |
8 files changed, 34 insertions, 31 deletions
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 454ff573624..bdff14d9d1e 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -4395,7 +4395,7 @@ int ha_partition::update_row(const uchar *old_data, const uchar *new_data) uint sub_factor= m_part_info->num_subparts ? m_part_info->num_subparts : 1; DBUG_ASSERT(m_tot_parts == m_part_info->num_parts * sub_factor); uint lpart_id= new_part_id / sub_factor; - // lpart_id is VERSIONING partition because new_part_id != old_part_id + // lpart_id is HISTORY partition because new_part_id != old_part_id m_part_info->vers_update_stats(thd, lpart_id); } diff --git a/sql/lex.h b/sql/lex.h index d31625292e3..bba28012df5 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -273,6 +273,7 @@ static SYMBOL symbols[] = { { "HAVING", SYM(HAVING)}, { "HELP", SYM(HELP_SYM)}, { "HIGH_PRIORITY", SYM(HIGH_PRIORITY)}, + { "HISTORY", SYM(HISTORY_SYM)}, { "HOST", SYM(HOST_SYM)}, { "HOSTS", SYM(HOSTS_SYM)}, { "HOUR", SYM(HOUR_SYM)}, diff --git a/sql/partition_element.h b/sql/partition_element.h index da08a15b2ce..4547feb9efd 100644 --- a/sql/partition_element.h +++ b/sql/partition_element.h @@ -156,8 +156,8 @@ public: enum elem_type { CONVENTIONAL= 0, - AS_OF_NOW, - VERSIONING + CURRENT, + HISTORY }; List<partition_element> subpartitions; diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 073d42f921f..86ec1fd2751 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -927,7 +927,7 @@ bool partition_info::vers_set_expression(THD *thd, partition_element *el, MYSQL_ 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) + if (el->type() == partition_element::CURRENT) { col_val->max_value= true; col_val->item_expression= NULL; @@ -991,20 +991,20 @@ bool partition_info::vers_setup_expression(THD * thd, uint32 alter_add) if (alter_add) { /* Non-empty historical partitions are left as is. */ - if (el->type() == partition_element::VERSIONING && !el->empty) + if (el->type() == partition_element::HISTORY && !el->empty) { ++id; continue; } /* Newly added element is inserted before AS_OF_NOW. */ - if (el->id == UINT32_MAX || el->type() == partition_element::AS_OF_NOW) + if (el->id == UINT32_MAX || el->type() == partition_element::CURRENT) { DBUG_ASSERT(table && table->s); 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); table->s->stat_trx[id * num_columns + STAT_TRX_END]= stat_trx_end; el->id= id++; - if (el->type() == partition_element::AS_OF_NOW) + if (el->type() == partition_element::CURRENT) break; goto set_expression; } @@ -1037,7 +1037,7 @@ bool partition_info::vers_scan_min_max(THD *thd, partition_element *part) uint32 part_id= part->id * sub_factor; uint32 part_id_end= part_id + sub_factor; DBUG_ASSERT(part->empty); - DBUG_ASSERT(part->type() == partition_element::VERSIONING); + DBUG_ASSERT(part->type() == partition_element::HISTORY); DBUG_ASSERT(table->s->stat_trx); for (; part_id < part_id_end; ++part_id) { @@ -1198,7 +1198,7 @@ bool partition_info::vers_setup_stats(THD * thd, bool is_create_table_ind) partition_element *el= NULL, *prev; while ((prev= el, el= it++)) { - if (el->type() == partition_element::VERSIONING && dont_stat) + if (el->type() == partition_element::HISTORY && dont_stat) { if (el->id == table->s->hist_part_id) { @@ -1216,7 +1216,7 @@ bool partition_info::vers_setup_stats(THD * thd, bool is_create_table_ind) if (!is_create_table_ind) { - if (el->type() == partition_element::AS_OF_NOW) + if (el->type() == partition_element::CURRENT) { uchar buf[8]; Field_timestampf fld(buf, NULL, 0, Field::NONE, &table->vers_end_field()->field_name, NULL, 6); @@ -1237,10 +1237,10 @@ bool partition_info::vers_setup_stats(THD * thd, bool is_create_table_ind) } } - if (el->type() == partition_element::AS_OF_NOW) + if (el->type() == partition_element::CURRENT) break; - DBUG_ASSERT(el->type() == partition_element::VERSIONING); + DBUG_ASSERT(el->type() == partition_element::HISTORY); if (vers_info->hist_part) { @@ -2085,13 +2085,13 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type, } if (part_type == VERSIONING_PARTITION) { - if (part_elem->type() == partition_element::VERSIONING) + if (part_elem->type() == partition_element::HISTORY) { hist_parts++; } else { - DBUG_ASSERT(part_elem->type() == partition_element::AS_OF_NOW); + DBUG_ASSERT(part_elem->type() == partition_element::CURRENT); now_parts++; } } @@ -2141,7 +2141,7 @@ bool partition_info::check_partition_info(THD *thd, handlerton **eng_type, Sql_condition::WARN_LEVEL_WARN, WARN_VERS_PARAMETERS, ER_THD(thd, WARN_VERS_PARAMETERS), - "no rotation condition for multiple `VERSIONING` partitions."); + "no rotation condition for multiple HISTORY partitions."); } } if (now_parts > 1) diff --git a/sql/partition_info.h b/sql/partition_info.h index 6b79fa82fb8..359eae6e8cb 100644 --- a/sql/partition_info.h +++ b/sql/partition_info.h @@ -58,11 +58,11 @@ struct Vers_part_info : public Sql_alloc if (now_part) { DBUG_ASSERT(now_part->id != UINT32_MAX); - DBUG_ASSERT(now_part->type() == partition_element::AS_OF_NOW); + DBUG_ASSERT(now_part->type() == partition_element::CURRENT); DBUG_ASSERT(!fully || (bool) hist_part); DBUG_ASSERT(!hist_part || ( hist_part->id != UINT32_MAX && - hist_part->type() == partition_element::VERSIONING)); + hist_part->type() == partition_element::HISTORY)); return true; } return false; @@ -436,7 +436,7 @@ public: while ((el= it++)) { DBUG_ASSERT(el->type() != partition_element::CONVENTIONAL); - if (el->type() == partition_element::VERSIONING && + if (el->type() == partition_element::HISTORY && el->id == table->s->hist_part_id) { vers_info->hist_part= el; @@ -508,7 +508,7 @@ public: { DBUG_ASSERT(vers_info && vers_info->initialized()); DBUG_ASSERT(table && table->s); - DBUG_ASSERT(el && el->type() == partition_element::VERSIONING); + DBUG_ASSERT(el && el->type() == partition_element::HISTORY); bool updated; mysql_rwlock_wrlock(&table->s->LOCK_stat_serial); el->empty= false; diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index bad7c786f46..31a7e930fee 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -7837,7 +7837,7 @@ ER_PARTITION_WRONG_TYPE eng "Wrong partition type, expected type: %`s" WARN_VERS_PART_FULL - eng "Versioned table %`s.%`s: partition %`s is full, add more VERSIONING partitions" + eng "Versioned table %`s.%`s: partition %`s is full, add more HISTORY partitions" WARN_VERS_PARAMETERS eng "Maybe missing parameters: %s" @@ -7897,7 +7897,7 @@ ER_PART_WRONG_VALUE eng "Wrong parameters for partitioned %`s: wrong value for '%s'" ER_VERS_WRONG_PARTS - eng "Wrong partitions consistency for %`s: must have at least one VERSIONING and exactly one last AS OF CURRENT_TIMESTAMP" + eng "Wrong partitions consistency for %`s: must have at least one HISTORY and exactly one last CURRENT" ER_VERS_HISTORY_LOCK eng "Versioned SELECT write-locking of history rows" diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 55d906bb3b4..e4662f2d52e 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -2220,11 +2220,11 @@ static int add_partition_values(String *str, partition_info *part_info, { switch (p_elem->type()) { - case partition_element::AS_OF_NOW: - err+= str->append(STRING_WITH_LEN(" AS OF CURRENT_TIMESTAMP")); + case partition_element::CURRENT: + err+= str->append(STRING_WITH_LEN(" CURRENT")); break; - case partition_element::VERSIONING: - err+= str->append(STRING_WITH_LEN(" VERSIONING")); + case partition_element::HISTORY: + err+= str->append(STRING_WITH_LEN(" HISTORY")); break; default: DBUG_ASSERT(0 && "wrong p_elem->type"); @@ -5000,7 +5000,7 @@ that are reorganised. partition_element *el; while ((el= it++)) { - if (el->type() == partition_element::AS_OF_NOW) + if (el->type() == partition_element::CURRENT) { DBUG_ASSERT(tab_part_info->vers_info && el == tab_part_info->vers_info->now_part); it.remove(); @@ -5094,7 +5094,7 @@ that are reorganised. alter_info->partition_names)) { if (tab_part_info->part_type == VERSIONING_PARTITION && - part_elem->type() == partition_element::AS_OF_NOW) + part_elem->type() == partition_element::CURRENT) { DBUG_ASSERT(table && table->s && table->s->table_name.str); my_error(ER_VERS_WRONG_PARTS, MYF(0), table->s->table_name.str); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 41db8bbead4..bfca3005713 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1156,6 +1156,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); %token HEX_NUM %token HEX_STRING %token HIGH_PRIORITY +%token HISTORY_SYM /* MYSQL */ %token HOST_SYM %token HOSTS_SYM %token HOUR_MICROSECOND_SYM @@ -5460,7 +5461,7 @@ opt_part_values: part_info->part_type= LIST_PARTITION; } part_values_in {} - | AS OF_SYM NOW_SYM + | CURRENT_SYM { LEX *lex= Lex; partition_info *part_info= lex->part_info; @@ -5479,7 +5480,7 @@ opt_part_values: my_yyabort_error((ER_VERS_WRONG_PARTS, MYF(0), Lex->create_last_non_select_table->table_name)); } - elem->type(partition_element::AS_OF_NOW); + elem->type(partition_element::CURRENT); DBUG_ASSERT(part_info->vers_info); part_info->vers_info->now_part= elem; if (part_info->init_column_part(thd)) @@ -5487,7 +5488,7 @@ opt_part_values: MYSQL_YYABORT; } } - | VERSIONING_SYM + | HISTORY_SYM { LEX *lex= Lex; partition_info *part_info= lex->part_info; @@ -5510,7 +5511,7 @@ opt_part_values: 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)); } - elem->type(partition_element::VERSIONING); + elem->type(partition_element::HISTORY); if (part_info->init_column_part(thd)) { MYSQL_YYABORT; @@ -15506,6 +15507,7 @@ keyword_sp_not_data_type: | GOTO_SYM {} | HASH_SYM {} | HARD_SYM {} + | HISTORY_SYM {} | HOSTS_SYM {} | HOUR_SYM {} | ID_SYM {} |