List:Internals« Previous MessageNext Message »
From:Mikael Ronström Date:June 20 2006 9:31am
Subject:bk commit - 5.1 tree (mikael:1.2220) BUG#18198
View as plain text  
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2006/06/20 10:57:02-04:00 mikael@dator5.(none)
#   BUG#18198: Too flexible partition functions
#
# sql/sql_yacc.yy
#   2006/06/20 10:56:58-04:00 mikael@dator5.(none) +9 -2
#   Verify that partition function is allowed before "fixing" it
#
# mysql-test/t/partition_error.test
#   2006/06/20 10:56:58-04:00 mikael@dator5.(none) +22 -0
#   New test cases
#
# mysql-test/r/partition_error.result
#   2006/06/20 10:56:58-04:00 mikael@dator5.(none) +17 -0
#   New test cases
#
diff -Nru a/mysql-test/r/partition_error.result 
b/mysql-test/r/partition_error.result
--- a/mysql-test/r/partition_error.result	2006-06-20 11:02:53 -04:00
+++ b/mysql-test/r/partition_error.result	2006-06-20 11:02:53 -04:00
@@ -1,5 +1,22 @@
  drop table if exists t1;
  create table t1 (a int)
+partition by range (a)
+(partition p0 values less than ((select count(*) from t1)));
+ERROR HY000: This partition function is not allowed
+create table t1 (a int)
+partition by range (a)
+(partition p0 values less than (a);
+ERROR 42S22: Unknown column 'a' in 'partition function'
+create table t1 (a int)
+partition by range (a)
+(partition p0 values less than (1));
+alter table t1 add partition (partition p1 values less than (a));
+ERROR 42S22: Unknown column 'a' in 'partition function'
+alter table t1 add partition
+(partition p1 values less than ((select count(*) from t1)));
+ERROR HY000: This partition function is not allowed
+drop table t1;
+create table t1 (a int)
  engine = x
  partition by key (a);
  Warnings:
diff -Nru a/mysql-test/t/partition_error.test 
b/mysql-test/t/partition_error.test
--- a/mysql-test/t/partition_error.test	2006-06-20 11:02:53 -04:00
+++ b/mysql-test/t/partition_error.test	2006-06-20 11:02:53 -04:00
@@ -9,6 +9,28 @@
  --enable_warnings

  #
+# Bug 18198: Partitions: Too flexible functions
+#
+-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
+create table t1 (a int)
+partition by range (a)
+(partition p0 values less than ((select count(*) from t1)));
+-- error 1054
+create table t1 (a int)
+partition by range (a)
+(partition p0 values less than (a);
+
+create table t1 (a int)
+partition by range (a)
+(partition p0 values less than (1));
+-- error 1054
+alter table t1 add partition (partition p1 values less than (a));
+-- error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED
+alter table t1 add partition
+(partition p1 values less than ((select count(*) from t1)));
+drop table t1;
+
+#
  # Bug 20397: Partitions: Crash when using non-existing engine
  #
  create table t1 (a int)
diff -Nru a/sql/sql_yacc.yy b/sql/sql_yacc.yy
--- a/sql/sql_yacc.yy	2006-06-20 11:02:53 -04:00
+++ b/sql/sql_yacc.yy	2006-06-20 11:02:53 -04:00
@@ -3616,6 +3616,7 @@
          {
            Item *part_expr= $1;
            bool not_corr_func;
+          bool part_expression_ok= TRUE;
            LEX *lex= Lex;
            THD *thd= YYTHD;
            longlong item_value;
@@ -3633,13 +3634,19 @@
              mem_alloc_error(sizeof(part_elem_value));
              YYABORT;
            }
-
+          part_expr->walk(&Item::check_partition_func_processor, 0,
+                          (byte*)(&part_expression_ok));
+          if (!part_expression_ok)
+          {
+            my_error(ER_PARTITION_FUNCTION_IS_NOT_ALLOWED, MYF(0));
+            YYABORT;
+          }
            if (part_expr->fix_fields(YYTHD, (Item**)0) ||
                ((context->table_list= save_list), FALSE) ||
                (!part_expr->const_item()) ||
                (!lex->safe_to_cache_query))
            {
-            yyerror(ER(ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR));
+            my_error(ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR, MYF(0));
              YYABORT;
            }
            thd->where= save_where;

Mikael Ronstrom, Senior Software Architect
MySQL AB, www.mysql.com

Jumpstart your cluster:
http://www.mysql.com/consulting/packaged/cluster.html
My blog:
http://mikaelronstrom.blogspot.com

Thread
bk commit - 5.1 tree (mikael:1.2220) BUG#18198Mikael Ronström20 Jun