Commit eb160d28 authored by unknown's avatar unknown
Browse files

Merge dator5.(none):/home/pappa/clean-mysql-5.1

into  dator5.(none):/home/pappa/bug18198


mysql-test/r/partition.result:
  Auto merged
mysql-test/r/partition_error.result:
  Auto merged
mysql-test/t/partition.test:
  Auto merged
mysql-test/t/partition_error.test:
  Auto merged
sql/sql_table.cc:
  Auto merged
parents 54b38dd6 604227e8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -756,7 +756,7 @@ t2 CREATE TABLE `t2` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='no comment' /*!50100 PARTITION BY KEY (a)  */
drop table t2;
create table t1 (s1 char(2) character set utf8)
partition by list (case when s1 > 'cz' then 1 else 2 end)
partition by list (cast(s1 as signed))
(partition p1 values in (1),
partition p2 values in (2));
drop table t1;
+17 −0
Original line number Diff line number Diff line
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:
+1 −1
Original line number Diff line number Diff line
@@ -891,7 +891,7 @@ drop table t2;
# Bug#14367: Partitions: crash if utf8 column
#
create table t1 (s1 char(2) character set utf8)
partition by list (case when s1 > 'cz' then 1 else 2 end)
partition by list (cast(s1 as signed))
(partition p1 values in (1),
 partition p2 values in (2));
drop table t1;
+22 −0
Original line number Diff line number Diff line
@@ -8,6 +8,28 @@
drop table if exists t1;
--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
#
+43 −21
Original line number Diff line number Diff line
@@ -789,7 +789,7 @@ class Item {
    Check if a partition function is allowed
    SYNOPSIS
      check_partition_func_processor()
      bool_arg                        Return argument
      int_arg                        Return argument
    RETURN VALUE
      0
    DESCRIPTION
@@ -806,8 +806,28 @@ class Item {
    whether this should be inherited to the new class. If not the function
    below should be defined in the new Item class.
  */
  virtual bool check_partition_func_processor(byte *bool_arg)
  { *(bool *)bool_arg= FALSE; return 0; }

#define PF_SAFE_BINARY_COLLATION 3
#define PF_SAFE_SINGLE_CHAR_COLLATION 2
#define PF_SAFE 1
#define PF_UNSAFE 0
  bool safe_for_binary_collation(byte *int_arg)
  {
    if (*(int *)int_arg != PF_UNSAFE)
      *(int*)int_arg= PF_SAFE_BINARY_COLLATION;
    return 0;
  }
  bool safe_for_single_char_collation(byte *int_arg)
  {
    if (*(int*)int_arg == PF_SAFE)
      *(int*)int_arg= PF_SAFE_SINGLE_CHAR_COLLATION;
    return 0;
  }
  virtual bool check_partition_func_processor(byte *int_arg)
  {
    *(int *)int_arg= PF_UNSAFE;
    return 0;
  }

  virtual Item *equal_fields_propagator(byte * arg) { return this; }
  virtual Item *set_no_const_sub(byte *arg) { return this; }
@@ -1106,7 +1126,8 @@ class Item_name_const : public Item
    Item::maybe_null= TRUE;
  }

  bool check_partition_func_processor(byte *bool_arg) { return 0; }
  bool check_partition_func_processor(byte *int_arg)
  { return safe_for_single_char_collation(int_arg); }
  bool fix_fields(THD *, Item **);

  enum Type type() const;
@@ -1153,7 +1174,7 @@ class Item_num: public Item
  Item_num() {}                               /* Remove gcc warning */
  virtual Item_num *neg()= 0;
  Item *safe_charset_converter(CHARSET_INFO *tocs);
  bool check_partition_func_processor(byte *bool_arg) { return 0;}
  bool check_partition_func_processor(byte *int_arg) { return 0;}
};

