You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

750 lines
27 KiB

WL #2604: Partition Management Optimised version of ADD/DROP/REORGANIZE partitions for non-NDB storage engines. New syntax to handle REBUILD/OPTIMIZE/ANALYZE/CHECK/REPAIR partitions Quite a few bug fixes include/thr_lock.h: New method to downgrade locks from TL_WRITE_ONLY Possibility to upgrade lock while aborting locks mysql-test/r/ndb_autodiscover.result: Fix for lowercase and that all NDB tables are now partitioned mysql-test/r/ndb_bitfield.result: Fix for lowercase and that all NDB tables are now partitioned mysql-test/r/ndb_gis.result: Fix for lowercase and that all NDB tables are now partitioned mysql-test/r/ndb_partition_key.result: New test case mysql-test/r/partition.result: New test case mysql-test/r/partition_error.result: New test case mysql-test/r/partition_mgm_err.result: Fix of test case results mysql-test/t/disabled.def: partition_03ndb still has bug mysql-test/t/ndb_partition_key.test: New test cases for new functionality and bugs mysql-test/t/partition.test: New test cases for new functionality and bugs mysql-test/t/partition_error.test: New test cases for new functionality and bugs mysql-test/t/partition_mgm_err.test: New test cases for new functionality and bugs mysys/thr_lock.c: New method to downgrade TL_WRITE_ONLY locks Possibility to specify if locks are to be upgraded at abort locks sql/ha_archive.cc: New handlerton methods sql/ha_berkeley.cc: New handlerton methods sql/ha_blackhole.cc: New handlerton methods sql/ha_federated.cc: New handlerton methods sql/ha_heap.cc: New handlerton methods sql/ha_innodb.cc: New handlerton methods sql/ha_myisam.cc: New handlerton methods sql/ha_myisammrg.cc: New handlerton methods sql/ha_ndbcluster.cc: New handlerton methods Moved out packfrm and unpackfrm methods Adapted many parts to use table_share instead of table->s Ensured that .ndb file uses filename and not tablename according to new encoding of names (WL 1324) All NDB tables are partitioned and set up partition info Fixed such that tablenames use tablenames and not filenames in NDB NDB uses auto partitioning for ENGINE=NDB tables Warning for very large tables Set RANGE data Set LIST data New method to set-up partition info Set Default number of partitions flag Set linear hash flag Set node group array Set number of fragments Set max rows Set tablespace names New method to get number of partitions of table to use at open table sql/ha_ndbcluster.h: Removed partition_flags and alter_table_flags from handler class A couple of new and changed method headers sql/ha_ndbcluster_binlog.cc: Use new method headers sql/ha_partition.cc: New handlerton methods Lots of new function headers Use #P# as separator between table name and partition name and #SP# as separator between partition name and subpartition name Use filename encoding for files both of table name part and of partition name parts New method to drop partitions based on partition state New method to rename partitions based on partition state New methods to optimize, analyze, check and repair partitions New methods to optimize, analyze, check and repair table Helper method to create new partition, open it and external lock it, not needed to lock it internally since no one else knows about it yet. Cleanup method at error for new partitions New methods to perform bulk of work at ADD/REORGANIZE partitions (change_partitions, copy_partitions) sql/ha_partition.h: New methods and variables A few dropped ones and a few changed ones sql/handler.cc: Handlerton interface changes New flag to open_table_from_share sql/handler.h: New alter_table_flags New partition flags New partition states More states for default handling Lots of new, dropped and changed interfaces sql/lex.h: Added REBUILD and changed name of REORGANISE to REORGANIZE sql/lock.cc: Method to downgrade locks Able to specify if locks upgraded on abort locks sql/log.cc: New handlerton methods sql/mysql_priv.h: Lots of new interfaces sql/share/errmsg.txt: Lots of new, dropped and changed error messages sql/sql_base.cc: Adapted to new method headers New method to abort and upgrade lock New method to close open tables and downgrade lock New method to wait for completed table sql/sql_lex.h: New flags sql/sql_partition.cc: Return int instead of bool in get_partition_id More defaults handling Make use of new mem_alloc_error method More work on function headers Changes to generate partition syntax to cater for intermediate partition states Lots of new code with large comments describing new features for Partition Management: ADD/DROP/REORGANIZE/OPTIMIZE/ANALYZE/CHECK/REPAIR partitions sql/sql_show.cc: Minors sql/sql_table.cc: Moved a couple of methods New methods to copy create lists and key lists for use with mysql_prepare_table New method to write frm file New handling of handlers with auto partitioning Fix CREATE TABLE LIKE Moved code for ADD/DROP/REORGANIZE partitions Use handlerton method for alter_table_flags sql/sql_yacc.yy: More memory alloc error checks New syntax for REBUILD, ANALYZE, CHECK, OPTIMIZE, REPAIR partitions sql/table.cc: Fix length of extra part to be 4 bytes Partition state introduced in frm file sql/table.h: Partition state introduced sql/unireg.cc: Partition state introduced Default partition storage/csv/ha_tina.cc: New handlerton methods storage/example/ha_example.cc: New handlerton methods storage/ndb/include/kernel/ndb_limits.h: RANGE DATA storage/ndb/include/kernel/signaldata/AlterTable.hpp: New interfaces in ALTER TABLE towards NDB kernel storage/ndb/include/kernel/signaldata/DiAddTab.hpp: New section storage/ndb/include/kernel/signaldata/DictTabInfo.hpp: Lots of new parts of table description storage/ndb/include/kernel/signaldata/LqhFrag.hpp: tablespace id specified in LQHFRAGREQ storage/ndb/include/ndbapi/NdbDictionary.hpp: Lots of new methods in NDB dictionary storage/ndb/src/common/debugger/signaldata/DictTabInfo.cpp: Lots of new variables in table description storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Lots of new variables in table description storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Lots of new variables in table description storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: New error insertion storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp: a few extra jam's storage/ndb/src/ndbapi/NdbBlob.cpp: Changes to definition of blob tables storage/ndb/src/ndbapi/NdbDictionary.cpp: Lots of new stuff in NDB dictionary storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp: Lots of new stuff in NDB dictionary storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp: Lots of new stuff in NDB dictionary storage/ndb/test/ndbapi/test_event.cpp: removed use of methods no longer in existence storage/ndb/tools/restore/Restore.cpp: Renamed variable
20 years ago
Fix test cases to work with non-standard --vardir. Rename mix_innodb_myisam_binlog-master.opt; when the test was moved to separate stm/row test cases, the .opt were not moved along with it, causing a 60-second test duration because of default lock timeout :-( mysql-test/t/binlog_row_mix_innodb_myisam-master.opt: bk cp mysql-test/t/mix_innodb_myisam_binlog-master.opt mysql-test/t/binlog_row_mix_innodb_myisam-master.opt mysql-test/t/binlog_stm_mix_innodb_myisam-master.opt: Rename: mysql-test/t/mix_innodb_myisam_binlog-master.opt -> mysql-test/t/binlog_stm_mix_innodb_myisam-master.opt mysql-test/r/mysqlbinlog_base64.result: Fix test cases to work with non-standard --vardir. mysql-test/r/ndb_load.result: Fix test cases to work with non-standard --vardir. mysql-test/r/rpl_LD_INFILE.result: Fix test cases to work with non-standard --vardir. mysql-test/r/rpl_loaddata2.result: Fix test cases to work with non-standard --vardir. mysql-test/r/rpl_loaddata_m.result: Fix test cases to work with non-standard --vardir. mysql-test/t/loaddata.test: Fix test cases to work with non-standard --vardir. mysql-test/t/mysqlbinlog_base64.test: Fix test cases to work with non-standard --vardir. mysql-test/t/ndb_dd_dump.test: Fix test cases to work with non-standard --vardir. mysql-test/t/ndb_load.test: Fix test cases to work with non-standard --vardir. mysql-test/t/rpl_LD_INFILE.test: Fix test cases to work with non-standard --vardir. mysql-test/t/rpl_loaddata2.test: Fix test cases to work with non-standard --vardir. mysql-test/t/rpl_loaddata_m.test: Fix test cases to work with non-standard --vardir. mysql-test/t/rpl_loadfile.test: Fix test cases to work with non-standard --vardir. mysql-test/extra/rpl_tests/rpl_row_001.test: Fix test cases to work with non-standard --vardir. mysql-test/r/rpl_load_table_from_master.result: Fix test cases to work with non-standard --vardir. mysql-test/r/rpl_loadfile.result: Fix test cases to work with non-standard --vardir. mysql-test/r/rpl_ndb_row_001.result: Fix test cases to work with non-standard --vardir. mysql-test/r/rpl_row_001.result: Fix test cases to work with non-standard --vardir. mysql-test/r/rpl_row_loaddata_m.result: Fix test cases to work with non-standard --vardir. mysql-test/r/rpl_row_stop_middle_update.result: Fix test cases to work with non-standard --vardir. mysql-test/t/rpl_drop_db.test: Fix test cases to work with non-standard --vardir. mysql-test/t/rpl_load_table_from_master.test: Fix test cases to work with non-standard --vardir. mysql-test/t/rpl_row_stop_middle_update.test: Fix test cases to work with non-standard --vardir. mysql-test/extra/rpl_tests/rpl_row_UUID.test: Fix test cases to work with non-standard --vardir. mysql-test/extra/rpl_tests/rpl_row_blob.test: Fix test cases to work with non-standard --vardir. mysql-test/extra/rpl_tests/rpl_row_charset.test: Fix test cases to work with non-standard --vardir. mysql-test/extra/rpl_tests/rpl_row_func003.test: Fix test cases to work with non-standard --vardir. mysql-test/extra/rpl_tests/rpl_row_sp006.test: Fix test cases to work with non-standard --vardir. mysql-test/include/ndb_backup.inc: Fix test cases to work with non-standard --vardir. mysql-test/r/rpl_ndb_bank.result: Fix test cases to work with non-standard --vardir. mysql-test/r/rpl_ndb_sync.result: Fix test cases to work with non-standard --vardir. mysql-test/t/rpl_ndb_bank.test: Fix test cases to work with non-standard --vardir. mysql-test/t/rpl_ndb_sync.test: Fix test cases to work with non-standard --vardir. mysql-test/t/rpl_row_NOW.test: Fix test cases to work with non-standard --vardir. mysql-test/t/rpl_row_func002.test: Fix test cases to work with non-standard --vardir. mysql-test/t/rpl_row_sp001.test: Fix test cases to work with non-standard --vardir. mysql-test/t/rpl_row_sp011.test: Fix test cases to work with non-standard --vardir. mysql-test/t/rpl_row_trig001.test: Fix test cases to work with non-standard --vardir. mysql-test/t/rpl_row_trig003.test: Fix test cases to work with non-standard --vardir. mysql-test/t/rpl_sp004.test: Fix test cases to work with non-standard --vardir. mysql-test/t/show_check.test: Fix test cases to work with non-standard --vardir. mysql-test/include/partition_1.inc: Fix test cases to work with non-standard --vardir. mysql-test/include/partition_layout.inc: Fix test cases to work with non-standard --vardir. mysql-test/r/ndb_dd_backuprestore.result: Fix test cases to work with non-standard --vardir.
20 years ago
WL #2604: Partition Management Optimised version of ADD/DROP/REORGANIZE partitions for non-NDB storage engines. New syntax to handle REBUILD/OPTIMIZE/ANALYZE/CHECK/REPAIR partitions Quite a few bug fixes include/thr_lock.h: New method to downgrade locks from TL_WRITE_ONLY Possibility to upgrade lock while aborting locks mysql-test/r/ndb_autodiscover.result: Fix for lowercase and that all NDB tables are now partitioned mysql-test/r/ndb_bitfield.result: Fix for lowercase and that all NDB tables are now partitioned mysql-test/r/ndb_gis.result: Fix for lowercase and that all NDB tables are now partitioned mysql-test/r/ndb_partition_key.result: New test case mysql-test/r/partition.result: New test case mysql-test/r/partition_error.result: New test case mysql-test/r/partition_mgm_err.result: Fix of test case results mysql-test/t/disabled.def: partition_03ndb still has bug mysql-test/t/ndb_partition_key.test: New test cases for new functionality and bugs mysql-test/t/partition.test: New test cases for new functionality and bugs mysql-test/t/partition_error.test: New test cases for new functionality and bugs mysql-test/t/partition_mgm_err.test: New test cases for new functionality and bugs mysys/thr_lock.c: New method to downgrade TL_WRITE_ONLY locks Possibility to specify if locks are to be upgraded at abort locks sql/ha_archive.cc: New handlerton methods sql/ha_berkeley.cc: New handlerton methods sql/ha_blackhole.cc: New handlerton methods sql/ha_federated.cc: New handlerton methods sql/ha_heap.cc: New handlerton methods sql/ha_innodb.cc: New handlerton methods sql/ha_myisam.cc: New handlerton methods sql/ha_myisammrg.cc: New handlerton methods sql/ha_ndbcluster.cc: New handlerton methods Moved out packfrm and unpackfrm methods Adapted many parts to use table_share instead of table->s Ensured that .ndb file uses filename and not tablename according to new encoding of names (WL 1324) All NDB tables are partitioned and set up partition info Fixed such that tablenames use tablenames and not filenames in NDB NDB uses auto partitioning for ENGINE=NDB tables Warning for very large tables Set RANGE data Set LIST data New method to set-up partition info Set Default number of partitions flag Set linear hash flag Set node group array Set number of fragments Set max rows Set tablespace names New method to get number of partitions of table to use at open table sql/ha_ndbcluster.h: Removed partition_flags and alter_table_flags from handler class A couple of new and changed method headers sql/ha_ndbcluster_binlog.cc: Use new method headers sql/ha_partition.cc: New handlerton methods Lots of new function headers Use #P# as separator between table name and partition name and #SP# as separator between partition name and subpartition name Use filename encoding for files both of table name part and of partition name parts New method to drop partitions based on partition state New method to rename partitions based on partition state New methods to optimize, analyze, check and repair partitions New methods to optimize, analyze, check and repair table Helper method to create new partition, open it and external lock it, not needed to lock it internally since no one else knows about it yet. Cleanup method at error for new partitions New methods to perform bulk of work at ADD/REORGANIZE partitions (change_partitions, copy_partitions) sql/ha_partition.h: New methods and variables A few dropped ones and a few changed ones sql/handler.cc: Handlerton interface changes New flag to open_table_from_share sql/handler.h: New alter_table_flags New partition flags New partition states More states for default handling Lots of new, dropped and changed interfaces sql/lex.h: Added REBUILD and changed name of REORGANISE to REORGANIZE sql/lock.cc: Method to downgrade locks Able to specify if locks upgraded on abort locks sql/log.cc: New handlerton methods sql/mysql_priv.h: Lots of new interfaces sql/share/errmsg.txt: Lots of new, dropped and changed error messages sql/sql_base.cc: Adapted to new method headers New method to abort and upgrade lock New method to close open tables and downgrade lock New method to wait for completed table sql/sql_lex.h: New flags sql/sql_partition.cc: Return int instead of bool in get_partition_id More defaults handling Make use of new mem_alloc_error method More work on function headers Changes to generate partition syntax to cater for intermediate partition states Lots of new code with large comments describing new features for Partition Management: ADD/DROP/REORGANIZE/OPTIMIZE/ANALYZE/CHECK/REPAIR partitions sql/sql_show.cc: Minors sql/sql_table.cc: Moved a couple of methods New methods to copy create lists and key lists for use with mysql_prepare_table New method to write frm file New handling of handlers with auto partitioning Fix CREATE TABLE LIKE Moved code for ADD/DROP/REORGANIZE partitions Use handlerton method for alter_table_flags sql/sql_yacc.yy: More memory alloc error checks New syntax for REBUILD, ANALYZE, CHECK, OPTIMIZE, REPAIR partitions sql/table.cc: Fix length of extra part to be 4 bytes Partition state introduced in frm file sql/table.h: Partition state introduced sql/unireg.cc: Partition state introduced Default partition storage/csv/ha_tina.cc: New handlerton methods storage/example/ha_example.cc: New handlerton methods storage/ndb/include/kernel/ndb_limits.h: RANGE DATA storage/ndb/include/kernel/signaldata/AlterTable.hpp: New interfaces in ALTER TABLE towards NDB kernel storage/ndb/include/kernel/signaldata/DiAddTab.hpp: New section storage/ndb/include/kernel/signaldata/DictTabInfo.hpp: Lots of new parts of table description storage/ndb/include/kernel/signaldata/LqhFrag.hpp: tablespace id specified in LQHFRAGREQ storage/ndb/include/ndbapi/NdbDictionary.hpp: Lots of new methods in NDB dictionary storage/ndb/src/common/debugger/signaldata/DictTabInfo.cpp: Lots of new variables in table description storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp: Lots of new variables in table description storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp: Lots of new variables in table description storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: New error insertion storage/ndb/src/kernel/blocks/dbtup/DbtupMeta.cpp: a few extra jam's storage/ndb/src/ndbapi/NdbBlob.cpp: Changes to definition of blob tables storage/ndb/src/ndbapi/NdbDictionary.cpp: Lots of new stuff in NDB dictionary storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp: Lots of new stuff in NDB dictionary storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp: Lots of new stuff in NDB dictionary storage/ndb/test/ndbapi/test_event.cpp: removed use of methods no longer in existence storage/ndb/tools/restore/Restore.cpp: Renamed variable
20 years ago
  1. -- source include/have_partition.inc
  2. # include/partition_1.inc
  3. #
  4. # Partitionong tests
  5. #
  6. # Attention: The variable
  7. # $engine -- Storage engine to be tested.
  8. # must be set within the script sourcing this file.
  9. #
  10. --disable_abort_on_error
  11. SET AUTOCOMMIT= 1;
  12. ##### Disabled testcases, because of open bugs #####
  13. --echo
  14. --echo #------------------------------------------------------------------------
  15. --echo # There are several testcases disabled because ouf the open bugs
  16. --echo # #15407 , #15408 , #15890 , #15961 , #13447 , #15966 , #15968, #16370
  17. --echo #------------------------------------------------------------------------
  18. # Bug#15407 Partitions: crash if subpartition
  19. let $fixed_bug15407= 0;
  20. # Bug#15408 Partitions: subpartition names are not unique
  21. let $fixed_bug15408= 0;
  22. # Bug#15890 Partitions: Strange interpretation of partition number
  23. let $fixed_bug15890= 0;
  24. # Bug#15961 Partitions: Creation of subpart. table without subpart. rule not rejected
  25. let $fixed_bug15961= 0;
  26. # Bug#13447 Partitions: crash with alter table
  27. let $fixed_bug13447= 0;
  28. # Bug#15966 Partitions: crash if session default engine <> engine used in create table
  29. let $fixed_bug15966= 0;
  30. # Bug#15968 Partitions: crash when INSERT with f1 = -1 into PARTITION BY HASH(f1)
  31. let $fixed_bug15968= 0;
  32. # Bug #16370 Partitions: subpartitions names not mentioned in SHOW CREATE TABLE output
  33. let $fixed_bug16370= 0;
  34. ##### Option, for displaying files #####
  35. #
  36. # Attention: Displaying the directory content via "ls $MYSQLTEST_VARDIR/master-data/test/t*"
  37. # is probably not portable.
  38. # let $ls= 0; disables the execution of "ls ....."
  39. let $ls= 0;
  40. ################################################################################
  41. # Partitioning syntax
  42. #
  43. # CREATE TABLE .... (column-list ..)
  44. # PARTITION BY
  45. # KEY '(' ( column-list ) ')'
  46. # | RANGE '(' ( expr ) ')'
  47. # | LIST '(' ( expr ) ')'
  48. # | HASH '(' ( expr ) ')'
  49. # [PARTITIONS num ]
  50. # [SUBPARTITION BY
  51. # KEY '(' ( column-list ) ')'
  52. # | HASH '(' ( expr ) ')'
  53. # [SUBPARTITIONS num ]
  54. # ]
  55. # [ '('
  56. # ( PARTITION logical-name
  57. # [ VALUES LESS THAN '(' ( expr | MAX_VALUE ) ')' ]
  58. # [ VALUES IN '(' (expr)+ ')' ]
  59. # [ TABLESPACE tablespace-name ]
  60. # [ [ STORAGE ] ENGINE [ '=' ] storage-engine-name ]
  61. # [ NODEGROUP nodegroup-id ]
  62. # [ '('
  63. # ( SUBPARTITION logical-name
  64. # [ TABLESPACE tablespace-name ]
  65. # [ STORAGE ENGINE = storage-engine-name ]
  66. # [ NODEGROUP nodegroup-id ]
  67. # )+
  68. # ')'
  69. # )+
  70. # ')'
  71. # ]
  72. ################################################################################
  73. --echo
  74. --echo #------------------------------------------------------------------------
  75. --echo # 0. Setting of auxiliary variables + Creation of an auxiliary table
  76. --echo # needed in all testcases
  77. --echo #------------------------------------------------------------------------
  78. let $max_row= `SELECT @max_row`;
  79. let $max_row_div2= `SELECT @max_row DIV 2`;
  80. let $max_row_div3= `SELECT @max_row DIV 3`;
  81. let $max_row_div4= `SELECT @max_row DIV 4`;
  82. let $max_int_4= 2147483647;
  83. --disable_warnings
  84. DROP TABLE IF EXISTS t0_template;
  85. --enable_warnings
  86. CREATE TABLE t0_template ( f1 INTEGER, f2 char(20), PRIMARY KEY(f1))
  87. ENGINE = MEMORY;
  88. --echo # Logging of <max_row> INSERTs into t0_template suppressed
  89. --disable_query_log
  90. let $num= $max_row;
  91. while ($num)
  92. {
  93. eval INSERT INTO t0_template SET f1 = $num, f2 = '---$num---';
  94. dec $num;
  95. }
  96. --enable_query_log
  97. --echo
  98. --echo #------------------------------------------------------------------------
  99. --echo # 1. Some syntax checks
  100. --echo #------------------------------------------------------------------------
  101. --echo # 1.1 Subpartioned table without subpartitioning rule must be rejected
  102. --disable_warnings
  103. DROP TABLE IF EXISTS t1;
  104. --enable_warnings
  105. if ($fixed_bug15961)
  106. {
  107. # Bug#15961 Partitions: Creation of subpart. table without subpart. rule not rejected
  108. --error 9999
  109. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  110. PARTITION BY RANGE(f1)
  111. ( PARTITION part1 VALUES LESS THAN (1000) (SUBPARTITION subpart11));
  112. }
  113. --echo # FIXME Implement testcases, where it is checked that all create and
  114. --echo # alter table statements
  115. --echo # - with missing mandatory parameters are rejected
  116. --echo # - with optional parameters are accepted
  117. --echo # - with wrong combinations of optional parameters are rejected
  118. --echo # - ............
  119. --echo
  120. --echo #------------------------------------------------------------------------
  121. --echo # 2. Checks where the engine is assigned on all supported (CREATE TABLE
  122. --echo # statement) positions + basic operations on the tables
  123. --echo # Storage engine mixups are currently (2005-12-23) not supported
  124. --echo #------------------------------------------------------------------------
  125. --disable_warnings
  126. DROP TABLE IF EXISTS t1;
  127. --enable_warnings
  128. --echo # 2.1 non partitioned table (for comparison)
  129. eval CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) ENGINE = $engine;
  130. # MLML Full size (as check of check routine)
  131. --source include/partition_10.inc
  132. DROP TABLE t1;
  133. #
  134. --echo # 2.2 Assignment of storage engine just after column list only
  135. eval CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) ENGINE = $engine
  136. PARTITION BY HASH(f1) PARTITIONS 2;
  137. --source include/partition_10.inc
  138. DROP TABLE t1;
  139. #
  140. --echo # 2.3 Assignment of storage engine just after partition or subpartition
  141. --echo # name only
  142. eval CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  143. PARTITION BY HASH(f1)
  144. ( PARTITION part1 STORAGE ENGINE = $engine,
  145. PARTITION part2 STORAGE ENGINE = $engine
  146. );
  147. --source include/partition_10.inc
  148. DROP TABLE t1;
  149. eval CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  150. PARTITION BY RANGE(f1)
  151. SUBPARTITION BY HASH(f1)
  152. ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
  153. (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
  154. SUBPARTITION subpart12 STORAGE ENGINE = $engine),
  155. PARTITION part2 VALUES LESS THAN ($max_int_4)
  156. (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
  157. SUBPARTITION subpart22 STORAGE ENGINE = $engine)
  158. );
  159. --source include/partition_10.inc
  160. DROP TABLE t1;
  161. #
  162. --echo # 2.4 Some but not all named partitions or subpartitions get a storage
  163. --echo # engine assigned
  164. eval CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  165. PARTITION BY HASH(f1)
  166. ( PARTITION part1 STORAGE ENGINE = $engine,
  167. PARTITION part2
  168. );
  169. --source include/partition_10.inc
  170. DROP TABLE t1;
  171. eval CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  172. PARTITION BY HASH(f1)
  173. ( PARTITION part1 ,
  174. PARTITION part2 STORAGE ENGINE = $engine
  175. );
  176. --source include/partition_10.inc
  177. DROP TABLE t1;
  178. eval CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  179. PARTITION BY RANGE(f1)
  180. SUBPARTITION BY HASH(f1)
  181. ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
  182. (SUBPARTITION subpart11,
  183. SUBPARTITION subpart12 STORAGE ENGINE = $engine),
  184. PARTITION part2 VALUES LESS THAN ($max_int_4)
  185. (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
  186. SUBPARTITION subpart22 STORAGE ENGINE = $engine)
  187. );
  188. --source include/partition_10.inc
  189. DROP TABLE t1;
  190. eval CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  191. PARTITION BY RANGE(f1)
  192. SUBPARTITION BY HASH(f1)
  193. ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
  194. (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
  195. SUBPARTITION subpart12 STORAGE ENGINE = $engine),
  196. PARTITION part2 VALUES LESS THAN ($max_int_4)
  197. (SUBPARTITION subpart21,
  198. SUBPARTITION subpart22 )
  199. );
  200. --source include/partition_10.inc
  201. DROP TABLE t1;
  202. #
  203. --echo # 2.5 Storage engine assignment after partition name + after name of
  204. --echo # subpartitions belonging to another partition
  205. eval CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  206. PARTITION BY RANGE(f1)
  207. SUBPARTITION BY HASH(f1)
  208. ( PARTITION part1 VALUES LESS THAN ($max_row_div2) ENGINE = $engine
  209. (SUBPARTITION subpart11,
  210. SUBPARTITION subpart12),
  211. PARTITION part2 VALUES LESS THAN ($max_int_4)
  212. (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
  213. SUBPARTITION subpart22 STORAGE ENGINE = $engine)
  214. );
  215. --source include/partition_10.inc
  216. DROP TABLE t1;
  217. eval CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  218. PARTITION BY RANGE(f1)
  219. SUBPARTITION BY HASH(f1)
  220. ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
  221. (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
  222. SUBPARTITION subpart12 STORAGE ENGINE = $engine),
  223. PARTITION part2 VALUES LESS THAN ($max_int_4) ENGINE = $engine
  224. (SUBPARTITION subpart21,
  225. SUBPARTITION subpart22)
  226. );
  227. --source include/partition_10.inc
  228. DROP TABLE t1;
  229. #
  230. --echo # 2.6 Precedence of storage engine assignments
  231. --echo # 2.6.1 Storage engine assignment after column list + after partition
  232. --echo # or subpartition name
  233. eval CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) ENGINE = $engine
  234. PARTITION BY HASH(f1)
  235. ( PARTITION part1 STORAGE ENGINE = $engine,
  236. PARTITION part2 STORAGE ENGINE = $engine
  237. );
  238. --source include/partition_10.inc
  239. DROP TABLE t1;
  240. eval CREATE TABLE t1 ( f1 INTEGER, f2 char(20)) ENGINE = $engine
  241. PARTITION BY RANGE(f1)
  242. SUBPARTITION BY HASH(f1)
  243. ( PARTITION part1 VALUES LESS THAN ($max_row_div2)
  244. (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
  245. SUBPARTITION subpart12 STORAGE ENGINE = $engine),
  246. PARTITION part2 VALUES LESS THAN ($max_int_4)
  247. (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
  248. SUBPARTITION subpart22 STORAGE ENGINE = $engine)
  249. );
  250. --source include/partition_10.inc
  251. DROP TABLE t1;
  252. --echo # 2.6.2 Storage engine assignment after partition name + after
  253. --echo # subpartition name
  254. # in partition part + in sub partition part
  255. eval CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  256. PARTITION BY RANGE(f1)
  257. SUBPARTITION BY HASH(f1)
  258. ( PARTITION part1 VALUES LESS THAN ($max_row_div2) STORAGE ENGINE = $engine
  259. (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
  260. SUBPARTITION subpart12 STORAGE ENGINE = $engine),
  261. PARTITION part2 VALUES LESS THAN ($max_int_4)
  262. (SUBPARTITION subpart21 STORAGE ENGINE = $engine,
  263. SUBPARTITION subpart22 STORAGE ENGINE = $engine)
  264. );
  265. --source include/partition_10.inc
  266. DROP TABLE t1;
  267. --echo # 2.7 Session default engine differs from engine used within create table
  268. eval SET SESSION storage_engine=$engine_other;
  269. if ($fixed_bug15966)
  270. {
  271. # Bug#15966 Partitions: crash if session default engine <> engine used in create table
  272. eval CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  273. PARTITION BY HASH(f1) ( PARTITION part1 ENGINE = $engine);
  274. --source include/partition_10.inc
  275. DROP TABLE t1;
  276. # Bug#15966 Partitions: crash if session default engine <> engine used in create table
  277. eval CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  278. PARTITION BY RANGE(f1)
  279. SUBPARTITION BY HASH(f1)
  280. ( PARTITION part1 VALUES LESS THAN (1000)
  281. (SUBPARTITION subpart11 STORAGE ENGINE = $engine,
  282. SUBPARTITION subpart12 STORAGE ENGINE = $engine));
  283. --source include/partition_10.inc
  284. DROP TABLE t1;
  285. }
  286. eval SET SESSION storage_engine=$engine;
  287. --echo
  288. --echo #------------------------------------------------------------------------
  289. --echo # 3. Check assigning the number of partitions and subpartitions
  290. --echo # with and without named partitions/subpartitions
  291. --echo #------------------------------------------------------------------------
  292. --disable_warnings
  293. DROP TABLE IF EXISTS t1;
  294. --enable_warnings
  295. --echo # 3.1 (positive) without partition/subpartition number assignment
  296. --echo # 3.1.1 no partition number, no named partitions
  297. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  298. PARTITION BY HASH(f1);
  299. --source include/partition_10.inc
  300. DROP TABLE t1;
  301. --echo # 3.1.2 no partition number, named partitions
  302. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  303. PARTITION BY HASH(f1) (PARTITION part1, PARTITION part2);
  304. --source include/partition_10.inc
  305. DROP TABLE t1;
  306. # Attention: Several combinations are impossible
  307. # If subpartitioning exists
  308. # - partitioning algorithm must be RANGE or LIST
  309. # This implies the assignment of named partitions.
  310. # - subpartitioning algorithm must be HASH or KEY
  311. --echo # 3.1.3 variations on no partition/subpartition number, named partitions,
  312. --echo # different subpartitions are/are not named
  313. #
  314. # Partition name -- "properties"
  315. # part1 -- first/non last
  316. # part2 -- non first/non last
  317. # part3 -- non first/ last
  318. #
  319. # Testpattern:
  320. # named subpartitions in
  321. # Partition part1 part2 part3
  322. # N N N
  323. # N N Y
  324. # N Y N
  325. # N Y Y
  326. # Y N N
  327. # Y N Y
  328. # Y Y N
  329. # Y Y Y
  330. --disable_query_log
  331. let $part0= CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  332. PARTITION BY RANGE(f1) SUBPARTITION BY HASH(f1);
  333. #
  334. eval SET @aux = '(PARTITION part1 VALUES LESS THAN ($max_row_div2),';
  335. let $part1_N= `SELECT @AUX`;
  336. eval SET @aux = '(PARTITION part1 VALUES LESS THAN ($max_row_div2)
  337. (SUBPARTITION subpart11 , SUBPARTITION subpart12 ),';
  338. let $part1_Y= `SELECT @AUX`;
  339. #
  340. eval SET @aux = 'PARTITION part2 VALUES LESS THAN ($max_row),';
  341. let $part2_N= `SELECT @AUX`;
  342. eval SET @aux = 'PARTITION part2 VALUES LESS THAN ($max_row)
  343. (SUBPARTITION subpart21 , SUBPARTITION subpart22 ),';
  344. let $part2_Y= `SELECT @AUX`;
  345. #
  346. eval SET @aux = 'PARTITION part3 VALUES LESS THAN ($max_int_4))';
  347. let $part3_N= `SELECT @AUX`;
  348. eval SET @aux = 'PARTITION part3 VALUES LESS THAN ($max_int_4)
  349. (SUBPARTITION subpart31 , SUBPARTITION subpart32 ))';
  350. let $part3_Y= `SELECT @AUX`;
  351. --enable_query_log
  352. eval $part0 $part1_N $part2_N $part3_N ;
  353. DROP TABLE t1;
  354. # Bug#15407 Partitions: crash if subpartition
  355. if ($fixed_bug15407)
  356. {
  357. eval $part0 $part1_N $part2_N $part3_Y ;
  358. --source include/partition_10.inc
  359. DROP TABLE t1;
  360. eval $part0 $part1_N $part2_Y $part3_N ;
  361. --source include/partition_10.inc
  362. DROP TABLE t1;
  363. eval $part0 $part1_N $part2_Y $part3_Y ;
  364. --source include/partition_10.inc
  365. DROP TABLE t1;
  366. eval $part0 $part1_Y $part2_N $part3_N ;
  367. --source include/partition_10.inc
  368. DROP TABLE t1;
  369. eval $part0 $part1_Y $part2_N $part3_Y ;
  370. --source include/partition_10.inc
  371. DROP TABLE t1;
  372. eval $part0 $part1_Y $part2_Y $part3_N ;
  373. --source include/partition_10.inc
  374. DROP TABLE t1;
  375. }
  376. eval $part0 $part1_Y $part2_Y $part3_Y ;
  377. --source include/partition_10.inc
  378. DROP TABLE t1;
  379. --echo # 3.2 partition/subpartition numbers good and bad values and notations
  380. --disable_warnings
  381. DROP TABLE IF EXISTS t1;
  382. --enable_warnings
  383. --echo # 3.2.1 partition/subpartition numbers INTEGER notation
  384. # ML: "positive/negative" is my private judgement. It need no to correspond
  385. # with the server response.
  386. # (positive) number = 2
  387. let $part_number= 2;
  388. --source include/partition_11.inc
  389. # (positive) special case number = 1
  390. let $part_number= 1;
  391. --source include/partition_11.inc
  392. # (negative) 0 is non sense
  393. let $part_number= 0;
  394. --source include/partition_11.inc
  395. # (negative) -1 is non sense
  396. let $part_number= -1;
  397. --source include/partition_11.inc
  398. # (negative) 1000000 is too huge
  399. let $part_number= 1000000;
  400. --source include/partition_11.inc
  401. if ($fixed_bug15890)
  402. {
  403. --echo # 3.2.2 partition/subpartition numbers DECIMAL notation
  404. # (positive) number = 2.0
  405. let $part_number= 2.0;
  406. --source include/partition_11.inc
  407. # (negative) -2.0 is non sense
  408. let $part_number= -2.0;
  409. --source include/partition_11.inc
  410. # (negative) case number = 0.0 is non sense
  411. let $part_number= 0.0;
  412. --source include/partition_11.inc
  413. # Bug#15890 Partitions: Strange interpretation of partition number
  414. # (negative) number = 1.5 is non sense
  415. let $part_number= 1.5;
  416. --source include/partition_11.inc
  417. # (negative) number is too huge
  418. let $part_number= 999999999999999999999999999999.999999999999999999999999999999;
  419. --source include/partition_11.inc
  420. # (negative) number is nearly zero
  421. let $part_number= 0.000000000000000000000000000001;
  422. --source include/partition_11.inc
  423. --echo # 3.2.3 partition/subpartition numbers FLOAT notation
  424. ##### FLOAT notation
  425. # (positive) number = 2.0E+0
  426. let $part_number= 2.0E+0;
  427. --source include/partition_11.inc
  428. # Bug#15890 Partitions: Strange interpretation of partition number
  429. # (positive) number = 0.2E+1
  430. let $part_number= 0.2E+1;
  431. --source include/partition_11.inc
  432. # (negative) -2.0E+0 is non sense
  433. let $part_number= -2.0E+0;
  434. --source include/partition_11.inc
  435. # (negative) 0.15E+1 is non sense
  436. let $part_number= 0.15E+1;
  437. --source include/partition_11.inc
  438. # (negative) 0.0E+300 is zero
  439. let $part_number= 0.0E+300;
  440. --source include/partition_11.inc
  441. # Bug#15890 Partitions: Strange interpretation of partition number
  442. # (negative) 1E+300 is too huge
  443. let $part_number= 1E+300;
  444. --source include/partition_11.inc
  445. # (negative) 1E-300 is nearly zero
  446. let $part_number= 1E-300;
  447. --source include/partition_11.inc
  448. }
  449. --echo # 3.2.4 partition/subpartition numbers STRING notation
  450. ##### STRING notation
  451. # (negative?) case number = '2'
  452. let $part_number= '2';
  453. --source include/partition_11.inc
  454. # (negative?) case number = '2.0'
  455. let $part_number= '2.0';
  456. --source include/partition_11.inc
  457. # (negative?) case number = '0.2E+1'
  458. let $part_number= '0.2E+1';
  459. --source include/partition_11.inc
  460. # (negative) Strings starts with digit, but 'A' follows
  461. let $part_number= '2A';
  462. --source include/partition_11.inc
  463. # (negative) Strings starts with 'A', but digit follows
  464. let $part_number= 'A2';
  465. --source include/partition_11.inc
  466. # (negative) empty string
  467. let $part_number= '';
  468. --source include/partition_11.inc
  469. # (negative) string without any digits
  470. let $part_number= 'GARBAGE';
  471. --source include/partition_11.inc
  472. --echo # 3.2.5 partition/subpartition numbers other notations
  473. # (negative) Strings starts with digit, but 'A' follows
  474. let $part_number= 2A;
  475. --source include/partition_11.inc
  476. # (negative) Strings starts with 'A', but digit follows
  477. let $part_number= A2;
  478. --source include/partition_11.inc
  479. # (negative) string without any digits
  480. let $part_number= GARBAGE;
  481. --source include/partition_11.inc
  482. # (negative?) double quotes
  483. let $part_number= "2";
  484. --source include/partition_11.inc
  485. # (negative) Strings starts with digit, but 'A' follows
  486. let $part_number= "2A";
  487. --source include/partition_11.inc
  488. # (negative) Strings starts with 'A', but digit follows
  489. let $part_number= "A2";
  490. --source include/partition_11.inc
  491. # (negative) string without any digits
  492. let $part_number= "GARBAGE";
  493. --source include/partition_11.inc
  494. --echo # 3.3 Mixups of assigned partition/subpartition numbers and names
  495. --echo # 3.3.1 (positive) number of partition/subpartition
  496. --echo # = number of named partition/subpartition
  497. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  498. PARTITION BY HASH(f1) PARTITIONS 2 ( PARTITION part1, PARTITION part2 ) ;
  499. SHOW CREATE TABLE t1;
  500. DROP TABLE t1;
  501. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  502. PARTITION BY RANGE(f1) PARTITIONS 2
  503. SUBPARTITION BY HASH(f1) SUBPARTITIONS 2
  504. ( PARTITION part1 VALUES LESS THAN (1000)
  505. (SUBPARTITION subpart11, SUBPARTITION subpart12),
  506. PARTITION part2 VALUES LESS THAN (2147483647)
  507. (SUBPARTITION subpart21, SUBPARTITION subpart22)
  508. );
  509. --source include/partition_layout.inc
  510. DROP TABLE t1;
  511. --echo # 3.3.2 (positive) number of partition/subpartition ,
  512. --echo # 0 (= no) named partition/subpartition
  513. --echo # already checked above
  514. --echo # 3.3.3 (negative) number of partitions/subpartitions
  515. --echo # > number of named partitions/subpartitions
  516. --error 1064
  517. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  518. PARTITION BY HASH(f1) PARTITIONS 2 ( PARTITION part1 ) ;
  519. # Wrong number of named subpartitions in first partition
  520. --error 1064
  521. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  522. PARTITION BY RANGE(f1)
  523. SUBPARTITION BY HASH(f1) SUBPARTITIONS 2
  524. ( PARTITION part1 VALUES LESS THAN (1000)
  525. (SUBPARTITION subpart11 ),
  526. PARTITION part2 VALUES LESS THAN (2147483647)
  527. (SUBPARTITION subpart21, SUBPARTITION subpart22)
  528. );
  529. # Wrong number of named subpartitions in non first/non last partition
  530. --error 1064
  531. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  532. PARTITION BY RANGE(f1)
  533. SUBPARTITION BY HASH(f1) SUBPARTITIONS 2
  534. ( PARTITION part1 VALUES LESS THAN (1000)
  535. (SUBPARTITION subpart11, SUBPARTITION subpart12),
  536. PARTITION part2 VALUES LESS THAN (2000)
  537. (SUBPARTITION subpart21 ),
  538. PARTITION part3 VALUES LESS THAN (2147483647)
  539. (SUBPARTITION subpart31, SUBPARTITION subpart32)
  540. );
  541. # Wrong number of named subpartitions in last partition
  542. --error 1064
  543. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  544. PARTITION BY RANGE(f1) PARTITIONS 2
  545. SUBPARTITION BY HASH(f1) SUBPARTITIONS 2
  546. ( PARTITION part1 VALUES LESS THAN (1000)
  547. (SUBPARTITION subpart11, SUBPARTITION subpart12),
  548. PARTITION part2 VALUES LESS THAN (2147483647)
  549. (SUBPARTITION subpart21 )
  550. );
  551. --echo # 3.3.4 (negative) number of partitions < number of named partitions
  552. --error 1064
  553. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  554. PARTITION BY HASH(f1) PARTITIONS 1 ( PARTITION part1, PARTITION part2 ) ;
  555. # Wrong number of named subpartitions in first partition
  556. --error 1064
  557. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  558. PARTITION BY RANGE(f1)
  559. SUBPARTITION BY HASH(f1) SUBPARTITIONS 1
  560. ( PARTITION part1 VALUES LESS THAN (1000)
  561. (SUBPARTITION subpart11, SUBPARTITION subpart12),
  562. PARTITION part2 VALUES LESS THAN (2147483647)
  563. (SUBPARTITION subpart21, SUBPARTITION subpart22)
  564. );
  565. # Wrong number of named subpartitions in non first/non last partition
  566. --error 1064
  567. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  568. PARTITION BY RANGE(f1)
  569. SUBPARTITION BY HASH(f1) SUBPARTITIONS 1
  570. ( PARTITION part1 VALUES LESS THAN (1000)
  571. (SUBPARTITION subpart11, SUBPARTITION subpart12),
  572. PARTITION part2 VALUES LESS THAN (2000)
  573. (SUBPARTITION subpart21 ),
  574. PARTITION part3 VALUES LESS THAN (2147483647)
  575. (SUBPARTITION subpart31, SUBPARTITION subpart32)
  576. );
  577. # Wrong number of named subpartitions in last partition
  578. --error 1064
  579. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  580. PARTITION BY RANGE(f1)
  581. SUBPARTITION BY HASH(f1) SUBPARTITIONS 1
  582. ( PARTITION part1 VALUES LESS THAN (1000)
  583. (SUBPARTITION subpart11, SUBPARTITION subpart12),
  584. PARTITION part2 VALUES LESS THAN (2147483647)
  585. (SUBPARTITION subpart21, SUBPARTITION subpart22)
  586. );
  587. --echo
  588. --echo #------------------------------------------------------------------------
  589. --echo # 4. Checks of logical partition/subpartition name
  590. --echo # file name clashes during CREATE TABLE
  591. --echo #------------------------------------------------------------------------
  592. --disable_warnings
  593. DROP TABLE IF EXISTS t1;
  594. --enable_warnings
  595. --echo # 4.1 (negative) A partition name used more than once
  596. --error ER_SAME_NAME_PARTITION
  597. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  598. PARTITION BY HASH(f1) (PARTITION part1, PARTITION part1);
  599. #
  600. if ($fixed_bug15408)
  601. {
  602. # Bug#15408 Partitions: subpartition names are not unique
  603. --error ER_SAME_NAME_PARTITION
  604. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  605. PARTITION BY RANGE(f1)
  606. SUBPARTITION BY HASH(f1)
  607. ( PARTITION part1 VALUES LESS THAN (1000)
  608. (SUBPARTITION subpart11, SUBPARTITION subpart11)
  609. );
  610. }
  611. --echo # FIXME Implement testcases with filename problems
  612. --echo # existing file of other table --- partition/subpartition file name
  613. --echo # partition/subpartition file name --- file of the same table
  614. --echo
  615. --echo #------------------------------------------------------------------------
  616. --echo # 5. Alter table experiments
  617. --echo #------------------------------------------------------------------------
  618. --disable_warnings
  619. DROP TABLE IF EXISTS t1;
  620. --enable_warnings
  621. --echo # 5.1 alter table add partition
  622. --echo # 5.1.1 (negative) add partition to non partitioned table
  623. CREATE TABLE t1 ( f1 INTEGER, f2 char(20));
  624. --source include/partition_layout.inc
  625. # MyISAM gets ER_PARTITION_MGMT_ON_NONPARTITIONED and NDB 1005
  626. # The error code of NDB differs, because all NDB tables are partitioned even
  627. # if the CREATE TABLE does not contain a partitioning clause.
  628. --error ER_PARTITION_MGMT_ON_NONPARTITIONED,1005
  629. ALTER TABLE t1 ADD PARTITION (PARTITION part1);
  630. --source include/partition_layout.inc
  631. DROP TABLE t1;
  632. --echo # 5.1.2 Add one partition to a table with one partition
  633. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  634. PARTITION BY HASH(f1);
  635. --source include/partition_layout.inc
  636. eval INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND $max_row_div2 - 1;
  637. --disable_query_log
  638. eval SELECT $engine = 'NDB' INTO @aux;
  639. let $my_exit= `SELECT @aux`;
  640. if ($my_exit)
  641. {
  642. exit;
  643. }
  644. --enable_query_log
  645. ALTER TABLE t1 ADD PARTITION (PARTITION part1);
  646. --source include/partition_12.inc
  647. DROP TABLE t1;
  648. --echo # 5.1.3 Several times add one partition to a table with some partitions
  649. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  650. PARTITION BY HASH(f1) (PARTITION part1, PARTITION part3);
  651. --source include/partition_layout.inc
  652. eval INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND $max_row_div2 - 1;
  653. # Partition name before first existing partition name
  654. ALTER TABLE t1 ADD PARTITION (PARTITION part0);
  655. --source include/partition_12.inc
  656. DELETE FROM t1;
  657. eval INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND $max_row_div2 - 1;
  658. # Partition name between existing partition names
  659. ALTER TABLE t1 ADD PARTITION (PARTITION part2);
  660. --source include/partition_12.inc
  661. DELETE FROM t1;
  662. eval INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND $max_row_div2 - 1;
  663. if ($fixed_bug13447)
  664. {
  665. # Partition name after all existing partition names
  666. # Bug#13447 Partitions: crash with alter table
  667. ALTER TABLE t1 ADD PARTITION (PARTITION part4);
  668. }
  669. --source include/partition_12.inc
  670. DROP TABLE t1;
  671. --echo # 5.1.4 Add several partitions to a table with some partitions
  672. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  673. PARTITION BY HASH(f1) (PARTITION part1, PARTITION part3);
  674. --source include/partition_layout.inc
  675. eval INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND $max_row_div2 - 1;
  676. if ($fixed_bug13447)
  677. {
  678. # Bug#13447 Partitions: crash with alter table
  679. ALTER TABLE t1 ADD PARTITION (PARTITION part0, PARTITION part2, PARTITION part4);
  680. }
  681. --source include/partition_12.inc
  682. DROP TABLE t1;
  683. --echo # 5.1.5 (negative) Add partitions to a table with some partitions
  684. --echo # clash on new and already existing partition names
  685. CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  686. PARTITION BY HASH(f1) (PARTITION part1, PARTITION part2, PARTITION part3);
  687. # Clash on first/non last partition name
  688. --error ER_SAME_NAME_PARTITION
  689. ALTER TABLE t1 ADD PARTITION (PARTITION part1);
  690. # Clash on non first/non last partition name
  691. --error ER_SAME_NAME_PARTITION
  692. ALTER TABLE t1 ADD PARTITION (PARTITION part2);
  693. # Clash on non first/last partition name
  694. --error ER_SAME_NAME_PARTITION
  695. ALTER TABLE t1 ADD PARTITION (PARTITION part3);
  696. # Clash on all partition names
  697. --error ER_SAME_NAME_PARTITION
  698. ALTER TABLE t1 ADD PARTITION (PARTITION part1, PARTITION part2, PARTITION part3);
  699. DROP TABLE t1;
  700. # FIXME Is there any way to add a subpartition to an already existing partition
  701. --echo # 5.2 alter table add subpartition
  702. --echo # 5.2.1 Add one subpartition to a table with subpartitioning rule and
  703. --echo # no explicit defined subpartitions
  704. eval CREATE TABLE t1 ( f1 INTEGER, f2 char(20))
  705. PARTITION BY RANGE(f1)
  706. SUBPARTITION BY HASH(f1)
  707. (PARTITION part1 VALUES LESS THAN ($max_row_div2));
  708. if ($fixed_bug16370)
  709. {
  710. --source include/partition_layout.inc
  711. }
  712. eval INSERT INTO t1 SELECT * FROM t0_template WHERE f1 BETWEEN 1 AND $max_row_div2 - 1;
  713. eval ALTER TABLE t1 ADD PARTITION (PARTITION part2 VALUES LESS THAN ($max_int_4)
  714. (SUBPARTITION subpart21));
  715. if ($fixed_bug16370)
  716. {
  717. --source include/partition_12.inc
  718. }
  719. DROP TABLE t1;
  720. DROP TABLE if exists t0_template;