summaryrefslogtreecommitdiff
path: root/sql/sql_partition.cc
diff options
context:
space:
mode:
authorunknown <mikael/pappa@dator5.(none)>2006-07-31 05:42:06 -0400
committerunknown <mikael/pappa@dator5.(none)>2006-07-31 05:42:06 -0400
commit1e949e84c59af2f32d116117d4e4b9ae2f1ffdb7 (patch)
tree2dd37edb87660fedfae837ba0f39c7a32785b042 /sql/sql_partition.cc
parentb230225b459bdcbf0cf82c60e62b894453411a14 (diff)
parent76ba12d6d99f0c613824997f1d0f8f874a614c5a (diff)
downloadmariadb-git-1e949e84c59af2f32d116117d4e4b9ae2f1ffdb7.tar.gz
Merge dator5.(none):/home/pappa/clean-mysql-5.1
into dator5.(none):/home/pappa/bug18198 mysql-test/r/partition.result: Auto merged mysql-test/t/partition.test: Auto merged sql/item_func.h: Auto merged sql/item_strfunc.h: Auto merged sql/sql_partition.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_yacc.yy: Auto merged
Diffstat (limited to 'sql/sql_partition.cc')
-rw-r--r--sql/sql_partition.cc50
1 files changed, 48 insertions, 2 deletions
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 3f1572ee676..55eab215746 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -525,6 +525,7 @@ static bool set_up_field_array(TABLE *table,
}
+
/*
Create a field array including all fields of both the partitioning and the
subpartitioning functions.
@@ -549,6 +550,7 @@ static bool create_full_part_field_array(TABLE *table,
partition_info *part_info)
{
bool result= FALSE;
+ Field **ptr;
DBUG_ENTER("create_full_part_field_array");
if (!part_info->is_sub_partitioned())
@@ -558,7 +560,7 @@ static bool create_full_part_field_array(TABLE *table,
}
else
{
- Field **ptr, *field, **field_array;
+ Field *field, **field_array;
uint no_part_fields=0, size_field_array;
ptr= table->field;
while ((field= *(ptr++)))
@@ -1369,6 +1371,43 @@ static uint32 get_part_id_from_linear_hash(longlong hash_value, uint mask,
return part_id;
}
+
+/*
+ Check that partition function do not contain any forbidden
+ character sets and collations.
+ SYNOPSIS
+ check_part_func_fields()
+ part_info Partition info
+ ptr Array of Field pointers
+ RETURN VALUES
+ FALSE Success
+ TRUE Error
+*/
+
+static bool check_part_func_fields(Field **ptr)
+{
+ Field *field;
+ while ((field= *(ptr++)))
+ {
+ /*
+ For CHAR/VARCHAR fields we need to take special precautions.
+ Binary collation with CHAR is automatically supported. Other
+ types need some kind of standardisation function handling
+ */
+ if (field->type() == MYSQL_TYPE_STRING ||
+ field->type() == MYSQL_TYPE_VARCHAR)
+ {
+ CHARSET_INFO *cs= ((Field_str*)field)->charset();
+ if (field->type() == MYSQL_TYPE_STRING &&
+ cs->state & MY_CS_BINSORT)
+ return FALSE;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
/*
fix partition functions
@@ -1514,6 +1553,13 @@ bool fix_partition_func(THD *thd, TABLE *table,
goto end;
}
}
+ if ((check_part_func_fields(part_info->part_field_array)) ||
+ (part_info->is_sub_partitioned() &&
+ check_part_func_fields(part_info->subpart_field_array)))
+ {
+ my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
+ goto end;
+ }
if (unlikely(create_full_part_field_array(table, part_info)))
goto end;
if (unlikely(check_primary_key(table)))
@@ -4544,7 +4590,7 @@ the generated partition syntax in a correct manner.
tab_part_info->use_default_no_subpartitions= FALSE;
}
if (tab_part_info->check_partition_info(thd, (handlerton**)NULL,
- table->file, ULL(0)))
+ table->file, ULL(0), FALSE))
{
DBUG_RETURN(TRUE);
}