Commit 2a0f7a34 authored by Sergei Golubchik's avatar Sergei Golubchik

bugfix: non-deterministic vcols in partitioning

parent d1f37633
......@@ -126,3 +126,14 @@ select * from t1;
select partition_name,table_rows,data_length from information_schema.partitions where table_name = 't1';
drop table t1;
#
# Restrictions when partitioned
#
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
create table t1 (a int, b datetime as (now())) partition by hash(b+1) partitions 3;
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
create table t1 (a int, b varchar(100) as (user())) partition by hash(b+1) partitions 3;
--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR
create table t1 (a int, b double as (rand())) partition by hash(b+1) partitions 3;
......@@ -81,3 +81,9 @@ p0 1 16384
p1 1 16384
p2 0 16384
drop table t1;
create table t1 (a int, b datetime as (now())) partition by hash(b+1) partitions 3;
ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed
create table t1 (a int, b varchar(100) as (user())) partition by hash(b+1) partitions 3;
ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed
create table t1 (a int, b double as (rand())) partition by hash(b+1) partitions 3;
ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed
......@@ -81,3 +81,9 @@ p0 1 7
p1 1 7
p2 0 0
drop table t1;
create table t1 (a int, b datetime as (now())) partition by hash(b+1) partitions 3;
ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed
create table t1 (a int, b varchar(100) as (user())) partition by hash(b+1) partitions 3;
ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed
create table t1 (a int, b double as (rand())) partition by hash(b+1) partitions 3;
ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed
......@@ -5576,6 +5576,14 @@ bool Item_field::vcol_in_partition_func_processor(void *int_arg)
return FALSE;
}
bool Item_field::check_valid_arguments_processor(void *bool_arg)
{
Virtual_column_info *vcol= field->vcol_info;
if (!vcol)
return FALSE;
return vcol->expr->walk(&Item::check_partition_func_processor, 0, NULL)
|| vcol->expr->walk(&Item::check_valid_arguments_processor, 0, NULL);
}
void Item_field::cleanup()
{
......
......@@ -2576,6 +2576,7 @@ class Item_field :public Item_ident
bool register_field_in_bitmap(void *arg);
bool check_partition_func_processor(void *int_arg) {return FALSE;}
bool vcol_in_partition_func_processor(void *bool_arg);
bool check_valid_arguments_processor(void *bool_arg);
bool check_field_expression_processor(void *arg);
bool enumerate_field_refs_processor(void *arg);
bool update_table_bitmaps_processor(void *arg);
......
......@@ -3339,6 +3339,8 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share,
outparam->file= 0; // For easier error checking
outparam->db_stat=0;
thd->lex->context_analysis_only= save_context_analysis_only;
if (outparam->expr_arena)
outparam->expr_arena->free_items();
free_root(&outparam->mem_root, MYF(0)); // Safe to call on bzero'd root
outparam->alias.free();
DBUG_RETURN (error);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment