From d4f8ffeeb622b3d2ecfd9f66d96627ff9fde0487 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Wed, 1 Dec 2010 12:20:46 +0100 Subject: Bug#56380: valgrind memory leak warning from partition tests There could be memory leaks if ALTER ... PARTITION command fails. Problem was that the list of items to free was not set in the partition info structure when fix_partition_func call failed during ALTER ... PARTITION. Solved by always setting the list in the partition info struct. --- sql/table.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/table.cc b/sql/table.cc index 18523f08551..b43d29294a8 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1867,8 +1867,8 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, { if (work_part_info_used) tmp= fix_partition_func(thd, outparam, is_create_table); - outparam->part_info->item_free_list= part_func_arena.free_list; } + outparam->part_info->item_free_list= part_func_arena.free_list; partititon_err: if (tmp) { -- cgit v1.2.1 From 966d0ebaf3672458056c6de32da429d50b3f76d9 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Wed, 22 Dec 2010 10:50:36 +0100 Subject: Bug#54483: valgrind errors when making warnings for multiline inserts into partition Bug#57071: EXTRACT(WEEK from date_col) cannot be allowed as partitioning function There were functions allowed as partitioning functions that implicit allowed cast. That could result in unacceptable behaviour. Solution was to check that the arguments of date and time functions have allowed types (field and date/datetime/time depending on function). --- mysql-test/r/partition.result | 2 +- mysql-test/r/partition_error.result | 638 +++ .../parts/inc/part_supported_sql_funcs_main.inc | 48 +- .../parts/r/part_supported_sql_func_innodb.result | 5210 ++++++-------------- .../parts/r/part_supported_sql_func_myisam.result | 5210 ++++++-------------- mysql-test/t/partition.test | 5 +- mysql-test/t/partition_error.test | 664 +++ sql/item.h | 8 +- sql/item_func.h | 42 +- sql/item_timefunc.h | 94 +- sql/sql_partition.cc | 2 +- 11 files changed, 4637 insertions(+), 7286 deletions(-) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 8e65557d690..27ada9d1129 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -1778,7 +1778,7 @@ c1 bigint, c2 set('sweet'), key (c2,c1,c0), key(c0) -) engine=myisam partition by hash (month(c0)) partitions 5; +) engine=myisam partition by hash (c0) partitions 5; insert ignore into t1 set c0 = -6502262, c1 = 3992917, c2 = 35019; insert ignore into t1 set c0 = 241221, c1 = -6862346, c2 = 56644; select c1 from t1 group by (select c0 from t1 limit 1); diff --git a/mysql-test/r/partition_error.result b/mysql-test/r/partition_error.result index ea74f476ceb..0426ce42071 100644 --- a/mysql-test/r/partition_error.result +++ b/mysql-test/r/partition_error.result @@ -1,5 +1,643 @@ drop table if exists t1; # +# Bug#54483: valgrind errors when making warnings for multiline inserts +# into partition +# +CREATE TABLE t1 (a VARBINARY(10)) +PARTITION BY RANGE (DAYOFWEEK(a)) +(PARTITION a1 VALUES LESS THAN (60)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a CHAR(10)) +PARTITION BY RANGE (DAYOFWEEK(a)) +(PARTITION a1 VALUES LESS THAN (60)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY RANGE (DAYOFWEEK(a)) +(PARTITION a1 VALUES LESS THAN (60)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIMESTAMP) +PARTITION BY RANGE (DAYOFWEEK(a)) +(PARTITION a1 VALUES LESS THAN (60)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY RANGE (DAYOFWEEK(a)) +(PARTITION a1 VALUES LESS THAN (60)); +INSERT INTO t1 VALUES ('test'),('a'),('5'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +Warning 1265 Data truncated for column 'a' at row 2 +Warning 1265 Data truncated for column 'a' at row 3 +SHOW WARNINGS; +Level Code Message +Warning 1265 Data truncated for column 'a' at row 1 +Warning 1265 Data truncated for column 'a' at row 2 +Warning 1265 Data truncated for column 'a' at row 3 +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY RANGE (DAYOFWEEK(a)) +(PARTITION a1 VALUES LESS THAN (60)); +INSERT INTO t1 VALUES ('test'),('a'),('5'); +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +Warning 1264 Out of range value for column 'a' at row 3 +SHOW WARNINGS; +Level Code Message +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +Warning 1264 Out of range value for column 'a' at row 3 +DROP TABLE t1; +CREATE TABLE t1 (a TIME) +PARTITION BY RANGE (DAYOFWEEK(a)) +(PARTITION a1 VALUES LESS THAN (60)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +SHOW WARNINGS; +Level Code Message +Error 1486 Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (TO_DAYS(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (TO_DAYS(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (TO_DAYS(a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (TO_DAYS(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (TO_DAYS(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (DAYOFMONTH(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (DAYOFMONTH(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (DAYOFMONTH(a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (DAYOFMONTH(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (DAYOFMONTH(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (MONTH(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (MONTH(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (MONTH(a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (MONTH(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (MONTH(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (DAYOFYEAR(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (DAYOFYEAR(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (DAYOFYEAR(a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (DAYOFYEAR(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (DAYOFYEAR(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (HOUR(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (HOUR(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (HOUR(a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (HOUR(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (HOUR(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (MINUTE(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (MINUTE(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (MINUTE(a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (MINUTE(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (MINUTE(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (QUARTER(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (QUARTER(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (QUARTER(a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (QUARTER(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (QUARTER(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (SECOND(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (SECOND(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (SECOND(a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (SECOND(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (SECOND(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (YEARWEEK(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (YEARWEEK(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (YEARWEEK(a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (YEARWEEK(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (YEARWEEK(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (WEEKDAY(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (WEEKDAY(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (WEEKDAY(a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (WEEKDAY(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (WEEKDAY(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +# TO_SECONDS() is added in 5.5. +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (TO_SECONDS(a)); +ERROR 42000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed near ')' at line 2 +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (TIME_TO_SEC(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (TIME_TO_SEC(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (TIME_TO_SEC(a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (TIME_TO_SEC(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (TIME_TO_SEC(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (FROM_DAYS(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (FROM_DAYS(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (FROM_DAYS(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (TO_DAYS(FROM_DAYS(a))); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (FROM_DAYS(a)); +ERROR HY000: The PARTITION function returns the wrong type +CREATE TABLE t1 (a INT) +PARTITION BY HASH (TO_DAYS(FROM_DAYS(a))); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (FROM_DAYS(a)); +ERROR HY000: The PARTITION function returns the wrong type +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (MICROSECOND(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (MICROSECOND(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (MICROSECOND(a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (MICROSECOND(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (MICROSECOND(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +# Bug#57071 +CREATE TABLE t1 +(`date` date, +`extracted_week` int, +`yearweek` int, +`week` int, +`default_week_format` int) +PARTITION BY LIST (EXTRACT(WEEK FROM date) % 3) +(PARTITION p0 VALUES IN (0), +PARTITION p1 VALUES IN (1), +PARTITION p2 VALUES IN (2)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 +(`date` date, +`extracted_week` int, +`yearweek` int, +`week` int, +`default_week_format` int); +SET @old_default_week_format := @@default_week_format; +SET default_week_format = 0; +INSERT INTO t1 VALUES ('2000-01-01', EXTRACT(WEEK FROM '2000-01-01'), YEARWEEK('2000-01-01'), WEEK('2000-01-01'), @@default_week_format); +SET default_week_format = 1; +INSERT INTO t1 VALUES ('2000-01-01', EXTRACT(WEEK FROM '2000-01-01'), YEARWEEK('2000-01-01'), WEEK('2000-01-01'), @@default_week_format); +SET default_week_format = 2; +INSERT INTO t1 VALUES ('2000-01-01', EXTRACT(WEEK FROM '2000-01-01'), YEARWEEK('2000-01-01'), WEEK('2000-01-01'), @@default_week_format); +SET default_week_format = 3; +INSERT INTO t1 VALUES ('2000-01-01', EXTRACT(WEEK FROM '2000-01-01'), YEARWEEK('2000-01-01'), WEEK('2000-01-01'), @@default_week_format); +SET default_week_format = 4; +INSERT INTO t1 VALUES ('2000-01-01', EXTRACT(WEEK FROM '2000-01-01'), YEARWEEK('2000-01-01'), WEEK('2000-01-01'), @@default_week_format); +SET default_week_format = 5; +INSERT INTO t1 VALUES ('2000-01-01', EXTRACT(WEEK FROM '2000-01-01'), YEARWEEK('2000-01-01'), WEEK('2000-01-01'), @@default_week_format); +SET default_week_format = 6; +INSERT INTO t1 VALUES ('2000-01-01', EXTRACT(WEEK FROM '2000-01-01'), YEARWEEK('2000-01-01'), WEEK('2000-01-01'), @@default_week_format); +SET default_week_format = 7; +INSERT INTO t1 VALUES ('2000-01-01', EXTRACT(WEEK FROM '2000-01-01'), YEARWEEK('2000-01-01'), WEEK('2000-01-01'), @@default_week_format); +SELECT * FROM t1; +date extracted_week yearweek week default_week_format +2000-01-01 0 199952 0 0 +2000-01-01 0 199952 0 1 +2000-01-01 52 199952 52 2 +2000-01-01 52 199952 52 3 +2000-01-01 0 199952 0 4 +2000-01-01 0 199952 0 5 +2000-01-01 52 199952 52 6 +2000-01-01 52 199952 52 7 +SET default_week_format = @old_default_week_format; +DROP TABLE t1; +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(YEAR FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(YEAR FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(YEAR FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(YEAR FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(YEAR FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(YEAR_MONTH FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(YEAR_MONTH FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(YEAR_MONTH FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(YEAR_MONTH FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(YEAR_MONTH FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(QUARTER FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(QUARTER FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(QUARTER FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(QUARTER FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(QUARTER FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(MONTH FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(MONTH FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(MONTH FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(MONTH FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(MONTH FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +# EXTRACT(WEEK...) is disallowed, see bug#57071. +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(WEEK FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(WEEK FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(WEEK FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(WEEK FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(WEEK FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(DAY FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(DAY FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(DAY FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(DAY FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(DAY FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(DAY_HOUR FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(DAY_HOUR FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(DAY_HOUR FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(DAY_HOUR FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(DAY_HOUR FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(DAY_MINUTE FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(DAY_MINUTE FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(DAY_MINUTE FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(DAY_MINUTE FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(DAY_MINUTE FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(DAY_SECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(DAY_SECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(DAY_SECOND FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(DAY_SECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(DAY_SECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(HOUR FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(HOUR FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(HOUR FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(HOUR FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(HOUR FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(HOUR_MINUTE FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(HOUR_MINUTE FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(HOUR_MINUTE FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(HOUR_MINUTE FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(HOUR_MINUTE FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(HOUR_SECOND FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(HOUR_SECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(HOUR_SECOND FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(HOUR_SECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(HOUR_SECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(MINUTE FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(MINUTE FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(MINUTE FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(MINUTE FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(MINUTE FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(MINUTE_SECOND FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(MINUTE_SECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(MINUTE_SECOND FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(MINUTE_SECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(MINUTE_SECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(SECOND FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(SECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(SECOND FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(SECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(SECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(MICROSECOND FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(MICROSECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(MICROSECOND FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(MICROSECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(MICROSECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(DAY_MICROSECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(DAY_MICROSECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(DAY_MICROSECOND FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(DAY_MICROSECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(DAY_MICROSECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(HOUR_MICROSECOND FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(HOUR_MICROSECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(HOUR_MICROSECOND FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(HOUR_MICROSECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(HOUR_MICROSECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(MINUTE_MICROSECOND FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(MINUTE_MICROSECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(MINUTE_MICROSECOND FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(MINUTE_MICROSECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(MINUTE_MICROSECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(SECOND_MICROSECOND FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(SECOND_MICROSECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(SECOND_MICROSECOND FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(SECOND_MICROSECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(SECOND_MICROSECOND FROM a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME, b DATE) +PARTITION BY HASH (DATEDIFF(a, b)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATE, b DATETIME) +PARTITION BY HASH (DATEDIFF(a, b)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME, b DATE) +PARTITION BY HASH (DATEDIFF(a, b)); +DROP TABLE t1; +CREATE TABLE t1 (a DATE, b VARCHAR(10)) +PARTITION BY HASH (DATEDIFF(a, b)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT, b DATETIME) +PARTITION BY HASH (DATEDIFF(a, b)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (TIME_TO_SEC(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (TIME_TO_SEC(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (TIME_TO_SEC(a)); +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (TIME_TO_SEC(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +CREATE TABLE t1 (a INT) +PARTITION BY HASH (TIME_TO_SEC(a)); +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +# # Bug#49161: Out of memory; restart server and try again (needed 2 bytes) # CREATE TABLE t1 (a INT) PARTITION BY HASH (a); diff --git a/mysql-test/suite/parts/inc/part_supported_sql_funcs_main.inc b/mysql-test/suite/parts/inc/part_supported_sql_funcs_main.inc index 45d77225a23..b7a170dd9d8 100644 --- a/mysql-test/suite/parts/inc/part_supported_sql_funcs_main.inc +++ b/mysql-test/suite/parts/inc/part_supported_sql_funcs_main.inc @@ -88,8 +88,9 @@ let $val2 = '2006-01-17'; let $val3 = '2006-02-25'; let $val4 = '2006-02-05'; --source suite/parts/inc/partition_supported_sql_funcs.inc -let $coltype = char(30); ---source suite/parts/inc/partition_supported_sql_funcs.inc +# Disabled after fixing bug#54483. +#let $coltype = char(30); +#--source suite/parts/inc/partition_supported_sql_funcs.inc let $sqlfunc = extract(month from col1); let $valsqlfunc = extract(year from '1998-11-23'); @@ -139,8 +140,9 @@ let $val2 = '14:30:20'; let $val3 = '21:59:22'; let $val4 = '10:22:33'; --source suite/parts/inc/partition_supported_sql_funcs.inc -let $coltype = char(30); ---source suite/parts/inc/partition_supported_sql_funcs.inc +# second(non_time_col) is disabled after bug#54483. +#let $coltype = char(30); +#--source suite/parts/inc/partition_supported_sql_funcs.inc let $sqlfunc = month(col1); let $valsqlfunc = month('2006-10-14'); @@ -172,26 +174,28 @@ let $val3 = '21:59:22'; let $val4 = '10:33:11'; --source suite/parts/inc/partition_supported_sql_funcs.inc -let $sqlfunc = to_days(col1)-to_days('2006-01-01'); -let $valsqlfunc = to_days('2006-02-02')-to_days('2006-01-01'); -let $coltype = date; -let $infile = part_supported_sql_funcs_int_date.inc; -let $val1 = '2006-02-03'; -let $val2 = '2006-01-17'; -let $val3 = '2006-01-25'; -let $val4 = '2006-02-06'; ---source suite/parts/inc/partition_supported_sql_funcs.inc +# to_days(non_date_col) is disabled after bug#54483. +#let $sqlfunc = to_days(col1)-to_days('2006-01-01'); +#let $valsqlfunc = to_days('2006-02-02')-to_days('2006-01-01'); +#let $coltype = date; +#let $infile = part_supported_sql_funcs_int_date.inc; +#let $val1 = '2006-02-03'; +#let $val2 = '2006-01-17'; +#let $val3 = '2006-01-25'; +#let $val4 = '2006-02-06'; +#--source suite/parts/inc/partition_supported_sql_funcs.inc +# to_days(non_date_col) is disabled after bug#54483. # DATEDIFF() is implemented as (TO_DAYS(d1) - TO_DAYS(d2)) -let $sqlfunc = datediff(col1, '2006-01-01'); -let $valsqlfunc = datediff('2006-02-02', '2006-01-01'); -let $coltype = date; -let $infile = part_supported_sql_funcs_int_date.inc; -let $val1 = '2006-02-03'; -let $val2 = '2006-01-17'; -let $val3 = '2006-01-25'; -let $val4 = '2006-02-06'; ---source suite/parts/inc/partition_supported_sql_funcs.inc +#let $sqlfunc = datediff(col1, '2006-01-01'); +#let $valsqlfunc = datediff('2006-02-02', '2006-01-01'); +#let $coltype = date; +#let $infile = part_supported_sql_funcs_int_date.inc; +#let $val1 = '2006-02-03'; +#let $val2 = '2006-01-17'; +#let $val3 = '2006-01-25'; +#let $val4 = '2006-02-06'; +#--source suite/parts/inc/partition_supported_sql_funcs.inc let $sqlfunc = weekday(col1); let $valsqlfunc = weekday('2006-10-14'); diff --git a/mysql-test/suite/parts/r/part_supported_sql_func_innodb.result b/mysql-test/suite/parts/r/part_supported_sql_func_innodb.result index 79462c25050..c5b4e0a8665 100644 --- a/mysql-test/suite/parts/r/part_supported_sql_func_innodb.result +++ b/mysql-test/suite/parts/r/part_supported_sql_func_innodb.result @@ -5425,7 +5425,7 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- dayofyear(col1) in partition with coltype char(30) +--- extract(month from col1) in partition with coltype date ------------------------------------------------------------------------- drop table if exists t1 ; drop table if exists t2 ; @@ -5434,14 +5434,14 @@ drop table if exists t4 ; drop table if exists t5 ; drop table if exists t6 ; ------------------------------------------------------------------------- ---- Create tables with dayofyear(col1) +--- Create tables with extract(month from col1) ------------------------------------------------------------------------- -create table t1 (col1 char(30)) engine='INNODB' -partition by range(dayofyear(col1)) +create table t1 (col1 date) engine='INNODB' +partition by range(extract(month from col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t2 (col1 char(30)) engine='INNODB' -partition by list(dayofyear(col1)) +create table t2 (col1 date) engine='INNODB' +partition by list(extract(month from col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -5449,16 +5449,16 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t3 (col1 char(30)) engine='INNODB' -partition by hash(dayofyear(col1)); -create table t4 (colint int, col1 char(30)) engine='INNODB' +create table t3 (col1 date) engine='INNODB' +partition by hash(extract(month from col1)); +create table t4 (colint int, col1 date) engine='INNODB' partition by range(colint) -subpartition by hash(dayofyear(col1)) subpartitions 2 +subpartition by hash(extract(month from col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t5 (colint int, col1 char(30)) engine='INNODB' +create table t5 (colint int, col1 date) engine='INNODB' partition by list(colint) -subpartition by hash(dayofyear(col1)) subpartitions 2 +subpartition by hash(extract(month from col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -5466,42 +5466,42 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t6 (colint int, col1 char(30)) engine='INNODB' +create table t6 (colint int, col1 date) engine='INNODB' partition by range(colint) -(partition p0 values less than (dayofyear('2006-12-25')), +(partition p0 values less than (extract(year from '1998-11-23')), partition p1 values less than maxvalue); ------------------------------------------------------------------------- ---- Access tables with dayofyear(col1) +--- Access tables with extract(month from col1) ------------------------------------------------------------------------- insert into t1 values ('2006-01-03'); -insert into t1 values ('2006-01-17'); +insert into t1 values ('2006-02-17'); insert into t2 values ('2006-01-03'); -insert into t2 values ('2006-01-17'); -insert into t2 values ('2006-02-25'); +insert into t2 values ('2006-02-17'); +insert into t2 values ('2006-01-25'); insert into t3 values ('2006-01-03'); -insert into t3 values ('2006-01-17'); -insert into t3 values ('2006-02-25'); +insert into t3 values ('2006-02-17'); +insert into t3 values ('2006-01-25'); load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; -select dayofyear(col1) from t1 order by col1; -dayofyear(col1) -3 -17 +select extract(month from col1) from t1 order by col1; +extract(month from col1) +1 +2 select * from t1 order by col1; col1 2006-01-03 -2006-01-17 +2006-02-17 select * from t2 order by col1; col1 2006-01-03 -2006-01-17 -2006-02-25 +2006-01-25 +2006-02-17 select * from t3 order by col1; col1 2006-01-03 -2006-01-17 -2006-02-25 +2006-01-25 +2006-02-17 select * from t4 order by colint; colint col1 1 2006-02-03 @@ -5528,18 +5528,18 @@ update t5 set col1='2006-02-05' where col1='2006-01-03'; update t6 set col1='2006-02-05' where col1='2006-01-03'; select * from t1 order by col1; col1 -2006-01-17 2006-02-05 +2006-02-17 select * from t2 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t3 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t4 order by colint; colint col1 1 2006-02-03 @@ -5559,7 +5559,7 @@ colint col1 3 2006-01-25 4 2006-02-05 ------------------------------------------------------------------------- ---- Alter tables with dayofyear(col1) +--- Alter tables with extract(month from col1) ------------------------------------------------------------------------- drop table if exists t11 ; drop table if exists t22 ; @@ -5574,11 +5574,11 @@ create table t44 engine='INNODB' as select * from t4; create table t55 engine='INNODB' as select * from t5; create table t66 engine='INNODB' as select * from t6; alter table t11 -partition by range(dayofyear(col1)) +partition by range(extract(month from col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t22 -partition by list(dayofyear(col1)) +partition by list(extract(month from col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -5587,15 +5587,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t33 -partition by hash(dayofyear(col1)); +partition by hash(extract(month from col1)); alter table t44 partition by range(colint) -subpartition by hash(dayofyear(col1)) subpartitions 2 +subpartition by hash(extract(month from col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t55 partition by list(colint) -subpartition by hash(dayofyear(col1)) subpartitions 2 +subpartition by hash(extract(month from col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -5605,22 +5605,22 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t66 partition by range(colint) -(partition p0 values less than (dayofyear('2006-12-25')), +(partition p0 values less than (extract(year from '1998-11-23')), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -2006-01-17 2006-02-05 +2006-02-17 select * from t22 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t33 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t44 order by colint; colint col1 1 2006-02-03 @@ -5647,19 +5647,19 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t11 order by col1; col1 -2006-01-17 2006-02-05 +2006-02-17 alter table t11 reorganize partition s1 into (partition p0 values less than (15), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -2006-01-17 2006-02-05 +2006-02-17 alter table t55 partition by list(colint) -subpartition by hash(dayofyear(col1)) subpartitions 5 +subpartition by hash(extract(month from col1)) subpartitions 5 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -5671,10 +5671,10 @@ show create table t55; Table Create Table t55 CREATE TABLE `t55` ( `colint` int(11) DEFAULT NULL, - `col1` char(30) DEFAULT NULL + `col1` date DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (dayofyear(col1)) +SUBPARTITION BY HASH (extract(month from col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB, @@ -5699,7 +5699,7 @@ colint col1 4 2006-02-05 alter table t66 reorganize partition s1 into -(partition p0 values less than (dayofyear('2006-12-25')), +(partition p0 values less than (extract(year from '1998-11-23')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 @@ -5718,7 +5718,7 @@ colint col1 4 2006-02-05 alter table t66 reorganize partition s1 into -(partition p0 values less than (dayofyear('2006-12-25')), +(partition p0 values less than (extract(year from '1998-11-23')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 @@ -5727,73 +5727,78 @@ colint col1 3 2006-01-25 4 2006-02-05 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with dayofyear(col1) +--- Delete rows and partitions of tables with extract(month from col1) ------------------------------------------------------------------------- -delete from t1 where col1='2006-01-17'; -delete from t2 where col1='2006-01-17'; -delete from t3 where col1='2006-01-17'; -delete from t4 where col1='2006-01-17'; -delete from t5 where col1='2006-01-17'; -delete from t6 where col1='2006-01-17'; +delete from t1 where col1='2006-02-17'; +delete from t2 where col1='2006-02-17'; +delete from t3 where col1='2006-02-17'; +delete from t4 where col1='2006-02-17'; +delete from t5 where col1='2006-02-17'; +delete from t6 where col1='2006-02-17'; select * from t1 order by col1; col1 2006-02-05 select * from t2 order by col1; col1 +2006-01-25 2006-02-05 -2006-02-25 select * from t3 order by col1; col1 +2006-01-25 2006-02-05 -2006-02-25 select * from t4 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 select * from t5 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 -insert into t1 values ('2006-01-17'); -insert into t2 values ('2006-01-17'); -insert into t3 values ('2006-01-17'); -insert into t4 values (60,'2006-01-17'); -insert into t5 values (60,'2006-01-17'); -insert into t6 values (60,'2006-01-17'); +insert into t1 values ('2006-02-17'); +insert into t2 values ('2006-02-17'); +insert into t3 values ('2006-02-17'); +insert into t4 values (60,'2006-02-17'); +insert into t5 values (60,'2006-02-17'); +insert into t6 values (60,'2006-02-17'); select * from t1 order by col1; col1 -2006-01-17 2006-02-05 +2006-02-17 select * from t2 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t3 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t4 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 -60 2006-01-17 +60 2006-02-17 select * from t5 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 -60 2006-01-17 +60 2006-02-17 select * from t6 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 -60 2006-01-17 +60 2006-02-17 alter table t1 drop partition p0; alter table t2 drop partition p0; alter table t4 drop partition p0; @@ -5801,94 +5806,94 @@ alter table t5 drop partition p0; alter table t6 drop partition p0; select * from t1 order by col1; col1 -2006-01-17 -2006-02-05 select * from t2 order by col1; col1 -2006-01-17 -2006-02-05 -2006-02-25 select * from t3 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t4 order by colint; colint col1 -60 2006-01-17 +60 2006-02-17 select * from t5 order by colint; colint col1 -60 2006-01-17 +60 2006-02-17 select * from t6 order by colint; colint col1 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with dayofyear(col1) +--- Delete rows and partitions of tables with extract(month from col1) ------------------------------------------------------------------------- -delete from t11 where col1='2006-01-17'; -delete from t22 where col1='2006-01-17'; -delete from t33 where col1='2006-01-17'; -delete from t44 where col1='2006-01-17'; -delete from t55 where col1='2006-01-17'; -delete from t66 where col1='2006-01-17'; +delete from t11 where col1='2006-02-17'; +delete from t22 where col1='2006-02-17'; +delete from t33 where col1='2006-02-17'; +delete from t44 where col1='2006-02-17'; +delete from t55 where col1='2006-02-17'; +delete from t66 where col1='2006-02-17'; select * from t11 order by col1; col1 2006-02-05 select * from t22 order by col1; col1 +2006-01-25 2006-02-05 -2006-02-25 select * from t33 order by col1; col1 +2006-01-25 2006-02-05 -2006-02-25 select * from t44 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 select * from t55 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 -insert into t11 values ('2006-01-17'); -insert into t22 values ('2006-01-17'); -insert into t33 values ('2006-01-17'); -insert into t44 values (60,'2006-01-17'); -insert into t55 values (60,'2006-01-17'); -insert into t66 values (60,'2006-01-17'); +insert into t11 values ('2006-02-17'); +insert into t22 values ('2006-02-17'); +insert into t33 values ('2006-02-17'); +insert into t44 values (60,'2006-02-17'); +insert into t55 values (60,'2006-02-17'); +insert into t66 values (60,'2006-02-17'); select * from t11 order by col1; col1 -2006-01-17 2006-02-05 +2006-02-17 select * from t22 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t33 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t44 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 -60 2006-01-17 +60 2006-02-17 select * from t55 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 -60 2006-01-17 +60 2006-02-17 select * from t66 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 -60 2006-01-17 +60 2006-02-17 alter table t11 drop partition p0; alter table t22 drop partition p0; alter table t44 drop partition p0; @@ -5896,24 +5901,19 @@ alter table t55 drop partition p0; alter table t66 drop partition p0; select * from t11 order by col1; col1 -2006-01-17 -2006-02-05 select * from t22 order by col1; col1 -2006-01-17 -2006-02-05 -2006-02-25 select * from t33 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t44 order by colint; colint col1 -60 2006-01-17 +60 2006-02-17 select * from t55 order by colint; colint col1 -60 2006-01-17 +60 2006-02-17 select * from t66 order by colint; colint col1 ------------------------- @@ -5932,7 +5932,7 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- extract(month from col1) in partition with coltype date +--- hour(col1) in partition with coltype time ------------------------------------------------------------------------- drop table if exists t1 ; drop table if exists t2 ; @@ -5941,14 +5941,14 @@ drop table if exists t4 ; drop table if exists t5 ; drop table if exists t6 ; ------------------------------------------------------------------------- ---- Create tables with extract(month from col1) +--- Create tables with hour(col1) ------------------------------------------------------------------------- -create table t1 (col1 date) engine='INNODB' -partition by range(extract(month from col1)) +create table t1 (col1 time) engine='INNODB' +partition by range(hour(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t2 (col1 date) engine='INNODB' -partition by list(extract(month from col1)) +create table t2 (col1 time) engine='INNODB' +partition by list(hour(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -5956,16 +5956,16 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t3 (col1 date) engine='INNODB' -partition by hash(extract(month from col1)); -create table t4 (colint int, col1 date) engine='INNODB' +create table t3 (col1 time) engine='INNODB' +partition by hash(hour(col1)); +create table t4 (colint int, col1 time) engine='INNODB' partition by range(colint) -subpartition by hash(extract(month from col1)) subpartitions 2 +subpartition by hash(hour(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t5 (colint int, col1 date) engine='INNODB' +create table t5 (colint int, col1 time) engine='INNODB' partition by list(colint) -subpartition by hash(extract(month from col1)) subpartitions 2 +subpartition by hash(hour(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -5973,100 +5973,100 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t6 (colint int, col1 date) engine='INNODB' +create table t6 (colint int, col1 time) engine='INNODB' partition by range(colint) -(partition p0 values less than (extract(year from '1998-11-23')), +(partition p0 values less than (hour('18:30')), partition p1 values less than maxvalue); ------------------------------------------------------------------------- ---- Access tables with extract(month from col1) +--- Access tables with hour(col1) ------------------------------------------------------------------------- -insert into t1 values ('2006-01-03'); -insert into t1 values ('2006-02-17'); -insert into t2 values ('2006-01-03'); -insert into t2 values ('2006-02-17'); -insert into t2 values ('2006-01-25'); -insert into t3 values ('2006-01-03'); -insert into t3 values ('2006-02-17'); -insert into t3 values ('2006-01-25'); -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; -select extract(month from col1) from t1 order by col1; -extract(month from col1) -1 -2 +insert into t1 values ('09:09'); +insert into t1 values ('14:30'); +insert into t2 values ('09:09'); +insert into t2 values ('14:30'); +insert into t2 values ('21:59'); +insert into t3 values ('09:09'); +insert into t3 values ('14:30'); +insert into t3 values ('21:59'); +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; +select hour(col1) from t1 order by col1; +hour(col1) +9 +14 select * from t1 order by col1; col1 -2006-01-03 -2006-02-17 +09:09:00 +14:30:00 select * from t2 order by col1; col1 -2006-01-03 -2006-01-25 -2006-02-17 +09:09:00 +14:30:00 +21:59:00 select * from t3 order by col1; col1 -2006-01-03 -2006-01-25 -2006-02-17 +09:09:00 +14:30:00 +21:59:00 select * from t4 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t5 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t6 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -update t1 set col1='2006-02-05' where col1='2006-01-03'; -update t2 set col1='2006-02-05' where col1='2006-01-03'; -update t3 set col1='2006-02-05' where col1='2006-01-03'; -update t4 set col1='2006-02-05' where col1='2006-01-03'; -update t5 set col1='2006-02-05' where col1='2006-01-03'; -update t6 set col1='2006-02-05' where col1='2006-01-03'; +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +update t1 set col1='10:30' where col1='09:09'; +update t2 set col1='10:30' where col1='09:09'; +update t3 set col1='10:30' where col1='09:09'; +update t4 set col1='10:30' where col1='09:09'; +update t5 set col1='10:30' where col1='09:09'; +update t6 set col1='10:30' where col1='09:09'; select * from t1 order by col1; col1 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 select * from t2 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t3 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t4 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t5 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t6 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 ------------------------------------------------------------------------- ---- Alter tables with extract(month from col1) +--- Alter tables with hour(col1) ------------------------------------------------------------------------- drop table if exists t11 ; drop table if exists t22 ; @@ -6081,11 +6081,11 @@ create table t44 engine='INNODB' as select * from t4; create table t55 engine='INNODB' as select * from t5; create table t66 engine='INNODB' as select * from t6; alter table t11 -partition by range(extract(month from col1)) +partition by range(hour(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t22 -partition by list(extract(month from col1)) +partition by list(hour(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6094,15 +6094,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t33 -partition by hash(extract(month from col1)); +partition by hash(hour(col1)); alter table t44 partition by range(colint) -subpartition by hash(extract(month from col1)) subpartitions 2 +subpartition by hash(hour(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t55 partition by list(colint) -subpartition by hash(extract(month from col1)) subpartitions 2 +subpartition by hash(hour(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6112,40 +6112,40 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t66 partition by range(colint) -(partition p0 values less than (extract(year from '1998-11-23')), +(partition p0 values less than (hour('18:30')), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 select * from t22 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t33 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t44 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t55 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 --------------------------- ---- some alter table begin --------------------------- @@ -6154,19 +6154,19 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t11 order by col1; col1 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 alter table t11 reorganize partition s1 into (partition p0 values less than (15), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 alter table t55 partition by list(colint) -subpartition by hash(extract(month from col1)) subpartitions 5 +subpartition by hash(hour(col1)) subpartitions 5 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6178,10 +6178,10 @@ show create table t55; Table Create Table t55 CREATE TABLE `t55` ( `colint` int(11) DEFAULT NULL, - `col1` date DEFAULT NULL + `col1` time DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (extract(month from col1)) +SUBPARTITION BY HASH (hour(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB, @@ -6191,121 +6191,121 @@ SUBPARTITIONS 5 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */ select * from t55 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (extract(year from '1998-11-23')), +(partition p0 values less than (hour('18:30')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (extract(year from '1998-11-23')), +(partition p0 values less than (hour('18:30')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with extract(month from col1) +--- Delete rows and partitions of tables with hour(col1) ------------------------------------------------------------------------- -delete from t1 where col1='2006-02-17'; -delete from t2 where col1='2006-02-17'; -delete from t3 where col1='2006-02-17'; -delete from t4 where col1='2006-02-17'; -delete from t5 where col1='2006-02-17'; -delete from t6 where col1='2006-02-17'; +delete from t1 where col1='14:30'; +delete from t2 where col1='14:30'; +delete from t3 where col1='14:30'; +delete from t4 where col1='14:30'; +delete from t5 where col1='14:30'; +delete from t6 where col1='14:30'; select * from t1 order by col1; col1 -2006-02-05 +10:30:00 select * from t2 order by col1; col1 -2006-01-25 -2006-02-05 +10:30:00 +21:59:00 select * from t3 order by col1; col1 -2006-01-25 -2006-02-05 +10:30:00 +21:59:00 select * from t4 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t5 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -insert into t1 values ('2006-02-17'); -insert into t2 values ('2006-02-17'); -insert into t3 values ('2006-02-17'); -insert into t4 values (60,'2006-02-17'); -insert into t5 values (60,'2006-02-17'); -insert into t6 values (60,'2006-02-17'); +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +insert into t1 values ('14:30'); +insert into t2 values ('14:30'); +insert into t3 values ('14:30'); +insert into t4 values (60,'14:30'); +insert into t5 values (60,'14:30'); +insert into t6 values (60,'14:30'); select * from t1 order by col1; col1 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 select * from t2 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t3 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t4 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-02-17 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:00 select * from t5 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-02-17 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:00 select * from t6 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-02-17 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:00 alter table t1 drop partition p0; alter table t2 drop partition p0; alter table t4 drop partition p0; @@ -6315,92 +6315,95 @@ select * from t1 order by col1; col1 select * from t2 order by col1; col1 +14:30:00 +21:59:00 select * from t3 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t4 order by colint; colint col1 -60 2006-02-17 +60 14:30:00 select * from t5 order by colint; colint col1 -60 2006-02-17 +60 14:30:00 select * from t6 order by colint; colint col1 +60 14:30:00 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with extract(month from col1) +--- Delete rows and partitions of tables with hour(col1) ------------------------------------------------------------------------- -delete from t11 where col1='2006-02-17'; -delete from t22 where col1='2006-02-17'; -delete from t33 where col1='2006-02-17'; -delete from t44 where col1='2006-02-17'; -delete from t55 where col1='2006-02-17'; -delete from t66 where col1='2006-02-17'; +delete from t11 where col1='14:30'; +delete from t22 where col1='14:30'; +delete from t33 where col1='14:30'; +delete from t44 where col1='14:30'; +delete from t55 where col1='14:30'; +delete from t66 where col1='14:30'; select * from t11 order by col1; col1 -2006-02-05 +10:30:00 select * from t22 order by col1; col1 -2006-01-25 -2006-02-05 +10:30:00 +21:59:00 select * from t33 order by col1; col1 -2006-01-25 -2006-02-05 +10:30:00 +21:59:00 select * from t44 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t55 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -insert into t11 values ('2006-02-17'); -insert into t22 values ('2006-02-17'); -insert into t33 values ('2006-02-17'); -insert into t44 values (60,'2006-02-17'); -insert into t55 values (60,'2006-02-17'); -insert into t66 values (60,'2006-02-17'); +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +insert into t11 values ('14:30'); +insert into t22 values ('14:30'); +insert into t33 values ('14:30'); +insert into t44 values (60,'14:30'); +insert into t55 values (60,'14:30'); +insert into t66 values (60,'14:30'); select * from t11 order by col1; col1 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 select * from t22 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t33 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t44 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-02-17 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:00 select * from t55 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-02-17 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:00 select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-02-17 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:00 alter table t11 drop partition p0; alter table t22 drop partition p0; alter table t44 drop partition p0; @@ -6410,19 +6413,22 @@ select * from t11 order by col1; col1 select * from t22 order by col1; col1 +14:30:00 +21:59:00 select * from t33 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t44 order by colint; colint col1 -60 2006-02-17 +60 14:30:00 select * from t55 order by colint; colint col1 -60 2006-02-17 +60 14:30:00 select * from t66 order by colint; colint col1 +60 14:30:00 ------------------------- ---- some alter table end ------------------------- @@ -6439,7 +6445,7 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- hour(col1) in partition with coltype time +--- microsecond(col1) in partition with coltype time ------------------------------------------------------------------------- drop table if exists t1 ; drop table if exists t2 ; @@ -6448,14 +6454,14 @@ drop table if exists t4 ; drop table if exists t5 ; drop table if exists t6 ; ------------------------------------------------------------------------- ---- Create tables with hour(col1) +--- Create tables with microsecond(col1) ------------------------------------------------------------------------- create table t1 (col1 time) engine='INNODB' -partition by range(hour(col1)) +partition by range(microsecond(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); create table t2 (col1 time) engine='INNODB' -partition by list(hour(col1)) +partition by list(microsecond(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6464,15 +6470,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); create table t3 (col1 time) engine='INNODB' -partition by hash(hour(col1)); +partition by hash(microsecond(col1)); create table t4 (colint int, col1 time) engine='INNODB' partition by range(colint) -subpartition by hash(hour(col1)) subpartitions 2 +subpartition by hash(microsecond(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); create table t5 (colint int, col1 time) engine='INNODB' partition by list(colint) -subpartition by hash(hour(col1)) subpartitions 2 +subpartition by hash(microsecond(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6482,41 +6488,41 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); create table t6 (colint int, col1 time) engine='INNODB' partition by range(colint) -(partition p0 values less than (hour('18:30')), +(partition p0 values less than (microsecond('10:30:10.000010')), partition p1 values less than maxvalue); ------------------------------------------------------------------------- ---- Access tables with hour(col1) +--- Access tables with microsecond(col1) ------------------------------------------------------------------------- -insert into t1 values ('09:09'); -insert into t1 values ('14:30'); -insert into t2 values ('09:09'); -insert into t2 values ('14:30'); -insert into t2 values ('21:59'); -insert into t3 values ('09:09'); -insert into t3 values ('14:30'); -insert into t3 values ('21:59'); +insert into t1 values ('09:09:15.000002'); +insert into t1 values ('04:30:01.000018'); +insert into t2 values ('09:09:15.000002'); +insert into t2 values ('04:30:01.000018'); +insert into t2 values ('00:59:22.000024'); +insert into t3 values ('09:09:15.000002'); +insert into t3 values ('04:30:01.000018'); +insert into t3 values ('00:59:22.000024'); load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; -select hour(col1) from t1 order by col1; -hour(col1) -9 -14 +select microsecond(col1) from t1 order by col1; +microsecond(col1) +0 +0 select * from t1 order by col1; col1 -09:09:00 -14:30:00 +04:30:01 +09:09:15 select * from t2 order by col1; col1 -09:09:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +09:09:15 select * from t3 order by col1; col1 -09:09:00 -14:30:00 -21:59:00 -select * from t4 order by colint; +00:59:22 +04:30:01 +09:09:15 +select * from t4 order by colint; colint col1 1 09:09:15 2 04:30:01 @@ -6534,46 +6540,46 @@ colint col1 2 04:30:01 3 00:59:22 4 05:30:34 -update t1 set col1='10:30' where col1='09:09'; -update t2 set col1='10:30' where col1='09:09'; -update t3 set col1='10:30' where col1='09:09'; -update t4 set col1='10:30' where col1='09:09'; -update t5 set col1='10:30' where col1='09:09'; -update t6 set col1='10:30' where col1='09:09'; +update t1 set col1='05:30:34.000037' where col1='09:09:15.000002'; +update t2 set col1='05:30:34.000037' where col1='09:09:15.000002'; +update t3 set col1='05:30:34.000037' where col1='09:09:15.000002'; +update t4 set col1='05:30:34.000037' where col1='09:09:15.000002'; +update t5 set col1='05:30:34.000037' where col1='09:09:15.000002'; +update t6 set col1='05:30:34.000037' where col1='09:09:15.000002'; select * from t1 order by col1; col1 -10:30:00 -14:30:00 +04:30:01 +05:30:34 select * from t2 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t3 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t4 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 select * from t5 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 select * from t6 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 ------------------------------------------------------------------------- ---- Alter tables with hour(col1) +--- Alter tables with microsecond(col1) ------------------------------------------------------------------------- drop table if exists t11 ; drop table if exists t22 ; @@ -6588,11 +6594,11 @@ create table t44 engine='INNODB' as select * from t4; create table t55 engine='INNODB' as select * from t5; create table t66 engine='INNODB' as select * from t6; alter table t11 -partition by range(hour(col1)) +partition by range(microsecond(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t22 -partition by list(hour(col1)) +partition by list(microsecond(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6601,15 +6607,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t33 -partition by hash(hour(col1)); +partition by hash(microsecond(col1)); alter table t44 partition by range(colint) -subpartition by hash(hour(col1)) subpartitions 2 +subpartition by hash(microsecond(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t55 partition by list(colint) -subpartition by hash(hour(col1)) subpartitions 2 +subpartition by hash(microsecond(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6619,37 +6625,37 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t66 partition by range(colint) -(partition p0 values less than (hour('18:30')), +(partition p0 values less than (microsecond('10:30:10.000010')), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -10:30:00 -14:30:00 +04:30:01 +05:30:34 select * from t22 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t33 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t44 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 select * from t55 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 select * from t66 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 @@ -6661,19 +6667,19 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t11 order by col1; col1 -10:30:00 -14:30:00 +04:30:01 +05:30:34 alter table t11 reorganize partition s1 into (partition p0 values less than (15), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -10:30:00 -14:30:00 +04:30:01 +05:30:34 alter table t55 partition by list(colint) -subpartition by hash(hour(col1)) subpartitions 5 +subpartition by hash(microsecond(col1)) subpartitions 5 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6688,7 +6694,7 @@ t55 CREATE TABLE `t55` ( `col1` time DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (hour(col1)) +SUBPARTITION BY HASH (microsecond(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB, @@ -6698,7 +6704,7 @@ SUBPARTITIONS 5 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */ select * from t55 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 @@ -6707,17 +6713,17 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (hour('18:30')), +(partition p0 values less than (microsecond('10:30:10.000010')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 @@ -6726,93 +6732,88 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (hour('18:30')), +(partition p0 values less than (microsecond('10:30:10.000010')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with hour(col1) +--- Delete rows and partitions of tables with microsecond(col1) ------------------------------------------------------------------------- -delete from t1 where col1='14:30'; -delete from t2 where col1='14:30'; -delete from t3 where col1='14:30'; -delete from t4 where col1='14:30'; -delete from t5 where col1='14:30'; -delete from t6 where col1='14:30'; +delete from t1 where col1='04:30:01.000018'; +delete from t2 where col1='04:30:01.000018'; +delete from t3 where col1='04:30:01.000018'; +delete from t4 where col1='04:30:01.000018'; +delete from t5 where col1='04:30:01.000018'; +delete from t6 where col1='04:30:01.000018'; select * from t1 order by col1; col1 -10:30:00 +05:30:34 select * from t2 order by col1; col1 -10:30:00 -21:59:00 +00:59:22 +05:30:34 select * from t3 order by col1; col1 -10:30:00 -21:59:00 +00:59:22 +05:30:34 select * from t4 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 select * from t5 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 -insert into t1 values ('14:30'); -insert into t2 values ('14:30'); -insert into t3 values ('14:30'); -insert into t4 values (60,'14:30'); -insert into t5 values (60,'14:30'); -insert into t6 values (60,'14:30'); +insert into t1 values ('04:30:01.000018'); +insert into t2 values ('04:30:01.000018'); +insert into t3 values ('04:30:01.000018'); +insert into t4 values (60,'04:30:01.000018'); +insert into t5 values (60,'04:30:01.000018'); +insert into t6 values (60,'04:30:01.000018'); select * from t1 order by col1; col1 -10:30:00 -14:30:00 +04:30:01 +05:30:34 select * from t2 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t3 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t4 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 -60 14:30:00 +60 04:30:01 select * from t5 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 -60 14:30:00 +60 04:30:01 select * from t6 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 -60 14:30:00 +60 04:30:01 alter table t1 drop partition p0; alter table t2 drop partition p0; alter table t4 drop partition p0; @@ -6822,95 +6823,88 @@ select * from t1 order by col1; col1 select * from t2 order by col1; col1 -14:30:00 -21:59:00 select * from t3 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t4 order by colint; colint col1 -60 14:30:00 +60 04:30:01 select * from t5 order by colint; colint col1 -60 14:30:00 +60 04:30:01 select * from t6 order by colint; colint col1 -60 14:30:00 +60 04:30:01 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with hour(col1) +--- Delete rows and partitions of tables with microsecond(col1) ------------------------------------------------------------------------- -delete from t11 where col1='14:30'; -delete from t22 where col1='14:30'; -delete from t33 where col1='14:30'; -delete from t44 where col1='14:30'; -delete from t55 where col1='14:30'; -delete from t66 where col1='14:30'; +delete from t11 where col1='04:30:01.000018'; +delete from t22 where col1='04:30:01.000018'; +delete from t33 where col1='04:30:01.000018'; +delete from t44 where col1='04:30:01.000018'; +delete from t55 where col1='04:30:01.000018'; +delete from t66 where col1='04:30:01.000018'; select * from t11 order by col1; col1 -10:30:00 +05:30:34 select * from t22 order by col1; col1 -10:30:00 -21:59:00 +00:59:22 +05:30:34 select * from t33 order by col1; col1 -10:30:00 -21:59:00 +00:59:22 +05:30:34 select * from t44 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 select * from t55 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 -insert into t11 values ('14:30'); -insert into t22 values ('14:30'); -insert into t33 values ('14:30'); -insert into t44 values (60,'14:30'); -insert into t55 values (60,'14:30'); -insert into t66 values (60,'14:30'); +insert into t11 values ('04:30:01.000018'); +insert into t22 values ('04:30:01.000018'); +insert into t33 values ('04:30:01.000018'); +insert into t44 values (60,'04:30:01.000018'); +insert into t55 values (60,'04:30:01.000018'); +insert into t66 values (60,'04:30:01.000018'); select * from t11 order by col1; col1 -10:30:00 -14:30:00 +04:30:01 +05:30:34 select * from t22 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t33 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t44 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 -60 14:30:00 +60 04:30:01 select * from t55 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 -60 14:30:00 +60 04:30:01 select * from t66 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 -60 14:30:00 +60 04:30:01 alter table t11 drop partition p0; alter table t22 drop partition p0; alter table t44 drop partition p0; @@ -6920,22 +6914,20 @@ select * from t11 order by col1; col1 select * from t22 order by col1; col1 -14:30:00 -21:59:00 select * from t33 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t44 order by colint; colint col1 -60 14:30:00 +60 04:30:01 select * from t55 order by colint; colint col1 -60 14:30:00 +60 04:30:01 select * from t66 order by colint; colint col1 -60 14:30:00 +60 04:30:01 ------------------------- ---- some alter table end ------------------------- @@ -6952,7 +6944,7 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- microsecond(col1) in partition with coltype time +--- minute(col1) in partition with coltype time ------------------------------------------------------------------------- drop table if exists t1 ; drop table if exists t2 ; @@ -6961,14 +6953,14 @@ drop table if exists t4 ; drop table if exists t5 ; drop table if exists t6 ; ------------------------------------------------------------------------- ---- Create tables with microsecond(col1) +--- Create tables with minute(col1) ------------------------------------------------------------------------- create table t1 (col1 time) engine='INNODB' -partition by range(microsecond(col1)) +partition by range(minute(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); create table t2 (col1 time) engine='INNODB' -partition by list(microsecond(col1)) +partition by list(minute(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6977,15 +6969,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); create table t3 (col1 time) engine='INNODB' -partition by hash(microsecond(col1)); +partition by hash(minute(col1)); create table t4 (colint int, col1 time) engine='INNODB' partition by range(colint) -subpartition by hash(microsecond(col1)) subpartitions 2 +subpartition by hash(minute(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); create table t5 (colint int, col1 time) engine='INNODB' partition by list(colint) -subpartition by hash(microsecond(col1)) subpartitions 2 +subpartition by hash(minute(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6995,40 +6987,40 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); create table t6 (colint int, col1 time) engine='INNODB' partition by range(colint) -(partition p0 values less than (microsecond('10:30:10.000010')), +(partition p0 values less than (minute('18:30')), partition p1 values less than maxvalue); ------------------------------------------------------------------------- ---- Access tables with microsecond(col1) +--- Access tables with minute(col1) ------------------------------------------------------------------------- -insert into t1 values ('09:09:15.000002'); -insert into t1 values ('04:30:01.000018'); -insert into t2 values ('09:09:15.000002'); -insert into t2 values ('04:30:01.000018'); -insert into t2 values ('00:59:22.000024'); -insert into t3 values ('09:09:15.000002'); -insert into t3 values ('04:30:01.000018'); -insert into t3 values ('00:59:22.000024'); +insert into t1 values ('09:09:15'); +insert into t1 values ('14:30:45'); +insert into t2 values ('09:09:15'); +insert into t2 values ('14:30:45'); +insert into t2 values ('21:59:22'); +insert into t3 values ('09:09:15'); +insert into t3 values ('14:30:45'); +insert into t3 values ('21:59:22'); load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; -select microsecond(col1) from t1 order by col1; -microsecond(col1) -0 -0 +select minute(col1) from t1 order by col1; +minute(col1) +9 +30 select * from t1 order by col1; col1 -04:30:01 09:09:15 +14:30:45 select * from t2 order by col1; col1 -00:59:22 -04:30:01 09:09:15 +14:30:45 +21:59:22 select * from t3 order by col1; col1 -00:59:22 -04:30:01 09:09:15 +14:30:45 +21:59:22 select * from t4 order by colint; colint col1 1 09:09:15 @@ -7047,46 +7039,46 @@ colint col1 2 04:30:01 3 00:59:22 4 05:30:34 -update t1 set col1='05:30:34.000037' where col1='09:09:15.000002'; -update t2 set col1='05:30:34.000037' where col1='09:09:15.000002'; -update t3 set col1='05:30:34.000037' where col1='09:09:15.000002'; -update t4 set col1='05:30:34.000037' where col1='09:09:15.000002'; -update t5 set col1='05:30:34.000037' where col1='09:09:15.000002'; -update t6 set col1='05:30:34.000037' where col1='09:09:15.000002'; +update t1 set col1='10:24:23' where col1='09:09:15'; +update t2 set col1='10:24:23' where col1='09:09:15'; +update t3 set col1='10:24:23' where col1='09:09:15'; +update t4 set col1='10:24:23' where col1='09:09:15'; +update t5 set col1='10:24:23' where col1='09:09:15'; +update t6 set col1='10:24:23' where col1='09:09:15'; select * from t1 order by col1; col1 -04:30:01 -05:30:34 +10:24:23 +14:30:45 select * from t2 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t3 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t4 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 select * from t5 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 select * from t6 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 ------------------------------------------------------------------------- ---- Alter tables with microsecond(col1) +--- Alter tables with minute(col1) ------------------------------------------------------------------------- drop table if exists t11 ; drop table if exists t22 ; @@ -7101,11 +7093,11 @@ create table t44 engine='INNODB' as select * from t4; create table t55 engine='INNODB' as select * from t5; create table t66 engine='INNODB' as select * from t6; alter table t11 -partition by range(microsecond(col1)) +partition by range(minute(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t22 -partition by list(microsecond(col1)) +partition by list(minute(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7114,15 +7106,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t33 -partition by hash(microsecond(col1)); +partition by hash(minute(col1)); alter table t44 partition by range(colint) -subpartition by hash(microsecond(col1)) subpartitions 2 +subpartition by hash(minute(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t55 partition by list(colint) -subpartition by hash(microsecond(col1)) subpartitions 2 +subpartition by hash(minute(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7132,37 +7124,37 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t66 partition by range(colint) -(partition p0 values less than (microsecond('10:30:10.000010')), +(partition p0 values less than (minute('18:30')), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -04:30:01 -05:30:34 +10:24:23 +14:30:45 select * from t22 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t33 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t44 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 select * from t55 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 select * from t66 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 @@ -7174,19 +7166,19 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t11 order by col1; col1 -04:30:01 -05:30:34 +10:24:23 +14:30:45 alter table t11 reorganize partition s1 into (partition p0 values less than (15), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -04:30:01 -05:30:34 +10:24:23 +14:30:45 alter table t55 partition by list(colint) -subpartition by hash(microsecond(col1)) subpartitions 5 +subpartition by hash(minute(col1)) subpartitions 5 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7201,7 +7193,7 @@ t55 CREATE TABLE `t55` ( `col1` time DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (microsecond(col1)) +SUBPARTITION BY HASH (minute(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB, @@ -7211,7 +7203,7 @@ SUBPARTITIONS 5 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */ select * from t55 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 @@ -7220,17 +7212,17 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (microsecond('10:30:10.000010')), +(partition p0 values less than (minute('18:30')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 @@ -7239,88 +7231,93 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (microsecond('10:30:10.000010')), +(partition p0 values less than (minute('18:30')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with microsecond(col1) +--- Delete rows and partitions of tables with minute(col1) ------------------------------------------------------------------------- -delete from t1 where col1='04:30:01.000018'; -delete from t2 where col1='04:30:01.000018'; -delete from t3 where col1='04:30:01.000018'; -delete from t4 where col1='04:30:01.000018'; -delete from t5 where col1='04:30:01.000018'; -delete from t6 where col1='04:30:01.000018'; +delete from t1 where col1='14:30:45'; +delete from t2 where col1='14:30:45'; +delete from t3 where col1='14:30:45'; +delete from t4 where col1='14:30:45'; +delete from t5 where col1='14:30:45'; +delete from t6 where col1='14:30:45'; select * from t1 order by col1; col1 -05:30:34 +10:24:23 select * from t2 order by col1; col1 -00:59:22 -05:30:34 +10:24:23 +21:59:22 select * from t3 order by col1; col1 -00:59:22 -05:30:34 +10:24:23 +21:59:22 select * from t4 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 select * from t5 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 -insert into t1 values ('04:30:01.000018'); -insert into t2 values ('04:30:01.000018'); -insert into t3 values ('04:30:01.000018'); -insert into t4 values (60,'04:30:01.000018'); -insert into t5 values (60,'04:30:01.000018'); -insert into t6 values (60,'04:30:01.000018'); +insert into t1 values ('14:30:45'); +insert into t2 values ('14:30:45'); +insert into t3 values ('14:30:45'); +insert into t4 values (60,'14:30:45'); +insert into t5 values (60,'14:30:45'); +insert into t6 values (60,'14:30:45'); select * from t1 order by col1; col1 -04:30:01 -05:30:34 +10:24:23 +14:30:45 select * from t2 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t3 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t4 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 -60 04:30:01 +60 14:30:45 select * from t5 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 -60 04:30:01 +60 14:30:45 select * from t6 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 -60 04:30:01 +60 14:30:45 alter table t1 drop partition p0; alter table t2 drop partition p0; alter table t4 drop partition p0; @@ -7328,90 +7325,100 @@ alter table t5 drop partition p0; alter table t6 drop partition p0; select * from t1 order by col1; col1 +10:24:23 +14:30:45 select * from t2 order by col1; col1 +10:24:23 +14:30:45 +21:59:22 select * from t3 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t4 order by colint; colint col1 -60 04:30:01 +60 14:30:45 select * from t5 order by colint; colint col1 -60 04:30:01 +60 14:30:45 select * from t6 order by colint; colint col1 -60 04:30:01 +60 14:30:45 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with microsecond(col1) +--- Delete rows and partitions of tables with minute(col1) ------------------------------------------------------------------------- -delete from t11 where col1='04:30:01.000018'; -delete from t22 where col1='04:30:01.000018'; -delete from t33 where col1='04:30:01.000018'; -delete from t44 where col1='04:30:01.000018'; -delete from t55 where col1='04:30:01.000018'; -delete from t66 where col1='04:30:01.000018'; +delete from t11 where col1='14:30:45'; +delete from t22 where col1='14:30:45'; +delete from t33 where col1='14:30:45'; +delete from t44 where col1='14:30:45'; +delete from t55 where col1='14:30:45'; +delete from t66 where col1='14:30:45'; select * from t11 order by col1; col1 -05:30:34 +10:24:23 select * from t22 order by col1; col1 -00:59:22 -05:30:34 +10:24:23 +21:59:22 select * from t33 order by col1; col1 -00:59:22 -05:30:34 +10:24:23 +21:59:22 select * from t44 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 select * from t55 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 -insert into t11 values ('04:30:01.000018'); -insert into t22 values ('04:30:01.000018'); -insert into t33 values ('04:30:01.000018'); -insert into t44 values (60,'04:30:01.000018'); -insert into t55 values (60,'04:30:01.000018'); -insert into t66 values (60,'04:30:01.000018'); +insert into t11 values ('14:30:45'); +insert into t22 values ('14:30:45'); +insert into t33 values ('14:30:45'); +insert into t44 values (60,'14:30:45'); +insert into t55 values (60,'14:30:45'); +insert into t66 values (60,'14:30:45'); select * from t11 order by col1; col1 -04:30:01 -05:30:34 +10:24:23 +14:30:45 select * from t22 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t33 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t44 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 -60 04:30:01 +60 14:30:45 select * from t55 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 -60 04:30:01 +60 14:30:45 select * from t66 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 -60 04:30:01 +60 14:30:45 alter table t11 drop partition p0; alter table t22 drop partition p0; alter table t44 drop partition p0; @@ -7419,22 +7426,27 @@ alter table t55 drop partition p0; alter table t66 drop partition p0; select * from t11 order by col1; col1 +10:24:23 +14:30:45 select * from t22 order by col1; col1 +10:24:23 +14:30:45 +21:59:22 select * from t33 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t44 order by colint; colint col1 -60 04:30:01 +60 14:30:45 select * from t55 order by colint; colint col1 -60 04:30:01 +60 14:30:45 select * from t66 order by colint; colint col1 -60 04:30:01 +60 14:30:45 ------------------------- ---- some alter table end ------------------------- @@ -7451,7 +7463,7 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- minute(col1) in partition with coltype time +--- second(col1) in partition with coltype time ------------------------------------------------------------------------- drop table if exists t1 ; drop table if exists t2 ; @@ -7460,14 +7472,14 @@ drop table if exists t4 ; drop table if exists t5 ; drop table if exists t6 ; ------------------------------------------------------------------------- ---- Create tables with minute(col1) +--- Create tables with second(col1) ------------------------------------------------------------------------- create table t1 (col1 time) engine='INNODB' -partition by range(minute(col1)) +partition by range(second(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); create table t2 (col1 time) engine='INNODB' -partition by list(minute(col1)) +partition by list(second(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7476,15 +7488,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); create table t3 (col1 time) engine='INNODB' -partition by hash(minute(col1)); +partition by hash(second(col1)); create table t4 (colint int, col1 time) engine='INNODB' partition by range(colint) -subpartition by hash(minute(col1)) subpartitions 2 +subpartition by hash(second(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); create table t5 (colint int, col1 time) engine='INNODB' partition by list(colint) -subpartition by hash(minute(col1)) subpartitions 2 +subpartition by hash(second(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7494,39 +7506,39 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); create table t6 (colint int, col1 time) engine='INNODB' partition by range(colint) -(partition p0 values less than (minute('18:30')), +(partition p0 values less than (second('18:30:14')), partition p1 values less than maxvalue); ------------------------------------------------------------------------- ---- Access tables with minute(col1) +--- Access tables with second(col1) ------------------------------------------------------------------------- -insert into t1 values ('09:09:15'); -insert into t1 values ('14:30:45'); -insert into t2 values ('09:09:15'); -insert into t2 values ('14:30:45'); +insert into t1 values ('09:09:09'); +insert into t1 values ('14:30:20'); +insert into t2 values ('09:09:09'); +insert into t2 values ('14:30:20'); insert into t2 values ('21:59:22'); -insert into t3 values ('09:09:15'); -insert into t3 values ('14:30:45'); +insert into t3 values ('09:09:09'); +insert into t3 values ('14:30:20'); insert into t3 values ('21:59:22'); load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; -select minute(col1) from t1 order by col1; -minute(col1) +select second(col1) from t1 order by col1; +second(col1) 9 -30 +20 select * from t1 order by col1; col1 -09:09:15 -14:30:45 +09:09:09 +14:30:20 select * from t2 order by col1; col1 -09:09:15 -14:30:45 +09:09:09 +14:30:20 21:59:22 select * from t3 order by col1; col1 -09:09:15 -14:30:45 +09:09:09 +14:30:20 21:59:22 select * from t4 order by colint; colint col1 @@ -7546,46 +7558,46 @@ colint col1 2 04:30:01 3 00:59:22 4 05:30:34 -update t1 set col1='10:24:23' where col1='09:09:15'; -update t2 set col1='10:24:23' where col1='09:09:15'; -update t3 set col1='10:24:23' where col1='09:09:15'; -update t4 set col1='10:24:23' where col1='09:09:15'; -update t5 set col1='10:24:23' where col1='09:09:15'; -update t6 set col1='10:24:23' where col1='09:09:15'; +update t1 set col1='10:22:33' where col1='09:09:09'; +update t2 set col1='10:22:33' where col1='09:09:09'; +update t3 set col1='10:22:33' where col1='09:09:09'; +update t4 set col1='10:22:33' where col1='09:09:09'; +update t5 set col1='10:22:33' where col1='09:09:09'; +update t6 set col1='10:22:33' where col1='09:09:09'; select * from t1 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 select * from t2 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t3 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t4 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 select * from t5 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 select * from t6 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 ------------------------------------------------------------------------- ---- Alter tables with minute(col1) +--- Alter tables with second(col1) ------------------------------------------------------------------------- drop table if exists t11 ; drop table if exists t22 ; @@ -7600,11 +7612,11 @@ create table t44 engine='INNODB' as select * from t4; create table t55 engine='INNODB' as select * from t5; create table t66 engine='INNODB' as select * from t6; alter table t11 -partition by range(minute(col1)) +partition by range(second(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t22 -partition by list(minute(col1)) +partition by list(second(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7613,15 +7625,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t33 -partition by hash(minute(col1)); +partition by hash(second(col1)); alter table t44 partition by range(colint) -subpartition by hash(minute(col1)) subpartitions 2 +subpartition by hash(second(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t55 partition by list(colint) -subpartition by hash(minute(col1)) subpartitions 2 +subpartition by hash(second(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7631,37 +7643,37 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t66 partition by range(colint) -(partition p0 values less than (minute('18:30')), +(partition p0 values less than (second('18:30:14')), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 select * from t22 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t33 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t44 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 select * from t55 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 select * from t66 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 @@ -7673,19 +7685,19 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t11 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 alter table t11 reorganize partition s1 into (partition p0 values less than (15), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 alter table t55 partition by list(colint) -subpartition by hash(minute(col1)) subpartitions 5 +subpartition by hash(second(col1)) subpartitions 5 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7700,7 +7712,7 @@ t55 CREATE TABLE `t55` ( `col1` time DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (minute(col1)) +SUBPARTITION BY HASH (second(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB, @@ -7710,7 +7722,7 @@ SUBPARTITIONS 5 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */ select * from t55 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 @@ -7719,17 +7731,17 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (minute('18:30')), +(partition p0 values less than (second('18:30:14')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 @@ -7738,93 +7750,93 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (minute('18:30')), +(partition p0 values less than (second('18:30:14')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with minute(col1) +--- Delete rows and partitions of tables with second(col1) ------------------------------------------------------------------------- -delete from t1 where col1='14:30:45'; -delete from t2 where col1='14:30:45'; -delete from t3 where col1='14:30:45'; -delete from t4 where col1='14:30:45'; -delete from t5 where col1='14:30:45'; -delete from t6 where col1='14:30:45'; +delete from t1 where col1='14:30:20'; +delete from t2 where col1='14:30:20'; +delete from t3 where col1='14:30:20'; +delete from t4 where col1='14:30:20'; +delete from t5 where col1='14:30:20'; +delete from t6 where col1='14:30:20'; select * from t1 order by col1; col1 -10:24:23 +10:22:33 select * from t2 order by col1; col1 -10:24:23 +10:22:33 21:59:22 select * from t3 order by col1; col1 -10:24:23 +10:22:33 21:59:22 select * from t4 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 select * from t5 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 -insert into t1 values ('14:30:45'); -insert into t2 values ('14:30:45'); -insert into t3 values ('14:30:45'); -insert into t4 values (60,'14:30:45'); -insert into t5 values (60,'14:30:45'); -insert into t6 values (60,'14:30:45'); +insert into t1 values ('14:30:20'); +insert into t2 values ('14:30:20'); +insert into t3 values ('14:30:20'); +insert into t4 values (60,'14:30:20'); +insert into t5 values (60,'14:30:20'); +insert into t6 values (60,'14:30:20'); select * from t1 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 select * from t2 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t3 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t4 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 -60 14:30:45 +60 14:30:20 select * from t5 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 -60 14:30:45 +60 14:30:20 select * from t6 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 -60 14:30:45 +60 14:30:20 alter table t1 drop partition p0; alter table t2 drop partition p0; alter table t4 drop partition p0; @@ -7832,100 +7844,100 @@ alter table t5 drop partition p0; alter table t6 drop partition p0; select * from t1 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 select * from t2 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t3 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t4 order by colint; colint col1 -60 14:30:45 +60 14:30:20 select * from t5 order by colint; colint col1 -60 14:30:45 +60 14:30:20 select * from t6 order by colint; colint col1 -60 14:30:45 +60 14:30:20 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with minute(col1) +--- Delete rows and partitions of tables with second(col1) ------------------------------------------------------------------------- -delete from t11 where col1='14:30:45'; -delete from t22 where col1='14:30:45'; -delete from t33 where col1='14:30:45'; -delete from t44 where col1='14:30:45'; -delete from t55 where col1='14:30:45'; -delete from t66 where col1='14:30:45'; +delete from t11 where col1='14:30:20'; +delete from t22 where col1='14:30:20'; +delete from t33 where col1='14:30:20'; +delete from t44 where col1='14:30:20'; +delete from t55 where col1='14:30:20'; +delete from t66 where col1='14:30:20'; select * from t11 order by col1; col1 -10:24:23 +10:22:33 select * from t22 order by col1; col1 -10:24:23 +10:22:33 21:59:22 select * from t33 order by col1; col1 -10:24:23 +10:22:33 21:59:22 select * from t44 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 select * from t55 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 -insert into t11 values ('14:30:45'); -insert into t22 values ('14:30:45'); -insert into t33 values ('14:30:45'); -insert into t44 values (60,'14:30:45'); -insert into t55 values (60,'14:30:45'); -insert into t66 values (60,'14:30:45'); +insert into t11 values ('14:30:20'); +insert into t22 values ('14:30:20'); +insert into t33 values ('14:30:20'); +insert into t44 values (60,'14:30:20'); +insert into t55 values (60,'14:30:20'); +insert into t66 values (60,'14:30:20'); select * from t11 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 select * from t22 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t33 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t44 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 -60 14:30:45 +60 14:30:20 select * from t55 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 -60 14:30:45 +60 14:30:20 select * from t66 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 -60 14:30:45 +60 14:30:20 alter table t11 drop partition p0; alter table t22 drop partition p0; alter table t44 drop partition p0; @@ -7933,27 +7945,27 @@ alter table t55 drop partition p0; alter table t66 drop partition p0; select * from t11 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 select * from t22 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t33 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t44 order by colint; colint col1 -60 14:30:45 +60 14:30:20 select * from t55 order by colint; colint col1 -60 14:30:45 +60 14:30:20 select * from t66 order by colint; colint col1 -60 14:30:45 +60 14:30:20 ------------------------- ---- some alter table end ------------------------- @@ -7970,7 +7982,7 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- second(col1) in partition with coltype time +--- month(col1) in partition with coltype date ------------------------------------------------------------------------- drop table if exists t1 ; drop table if exists t2 ; @@ -7979,14 +7991,14 @@ drop table if exists t4 ; drop table if exists t5 ; drop table if exists t6 ; ------------------------------------------------------------------------- ---- Create tables with second(col1) +--- Create tables with month(col1) ------------------------------------------------------------------------- -create table t1 (col1 time) engine='INNODB' -partition by range(second(col1)) +create table t1 (col1 date) engine='INNODB' +partition by range(month(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t2 (col1 time) engine='INNODB' -partition by list(second(col1)) +create table t2 (col1 date) engine='INNODB' +partition by list(month(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7994,16 +8006,16 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t3 (col1 time) engine='INNODB' -partition by hash(second(col1)); -create table t4 (colint int, col1 time) engine='INNODB' +create table t3 (col1 date) engine='INNODB' +partition by hash(month(col1)); +create table t4 (colint int, col1 date) engine='INNODB' partition by range(colint) -subpartition by hash(second(col1)) subpartitions 2 +subpartition by hash(month(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t5 (colint int, col1 time) engine='INNODB' +create table t5 (colint int, col1 date) engine='INNODB' partition by list(colint) -subpartition by hash(second(col1)) subpartitions 2 +subpartition by hash(month(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8011,100 +8023,100 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t6 (colint int, col1 time) engine='INNODB' +create table t6 (colint int, col1 date) engine='INNODB' partition by range(colint) -(partition p0 values less than (second('18:30:14')), +(partition p0 values less than (month('2006-10-14')), partition p1 values less than maxvalue); ------------------------------------------------------------------------- ---- Access tables with second(col1) +--- Access tables with month(col1) ------------------------------------------------------------------------- -insert into t1 values ('09:09:09'); -insert into t1 values ('14:30:20'); -insert into t2 values ('09:09:09'); -insert into t2 values ('14:30:20'); -insert into t2 values ('21:59:22'); -insert into t3 values ('09:09:09'); -insert into t3 values ('14:30:20'); -insert into t3 values ('21:59:22'); -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; -select second(col1) from t1 order by col1; -second(col1) -9 -20 +insert into t1 values ('2006-01-03'); +insert into t1 values ('2006-12-17'); +insert into t2 values ('2006-01-03'); +insert into t2 values ('2006-12-17'); +insert into t2 values ('2006-05-25'); +insert into t3 values ('2006-01-03'); +insert into t3 values ('2006-12-17'); +insert into t3 values ('2006-05-25'); +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; +select month(col1) from t1 order by col1; +month(col1) +1 +12 select * from t1 order by col1; col1 -09:09:09 -14:30:20 +2006-01-03 +2006-12-17 select * from t2 order by col1; col1 -09:09:09 -14:30:20 -21:59:22 +2006-01-03 +2006-05-25 +2006-12-17 select * from t3 order by col1; col1 -09:09:09 -14:30:20 -21:59:22 +2006-01-03 +2006-05-25 +2006-12-17 select * from t4 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t5 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t6 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -update t1 set col1='10:22:33' where col1='09:09:09'; -update t2 set col1='10:22:33' where col1='09:09:09'; -update t3 set col1='10:22:33' where col1='09:09:09'; -update t4 set col1='10:22:33' where col1='09:09:09'; -update t5 set col1='10:22:33' where col1='09:09:09'; -update t6 set col1='10:22:33' where col1='09:09:09'; +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +update t1 set col1='2006-11-06' where col1='2006-01-03'; +update t2 set col1='2006-11-06' where col1='2006-01-03'; +update t3 set col1='2006-11-06' where col1='2006-01-03'; +update t4 set col1='2006-11-06' where col1='2006-01-03'; +update t5 set col1='2006-11-06' where col1='2006-01-03'; +update t6 set col1='2006-11-06' where col1='2006-01-03'; select * from t1 order by col1; col1 -10:22:33 -14:30:20 +2006-11-06 +2006-12-17 select * from t2 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t3 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t4 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t5 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t6 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 ------------------------------------------------------------------------- ---- Alter tables with second(col1) +--- Alter tables with month(col1) ------------------------------------------------------------------------- drop table if exists t11 ; drop table if exists t22 ; @@ -8119,11 +8131,11 @@ create table t44 engine='INNODB' as select * from t4; create table t55 engine='INNODB' as select * from t5; create table t66 engine='INNODB' as select * from t6; alter table t11 -partition by range(second(col1)) +partition by range(month(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t22 -partition by list(second(col1)) +partition by list(month(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8132,15 +8144,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t33 -partition by hash(second(col1)); +partition by hash(month(col1)); alter table t44 partition by range(colint) -subpartition by hash(second(col1)) subpartitions 2 +subpartition by hash(month(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t55 partition by list(colint) -subpartition by hash(second(col1)) subpartitions 2 +subpartition by hash(month(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8150,40 +8162,40 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t66 partition by range(colint) -(partition p0 values less than (second('18:30:14')), +(partition p0 values less than (month('2006-10-14')), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -10:22:33 -14:30:20 +2006-11-06 +2006-12-17 select * from t22 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t33 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t44 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t55 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t66 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 --------------------------- ---- some alter table begin --------------------------- @@ -8192,19 +8204,19 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t11 order by col1; col1 -10:22:33 -14:30:20 +2006-11-06 +2006-12-17 alter table t11 reorganize partition s1 into (partition p0 values less than (15), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -10:22:33 -14:30:20 +2006-11-06 +2006-12-17 alter table t55 partition by list(colint) -subpartition by hash(second(col1)) subpartitions 5 +subpartition by hash(month(col1)) subpartitions 5 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8216,10 +8228,10 @@ show create table t55; Table Create Table t55 CREATE TABLE `t55` ( `colint` int(11) DEFAULT NULL, - `col1` time DEFAULT NULL + `col1` date DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (second(col1)) +SUBPARTITION BY HASH (month(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB, @@ -8229,121 +8241,121 @@ SUBPARTITIONS 5 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */ select * from t55 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 alter table t66 reorganize partition s1 into -(partition p0 values less than (second('18:30:14')), +(partition p0 values less than (month('2006-10-14')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 alter table t66 reorganize partition s1 into -(partition p0 values less than (second('18:30:14')), +(partition p0 values less than (month('2006-10-14')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with second(col1) +--- Delete rows and partitions of tables with month(col1) ------------------------------------------------------------------------- -delete from t1 where col1='14:30:20'; -delete from t2 where col1='14:30:20'; -delete from t3 where col1='14:30:20'; -delete from t4 where col1='14:30:20'; -delete from t5 where col1='14:30:20'; -delete from t6 where col1='14:30:20'; +delete from t1 where col1='2006-12-17'; +delete from t2 where col1='2006-12-17'; +delete from t3 where col1='2006-12-17'; +delete from t4 where col1='2006-12-17'; +delete from t5 where col1='2006-12-17'; +delete from t6 where col1='2006-12-17'; select * from t1 order by col1; col1 -10:22:33 +2006-11-06 select * from t2 order by col1; col1 -10:22:33 -21:59:22 +2006-05-25 +2006-11-06 select * from t3 order by col1; col1 -10:22:33 -21:59:22 +2006-05-25 +2006-11-06 select * from t4 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t5 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -insert into t1 values ('14:30:20'); -insert into t2 values ('14:30:20'); -insert into t3 values ('14:30:20'); -insert into t4 values (60,'14:30:20'); -insert into t5 values (60,'14:30:20'); -insert into t6 values (60,'14:30:20'); +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +insert into t1 values ('2006-12-17'); +insert into t2 values ('2006-12-17'); +insert into t3 values ('2006-12-17'); +insert into t4 values (60,'2006-12-17'); +insert into t5 values (60,'2006-12-17'); +insert into t6 values (60,'2006-12-17'); select * from t1 order by col1; col1 -10:22:33 -14:30:20 +2006-11-06 +2006-12-17 select * from t2 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t3 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t4 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 select * from t5 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 select * from t6 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 alter table t1 drop partition p0; alter table t2 drop partition p0; alter table t4 drop partition p0; @@ -8351,100 +8363,97 @@ alter table t5 drop partition p0; alter table t6 drop partition p0; select * from t1 order by col1; col1 -10:22:33 -14:30:20 select * from t2 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-11-06 +2006-12-17 select * from t3 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t4 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 select * from t5 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 select * from t6 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with second(col1) +--- Delete rows and partitions of tables with month(col1) ------------------------------------------------------------------------- -delete from t11 where col1='14:30:20'; -delete from t22 where col1='14:30:20'; -delete from t33 where col1='14:30:20'; -delete from t44 where col1='14:30:20'; -delete from t55 where col1='14:30:20'; -delete from t66 where col1='14:30:20'; +delete from t11 where col1='2006-12-17'; +delete from t22 where col1='2006-12-17'; +delete from t33 where col1='2006-12-17'; +delete from t44 where col1='2006-12-17'; +delete from t55 where col1='2006-12-17'; +delete from t66 where col1='2006-12-17'; select * from t11 order by col1; col1 -10:22:33 +2006-11-06 select * from t22 order by col1; col1 -10:22:33 -21:59:22 +2006-05-25 +2006-11-06 select * from t33 order by col1; col1 -10:22:33 -21:59:22 +2006-05-25 +2006-11-06 select * from t44 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t55 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -insert into t11 values ('14:30:20'); -insert into t22 values ('14:30:20'); -insert into t33 values ('14:30:20'); -insert into t44 values (60,'14:30:20'); -insert into t55 values (60,'14:30:20'); -insert into t66 values (60,'14:30:20'); +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +insert into t11 values ('2006-12-17'); +insert into t22 values ('2006-12-17'); +insert into t33 values ('2006-12-17'); +insert into t44 values (60,'2006-12-17'); +insert into t55 values (60,'2006-12-17'); +insert into t66 values (60,'2006-12-17'); select * from t11 order by col1; col1 -10:22:33 -14:30:20 +2006-11-06 +2006-12-17 select * from t22 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t33 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t44 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 select * from t55 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 select * from t66 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 alter table t11 drop partition p0; alter table t22 drop partition p0; alter table t44 drop partition p0; @@ -8452,27 +8461,24 @@ alter table t55 drop partition p0; alter table t66 drop partition p0; select * from t11 order by col1; col1 -10:22:33 -14:30:20 select * from t22 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-11-06 +2006-12-17 select * from t33 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t44 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 select * from t55 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 select * from t66 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 ------------------------- ---- some alter table end ------------------------- @@ -8489,7 +8495,7 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- second(col1) in partition with coltype char(30) +--- quarter(col1) in partition with coltype date ------------------------------------------------------------------------- drop table if exists t1 ; drop table if exists t2 ; @@ -8498,14 +8504,14 @@ drop table if exists t4 ; drop table if exists t5 ; drop table if exists t6 ; ------------------------------------------------------------------------- ---- Create tables with second(col1) +--- Create tables with quarter(col1) ------------------------------------------------------------------------- -create table t1 (col1 char(30)) engine='INNODB' -partition by range(second(col1)) +create table t1 (col1 date) engine='INNODB' +partition by range(quarter(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t2 (col1 char(30)) engine='INNODB' -partition by list(second(col1)) +create table t2 (col1 date) engine='INNODB' +partition by list(quarter(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8513,16 +8519,16 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t3 (col1 char(30)) engine='INNODB' -partition by hash(second(col1)); -create table t4 (colint int, col1 char(30)) engine='INNODB' +create table t3 (col1 date) engine='INNODB' +partition by hash(quarter(col1)); +create table t4 (colint int, col1 date) engine='INNODB' partition by range(colint) -subpartition by hash(second(col1)) subpartitions 2 +subpartition by hash(quarter(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t5 (colint int, col1 char(30)) engine='INNODB' +create table t5 (colint int, col1 date) engine='INNODB' partition by list(colint) -subpartition by hash(second(col1)) subpartitions 2 +subpartition by hash(quarter(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8530,100 +8536,100 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t6 (colint int, col1 char(30)) engine='INNODB' +create table t6 (colint int, col1 date) engine='INNODB' partition by range(colint) -(partition p0 values less than (second('18:30:14')), +(partition p0 values less than (quarter('2006-10-14')), partition p1 values less than maxvalue); ------------------------------------------------------------------------- ---- Access tables with second(col1) +--- Access tables with quarter(col1) ------------------------------------------------------------------------- -insert into t1 values ('09:09:09'); -insert into t1 values ('14:30:20'); -insert into t2 values ('09:09:09'); -insert into t2 values ('14:30:20'); -insert into t2 values ('21:59:22'); -insert into t3 values ('09:09:09'); -insert into t3 values ('14:30:20'); -insert into t3 values ('21:59:22'); -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; -select second(col1) from t1 order by col1; -second(col1) -9 -20 +insert into t1 values ('2006-01-03'); +insert into t1 values ('2006-12-17'); +insert into t2 values ('2006-01-03'); +insert into t2 values ('2006-12-17'); +insert into t2 values ('2006-09-25'); +insert into t3 values ('2006-01-03'); +insert into t3 values ('2006-12-17'); +insert into t3 values ('2006-09-25'); +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; +select quarter(col1) from t1 order by col1; +quarter(col1) +1 +4 select * from t1 order by col1; col1 -09:09:09 -14:30:20 +2006-01-03 +2006-12-17 select * from t2 order by col1; col1 -09:09:09 -14:30:20 -21:59:22 +2006-01-03 +2006-09-25 +2006-12-17 select * from t3 order by col1; col1 -09:09:09 -14:30:20 -21:59:22 +2006-01-03 +2006-09-25 +2006-12-17 select * from t4 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t5 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t6 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -update t1 set col1='10:22:33' where col1='09:09:09'; -update t2 set col1='10:22:33' where col1='09:09:09'; -update t3 set col1='10:22:33' where col1='09:09:09'; -update t4 set col1='10:22:33' where col1='09:09:09'; -update t5 set col1='10:22:33' where col1='09:09:09'; -update t6 set col1='10:22:33' where col1='09:09:09'; +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +update t1 set col1='2006-07-30' where col1='2006-01-03'; +update t2 set col1='2006-07-30' where col1='2006-01-03'; +update t3 set col1='2006-07-30' where col1='2006-01-03'; +update t4 set col1='2006-07-30' where col1='2006-01-03'; +update t5 set col1='2006-07-30' where col1='2006-01-03'; +update t6 set col1='2006-07-30' where col1='2006-01-03'; select * from t1 order by col1; col1 -10:22:33 -14:30:20 +2006-07-30 +2006-12-17 select * from t2 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 select * from t3 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 select * from t4 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t5 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t6 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 ------------------------------------------------------------------------- ---- Alter tables with second(col1) +--- Alter tables with quarter(col1) ------------------------------------------------------------------------- drop table if exists t11 ; drop table if exists t22 ; @@ -8638,11 +8644,11 @@ create table t44 engine='INNODB' as select * from t4; create table t55 engine='INNODB' as select * from t5; create table t66 engine='INNODB' as select * from t6; alter table t11 -partition by range(second(col1)) +partition by range(quarter(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t22 -partition by list(second(col1)) +partition by list(quarter(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8651,15 +8657,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t33 -partition by hash(second(col1)); +partition by hash(quarter(col1)); alter table t44 partition by range(colint) -subpartition by hash(second(col1)) subpartitions 2 +subpartition by hash(quarter(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t55 partition by list(colint) -subpartition by hash(second(col1)) subpartitions 2 +subpartition by hash(quarter(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8669,40 +8675,40 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t66 partition by range(colint) -(partition p0 values less than (second('18:30:14')), +(partition p0 values less than (quarter('2006-10-14')), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -10:22:33 -14:30:20 +2006-07-30 +2006-12-17 select * from t22 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 -select * from t33 order by col1; -col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 +select * from t33 order by col1; +col1 +2006-07-30 +2006-09-25 +2006-12-17 select * from t44 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t55 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t66 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 --------------------------- ---- some alter table begin --------------------------- @@ -8711,19 +8717,19 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t11 order by col1; col1 -10:22:33 -14:30:20 +2006-07-30 +2006-12-17 alter table t11 reorganize partition s1 into (partition p0 values less than (15), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -10:22:33 -14:30:20 +2006-07-30 +2006-12-17 alter table t55 partition by list(colint) -subpartition by hash(second(col1)) subpartitions 5 +subpartition by hash(quarter(col1)) subpartitions 5 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8735,10 +8741,10 @@ show create table t55; Table Create Table t55 CREATE TABLE `t55` ( `colint` int(11) DEFAULT NULL, - `col1` char(30) DEFAULT NULL + `col1` date DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (second(col1)) +SUBPARTITION BY HASH (quarter(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB, @@ -8748,121 +8754,121 @@ SUBPARTITIONS 5 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */ select * from t55 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 alter table t66 reorganize partition s1 into -(partition p0 values less than (second('18:30:14')), +(partition p0 values less than (quarter('2006-10-14')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 alter table t66 reorganize partition s1 into -(partition p0 values less than (second('18:30:14')), +(partition p0 values less than (quarter('2006-10-14')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with second(col1) +--- Delete rows and partitions of tables with quarter(col1) ------------------------------------------------------------------------- -delete from t1 where col1='14:30:20'; -delete from t2 where col1='14:30:20'; -delete from t3 where col1='14:30:20'; -delete from t4 where col1='14:30:20'; -delete from t5 where col1='14:30:20'; -delete from t6 where col1='14:30:20'; +delete from t1 where col1='2006-12-17'; +delete from t2 where col1='2006-12-17'; +delete from t3 where col1='2006-12-17'; +delete from t4 where col1='2006-12-17'; +delete from t5 where col1='2006-12-17'; +delete from t6 where col1='2006-12-17'; select * from t1 order by col1; col1 -10:22:33 +2006-07-30 select * from t2 order by col1; col1 -10:22:33 -21:59:22 +2006-07-30 +2006-09-25 select * from t3 order by col1; col1 -10:22:33 -21:59:22 +2006-07-30 +2006-09-25 select * from t4 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t5 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -insert into t1 values ('14:30:20'); -insert into t2 values ('14:30:20'); -insert into t3 values ('14:30:20'); -insert into t4 values (60,'14:30:20'); -insert into t5 values (60,'14:30:20'); -insert into t6 values (60,'14:30:20'); +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +insert into t1 values ('2006-12-17'); +insert into t2 values ('2006-12-17'); +insert into t3 values ('2006-12-17'); +insert into t4 values (60,'2006-12-17'); +insert into t5 values (60,'2006-12-17'); +insert into t6 values (60,'2006-12-17'); select * from t1 order by col1; col1 -10:22:33 -14:30:20 +2006-07-30 +2006-12-17 select * from t2 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 select * from t3 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 select * from t4 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 select * from t5 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 select * from t6 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 alter table t1 drop partition p0; alter table t2 drop partition p0; alter table t4 drop partition p0; @@ -8870,100 +8876,96 @@ alter table t5 drop partition p0; alter table t6 drop partition p0; select * from t1 order by col1; col1 -10:22:33 -14:30:20 select * from t2 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 select * from t3 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 select * from t4 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 select * from t5 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 select * from t6 order by colint; colint col1 -60 14:30:20 +4 2006-02-05 +60 2006-12-17 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with second(col1) +--- Delete rows and partitions of tables with quarter(col1) ------------------------------------------------------------------------- -delete from t11 where col1='14:30:20'; -delete from t22 where col1='14:30:20'; -delete from t33 where col1='14:30:20'; -delete from t44 where col1='14:30:20'; -delete from t55 where col1='14:30:20'; -delete from t66 where col1='14:30:20'; +delete from t11 where col1='2006-12-17'; +delete from t22 where col1='2006-12-17'; +delete from t33 where col1='2006-12-17'; +delete from t44 where col1='2006-12-17'; +delete from t55 where col1='2006-12-17'; +delete from t66 where col1='2006-12-17'; select * from t11 order by col1; col1 -10:22:33 +2006-07-30 select * from t22 order by col1; col1 -10:22:33 -21:59:22 +2006-07-30 +2006-09-25 select * from t33 order by col1; col1 -10:22:33 -21:59:22 +2006-07-30 +2006-09-25 select * from t44 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t55 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -insert into t11 values ('14:30:20'); -insert into t22 values ('14:30:20'); -insert into t33 values ('14:30:20'); -insert into t44 values (60,'14:30:20'); -insert into t55 values (60,'14:30:20'); -insert into t66 values (60,'14:30:20'); +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +insert into t11 values ('2006-12-17'); +insert into t22 values ('2006-12-17'); +insert into t33 values ('2006-12-17'); +insert into t44 values (60,'2006-12-17'); +insert into t55 values (60,'2006-12-17'); +insert into t66 values (60,'2006-12-17'); select * from t11 order by col1; col1 -10:22:33 -14:30:20 +2006-07-30 +2006-12-17 select * from t22 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 select * from t33 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 select * from t44 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 select * from t55 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 select * from t66 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 alter table t11 drop partition p0; alter table t22 drop partition p0; alter table t44 drop partition p0; @@ -8971,27 +8973,23 @@ alter table t55 drop partition p0; alter table t66 drop partition p0; select * from t11 order by col1; col1 -10:22:33 -14:30:20 select * from t22 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 select * from t33 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 select * from t44 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 select * from t55 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 select * from t66 order by colint; colint col1 -60 14:30:20 +4 2006-02-05 +60 2006-12-17 ------------------------- ---- some alter table end ------------------------- @@ -9008,7 +9006,7 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- month(col1) in partition with coltype date +--- time_to_sec(col1)-(time_to_sec(col1)-20) in partition with coltype time ------------------------------------------------------------------------- drop table if exists t1 ; drop table if exists t2 ; @@ -9017,14 +9015,14 @@ drop table if exists t4 ; drop table if exists t5 ; drop table if exists t6 ; ------------------------------------------------------------------------- ---- Create tables with month(col1) +--- Create tables with time_to_sec(col1)-(time_to_sec(col1)-20) ------------------------------------------------------------------------- -create table t1 (col1 date) engine='INNODB' -partition by range(month(col1)) +create table t1 (col1 time) engine='INNODB' +partition by range(time_to_sec(col1)-(time_to_sec(col1)-20)) (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t2 (col1 date) engine='INNODB' -partition by list(month(col1)) +create table t2 (col1 time) engine='INNODB' +partition by list(time_to_sec(col1)-(time_to_sec(col1)-20)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -9032,16 +9030,16 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t3 (col1 date) engine='INNODB' -partition by hash(month(col1)); -create table t4 (colint int, col1 date) engine='INNODB' +create table t3 (col1 time) engine='INNODB' +partition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)); +create table t4 (colint int, col1 time) engine='INNODB' partition by range(colint) -subpartition by hash(month(col1)) subpartitions 2 +subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t5 (colint int, col1 date) engine='INNODB' +create table t5 (colint int, col1 time) engine='INNODB' partition by list(colint) -subpartition by hash(month(col1)) subpartitions 2 +subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -9049,100 +9047,100 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t6 (colint int, col1 date) engine='INNODB' +create table t6 (colint int, col1 time) engine='INNODB' partition by range(colint) -(partition p0 values less than (month('2006-10-14')), +(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), partition p1 values less than maxvalue); ------------------------------------------------------------------------- ---- Access tables with month(col1) +--- Access tables with time_to_sec(col1)-(time_to_sec(col1)-20) ------------------------------------------------------------------------- -insert into t1 values ('2006-01-03'); -insert into t1 values ('2006-12-17'); -insert into t2 values ('2006-01-03'); -insert into t2 values ('2006-12-17'); -insert into t2 values ('2006-05-25'); -insert into t3 values ('2006-01-03'); -insert into t3 values ('2006-12-17'); -insert into t3 values ('2006-05-25'); -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; -select month(col1) from t1 order by col1; -month(col1) -1 -12 +insert into t1 values ('09:09:15'); +insert into t1 values ('14:30:45'); +insert into t2 values ('09:09:15'); +insert into t2 values ('14:30:45'); +insert into t2 values ('21:59:22'); +insert into t3 values ('09:09:15'); +insert into t3 values ('14:30:45'); +insert into t3 values ('21:59:22'); +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; +select time_to_sec(col1)-(time_to_sec(col1)-20) from t1 order by col1; +time_to_sec(col1)-(time_to_sec(col1)-20) +20 +20 select * from t1 order by col1; col1 -2006-01-03 -2006-12-17 +09:09:15 +14:30:45 select * from t2 order by col1; col1 -2006-01-03 -2006-05-25 -2006-12-17 +09:09:15 +14:30:45 +21:59:22 select * from t3 order by col1; col1 -2006-01-03 -2006-05-25 -2006-12-17 +09:09:15 +14:30:45 +21:59:22 select * from t4 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t5 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t6 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -update t1 set col1='2006-11-06' where col1='2006-01-03'; -update t2 set col1='2006-11-06' where col1='2006-01-03'; -update t3 set col1='2006-11-06' where col1='2006-01-03'; -update t4 set col1='2006-11-06' where col1='2006-01-03'; -update t5 set col1='2006-11-06' where col1='2006-01-03'; -update t6 set col1='2006-11-06' where col1='2006-01-03'; +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +update t1 set col1='10:33:11' where col1='09:09:15'; +update t2 set col1='10:33:11' where col1='09:09:15'; +update t3 set col1='10:33:11' where col1='09:09:15'; +update t4 set col1='10:33:11' where col1='09:09:15'; +update t5 set col1='10:33:11' where col1='09:09:15'; +update t6 set col1='10:33:11' where col1='09:09:15'; select * from t1 order by col1; col1 -2006-11-06 -2006-12-17 +10:33:11 +14:30:45 select * from t2 order by col1; col1 -2006-05-25 -2006-11-06 -2006-12-17 +10:33:11 +14:30:45 +21:59:22 select * from t3 order by col1; col1 -2006-05-25 -2006-11-06 -2006-12-17 +10:33:11 +14:30:45 +21:59:22 select * from t4 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t5 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t6 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 ------------------------------------------------------------------------- ---- Alter tables with month(col1) +--- Alter tables with time_to_sec(col1)-(time_to_sec(col1)-20) ------------------------------------------------------------------------- drop table if exists t11 ; drop table if exists t22 ; @@ -9157,11 +9155,11 @@ create table t44 engine='INNODB' as select * from t4; create table t55 engine='INNODB' as select * from t5; create table t66 engine='INNODB' as select * from t6; alter table t11 -partition by range(month(col1)) +partition by range(time_to_sec(col1)-(time_to_sec(col1)-20)) (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t22 -partition by list(month(col1)) +partition by list(time_to_sec(col1)-(time_to_sec(col1)-20)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -9170,15 +9168,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t33 -partition by hash(month(col1)); +partition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)); alter table t44 partition by range(colint) -subpartition by hash(month(col1)) subpartitions 2 +subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t55 partition by list(colint) -subpartition by hash(month(col1)) subpartitions 2 +subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -9188,40 +9186,40 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t66 partition by range(colint) -(partition p0 values less than (month('2006-10-14')), +(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -2006-11-06 -2006-12-17 +10:33:11 +14:30:45 select * from t22 order by col1; col1 -2006-05-25 -2006-11-06 -2006-12-17 +10:33:11 +14:30:45 +21:59:22 select * from t33 order by col1; col1 -2006-05-25 -2006-11-06 -2006-12-17 +10:33:11 +14:30:45 +21:59:22 select * from t44 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t55 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 --------------------------- ---- some alter table begin --------------------------- @@ -9230,19 +9228,19 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t11 order by col1; col1 -2006-11-06 -2006-12-17 +10:33:11 +14:30:45 alter table t11 reorganize partition s1 into (partition p0 values less than (15), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -2006-11-06 -2006-12-17 +10:33:11 +14:30:45 alter table t55 partition by list(colint) -subpartition by hash(month(col1)) subpartitions 5 +subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 5 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -9254,10 +9252,10 @@ show create table t55; Table Create Table t55 CREATE TABLE `t55` ( `colint` int(11) DEFAULT NULL, - `col1` date DEFAULT NULL + `col1` time DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (month(col1)) +SUBPARTITION BY HASH (time_to_sec(col1)-(time_to_sec(col1)-20)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB, @@ -9267,2166 +9265,121 @@ SUBPARTITIONS 5 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */ select * from t55 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (month('2006-10-14')), +(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (month('2006-10-14')), +(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with month(col1) -------------------------------------------------------------------------- -delete from t1 where col1='2006-12-17'; -delete from t2 where col1='2006-12-17'; -delete from t3 where col1='2006-12-17'; -delete from t4 where col1='2006-12-17'; -delete from t5 where col1='2006-12-17'; -delete from t6 where col1='2006-12-17'; -select * from t1 order by col1; -col1 -2006-11-06 -select * from t2 order by col1; -col1 -2006-05-25 -2006-11-06 -select * from t3 order by col1; -col1 -2006-05-25 -2006-11-06 -select * from t4 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -insert into t1 values ('2006-12-17'); -insert into t2 values ('2006-12-17'); -insert into t3 values ('2006-12-17'); -insert into t4 values (60,'2006-12-17'); -insert into t5 values (60,'2006-12-17'); -insert into t6 values (60,'2006-12-17'); -select * from t1 order by col1; -col1 -2006-11-06 -2006-12-17 -select * from t2 order by col1; -col1 -2006-05-25 -2006-11-06 -2006-12-17 -select * from t3 order by col1; -col1 -2006-05-25 -2006-11-06 -2006-12-17 -select * from t4 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -select * from t5 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -select * from t6 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -alter table t1 drop partition p0; -alter table t2 drop partition p0; -alter table t4 drop partition p0; -alter table t5 drop partition p0; -alter table t6 drop partition p0; -select * from t1 order by col1; -col1 -select * from t2 order by col1; -col1 -2006-11-06 -2006-12-17 -select * from t3 order by col1; -col1 -2006-05-25 -2006-11-06 -2006-12-17 -select * from t4 order by colint; -colint col1 -60 2006-12-17 -select * from t5 order by colint; -colint col1 -60 2006-12-17 -select * from t6 order by colint; -colint col1 -60 2006-12-17 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with month(col1) -------------------------------------------------------------------------- -delete from t11 where col1='2006-12-17'; -delete from t22 where col1='2006-12-17'; -delete from t33 where col1='2006-12-17'; -delete from t44 where col1='2006-12-17'; -delete from t55 where col1='2006-12-17'; -delete from t66 where col1='2006-12-17'; -select * from t11 order by col1; -col1 -2006-11-06 -select * from t22 order by col1; -col1 -2006-05-25 -2006-11-06 -select * from t33 order by col1; -col1 -2006-05-25 -2006-11-06 -select * from t44 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t55 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -insert into t11 values ('2006-12-17'); -insert into t22 values ('2006-12-17'); -insert into t33 values ('2006-12-17'); -insert into t44 values (60,'2006-12-17'); -insert into t55 values (60,'2006-12-17'); -insert into t66 values (60,'2006-12-17'); -select * from t11 order by col1; -col1 -2006-11-06 -2006-12-17 -select * from t22 order by col1; -col1 -2006-05-25 -2006-11-06 -2006-12-17 -select * from t33 order by col1; -col1 -2006-05-25 -2006-11-06 -2006-12-17 -select * from t44 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -select * from t55 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -select * from t66 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -alter table t11 drop partition p0; -alter table t22 drop partition p0; -alter table t44 drop partition p0; -alter table t55 drop partition p0; -alter table t66 drop partition p0; -select * from t11 order by col1; -col1 -select * from t22 order by col1; -col1 -2006-11-06 -2006-12-17 -select * from t33 order by col1; -col1 -2006-05-25 -2006-11-06 -2006-12-17 -select * from t44 order by colint; -colint col1 -60 2006-12-17 -select * from t55 order by colint; -colint col1 -60 2006-12-17 -select * from t66 order by colint; -colint col1 -60 2006-12-17 -------------------------- ----- some alter table end -------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -------------------------------------------------------------------------- ---- quarter(col1) in partition with coltype date -------------------------------------------------------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -------------------------------------------------------------------------- ---- Create tables with quarter(col1) -------------------------------------------------------------------------- -create table t1 (col1 date) engine='INNODB' -partition by range(quarter(col1)) -(partition p0 values less than (15), -partition p1 values less than maxvalue); -create table t2 (col1 date) engine='INNODB' -partition by list(quarter(col1)) -(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -create table t3 (col1 date) engine='INNODB' -partition by hash(quarter(col1)); -create table t4 (colint int, col1 date) engine='INNODB' -partition by range(colint) -subpartition by hash(quarter(col1)) subpartitions 2 -(partition p0 values less than (15), -partition p1 values less than maxvalue); -create table t5 (colint int, col1 date) engine='INNODB' -partition by list(colint) -subpartition by hash(quarter(col1)) subpartitions 2 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -create table t6 (colint int, col1 date) engine='INNODB' -partition by range(colint) -(partition p0 values less than (quarter('2006-10-14')), -partition p1 values less than maxvalue); -------------------------------------------------------------------------- ---- Access tables with quarter(col1) -------------------------------------------------------------------------- -insert into t1 values ('2006-01-03'); -insert into t1 values ('2006-12-17'); -insert into t2 values ('2006-01-03'); -insert into t2 values ('2006-12-17'); -insert into t2 values ('2006-09-25'); -insert into t3 values ('2006-01-03'); -insert into t3 values ('2006-12-17'); -insert into t3 values ('2006-09-25'); -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; -select quarter(col1) from t1 order by col1; -quarter(col1) -1 -4 -select * from t1 order by col1; -col1 -2006-01-03 -2006-12-17 -select * from t2 order by col1; -col1 -2006-01-03 -2006-09-25 -2006-12-17 -select * from t3 order by col1; -col1 -2006-01-03 -2006-09-25 -2006-12-17 -select * from t4 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t6 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -update t1 set col1='2006-07-30' where col1='2006-01-03'; -update t2 set col1='2006-07-30' where col1='2006-01-03'; -update t3 set col1='2006-07-30' where col1='2006-01-03'; -update t4 set col1='2006-07-30' where col1='2006-01-03'; -update t5 set col1='2006-07-30' where col1='2006-01-03'; -update t6 set col1='2006-07-30' where col1='2006-01-03'; -select * from t1 order by col1; -col1 -2006-07-30 -2006-12-17 -select * from t2 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t3 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t4 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t6 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -------------------------------------------------------------------------- ---- Alter tables with quarter(col1) -------------------------------------------------------------------------- -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -create table t11 engine='INNODB' as select * from t1; -create table t22 engine='INNODB' as select * from t2; -create table t33 engine='INNODB' as select * from t3; -create table t44 engine='INNODB' as select * from t4; -create table t55 engine='INNODB' as select * from t5; -create table t66 engine='INNODB' as select * from t6; -alter table t11 -partition by range(quarter(col1)) -(partition p0 values less than (15), -partition p1 values less than maxvalue); -alter table t22 -partition by list(quarter(col1)) -(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -alter table t33 -partition by hash(quarter(col1)); -alter table t44 -partition by range(colint) -subpartition by hash(quarter(col1)) subpartitions 2 -(partition p0 values less than (15), -partition p1 values less than maxvalue); -alter table t55 -partition by list(colint) -subpartition by hash(quarter(col1)) subpartitions 2 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -alter table t66 -partition by range(colint) -(partition p0 values less than (quarter('2006-10-14')), -partition p1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-07-30 -2006-12-17 -select * from t22 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t33 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t44 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t55 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t66 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 ---------------------------- ----- some alter table begin ---------------------------- -alter table t11 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-07-30 -2006-12-17 -alter table t11 -reorganize partition s1 into -(partition p0 values less than (15), -partition p1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-07-30 -2006-12-17 -alter table t55 -partition by list(colint) -subpartition by hash(quarter(col1)) subpartitions 5 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -show create table t55; -Table Create Table -t55 CREATE TABLE `t55` ( - `colint` int(11) DEFAULT NULL, - `col1` date DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (quarter(col1)) -SUBPARTITIONS 5 -(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB, - PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB, - PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB, - PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB, - PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB, - PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */ -select * from t55 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (quarter('2006-10-14')), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (quarter('2006-10-14')), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with quarter(col1) -------------------------------------------------------------------------- -delete from t1 where col1='2006-12-17'; -delete from t2 where col1='2006-12-17'; -delete from t3 where col1='2006-12-17'; -delete from t4 where col1='2006-12-17'; -delete from t5 where col1='2006-12-17'; -delete from t6 where col1='2006-12-17'; -select * from t1 order by col1; -col1 -2006-07-30 -select * from t2 order by col1; -col1 -2006-07-30 -2006-09-25 -select * from t3 order by col1; -col1 -2006-07-30 -2006-09-25 -select * from t4 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -insert into t1 values ('2006-12-17'); -insert into t2 values ('2006-12-17'); -insert into t3 values ('2006-12-17'); -insert into t4 values (60,'2006-12-17'); -insert into t5 values (60,'2006-12-17'); -insert into t6 values (60,'2006-12-17'); -select * from t1 order by col1; -col1 -2006-07-30 -2006-12-17 -select * from t2 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t3 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t4 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -select * from t5 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -select * from t6 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -alter table t1 drop partition p0; -alter table t2 drop partition p0; -alter table t4 drop partition p0; -alter table t5 drop partition p0; -alter table t6 drop partition p0; -select * from t1 order by col1; -col1 -select * from t2 order by col1; -col1 -select * from t3 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t4 order by colint; -colint col1 -60 2006-12-17 -select * from t5 order by colint; -colint col1 -60 2006-12-17 -select * from t6 order by colint; -colint col1 -4 2006-02-05 -60 2006-12-17 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with quarter(col1) -------------------------------------------------------------------------- -delete from t11 where col1='2006-12-17'; -delete from t22 where col1='2006-12-17'; -delete from t33 where col1='2006-12-17'; -delete from t44 where col1='2006-12-17'; -delete from t55 where col1='2006-12-17'; -delete from t66 where col1='2006-12-17'; -select * from t11 order by col1; -col1 -2006-07-30 -select * from t22 order by col1; -col1 -2006-07-30 -2006-09-25 -select * from t33 order by col1; -col1 -2006-07-30 -2006-09-25 -select * from t44 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t55 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -insert into t11 values ('2006-12-17'); -insert into t22 values ('2006-12-17'); -insert into t33 values ('2006-12-17'); -insert into t44 values (60,'2006-12-17'); -insert into t55 values (60,'2006-12-17'); -insert into t66 values (60,'2006-12-17'); -select * from t11 order by col1; -col1 -2006-07-30 -2006-12-17 -select * from t22 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t33 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t44 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -select * from t55 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -select * from t66 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -alter table t11 drop partition p0; -alter table t22 drop partition p0; -alter table t44 drop partition p0; -alter table t55 drop partition p0; -alter table t66 drop partition p0; -select * from t11 order by col1; -col1 -select * from t22 order by col1; -col1 -select * from t33 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t44 order by colint; -colint col1 -60 2006-12-17 -select * from t55 order by colint; -colint col1 -60 2006-12-17 -select * from t66 order by colint; -colint col1 -4 2006-02-05 -60 2006-12-17 -------------------------- ----- some alter table end -------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -------------------------------------------------------------------------- ---- time_to_sec(col1)-(time_to_sec(col1)-20) in partition with coltype time -------------------------------------------------------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -------------------------------------------------------------------------- ---- Create tables with time_to_sec(col1)-(time_to_sec(col1)-20) -------------------------------------------------------------------------- -create table t1 (col1 time) engine='INNODB' -partition by range(time_to_sec(col1)-(time_to_sec(col1)-20)) -(partition p0 values less than (15), -partition p1 values less than maxvalue); -create table t2 (col1 time) engine='INNODB' -partition by list(time_to_sec(col1)-(time_to_sec(col1)-20)) -(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -create table t3 (col1 time) engine='INNODB' -partition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)); -create table t4 (colint int, col1 time) engine='INNODB' -partition by range(colint) -subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 -(partition p0 values less than (15), -partition p1 values less than maxvalue); -create table t5 (colint int, col1 time) engine='INNODB' -partition by list(colint) -subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -create table t6 (colint int, col1 time) engine='INNODB' -partition by range(colint) -(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), -partition p1 values less than maxvalue); -------------------------------------------------------------------------- ---- Access tables with time_to_sec(col1)-(time_to_sec(col1)-20) -------------------------------------------------------------------------- -insert into t1 values ('09:09:15'); -insert into t1 values ('14:30:45'); -insert into t2 values ('09:09:15'); -insert into t2 values ('14:30:45'); -insert into t2 values ('21:59:22'); -insert into t3 values ('09:09:15'); -insert into t3 values ('14:30:45'); -insert into t3 values ('21:59:22'); -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; -select time_to_sec(col1)-(time_to_sec(col1)-20) from t1 order by col1; -time_to_sec(col1)-(time_to_sec(col1)-20) -20 -20 -select * from t1 order by col1; -col1 -09:09:15 -14:30:45 -select * from t2 order by col1; -col1 -09:09:15 -14:30:45 -21:59:22 -select * from t3 order by col1; -col1 -09:09:15 -14:30:45 -21:59:22 -select * from t4 order by colint; -colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t5 order by colint; -colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t6 order by colint; -colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -update t1 set col1='10:33:11' where col1='09:09:15'; -update t2 set col1='10:33:11' where col1='09:09:15'; -update t3 set col1='10:33:11' where col1='09:09:15'; -update t4 set col1='10:33:11' where col1='09:09:15'; -update t5 set col1='10:33:11' where col1='09:09:15'; -update t6 set col1='10:33:11' where col1='09:09:15'; -select * from t1 order by col1; -col1 -10:33:11 -14:30:45 -select * from t2 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t3 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t4 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t5 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t6 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -------------------------------------------------------------------------- ---- Alter tables with time_to_sec(col1)-(time_to_sec(col1)-20) -------------------------------------------------------------------------- -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -create table t11 engine='INNODB' as select * from t1; -create table t22 engine='INNODB' as select * from t2; -create table t33 engine='INNODB' as select * from t3; -create table t44 engine='INNODB' as select * from t4; -create table t55 engine='INNODB' as select * from t5; -create table t66 engine='INNODB' as select * from t6; -alter table t11 -partition by range(time_to_sec(col1)-(time_to_sec(col1)-20)) -(partition p0 values less than (15), -partition p1 values less than maxvalue); -alter table t22 -partition by list(time_to_sec(col1)-(time_to_sec(col1)-20)) -(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -alter table t33 -partition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)); -alter table t44 -partition by range(colint) -subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 -(partition p0 values less than (15), -partition p1 values less than maxvalue); -alter table t55 -partition by list(colint) -subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -alter table t66 -partition by range(colint) -(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), -partition p1 values less than maxvalue); -select * from t11 order by col1; -col1 -10:33:11 -14:30:45 -select * from t22 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t33 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t44 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t55 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t66 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 ---------------------------- ----- some alter table begin ---------------------------- -alter table t11 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t11 order by col1; -col1 -10:33:11 -14:30:45 -alter table t11 -reorganize partition s1 into -(partition p0 values less than (15), -partition p1 values less than maxvalue); -select * from t11 order by col1; -col1 -10:33:11 -14:30:45 -alter table t55 -partition by list(colint) -subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 5 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -show create table t55; -Table Create Table -t55 CREATE TABLE `t55` ( - `colint` int(11) DEFAULT NULL, - `col1` time DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (time_to_sec(col1)-(time_to_sec(col1)-20)) -SUBPARTITIONS 5 -(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB, - PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB, - PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB, - PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB, - PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB, - PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */ -select * from t55 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20) -------------------------------------------------------------------------- -delete from t1 where col1='14:30:45'; -delete from t2 where col1='14:30:45'; -delete from t3 where col1='14:30:45'; -delete from t4 where col1='14:30:45'; -delete from t5 where col1='14:30:45'; -delete from t6 where col1='14:30:45'; -select * from t1 order by col1; -col1 -10:33:11 -select * from t2 order by col1; -col1 -10:33:11 -21:59:22 -select * from t3 order by col1; -col1 -10:33:11 -21:59:22 -select * from t4 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t5 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -insert into t1 values ('14:30:45'); -insert into t2 values ('14:30:45'); -insert into t3 values ('14:30:45'); -insert into t4 values (60,'14:30:45'); -insert into t5 values (60,'14:30:45'); -insert into t6 values (60,'14:30:45'); -select * from t1 order by col1; -col1 -10:33:11 -14:30:45 -select * from t2 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t3 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t4 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -select * from t5 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -select * from t6 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -alter table t1 drop partition p0; -alter table t2 drop partition p0; -alter table t4 drop partition p0; -alter table t5 drop partition p0; -alter table t6 drop partition p0; -select * from t1 order by col1; -col1 -10:33:11 -14:30:45 -select * from t2 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t3 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t4 order by colint; -colint col1 -60 14:30:45 -select * from t5 order by colint; -colint col1 -60 14:30:45 -select * from t6 order by colint; -colint col1 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20) -------------------------------------------------------------------------- -delete from t11 where col1='14:30:45'; -delete from t22 where col1='14:30:45'; -delete from t33 where col1='14:30:45'; -delete from t44 where col1='14:30:45'; -delete from t55 where col1='14:30:45'; -delete from t66 where col1='14:30:45'; -select * from t11 order by col1; -col1 -10:33:11 -select * from t22 order by col1; -col1 -10:33:11 -21:59:22 -select * from t33 order by col1; -col1 -10:33:11 -21:59:22 -select * from t44 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t55 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -insert into t11 values ('14:30:45'); -insert into t22 values ('14:30:45'); -insert into t33 values ('14:30:45'); -insert into t44 values (60,'14:30:45'); -insert into t55 values (60,'14:30:45'); -insert into t66 values (60,'14:30:45'); -select * from t11 order by col1; -col1 -10:33:11 -14:30:45 -select * from t22 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t33 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t44 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -select * from t55 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -select * from t66 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -alter table t11 drop partition p0; -alter table t22 drop partition p0; -alter table t44 drop partition p0; -alter table t55 drop partition p0; -alter table t66 drop partition p0; -select * from t11 order by col1; -col1 -10:33:11 -14:30:45 -select * from t22 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t33 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t44 order by colint; -colint col1 -60 14:30:45 -select * from t55 order by colint; -colint col1 -60 14:30:45 -select * from t66 order by colint; -colint col1 -------------------------- ----- some alter table end -------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -------------------------------------------------------------------------- ---- to_days(col1)-to_days('2006-01-01') in partition with coltype date -------------------------------------------------------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -------------------------------------------------------------------------- ---- Create tables with to_days(col1)-to_days('2006-01-01') -------------------------------------------------------------------------- -create table t1 (col1 date) engine='INNODB' -partition by range(to_days(col1)-to_days('2006-01-01')) -(partition p0 values less than (15), -partition p1 values less than maxvalue); -create table t2 (col1 date) engine='INNODB' -partition by list(to_days(col1)-to_days('2006-01-01')) -(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -create table t3 (col1 date) engine='INNODB' -partition by hash(to_days(col1)-to_days('2006-01-01')); -create table t4 (colint int, col1 date) engine='INNODB' -partition by range(colint) -subpartition by hash(to_days(col1)-to_days('2006-01-01')) subpartitions 2 -(partition p0 values less than (15), -partition p1 values less than maxvalue); -create table t5 (colint int, col1 date) engine='INNODB' -partition by list(colint) -subpartition by hash(to_days(col1)-to_days('2006-01-01')) subpartitions 2 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -create table t6 (colint int, col1 date) engine='INNODB' -partition by range(colint) -(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')), -partition p1 values less than maxvalue); -------------------------------------------------------------------------- ---- Access tables with to_days(col1)-to_days('2006-01-01') -------------------------------------------------------------------------- -insert into t1 values ('2006-02-03'); -insert into t1 values ('2006-01-17'); -insert into t2 values ('2006-02-03'); -insert into t2 values ('2006-01-17'); -insert into t2 values ('2006-01-25'); -insert into t3 values ('2006-02-03'); -insert into t3 values ('2006-01-17'); -insert into t3 values ('2006-01-25'); -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; -select to_days(col1)-to_days('2006-01-01') from t1 order by col1; -to_days(col1)-to_days('2006-01-01') -16 -33 -select * from t1 order by col1; -col1 -2006-01-17 -2006-02-03 -select * from t2 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-03 -select * from t3 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-03 -select * from t4 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t6 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -update t1 set col1='2006-02-06' where col1='2006-02-03'; -update t2 set col1='2006-02-06' where col1='2006-02-03'; -update t3 set col1='2006-02-06' where col1='2006-02-03'; -update t4 set col1='2006-02-06' where col1='2006-02-03'; -update t5 set col1='2006-02-06' where col1='2006-02-03'; -update t6 set col1='2006-02-06' where col1='2006-02-03'; -select * from t1 order by col1; -col1 -2006-01-17 -2006-02-06 -select * from t2 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t3 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t4 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t6 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -------------------------------------------------------------------------- ---- Alter tables with to_days(col1)-to_days('2006-01-01') -------------------------------------------------------------------------- -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -create table t11 engine='INNODB' as select * from t1; -create table t22 engine='INNODB' as select * from t2; -create table t33 engine='INNODB' as select * from t3; -create table t44 engine='INNODB' as select * from t4; -create table t55 engine='INNODB' as select * from t5; -create table t66 engine='INNODB' as select * from t6; -alter table t11 -partition by range(to_days(col1)-to_days('2006-01-01')) -(partition p0 values less than (15), -partition p1 values less than maxvalue); -alter table t22 -partition by list(to_days(col1)-to_days('2006-01-01')) -(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -alter table t33 -partition by hash(to_days(col1)-to_days('2006-01-01')); -alter table t44 -partition by range(colint) -subpartition by hash(to_days(col1)-to_days('2006-01-01')) subpartitions 2 -(partition p0 values less than (15), -partition p1 values less than maxvalue); -alter table t55 -partition by list(colint) -subpartition by hash(to_days(col1)-to_days('2006-01-01')) subpartitions 2 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -alter table t66 -partition by range(colint) -(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')), -partition p1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-01-17 -2006-02-06 -select * from t22 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t33 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t44 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t55 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 ---------------------------- ----- some alter table begin ---------------------------- -alter table t11 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-01-17 -2006-02-06 -alter table t11 -reorganize partition s1 into -(partition p0 values less than (15), -partition p1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-01-17 -2006-02-06 -alter table t55 -partition by list(colint) -subpartition by hash(to_days(col1)-to_days('2006-01-01')) subpartitions 5 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -show create table t55; -Table Create Table -t55 CREATE TABLE `t55` ( - `colint` int(11) DEFAULT NULL, - `col1` date DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (to_days(col1)-to_days('2006-01-01')) -SUBPARTITIONS 5 -(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB, - PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB, - PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB, - PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB, - PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB, - PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */ -select * from t55 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with to_days(col1)-to_days('2006-01-01') -------------------------------------------------------------------------- -delete from t1 where col1='2006-01-17'; -delete from t2 where col1='2006-01-17'; -delete from t3 where col1='2006-01-17'; -delete from t4 where col1='2006-01-17'; -delete from t5 where col1='2006-01-17'; -delete from t6 where col1='2006-01-17'; -select * from t1 order by col1; -col1 -2006-02-06 -select * from t2 order by col1; -col1 -2006-01-25 -2006-02-06 -select * from t3 order by col1; -col1 -2006-01-25 -2006-02-06 -select * from t4 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -insert into t1 values ('2006-01-17'); -insert into t2 values ('2006-01-17'); -insert into t3 values ('2006-01-17'); -insert into t4 values (60,'2006-01-17'); -insert into t5 values (60,'2006-01-17'); -insert into t6 values (60,'2006-01-17'); -select * from t1 order by col1; -col1 -2006-01-17 -2006-02-06 -select * from t2 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t3 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t4 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 -select * from t5 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 -select * from t6 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 -alter table t1 drop partition p0; -alter table t2 drop partition p0; -alter table t4 drop partition p0; -alter table t5 drop partition p0; -alter table t6 drop partition p0; -select * from t1 order by col1; -col1 -2006-01-17 -2006-02-06 -select * from t2 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t3 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t4 order by colint; -colint col1 -60 2006-01-17 -select * from t5 order by colint; -colint col1 -60 2006-01-17 -select * from t6 order by colint; -colint col1 -60 2006-01-17 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with to_days(col1)-to_days('2006-01-01') -------------------------------------------------------------------------- -delete from t11 where col1='2006-01-17'; -delete from t22 where col1='2006-01-17'; -delete from t33 where col1='2006-01-17'; -delete from t44 where col1='2006-01-17'; -delete from t55 where col1='2006-01-17'; -delete from t66 where col1='2006-01-17'; -select * from t11 order by col1; -col1 -2006-02-06 -select * from t22 order by col1; -col1 -2006-01-25 -2006-02-06 -select * from t33 order by col1; -col1 -2006-01-25 -2006-02-06 -select * from t44 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -select * from t55 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -insert into t11 values ('2006-01-17'); -insert into t22 values ('2006-01-17'); -insert into t33 values ('2006-01-17'); -insert into t44 values (60,'2006-01-17'); -insert into t55 values (60,'2006-01-17'); -insert into t66 values (60,'2006-01-17'); -select * from t11 order by col1; -col1 -2006-01-17 -2006-02-06 -select * from t22 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t33 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t44 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 -select * from t55 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 -select * from t66 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 -alter table t11 drop partition p0; -alter table t22 drop partition p0; -alter table t44 drop partition p0; -alter table t55 drop partition p0; -alter table t66 drop partition p0; -select * from t11 order by col1; -col1 -2006-01-17 -2006-02-06 -select * from t22 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t33 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t44 order by colint; -colint col1 -60 2006-01-17 -select * from t55 order by colint; -colint col1 -60 2006-01-17 -select * from t66 order by colint; -colint col1 -60 2006-01-17 -------------------------- ----- some alter table end -------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -------------------------------------------------------------------------- ---- datediff(col1, '2006-01-01') in partition with coltype date -------------------------------------------------------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -------------------------------------------------------------------------- ---- Create tables with datediff(col1, '2006-01-01') -------------------------------------------------------------------------- -create table t1 (col1 date) engine='INNODB' -partition by range(datediff(col1, '2006-01-01')) -(partition p0 values less than (15), -partition p1 values less than maxvalue); -create table t2 (col1 date) engine='INNODB' -partition by list(datediff(col1, '2006-01-01')) -(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -create table t3 (col1 date) engine='INNODB' -partition by hash(datediff(col1, '2006-01-01')); -create table t4 (colint int, col1 date) engine='INNODB' -partition by range(colint) -subpartition by hash(datediff(col1, '2006-01-01')) subpartitions 2 -(partition p0 values less than (15), -partition p1 values less than maxvalue); -create table t5 (colint int, col1 date) engine='INNODB' -partition by list(colint) -subpartition by hash(datediff(col1, '2006-01-01')) subpartitions 2 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -create table t6 (colint int, col1 date) engine='INNODB' -partition by range(colint) -(partition p0 values less than (datediff('2006-02-02', '2006-01-01')), -partition p1 values less than maxvalue); -------------------------------------------------------------------------- ---- Access tables with datediff(col1, '2006-01-01') -------------------------------------------------------------------------- -insert into t1 values ('2006-02-03'); -insert into t1 values ('2006-01-17'); -insert into t2 values ('2006-02-03'); -insert into t2 values ('2006-01-17'); -insert into t2 values ('2006-01-25'); -insert into t3 values ('2006-02-03'); -insert into t3 values ('2006-01-17'); -insert into t3 values ('2006-01-25'); -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; -select datediff(col1, '2006-01-01') from t1 order by col1; -datediff(col1, '2006-01-01') -16 -33 -select * from t1 order by col1; -col1 -2006-01-17 -2006-02-03 -select * from t2 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-03 -select * from t3 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-03 -select * from t4 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t6 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -update t1 set col1='2006-02-06' where col1='2006-02-03'; -update t2 set col1='2006-02-06' where col1='2006-02-03'; -update t3 set col1='2006-02-06' where col1='2006-02-03'; -update t4 set col1='2006-02-06' where col1='2006-02-03'; -update t5 set col1='2006-02-06' where col1='2006-02-03'; -update t6 set col1='2006-02-06' where col1='2006-02-03'; -select * from t1 order by col1; -col1 -2006-01-17 -2006-02-06 -select * from t2 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t3 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t4 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t6 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -------------------------------------------------------------------------- ---- Alter tables with datediff(col1, '2006-01-01') -------------------------------------------------------------------------- -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -create table t11 engine='INNODB' as select * from t1; -create table t22 engine='INNODB' as select * from t2; -create table t33 engine='INNODB' as select * from t3; -create table t44 engine='INNODB' as select * from t4; -create table t55 engine='INNODB' as select * from t5; -create table t66 engine='INNODB' as select * from t6; -alter table t11 -partition by range(datediff(col1, '2006-01-01')) -(partition p0 values less than (15), -partition p1 values less than maxvalue); -alter table t22 -partition by list(datediff(col1, '2006-01-01')) -(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -alter table t33 -partition by hash(datediff(col1, '2006-01-01')); -alter table t44 -partition by range(colint) -subpartition by hash(datediff(col1, '2006-01-01')) subpartitions 2 -(partition p0 values less than (15), -partition p1 values less than maxvalue); -alter table t55 -partition by list(colint) -subpartition by hash(datediff(col1, '2006-01-01')) subpartitions 2 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -alter table t66 -partition by range(colint) -(partition p0 values less than (datediff('2006-02-02', '2006-01-01')), -partition p1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-01-17 -2006-02-06 -select * from t22 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t33 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t44 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t55 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 ---------------------------- ----- some alter table begin ---------------------------- -alter table t11 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-01-17 -2006-02-06 -alter table t11 -reorganize partition s1 into -(partition p0 values less than (15), -partition p1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-01-17 -2006-02-06 -alter table t55 -partition by list(colint) -subpartition by hash(datediff(col1, '2006-01-01')) subpartitions 5 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -show create table t55; -Table Create Table -t55 CREATE TABLE `t55` ( - `colint` int(11) DEFAULT NULL, - `col1` date DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (datediff(col1, '2006-01-01')) -SUBPARTITIONS 5 -(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = InnoDB, - PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = InnoDB, - PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = InnoDB, - PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = InnoDB, - PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = InnoDB, - PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = InnoDB) */ -select * from t55 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (datediff('2006-02-02', '2006-01-01')), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (datediff('2006-02-02', '2006-01-01')), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with datediff(col1, '2006-01-01') +--- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20) ------------------------------------------------------------------------- -delete from t1 where col1='2006-01-17'; -delete from t2 where col1='2006-01-17'; -delete from t3 where col1='2006-01-17'; -delete from t4 where col1='2006-01-17'; -delete from t5 where col1='2006-01-17'; -delete from t6 where col1='2006-01-17'; +delete from t1 where col1='14:30:45'; +delete from t2 where col1='14:30:45'; +delete from t3 where col1='14:30:45'; +delete from t4 where col1='14:30:45'; +delete from t5 where col1='14:30:45'; +delete from t6 where col1='14:30:45'; select * from t1 order by col1; col1 -2006-02-06 +10:33:11 select * from t2 order by col1; col1 -2006-01-25 -2006-02-06 +10:33:11 +21:59:22 select * from t3 order by col1; col1 -2006-01-25 -2006-02-06 +10:33:11 +21:59:22 select * from t4 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t5 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -insert into t1 values ('2006-01-17'); -insert into t2 values ('2006-01-17'); -insert into t3 values ('2006-01-17'); -insert into t4 values (60,'2006-01-17'); -insert into t5 values (60,'2006-01-17'); -insert into t6 values (60,'2006-01-17'); +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +insert into t1 values ('14:30:45'); +insert into t2 values ('14:30:45'); +insert into t3 values ('14:30:45'); +insert into t4 values (60,'14:30:45'); +insert into t5 values (60,'14:30:45'); +insert into t6 values (60,'14:30:45'); select * from t1 order by col1; col1 -2006-01-17 -2006-02-06 +10:33:11 +14:30:45 select * from t2 order by col1; col1 -2006-01-17 -2006-01-25 -2006-02-06 +10:33:11 +14:30:45 +21:59:22 select * from t3 order by col1; col1 -2006-01-17 -2006-01-25 -2006-02-06 +10:33:11 +14:30:45 +21:59:22 select * from t4 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 select * from t5 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 select * from t6 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 alter table t1 drop partition p0; alter table t2 drop partition p0; alter table t4 drop partition p0; @@ -11434,95 +9387,99 @@ alter table t5 drop partition p0; alter table t6 drop partition p0; select * from t1 order by col1; col1 -2006-01-17 -2006-02-06 +10:33:11 +14:30:45 select * from t2 order by col1; col1 -2006-01-17 -2006-01-25 -2006-02-06 +10:33:11 +14:30:45 +21:59:22 select * from t3 order by col1; col1 -2006-01-17 -2006-01-25 -2006-02-06 +10:33:11 +14:30:45 +21:59:22 select * from t4 order by colint; colint col1 -60 2006-01-17 +60 14:30:45 select * from t5 order by colint; colint col1 -60 2006-01-17 +60 14:30:45 select * from t6 order by colint; colint col1 -60 2006-01-17 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with datediff(col1, '2006-01-01') +--- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20) ------------------------------------------------------------------------- -delete from t11 where col1='2006-01-17'; -delete from t22 where col1='2006-01-17'; -delete from t33 where col1='2006-01-17'; -delete from t44 where col1='2006-01-17'; -delete from t55 where col1='2006-01-17'; -delete from t66 where col1='2006-01-17'; +delete from t11 where col1='14:30:45'; +delete from t22 where col1='14:30:45'; +delete from t33 where col1='14:30:45'; +delete from t44 where col1='14:30:45'; +delete from t55 where col1='14:30:45'; +delete from t66 where col1='14:30:45'; select * from t11 order by col1; col1 -2006-02-06 +10:33:11 select * from t22 order by col1; col1 -2006-01-25 -2006-02-06 +10:33:11 +21:59:22 select * from t33 order by col1; col1 -2006-01-25 -2006-02-06 +10:33:11 +21:59:22 select * from t44 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t55 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -insert into t11 values ('2006-01-17'); -insert into t22 values ('2006-01-17'); -insert into t33 values ('2006-01-17'); -insert into t44 values (60,'2006-01-17'); -insert into t55 values (60,'2006-01-17'); -insert into t66 values (60,'2006-01-17'); +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +insert into t11 values ('14:30:45'); +insert into t22 values ('14:30:45'); +insert into t33 values ('14:30:45'); +insert into t44 values (60,'14:30:45'); +insert into t55 values (60,'14:30:45'); +insert into t66 values (60,'14:30:45'); select * from t11 order by col1; col1 -2006-01-17 -2006-02-06 +10:33:11 +14:30:45 select * from t22 order by col1; col1 -2006-01-17 -2006-01-25 -2006-02-06 +10:33:11 +14:30:45 +21:59:22 select * from t33 order by col1; col1 -2006-01-17 -2006-01-25 -2006-02-06 +10:33:11 +14:30:45 +21:59:22 select * from t44 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 select * from t55 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 select * from t66 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 alter table t11 drop partition p0; alter table t22 drop partition p0; alter table t44 drop partition p0; @@ -11530,27 +9487,26 @@ alter table t55 drop partition p0; alter table t66 drop partition p0; select * from t11 order by col1; col1 -2006-01-17 -2006-02-06 +10:33:11 +14:30:45 select * from t22 order by col1; col1 -2006-01-17 -2006-01-25 -2006-02-06 +10:33:11 +14:30:45 +21:59:22 select * from t33 order by col1; col1 -2006-01-17 -2006-01-25 -2006-02-06 +10:33:11 +14:30:45 +21:59:22 select * from t44 order by colint; colint col1 -60 2006-01-17 +60 14:30:45 select * from t55 order by colint; colint col1 -60 2006-01-17 +60 14:30:45 select * from t66 order by colint; colint col1 -60 2006-01-17 ------------------------- ---- some alter table end ------------------------- diff --git a/mysql-test/suite/parts/r/part_supported_sql_func_myisam.result b/mysql-test/suite/parts/r/part_supported_sql_func_myisam.result index 375a6e130be..3cd8e10a4f3 100644 --- a/mysql-test/suite/parts/r/part_supported_sql_func_myisam.result +++ b/mysql-test/suite/parts/r/part_supported_sql_func_myisam.result @@ -5425,7 +5425,7 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- dayofyear(col1) in partition with coltype char(30) +--- extract(month from col1) in partition with coltype date ------------------------------------------------------------------------- drop table if exists t1 ; drop table if exists t2 ; @@ -5434,14 +5434,14 @@ drop table if exists t4 ; drop table if exists t5 ; drop table if exists t6 ; ------------------------------------------------------------------------- ---- Create tables with dayofyear(col1) +--- Create tables with extract(month from col1) ------------------------------------------------------------------------- -create table t1 (col1 char(30)) engine='MYISAM' -partition by range(dayofyear(col1)) +create table t1 (col1 date) engine='MYISAM' +partition by range(extract(month from col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t2 (col1 char(30)) engine='MYISAM' -partition by list(dayofyear(col1)) +create table t2 (col1 date) engine='MYISAM' +partition by list(extract(month from col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -5449,16 +5449,16 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t3 (col1 char(30)) engine='MYISAM' -partition by hash(dayofyear(col1)); -create table t4 (colint int, col1 char(30)) engine='MYISAM' +create table t3 (col1 date) engine='MYISAM' +partition by hash(extract(month from col1)); +create table t4 (colint int, col1 date) engine='MYISAM' partition by range(colint) -subpartition by hash(dayofyear(col1)) subpartitions 2 +subpartition by hash(extract(month from col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t5 (colint int, col1 char(30)) engine='MYISAM' +create table t5 (colint int, col1 date) engine='MYISAM' partition by list(colint) -subpartition by hash(dayofyear(col1)) subpartitions 2 +subpartition by hash(extract(month from col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -5466,42 +5466,42 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t6 (colint int, col1 char(30)) engine='MYISAM' +create table t6 (colint int, col1 date) engine='MYISAM' partition by range(colint) -(partition p0 values less than (dayofyear('2006-12-25')), +(partition p0 values less than (extract(year from '1998-11-23')), partition p1 values less than maxvalue); ------------------------------------------------------------------------- ---- Access tables with dayofyear(col1) +--- Access tables with extract(month from col1) ------------------------------------------------------------------------- insert into t1 values ('2006-01-03'); -insert into t1 values ('2006-01-17'); +insert into t1 values ('2006-02-17'); insert into t2 values ('2006-01-03'); -insert into t2 values ('2006-01-17'); -insert into t2 values ('2006-02-25'); +insert into t2 values ('2006-02-17'); +insert into t2 values ('2006-01-25'); insert into t3 values ('2006-01-03'); -insert into t3 values ('2006-01-17'); -insert into t3 values ('2006-02-25'); +insert into t3 values ('2006-02-17'); +insert into t3 values ('2006-01-25'); load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; -select dayofyear(col1) from t1 order by col1; -dayofyear(col1) -3 -17 +select extract(month from col1) from t1 order by col1; +extract(month from col1) +1 +2 select * from t1 order by col1; col1 2006-01-03 -2006-01-17 +2006-02-17 select * from t2 order by col1; col1 2006-01-03 -2006-01-17 -2006-02-25 +2006-01-25 +2006-02-17 select * from t3 order by col1; col1 2006-01-03 -2006-01-17 -2006-02-25 +2006-01-25 +2006-02-17 select * from t4 order by colint; colint col1 1 2006-02-03 @@ -5528,18 +5528,18 @@ update t5 set col1='2006-02-05' where col1='2006-01-03'; update t6 set col1='2006-02-05' where col1='2006-01-03'; select * from t1 order by col1; col1 -2006-01-17 2006-02-05 +2006-02-17 select * from t2 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t3 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t4 order by colint; colint col1 1 2006-02-03 @@ -5559,7 +5559,7 @@ colint col1 3 2006-01-25 4 2006-02-05 ------------------------------------------------------------------------- ---- Alter tables with dayofyear(col1) +--- Alter tables with extract(month from col1) ------------------------------------------------------------------------- drop table if exists t11 ; drop table if exists t22 ; @@ -5574,11 +5574,11 @@ create table t44 engine='MYISAM' as select * from t4; create table t55 engine='MYISAM' as select * from t5; create table t66 engine='MYISAM' as select * from t6; alter table t11 -partition by range(dayofyear(col1)) +partition by range(extract(month from col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t22 -partition by list(dayofyear(col1)) +partition by list(extract(month from col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -5587,15 +5587,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t33 -partition by hash(dayofyear(col1)); +partition by hash(extract(month from col1)); alter table t44 partition by range(colint) -subpartition by hash(dayofyear(col1)) subpartitions 2 +subpartition by hash(extract(month from col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t55 partition by list(colint) -subpartition by hash(dayofyear(col1)) subpartitions 2 +subpartition by hash(extract(month from col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -5605,22 +5605,22 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t66 partition by range(colint) -(partition p0 values less than (dayofyear('2006-12-25')), +(partition p0 values less than (extract(year from '1998-11-23')), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -2006-01-17 2006-02-05 +2006-02-17 select * from t22 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t33 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t44 order by colint; colint col1 1 2006-02-03 @@ -5647,19 +5647,19 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t11 order by col1; col1 -2006-01-17 2006-02-05 +2006-02-17 alter table t11 reorganize partition s1 into (partition p0 values less than (15), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -2006-01-17 2006-02-05 +2006-02-17 alter table t55 partition by list(colint) -subpartition by hash(dayofyear(col1)) subpartitions 5 +subpartition by hash(extract(month from col1)) subpartitions 5 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -5671,10 +5671,10 @@ show create table t55; Table Create Table t55 CREATE TABLE `t55` ( `colint` int(11) DEFAULT NULL, - `col1` char(30) DEFAULT NULL + `col1` date DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (dayofyear(col1)) +SUBPARTITION BY HASH (extract(month from col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = MyISAM, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = MyISAM, @@ -5699,7 +5699,7 @@ colint col1 4 2006-02-05 alter table t66 reorganize partition s1 into -(partition p0 values less than (dayofyear('2006-12-25')), +(partition p0 values less than (extract(year from '1998-11-23')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 @@ -5718,7 +5718,7 @@ colint col1 4 2006-02-05 alter table t66 reorganize partition s1 into -(partition p0 values less than (dayofyear('2006-12-25')), +(partition p0 values less than (extract(year from '1998-11-23')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 @@ -5727,73 +5727,78 @@ colint col1 3 2006-01-25 4 2006-02-05 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with dayofyear(col1) +--- Delete rows and partitions of tables with extract(month from col1) ------------------------------------------------------------------------- -delete from t1 where col1='2006-01-17'; -delete from t2 where col1='2006-01-17'; -delete from t3 where col1='2006-01-17'; -delete from t4 where col1='2006-01-17'; -delete from t5 where col1='2006-01-17'; -delete from t6 where col1='2006-01-17'; +delete from t1 where col1='2006-02-17'; +delete from t2 where col1='2006-02-17'; +delete from t3 where col1='2006-02-17'; +delete from t4 where col1='2006-02-17'; +delete from t5 where col1='2006-02-17'; +delete from t6 where col1='2006-02-17'; select * from t1 order by col1; col1 2006-02-05 select * from t2 order by col1; col1 +2006-01-25 2006-02-05 -2006-02-25 select * from t3 order by col1; col1 +2006-01-25 2006-02-05 -2006-02-25 select * from t4 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 select * from t5 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 -insert into t1 values ('2006-01-17'); -insert into t2 values ('2006-01-17'); -insert into t3 values ('2006-01-17'); -insert into t4 values (60,'2006-01-17'); -insert into t5 values (60,'2006-01-17'); -insert into t6 values (60,'2006-01-17'); +insert into t1 values ('2006-02-17'); +insert into t2 values ('2006-02-17'); +insert into t3 values ('2006-02-17'); +insert into t4 values (60,'2006-02-17'); +insert into t5 values (60,'2006-02-17'); +insert into t6 values (60,'2006-02-17'); select * from t1 order by col1; col1 -2006-01-17 2006-02-05 +2006-02-17 select * from t2 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t3 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t4 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 -60 2006-01-17 +60 2006-02-17 select * from t5 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 -60 2006-01-17 +60 2006-02-17 select * from t6 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 -60 2006-01-17 +60 2006-02-17 alter table t1 drop partition p0; alter table t2 drop partition p0; alter table t4 drop partition p0; @@ -5801,94 +5806,94 @@ alter table t5 drop partition p0; alter table t6 drop partition p0; select * from t1 order by col1; col1 -2006-01-17 -2006-02-05 select * from t2 order by col1; col1 -2006-01-17 -2006-02-05 -2006-02-25 select * from t3 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t4 order by colint; colint col1 -60 2006-01-17 +60 2006-02-17 select * from t5 order by colint; colint col1 -60 2006-01-17 +60 2006-02-17 select * from t6 order by colint; colint col1 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with dayofyear(col1) +--- Delete rows and partitions of tables with extract(month from col1) ------------------------------------------------------------------------- -delete from t11 where col1='2006-01-17'; -delete from t22 where col1='2006-01-17'; -delete from t33 where col1='2006-01-17'; -delete from t44 where col1='2006-01-17'; -delete from t55 where col1='2006-01-17'; -delete from t66 where col1='2006-01-17'; +delete from t11 where col1='2006-02-17'; +delete from t22 where col1='2006-02-17'; +delete from t33 where col1='2006-02-17'; +delete from t44 where col1='2006-02-17'; +delete from t55 where col1='2006-02-17'; +delete from t66 where col1='2006-02-17'; select * from t11 order by col1; col1 2006-02-05 select * from t22 order by col1; col1 +2006-01-25 2006-02-05 -2006-02-25 select * from t33 order by col1; col1 +2006-01-25 2006-02-05 -2006-02-25 select * from t44 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 select * from t55 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 -insert into t11 values ('2006-01-17'); -insert into t22 values ('2006-01-17'); -insert into t33 values ('2006-01-17'); -insert into t44 values (60,'2006-01-17'); -insert into t55 values (60,'2006-01-17'); -insert into t66 values (60,'2006-01-17'); +insert into t11 values ('2006-02-17'); +insert into t22 values ('2006-02-17'); +insert into t33 values ('2006-02-17'); +insert into t44 values (60,'2006-02-17'); +insert into t55 values (60,'2006-02-17'); +insert into t66 values (60,'2006-02-17'); select * from t11 order by col1; col1 -2006-01-17 2006-02-05 +2006-02-17 select * from t22 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t33 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t44 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 -60 2006-01-17 +60 2006-02-17 select * from t55 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 -60 2006-01-17 +60 2006-02-17 select * from t66 order by colint; colint col1 1 2006-02-03 +2 2006-01-17 3 2006-01-25 4 2006-02-05 -60 2006-01-17 +60 2006-02-17 alter table t11 drop partition p0; alter table t22 drop partition p0; alter table t44 drop partition p0; @@ -5896,24 +5901,19 @@ alter table t55 drop partition p0; alter table t66 drop partition p0; select * from t11 order by col1; col1 -2006-01-17 -2006-02-05 select * from t22 order by col1; col1 -2006-01-17 -2006-02-05 -2006-02-25 select * from t33 order by col1; col1 -2006-01-17 +2006-01-25 2006-02-05 -2006-02-25 +2006-02-17 select * from t44 order by colint; colint col1 -60 2006-01-17 +60 2006-02-17 select * from t55 order by colint; colint col1 -60 2006-01-17 +60 2006-02-17 select * from t66 order by colint; colint col1 ------------------------- @@ -5932,7 +5932,7 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- extract(month from col1) in partition with coltype date +--- hour(col1) in partition with coltype time ------------------------------------------------------------------------- drop table if exists t1 ; drop table if exists t2 ; @@ -5941,14 +5941,14 @@ drop table if exists t4 ; drop table if exists t5 ; drop table if exists t6 ; ------------------------------------------------------------------------- ---- Create tables with extract(month from col1) +--- Create tables with hour(col1) ------------------------------------------------------------------------- -create table t1 (col1 date) engine='MYISAM' -partition by range(extract(month from col1)) +create table t1 (col1 time) engine='MYISAM' +partition by range(hour(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t2 (col1 date) engine='MYISAM' -partition by list(extract(month from col1)) +create table t2 (col1 time) engine='MYISAM' +partition by list(hour(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -5956,16 +5956,16 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t3 (col1 date) engine='MYISAM' -partition by hash(extract(month from col1)); -create table t4 (colint int, col1 date) engine='MYISAM' +create table t3 (col1 time) engine='MYISAM' +partition by hash(hour(col1)); +create table t4 (colint int, col1 time) engine='MYISAM' partition by range(colint) -subpartition by hash(extract(month from col1)) subpartitions 2 +subpartition by hash(hour(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t5 (colint int, col1 date) engine='MYISAM' +create table t5 (colint int, col1 time) engine='MYISAM' partition by list(colint) -subpartition by hash(extract(month from col1)) subpartitions 2 +subpartition by hash(hour(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -5973,100 +5973,100 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t6 (colint int, col1 date) engine='MYISAM' +create table t6 (colint int, col1 time) engine='MYISAM' partition by range(colint) -(partition p0 values less than (extract(year from '1998-11-23')), +(partition p0 values less than (hour('18:30')), partition p1 values less than maxvalue); ------------------------------------------------------------------------- ---- Access tables with extract(month from col1) +--- Access tables with hour(col1) ------------------------------------------------------------------------- -insert into t1 values ('2006-01-03'); -insert into t1 values ('2006-02-17'); -insert into t2 values ('2006-01-03'); -insert into t2 values ('2006-02-17'); -insert into t2 values ('2006-01-25'); -insert into t3 values ('2006-01-03'); -insert into t3 values ('2006-02-17'); -insert into t3 values ('2006-01-25'); -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; -select extract(month from col1) from t1 order by col1; -extract(month from col1) -1 -2 +insert into t1 values ('09:09'); +insert into t1 values ('14:30'); +insert into t2 values ('09:09'); +insert into t2 values ('14:30'); +insert into t2 values ('21:59'); +insert into t3 values ('09:09'); +insert into t3 values ('14:30'); +insert into t3 values ('21:59'); +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; +select hour(col1) from t1 order by col1; +hour(col1) +9 +14 select * from t1 order by col1; col1 -2006-01-03 -2006-02-17 +09:09:00 +14:30:00 select * from t2 order by col1; col1 -2006-01-03 -2006-01-25 -2006-02-17 +09:09:00 +14:30:00 +21:59:00 select * from t3 order by col1; col1 -2006-01-03 -2006-01-25 -2006-02-17 +09:09:00 +14:30:00 +21:59:00 select * from t4 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t5 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t6 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -update t1 set col1='2006-02-05' where col1='2006-01-03'; -update t2 set col1='2006-02-05' where col1='2006-01-03'; -update t3 set col1='2006-02-05' where col1='2006-01-03'; -update t4 set col1='2006-02-05' where col1='2006-01-03'; -update t5 set col1='2006-02-05' where col1='2006-01-03'; -update t6 set col1='2006-02-05' where col1='2006-01-03'; +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +update t1 set col1='10:30' where col1='09:09'; +update t2 set col1='10:30' where col1='09:09'; +update t3 set col1='10:30' where col1='09:09'; +update t4 set col1='10:30' where col1='09:09'; +update t5 set col1='10:30' where col1='09:09'; +update t6 set col1='10:30' where col1='09:09'; select * from t1 order by col1; col1 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 select * from t2 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t3 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t4 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t5 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t6 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 ------------------------------------------------------------------------- ---- Alter tables with extract(month from col1) +--- Alter tables with hour(col1) ------------------------------------------------------------------------- drop table if exists t11 ; drop table if exists t22 ; @@ -6081,11 +6081,11 @@ create table t44 engine='MYISAM' as select * from t4; create table t55 engine='MYISAM' as select * from t5; create table t66 engine='MYISAM' as select * from t6; alter table t11 -partition by range(extract(month from col1)) +partition by range(hour(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t22 -partition by list(extract(month from col1)) +partition by list(hour(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6094,15 +6094,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t33 -partition by hash(extract(month from col1)); +partition by hash(hour(col1)); alter table t44 partition by range(colint) -subpartition by hash(extract(month from col1)) subpartitions 2 +subpartition by hash(hour(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t55 partition by list(colint) -subpartition by hash(extract(month from col1)) subpartitions 2 +subpartition by hash(hour(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6112,40 +6112,40 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t66 partition by range(colint) -(partition p0 values less than (extract(year from '1998-11-23')), +(partition p0 values less than (hour('18:30')), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 select * from t22 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t33 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t44 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t55 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 --------------------------- ---- some alter table begin --------------------------- @@ -6154,19 +6154,19 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t11 order by col1; col1 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 alter table t11 reorganize partition s1 into (partition p0 values less than (15), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 alter table t55 partition by list(colint) -subpartition by hash(extract(month from col1)) subpartitions 5 +subpartition by hash(hour(col1)) subpartitions 5 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6178,10 +6178,10 @@ show create table t55; Table Create Table t55 CREATE TABLE `t55` ( `colint` int(11) DEFAULT NULL, - `col1` date DEFAULT NULL + `col1` time DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (extract(month from col1)) +SUBPARTITION BY HASH (hour(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = MyISAM, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = MyISAM, @@ -6191,121 +6191,121 @@ SUBPARTITIONS 5 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = MyISAM) */ select * from t55 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (extract(year from '1998-11-23')), +(partition p0 values less than (hour('18:30')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (extract(year from '1998-11-23')), +(partition p0 values less than (hour('18:30')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with extract(month from col1) +--- Delete rows and partitions of tables with hour(col1) ------------------------------------------------------------------------- -delete from t1 where col1='2006-02-17'; -delete from t2 where col1='2006-02-17'; -delete from t3 where col1='2006-02-17'; -delete from t4 where col1='2006-02-17'; -delete from t5 where col1='2006-02-17'; -delete from t6 where col1='2006-02-17'; +delete from t1 where col1='14:30'; +delete from t2 where col1='14:30'; +delete from t3 where col1='14:30'; +delete from t4 where col1='14:30'; +delete from t5 where col1='14:30'; +delete from t6 where col1='14:30'; select * from t1 order by col1; col1 -2006-02-05 +10:30:00 select * from t2 order by col1; col1 -2006-01-25 -2006-02-05 +10:30:00 +21:59:00 select * from t3 order by col1; col1 -2006-01-25 -2006-02-05 +10:30:00 +21:59:00 select * from t4 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t5 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -insert into t1 values ('2006-02-17'); -insert into t2 values ('2006-02-17'); -insert into t3 values ('2006-02-17'); -insert into t4 values (60,'2006-02-17'); -insert into t5 values (60,'2006-02-17'); -insert into t6 values (60,'2006-02-17'); +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +insert into t1 values ('14:30'); +insert into t2 values ('14:30'); +insert into t3 values ('14:30'); +insert into t4 values (60,'14:30'); +insert into t5 values (60,'14:30'); +insert into t6 values (60,'14:30'); select * from t1 order by col1; col1 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 select * from t2 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t3 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t4 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-02-17 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:00 select * from t5 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-02-17 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:00 select * from t6 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-02-17 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:00 alter table t1 drop partition p0; alter table t2 drop partition p0; alter table t4 drop partition p0; @@ -6315,92 +6315,95 @@ select * from t1 order by col1; col1 select * from t2 order by col1; col1 +14:30:00 +21:59:00 select * from t3 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t4 order by colint; colint col1 -60 2006-02-17 +60 14:30:00 select * from t5 order by colint; colint col1 -60 2006-02-17 +60 14:30:00 select * from t6 order by colint; colint col1 +60 14:30:00 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with extract(month from col1) +--- Delete rows and partitions of tables with hour(col1) ------------------------------------------------------------------------- -delete from t11 where col1='2006-02-17'; -delete from t22 where col1='2006-02-17'; -delete from t33 where col1='2006-02-17'; -delete from t44 where col1='2006-02-17'; -delete from t55 where col1='2006-02-17'; -delete from t66 where col1='2006-02-17'; +delete from t11 where col1='14:30'; +delete from t22 where col1='14:30'; +delete from t33 where col1='14:30'; +delete from t44 where col1='14:30'; +delete from t55 where col1='14:30'; +delete from t66 where col1='14:30'; select * from t11 order by col1; col1 -2006-02-05 +10:30:00 select * from t22 order by col1; col1 -2006-01-25 -2006-02-05 +10:30:00 +21:59:00 select * from t33 order by col1; col1 -2006-01-25 -2006-02-05 +10:30:00 +21:59:00 select * from t44 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t55 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -insert into t11 values ('2006-02-17'); -insert into t22 values ('2006-02-17'); -insert into t33 values ('2006-02-17'); -insert into t44 values (60,'2006-02-17'); -insert into t55 values (60,'2006-02-17'); -insert into t66 values (60,'2006-02-17'); +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +insert into t11 values ('14:30'); +insert into t22 values ('14:30'); +insert into t33 values ('14:30'); +insert into t44 values (60,'14:30'); +insert into t55 values (60,'14:30'); +insert into t66 values (60,'14:30'); select * from t11 order by col1; col1 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 select * from t22 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t33 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t44 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-02-17 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:00 select * from t55 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-02-17 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:00 select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-02-17 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:00 alter table t11 drop partition p0; alter table t22 drop partition p0; alter table t44 drop partition p0; @@ -6410,19 +6413,22 @@ select * from t11 order by col1; col1 select * from t22 order by col1; col1 +14:30:00 +21:59:00 select * from t33 order by col1; col1 -2006-01-25 -2006-02-05 -2006-02-17 +10:30:00 +14:30:00 +21:59:00 select * from t44 order by colint; colint col1 -60 2006-02-17 +60 14:30:00 select * from t55 order by colint; colint col1 -60 2006-02-17 +60 14:30:00 select * from t66 order by colint; colint col1 +60 14:30:00 ------------------------- ---- some alter table end ------------------------- @@ -6439,7 +6445,7 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- hour(col1) in partition with coltype time +--- microsecond(col1) in partition with coltype time ------------------------------------------------------------------------- drop table if exists t1 ; drop table if exists t2 ; @@ -6448,14 +6454,14 @@ drop table if exists t4 ; drop table if exists t5 ; drop table if exists t6 ; ------------------------------------------------------------------------- ---- Create tables with hour(col1) +--- Create tables with microsecond(col1) ------------------------------------------------------------------------- create table t1 (col1 time) engine='MYISAM' -partition by range(hour(col1)) +partition by range(microsecond(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); create table t2 (col1 time) engine='MYISAM' -partition by list(hour(col1)) +partition by list(microsecond(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6464,15 +6470,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); create table t3 (col1 time) engine='MYISAM' -partition by hash(hour(col1)); +partition by hash(microsecond(col1)); create table t4 (colint int, col1 time) engine='MYISAM' partition by range(colint) -subpartition by hash(hour(col1)) subpartitions 2 +subpartition by hash(microsecond(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); create table t5 (colint int, col1 time) engine='MYISAM' partition by list(colint) -subpartition by hash(hour(col1)) subpartitions 2 +subpartition by hash(microsecond(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6482,41 +6488,41 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); create table t6 (colint int, col1 time) engine='MYISAM' partition by range(colint) -(partition p0 values less than (hour('18:30')), +(partition p0 values less than (microsecond('10:30:10.000010')), partition p1 values less than maxvalue); ------------------------------------------------------------------------- ---- Access tables with hour(col1) +--- Access tables with microsecond(col1) ------------------------------------------------------------------------- -insert into t1 values ('09:09'); -insert into t1 values ('14:30'); -insert into t2 values ('09:09'); -insert into t2 values ('14:30'); -insert into t2 values ('21:59'); -insert into t3 values ('09:09'); -insert into t3 values ('14:30'); -insert into t3 values ('21:59'); +insert into t1 values ('09:09:15.000002'); +insert into t1 values ('04:30:01.000018'); +insert into t2 values ('09:09:15.000002'); +insert into t2 values ('04:30:01.000018'); +insert into t2 values ('00:59:22.000024'); +insert into t3 values ('09:09:15.000002'); +insert into t3 values ('04:30:01.000018'); +insert into t3 values ('00:59:22.000024'); load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; -select hour(col1) from t1 order by col1; -hour(col1) -9 -14 +select microsecond(col1) from t1 order by col1; +microsecond(col1) +0 +0 select * from t1 order by col1; col1 -09:09:00 -14:30:00 +04:30:01 +09:09:15 select * from t2 order by col1; col1 -09:09:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +09:09:15 select * from t3 order by col1; col1 -09:09:00 -14:30:00 -21:59:00 -select * from t4 order by colint; +00:59:22 +04:30:01 +09:09:15 +select * from t4 order by colint; colint col1 1 09:09:15 2 04:30:01 @@ -6534,46 +6540,46 @@ colint col1 2 04:30:01 3 00:59:22 4 05:30:34 -update t1 set col1='10:30' where col1='09:09'; -update t2 set col1='10:30' where col1='09:09'; -update t3 set col1='10:30' where col1='09:09'; -update t4 set col1='10:30' where col1='09:09'; -update t5 set col1='10:30' where col1='09:09'; -update t6 set col1='10:30' where col1='09:09'; +update t1 set col1='05:30:34.000037' where col1='09:09:15.000002'; +update t2 set col1='05:30:34.000037' where col1='09:09:15.000002'; +update t3 set col1='05:30:34.000037' where col1='09:09:15.000002'; +update t4 set col1='05:30:34.000037' where col1='09:09:15.000002'; +update t5 set col1='05:30:34.000037' where col1='09:09:15.000002'; +update t6 set col1='05:30:34.000037' where col1='09:09:15.000002'; select * from t1 order by col1; col1 -10:30:00 -14:30:00 +04:30:01 +05:30:34 select * from t2 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t3 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t4 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 select * from t5 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 select * from t6 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 ------------------------------------------------------------------------- ---- Alter tables with hour(col1) +--- Alter tables with microsecond(col1) ------------------------------------------------------------------------- drop table if exists t11 ; drop table if exists t22 ; @@ -6588,11 +6594,11 @@ create table t44 engine='MYISAM' as select * from t4; create table t55 engine='MYISAM' as select * from t5; create table t66 engine='MYISAM' as select * from t6; alter table t11 -partition by range(hour(col1)) +partition by range(microsecond(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t22 -partition by list(hour(col1)) +partition by list(microsecond(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6601,15 +6607,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t33 -partition by hash(hour(col1)); +partition by hash(microsecond(col1)); alter table t44 partition by range(colint) -subpartition by hash(hour(col1)) subpartitions 2 +subpartition by hash(microsecond(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t55 partition by list(colint) -subpartition by hash(hour(col1)) subpartitions 2 +subpartition by hash(microsecond(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6619,37 +6625,37 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t66 partition by range(colint) -(partition p0 values less than (hour('18:30')), +(partition p0 values less than (microsecond('10:30:10.000010')), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -10:30:00 -14:30:00 +04:30:01 +05:30:34 select * from t22 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t33 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t44 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 select * from t55 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 select * from t66 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 @@ -6661,19 +6667,19 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t11 order by col1; col1 -10:30:00 -14:30:00 +04:30:01 +05:30:34 alter table t11 reorganize partition s1 into (partition p0 values less than (15), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -10:30:00 -14:30:00 +04:30:01 +05:30:34 alter table t55 partition by list(colint) -subpartition by hash(hour(col1)) subpartitions 5 +subpartition by hash(microsecond(col1)) subpartitions 5 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6688,7 +6694,7 @@ t55 CREATE TABLE `t55` ( `col1` time DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (hour(col1)) +SUBPARTITION BY HASH (microsecond(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = MyISAM, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = MyISAM, @@ -6698,7 +6704,7 @@ SUBPARTITIONS 5 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = MyISAM) */ select * from t55 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 @@ -6707,17 +6713,17 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (hour('18:30')), +(partition p0 values less than (microsecond('10:30:10.000010')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 @@ -6726,93 +6732,88 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (hour('18:30')), +(partition p0 values less than (microsecond('10:30:10.000010')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15 +1 05:30:34 2 04:30:01 3 00:59:22 4 05:30:34 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with hour(col1) +--- Delete rows and partitions of tables with microsecond(col1) ------------------------------------------------------------------------- -delete from t1 where col1='14:30'; -delete from t2 where col1='14:30'; -delete from t3 where col1='14:30'; -delete from t4 where col1='14:30'; -delete from t5 where col1='14:30'; -delete from t6 where col1='14:30'; +delete from t1 where col1='04:30:01.000018'; +delete from t2 where col1='04:30:01.000018'; +delete from t3 where col1='04:30:01.000018'; +delete from t4 where col1='04:30:01.000018'; +delete from t5 where col1='04:30:01.000018'; +delete from t6 where col1='04:30:01.000018'; select * from t1 order by col1; col1 -10:30:00 +05:30:34 select * from t2 order by col1; col1 -10:30:00 -21:59:00 +00:59:22 +05:30:34 select * from t3 order by col1; col1 -10:30:00 -21:59:00 +00:59:22 +05:30:34 select * from t4 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 select * from t5 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 -insert into t1 values ('14:30'); -insert into t2 values ('14:30'); -insert into t3 values ('14:30'); -insert into t4 values (60,'14:30'); -insert into t5 values (60,'14:30'); -insert into t6 values (60,'14:30'); +insert into t1 values ('04:30:01.000018'); +insert into t2 values ('04:30:01.000018'); +insert into t3 values ('04:30:01.000018'); +insert into t4 values (60,'04:30:01.000018'); +insert into t5 values (60,'04:30:01.000018'); +insert into t6 values (60,'04:30:01.000018'); select * from t1 order by col1; col1 -10:30:00 -14:30:00 +04:30:01 +05:30:34 select * from t2 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t3 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t4 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 -60 14:30:00 +60 04:30:01 select * from t5 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 -60 14:30:00 +60 04:30:01 select * from t6 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 -60 14:30:00 +60 04:30:01 alter table t1 drop partition p0; alter table t2 drop partition p0; alter table t4 drop partition p0; @@ -6822,95 +6823,88 @@ select * from t1 order by col1; col1 select * from t2 order by col1; col1 -14:30:00 -21:59:00 select * from t3 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t4 order by colint; colint col1 -60 14:30:00 +60 04:30:01 select * from t5 order by colint; colint col1 -60 14:30:00 +60 04:30:01 select * from t6 order by colint; colint col1 -60 14:30:00 +60 04:30:01 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with hour(col1) +--- Delete rows and partitions of tables with microsecond(col1) ------------------------------------------------------------------------- -delete from t11 where col1='14:30'; -delete from t22 where col1='14:30'; -delete from t33 where col1='14:30'; -delete from t44 where col1='14:30'; -delete from t55 where col1='14:30'; -delete from t66 where col1='14:30'; +delete from t11 where col1='04:30:01.000018'; +delete from t22 where col1='04:30:01.000018'; +delete from t33 where col1='04:30:01.000018'; +delete from t44 where col1='04:30:01.000018'; +delete from t55 where col1='04:30:01.000018'; +delete from t66 where col1='04:30:01.000018'; select * from t11 order by col1; col1 -10:30:00 +05:30:34 select * from t22 order by col1; col1 -10:30:00 -21:59:00 +00:59:22 +05:30:34 select * from t33 order by col1; col1 -10:30:00 -21:59:00 +00:59:22 +05:30:34 select * from t44 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 select * from t55 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 -insert into t11 values ('14:30'); -insert into t22 values ('14:30'); -insert into t33 values ('14:30'); -insert into t44 values (60,'14:30'); -insert into t55 values (60,'14:30'); -insert into t66 values (60,'14:30'); +insert into t11 values ('04:30:01.000018'); +insert into t22 values ('04:30:01.000018'); +insert into t33 values ('04:30:01.000018'); +insert into t44 values (60,'04:30:01.000018'); +insert into t55 values (60,'04:30:01.000018'); +insert into t66 values (60,'04:30:01.000018'); select * from t11 order by col1; col1 -10:30:00 -14:30:00 +04:30:01 +05:30:34 select * from t22 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t33 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t44 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 -60 14:30:00 +60 04:30:01 select * from t55 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 -60 14:30:00 +60 04:30:01 select * from t66 order by colint; colint col1 -1 09:09:15 -2 04:30:01 +1 05:30:34 3 00:59:22 4 05:30:34 -60 14:30:00 +60 04:30:01 alter table t11 drop partition p0; alter table t22 drop partition p0; alter table t44 drop partition p0; @@ -6920,22 +6914,20 @@ select * from t11 order by col1; col1 select * from t22 order by col1; col1 -14:30:00 -21:59:00 select * from t33 order by col1; col1 -10:30:00 -14:30:00 -21:59:00 +00:59:22 +04:30:01 +05:30:34 select * from t44 order by colint; colint col1 -60 14:30:00 +60 04:30:01 select * from t55 order by colint; colint col1 -60 14:30:00 +60 04:30:01 select * from t66 order by colint; colint col1 -60 14:30:00 +60 04:30:01 ------------------------- ---- some alter table end ------------------------- @@ -6952,7 +6944,7 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- microsecond(col1) in partition with coltype time +--- minute(col1) in partition with coltype time ------------------------------------------------------------------------- drop table if exists t1 ; drop table if exists t2 ; @@ -6961,14 +6953,14 @@ drop table if exists t4 ; drop table if exists t5 ; drop table if exists t6 ; ------------------------------------------------------------------------- ---- Create tables with microsecond(col1) +--- Create tables with minute(col1) ------------------------------------------------------------------------- create table t1 (col1 time) engine='MYISAM' -partition by range(microsecond(col1)) +partition by range(minute(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); create table t2 (col1 time) engine='MYISAM' -partition by list(microsecond(col1)) +partition by list(minute(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6977,15 +6969,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); create table t3 (col1 time) engine='MYISAM' -partition by hash(microsecond(col1)); +partition by hash(minute(col1)); create table t4 (colint int, col1 time) engine='MYISAM' partition by range(colint) -subpartition by hash(microsecond(col1)) subpartitions 2 +subpartition by hash(minute(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); create table t5 (colint int, col1 time) engine='MYISAM' partition by list(colint) -subpartition by hash(microsecond(col1)) subpartitions 2 +subpartition by hash(minute(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -6995,40 +6987,40 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); create table t6 (colint int, col1 time) engine='MYISAM' partition by range(colint) -(partition p0 values less than (microsecond('10:30:10.000010')), +(partition p0 values less than (minute('18:30')), partition p1 values less than maxvalue); ------------------------------------------------------------------------- ---- Access tables with microsecond(col1) +--- Access tables with minute(col1) ------------------------------------------------------------------------- -insert into t1 values ('09:09:15.000002'); -insert into t1 values ('04:30:01.000018'); -insert into t2 values ('09:09:15.000002'); -insert into t2 values ('04:30:01.000018'); -insert into t2 values ('00:59:22.000024'); -insert into t3 values ('09:09:15.000002'); -insert into t3 values ('04:30:01.000018'); -insert into t3 values ('00:59:22.000024'); +insert into t1 values ('09:09:15'); +insert into t1 values ('14:30:45'); +insert into t2 values ('09:09:15'); +insert into t2 values ('14:30:45'); +insert into t2 values ('21:59:22'); +insert into t3 values ('09:09:15'); +insert into t3 values ('14:30:45'); +insert into t3 values ('21:59:22'); load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; -select microsecond(col1) from t1 order by col1; -microsecond(col1) -0 -0 +select minute(col1) from t1 order by col1; +minute(col1) +9 +30 select * from t1 order by col1; col1 -04:30:01 09:09:15 +14:30:45 select * from t2 order by col1; col1 -00:59:22 -04:30:01 09:09:15 +14:30:45 +21:59:22 select * from t3 order by col1; col1 -00:59:22 -04:30:01 09:09:15 +14:30:45 +21:59:22 select * from t4 order by colint; colint col1 1 09:09:15 @@ -7047,46 +7039,46 @@ colint col1 2 04:30:01 3 00:59:22 4 05:30:34 -update t1 set col1='05:30:34.000037' where col1='09:09:15.000002'; -update t2 set col1='05:30:34.000037' where col1='09:09:15.000002'; -update t3 set col1='05:30:34.000037' where col1='09:09:15.000002'; -update t4 set col1='05:30:34.000037' where col1='09:09:15.000002'; -update t5 set col1='05:30:34.000037' where col1='09:09:15.000002'; -update t6 set col1='05:30:34.000037' where col1='09:09:15.000002'; +update t1 set col1='10:24:23' where col1='09:09:15'; +update t2 set col1='10:24:23' where col1='09:09:15'; +update t3 set col1='10:24:23' where col1='09:09:15'; +update t4 set col1='10:24:23' where col1='09:09:15'; +update t5 set col1='10:24:23' where col1='09:09:15'; +update t6 set col1='10:24:23' where col1='09:09:15'; select * from t1 order by col1; col1 -04:30:01 -05:30:34 +10:24:23 +14:30:45 select * from t2 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t3 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t4 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 select * from t5 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 select * from t6 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 ------------------------------------------------------------------------- ---- Alter tables with microsecond(col1) +--- Alter tables with minute(col1) ------------------------------------------------------------------------- drop table if exists t11 ; drop table if exists t22 ; @@ -7101,11 +7093,11 @@ create table t44 engine='MYISAM' as select * from t4; create table t55 engine='MYISAM' as select * from t5; create table t66 engine='MYISAM' as select * from t6; alter table t11 -partition by range(microsecond(col1)) +partition by range(minute(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t22 -partition by list(microsecond(col1)) +partition by list(minute(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7114,15 +7106,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t33 -partition by hash(microsecond(col1)); +partition by hash(minute(col1)); alter table t44 partition by range(colint) -subpartition by hash(microsecond(col1)) subpartitions 2 +subpartition by hash(minute(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t55 partition by list(colint) -subpartition by hash(microsecond(col1)) subpartitions 2 +subpartition by hash(minute(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7132,37 +7124,37 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t66 partition by range(colint) -(partition p0 values less than (microsecond('10:30:10.000010')), +(partition p0 values less than (minute('18:30')), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -04:30:01 -05:30:34 +10:24:23 +14:30:45 select * from t22 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t33 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t44 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 select * from t55 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 select * from t66 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 @@ -7174,19 +7166,19 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t11 order by col1; col1 -04:30:01 -05:30:34 +10:24:23 +14:30:45 alter table t11 reorganize partition s1 into (partition p0 values less than (15), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -04:30:01 -05:30:34 +10:24:23 +14:30:45 alter table t55 partition by list(colint) -subpartition by hash(microsecond(col1)) subpartitions 5 +subpartition by hash(minute(col1)) subpartitions 5 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7201,7 +7193,7 @@ t55 CREATE TABLE `t55` ( `col1` time DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (microsecond(col1)) +SUBPARTITION BY HASH (minute(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = MyISAM, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = MyISAM, @@ -7211,7 +7203,7 @@ SUBPARTITIONS 5 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = MyISAM) */ select * from t55 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 @@ -7220,17 +7212,17 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (microsecond('10:30:10.000010')), +(partition p0 values less than (minute('18:30')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 @@ -7239,88 +7231,93 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (microsecond('10:30:10.000010')), +(partition p0 values less than (minute('18:30')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 05:30:34 +1 10:24:23 2 04:30:01 3 00:59:22 4 05:30:34 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with microsecond(col1) +--- Delete rows and partitions of tables with minute(col1) ------------------------------------------------------------------------- -delete from t1 where col1='04:30:01.000018'; -delete from t2 where col1='04:30:01.000018'; -delete from t3 where col1='04:30:01.000018'; -delete from t4 where col1='04:30:01.000018'; -delete from t5 where col1='04:30:01.000018'; -delete from t6 where col1='04:30:01.000018'; +delete from t1 where col1='14:30:45'; +delete from t2 where col1='14:30:45'; +delete from t3 where col1='14:30:45'; +delete from t4 where col1='14:30:45'; +delete from t5 where col1='14:30:45'; +delete from t6 where col1='14:30:45'; select * from t1 order by col1; col1 -05:30:34 +10:24:23 select * from t2 order by col1; col1 -00:59:22 -05:30:34 +10:24:23 +21:59:22 select * from t3 order by col1; col1 -00:59:22 -05:30:34 +10:24:23 +21:59:22 select * from t4 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 select * from t5 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 -insert into t1 values ('04:30:01.000018'); -insert into t2 values ('04:30:01.000018'); -insert into t3 values ('04:30:01.000018'); -insert into t4 values (60,'04:30:01.000018'); -insert into t5 values (60,'04:30:01.000018'); -insert into t6 values (60,'04:30:01.000018'); +insert into t1 values ('14:30:45'); +insert into t2 values ('14:30:45'); +insert into t3 values ('14:30:45'); +insert into t4 values (60,'14:30:45'); +insert into t5 values (60,'14:30:45'); +insert into t6 values (60,'14:30:45'); select * from t1 order by col1; col1 -04:30:01 -05:30:34 +10:24:23 +14:30:45 select * from t2 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t3 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t4 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 -60 04:30:01 +60 14:30:45 select * from t5 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 -60 04:30:01 +60 14:30:45 select * from t6 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 -60 04:30:01 +60 14:30:45 alter table t1 drop partition p0; alter table t2 drop partition p0; alter table t4 drop partition p0; @@ -7328,90 +7325,100 @@ alter table t5 drop partition p0; alter table t6 drop partition p0; select * from t1 order by col1; col1 +10:24:23 +14:30:45 select * from t2 order by col1; col1 +10:24:23 +14:30:45 +21:59:22 select * from t3 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t4 order by colint; colint col1 -60 04:30:01 +60 14:30:45 select * from t5 order by colint; colint col1 -60 04:30:01 +60 14:30:45 select * from t6 order by colint; colint col1 -60 04:30:01 +60 14:30:45 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with microsecond(col1) +--- Delete rows and partitions of tables with minute(col1) ------------------------------------------------------------------------- -delete from t11 where col1='04:30:01.000018'; -delete from t22 where col1='04:30:01.000018'; -delete from t33 where col1='04:30:01.000018'; -delete from t44 where col1='04:30:01.000018'; -delete from t55 where col1='04:30:01.000018'; -delete from t66 where col1='04:30:01.000018'; +delete from t11 where col1='14:30:45'; +delete from t22 where col1='14:30:45'; +delete from t33 where col1='14:30:45'; +delete from t44 where col1='14:30:45'; +delete from t55 where col1='14:30:45'; +delete from t66 where col1='14:30:45'; select * from t11 order by col1; col1 -05:30:34 +10:24:23 select * from t22 order by col1; col1 -00:59:22 -05:30:34 +10:24:23 +21:59:22 select * from t33 order by col1; col1 -00:59:22 -05:30:34 +10:24:23 +21:59:22 select * from t44 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 select * from t55 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 -insert into t11 values ('04:30:01.000018'); -insert into t22 values ('04:30:01.000018'); -insert into t33 values ('04:30:01.000018'); -insert into t44 values (60,'04:30:01.000018'); -insert into t55 values (60,'04:30:01.000018'); -insert into t66 values (60,'04:30:01.000018'); +insert into t11 values ('14:30:45'); +insert into t22 values ('14:30:45'); +insert into t33 values ('14:30:45'); +insert into t44 values (60,'14:30:45'); +insert into t55 values (60,'14:30:45'); +insert into t66 values (60,'14:30:45'); select * from t11 order by col1; col1 -04:30:01 -05:30:34 +10:24:23 +14:30:45 select * from t22 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t33 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t44 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 -60 04:30:01 +60 14:30:45 select * from t55 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 -60 04:30:01 +60 14:30:45 select * from t66 order by colint; colint col1 -1 05:30:34 +1 10:24:23 +2 04:30:01 3 00:59:22 4 05:30:34 -60 04:30:01 +60 14:30:45 alter table t11 drop partition p0; alter table t22 drop partition p0; alter table t44 drop partition p0; @@ -7419,22 +7426,27 @@ alter table t55 drop partition p0; alter table t66 drop partition p0; select * from t11 order by col1; col1 +10:24:23 +14:30:45 select * from t22 order by col1; col1 +10:24:23 +14:30:45 +21:59:22 select * from t33 order by col1; col1 -00:59:22 -04:30:01 -05:30:34 +10:24:23 +14:30:45 +21:59:22 select * from t44 order by colint; colint col1 -60 04:30:01 +60 14:30:45 select * from t55 order by colint; colint col1 -60 04:30:01 +60 14:30:45 select * from t66 order by colint; colint col1 -60 04:30:01 +60 14:30:45 ------------------------- ---- some alter table end ------------------------- @@ -7451,7 +7463,7 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- minute(col1) in partition with coltype time +--- second(col1) in partition with coltype time ------------------------------------------------------------------------- drop table if exists t1 ; drop table if exists t2 ; @@ -7460,14 +7472,14 @@ drop table if exists t4 ; drop table if exists t5 ; drop table if exists t6 ; ------------------------------------------------------------------------- ---- Create tables with minute(col1) +--- Create tables with second(col1) ------------------------------------------------------------------------- create table t1 (col1 time) engine='MYISAM' -partition by range(minute(col1)) +partition by range(second(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); create table t2 (col1 time) engine='MYISAM' -partition by list(minute(col1)) +partition by list(second(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7476,15 +7488,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); create table t3 (col1 time) engine='MYISAM' -partition by hash(minute(col1)); +partition by hash(second(col1)); create table t4 (colint int, col1 time) engine='MYISAM' partition by range(colint) -subpartition by hash(minute(col1)) subpartitions 2 +subpartition by hash(second(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); create table t5 (colint int, col1 time) engine='MYISAM' partition by list(colint) -subpartition by hash(minute(col1)) subpartitions 2 +subpartition by hash(second(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7494,39 +7506,39 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); create table t6 (colint int, col1 time) engine='MYISAM' partition by range(colint) -(partition p0 values less than (minute('18:30')), +(partition p0 values less than (second('18:30:14')), partition p1 values less than maxvalue); ------------------------------------------------------------------------- ---- Access tables with minute(col1) +--- Access tables with second(col1) ------------------------------------------------------------------------- -insert into t1 values ('09:09:15'); -insert into t1 values ('14:30:45'); -insert into t2 values ('09:09:15'); -insert into t2 values ('14:30:45'); +insert into t1 values ('09:09:09'); +insert into t1 values ('14:30:20'); +insert into t2 values ('09:09:09'); +insert into t2 values ('14:30:20'); insert into t2 values ('21:59:22'); -insert into t3 values ('09:09:15'); -insert into t3 values ('14:30:45'); +insert into t3 values ('09:09:09'); +insert into t3 values ('14:30:20'); insert into t3 values ('21:59:22'); load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; -select minute(col1) from t1 order by col1; -minute(col1) +select second(col1) from t1 order by col1; +second(col1) 9 -30 +20 select * from t1 order by col1; col1 -09:09:15 -14:30:45 +09:09:09 +14:30:20 select * from t2 order by col1; col1 -09:09:15 -14:30:45 +09:09:09 +14:30:20 21:59:22 select * from t3 order by col1; col1 -09:09:15 -14:30:45 +09:09:09 +14:30:20 21:59:22 select * from t4 order by colint; colint col1 @@ -7546,46 +7558,46 @@ colint col1 2 04:30:01 3 00:59:22 4 05:30:34 -update t1 set col1='10:24:23' where col1='09:09:15'; -update t2 set col1='10:24:23' where col1='09:09:15'; -update t3 set col1='10:24:23' where col1='09:09:15'; -update t4 set col1='10:24:23' where col1='09:09:15'; -update t5 set col1='10:24:23' where col1='09:09:15'; -update t6 set col1='10:24:23' where col1='09:09:15'; +update t1 set col1='10:22:33' where col1='09:09:09'; +update t2 set col1='10:22:33' where col1='09:09:09'; +update t3 set col1='10:22:33' where col1='09:09:09'; +update t4 set col1='10:22:33' where col1='09:09:09'; +update t5 set col1='10:22:33' where col1='09:09:09'; +update t6 set col1='10:22:33' where col1='09:09:09'; select * from t1 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 select * from t2 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t3 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t4 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 select * from t5 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 select * from t6 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 ------------------------------------------------------------------------- ---- Alter tables with minute(col1) +--- Alter tables with second(col1) ------------------------------------------------------------------------- drop table if exists t11 ; drop table if exists t22 ; @@ -7600,11 +7612,11 @@ create table t44 engine='MYISAM' as select * from t4; create table t55 engine='MYISAM' as select * from t5; create table t66 engine='MYISAM' as select * from t6; alter table t11 -partition by range(minute(col1)) +partition by range(second(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t22 -partition by list(minute(col1)) +partition by list(second(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7613,15 +7625,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t33 -partition by hash(minute(col1)); +partition by hash(second(col1)); alter table t44 partition by range(colint) -subpartition by hash(minute(col1)) subpartitions 2 +subpartition by hash(second(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t55 partition by list(colint) -subpartition by hash(minute(col1)) subpartitions 2 +subpartition by hash(second(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7631,37 +7643,37 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t66 partition by range(colint) -(partition p0 values less than (minute('18:30')), +(partition p0 values less than (second('18:30:14')), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 select * from t22 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t33 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t44 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 select * from t55 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 select * from t66 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 @@ -7673,19 +7685,19 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t11 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 alter table t11 reorganize partition s1 into (partition p0 values less than (15), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 alter table t55 partition by list(colint) -subpartition by hash(minute(col1)) subpartitions 5 +subpartition by hash(second(col1)) subpartitions 5 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7700,7 +7712,7 @@ t55 CREATE TABLE `t55` ( `col1` time DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (minute(col1)) +SUBPARTITION BY HASH (second(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = MyISAM, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = MyISAM, @@ -7710,7 +7722,7 @@ SUBPARTITIONS 5 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = MyISAM) */ select * from t55 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 @@ -7719,17 +7731,17 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (minute('18:30')), +(partition p0 values less than (second('18:30:14')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 @@ -7738,93 +7750,93 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (minute('18:30')), +(partition p0 values less than (second('18:30:14')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with minute(col1) +--- Delete rows and partitions of tables with second(col1) ------------------------------------------------------------------------- -delete from t1 where col1='14:30:45'; -delete from t2 where col1='14:30:45'; -delete from t3 where col1='14:30:45'; -delete from t4 where col1='14:30:45'; -delete from t5 where col1='14:30:45'; -delete from t6 where col1='14:30:45'; +delete from t1 where col1='14:30:20'; +delete from t2 where col1='14:30:20'; +delete from t3 where col1='14:30:20'; +delete from t4 where col1='14:30:20'; +delete from t5 where col1='14:30:20'; +delete from t6 where col1='14:30:20'; select * from t1 order by col1; col1 -10:24:23 +10:22:33 select * from t2 order by col1; col1 -10:24:23 +10:22:33 21:59:22 select * from t3 order by col1; col1 -10:24:23 +10:22:33 21:59:22 select * from t4 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 select * from t5 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 -insert into t1 values ('14:30:45'); -insert into t2 values ('14:30:45'); -insert into t3 values ('14:30:45'); -insert into t4 values (60,'14:30:45'); -insert into t5 values (60,'14:30:45'); -insert into t6 values (60,'14:30:45'); +insert into t1 values ('14:30:20'); +insert into t2 values ('14:30:20'); +insert into t3 values ('14:30:20'); +insert into t4 values (60,'14:30:20'); +insert into t5 values (60,'14:30:20'); +insert into t6 values (60,'14:30:20'); select * from t1 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 select * from t2 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t3 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t4 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 -60 14:30:45 +60 14:30:20 select * from t5 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 -60 14:30:45 +60 14:30:20 select * from t6 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 -60 14:30:45 +60 14:30:20 alter table t1 drop partition p0; alter table t2 drop partition p0; alter table t4 drop partition p0; @@ -7832,100 +7844,100 @@ alter table t5 drop partition p0; alter table t6 drop partition p0; select * from t1 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 select * from t2 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t3 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t4 order by colint; colint col1 -60 14:30:45 +60 14:30:20 select * from t5 order by colint; colint col1 -60 14:30:45 +60 14:30:20 select * from t6 order by colint; colint col1 -60 14:30:45 +60 14:30:20 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with minute(col1) +--- Delete rows and partitions of tables with second(col1) ------------------------------------------------------------------------- -delete from t11 where col1='14:30:45'; -delete from t22 where col1='14:30:45'; -delete from t33 where col1='14:30:45'; -delete from t44 where col1='14:30:45'; -delete from t55 where col1='14:30:45'; -delete from t66 where col1='14:30:45'; +delete from t11 where col1='14:30:20'; +delete from t22 where col1='14:30:20'; +delete from t33 where col1='14:30:20'; +delete from t44 where col1='14:30:20'; +delete from t55 where col1='14:30:20'; +delete from t66 where col1='14:30:20'; select * from t11 order by col1; col1 -10:24:23 +10:22:33 select * from t22 order by col1; col1 -10:24:23 +10:22:33 21:59:22 select * from t33 order by col1; col1 -10:24:23 +10:22:33 21:59:22 select * from t44 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 select * from t55 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 -insert into t11 values ('14:30:45'); -insert into t22 values ('14:30:45'); -insert into t33 values ('14:30:45'); -insert into t44 values (60,'14:30:45'); -insert into t55 values (60,'14:30:45'); -insert into t66 values (60,'14:30:45'); +insert into t11 values ('14:30:20'); +insert into t22 values ('14:30:20'); +insert into t33 values ('14:30:20'); +insert into t44 values (60,'14:30:20'); +insert into t55 values (60,'14:30:20'); +insert into t66 values (60,'14:30:20'); select * from t11 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 select * from t22 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t33 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t44 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 -60 14:30:45 +60 14:30:20 select * from t55 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 -60 14:30:45 +60 14:30:20 select * from t66 order by colint; colint col1 -1 10:24:23 +1 09:09:15 2 04:30:01 3 00:59:22 4 05:30:34 -60 14:30:45 +60 14:30:20 alter table t11 drop partition p0; alter table t22 drop partition p0; alter table t44 drop partition p0; @@ -7933,27 +7945,27 @@ alter table t55 drop partition p0; alter table t66 drop partition p0; select * from t11 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 select * from t22 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t33 order by col1; col1 -10:24:23 -14:30:45 +10:22:33 +14:30:20 21:59:22 select * from t44 order by colint; colint col1 -60 14:30:45 +60 14:30:20 select * from t55 order by colint; colint col1 -60 14:30:45 +60 14:30:20 select * from t66 order by colint; colint col1 -60 14:30:45 +60 14:30:20 ------------------------- ---- some alter table end ------------------------- @@ -7970,7 +7982,7 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- second(col1) in partition with coltype time +--- month(col1) in partition with coltype date ------------------------------------------------------------------------- drop table if exists t1 ; drop table if exists t2 ; @@ -7979,14 +7991,14 @@ drop table if exists t4 ; drop table if exists t5 ; drop table if exists t6 ; ------------------------------------------------------------------------- ---- Create tables with second(col1) +--- Create tables with month(col1) ------------------------------------------------------------------------- -create table t1 (col1 time) engine='MYISAM' -partition by range(second(col1)) +create table t1 (col1 date) engine='MYISAM' +partition by range(month(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t2 (col1 time) engine='MYISAM' -partition by list(second(col1)) +create table t2 (col1 date) engine='MYISAM' +partition by list(month(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -7994,16 +8006,16 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t3 (col1 time) engine='MYISAM' -partition by hash(second(col1)); -create table t4 (colint int, col1 time) engine='MYISAM' +create table t3 (col1 date) engine='MYISAM' +partition by hash(month(col1)); +create table t4 (colint int, col1 date) engine='MYISAM' partition by range(colint) -subpartition by hash(second(col1)) subpartitions 2 +subpartition by hash(month(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t5 (colint int, col1 time) engine='MYISAM' +create table t5 (colint int, col1 date) engine='MYISAM' partition by list(colint) -subpartition by hash(second(col1)) subpartitions 2 +subpartition by hash(month(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8011,100 +8023,100 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t6 (colint int, col1 time) engine='MYISAM' +create table t6 (colint int, col1 date) engine='MYISAM' partition by range(colint) -(partition p0 values less than (second('18:30:14')), +(partition p0 values less than (month('2006-10-14')), partition p1 values less than maxvalue); ------------------------------------------------------------------------- ---- Access tables with second(col1) +--- Access tables with month(col1) ------------------------------------------------------------------------- -insert into t1 values ('09:09:09'); -insert into t1 values ('14:30:20'); -insert into t2 values ('09:09:09'); -insert into t2 values ('14:30:20'); -insert into t2 values ('21:59:22'); -insert into t3 values ('09:09:09'); -insert into t3 values ('14:30:20'); -insert into t3 values ('21:59:22'); -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; -select second(col1) from t1 order by col1; -second(col1) -9 -20 +insert into t1 values ('2006-01-03'); +insert into t1 values ('2006-12-17'); +insert into t2 values ('2006-01-03'); +insert into t2 values ('2006-12-17'); +insert into t2 values ('2006-05-25'); +insert into t3 values ('2006-01-03'); +insert into t3 values ('2006-12-17'); +insert into t3 values ('2006-05-25'); +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; +select month(col1) from t1 order by col1; +month(col1) +1 +12 select * from t1 order by col1; col1 -09:09:09 -14:30:20 +2006-01-03 +2006-12-17 select * from t2 order by col1; col1 -09:09:09 -14:30:20 -21:59:22 +2006-01-03 +2006-05-25 +2006-12-17 select * from t3 order by col1; col1 -09:09:09 -14:30:20 -21:59:22 +2006-01-03 +2006-05-25 +2006-12-17 select * from t4 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t5 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t6 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -update t1 set col1='10:22:33' where col1='09:09:09'; -update t2 set col1='10:22:33' where col1='09:09:09'; -update t3 set col1='10:22:33' where col1='09:09:09'; -update t4 set col1='10:22:33' where col1='09:09:09'; -update t5 set col1='10:22:33' where col1='09:09:09'; -update t6 set col1='10:22:33' where col1='09:09:09'; +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +update t1 set col1='2006-11-06' where col1='2006-01-03'; +update t2 set col1='2006-11-06' where col1='2006-01-03'; +update t3 set col1='2006-11-06' where col1='2006-01-03'; +update t4 set col1='2006-11-06' where col1='2006-01-03'; +update t5 set col1='2006-11-06' where col1='2006-01-03'; +update t6 set col1='2006-11-06' where col1='2006-01-03'; select * from t1 order by col1; col1 -10:22:33 -14:30:20 +2006-11-06 +2006-12-17 select * from t2 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t3 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t4 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t5 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t6 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 ------------------------------------------------------------------------- ---- Alter tables with second(col1) +--- Alter tables with month(col1) ------------------------------------------------------------------------- drop table if exists t11 ; drop table if exists t22 ; @@ -8119,11 +8131,11 @@ create table t44 engine='MYISAM' as select * from t4; create table t55 engine='MYISAM' as select * from t5; create table t66 engine='MYISAM' as select * from t6; alter table t11 -partition by range(second(col1)) +partition by range(month(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t22 -partition by list(second(col1)) +partition by list(month(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8132,15 +8144,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t33 -partition by hash(second(col1)); +partition by hash(month(col1)); alter table t44 partition by range(colint) -subpartition by hash(second(col1)) subpartitions 2 +subpartition by hash(month(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t55 partition by list(colint) -subpartition by hash(second(col1)) subpartitions 2 +subpartition by hash(month(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8150,40 +8162,40 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t66 partition by range(colint) -(partition p0 values less than (second('18:30:14')), +(partition p0 values less than (month('2006-10-14')), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -10:22:33 -14:30:20 +2006-11-06 +2006-12-17 select * from t22 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t33 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t44 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t55 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t66 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 --------------------------- ---- some alter table begin --------------------------- @@ -8192,19 +8204,19 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t11 order by col1; col1 -10:22:33 -14:30:20 +2006-11-06 +2006-12-17 alter table t11 reorganize partition s1 into (partition p0 values less than (15), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -10:22:33 -14:30:20 +2006-11-06 +2006-12-17 alter table t55 partition by list(colint) -subpartition by hash(second(col1)) subpartitions 5 +subpartition by hash(month(col1)) subpartitions 5 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8216,10 +8228,10 @@ show create table t55; Table Create Table t55 CREATE TABLE `t55` ( `colint` int(11) DEFAULT NULL, - `col1` time DEFAULT NULL + `col1` date DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (second(col1)) +SUBPARTITION BY HASH (month(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = MyISAM, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = MyISAM, @@ -8229,121 +8241,121 @@ SUBPARTITIONS 5 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = MyISAM) */ select * from t55 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 alter table t66 reorganize partition s1 into -(partition p0 values less than (second('18:30:14')), +(partition p0 values less than (month('2006-10-14')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 alter table t66 reorganize partition s1 into -(partition p0 values less than (second('18:30:14')), +(partition p0 values less than (month('2006-10-14')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with second(col1) +--- Delete rows and partitions of tables with month(col1) ------------------------------------------------------------------------- -delete from t1 where col1='14:30:20'; -delete from t2 where col1='14:30:20'; -delete from t3 where col1='14:30:20'; -delete from t4 where col1='14:30:20'; -delete from t5 where col1='14:30:20'; -delete from t6 where col1='14:30:20'; +delete from t1 where col1='2006-12-17'; +delete from t2 where col1='2006-12-17'; +delete from t3 where col1='2006-12-17'; +delete from t4 where col1='2006-12-17'; +delete from t5 where col1='2006-12-17'; +delete from t6 where col1='2006-12-17'; select * from t1 order by col1; col1 -10:22:33 +2006-11-06 select * from t2 order by col1; col1 -10:22:33 -21:59:22 +2006-05-25 +2006-11-06 select * from t3 order by col1; col1 -10:22:33 -21:59:22 +2006-05-25 +2006-11-06 select * from t4 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t5 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -insert into t1 values ('14:30:20'); -insert into t2 values ('14:30:20'); -insert into t3 values ('14:30:20'); -insert into t4 values (60,'14:30:20'); -insert into t5 values (60,'14:30:20'); -insert into t6 values (60,'14:30:20'); +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +insert into t1 values ('2006-12-17'); +insert into t2 values ('2006-12-17'); +insert into t3 values ('2006-12-17'); +insert into t4 values (60,'2006-12-17'); +insert into t5 values (60,'2006-12-17'); +insert into t6 values (60,'2006-12-17'); select * from t1 order by col1; col1 -10:22:33 -14:30:20 +2006-11-06 +2006-12-17 select * from t2 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t3 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t4 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 select * from t5 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 select * from t6 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 alter table t1 drop partition p0; alter table t2 drop partition p0; alter table t4 drop partition p0; @@ -8351,100 +8363,97 @@ alter table t5 drop partition p0; alter table t6 drop partition p0; select * from t1 order by col1; col1 -10:22:33 -14:30:20 select * from t2 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-11-06 +2006-12-17 select * from t3 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t4 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 select * from t5 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 select * from t6 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with second(col1) +--- Delete rows and partitions of tables with month(col1) ------------------------------------------------------------------------- -delete from t11 where col1='14:30:20'; -delete from t22 where col1='14:30:20'; -delete from t33 where col1='14:30:20'; -delete from t44 where col1='14:30:20'; -delete from t55 where col1='14:30:20'; -delete from t66 where col1='14:30:20'; +delete from t11 where col1='2006-12-17'; +delete from t22 where col1='2006-12-17'; +delete from t33 where col1='2006-12-17'; +delete from t44 where col1='2006-12-17'; +delete from t55 where col1='2006-12-17'; +delete from t66 where col1='2006-12-17'; select * from t11 order by col1; col1 -10:22:33 +2006-11-06 select * from t22 order by col1; col1 -10:22:33 -21:59:22 +2006-05-25 +2006-11-06 select * from t33 order by col1; col1 -10:22:33 -21:59:22 +2006-05-25 +2006-11-06 select * from t44 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t55 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -insert into t11 values ('14:30:20'); -insert into t22 values ('14:30:20'); -insert into t33 values ('14:30:20'); -insert into t44 values (60,'14:30:20'); -insert into t55 values (60,'14:30:20'); -insert into t66 values (60,'14:30:20'); +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +insert into t11 values ('2006-12-17'); +insert into t22 values ('2006-12-17'); +insert into t33 values ('2006-12-17'); +insert into t44 values (60,'2006-12-17'); +insert into t55 values (60,'2006-12-17'); +insert into t66 values (60,'2006-12-17'); select * from t11 order by col1; col1 -10:22:33 -14:30:20 +2006-11-06 +2006-12-17 select * from t22 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t33 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t44 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 select * from t55 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 select * from t66 order by colint; colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 alter table t11 drop partition p0; alter table t22 drop partition p0; alter table t44 drop partition p0; @@ -8452,27 +8461,24 @@ alter table t55 drop partition p0; alter table t66 drop partition p0; select * from t11 order by col1; col1 -10:22:33 -14:30:20 select * from t22 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-11-06 +2006-12-17 select * from t33 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-05-25 +2006-11-06 +2006-12-17 select * from t44 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 select * from t55 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 select * from t66 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 ------------------------- ---- some alter table end ------------------------- @@ -8489,7 +8495,7 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- second(col1) in partition with coltype char(30) +--- quarter(col1) in partition with coltype date ------------------------------------------------------------------------- drop table if exists t1 ; drop table if exists t2 ; @@ -8498,14 +8504,14 @@ drop table if exists t4 ; drop table if exists t5 ; drop table if exists t6 ; ------------------------------------------------------------------------- ---- Create tables with second(col1) +--- Create tables with quarter(col1) ------------------------------------------------------------------------- -create table t1 (col1 char(30)) engine='MYISAM' -partition by range(second(col1)) +create table t1 (col1 date) engine='MYISAM' +partition by range(quarter(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t2 (col1 char(30)) engine='MYISAM' -partition by list(second(col1)) +create table t2 (col1 date) engine='MYISAM' +partition by list(quarter(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8513,16 +8519,16 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t3 (col1 char(30)) engine='MYISAM' -partition by hash(second(col1)); -create table t4 (colint int, col1 char(30)) engine='MYISAM' +create table t3 (col1 date) engine='MYISAM' +partition by hash(quarter(col1)); +create table t4 (colint int, col1 date) engine='MYISAM' partition by range(colint) -subpartition by hash(second(col1)) subpartitions 2 +subpartition by hash(quarter(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t5 (colint int, col1 char(30)) engine='MYISAM' +create table t5 (colint int, col1 date) engine='MYISAM' partition by list(colint) -subpartition by hash(second(col1)) subpartitions 2 +subpartition by hash(quarter(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8530,100 +8536,100 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t6 (colint int, col1 char(30)) engine='MYISAM' +create table t6 (colint int, col1 date) engine='MYISAM' partition by range(colint) -(partition p0 values less than (second('18:30:14')), +(partition p0 values less than (quarter('2006-10-14')), partition p1 values less than maxvalue); ------------------------------------------------------------------------- ---- Access tables with second(col1) +--- Access tables with quarter(col1) ------------------------------------------------------------------------- -insert into t1 values ('09:09:09'); -insert into t1 values ('14:30:20'); -insert into t2 values ('09:09:09'); -insert into t2 values ('14:30:20'); -insert into t2 values ('21:59:22'); -insert into t3 values ('09:09:09'); -insert into t3 values ('14:30:20'); -insert into t3 values ('21:59:22'); -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; -select second(col1) from t1 order by col1; -second(col1) -9 -20 +insert into t1 values ('2006-01-03'); +insert into t1 values ('2006-12-17'); +insert into t2 values ('2006-01-03'); +insert into t2 values ('2006-12-17'); +insert into t2 values ('2006-09-25'); +insert into t3 values ('2006-01-03'); +insert into t3 values ('2006-12-17'); +insert into t3 values ('2006-09-25'); +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; +select quarter(col1) from t1 order by col1; +quarter(col1) +1 +4 select * from t1 order by col1; col1 -09:09:09 -14:30:20 +2006-01-03 +2006-12-17 select * from t2 order by col1; col1 -09:09:09 -14:30:20 -21:59:22 +2006-01-03 +2006-09-25 +2006-12-17 select * from t3 order by col1; col1 -09:09:09 -14:30:20 -21:59:22 +2006-01-03 +2006-09-25 +2006-12-17 select * from t4 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t5 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t6 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -update t1 set col1='10:22:33' where col1='09:09:09'; -update t2 set col1='10:22:33' where col1='09:09:09'; -update t3 set col1='10:22:33' where col1='09:09:09'; -update t4 set col1='10:22:33' where col1='09:09:09'; -update t5 set col1='10:22:33' where col1='09:09:09'; -update t6 set col1='10:22:33' where col1='09:09:09'; +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +update t1 set col1='2006-07-30' where col1='2006-01-03'; +update t2 set col1='2006-07-30' where col1='2006-01-03'; +update t3 set col1='2006-07-30' where col1='2006-01-03'; +update t4 set col1='2006-07-30' where col1='2006-01-03'; +update t5 set col1='2006-07-30' where col1='2006-01-03'; +update t6 set col1='2006-07-30' where col1='2006-01-03'; select * from t1 order by col1; col1 -10:22:33 -14:30:20 +2006-07-30 +2006-12-17 select * from t2 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 select * from t3 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 select * from t4 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t5 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t6 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 ------------------------------------------------------------------------- ---- Alter tables with second(col1) +--- Alter tables with quarter(col1) ------------------------------------------------------------------------- drop table if exists t11 ; drop table if exists t22 ; @@ -8638,11 +8644,11 @@ create table t44 engine='MYISAM' as select * from t4; create table t55 engine='MYISAM' as select * from t5; create table t66 engine='MYISAM' as select * from t6; alter table t11 -partition by range(second(col1)) +partition by range(quarter(col1)) (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t22 -partition by list(second(col1)) +partition by list(quarter(col1)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8651,15 +8657,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t33 -partition by hash(second(col1)); +partition by hash(quarter(col1)); alter table t44 partition by range(colint) -subpartition by hash(second(col1)) subpartitions 2 +subpartition by hash(quarter(col1)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t55 partition by list(colint) -subpartition by hash(second(col1)) subpartitions 2 +subpartition by hash(quarter(col1)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8669,40 +8675,40 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t66 partition by range(colint) -(partition p0 values less than (second('18:30:14')), +(partition p0 values less than (quarter('2006-10-14')), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -10:22:33 -14:30:20 +2006-07-30 +2006-12-17 select * from t22 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 -select * from t33 order by col1; -col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 +select * from t33 order by col1; +col1 +2006-07-30 +2006-09-25 +2006-12-17 select * from t44 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t55 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t66 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 --------------------------- ---- some alter table begin --------------------------- @@ -8711,19 +8717,19 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t11 order by col1; col1 -10:22:33 -14:30:20 +2006-07-30 +2006-12-17 alter table t11 reorganize partition s1 into (partition p0 values less than (15), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -10:22:33 -14:30:20 +2006-07-30 +2006-12-17 alter table t55 partition by list(colint) -subpartition by hash(second(col1)) subpartitions 5 +subpartition by hash(quarter(col1)) subpartitions 5 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -8735,10 +8741,10 @@ show create table t55; Table Create Table t55 CREATE TABLE `t55` ( `colint` int(11) DEFAULT NULL, - `col1` char(30) DEFAULT NULL + `col1` date DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (second(col1)) +SUBPARTITION BY HASH (quarter(col1)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = MyISAM, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = MyISAM, @@ -8748,121 +8754,121 @@ SUBPARTITIONS 5 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = MyISAM) */ select * from t55 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 alter table t66 reorganize partition s1 into -(partition p0 values less than (second('18:30:14')), +(partition p0 values less than (quarter('2006-10-14')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 alter table t66 reorganize partition s1 into -(partition p0 values less than (second('18:30:14')), +(partition p0 values less than (quarter('2006-10-14')), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with second(col1) +--- Delete rows and partitions of tables with quarter(col1) ------------------------------------------------------------------------- -delete from t1 where col1='14:30:20'; -delete from t2 where col1='14:30:20'; -delete from t3 where col1='14:30:20'; -delete from t4 where col1='14:30:20'; -delete from t5 where col1='14:30:20'; -delete from t6 where col1='14:30:20'; +delete from t1 where col1='2006-12-17'; +delete from t2 where col1='2006-12-17'; +delete from t3 where col1='2006-12-17'; +delete from t4 where col1='2006-12-17'; +delete from t5 where col1='2006-12-17'; +delete from t6 where col1='2006-12-17'; select * from t1 order by col1; col1 -10:22:33 +2006-07-30 select * from t2 order by col1; col1 -10:22:33 -21:59:22 +2006-07-30 +2006-09-25 select * from t3 order by col1; col1 -10:22:33 -21:59:22 +2006-07-30 +2006-09-25 select * from t4 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t5 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -insert into t1 values ('14:30:20'); -insert into t2 values ('14:30:20'); -insert into t3 values ('14:30:20'); -insert into t4 values (60,'14:30:20'); -insert into t5 values (60,'14:30:20'); -insert into t6 values (60,'14:30:20'); +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +insert into t1 values ('2006-12-17'); +insert into t2 values ('2006-12-17'); +insert into t3 values ('2006-12-17'); +insert into t4 values (60,'2006-12-17'); +insert into t5 values (60,'2006-12-17'); +insert into t6 values (60,'2006-12-17'); select * from t1 order by col1; col1 -10:22:33 -14:30:20 +2006-07-30 +2006-12-17 select * from t2 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 select * from t3 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 select * from t4 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 select * from t5 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 select * from t6 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 alter table t1 drop partition p0; alter table t2 drop partition p0; alter table t4 drop partition p0; @@ -8870,100 +8876,96 @@ alter table t5 drop partition p0; alter table t6 drop partition p0; select * from t1 order by col1; col1 -10:22:33 -14:30:20 select * from t2 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 select * from t3 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 select * from t4 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 select * from t5 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 select * from t6 order by colint; colint col1 -60 14:30:20 +4 2006-02-05 +60 2006-12-17 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with second(col1) +--- Delete rows and partitions of tables with quarter(col1) ------------------------------------------------------------------------- -delete from t11 where col1='14:30:20'; -delete from t22 where col1='14:30:20'; -delete from t33 where col1='14:30:20'; -delete from t44 where col1='14:30:20'; -delete from t55 where col1='14:30:20'; -delete from t66 where col1='14:30:20'; +delete from t11 where col1='2006-12-17'; +delete from t22 where col1='2006-12-17'; +delete from t33 where col1='2006-12-17'; +delete from t44 where col1='2006-12-17'; +delete from t55 where col1='2006-12-17'; +delete from t66 where col1='2006-12-17'; select * from t11 order by col1; col1 -10:22:33 +2006-07-30 select * from t22 order by col1; col1 -10:22:33 -21:59:22 +2006-07-30 +2006-09-25 select * from t33 order by col1; col1 -10:22:33 -21:59:22 +2006-07-30 +2006-09-25 select * from t44 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 select * from t55 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -insert into t11 values ('14:30:20'); -insert into t22 values ('14:30:20'); -insert into t33 values ('14:30:20'); -insert into t44 values (60,'14:30:20'); -insert into t55 values (60,'14:30:20'); -insert into t66 values (60,'14:30:20'); +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +insert into t11 values ('2006-12-17'); +insert into t22 values ('2006-12-17'); +insert into t33 values ('2006-12-17'); +insert into t44 values (60,'2006-12-17'); +insert into t55 values (60,'2006-12-17'); +insert into t66 values (60,'2006-12-17'); select * from t11 order by col1; col1 -10:22:33 -14:30:20 +2006-07-30 +2006-12-17 select * from t22 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 select * from t33 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 select * from t44 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 select * from t55 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 select * from t66 order by colint; colint col1 -1 09:09:15.000002 -2 04:30:01.000018 -3 00:59:22.000024 -4 05:30:34.000037 -60 14:30:20 +1 2006-02-03 +2 2006-01-17 +3 2006-01-25 +4 2006-02-05 +60 2006-12-17 alter table t11 drop partition p0; alter table t22 drop partition p0; alter table t44 drop partition p0; @@ -8971,27 +8973,23 @@ alter table t55 drop partition p0; alter table t66 drop partition p0; select * from t11 order by col1; col1 -10:22:33 -14:30:20 select * from t22 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 select * from t33 order by col1; col1 -10:22:33 -14:30:20 -21:59:22 +2006-07-30 +2006-09-25 +2006-12-17 select * from t44 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 select * from t55 order by colint; colint col1 -60 14:30:20 +60 2006-12-17 select * from t66 order by colint; colint col1 -60 14:30:20 +4 2006-02-05 +60 2006-12-17 ------------------------- ---- some alter table end ------------------------- @@ -9008,7 +9006,7 @@ drop table if exists t44 ; drop table if exists t55 ; drop table if exists t66 ; ------------------------------------------------------------------------- ---- month(col1) in partition with coltype date +--- time_to_sec(col1)-(time_to_sec(col1)-20) in partition with coltype time ------------------------------------------------------------------------- drop table if exists t1 ; drop table if exists t2 ; @@ -9017,14 +9015,14 @@ drop table if exists t4 ; drop table if exists t5 ; drop table if exists t6 ; ------------------------------------------------------------------------- ---- Create tables with month(col1) +--- Create tables with time_to_sec(col1)-(time_to_sec(col1)-20) ------------------------------------------------------------------------- -create table t1 (col1 date) engine='MYISAM' -partition by range(month(col1)) +create table t1 (col1 time) engine='MYISAM' +partition by range(time_to_sec(col1)-(time_to_sec(col1)-20)) (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t2 (col1 date) engine='MYISAM' -partition by list(month(col1)) +create table t2 (col1 time) engine='MYISAM' +partition by list(time_to_sec(col1)-(time_to_sec(col1)-20)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -9032,16 +9030,16 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t3 (col1 date) engine='MYISAM' -partition by hash(month(col1)); -create table t4 (colint int, col1 date) engine='MYISAM' +create table t3 (col1 time) engine='MYISAM' +partition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)); +create table t4 (colint int, col1 time) engine='MYISAM' partition by range(colint) -subpartition by hash(month(col1)) subpartitions 2 +subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); -create table t5 (colint int, col1 date) engine='MYISAM' +create table t5 (colint int, col1 time) engine='MYISAM' partition by list(colint) -subpartition by hash(month(col1)) subpartitions 2 +subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -9049,100 +9047,100 @@ partition p3 values in (31,32,33,34,35,36,37,38,39,40), partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); -create table t6 (colint int, col1 date) engine='MYISAM' +create table t6 (colint int, col1 time) engine='MYISAM' partition by range(colint) -(partition p0 values less than (month('2006-10-14')), +(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), partition p1 values less than maxvalue); ------------------------------------------------------------------------- ---- Access tables with month(col1) +--- Access tables with time_to_sec(col1)-(time_to_sec(col1)-20) ------------------------------------------------------------------------- -insert into t1 values ('2006-01-03'); -insert into t1 values ('2006-12-17'); -insert into t2 values ('2006-01-03'); -insert into t2 values ('2006-12-17'); -insert into t2 values ('2006-05-25'); -insert into t3 values ('2006-01-03'); -insert into t3 values ('2006-12-17'); -insert into t3 values ('2006-05-25'); -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; -select month(col1) from t1 order by col1; -month(col1) -1 -12 +insert into t1 values ('09:09:15'); +insert into t1 values ('14:30:45'); +insert into t2 values ('09:09:15'); +insert into t2 values ('14:30:45'); +insert into t2 values ('21:59:22'); +insert into t3 values ('09:09:15'); +insert into t3 values ('14:30:45'); +insert into t3 values ('21:59:22'); +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; +load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; +select time_to_sec(col1)-(time_to_sec(col1)-20) from t1 order by col1; +time_to_sec(col1)-(time_to_sec(col1)-20) +20 +20 select * from t1 order by col1; col1 -2006-01-03 -2006-12-17 +09:09:15 +14:30:45 select * from t2 order by col1; col1 -2006-01-03 -2006-05-25 -2006-12-17 +09:09:15 +14:30:45 +21:59:22 select * from t3 order by col1; col1 -2006-01-03 -2006-05-25 -2006-12-17 +09:09:15 +14:30:45 +21:59:22 select * from t4 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t5 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t6 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -update t1 set col1='2006-11-06' where col1='2006-01-03'; -update t2 set col1='2006-11-06' where col1='2006-01-03'; -update t3 set col1='2006-11-06' where col1='2006-01-03'; -update t4 set col1='2006-11-06' where col1='2006-01-03'; -update t5 set col1='2006-11-06' where col1='2006-01-03'; -update t6 set col1='2006-11-06' where col1='2006-01-03'; +1 09:09:15 +2 04:30:01 +3 00:59:22 +4 05:30:34 +update t1 set col1='10:33:11' where col1='09:09:15'; +update t2 set col1='10:33:11' where col1='09:09:15'; +update t3 set col1='10:33:11' where col1='09:09:15'; +update t4 set col1='10:33:11' where col1='09:09:15'; +update t5 set col1='10:33:11' where col1='09:09:15'; +update t6 set col1='10:33:11' where col1='09:09:15'; select * from t1 order by col1; col1 -2006-11-06 -2006-12-17 +10:33:11 +14:30:45 select * from t2 order by col1; col1 -2006-05-25 -2006-11-06 -2006-12-17 +10:33:11 +14:30:45 +21:59:22 select * from t3 order by col1; col1 -2006-05-25 -2006-11-06 -2006-12-17 +10:33:11 +14:30:45 +21:59:22 select * from t4 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t5 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t6 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 ------------------------------------------------------------------------- ---- Alter tables with month(col1) +--- Alter tables with time_to_sec(col1)-(time_to_sec(col1)-20) ------------------------------------------------------------------------- drop table if exists t11 ; drop table if exists t22 ; @@ -9157,11 +9155,11 @@ create table t44 engine='MYISAM' as select * from t4; create table t55 engine='MYISAM' as select * from t5; create table t66 engine='MYISAM' as select * from t6; alter table t11 -partition by range(month(col1)) +partition by range(time_to_sec(col1)-(time_to_sec(col1)-20)) (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t22 -partition by list(month(col1)) +partition by list(time_to_sec(col1)-(time_to_sec(col1)-20)) (partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -9170,15 +9168,15 @@ partition p4 values in (41,42,43,44,45,46,47,48,49,50), partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t33 -partition by hash(month(col1)); +partition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)); alter table t44 partition by range(colint) -subpartition by hash(month(col1)) subpartitions 2 +subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 (partition p0 values less than (15), partition p1 values less than maxvalue); alter table t55 partition by list(colint) -subpartition by hash(month(col1)) subpartitions 2 +subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -9188,40 +9186,40 @@ partition p5 values in (51,52,53,54,55,56,57,58,59,60) ); alter table t66 partition by range(colint) -(partition p0 values less than (month('2006-10-14')), +(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -2006-11-06 -2006-12-17 +10:33:11 +14:30:45 select * from t22 order by col1; col1 -2006-05-25 -2006-11-06 -2006-12-17 +10:33:11 +14:30:45 +21:59:22 select * from t33 order by col1; col1 -2006-05-25 -2006-11-06 -2006-12-17 +10:33:11 +14:30:45 +21:59:22 select * from t44 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t55 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 --------------------------- ---- some alter table begin --------------------------- @@ -9230,19 +9228,19 @@ reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t11 order by col1; col1 -2006-11-06 -2006-12-17 +10:33:11 +14:30:45 alter table t11 reorganize partition s1 into (partition p0 values less than (15), partition p1 values less than maxvalue); select * from t11 order by col1; col1 -2006-11-06 -2006-12-17 +10:33:11 +14:30:45 alter table t55 partition by list(colint) -subpartition by hash(month(col1)) subpartitions 5 +subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 5 (partition p0 values in (1,2,3,4,5,6,7,8,9,10), partition p1 values in (11,12,13,14,15,16,17,18,19,20), partition p2 values in (21,22,23,24,25,26,27,28,29,30), @@ -9254,10 +9252,10 @@ show create table t55; Table Create Table t55 CREATE TABLE `t55` ( `colint` int(11) DEFAULT NULL, - `col1` date DEFAULT NULL + `col1` time DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (month(col1)) +SUBPARTITION BY HASH (time_to_sec(col1)-(time_to_sec(col1)-20)) SUBPARTITIONS 5 (PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = MyISAM, PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = MyISAM, @@ -9267,2166 +9265,121 @@ SUBPARTITIONS 5 PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = MyISAM) */ select * from t55 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (month('2006-10-14')), +(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 alter table t66 reorganize partition p0,p1 into (partition s1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 alter table t66 reorganize partition s1 into -(partition p0 values less than (month('2006-10-14')), +(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), partition p1 values less than maxvalue); select * from t66 order by colint; colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with month(col1) -------------------------------------------------------------------------- -delete from t1 where col1='2006-12-17'; -delete from t2 where col1='2006-12-17'; -delete from t3 where col1='2006-12-17'; -delete from t4 where col1='2006-12-17'; -delete from t5 where col1='2006-12-17'; -delete from t6 where col1='2006-12-17'; -select * from t1 order by col1; -col1 -2006-11-06 -select * from t2 order by col1; -col1 -2006-05-25 -2006-11-06 -select * from t3 order by col1; -col1 -2006-05-25 -2006-11-06 -select * from t4 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -insert into t1 values ('2006-12-17'); -insert into t2 values ('2006-12-17'); -insert into t3 values ('2006-12-17'); -insert into t4 values (60,'2006-12-17'); -insert into t5 values (60,'2006-12-17'); -insert into t6 values (60,'2006-12-17'); -select * from t1 order by col1; -col1 -2006-11-06 -2006-12-17 -select * from t2 order by col1; -col1 -2006-05-25 -2006-11-06 -2006-12-17 -select * from t3 order by col1; -col1 -2006-05-25 -2006-11-06 -2006-12-17 -select * from t4 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -select * from t5 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -select * from t6 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -alter table t1 drop partition p0; -alter table t2 drop partition p0; -alter table t4 drop partition p0; -alter table t5 drop partition p0; -alter table t6 drop partition p0; -select * from t1 order by col1; -col1 -select * from t2 order by col1; -col1 -2006-11-06 -2006-12-17 -select * from t3 order by col1; -col1 -2006-05-25 -2006-11-06 -2006-12-17 -select * from t4 order by colint; -colint col1 -60 2006-12-17 -select * from t5 order by colint; -colint col1 -60 2006-12-17 -select * from t6 order by colint; -colint col1 -60 2006-12-17 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with month(col1) -------------------------------------------------------------------------- -delete from t11 where col1='2006-12-17'; -delete from t22 where col1='2006-12-17'; -delete from t33 where col1='2006-12-17'; -delete from t44 where col1='2006-12-17'; -delete from t55 where col1='2006-12-17'; -delete from t66 where col1='2006-12-17'; -select * from t11 order by col1; -col1 -2006-11-06 -select * from t22 order by col1; -col1 -2006-05-25 -2006-11-06 -select * from t33 order by col1; -col1 -2006-05-25 -2006-11-06 -select * from t44 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t55 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -insert into t11 values ('2006-12-17'); -insert into t22 values ('2006-12-17'); -insert into t33 values ('2006-12-17'); -insert into t44 values (60,'2006-12-17'); -insert into t55 values (60,'2006-12-17'); -insert into t66 values (60,'2006-12-17'); -select * from t11 order by col1; -col1 -2006-11-06 -2006-12-17 -select * from t22 order by col1; -col1 -2006-05-25 -2006-11-06 -2006-12-17 -select * from t33 order by col1; -col1 -2006-05-25 -2006-11-06 -2006-12-17 -select * from t44 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -select * from t55 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -select * from t66 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -alter table t11 drop partition p0; -alter table t22 drop partition p0; -alter table t44 drop partition p0; -alter table t55 drop partition p0; -alter table t66 drop partition p0; -select * from t11 order by col1; -col1 -select * from t22 order by col1; -col1 -2006-11-06 -2006-12-17 -select * from t33 order by col1; -col1 -2006-05-25 -2006-11-06 -2006-12-17 -select * from t44 order by colint; -colint col1 -60 2006-12-17 -select * from t55 order by colint; -colint col1 -60 2006-12-17 -select * from t66 order by colint; -colint col1 -60 2006-12-17 -------------------------- ----- some alter table end -------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -------------------------------------------------------------------------- ---- quarter(col1) in partition with coltype date -------------------------------------------------------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -------------------------------------------------------------------------- ---- Create tables with quarter(col1) -------------------------------------------------------------------------- -create table t1 (col1 date) engine='MYISAM' -partition by range(quarter(col1)) -(partition p0 values less than (15), -partition p1 values less than maxvalue); -create table t2 (col1 date) engine='MYISAM' -partition by list(quarter(col1)) -(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -create table t3 (col1 date) engine='MYISAM' -partition by hash(quarter(col1)); -create table t4 (colint int, col1 date) engine='MYISAM' -partition by range(colint) -subpartition by hash(quarter(col1)) subpartitions 2 -(partition p0 values less than (15), -partition p1 values less than maxvalue); -create table t5 (colint int, col1 date) engine='MYISAM' -partition by list(colint) -subpartition by hash(quarter(col1)) subpartitions 2 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -create table t6 (colint int, col1 date) engine='MYISAM' -partition by range(colint) -(partition p0 values less than (quarter('2006-10-14')), -partition p1 values less than maxvalue); -------------------------------------------------------------------------- ---- Access tables with quarter(col1) -------------------------------------------------------------------------- -insert into t1 values ('2006-01-03'); -insert into t1 values ('2006-12-17'); -insert into t2 values ('2006-01-03'); -insert into t2 values ('2006-12-17'); -insert into t2 values ('2006-09-25'); -insert into t3 values ('2006-01-03'); -insert into t3 values ('2006-12-17'); -insert into t3 values ('2006-09-25'); -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; -select quarter(col1) from t1 order by col1; -quarter(col1) -1 -4 -select * from t1 order by col1; -col1 -2006-01-03 -2006-12-17 -select * from t2 order by col1; -col1 -2006-01-03 -2006-09-25 -2006-12-17 -select * from t3 order by col1; -col1 -2006-01-03 -2006-09-25 -2006-12-17 -select * from t4 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t6 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -update t1 set col1='2006-07-30' where col1='2006-01-03'; -update t2 set col1='2006-07-30' where col1='2006-01-03'; -update t3 set col1='2006-07-30' where col1='2006-01-03'; -update t4 set col1='2006-07-30' where col1='2006-01-03'; -update t5 set col1='2006-07-30' where col1='2006-01-03'; -update t6 set col1='2006-07-30' where col1='2006-01-03'; -select * from t1 order by col1; -col1 -2006-07-30 -2006-12-17 -select * from t2 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t3 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t4 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t6 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -------------------------------------------------------------------------- ---- Alter tables with quarter(col1) -------------------------------------------------------------------------- -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -create table t11 engine='MYISAM' as select * from t1; -create table t22 engine='MYISAM' as select * from t2; -create table t33 engine='MYISAM' as select * from t3; -create table t44 engine='MYISAM' as select * from t4; -create table t55 engine='MYISAM' as select * from t5; -create table t66 engine='MYISAM' as select * from t6; -alter table t11 -partition by range(quarter(col1)) -(partition p0 values less than (15), -partition p1 values less than maxvalue); -alter table t22 -partition by list(quarter(col1)) -(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -alter table t33 -partition by hash(quarter(col1)); -alter table t44 -partition by range(colint) -subpartition by hash(quarter(col1)) subpartitions 2 -(partition p0 values less than (15), -partition p1 values less than maxvalue); -alter table t55 -partition by list(colint) -subpartition by hash(quarter(col1)) subpartitions 2 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -alter table t66 -partition by range(colint) -(partition p0 values less than (quarter('2006-10-14')), -partition p1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-07-30 -2006-12-17 -select * from t22 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t33 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t44 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t55 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t66 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 ---------------------------- ----- some alter table begin ---------------------------- -alter table t11 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-07-30 -2006-12-17 -alter table t11 -reorganize partition s1 into -(partition p0 values less than (15), -partition p1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-07-30 -2006-12-17 -alter table t55 -partition by list(colint) -subpartition by hash(quarter(col1)) subpartitions 5 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -show create table t55; -Table Create Table -t55 CREATE TABLE `t55` ( - `colint` int(11) DEFAULT NULL, - `col1` date DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (quarter(col1)) -SUBPARTITIONS 5 -(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = MyISAM, - PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = MyISAM, - PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = MyISAM, - PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = MyISAM, - PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = MyISAM, - PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = MyISAM) */ -select * from t55 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (quarter('2006-10-14')), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (quarter('2006-10-14')), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with quarter(col1) -------------------------------------------------------------------------- -delete from t1 where col1='2006-12-17'; -delete from t2 where col1='2006-12-17'; -delete from t3 where col1='2006-12-17'; -delete from t4 where col1='2006-12-17'; -delete from t5 where col1='2006-12-17'; -delete from t6 where col1='2006-12-17'; -select * from t1 order by col1; -col1 -2006-07-30 -select * from t2 order by col1; -col1 -2006-07-30 -2006-09-25 -select * from t3 order by col1; -col1 -2006-07-30 -2006-09-25 -select * from t4 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -insert into t1 values ('2006-12-17'); -insert into t2 values ('2006-12-17'); -insert into t3 values ('2006-12-17'); -insert into t4 values (60,'2006-12-17'); -insert into t5 values (60,'2006-12-17'); -insert into t6 values (60,'2006-12-17'); -select * from t1 order by col1; -col1 -2006-07-30 -2006-12-17 -select * from t2 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t3 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t4 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -select * from t5 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -select * from t6 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -alter table t1 drop partition p0; -alter table t2 drop partition p0; -alter table t4 drop partition p0; -alter table t5 drop partition p0; -alter table t6 drop partition p0; -select * from t1 order by col1; -col1 -select * from t2 order by col1; -col1 -select * from t3 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t4 order by colint; -colint col1 -60 2006-12-17 -select * from t5 order by colint; -colint col1 -60 2006-12-17 -select * from t6 order by colint; -colint col1 -4 2006-02-05 -60 2006-12-17 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with quarter(col1) -------------------------------------------------------------------------- -delete from t11 where col1='2006-12-17'; -delete from t22 where col1='2006-12-17'; -delete from t33 where col1='2006-12-17'; -delete from t44 where col1='2006-12-17'; -delete from t55 where col1='2006-12-17'; -delete from t66 where col1='2006-12-17'; -select * from t11 order by col1; -col1 -2006-07-30 -select * from t22 order by col1; -col1 -2006-07-30 -2006-09-25 -select * from t33 order by col1; -col1 -2006-07-30 -2006-09-25 -select * from t44 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t55 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -insert into t11 values ('2006-12-17'); -insert into t22 values ('2006-12-17'); -insert into t33 values ('2006-12-17'); -insert into t44 values (60,'2006-12-17'); -insert into t55 values (60,'2006-12-17'); -insert into t66 values (60,'2006-12-17'); -select * from t11 order by col1; -col1 -2006-07-30 -2006-12-17 -select * from t22 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t33 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t44 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -select * from t55 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -select * from t66 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -60 2006-12-17 -alter table t11 drop partition p0; -alter table t22 drop partition p0; -alter table t44 drop partition p0; -alter table t55 drop partition p0; -alter table t66 drop partition p0; -select * from t11 order by col1; -col1 -select * from t22 order by col1; -col1 -select * from t33 order by col1; -col1 -2006-07-30 -2006-09-25 -2006-12-17 -select * from t44 order by colint; -colint col1 -60 2006-12-17 -select * from t55 order by colint; -colint col1 -60 2006-12-17 -select * from t66 order by colint; -colint col1 -4 2006-02-05 -60 2006-12-17 -------------------------- ----- some alter table end -------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -------------------------------------------------------------------------- ---- time_to_sec(col1)-(time_to_sec(col1)-20) in partition with coltype time -------------------------------------------------------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -------------------------------------------------------------------------- ---- Create tables with time_to_sec(col1)-(time_to_sec(col1)-20) -------------------------------------------------------------------------- -create table t1 (col1 time) engine='MYISAM' -partition by range(time_to_sec(col1)-(time_to_sec(col1)-20)) -(partition p0 values less than (15), -partition p1 values less than maxvalue); -create table t2 (col1 time) engine='MYISAM' -partition by list(time_to_sec(col1)-(time_to_sec(col1)-20)) -(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -create table t3 (col1 time) engine='MYISAM' -partition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)); -create table t4 (colint int, col1 time) engine='MYISAM' -partition by range(colint) -subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 -(partition p0 values less than (15), -partition p1 values less than maxvalue); -create table t5 (colint int, col1 time) engine='MYISAM' -partition by list(colint) -subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -create table t6 (colint int, col1 time) engine='MYISAM' -partition by range(colint) -(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), -partition p1 values less than maxvalue); -------------------------------------------------------------------------- ---- Access tables with time_to_sec(col1)-(time_to_sec(col1)-20) -------------------------------------------------------------------------- -insert into t1 values ('09:09:15'); -insert into t1 values ('14:30:45'); -insert into t2 values ('09:09:15'); -insert into t2 values ('14:30:45'); -insert into t2 values ('21:59:22'); -insert into t3 values ('09:09:15'); -insert into t3 values ('14:30:45'); -insert into t3 values ('21:59:22'); -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t4; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t5; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_time.inc' into table t6; -select time_to_sec(col1)-(time_to_sec(col1)-20) from t1 order by col1; -time_to_sec(col1)-(time_to_sec(col1)-20) -20 -20 -select * from t1 order by col1; -col1 -09:09:15 -14:30:45 -select * from t2 order by col1; -col1 -09:09:15 -14:30:45 -21:59:22 -select * from t3 order by col1; -col1 -09:09:15 -14:30:45 -21:59:22 -select * from t4 order by colint; -colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t5 order by colint; -colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t6 order by colint; -colint col1 -1 09:09:15 -2 04:30:01 -3 00:59:22 -4 05:30:34 -update t1 set col1='10:33:11' where col1='09:09:15'; -update t2 set col1='10:33:11' where col1='09:09:15'; -update t3 set col1='10:33:11' where col1='09:09:15'; -update t4 set col1='10:33:11' where col1='09:09:15'; -update t5 set col1='10:33:11' where col1='09:09:15'; -update t6 set col1='10:33:11' where col1='09:09:15'; -select * from t1 order by col1; -col1 -10:33:11 -14:30:45 -select * from t2 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t3 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t4 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t5 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t6 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -------------------------------------------------------------------------- ---- Alter tables with time_to_sec(col1)-(time_to_sec(col1)-20) -------------------------------------------------------------------------- -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -create table t11 engine='MYISAM' as select * from t1; -create table t22 engine='MYISAM' as select * from t2; -create table t33 engine='MYISAM' as select * from t3; -create table t44 engine='MYISAM' as select * from t4; -create table t55 engine='MYISAM' as select * from t5; -create table t66 engine='MYISAM' as select * from t6; -alter table t11 -partition by range(time_to_sec(col1)-(time_to_sec(col1)-20)) -(partition p0 values less than (15), -partition p1 values less than maxvalue); -alter table t22 -partition by list(time_to_sec(col1)-(time_to_sec(col1)-20)) -(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -alter table t33 -partition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)); -alter table t44 -partition by range(colint) -subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 -(partition p0 values less than (15), -partition p1 values less than maxvalue); -alter table t55 -partition by list(colint) -subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 2 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -alter table t66 -partition by range(colint) -(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), -partition p1 values less than maxvalue); -select * from t11 order by col1; -col1 -10:33:11 -14:30:45 -select * from t22 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t33 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t44 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t55 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t66 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 ---------------------------- ----- some alter table begin ---------------------------- -alter table t11 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t11 order by col1; -col1 -10:33:11 -14:30:45 -alter table t11 -reorganize partition s1 into -(partition p0 values less than (15), -partition p1 values less than maxvalue); -select * from t11 order by col1; -col1 -10:33:11 -14:30:45 -alter table t55 -partition by list(colint) -subpartition by hash(time_to_sec(col1)-(time_to_sec(col1)-20)) subpartitions 5 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -show create table t55; -Table Create Table -t55 CREATE TABLE `t55` ( - `colint` int(11) DEFAULT NULL, - `col1` time DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (time_to_sec(col1)-(time_to_sec(col1)-20)) -SUBPARTITIONS 5 -(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = MyISAM, - PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = MyISAM, - PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = MyISAM, - PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = MyISAM, - PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = MyISAM, - PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = MyISAM) */ -select * from t55 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (time_to_sec('18:30:14')-(time_to_sec('17:59:59'))), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20) -------------------------------------------------------------------------- -delete from t1 where col1='14:30:45'; -delete from t2 where col1='14:30:45'; -delete from t3 where col1='14:30:45'; -delete from t4 where col1='14:30:45'; -delete from t5 where col1='14:30:45'; -delete from t6 where col1='14:30:45'; -select * from t1 order by col1; -col1 -10:33:11 -select * from t2 order by col1; -col1 -10:33:11 -21:59:22 -select * from t3 order by col1; -col1 -10:33:11 -21:59:22 -select * from t4 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t5 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -insert into t1 values ('14:30:45'); -insert into t2 values ('14:30:45'); -insert into t3 values ('14:30:45'); -insert into t4 values (60,'14:30:45'); -insert into t5 values (60,'14:30:45'); -insert into t6 values (60,'14:30:45'); -select * from t1 order by col1; -col1 -10:33:11 -14:30:45 -select * from t2 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t3 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t4 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -select * from t5 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -select * from t6 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -alter table t1 drop partition p0; -alter table t2 drop partition p0; -alter table t4 drop partition p0; -alter table t5 drop partition p0; -alter table t6 drop partition p0; -select * from t1 order by col1; -col1 -10:33:11 -14:30:45 -select * from t2 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t3 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t4 order by colint; -colint col1 -60 14:30:45 -select * from t5 order by colint; -colint col1 -60 14:30:45 -select * from t6 order by colint; -colint col1 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20) -------------------------------------------------------------------------- -delete from t11 where col1='14:30:45'; -delete from t22 where col1='14:30:45'; -delete from t33 where col1='14:30:45'; -delete from t44 where col1='14:30:45'; -delete from t55 where col1='14:30:45'; -delete from t66 where col1='14:30:45'; -select * from t11 order by col1; -col1 -10:33:11 -select * from t22 order by col1; -col1 -10:33:11 -21:59:22 -select * from t33 order by col1; -col1 -10:33:11 -21:59:22 -select * from t44 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -select * from t55 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -insert into t11 values ('14:30:45'); -insert into t22 values ('14:30:45'); -insert into t33 values ('14:30:45'); -insert into t44 values (60,'14:30:45'); -insert into t55 values (60,'14:30:45'); -insert into t66 values (60,'14:30:45'); -select * from t11 order by col1; -col1 -10:33:11 -14:30:45 -select * from t22 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t33 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t44 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -select * from t55 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -select * from t66 order by colint; -colint col1 -1 10:33:11 -2 04:30:01 -3 00:59:22 -4 05:30:34 -60 14:30:45 -alter table t11 drop partition p0; -alter table t22 drop partition p0; -alter table t44 drop partition p0; -alter table t55 drop partition p0; -alter table t66 drop partition p0; -select * from t11 order by col1; -col1 -10:33:11 -14:30:45 -select * from t22 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t33 order by col1; -col1 -10:33:11 -14:30:45 -21:59:22 -select * from t44 order by colint; -colint col1 -60 14:30:45 -select * from t55 order by colint; -colint col1 -60 14:30:45 -select * from t66 order by colint; -colint col1 -------------------------- ----- some alter table end -------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -------------------------------------------------------------------------- ---- to_days(col1)-to_days('2006-01-01') in partition with coltype date -------------------------------------------------------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -------------------------------------------------------------------------- ---- Create tables with to_days(col1)-to_days('2006-01-01') -------------------------------------------------------------------------- -create table t1 (col1 date) engine='MYISAM' -partition by range(to_days(col1)-to_days('2006-01-01')) -(partition p0 values less than (15), -partition p1 values less than maxvalue); -create table t2 (col1 date) engine='MYISAM' -partition by list(to_days(col1)-to_days('2006-01-01')) -(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -create table t3 (col1 date) engine='MYISAM' -partition by hash(to_days(col1)-to_days('2006-01-01')); -create table t4 (colint int, col1 date) engine='MYISAM' -partition by range(colint) -subpartition by hash(to_days(col1)-to_days('2006-01-01')) subpartitions 2 -(partition p0 values less than (15), -partition p1 values less than maxvalue); -create table t5 (colint int, col1 date) engine='MYISAM' -partition by list(colint) -subpartition by hash(to_days(col1)-to_days('2006-01-01')) subpartitions 2 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -create table t6 (colint int, col1 date) engine='MYISAM' -partition by range(colint) -(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')), -partition p1 values less than maxvalue); -------------------------------------------------------------------------- ---- Access tables with to_days(col1)-to_days('2006-01-01') -------------------------------------------------------------------------- -insert into t1 values ('2006-02-03'); -insert into t1 values ('2006-01-17'); -insert into t2 values ('2006-02-03'); -insert into t2 values ('2006-01-17'); -insert into t2 values ('2006-01-25'); -insert into t3 values ('2006-02-03'); -insert into t3 values ('2006-01-17'); -insert into t3 values ('2006-01-25'); -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; -select to_days(col1)-to_days('2006-01-01') from t1 order by col1; -to_days(col1)-to_days('2006-01-01') -16 -33 -select * from t1 order by col1; -col1 -2006-01-17 -2006-02-03 -select * from t2 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-03 -select * from t3 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-03 -select * from t4 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t6 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -update t1 set col1='2006-02-06' where col1='2006-02-03'; -update t2 set col1='2006-02-06' where col1='2006-02-03'; -update t3 set col1='2006-02-06' where col1='2006-02-03'; -update t4 set col1='2006-02-06' where col1='2006-02-03'; -update t5 set col1='2006-02-06' where col1='2006-02-03'; -update t6 set col1='2006-02-06' where col1='2006-02-03'; -select * from t1 order by col1; -col1 -2006-01-17 -2006-02-06 -select * from t2 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t3 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t4 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t6 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -------------------------------------------------------------------------- ---- Alter tables with to_days(col1)-to_days('2006-01-01') -------------------------------------------------------------------------- -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -create table t11 engine='MYISAM' as select * from t1; -create table t22 engine='MYISAM' as select * from t2; -create table t33 engine='MYISAM' as select * from t3; -create table t44 engine='MYISAM' as select * from t4; -create table t55 engine='MYISAM' as select * from t5; -create table t66 engine='MYISAM' as select * from t6; -alter table t11 -partition by range(to_days(col1)-to_days('2006-01-01')) -(partition p0 values less than (15), -partition p1 values less than maxvalue); -alter table t22 -partition by list(to_days(col1)-to_days('2006-01-01')) -(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -alter table t33 -partition by hash(to_days(col1)-to_days('2006-01-01')); -alter table t44 -partition by range(colint) -subpartition by hash(to_days(col1)-to_days('2006-01-01')) subpartitions 2 -(partition p0 values less than (15), -partition p1 values less than maxvalue); -alter table t55 -partition by list(colint) -subpartition by hash(to_days(col1)-to_days('2006-01-01')) subpartitions 2 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -alter table t66 -partition by range(colint) -(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')), -partition p1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-01-17 -2006-02-06 -select * from t22 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t33 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t44 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t55 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 ---------------------------- ----- some alter table begin ---------------------------- -alter table t11 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-01-17 -2006-02-06 -alter table t11 -reorganize partition s1 into -(partition p0 values less than (15), -partition p1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-01-17 -2006-02-06 -alter table t55 -partition by list(colint) -subpartition by hash(to_days(col1)-to_days('2006-01-01')) subpartitions 5 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -show create table t55; -Table Create Table -t55 CREATE TABLE `t55` ( - `colint` int(11) DEFAULT NULL, - `col1` date DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (to_days(col1)-to_days('2006-01-01')) -SUBPARTITIONS 5 -(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = MyISAM, - PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = MyISAM, - PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = MyISAM, - PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = MyISAM, - PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = MyISAM, - PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = MyISAM) */ -select * from t55 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (to_days('2006-02-02')-to_days('2006-01-01')), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with to_days(col1)-to_days('2006-01-01') -------------------------------------------------------------------------- -delete from t1 where col1='2006-01-17'; -delete from t2 where col1='2006-01-17'; -delete from t3 where col1='2006-01-17'; -delete from t4 where col1='2006-01-17'; -delete from t5 where col1='2006-01-17'; -delete from t6 where col1='2006-01-17'; -select * from t1 order by col1; -col1 -2006-02-06 -select * from t2 order by col1; -col1 -2006-01-25 -2006-02-06 -select * from t3 order by col1; -col1 -2006-01-25 -2006-02-06 -select * from t4 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -insert into t1 values ('2006-01-17'); -insert into t2 values ('2006-01-17'); -insert into t3 values ('2006-01-17'); -insert into t4 values (60,'2006-01-17'); -insert into t5 values (60,'2006-01-17'); -insert into t6 values (60,'2006-01-17'); -select * from t1 order by col1; -col1 -2006-01-17 -2006-02-06 -select * from t2 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t3 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t4 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 -select * from t5 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 -select * from t6 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 -alter table t1 drop partition p0; -alter table t2 drop partition p0; -alter table t4 drop partition p0; -alter table t5 drop partition p0; -alter table t6 drop partition p0; -select * from t1 order by col1; -col1 -2006-01-17 -2006-02-06 -select * from t2 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t3 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t4 order by colint; -colint col1 -60 2006-01-17 -select * from t5 order by colint; -colint col1 -60 2006-01-17 -select * from t6 order by colint; -colint col1 -60 2006-01-17 -------------------------------------------------------------------------- ---- Delete rows and partitions of tables with to_days(col1)-to_days('2006-01-01') -------------------------------------------------------------------------- -delete from t11 where col1='2006-01-17'; -delete from t22 where col1='2006-01-17'; -delete from t33 where col1='2006-01-17'; -delete from t44 where col1='2006-01-17'; -delete from t55 where col1='2006-01-17'; -delete from t66 where col1='2006-01-17'; -select * from t11 order by col1; -col1 -2006-02-06 -select * from t22 order by col1; -col1 -2006-01-25 -2006-02-06 -select * from t33 order by col1; -col1 -2006-01-25 -2006-02-06 -select * from t44 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -select * from t55 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -insert into t11 values ('2006-01-17'); -insert into t22 values ('2006-01-17'); -insert into t33 values ('2006-01-17'); -insert into t44 values (60,'2006-01-17'); -insert into t55 values (60,'2006-01-17'); -insert into t66 values (60,'2006-01-17'); -select * from t11 order by col1; -col1 -2006-01-17 -2006-02-06 -select * from t22 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t33 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t44 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 -select * from t55 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 -select * from t66 order by colint; -colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 -alter table t11 drop partition p0; -alter table t22 drop partition p0; -alter table t44 drop partition p0; -alter table t55 drop partition p0; -alter table t66 drop partition p0; -select * from t11 order by col1; -col1 -2006-01-17 -2006-02-06 -select * from t22 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t33 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t44 order by colint; -colint col1 -60 2006-01-17 -select * from t55 order by colint; -colint col1 -60 2006-01-17 -select * from t66 order by colint; -colint col1 -60 2006-01-17 -------------------------- ----- some alter table end -------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -------------------------------------------------------------------------- ---- datediff(col1, '2006-01-01') in partition with coltype date -------------------------------------------------------------------------- -drop table if exists t1 ; -drop table if exists t2 ; -drop table if exists t3 ; -drop table if exists t4 ; -drop table if exists t5 ; -drop table if exists t6 ; -------------------------------------------------------------------------- ---- Create tables with datediff(col1, '2006-01-01') -------------------------------------------------------------------------- -create table t1 (col1 date) engine='MYISAM' -partition by range(datediff(col1, '2006-01-01')) -(partition p0 values less than (15), -partition p1 values less than maxvalue); -create table t2 (col1 date) engine='MYISAM' -partition by list(datediff(col1, '2006-01-01')) -(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -create table t3 (col1 date) engine='MYISAM' -partition by hash(datediff(col1, '2006-01-01')); -create table t4 (colint int, col1 date) engine='MYISAM' -partition by range(colint) -subpartition by hash(datediff(col1, '2006-01-01')) subpartitions 2 -(partition p0 values less than (15), -partition p1 values less than maxvalue); -create table t5 (colint int, col1 date) engine='MYISAM' -partition by list(colint) -subpartition by hash(datediff(col1, '2006-01-01')) subpartitions 2 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -create table t6 (colint int, col1 date) engine='MYISAM' -partition by range(colint) -(partition p0 values less than (datediff('2006-02-02', '2006-01-01')), -partition p1 values less than maxvalue); -------------------------------------------------------------------------- ---- Access tables with datediff(col1, '2006-01-01') -------------------------------------------------------------------------- -insert into t1 values ('2006-02-03'); -insert into t1 values ('2006-01-17'); -insert into t2 values ('2006-02-03'); -insert into t2 values ('2006-01-17'); -insert into t2 values ('2006-01-25'); -insert into t3 values ('2006-02-03'); -insert into t3 values ('2006-01-17'); -insert into t3 values ('2006-01-25'); -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t4; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t5; -load data infile 'MYSQLTEST_VARDIR/std_data/parts/part_supported_sql_funcs_int_date.inc' into table t6; -select datediff(col1, '2006-01-01') from t1 order by col1; -datediff(col1, '2006-01-01') -16 -33 -select * from t1 order by col1; -col1 -2006-01-17 -2006-02-03 -select * from t2 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-03 -select * from t3 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-03 -select * from t4 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t6 order by colint; -colint col1 -1 2006-02-03 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -update t1 set col1='2006-02-06' where col1='2006-02-03'; -update t2 set col1='2006-02-06' where col1='2006-02-03'; -update t3 set col1='2006-02-06' where col1='2006-02-03'; -update t4 set col1='2006-02-06' where col1='2006-02-03'; -update t5 set col1='2006-02-06' where col1='2006-02-03'; -update t6 set col1='2006-02-06' where col1='2006-02-03'; -select * from t1 order by col1; -col1 -2006-01-17 -2006-02-06 -select * from t2 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t3 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t4 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t5 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t6 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -------------------------------------------------------------------------- ---- Alter tables with datediff(col1, '2006-01-01') -------------------------------------------------------------------------- -drop table if exists t11 ; -drop table if exists t22 ; -drop table if exists t33 ; -drop table if exists t44 ; -drop table if exists t55 ; -drop table if exists t66 ; -create table t11 engine='MYISAM' as select * from t1; -create table t22 engine='MYISAM' as select * from t2; -create table t33 engine='MYISAM' as select * from t3; -create table t44 engine='MYISAM' as select * from t4; -create table t55 engine='MYISAM' as select * from t5; -create table t66 engine='MYISAM' as select * from t6; -alter table t11 -partition by range(datediff(col1, '2006-01-01')) -(partition p0 values less than (15), -partition p1 values less than maxvalue); -alter table t22 -partition by list(datediff(col1, '2006-01-01')) -(partition p0 values in (0,1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -alter table t33 -partition by hash(datediff(col1, '2006-01-01')); -alter table t44 -partition by range(colint) -subpartition by hash(datediff(col1, '2006-01-01')) subpartitions 2 -(partition p0 values less than (15), -partition p1 values less than maxvalue); -alter table t55 -partition by list(colint) -subpartition by hash(datediff(col1, '2006-01-01')) subpartitions 2 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -alter table t66 -partition by range(colint) -(partition p0 values less than (datediff('2006-02-02', '2006-01-01')), -partition p1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-01-17 -2006-02-06 -select * from t22 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t33 order by col1; -col1 -2006-01-17 -2006-01-25 -2006-02-06 -select * from t44 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t55 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 ---------------------------- ----- some alter table begin ---------------------------- -alter table t11 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-01-17 -2006-02-06 -alter table t11 -reorganize partition s1 into -(partition p0 values less than (15), -partition p1 values less than maxvalue); -select * from t11 order by col1; -col1 -2006-01-17 -2006-02-06 -alter table t55 -partition by list(colint) -subpartition by hash(datediff(col1, '2006-01-01')) subpartitions 5 -(partition p0 values in (1,2,3,4,5,6,7,8,9,10), -partition p1 values in (11,12,13,14,15,16,17,18,19,20), -partition p2 values in (21,22,23,24,25,26,27,28,29,30), -partition p3 values in (31,32,33,34,35,36,37,38,39,40), -partition p4 values in (41,42,43,44,45,46,47,48,49,50), -partition p5 values in (51,52,53,54,55,56,57,58,59,60) -); -show create table t55; -Table Create Table -t55 CREATE TABLE `t55` ( - `colint` int(11) DEFAULT NULL, - `col1` date DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -/*!50100 PARTITION BY LIST (colint) -SUBPARTITION BY HASH (datediff(col1, '2006-01-01')) -SUBPARTITIONS 5 -(PARTITION p0 VALUES IN (1,2,3,4,5,6,7,8,9,10) ENGINE = MyISAM, - PARTITION p1 VALUES IN (11,12,13,14,15,16,17,18,19,20) ENGINE = MyISAM, - PARTITION p2 VALUES IN (21,22,23,24,25,26,27,28,29,30) ENGINE = MyISAM, - PARTITION p3 VALUES IN (31,32,33,34,35,36,37,38,39,40) ENGINE = MyISAM, - PARTITION p4 VALUES IN (41,42,43,44,45,46,47,48,49,50) ENGINE = MyISAM, - PARTITION p5 VALUES IN (51,52,53,54,55,56,57,58,59,60) ENGINE = MyISAM) */ -select * from t55 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (datediff('2006-02-02', '2006-01-01')), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition p0,p1 into -(partition s1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 -alter table t66 -reorganize partition s1 into -(partition p0 values less than (datediff('2006-02-02', '2006-01-01')), -partition p1 values less than maxvalue); -select * from t66 order by colint; -colint col1 -1 2006-02-06 -2 2006-01-17 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with datediff(col1, '2006-01-01') +--- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20) ------------------------------------------------------------------------- -delete from t1 where col1='2006-01-17'; -delete from t2 where col1='2006-01-17'; -delete from t3 where col1='2006-01-17'; -delete from t4 where col1='2006-01-17'; -delete from t5 where col1='2006-01-17'; -delete from t6 where col1='2006-01-17'; +delete from t1 where col1='14:30:45'; +delete from t2 where col1='14:30:45'; +delete from t3 where col1='14:30:45'; +delete from t4 where col1='14:30:45'; +delete from t5 where col1='14:30:45'; +delete from t6 where col1='14:30:45'; select * from t1 order by col1; col1 -2006-02-06 +10:33:11 select * from t2 order by col1; col1 -2006-01-25 -2006-02-06 +10:33:11 +21:59:22 select * from t3 order by col1; col1 -2006-01-25 -2006-02-06 +10:33:11 +21:59:22 select * from t4 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t5 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -insert into t1 values ('2006-01-17'); -insert into t2 values ('2006-01-17'); -insert into t3 values ('2006-01-17'); -insert into t4 values (60,'2006-01-17'); -insert into t5 values (60,'2006-01-17'); -insert into t6 values (60,'2006-01-17'); +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +insert into t1 values ('14:30:45'); +insert into t2 values ('14:30:45'); +insert into t3 values ('14:30:45'); +insert into t4 values (60,'14:30:45'); +insert into t5 values (60,'14:30:45'); +insert into t6 values (60,'14:30:45'); select * from t1 order by col1; col1 -2006-01-17 -2006-02-06 +10:33:11 +14:30:45 select * from t2 order by col1; col1 -2006-01-17 -2006-01-25 -2006-02-06 +10:33:11 +14:30:45 +21:59:22 select * from t3 order by col1; col1 -2006-01-17 -2006-01-25 -2006-02-06 +10:33:11 +14:30:45 +21:59:22 select * from t4 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 select * from t5 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 select * from t6 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 alter table t1 drop partition p0; alter table t2 drop partition p0; alter table t4 drop partition p0; @@ -11434,95 +9387,99 @@ alter table t5 drop partition p0; alter table t6 drop partition p0; select * from t1 order by col1; col1 -2006-01-17 -2006-02-06 +10:33:11 +14:30:45 select * from t2 order by col1; col1 -2006-01-17 -2006-01-25 -2006-02-06 +10:33:11 +14:30:45 +21:59:22 select * from t3 order by col1; col1 -2006-01-17 -2006-01-25 -2006-02-06 +10:33:11 +14:30:45 +21:59:22 select * from t4 order by colint; colint col1 -60 2006-01-17 +60 14:30:45 select * from t5 order by colint; colint col1 -60 2006-01-17 +60 14:30:45 select * from t6 order by colint; colint col1 -60 2006-01-17 ------------------------------------------------------------------------- ---- Delete rows and partitions of tables with datediff(col1, '2006-01-01') +--- Delete rows and partitions of tables with time_to_sec(col1)-(time_to_sec(col1)-20) ------------------------------------------------------------------------- -delete from t11 where col1='2006-01-17'; -delete from t22 where col1='2006-01-17'; -delete from t33 where col1='2006-01-17'; -delete from t44 where col1='2006-01-17'; -delete from t55 where col1='2006-01-17'; -delete from t66 where col1='2006-01-17'; +delete from t11 where col1='14:30:45'; +delete from t22 where col1='14:30:45'; +delete from t33 where col1='14:30:45'; +delete from t44 where col1='14:30:45'; +delete from t55 where col1='14:30:45'; +delete from t66 where col1='14:30:45'; select * from t11 order by col1; col1 -2006-02-06 +10:33:11 select * from t22 order by col1; col1 -2006-01-25 -2006-02-06 +10:33:11 +21:59:22 select * from t33 order by col1; col1 -2006-01-25 -2006-02-06 +10:33:11 +21:59:22 select * from t44 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 select * from t55 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -insert into t11 values ('2006-01-17'); -insert into t22 values ('2006-01-17'); -insert into t33 values ('2006-01-17'); -insert into t44 values (60,'2006-01-17'); -insert into t55 values (60,'2006-01-17'); -insert into t66 values (60,'2006-01-17'); +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +insert into t11 values ('14:30:45'); +insert into t22 values ('14:30:45'); +insert into t33 values ('14:30:45'); +insert into t44 values (60,'14:30:45'); +insert into t55 values (60,'14:30:45'); +insert into t66 values (60,'14:30:45'); select * from t11 order by col1; col1 -2006-01-17 -2006-02-06 +10:33:11 +14:30:45 select * from t22 order by col1; col1 -2006-01-17 -2006-01-25 -2006-02-06 +10:33:11 +14:30:45 +21:59:22 select * from t33 order by col1; col1 -2006-01-17 -2006-01-25 -2006-02-06 +10:33:11 +14:30:45 +21:59:22 select * from t44 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 select * from t55 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 select * from t66 order by colint; colint col1 -1 2006-02-06 -3 2006-01-25 -4 2006-02-05 -60 2006-01-17 +1 10:33:11 +2 04:30:01 +3 00:59:22 +4 05:30:34 +60 14:30:45 alter table t11 drop partition p0; alter table t22 drop partition p0; alter table t44 drop partition p0; @@ -11530,27 +9487,26 @@ alter table t55 drop partition p0; alter table t66 drop partition p0; select * from t11 order by col1; col1 -2006-01-17 -2006-02-06 +10:33:11 +14:30:45 select * from t22 order by col1; col1 -2006-01-17 -2006-01-25 -2006-02-06 +10:33:11 +14:30:45 +21:59:22 select * from t33 order by col1; col1 -2006-01-17 -2006-01-25 -2006-02-06 +10:33:11 +14:30:45 +21:59:22 select * from t44 order by colint; colint col1 -60 2006-01-17 +60 14:30:45 select * from t55 order by colint; colint col1 -60 2006-01-17 +60 14:30:45 select * from t66 order by colint; colint col1 -60 2006-01-17 ------------------------- ---- some alter table end ------------------------- diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 86e2603cd01..0151820cef9 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1821,15 +1821,16 @@ while ($cnt) drop table t1; # -# BUG#32272: partition crash 1: enum column +# BUG#32772: partition crash 1: enum column # +# Note that month(int_col) is disallowed after bug#54483. create table t1 ( c0 int, c1 bigint, c2 set('sweet'), key (c2,c1,c0), key(c0) -) engine=myisam partition by hash (month(c0)) partitions 5; +) engine=myisam partition by hash (c0) partitions 5; --disable_warnings insert ignore into t1 set c0 = -6502262, c1 = 3992917, c2 = 35019; diff --git a/mysql-test/t/partition_error.test b/mysql-test/t/partition_error.test index d3f10628254..b222b02252b 100644 --- a/mysql-test/t/partition_error.test +++ b/mysql-test/t/partition_error.test @@ -10,6 +10,670 @@ drop table if exists t1; let $MYSQLD_DATADIR= `SELECT @@datadir`; +--echo # +--echo # Bug#54483: valgrind errors when making warnings for multiline inserts +--echo # into partition +--echo # +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARBINARY(10)) +PARTITION BY RANGE (DAYOFWEEK(a)) +(PARTITION a1 VALUES LESS THAN (60)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a CHAR(10)) +PARTITION BY RANGE (DAYOFWEEK(a)) +(PARTITION a1 VALUES LESS THAN (60)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY RANGE (DAYOFWEEK(a)) +(PARTITION a1 VALUES LESS THAN (60)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIMESTAMP) +PARTITION BY RANGE (DAYOFWEEK(a)) +(PARTITION a1 VALUES LESS THAN (60)); +CREATE TABLE t1 (a DATE) +PARTITION BY RANGE (DAYOFWEEK(a)) +(PARTITION a1 VALUES LESS THAN (60)); +INSERT INTO t1 VALUES ('test'),('a'),('5'); +SHOW WARNINGS; +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY RANGE (DAYOFWEEK(a)) +(PARTITION a1 VALUES LESS THAN (60)); +INSERT INTO t1 VALUES ('test'),('a'),('5'); +SHOW WARNINGS; +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY RANGE (DAYOFWEEK(a)) +(PARTITION a1 VALUES LESS THAN (60)); +SHOW WARNINGS; + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (TO_DAYS(a)); +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (TO_DAYS(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (TO_DAYS(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (TO_DAYS(a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (TO_DAYS(a)); + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (DAYOFMONTH(a)); +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (DAYOFMONTH(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (DAYOFMONTH(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (DAYOFMONTH(a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (DAYOFMONTH(a)); + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (MONTH(a)); +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (MONTH(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (MONTH(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (MONTH(a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (MONTH(a)); + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (DAYOFYEAR(a)); +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (DAYOFYEAR(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (DAYOFYEAR(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (DAYOFYEAR(a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (DAYOFYEAR(a)); + +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (HOUR(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (HOUR(a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (HOUR(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (HOUR(a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (HOUR(a)); + +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (MINUTE(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (MINUTE(a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (MINUTE(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (MINUTE(a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (MINUTE(a)); + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (QUARTER(a)); +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (QUARTER(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (QUARTER(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (QUARTER(a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (QUARTER(a)); + +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (SECOND(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (SECOND(a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (SECOND(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (SECOND(a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (SECOND(a)); + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (YEARWEEK(a)); +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (YEARWEEK(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (YEARWEEK(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (YEARWEEK(a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (YEARWEEK(a)); + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (WEEKDAY(a)); +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (WEEKDAY(a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (WEEKDAY(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (WEEKDAY(a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (WEEKDAY(a)); +--echo # TO_SECONDS() is added in 5.5. + +--error ER_PARSE_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (TO_SECONDS(a)); +#--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +#CREATE TABLE t1 (a TIME) +#PARTITION BY HASH (TO_SECONDS(a)); +#CREATE TABLE t1 (a DATE) +#PARTITION BY HASH (TO_SECONDS(a)); +#DROP TABLE t1; +#CREATE TABLE t1 (a DATETIME) +#PARTITION BY HASH (TO_SECONDS(a)); +#DROP TABLE t1; +#--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +#CREATE TABLE t1 (a VARCHAR(10)) +#PARTITION BY HASH (TO_SECONDS(a)); +#--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +#CREATE TABLE t1 (a INT) +#PARTITION BY HASH (TO_SECONDS(a)); + +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (TIME_TO_SEC(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (TIME_TO_SEC(a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (TIME_TO_SEC(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (TIME_TO_SEC(a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (TIME_TO_SEC(a)); + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (FROM_DAYS(a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (FROM_DAYS(a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (FROM_DAYS(a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (TO_DAYS(FROM_DAYS(a))); +--error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (FROM_DAYS(a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (TO_DAYS(FROM_DAYS(a))); +--error ER_PARTITION_FUNC_NOT_ALLOWED_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (FROM_DAYS(a)); + +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (MICROSECOND(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (MICROSECOND(a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (MICROSECOND(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (MICROSECOND(a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (MICROSECOND(a)); +--echo # Bug#57071 +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 +(`date` date, + `extracted_week` int, + `yearweek` int, + `week` int, + `default_week_format` int) +PARTITION BY LIST (EXTRACT(WEEK FROM date) % 3) +(PARTITION p0 VALUES IN (0), + PARTITION p1 VALUES IN (1), + PARTITION p2 VALUES IN (2)); +CREATE TABLE t1 +(`date` date, + `extracted_week` int, + `yearweek` int, + `week` int, + `default_week_format` int); +SET @old_default_week_format := @@default_week_format; +SET default_week_format = 0; +INSERT INTO t1 VALUES ('2000-01-01', EXTRACT(WEEK FROM '2000-01-01'), YEARWEEK('2000-01-01'), WEEK('2000-01-01'), @@default_week_format); +SET default_week_format = 1; +INSERT INTO t1 VALUES ('2000-01-01', EXTRACT(WEEK FROM '2000-01-01'), YEARWEEK('2000-01-01'), WEEK('2000-01-01'), @@default_week_format); +SET default_week_format = 2; +INSERT INTO t1 VALUES ('2000-01-01', EXTRACT(WEEK FROM '2000-01-01'), YEARWEEK('2000-01-01'), WEEK('2000-01-01'), @@default_week_format); +SET default_week_format = 3; +INSERT INTO t1 VALUES ('2000-01-01', EXTRACT(WEEK FROM '2000-01-01'), YEARWEEK('2000-01-01'), WEEK('2000-01-01'), @@default_week_format); +SET default_week_format = 4; +INSERT INTO t1 VALUES ('2000-01-01', EXTRACT(WEEK FROM '2000-01-01'), YEARWEEK('2000-01-01'), WEEK('2000-01-01'), @@default_week_format); +SET default_week_format = 5; +INSERT INTO t1 VALUES ('2000-01-01', EXTRACT(WEEK FROM '2000-01-01'), YEARWEEK('2000-01-01'), WEEK('2000-01-01'), @@default_week_format); +SET default_week_format = 6; +INSERT INTO t1 VALUES ('2000-01-01', EXTRACT(WEEK FROM '2000-01-01'), YEARWEEK('2000-01-01'), WEEK('2000-01-01'), @@default_week_format); +SET default_week_format = 7; +INSERT INTO t1 VALUES ('2000-01-01', EXTRACT(WEEK FROM '2000-01-01'), YEARWEEK('2000-01-01'), WEEK('2000-01-01'), @@default_week_format); +SELECT * FROM t1; +SET default_week_format = @old_default_week_format; +DROP TABLE t1; + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(YEAR FROM a)); +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(YEAR FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(YEAR FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(YEAR FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(YEAR FROM a)); + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(YEAR_MONTH FROM a)); +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(YEAR_MONTH FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(YEAR_MONTH FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(YEAR_MONTH FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(YEAR_MONTH FROM a)); + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(QUARTER FROM a)); +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(QUARTER FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(QUARTER FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(QUARTER FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(QUARTER FROM a)); + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(MONTH FROM a)); +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(MONTH FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(MONTH FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(MONTH FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(MONTH FROM a)); + +--echo # EXTRACT(WEEK...) is disallowed, see bug#57071. +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(WEEK FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(WEEK FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(WEEK FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(WEEK FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(WEEK FROM a)); + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(DAY FROM a)); +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(DAY FROM a)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(DAY FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(DAY FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(DAY FROM a)); + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(DAY_HOUR FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(DAY_HOUR FROM a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(DAY_HOUR FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(DAY_HOUR FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(DAY_HOUR FROM a)); + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(DAY_MINUTE FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(DAY_MINUTE FROM a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(DAY_MINUTE FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(DAY_MINUTE FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(DAY_MINUTE FROM a)); + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(DAY_SECOND FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(DAY_SECOND FROM a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(DAY_SECOND FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(DAY_SECOND FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(DAY_SECOND FROM a)); + +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(HOUR FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(HOUR FROM a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(HOUR FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(HOUR FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(HOUR FROM a)); + +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(HOUR_MINUTE FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(HOUR_MINUTE FROM a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(HOUR_MINUTE FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(HOUR_MINUTE FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(HOUR_MINUTE FROM a)); + +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(HOUR_SECOND FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(HOUR_SECOND FROM a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(HOUR_SECOND FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(HOUR_SECOND FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(HOUR_SECOND FROM a)); + +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(MINUTE FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(MINUTE FROM a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(MINUTE FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(MINUTE FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(MINUTE FROM a)); + +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(MINUTE_SECOND FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(MINUTE_SECOND FROM a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(MINUTE_SECOND FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(MINUTE_SECOND FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(MINUTE_SECOND FROM a)); + +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(SECOND FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(SECOND FROM a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(SECOND FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(SECOND FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(SECOND FROM a)); + +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(MICROSECOND FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(MICROSECOND FROM a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(MICROSECOND FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(MICROSECOND FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(MICROSECOND FROM a)); + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(DAY_MICROSECOND FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(DAY_MICROSECOND FROM a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(DAY_MICROSECOND FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(DAY_MICROSECOND FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(DAY_MICROSECOND FROM a)); + +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(HOUR_MICROSECOND FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(HOUR_MICROSECOND FROM a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(HOUR_MICROSECOND FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(HOUR_MICROSECOND FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(HOUR_MICROSECOND FROM a)); + +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(MINUTE_MICROSECOND FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(MINUTE_MICROSECOND FROM a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(MINUTE_MICROSECOND FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(MINUTE_MICROSECOND FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(MINUTE_MICROSECOND FROM a)); + +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (EXTRACT(SECOND_MICROSECOND FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (EXTRACT(SECOND_MICROSECOND FROM a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (EXTRACT(SECOND_MICROSECOND FROM a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (EXTRACT(SECOND_MICROSECOND FROM a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (EXTRACT(SECOND_MICROSECOND FROM a)); + +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a TIME, b DATE) +PARTITION BY HASH (DATEDIFF(a, b)); +CREATE TABLE t1 (a DATE, b DATETIME) +PARTITION BY HASH (DATEDIFF(a, b)); +DROP TABLE t1; +CREATE TABLE t1 (a DATETIME, b DATE) +PARTITION BY HASH (DATEDIFF(a, b)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE, b VARCHAR(10)) +PARTITION BY HASH (DATEDIFF(a, b)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT, b DATETIME) +PARTITION BY HASH (DATEDIFF(a, b)); + +CREATE TABLE t1 (a TIME) +PARTITION BY HASH (TIME_TO_SEC(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a DATE) +PARTITION BY HASH (TIME_TO_SEC(a)); +CREATE TABLE t1 (a DATETIME) +PARTITION BY HASH (TIME_TO_SEC(a)); +DROP TABLE t1; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a VARCHAR(10)) +PARTITION BY HASH (TIME_TO_SEC(a)); +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +CREATE TABLE t1 (a INT) +PARTITION BY HASH (TIME_TO_SEC(a)); + + --echo # --echo # Bug#49161: Out of memory; restart server and try again (needed 2 bytes) --echo # diff --git a/sql/item.h b/sql/item.h index 57abb43010e..d0fbdc81d0e 100644 --- a/sql/item.h +++ b/sql/item.h @@ -966,11 +966,11 @@ public: virtual bool set_no_const_sub(uchar *arg) { return FALSE; } virtual Item *replace_equal_field(uchar * arg) { return this; } /* - Check if an expression value depends on the current timezone. Used by - partitioning code to reject timezone-dependent expressions in a - (sub)partitioning function. + Check if an expression value has allowed arguments, like DATE/DATETIME + for date functions. Also used by partitioning code to reject + timezone-dependent expressions in a (sub)partitioning function. */ - virtual bool is_timezone_dependent_processor(uchar *bool_arg) + virtual bool is_arguments_valid_processor(uchar *bool_arg) { return FALSE; } diff --git a/sql/item_func.h b/sql/item_func.h index 26a7e033692..176e3dc4d44 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -189,6 +189,7 @@ public: null_value=1; return 0.0; } + bool has_timestamp_args() { DBUG_ASSERT(fixed == TRUE); @@ -200,6 +201,45 @@ public: } return FALSE; } + + bool has_date_args() + { + DBUG_ASSERT(fixed == TRUE); + for (uint i= 0; i < arg_count; i++) + { + if (args[i]->type() == Item::FIELD_ITEM && + (args[i]->field_type() == MYSQL_TYPE_DATE || + args[i]->field_type() == MYSQL_TYPE_DATETIME)) + return TRUE; + } + return FALSE; + } + + bool has_time_args() + { + DBUG_ASSERT(fixed == TRUE); + for (uint i= 0; i < arg_count; i++) + { + if (args[i]->type() == Item::FIELD_ITEM && + (args[i]->field_type() == MYSQL_TYPE_TIME || + args[i]->field_type() == MYSQL_TYPE_DATETIME)) + return TRUE; + } + return FALSE; + } + + bool has_datetime_args() + { + DBUG_ASSERT(fixed == TRUE); + for (uint i= 0; i < arg_count; i++) + { + if (args[i]->type() == Item::FIELD_ITEM && + args[i]->field_type() == MYSQL_TYPE_DATETIME) + return TRUE; + } + return FALSE; + } + /* We assume the result of any function that has a TIMESTAMP argument to be timezone-dependent, since a TIMESTAMP value in both numeric and string @@ -208,7 +248,7 @@ public: representation of a TIMESTAMP argument verbatim, and thus does not depend on the timezone. */ - virtual bool is_timezone_dependent_processor(uchar *bool_arg) + virtual bool is_arguments_valid_processor(uchar *bool_arg) { return has_timestamp_args(); } diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 47bb9509582..b6356504788 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -70,6 +70,10 @@ public: enum_monotonicity_info get_monotonicity_info() const; longlong val_int_endpoint(bool left_endp, bool *incl_endp); bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool is_arguments_valid_processor(uchar *int_arg) + { + return !has_date_args(); + } }; @@ -86,6 +90,10 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool is_arguments_valid_processor(uchar *int_arg) + { + return !has_date_args(); + } }; @@ -111,6 +119,10 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool is_arguments_valid_processor(uchar *int_arg) + { + return !has_date_args(); + } }; @@ -140,6 +152,10 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool is_arguments_valid_processor(uchar *int_arg) + { + return !has_date_args(); + } }; @@ -156,6 +172,10 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool is_arguments_valid_processor(uchar *int_arg) + { + return !has_time_args(); + } }; @@ -172,6 +192,10 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool is_arguments_valid_processor(uchar *int_arg) + { + return !has_time_args(); + } }; @@ -188,6 +212,10 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool is_arguments_valid_processor(uchar *int_arg) + { + return !has_date_args(); + } }; @@ -204,6 +232,10 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool is_arguments_valid_processor(uchar *int_arg) + { + return !has_time_args(); + } }; @@ -234,6 +266,10 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool is_arguments_valid_processor(uchar *int_arg) + { + return !has_date_args(); + } }; @@ -252,6 +288,10 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool is_arguments_valid_processor(uchar *int_arg) + { + return !has_date_args(); + } }; @@ -282,6 +322,10 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool is_arguments_valid_processor(uchar *int_arg) + { + return !has_date_args(); + } }; class Item_func_dayname :public Item_func_weekday @@ -311,7 +355,7 @@ public: (and thus may not be used as a partitioning function) when its argument is NOT of the TIMESTAMP type. */ - bool is_timezone_dependent_processor(uchar *int_arg) + bool is_arguments_valid_processor(uchar *int_arg) { return !has_timestamp_args(); } @@ -336,6 +380,10 @@ public: max_length=10*MY_CHARSET_BIN_MB_MAXLEN; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool is_arguments_valid_processor(uchar *int_arg) + { + return !has_time_args(); + } }; @@ -589,6 +637,10 @@ public: const char *func_name() const { return "from_days"; } bool get_date(MYSQL_TIME *res, uint fuzzy_date); bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool is_arguments_valid_processor(uchar *int_arg) + { + return has_date_args() || has_time_args(); + } }; @@ -715,6 +767,42 @@ class Item_extract :public Item_int_func bool eq(const Item *item, bool binary_cmp) const; virtual void print(String *str, enum_query_type query_type); bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool is_arguments_valid_processor(uchar *int_arg) + { + switch (int_type) { + case INTERVAL_YEAR: + case INTERVAL_YEAR_MONTH: + case INTERVAL_QUARTER: + case INTERVAL_MONTH: + /* case INTERVAL_WEEK: Not allowed as partitioning function, bug#57071 */ + case INTERVAL_DAY: + return !has_date_args(); + case INTERVAL_DAY_HOUR: + case INTERVAL_DAY_MINUTE: + case INTERVAL_DAY_SECOND: + case INTERVAL_DAY_MICROSECOND: + return !has_datetime_args(); + case INTERVAL_HOUR: + case INTERVAL_HOUR_MINUTE: + case INTERVAL_HOUR_SECOND: + case INTERVAL_MINUTE: + case INTERVAL_MINUTE_SECOND: + case INTERVAL_SECOND: + case INTERVAL_MICROSECOND: + case INTERVAL_HOUR_MICROSECOND: + case INTERVAL_MINUTE_MICROSECOND: + case INTERVAL_SECOND_MICROSECOND: + return !has_time_args(); + default: + /* + INTERVAL_LAST is only an end marker, + INTERVAL_WEEK depends on default_week_format which is a session + variable and cannot be used for partitioning. See bug#57071. + */ + break; + } + return true; + } }; @@ -965,6 +1053,10 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool is_arguments_valid_processor(uchar *int_arg) + { + return !has_time_args(); + } }; diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 48d50c3a303..835ddcc4bc6 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1019,7 +1019,7 @@ static bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, opening existing tables for easier maintenance. This exception should be deprecated at some point in future so that we always throw an error. */ - if (func_expr->walk(&Item::is_timezone_dependent_processor, + if (func_expr->walk(&Item::is_arguments_valid_processor, 0, NULL)) { if (is_create_table_ind) -- cgit v1.2.1 From 991815352259545d80dc1049d65854b08bd799c4 Mon Sep 17 00:00:00 2001 From: Mattias Jonsson Date: Wed, 22 Dec 2010 15:45:17 +0100 Subject: Bug#54483: valgrind errors when making warnings for multiline inserts into partition Bug#57071: EXTRACT(WEEK from date_col) cannot be allowed as partitioning function Renamed function according to reviewers comments. --- sql/item.h | 2 +- sql/item_func.h | 2 +- sql/item_timefunc.h | 32 ++++++++++++++++---------------- sql/sql_partition.cc | 11 ++++++----- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/sql/item.h b/sql/item.h index d0fbdc81d0e..e3df08e7512 100644 --- a/sql/item.h +++ b/sql/item.h @@ -970,7 +970,7 @@ public: for date functions. Also used by partitioning code to reject timezone-dependent expressions in a (sub)partitioning function. */ - virtual bool is_arguments_valid_processor(uchar *bool_arg) + virtual bool check_valid_arguments_processor(uchar *bool_arg) { return FALSE; } diff --git a/sql/item_func.h b/sql/item_func.h index 176e3dc4d44..5c935e8f10f 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -248,7 +248,7 @@ public: representation of a TIMESTAMP argument verbatim, and thus does not depend on the timezone. */ - virtual bool is_arguments_valid_processor(uchar *bool_arg) + virtual bool check_valid_arguments_processor(uchar *bool_arg) { return has_timestamp_args(); } diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index b6356504788..f4299460abf 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -70,7 +70,7 @@ public: enum_monotonicity_info get_monotonicity_info() const; longlong val_int_endpoint(bool left_endp, bool *incl_endp); bool check_partition_func_processor(uchar *int_arg) {return FALSE;} - bool is_arguments_valid_processor(uchar *int_arg) + bool check_valid_arguments_processor(uchar *int_arg) { return !has_date_args(); } @@ -90,7 +90,7 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} - bool is_arguments_valid_processor(uchar *int_arg) + bool check_valid_arguments_processor(uchar *int_arg) { return !has_date_args(); } @@ -119,7 +119,7 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} - bool is_arguments_valid_processor(uchar *int_arg) + bool check_valid_arguments_processor(uchar *int_arg) { return !has_date_args(); } @@ -152,7 +152,7 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} - bool is_arguments_valid_processor(uchar *int_arg) + bool check_valid_arguments_processor(uchar *int_arg) { return !has_date_args(); } @@ -172,7 +172,7 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} - bool is_arguments_valid_processor(uchar *int_arg) + bool check_valid_arguments_processor(uchar *int_arg) { return !has_time_args(); } @@ -192,7 +192,7 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} - bool is_arguments_valid_processor(uchar *int_arg) + bool check_valid_arguments_processor(uchar *int_arg) { return !has_time_args(); } @@ -212,7 +212,7 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} - bool is_arguments_valid_processor(uchar *int_arg) + bool check_valid_arguments_processor(uchar *int_arg) { return !has_date_args(); } @@ -232,7 +232,7 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} - bool is_arguments_valid_processor(uchar *int_arg) + bool check_valid_arguments_processor(uchar *int_arg) { return !has_time_args(); } @@ -266,7 +266,7 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} - bool is_arguments_valid_processor(uchar *int_arg) + bool check_valid_arguments_processor(uchar *int_arg) { return !has_date_args(); } @@ -288,7 +288,7 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} - bool is_arguments_valid_processor(uchar *int_arg) + bool check_valid_arguments_processor(uchar *int_arg) { return !has_date_args(); } @@ -322,7 +322,7 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} - bool is_arguments_valid_processor(uchar *int_arg) + bool check_valid_arguments_processor(uchar *int_arg) { return !has_date_args(); } @@ -355,7 +355,7 @@ public: (and thus may not be used as a partitioning function) when its argument is NOT of the TIMESTAMP type. */ - bool is_arguments_valid_processor(uchar *int_arg) + bool check_valid_arguments_processor(uchar *int_arg) { return !has_timestamp_args(); } @@ -380,7 +380,7 @@ public: max_length=10*MY_CHARSET_BIN_MB_MAXLEN; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} - bool is_arguments_valid_processor(uchar *int_arg) + bool check_valid_arguments_processor(uchar *int_arg) { return !has_time_args(); } @@ -637,7 +637,7 @@ public: const char *func_name() const { return "from_days"; } bool get_date(MYSQL_TIME *res, uint fuzzy_date); bool check_partition_func_processor(uchar *int_arg) {return FALSE;} - bool is_arguments_valid_processor(uchar *int_arg) + bool check_valid_arguments_processor(uchar *int_arg) { return has_date_args() || has_time_args(); } @@ -767,7 +767,7 @@ class Item_extract :public Item_int_func bool eq(const Item *item, bool binary_cmp) const; virtual void print(String *str, enum_query_type query_type); bool check_partition_func_processor(uchar *int_arg) {return FALSE;} - bool is_arguments_valid_processor(uchar *int_arg) + bool check_valid_arguments_processor(uchar *int_arg) { switch (int_type) { case INTERVAL_YEAR: @@ -1053,7 +1053,7 @@ public: maybe_null=1; } bool check_partition_func_processor(uchar *int_arg) {return FALSE;} - bool is_arguments_valid_processor(uchar *int_arg) + bool check_valid_arguments_processor(uchar *int_arg) { return !has_time_args(); } diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index 835ddcc4bc6..f8e5130880b 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -1014,12 +1014,13 @@ static bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, } /* - We don't allow creating partitions with timezone-dependent expressions as - a (sub)partitioning function, but we want to allow such expressions when - opening existing tables for easier maintenance. This exception should be - deprecated at some point in future so that we always throw an error. + We don't allow creating partitions with expressions with non matching + arguments as a (sub)partitioning function, + but we want to allow such expressions when opening existing tables for + easier maintenance. This exception should be deprecated at some point + in future so that we always throw an error. */ - if (func_expr->walk(&Item::is_arguments_valid_processor, + if (func_expr->walk(&Item::check_valid_arguments_processor, 0, NULL)) { if (is_create_table_ind) -- cgit v1.2.1 From f4adb7c6e4cd855499d92c9352dd4d75aab5e1b0 Mon Sep 17 00:00:00 2001 From: Jan Wedvik Date: Tue, 11 Jan 2011 12:09:54 +0100 Subject: Fix for bug#58553, "Queries with pushed conditions causes 'explain extended' to crash mysqld". handler::pushed_cond was not always properly reset when table objects where recycled via the table cache. handler::pushed_cond is now set to NULL in handler::ha_reset(). This should prevent pushed conditions from (incorrectly) re-apperaring in later queries. --- sql/handler.cc | 1 + sql/sql_base.cc | 5 +++++ sql/sql_select.cc | 1 - 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/sql/handler.cc b/sql/handler.cc index ce4e4a9e3a9..711d2942ce0 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -4657,6 +4657,7 @@ int handler::ha_reset() free_io_cache(table); /* reset the bitmaps to point to defaults */ table->default_column_bitmaps(); + pushed_cond= NULL; DBUG_RETURN(reset()); } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 13876b8b331..f609a073161 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2993,6 +2993,11 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, table->insert_values= 0; table->fulltext_searched= 0; table->file->ft_handler= 0; + /* + Check that there is no reference to a condtion from an earlier query + (cf. Bug#58553). + */ + DBUG_ASSERT(table->file->pushed_cond == NULL); table->reginfo.impossible_range= 0; /* Catch wrong handling of the auto_increment_field_not_null. */ DBUG_ASSERT(!table->auto_increment_field_not_null); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9e0a82aa342..067f3cfc95d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -6380,7 +6380,6 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) tab->select_cond=sel->cond=tmp; /* Push condition to storage engine if this is enabled and the condition is not guarded */ - tab->table->file->pushed_cond= NULL; if (thd->variables.engine_condition_pushdown) { COND *push_cond= -- cgit v1.2.1 From 409f7db22b71d0f38a9d99dbc23d48daf551fd9c Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Tue, 11 Jan 2011 11:44:38 -0200 Subject: Bug#42054: SELECT CURDATE() is returning bad value The problem from a user point of view was that on Solaris the time related functions (e.g. NOW(), SYSDATE(), etc) would always return a fixed time. This bug was happening due to a logic in the time retrieving wrapper function which would only call the time() function every half second. This interval between calls would be calculated using the gethrtime() and the logic relied on the fact that time returned by it is monotonic. Unfortunately, due to bugs in the gethrtime() implementation, there are some cases where the time returned by it can drift (See Solaris bug id 6600939), potentially causing the interval calculation logic to fail. The solution is to retrieve the correct time whenever a drift in the time returned by gethrtime() is detected. That is, do not use the cached time whenever the values (previous and current) returned by gethrtime() are not monotonically increasing. --- mysys/my_getsystime.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mysys/my_getsystime.c b/mysys/my_getsystime.c index b692b18bfc7..dfd99f6380d 100644 --- a/mysys/my_getsystime.c +++ b/mysys/my_getsystime.c @@ -170,7 +170,13 @@ ulonglong my_micro_time_and_time(time_t *time_arg) pthread_mutex_lock(&THR_LOCK_time); cur_gethrtime= gethrtime(); - if ((cur_gethrtime - prev_gethrtime) > DELTA_FOR_SECONDS) + /* + Due to bugs in the Solaris (x86) implementation of gethrtime(), + the time returned by it might not be monotonic. Don't use the + cached time(2) value if this is a case. + */ + if ((prev_gethrtime > cur_gethrtime) || + ((cur_gethrtime - prev_gethrtime) > DELTA_FOR_SECONDS)) { cur_time= time(0); prev_gethrtime= cur_gethrtime; -- cgit v1.2.1 From 5bd50b80a75d4d5246e40d032e14397bcde036bb Mon Sep 17 00:00:00 2001 From: Dmitry Shulga Date: Tue, 11 Jan 2011 21:18:25 +0600 Subject: Fixed Bug#58887 - server not throwing "Packet too large" error if max_allowed_packet >= 16M. This bug was introduced by patch for bug#42503. This patch restores behaviour that there was before patch for bug#42503 was applied. --- sql/net_serv.cc | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/sql/net_serv.cc b/sql/net_serv.cc index d2d3b1903a2..0c559f5619d 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -170,17 +170,7 @@ my_bool net_realloc(NET *net, size_t length) DBUG_ENTER("net_realloc"); DBUG_PRINT("enter",("length: %lu", (ulong) length)); - /* - When compression is off, net->where_b is always 0. - With compression turned on, net->where_b may indicate - that we still have a piece of the previous logical - packet in the buffer, unprocessed. Take it into account - when checking that max_allowed_packet is not exceeded. - This ensures that the client treats max_allowed_packet - limit identically, regardless of compression being on - or off. - */ - if (length >= (net->max_packet_size + net->where_b)) + if (length >= net->max_packet_size) { DBUG_PRINT("error", ("Packet too large. Max size: %lu", net->max_packet_size)); -- cgit v1.2.1 From fc42cbaca3d19eeb1119169056b2fdfcedd96d69 Mon Sep 17 00:00:00 2001 From: Martin Hansson Date: Wed, 12 Jan 2011 09:55:31 +0100 Subject: Bug#58207: invalid memory reads when using default column value and tmptable needed The function DEFAULT() works by modifying the the data buffer pointers (often referred to as 'record' or 'table record') of its argument. This modification is done during name resolution (fix_fields().) Unfortunately, the same modification is done when creating a temporary table, because default values need to propagate to the new table. Fixed by skipping the pointer modification for fields that are arguments to the DEFAULT function. --- mysql-test/r/subselect4.result | 11 +++++++++++ mysql-test/t/subselect4.test | 10 ++++++++++ sql/sql_select.cc | 7 ++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/subselect4.result b/mysql-test/r/subselect4.result index 63265970c4b..47157a61731 100644 --- a/mysql-test/r/subselect4.result +++ b/mysql-test/r/subselect4.result @@ -164,5 +164,16 @@ a b 2 NULL DROP TABLE t1, t2, t3, t4, t5; # +# Bug#58207: invalid memory reads when using default column value and +# tmptable needed +# +CREATE TABLE t(a VARCHAR(245) DEFAULT +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'); +INSERT INTO t VALUES (''),(''),(''),(''),(''),(''),(''),(''),(''),(''),(''); +SELECT * FROM (SELECT default(a) FROM t GROUP BY a) d; +default(a) +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +DROP TABLE t; +# # End of 5.1 tests. # diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test index eb8baf9bac8..b8ab655da42 100644 --- a/mysql-test/t/subselect4.test +++ b/mysql-test/t/subselect4.test @@ -136,6 +136,16 @@ SELECT * FROM t1 WHERE NULL NOT IN ( SELECT c FROM t2 WHERE c = 1 AND c <> 1 ); DROP TABLE t1, t2, t3, t4, t5; +--echo # +--echo # Bug#58207: invalid memory reads when using default column value and +--echo # tmptable needed +--echo # +CREATE TABLE t(a VARCHAR(245) DEFAULT +'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'); +INSERT INTO t VALUES (''),(''),(''),(''),(''),(''),(''),(''),(''),(''),(''); +SELECT * FROM (SELECT default(a) FROM t GROUP BY a) d; +DROP TABLE t; + --echo # --echo # End of 5.1 tests. diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 067f3cfc95d..8cc2ec6a0f8 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9816,7 +9816,12 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, convert_blob_length); if (orig_type == Item::REF_ITEM && orig_modify) ((Item_ref*)orig_item)->set_result_field(result); - if (field->field->eq_def(result)) + /* + Fields that are used as arguments to the DEFAULT() function already have + their data pointers set to the default value during name resulotion. See + Item_default_value::fix_fields. + */ + if (orig_type != Item::DEFAULT_VALUE_ITEM && field->field->eq_def(result)) *default_field= field->field; return result; } -- cgit v1.2.1 From 94fbedd3e3f17a624c5e66f3914b67d9f46d1b2b Mon Sep 17 00:00:00 2001 From: Dmitry Lenev Date: Wed, 12 Jan 2011 16:08:30 +0300 Subject: Fix for bug #58499 "DEFINER-security view selecting from INVOKER-security view access check wrong". When privilege checks were done for tables used from an INVOKER-security view which in its turn was used from a DEFINER-security view connection's active security context was incorrectly used instead of security context with privileges of the second view's creator. This meant that users which had enough rights to access the DEFINER-security view and as result were supposed to be able successfully access it were unable to do so in cases when they didn't have privileges on underlying tables of the INVOKER-security view. This problem was caused by the fact that for INVOKER-security views TABLE_LIST::security_ctx member for underlying tables were set to 0 even in cases when particular view was used from another DEFINER-security view. This meant that when checks of privileges on these underlying tables was done in setup_tables_and_check_access() active connection security context was used instead of context corresponding to the creator of caller view. This fix addresses the problem by ensuring that underlying tables of an INVOKER-security view inherit security context from the view and thus correct security context is used for privilege checks on underlying tables in cases when such view is used from another view with DEFINER-security. --- mysql-test/r/view_grant.result | 126 ++++++++++++++++++++++++++++++++++++ mysql-test/t/view_grant.test | 144 ++++++++++++++++++++++++++++++++++++++++- sql/sql_view.cc | 42 ++++++++---- 3 files changed, 296 insertions(+), 16 deletions(-) diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result index 52c8bc8a3d5..0348a8428a5 100644 --- a/mysql-test/r/view_grant.result +++ b/mysql-test/r/view_grant.result @@ -1248,3 +1248,129 @@ Note 1449 The user specified as a definer ('unknown'@'unknown') does not exist LOCK TABLES v1 READ; ERROR HY000: The user specified as a definer ('unknown'@'unknown') does not exist DROP VIEW v1; +# +# Bug #58499 "DEFINER-security view selecting from INVOKER-security view +# access check wrong". +# +# Check that we correctly handle privileges for various combinations +# of INVOKER and DEFINER-security views using each other. +DROP DATABASE IF EXISTS mysqltest1; +CREATE DATABASE mysqltest1; +USE mysqltest1; +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (j INT); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +# +# 1) DEFINER-security view uses INVOKER-security view (covers +# scenario originally described in the bug report). +CREATE SQL SECURITY INVOKER VIEW v1_uses_t1 AS SELECT * FROM t1; +CREATE SQL SECURITY INVOKER VIEW v1_uses_t2 AS SELECT * FROM t2; +CREATE USER 'mysqluser1'@'%'; +GRANT CREATE VIEW ON mysqltest1.* TO 'mysqluser1'@'%'; +GRANT SELECT ON t1 TO 'mysqluser1'@'%'; +# To be able create 'v2_uses_t2' we also need select on t2. +GRANT SELECT ON t2 TO 'mysqluser1'@'%'; +GRANT SELECT ON v1_uses_t1 TO 'mysqluser1'@'%'; +GRANT SELECT ON v1_uses_t2 TO 'mysqluser1'@'%'; +# +# Connection 'mysqluser1'. +CREATE SQL SECURITY DEFINER VIEW v2_uses_t1 AS SELECT * FROM v1_uses_t1; +CREATE SQL SECURITY DEFINER VIEW v2_uses_t2 AS SELECT * FROM v1_uses_t2; +# +# Connection 'default'. +CREATE USER 'mysqluser2'@'%'; +GRANT SELECT ON v2_uses_t1 TO 'mysqluser2'@'%'; +GRANT SELECT ON v2_uses_t2 TO 'mysqluser2'@'%'; +GRANT SELECT ON t2 TO 'mysqluser2'@'%'; +GRANT CREATE VIEW ON mysqltest1.* TO 'mysqluser2'@'%'; +# Make 'mysqluser1' unable to access t2. +REVOKE SELECT ON t2 FROM 'mysqluser1'@'%'; +# +# Connection 'mysqluser2'. +# The below statement should succeed thanks to suid nature of v2_uses_t1. +SELECT * FROM v2_uses_t1; +i +1 +# The below statement should fail due to suid nature of v2_uses_t2. +SELECT * FROM v2_uses_t2; +ERROR HY000: View 'mysqltest1.v2_uses_t2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +# +# 2) INVOKER-security view uses INVOKER-security view. +# +# Connection 'default'. +DROP VIEW v2_uses_t1, v2_uses_t2; +CREATE SQL SECURITY INVOKER VIEW v2_uses_t1 AS SELECT * FROM v1_uses_t1; +CREATE SQL SECURITY INVOKER VIEW v2_uses_t2 AS SELECT * FROM v1_uses_t2; +GRANT SELECT ON v2_uses_t1 TO 'mysqluser1'@'%'; +GRANT SELECT ON v2_uses_t2 TO 'mysqluser1'@'%'; +GRANT SELECT ON v1_uses_t1 TO 'mysqluser2'@'%'; +GRANT SELECT ON v1_uses_t2 TO 'mysqluser2'@'%'; +# +# Connection 'mysqluser1'. +# For both versions of 'v2' 'mysqluser1' privileges should be used. +SELECT * FROM v2_uses_t1; +i +1 +SELECT * FROM v2_uses_t2; +ERROR HY000: View 'mysqltest1.v2_uses_t2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +# +# Connection 'mysqluser2'. +# And now for both versions of 'v2' 'mysqluser2' privileges should +# be used. +SELECT * FROM v2_uses_t1; +ERROR HY000: View 'mysqltest1.v2_uses_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +SELECT * FROM v2_uses_t2; +j +2 +# +# 3) INVOKER-security view uses DEFINER-security view. +# +# Connection 'default'. +DROP VIEW v1_uses_t1, v1_uses_t2; +# To be able create 'v1_uses_t2' we also need select on t2. +GRANT SELECT ON t2 TO 'mysqluser1'@'%'; +# +# Connection 'mysqluser1'. +CREATE SQL SECURITY DEFINER VIEW v1_uses_t1 AS SELECT * FROM t1; +CREATE SQL SECURITY DEFINER VIEW v1_uses_t2 AS SELECT * FROM t2; +# +# Connection 'default'. +# Make 'mysqluser1' unable to access t2. +REVOKE SELECT ON t2 FROM 'mysqluser1'@'%'; +# +# Connection 'mysqluser2'. +# Due to suid nature of v1_uses_t1 and v1_uses_t2 the first +# select should succeed and the second select should fail. +SELECT * FROM v2_uses_t1; +i +1 +SELECT * FROM v2_uses_t2; +ERROR HY000: View 'mysqltest1.v2_uses_t2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +# +# 4) DEFINER-security view uses DEFINER-security view. +# +# Connection 'default'. +DROP VIEW v2_uses_t1, v2_uses_t2; +# To be able create 'v2_uses_t2' we also need select on t2. +GRANT SELECT ON t2 TO 'mysqluser1'@'%'; +# +# Connection 'mysqluser2'. +CREATE SQL SECURITY DEFINER VIEW v2_uses_t1 AS SELECT * FROM v1_uses_t1; +CREATE SQL SECURITY DEFINER VIEW v2_uses_t2 AS SELECT * FROM v1_uses_t2; +# +# Connection 'default'. +# Make 'mysqluser1' unable to access t2. +REVOKE SELECT ON t2 FROM 'mysqluser1'@'%'; +# +# Connection 'mysqluser2'. +# Again privileges of creator of innermost views should apply. +SELECT * FROM v2_uses_t1; +i +1 +SELECT * FROM v2_uses_t2; +ERROR HY000: View 'mysqltest1.v2_uses_t2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them +USE test; +DROP DATABASE mysqltest1; +DROP USER 'mysqluser1'@'%'; +DROP USER 'mysqluser2'@'%'; diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test index ba603bde7f8..21c6f376f8a 100644 --- a/mysql-test/t/view_grant.test +++ b/mysql-test/t/view_grant.test @@ -1503,8 +1503,6 @@ SHOW CREATE VIEW v1; DROP TABLE t1; DROP VIEW v1; -# Wait till we reached the initial number of concurrent sessions ---source include/wait_until_count_sessions.inc --echo # --echo # Bug #46019: ERROR 1356 When selecting from within another @@ -1546,3 +1544,145 @@ CREATE DEFINER=`unknown`@`unknown` SQL SECURITY DEFINER VIEW v1 AS SELECT 1; --error ER_NO_SUCH_USER LOCK TABLES v1 READ; DROP VIEW v1; + + +--echo # +--echo # Bug #58499 "DEFINER-security view selecting from INVOKER-security view +--echo # access check wrong". +--echo # +--echo # Check that we correctly handle privileges for various combinations +--echo # of INVOKER and DEFINER-security views using each other. +--disable_warnings +DROP DATABASE IF EXISTS mysqltest1; +--enable_warnings +CREATE DATABASE mysqltest1; +USE mysqltest1; +CREATE TABLE t1 (i INT); +CREATE TABLE t2 (j INT); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +--echo # +--echo # 1) DEFINER-security view uses INVOKER-security view (covers +--echo # scenario originally described in the bug report). +CREATE SQL SECURITY INVOKER VIEW v1_uses_t1 AS SELECT * FROM t1; +CREATE SQL SECURITY INVOKER VIEW v1_uses_t2 AS SELECT * FROM t2; +CREATE USER 'mysqluser1'@'%'; +GRANT CREATE VIEW ON mysqltest1.* TO 'mysqluser1'@'%'; +GRANT SELECT ON t1 TO 'mysqluser1'@'%'; +--echo # To be able create 'v2_uses_t2' we also need select on t2. +GRANT SELECT ON t2 TO 'mysqluser1'@'%'; +GRANT SELECT ON v1_uses_t1 TO 'mysqluser1'@'%'; +GRANT SELECT ON v1_uses_t2 TO 'mysqluser1'@'%'; +--echo # +--echo # Connection 'mysqluser1'. +--connect (mysqluser1, localhost, mysqluser1,,mysqltest1) +CREATE SQL SECURITY DEFINER VIEW v2_uses_t1 AS SELECT * FROM v1_uses_t1; +CREATE SQL SECURITY DEFINER VIEW v2_uses_t2 AS SELECT * FROM v1_uses_t2; +--echo # +--echo # Connection 'default'. +--connection default +CREATE USER 'mysqluser2'@'%'; +GRANT SELECT ON v2_uses_t1 TO 'mysqluser2'@'%'; +GRANT SELECT ON v2_uses_t2 TO 'mysqluser2'@'%'; +GRANT SELECT ON t2 TO 'mysqluser2'@'%'; +GRANT CREATE VIEW ON mysqltest1.* TO 'mysqluser2'@'%'; +--echo # Make 'mysqluser1' unable to access t2. +REVOKE SELECT ON t2 FROM 'mysqluser1'@'%'; +--echo # +--echo # Connection 'mysqluser2'. +--connect (mysqluser2, localhost, mysqluser2,,mysqltest1) +--echo # The below statement should succeed thanks to suid nature of v2_uses_t1. +SELECT * FROM v2_uses_t1; +--echo # The below statement should fail due to suid nature of v2_uses_t2. +--error ER_VIEW_INVALID +SELECT * FROM v2_uses_t2; +--echo # +--echo # 2) INVOKER-security view uses INVOKER-security view. +--echo # +--echo # Connection 'default'. +--connection default +DROP VIEW v2_uses_t1, v2_uses_t2; +CREATE SQL SECURITY INVOKER VIEW v2_uses_t1 AS SELECT * FROM v1_uses_t1; +CREATE SQL SECURITY INVOKER VIEW v2_uses_t2 AS SELECT * FROM v1_uses_t2; +GRANT SELECT ON v2_uses_t1 TO 'mysqluser1'@'%'; +GRANT SELECT ON v2_uses_t2 TO 'mysqluser1'@'%'; +GRANT SELECT ON v1_uses_t1 TO 'mysqluser2'@'%'; +GRANT SELECT ON v1_uses_t2 TO 'mysqluser2'@'%'; +--echo # +--echo # Connection 'mysqluser1'. +--connection mysqluser1 +--echo # For both versions of 'v2' 'mysqluser1' privileges should be used. +SELECT * FROM v2_uses_t1; +--error ER_VIEW_INVALID +SELECT * FROM v2_uses_t2; +--echo # +--echo # Connection 'mysqluser2'. +--connection mysqluser2 +--echo # And now for both versions of 'v2' 'mysqluser2' privileges should +--echo # be used. +--error ER_VIEW_INVALID +SELECT * FROM v2_uses_t1; +SELECT * FROM v2_uses_t2; +--echo # +--echo # 3) INVOKER-security view uses DEFINER-security view. +--echo # +--echo # Connection 'default'. +--connection default +DROP VIEW v1_uses_t1, v1_uses_t2; +--echo # To be able create 'v1_uses_t2' we also need select on t2. +GRANT SELECT ON t2 TO 'mysqluser1'@'%'; +--echo # +--echo # Connection 'mysqluser1'. +--connection mysqluser1 +CREATE SQL SECURITY DEFINER VIEW v1_uses_t1 AS SELECT * FROM t1; +CREATE SQL SECURITY DEFINER VIEW v1_uses_t2 AS SELECT * FROM t2; +--echo # +--echo # Connection 'default'. +--connection default +--echo # Make 'mysqluser1' unable to access t2. +REVOKE SELECT ON t2 FROM 'mysqluser1'@'%'; +--echo # +--echo # Connection 'mysqluser2'. +--connection mysqluser2 +--echo # Due to suid nature of v1_uses_t1 and v1_uses_t2 the first +--echo # select should succeed and the second select should fail. +SELECT * FROM v2_uses_t1; +--error ER_VIEW_INVALID +SELECT * FROM v2_uses_t2; +--echo # +--echo # 4) DEFINER-security view uses DEFINER-security view. +--echo # +--echo # Connection 'default'. +--connection default +DROP VIEW v2_uses_t1, v2_uses_t2; +--echo # To be able create 'v2_uses_t2' we also need select on t2. +GRANT SELECT ON t2 TO 'mysqluser1'@'%'; +--echo # +--echo # Connection 'mysqluser2'. +--connection mysqluser2 +CREATE SQL SECURITY DEFINER VIEW v2_uses_t1 AS SELECT * FROM v1_uses_t1; +CREATE SQL SECURITY DEFINER VIEW v2_uses_t2 AS SELECT * FROM v1_uses_t2; +--echo # +--echo # Connection 'default'. +--connection default +--echo # Make 'mysqluser1' unable to access t2. +REVOKE SELECT ON t2 FROM 'mysqluser1'@'%'; +--echo # +--echo # Connection 'mysqluser2'. +--connection mysqluser2 +--echo # Again privileges of creator of innermost views should apply. +SELECT * FROM v2_uses_t1; +--error ER_VIEW_INVALID +SELECT * FROM v2_uses_t2; + +--disconnect mysqluser1 +--disconnect mysqluser2 +--connection default +USE test; +DROP DATABASE mysqltest1; +DROP USER 'mysqluser1'@'%'; +DROP USER 'mysqluser2'@'%'; + + +# Wait till we reached the initial number of concurrent sessions +--source include/wait_until_count_sessions.inc diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 6cb4f590ae0..a25ef931344 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -1255,6 +1255,7 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, TABLE_LIST *view_tables= lex->query_tables; TABLE_LIST *view_tables_tail= 0; TABLE_LIST *tbl; + Security_context *security_ctx; /* Check rights to run commands (EXPLAIN SELECT & SHOW CREATE) which show @@ -1396,26 +1397,39 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, if (table->view_suid) { /* - Prepare a security context to check underlying objects of the view + For suid views prepare a security context for checking underlying + objects of the view. */ if (!(table->view_sctx= (Security_context *) thd->stmt_arena->alloc(sizeof(Security_context)))) goto err; - /* Assign the context to the tables referenced in the view */ - if (view_tables) - { - DBUG_ASSERT(view_tables_tail); - for (tbl= view_tables; tbl != view_tables_tail->next_global; - tbl= tbl->next_global) - tbl->security_ctx= table->view_sctx; - } - /* assign security context to SELECT name resolution contexts of view */ - for(SELECT_LEX *sl= lex->all_selects_list; - sl; - sl= sl->next_select_in_list()) - sl->context.security_ctx= table->view_sctx; + security_ctx= table->view_sctx; + } + else + { + /* + For non-suid views inherit security context from view's table list. + This allows properly handle situation when non-suid view is used + from within suid view. + */ + security_ctx= table->security_ctx; + } + + /* Assign the context to the tables referenced in the view */ + if (view_tables) + { + DBUG_ASSERT(view_tables_tail); + for (tbl= view_tables; tbl != view_tables_tail->next_global; + tbl= tbl->next_global) + tbl->security_ctx= security_ctx; } + /* assign security context to SELECT name resolution contexts of view */ + for(SELECT_LEX *sl= lex->all_selects_list; + sl; + sl= sl->next_select_in_list()) + sl->context.security_ctx= security_ctx; + /* Setup an error processor to hide error messages issued by stored routines referenced in the view -- cgit v1.2.1 From e073e2c0be3860eafd08b2ab14c8490dcb3b05fc Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Wed, 12 Jan 2011 17:02:41 +0400 Subject: Bug #57321 crashes and valgrind errors from spatial types Item_func_spatial_collection::fix_length_and_dec didn't call parent's method, so the maybe_null was set to '0' after it. But in this case the result was just NULL, that caused wrong behaviour. per-file comments: mysql-test/r/gis.result Bug #57321 crashes and valgrind errors from spatial types test result updated. mysql-test/t/gis.test Bug #57321 crashes and valgrind errors from spatial types test case added. sql/item_geofunc.h Bug #57321 crashes and valgrind errors from spatial types Item_func_geometry::fix_length_and_dec() called in Item_func_spatial_collection::fix_length_and_dec(). --- mysql-test/r/gis.result | 8 ++++++++ mysql-test/t/gis.test | 10 ++++++++++ sql/item_geofunc.h | 1 + 3 files changed, 19 insertions(+) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 3b18ee61336..f4aa361ffcf 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -1014,4 +1014,12 @@ SET @a=0x00000000030000000100000000000000000000000000144000000000000014400000000 SET @a=POLYFROMWKB(@a); SET @a=0x00000000030000000000000000000000000000000000144000000000000014400000000000001840000000000000184000000000000014400000000000001440; SET @a=POLYFROMWKB(@a); +create table t1(a polygon NOT NULL)engine=myisam; +insert into t1 values (geomfromtext("point(0 1)")); +insert into t1 values (geomfromtext("point(1 0)")); +select * from (select polygon(t1.a) as p from t1 order by t1.a) d; +p +NULL +NULL +drop table t1; End of 5.1 tests diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index fd0a18ab4dd..97fc6f94b6a 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -744,4 +744,14 @@ SET @a=0x00000000030000000000000000000000000000000000144000000000000014400000000 SET @a=POLYFROMWKB(@a); +# +# Bug #57321 crashes and valgrind errors from spatial types +# + +create table t1(a polygon NOT NULL)engine=myisam; +insert into t1 values (geomfromtext("point(0 1)")); +insert into t1 values (geomfromtext("point(1 0)")); +select * from (select polygon(t1.a) as p from t1 order by t1.a) d; +drop table t1; + --echo End of 5.1 tests diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h index b3ecbc39933..08161badfd3 100644 --- a/sql/item_geofunc.h +++ b/sql/item_geofunc.h @@ -177,6 +177,7 @@ public: String *val_str(String *); void fix_length_and_dec() { + Item_geometry_func::fix_length_and_dec(); for (unsigned int i= 0; i < arg_count; ++i) { if (args[i]->fixed && args[i]->field_type() != MYSQL_TYPE_GEOMETRY) -- cgit v1.2.1