From d868d032aa5f12ad95c1b9f9ffa54cbdda61cafc Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Apr 2006 12:39:06 +0200 Subject: [PATCH] BUG#18198: Too much expressiveness in partition functions allowed First step sql/item.h: Add function to check for partition function whether allowed or not. In this first step allow only a field on its own. Further steps will add a lot more possibilities. sql/partition_info.cc: Add a check whether the partition function is allowed by walking the partition function expression. sql/share/errmsg.txt: Add a new error code for partition function not allowed --- sql/item.h | 6 ++++++ sql/partition_info.cc | 7 +++++++ sql/share/errmsg.txt | 3 +++ 3 files changed, 16 insertions(+) diff --git a/sql/item.h b/sql/item.h index 6c7a0976df1..9c979eb4acd 100644 --- a/sql/item.h +++ b/sql/item.h @@ -744,6 +744,11 @@ public: virtual bool find_item_in_field_list_processor(byte *arg) { return 0; } virtual bool change_context_processor(byte *context) { return 0; } virtual bool reset_query_id_processor(byte *query_id) { return 0; } + virtual bool check_partition_func_processor(byte *bool_arg) + { + *(bool *)bool_arg= FALSE; + return 0; + } virtual Item *equal_fields_propagator(byte * arg) { return this; } virtual Item *set_no_const_sub(byte *arg) { return this; } @@ -1202,6 +1207,7 @@ public: result_field->query_id= field->query_id; return 0; } + bool check_partition_func_processor(byte *bool_arg) { return 0; } void cleanup(); Item_equal *find_item_equal(COND_EQUAL *cond_equal); Item *equal_fields_propagator(byte *arg); diff --git a/sql/partition_info.cc b/sql/partition_info.cc index ad0aa053ae2..9c7999b136b 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -655,8 +655,15 @@ bool partition_info::check_partition_info(handlerton **eng_type, uint i, tot_partitions; bool result= TRUE; char *same_name; + bool part_expression_ok= TRUE; DBUG_ENTER("partition_info::check_partition_info"); + if (part_expr->walk(Item::check_partition_func_processor, + (byte*)&part_expression_ok)) + { + my_error(ER_PARTITION_FUNC_NOT_ALLOWED, MYF(0)); + goto end; + } if (unlikely(!is_sub_partitioned() && !(use_default_subpartitions && use_default_no_subpartitions))) { diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index e8766b3d882..01202bb5b71 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -5826,3 +5826,6 @@ ER_NDB_CANT_SWITCH_BINLOG_FORMAT eng "The NDB cluster engine does not support changing the binlog format on the fly yet" ER_PARTITION_NO_TEMPORARY eng "Cannot create temporary table with partitions" +ER_PARTITION_FUNCTION_NOT_ALLOWED + eng "This partition function is not allowed" + swe "Denna partitioneringsfunktion är inte tillåten"