#define NO_CACHED_FIELD_INDEX ((uint)(-1))
@@ -1289,7 +1310,7 @@ class Item_field :public Item_ident
  bool collect_item_field_processor(byte * arg);
  bool find_item_in_field_list_processor(byte *arg);
  bool register_field_in_read_map(byte *arg);
  bool check_partition_func_processor(byte *bool_arg) { return 0; }
  bool check_partition_func_processor(byte *int_arg) { return 0; }
  void cleanup();
  bool result_as_longlong()
  {
@@ -1337,7 +1358,7 @@ class Item_null :public Item
  bool is_null() { return 1; }
  void print(String *str) { str->append(STRING_WITH_LEN("NULL")); }
  Item *safe_charset_converter(CHARSET_INFO *tocs);
  bool check_partition_func_processor(byte *bool_arg) { return 0;}
  bool check_partition_func_processor(byte *int_arg) { return 0;}
};

class Item_null_result :public Item_null
@@ -1350,8 +1371,8 @@ class Item_null_result :public Item_null
  {
    save_in_field(result_field, no_conversions);
  }
  bool check_partition_func_processor(byte *bool_arg)
  { *(bool *)bool_arg= FALSE; return 0; }
  bool check_partition_func_processor(byte *int_arg)
  { *(int *)int_arg= PF_UNSAFE; return 0; }
};  

/* Item represents one placeholder ('?') of prepared statement */
@@ -1642,8 +1663,8 @@ class Item_static_float_func :public Item_float
  {}
  void print(String *str) { str->append(func_name); }
  Item *safe_charset_converter(CHARSET_INFO *tocs);
  bool check_partition_func_processor(byte *bool_arg)
  { *(bool *)bool_arg= FALSE; return 0; }
  bool check_partition_func_processor(byte *int_arg)
  { *(int *)int_arg= PF_UNSAFE; return 0; }
};


@@ -1721,7 +1742,7 @@ class Item_string :public Item
  void print(String *str);
  // to prevent drop fixed flag (no need parent cleanup call)
  void cleanup() {}
  bool check_partition_func_processor(byte *bool_arg) { return 0;}
  bool check_partition_func_processor(byte *int_arg) { return 0;}
};


@@ -1736,8 +1757,8 @@ class Item_static_string_func :public Item_string
  {}
  Item *safe_charset_converter(CHARSET_INFO *tocs);
  void print(String *str) { str->append(func_name); }
  bool check_partition_func_processor(byte *bool_arg)
  { *(bool *)bool_arg= FALSE; return 0; }
  bool check_partition_func_processor(byte *int_arg)
  { *(int *)int_arg= PF_UNSAFE; return 0; }
};


@@ -1750,8 +1771,8 @@ class Item_datetime :public Item_string
                                                    &my_charset_bin)
  { max_length=19;}
  enum_field_types field_type() const { return MYSQL_TYPE_DATETIME; }
  bool check_partition_func_processor(byte *bool_arg)
  { *(bool *)bool_arg= FALSE; return 0; }
  bool check_partition_func_processor(byte *int_arg)
  { *(int *)int_arg= PF_UNSAFE; return 0; }
};

class Item_empty_string :public Item_string
@@ -1774,8 +1795,8 @@ class Item_return_int :public Item_int
    unsigned_flag=1;
  }
  enum_field_types field_type() const { return int_field_type; }
  bool check_partition_func_processor(byte *bool_arg)
  { *(bool *)bool_arg= FALSE; return 0; }
  bool check_partition_func_processor(byte *int_arg)
  { *(int *)int_arg= PF_UNSAFE; return 0; }
};


@@ -1799,7 +1820,8 @@ class Item_hex_string: public Item
  void cleanup() {}
  bool eq(const Item *item, bool binary_cmp) const;
  virtual Item *safe_charset_converter(CHARSET_INFO *tocs);
  bool check_partition_func_processor(byte *bool_arg) { return 0;}
  bool check_partition_func_processor(byte *int_arg)
  { return safe_for_binary_collation(int_arg);}
};


@@ -2026,8 +2048,8 @@ class Item_int_with_ref :public Item_int
  }
  Item *new_item();
  virtual Item *real_item() { return ref; }
  bool check_partition_func_processor(byte *bool_arg)
  { *(bool *)bool_arg= FALSE; return 0; }
  bool check_partition_func_processor(byte *int_arg)
  { *(int *)int_arg= PF_UNSAFE; return 0; }
};

#ifdef MYSQL_SERVER
Loading