mariadb/mysql-test/r/partition_bug18198.result
Alexey Kopytov c08e6c8867 Bug #42849: innodb crash with varying time_zone on partitioned
timestamp primary key 
 
Since TIMESTAMP values are adjusted by the current time zone  
settings in both numeric and string contexts, using any 
expressions involving TIMESTAMP values as a  
(sub)partitioning function leads to undeterministic behavior of  
partitioned tables. The effect may vary depending on a storage  
engine, it can be either incorrect data being retrieved or  
stored, or an assertion failure. The root cause of this is the  
fact that the calculated partition ID may differ from a  
previously calculated ID for the same data due to timezone  
adjustments of the partitioning expression value. 
 
Fixed by disabling any expressions involving TIMESTAMP values  
to be used in partitioning functions with the follwing two 
exceptions: 
 
1. Creating or altering into a partitioned table that violates 
the above rule is not allowed, but opening existing such tables 
results in a warning rather than an error so that such tables 
could be fixed. 
 
2. UNIX_TIMESTAMP() is the only way to get a 
timezone-independent value from a TIMESTAMP column, because it 
returns the internal representation (a time_t value) of a 
TIMESTAMP argument verbatim. So UNIX_TIMESTAMP(timestamp_column)
is allowed and should be used to fix existing tables if one 
wants to use TIMESTAMP columns with partitioning.

mysql-test/r/partition_bug18198.result:
  Corrected the error.
mysql-test/r/partition_error.result:
  Corrected error texts.
  Added test cases for bug #42849.
mysql-test/t/partition_bug18198.test:
  Corrected error code.
mysql-test/t/partition_error.test:
  Corrected error codes.
  Added test cases for bug #42849.
sql/item.h:
  Added is_timezone_dependent_processor() to Item.
sql/item_func.h:
  Added has_timestamp_args() and the implementation of
  is_timezone_dependent_processor() for Item_func.
sql/item_timefunc.h:
  Added is_timezone_dependent_processor() to 
  Item_func_unix_timestamp.
sql/share/errmsg.txt:
  Renamed ER_CONST_EXPR_IN_PARTITION_FUNC_ERROR to
  ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR to better reflect the
  meaning. Adjusted the error message.
sql/sql_partition.cc:
  Modified fix_fields_part_func() to walk through partitioning
  expression tree with is_timezone_dependent_processor() and issue
  a warning/error if it depends on the timezone settings.
  
  Changed fix_fields_part_func() to a static function since it is
  not used anywhere except sql_partition.cc
sql/sql_partition.h:
  Removed the unneeded declaration of fix_fields_part_func()
  since it is now a static function.
sql/sql_yacc.yy:
  ER_CONST_EXPR_IN_PARTITION_FUNC_ERROR ->
  ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR.
2009-12-13 23:29:50 +03:00

173 lines
8.1 KiB
Text

drop table if exists t1;
create table t1 (col1 datetime)
partition by range(datediff(col1,col1))
(partition p0 values less than (10), partition p1 values less than (30));
drop table t1;
create table t1 (col1 int)
partition by range(greatest(col1,10))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(isnull(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(least(col1,12))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(case when col1>0 then 10 else 20 end)
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(ifnull(col1,5))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(nullif(col1,5))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(bit_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(bit_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(char_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(char_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(character_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(find_in_set(col1,1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(find_in_set(col1,'1'))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(instr(col1,3))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(instr(col1,'3'))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(locate(1,col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(locate(1,col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(octet_length(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(position(1 in col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(position(1 in col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 char(5))
partition by range(strcmp(col1,2))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(strcmp(col1,2))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(crc32(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(round(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(sign(col1))
(partition p0 values less than (2), partition p1 values less than (6));
ERROR HY000: This partition function is not allowed
create table t1 (col1 datetime)
partition by range(period_add(col1,5))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 datetime, col2 datetime)
partition by range(period_diff(col1,col2))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int, col2 int)
partition by range(period_diff(col1,col2))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 datetime)
partition by range(timestampdiff(day,5,col1))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 date)
partition by range(unix_timestamp(col1))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed
create table t1 (col1 datetime)
partition by range(week(col1))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 varchar(25))
partition by range(cast(col1 as signed))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 varchar(25))
partition by range(convert(col1,unsigned))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(col1 | 20)
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(col1 & 20)
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(col1 ^ 20)
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(col1 << 20)
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(col1 >> 20)
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(~col1)
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(bit_count(col1))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed
create table t1 (col1 int)
partition by range(inet_aton(col1))
(partition p0 values less than (10), partition p1 values less than (30));
ERROR HY000: This partition function is not allowed