diff options
author | Konstantin Osipov <kostja@sun.com> | 2010-02-02 12:22:17 +0300 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2010-02-02 12:22:17 +0300 |
commit | c6c1ddabaf2d41b362921524d617fbc772c1c9b6 (patch) | |
tree | 919a1043e20b3f1f6a58331ae90a4a9529b0ab5e /sql/sql_partition.cc | |
parent | 665100b69dfebe45e2d3b68116c6718560bf63b2 (diff) | |
parent | d4f23f0cf6db38731a161c5c7b0b056fc67e5c02 (diff) | |
download | mariadb-git-c6c1ddabaf2d41b362921524d617fbc772c1c9b6.tar.gz |
Merge next-mr -> next-4284.
Diffstat (limited to 'sql/sql_partition.cc')
-rw-r--r-- | sql/sql_partition.cc | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index e75a9389f9f..88d03aa855f 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1027,6 +1027,8 @@ end_lex_with_single_table(THD *thd, TABLE *table, LEX *old_lex) table The table object part_info Reference to partitioning data structure is_sub_part Is the table subpartitioned as well + is_create_table_ind Indicator of whether openfrm was called as part of + CREATE or ALTER TABLE RETURN VALUE TRUE An error occurred, something was wrong with the @@ -1050,7 +1052,7 @@ end_lex_with_single_table(THD *thd, TABLE *table, LEX *old_lex) */ static bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, - bool is_sub_part) + bool is_sub_part, bool is_create_table_ind) { partition_info *part_info= table->part_info; bool result= TRUE; @@ -1106,10 +1108,31 @@ static bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, } if (unlikely(func_expr->const_item())) { - my_error(ER_CONST_EXPR_IN_PARTITION_FUNC_ERROR, MYF(0)); + my_error(ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR, MYF(0)); clear_field_flag(table); goto end; } + + /* + We don't allow creating partitions with timezone-dependent expressions as + a (sub)partitioning function, but we want to allow such expressions when + opening existing tables for easier maintenance. This exception should be + deprecated at some point in future so that we always throw an error. + */ + if (func_expr->walk(&Item::is_timezone_dependent_processor, + 0, NULL)) + { + if (is_create_table_ind) + { + my_error(ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR, MYF(0)); + goto end; + } + else + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR, + ER(ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR)); + } + if ((!is_sub_part) && (error= check_signed_flag(part_info))) goto end; result= set_up_field_array(table, is_sub_part); @@ -1720,7 +1743,7 @@ bool fix_partition_func(THD *thd, TABLE *table, else { if (unlikely(fix_fields_part_func(thd, part_info->subpart_expr, - table, TRUE))) + table, TRUE, is_create_table_ind))) goto end; if (unlikely(part_info->subpart_expr->result_type() != INT_RESULT)) { @@ -1748,7 +1771,7 @@ bool fix_partition_func(THD *thd, TABLE *table, else { if (unlikely(fix_fields_part_func(thd, part_info->part_expr, - table, FALSE))) + table, FALSE, is_create_table_ind))) goto end; if (unlikely(part_info->part_expr->result_type() != INT_RESULT)) { @@ -1771,7 +1794,7 @@ bool fix_partition_func(THD *thd, TABLE *table, else { if (unlikely(fix_fields_part_func(thd, part_info->part_expr, - table, FALSE))) + table, FALSE, is_create_table_ind))) goto end; } part_info->fixed= TRUE; |