summaryrefslogtreecommitdiff
path: root/mysql-test/suite/parts/inc
diff options
context:
space:
mode:
authorunknown <tomas@whalegate.ndb.mysql.com>2007-04-30 16:24:13 +0200
committerunknown <tomas@whalegate.ndb.mysql.com>2007-04-30 16:24:13 +0200
commit3df9f94f35d646d01ac840fe58b263b4f69eaf63 (patch)
tree323d685ec3b0aa27283e2475fa69a7eacf79faed /mysql-test/suite/parts/inc
parent1fb5a61cb617daee1c580d34cbf2437bae042a87 (diff)
downloadmariadb-git-3df9f94f35d646d01ac840fe58b263b4f69eaf63.tar.gz
shorten filenames
mysql-test/suite/parts/r/ndb_blob_partition.result: Rename: mysql-test/suite/partitions/r/ndb_blob_partition.result -> mysql-test/suite/parts/r/ndb_blob_partition.result mysql-test/suite/parts/r/ndb_dd_backuprestore.result: Rename: mysql-test/suite/partitions/r/ndb_dd_backuprestore.result -> mysql-test/suite/parts/r/ndb_dd_backuprestore.result mysql-test/suite/parts/r/ndb_partition_error.result: Rename: mysql-test/suite/partitions/r/ndb_partition_error.result -> mysql-test/suite/parts/r/ndb_partition_error.result mysql-test/suite/parts/r/ndb_partition_list.result: Rename: mysql-test/suite/partitions/r/ndb_partition_list.result -> mysql-test/suite/parts/r/ndb_partition_list.result mysql-test/suite/parts/r/ndb_partition_range.result: Rename: mysql-test/suite/partitions/r/ndb_partition_range.result -> mysql-test/suite/parts/r/ndb_partition_range.result mysql-test/suite/parts/r/partition_alter1_innodb.result: Rename: mysql-test/suite/partitions/r/partition_alter1_innodb.result -> mysql-test/suite/parts/r/partition_alter1_innodb.result mysql-test/suite/parts/r/partition_alter1_myisam.result: Rename: mysql-test/suite/partitions/r/partition_alter1_myisam.result -> mysql-test/suite/parts/r/partition_alter1_myisam.result mysql-test/suite/parts/r/partition_alter2_innodb.result: Rename: mysql-test/suite/partitions/r/partition_alter2_innodb.result -> mysql-test/suite/parts/r/partition_alter2_innodb.result mysql-test/suite/parts/r/partition_alter2_myisam.result: Rename: mysql-test/suite/partitions/r/partition_alter2_myisam.result -> mysql-test/suite/parts/r/partition_alter2_myisam.result mysql-test/suite/parts/r/partition_alter3_innodb.result: Rename: mysql-test/suite/partitions/r/partition_alter3_innodb.result -> mysql-test/suite/parts/r/partition_alter3_innodb.result mysql-test/suite/parts/r/partition_alter3_myisam.result: Rename: mysql-test/suite/partitions/r/partition_alter3_myisam.result -> mysql-test/suite/parts/r/partition_alter3_myisam.result mysql-test/suite/parts/r/partition_alter4_innodb.result: Rename: mysql-test/suite/partitions/r/partition_alter4_innodb.result -> mysql-test/suite/parts/r/partition_alter4_innodb.result mysql-test/suite/parts/r/partition_alter4_myisam.result: Rename: mysql-test/suite/partitions/r/partition_alter4_myisam.result -> mysql-test/suite/parts/r/partition_alter4_myisam.result mysql-test/suite/parts/r/partition_basic_innodb.result: Rename: mysql-test/suite/partitions/r/partition_basic_innodb.result -> mysql-test/suite/parts/r/partition_basic_innodb.result mysql-test/suite/parts/r/partition_basic_myisam.result: Rename: mysql-test/suite/partitions/r/partition_basic_myisam.result -> mysql-test/suite/parts/r/partition_basic_myisam.result mysql-test/suite/parts/r/partition_bit_innodb.result: Rename: mysql-test/suite/partitions/r/partition_bit_innodb.result -> mysql-test/suite/parts/r/partition_bit_innodb.result mysql-test/suite/parts/r/partition_bit_myisam.result: Rename: mysql-test/suite/partitions/r/partition_bit_myisam.result -> mysql-test/suite/parts/r/partition_bit_myisam.result mysql-test/suite/parts/r/partition_bit_ndb.result: Rename: mysql-test/suite/partitions/r/partition_bit_ndb.result -> mysql-test/suite/parts/r/partition_bit_ndb.result mysql-test/suite/parts/r/partition_char_innodb.result: Rename: mysql-test/suite/partitions/r/partition_char_innodb.result -> mysql-test/suite/parts/r/partition_char_innodb.result mysql-test/suite/parts/r/partition_char_myisam.result: Rename: mysql-test/suite/partitions/r/partition_char_myisam.result -> mysql-test/suite/parts/r/partition_char_myisam.result mysql-test/suite/parts/r/partition_datetime_innodb.result: Rename: mysql-test/suite/partitions/r/partition_datetime_innodb.result -> mysql-test/suite/parts/r/partition_datetime_innodb.result mysql-test/suite/parts/r/partition_datetime_myisam.result: Rename: mysql-test/suite/partitions/r/partition_datetime_myisam.result -> mysql-test/suite/parts/r/partition_datetime_myisam.result mysql-test/suite/parts/r/partition_decimal_innodb.result: Rename: mysql-test/suite/partitions/r/partition_decimal_innodb.result -> mysql-test/suite/parts/r/partition_decimal_innodb.result mysql-test/suite/parts/r/partition_decimal_myisam.result: Rename: mysql-test/suite/partitions/r/partition_decimal_myisam.result -> mysql-test/suite/parts/r/partition_decimal_myisam.result mysql-test/suite/parts/r/partition_engine_innodb.result: Rename: mysql-test/suite/partitions/r/partition_engine_innodb.result -> mysql-test/suite/parts/r/partition_engine_innodb.result mysql-test/suite/parts/r/partition_engine_myisam.result: Rename: mysql-test/suite/partitions/r/partition_engine_myisam.result -> mysql-test/suite/parts/r/partition_engine_myisam.result mysql-test/suite/parts/r/partition_engine_ndb.result: Rename: mysql-test/suite/partitions/r/partition_engine_ndb.result -> mysql-test/suite/parts/r/partition_engine_ndb.result mysql-test/suite/parts/r/partition_float_innodb.result: Rename: mysql-test/suite/partitions/r/partition_float_innodb.result -> mysql-test/suite/parts/r/partition_float_innodb.result mysql-test/suite/parts/r/partition_float_myisam.result: Rename: mysql-test/suite/partitions/r/partition_float_myisam.result -> mysql-test/suite/parts/r/partition_float_myisam.result mysql-test/suite/parts/r/partition_int_innodb.result: Rename: mysql-test/suite/partitions/r/partition_int_innodb.result -> mysql-test/suite/parts/r/partition_int_innodb.result mysql-test/suite/parts/r/partition_int_myisam.result: Rename: mysql-test/suite/partitions/r/partition_int_myisam.result -> mysql-test/suite/parts/r/partition_int_myisam.result mysql-test/suite/parts/r/partition_int_ndb.result: Rename: mysql-test/suite/partitions/r/partition_int_ndb.result -> mysql-test/suite/parts/r/partition_int_ndb.result mysql-test/suite/parts/r/partition_special_innodb.result: Rename: mysql-test/suite/partitions/r/partition_special_innodb.result -> mysql-test/suite/parts/r/partition_special_innodb.result mysql-test/suite/parts/r/partition_special_myisam.result: Rename: mysql-test/suite/partitions/r/partition_special_myisam.result -> mysql-test/suite/parts/r/partition_special_myisam.result mysql-test/suite/parts/r/partition_syntax_innodb.result: Rename: mysql-test/suite/partitions/r/partition_syntax_innodb.result -> mysql-test/suite/parts/r/partition_syntax_innodb.result mysql-test/suite/parts/r/partition_syntax_myisam.result: Rename: mysql-test/suite/partitions/r/partition_syntax_myisam.result -> mysql-test/suite/parts/r/partition_syntax_myisam.result mysql-test/suite/parts/r/partition_syntax_ndb.result: Rename: mysql-test/suite/partitions/r/partition_syntax_ndb.result -> mysql-test/suite/parts/r/partition_syntax_ndb.result mysql-test/suite/parts/r/partition_t55.out: Rename: mysql-test/suite/partitions/r/partition_t55.out -> mysql-test/suite/parts/r/partition_t55.out mysql-test/suite/parts/r/partition_value_innodb.result: Rename: mysql-test/suite/partitions/r/partition_value_innodb.result -> mysql-test/suite/parts/r/partition_value_innodb.result mysql-test/suite/parts/r/partition_value_myisam.result: Rename: mysql-test/suite/partitions/r/partition_value_myisam.result -> mysql-test/suite/parts/r/partition_value_myisam.result mysql-test/suite/parts/r/partition_value_ndb.result: Rename: mysql-test/suite/partitions/r/partition_value_ndb.result -> mysql-test/suite/parts/r/partition_value_ndb.result mysql-test/suite/parts/r/rpl_ndb_dd_partitions.result: Rename: mysql-test/suite/partitions/r/rpl_ndb_dd_partitions.result -> mysql-test/suite/parts/r/rpl_ndb_dd_partitions.result mysql-test/suite/parts/t/disabled.def: Rename: mysql-test/suite/partitions/t/disabled.def -> mysql-test/suite/parts/t/disabled.def mysql-test/suite/parts/t/ndb_blob_partition.test: Rename: mysql-test/suite/partitions/t/ndb_blob_partition.test -> mysql-test/suite/parts/t/ndb_blob_partition.test mysql-test/suite/parts/t/ndb_dd_backuprestore.test: Rename: mysql-test/suite/partitions/t/ndb_dd_backuprestore.test -> mysql-test/suite/parts/t/ndb_dd_backuprestore.test mysql-test/suite/parts/t/ndb_partition_error.test: Rename: mysql-test/suite/partitions/t/ndb_partition_error.test -> mysql-test/suite/parts/t/ndb_partition_error.test mysql-test/suite/parts/t/ndb_partition_key.test: Rename: mysql-test/suite/partitions/t/ndb_partition_key.test -> mysql-test/suite/parts/t/ndb_partition_key.test mysql-test/suite/parts/t/ndb_partition_list.test: Rename: mysql-test/suite/partitions/t/ndb_partition_list.test -> mysql-test/suite/parts/t/ndb_partition_list.test mysql-test/suite/parts/t/ndb_partition_range.test: Rename: mysql-test/suite/partitions/t/ndb_partition_range.test -> mysql-test/suite/parts/t/ndb_partition_range.test mysql-test/suite/parts/t/partition_sessions.test: Rename: mysql-test/suite/partitions/t/partition_sessions.test -> mysql-test/suite/parts/t/partition_sessions.test mysql-test/suite/parts/t/rpl_ndb_dd_partitions.test: Rename: mysql-test/suite/partitions/t/rpl_ndb_dd_partitions.test -> mysql-test/suite/parts/t/rpl_ndb_dd_partitions.test mysql-test/suite/parts/inc/partition.pre: Rename: mysql-test/suite/parts/include/partition.pre -> mysql-test/suite/parts/inc/partition.pre mysql-test/suite/parts/inc/partition_20.inc: Rename: mysql-test/suite/parts/include/partition_20.inc -> mysql-test/suite/parts/inc/partition_20.inc mysql-test/suite/parts/inc/partition_bigint.inc: Rename: mysql-test/suite/parts/include/partition_bigint.inc -> mysql-test/suite/parts/inc/partition_bigint.inc mysql-test/suite/parts/inc/partition_binary.inc: Rename: mysql-test/suite/parts/include/partition_binary.inc -> mysql-test/suite/parts/inc/partition_binary.inc mysql-test/suite/parts/inc/partition_bit.inc: Rename: mysql-test/suite/parts/include/partition_bit.inc -> mysql-test/suite/parts/inc/partition_bit.inc mysql-test/suite/parts/inc/partition_blob.inc: Rename: mysql-test/suite/parts/include/partition_blob.inc -> mysql-test/suite/parts/inc/partition_blob.inc mysql-test/suite/parts/inc/partition_blocked_sql_funcs.inc: Rename: mysql-test/suite/parts/include/partition_blocked_sql_funcs.inc -> mysql-test/suite/parts/inc/partition_blocked_sql_funcs.inc mysql-test/suite/parts/inc/partition_char.inc: Rename: mysql-test/suite/parts/include/partition_char.inc -> mysql-test/suite/parts/inc/partition_char.inc mysql-test/suite/parts/inc/partition_check_drop.inc: Rename: mysql-test/suite/parts/include/partition_check_drop.inc -> mysql-test/suite/parts/inc/partition_check_drop.inc mysql-test/suite/parts/inc/partition_check_read.inc: Rename: mysql-test/suite/parts/include/partition_check_read.inc -> mysql-test/suite/parts/inc/partition_check_read.inc mysql-test/suite/parts/inc/partition_check_read1.inc: Rename: mysql-test/suite/parts/include/partition_check_read1.inc -> mysql-test/suite/parts/inc/partition_check_read1.inc mysql-test/suite/parts/inc/partition_check_read2.inc: Rename: mysql-test/suite/parts/include/partition_check_read2.inc -> mysql-test/suite/parts/inc/partition_check_read2.inc mysql-test/suite/parts/inc/partition_cleanup.inc: Rename: mysql-test/suite/parts/include/partition_cleanup.inc -> mysql-test/suite/parts/inc/partition_cleanup.inc mysql-test/suite/parts/inc/partition_date.inc: Rename: mysql-test/suite/parts/include/partition_date.inc -> mysql-test/suite/parts/inc/partition_date.inc mysql-test/suite/parts/inc/partition_datetime.inc: Rename: mysql-test/suite/parts/include/partition_datetime.inc -> mysql-test/suite/parts/inc/partition_datetime.inc mysql-test/suite/parts/inc/partition_decimal.inc: Rename: mysql-test/suite/parts/include/partition_decimal.inc -> mysql-test/suite/parts/inc/partition_decimal.inc mysql-test/suite/parts/inc/partition_double.inc: Rename: mysql-test/suite/parts/include/partition_double.inc -> mysql-test/suite/parts/inc/partition_double.inc mysql-test/suite/parts/inc/partition_enum.inc: Rename: mysql-test/suite/parts/include/partition_enum.inc -> mysql-test/suite/parts/inc/partition_enum.inc mysql-test/suite/parts/inc/partition_float.inc: Rename: mysql-test/suite/parts/include/partition_float.inc -> mysql-test/suite/parts/inc/partition_float.inc mysql-test/suite/parts/inc/partition_int.inc: Rename: mysql-test/suite/parts/include/partition_int.inc -> mysql-test/suite/parts/inc/partition_int.inc mysql-test/suite/parts/inc/partition_key_16col.inc: Rename: mysql-test/suite/parts/include/partition_key_16col.inc -> mysql-test/suite/parts/inc/partition_key_16col.inc mysql-test/suite/parts/inc/partition_key_32col.inc: Rename: mysql-test/suite/parts/include/partition_key_32col.inc -> mysql-test/suite/parts/inc/partition_key_32col.inc mysql-test/suite/parts/inc/partition_key_4col.inc: Rename: mysql-test/suite/parts/include/partition_key_4col.inc -> mysql-test/suite/parts/inc/partition_key_4col.inc mysql-test/suite/parts/inc/partition_key_8col.inc: Rename: mysql-test/suite/parts/include/partition_key_8col.inc -> mysql-test/suite/parts/inc/partition_key_8col.inc mysql-test/suite/parts/inc/partition_layout_check1.inc: Rename: mysql-test/suite/parts/include/partition_layout_check1.inc -> mysql-test/suite/parts/inc/partition_layout_check1.inc mysql-test/suite/parts/inc/partition_layout_check2.inc: Rename: mysql-test/suite/parts/include/partition_layout_check2.inc -> mysql-test/suite/parts/inc/partition_layout_check2.inc mysql-test/suite/parts/inc/partition_mediumint.inc: Rename: mysql-test/suite/parts/include/partition_mediumint.inc -> mysql-test/suite/parts/inc/partition_mediumint.inc mysql-test/suite/parts/inc/partition_set.inc: Rename: mysql-test/suite/parts/include/partition_set.inc -> mysql-test/suite/parts/inc/partition_set.inc mysql-test/suite/parts/inc/partition_smallint.inc: Rename: mysql-test/suite/parts/include/partition_smallint.inc -> mysql-test/suite/parts/inc/partition_smallint.inc mysql-test/suite/parts/inc/partition_text.inc: Rename: mysql-test/suite/parts/include/partition_text.inc -> mysql-test/suite/parts/inc/partition_text.inc mysql-test/suite/parts/inc/partition_time.inc: Rename: mysql-test/suite/parts/include/partition_time.inc -> mysql-test/suite/parts/inc/partition_time.inc mysql-test/suite/parts/inc/partition_timestamp.inc: Rename: mysql-test/suite/parts/include/partition_timestamp.inc -> mysql-test/suite/parts/inc/partition_timestamp.inc mysql-test/suite/parts/inc/partition_tinyint.inc: Rename: mysql-test/suite/parts/include/partition_tinyint.inc -> mysql-test/suite/parts/inc/partition_tinyint.inc mysql-test/suite/parts/inc/partition_trigg1.inc: Rename: mysql-test/suite/parts/include/partition_trigg1.inc -> mysql-test/suite/parts/inc/partition_trigg1.inc mysql-test/suite/parts/inc/partition_trigg2.inc: Rename: mysql-test/suite/parts/include/partition_trigg2.inc -> mysql-test/suite/parts/inc/partition_trigg2.inc mysql-test/suite/parts/inc/partition_trigg3.inc: Rename: mysql-test/suite/parts/include/partition_trigg3.inc -> mysql-test/suite/parts/inc/partition_trigg3.inc mysql-test/suite/parts/inc/partition_value.inc: Rename: mysql-test/suite/parts/include/partition_value.inc -> mysql-test/suite/parts/inc/partition_value.inc mysql-test/suite/parts/inc/partition_varbinary.inc: Rename: mysql-test/suite/parts/include/partition_varbinary.inc -> mysql-test/suite/parts/inc/partition_varbinary.inc mysql-test/suite/parts/inc/partition_varchar.inc: Rename: mysql-test/suite/parts/include/partition_varchar.inc -> mysql-test/suite/parts/inc/partition_varchar.inc mysql-test/suite/parts/inc/partition_year.inc: Rename: mysql-test/suite/parts/include/partition_year.inc -> mysql-test/suite/parts/inc/partition_year.inc mysql-test/suite/parts/inc/part_supported_sql_funcs_int_ch1.inc: Rename: mysql-test/suite/parts/inc/partition_supported_sql_funcs_int_ch1.in -> mysql-test/suite/parts/inc/part_supported_sql_funcs_int_ch1.inc mysql-test/suite/parts/inc/part_supported_sql_funcs_int_date.inc: Rename: mysql-test/suite/parts/inc/partition_supported_sql_funcs_int_date.in -> mysql-test/suite/parts/inc/part_supported_sql_funcs_int_date.inc mysql-test/suite/parts/inc/part_supported_sql_funcs_int_float.inc: Rename: mysql-test/suite/parts/inc/partition_supported_sql_funcs_int_float.in -> mysql-test/suite/parts/inc/part_supported_sql_funcs_int_float.inc mysql-test/suite/parts/inc/part_supported_sql_funcs_int_int.inc: Rename: mysql-test/suite/parts/inc/partition_supported_sql_funcs_int_int.in -> mysql-test/suite/parts/inc/part_supported_sql_funcs_int_int.inc mysql-test/suite/parts/r/part_blocked_sql_func_innodb.result: Rename: mysql-test/suite/parts/r/partition_blocked_sql_func_innodb.result -> mysql-test/suite/parts/r/part_blocked_sql_func_innodb.result mysql-test/suite/parts/r/part_blocked_sql_func_myisam.result: Rename: mysql-test/suite/parts/r/partition_blocked_sql_func_myisam.result -> mysql-test/suite/parts/r/part_blocked_sql_func_myisam.result mysql-test/suite/parts/r/part_supported_sql_func_ndb.result: Rename: mysql-test/suite/parts/r/partition_supported_sql_func_ndb.result -> mysql-test/suite/parts/r/part_supported_sql_func_ndb.result mysql-test/suite/parts/inc/part_supported_sql_funcs_int_time.inc: Rename: mysql-test/suite/parts/inc/part_supported_sql_funcs_int_time.cin -> mysql-test/suite/parts/inc/part_supported_sql_funcs_int_time.inc
Diffstat (limited to 'mysql-test/suite/parts/inc')
-rw-r--r--mysql-test/suite/parts/inc/methods1.inc213
-rw-r--r--mysql-test/suite/parts/inc/part_blocked_sql_funcs_main.inc290
-rw-r--r--mysql-test/suite/parts/inc/part_supported_sql_funcs_delete.inc56
-rw-r--r--mysql-test/suite/parts/inc/part_supported_sql_funcs_int_ch1.inc4
-rw-r--r--mysql-test/suite/parts/inc/part_supported_sql_funcs_int_date.inc4
-rw-r--r--mysql-test/suite/parts/inc/part_supported_sql_funcs_int_float.inc4
-rw-r--r--mysql-test/suite/parts/inc/part_supported_sql_funcs_int_int.inc45
-rw-r--r--mysql-test/suite/parts/inc/part_supported_sql_funcs_int_time.inc4
-rw-r--r--mysql-test/suite/parts/inc/part_supported_sql_funcs_main.inc288
-rw-r--r--mysql-test/suite/parts/inc/partition.pre406
-rw-r--r--mysql-test/suite/parts/inc/partition_20.inc48
-rw-r--r--mysql-test/suite/parts/inc/partition_alter1.inc238
-rw-r--r--mysql-test/suite/parts/inc/partition_alter2.inc347
-rw-r--r--mysql-test/suite/parts/inc/partition_alter3.inc201
-rw-r--r--mysql-test/suite/parts/inc/partition_alter4.inc126
-rw-r--r--mysql-test/suite/parts/inc/partition_alter_1.inc68
-rw-r--r--mysql-test/suite/parts/inc/partition_alter_11.inc202
-rw-r--r--mysql-test/suite/parts/inc/partition_alter_13.inc202
-rw-r--r--mysql-test/suite/parts/inc/partition_alter_41.inc202
-rw-r--r--mysql-test/suite/parts/inc/partition_basic.inc179
-rw-r--r--mysql-test/suite/parts/inc/partition_bigint.inc59
-rw-r--r--mysql-test/suite/parts/inc/partition_binary.inc91
-rw-r--r--mysql-test/suite/parts/inc/partition_bit.inc115
-rw-r--r--mysql-test/suite/parts/inc/partition_blob.inc60
-rw-r--r--mysql-test/suite/parts/inc/partition_blocked_sql_funcs.inc149
-rw-r--r--mysql-test/suite/parts/inc/partition_char.inc95
-rw-r--r--mysql-test/suite/parts/inc/partition_check.inc1198
-rw-r--r--mysql-test/suite/parts/inc/partition_check_drop.inc72
-rw-r--r--mysql-test/suite/parts/inc/partition_check_read.inc89
-rw-r--r--mysql-test/suite/parts/inc/partition_check_read1.inc79
-rw-r--r--mysql-test/suite/parts/inc/partition_check_read2.inc75
-rw-r--r--mysql-test/suite/parts/inc/partition_cleanup.inc22
-rw-r--r--mysql-test/suite/parts/inc/partition_date.inc89
-rw-r--r--mysql-test/suite/parts/inc/partition_datetime.inc86
-rw-r--r--mysql-test/suite/parts/inc/partition_decimal.inc92
-rw-r--r--mysql-test/suite/parts/inc/partition_directory.inc263
-rw-r--r--mysql-test/suite/parts/inc/partition_double.inc89
-rw-r--r--mysql-test/suite/parts/inc/partition_engine.inc271
-rw-r--r--mysql-test/suite/parts/inc/partition_enum.inc99
-rw-r--r--mysql-test/suite/parts/inc/partition_float.inc92
-rw-r--r--mysql-test/suite/parts/inc/partition_int.inc56
-rw-r--r--mysql-test/suite/parts/inc/partition_key_16col.inc27
-rw-r--r--mysql-test/suite/parts/inc/partition_key_32col.inc39
-rw-r--r--mysql-test/suite/parts/inc/partition_key_4col.inc28
-rw-r--r--mysql-test/suite/parts/inc/partition_key_8col.inc27
-rw-r--r--mysql-test/suite/parts/inc/partition_layout_check1.inc71
-rw-r--r--mysql-test/suite/parts/inc/partition_layout_check2.inc70
-rw-r--r--mysql-test/suite/parts/inc/partition_mediumint.inc56
-rw-r--r--mysql-test/suite/parts/inc/partition_methods1.inc335
-rw-r--r--mysql-test/suite/parts/inc/partition_methods2.inc212
-rw-r--r--mysql-test/suite/parts/inc/partition_set.inc83
-rw-r--r--mysql-test/suite/parts/inc/partition_smallint.inc56
-rw-r--r--mysql-test/suite/parts/inc/partition_supported_sql_funcs.inc270
-rw-r--r--mysql-test/suite/parts/inc/partition_syntax.inc811
-rw-r--r--mysql-test/suite/parts/inc/partition_syntax_1.inc91
-rw-r--r--mysql-test/suite/parts/inc/partition_syntax_2.inc56
-rw-r--r--mysql-test/suite/parts/inc/partition_text.inc56
-rw-r--r--mysql-test/suite/parts/inc/partition_time.inc86
-rw-r--r--mysql-test/suite/parts/inc/partition_timestamp.inc86
-rw-r--r--mysql-test/suite/parts/inc/partition_tinyint.inc56
-rw-r--r--mysql-test/suite/parts/inc/partition_trigg1.inc115
-rw-r--r--mysql-test/suite/parts/inc/partition_trigg2.inc45
-rw-r--r--mysql-test/suite/parts/inc/partition_trigg3.inc87
-rw-r--r--mysql-test/suite/parts/inc/partition_value.inc157
-rw-r--r--mysql-test/suite/parts/inc/partition_varbinary.inc96
-rw-r--r--mysql-test/suite/parts/inc/partition_varchar.inc95
-rw-r--r--mysql-test/suite/parts/inc/partition_year.inc48
67 files changed, 9527 insertions, 0 deletions
diff --git a/mysql-test/suite/parts/inc/methods1.inc b/mysql-test/suite/parts/inc/methods1.inc
new file mode 100644
index 00000000000..24006b6e0f1
--- /dev/null
+++ b/mysql-test/suite/parts/inc/methods1.inc
@@ -0,0 +1,213 @@
+################################################################################
+# include/partition_methods1.inc #
+# #
+# Purpose: #
+# Create and check partitioned tables #
+# The partitioning function use the column f_int1 #
+# #
+# For all partitioning methods #
+# PARTITION BY HASH/KEY/LIST/RANGE #
+# PARTITION BY RANGE/LIST ... SUBPARTITION BY HASH/KEY ... #
+# do #
+# 1. Create the partitioned table #
+# 2 Insert the content of the table t0_template into t1 #
+# 3. Execute include/partition_check.inc #
+# 4. Drop the table t1 #
+# done #
+# #
+# The parameter #
+# $unique -- PRIMARY KEY or UNIQUE INDEXes to be created within the #
+# CREATE TABLE STATEMENT #
+# has to be set before sourcing this routine. #
+# Example: #
+# let $unique= , UNIQUE INDEX uidx1 (f_int1); #
+# include/partition_method1s.inc #
+# #
+# Attention: The routine include/partition_methods2.inc is very similar #
+# to this one. So if something has to be changed here it #
+# might be necessary to do it also there #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $partitioning= ;
+#----------- PARTITION BY HASH
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY HASH(f_int1) PARTITIONS 2;
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+
+#----------- PARTITION BY KEY
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY KEY(f_int1) PARTITIONS 5;
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+
+#----------- PARTITION BY LIST
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY LIST(MOD(f_int1,4))
+(PARTITION part_3 VALUES IN (-3),
+ PARTITION part_2 VALUES IN (-2),
+ PARTITION part_1 VALUES IN (-1),
+ PARTITION part_N VALUES IN (NULL),
+ PARTITION part0 VALUES IN (0),
+ PARTITION part1 VALUES IN (1),
+ PARTITION part2 VALUES IN (2),
+ PARTITION part3 VALUES IN (3));
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+
+#----------- PARTITION BY RANGE
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux = 'PARTITION BY RANGE(f_int1)
+(PARTITION parta VALUES LESS THAN (0),
+PARTITION partb VALUES LESS THAN ($max_row_div4),
+PARTITION partc VALUES LESS THAN ($max_row_div2),
+PARTITION partd VALUES LESS THAN ($max_row_div2 + $max_row_div4),
+PARTITION parte VALUES LESS THAN ($max_row),
+PARTITION partf VALUES LESS THAN $MAX_VALUE)';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+
+#----------- PARTITION BY RANGE -- SUBPARTITION BY HASH
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2
+(PARTITION parta VALUES LESS THAN (0),
+PARTITION partb VALUES LESS THAN ($max_row_div4),
+PARTITION partc VALUES LESS THAN ($max_row_div2),
+PARTITION partd VALUES LESS THAN $MAX_VALUE)';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+
+#----------- PARTITION BY RANGE -- SUBPARTITION BY KEY
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux = 'PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1)
+(PARTITION part1 VALUES LESS THAN (0)
+(SUBPARTITION subpart11, SUBPARTITION subpart12),
+PARTITION part2 VALUES LESS THAN ($max_row_div4)
+(SUBPARTITION subpart21, SUBPARTITION subpart22),
+PARTITION part3 VALUES LESS THAN ($max_row_div2)
+(SUBPARTITION subpart31, SUBPARTITION subpart32),
+PARTITION part4 VALUES LESS THAN $MAX_VALUE
+(SUBPARTITION subpart41, SUBPARTITION subpart42))';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+
+#----------- PARTITION BY LIST -- SUBPARTITION BY HASH
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1)
+(PARTITION part1 VALUES IN (0)
+ (SUBPARTITION sp11, SUBPARTITION sp12),
+ PARTITION part2 VALUES IN (1)
+ (SUBPARTITION sp21, SUBPARTITION sp22),
+ PARTITION part3 VALUES IN (2)
+ (SUBPARTITION sp31, SUBPARTITION sp32),
+ PARTITION part4 VALUES IN (NULL)
+ (SUBPARTITION sp41, SUBPARTITION sp42));
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+
+#----------- PARTITION BY LIST -- SUBPARTITION BY KEY
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY LIST(ABS(MOD(f_int1,2)))
+SUBPARTITION BY KEY(f_int1) SUBPARTITIONS $sub_part_no
+(PARTITION part1 VALUES IN (0),
+ PARTITION part2 VALUES IN (1),
+ PARTITION part3 VALUES IN (NULL))';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
diff --git a/mysql-test/suite/parts/inc/part_blocked_sql_funcs_main.inc b/mysql-test/suite/parts/inc/part_blocked_sql_funcs_main.inc
new file mode 100644
index 00000000000..ec258b5387b
--- /dev/null
+++ b/mysql-test/suite/parts/inc/part_blocked_sql_funcs_main.inc
@@ -0,0 +1,290 @@
+################################################################################
+# t/partition_blocked_sql_funcs_main.inc #
+# #
+# Purpose: #
+# Tests around sql functions #
+# #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-11-22 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+--echo -------------------------------------------------------------------------
+--echo --- All SQL functions should be rejected, otherwise BUG (see 18198)
+--echo -------------------------------------------------------------------------
+
+let $sqlfunc = greatest(col1,15);
+let $valsqlfunc = greatest(1,15);
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = isnull(col1);
+let $valsqlfunc = isnull(15);
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = least(col1,15);
+let $valsqlfunc = least(15,30);
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = case when col1>15 then 20 else 10 end;
+let $valsqlfunc = case when 1>30 then 20 else 15 end;
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = ifnull(col1,30);
+let $valsqlfunc = ifnull(1,30);
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = nullif(col1,30);
+let $valsqlfunc = nullif(1,30);
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = bit_length(col1);
+let $valsqlfunc = bit_length(255);
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+let $coltype = char(30);
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = char_length(col1);
+let $valsqlfunc = char_length('a');
+#let $coltype = int;
+#--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+let $coltype = char(30);
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = character_length(col1);
+let $valsqlfunc = character_length('a');
+let $coltype = char(30)
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = find_in_set(col1,'1,2,3,4,5,6,7,8,9');
+let $valsqlfunc = find_in_set('i','a,b,c,d,e,f,g,h,i');
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+let $coltype = char(30);
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = instr(col1,'acb');
+let $valsqlfunc = instr('i','a,b,c,d,e,f,g,h,i');
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+let $coltype = char(30);
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = length(col1);
+let $valsqlfunc = length('a,b,c,d,e,f,g,h,i');
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = locate('a',col1);
+let $valsqlfunc = locate('i','a,b,c,d,e,f,g,h,i');
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+let $coltype = char(30);
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = octet_length(col1);
+let $valsqlfunc = octet_length('a,b,c,d,e,f,g,h,i');
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = position('a' in col1);
+let $valsqlfunc = position('i' in 'a,b,c,d,e,f,g,h,i');
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+let $coltype = char(30);
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = strcmp(col1,'acb');
+let $valsqlfunc = strcmp('i','a,b,c,d,e,f,g,h,i');
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+let $coltype = char(30);
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = crc32(col1);
+let $valsqlfunc = crc32('a,b,c,d,e,f,g,h,i');
+let $coltype = char(30);
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = round(col1);
+let $valsqlfunc = round(15);
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = sign(col1);
+let $valsqlfunc = sign(123);
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = datediff(col1,col1);
+let $valsqlfunc = datediff('1997-11-30 23:59:59','1997-12-31');
+let $coltype = datetime;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = period_add(col1,5);
+let $valsqlfunc = period_add(9804,5);
+let $coltype = datetime;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = period_diff(col1,col2);
+let $valsqlfunc = period_diff(9809,199907);
+let $coltype = datetime,col2 datetime;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+let $coltype = int,col2 int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = timestampdiff(day,5,col1);
+let $valsqlfunc = timestampdiff(YEAR,'2002-05-01','2001-01-01');
+let $coltype = datetime;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = unix_timestamp(col1);
+let $valsqlfunc = unix_timestamp ('2002-05-01');
+let $coltype = date;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = week(col1);
+let $valsqlfunc = week('2002-05-01');
+let $coltype = datetime;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = cast(col1 as signed);
+let $valsqlfunc = cast(123 as signed);
+let $coltype = varchar(30);
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = convert(col1,unsigned);
+let $valsqlfunc = convert(123,unsigned);
+let $coltype = varchar(30);
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = col1 | 20;
+let $valsqlfunc = 10 | 20;
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = col1 & 20;
+let $valsqlfunc = 10 & 20;
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = col1 ^ 20;
+let $valsqlfunc = 10 ^ 20;
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = col1 << 20;
+let $valsqlfunc = 10 << 20;
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = col1 >> 20;
+let $valsqlfunc = 10 >> 20;
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = ~col1;
+let $valsqlfunc = ~20;
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = bit_count(col1);
+let $valsqlfunc = bit_count(20);
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+let $sqlfunc = inet_aton(col1);
+let $valsqlfunc = inet_aton('192.168.1.1');
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+set @var =20;
+let $sqlfunc = bit_length(col1)+@var-@var;
+let $valsqlfunc = bit_length(20)+@var-@var;
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+
+
+delimiter //;
+create function getmaxsigned_t1(col int) returns int
+begin
+ declare done int default 0;
+ declare v4 int;
+ declare max int;
+ declare cur1 cursor for
+ select col from t1;
+ declare continue handler for sqlstate '01000' set done = 1;
+ declare continue handler for sqlstate '02000' set done = 1;
+ open cur1;
+ set max = 0;
+ fetch cur1 into v4;
+ wl_loop: WHILE NOT done DO
+ fetch cur1 into v4;
+ IF v4 > max
+ then set max = v4;
+ END IF;
+ END WHILE wl_loop;
+ close cur1;
+ return max;
+ end//
+delimiter ;//
+
+let $sqlfunc = getmaxsigned_t1(col1);
+let $valsqlfunc = getmaxsigned(10);
+let $coltype = int;
+--source suite/parts/inc/partition_blocked_sql_funcs.inc
+# --source include/partition_blocked_sql_funcs.inc
+drop function if exists getmaxsigned_t1;
diff --git a/mysql-test/suite/parts/inc/part_supported_sql_funcs_delete.inc b/mysql-test/suite/parts/inc/part_supported_sql_funcs_delete.inc
new file mode 100644
index 00000000000..c0769cdeef1
--- /dev/null
+++ b/mysql-test/suite/parts/inc/part_supported_sql_funcs_delete.inc
@@ -0,0 +1,56 @@
+################################################################################
+# t/part_supported_sql_funcs_delete.inc # # #
+# Purpose: #
+# Delete access of the tests frame for allowed sql functions #
+# #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-11-22 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+--echo -------------------------------------------------------------------------
+--echo --- Delete rows and partitions of tables with $sqlfunc
+--echo -------------------------------------------------------------------------
+
+eval delete from $t1 where col1=$val2;
+eval delete from $t2 where col1=$val2;
+eval delete from $t3 where col1=$val2;
+eval delete from $t4 where col1=$val2;
+eval delete from $t5 where col1=$val2;
+eval delete from $t6 where col1=$val2;
+
+eval select * from $t1 order by col1;
+eval select * from $t2 order by col1;
+eval select * from $t3 order by col1;
+eval select * from $t4 order by colint;
+eval select * from $t5 order by colint;
+
+eval insert into $t1 values ($val2);
+eval insert into $t2 values ($val2);
+eval insert into $t3 values ($val2);
+eval insert into $t4 values (60,$val2);
+eval insert into $t5 values (60,$val2);
+eval insert into $t6 values (60,$val2);
+
+eval select * from $t1 order by col1;
+eval select * from $t2 order by col1;
+eval select * from $t3 order by col1;
+eval select * from $t4 order by colint;
+eval select * from $t5 order by colint;
+eval select * from $t6 order by colint;
+
+eval alter table $t1 drop partition p0;
+eval alter table $t2 drop partition p0;
+eval alter table $t4 drop partition p0;
+eval alter table $t5 drop partition p0;
+eval alter table $t6 drop partition p0;
+
+eval select * from $t1 order by col1;
+eval select * from $t2 order by col1;
+eval select * from $t3 order by col1;
+eval select * from $t4 order by colint;
+eval select * from $t5 order by colint;
+eval select * from $t6 order by colint;
diff --git a/mysql-test/suite/parts/inc/part_supported_sql_funcs_int_ch1.inc b/mysql-test/suite/parts/inc/part_supported_sql_funcs_int_ch1.inc
new file mode 100644
index 00000000000..8ae6e5fc807
--- /dev/null
+++ b/mysql-test/suite/parts/inc/part_supported_sql_funcs_int_ch1.inc
@@ -0,0 +1,4 @@
+1 1
+2 9
+3 3
+4 8 \ No newline at end of file
diff --git a/mysql-test/suite/parts/inc/part_supported_sql_funcs_int_date.inc b/mysql-test/suite/parts/inc/part_supported_sql_funcs_int_date.inc
new file mode 100644
index 00000000000..9eb41fb007b
--- /dev/null
+++ b/mysql-test/suite/parts/inc/part_supported_sql_funcs_int_date.inc
@@ -0,0 +1,4 @@
+1 2006-02-03
+2 2006-01-17
+3 2006-01-25
+4 2006-02-05 \ No newline at end of file
diff --git a/mysql-test/suite/parts/inc/part_supported_sql_funcs_int_float.inc b/mysql-test/suite/parts/inc/part_supported_sql_funcs_int_float.inc
new file mode 100644
index 00000000000..34d8b1d1c4d
--- /dev/null
+++ b/mysql-test/suite/parts/inc/part_supported_sql_funcs_int_float.inc
@@ -0,0 +1,4 @@
+1 5.1230
+2 13.345
+3 17.987
+4 15.654
diff --git a/mysql-test/suite/parts/inc/part_supported_sql_funcs_int_int.inc b/mysql-test/suite/parts/inc/part_supported_sql_funcs_int_int.inc
new file mode 100644
index 00000000000..d2f5c82a241
--- /dev/null
+++ b/mysql-test/suite/parts/inc/part_supported_sql_funcs_int_int.inc
@@ -0,0 +1,45 @@
+1 5
+2 13
+3 15
+4 17
+5 23
+6 34
+7 56
+8 56
+9 45
+10 34
+11 78
+12 89
+13 67
+14 46
+15 34
+16 324
+17 345
+18 34
+19 78
+20 567
+21 4
+22 435
+23 34
+24 45
+25 4565
+26 4
+27 3
+28 2
+29 3
+30 5
+31 6
+32 8
+33 9
+34 745
+35 34
+36 34
+37 324
+38 67
+39 78
+40 89
+41 90
+42 78967
+50 56
+51 34
+55 123 \ No newline at end of file
diff --git a/mysql-test/suite/parts/inc/part_supported_sql_funcs_int_time.inc b/mysql-test/suite/parts/inc/part_supported_sql_funcs_int_time.inc
new file mode 100644
index 00000000000..941ba418f32
--- /dev/null
+++ b/mysql-test/suite/parts/inc/part_supported_sql_funcs_int_time.inc
@@ -0,0 +1,4 @@
+1 09:09:15.000002
+2 04:30:01.000018
+3 00:59:22.000024
+4 05:30:34.000037
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
new file mode 100644
index 00000000000..4dc0e7bdad3
--- /dev/null
+++ b/mysql-test/suite/parts/inc/part_supported_sql_funcs_main.inc
@@ -0,0 +1,288 @@
+################################################################################
+# t/partition_supported_sql_funcs_main.inc #
+# #
+# Purpose: #
+# Tests which SQL functions are allowed in partinioning clauses. #
+# #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-11-22 #
+# Change Author: #
+# Change Date: #
+# Change: #
+# #
+# This test uses a test frame (partition_supported_sql_funcs.inc) for every #
+# SQL function allowed in the partitioning parts of CREATE and ALTE TABLE. #
+# The variales represent the #
+# - SQL function isself with a column (sqlfunc) and a literal (valsqlsunc), #
+# - the type of the column (coltype), #
+# - a file with test values of the coltype (infile) and #
+# - single test values (val1 to val4). #
+# The test frame includes CREATE/ALTER TABLE and some access statements. #
+# Column types are int, float(7,4), char(1), date and time depending on the #
+# SQL function. The test frame uses the include file #
+# "part_supported_sql_funcs_delete.inc" testing the deletion of #
+# partitions. #
+# The CREATE and ALTER TABLE statement do not cover the complete partitions #
+# functions, but will ashure that the SQL functions are basically working. #
+################################################################################
+
+
+let $sqlfunc = abs(col1);
+let $valsqlfunc = abs(15);
+let $coltype = int;
+let $infile = part_supported_sql_funcs_int_int.inc;
+let $val1 = 5 ;
+let $val2 = 13 ;
+let $val3 = 17 ;
+let $val4 = 15 ;
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = ascii(col1);
+let $valsqlfunc = ascii('5');
+let $coltype = char(1);
+let $infile = part_supported_sql_funcs_int_ch1.inc;
+let $val1 = '1';
+let $val2 = '9';
+let $val3 = '3';
+let $val4 = '8';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = cast(ceiling(col1) as signed integer);
+let $valsqlfunc = cast(ceiling(15) as signed integer);
+let $coltype = float(7,4);
+let $infile = part_supported_sql_funcs_int_float.inc;
+let $val1 = 5.1230;
+let $val2 = 13.345;
+let $val3 = 17.987;
+let $val4 = 15.654 ;
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = cast(floor(col1) as signed);
+let $valsqlfunc = cast(floor(15.123) as signed);
+let $coltype = float(7,4);
+let $infile = part_supported_sql_funcs_int_float.inc;
+let $val1 = 5.1230;
+let $val2 = 13.345;
+let $val3 = 17.987;
+let $val4 = 15.654 ;
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = cast(mod(col1,10) as signed);
+let $valsqlfunc = cast(mod(15,10) as signed);
+let $coltype = float(7,4);
+let $infile = part_supported_sql_funcs_int_float.inc;
+let $val1 = 5.0000;
+let $val2 = 19;
+let $val3 = 17;
+let $val4 = 15 ;
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = ord(col1);
+let $valsqlfunc = ord('a');
+let $coltype = char(3);
+let $infile = part_supported_sql_funcs_int_ch1.inc;
+let $val1 = '1';
+let $val2 = '9';
+let $val3 = '3';
+let $val4 = '8';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = day(col1);
+let $valsqlfunc = day('2006-12-21');
+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-05';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = dayofmonth(col1);
+let $valsqlfunc = dayofmonth('2006-12-24');
+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-05';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = dayofweek(col1);
+let $valsqlfunc = dayofweek('2006-12-24');
+let $coltype = date;
+let $infile = part_supported_sql_funcs_int_date.inc;
+let $val1 = '2006-01-03';
+let $val2 = '2006-02-17';
+let $val3 = '2006-01-25';
+let $val4 = '2006-02-05';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = dayofyear(col1);
+let $valsqlfunc = dayofyear('2006-12-25');
+let $coltype = date;
+let $infile = part_supported_sql_funcs_int_date.inc;
+let $val1 = '2006-01-03';
+let $val2 = '2006-01-17';
+let $val3 = '2006-02-25';
+let $val4 = '2006-02-05';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+let $coltype = char(30);
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = extract(month from col1);
+let $valsqlfunc = extract(year from '1998-11-23');
+let $coltype = date;
+let $infile = part_supported_sql_funcs_int_date.inc;
+let $val1 = '2006-01-03';
+let $val2 = '2006-02-17';
+let $val3 = '2006-01-25';
+let $val4 = '2006-02-05';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = hour(col1);
+let $valsqlfunc = hour('18:30');
+let $coltype = time;
+let $infile = part_supported_sql_funcs_int_time.inc;
+let $val1 = '09:09';
+let $val2 = '14:30';
+let $val3 = '21:59';
+let $val4 = '10:30';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = microsecond(col1);
+let $valsqlfunc = microsecond('10:30:10.000010');
+let $coltype = time;
+let $infile = part_supported_sql_funcs_int_time.inc;
+let $val1 = '09:09:15.000002';
+let $val2 = '04:30:01.000018';
+let $val3 = '00:59:22.000024';
+let $val4 = '05:30:34.000037';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = minute(col1);
+let $valsqlfunc = minute('18:30');
+let $coltype = time;
+let $val1 = '09:09:15';
+let $val2 = '14:30:45';
+let $val3 = '21:59:22';
+let $val4 = '10:24:23';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = second(col1);
+let $valsqlfunc = second('18:30:14');
+let $coltype = time;
+let $infile = part_supported_sql_funcs_int_time.inc;
+let $val1 = '09:09:09';
+let $val2 = '14:30:20';
+let $val3 = '21:59:22';
+let $val4 = '10:22:33';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+let $coltype = char(30);
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = month(col1);
+let $valsqlfunc = month('2006-10-14');
+let $coltype = date;
+let $infile = part_supported_sql_funcs_int_date.inc;
+let $val1 = '2006-01-03';
+let $val2 = '2006-12-17';
+let $val3 = '2006-05-25';
+let $val4 = '2006-11-06';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = quarter(col1);
+let $valsqlfunc = quarter('2006-10-14');
+let $coltype = date;
+let $infile = part_supported_sql_funcs_int_date.inc;
+let $val1 = '2006-01-03';
+let $val2 = '2006-12-17';
+let $val3 = '2006-09-25';
+let $val4 = '2006-07-30';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = time_to_sec(col1)-(time_to_sec(col1)-20);
+let $valsqlfunc = time_to_sec('18:30:14')-(time_to_sec('17:59:59'));
+let $coltype = time;
+let $infile = part_supported_sql_funcs_int_time.inc;
+let $val1 = '09:09:15';
+let $val2 = '14:30:45';
+let $val3 = '21:59:22';
+let $val4 = '10:33:11';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/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
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = weekday(col1);
+let $valsqlfunc = weekday('2006-10-14');
+let $coltype = date;
+let $infile = part_supported_sql_funcs_int_date.inc;
+let $val1 = '2006-12-03';
+let $val2 = '2006-11-17';
+let $val3 = '2006-05-25';
+let $val4 = '2006-02-06';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = weekofyear(col1);
+let $valsqlfunc = weekofyear('2006-02-14');
+let $coltype = date;
+let $infile = part_supported_sql_funcs_int_date.inc;
+let $val1 = '2006-01-03';
+let $val2 = '2006-03-17';
+let $val3 = '2006-05-25';
+let $val4 = '2006-09-06';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = year(col1)-1990;
+let $valsqlfunc = year('2005-10-14')-1990;
+let $coltype = date;
+let $infile = part_supported_sql_funcs_int_date.inc;
+let $val1 = '1996-01-03';
+let $val2 = '2000-02-17';
+let $val3 = '2004-05-25';
+let $val4 = '2002-02-15';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
+
+let $sqlfunc = yearweek(col1)-200600;
+let $valsqlfunc = yearweek('2006-10-14')-200600;
+let $coltype = date;
+let $infile = part_supported_sql_funcs_int_date.inc;
+let $val1 = '2006-01-03';
+let $val2 = '2006-08-17';
+let $val3 = '2006-03-25';
+let $val4 = '2006-11-15';
+--source suite/parts/inc/partition_supported_sql_funcs.inc
+# --source include/partition_supported_sql_funcs.inc
diff --git a/mysql-test/suite/parts/inc/partition.pre b/mysql-test/suite/parts/inc/partition.pre
new file mode 100644
index 00000000000..c09cfed29e6
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition.pre
@@ -0,0 +1,406 @@
+################################################################################
+# include/partition.pre #
+# #
+# Purpose: #
+# Auxiliary script creating prerequisites needed by the partitioning tests #
+# The name of the toplevel scripts sourcing this one is #
+# t/partition_<feature>_<storage engine>.test #
+# #
+# Several parameters have to be set before this file is sourced. #
+# Please refer to the README. #
+# #
+# The README for the partitioning testcases is at the end of this file. #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+# Set the session storage engine
+eval SET @@session.storage_engine = $engine;
+
+##### Disabled/affected testcases, because of open bugs #####
+--echo
+--echo #------------------------------------------------------------------------
+--echo # There are several testcases disabled because of the open bugs
+--echo # #15890
+if (`SELECT @@session.storage_engine IN('ndbcluster')`)
+{
+--echo # #18730, Bug#18735
+}
+--echo # The expected results suffer from the following bugs
+--echo # harmless #17455, #19305
+--echo # which cannot be suppressed because of technical reasons.
+--echo #------------------------------------------------------------------------
+# Attention: Only bugs appearing in all storage engines should be mentioned above.
+# The top level test wrapper (example: t/partition_basic_ndb.test)
+# may set the $fixed_bug<nnnnn> variable to 0 after sourcing
+# this file.
+# Bug#15890 Partitions: Strange interpretation of partition number
+let $fixed_bug15890= 0;
+# Bug#18730: Partitions: NDB, crash on SELECT MIN(<unique column>)
+# Attention: NDB testcases set this variable later to 0
+let $fixed_bug18730= 1;
+# Bug#18735: Partitions: NDB, UNIQUE INDEX, UPDATE, strange server response
+# Attention: NDB testcases set this variable later to 0
+let $fixed_bug18735= 1;
+
+--echo
+--echo #------------------------------------------------------------------------
+--echo # 0. Setting of auxiliary variables + Creation of an auxiliary tables
+--echo # needed in many testcases
+--echo #------------------------------------------------------------------------
+# Set the variable $no_debug depending on the current value of $debug;
+--disable_query_log
+eval SET @aux = $debug;
+let $no_debug= `SELECT @aux = 0`;
+--enable_query_log
+if ($debug)
+{
+--echo # Attention: Script debugging is swiched on.
+--echo # - all statements will be protocolled
+--echo # - some additional will be executed
+--echo # It is to be expected, that we get huge differences.
+}
+
+
+# Set the variable $engine_other to a storage engine <> $engine
+--disable_query_log
+eval SELECT UPPER($engine) = 'MEMORY' INTO @aux;
+let $aux= `SELECT @aux`;
+if ($aux)
+{
+ let $engine_other= 'MyISAM';
+}
+if (!$aux)
+{
+ let $engine_other= 'MEMORY';
+}
+--enable_query_log
+
+# Numbers used for
+# - partitioning Example: ... PARTITION part1 VALUES LESS THAN ($max_row_div2)
+# - INSERT/SELECT/UPDATE/DELETE Example: ... WHERE f_int1 > @max_row_div3
+let $max_row= `SELECT @max_row`;
+SELECT @max_row DIV 2 INTO @max_row_div2;
+let $max_row_div2= `SELECT @max_row_div2`;
+SELECT @max_row DIV 3 INTO @max_row_div3;
+let $max_row_div3= `SELECT @max_row_div3`;
+SELECT @max_row DIV 4 INTO @max_row_div4;
+let $max_row_div4= `SELECT @max_row_div4`;
+SET @max_int_4 = 2147483647;
+let $max_int_4= `SELECT @max_int_4`;
+
+# Three insert statements used in many testcases.
+let $insert_first_half= INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template
+WHERE f_int1 BETWEEN 1 AND @max_row_div2 - 1;
+let $insert_second_half= INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template
+WHERE f_int1 BETWEEN @max_row_div2 AND @max_row;
+#
+let $insert_first_third= INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template
+WHERE f_int1 BETWEEN 1 AND @max_row_div3 - 1;
+let $insert_second_third= INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template
+WHERE f_int1 BETWEEN @max_row_div3 AND 2 * @max_row_div3 - 1;
+let $insert_third_third= INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template
+WHERE f_int1 BETWEEN 2 * @max_row_div3 AND @max_row;
+#
+let $insert_all= INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
+
+# Column list with definition for all tables to be checked
+let $column_list= f_int1 INTEGER,
+f_int2 INTEGER,
+f_char1 CHAR(20),
+f_char2 CHAR(20),
+f_charbig VARCHAR(1000);
+
+# Currently (April 2006) the default compiled NDB cannot manage
+# no_of_partitions (no subpartitioning) > 8
+# no_of_partitions * no_of_subpartitions > 8
+# This NDB specific limitation will cause
+# 1005: Can't create table 'test.t1' (errno: 1224)
+# in partition_methods[1|2].inc and partition_alter_1[1|3].inc
+# when $sub_part_no is set to >= 3.
+let $sub_part_no= 3;
+if (`SELECT @@session.storage_engine = 'ndbcluster'`)
+{
+ let $sub_part_no= 2;
+}
+
+# Auxiliary table used for many experiments (INSERT INTO t1 ... SELECT ...)
+# on the tables to be checked
+--disable_warnings
+DROP TABLE IF EXISTS t0_template;
+--enable_warnings
+eval CREATE TABLE t0_template (
+$column_list ,
+PRIMARY KEY(f_int1))
+ENGINE = MEMORY;
+--echo # Logging of <max_row> INSERTs into t0_template suppressed
+--disable_query_log
+let $num= `SELECT @max_row`;
+while ($num)
+{
+ eval INSERT INTO t0_template
+SET f_int1 = $num, f_int2 = $num, f_char1 = '$num', f_char2 = '$num',
+f_charbig = '===$num===';
+
+ dec $num;
+}
+--enable_query_log
+
+# Auxiliary table used for comparisons of table definitions and file lists
+--disable_warnings
+DROP TABLE IF EXISTS t0_definition;
+--enable_warnings
+CREATE TABLE t0_definition (
+state CHAR(3),
+create_command VARBINARY(5000),
+file_list VARBINARY(5000),
+PRIMARY KEY (state)
+) ENGINE = MEMORY;
+
+# Auxiliary table used for trigger experiments
+--disable_warnings
+DROP TABLE IF EXISTS t0_aux;
+--enable_warnings
+eval CREATE TABLE t0_aux ( $column_list )
+ENGINE = MEMORY;
+
+# Prevent that a change of defaults breaks the tests.
+SET AUTOCOMMIT= 1;
+SET @@session.sql_mode= '';
+
+--echo # End of basic preparations needed for all tests
+--echo #-----------------------------------------------
+
+if (0)
+{
+# README for the partioning tests (t/partition_<feature>_<engine>.test)
+# ========================================================================
+#
+# 1. Explanation of the variables to be assigned in the top-level storage engine
+# specific scripts
+#------------------------------------------------------------------------------#
+#
+# Options, for mostly test(script+logic+result) debugging support:
+# $debug= 0 (default)
+# --> The protocolling of auxiliary stuff is suppressed.
+# The file with expected results fits to this setting.
+# $debug= 1
+# --> All executed statements will be printed into the protocol.
+# That means statements which
+# - are most time of low interest and do auxiliary stuff
+# like generating the next SQL statement to be executed
+# - additional statements giving informations about table
+# contents or the value of some variables
+# You will get huge differences, because the file with the
+# expected results was created with $debug = 0 .
+#
+# $with_partitioning= 1 (default)
+# --> Do the test with really partitioned tables.
+# $with_partitioning= 0
+# --> Do not use partitioned tables. This means omit the
+# "PARTITION BY ... SUBPARTITION BY ..." part of the CREATE TABLE
+# statement. This setting has only an effect on tests where
+# partition_methods1.inc and/or partition_methods2.inc are sourced.
+#
+# You will get differences when the CREATE TABLE statements
+# and table related files are printed or testcases check
+# partition borders, but most server responses and result
+# sets should be usable as reference for the test with the
+# partioned tables.
+# Please make a run with $with_partitioning= 0, whenever
+# - you do not trust the scripts (routines checking server codes/
+# result sets)
+# - fear that there is a new bug affecting partitioned and non
+# partitioned tables
+#
+#
+# Execute the test of "table" files
+# $do_file_tests= 1 (default for
+# - all storage engines within the extended QA test
+# - only MyISAM within the main regression tests)
+# --> Collect the file list and compare the file list before and after
+# OPTIMIZE/REPAIR/TRUNCATE
+# $do_file_tests= 0 (default for non MyISAM storage engines within the
+# main regression tests)
+# --> Do not collect the file list.
+# Only MyISAM has files per PARTITION/SUBPARTITION, PRIMARY KEY, INDEX, ..
+# There is a low probability that this tests detects bugs when used in
+# connection with other storage engines.
+#
+# Option, for displaying files:
+# $ls= 1 (default)
+# --> Display the table related directory content via
+# "ls $MYSQLTEST_VARDIR/master-data/test/t1*"
+# if these informations were collected.
+# This is probably not portable to some OS.
+# $ls= 0
+# --> Omit displaying the directory
+#
+#
+# Number of rows for the INSERT/UPDATE/DELETE/SELECT experiments
+# on partitioned tables:
+# @max_row is the number of rows which will be filled into the auxiliary
+# MEMORY table t0_template. This table is used for INSERT ... SELECT
+# experiments. The typical test table t1 contains most of the time
+# about @max_row DIV 2 rows.
+# Too small values of @max_row should be avoided, because some statements
+# should affect several rows and partitions.
+# Too big values of @max_row should be avoided, because of runtime issues.
+# @max_row= 20 (default for the main regression tests)
+# The file with expected results fits to this amount of rows.
+# @max_row= 300 (default for extended QA test)
+# --> Use <number rows>.
+# There should be only a few systematic differences to the file
+# with expected results, because most SQL statements use @max_row and
+# variables like max_row_div2 instead of a constant with the actual
+# number of rows.
+# I assume a value of 300 rows should be
+#
+#
+# Perform the variant with extended tests:
+# $more_trigger_tests, $more_pk_ui_tests(PK=PRIMARY KEY,UI=UNIQUE INDEX),
+# =0 (default for the main regression tests)
+# - There is a very low probability, that the omitted tests reveal a
+# bug which cannot be detected with the other tests.
+# - Limiting the partitioning tests solves issues with runtime and
+# protocol size.
+# =1 (default for extended QA test)
+#
+#
+# Perform PRIMARY KEY specific tests:
+# $do_pk_tests= 0;
+# --> Do not execute the PRIMARY KEY related tests.
+# $do_pk_tests= 1 (default for extended QA test)
+# --> Execute the PRIMARY KEY related tests.
+# The default setting for the main regression tests depends on the
+# storage engine. The PRIMARY KEY tests must be executed for every storage
+# engine, where the existence of a PRIMARY KEY affects the kind how the
+# table rows are stored.
+# Examples for the main rgression tests:
+# InnoDB - The PRIMARY KEY is a clustered index where the data for the
+# rows are stored. $do_pk_tests= 1
+# NDB - The PRIMARY KEY is used for implicit partitioning (NDB).
+# $do_pk_tests= 1
+# MyISAM - AFAIK there is no effect on the tree containing the rows.
+# $do_pk_tests= 0
+#
+# Assign a big number smaller than the maximum value for partitions
+# and smaller than the maximum value of SIGNED INTEGER
+# The NDB handler only supports 32 bit integers in VALUES
+# 2147483647 seems to be too big.
+# $MAX_VALUE= (2147483646);
+#
+#
+# 2. Typical architecture of a test:
+#------------------------------------------------------------------------------#
+# 2.1. storage engine specific script on top level
+# (t/partition_<feature>_<engine>.test)
+# a) General not engine specific settings and requirements
+# $debug, $ls, @max_row, $more_trigger_tests, .....
+# --source include/have_partition.inc
+# b) Engine specific settings and requirements
+# $do_pk_tests, $MAX_VALUE, $engine
+# SET SESSION storage_engine
+# $engine_other
+# c) Generate the prerequisites ($variables, @variables, tables) needed
+# via
+# --source include/partition.pre
+# d) Set "fixed_bug<number>" variables to 1 if there are open engine
+# specific bugs which need worarounds.
+# e) Execute the feature specific testscript via
+# --source include/partition_<feature>.inc
+# f) Perform a cleanup by removing all objects created within the tests
+# --source include/partition_cleanup.inc
+#
+# 2.2. script generating the prerequisites needed in all tests
+# (include/partition.pre)
+# a) Message about open bugs causing that
+# - some testcases are disabled
+# - it cannot be avoided that the file with expected results suffers
+# from open bugs
+# This should not occur often !
+# Example: There is extreme often an auxiliary testscript sourced,
+# but the the conditions vary. We get under a certain combination
+# of conditions a wrong result set or server response.
+# b) Set "fixed_bug<number>" variables to 0 if there are open engine
+# specific bugs. They are later set to 1 within the toplevel script.
+# Set "fixed_bug<number>" variables to 1 if there are open NOT engine
+# specific bugs.
+# c) Setting of auxiliary variables
+# d) Creation of auxiliary tables ....
+#
+# 3. script checking a feature
+# (include/partition_<feature.inc>.inc)
+# Example:
+# a) "set/compute" a CREATE TABLE t1 .. and an ALTER TABLE ... statement
+# b) CREATE TABLE t1 ...
+# c) INSERT INTO t1 (.....) SELECT .... FROM t0_template WHERE ...
+# The first 50 % of all t0_template rows will be inserted into t1.
+# d) ALTER TABLE t1 (Example: ADD/DROP UNIQUE INDEX)
+# e) INSERT INTO t1 (.....) SELECT .... FROM t0_template WHERE ...
+# The second 50 % of all t0_template rows will be inserted into t1.
+# Now t1 and t0_template should have the same content.
+# f) Check the "usability" of the current table t1
+# via
+# --source include/partition_check.pre
+# g) DROP TABLE t1
+# Switch to other CREATE and ALTER statements and run sequence a)-g) again
+# ...
+#
+# 4. script checking if a certain table shows the expected behaviour
+# ("usability" check): include/partition_check.inc
+# - SELECT/INSERT/UPDATE/DELETE affecting single and multiple records
+# - check of values of special interest like NULL etc.
+# - INSERT/UPDATE with BEFORE/AFTER triggers
+# - violations of UNIQUE constraints, if there are any defined
+# - transactions ...
+# - TRUNCATE/OPTIMIZE/..
+# - ...
+#
+# 3. How to analyze a partitioning bug revealed with these tests/ How to build
+# a small replay script from the monstrous protocols ?
+#------------------------------------------------------------------------------#
+# a) crash -- use the file var/master-data/mysql/general_log.CSV
+# b) no crash, but unexpected server response (there is no "reject file)
+# -- use the file r/<testcase>.log
+# Please be aware that the option $debug= 0 suppresses the
+# protocolling of some queries.
+# c) no crash, but unexpected result set
+# -- use the file r/<testcase>.reject
+# Please be aware that the option $debug= 0 suppresses the
+# protocolling of some queries.
+# In most cases you will find that the r/<testcase>.<log/reject> contains at
+# least a line "# # check <something>: 0".
+# That means that a check within include/partition_check did not got the
+# expected result.
+# A good start for a replay script would be
+# 1. Copy t/partition_<feature>_<engine>.test to t/my_test.test
+# 2. Edit t/my_test.test
+# - set $debug to 1
+# - replace the line
+# "--source include/partition_<feature>.inc"
+# with all statements between the last
+# CREATE TABLE t1 statement (included this)
+# and the line
+# "# Start usability test (include/partition_check.inc)"
+# - add the content of include/partition_check.inc at the end.
+#
+# Please excuse that the partitioning tests generate such huge protocols which
+# and are not very handy when it comes to bug analysis. I tried to squeez out
+# as much test coverage as possible by writing some hopefully smart routines
+# and reusing them in various combinations.
+#
+# Matthias
+#
+}
diff --git a/mysql-test/suite/parts/inc/partition_20.inc b/mysql-test/suite/parts/inc/partition_20.inc
new file mode 100644
index 00000000000..7901b332a11
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_20.inc
@@ -0,0 +1,48 @@
+################################################################################
+# include/partition_20.inc #
+# #
+# Purpose: #
+# Auxiliary script, only useful when sourced by include/partition_check.inc. #
+# #
+# 1. Check if the preceeding statement caused that the expected number of #
+# records was #
+# - inserted #
+# - updated or deleted+inserted #
+# 2. Revert the modifications #
+# #
+# The parameters #
+# @try_count = total number of inserted and updated or deleted+inserted #
+# records #
+# @clash_count = number of records where a DUPLICATE KEY appears #
+# must be set before sourcing this routine. #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+# include/partition_20.inc
+#
+# Auxiliary script, only useful when sourced by include/partition_check.inc.
+#
+
+# Check of preceeding statement via Select
+if ($no_debug)
+{
+ --disable_query_log
+}
+eval SELECT '# check unique-$num-a success: ' AS "", COUNT(*) = @clash_count AS ""
+FROM t1 WHERE f_charbig = 'was updated';
+eval SELECT '# check unique-$num-b success: ' AS "", COUNT(*) = @try_count AS ""
+FROM t1 WHERE f_charbig IN ('was updated','was inserted');
+--enable_query_log
+# Revert the modification
+DELETE FROM t1 WHERE f_charbig = 'was inserted';
+UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
+ f_int2 = CAST(f_char1 AS SIGNED INT),
+ f_charbig = CONCAT('===',f_char1,'===')
+WHERE f_charbig = 'was updated';
+inc $num;
diff --git a/mysql-test/suite/parts/inc/partition_alter1.inc b/mysql-test/suite/parts/inc/partition_alter1.inc
new file mode 100644
index 00000000000..a9706d5eb98
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_alter1.inc
@@ -0,0 +1,238 @@
+################################################################################
+# include/partition_alter1.inc #
+# #
+# Purpose: #
+# ADD/DROP PRIMARY KEYs and/or UNIQUE INDEXes tests on partitioned tables #
+# This routine is only useful for the partition_<feature>_<engine> tests. #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+--echo
+--echo #========================================================================
+--echo # 1. ALTER TABLE ADD PRIMARY KEY and/or UNIQUE INDEX
+--echo #========================================================================
+# Rule: The table does not have a PRIMARY KEY or UNIQUE INDEX.
+# ---> $unique must be empty
+# ---> The PRIMARY KEY or UNIQUE INDEX to be created must contain
+# the columns used for partitioning.
+--echo #------------------------------------------------------------------------
+--echo # 1.1 ADD PRIMARY KEY or UNIQUE INDEX to table with one column (f_int1)
+--echo # within the partitioning function
+--echo #------------------------------------------------------------------------
+# Rule: Only f_int1 is used within the partitioning function
+# ---> include/partition_alter_11.inc
+if ($do_pk_tests)
+{
+ # The value of the following test is maybe covered by 1.1.3.
+ if ($more_pk_ui_tests)
+ {
+ --echo # 1.1.1 PRIMARY KEY consisting of one column
+ let $alter= ALTER TABLE t1 ADD PRIMARY KEY(f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ }
+ # This must fail, because PRIMARY KEY does not contain f_int1
+ let $alter= ALTER TABLE t1 ADD PRIMARY KEY(f_int2);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+}
+# The value of the following test is maybe covered by 1.1.4.
+if ($more_pk_ui_tests)
+{
+ --echo # 1.1.2 UNIQUE INDEX consisting of one column
+ let $alter= ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+}
+# This must fail, because UNIQUE INDEX does not contain f_int1
+let $alter= ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int2);
+--source suite/parts/inc/partition_alter_11.inc
+# --source include/partition_alter_11.inc
+if ($do_pk_tests)
+{
+ --echo # 1.1.3 PRIMARY KEY consisting of two columns
+ let $alter= ALTER TABLE t1 ADD PRIMARY KEY(f_int1,f_int2);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ let $alter= ALTER TABLE t1 ADD PRIMARY KEY(f_int2,f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+}
+--echo # 1.1.4 UNIQUE INDEX consisting of two columns
+let $alter= ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int1,f_int2);
+--source suite/parts/inc/partition_alter_11.inc
+# --source include/partition_alter_11.inc
+let $alter= ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int2,f_int1);
+--source suite/parts/inc/partition_alter_11.inc
+# --source include/partition_alter_11.inc
+#
+--echo #------------------------------------------------------------------------
+--echo # 1.2 ADD PRIMARY KEY or UNIQUE INDEX to table with two columns
+--echo # (f_int1 and f_int2) within the partitioning function
+--echo #------------------------------------------------------------------------
+# Rule: f_int1 and f_int2 is used within the partitioning function
+# ---> include/partition_alter_13.inc
+if ($do_pk_tests)
+{
+ --echo # 1.2.1 PRIMARY KEY consisting of two columns
+ let $alter= ALTER TABLE t1 ADD PRIMARY KEY(f_int1,f_int2);
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+ let $alter= ALTER TABLE t1 ADD PRIMARY KEY(f_int2,f_int1);
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+}
+--echo # 1.2.2 UNIQUE INDEX consisting of two columns
+let $alter= ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int1,f_int2);
+--source suite/parts/inc/partition_alter_13.inc
+# --source include/partition_alter_13.inc
+let $alter= ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int2,f_int1);
+--source suite/parts/inc/partition_alter_13.inc
+# --source include/partition_alter_13.inc
+if ($do_pk_tests)
+{
+ --echo # 1.2.3 PRIMARY KEY and UNIQUE INDEX consisting of two columns
+ let $alter= ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int1,f_int2), ADD PRIMARY KEY(f_int2,f_int1);
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+ let $alter= ALTER TABLE t1 ADD UNIQUE INDEX uidx1 (f_int2,f_int1), ADD PRIMARY KEY(f_int1,f_int2);
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+ let $unique= ;
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+}
+#
+#
+--echo
+--echo #========================================================================
+--echo # 2 DROP PRIMARY KEY or UNIQUE INDEX
+--echo #========================================================================
+# Rule: The table must have a PRIMARY KEY or UNIQUE INDEX.
+# ---> $unique must not be empty
+# ---> The PRIMARY KEY or UNIQUE INDEX to be dropped must contain
+# the columns used for partitioning.
+--echo #------------------------------------------------------------------------
+--echo # 2.1 Partitioning function contains one column(f_int1)
+--echo #------------------------------------------------------------------------
+# Rule: Only f_int1 is used within the partitioning function
+# ---> include/partition_alter_11.inc
+# The value of the following test is maybe covered by 2.1.5.
+if ($more_pk_ui_tests)
+{
+ if ($do_pk_tests)
+ {
+ --echo # 2.1.1 DROP PRIMARY KEY consisting of one column
+ let $unique= , PRIMARY KEY(f_int1);
+ let $alter= ALTER TABLE t1 DROP PRIMARY KEY;
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ }
+ #
+ --echo # 2.1.2 DROP UNIQUE INDEX consisting of one column
+ let $unique= , UNIQUE INDEX uidx1 (f_int1);
+ let $alter= ALTER TABLE t1 DROP INDEX uidx1;
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ #
+ if ($do_pk_tests)
+ {
+ --echo # 2.1.3 DROP PRIMARY KEY consisting of two columns
+ let $alter= ALTER TABLE t1 DROP PRIMARY KEY;
+ let $unique= , PRIMARY KEY(f_int1,f_int2);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ let $unique= , PRIMARY KEY(f_int2,f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ }
+ #
+ --echo # 2.1.4 DROP UNIQUE INDEX consisting of two columns
+ let $alter= ALTER TABLE t1 DROP INDEX uidx1;
+ let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ }
+#
+if ($do_pk_tests)
+{
+ --echo # 2.1.5 DROP PRIMARY KEY + UNIQUE INDEX consisting of two columns
+ let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1);
+ let $alter= ALTER TABLE t1 DROP PRIMARY KEY, DROP INDEX uidx1;
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2);
+ let $alter= ALTER TABLE t1 DROP PRIMARY KEY, DROP INDEX uidx1;
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+}
+let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1);
+let $alter= ALTER TABLE t1 DROP INDEX uidx1, DROP INDEX uidx2;
+--source suite/parts/inc/partition_alter_11.inc
+# --source include/partition_alter_11.inc
+#
+--echo #------------------------------------------------------------------------
+--echo # 2.2 Partitioning function contains two columns (f_int1,f_int2)
+--echo #------------------------------------------------------------------------
+# Rule: f_int1 and f_int2 is used within the partitioning function
+# ---> include/partition_alter_13.inc
+if ($do_pk_tests)
+{
+ --echo # 2.2.1 DROP PRIMARY KEY consisting of two columns
+ let $alter= ALTER TABLE t1 DROP PRIMARY KEY;
+ let $unique= , PRIMARY KEY(f_int1,f_int2);
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+ let $unique= , PRIMARY KEY(f_int2,f_int1);
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+}
+#
+--echo # 2.2.2 DROP UNIQUE INDEX consisting of two columns
+let $alter= ALTER TABLE t1 DROP INDEX uidx1;
+let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2);
+--source suite/parts/inc/partition_alter_13.inc
+# --source include/partition_alter_13.inc
+let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1);
+--source suite/parts/inc/partition_alter_13.inc
+# --source include/partition_alter_13.inc
+#
+if ($do_pk_tests)
+{
+ --echo # 2.2.3 DROP PRIMARY KEY + UNIQUE INDEX consisting of two columns
+ let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1);
+ let $alter= ALTER TABLE t1 DROP PRIMARY KEY, DROP INDEX uidx1;
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+ let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2);
+ let $alter= ALTER TABLE t1 DROP PRIMARY KEY, DROP INDEX uidx1;
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+}
+let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1);
+let $alter= ALTER TABLE t1 DROP INDEX uidx1, DROP INDEX uidx2;
+--source suite/parts/inc/partition_alter_13.inc
+# --source include/partition_alter_13.inc
+
+if (0)
+{
+--echo
+--echo #========================================================================
+--echo # 3. ALTER TABLE "ALTER" PRIMARY KEY
+--echo # ML: I think that an ALTER TABLE statement where a PRIMARY KEY is
+--echo # dropped and recreated (with different layout) might be of
+--echo # interest, if the tree containing the table data has to be
+--echo # reorganized during this operation.
+--echo # To be implemented
+--echo #========================================================================
+--echo
+}
diff --git a/mysql-test/suite/parts/inc/partition_alter2.inc b/mysql-test/suite/parts/inc/partition_alter2.inc
new file mode 100644
index 00000000000..3e01c3972bc
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_alter2.inc
@@ -0,0 +1,347 @@
+################################################################################
+# include/partition_alter2.inc #
+# #
+# Purpose: #
+# Tests where the columns used within the partitioning function are altered. #
+# This routine is only useful for the partition_<feature>_<engine> tests. .#
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+--echo
+--echo #========================================================================
+--echo # 1 Increase the size of the column used in the partitioning
+--echo # function and/or PRIMARY KEY and/or UNIQUE INDEX
+--echo #========================================================================
+--echo #------------------------------------------------------------------------
+--echo # 1.1 ALTER column f_int2 not used in partitioning function
+--echo #------------------------------------------------------------------------
+# Rule: Only f_int1 is used within the partitioning function
+# ---> include/partition_alter_11.inc
+let $alter= ALTER TABLE t1 MODIFY f_int2 BIGINT;
+--echo # 1.1.1 no PRIMARY KEY or UNIQUE INDEX exists
+let $unique= ;
+--source suite/parts/inc/partition_alter_11.inc
+# --source include/partition_alter_11.inc
+#
+if ($do_pk_tests)
+{
+ --echo # 1.1.2 PRIMARY KEY exists
+ # The value of the direct following test is maybe covered by the test with
+ # the PRIMARY KEY containing two columns.
+ if ($more_pk_ui_tests)
+ {
+ let $unique= , PRIMARY KEY (f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ }
+ let $unique= , PRIMARY KEY (f_int1,f_int2);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ let $unique= , PRIMARY KEY (f_int2,f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+}
+#
+--echo # 1.1.3 UNIQUE INDEX exists
+# The value of the direct following test is maybe covered by the test with
+# the UNIQUE INDEX containing two columns
+if ($more_pk_ui_tests)
+{
+ let $unique= , UNIQUE INDEX uidx1 (f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+}
+let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2);
+--source suite/parts/inc/partition_alter_11.inc
+# --source include/partition_alter_11.inc
+let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1);
+--source suite/parts/inc/partition_alter_11.inc
+# --source include/partition_alter_11.inc
+#
+if ($more_pk_ui_tests)
+{
+ # The value of the tests 1.2 is maybe covered by the tests 1.3
+ --echo #------------------------------------------------------------------------
+ --echo # 1.2 ALTER column f_int1 used in partitioning function
+ --echo #------------------------------------------------------------------------
+ # Rule: Only f_int1 is used within the partitioning function
+ # ---> include/partition_alter_11.inc
+ let $alter= ALTER TABLE t1 MODIFY f_int1 BIGINT;
+ --echo # 1.2.1 no PRIMARY KEY or UNIQUE INDEX exists
+ let $unique= ;
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+ #
+ if ($do_pk_tests)
+ {
+ --echo # 1.2.2 PRIMARY KEY exists
+ let $unique= , PRIMARY KEY (f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ let $unique= , PRIMARY KEY (f_int1,f_int2);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+ let $unique= , PRIMARY KEY (f_int2,f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+ }
+ #
+ --echo # 1.2.3 UNIQUE INDEX exists
+ let $unique= , UNIQUE INDEX uidx (f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ let $unique= , UNIQUE INDEX uidx (f_int1,f_int2);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+ let $unique= , UNIQUE INDEX uidx (f_int2,f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+}
+#
+--echo #------------------------------------------------------------------------
+--echo # 1.3 ALTER column f_int1 and f_int2
+--echo # f_int1 or (f_int1 and f_int2) used in partitioning function
+--echo #------------------------------------------------------------------------
+# Rule: f_int1 and f_int2 is used within the partitioning function
+# ---> include/partition_alter_13.inc
+let $alter= ALTER TABLE t1 MODIFY f_int1 BIGINT, MODIFY f_int2 BIGINT;
+--echo # 1.3.1 no PRIMARY KEY or UNIQUE INDEX exists
+let $unique= ;
+--source suite/parts/inc/partition_alter_11.inc
+# --source include/partition_alter_11.inc
+--source suite/parts/inc/partition_alter_13.inc
+# --source include/partition_alter_13.inc
+#
+if ($do_pk_tests)
+{
+ --echo # 1.3.2 PRIMARY KEY exists
+ # The value of the direct following test is maybe covered by the test with
+ # the PRIMARY KEY containing two columns.
+ if ($more_pk_ui_tests)
+ {
+ let $unique= , PRIMARY KEY (f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ }
+ let $unique= , PRIMARY KEY (f_int1,f_int2);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+ let $unique= , PRIMARY KEY (f_int2,f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+}
+#
+--echo # 1.3.3 UNIQUE INDEX exists
+# The value of the direct following test is maybe covered by the test with
+# the UNIQUE INDEX containing two columns.
+if ($more_pk_ui_tests)
+{
+ let $unique= , UNIQUE INDEX uidx (f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+}
+let $unique= , UNIQUE INDEX uidx (f_int1,f_int2);
+--source suite/parts/inc/partition_alter_11.inc
+# --source include/partition_alter_11.inc
+--source suite/parts/inc/partition_alter_13.inc
+# --source include/partition_alter_13.inc
+let $unique= , UNIQUE INDEX uidx (f_int2,f_int1);
+--source suite/parts/inc/partition_alter_11.inc
+# --source include/partition_alter_11.inc
+--source suite/parts/inc/partition_alter_13.inc
+# --source include/partition_alter_13.inc
+
+--echo
+--echo #========================================================================
+--echo # 2 Decrease the size of the column used in the partitioning
+--echo # function and/or PRIMARY KEY and/or UNIQUE INDEX
+--echo #========================================================================
+--echo #------------------------------------------------------------------------
+--echo # 2.1 ALTER column f_int2 not used in partitioning function
+--echo #------------------------------------------------------------------------
+# Rule: Only f_int1 is used within the partitioning function
+# ---> include/partition_alter_11.inc
+let $alter= ALTER TABLE t1 MODIFY f_int2 MEDIUMINT;
+--echo # 2.1.1 no PRIMARY KEY or UNIQUE INDEX exists
+let $unique= ;
+--source suite/parts/inc/partition_alter_11.inc
+# --source include/partition_alter_11.inc
+#
+if ($do_pk_tests)
+{
+ # The value of the direct following test is maybe covered by the test with
+ # the PRIMARY KEY containing two columns.
+ if ($more_pk_ui_tests)
+ {
+ --echo # 2.1.2 PRIMARY KEY exists
+ let $unique= , PRIMARY KEY (f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ }
+ let $unique= , PRIMARY KEY (f_int1,f_int2);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ let $unique= , PRIMARY KEY (f_int2,f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+}
+#
+--echo # 2.1.3 UNIQUE INDEX exists
+# The value of the direct following test is maybe covered by the test with
+# the UNIQUE INDEX containing two columns.
+if ($more_pk_ui_tests)
+{
+ let $unique= , UNIQUE INDEX uidx1 (f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+}
+let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2);
+--source suite/parts/inc/partition_alter_11.inc
+# --source include/partition_alter_11.inc
+let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1);
+--source suite/parts/inc/partition_alter_11.inc
+# --source include/partition_alter_11.inc
+#
+if ($more_pk_ui_tests)
+{
+ # The value of the tests 2.2 is maybe covered by the tests 2.3
+ --echo #------------------------------------------------------------------------
+ --echo # 2.2 ALTER column f_int1 used in partitioning function
+ --echo #------------------------------------------------------------------------
+ # Rule: Only f_int1 is used within the partitioning function
+ # ---> include/partition_alter_11.inc
+ let $alter= ALTER TABLE t1 MODIFY f_int1 MEDIUMINT;
+ --echo # 2.2.1 no PRIMARY KEY or UNIQUE INDEX exists
+ let $unique= ;
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+ #
+ if ($do_pk_tests)
+ {
+ --echo # 2.2.2 PRIMARY KEY exists
+ let $unique= , PRIMARY KEY (f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ let $unique= , PRIMARY KEY (f_int1,f_int2);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+ let $unique= , PRIMARY KEY (f_int2,f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+ }
+ #
+ --echo # 2.2.3 UNIQUE INDEX exists
+ let $unique= , UNIQUE INDEX uidx (f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ let $unique= , UNIQUE INDEX uidx (f_int1,f_int2);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+ let $unique= , UNIQUE INDEX uidx (f_int2,f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+}
+#
+--echo #------------------------------------------------------------------------
+--echo # 2.3 ALTER column f_int1 and f_int2 used in partitioning function
+--echo #------------------------------------------------------------------------
+# Rule: f_int1 and f_int2 is used within the partitioning function
+# ---> include/partition_alter_13.inc
+let $alter= ALTER TABLE t1 MODIFY f_int1 MEDIUMINT, MODIFY f_int2 MEDIUMINT;
+--echo # 2.3.1 no PRIMARY KEY or UNIQUE INDEX exists
+let $unique= ;
+--source suite/parts/inc/partition_alter_11.inc
+# --source include/partition_alter_11.inc
+--source suite/parts/inc/partition_alter_13.inc
+# --source include/partition_alter_13.inc
+#
+if ($do_pk_tests)
+{
+ --echo # 2.3.2 PRIMARY KEY exists
+ # The value of the direct following test is maybe covered by the test with
+ # the PRIMARY KEY containing two columns.
+ if ($more_pk_ui_tests)
+ {
+ let $unique= , PRIMARY KEY (f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ }
+ # --source include/partition_alter_11.inc
+ let $unique= , PRIMARY KEY (f_int1,f_int2);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+ let $unique= , PRIMARY KEY (f_int2,f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+ --source suite/parts/inc/partition_alter_13.inc
+ # --source include/partition_alter_13.inc
+}
+#
+--echo # 2.3.3 UNIQUE INDEX exists
+# The value of the direct following test is maybe covered by the test with
+# the UNIQUE INDEX containing two columns.
+if ($more_pk_ui_tests)
+{
+ let $unique= , UNIQUE INDEX uidx (f_int1);
+ --source suite/parts/inc/partition_alter_11.inc
+ # --source include/partition_alter_11.inc
+}
+let $unique= , UNIQUE INDEX uidx (f_int1,f_int2);
+--source suite/parts/inc/partition_alter_11.inc
+# --source include/partition_alter_11.inc
+--source suite/parts/inc/partition_alter_13.inc
+# --source include/partition_alter_13.inc
+let $unique= , UNIQUE INDEX uidx (f_int2,f_int1);
+--source suite/parts/inc/partition_alter_11.inc
+# --source include/partition_alter_11.inc
+--source suite/parts/inc/partition_alter_13.inc
+# --source include/partition_alter_13.inc
+#
+
+if (0)
+{
+--echo
+--echo #========================================================================
+--echo # 3 ALTER the type of the column used in the partitioning
+--echo # function and/or PRIMARY KEY and/or UNIQUE INDEX
+--echo # INTEGER --> FLOAT
+--echo # INTEGER --> DECIMAL
+--echo # INTEGER --> VARCHAR
+--echo # ML: I assume that at least the first two variants are of some
+--echo # interest. But I am unsure if the server allows such
+--echo # conversions. I also think that such operations have a
+--echo # conversions very small likelihood.
+--echo # To be implemented.
+--echo #========================================================================
+}
diff --git a/mysql-test/suite/parts/inc/partition_alter3.inc b/mysql-test/suite/parts/inc/partition_alter3.inc
new file mode 100644
index 00000000000..48ad61ebe08
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_alter3.inc
@@ -0,0 +1,201 @@
+################################################################################
+# include/partition_alter3.inc #
+# #
+# Purpose: #
+# Tests for partition management commands for HASH and KEY partitioning #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-04-11 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+--echo
+--echo #========================================================================
+--echo # 1. Partition management commands on HASH partitioned table
+--echo # column in partitioning function is of type DATE
+--echo #========================================================================
+# 1. Create the table
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+eval CREATE TABLE t1 (f_date DATE, f_varchar VARCHAR(30));
+# 2. Fill the table t1 with records
+INSERT INTO t1 (f_date, f_varchar)
+SELECT CONCAT(CAST((f_int1 + 999) AS CHAR),'-02-10'), CAST(f_char1 AS CHAR)
+FROM t0_template
+WHERE f_int1 + 999 BETWEEN 1000 AND 9999;
+# 3. Calculate the number of inserted records.
+SELECT IF(9999 - 1000 + 1 > @max_row, @max_row , 9999 - 1000 + 1)
+ INTO @exp_row_count;
+# DEBUG SELECT @exp_row_count;
+# 4. Print the layout, check Readability
+--source include/partition_layout.inc
+--source suite/parts/inc/partition_check_read1.inc
+#
+--echo #------------------------------------------------------------------------
+--echo # 1.1 Increase number of PARTITIONS
+--echo #------------------------------------------------------------------------
+--echo # 1.1.1 ADD PARTITION to not partitioned table --> must fail
+--error ER_PARTITION_MGMT_ON_NONPARTITIONED
+ALTER TABLE t1 ADD PARTITION (PARTITION part2);
+#
+--echo # 1.1.2 Assign HASH partitioning
+ALTER TABLE t1 PARTITION BY HASH(CAST(YEAR(f_date) AS SIGNED INTEGER));
+--source include/partition_layout.inc
+--source suite/parts/inc/partition_check_read1.inc
+#
+--echo # 1.1.3 Assign other HASH partitioning to already partitioned table
+--echo # + test and switch back + test
+ALTER TABLE t1 PARTITION BY HASH(CAST(f_varchar AS SIGNED INTEGER));
+--source include/partition_layout.inc
+--source suite/parts/inc/partition_check_read1.inc
+ALTER TABLE t1 PARTITION BY HASH(CAST(YEAR(f_date) AS SIGNED INTEGER));
+--source include/partition_layout.inc
+--source suite/parts/inc/partition_check_read1.inc
+#
+--echo # 1.1.4 Add PARTITIONS not fitting to HASH --> must fail
+--error ER_PARTITION_WRONG_VALUES_ERROR
+ALTER TABLE t1 ADD PARTITION (PARTITION part1 VALUES IN (0));
+--error ER_PARTITION_WRONG_VALUES_ERROR
+ALTER TABLE t1 ADD PARTITION (PARTITION part2 VALUES LESS THAN (0));
+#
+--echo # 1.1.5 Add two named partitions + test
+ALTER TABLE t1 ADD PARTITION (PARTITION part1, PARTITION part7);
+--source include/partition_layout.inc
+--source suite/parts/inc/partition_check_read1.inc
+#
+--echo # 1.1.6 Add two named partitions, name clash --> must fail
+--error ER_SAME_NAME_PARTITION
+ALTER TABLE t1 ADD PARTITION (PARTITION part1, PARTITION part7);
+#
+--echo # 1.1.7 Add one named partition + test
+ALTER TABLE t1 ADD PARTITION (PARTITION part2);
+--source include/partition_layout.inc
+--source suite/parts/inc/partition_check_read1.inc
+#
+--echo # 1.1.8 Add four not named partitions + test
+ALTER TABLE t1 ADD PARTITION PARTITIONS 4;
+--source include/partition_layout.inc
+--source suite/parts/inc/partition_check_read1.inc
+
+--echo #------------------------------------------------------------------------
+--echo # 1.2 Decrease number of PARTITIONS
+--echo #------------------------------------------------------------------------
+--echo # 1.2.1 DROP PARTITION is not supported for HASH --> must fail
+--error ER_ONLY_ON_RANGE_LIST_PARTITION
+ALTER TABLE t1 DROP PARTITION part1;
+#
+--echo # 1.2.2 COALESCE PARTITION partitionname is not supported
+--error 1064
+ALTER TABLE t1 COALESCE PARTITION part1;
+#
+--echo # 1.2.3 Decrease by 0 is non sense --> must fail
+--error ER_COALESCE_PARTITION_NO_PARTITION
+ALTER TABLE t1 COALESCE PARTITION 0;
+#
+--echo # 1.2.4 COALESCE one partition + test loop
+let $loop= 7;
+while ($loop)
+{
+ ALTER TABLE t1 COALESCE PARTITION 1;
+ --source include/partition_layout.inc
+ --source suite/parts/inc/partition_check_read1.inc
+ dec $loop;
+}
+--echo # 1.2.5 COALESCE of last partition --> must fail
+--error ER_DROP_LAST_PARTITION
+ALTER TABLE t1 COALESCE PARTITION 1;
+#
+--echo # 1.2.6 Remove partitioning
+ALTER TABLE t1 REMOVE PARTITIONING;
+--source include/partition_layout.inc
+--source suite/parts/inc/partition_check_read1.inc
+#
+--echo # 1.2.7 Remove partitioning from not partitioned table --> ????
+ALTER TABLE t1 REMOVE PARTITIONING;
+DROP TABLE t1;
+--source suite/parts/inc/partition_check_drop.inc
+# --source suite/parts/inc/partition_check_drop.inc
+
+--echo
+--echo #========================================================================
+--echo # 2. Partition management commands on KEY partitioned table
+--echo #========================================================================
+# 1. Create the table
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+eval CREATE TABLE t1 (
+$column_list
+);
+# 2. Fill the table t1 with some records
+eval $insert_all;
+# 4. Print the layout, check Readability
+--source include/partition_layout.inc
+--source suite/parts/inc/partition_check_read2.inc
+#
+--echo #------------------------------------------------------------------------
+--echo # 2.1 Increase number of PARTITIONS
+--echo # Some negative testcases are omitted (already checked with HASH).
+--echo #------------------------------------------------------------------------
+--echo # 2.1.1 Assign KEY partitioning
+ALTER TABLE t1 PARTITION BY KEY(f_int1);
+--source include/partition_layout.inc
+--source suite/parts/inc/partition_check_read2.inc
+#
+--echo # 2.1.2 Add PARTITIONS not fitting to KEY --> must fail
+--error ER_PARTITION_WRONG_VALUES_ERROR
+ALTER TABLE t1 ADD PARTITION (PARTITION part1 VALUES IN (0));
+--error ER_PARTITION_WRONG_VALUES_ERROR
+ALTER TABLE t1 ADD PARTITION (PARTITION part2 VALUES LESS THAN (0));
+#
+--echo # 2.1.3 Add two named partitions + test
+ALTER TABLE t1 ADD PARTITION (PARTITION part1, PARTITION part7);
+--source include/partition_layout.inc
+--source suite/parts/inc/partition_check_read2.inc
+#
+--echo # 2.1.4 Add one named partition + test
+ALTER TABLE t1 ADD PARTITION (PARTITION part2);
+--source include/partition_layout.inc
+--source suite/parts/inc/partition_check_read2.inc
+#
+--echo # 2.1.5 Add four not named partitions + test
+ALTER TABLE t1 ADD PARTITION PARTITIONS 4;
+--source include/partition_layout.inc
+--source suite/parts/inc/partition_check_read2.inc
+
+--echo #------------------------------------------------------------------------
+--echo # 2.2 Decrease number of PARTITIONS
+--echo # Some negative testcases are omitted (already checked with HASH).
+--echo #------------------------------------------------------------------------
+--echo # 2.2.1 DROP PARTITION is not supported for KEY --> must fail
+--error ER_ONLY_ON_RANGE_LIST_PARTITION
+ALTER TABLE t1 DROP PARTITION part1;
+#
+--echo # 2.2.4 COALESCE one partition + test loop
+let $loop= 7;
+while ($loop)
+{
+ ALTER TABLE t1 COALESCE PARTITION 1;
+ --source include/partition_layout.inc
+ --source suite/parts/inc/partition_check_read2.inc
+ dec $loop;
+}
+--echo # 2.2.5 COALESCE of last partition --> must fail
+--error ER_DROP_LAST_PARTITION
+ALTER TABLE t1 COALESCE PARTITION 1;
+#
+--echo # 2.2.6 Remove partitioning
+ALTER TABLE t1 REMOVE PARTITIONING;
+--source include/partition_layout.inc
+--source suite/parts/inc/partition_check_read2.inc
+#
+--echo # 2.2.7 Remove partitioning from not partitioned table --> ????
+ALTER TABLE t1 REMOVE PARTITIONING;
+DROP TABLE t1;
+--source suite/parts/inc/partition_check_drop.inc
+# --source suite/parts/inc/partition_check_drop.inc
+
diff --git a/mysql-test/suite/parts/inc/partition_alter4.inc b/mysql-test/suite/parts/inc/partition_alter4.inc
new file mode 100644
index 00000000000..e6f5dadbcca
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_alter4.inc
@@ -0,0 +1,126 @@
+################################################################################
+# include/partition_alter1.inc #
+# #
+# Purpose: #
+# Execute ALTER ... OPTIMIZE/CHECK/REBUID/ANALYZE statements (maintenance) #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-07-27 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+--echo
+--echo #========================================================================
+--echo # 1.1.1.12 ALTER TABLE <maintenance> PARTITION
+--echo #========================================================================
+--echo #------------------------------------------------------------------------
+--echo # 1 ALTER ... ANALYZE PARTITION
+--echo #------------------------------------------------------------------------
+--echo # 1.1 ALTER ... ANALYZE PARTITION part_1;
+let $alter= ALTER TABLE t1 ANALYZE PARTITION part_1;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+--echo # 1.2 ALTER ... ANALYZE PARTITION part_1,part_2;
+let $alter= ALTER TABLE t1 ANALYZE PARTITION part_1,part_2;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+--echo # 1.3 ALTER ... ANALYZE PARTITION part_1,part_2,part_5,part_6,part_10;
+let $alter= ALTER TABLE t1 ANALYZE PARTITION part_1,part_2,part_5,part_6,part_10;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+--echo # 1.4 ALTER ... ANALYZE PARTITION part_1,part_1,part_1;
+let $alter= ALTER TABLE t1 ANALYZE PARTITION part_1,part_1,part_1;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+
+--echo #------------------------------------------------------------------------
+--echo # 2 ALTER ... CHECK PARTITION
+--echo #------------------------------------------------------------------------
+--echo # 2.1 ALTER ... CHECK PARTITION part_1;
+let $alter= ALTER TABLE t1 CHECK PARTITION part_1;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+--echo # 2.2 ALTER ... CHECK PARTITION part_1,part_2;
+let $alter= ALTER TABLE t1 CHECK PARTITION part_1,part_2;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+--echo # 2.3 ALTER ... CHECK PARTITION part_1,part_2,part_5,part_6,part_10;
+let $alter= ALTER TABLE t1 CHECK PARTITION part_1,part_2,part_5,part_6,part_10;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+--echo # 2.4 ALTER ... CHECK PARTITION part_1,part_1,part_1;
+let $alter= ALTER TABLE t1 CHECK PARTITION part_1,part_1,part_1;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+
+--echo #------------------------------------------------------------------------
+--echo # 3 ALTER ... OPTIMIZE PARTITION
+--echo #------------------------------------------------------------------------
+--echo # 3.1 ALTER ... OPTIMIZE PARTITION part_1;
+let $alter= ALTER TABLE t1 OPTIMIZE PARTITION part_1;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+--echo # 3.2 ALTER ... OPTIMIZE PARTITION part_1,part_2;
+let $alter= ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+--echo # 3.3 ALTER ... OPTIMIZE PARTITION part_1,part_2,part_5,part_6,part_10;
+let $alter= ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_2,part_5,part_6,part_10;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+--echo # 3.4 ALTER ... OPTIMIZE PARTITION part_1,part_1,part_1;
+let $alter= ALTER TABLE t1 OPTIMIZE PARTITION part_1,part_1,part_1;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+
+--echo #------------------------------------------------------------------------
+--echo # 4 ALTER ... REBUILD PARTITION
+--echo #------------------------------------------------------------------------
+--echo # 4.1 ALTER ... REBUILD PARTITION part_1;
+let $alter= ALTER TABLE t1 REBUILD PARTITION part_1;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+--echo # 4.2 ALTER ... REBUILD PARTITION part_1,part_2;
+let $alter= ALTER TABLE t1 REBUILD PARTITION part_1,part_2;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+--echo # 4.3 ALTER ... REBUILD PARTITION part_1,part_2,part_5,part_6,part_10;
+let $alter= ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+--echo # 4.4 ALTER ... REBUILD PARTITION part_1,part_1,part_1;
+let $alter= ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+
+--echo #------------------------------------------------------------------------
+--echo # 5 ALTER ... REPAIR PARTITION
+--echo #------------------------------------------------------------------------
+--echo # 5.1 ALTER ... REBUILD PARTITION part_1;
+let $alter= ALTER TABLE t1 REBUILD PARTITION part_1;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+--echo # 5.2 ALTER ... REBUILD PARTITION part_1,part_2;
+let $alter= ALTER TABLE t1 REBUILD PARTITION part_1,part_2;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+--echo # 5.3 ALTER ... REBUILD PARTITION part_1,part_2,part_5,part_6,part_10;
+let $alter= ALTER TABLE t1 REBUILD PARTITION part_1,part_2,part_5,part_6,part_10;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+--echo # 5.4 ALTER ... REBUILD PARTITION part_1,part_1,part_1;
+let $alter= ALTER TABLE t1 REBUILD PARTITION part_1,part_1,part_1;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+
+--echo #------------------------------------------------------------------------
+--echo # 6 ALTER ... REMOVE PARTITIONING
+--echo #------------------------------------------------------------------------
+--echo # 6.1 ALTER ... REMOVE PARTITIONING;
+let $alter= ALTER TABLE t1 REMOVE PARTITIONING;
+--source suite/parts/inc/partition_alter_41.inc
+# --source include/partition_alter_41.inc
+
diff --git a/mysql-test/suite/parts/inc/partition_alter_1.inc b/mysql-test/suite/parts/inc/partition_alter_1.inc
new file mode 100644
index 00000000000..542a67ccbef
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_alter_1.inc
@@ -0,0 +1,68 @@
+################################################################################
+# include/partition_alter_1.inc #
+# #
+# Purpose: #
+# Alter a partioned table and check the usability afterwards #
+# This script is only usefule when sourced by #
+# include/partition_alter_1[1|3].inc #
+# #
+# 0. Expect there is a table t1 #
+# 1. Insert the first half of the table t0_template into t1 #
+# 2. Execute the ALTER TABLE statement within the variable $alter #
+# Case SQL code in #
+# 0: 1. Insert the second half of the table t0_template into t1 #
+# 2. Execute the usability test include/partition_check.inc #
+# >0, but expected: nothing #
+# >0 and unexpected: abort #
+# 3. DROP the table t1 #
+# #
+# The parameter $alter has to be set before sourcing this script. #
+# Example: #
+# CREATE TABLE t1 (f_int1 INT,f_int2 INT, .... ); #
+# let $alter= ALTER TABLE t1 ADD PRIMARY KEY(f_int2); #
+# include/partition_alter_1.inc #
+# #
+# The parameters $insert_first_half and $insert_second_half #
+# are also to be set outside (source ./include/partition.pre). #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+eval $insert_first_half;
+# Possible/Expected return codes for ALTER TABLE ...
+# 0
+# 1491: A PRIMARY KEY need to include all fields in the partition function
+# A UNIQUE INDEX need to include all fields in the partition function
+--disable_abort_on_error
+eval $alter;
+--enable_abort_on_error
+if ($no_debug)
+{
+--disable_query_log
+}
+eval SET @my_errno = $mysql_errno;
+let $run_test= `SELECT @my_errno = 0`;
+let $unexpected_error= `SELECT @my_errno NOT IN (0,1030,1491,1495)`;
+if ($unexpected_error)
+{
+ --echo # The last command got an unexepected error response.
+ --echo # Expected/handled SQL codes are 0,1030,1491,1495
+ SELECT '# SQL code we got was: ' AS "", @my_errno AS "";
+ --echo # Sorry, have to abort.
+ exit;
+ --echo
+}
+--enable_query_log
+# Prevent execution of following usage tests, when ALTER TABLE failed
+if ($run_test)
+{
+eval $insert_second_half;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+}
+DROP TABLE t1;
diff --git a/mysql-test/suite/parts/inc/partition_alter_11.inc b/mysql-test/suite/parts/inc/partition_alter_11.inc
new file mode 100644
index 00000000000..f26d8e822ae
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_alter_11.inc
@@ -0,0 +1,202 @@
+################################################################################
+# include/partition_alter_11.inc #
+# #
+# Purpose: #
+# Check ALTER partitioned table and the state of the table afterwards #
+# The partitioning function use the column f_int1 #
+# #
+# For all partitioning methods #
+# PARTITION BY HASH/KEY/LIST/RANGE #
+# PARTITION BY RANGE/LIST ... SUBPARTITION BY HASH/KEY ... #
+# do #
+# 1. Create the partitioned table #
+# 2. Execute include/partition_alter_1.inc, which will #
+# - Insert the first half of the table t0_template into t1 #
+# - Execute the ALTER TABLE statement #
+# - Insert the second half of the table t0_template into t1 #
+# - Execute the usability test include/partition_check.inc #
+# - Drop the table t1 #
+# done #
+# #
+# The parameters #
+# $unique -- PRIMARY KEY or UNIQUE INDEXes to be created within the #
+# CREATE TABLE STATEMENT #
+# $alter -- ALTER TABLE statement, which has to be executed #
+# have to be set before sourcing this routine. #
+# Example: #
+# let $unique= , UNIQUE INDEX uidx1 (f_int1); #
+# let $alter= ALTER TABLE t1 DROP UNIQUE INDEX uidx1; #
+# include/partition_alter1.inc #
+# #
+# Attention: The routine include/partition_alter_13.inc is very similar #
+# to this one. So if something has to be changed here it #
+# might be necessary to do it also there #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $partitioning= ;
+#----------- PARTITION BY HASH
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY HASH(f_int1) PARTITIONS 2;
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY KEY
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY KEY(f_int1) PARTITIONS 5;
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY LIST
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY LIST(MOD(f_int1,4))
+(PARTITION part_3 VALUES IN (-3),
+ PARTITION part_2 VALUES IN (-2),
+ PARTITION part_1 VALUES IN (-1),
+ PARTITION part_N VALUES IN (NULL),
+ PARTITION part0 VALUES IN (0),
+ PARTITION part1 VALUES IN (1),
+ PARTITION part2 VALUES IN (2),
+ PARTITION part3 VALUES IN (3));
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY RANGE
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux = 'PARTITION BY RANGE(f_int1)
+(PARTITION parta VALUES LESS THAN (0),
+PARTITION partb VALUES LESS THAN ($max_row_div4),
+PARTITION partc VALUES LESS THAN ($max_row_div2),
+PARTITION partd VALUES LESS THAN ($max_row_div2 + $max_row_div4),
+PARTITION parte VALUES LESS THAN ($max_row),
+PARTITION partf VALUES LESS THAN $MAX_VALUE)';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY RANGE -- SUBPARTITION BY HASH
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2
+(PARTITION parta VALUES LESS THAN (0),
+PARTITION partb VALUES LESS THAN ($max_row_div4),
+PARTITION partc VALUES LESS THAN ($max_row_div2),
+PARTITION partd VALUES LESS THAN $MAX_VALUE)';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY RANGE -- SUBPARTITION BY KEY
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux = 'PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1)
+(PARTITION part1 VALUES LESS THAN (0)
+(SUBPARTITION subpart11, SUBPARTITION subpart12),
+PARTITION part2 VALUES LESS THAN ($max_row_div4)
+(SUBPARTITION subpart21, SUBPARTITION subpart22),
+PARTITION part3 VALUES LESS THAN ($max_row_div2)
+(SUBPARTITION subpart31, SUBPARTITION subpart32),
+PARTITION part4 VALUES LESS THAN $MAX_VALUE
+(SUBPARTITION subpart41, SUBPARTITION subpart42))';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY LIST -- SUBPARTITION BY HASH
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1)
+(PARTITION part1 VALUES IN (0)
+ (SUBPARTITION sp11, SUBPARTITION sp12),
+ PARTITION part2 VALUES IN (1)
+ (SUBPARTITION sp21, SUBPARTITION sp22),
+ PARTITION part3 VALUES IN (2)
+ (SUBPARTITION sp31, SUBPARTITION sp32),
+ PARTITION part4 VALUES IN (NULL)
+ (SUBPARTITION sp41, SUBPARTITION sp42));
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY LIST -- SUBPARTITION BY KEY
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY LIST(ABS(MOD(f_int1,2)))
+SUBPARTITION BY KEY(f_int1) SUBPARTITIONS $sub_part_no
+(PARTITION part1 VALUES IN (0),
+ PARTITION part2 VALUES IN (1),
+ PARTITION part3 VALUES IN (NULL))';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
diff --git a/mysql-test/suite/parts/inc/partition_alter_13.inc b/mysql-test/suite/parts/inc/partition_alter_13.inc
new file mode 100644
index 00000000000..5152230795a
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_alter_13.inc
@@ -0,0 +1,202 @@
+################################################################################
+# include/partition_alter_13.inc #
+# #
+# Purpose: #
+# Check ALTER partitioned table and the state of the table afterwards #
+# The partitioning function uses the columns f_int1 and f_int2 #
+# #
+# For all partitioning methods #
+# PARTITION BY HASH/KEY/LIST/RANGE #
+# PARTITION BY RANGE/LIST ... SUBPARTITION BY HASH/KEY ... #
+# do #
+# 1. Create the partitioned table #
+# 2. Execute include/partition_alter_1.inc, which will #
+# - Insert the first half of the table t0_template into t1 #
+# - Execute the ALTER TABLE statement #
+# - Insert the second half of the table t0_template into t1 #
+# - Execute the usability test include/partition_check.inc #
+# - Drop the table t1 #
+# done #
+# #
+# The parameters #
+# $unique -- PRIMARY KEY or UNIQUE INDEXes to be created within the #
+# CREATE TABLE STATEMENT #
+# $alter -- ALTER TABLE statement, which has to be executed #
+# have to be set before sourcing this routine. #
+# Example: #
+# let $unique= , UNIQUE INDEX uidx1 (f_int1); #
+# let $alter= ALTER TABLE t1 DROP UNIQUE INDEX uidx1; #
+# include/partition_alter1.inc #
+# #
+# Attention: The routine include/partition_alter_11.inc is very similar #
+# to this one. So if something has to be changed here it #
+# might be necessary to do it also there #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $partitioning= ;
+#----------- PARTITION BY HASH
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY HASH(f_int1 + f_int2) PARTITIONS 2;
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY KEY
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY KEY(f_int1,f_int2) PARTITIONS 5;
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY LIST
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY LIST(MOD(f_int1 + f_int2,4))
+(PARTITION part_3 VALUES IN (-3),
+ PARTITION part_2 VALUES IN (-2),
+ PARTITION part_1 VALUES IN (-1),
+ PARTITION part_N VALUES IN (NULL),
+ PARTITION part0 VALUES IN (0),
+ PARTITION part1 VALUES IN (1),
+ PARTITION part2 VALUES IN (2),
+ PARTITION part3 VALUES IN (3));
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY RANGE
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux = 'PARTITION BY RANGE((f_int1 + f_int2) DIV 2)
+(PARTITION parta VALUES LESS THAN (0),
+PARTITION partb VALUES LESS THAN ($max_row_div4),
+PARTITION partc VALUES LESS THAN ($max_row_div2),
+PARTITION partd VALUES LESS THAN ($max_row_div2 + $max_row_div4),
+PARTITION parte VALUES LESS THAN ($max_row),
+PARTITION partf VALUES LESS THAN $MAX_VALUE)';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY RANGE -- SUBPARTITION BY HASH
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY RANGE(f_int1) SUBPARTITION BY HASH(f_int2) SUBPARTITIONS 2
+(PARTITION parta VALUES LESS THAN (0),
+PARTITION partb VALUES LESS THAN ($max_row_div4),
+PARTITION partc VALUES LESS THAN ($max_row_div2),
+PARTITION partd VALUES LESS THAN $MAX_VALUE)';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY RANGE -- SUBPARTITION BY KEY
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux = 'PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int2)
+(PARTITION part1 VALUES LESS THAN (0)
+(SUBPARTITION subpart11, SUBPARTITION subpart12),
+PARTITION part2 VALUES LESS THAN ($max_row_div4)
+(SUBPARTITION subpart21, SUBPARTITION subpart22),
+PARTITION part3 VALUES LESS THAN ($max_row_div2)
+(SUBPARTITION subpart31, SUBPARTITION subpart32),
+PARTITION part4 VALUES LESS THAN $MAX_VALUE
+(SUBPARTITION subpart41, SUBPARTITION subpart42))';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY LIST -- SUBPARTITION BY HASH
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int2 + 1)
+(PARTITION part1 VALUES IN (0)
+ (SUBPARTITION sp11, SUBPARTITION sp12),
+ PARTITION part2 VALUES IN (1)
+ (SUBPARTITION sp21, SUBPARTITION sp22),
+ PARTITION part3 VALUES IN (2)
+ (SUBPARTITION sp31, SUBPARTITION sp32),
+ PARTITION part4 VALUES IN (NULL)
+ (SUBPARTITION sp41, SUBPARTITION sp42));
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY LIST -- SUBPARTITION BY KEY
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY LIST(ABS(MOD(f_int1,2)))
+SUBPARTITION BY KEY(f_int2) SUBPARTITIONS $sub_part_no
+(PARTITION part1 VALUES IN (0),
+ PARTITION part2 VALUES IN (1),
+ PARTITION part3 VALUES IN (NULL))';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
diff --git a/mysql-test/suite/parts/inc/partition_alter_41.inc b/mysql-test/suite/parts/inc/partition_alter_41.inc
new file mode 100644
index 00000000000..303ec8c2062
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_alter_41.inc
@@ -0,0 +1,202 @@
+################################################################################
+# include/partition_alter_11.inc #
+# #
+# Purpose: #
+# Check ALTER partitioned table and the state of the table afterwards #
+# The partitioning function use the column f_int1 #
+# #
+# For all partitioning methods #
+# PARTITION BY HASH/KEY/LIST/RANGE #
+# PARTITION BY RANGE/LIST ... SUBPARTITION BY HASH/KEY ... #
+# do #
+# 1. Create the partitioned table #
+# 2. Execute include/partition_alter_1.inc, which will #
+# - Insert the first half of the table t0_template into t1 #
+# - Execute the ALTER TABLE statement #
+# - Insert the second half of the table t0_template into t1 #
+# - Execute the usability test include/partition_check.inc #
+# - Drop the table t1 #
+# done #
+# #
+# The parameters #
+# $unique -- PRIMARY KEY or UNIQUE INDEXes to be created within the #
+# CREATE TABLE STATEMENT #
+# $alter -- ALTER TABLE statement, which has to be executed #
+# have to be set before sourcing this routine. #
+# Example: #
+# let $unique= , UNIQUE INDEX uidx1 (f_int1); #
+# let $alter= ALTER TABLE t1 DROP UNIQUE INDEX uidx1; #
+# include/partition_alter1.inc #
+# #
+# Attention: The routine include/partition_alter_13.inc is very similar #
+# to this one. So if something has to be changed here it #
+# might be necessary to do it also there #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $partitioning= ;
+#----------- PARTITION BY HASH
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY HASH(f_int1) PARTITIONS 2 (partition part_1, partition part_2);
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY KEY
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY KEY(f_int1) PARTITIONS 5 (partition part_1, partition part_2, partition part_3, partition part_4, partition part_5);
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY LIST
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY LIST(MOD(f_int1,4))
+(PARTITION part_3 VALUES IN (-3),
+ PARTITION part_2 VALUES IN (-2),
+ PARTITION part_1 VALUES IN (-1),
+ PARTITION part_N VALUES IN (NULL),
+ PARTITION part0 VALUES IN (0),
+ PARTITION part1 VALUES IN (1),
+ PARTITION part2 VALUES IN (2),
+ PARTITION part3 VALUES IN (3));
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY RANGE
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux = 'PARTITION BY RANGE(f_int1)
+(PARTITION parta VALUES LESS THAN (0),
+PARTITION part_1 VALUES LESS THAN ($max_row_div4),
+PARTITION part_2 VALUES LESS THAN ($max_row_div2),
+PARTITION part_3 VALUES LESS THAN ($max_row_div2 + $max_row_div4),
+PARTITION part_4 VALUES LESS THAN ($max_row),
+PARTITION part_5 VALUES LESS THAN $MAX_VALUE)';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY RANGE -- SUBPARTITION BY HASH
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2
+(PARTITION part_1 VALUES LESS THAN (0),
+PARTITION part_2 VALUES LESS THAN ($max_row_div4),
+PARTITION part_3 VALUES LESS THAN ($max_row_div2),
+PARTITION part_4 VALUES LESS THAN $MAX_VALUE)';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY RANGE -- SUBPARTITION BY KEY
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux = 'PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1)
+(PARTITION part_1 VALUES LESS THAN (0)
+(SUBPARTITION subpart11, SUBPARTITION subpart12),
+PARTITION part_2 VALUES LESS THAN ($max_row_div4)
+(SUBPARTITION subpart21, SUBPARTITION subpart22),
+PARTITION part_3 VALUES LESS THAN ($max_row_div2)
+(SUBPARTITION subpart31, SUBPARTITION subpart32),
+PARTITION part_4 VALUES LESS THAN $MAX_VALUE
+(SUBPARTITION subpart41, SUBPARTITION subpart42))';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY LIST -- SUBPARTITION BY HASH
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1)
+(PARTITION part_1 VALUES IN (0)
+ (SUBPARTITION sp11, SUBPARTITION sp12),
+ PARTITION part_2 VALUES IN (1)
+ (SUBPARTITION sp21, SUBPARTITION sp22),
+ PARTITION part_3 VALUES IN (2)
+ (SUBPARTITION sp31, SUBPARTITION sp32),
+ PARTITION part_4 VALUES IN (NULL)
+ (SUBPARTITION sp41, SUBPARTITION sp42));
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
+
+#----------- PARTITION BY LIST -- SUBPARTITION BY KEY
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY LIST(ABS(MOD(f_int1,2)))
+SUBPARTITION BY KEY(f_int1) SUBPARTITIONS $sub_part_no
+(PARTITION part_1 VALUES IN (0),
+ PARTITION part_2 VALUES IN (1),
+ PARTITION part_3 VALUES IN (NULL))';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+--source suite/parts/inc/partition_alter_1.inc
+# --source include/partition_alter_1.inc
diff --git a/mysql-test/suite/parts/inc/partition_basic.inc b/mysql-test/suite/parts/inc/partition_basic.inc
new file mode 100644
index 00000000000..9854edab634
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_basic.inc
@@ -0,0 +1,179 @@
+################################################################################
+# include/partition_basic.inc #
+# #
+# Purpose: #
+# Basic tests around create partitioned table with/without PRIMARY KEY and #
+# /or UNIQUE INDEX #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+--enable_abort_on_error
+
+--echo
+--echo #========================================================================
+--echo # Check partitioning methods on just created tables
+--echo # The tables should be defined without/with PRIMARY KEY and
+--echo # UNIQUE INDEXes.
+--echo # Every test round has to check
+--echo # PARTITION BY HASH/KEY/LIST/RANGE
+--echo # PARTITION BY RANGE/LIST ... SUBPARTITION BY HASH/KEY ...
+--echo #========================================================================
+--echo #------------------------------------------------------------------------
+--echo # 1 Tables without PRIMARY KEY or UNIQUE INDEXes
+--echo #------------------------------------------------------------------------
+--echo # 1.1 The partitioning function contains one column.
+let $unique= ;
+--source suite/parts/inc/partition_methods1.inc
+# --source include/partition_methods1.inc
+#
+ --echo # 1.1.1 with DATA DIECTORY/INDEX DIRECTORY
+ #
+ --disable_query_log
+ # DATA DIRECTORY
+ # Make directory for partition data
+ --exec mkdir $MYSQLTEST_VARDIR/master-data/test/data || true
+ eval SET @data_dir = 'DATA DIRECTORY =
+ ''''$MYSQLTEST_VARDIR/master-data/test/data''''';
+ let $data_directory = `select @data_dir`;
+
+ #INDEX DIRECTORY
+ # Make directory for partition index
+ --exec mkdir $MYSQLTEST_VARDIR/master-data/test/index || true
+ eval SET @indx_dir = 'INDEX DIRECTORY =
+ ''''$MYSQLTEST_VARDIR/master-data/test/index''''';
+ let $index_directory = `select @indx_dir`;
+
+ let $with_directories= 1;
+ --source suite/parts/inc/partition_methods1.inc
+ # --source include/partition_methods1.inc
+ --source suite/parts/inc/partition_directory.inc
+ # --source include/partition_methods1.inc
+ let $with_directories= 0;
+ --enable_query_log
+ #
+--echo # 1.2 The partitioning function contains two columns.
+let $unique= ;
+--source suite/parts/inc/partition_methods2.inc
+# --source include/partition_methods2.inc
+#
+--echo #------------------------------------------------------------------------
+--echo # 2 Tables with PRIMARY KEY and/or UNIQUE INDEXes
+--echo # The partitioning function contains one column.
+--echo #------------------------------------------------------------------------
+if ($more_pk_ui_tests)
+{
+ if ($do_pk_tests)
+ {
+ --echo # 2.1 PRIMARY KEY consisting of one column
+ let $unique= , PRIMARY KEY(f_int1);
+ --source suite/parts/inc/partition_methods1.inc
+ # --source include/partition_methods1.inc
+ }
+ --echo # 2.2 UNIQUE INDEX consisting of one column
+ let $unique= , UNIQUE INDEX uidx1 (f_int1);
+ --source suite/parts/inc/partition_methods1.inc
+ # --source include/partition_methods1.inc
+
+ --echo # 2.2.1 with DATA DIECTORY/INDEX DIRECTORY
+ #
+ --disable_query_log
+ # DATA DIRECTORY
+ # Make directory for partition data
+ --exec mkdir $MYSQLTEST_VARDIR/master-data/test/data || true
+ eval SET @data_dir = 'DATA DIRECTORY =
+ ''''$MYSQLTEST_VARDIR/master-data/test/data''''';
+ let $data_directory = `select @data_dir`;
+
+ #INDEX DIRECTORY
+ # Make directory for partition index
+ --exec mkdir $MYSQLTEST_VARDIR/master-data/test/index || true
+ eval SET @indx_dir = 'INDEX DIRECTORY =
+ ''''$MYSQLTEST_VARDIR/master-data/test/index''''';
+ let $index_directory = `select @indx_dir`;
+
+ let $with_directories= TRUE;
+ --source suite/parts/inc/partition_methods1.inc
+ # --source include/partition_methods1.inc
+ let $with_directories= FALSE;
+ --enable_query_log
+ #
+ if ($do_pk_tests)
+ {
+ --echo # 2.3 PRIMARY KEY consisting of two columns
+ let $unique= , PRIMARY KEY(f_int1,f_int2);
+ --source suite/parts/inc/partition_methods1.inc
+ # --source include/partition_methods1.inc
+ let $unique= , PRIMARY KEY(f_int2,f_int1);
+ --source suite/parts/inc/partition_methods1.inc
+ # --source include/partition_methods1.inc
+ }
+ #
+ --echo # 2.4 UNIQUE INDEX consisting of two columns
+ let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2);
+ --source suite/parts/inc/partition_methods1.inc
+ # --source include/partition_methods1.inc
+ let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1);
+ --source suite/parts/inc/partition_methods1.inc
+ # --source include/partition_methods1.inc
+ #
+}
+--echo # 2.5 PRIMARY KEY + UNIQUE INDEX consisting of two columns
+if ($do_pk_tests)
+{
+ let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1);
+ --source suite/parts/inc/partition_methods1.inc
+ # --source include/partition_methods1.inc
+ let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2);
+ --source suite/parts/inc/partition_methods1.inc
+ # --source include/partition_methods1.inc
+}
+let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1);
+--source suite/parts/inc/partition_methods1.inc
+# --source include/partition_methods1.inc
+
+--echo #------------------------------------------------------------------------
+--echo # 3 Tables with PRIMARY KEY and/or UNIQUE INDEXes
+--echo # The partitioning function contains two columns.
+--echo #------------------------------------------------------------------------
+#
+if ($more_pk_ui_tests)
+{
+ if ($do_pk_tests)
+ {
+ --echo # 3.1 PRIMARY KEY consisting of two columns
+ let $unique= , PRIMARY KEY(f_int1,f_int2);
+ --source suite/parts/inc/partition_methods2.inc
+ # --source include/partition_methods2.inc
+
+ let $unique= , PRIMARY KEY(f_int2,f_int1);
+ --source suite/parts/inc/partition_methods2.inc
+ # --source include/partition_methods2.inc
+ }
+ #
+ --echo # 3.2 UNIQUE INDEX consisting of two columns
+ let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2);
+ --source suite/parts/inc/partition_methods2.inc
+ # --source include/partition_methods2.inc
+ let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1);
+ --source suite/parts/inc/partition_methods2.inc
+ # --source include/partition_methods2.inc
+}
+#
+--echo # 3.3 PRIMARY KEY and UNIQUE INDEX consisting of two columns
+if ($do_pk_tests)
+{
+ let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2), PRIMARY KEY(f_int2,f_int1);
+ --source suite/parts/inc/partition_methods2.inc
+ # --source include/partition_methods2.inc
+ let $unique= , UNIQUE INDEX uidx1 (f_int2,f_int1), PRIMARY KEY(f_int1,f_int2);
+ --source suite/parts/inc/partition_methods2.inc
+ # --source include/partition_methods2.inc
+}
+let $unique= , UNIQUE INDEX uidx1 (f_int1,f_int2), UNIQUE INDEX uidx2 (f_int2,f_int1);
+--source suite/parts/inc/partition_methods2.inc
+# --source include/partition_methods2.inc
diff --git a/mysql-test/suite/parts/inc/partition_bigint.inc b/mysql-test/suite/parts/inc/partition_bigint.inc
new file mode 100644
index 00000000000..f7d22ce17d1
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_bigint.inc
@@ -0,0 +1,59 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a bigint unsigned not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612), (1), (2), (65535);
+select * from t1;
+select * from t1 where a=-2;
+delete from t1 where a=-2;
+select * from t1;
+select * from t1 where a=18446744073709551615;
+delete from t1 where a=18446744073709551615;
+select * from t1;
+drop table t1;
+
+eval create table t2 (a bigint unsigned not null, primary key(a)) engine=$engine
+partition by key (a) partitions 10;
+show create table t2;
+insert into t2 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612);
+select * from t2;
+select * from t2 where a=18446744073709551615;
+delete from t2 where a=18446744073709551615;
+select * from t2;
+delete from t2;
+let $count=$maxrows;
+--echo $maxrows inserts;
+--disable_query_log
+while ($count)
+{
+eval insert into t2 values ($count);
+dec $count;
+}
+--enable_query_log
+select count(*) from t2;
+drop table t2;
+
+eval create table t3 (a bigint not null, primary key(a)) engine=$engine
+partition by key (a) partitions 10;
+show create table t3;
+insert into t3 values (9223372036854775807), (9223372036854775806), (9223372036854775805), (9223372036854775804), (-9223372036854775808), (-9223372036854775807), (1), (-1), (0);
+select * from t3;
+select * from t3 where a=9223372036854775806;
+delete from t3 where a=9223372036854775806;
+select * from t3;
+drop table t3;
diff --git a/mysql-test/suite/parts/inc/partition_binary.inc b/mysql-test/suite/parts/inc/partition_binary.inc
new file mode 100644
index 00000000000..7243d6c2ce7
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_binary.inc
@@ -0,0 +1,91 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a binary(255) not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values (repeat('a',255)), ('b'), (repeat('a',128)), (repeat('b',64));
+select hex(a) from t1;
+select a from t1 where substr(a,1,2)='b\0';
+update t1 set a='cc' where substr(a,1,2)= 'b\0';
+select a from t1 where substr(a,1,1)='c';
+delete from t1 where substr(a,1,2)='cc';
+select hex(a) from t1;
+drop table t1;
+
+eval create table t2 (a binary(255) not null, primary key(a)) engine=$engine
+partition by key (a) partitions 27;
+show create table t2;
+let $count=26;
+let $letter=0;
+--echo $count inserts;
+#--disable_query_log
+while ($count)
+{
+eval insert into t2 values (repeat(char(ascii('a')+$letter),$count+54));
+dec $count;
+inc $letter;
+}
+select count(*) from t2;
+select hex(a) from t2;
+drop table t2;
+
+eval create table t3 (a binary(255) not null, primary key(a)) engine=$engine
+partition by range (ascii(a)) subpartition by key (a) subpartitions 4 (
+partition pa16 values less than (16),
+partition pa32 values less than (32),
+partition pa64 values less than (64),
+partition pa128 values less than (128),
+partition pa256 values less than (256)
+);
+show create table t3;
+let $count=26;
+let $letter=0;
+--echo $count inserts;
+#--disable_query_log
+while ($count)
+{
+eval insert into t3 values (repeat(char(ascii('a')+$letter),$count+54));
+dec $count;
+inc $letter;
+}
+select count(*) from t3;
+select hex(a) from t3;
+drop table t3;
+
+eval create table t4 (a binary(255) not null, primary key(a)) engine=$engine
+partition by list (ascii(a)) subpartition by key (a) subpartitions 4 (
+partition pa16 values in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16),
+partition pa32 values in (17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32),
+partition pa64 values in (33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64),
+partition pa128 values in (65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128),
+partition pa256 values in (129,130,131,132,133,134,135,136,137,138,139,140
+,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256)
+);
+show create table t4;
+let $count=26;
+let $letter=0;
+--echo $count inserts;
+#--disable_query_log
+while ($count)
+{
+eval insert into t4 values (repeat(char(ascii('a')+$letter),$count+54));
+dec $count;
+inc $letter;
+}
+select count(*) from t4;
+select hex(a) from t4;
+drop table t4;
diff --git a/mysql-test/suite/parts/inc/partition_bit.inc b/mysql-test/suite/parts/inc/partition_bit.inc
new file mode 100644
index 00000000000..3dd880595a3
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_bit.inc
@@ -0,0 +1,115 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+--error 1439
+eval create table t1 (a bit(65), primary key (a)) engine=$engine partition by key (a);
+
+eval create table t1 (a bit(0), primary key (a)) engine=$engine partition by key (a);
+show create table t1;
+drop table t1;
+
+eval create table t1 (a bit(0), primary key (a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory,
+partition pa2 $data_directory $index_directory);
+show create table t1;
+drop table t1;
+
+eval create table t1 (a bit(64), primary key (a)) engine=$engine
+partition by key (a) partitions 2;
+show create table t1;
+insert into t1 values
+(b'1111111111111111111111111111111111111111111111111111111111111111'),
+(b'1000000000000000000000000000000000000000000000000000000000000000'),
+(b'0000000000000000000000000000000000000000000000000000000000000001'),
+(b'1010101010101010101010101010101010101010101010101010101010101010'),
+(b'0101010101010101010101010101010101010101010101010101010101010101');
+select hex(a) from t1;
+drop table t1;
+
+eval create table t1 (a bit(64), primary key (a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values
+(b'1111111111111111111111111111111111111111111111111111111111111111'),
+(b'1000000000000000000000000000000000000000000000000000000000000000'),
+(b'0000000000000000000000000000000000000000000000000000000000000001'),
+(b'1010101010101010101010101010101010101010101010101010101010101010'),
+(b'0101010101010101010101010101010101010101010101010101010101010101');
+select hex(a) from t1 where a=b'0101010101010101010101010101010101010101010101010101010101010101';
+delete from t1 where a=b'0101010101010101010101010101010101010101010101010101010101010101';
+select hex(a) from t1;
+drop table t1;
+
+eval create table t2 (a bit, primary key (a)) engine=$engine
+partition by key (a) partitions 4;
+show create table t2;
+insert into t2 values (b'0'), (b'1');
+select hex(a) from t2;
+alter table t2 drop primary key;
+show create table t2;
+select hex(a) from t2;
+alter table t2 add primary key (a);
+show create table t2;
+select hex(a) from t2;
+drop table t2;
+
+eval create table t3 (a bit(8), primary key (a)) engine=$engine
+partition by range (a) subpartition by key (a) subpartitions 2 (
+partition pa1 values less than (3),
+partition pa2 values less than (16),
+partition pa3 values less than (64),
+partition pa4 values less than (256));
+show create table t3;
+let $count=255;
+--echo $count inserts;
+--disable_query_log
+while ($count)
+{
+eval insert into t3 values ($count);
+dec $count;
+}
+--enable_query_log
+select hex(a) from t3 where a=b'01010101';
+delete from t3 where a=b'01010101';
+select count(*) from t3;
+select hex(a) from t3;
+drop table t3;
+
+eval create table t4 (a bit(8), primary key (a)) engine=$engine
+partition by list (a) subpartition by key (a) subpartitions 2 (
+partition pa1 values in (0,1,2,3),
+partition pa2 values in (4,5,6,7,8,9,10,11,12,13,14,15,16),
+partition pa3 values in (17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32));
+show create table t4;
+let $count=32;
+--echo $count inserts;
+--disable_query_log
+while ($count)
+{
+eval insert into t4 values ($count);
+dec $count;
+}
+--enable_query_log
+select hex(a) from t4 where a=b'00000001';
+delete from t4 where a=b'00000001';
+select count(*) from t4;
+select hex(a) from t4;
+drop table t4;
diff --git a/mysql-test/suite/parts/inc/partition_blob.inc b/mysql-test/suite/parts/inc/partition_blob.inc
new file mode 100644
index 00000000000..ccff06ba633
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_blob.inc
@@ -0,0 +1,60 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+--error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
+eval create table t1 (a blob not null, primary key(a(767))) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+
+#show create table t1;
+#insert into t1 values (repeat('a',1000)), ('b'), (repeat('a',500)), (repeat('b',64));
+#select * from t1;
+#select * from t1 where a='b';
+#update t1 set a='bb' where a='b';
+#delete from t1 where a='bb';
+#select * from t1;
+#drop table t1;
+
+--error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
+eval create table t2 (a blob not null, primary key(a(767))) engine=$engine
+partition by key (a) partitions 30;
+
+--error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
+eval create table t2 (a tinyblob not null, primary key(a(767))) engine=$engine
+partition by key (a) partitions 30;
+
+--error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
+eval create table t2 (a mediumblob not null, primary key(a(767))) engine=$engine
+partition by key (a) partitions 30;
+
+--error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
+eval create table t2 (a longblob not null, primary key(a(767))) engine=$engine
+partition by key (a) partitions 30;
+
+#show create table t2;
+#let $count=30;
+#let $letter=0;
+#--echo $count inserts;
+#--disable_query_log
+#while ($count)
+#{
+#eval insert into t2 values (repeat(char(ascii('a')+$letter),$count*$count));
+#dec $count;
+#inc $letter;
+#}
+#select count(*) from t2;
+#select * from t2;
+#drop table t2;
+
diff --git a/mysql-test/suite/parts/inc/partition_blocked_sql_funcs.inc b/mysql-test/suite/parts/inc/partition_blocked_sql_funcs.inc
new file mode 100644
index 00000000000..7843a44134c
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_blocked_sql_funcs.inc
@@ -0,0 +1,149 @@
+################################################################################
+# t/partition_blocked_sql_funcs.inc #
+# #
+# Purpose: #
+# Tests around sql functions #
+# #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-11-22 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+--echo -------------------------------------------------------------------------
+--echo --- $sqlfunc in partition with coltype $coltype
+--echo -------------------------------------------------------------------------
+--echo must all fail! (delete 0 and comment char, if bug fixed)
+--disable_abort_on_error
+--disable_warnings
+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 ;
+--enable_warnings
+
+#--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval create table t1 (col1 $coltype) engine=$engine
+partition by range($sqlfunc)
+(partition p0 values less than (15),
+ partition p1 values less than (31));
+
+#--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval create table t2 (col1 $coltype) engine=$engine
+partition by list($sqlfunc)
+(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));
+
+#--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval create table t3 (col1 $coltype) engine=$engine
+partition by hash($sqlfunc);
+--enable_abort_on_error
+
+--error 0,ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval create table t4 (colint int, col1 $coltype) engine=$engine
+partition by range(colint)
+subpartition by hash($sqlfunc) subpartitions 2
+(partition p0 values less than (15),
+ partition p1 values less than (31));
+
+--error 0,ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval create table t5 (colint int, col1 $coltype) engine=$engine
+partition by list(colint)
+subpartition by hash($sqlfunc) 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));
+
+--error 0,ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval create table t6 (colint int, col1 $coltype) engine=$engine
+partition by range(colint)
+(partition p0 values less than ($valsqlfunc),
+ partition p1 values less than maxvalue);
+
+--disable_abort_on_error
+--disable_warnings
+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 ;
+--enable_warnings
+
+#--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval create table t11 (col1 $coltype) engine=$engine ;
+
+#--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval create table t22 (col1 $coltype) engine=$engine ;
+
+#--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval create table t33 (col1 $coltype) engine=$engine ;
+
+--error 0,ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval create table t44 (colint int, col1 $coltype) engine=$engine ;
+
+--error 0,ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval create table t55 (colint int, col1 $coltype) engine=$engine ;
+
+--error 0,ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval create table t66 (colint int, col1 $coltype) engine=$engine ;
+
+#--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval alter table t11
+partition by range($sqlfunc)
+(partition p0 values less than (15),
+ partition p1 values less than (31));
+
+#--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval alter table t22
+partition by list($sqlfunc)
+(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));
+
+#--error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval alter table t33
+partition by hash($sqlfunc);
+--enable_abort_on_error
+
+--error 0,ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval alter table t44
+partition by range(colint)
+subpartition by hash($sqlfunc) subpartitions 2
+(partition p0 values less than (15),
+ partition p1 values less than (31));
+
+--error 0,ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval alter table t55
+partition by list(colint)
+subpartition by hash($sqlfunc) 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));
+
+--error 0,ER_PARTITION_FUNCTION_IS_NOT_ALLOWED,ER_PARSE_ERROR
+eval alter table t66
+partition by range(colint)
+(partition p0 values less than ($valsqlfunc),
+ partition p1 values less than maxvalue);
+
+--disable_warnings
+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 ;
+--enable_warnings
+
diff --git a/mysql-test/suite/parts/inc/partition_char.inc b/mysql-test/suite/parts/inc/partition_char.inc
new file mode 100644
index 00000000000..4e330b122e3
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_char.inc
@@ -0,0 +1,95 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a char(255) not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values (repeat('a',255)), ('b'), (repeat('a',128)), (repeat('b',64));
+select * from t1;
+select * from t1 where a='b';
+update t1 set a='bb' where a='b';
+delete from t1 where a='bb';
+select * from t1;
+drop table t1;
+
+eval create table t2 (a char(255) not null, primary key(a)) engine=$engine
+partition by key (a) partitions 27;
+show create table t2;
+let $count=26;
+let $letter=0;
+--echo $count inserts;
+#--disable_query_log
+while ($count)
+{
+eval insert into t2 values (repeat(char(ascii('a')+$letter),$count+54));
+dec $count;
+inc $letter;
+}
+select count(*) from t2;
+select * from t2;
+drop table t2;
+
+if (0)
+{
+eval create table t3 (a char(255) not null, primary key(a)) engine=$engine
+partition by range (ascii(a)) subpartition by key (a) subpartitions 4 (
+partition pa16 values less than (16),
+partition pa32 values less than (32),
+partition pa64 values less than (64),
+partition pa128 values less than (128),
+partition pa256 values less than (256)
+);
+show create table t3;
+let $count=26;
+let $letter=0;
+--echo $count inserts;
+#--disable_query_log
+while ($count)
+{
+eval insert into t3 values (repeat(char(ascii('a')+$letter),$count+54));
+dec $count;
+inc $letter;
+}
+select count(*) from t3;
+select a from t3;
+drop table t3;
+
+eval create table t4 (a char(255) not null, primary key(a)) engine=$engine
+partition by list (ascii(a)) subpartition by key (a) subpartitions 4 (
+partition pa16 values in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16),
+partition pa32 values in (17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32),
+partition pa64 values in (33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64),
+partition pa128 values in (65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128),
+partition pa256 values in (129,130,131,132,133,134,135,136,137,138,139,140
+,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256)
+);
+show create table t4;
+let $count=26;
+let $letter=0;
+--echo $count inserts;
+#--disable_query_log
+while ($count)
+{
+eval insert into t4 values (repeat(char(ascii('a')+$letter),$count+54));
+dec $count;
+inc $letter;
+}
+select count(*) from t4;
+select a from t4;
+drop table t4;
+}
+#if (0)
+
diff --git a/mysql-test/suite/parts/inc/partition_check.inc b/mysql-test/suite/parts/inc/partition_check.inc
new file mode 100644
index 00000000000..698e9611af1
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_check.inc
@@ -0,0 +1,1198 @@
+################################################################################
+# include/partition_check.inc #
+# #
+# Purpose: #
+# Do some basic usability checks on table t1. #
+# This routine is only useful for the partition_<feature>_<engine> tests. #
+# #
+# Some Notes: #
+# It is intended that in many testcases (statements) more than one partition #
+# or subpartition is affected. #
+# Without analysis of the partitioning function used during CREATE TABLE #
+# we cannot be 100% sure that this goal is reached. #
+# But statements affecting many rows give a good probability that this #
+# appears. #
+# #
+# It is expected that the table to be checked contains at the beginning #
+# of this script records following the scheme #
+# f_int1 f_int2 f_char1 f_char2 f_charbig #
+# 1 1 '1' '1' '###1###' #
+# 2 2 '2' '1' '###2###' #
+# ... ... ... ... ... #
+# x x 'x' 'x' '###x###' #
+# x = @max_row #
+# #
+# The table content must be equal to the content of the table t0_template. #
+# Attention: Please be careful when modiying the data. #
+# Records can be deleted or inserted, but the content of the #
+# records after a test/testsequence should follow this scheme. #
+# #
+# All checks of preceeding statements via Select are so written, #
+# that they deliver a #
+# # check <n> success: 1 #
+# when everything is like expected. #
+# - f_charbig is typically used for showing if something was changed. #
+# This is useful for cleanups. #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+
+--echo # Start usability test (include/partition_check.inc)
+# Print the CREATE TABLE STATEMENT and store the current layout of the table
+--source suite/parts/inc/partition_layout_check1.inc
+# --source include/partition_layout_check1.inc
+
+
+#-------------------------------------------------------------------------------
+## 1. Check the prerequisites for the following tests
+# (sideeffect some SELECT functionality is also tested)
+# Determine if we have PRIMARY KEYs or UNIQUE INDEXes
+## 1.1 Check if the content of the records is like expected
+# Sideeffect: mass SELECT, all records/partitions/subpartitions have to be
+# read, because at least f_charbig is not part of any
+# INDEX/PRIMARY KEY
+if ($no_debug)
+{
+--disable_query_log
+}
+let $my_stmt= SELECT COUNT(*) <> 0 INTO @aux FROM t1
+WHERE f_int1 <> f_int2 OR f_char1 <> CAST(f_int1 AS CHAR) OR f_char1 <> f_char2
+ OR f_charbig <> CONCAT('===',f_char1,'===')
+ OR f_int1 IS NULL OR f_int2 IS NULL OR f_char1 IS NULL OR f_char2 IS NULL
+ OR f_charbig IS NULL;
+eval $my_stmt;
+let $run= `SELECT @aux`;
+--enable_query_log
+if ($run)
+{
+ --echo # Prerequisites for following tests not fullfilled.
+ --echo # The content of the table t1 is unexpected
+ eval $my_stmt;
+ SELECT @aux;
+ --echo # Sorry, have to abort.
+ exit;
+}
+# Give a success message like in the other following tests
+--echo # check prerequisites-1 success: 1
+#-------------------------------------------------------------------------------
+## 1.2 Check if the number of records and the maximum and minimum values are
+# like expected
+# Sideeffect: Check
+# - COUNT(*)
+# - MIN/MAX on all columns possibly used in part. function
+# The optimizer might decide to run on INDEX only, if available.
+#
+## 1.2.1 Check COUNT(*)
+if ($no_debug)
+{
+--disable_query_log
+}
+let $my_stmt= SELECT COUNT(*) <> @max_row INTO @aux FROM t1;
+let $run= `SELECT @aux`;
+--enable_query_log
+if ($run)
+{
+ --echo # Prerequisites for following tests not fullfilled.
+ --echo # The content of the table t1 is unexpected
+ eval $my_stmt;
+ SELECT @aux;
+ --echo # Sorry, have to abort.
+ exit;
+}
+# Give a success message like in the other following tests
+--echo # check COUNT(*) success: 1
+## 1.2.2 Check MAX(f_int1),MIN(f_int1)
+if ($no_debug)
+{
+--disable_query_log
+}
+let $my_stmt= SELECT MIN(f_int1) <> 1 AND MAX(f_int1) <> @max_row INTO @aux
+FROM t1;
+let $run= `SELECT @aux`;
+--enable_query_log
+if ($run)
+{
+ --echo # Prerequisites for following tests not fullfilled.
+ --echo # The content of the table t1 is unexpected
+ eval $my_stmt;
+ SELECT @aux;
+ --echo # Sorry, have to abort.
+ exit;
+}
+# Give a success message like in the other following tests
+--echo # check MIN/MAX(f_int1) success: 1
+## 1.2.3 Check MAX(f_int2),MIN(f_int2)
+if ($no_debug)
+{
+--disable_query_log
+}
+let $my_stmt= SELECT MIN(f_int2) <> 1 AND MAX(f_int2) <> @max_row INTO @aux
+FROM t1;
+let $run= `SELECT @aux`;
+--enable_query_log
+if ($run)
+{
+ --echo # Prerequisites for following tests not fullfilled.
+ --echo # The content of the table t1 is unexpected
+ eval $my_stmt;
+ SELECT @aux;
+ --echo # Sorry, have to abort.
+ exit;
+}
+# Give a success message like in the other following tests
+--echo # check MIN/MAX(f_int2) success: 1
+
+#-------------------------------------------------------------------------------
+## 1.3 Check, if f_int1 and/or f_char2 and/or (f_char1,f_char2) is UNIQUE
+# by testing if any DUPLICATE KEY might appear
+# Note: INFORMATION_SCHEMA SELECTs could be also used, but testing the
+# table via INSERT and SELECT is better because is stresses the
+# partitioning mechanism.
+# Sideeffect: Attempt to INSERT one record
+# DUPLICATE KEY will appear if we have UNIQUE columns
+# 1022: Can't write; duplicate key in table 't1' UIDX/PK(f_int1)
+# 1062: Duplicate entry '2' for key 1 UIDX/PK(f_int2)
+--disable_abort_on_error
+INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
+SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
+ CAST(f_int1 AS CHAR), 'delete me' FROM t0_template
+WHERE f_int1 IN (2,3);
+--enable_abort_on_error
+if ($no_debug)
+{
+--disable_query_log
+}
+eval SET @my_errno = $mysql_errno;
+let $run_delete= `SELECT @my_errno = 0`;
+let $any_unique= `SELECT @my_errno IN (1022,1062)`;
+let $unexpected_error= `SELECT @my_errno NOT IN (0,1022,1062)`;
+# DEBUG eval SELECT $run_delete AS run_delete, $any_unique AS any_unique,
+# $unexpected_error AS unexpected_error;
+if ($unexpected_error)
+{
+ --echo # The last command got an unexepected error response.
+ --echo # Expected/handled SQL codes are 0,1022,1062
+ SELECT '# SQL code we got was: ' AS "", @my_errno AS "";
+ --echo # Sorry, have to abort.
+ exit;
+ --echo
+}
+# Give a success message like in the other following tests
+--echo # check prerequisites-3 success: 1
+--enable_query_log
+# DEBUG eval SELECT $run_delete AS run_delete, $any_unique AS any_unique;
+if ($run_delete)
+{
+ # INSERT was successful -> DELETE this new record
+ DELETE FROM t1 WHERE f_charbig = 'delete me';
+ --echo # INFO: Neither f_int1 nor f_int2 nor (f_int1,f_int2) is UNIQUE
+}
+if ($any_unique)
+{
+ --echo # INFO: f_int1 AND/OR f_int2 AND/OR (f_int1,f_int2) is UNIQUE
+
+ ## 1.3.1 Check, if f_int1 is UNIQUE
+ # Sideeffect: Attempt to INSERT one record
+ # DUPLICATE KEY will appear if we have UNIQUE columns
+ # 1022: Can't write; duplicate key in table 't1' UIDX/PK
+ --disable_abort_on_error
+ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
+ SELECT f_int1, 2 * @max_row + f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
+ CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
+ WHERE f_int1 IN (2,3);
+ --enable_abort_on_error
+ if ($no_debug)
+ {
+ --disable_query_log
+ }
+ eval SET @my_errno = $mysql_errno;
+ let $run_delete= `SELECT @my_errno = 0`;
+ let $f_int1_is_unique= `SELECT @my_errno IN (1022,1062)`;
+ let $unexpected_error= `SELECT @my_errno NOT IN (0,1022,1062)`;
+ # DEBUG eval SELECT $run_delete AS run_delete, $f_int1_is_unique AS any_unique,
+ # $unexpected_error AS unexpected_error;
+ if ($unexpected_error)
+ {
+ --echo # The last command got an unexepected error response.
+ --echo # Expected/handled SQL codes are 0,1022,1062
+ SELECT '# SQL code we got was: ' AS "", @my_errno AS "";
+ --echo # Sorry, have to abort.
+ exit;
+ --echo
+ }
+ --enable_query_log
+ if ($f_int1_is_unique)
+ {
+ --echo # INFO: f_int1 is UNIQUE
+ }
+ if ($run_delete)
+ {
+ # INSERT was successful -> DELETE this new record
+ DELETE FROM t1 WHERE f_charbig = 'delete me';
+ }
+
+ ## 1.3.2 Check, if f_int2 is UNIQUE
+ --disable_abort_on_error
+ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
+ SELECT 2 * @max_row + f_int1, f_int1, CAST((2 * @max_row + f_int1) AS CHAR),
+ CAST((2 * @max_row + f_int1) AS CHAR), 'delete me' FROM t0_template
+ WHERE f_int1 IN (2,3);
+ --enable_abort_on_error
+ if ($no_debug)
+ {
+ --disable_query_log
+ }
+ eval SET @my_errno = $mysql_errno;
+ let $run_delete= `SELECT @my_errno = 0`;
+ let $f_int1_is_unique= `SELECT @my_errno IN (1022,1062)`;
+ let $unexpected_error= `SELECT @my_errno NOT IN (0,1022,1062)`;
+ # DEBUG eval SELECT $run_delete AS run_delete, $f_int1_is_unique AS any_unique,
+ # $unexpected_error AS unexpected_error;
+ if ($unexpected_error)
+ {
+ --echo # The last command got an unexepected error response.
+ --echo # Expected/handled SQL codes are 0,1022,1062
+ SELECT '# SQL code we got was: ' AS "", @my_errno AS "";
+ --echo # Sorry, have to abort.
+ exit;
+ --echo
+ }
+ if ($f_int2_is_unique)
+ {
+ --echo # INFO: f_int2 is UNIQUE
+ }
+ --enable_query_log
+ if ($run_delete)
+ {
+ # INSERT was successful -> DELETE this new record
+ DELETE FROM t1 WHERE f_charbig = 'delete me';
+ }
+}
+
+
+#-------------------------------------------------------------------------------
+## 2. Read the table row by row
+# Note: There were crashes in history when reading a partitioned table
+# PRIMARY KEY AND/OR UNIQUE INDEXes
+## 2.1 Read all existing and some not existing records of table
+# per f_int1 used in partitioning function
+let $col_to_check= f_int1;
+--source suite/parts/inc/partition_check_read.inc
+# --source include/partition_check_read.inc
+## 2.2 Read all existing and some not existing records of table
+# per f_int2 used in partitioning function
+let $col_to_check= f_int2;
+--source suite/parts/inc/partition_check_read.inc
+
+if ($fixed_bug18735)
+{
+
+#-------------------------------------------------------------------------------
+# 3 Some operations with multiple records
+# 3.1 Select on "full" table
+if ($no_debug)
+{
+--disable_query_log
+}
+SELECT '# check multiple-1 success: ' AS "",COUNT(*) = @max_row AS "" FROM t1;
+--enable_query_log
+#
+# 3.2 (mass) DELETE of @max_row_div3 records
+DELETE FROM t1 WHERE MOD(f_int1,3) = 0;
+if ($no_debug)
+{
+--disable_query_log
+}
+SELECT '# check multiple-2 success: ' AS "",COUNT(*) = @max_row - @max_row_div3 AS "" FROM t1;
+--enable_query_log
+#
+# 3.3 (mass) Insert of @max_row_div3 records
+# (Insert the records deleted in 3.2)
+INSERT INTO t1 SELECT * FROM t0_template
+WHERE MOD(f_int1,3) = 0;
+# Check of preceeding statement via Select
+if ($no_debug)
+{
+--disable_query_log
+}
+SELECT '# check multiple-3 success: ' AS "",
+(COUNT(*) = @max_row) AND (MIN(f_int1) = 1) AND (MAX(f_int1) = @max_row) AS ""
+FROM t1;
+--enable_query_log
+# DEBUG SELECT COUNT(*),MIN(f_int1),MAX(f_int1) FROM t1;
+#
+# 3.4 (mass) Update @max_row_div4 * 2 + 1 records
+# Bug#18735: Partitions: NDB, UNIQUE INDEX, UPDATE, strange server response
+UPDATE t1 SET f_int1 = f_int1 + @max_row
+WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4
+ AND @max_row_div2 + @max_row_div4;
+# Check of preceeding statement via Select
+if ($no_debug)
+{
+--disable_query_log
+}
+SELECT '# check multiple-4 success: ' AS "",(COUNT(*) = @max_row) AND (MIN(f_int1) = 1) AND
+(MAX(f_int1) = @max_row_div2 + @max_row_div4 + @max_row ) AS "" FROM t1;
+--enable_query_log
+# DEBUG SELECT COUNT(*),MIN(f_int1),MAX(f_int1) FROM t1;
+#
+# 3.5 (mass) Delete @max_row_div4 * 2 + 1 records
+# (Delete the records updated in 3.4)
+DELETE FROM t1
+WHERE f_int1 BETWEEN @max_row_div2 - @max_row_div4 + @max_row
+ AND @max_row_div2 + @max_row_div4 + @max_row;
+# Check of preceeding statement via Select
+if ($no_debug)
+{
+--disable_query_log
+}
+SELECT '# check multiple-5 success: ' AS "",
+(COUNT(*) = @max_row - @max_row_div4 - @max_row_div4 - 1)
+AND (MIN(f_int1) = 1) AND (MAX(f_int1) = @max_row) AS "" FROM t1;
+--enable_query_log
+# DEBUG SELECT COUNT(*),MIN(f_int1),MAX(f_int1) FROM t1;
+
+#-------------------------------------------------------------------------------
+# Attention: After this section all modification on the table have to be reverted !
+# Current content of t1 follows the rule:
+# <value>,<value>,'<value>','<value>',===<value>===
+# <value> contains all INTEGER values
+# between 1 and @max_row_div2 - @max_row_div4 - 1
+# and
+# between @max_row_div2 + @max_row_div4 + 1 and @max_row
+# With other words the values between @max_row_div2 - @max_row_div4
+# and @max_row_div2 + @max_row_div4 are "missing".
+#-------------------------------------------------------------------------------
+# The following is only needed for tests of UNIQUE CONSTRAINTs.
+if ($any_unique)
+{
+ # Calculate the number of records, where we will try INSERT ..... or REPLACE
+ SELECT COUNT(*) INTO @try_count FROM t0_template
+ WHERE MOD(f_int1,3) = 0
+ AND f_int1 BETWEEN @max_row_div2 AND @max_row;
+ #
+ # Calculate the number of records, where we will get DUPLICATE KEY
+ # f_int1 is sufficient for calculating this, because 1.1
+ # checks, that f_int1 = f_int2 is valid for all rows.
+ SELECT COUNT(*) INTO @clash_count
+ FROM t1 INNER JOIN t0_template USING(f_int1)
+ WHERE MOD(f_int1,3) = 0
+ AND f_int1 BETWEEN @max_row_div2 AND @max_row;
+ if ($debug)
+ {
+ SELECT @try_count, @clash_count;
+ }
+}
+
+
+#-------------------------------------------------------------------------------
+# 4 Some operations with single records
+# 4.1 Insert one record with a value for f_int1 which is lower than in all
+# existing records.
+SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1;
+INSERT INTO t1
+SET f_int1 = @cur_value , f_int2 = @cur_value,
+ f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
+ f_charbig = '#SINGLE#';
+# Check of preceeding statement via Select
+if ($no_debug)
+{
+--disable_query_log
+}
+SELECT '# check single-1 success: ' AS "",COUNT(*) = 1 AS "" FROM t1
+WHERE f_int1 = @cur_value AND f_int2 = @cur_value
+ AND f_char1 = CAST(@cur_value AS CHAR)
+ AND f_char2 = CAST(@cur_value AS CHAR) AND f_charbig = '#SINGLE#';
+--enable_query_log
+#
+# 4.2 Insert one record with a value for f_int1 which is higher than in all
+# existing records.
+SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1;
+INSERT INTO t1
+SET f_int1 = @cur_value , f_int2 = @cur_value,
+ f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR),
+ f_charbig = '#SINGLE#';
+# Check of preceeding statement via Select
+if ($no_debug)
+{
+--disable_query_log
+}
+SELECT '# check single-2 success: ' AS "",COUNT(*) = 1 AS "" FROM t1
+WHERE f_int1 = @cur_value AND f_int2 = @cur_value
+ AND f_char1 = CAST(@cur_value AS CHAR)
+ AND f_char2 = CAST(@cur_value AS CHAR) AND f_charbig = '#SINGLE#';
+--enable_query_log
+#
+# 4.3 Update one record. The value of f_int1 is altered from the lowest to
+# the highest value of all existing records.
+# If f_int1 is used for the partitioning expression a movement of the
+# record to another partition/subpartition might appear.
+SELECT MIN(f_int1) INTO @cur_value1 FROM t1;
+SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1;
+# Bug#18735: Partitions: NDB, UNIQUE INDEX, UPDATE, strange server response
+UPDATE t1 SET f_int1 = @cur_value2
+WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
+# Check of preceeding statement via Select
+if ($no_debug)
+{
+--disable_query_log
+}
+SELECT '# check single-3 success: ' AS "",COUNT(*) = 1 AS "" FROM t1
+WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
+--enable_query_log
+#
+# 4.4 Update one record. The value of f_int1 is altered from the highest value
+# to a value lower than in all existing records.
+# If f_int1 is used for the partitioning expression a movement of the
+# record to another partition/subpartition might appear.
+# f_int1 gets the delicate value '-1'.
+SET @cur_value1= -1;
+SELECT MAX(f_int1) INTO @cur_value2 FROM t1;
+# Bug#15968: Partitions: crash when INSERT with f_int1 = -1 into PARTITION BY HASH(f_int1)
+# Bug#16385: Partitions: crash when updating a range partitioned NDB table
+# Bug#18735: Partitions: NDB, UNIQUE INDEX, UPDATE, strange server response
+UPDATE t1 SET f_int1 = @cur_value1
+WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#';
+# Check of preceeding statement via Select
+if ($no_debug)
+{
+--disable_query_log
+}
+SELECT '# check single-4 success: ' AS "",COUNT(*) AS "" FROM t1
+WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#';
+--enable_query_log
+#
+# 4.5 Delete the record with the highest value of f_int1.
+SELECT MAX(f_int1) INTO @cur_value FROM t1;
+DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#';
+# Check of preceeding statements via Select
+if ($no_debug)
+{
+--disable_query_log
+}
+SELECT '# check single-5 success: ' AS "",COUNT(*) = 0 AS "" FROM t1
+WHERE f_charbig = '#SINGLE#' AND f_int1 = f_int1 = @cur_value;
+--enable_query_log
+#
+# 4.6 Delete the record with f_int1 = -1
+DELETE FROM t1 WHERE f_int1 = -1 AND f_charbig = '#SINGLE#';
+# Check of preceeding statements via Select
+if ($no_debug)
+{
+--disable_query_log
+}
+SELECT '# check single-6 success: ' AS "",COUNT(*) = 0 AS "" FROM t1
+WHERE f_charbig = '#SINGLE#' AND f_int1 IN (-1,@cur_value);
+--enable_query_log
+#
+# 4.7 Insert one record with such a big value for f_int1, so that in case
+# - f_int1 is used within the partitioning algorithm
+# - we use range partitioning
+# we get error ER_NO_PARTITION_FOR_GIVEN_VALUE (1514)
+# "Table has no partition for value ...."
+--disable_abort_on_error
+eval INSERT INTO t1 SET f_int1 = @max_int_4 , f_int2 = @max_int_4, f_charbig = '#$max_int_4##';
+--enable_abort_on_error
+if ($no_debug)
+{
+--disable_query_log
+}
+eval SET @my_errno = $mysql_errno;
+let $unexpected_error= `SELECT @my_errno NOT IN (0,1505,1514)`;
+if ($unexpected_error)
+{
+ --echo # The last command got an unexepected error response.
+ --echo # Expected/handled SQL codes are 0,1514
+ SELECT '# SQL code we got was: ' AS "", @my_errno AS "";
+ --echo # Sorry, have to abort.
+ exit;
+ --echo
+}
+# Check of preceeding statement via Select, if the INSERT was successful
+let $run= `SELECT @my_errno = 0`;
+if ($run)
+{
+# Attention: There are some tests where the column type is changed from
+# INTEGER to MEDIUMINT. MEDIUMINT has a smaller range and the
+# inserted value is automatically adjusted to the maximum value
+# of the data type.
+# that's the reason why we cannot use WHERE <column> = @max_int_4 here.
+#
+eval SELECT '# check single-7 success: ' AS "",
+COUNT(*) = 1 AS "" FROM t1 WHERE f_charbig = '#$max_int_4##';
+# Revert this modification
+--enable_query_log
+eval DELETE FROM t1 WHERE f_charbig = '#$max_int_4##';
+}
+--enable_query_log
+
+}
+# End workaround for Bug#18735
+
+#-------------------------------------------------------------------------------
+# 5 Experiments with NULL
+# If the result of the partitioning function IS NULL partitioning treats
+# this record as if the the result of the partitioning function is
+# MySQL 5.1 < March 2006 : zero
+# MySQL 5.1 >= March 2006 : LONGLONG_MIN
+# Let's INSERT a record where the result of the partitioning function is
+# probably (depends on function currently used) zero and look if there are
+# any strange effects during the execution of the next statements.
+# Bug#17891: Partitions: NDB, crash on select .. where col is null or col = value
+# Bug#18659: Partitions: wrong result on WHERE <col. used in part. function> IS NULL
+DELETE FROM t1 WHERE f_int1 IS NULL OR f_int1 = 0;
+# Attention: Zero should be tested
+INSERT t1 SET f_int1 = 0 , f_int2 = 0,
+ f_char1 = CAST(0 AS CHAR), f_char2 = CAST(0 AS CHAR),
+ f_charbig = '#NULL#';
+# 5.1 Insert one record with f_int1 IS NULL.
+# f1 "=" NULL is a delicate value which might stress the partitioning
+# mechanism if the result of the expression in the partitioning algorithm
+# becomes NULL.
+# Not: This INSERT will fail, if f_int1 is PRIMARY KEY or UNIQUE INDEX
+# 1048: Column 'f_int1' cannot be null
+--disable_abort_on_error
+
+INSERT INTO t1
+ SET f_int1 = NULL , f_int2 = -@max_row,
+ f_char1 = CAST(-@max_row AS CHAR), f_char2 = CAST(-@max_row AS CHAR),
+ f_charbig = '#NULL#';
+# Some other NULL experiments if preceeding INSERT was successfull
+--enable_abort_on_error
+if ($no_debug)
+{
+--disable_query_log
+}
+eval SET @my_errno = $mysql_errno;
+let $run= `SELECT @my_errno = 0`;
+let $unexpected_error= `SELECT @my_errno NOT IN (0,1048)`;
+if ($unexpected_error)
+{
+ --echo # The last command got an unexepected error response.
+ --echo # Expected/handled SQL codes are 0,1048
+ SELECT '# SQL code we got was: ' AS "", @my_errno AS "";
+ --echo # Sorry, have to abort.
+ exit;
+ --echo
+}
+--enable_query_log
+# Give a success message like in the other following tests
+--echo # check null success: 1
+# The following checks do not make sense if f_int1 cannot be NULL
+if ($run)
+{
+# Check of preceeding statement via Select
+if ($no_debug)
+{
+--disable_query_log
+}
+# Bug#17432: Partitions: wrong result, SELECT ... where <column> is null
+SELECT '# check null-1 success: ' AS "",COUNT(*) = 1 AS "" FROM t1
+WHERE f_int1 IS NULL AND f_charbig = '#NULL#';
+--enable_query_log
+#
+# 5.2 Update of f_int1 from NULL to negative value
+# Bug#17432: Partitions: wrong result, SELECT ... where <column> is null
+UPDATE t1 SET f_int1 = -@max_row
+WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
+ AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
+if ($no_debug)
+{
+--disable_query_log
+}
+# Check of preceeding statement via Select
+SELECT '# check null-2 success: ' AS "",COUNT(*) = 1 AS "" FROM t1
+WHERE f_int1 = -@max_row AND f_charbig = '#NULL#';
+--enable_query_log
+# 5.3 Update of f_int1 from negative value to NULL
+UPDATE t1 SET f_int1 = NULL
+WHERE f_int1 = -@max_row AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
+ AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
+if ($no_debug)
+{
+--disable_query_log
+}
+# Check of preceeding statement via Select
+SELECT '# check null-3 success: ' AS "",COUNT(*) = 1 AS "" FROM t1
+WHERE f_int1 IS NULL AND f_charbig = '#NULL#';
+--enable_query_log
+# 5.4 DELETE of the record with f_int1 IS NULL
+DELETE FROM t1
+WHERE f_int1 IS NULL AND f_int2 = -@max_row AND f_char1 = CAST(-@max_row AS CHAR)
+ AND f_char2 = CAST(-@max_row AS CHAR) AND f_charbig = '#NULL#';
+# Check of preceeding statement via Select
+if ($no_debug)
+{
+--disable_query_log
+}
+SELECT '# check null-4 success: ' AS "",COUNT(*) = 0 AS "" FROM t1
+WHERE f_int1 IS NULL;
+--enable_query_log
+}
+# Remove the "0" record
+DELETE FROM t1
+WHERE f_int1 = 0 AND f_int2 = 0
+ AND f_char1 = CAST(0 AS CHAR) AND f_char2 = CAST(0 AS CHAR)
+ AND f_charbig = '#NULL#';
+
+
+#-------------------------------------------------------------------------------
+## 6. UPDATEs of columns used in the partitioning function and the PRIMARY KEY
+# the UNIQUE INDEX without using straight forward UPDATE.
+# INSERT .... ON DUPLICATE KEY UPDATE .... --> update existing record
+# REPLACE --> delete existing record + insert new record
+# Note:
+# - This test is skipped for tables without any PRIMARY KEY or
+# UNIQUE INDEX.
+# - MOD(<column>,n) with n = prime number, n <> 2 is used to cause
+# that many records and most probably more than one PARTITION/
+# SUBPARTITION are affected.
+# - Under certain circumstanditions a movement of one or more records
+# to other PARTITIONs/SUBPARTITIONs might appear.
+# - There are some storage engines, which are unable to revert changes
+# of a failing statement. This has to be taken into account when
+# checking if a DUPLICATE KEY might occur.
+#
+# What to test ?
+# UNIQUE columns
+# f_int1 IU f_int1 IU f_int1,f_int2 R
+# f_int2 IU f_int2 IU f_int1,f_int2 R
+# f_int1,f_int2 IU f_int1,f_int2 R
+#
+# IU column = INSERT .. ON DUPLICATE KEY UPDATE column
+# R = REPLACE ..
+#
+# Current state of the data
+# 1. f_int1 = f_int2, f_char1 = CAST(f_int1 AS CHAR), f_char2 = f_char1,
+# f_charbig = CONCAT('===',f_char1,'===);
+# 2. f_int1 FROM 1 TO @max_row_div4
+# AND @max_row_div2 + @max_row_div4 TO @max_row
+#
+# Do not apply the following tests to tables without UNIQUE columns.
+if ($any_unique)
+{
+ let $num= 1;
+ if ($f_int1_is_unique)
+ {
+ ## 6.1 f_int1 is UNIQUE, UPDATE f_int1 when DUPLICATE KEY
+ # Bug#15236 Partitions: crash, if Insert .. on duplicate key causes update of existing row
+ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
+ SELECT f_int1, f_int1, '', '', 'was inserted'
+ FROM t0_template source_tab
+ WHERE MOD(f_int1,3) = 0
+ AND f_int1 BETWEEN @max_row_div2 AND @max_row
+ ON DUPLICATE KEY
+ UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
+ f_charbig = 'was updated';
+ --source suite/parts/inc/partition_20.inc
+ # --source include/partition_20.inc
+ }
+
+ if ($f_int2_is_unique)
+ {
+ ## 6.2 f_int2 is UNIQUE, UPDATE f_int2 when DUPLICATE KEY
+ # Bug#15236 Partitions: crash, if Insert .. on duplicate key causes update of existing row
+ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
+ SELECT f_int1, f_int1, '', '', 'was inserted'
+ FROM t0_template source_tab
+ WHERE MOD(f_int1,3) = 0
+ AND f_int1 BETWEEN @max_row_div2 AND @max_row
+ ON DUPLICATE KEY
+ UPDATE f_int2 = 2 * @max_row + source_tab.f_int1,
+ f_charbig = 'was updated';
+ --source suite/parts/inc/partition_20.inc
+ # --source include/partition_20.inc
+ }
+
+ ## 6.3 f_int1, f_int2 is UNIQUE, UPDATE f_int1, f_int2 when DUPLICATE KEY
+ INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
+ SELECT f_int1, f_int1, '', '', 'was inserted'
+ FROM t0_template source_tab
+ WHERE MOD(f_int1,3) = 0
+ AND f_int1 BETWEEN @max_row_div2 AND @max_row
+ ON DUPLICATE KEY
+ UPDATE f_int1 = 2 * @max_row + source_tab.f_int1,
+ f_int2 = 2 * @max_row + source_tab.f_int1,
+ f_charbig = 'was updated';
+ --source suite/parts/inc/partition_20.inc
+ # --source include/partition_20.inc
+
+ ## 6.4 REPLACE
+ # Bug#16782: Partitions: crash, REPLACE .. on table with PK, DUPLICATE KEY
+ REPLACE INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
+ SELECT f_int1, - f_int1, '', '', 'was inserted or replaced'
+ FROM t0_template source_tab
+ WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row;
+ # DEBUG SELECT * FROM t1 ORDER BY f_int1, f_int2;
+ # Check of preceeding statement via Select
+ if ($no_debug)
+ {
+ --disable_query_log
+ }
+ SELECT '# check replace success: ' AS "", COUNT(*) = @try_count AS ""
+ FROM t1 WHERE f_charbig = 'was inserted or replaced';
+ --enable_query_log
+ # Revert the modification
+ DELETE FROM t1
+ WHERE f_int1 BETWEEN @max_row_div2 AND @max_row_div2 + @max_row_div4;
+ # If there is only UNIQUE (f1,f2) we will have pairs f_int1,f_int2
+ # <n>, <n> and <n>, <-n>
+ # where MOD(f_int1,3) = 0
+ # and f_int1 between @max_row_div2 + @max_row_div4 and @max_row.
+ # Delete the <n>, <n> records.
+ DELETE FROM t1
+ WHERE f_int1 = f_int2 AND MOD(f_int1,3) = 0 AND
+ f_int1 BETWEEN @max_row_div2 + @max_row_div4 AND @max_row;
+ UPDATE t1 SET f_int2 = f_int1,
+ f_char1 = CAST(f_int1 AS CHAR),
+ f_char2 = CAST(f_int1 AS CHAR),
+ f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===')
+ WHERE f_charbig = 'was inserted or replaced' AND f_int1 = - f_int2;
+ # DEBUG SELECT * FROM t1 ORDER BY f_int1, f_int2;
+}
+
+if ($fixed_bug18735)
+{
+ # The following tests work cannot like intended, if we had to omit
+ # tests because of Bug#18735
+
+#-------------------------------------------------------------------------------
+# 7 Transactions
+SET AUTOCOMMIT= 0;
+# DEBUG SELECT @max_row_div4 , @max_row_div2 + @max_row_div4;
+if ($no_debug)
+{
+ --disable_query_log
+}
+SELECT COUNT(f_int1) INTO @start_count FROM t1
+WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
+--enable_query_log
+let $run= `SELECT @start_count <> 0`;
+if ($run)
+{
+ --echo # Prerequisites for following tests not fullfilled.
+ --echo # The content of the table t1 is unexpected
+ --echo # There must be no rows BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
+ SELECT COUNT(f_int1) FROM t1
+ WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
+ --echo # Sorry, have to abort.
+ exit;
+}
+# Number of records to be inserted
+if ($no_debug)
+{
+ --disable_query_log
+}
+SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
+--enable_query_log
+# 7.1 Successful INSERT + COMMIT
+INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
+SELECT f_int1, f_int1, '', '', 'was inserted'
+FROM t0_template source_tab
+WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
+# The inserted records must be visible (at least for our current session)
+if ($no_debug)
+{
+ --disable_query_log
+}
+SELECT '# check transactions-1 success: ' AS "",
+ COUNT(*) = @exp_inserted_rows AS ""
+FROM t1 WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
+--enable_query_log
+# Make the changes persistent for all storage engines
+COMMIT WORK;
+# The inserted records must be visible (for all open and future sessions)
+if ($no_debug)
+{
+ --disable_query_log
+}
+SELECT '# check transactions-2 success: ' AS "",
+ COUNT(*) = @exp_inserted_rows AS ""
+FROM t1 WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
+--enable_query_log
+# Let's assume we have a transactional engine + COMMIT is ill.
+# A correct working ROLLBACK might revert the INSERT.
+ROLLBACK WORK;
+if ($no_debug)
+{
+ --disable_query_log
+}
+SELECT '# check transactions-3 success: ' AS "",
+ COUNT(*) = @exp_inserted_rows AS ""
+FROM t1 WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
+--enable_query_log
+# Revert the changes
+DELETE FROM t1 WHERE f_charbig = 'was inserted';
+COMMIT WORK;
+ROLLBACK WORK;
+if ($no_debug)
+{
+ --disable_query_log
+}
+SELECT '# check transactions-4 success: ' AS "",
+ COUNT(*) = 0 AS ""
+FROM t1 WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
+--enable_query_log
+#
+# 7.2 Successful INSERT + ROLLBACK
+INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
+SELECT f_int1, f_int1, '', '', 'was inserted'
+FROM t0_template source_tab
+WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
+if ($no_debug)
+{
+ --disable_query_log
+}
+SELECT '# check transactions-5 success: ' AS "",
+ COUNT(*) = @exp_inserted_rows AS ""
+FROM t1 WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
+--enable_query_log
+ROLLBACK WORK;
+if ($no_debug)
+{
+ --disable_query_log
+}
+SELECT COUNT(*) INTO @my_count
+FROM t1 WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
+SELECT '# check transactions-6 success: ' AS "",
+ @my_count IN (0,@exp_inserted_rows) AS "";
+let $run= `SELECT @my_count = 0`;
+if ($run)
+{
+ --echo # INFO: Storage engine used for t1 seems to be transactional.
+}
+let $run= `SELECT @my_count = @exp_inserted_rows`;
+if ($run)
+{
+ --echo # INFO: Storage engine used for t1 seems to be not transactional.
+}
+--enable_query_log
+# Let's assume we have a transactional engine + ROLLBACK is ill.
+# A correct working COMMIT might make the inserted records again visible.
+COMMIT;
+if ($no_debug)
+{
+ --disable_query_log
+}
+SELECT '# check transactions-7 success: ' AS "",
+ COUNT(*) IN (0,@exp_inserted_rows) AS ""
+FROM t1 WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
+--enable_query_log
+# Revert the changes
+DELETE FROM t1 WHERE f_charbig = 'was inserted';
+COMMIT WORK;
+#
+# 7.3 Failing INSERT (in mid of statement processing) + COMMIT
+SET @@session.sql_mode = 'traditional';
+# Number of records where a INSERT has to be tried
+SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows;
+#
+--disable_abort_on_error
+INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
+SELECT IF(f_int1 = @max_row_div2,f_int1 / 0,f_int1),f_int1,
+ '', '', 'was inserted' FROM t0_template
+WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
+--enable_abort_on_error
+COMMIT;
+# How many new records should be now visible ?
+# 1. storage engine unable to revert changes made by the failing statement
+# @max_row_div2 - 1 - @max_row_div4 + 1
+# 2. storage engine able to revert changes made by the failing statement
+# 0
+if ($no_debug)
+{
+ --disable_query_log
+}
+SELECT COUNT(*) INTO @my_count
+FROM t1 WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4;
+SELECT '# check transactions-8 success: ' AS "",
+ @my_count IN (@max_row_div2 - 1 - @max_row_div4 + 1,0) AS "";
+let $run= `SELECT @my_count = @max_row_div2 - 1 - @max_row_div4 + 1`;
+if ($run)
+{
+ --echo # INFO: Storage engine used for t1 seems to be unable to revert
+ --echo # changes made by the failing statement.
+}
+let $run= `SELECT @my_count = 0`;
+if ($run)
+{
+ --echo # INFO: Storage engine used for t1 seems to be able to revert
+ --echo # changes made by the failing statement.
+}
+--enable_query_log
+SET @@session.sql_mode = '';
+SET AUTOCOMMIT= 1;
+# Revert the changes
+DELETE FROM t1 WHERE f_charbig = 'was inserted';
+COMMIT WORK;
+
+if ($debug)
+{
+ SELECT * FROM t1 ORDER BY f_int1;
+}
+
+}
+# End workaround for Bug#18735
+
+#-------------------------------------------------------------------------------
+# 8 Some special cases
+# 8.1 Dramatic increase of the record/partition/subpartition/table sizes
+UPDATE t1 SET f_charbig = REPEAT('b', 1000);
+# partial check of preceeding statement via Select
+if ($no_debug)
+{
+--disable_query_log
+}
+eval SELECT '# check special-1 success: ' AS "",1 AS "" FROM t1
+WHERE f_int1 = 1 AND f_charbig = REPEAT('b', 1000);
+--enable_query_log
+#
+# 8.2 Dramatic decrease of the record/partition/subpartition/table sizes
+UPDATE t1 SET f_charbig = '';
+# partial check of preceeding statement via Select
+if ($no_debug)
+{
+--disable_query_log
+}
+eval SELECT '# check special-2 success: ' AS "",1 AS "" FROM t1
+WHERE f_int1 = 1 AND f_charbig = '';
+--enable_query_log
+# Revert the changes
+UPDATE t1 SET f_charbig = CONCAT('===',CAST(f_int1 AS CHAR),'===');
+
+if ($debug)
+{
+ SELECT * FROM t1 ORDER BY f_int1;
+}
+
+if ($fixed_bug18735)
+{
+#-------------------------------------------------------------------------------
+# 9 TRIGGERs
+let $num= 1;
+# 9.1 BEFORE/AFTER INSERT/UPDATE/DELETE TRIGGER on table t0_aux causes that
+# column values used in partitioning function of t1 are changed.
+let $tab_has_trigg= t0_aux;
+let $tab_in_trigg= t1;
+
+# Insert three records, which will be updated by the trigger
+# Bug#18735: Partitions: NDB, UNIQUE INDEX, UPDATE, strange server response
+eval INSERT INTO $tab_in_trigg(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
+WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
+
+let $statement= INSERT INTO t0_aux(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
+WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
+let $event= BEFORE INSERT;
+--source suite/parts/inc/partition_trigg1.inc
+# --source include/partition_trigg1.inc
+let $event= AFTER INSERT;
+--source suite/parts/inc/partition_trigg1.inc
+# --source include/partition_trigg1.inc
+
+let $statement= UPDATE t0_aux SET f_int1 = - f_int1, f_int2 = - f_int2
+WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
+let $event= BEFORE UPDATE;
+--source suite/parts/inc/partition_trigg1.inc
+# --source include/partition_trigg1.inc
+let $event= AFTER UPDATE;
+--source suite/parts/inc/partition_trigg1.inc
+# --source include/partition_trigg1.inc
+
+let $statement= DELETE FROM t0_aux
+WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
+let $event= BEFORE DELETE;
+--source suite/parts/inc/partition_trigg1.inc
+# --source include/partition_trigg1.inc
+let $event= AFTER DELETE;
+--source suite/parts/inc/partition_trigg1.inc
+# --source include/partition_trigg1.inc
+
+# Cleanup
+eval DELETE FROM $tab_in_trigg
+WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
+
+# Two currently (February 2006) impossible operations.
+# 1442: 'Can't update table 't1' in stored function/trigger because it is
+# already used by statement which invoked this stored function/trigger.'
+# 1362: 'Updating of OLD row is not allowed in trigger'
+
+if ($debug)
+{
+ SELECT * FROM t1 ORDER BY f_int1;
+}
+
+if ($more_trigger_tests)
+{
+# 9.2 BEFORE/AFTER INSERT/UPDATE/DELETE TRIGGER on partitioned table t1 causes
+# that column values in not partitioned table t0_aux are changed.
+let $tab_has_trigg= t1;
+let $tab_in_trigg= t0_aux;
+
+# Insert three records, which will be updated by the trigger
+eval INSERT INTO $tab_in_trigg(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,'just inserted' FROM t0_template
+WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
+
+let $statement= INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,NULL FROM t0_template
+WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
+let $event= BEFORE INSERT;
+--source suite/parts/inc/partition_trigg1.inc
+# --source include/partition_trigg1.inc
+let $event= AFTER INSERT;
+--source suite/parts/inc/partition_trigg1.inc
+# --source include/partition_trigg1.inc
+
+let $statement= UPDATE t1 SET f_int1 = - f_int1, f_int2 = - f_int2
+WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
+let $event= BEFORE UPDATE;
+--source suite/parts/inc/partition_trigg1.inc
+# --source include/partition_trigg1.inc
+let $event= AFTER UPDATE;
+--source suite/parts/inc/partition_trigg1.inc
+# --source include/partition_trigg1.inc
+
+let $statement= DELETE FROM t1
+WHERE f_int1 IN (- (@max_row_div2 - 1),- @max_row_div2,- (@max_row_div2 + 1));
+let $event= BEFORE DELETE;
+--source suite/parts/inc/partition_trigg1.inc
+# --source include/partition_trigg1.inc
+let $event= AFTER DELETE;
+--source suite/parts/inc/partition_trigg1.inc
+# --source include/partition_trigg1.inc
+eval DELETE FROM $tab_in_trigg
+WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
+}
+
+if ($debug)
+{
+ SELECT * FROM t1 ORDER BY f_int1;
+}
+
+# 9.3 BEFORE/AFTER UPDATE TRIGGER on partitioned table causes that the value
+# of columns in partitioning function is recalculated
+if ($more_trigger_tests)
+{
+# 9.3.1 The UPDATE itself changes a column which is not used in the partitioning
+# function.
+# "old" values are used as source within the trigger.
+let $statement= UPDATE t1
+SET f_charbig = '####updated per update statement itself####';
+let $source= old;
+let $event= BEFORE UPDATE;
+--source suite/parts/inc/partition_trigg2.inc
+# --source include/partition_trigg2.inc
+# FIXME when AFTER TRIGGER can be used
+# Currently (2006-02-23) a AFTER TRIGGER is not allowed to modify a row, which
+# was just modified: 1362: Updating of NEW row is not allowed in after trigger
+}
+
+# 9.3.2 The UPDATE itself changes a column which is used in the partitioning
+# function.
+let $statement= UPDATE t1
+SET f_int1 = f_int1 + @max_row, f_int2 = f_int2 - @max_row,
+f_charbig = '####updated per update statement itself####';
+
+# 9.3.2.1 "old" values are used as source within the trigger.
+let $source= old;
+let $event= BEFORE UPDATE;
+--source suite/parts/inc/partition_trigg2.inc
+# --source include/partition_trigg2.inc
+# FIXME when AFTER TRIGGER can be used
+# Currently (2006-02-23) a AFTER TRIGGER is not allowed to modify a row, which
+# was just modified: 1362: Updating of NEW row is not allowed in after trigger
+# 9.3.2.2 "new" values are used as source within the trigger.
+let $source= new;
+let $event= BEFORE UPDATE;
+--source suite/parts/inc/partition_trigg2.inc
+# --source include/partition_trigg2.inc
+# FIXME when AFTER TRIGGER can be used
+
+if ($debug)
+{
+ SELECT * FROM t1 ORDER BY f_int1;
+}
+
+# 9.4 BEFORE/AFTER INSERT TRIGGER on partitioned table causes that the value of
+# columns in partitioning function is recalculated.
+# 9.4.1 INSERT assigns values to the recalculate columns
+let $statement= INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig)
+SELECT f_int1, f_int1, CAST(f_int1 AS CHAR),
+ CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
+WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
+ORDER BY f_int1;
+let $event= BEFORE INSERT;
+let $source= new;
+--source suite/parts/inc/partition_trigg3.inc
+# --source include/partition_trigg3.inc
+# FIXME when AFTER TRIGGER can be used
+
+# 9.4.2 INSERT assigns no values to the recalculate columns
+let $statement= INSERT INTO t1 (f_char1, f_char2, f_charbig)
+SELECT CAST(f_int1 AS CHAR),
+ CAST(f_int1 AS CHAR), 'just inserted' FROM t0_template
+WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1
+ORDER BY f_int1;
+let $event= BEFORE INSERT;
+let $source= new;
+--source suite/parts/inc/partition_trigg3.inc
+# --source include/partition_trigg3.inc
+# FIXME when AFTER TRIGGER can be used
+
+if ($debug)
+{
+ SELECT * FROM t1 ORDER BY f_int1;
+}
+
+}
+# End workaround for Bug#18735
+
+#-------------------------------------------------------------------------------
+# 10 ANALYZE/CHECK/CHECKSUM
+ANALYZE TABLE t1;
+CHECK TABLE t1 EXTENDED;
+# Checksum depends on @max_row so we have to unify the value
+--replace_column 2 <some_value>
+CHECKSUM TABLE t1 EXTENDED;
+
+
+#-------------------------------------------------------------------------------
+# 11 Some special statements, which may lead to a rebuild of the trees
+# depending on the storage engine and some particular conditions
+# 11.1 OPTIMIZE TABLE
+# Manual about OPTIMIZE <InnoDB table>:
+# ... , it is mapped to ALTER TABLE, which rebuilds the table.
+# Rebuilding updates index statistics and frees unused space in the
+# clustered index.
+# FIXME What will happen with NDB ?
+OPTIMIZE TABLE t1;
+--source suite/parts/inc/partition_layout_check2.inc
+# --source include/partition_layout_check2.inc
+# 10.2 REPAIR TABLE
+REPAIR TABLE t1 EXTENDED;
+--source suite/parts/inc/partition_layout_check2.inc
+# --source include/partition_layout_check2.inc
+#
+# 11.3 Truncate
+# Manual about TRUNCATE on tables ( != InnoDB table with FOREIGN KEY ):
+# Truncate operations drop and re-create the table ....
+TRUNCATE t1;
+# Check of preceeding statement via Select
+if ($no_debug)
+{
+--disable_query_log
+}
+SELECT '# check TRUNCATE success: ' AS "",COUNT(*) = 0 AS "" FROM t1;
+--enable_query_log
+--source suite/parts/inc/partition_layout_check2.inc
+# --source include/partition_layout_check2.inc
+--echo # End usability test (include/partition_check.inc)
+
diff --git a/mysql-test/suite/parts/inc/partition_check_drop.inc b/mysql-test/suite/parts/inc/partition_check_drop.inc
new file mode 100644
index 00000000000..825ebecba24
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_check_drop.inc
@@ -0,0 +1,72 @@
+################################################################################
+# include/partition_check_drop.inc #
+# #
+# Purpose: #
+# Check that a drop table removes all files belonging to this table. #
+# Remaining unused files can be caused by imperfect DROP TABLE or #
+# ALTER TABLE <alter partitioning>. #
+# #
+# This routine is only useful for the partition_<feature>_<engine> tests. #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-05-12 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+if ($no_debug)
+{
+ --disable_query_log
+}
+
+if ($do_file_tests)
+{
+# List the files belonging to the table t1
+--exec ls $MYSQLTEST_VARDIR/master-data/test/t1* > $MYSQLTEST_VARDIR/master-data/test/tmp2 || true
+if ($with_directories)
+{
+--exec ls $MYSQLTEST_VARDIR/master-data/test/data/t1* >> $MYSQLTEST_VARDIR/master-data/test/tmp2 || true
+--exec ls $MYSQLTEST_VARDIR/master-data/test/index/t1* >> $MYSQLTEST_VARDIR/master-data/test/tmp2 || true
+}
+eval SET @aux = CONCAT('load_file(''$MYSQLTEST_VARDIR','/master-data/test/tmp2'')');
+let $file_list= `SELECT @aux`;
+}
+if (!$do_file_tests)
+{
+let $file_list= '--- not determined ---';
+}
+
+# UPDATE the current filelist of the table t1 within t0_definition
+# Note: This list should be empty, because the table t1 was dropped !
+eval INSERT INTO t0_definition SET state = 'old', file_list = $file_list
+ON DUPLICATE KEY UPDATE file_list = $file_list;
+# eval UPDATE t0_definition SET file_list = $file_list WHERE state = 'old';
+
+# Check if filelist is empty.
+let $found_garbage= `SELECT file_list <> '' FROM t0_definition WHERE state = 'old'`;
+if ($found_garbage)
+{
+ # Unfortunately the DROP TABLE did not remove the unused files
+ if ($ls)
+ {
+ --echo # Attention: There are unused files.
+ --echo # Either the DROP TABLE or a preceeding ALTER TABLE
+ --echo # <alter partitioning> worked incomplete.
+ --echo # We found:
+ # Print the list of files into the protocol
+ eval SELECT REPLACE(file_list,'$MYSQLTEST_VARDIR','\$MYSQLTEST_VARDIR')
+ AS "unified filelist"
+ FROM t0_definition WHERE state = 'old';
+ }
+ # Do a manual cleanup, because the following tests should not suffer from
+ # remaining files
+ --exec rm -f $MYSQLTEST_VARDIR/master-data/test/t1* || true
+ if ($with_directories)
+ {
+ --exec rm -f $MYSQLTEST_VARDIR/master-data/test/data/t1* || true
+ --exec rm -f $MYSQLTEST_VARDIR/master-data/test/index/t1* || true
+ }
+}
+--enable_query_log
diff --git a/mysql-test/suite/parts/inc/partition_check_read.inc b/mysql-test/suite/parts/inc/partition_check_read.inc
new file mode 100644
index 00000000000..14bbd46ac7f
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_check_read.inc
@@ -0,0 +1,89 @@
+################################################################################
+# include/partition_check_read.inc #
+# #
+# Purpose: #
+# Read table t1 row by row #
+# This routine is only useful for the partition_<feature>_<engine> tests. #
+# #
+# Note: If this routine is successful, at least the following is fullfilled #
+# - select single row via $col_to_check basically works -- no crash #
+# - the table contains all expected rows #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+let $success= 1;
+
+## Read all existing records
+let $num= `SELECT @max_row`;
+while ($num)
+{
+ if ($no_debug)
+ {
+ --disable_query_log
+ }
+ eval SELECT COUNT(*) <> 1 INTO @aux FROM t1 WHERE $col_to_check = $num;
+ --enable_query_log
+ let $run= `SELECT @aux`;
+ if ($run)
+ {
+ --echo # Unexpected result on SELECT
+ eval SELECT COUNT(*) <> 1 FROM t1 WHERE $col_to_check = $num;
+ let $success= 0;
+ }
+ dec $num;
+}
+## Read some not existing records
+let $num= `SELECT @max_row_div2`;
+while ($num)
+{
+ if ($no_debug)
+ {
+ --disable_query_log
+ }
+ eval SELECT COUNT(*) = 1 INTO @aux FROM t1 WHERE $col_to_check = @max_row + $num;
+ --enable_query_log
+ let $run= `SELECT @aux`;
+ if ($run)
+ {
+ --echo # Unexpected result on SELECT
+ eval SELECT COUNT(*) <> 1 FROM t1 WHERE $col_to_check = @max_row + $num;
+ let $success= 0;
+ }
+ dec $num;
+}
+let $num= `SELECT @max_row_div2`;
+while ($num)
+{
+ if ($no_debug)
+ {
+ --disable_query_log
+ }
+ eval SELECT COUNT(*) = 1 INTO @aux FROM t1 WHERE $col_to_check = 1 - $num;
+ --enable_query_log
+ let $run= `SELECT @aux`;
+ if ($run)
+ {
+ --echo # Unexpected result on SELECT
+ eval SELECT COUNT(*) <> 1 FROM t1 WHERE $col_to_check = 1 - $num;
+ let $success= 0;
+ }
+ dec $num;
+}
+if ($no_debug)
+{
+--disable_query_log
+}
+--echo # check read via $col_to_check success: $success
+# ML: The following is omitted because of not reported mysqltest bug
+# (@max_row time the success message)
+if (0)
+{
+eval SELECT '# check read via $col_to_check success: ' AS "", $success AS "" FROM t1;
+}
+--enable_query_log
diff --git a/mysql-test/suite/parts/inc/partition_check_read1.inc b/mysql-test/suite/parts/inc/partition_check_read1.inc
new file mode 100644
index 00000000000..dad5c347052
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_check_read1.inc
@@ -0,0 +1,79 @@
+################################################################################
+# include/partition_check_read1.inc #
+# #
+# Purpose: #
+# Read rows from table t1 in different ways #
+# This routine is only useful for the partition_<feature>_<engine> tests. #
+# #
+# The parameter #
+# @exp_row_count -- expected number of rows within t1 #
+# must be set before sourcing this routine. #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-04-11 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+## EXPLAIN PARTITIONS SELECT for one single row
+EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
+
+## Check SELECT for one single row
+let $success= 1;
+if ($no_debug)
+{
+--disable_query_log
+}
+SELECT COUNT(*) <> 1 INTO @aux FROM t1 WHERE f_date = '1000-02-10';
+--enable_query_log
+let $run= `SELECT @aux`;
+if ($run)
+{
+ --echo # Unexpected result on SELECT
+ eval SELECT COUNT(*) <> 1 FROM t1 WHERE f_date = '1000-02-10';
+ let $success= 0;
+}
+--echo # check read single success: $success
+
+## Read all existing records in one step
+let $success= 1;
+if ($no_debug)
+{
+--disable_query_log
+}
+eval SELECT COUNT(*) <> @exp_row_count INTO @aux FROM t1;
+--enable_query_log
+let $run= `SELECT @aux`;
+if ($run)
+{
+ --echo # Unexpected result on SELECT
+ eval SELECT COUNT(*) <> @exp_row_count FROM t1;
+ let $success= 0;
+}
+--echo # check read all success: $success
+
+## Read all existing records row by row
+let $success= 1;
+let $num= `SELECT @exp_row_count`;
+while ($num)
+{
+ if ($no_debug)
+ {
+ --disable_query_log
+ }
+ eval SELECT COUNT(*) <> 1 INTO @aux FROM t1
+ WHERE f_date = CONCAT(CAST(999 + $num AS CHAR),'-02-10');
+ --enable_query_log
+ let $run= `SELECT @aux`;
+ if ($run)
+ {
+ --echo # Unexpected result on SELECT
+ eval SELECT COUNT(*) <> 1 FROM t1
+ WHERE f_date = CONCAT(CAST(999 + $num AS CHAR),'-02-10');
+ let $success= 0;
+ }
+ dec $num;
+}
+--echo # check read row by row success: $success
diff --git a/mysql-test/suite/parts/inc/partition_check_read2.inc b/mysql-test/suite/parts/inc/partition_check_read2.inc
new file mode 100644
index 00000000000..4c32456a31e
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_check_read2.inc
@@ -0,0 +1,75 @@
+################################################################################
+# include/partition_check_read2.inc #
+# #
+# Purpose: #
+# Read rows from table t1 in different ways #
+# This routine is only useful for the partition_<feature>_<engine> tests. #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-04-11 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+## EXPLAIN PARTITIONS SELECT for one single row
+EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
+
+## Check SELECT for one single row
+let $success= 1;
+if ($no_debug)
+{
+--disable_query_log
+}
+SELECT COUNT(*) <> 1 INTO @aux FROM t1 WHERE f_int1 = 3;
+--enable_query_log
+let $run= `SELECT @aux`;
+if ($run)
+{
+ --echo # Unexpected result on SELECT
+ eval SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
+ let $success= 0;
+}
+--echo # check read single success: $success
+
+## Read all existing records in one step
+let $success= 1;
+if ($no_debug)
+{
+--disable_query_log
+}
+eval SELECT COUNT(*) <> @max_row INTO @aux FROM t1;
+--enable_query_log
+let $run= `SELECT @aux`;
+if ($run)
+{
+ --echo # Unexpected result on SELECT
+ eval SELECT COUNT(*) <> @max_row FROM t1;
+ let $success= 0;
+}
+--echo # check read all success: $success
+
+## Read all existing records row by row
+let $success= 1;
+let $num= `SELECT @max_row`;
+while ($num)
+{
+ if ($no_debug)
+ {
+ --disable_query_log
+ }
+ eval SELECT COUNT(*) <> 1 INTO @aux FROM t1
+ WHERE f_int1 = 3;
+ --enable_query_log
+ let $run= `SELECT @aux`;
+ if ($run)
+ {
+ --echo # Unexpected result on SELECT
+ eval SELECT COUNT(*) <> 1 FROM t1
+ WHERE f_int1 = 3;
+ let $success= 0;
+ }
+ dec $num;
+}
+--echo # check read row by row success: $success
diff --git a/mysql-test/suite/parts/inc/partition_cleanup.inc b/mysql-test/suite/parts/inc/partition_cleanup.inc
new file mode 100644
index 00000000000..dcd6005287e
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_cleanup.inc
@@ -0,0 +1,22 @@
+################################################################################
+# include/partition_cleanup.inc #
+# #
+# Purpose: #
+# Removal of the objects created by the t/partition_<feature>_<engine>.test #
+# scripts. #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+--disable_warnings
+DROP VIEW IF EXISTS v1;
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t0_aux;
+DROP TABLE IF EXISTS t0_definition;
+DROP TABLE IF EXISTS t0_template;
+--enable_warnings
diff --git a/mysql-test/suite/parts/inc/partition_date.inc b/mysql-test/suite/parts/inc/partition_date.inc
new file mode 100644
index 00000000000..b58a7598236
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_date.inc
@@ -0,0 +1,89 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a date not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values ('1975-01-01'), ('2020-12-31'), ('1980-10-14'), ('2000-06-15');
+select * from t1;
+select * from t1 where a=19801014;
+delete from t1 where a=19801014;
+select * from t1;
+drop table t1;
+
+eval create table t2 (a date not null, primary key(a)) engine=$engine
+partition by key (a) partitions 12;
+show create table t2;
+insert into t2 values ('1975-01-01'), ('2020-12-31'), ('1980-10-14'), ('2000-06-15');
+select * from t2;
+select * from t2 where a='1980-10-14';
+delete from t2 where a='1980-10-14';
+select * from t2;
+delete from t2;
+let $count=28;
+--echo $count inserts;
+#--disable_query_log
+while ($count)
+{
+eval insert into t2 values (19700101+$count-1);
+eval insert into t2 values (19700201+$count-1);
+eval insert into t2 values (19700301+$count-1);
+dec $count;
+}
+#--enable_query_log
+select count(*) from t2;
+select * from t2;
+drop table t2;
+
+eval create table t3 (a date not null, primary key(a)) engine=$engine
+partition by range (cast(month(a) as unsigned)) subpartition by key (a)
+subpartitions 3 (
+partition quarter1 values less than (4),
+partition quarter2 values less than (7),
+partition quarter3 values less than (10),
+partition quarter4 values less than (13)
+);
+show create table t3;
+let $count=12;
+--echo $count inserts;
+while ($count)
+{
+eval insert into t3 values (adddate(19700101,interval $count-1 month));
+dec $count;
+}
+select count(*) from t3;
+select * from t3;
+drop table t3;
+
+eval create table t4 (a date not null, primary key(a)) engine=$engine
+partition by list (cast(month(a) as unsigned)) subpartition by key (a)
+subpartitions 3 (
+partition quarter1 values in (1,2,3),
+partition quarter2 values in (4,5,6),
+partition quarter3 values in (7,8,9),
+partition quarter4 values in (10,11,12)
+);
+show create table t4;
+let $count=12;
+--echo $count inserts;
+while ($count)
+{
+eval insert into t4 values (adddate(19700101,interval $count-1 month));
+dec $count;
+}
+select count(*) from t4;
+select * from t4;
+drop table t4;
diff --git a/mysql-test/suite/parts/inc/partition_datetime.inc b/mysql-test/suite/parts/inc/partition_datetime.inc
new file mode 100644
index 00000000000..94c9d3d75da
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_datetime.inc
@@ -0,0 +1,86 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a datetime not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values ('1975-01-01 21:21:21'), ('2020-12-31 12:10:30'), ('1980-10-14 03:03'), ('2000-06-15 23:59');
+select * from t1;
+select * from t1 where a=19801014030300;
+delete from t1 where a=19801014030300;
+select * from t1;
+drop table t1;
+
+eval create table t2 (a datetime not null, primary key(a)) engine=$engine
+partition by key (a) partitions 12;
+show create table t2;
+insert into t2 values ('1975-01-01 0:1:1'), ('2020-12-31 10:11:12'), ('1980-10-14 13:14:15'), ('2000-06-15 14:15:16');
+select * from t2;
+select * from t2 where a='1980-10-14 13:14:15';
+delete from t2 where a='1980-10-14 13:14:15';
+select * from t2;
+delete from t2;
+let $count=59;
+--echo $count inserts;
+#--disable_query_log
+while ($count)
+{
+eval insert into t2 values (19700101000000+$count);
+dec $count;
+}
+select count(*) from t2;
+select * from t2;
+drop table t2;
+
+eval create table t3 (a datetime not null, primary key(a)) engine=$engine
+partition by range (cast(month(a) as unsigned)) subpartition by key (a)
+subpartitions 3 (
+partition quarter1 values less than (4),
+partition quarter2 values less than (7),
+partition quarter3 values less than (10),
+partition quarter4 values less than (13)
+);
+show create table t3;
+let $count=12;
+--echo $count inserts;
+while ($count)
+{
+eval insert into t3 values (adddate(19700101000000,interval $count-1 month));
+dec $count;
+}
+select count(*) from t3;
+select * from t3;
+drop table t3;
+
+eval create table t4 (a datetime not null, primary key(a)) engine=$engine
+partition by list (cast(month(a) as unsigned)) subpartition by key (a)
+subpartitions 3 (
+partition quarter1 values in (1,2,3),
+partition quarter2 values in (4,5,6),
+partition quarter3 values in (7,8,9),
+partition quarter4 values in (10,11,12)
+);
+show create table t4;
+let $count=12;
+--echo $count inserts;
+while ($count)
+{
+eval insert into t4 values (adddate(19700101000000,interval $count-1 month));
+dec $count;
+}
+select count(*) from t4;
+select * from t4;
+drop table t4;
diff --git a/mysql-test/suite/parts/inc/partition_decimal.inc b/mysql-test/suite/parts/inc/partition_decimal.inc
new file mode 100644
index 00000000000..eb35416f395
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_decimal.inc
@@ -0,0 +1,92 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a decimal(10,4) not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values (999999.9999), (-999999.9999), (123456.7899), (-123456.7899), (-1.5), (1), (0), (-1), (1.5), (1234.567), (-1234.567);
+select * from t1;
+select * from t1 where a=1234.567;
+delete from t1 where a=1234.567;
+select * from t1;
+drop table t1;
+
+eval create table t2 (a decimal(18,9) not null, primary key(a)) engine=$engine
+partition by key (a) partitions 10;
+show create table t2;
+insert into t2 values (999999999.999999999), (-999999999.999999999), (-1.5), (-1), (0), (1.5), (1234.567), (-1234.567);
+select * from t2;
+select * from t2 where a=1234.567;
+delete from t2 where a=1234.567;
+select * from t2;
+delete from t2;
+let $count=$maxrows;
+--echo $count*3 inserts;
+--disable_query_log
+while ($count)
+{
+eval insert into t2 values ($count);
+eval insert into t2 values ($count+0.333333333);
+eval insert into t2 values ($count+0.755555555);
+dec $count;
+}
+--enable_query_log
+select count(*) from t2;
+drop table t2;
+
+eval create table t3 (a decimal(18,9) not null, primary key(a)) engine=$engine
+partition by range (cast(floor(a) as signed)) subpartition by key (a) subpartitions 2 (
+partition pa2 values less than (2),
+partition pa4 values less than (4),
+partition pa6 values less than (6),
+partition pa8 values less than (8),
+partition pa10 values less than (10)
+);
+show create table t3;
+let $count=9;
+--echo $count*3 inserts;
+while ($count)
+{
+eval insert into t3 values ($count);
+eval insert into t3 values ($count+0.333333333);
+eval insert into t3 values ($count+0.755555555);
+dec $count;
+}
+--enable_query_log
+select count(*) from t3;
+drop table t3;
+
+eval create table t4 (a decimal(18,9) not null, primary key(a)) engine=$engine
+partition by list (cast(floor(a) as signed)) subpartition by key (a) subpartitions 2 (
+partition pa2 values in (1,2),
+partition pa4 values in (3,4),
+partition pa6 values in (5,6),
+partition pa8 values in (7,8),
+partition pa10 values in (9,10)
+);
+show create table t4;
+let $count=9;
+--echo $count*3 inserts;
+while ($count)
+{
+eval insert into t4 values ($count);
+eval insert into t4 values ($count+0.333333333);
+eval insert into t4 values ($count+0.755555555);
+dec $count;
+}
+--enable_query_log
+select count(*) from t4;
+drop table t4;
diff --git a/mysql-test/suite/parts/inc/partition_directory.inc b/mysql-test/suite/parts/inc/partition_directory.inc
new file mode 100644
index 00000000000..2c765e1f5ab
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_directory.inc
@@ -0,0 +1,263 @@
+################################################################################
+# include/partition_rectory.inc #
+# #
+# Purpose: #
+# Create and check partitioned tables #
+# The partitioning function use the column f_int1 #
+# #
+# For all Data/Index directory combinations #
+# do #
+# 1. Create the partitioned table #
+# 2 Insert the content of the table t0_template into t1 #
+# 3. Execute include/partition_check.inc #
+# 4. Drop the table t1 #
+# done #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-05-11 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $partitioning= ;
+#----------- PARTITION BY HASH
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY HASH(f_int1) PARTITIONS 2;
+if ($with_directories)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY HASH(f_int1) PARTITIONS 2
+(PARTITION p1
+$index_directory,
+PARTITION p2
+$index_directory)';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+--source suite/parts/inc/partition_check_drop.inc
+
+#----------- PARTITION BY KEY
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY KEY(f_int1) PARTITIONS 5';
+let $partitioning= `SELECT @aux`;
+if ($with_directories)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY HASH(f_int1) PARTITIONS 5
+(PARTITION p1
+$data_directory,
+PARTITION p2
+$index_directory,
+PARTITION p3
+$data_directory
+$index_directory,
+PARTITION p4,
+PARTITION p5
+$index_directory)';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+--source suite/parts/inc/partition_check_drop.inc
+
+#----------- PARTITION BY LIST
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY LIST(MOD(f_int1,4))
+(PARTITION part_3 VALUES IN (-3)
+$index_directory,
+ PARTITION part_2 VALUES IN (-2)
+$data_directory,
+ PARTITION part_1 VALUES IN (-1)
+$data_directory $index_directory,
+ PARTITION part_N VALUES IN (NULL)
+$data_directory,
+ PARTITION part0 VALUES IN (0)
+$index_directory,
+ PARTITION part1 VALUES IN (1)
+,
+ PARTITION part2 VALUES IN (2)
+$data_directory,
+ PARTITION part3 VALUES IN (3)
+$data_directory $index_directory)';
+let $partitioning= `SELECT @aux`;
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+--source suite/parts/inc/partition_check_drop.inc
+
+#----------- PARTITION BY RANGE
+if ($with_partitioning)
+{
+#--disable_query_log
+eval SET @aux = 'PARTITION BY RANGE(f_int1)
+(PARTITION parta VALUES LESS THAN (0)
+$index_directory,
+PARTITION partb VALUES LESS THAN ($max_row_div4)
+$data_directory,
+PARTITION partc VALUES LESS THAN ($max_row_div2)
+$data_directory
+$index_directory,
+PARTITION partd VALUES LESS THAN ($max_row_div2 + $max_row_div4),
+PARTITION parte VALUES LESS THAN ($max_row)
+$data_directory,
+PARTITION partf VALUES LESS THAN $MAX_VALUE
+$index_directory)';
+let $partitioning= `SELECT @aux`;
+#--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+--source suite/parts/inc/partition_check_drop.inc
+
+#----------- PARTITION BY RANGE -- SUBPARTITION BY HASH
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2
+(PARTITION parta VALUES LESS THAN (0)
+$index_directory,
+PARTITION partb VALUES LESS THAN ($max_row_div4)
+$data_directory,
+PARTITION partc VALUES LESS THAN ($max_row_div2),
+PARTITION partd VALUES LESS THAN $MAX_VALUE
+$data_directory
+$index_directory)';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+--source suite/parts/inc/partition_check_drop.inc
+
+#----------- PARTITION BY RANGE -- SUBPARTITION BY KEY
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux = 'PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1)
+(PARTITION part1 VALUES LESS THAN (0)
+$data_directory
+(SUBPARTITION subpart11, SUBPARTITION subpart12),
+PARTITION part2 VALUES LESS THAN ($max_row_div4)
+$index_directory
+(SUBPARTITION subpart21, SUBPARTITION subpart22),
+PARTITION part3 VALUES LESS THAN ($max_row_div2)
+$data_directory
+$index_directory
+(SUBPARTITION subpart31, SUBPARTITION subpart32),
+PARTITION part4 VALUES LESS THAN $MAX_VALUE
+(SUBPARTITION subpart41, SUBPARTITION subpart42))';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+--source suite/parts/inc/partition_check_drop.inc
+
+#----------- PARTITION BY LIST -- SUBPARTITION BY HASH
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1)
+(PARTITION part1 VALUES IN (0)
+ $index_directory
+ (SUBPARTITION sp11
+ $data_directory,
+ SUBPARTITION sp12
+ $index_directory),
+ PARTITION part2 VALUES IN (1)
+ $data_directory
+ (SUBPARTITION sp21
+ $data_directory,
+ SUBPARTITION sp22
+ $index_directory),
+ PARTITION part3 VALUES IN (2)
+ $data_directory
+ $index_directory
+ (SUBPARTITION sp31,
+ SUBPARTITION sp32),
+ PARTITION part4 VALUES IN (NULL)
+ (SUBPARTITION sp41
+ $data_directory
+ $index_directory,
+ SUBPARTITION sp42
+ $data_directory
+ $index_directory))';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+--source suite/parts/inc/partition_check_drop.inc
+
+let $with_directories= FALSE;
+
diff --git a/mysql-test/suite/parts/inc/partition_double.inc b/mysql-test/suite/parts/inc/partition_double.inc
new file mode 100644
index 00000000000..96cf7fd4871
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_double.inc
@@ -0,0 +1,89 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a double not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208);
+select * from t1;
+select * from t1 where a=1.5;
+delete from t1 where a=1.5;
+select * from t1;
+drop table t1;
+
+eval create table t2 (a double not null, primary key(a)) engine=$engine
+partition by key (a) partitions 10;
+show create table t2;
+insert into t2 values (-2.2250738585072014E+208), (-2.2250738585072014E-208), (-1.5), (-1), (0), (1.5), (1234.567), (2.2250738585072014E+208);
+select * from t2;
+select * from t2 where a=1234.567;
+delete from t2 where a=1234.567;
+select * from t2;
+delete from t2;
+let $count=$maxrows;
+--echo $maxrows*3 inserts;
+--disable_query_log
+while ($count)
+{
+eval insert into t2 values ($count);
+eval insert into t2 values ($count+0.33);
+eval insert into t2 values ($count+0.75);
+dec $count;
+}
+--enable_query_log
+select count(*) from t2;
+drop table t2;
+
+
+eval create table t3 (a double not null, primary key(a)) engine=$engine
+partition by range (cast(floor(a) as signed)) subpartition by key (a) subpartitions 3 (
+partition pa1 values less than (3),
+partition pa3 values less than (6),
+partition pa10 values less than (10)
+);
+show create table t3;
+let $count=9;
+--echo $count*3 inserts;
+while ($count)
+{
+eval insert into t3 values ($count);
+eval insert into t3 values ($count+0.33);
+eval insert into t3 values ($count+0.75);
+dec $count;
+}
+select count(*) from t3;
+select * from t3;
+drop table t3;
+
+eval create table t4 (a double not null, primary key(a)) engine=$engine
+partition by list (cast(floor(a) as signed)) subpartition by key (a) subpartitions 3 (
+partition pa1 values in (1,2,3),
+partition pa3 values in (4,5,6),
+partition pa10 values in (7,8,9,10)
+);
+show create table t4;
+let $count=9;
+--echo $count*3 inserts;
+while ($count)
+{
+eval insert into t4 values ($count);
+eval insert into t4 values ($count+0.33);
+eval insert into t4 values ($count+0.75);
+dec $count;
+}
+select count(*) from t4;
+select * from t4;
+drop table t4;
diff --git a/mysql-test/suite/parts/inc/partition_engine.inc b/mysql-test/suite/parts/inc/partition_engine.inc
new file mode 100644
index 00000000000..2beb08e7626
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_engine.inc
@@ -0,0 +1,271 @@
+################################################################################
+# include/partition_engine.inc #
+# #
+# Purpose: #
+# Tests around Create/Alter partitioned tables and storage engine settings #
+# at different places within the statement. #
+# This routine is only useful for the partition_<feature>_<engine> tests. #
+# #
+# Note: There were some problems in history. #
+# It looks like a table holds informations about the storage engine #
+# for #
+# "the whole table" -> in statement after column list before partitioning #
+# a partition -> in statement after definition of partition #
+# a subpartition -> in statement after definition of subpartition #
+# If there is a CREATE TABLE statement where not at all of these place #
+# a storage engine is assigned, the server must decide by itself whic #
+# storage engine to use. #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+--echo
+--echo #========================================================================
+--echo # Checks where the engine is assigned on all supported (CREATE TABLE
+--echo # statement) positions + basic operations on the tables
+--echo # Storage engine mixups are currently (2005-12-23) not supported
+--echo #========================================================================
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+#
+--echo #------------------------------------------------------------------------
+--echo # 1 Assignment of storage engine just after column list only
+--echo #------------------------------------------------------------------------
+eval CREATE TABLE t1 (
+$column_list
+) ENGINE = $engine
+ PARTITION BY HASH(f_int1) PARTITIONS 2;
+INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+#
+--echo #------------------------------------------------------------------------
+--echo # 2 Assignment of storage engine just after partition or subpartition
+--echo # name only
+--echo #------------------------------------------------------------------------
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY HASH(f_int1)
+( PARTITION part1 STORAGE ENGINE = $engine,
+ PARTITION part2 STORAGE ENGINE = $engine
+);
+INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+SUBPARTITION BY HASH(f_int1)
+( PARTITION part1 VALUES LESS THAN ($max_row_div2)
+ (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
+ SUBPARTITION subpart12 STORAGE ENGINE = $engine),
+ PARTITION part2 VALUES LESS THAN $MAX_VALUE
+ (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
+ SUBPARTITION subpart22 STORAGE ENGINE = $engine)
+);
+INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+#
+--echo #------------------------------------------------------------------------
+--echo # 3 Some but not all named partitions or subpartitions get a storage
+--echo # engine assigned
+--echo #------------------------------------------------------------------------
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY HASH(f_int1)
+( PARTITION part1 STORAGE ENGINE = $engine,
+ PARTITION part2
+);
+INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY HASH(f_int1)
+( PARTITION part1 ,
+ PARTITION part2 STORAGE ENGINE = $engine
+);
+INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+SUBPARTITION BY HASH(f_int1)
+( PARTITION part1 VALUES LESS THAN ($max_row_div2)
+ (SUBPARTITION subpart11,
+ SUBPARTITION subpart12 STORAGE ENGINE = $engine),
+ PARTITION part2 VALUES LESS THAN $MAX_VALUE
+ (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
+ SUBPARTITION subpart22 STORAGE ENGINE = $engine)
+);
+INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+SUBPARTITION BY HASH(f_int1)
+( PARTITION part1 VALUES LESS THAN ($max_row_div2)
+ (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
+ SUBPARTITION subpart12 STORAGE ENGINE = $engine),
+ PARTITION part2 VALUES LESS THAN $MAX_VALUE
+ (SUBPARTITION subpart21,
+ SUBPARTITION subpart22 )
+);
+INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+#
+--echo #------------------------------------------------------------------------
+--echo # 4 Storage engine assignment after partition name + after name of
+--echo # subpartitions belonging to another partition
+--echo #------------------------------------------------------------------------
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+SUBPARTITION BY HASH(f_int1)
+( PARTITION part1 VALUES LESS THAN ($max_row_div2) ENGINE = $engine
+ (SUBPARTITION subpart11,
+ SUBPARTITION subpart12),
+ PARTITION part2 VALUES LESS THAN $MAX_VALUE
+ (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
+ SUBPARTITION subpart22 STORAGE ENGINE = $engine)
+);
+INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+SUBPARTITION BY HASH(f_int1)
+( PARTITION part1 VALUES LESS THAN ($max_row_div2)
+ (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
+ SUBPARTITION subpart12 STORAGE ENGINE = $engine),
+ PARTITION part2 VALUES LESS THAN $MAX_VALUE ENGINE = $engine
+ (SUBPARTITION subpart21,
+ SUBPARTITION subpart22)
+);
+INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+#
+--echo #------------------------------------------------------------------------
+--echo # 5 Precedence of storage engine assignments (if there is any)
+--echo #------------------------------------------------------------------------
+--echo # 5.1 Storage engine assignment after column list + after partition
+--echo # or subpartition name
+eval CREATE TABLE t1 (
+$column_list
+) ENGINE = $engine
+PARTITION BY HASH(f_int1)
+( PARTITION part1 STORAGE ENGINE = $engine,
+ PARTITION part2 STORAGE ENGINE = $engine
+);
+INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+SUBPARTITION BY HASH(f_int1)
+( PARTITION part1 VALUES LESS THAN ($max_row_div2)
+ (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
+ SUBPARTITION subpart12 STORAGE ENGINE = $engine),
+ PARTITION part2 VALUES LESS THAN $MAX_VALUE
+ (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
+ SUBPARTITION subpart22 STORAGE ENGINE = $engine)
+);
+INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+--echo # 6.2 Storage engine assignment after partition name + after
+--echo # subpartition name
+# in partition part + in sub partition part
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+SUBPARTITION BY HASH(f_int1)
+( PARTITION part1 VALUES LESS THAN ($max_row_div2) STORAGE ENGINE = $engine
+ (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
+ SUBPARTITION subpart12 STORAGE ENGINE = $engine),
+ PARTITION part2 VALUES LESS THAN $MAX_VALUE
+ (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
+ SUBPARTITION subpart22 STORAGE ENGINE = $engine)
+);
+INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+
+--echo #------------------------------------------------------------------------
+--echo # 6 Session default engine differs from engine used within create table
+--echo #------------------------------------------------------------------------
+eval SET SESSION storage_engine=$engine_other;
+# Bug#16775 Partitions: strange effects on subpartitioned tables, mixed storage engines
+# Bug#15966 Partitions: crash if session default engine <> engine used in create table
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY HASH(f_int1) ( PARTITION part1 ENGINE = $engine);
+INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+# Bug#15966 Partitions: crash if session default engine <> engine used in create table
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+SUBPARTITION BY HASH(f_int1)
+( PARTITION part1 VALUES LESS THAN (1000)
+ (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
+ SUBPARTITION subpart12 STORAGE ENGINE = $engine));
+INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+eval SET SESSION storage_engine=$engine;
diff --git a/mysql-test/suite/parts/inc/partition_enum.inc b/mysql-test/suite/parts/inc/partition_enum.inc
new file mode 100644
index 00000000000..f8fcb1110ae
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_enum.inc
@@ -0,0 +1,99 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a enum('A','B','C','D','E','F','G','H','I','J','K','L') not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values ('A'),('D'),('L'),('G');
+select * from t1;
+select * from t1 where a='A';
+update t1 set a='E' where a='L';
+select * from t1;
+delete from t1 where a='E';
+select * from t1;
+drop table t1;
+
+eval create table t2 (a enum (
+'1','2','3','4','5','6','7','8','9','0',
+'A','B','C','D','E','F','G','H','I','J','K','L',
+'M','N','O','P','Q','R','S','T','U','V','W','X',
+'Y','Z'
+) not null, primary key(a)) engine=$engine
+partition by key (a) partitions 27;
+show create table t2;
+let $letter=26;
+--echo $count inserts;
+#--disable_query_log
+while ($letter)
+{
+eval insert into t2 values (char(ascii('A')+$letter));
+dec $letter;
+}
+insert into t2 values ('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'),('0');
+select count(*) from t2;
+select * from t2;
+drop table t2;
+
+eval create table t3 (a enum (
+'1','2','3','4','5','6','7','8','9','0',
+'A','B','C','D','E','F','G','H','I','J','K','L',
+'M','N','O','P','Q','R','S','T','U','V','W','X',
+'Y','Z'
+) not null, primary key(a)) engine=$engine
+partition by range (cast(a as unsigned)) subpartition by key (a) subpartitions 3 (
+partition pa9 values less than (10),
+partition pa18 values less than (19),
+partition pa27 values less than (28),
+partition pa36 values less than (37)
+);
+show create table t3;
+let $letter=36;
+--echo $count inserts;
+#--disable_query_log
+while ($letter)
+{
+#eval insert into t3 values ($letter);
+dec $letter;
+}
+select count(*) from t3;
+select * from t3;
+drop table t3;
+
+eval create table t4 (a enum (
+'1','2','3','4','5','6','7','8','9','0',
+'A','B','C','D','E','F','G','H','I','J','K','L',
+'M','N','O','P','Q','R','S','T','U','V','W','X',
+'Y','Z'
+) not null, primary key(a)) engine=$engine
+partition by list (cast(a as unsigned)) subpartition by key (a) subpartitions 3 (
+partition pa9 values in (1,2,3,4,5,6,7,8,9),
+partition pa18 values in (10,11,12,13,14,15,16,17,18),
+partition pa27 values in (19,20,21,22,23,24,25,26,27),
+partition pa36 values in (28,29,30,31,32,33,34,35,36)
+);
+show create table t4;
+let $letter=36;
+--echo $count inserts;
+#--disable_query_log
+while ($letter)
+{
+#eval insert into t4 values ($letter);
+dec $letter;
+}
+select count(*) from t4;
+select * from t4;
+drop table t4;
+
diff --git a/mysql-test/suite/parts/inc/partition_float.inc b/mysql-test/suite/parts/inc/partition_float.inc
new file mode 100644
index 00000000000..25c59a10153
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_float.inc
@@ -0,0 +1,92 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a float not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values (-3.402823466E+38), (3.402823466E+38), (-1.5), (-1), (0), (1), (1.5);
+select * from t1;
+select * from t1 where a=1.5;
+delete from t1 where a=1.5;
+select * from t1;
+drop table t1;
+
+eval create table t2 (a float not null, primary key(a)) engine=$engine
+partition by key (a) partitions 10;
+show create table t2;
+insert into t2 values (-3.402823466E+38), (-3.402823466E+37), (-123.456), (0), (1234546.789), (123.456), (1.5);
+select * from t2;
+#result set is empty: Not a bug with float!!
+select * from t2 where a=123.456;
+delete from t2 where a=123.456;
+select * from t2;
+select * from t2 where a=1.5;
+delete from t2 where a=1.5;
+select * from t2;
+delete from t2;
+let $count=$maxrows;
+--echo $maxrows*3 inserts;
+--disable_query_log
+while ($count)
+{
+eval insert into t2 values ($count);
+eval insert into t2 values ($count+0.33);
+eval insert into t2 values ($count+0.75);
+dec $count;
+}
+--enable_query_log
+select count(*) from t2;
+drop table t2;
+
+eval create table t3 (a float not null, primary key(a)) engine=$engine
+partition by range (cast(floor(a) as signed)) subpartition by key (a) subpartitions 3 (
+partition pa1 values less than (3),
+partition pa3 values less than (6),
+partition pa10 values less than (10)
+);
+show create table t3;
+let $count=9;
+--echo $count*3 inserts;
+while ($count)
+{
+eval insert into t3 values ($count);
+eval insert into t3 values ($count+0.33);
+eval insert into t3 values ($count+0.75);
+dec $count;
+}
+select count(*) from t3;
+select * from t3;
+drop table t3;
+
+eval create table t4 (a float not null, primary key(a)) engine=$engine
+partition by list (cast(floor(a) as signed)) subpartition by key (a) subpartitions 3 (
+partition pa1 values in (1,2,3),
+partition pa3 values in (4,5,6),
+partition pa10 values in (7,8,9,10)
+);
+show create table t4;
+let $count=9;
+--echo $count*3 inserts;
+while ($count)
+{
+eval insert into t4 values ($count);
+eval insert into t4 values ($count+0.33);
+eval insert into t4 values ($count+0.75);
+dec $count;
+}
+select count(*) from t4;
+select * from t4;
+drop table t4;
diff --git a/mysql-test/suite/parts/inc/partition_int.inc b/mysql-test/suite/parts/inc/partition_int.inc
new file mode 100644
index 00000000000..7f019c96b94
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_int.inc
@@ -0,0 +1,56 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a int unsigned not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values (4294967295), (4294967294), (4294967293), (4294967292), (1), (2), (65535);
+select * from t1;
+select * from t1 where a=4294967293;
+delete from t1 where a=4294967293;
+select * from t1;
+drop table t1;
+
+eval create table t2 (a int unsigned not null, primary key(a)) engine=$engine
+partition by key (a) partitions 10;
+show create table t2;
+insert into t2 values (4294967295), (4294967294), (4294967293), (4294967292);
+select * from t2;
+select * from t2 where a=4294967293;
+delete from t2 where a=4294967293;
+select * from t2;
+delete from t2;
+let $count=$maxrows;
+--echo $count inserts;
+--disable_query_log
+while ($count)
+{
+eval insert into t2 values ($count);
+dec $count;
+}
+--enable_query_log
+select count(*) from t2;
+drop table t2;
+
+eval create table t3 (a int not null, primary key(a)) engine=$engine
+partition by key (a) partitions 10;
+show create table t3;
+insert into t3 values (2147483647), (2147483646), (2147483645), (2147483644), (-2147483648), (-2147483647), (1), (-1), (0);
+select * from t3;
+select * from t3 where a=2147483645;
+delete from t3 where a=2147483645;
+select * from t3;
+drop table t3;
diff --git a/mysql-test/suite/parts/inc/partition_key_16col.inc b/mysql-test/suite/parts/inc/partition_key_16col.inc
new file mode 100644
index 00000000000..5f97d5d0f71
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_key_16col.inc
@@ -0,0 +1,27 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a date not null, b varchar(50) not null, c varchar(50) not null, d enum('m', 'w') not null, e int not null, f decimal (18,2) not null, g bigint not null, h tinyint not null, a1 date not null, b1 varchar(50) not null, c1 varchar(50) not null, d1 enum('m', 'w') not null, e1 int not null, f1 decimal (18,2) not null, g1 bigint not null, h1 tinyint not null, i char(255), primary key(a,b,c,d,e,f,g,h,a1,b1,c1,d1,e1,f1,g1,h1)) engine=$engine
+partition by key(a,b,c,d,e,f,g,h,a1,b1,c1,d1,e1,f1,g1,h1) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values
+('1975-01-01', 'abcde', 'abcde','m', 1234, 123.45, 32412341234, 113,'1975-01-01', 'abcde', 'abcde','m', 1234, 123.45, 32412341234, 113, 'tbhth nrzh ztfghgfh fzh ftzhj fztjh'),
+('1983-12-31', 'cdef', 'srtbvsr', 'w', 45634, 13452.56, 3452346456, 127,'1983-12-31', 'cdef', 'srtbvsr', 'w', 45634, 13452.56, 3452346456, 127, 'liuugbzvdmrlti b itiortudirtfgtibm dfi'),
+('1980-10-14', 'fgbbd', 'dtzndtz', 'w', 67856, 5463354.67, 3567845333, 124,'1980-10-14', 'fgbbd', 'dtzndtz', 'w', 67856, 5463354.67, 3567845333, 124, 'd,f söierugsig msireg siug ei5ggth lrutluitgzeöjrtnb.rkjthuekuhzrkuthgjdnffjmbr'),
+('2000-06-15', 'jukg','zikhuk','m', 45675, 6465754.13, 435242623462, 18, '2000-06-15', 'jukg','zikhuk','m', 45675, 6465754.13, 435242623462, 18, 'pib mdotkbm.m');
+select * from t1;
+select * from t1 where a<19851231;
+drop table t1;
diff --git a/mysql-test/suite/parts/inc/partition_key_32col.inc b/mysql-test/suite/parts/inc/partition_key_32col.inc
new file mode 100644
index 00000000000..90a36d2a228
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_key_32col.inc
@@ -0,0 +1,39 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+--error ER_TOO_MANY_KEY_PARTS
+eval create table t1 (a date not null, b varchar(50) not null, c varchar(50) not null, d enum('m', 'w') not null, e int not null, f decimal (18,2) not null, g bigint not null, h tinyint not null, a1 date not null, b1 varchar(50) not null, c1 varchar(50) not null, d1 enum('m', 'w') not null, e1 int not null, f1 decimal (18,2) not null, g1 bigint not null, h1 tinyint not null, a2 date not null, b2 varchar(50) not null, c2 varchar(50) not null, d2 enum('m', 'w') not null, e2 int not null, f2 decimal (18,2) not null, g2 bigint not null, h2 tinyint not null, a3 date not null, b3 varchar(50) not null, c3 varchar(50) not null, d3 enum('m', 'w') not null, e3 int not null, f3 decimal (18,2) not null, g3 bigint not null, h3 tinyint not null, i char(255), primary key(a,b,c,d,e,f,g,h,a1,b1,c1,d1,e1,f1,g1,h1,a2,b2,c2,d2,e2,f2,g2,h2,a3,b3,c3,d3,e3,f3,g3,h3)) engine=$engine
+partition by key(a,b,c,d,e,f,g,h,a1,b1,c1,d1,e1,f1,g1,h1,a2,b2,c2,d2,e2,f2,g2,h2,a3,b3,c3,d3,e3,f3,g3,h3) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+
+eval create table t1 (a date not null, b varchar(50) not null, c varchar(50) not null, d enum('m', 'w') not null, e int not null, f decimal (18,2) not null, g bigint not null, h tinyint not null, a1 date not null, b1 varchar(50) not null, c1 varchar(50) not null, d1 enum('m', 'w') not null, e1 int not null, f1 decimal (18,2) not null, g1 bigint not null, h1 tinyint not null, a2 date not null, b2 varchar(50) not null, c2 varchar(50) not null, d2 enum('m', 'w') not null, e2 int not null, f2 decimal (18,2) not null, g2 bigint not null, h2 tinyint not null, a3 date not null, b3 varchar(50) not null, c3 varchar(50) not null, d3 enum('m', 'w') not null, e3 int not null, f3 decimal (18,2) not null, g3 bigint not null, h3 tinyint not null, i char(255), primary key(a,b,c,d,e,f,g,h,a1,b1,c1,d1,e1,f1,g1,h1)) engine=$engine
+partition by key(a,b,c,d,e,f,g,h) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+
+--disable_abort_on error
+show create table t1;
+insert into t1 values
+('1975-01-01', 'abcde', 'abcde','m', 1234, 123.45, 32412341234, 113,'1975-01-01', 'abcde', 'abcde','m', 1234, 123.45, 32412341234, 113,'1975-01-01', 'abcde', 'abcde','m', 1234, 123.45, 32412341234, 113, '1975-01-01', 'abcde', 'abcde','m', 1234, 123.45, 32412341234, 113, 'tbhth nrzh ztfghgfh fzh ftzhj fztjh'),
+('1983-12-31', 'cdef', 'srtbvsr', 'w', 45634, 13452.56, 3452346456, 127,'1983-12-31', 'cdef', 'srtbvsr', 'w', 45634, 13452.56, 3452346456, 127, '1983-12-31', 'cdef', 'srtbvsr', 'w', 45634, 13452.56, 3452346456, 127, '1983-12-31', 'cdef', 'srtbvsr', 'w', 45634, 13452.56, 3452346456, 127, 'liuugbzvdmrlti b itiortudirtfgtibm dfi'),
+('1980-10-14', 'fgbbd', 'dtzndtz', 'w', 67856, 5463354.67, 3567845333, 124, '1980-10-14', 'fgbbd', 'dtzndtz', 'w', 67856, 5463354.67, 3567845333, 124, '1980-10-14', 'fgbbd', 'dtzndtz', 'w', 67856, 5463354.67, 3567845333, 124, '1980-10-14', 'fgbbd', 'dtzndtz', 'w', 67856, 5463354.67, 3567845333, 124, 'd,f söierugsig msireg siug ei5ggth lrutluitgzeöjrtnb.rkjthuekuhzrkuthgjdnffjmbr'),
+('2000-06-15', 'jukg','zikhuk','m', 45675, 6465754.13, 435242623462, 18, '2000-06-15', 'jukg','zikhuk','m', 45675, 6465754.13, 435242623462, 18, '2000-06-15', 'jukg','zikhuk','m', 45675, 6465754.13, 435242623462, 18, '2000-06-15', 'jukg','zikhuk','m', 45675, 6465754.13, 435242623462, 18, 'pib mdotkbm.m');
+select * from t1;
+select * from t1 where a<19851231;
+drop table t1;
+--enable_abort_on_error
+
diff --git a/mysql-test/suite/parts/inc/partition_key_4col.inc b/mysql-test/suite/parts/inc/partition_key_4col.inc
new file mode 100644
index 00000000000..c5d1452080f
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_key_4col.inc
@@ -0,0 +1,28 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a date not null, b varchar(50) not null, c varchar(50) not null, d enum('m', 'w'), primary key(a,b,c,d)) engine=$engine
+partition by key (a,b,c,d) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values
+('1975-01-01', 'abcde', 'abcde','m'),
+('1983-12-31', 'cdef', 'srtbvsr', 'w'),
+('1980-10-14', 'fgbbd', 'dtzndtz', 'w'),
+('2000-06-15', 'jukg','zikhuk','m');
+select * from t1;
+select * from t1 where a<19851231;
+drop table t1;
+
diff --git a/mysql-test/suite/parts/inc/partition_key_8col.inc b/mysql-test/suite/parts/inc/partition_key_8col.inc
new file mode 100644
index 00000000000..a0d2e1532f3
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_key_8col.inc
@@ -0,0 +1,27 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a date not null, b varchar(50) not null, c varchar(50) not null, d enum('m', 'w') not null, e int not null, f decimal (18,2) not null, g bigint not null, h tinyint not null, i char(255), primary key(a,b,c,d,e,f,g,h)) engine=$engine
+partition by key(a,b,c,d,e,f,g,h) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values
+('1975-01-01', 'abcde', 'abcde','m', 1234, 123.45, 32412341234, 113, 'tbhth nrzh ztfghgfh fzh ftzhj fztjh'),
+('1983-12-31', 'cdef', 'srtbvsr', 'w', 45634, 13452.56, 3452346456, 127, 'liuugbzvdmrlti b itiortudirtfgtibm dfi'),
+('1980-10-14', 'fgbbd', 'dtzndtz', 'w', 67856, 5463354.67, 3567845333, 124, 'd,f söierugsig msireg siug ei5ggth lrutluitgzeöjrtnb.rkjthuekuhzrkuthgjdnffjmbr'),
+('2000-06-15', 'jukg','zikhuk','m', 45675, 6465754.13, 435242623462, 18, 'pib mdotkbm.m' );
+select * from t1;
+select * from t1 where a<19851231;
+drop table t1;
diff --git a/mysql-test/suite/parts/inc/partition_layout_check1.inc b/mysql-test/suite/parts/inc/partition_layout_check1.inc
new file mode 100644
index 00000000000..fe0d9d138a0
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_layout_check1.inc
@@ -0,0 +1,71 @@
+################################################################################
+# include/partition_layout_check1.inc #
+# #
+# Purpose: #
+# Store the SHOW CREATE TABLE output and the list of files belonging to #
+# this table + print this into the protocol #
+# This script is only usefule when sourced within the partitioning tests. #
+# #
+# Attention: The routine include/partition_layout_check2.inc is very similar #
+# to this one. So if something has to be changed here it #
+# might be necessary to do it also there #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+if ($no_debug)
+{
+--disable_query_log
+}
+# Clean the table holding the definition of t1
+DELETE FROM t0_definition;
+
+# Dump the current definition of the table t1 to tmp1
+# This complicated method - let another mysqltest collect the output - is used
+# because of two reasons
+# - SHOW CREATE TABLE t1 is at least currently most probably more reliable than
+# the corresponding SELECT on the INFORMATION_SCHEMA
+# - SHOW CREATE TABLE .. cannot write its out put into a file like SELECT
+--exec echo "SHOW CREATE TABLE t1;" | $MYSQL_TEST > $MYSQLTEST_VARDIR/master-data/test/tmp1 2>&1 || true
+if ($do_file_tests)
+{
+# List the files belonging to the table t1
+--exec ls $MYSQLTEST_VARDIR/master-data/test/t1* > $MYSQLTEST_VARDIR/master-data/test/tmp2 2>&1 || true
+if ($with_directories)
+{
+--exec ls $MYSQLTEST_VARDIR/master-data/test/data/t1* >> $MYSQLTEST_VARDIR/master-data/test/tmp2 2>&1 || true
+--exec ls $MYSQLTEST_VARDIR/master-data/test/index/t1* >> $MYSQLTEST_VARDIR/master-data/test/tmp2 2>&1 || true
+}
+eval SET @aux = CONCAT('load_file(''$MYSQLTEST_VARDIR','/master-data/test/tmp2''
+)');
+let $file_list= `SELECT @aux`;
+}
+if (!$do_file_tests)
+{
+let $file_list= '--- not determined ---';
+}
+
+# Insert the current definition of the table t1 into t0_definition
+eval INSERT INTO t0_definition SET state = 'old',
+ create_command = load_file('$MYSQLTEST_VARDIR/master-data/test/tmp1'),
+ file_list = $file_list;
+
+# Print the create table statement into the protocol
+SELECT create_command FROM t0_definition WHERE state = 'old';
+if ($do_file_tests)
+{
+ # We stored the list of files, therefore printing the content makes sense
+ if ($ls)
+ {
+ # Print the list of files into the protocol
+ eval SELECT REPLACE(file_list,'$MYSQLTEST_VARDIR','\$MYSQLTEST_VARDIR')
+ AS "unified filelist"
+ FROM t0_definition WHERE state = 'old';
+ }
+}
+--enable_query_log
diff --git a/mysql-test/suite/parts/inc/partition_layout_check2.inc b/mysql-test/suite/parts/inc/partition_layout_check2.inc
new file mode 100644
index 00000000000..c28387cccd0
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_layout_check2.inc
@@ -0,0 +1,70 @@
+################################################################################
+# include/partition_layout_check2.inc #
+# #
+# Purpose: #
+# Store the SHOW CREATE TABLE output and the list of files belonging to #
+# this table + Check if the layout of the table was not modified #
+# since the call of include/partition_layout_check1.inc #
+# This script is only usefule when sourced within the partitioning tests. #
+# #
+# Attention: The routine include/partition_layout_check1.inc is very similar #
+# to this one. So if something has to be changed here it #
+# might be necessary to do it also there #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+if ($no_debug)
+{
+--disable_query_log
+}
+# Clean the table holding the definition of t1
+DELETE FROM t0_definition WHERE state = 'new';
+
+# Dump the current definition of the table t1 to tmp1
+--exec echo "SHOW CREATE TABLE t1;" | $MYSQL_TEST > $MYSQLTEST_VARDIR/master-data/test/tmp1 2>&1 || true
+if ($do_file_tests)
+{
+# List the files belonging to the table t1
+--exec ls $MYSQLTEST_VARDIR/master-data/test/t1* > $MYSQLTEST_VARDIR/master-data/test/tmp2 2>&1 || true
+eval SET @aux = CONCAT('load_file(''$MYSQLTEST_VARDIR','/master-data/test/tmp2'')');
+let $file_list= `SELECT @aux`;
+}
+if (!$do_file_tests)
+{
+let $file_list= '--- not determined ---';
+}
+
+# Insert the current definition of the table t1 into t0_definition
+eval INSERT INTO t0_definition SET state = 'new',
+ create_command = load_file('$MYSQLTEST_VARDIR/master-data/test/tmp1'),
+ file_list = $file_list;
+
+# Print the old and new table layout, if they differ
+SELECT COUNT(*) <> 1 INTO @aux
+FROM t0_definition tab1, t0_definition tab2
+WHERE tab1.state = 'old' AND tab2.state = 'new'
+ AND tab1.create_command = tab2.create_command
+ AND tab1.file_list = tab2.file_list;
+let $run= `SELECT @aux`;
+if ($run)
+{
+ --vertical_results
+ SELECT state,
+ REPLACE(create_command,'\n',' ') AS "Table definition",
+ REPLACE(file_list ,'\n',' ') AS "File list"
+ FROM t0_definition WHERE state in ('old','new');
+ --horizontal_results
+ --echo # check layout success: 0
+}
+let $run= `SELECT @aux = 0`;
+if ($run)
+{
+ --echo # check layout success: 1
+}
+--enable_query_log
diff --git a/mysql-test/suite/parts/inc/partition_mediumint.inc b/mysql-test/suite/parts/inc/partition_mediumint.inc
new file mode 100644
index 00000000000..18bfedf7ed9
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_mediumint.inc
@@ -0,0 +1,56 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a mediumint unsigned not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values (16777215), (16777214), (16777213), (16777212), (1), (2), (65535);
+select * from t1;
+select * from t1 where a=16777213;
+delete from t1 where a=16777213;
+select * from t1;
+drop table t1;
+
+eval create table t2 (a mediumint unsigned not null, primary key(a)) engine=$engine
+partition by key (a) partitions 8;
+show create table t2;
+insert into t2 values (16777215), (16777214), (16777213), (16777212);
+select * from t2;
+select * from t2 where a=16777213;
+delete from t2 where a=16777213;
+select * from t2;
+delete from t2;
+let $count=$maxrows;
+--echo $maxrows inserts;
+--disable_query_log
+while ($count)
+{
+eval insert into t2 values ($count);
+dec $count;
+}
+--enable_query_log
+select count(*) from t2;
+drop table t2;
+
+eval create table t3 (a mediumint not null, primary key(a)) engine=$engine
+partition by key (a) partitions 10;
+show create table t3;
+insert into t3 values (8388607), (8388606), (8388605), (8388604), (-8388608), (-8388607), (1), (-1), (0);
+select * from t3;
+select * from t3 where a=8388605;
+delete from t3 where a=8388605;
+select * from t3;
+drop table t3;
diff --git a/mysql-test/suite/parts/inc/partition_methods1.inc b/mysql-test/suite/parts/inc/partition_methods1.inc
new file mode 100644
index 00000000000..bec0c747f28
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_methods1.inc
@@ -0,0 +1,335 @@
+################################################################################
+# include/partition_methods1.inc #
+# #
+# Purpose: #
+# Create and check partitioned tables #
+# The partitioning function use the column f_int1 #
+# #
+# For all partitioning methods #
+# PARTITION BY HASH/KEY/LIST/RANGE #
+# PARTITION BY RANGE/LIST ... SUBPARTITION BY HASH/KEY ... #
+# do #
+# 1. Create the partitioned table #
+# 2 Insert the content of the table t0_template into t1 #
+# 3. Execute include/partition_check.inc #
+# 4. Drop the table t1 #
+# done #
+# #
+# The parameter #
+# $unique -- PRIMARY KEY or UNIQUE INDEXes to be created within the #
+# CREATE TABLE STATEMENT #
+# has to be set before sourcing this routine. #
+# Example: #
+# let $unique= , UNIQUE INDEX uidx1 (f_int1); #
+# include/partition_method1s.inc #
+# #
+# Attention: The routine include/partition_methods2.inc is very similar #
+# to this one. So if something has to be changed here it #
+# might be necessary to do it also there #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: HH #
+# Change Date: 2006-05-12 #
+# Change: Introduced DATA/INDEX DIRECTORY #
+################################################################################
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $partitioning= ;
+#----------- PARTITION BY HASH
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY HASH(f_int1) PARTITIONS 2;
+if ($with_directories)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY HASH(f_int1) PARTITIONS 2
+(PARTITION p1
+$data_directory
+$index_directory,
+PARTITION p2
+$data_directory
+$index_directory)';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+--source suite/parts/inc/partition_check_drop.inc
+
+#----------- PARTITION BY KEY
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY KEY(f_int1) PARTITIONS 5';
+let $partitioning= `SELECT @aux`;
+if ($with_directories)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY HASH(f_int1) PARTITIONS 5
+(PARTITION p1
+$data_directory
+$index_directory,
+PARTITION p2
+$data_directory
+$index_directory,
+PARTITION p3
+$data_directory
+$index_directory,
+PARTITION p4
+$data_directory
+$index_directory,
+PARTITION p5
+$data_directory
+$index_directory)';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+--source suite/parts/inc/partition_check_drop.inc
+
+#----------- PARTITION BY LIST
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY LIST(MOD(f_int1,4))
+(PARTITION part_3 VALUES IN (-3)
+$data_directory $index_directory,
+ PARTITION part_2 VALUES IN (-2)
+$data_directory $index_directory,
+ PARTITION part_1 VALUES IN (-1)
+$data_directory $index_directory,
+ PARTITION part_N VALUES IN (NULL)
+$data_directory $index_directory,
+ PARTITION part0 VALUES IN (0)
+$data_directory $index_directory,
+ PARTITION part1 VALUES IN (1)
+$data_directory $index_directory,
+ PARTITION part2 VALUES IN (2)
+$data_directory $index_directory,
+ PARTITION part3 VALUES IN (3)
+$data_directory $index_directory)';
+let $partitioning= `SELECT @aux`;
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+--source suite/parts/inc/partition_check_drop.inc
+
+#----------- PARTITION BY RANGE
+if ($with_partitioning)
+{
+#--disable_query_log
+eval SET @aux = 'PARTITION BY RANGE(f_int1)
+(PARTITION parta VALUES LESS THAN (0)
+$data_directory
+$index_directory,
+PARTITION partb VALUES LESS THAN ($max_row_div4)
+$data_directory
+$index_directory,
+PARTITION partc VALUES LESS THAN ($max_row_div2)
+$data_directory
+$index_directory,
+PARTITION partd VALUES LESS THAN ($max_row_div2 + $max_row_div4)
+$data_directory
+$index_directory,
+PARTITION parte VALUES LESS THAN ($max_row)
+$data_directory
+$index_directory,
+PARTITION partf VALUES LESS THAN $MAX_VALUE
+$data_directory
+$index_directory)';
+let $partitioning= `SELECT @aux`;
+#--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+--source suite/parts/inc/partition_check_drop.inc
+
+#----------- PARTITION BY RANGE -- SUBPARTITION BY HASH
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY RANGE(f_int1 DIV 2) SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2
+(PARTITION parta VALUES LESS THAN (0)
+$data_directory
+$index_directory,
+PARTITION partb VALUES LESS THAN ($max_row_div4)
+$data_directory
+$index_directory,
+PARTITION partc VALUES LESS THAN ($max_row_div2)
+$data_directory
+$index_directory,
+PARTITION partd VALUES LESS THAN $MAX_VALUE
+$data_directory
+$index_directory)';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+--source suite/parts/inc/partition_check_drop.inc
+
+#----------- PARTITION BY RANGE -- SUBPARTITION BY KEY
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux = 'PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1)
+(PARTITION part1 VALUES LESS THAN (0)
+$data_directory
+$index_directory
+(SUBPARTITION subpart11, SUBPARTITION subpart12),
+PARTITION part2 VALUES LESS THAN ($max_row_div4)
+$data_directory
+$index_directory
+(SUBPARTITION subpart21, SUBPARTITION subpart22),
+PARTITION part3 VALUES LESS THAN ($max_row_div2)
+$data_directory
+$index_directory
+(SUBPARTITION subpart31, SUBPARTITION subpart32),
+PARTITION part4 VALUES LESS THAN $MAX_VALUE
+$data_directory
+$index_directory
+(SUBPARTITION subpart41, SUBPARTITION subpart42))';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+--source suite/parts/inc/partition_check_drop.inc
+
+#----------- PARTITION BY LIST -- SUBPARTITION BY HASH
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int1 + 1)
+(PARTITION part1 VALUES IN (0)
+ $data_directory
+ $index_directory
+ (SUBPARTITION sp11
+ $data_directory
+ $index_directory,
+ SUBPARTITION sp12
+ $data_directory
+ $index_directory),
+ PARTITION part2 VALUES IN (1)
+ $data_directory
+ $index_directory
+ (SUBPARTITION sp21
+ $data_directory
+ $index_directory,
+ SUBPARTITION sp22
+ $data_directory
+ $index_directory),
+ PARTITION part3 VALUES IN (2)
+ $data_directory
+ $index_directory
+ (SUBPARTITION sp31,
+ SUBPARTITION sp32),
+ PARTITION part4 VALUES IN (NULL)
+ $data_directory
+ $index_directory
+ (SUBPARTITION sp41
+ $data_directory
+ $index_directory,
+ SUBPARTITION sp42
+ $data_directory
+ $index_directory))';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+--source suite/parts/inc/partition_check_drop.inc
+
+#----------- PARTITION BY LIST -- SUBPARTITION BY KEY
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY LIST(ABS(MOD(f_int1,2)))
+SUBPARTITION BY KEY(f_int1) SUBPARTITIONS $sub_part_no
+(PARTITION part1 VALUES IN (0)
+ $data_directory
+ $index_directory,
+ PARTITION part2 VALUES IN (1)
+ $data_directory
+ $index_directory,
+ PARTITION part3 VALUES IN (NULL)
+ $data_directory
+ $index_directory)';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+--source suite/parts/inc/partition_check_drop.inc
+let $with_directories= FALSE;
diff --git a/mysql-test/suite/parts/inc/partition_methods2.inc b/mysql-test/suite/parts/inc/partition_methods2.inc
new file mode 100644
index 00000000000..31b083bfa7a
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_methods2.inc
@@ -0,0 +1,212 @@
+################################################################################
+# include/partition_methods2.inc #
+# #
+# Purpose: #
+# Create and check partitioned tables #
+# The partitioning function uses the columns f_int1 and f_int2 #
+# For all partitioning methods #
+# PARTITION BY HASH/KEY/LIST/RANGE #
+# PARTITION BY RANGE/LIST ... SUBPARTITION BY HASH/KEY ... #
+# do #
+# 1. Create the partitioned table #
+# 2 Insert the content of the table t0_template into t1 #
+# 3. Execute include/partition_check.inc #
+# 4. Drop the table t1 #
+# done #
+# #
+# The parameter #
+# $unique -- PRIMARY KEY or UNIQUE INDEXes to be created within the #
+# CREATE TABLE STATEMENT #
+# has to be set before sourcing this routine. #
+# Example: #
+# let $unique= , UNIQUE INDEX uidx1 (f_int1); #
+# include/partition_methods2.inc #
+# #
+# Attention: The routine include/partition_methods1.inc is very similar #
+# to this one. So if something has to be changed here it #
+# might be necessary to do it also there #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $partitioning= ;
+#----------- PARTITION BY HASH
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY HASH(f_int1 + f_int2) PARTITIONS 2;
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+
+#----------- PARTITION BY KEY
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY KEY(f_int1,f_int2) PARTITIONS 5;
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+
+#----------- PARTITION BY LIST
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY LIST(MOD(f_int1 + f_int2,4))
+(PARTITION part_3 VALUES IN (-3),
+ PARTITION part_2 VALUES IN (-2),
+ PARTITION part_1 VALUES IN (-1),
+ PARTITION part_N VALUES IN (NULL),
+ PARTITION part0 VALUES IN (0),
+ PARTITION part1 VALUES IN (1),
+ PARTITION part2 VALUES IN (2),
+ PARTITION part3 VALUES IN (3));
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+
+#----------- PARTITION BY RANGE
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux = 'PARTITION BY RANGE((f_int1 + f_int2) DIV 2)
+(PARTITION parta VALUES LESS THAN (0),
+PARTITION partb VALUES LESS THAN ($max_row_div4),
+PARTITION partc VALUES LESS THAN ($max_row_div2),
+PARTITION partd VALUES LESS THAN ($max_row_div2 + $max_row_div4),
+PARTITION parte VALUES LESS THAN ($max_row),
+PARTITION partf VALUES LESS THAN $MAX_VALUE)';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+
+#----------- PARTITION BY RANGE -- SUBPARTITION BY HASH
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY RANGE(f_int1) SUBPARTITION BY HASH(f_int2) SUBPARTITIONS 2
+(PARTITION parta VALUES LESS THAN (0),
+PARTITION partb VALUES LESS THAN ($max_row_div4),
+PARTITION partc VALUES LESS THAN ($max_row_div2),
+PARTITION partd VALUES LESS THAN $MAX_VALUE)';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+
+#----------- PARTITION BY RANGE -- SUBPARTITION BY KEY
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux = 'PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int2)
+(PARTITION part1 VALUES LESS THAN (0)
+(SUBPARTITION subpart11, SUBPARTITION subpart12),
+PARTITION part2 VALUES LESS THAN ($max_row_div4)
+(SUBPARTITION subpart21, SUBPARTITION subpart22),
+PARTITION part3 VALUES LESS THAN ($max_row_div2)
+(SUBPARTITION subpart31, SUBPARTITION subpart32),
+PARTITION part4 VALUES LESS THAN $MAX_VALUE
+(SUBPARTITION subpart41, SUBPARTITION subpart42))';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+
+#----------- PARTITION BY LIST -- SUBPARTITION BY HASH
+if ($with_partitioning)
+{
+let $partitioning= PARTITION BY LIST(ABS(MOD(f_int1,3))) SUBPARTITION BY HASH(f_int2 + 1)
+(PARTITION part1 VALUES IN (0)
+ (SUBPARTITION sp11, SUBPARTITION sp12),
+ PARTITION part2 VALUES IN (1)
+ (SUBPARTITION sp21, SUBPARTITION sp22),
+ PARTITION part3 VALUES IN (2)
+ (SUBPARTITION sp31, SUBPARTITION sp32),
+ PARTITION part4 VALUES IN (NULL)
+ (SUBPARTITION sp41, SUBPARTITION sp42));
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
+
+#----------- PARTITION BY LIST -- SUBPARTITION BY KEY
+if ($with_partitioning)
+{
+--disable_query_log
+eval SET @aux =
+'PARTITION BY LIST(ABS(MOD(f_int1,2)))
+SUBPARTITION BY KEY(f_int2) SUBPARTITIONS $sub_part_no
+(PARTITION part1 VALUES IN (0),
+ PARTITION part2 VALUES IN (1),
+ PARTITION part3 VALUES IN (NULL))';
+let $partitioning= `SELECT @aux`;
+--enable_query_log
+}
+eval CREATE TABLE t1 (
+$column_list
+$unique
+)
+$partitioning;
+eval $insert_all;
+--source suite/parts/inc/partition_check.inc
+# --source include/partition_check.inc
+DROP TABLE t1;
diff --git a/mysql-test/suite/parts/inc/partition_set.inc b/mysql-test/suite/parts/inc/partition_set.inc
new file mode 100644
index 00000000000..76fc1aea4ba
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_set.inc
@@ -0,0 +1,83 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a set('A','B','C','D','E','F','G','H','I','J','K','L') not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values ('A,B'),('C,D'),('E,L'),('G,H,K');
+select * from t1 order by a;
+select * from t1 where a='A,B';
+update t1 set a='A,B,C' where a='E,L';
+select * from t1 order by a;
+delete from t1 where a='A,B';
+select * from t1 order by a;
+drop table t1;
+
+eval create table t2 (a set (
+'1','2','3','4','5','6','7','8','9','0',
+'A','B','C','D','E','F','G','H','I','J','K','L',
+'M','N','O','P','Q','R','S','T','U','V','W','X',
+'Y','Z'
+) not null, primary key(a)) engine=$engine
+partition by key (a) partitions 27;
+show create table t2;
+insert into t2 values ('A'),('B'),('C'),('D'),('E'),('F'),('G'),('H'),('I'),('K'),('L'),('M'),('N'),('O'),('P'),('Q'),('S'),('T'),('U'),('V'),('X'),('Y'),('Z');
+insert into t2 values ('A,B'),('B,C'),('C,D'),('D,E'),('E,F'),('F,G'),('G,H'),('H,I'),('I,J'),('K,L'),('L,M'),('M,N'),('N,O'),('O,P'),('P,Q'),('Q,R'),('S,T'),('T,U'),('U,V'),('V,W'),('X,Y'),('Y,Z'),('Z,A');
+insert into t2 values ('A,B,C'),('B,C,D'),('C,D,E'),('D,E,F'),('E,F,G'),('F,G,H'),('G,H,I'),('H,I,J'),('I,J,K'),('K,L,M'),('L,M,N'),('M,N,O'),('N,O,P'),('O,P,Q'),('P,Q,R'),('Q,R,S'),('S,T,U'),('T,U,V'),('U,V,W'),('V,W,X'),('X,Y,Z'),('Y,Z,A'),('Z,A,B');
+insert into t2 values ('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'),('0');
+insert into t2 values ('1,2'),('2,3'),('3,4'),('4,5'),('5,6'),('6,7'),('7,8'),('8,9'),('9,0'),('0,1');
+insert into t2 values ('1,2,3'),('2,3,4'),('3,4,5'),('4,5,6'),('5,6,7'),('6,7,8'),('7,8,9'),('8,9,0'),('9,0,1'),('0,1,2');
+select count(*) from t2;
+select * from t2 order by a;
+drop table t2;
+
+eval create table t3 (a set (
+'1','2','3','4','5','6','7','8','9','0'
+) not null, primary key(a)) engine=$engine
+partition by range (cast(a as unsigned)) subpartition by key (a) subpartitions 3 (
+partition pa9 values less than (10),
+partition pa18 values less than (19),
+partition pa27 values less than (28),
+partition pa36 values less than (37),
+partition pa64 values less than (65),
+partition pa128 values less than (129),
+partition pa256 values less than (257),
+partition pa512 values less than (513),
+partition pa768 values less than (769),
+partition pa1024 values less than (1025)
+);
+show create table t3;
+#insert into t3 values ('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'),('0');
+#insert into t3 values ('1,2'),('2,3'),('3,4'),('4,5'),('5,6'),('6,7'),('7,8'),('8,9'),('9,0'),('0,1');
+#insert into t3 values ('1,2,3'),('2,3,4'),('3,4,5'),('4,5,6'),('5,6,7'),('6,7,8'),('7,8,9'),('8,9,0'),('9,0,1'),('0,1,2');
+select count(*) from t3;
+select * from t3 order by a;
+drop table t3;
+
+eval create table t4 (a set (
+'1','2','3') not null, primary key(a)) engine=$engine
+partition by list (cast(a as unsigned)) subpartition by key (a) subpartitions 3 (
+partition pa9 values in (1,2,3,4,5,6,7,8,9),
+partition pa18 values in (10,11,12,13,14,15,16,17,18),
+partition pa27 values in (19,20,21,22,23,24,25,26,27)
+);
+show create table t4;
+#insert into t4 values ('1'),('2'),('3');
+#insert into t4 values ('1,2'),('2,3'),('3,1');
+#insert into t4 values ('1,2,3');
+select count(*) from t4;
+select * from t4 order by a;
+drop table t4;
diff --git a/mysql-test/suite/parts/inc/partition_smallint.inc b/mysql-test/suite/parts/inc/partition_smallint.inc
new file mode 100644
index 00000000000..c594cd4c26c
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_smallint.inc
@@ -0,0 +1,56 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a smallint unsigned not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values (65535), (65534), (65533), (65532), (1), (2), (256);
+select * from t1;
+select * from t1 where a=65533;
+delete from t1 where a=65533;
+select * from t1;
+drop table t1;
+
+eval create table t2 (a smallint unsigned not null, primary key(a)) engine=$engine
+partition by key (a) partitions 8;
+show create table t2;
+insert into t2 values (65535), (65534), (65533), (65532);
+select * from t2;
+select * from t2 where a=65533;
+delete from t2 where a=65533;
+select * from t2;
+delete from t2;
+let $count=$maxrows;
+--echo $count inserts;
+--disable_query_log
+while ($count)
+{
+eval insert into t2 values ($count);
+dec $count;
+}
+--enable_query_log
+select count(*) from t2;
+drop table t2;
+
+eval create table t3 (a smallint not null, primary key(a)) engine=$engine
+partition by key (a) partitions 10;
+show create table t3;
+insert into t3 values (32767), (32766), (32765), (32764), (-32768), (-32767), (1), (-1), (0);
+select * from t3;
+select * from t3 where a=32765;
+delete from t3 where a=32765;
+select * from t3;
+drop table t3;
diff --git a/mysql-test/suite/parts/inc/partition_supported_sql_funcs.inc b/mysql-test/suite/parts/inc/partition_supported_sql_funcs.inc
new file mode 100644
index 00000000000..a26e6650893
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_supported_sql_funcs.inc
@@ -0,0 +1,270 @@
+################################################################################
+# t/partition_supported_sql_funcs.inc # # #
+# Purpose: #
+# Tests frame for allowed sql functions #
+# #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: HH #
+# Original Date: 2006-11-22 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+--echo -------------------------------------------------------------------------
+--echo --- $sqlfunc in partition with coltype $coltype
+--echo -------------------------------------------------------------------------
+--disable_abort_on_error
+--disable_warnings
+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 ;
+--enable_warnings
+--enable_abort_on_error
+
+--echo -------------------------------------------------------------------------
+--echo --- Create tables with $sqlfunc
+--echo -------------------------------------------------------------------------
+eval create table t1 (col1 $coltype) engine=$engine
+partition by range($sqlfunc)
+(partition p0 values less than (15),
+ partition p1 values less than maxvalue);
+
+eval create table t2 (col1 $coltype) engine=$engine
+partition by list($sqlfunc)
+(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)
+);
+
+eval create table t3 (col1 $coltype) engine=$engine
+partition by hash($sqlfunc);
+
+eval create table t4 (colint int, col1 $coltype) engine=$engine
+partition by range(colint)
+subpartition by hash($sqlfunc) subpartitions 2
+(partition p0 values less than (15),
+ partition p1 values less than maxvalue);
+
+eval create table t5 (colint int, col1 $coltype) engine=$engine
+partition by list(colint)
+subpartition by hash($sqlfunc) 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)
+);
+
+eval create table t6 (colint int, col1 $coltype) engine=$engine
+partition by range(colint)
+(partition p0 values less than ($valsqlfunc),
+ partition p1 values less than maxvalue);
+
+--echo -------------------------------------------------------------------------
+--echo --- Access tables with $sqlfunc
+--echo -------------------------------------------------------------------------
+
+eval insert into t1 values ($val1);
+eval insert into t1 values ($val2);
+
+eval insert into t2 values ($val1);
+eval insert into t2 values ($val2);
+eval insert into t2 values ($val3);
+
+eval insert into t3 values ($val1);
+eval insert into t3 values ($val2);
+eval insert into t3 values ($val3);
+
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+eval load data infile '$MYSQL_TEST_DIR/suite/parts/inc/$infile' into table t4;
+
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+eval load data infile '$MYSQL_TEST_DIR/suite/parts/inc/$infile' into table t5;
+
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+eval load data infile '$MYSQL_TEST_DIR/suite/parts/inc/$infile' into table t6;
+
+eval select $sqlfunc from t1 order by col1;
+
+select * from t1 order by col1;
+select * from t2 order by col1;
+select * from t3 order by col1;
+select * from t4 order by colint;
+select * from t5 order by colint;
+select * from t6 order by colint;
+
+if ($do_long_tests)
+{
+ eval update t1 set col1=$val4 where col1=$val1;
+ eval update t2 set col1=$val4 where col1=$val1;
+ eval update t3 set col1=$val4 where col1=$val1;
+ eval update t4 set col1=$val4 where col1=$val1;
+ eval update t5 set col1=$val4 where col1=$val1;
+ eval update t6 set col1=$val4 where col1=$val1;
+
+ select * from t1 order by col1;
+ select * from t2 order by col1;
+ select * from t3 order by col1;
+ select * from t4 order by colint;
+ select * from t5 order by colint;
+ select * from t6 order by colint;
+}
+
+--echo -------------------------------------------------------------------------
+--echo --- Alter tables with $sqlfunc
+--echo -------------------------------------------------------------------------
+
+--disable_abort_on_error
+--disable_warnings
+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 ;
+--enable_warnings
+--enable_abort_on_error
+
+eval create table t11 engine=$engine as select * from t1;
+eval create table t22 engine=$engine as select * from t2;
+eval create table t33 engine=$engine as select * from t3;
+eval create table t44 engine=$engine as select * from t4;
+eval create table t55 engine=$engine as select * from t5;
+eval create table t66 engine=$engine as select * from t6;
+eval alter table t11
+partition by range($sqlfunc)
+(partition p0 values less than (15),
+ partition p1 values less than maxvalue);
+eval alter table t22
+partition by list($sqlfunc)
+(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)
+);
+eval alter table t33
+partition by hash($sqlfunc);
+eval alter table t44
+partition by range(colint)
+subpartition by hash($sqlfunc) subpartitions 2
+(partition p0 values less than (15),
+ partition p1 values less than maxvalue);
+eval alter table t55
+partition by list(colint)
+subpartition by hash($sqlfunc) 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)
+);
+eval alter table t66
+partition by range(colint)
+(partition p0 values less than ($valsqlfunc),
+ partition p1 values less than maxvalue);
+
+select * from t11 order by col1;
+select * from t22 order by col1;
+select * from t33 order by col1;
+select * from t44 order by colint;
+select * from t55 order by colint;
+select * from t66 order by colint;
+
+if ($do_long_tests)
+{
+ --echo ---------------------------
+ --echo ---- some alter table begin
+ --echo ---------------------------
+ eval alter table t11
+ reorganize partition p0,p1 into
+ (partition s1 values less than maxvalue);
+ select * from t11 order by col1;
+
+ eval 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;
+
+eval alter table t55
+partition by list(colint)
+subpartition by hash($sqlfunc) 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;
+ select * from t55 order by colint;
+
+ eval alter table t66
+ reorganize partition p0,p1 into
+ (partition s1 values less than maxvalue);
+ select * from t66 order by colint;
+
+ eval alter table t66
+ reorganize partition s1 into
+ (partition p0 values less than ($valsqlfunc),
+ partition p1 values less than maxvalue);
+ select * from t66 order by colint;
+
+ eval alter table t66
+ reorganize partition p0,p1 into
+ (partition s1 values less than maxvalue);
+ select * from t66 order by colint;
+
+ eval alter table t66
+ reorganize partition s1 into
+ (partition p0 values less than ($valsqlfunc),
+ partition p1 values less than maxvalue);
+ select * from t66 order by colint;
+
+ let $t1=t1;
+ let $t2=t2;
+ let $t3=t3;
+ let $t4=t4;
+ let $t5=t5;
+ let $t6=t6;
+ --source suite/parts/inc/part_supported_sql_funcs_delete.inc
+ # --source include/part_supported_sql_funcs_delete.inc
+
+ let $t1=t11;
+ let $t2=t22;
+ let $t3=t33;
+ let $t4=t44;
+ let $t5=t55;
+ let $t6=t66;
+ --source suite/parts/inc/part_supported_sql_funcs_delete.inc
+ # --source include/part_supported_sql_funcs_delete.inc
+ --echo -------------------------
+ --echo ---- some alter table end
+ --echo -------------------------
+}
+--disable_warnings
+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 ;
+--enable_warnings
+
diff --git a/mysql-test/suite/parts/inc/partition_syntax.inc b/mysql-test/suite/parts/inc/partition_syntax.inc
new file mode 100644
index 00000000000..3c53861b95b
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_syntax.inc
@@ -0,0 +1,811 @@
+################################################################################
+# include/partition_syntax.inc #
+# #
+# Purpose: #
+# Tests around Create partitioned tables syntax #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+# FIXME Implement testcases, where it is checked that all create and
+# alter table statements
+# - with missing mandatory parameters are rejected
+# - with optional parameters are accepted
+# - with wrong combinations of optional parameters are rejected
+# - ............
+
+--echo
+--echo #========================================================================
+--echo # 1. Any PRIMARY KEYs or UNIQUE INDEXes must contain the columns used
+--echo # within the partitioning functions
+--echo #========================================================================
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+#
+--echo #------------------------------------------------------------------------
+--echo # 1.1 column of partitioning function not included in PRIMARY KEY
+--echo # PARTITION BY HASH/KEY/LIST/RANGE
+--echo #------------------------------------------------------------------------
+#----------- PARTITION BY HASH
+--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+eval CREATE TABLE t1 (
+$column_list,
+PRIMARY KEY (f_int2)
+)
+PARTITION BY HASH(f_int1) PARTITIONS 2;
+--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+eval CREATE TABLE t1 (
+$column_list,
+PRIMARY KEY (f_int2)
+)
+PARTITION BY HASH(f_int1 + f_int2) PARTITIONS 2;
+#----------- PARTITION BY KEY
+--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+eval CREATE TABLE t1 (
+$column_list,
+PRIMARY KEY (f_int2)
+)
+PARTITION BY KEY(f_int1) PARTITIONS 2;
+--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+eval CREATE TABLE t1 (
+$column_list,
+PRIMARY KEY (f_int2)
+)
+PARTITION BY KEY(f_int1,f_int2) PARTITIONS 2;
+#----------- PARTITION BY LIST
+--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+eval CREATE TABLE t1 (
+$column_list,
+PRIMARY KEY (f_int2)
+)
+PARTITION BY LIST(f_int1)
+(PARTITION part1 VALUES IN (1));
+--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+eval CREATE TABLE t1 (
+$column_list,
+PRIMARY KEY (f_int2)
+)
+PARTITION BY LIST(f_int1 + f_int2)
+(PARTITION part1 VALUES IN (1));
+#----------- PARTITION BY RANGE
+--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+eval CREATE TABLE t1 (
+$column_list,
+PRIMARY KEY (f_int2)
+)
+PARTITION BY RANGE(f_int1)
+(PARTITION part1 VALUES LESS THAN (1));
+--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+eval CREATE TABLE t1 (
+$column_list,
+PRIMARY KEY (f_int2)
+)
+PARTITION BY RANGE(f_int1 + f_int2)
+(PARTITION part1 VALUES LESS THAN (1));
+
+#
+--echo #------------------------------------------------------------------------
+--echo # 1.2 column of partitioning function not included in UNIQUE INDEX
+--echo # PARTITION BY HASH/KEY/LIST/RANGE
+--echo # Variant a) Without additional PRIMARY KEY
+--echo # Variant b) With correct additional PRIMARY KEY
+--echo # Variant 1) one column in partitioning function
+--echo # Variant 2) two columns in partitioning function
+--echo #------------------------------------------------------------------------
+# Note: If the CREATE TABLE statement contains no PRIMARY KEY but
+# UNIQUE INDEXes the MySQL layer tells the storage to use
+# the first UNIQUE INDEX as PRIMARY KEY.
+
+let $unique_index= UNIQUE INDEX (f_int2);
+
+#----------- PARTITION BY HASH
+let $partition_scheme= PARTITION BY HASH(f_int1) PARTITIONS 2;
+--source suite/parts/inc/partition_syntax_2.inc
+# --source include/partition_syntax_2.inc
+let $partition_scheme= PARTITION BY HASH(f_int1 + f_int2) PARTITIONS 2;
+--source suite/parts/inc/partition_syntax_2.inc
+# --source include/partition_syntax_2.inc
+#----------- PARTITION BY KEY
+let $partition_scheme= PARTITION BY KEY(f_int1) PARTITIONS 2;
+--source suite/parts/inc/partition_syntax_2.inc
+# --source include/partition_syntax_2.inc
+let $partition_scheme= PARTITION BY KEY(f_int1,f_int2) PARTITIONS 2;
+--source suite/parts/inc/partition_syntax_2.inc
+# --source include/partition_syntax_2.inc
+#----------- PARTITION BY LIST
+let $partition_scheme= PARTITION BY LIST(MOD(f_int1,3))
+ (PARTITION partN VALUES IN (NULL),
+ PARTITION part0 VALUES IN (0),
+ PARTITION part1 VALUES IN (1),
+ PARTITION part2 VALUES IN (2));
+--source suite/parts/inc/partition_syntax_2.inc
+# --source include/partition_syntax_2.inc
+let $partition_scheme= PARTITION BY LIST(MOD(f_int1 + f_int2,3))
+ (PARTITION partN VALUES IN (NULL),
+ PARTITION part0 VALUES IN (0),
+ PARTITION part1 VALUES IN (1),
+ PARTITION part2 VALUES IN (2));
+--source suite/parts/inc/partition_syntax_2.inc
+# --source include/partition_syntax_2.inc
+#----------- PARTITION BY RANGE
+let $partition_scheme= PARTITION BY RANGE(f_int1)
+ (PARTITION part1 VALUES LESS THAN (1),
+ PARTITION part2 VALUES LESS THAN (2147483646));
+--source suite/parts/inc/partition_syntax_2.inc
+# --source include/partition_syntax_2.inc
+let $partition_scheme= PARTITION BY RANGE(f_int1 + f_int2)
+ (PARTITION part1 VALUES LESS THAN (1),
+ PARTITION part2 VALUES LESS THAN (2147483646));
+--source suite/parts/inc/partition_syntax_2.inc
+# --source include/partition_syntax_2.inc
+
+#
+--echo #------------------------------------------------------------------------
+--echo # 1.3 column of subpartitioning function not included in PRIMARY KEY
+--echo # PARTITION BY RANGE/LIST -- SUBPARTITION BY HASH/KEY
+--echo #------------------------------------------------------------------------
+
+#----------- PARTITION BY RANGE -- SUBPARTITION BY HASH
+--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+eval CREATE TABLE t1 (
+$column_list,
+PRIMARY KEY (f_int2)
+)
+PARTITION BY RANGE(f_int2) SUBPARTITION BY HASH(f_int1)
+(PARTITION part1 VALUES LESS THAN (1)
+ (SUBPARTITION subpart1));
+#----------- PARTITION BY RANGE -- SUBPARTITION BY KEY
+--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+eval CREATE TABLE t1 (
+$column_list,
+PRIMARY KEY (f_int2)
+)
+PARTITION BY RANGE(f_int2) SUBPARTITION BY KEY(f_int1)
+(PARTITION part1 VALUES LESS THAN (1)
+ (SUBPARTITION subpart1));
+#----------- PARTITION BY LIST -- SUBPARTITION BY HASH
+--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+eval CREATE TABLE t1 (
+$column_list,
+PRIMARY KEY (f_int2)
+)
+PARTITION BY LIST(f_int2) SUBPARTITION BY HASH(f_int1)
+(PARTITION part1 VALUES IN (1)
+ (SUBPARTITION subpart1));
+#----------- PARTITION BY LIST -- SUBPARTITION BY KEY
+--error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+eval CREATE TABLE t1 (
+$column_list,
+PRIMARY KEY (f_int2)
+)
+PARTITION BY LIST(f_int2) SUBPARTITION BY KEY(f_int1)
+(PARTITION part1 VALUES IN (1)
+ (SUBPARTITION subpart1));
+
+#
+--echo #------------------------------------------------------------------------
+--echo # 1.4 column of subpartitioning function not included in UNIQUE INDEX
+--echo # PARTITION BY RANGE/LIST -- SUBPARTITION BY HASH/KEY
+--echo # Variant a) Without additional PRIMARY KEY
+--echo # Variant b) With correct additional PRIMARY KEY
+--echo #------------------------------------------------------------------------
+let $partition_scheme= PARTITION BY RANGE(f_int2)
+SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 3
+ (PARTITION part1 VALUES LESS THAN (1),
+ PARTITION part2 VALUES LESS THAN (2147483646));
+--source suite/parts/inc/partition_syntax_2.inc
+# --source include/partition_syntax_2.inc
+#----------- PARTITION BY RANGE -- SUBPARTITION BY KEY
+let $partition_scheme= PARTITION BY RANGE(f_int2)
+SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 3
+ (PARTITION part1 VALUES LESS THAN (1),
+ PARTITION part2 VALUES LESS THAN (2147483646));
+--source suite/parts/inc/partition_syntax_2.inc
+# --source include/partition_syntax_2.inc
+#----------- PARTITION BY LIST -- SUBPARTITION BY HASH
+let $partition_scheme= PARTITION BY LIST(MOD(f_int2,3))
+SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2
+ (PARTITION partN VALUES IN (NULL),
+ PARTITION part0 VALUES IN (0),
+ PARTITION part1 VALUES IN (1),
+ PARTITION part2 VALUES IN (2));
+--source suite/parts/inc/partition_syntax_2.inc
+# --source include/partition_syntax_2.inc
+#----------- PARTITION BY LIST -- SUBPARTITION BY KEY
+let $partition_scheme= PARTITION BY LIST(MOD(f_int2,3))
+SUBPARTITION BY KEY(f_int1) SUBPARTITIONS 2
+ (PARTITION partN VALUES IN (NULL),
+ PARTITION part0 VALUES IN (0),
+ PARTITION part1 VALUES IN (1),
+ PARTITION part2 VALUES IN (2));
+--source suite/parts/inc/partition_syntax_2.inc
+# --source include/partition_syntax_2.inc
+
+--echo
+--echo #========================================================================
+--echo # 2 Some properties around subpartitioning
+--echo #========================================================================
+--echo #------------------------------------------------------------------------
+--echo # 2.1 Subpartioned table without subpartitioning rule must be rejected
+--echo #------------------------------------------------------------------------
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+# Bug#15961 Partitions: Creation of subpart. table without subpart. rule not rejected
+--error ER_SUBPARTITION_ERROR
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+( PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11));
+--echo #------------------------------------------------------------------------
+--echo # 2.2 Every partition must have the same number of subpartitions.
+--echo # This is a limitation of MySQL 5.1, which could be removed in
+--echo # later releases.
+--echo #------------------------------------------------------------------------
+--error 1064
+eval CREATE TABLE t1 (
+$column_list,
+PRIMARY KEY (f_int1)
+)
+PARTITION BY RANGE(f_int1) SUBPARTITION BY KEY(f_int1)
+(
+ PARTITION part1 VALUES LESS THAN (0)
+ (SUBPARTITION subpart1),
+ PARTITION part2 VALUES LESS THAN ($max_row_div4)
+ (SUBPARTITION subpart1, SUBPARTITION subpart2));
+
+--echo
+--echo #========================================================================
+--echo # 3 VALUES clauses
+--echo #========================================================================
+--echo #------------------------------------------------------------------------
+--echo # 3.1 The constants in VALUES IN clauses must differ
+--echo #------------------------------------------------------------------------
+--error ER_MULTIPLE_DEF_CONST_IN_LIST_PART_ERROR
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY LIST(MOD(f_int1,2))
+( PARTITION part1 VALUES IN (-1),
+ PARTITION part2 VALUES IN (0),
+ PARTITION part3 VALUES IN (-1));
+# constant followed by the same constant
+--error ER_RANGE_NOT_INCREASING_ERROR
+CREATE TABLE t1 (f1 BIGINT, f2 BIGINT)
+PARTITION BY RANGE(f1)
+(PARTITION part1 VALUES LESS THAN (0),
+PARTITION part2 VALUES LESS THAN (0),
+PARTITION part3 VALUES LESS THAN (10000));
+
+--echo #------------------------------------------------------------------------
+--echo # 3.2 The constants in VALUES LESS must be in increasing order
+--echo #------------------------------------------------------------------------
+# constant followed somewhere by the smaller constant
+--error ER_RANGE_NOT_INCREASING_ERROR
+CREATE TABLE t1 (f1 BIGINT, f2 BIGINT)
+PARTITION BY RANGE(f1)
+(PARTITION part1 VALUES LESS THAN (0),
+PARTITION part2 VALUES LESS THAN (-1),
+PARTITION part3 VALUES LESS THAN (10000));
+
+--echo #------------------------------------------------------------------------
+--echo # 3.3 LIST partitions must be defined with VALUES IN
+--echo #------------------------------------------------------------------------
+--error ER_PARTITION_WRONG_VALUES_ERROR
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY LIST(MOD(f_int1,2))
+( PARTITION part1 VALUES LESS THAN (-1),
+ PARTITION part2 VALUES LESS THAN (0),
+ PARTITION part3 VALUES LESS THAN (1000));
+
+--echo #------------------------------------------------------------------------
+--echo # 3.4 RANGE partitions must be defined with VALUES LESS THAN
+--echo #------------------------------------------------------------------------
+--error ER_PARTITION_WRONG_VALUES_ERROR
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+( PARTITION part1 VALUES IN (-1),
+ PARTITION part2 VALUES IN (0),
+ PARTITION part3 VALUES IN (1000));
+
+--echo #------------------------------------------------------------------------
+--echo # 3.5 Use of NULL in VALUES clauses
+--echo #------------------------------------------------------------------------
+--echo # 3.5.1 NULL in RANGE partitioning clause
+--echo # 3.5.1.1 VALUE LESS THAN (NULL) is not allowed
+--error 1064
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+( PARTITION part1 VALUES LESS THAN (NULL),
+ PARTITION part2 VALUES LESS THAN (1000));
+--echo # 3.5.1.2 VALUE LESS THAN (CAST(NULL AS SIGNED INTEGER)) is not allowed
+--error 1064
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+( PARTITION part1 VALUES LESS THAN (CAST(NULL AS SIGNED INTEGER)),
+ PARTITION part2 VALUES LESS THAN (1000));
+--echo # 3.5.2 NULL in LIST partitioning clause
+--echo # 3.5.2.1 VALUE IN (NULL)
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY LIST(MOD(f_int1,2))
+( PARTITION part1 VALUES IN (NULL),
+ PARTITION part2 VALUES IN (0),
+ PARTITION part3 VALUES IN (1));
+DROP TABLE t1;
+--echo # 3.5.2.2 VALUE IN (CAST(NULL AS SIGNED INTEGER))
+# Attention: It is intended that there is no partition with
+# VALUES IN (0), because there was a time where NULL was treated as zero
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY LIST(MOD(f_int1,2))
+( PARTITION part1 VALUES IN (CAST(NULL AS SIGNED INTEGER)),
+ PARTITION part3 VALUES IN (1));
+--source suite/parts/inc/partition_layout_check1.inc
+# --source include/partition_layout_check1.inc
+DROP TABLE t1;
+--echo # 3.5.3 Reveal that IN (...NULL) is not mapped to IN(0)
+# Bug#15447: Partitions: NULL is treated as zero
+# We would get a clash here if such a mapping would be done.
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY LIST(MOD(f_int1,2))
+( PARTITION part1 VALUES IN (CAST(NULL AS SIGNED INTEGER)),
+ PARTITION part2 VALUES IN (0),
+ PARTITION part3 VALUES IN (1));
+--source suite/parts/inc/partition_layout_check1.inc
+# --source include/partition_layout_check1.inc
+DROP TABLE t1;
+
+# FIXME Implement some non integer constant tests
+
+
+--echo
+--echo #========================================================================
+--echo # 4. Check assigning the number of partitions and subpartitions
+--echo # with and without named partitions/subpartitions
+--echo #========================================================================
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+--echo #------------------------------------------------------------------------
+--echo # 4.1 (positive) without partition/subpartition number assignment
+--echo #------------------------------------------------------------------------
+--echo # 4.1.1 no partition number, no named partitions
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY HASH(f_int1);
+--source suite/parts/inc/partition_layout_check1.inc
+# --source include/partition_layout_check1.inc
+DROP TABLE t1;
+--echo # 4.1.2 no partition number, named partitions
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY HASH(f_int1) (PARTITION part1, PARTITION part2);
+--source suite/parts/inc/partition_layout_check1.inc
+# --source include/partition_layout_check1.inc
+DROP TABLE t1;
+# Attention: Several combinations are impossible
+# If subpartitioning exists
+# - partitioning algorithm must be RANGE or LIST
+# This implies the assignment of named partitions.
+# - subpartitioning algorithm must be HASH or KEY
+--echo # 4.1.3 variations on no partition/subpartition number, named partitions,
+--echo # different subpartitions are/are not named
+#
+# Partition name -- "properties"
+# part1 -- first/non last
+# part2 -- non first/non last
+# part3 -- non first/ last
+#
+# Testpattern:
+# named subpartitions in
+# Partition part1 part2 part3
+# N N N
+# N N Y
+# N Y N
+# N Y Y
+# Y N N
+# Y N Y
+# Y Y N
+# Y Y Y
+--disable_query_log
+let $part01= CREATE TABLE t1 ( ;
+let $part02= )
+PARTITION BY RANGE(f_int1) SUBPARTITION BY HASH(f_int1);
+#
+eval SET @aux = '(PARTITION part1 VALUES LESS THAN ($max_row_div2),';
+let $part1_N= `SELECT @AUX`;
+eval SET @aux = '(PARTITION part1 VALUES LESS THAN ($max_row_div2)
+(SUBPARTITION subpart11 , SUBPARTITION subpart12 ),';
+let $part1_Y= `SELECT @AUX`;
+#
+eval SET @aux = 'PARTITION part2 VALUES LESS THAN ($max_row),';
+let $part2_N= `SELECT @AUX`;
+eval SET @aux = 'PARTITION part2 VALUES LESS THAN ($max_row)
+(SUBPARTITION subpart21 , SUBPARTITION subpart22 ),';
+let $part2_Y= `SELECT @AUX`;
+#
+eval SET @aux = 'PARTITION part3 VALUES LESS THAN $MAX_VALUE)';
+let $part3_N= `SELECT @AUX`;
+eval SET @aux = 'PARTITION part3 VALUES LESS THAN $MAX_VALUE
+(SUBPARTITION subpart31 , SUBPARTITION subpart32 ))';
+let $part3_Y= `SELECT @AUX`;
+--enable_query_log
+
+eval $part01 $column_list $part02 $part1_N $part2_N $part3_N ;
+DROP TABLE t1;
+# Bug#15407 Partitions: crash if subpartition
+--error 1064
+eval $part01 $column_list $part02 $part1_N $part2_N $part3_Y ;
+--error 1064
+eval $part01 $column_list $part02 $part1_N $part2_Y $part3_N ;
+--error 1064
+eval $part01 $column_list $part02 $part1_N $part2_Y $part3_Y ;
+--error 1064
+eval $part01 $column_list $part02 $part1_Y $part2_N $part3_N ;
+--error 1064
+eval $part01 $column_list $part02 $part1_Y $part2_N $part3_Y ;
+--error 1064
+eval $part01 $column_list $part02 $part1_Y $part2_Y $part3_N ;
+eval $part01 $column_list $part02 $part1_Y $part2_Y $part3_Y ;
+--source suite/parts/inc/partition_layout_check1.inc
+# --source include/partition_layout_check1.inc
+DROP TABLE t1;
+
+--echo #------------------------------------------------------------------------
+--echo # 4.2 partition/subpartition numbers good and bad values and notations
+--echo #------------------------------------------------------------------------
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+--echo # 4.2.1 partition/subpartition numbers INTEGER notation
+# ML: "positive/negative" is my private judgement. It need no to correspond
+# with the server response.
+# (positive) number = 2
+let $part_number= 2;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (positive) special case number = 1
+let $part_number= 1;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative) 0 is non sense
+let $part_number= 0;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative) -1 is non sense
+let $part_number= -1;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative) 1000000 is too huge
+let $part_number= 1000000;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+
+--echo # 4.2.2 partition/subpartition numbers DECIMAL notation
+# (positive) number = 2.0
+let $part_number= 2.0;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative) -2.0 is non sense
+let $part_number= -2.0;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative) case number = 0.0 is non sense
+let $part_number= 0.0;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+if ($fixed_bug15890)
+{
+# Bug#15890 Partitions: Strange interpretation of partition number
+# (negative) number = 1.6 is non sense
+let $part_number= 1.6;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+}
+# (negative) number is too huge
+let $part_number= 999999999999999999999999999999.999999999999999999999999999999;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative) number is nearly zero
+let $part_number= 0.000000000000000000000000000001;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+
+--echo # 4.2.3 partition/subpartition numbers FLOAT notation
+##### FLOAT notation
+# (positive) number = 2.0E+0
+let $part_number= 2.0E+0;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+if ($fixed_bug15890)
+{
+# Bug#15890 Partitions: Strange interpretation of partition number
+# (positive) number = 0.2E+1
+let $part_number= 0.2E+1;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+}
+# (negative) -2.0E+0 is non sense
+let $part_number= -2.0E+0;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+if ($fixed_bug15890)
+{
+# Bug#15890 Partitions: Strange interpretation of partition number
+# (negative) 0.16E+1 is non sense
+let $part_number= 0.16E+1;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+}
+# (negative) 0.0E+300 is zero
+let $part_number= 0.0E+300;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+if ($fixed_bug15890)
+{
+# Bug#15890 Partitions: Strange interpretation of partition number
+# (negative) 1E+300 is too huge
+let $part_number= 1E+300;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative) 1E-300 is nearly zero
+let $part_number= 1E-300;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+}
+
+--echo # 4.2.4 partition/subpartition numbers STRING notation
+##### STRING notation
+# (negative?) case number = '2'
+let $part_number= '2';
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative?) case number = '2.0'
+let $part_number= '2.0';
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative?) case number = '0.2E+1'
+let $part_number= '0.2E+1';
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative) Strings starts with digit, but 'A' follows
+let $part_number= '2A';
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative) Strings starts with 'A', but digit follows
+let $part_number= 'A2';
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative) empty string
+let $part_number= '';
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative) string without any digits
+let $part_number= 'GARBAGE';
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+
+--echo # 4.2.5 partition/subpartition numbers other notations
+# (negative) Strings starts with digit, but 'A' follows
+let $part_number= 2A;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative) Strings starts with 'A', but digit follows
+let $part_number= A2;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative) string without any digits
+let $part_number= GARBAGE;
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+
+# (negative?) double quotes
+let $part_number= "2";
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative) Strings starts with digit, but 'A' follows
+let $part_number= "2A";
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative) Strings starts with 'A', but digit follows
+let $part_number= "A2";
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+# (negative) string without any digits
+let $part_number= "GARBAGE";
+--source suite/parts/inc/partition_syntax_1.inc
+# --source include/partition_syntax_1.inc
+
+--echo # 4.2.6 (negative) partition/subpartition numbers per @variables
+SET @aux = 5;
+--error 1064
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY HASH(f_int1) PARTITIONS @aux;
+--error 1064
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1) SUBPARTITION BY HASH(f_int1)
+SUBPARTITIONS @aux = 5
+(PARTITION part1 VALUES LESS THAN ($max_row_div2),
+ PARTITION part2 VALUES LESS THAN $MAX_VALUE);
+
+
+--echo #------------------------------------------------------------------------
+--echo # 4.3 Mixups of assigned partition/subpartition numbers and names
+--echo #------------------------------------------------------------------------
+--echo # 4.3.1 (positive) number of partition/subpartition
+--echo # = number of named partition/subpartition
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY HASH(f_int1) PARTITIONS 2 ( PARTITION part1, PARTITION part2 ) ;
+--source suite/parts/inc/partition_layout_check1.inc
+# --source include/partition_layout_check1.inc
+DROP TABLE t1;
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1) PARTITIONS 2
+SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2
+( PARTITION part1 VALUES LESS THAN (1000)
+ (SUBPARTITION subpart11, SUBPARTITION subpart12),
+ PARTITION part2 VALUES LESS THAN $MAX_VALUE
+ (SUBPARTITION subpart21, SUBPARTITION subpart22)
+);
+--source suite/parts/inc/partition_layout_check1.inc
+# --source include/partition_layout_check1.inc
+DROP TABLE t1;
+--echo # 4.3.2 (positive) number of partition/subpartition ,
+--echo # 0 (= no) named partition/subpartition
+--echo # already checked above
+--echo # 4.3.3 (negative) number of partitions/subpartitions
+--echo # > number of named partitions/subpartitions
+--error 1064
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY HASH(f_int1) PARTITIONS 2 ( PARTITION part1 ) ;
+# Wrong number of named subpartitions in first partition
+--error 1064
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2
+( PARTITION part1 VALUES LESS THAN (1000)
+ (SUBPARTITION subpart11 ),
+ PARTITION part2 VALUES LESS THAN $MAX_VALUE
+ (SUBPARTITION subpart21, SUBPARTITION subpart22)
+);
+# Wrong number of named subpartitions in non first/non last partition
+--error 1064
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2
+( PARTITION part1 VALUES LESS THAN (1000)
+ (SUBPARTITION subpart11, SUBPARTITION subpart12),
+ PARTITION part2 VALUES LESS THAN (2000)
+ (SUBPARTITION subpart21 ),
+ PARTITION part3 VALUES LESS THAN $MAX_VALUE
+ (SUBPARTITION subpart31, SUBPARTITION subpart32)
+);
+# Wrong number of named subpartitions in last partition
+--error 1064
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1) PARTITIONS 2
+SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 2
+( PARTITION part1 VALUES LESS THAN (1000)
+ (SUBPARTITION subpart11, SUBPARTITION subpart12),
+ PARTITION part2 VALUES LESS THAN $MAX_VALUE
+ (SUBPARTITION subpart21 )
+);
+--echo # 4.3.4 (negative) number of partitions < number of named partitions
+--error 1064
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY HASH(f_int1) PARTITIONS 1 ( PARTITION part1, PARTITION part2 ) ;
+# Wrong number of named subpartitions in first partition
+--error 1064
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 1
+( PARTITION part1 VALUES LESS THAN (1000)
+ (SUBPARTITION subpart11, SUBPARTITION subpart12),
+ PARTITION part2 VALUES LESS THAN $MAX_VALUE
+ (SUBPARTITION subpart21, SUBPARTITION subpart22)
+);
+# Wrong number of named subpartitions in non first/non last partition
+--error 1064
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 1
+( PARTITION part1 VALUES LESS THAN (1000)
+ (SUBPARTITION subpart11, SUBPARTITION subpart12),
+ PARTITION part2 VALUES LESS THAN (2000)
+ (SUBPARTITION subpart21 ),
+ PARTITION part3 VALUES LESS THAN $MAX_VALUE
+ (SUBPARTITION subpart31, SUBPARTITION subpart32)
+);
+# Wrong number of named subpartitions in last partition
+--error 1064
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+SUBPARTITION BY HASH(f_int1) SUBPARTITIONS 1
+( PARTITION part1 VALUES LESS THAN (1000)
+ (SUBPARTITION subpart11, SUBPARTITION subpart12),
+ PARTITION part2 VALUES LESS THAN $MAX_VALUE
+ (SUBPARTITION subpart21, SUBPARTITION subpart22)
+);
+
+
+--echo
+--echo #========================================================================
+--echo # 5. Checks of logical partition/subpartition name
+--echo # file name clashes during CREATE TABLE
+--echo #========================================================================
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo #------------------------------------------------------------------------
+--echo # 5.1 (negative) A partition/subpartition name used more than once
+--echo #------------------------------------------------------------------------
+--echo # 5.1.1 duplicate partition name
+--error ER_SAME_NAME_PARTITION
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY HASH(f_int1) (PARTITION part1, PARTITION part1);
+#
+--echo # 5.1.2 duplicate subpartition name
+# Bug#15408 Partitions: subpartition names are not unique
+--error ER_SAME_NAME_PARTITION
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1)
+SUBPARTITION BY HASH(f_int1)
+( PARTITION part1 VALUES LESS THAN (1000)
+ (SUBPARTITION subpart11, SUBPARTITION subpart11)
+);
+
+# FIXME Implement testcases with filename problems
+# existing file of other table --- partition/subpartition file name
+# partition/subpartition file name --- file of the same table
+
diff --git a/mysql-test/suite/parts/inc/partition_syntax_1.inc b/mysql-test/suite/parts/inc/partition_syntax_1.inc
new file mode 100644
index 00000000000..ac88b5ee668
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_syntax_1.inc
@@ -0,0 +1,91 @@
+################################################################################
+# include/partition_syntax_1.inc #
+# #
+# Purpose: #
+# Auxiliary script, only useful when sourced by include/partition_syntax.inc #
+# #
+# Try to create a table with number of partitions/subpartitions #
+# = $part_number. Print the layout of the table and drop it. #
+# #
+# The parameter $part_number must be set before sourcing this script. #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+--disable_abort_on_error
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY HASH(f_int1) PARTITIONS $part_number;
+--enable_abort_on_error
+--disable_query_log
+eval SET @my_errno= $mysql_errno ;
+let $run= `SELECT @my_errno = 0`;
+# Expected error codes are
+# 0
+# 1064 ERROR 42000: You have an error in your SQL syntax
+# Reason: assign -1 partitions
+# 1486 ERROR HY000: Too many partitions (including subpartitions) were defined
+# 1491 ERROR HY000: Number of partitions = 0 is not an allowed value
+let $unexpected_error= `SELECT @my_errno NOT IN (0,1064,1487,1492)`;
+if ($unexpected_error)
+{
+ --echo # The last command got an unexepected error response.
+ --echo # Expected/handled SQL codes are 0,1064,1487,1492
+ SELECT '# SQL code we got was: ' AS "", @my_errno AS "";
+ --echo # Sorry, have to abort.
+ exit;
+ --echo
+}
+--enable_query_log
+#
+# If this operation was successfull, print layout + drop this table
+if ($run)
+{
+ --source suite/parts/inc/partition_layout_check1.inc
+ # --source include/partition_layout_check1.inc
+ eval DROP TABLE t1;
+}
+#### Try to create a table with the given subpartition number
+--disable_abort_on_error
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(f_int1) SUBPARTITION BY HASH(f_int1)
+SUBPARTITIONS $part_number
+(PARTITION part1 VALUES LESS THAN ($max_row_div2),
+ PARTITION part2 VALUES LESS THAN $MAX_VALUE);
+--enable_abort_on_error
+--disable_query_log
+eval SET @my_errno= $mysql_errno ;
+let $run= `SELECT @my_errno = 0`;
+# Expected error codes are
+# 0
+# 1064 ERROR 42000: You have an error in your SQL syntax
+# Reason: assign -1 subpartitions
+# 1487 ERROR HY000: Too many partitions (including subpartitions) were defined
+# 1492 ERROR HY000: Number of partitions = 0 is not an allowed value
+let $unexpected_error= `SELECT @my_errno NOT IN (0,1064,1487,1492)`;
+if ($unexpected_error)
+{
+ --echo # The last command got an unexepected error response.
+ --echo # Expected/handled SQL codes are 0,1064,1487,1492
+ SELECT '# SQL code we got was: ' AS "", @my_errno AS "";
+ --echo # Sorry, have to abort.
+ exit;
+ --echo
+}
+--enable_query_log
+#
+# If this operation was successfull, print layout + drop this table
+if ($run)
+{
+ --source suite/parts/inc/partition_layout_check1.inc
+ # --source include/partition_layout_check1.inc
+ eval DROP TABLE t1;
+}
diff --git a/mysql-test/suite/parts/inc/partition_syntax_2.inc b/mysql-test/suite/parts/inc/partition_syntax_2.inc
new file mode 100644
index 00000000000..9adf1c9b2a0
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_syntax_2.inc
@@ -0,0 +1,56 @@
+################################################################################
+# include/partition_syntax_2.inc #
+# #
+# Purpose: #
+# Auxiliary script, only useful when sourced by include/partition_syntax.inc.#
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-05-11 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+if (`SELECT @@session.storage_engine NOT IN('ndbcluster')`)
+{
+ --error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+ eval CREATE TABLE t1 (
+ $column_list,
+ $unique_index
+ )
+ $partition_scheme;
+ --error ER_UNIQUE_KEY_NEED_ALL_FIELDS_IN_PF
+ eval CREATE TABLE t1 (
+ $column_list,
+ PRIMARY KEY(f_int1,f_int2), $unique_index
+ )
+ $partition_scheme;
+}
+if (`SELECT @@session.storage_engine IN('ndbcluster')`)
+{
+ eval CREATE TABLE t1 (
+ $column_list,
+ $unique_index
+ )
+ $partition_scheme;
+ eval $insert_all;
+ if ($fixed_bug18735)
+ {
+ --source suite/parts/inc/partition_check.inc
+ # --source include/partition_check.inc
+ }
+ DROP TABLE t1;
+ eval CREATE TABLE t1 (
+ $column_list,
+ PRIMARY KEY(f_int1,f_int2), $unique_index
+ )
+ $partition_scheme;
+ eval $insert_all;
+ if ($fixed_bug18735)
+ {
+ --source suite/parts/inc/partition_check.inc
+ # --source include/partition_check.inc
+ }
+ DROP TABLE t1;
+}
diff --git a/mysql-test/suite/parts/inc/partition_text.inc b/mysql-test/suite/parts/inc/partition_text.inc
new file mode 100644
index 00000000000..a655552c457
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_text.inc
@@ -0,0 +1,56 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+--error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
+eval create table t1 (a text not null, primary key(a(767))) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+
+#show create table t1;
+#insert into t1 values (repeat('a',1000)), ('b'), (repeat('a',500)), (repeat('b',64));
+#select * from t1;
+#select * from t1 where a='b';
+#update t1 set a='bb' where a='b';
+#delete from t1 where a='bb';
+#select * from t1;
+#drop table t1;
+
+--error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
+eval create table t2 (a tinytext not null, primary key(a(767))) engine=$engine
+partition by key (a) partitions 30;
+
+--error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
+eval create table t2 (a mediumtext not null, primary key(a(767))) engine=$engine
+partition by key (a) partitions 30;
+
+--error ER_BLOB_FIELD_IN_PART_FUNC_ERROR
+eval create table t2 (a longtext not null, primary key(a(767))) engine=$engine
+partition by key (a) partitions 30;
+
+#show create table t2;
+#let $count=30;
+#let $letter=0;
+#--echo $count inserts;
+#--disable_query_log
+#while ($count)
+#{
+#eval insert into t2 values (repeat(char(ascii('a')+$letter),$count*$count));
+#dec $count;
+#inc $letter;
+#}
+#select count(*) from t2;
+#select * from t2;
+#drop table t2;
+
diff --git a/mysql-test/suite/parts/inc/partition_time.inc b/mysql-test/suite/parts/inc/partition_time.inc
new file mode 100644
index 00000000000..a3388bdc902
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_time.inc
@@ -0,0 +1,86 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a time not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values ('21:21:21'), ('12:10:30'), ('03:03:03'), ('23:59');
+select * from t1;
+select * from t1 where a=030303;
+delete from t1 where a=030303;
+select * from t1;
+drop table t1;
+
+eval create table t2 (a time not null, primary key(a)) engine=$engine
+partition by key (a) partitions 12;
+show create table t2;
+insert into t2 values ('0:1:1'), ('10:11:12'), ('13:14:15'), ('14:15:16');
+select * from t2;
+select * from t2 where a='13:14:15';
+delete from t2 where a='13:14:15';
+select * from t2;
+delete from t2;
+let $count=59;
+--echo $count inserts;
+#--disable_query_log
+while ($count)
+{
+eval insert into t2 values (000100+$count);
+dec $count;
+}
+select count(*) from t2;
+select * from t2;
+drop table t2;
+
+eval create table t3 (a time not null, primary key(a)) engine=$engine
+partition by range (cast(second(a) as unsigned)) subpartition by key (a)
+subpartitions 3 (
+partition quarter1 values less than (16),
+partition quarter2 values less than (31),
+partition quarter3 values less than (46),
+partition quarter4 values less than (61)
+);
+show create table t3;
+let $count=59;
+--echo $count inserts;
+while ($count)
+{
+eval insert into t3 values (100000+$count);
+dec $count;
+}
+select count(*) from t3;
+select * from t3;
+drop table t3;
+
+eval create table t4 (a time not null, primary key(a)) engine=$engine
+partition by list (cast(second(a) as unsigned)) subpartition by key (a)
+subpartitions 3 (
+partition quarter1 values in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15),
+partition quarter2 values in (16,17,18,19,20,21,22,23,24,25,26,27,28,29,30),
+partition quarter3 values in (31,32,33,34,35,36,37,38,39,40,41,42,43,44,45),
+partition quarter4 values in (46,47,48,49,50,51,52,53,54,55,56,57,58,59,60)
+);
+show create table t4;
+let $count=59;
+--echo $count inserts;
+while ($count)
+{
+eval insert into t4 values (100000+$count);
+dec $count;
+}
+select count(*) from t4;
+select * from t4;
+drop table t4;
diff --git a/mysql-test/suite/parts/inc/partition_timestamp.inc b/mysql-test/suite/parts/inc/partition_timestamp.inc
new file mode 100644
index 00000000000..44eb3b5bd55
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_timestamp.inc
@@ -0,0 +1,86 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a timestamp not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values ('1975-01-01 21:21:21'), ('2020-12-31 12:10:30'), ('1980-10-14 03:03'), ('2000-06-15 23:59');
+select * from t1;
+select * from t1 where a=19801014030300;
+delete from t1 where a=19801014030300;
+select * from t1;
+drop table t1;
+
+eval create table t2 (a timestamp not null, primary key(a)) engine=$engine
+partition by key (a) partitions 12;
+show create table t2;
+insert into t2 values ('1975-01-01 0:1:1'), ('2020-12-31 10:11:12'), ('1980-10-14 13:14:15'), ('2000-06-15 14:15:16');
+select * from t2;
+select * from t2 where a='1980-10-14 13:14:15';
+delete from t2 where a='1980-10-14 13:14:15';
+select * from t2;
+delete from t2;
+let $count=59;
+--echo $count inserts;
+#--disable_query_log
+while ($count)
+{
+eval insert into t2 values (19710101000000+$count);
+dec $count;
+}
+select count(*) from t2;
+select * from t2;
+drop table t2;
+
+eval create table t3 (a timestamp not null, primary key(a)) engine=$engine
+partition by range (cast(month(a) as unsigned)) subpartition by key (a)
+subpartitions 3 (
+partition quarter1 values less than (4),
+partition quarter2 values less than (7),
+partition quarter3 values less than (10),
+partition quarter4 values less than (13)
+);
+show create table t3;
+let $count=12;
+--echo $count inserts;
+while ($count)
+{
+eval insert into t3 values (date_add('1970-01-01 00:00:00',interval $count-1 month));
+dec $count;
+}
+select count(*) from t3;
+select * from t3;
+drop table t3;
+
+eval create table t4 (a timestamp not null, primary key(a)) engine=$engine
+partition by list (cast(month(a) as unsigned)) subpartition by key (a)
+subpartitions 3 (
+partition quarter1 values in (0,1,2,3),
+partition quarter2 values in (4,5,6),
+partition quarter3 values in (7,8,9),
+partition quarter4 values in (10,11,12)
+);
+show create table t4;
+let $count=12;
+--echo $count inserts;
+while ($count)
+{
+eval insert into t4 values (date_add('1970-01-01 00:00:00',interval $count-1 month));
+dec $count;
+}
+select count(*) from t4;
+select * from t4;
+drop table t4;
diff --git a/mysql-test/suite/parts/inc/partition_tinyint.inc b/mysql-test/suite/parts/inc/partition_tinyint.inc
new file mode 100644
index 00000000000..a1f8874e794
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_tinyint.inc
@@ -0,0 +1,56 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a tinyint unsigned not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values (255), (254), (253), (252), (1), (2), (128);
+select * from t1;
+select * from t1 where a=253;
+delete from t1 where a=253;
+select * from t1;
+drop table t1;
+
+eval create table t2 (a tinyint unsigned not null, primary key(a)) engine=$engine
+partition by key (a) partitions 8;
+show create table t2;
+insert into t2 values (255), (254), (253), (252);
+select * from t2;
+select * from t2 where a=253;
+delete from t2 where a=253;
+select * from t2;
+delete from t2;
+let $count=255;
+--echo 255 inserts;
+--disable_query_log
+while ($count)
+{
+eval insert into t2 values ($count);
+dec $count;
+}
+--enable_query_log
+select count(*) from t2;
+drop table t2;
+
+eval create table t3 (a tinyint not null, primary key(a)) engine=$engine
+partition by key (a) partitions 10;
+show create table t3;
+insert into t3 values (127), (126), (125), (124), (-128), (-127), (1), (-1), (0);
+select * from t3;
+select * from t3 where a=125;
+delete from t3 where a=125;
+select * from t3;
+drop table t3;
diff --git a/mysql-test/suite/parts/inc/partition_trigg1.inc b/mysql-test/suite/parts/inc/partition_trigg1.inc
new file mode 100644
index 00000000000..7ebf2f411d3
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_trigg1.inc
@@ -0,0 +1,115 @@
+################################################################################
+# include/partition_trigg1.inc #
+# #
+# Purpose: #
+# Auxiliary script, only useful when sourced by include/partition_check.inc. #
+# One trigger uses new values (--> event UPDATE, INSERT only) #
+# One trigger uses old values (--> event UPDATE, DELETE only) #
+# #
+# 1. Create a trigger #
+# 2. Execute a statement, which activates the trigger #
+# 3. Check the results of the trigger activity #
+# 4. Revert the modifications #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+# Test for operations, which have new values (INSERT+UPDATE, but not DELETE)
+if ($no_debug)
+{
+ --disable_query_log
+}
+eval SELECT INSTR('$statement','DELETE') = 0 INTO @aux;
+let $run1= `SELECT @aux`;
+--enable_query_log
+if ($run1)
+{
+ # Insert three records which are only needed for UPDATE TRIGGER test
+ eval INSERT INTO $tab_has_trigg(f_int1,f_int2,f_char1,f_char2,f_charbig)
+ SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
+ 'just inserted' FROM t0_template
+ WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
+ delimiter |;
+ eval CREATE TRIGGER trg_1 $event ON $tab_has_trigg FOR EACH ROW
+ BEGIN
+ UPDATE $tab_in_trigg SET f_int1 = -f_int1, f_int2 = -f_int2,
+ f_charbig = 'updated by trigger'
+ WHERE f_int1 = new.f_int1;
+ END|
+ delimiter ;|
+
+ eval $statement;
+
+ # Check of preceeding statement via Select
+ if ($no_debug)
+ {
+ --disable_query_log
+ }
+ eval SELECT '# check trigger-$num success: ' AS "", COUNT(*) = 3 AS ""
+ FROM $tab_in_trigg
+ WHERE f_int1 = f_int2 AND CAST(f_char1 AS SIGNED INT) = -f_int1;
+ --enable_query_log
+
+ DROP TRIGGER trg_1;
+
+ # Revert the changes
+ eval UPDATE $tab_in_trigg SET f_int1 = CAST(f_char1 AS SIGNED INT),
+ f_int2 = CAST(f_char1 AS SIGNED INT),
+ f_charbig = 'just inserted'
+ WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
+ eval DELETE FROM $tab_has_trigg
+ WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
+ inc $num;
+}
+
+# Test for operations, which have old values (UPDATE+DELETE, but not INSERT)
+if ($no_debug)
+{
+ --disable_query_log
+}
+eval SELECT INSTR('$statement','INSERT') = 0 INTO @aux;
+let $run1= `SELECT @aux`;
+--enable_query_log
+if ($run1)
+{
+ # Insert three records which are only needed for UPDATE/DELETE TRIGGER test
+ eval INSERT INTO $tab_has_trigg(f_int1,f_int2,f_char1,f_char2,f_charbig)
+ SELECT -f_int1,-f_int1,CAST(-f_int1 AS CHAR),CAST(-f_int1 AS CHAR),
+ 'just inserted' FROM t0_template
+ WHERE f_int1 BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
+
+ delimiter |;
+ eval CREATE TRIGGER trg_1 $event ON $tab_has_trigg FOR EACH ROW
+ BEGIN
+ UPDATE $tab_in_trigg SET f_int1 = -f_int1, f_int2 = -f_int2,
+ f_charbig = 'updated by trigger'
+ WHERE f_int1 = - old.f_int1;
+ END|
+ delimiter ;|
+
+ eval $statement;
+
+ # Check of preceeding statement via Select
+ if ($no_debug)
+ {
+ --disable_query_log
+ }
+ eval SELECT '# check trigger-$num success: ' AS "", COUNT(*) = 3 AS ""
+ FROM $tab_in_trigg
+ WHERE f_int1 = f_int2 AND CAST(f_char1 AS SIGNED INT) = -f_int1;
+ --enable_query_log
+ DROP TRIGGER trg_1;
+ # Revert the changes
+ eval UPDATE $tab_in_trigg SET f_int1 = CAST(f_char1 AS SIGNED INT),
+ f_int2 = CAST(f_char1 AS SIGNED INT),
+ f_charbig = 'just inserted'
+ WHERE f_int1 <> CAST(f_char1 AS SIGNED INT);
+ eval DELETE FROM $tab_has_trigg
+ WHERE ABS(f_int1) BETWEEN @max_row_div2 - 1 AND @max_row_div2 + 1;
+ inc $num;
+}
diff --git a/mysql-test/suite/parts/inc/partition_trigg2.inc b/mysql-test/suite/parts/inc/partition_trigg2.inc
new file mode 100644
index 00000000000..767dbd52e47
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_trigg2.inc
@@ -0,0 +1,45 @@
+################################################################################
+# include/partition_trigg2.inc #
+# #
+# Purpose: #
+# Auxiliary script, only useful when sourced by include/partition_check.inc. #
+# The trigger uses new values (--> event UPDATE, INSERT only) #
+# #
+# 1. Create a trigger #
+# 2. Execute a statement, which activates the trigger #
+# 3. Check the results of the trigger activity #
+# 4. Revert the modifications #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+delimiter |;
+eval CREATE TRIGGER trg_2 $event ON t1 FOR EACH ROW
+BEGIN
+ SET new.f_int1 = $source.f_int1 + @max_row,
+ new.f_int2 = $source.f_int2 - @max_row,
+ new.f_charbig = '####updated per update trigger####';
+END|
+delimiter ;|
+eval $statement;
+# Check of preceeding statement via Select
+if ($no_debug)
+{
+ --disable_query_log
+}
+eval SELECT '# check trigger-$num success: ' AS "", COUNT(*) = 0 AS "" FROM t1
+WHERE f_int1 - CAST(f_char1 AS SIGNED INT) NOT IN (@max_row, 2 * @max_row)
+ OR f_int2 - CAST(f_char1 AS SIGNED INT) NOT IN (-@max_row, - 2 * @max_row)
+ OR f_charbig <> '####updated per update trigger####';
+--enable_query_log
+DROP TRIGGER trg_2;
+# Revert the changes
+eval UPDATE t1 SET f_int1 = CAST(f_char1 AS SIGNED INT),
+ f_int2 = CAST(f_char1 AS SIGNED INT),
+ f_charbig = CONCAT('===',f_char1,'===');
+inc $num;
diff --git a/mysql-test/suite/parts/inc/partition_trigg3.inc b/mysql-test/suite/parts/inc/partition_trigg3.inc
new file mode 100644
index 00000000000..a129cf75a1d
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_trigg3.inc
@@ -0,0 +1,87 @@
+###############################################################################
+# include/partition_trigg3.inc #
+# #
+# Purpose: #
+# Auxiliary script, only useful when sourced by include/partition_check.inc. #
+# The trigger uses new values (--> event UPDATE, INSERT only) #
+# #
+# 1. Create a trigger #
+# 2. Execute a statement, which activates the trigger #
+# 3. Check the results of the trigger activity #
+# 4. Revert the modifications #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-03-05 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+# include/partition_trigg3.inc
+#
+# Auxiliary script, only useful when sourced by include/partition_check.inc.
+#
+# 1. Create a trigger
+# 2. Execute a statement, which activates the trigger
+# 3. Check the results of the trigger activity
+# 4. Revert the modifications
+#
+
+delimiter |;
+# Original version of the trigger
+# eval CREATE TRIGGER trg_3 $event ON t1 FOR EACH ROW
+# BEGIN
+# SET @counter = 1;
+# SET @my_max1 = 0, @my_max2 = 0;
+# SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
+# SET new.f_int1 = @my_max1 + @counter,
+# new.f_int2 = @my_min2 - @counter,
+# new.f_charbig = '####updated per insert trigger####';
+# SET @counter = @counter + 1;
+# END|
+#
+# Bug/currently undocumented limitation:
+# 17704: Triggers: MAX, Insert select with several rows, strange error
+# "A trigger can not access (not even read data) the table it's defined for."
+#
+eval CREATE TRIGGER trg_3 $event ON t1 FOR EACH ROW
+BEGIN
+ SET new.f_int1 = @my_max1 + @counter,
+ new.f_int2 = @my_min2 - @counter,
+ new.f_charbig = '####updated per insert trigger####';
+ SET @counter = @counter + 1;
+END|
+delimiter ;|
+# Additional statements because of Bug(limitation)#17704
+SET @counter = 1;
+if ($fixed_bug18730)
+{
+# Bug#18730 Partitions: NDB, crash on SELECT MIN(<unique column>)
+SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1;
+}
+if (!$fixed_bug18730)
+{
+# Bug#18730 Partitions: NDB, crash on SELECT MIN(<unique column>)
+SELECT @max_row, 1 INTO @my_max1,@my_min2;
+}
+# Additional statements end
+eval $statement;
+DROP TRIGGER trg_3;
+# Check of preceeding statement via Select
+if ($no_debug)
+{
+ --disable_query_log
+}
+# We insert records around max_row_div2 !
+eval SELECT '# check trigger-$num success: ' AS "", COUNT(*) = 3 AS "" FROM t1
+WHERE f_int1 = CAST(f_char1 AS SIGNED INT) + @max_row_div2 + 2
+ AND f_int2 = - CAST(f_char1 AS SIGNED INT) + @max_row_div2 - 1
+ AND f_charbig = '####updated per insert trigger####';
+--enable_query_log
+# Revert the changes
+eval DELETE FROM t1
+WHERE f_int1 <> CAST(f_char1 AS SIGNED INT)
+ AND f_int2 <> CAST(f_char1 AS SIGNED INT)
+ AND f_charbig = '####updated per insert trigger####';
+inc $num;
diff --git a/mysql-test/suite/parts/inc/partition_value.inc b/mysql-test/suite/parts/inc/partition_value.inc
new file mode 100644
index 00000000000..75e9afd53d3
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_value.inc
@@ -0,0 +1,157 @@
+################################################################################
+# include/partition_value.inc #
+# #
+# Purpose: #
+# Tests around "exotic" values calculated by the partitioning function #
+# #
+#------------------------------------------------------------------------------#
+# Original Author: ML #
+# Original Date: 2006-04-11 #
+# Change Author: #
+# Change Date: #
+# Change: #
+################################################################################
+
+--echo
+--echo #========================================================================
+--echo # Calculation of "exotic" results within the partition function
+--echo # outside of SIGNED BIGINT value range, 0, NULL
+--echo # column used in partitioning function has type CHAR
+--echo #========================================================================
+--echo # 1. HASH(<check value>)
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+#
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY HASH(CAST(f_char1 AS SIGNED INTEGER) * CAST(5.0E+18 AS SIGNED INTEGER)) PARTITIONS 8;
+let $my_val= 2147483646;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES($my_val,$my_val,'$my_val','$my_val','#$my_val#');
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char1 = '$my_val';
+let $my_val= -2147483646;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES($my_val,$my_val,'$my_val','$my_val','#$my_val#');
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char1 = '$my_val';
+let $my_val= 0;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES($my_val,$my_val,'$my_val','$my_val','#$my_val#');
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char1 = '$my_val';
+# let $my_val= NULL;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES(NULL,NULL,NULL,NULL,NULL);
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char1 IS NULL;
+DROP TABLE t1;
+#
+--echo # 2. RANGE(<check value>)
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(CAST(f_char1 AS SIGNED INTEGER) * CAST(5.0E+18 AS SIGNED INTEGER))
+(PARTITION p0 VALUES LESS THAN (0),
+ PARTITION p1 VALUES LESS THAN (1000000),
+ PARTITION p2 VALUES LESS THAN MAXVALUE);
+let $my_val= 2147483646;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES($my_val,$my_val,'$my_val','$my_val','#$my_val#');
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char1 = '$my_val';
+let $my_val= -2147483646;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES($my_val,$my_val,'$my_val','$my_val','#$my_val#');
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char1 = '$my_val';
+let $my_val= 0;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES($my_val,$my_val,'$my_val','$my_val','#$my_val#');
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char1 = '$my_val';
+# let $my_val= NULL;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES(NULL,NULL,NULL,NULL,NULL);
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char1 IS NULL;
+DROP TABLE t1;
+#
+# The NDB handler only supports 32 bit integers in VALUES
+# therefor we have to skip the next test for NDB.
+if (`SELECT @@session.storage_engine NOT IN('ndbcluster')`)
+{
+--echo # 3. LIST(<check value>)
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY LIST(CAST(f_char1 AS SIGNED INTEGER) * CAST(5.0E+18 AS SIGNED INTEGER))
+(PARTITION p0 VALUES IN (0),
+ PARTITION p1 VALUES IN (NULL),
+ PARTITION p2 VALUES IN (CAST( 2147483646 AS SIGNED INTEGER) * CAST(5.0E+18 AS SIGNED INTEGER)),
+ PARTITION p3 VALUES IN (CAST(-2147483646 AS SIGNED INTEGER) * CAST(5.0E+18 AS SIGNED INTEGER)));
+let $my_val= 2147483646;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES($my_val,$my_val,'$my_val','$my_val','#$my_val#');
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char1 = '$my_val';
+let $my_val= -2147483646;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES($my_val,$my_val,'$my_val','$my_val','#$my_val#');
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char1 = '$my_val';
+let $my_val= 0;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES($my_val,$my_val,'$my_val','$my_val','#$my_val#');
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char1 = '$my_val';
+# let $my_val= NULL;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES(NULL,NULL,NULL,NULL,NULL);
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char1 IS NULL;
+DROP TABLE t1;
+}
+#
+--echo # 4. Partition by RANGE(...) subpartition by HASH(<check value>)
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY RANGE(CAST(f_char1 AS SIGNED INTEGER))
+SUBPARTITION BY HASH(CAST(f_char2 AS SIGNED INTEGER) * CAST(5.0E+18 AS SIGNED INTEGER)) SUBPARTITIONS 4
+(PARTITION p0 VALUES LESS THAN (0),
+ PARTITION p1 VALUES LESS THAN MAXVALUE);
+let $my_val= 2147483646;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES($my_val,$my_val,'1','$my_val','#$my_val#');
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char2 = '$my_val';
+let $my_val= -2147483646;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES($my_val,$my_val,'-1','$my_val','#$my_val#');
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char2 = '$my_val';
+let $my_val= 0;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES($my_val,$my_val,'$my_val','$my_val','#$my_val#');
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char2 = '$my_val';
+# let $my_val= NULL;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES(NULL,NULL,NULL,NULL,NULL);
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char2 IS NULL;
+DROP TABLE t1;
+#
+--echo # 5. Partition by LIST(...) subpartition by HASH(<check value>)
+eval CREATE TABLE t1 (
+$column_list
+)
+PARTITION BY LIST(CAST(f_char1 AS SIGNED INTEGER))
+SUBPARTITION BY HASH(CAST(f_char2 AS SIGNED INTEGER) * CAST(5.0E+18 AS SIGNED INTEGER)) SUBPARTITIONS 4
+(PARTITION p0 VALUES IN (NULL),
+ PARTITION p1 VALUES IN (1));
+let $my_val= 2147483646;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES($my_val,$my_val,'1','$my_val','#$my_val#');
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char2 = '$my_val';
+let $my_val= -2147483646;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES($my_val,$my_val,'1','$my_val','#$my_val#');
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char2 = '$my_val';
+let $my_val= 0;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES($my_val,$my_val,'1','$my_val','#$my_val#');
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char2 = '$my_val';
+# let $my_val= NULL;
+eval INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig)
+VALUES(NULL,NULL,NULL,NULL,NULL);
+eval SELECT COUNT(*) = 1 FROM t1 WHERE f_char2 IS NULL;
+DROP TABLE t1;
+#
diff --git a/mysql-test/suite/parts/inc/partition_varbinary.inc b/mysql-test/suite/parts/inc/partition_varbinary.inc
new file mode 100644
index 00000000000..b112cbe312e
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_varbinary.inc
@@ -0,0 +1,96 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a varbinary(767) not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values (repeat('a',767)), ('b'), (repeat('a',500)), (repeat('b',64));
+select * from t1;
+select * from t1 where a='b';
+update t1 set a='bb' where a='b';
+delete from t1 where a='bb';
+select * from t1;
+drop table t1;
+
+eval create table t2 (a varbinary(767) not null, primary key(a)) engine=$engine
+partition by key (a) partitions 30;
+show create table t2;
+let $count=26;
+let $letter=0;
+--echo $count inserts;
+#--disable_query_log
+while ($count)
+{
+eval insert into t2 values (repeat(char(ascii('a')+$letter),$count*$count));
+dec $count;
+inc $letter;
+}
+select count(*) from t2;
+select * from t2;
+drop table t2;
+
+
+if (0)
+{
+eval create table t3 (a varbinary(767) not null, primary key(a)) engine=$engine
+partition by range (ascii(a)) subpartition by key (a) subpartitions 4 (
+partition pa16 values less than (16),
+partition pa32 values less than (32),
+partition pa64 values less than (64),
+partition pa128 values less than (128),
+partition pa256 values less than (256)
+);
+show create table t3;
+let $count=26;
+let $letter=0;
+--echo $count inserts;
+#--disable_query_log
+while ($count)
+{
+eval insert into t3 values (repeat(char(ascii('a')+$letter),$count+54));
+dec $count;
+inc $letter;
+}
+select count(*) from t3;
+select hex(a) from t3;
+drop table t3;
+
+eval create table t4 (a varbinary(767) not null, primary key(a)) engine=$engine
+partition by list (ascii(a)) subpartition by key (a) subpartitions 4 (
+partition pa16 values in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16),
+partition pa32 values in (17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32),
+partition pa64 values in (33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64),
+partition pa128 values in (65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128),
+partition pa256 values in (129,130,131,132,133,134,135,136,137,138,139,140
+,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256)
+);
+show create table t4;
+let $count=26;
+let $letter=0;
+--echo $count inserts;
+#--disable_query_log
+while ($count)
+{
+eval insert into t4 values (repeat(char(ascii('a')+$letter),$count+54));
+dec $count;
+inc $letter;
+}
+select count(*) from t4;
+select hex(a) from t4;
+drop table t4;
+}
+#if (0)
+
diff --git a/mysql-test/suite/parts/inc/partition_varchar.inc b/mysql-test/suite/parts/inc/partition_varchar.inc
new file mode 100644
index 00000000000..1cd33fa49da
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_varchar.inc
@@ -0,0 +1,95 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a varchar(767) not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values (repeat('a',767)), ('b'), (repeat('a',500)), (repeat('b',64));
+select * from t1;
+select * from t1 where a='b';
+update t1 set a='bb' where a='b';
+delete from t1 where a='bb';
+select * from t1;
+drop table t1;
+
+eval create table t2 (a varchar(767) not null, primary key(a)) engine=$engine
+partition by key (a) partitions 27;
+show create table t2;
+let $count=26;
+let $letter=0;
+--echo $count inserts;
+#--disable_query_log
+while ($count)
+{
+eval insert into t2 values (repeat(char(ascii('a')+$letter),$count*$count));
+dec $count;
+inc $letter;
+}
+select count(*) from t2;
+select * from t2;
+drop table t2;
+
+if (0)
+{
+eval create table t3 (a varchar(767) not null, primary key(a)) engine=$engine
+partition by range (ascii(a)) subpartition by key (a) subpartitions 4 (
+partition pa16 values less than (16),
+partition pa32 values less than (32),
+partition pa64 values less than (64),
+partition pa128 values less than (128),
+partition pa256 values less than (256)
+);
+show create table t3;
+let $count=26;
+let $letter=0;
+--echo $count inserts;
+#--disable_query_log
+while ($count)
+{
+eval insert into t3 values (repeat(char(ascii('a')+$letter),$count+54));
+dec $count;
+inc $letter;
+}
+select count(*) from t3;
+select * from t3;
+drop table t3;
+
+eval create table t4 (a varchar(767) not null, primary key(a)) engine=$engine
+partition by list (ascii(a)) subpartition by key (a) subpartitions 4 (
+partition pa16 values in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16),
+partition pa32 values in (17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32),
+partition pa64 values in (33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64),
+partition pa128 values in (65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128),
+partition pa256 values in (129,130,131,132,133,134,135,136,137,138,139,140
+,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256)
+);
+show create table t4;
+let $count=26;
+let $letter=0;
+--echo $count inserts;
+#--disable_query_log
+while ($count)
+{
+eval insert into t4 values (repeat(char(ascii('a')+$letter),$count+54));
+dec $count;
+inc $letter;
+}
+select count(*) from t4;
+select * from t4;
+drop table t4;
+}
+#if (0)
+
diff --git a/mysql-test/suite/parts/inc/partition_year.inc b/mysql-test/suite/parts/inc/partition_year.inc
new file mode 100644
index 00000000000..2643380702e
--- /dev/null
+++ b/mysql-test/suite/parts/inc/partition_year.inc
@@ -0,0 +1,48 @@
+--disable_query_log
+# DATA DIRECTORY
+eval SET @data_dir = 'DATA DIRECTORY =
+''/tmp''';
+let $data_directory = `select @data_dir`;
+
+#INDEX DIRECTORY
+eval SET @indx_dir = 'INDEX DIRECTORY =
+''/tmp''';
+let $index_directory = `select @indx_dir`;
+--enable_query_log
+
+eval create table t1 (a year not null, primary key(a)) engine=$engine
+partition by key (a) (
+partition pa1 $data_directory $index_directory max_rows=20 min_rows=2,
+partition pa2 $data_directory $index_directory max_rows=30 min_rows=3,
+partition pa3 $data_directory $index_directory max_rows=30 min_rows=4,
+partition pa4 $data_directory $index_directory max_rows=40 min_rows=2);
+show create table t1;
+insert into t1 values ('1975'), (2020), ('1980'), ('2000');
+select * from t1;
+select * from t1 where a=1980;
+delete from t1 where a=1980;
+select * from t1;
+drop table t1;
+
+eval create table t2 (a year not null, primary key(a)) engine=$engine
+partition by key (a) partitions 12;
+show create table t2;
+insert into t2 values ('1975'), ('2020'), ('1980'), ('2000');
+select * from t2;
+select * from t2 where a='1980';
+delete from t2 where a='1980';
+select * from t2;
+delete from t2;
+let $count=255;
+--echo $count inserts;
+--disable_query_log
+while ($count)
+{
+eval insert into t2 values (1901+$count);
+dec $count;
+}
+--enable_query_log
+select count(*) from t2;
+select * from t2;
+drop table t2;
+