summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/storage_engine
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:24:36 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 12:24:36 +0000
commit06eaf7232e9a920468c0f8d74dcf2fe8b555501c (patch)
treee2c7b5777f728320e5b5542b6213fd3591ba51e2 /mysql-test/suite/storage_engine
parentInitial commit. (diff)
downloadmariadb-06eaf7232e9a920468c0f8d74dcf2fe8b555501c.tar.xz
mariadb-06eaf7232e9a920468c0f8d74dcf2fe8b555501c.zip
Adding upstream version 1:10.11.6.upstream/1%10.11.6
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mysql-test/suite/storage_engine')
-rw-r--r--mysql-test/suite/storage_engine/1st.result11
-rw-r--r--mysql-test/suite/storage_engine/1st.test81
-rw-r--r--mysql-test/suite/storage_engine/alter_table.inc91
-rw-r--r--mysql-test/suite/storage_engine/alter_table.result147
-rw-r--r--mysql-test/suite/storage_engine/alter_table.test148
-rw-r--r--mysql-test/suite/storage_engine/alter_table_online.result34
-rw-r--r--mysql-test/suite/storage_engine/alter_table_online.test158
-rw-r--r--mysql-test/suite/storage_engine/alter_tablespace.result21
-rw-r--r--mysql-test/suite/storage_engine/alter_tablespace.test102
-rw-r--r--mysql-test/suite/storage_engine/analyze_table.inc43
-rw-r--r--mysql-test/suite/storage_engine/analyze_table.result29
-rw-r--r--mysql-test/suite/storage_engine/analyze_table.test14
-rw-r--r--mysql-test/suite/storage_engine/autoinc_secondary.result40
-rw-r--r--mysql-test/suite/storage_engine/autoinc_secondary.test73
-rw-r--r--mysql-test/suite/storage_engine/autoinc_vars.result53
-rw-r--r--mysql-test/suite/storage_engine/autoinc_vars.test68
-rw-r--r--mysql-test/suite/storage_engine/autoincrement.result133
-rw-r--r--mysql-test/suite/storage_engine/autoincrement.test114
-rw-r--r--mysql-test/suite/storage_engine/cache_index.result69
-rw-r--r--mysql-test/suite/storage_engine/cache_index.test142
-rw-r--r--mysql-test/suite/storage_engine/check_errors.inc80
-rw-r--r--mysql-test/suite/storage_engine/check_table.inc62
-rw-r--r--mysql-test/suite/storage_engine/check_table.result68
-rw-r--r--mysql-test/suite/storage_engine/check_table.test14
-rw-r--r--mysql-test/suite/storage_engine/checksum_table.inc31
-rw-r--r--mysql-test/suite/storage_engine/checksum_table.result20
-rw-r--r--mysql-test/suite/storage_engine/checksum_table.test11
-rw-r--r--mysql-test/suite/storage_engine/checksum_table_live.inc30
-rw-r--r--mysql-test/suite/storage_engine/checksum_table_live.result20
-rw-r--r--mysql-test/suite/storage_engine/checksum_table_live.test13
-rw-r--r--mysql-test/suite/storage_engine/cleanup_engine.inc11
-rw-r--r--mysql-test/suite/storage_engine/col_not_null.inc92
-rw-r--r--mysql-test/suite/storage_engine/col_null.inc65
-rw-r--r--mysql-test/suite/storage_engine/col_opt_default.result20
-rw-r--r--mysql-test/suite/storage_engine/col_opt_default.test49
-rw-r--r--mysql-test/suite/storage_engine/col_opt_not_null.result2073
-rw-r--r--mysql-test/suite/storage_engine/col_opt_not_null.test260
-rw-r--r--mysql-test/suite/storage_engine/col_opt_null.result2003
-rw-r--r--mysql-test/suite/storage_engine/col_opt_null.test208
-rw-r--r--mysql-test/suite/storage_engine/col_opt_unsigned.result705
-rw-r--r--mysql-test/suite/storage_engine/col_opt_unsigned.test95
-rw-r--r--mysql-test/suite/storage_engine/col_opt_zerofill.result687
-rw-r--r--mysql-test/suite/storage_engine/col_opt_zerofill.test88
-rw-r--r--mysql-test/suite/storage_engine/create_table.inc174
-rw-r--r--mysql-test/suite/storage_engine/create_table.result45
-rw-r--r--mysql-test/suite/storage_engine/create_table.test107
-rw-r--r--mysql-test/suite/storage_engine/define_engine.inc45
-rw-r--r--mysql-test/suite/storage_engine/delete.result77
-rw-r--r--mysql-test/suite/storage_engine/delete.test68
-rw-r--r--mysql-test/suite/storage_engine/delete_ignore.result59
-rw-r--r--mysql-test/suite/storage_engine/delete_ignore.test44
-rw-r--r--mysql-test/suite/storage_engine/delete_low_prio.result59
-rw-r--r--mysql-test/suite/storage_engine/delete_low_prio.test160
-rw-r--r--mysql-test/suite/storage_engine/delete_quick.result25
-rw-r--r--mysql-test/suite/storage_engine/delete_quick.test55
-rw-r--r--mysql-test/suite/storage_engine/delete_with_keys.result38
-rw-r--r--mysql-test/suite/storage_engine/delete_with_keys.test74
-rw-r--r--mysql-test/suite/storage_engine/describe.result18
-rw-r--r--mysql-test/suite/storage_engine/describe.test50
-rw-r--r--mysql-test/suite/storage_engine/disabled.def12
-rw-r--r--mysql-test/suite/storage_engine/foreign_keys.result71
-rw-r--r--mysql-test/suite/storage_engine/foreign_keys.test149
-rw-r--r--mysql-test/suite/storage_engine/fulltext_search.result132
-rw-r--r--mysql-test/suite/storage_engine/fulltext_search.test187
-rw-r--r--mysql-test/suite/storage_engine/handler.result77
-rw-r--r--mysql-test/suite/storage_engine/handler.test81
-rw-r--r--mysql-test/suite/storage_engine/have_default_index.inc20
-rw-r--r--mysql-test/suite/storage_engine/have_engine.inc127
-rw-r--r--mysql-test/suite/storage_engine/index.inc194
-rw-r--r--mysql-test/suite/storage_engine/index.result67
-rw-r--r--mysql-test/suite/storage_engine/index.test23
-rw-r--r--mysql-test/suite/storage_engine/index_enable_disable.result45
-rw-r--r--mysql-test/suite/storage_engine/index_enable_disable.test88
-rw-r--r--mysql-test/suite/storage_engine/index_key_block_size.result43
-rw-r--r--mysql-test/suite/storage_engine/index_key_block_size.test125
-rw-r--r--mysql-test/suite/storage_engine/index_primary.result53
-rw-r--r--mysql-test/suite/storage_engine/index_primary.test136
-rw-r--r--mysql-test/suite/storage_engine/index_type_btree.result67
-rw-r--r--mysql-test/suite/storage_engine/index_type_btree.test12
-rw-r--r--mysql-test/suite/storage_engine/index_type_hash.result67
-rw-r--r--mysql-test/suite/storage_engine/index_type_hash.test12
-rw-r--r--mysql-test/suite/storage_engine/insert.result149
-rw-r--r--mysql-test/suite/storage_engine/insert.test78
-rw-r--r--mysql-test/suite/storage_engine/insert_delayed.result25
-rw-r--r--mysql-test/suite/storage_engine/insert_delayed.test60
-rw-r--r--mysql-test/suite/storage_engine/insert_high_prio.result64
-rw-r--r--mysql-test/suite/storage_engine/insert_high_prio.test141
-rw-r--r--mysql-test/suite/storage_engine/insert_low_prio.result39
-rw-r--r--mysql-test/suite/storage_engine/insert_low_prio.test93
-rw-r--r--mysql-test/suite/storage_engine/insert_with_keys.result173
-rw-r--r--mysql-test/suite/storage_engine/insert_with_keys.test173
-rw-r--r--mysql-test/suite/storage_engine/loaddata.result88
-rw-r--r--mysql-test/suite/storage_engine/loaddata.test104
-rw-r--r--mysql-test/suite/storage_engine/lock.result111
-rw-r--r--mysql-test/suite/storage_engine/lock.test242
-rw-r--r--mysql-test/suite/storage_engine/lock_concurrent.result19
-rw-r--r--mysql-test/suite/storage_engine/lock_concurrent.test52
-rw-r--r--mysql-test/suite/storage_engine/mask_engine.inc14
-rw-r--r--mysql-test/suite/storage_engine/misc.result100
-rw-r--r--mysql-test/suite/storage_engine/misc.test47
-rw-r--r--mysql-test/suite/storage_engine/my.cnf8
-rw-r--r--mysql-test/suite/storage_engine/obfuscate.inc4
-rw-r--r--mysql-test/suite/storage_engine/optimize_table.inc42
-rw-r--r--mysql-test/suite/storage_engine/optimize_table.result29
-rw-r--r--mysql-test/suite/storage_engine/optimize_table.test14
-rw-r--r--mysql-test/suite/storage_engine/parts/alter_table.result42
-rw-r--r--mysql-test/suite/storage_engine/parts/alter_table.test107
-rw-r--r--mysql-test/suite/storage_engine/parts/analyze_table.result47
-rw-r--r--mysql-test/suite/storage_engine/parts/analyze_table.test61
-rw-r--r--mysql-test/suite/storage_engine/parts/check_table.result104
-rw-r--r--mysql-test/suite/storage_engine/parts/check_table.test82
-rw-r--r--mysql-test/suite/storage_engine/parts/checksum_table.result40
-rw-r--r--mysql-test/suite/storage_engine/parts/checksum_table.test13
-rw-r--r--mysql-test/suite/storage_engine/parts/create_table.result91
-rw-r--r--mysql-test/suite/storage_engine/parts/create_table.test179
-rw-r--r--mysql-test/suite/storage_engine/parts/my.cnf9
-rw-r--r--mysql-test/suite/storage_engine/parts/optimize_table.result54
-rw-r--r--mysql-test/suite/storage_engine/parts/optimize_table.test69
-rw-r--r--mysql-test/suite/storage_engine/parts/repair_table.opt1
-rw-r--r--mysql-test/suite/storage_engine/parts/repair_table.result232
-rw-r--r--mysql-test/suite/storage_engine/parts/repair_table.test78
-rw-r--r--mysql-test/suite/storage_engine/parts/truncate_table.result68
-rw-r--r--mysql-test/suite/storage_engine/parts/truncate_table.test111
-rw-r--r--mysql-test/suite/storage_engine/repair_table.inc158
-rw-r--r--mysql-test/suite/storage_engine/repair_table.result108
-rw-r--r--mysql-test/suite/storage_engine/repair_table.test14
-rw-r--r--mysql-test/suite/storage_engine/replace.result47
-rw-r--r--mysql-test/suite/storage_engine/replace.test67
-rw-r--r--mysql-test/suite/storage_engine/se-innodb.out1
-rw-r--r--mysql-test/suite/storage_engine/select.result391
-rw-r--r--mysql-test/suite/storage_engine/select.test210
-rw-r--r--mysql-test/suite/storage_engine/select_high_prio.result45
-rw-r--r--mysql-test/suite/storage_engine/select_high_prio.test137
-rw-r--r--mysql-test/suite/storage_engine/show_engine.result11
-rw-r--r--mysql-test/suite/storage_engine/show_engine.test31
-rw-r--r--mysql-test/suite/storage_engine/show_table_status.result68
-rw-r--r--mysql-test/suite/storage_engine/show_table_status.test30
-rw-r--r--mysql-test/suite/storage_engine/strict_check_errors.inc23
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_ai.result14
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_ai.test35
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_avg_row_length.result16
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_avg_row_length.test35
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_checksum.result16
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_checksum.test30
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_connection.result24
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_connection.test52
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_data_dir.result19
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_data_dir.test52
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_delay_key_write.result16
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_delay_key_write.test35
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_index_dir.result19
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_index_dir.test52
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_insert_method.result16
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_insert_method.test35
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_key_block_size.result16
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_key_block_size.test35
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_max_rows.result16
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_max_rows.test35
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_min_rows.result16
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_min_rows.test35
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_pack_keys.result16
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_pack_keys.test35
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_password.result16
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_password.test40
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_row_format.result30
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_row_format.test59
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_union.result14
-rw-r--r--mysql-test/suite/storage_engine/tbl_opt_union.test41
-rw-r--r--mysql-test/suite/storage_engine/tbl_standard_opts.result40
-rw-r--r--mysql-test/suite/storage_engine/tbl_standard_opts.test60
-rw-r--r--mysql-test/suite/storage_engine/tbl_temporary.result11
-rw-r--r--mysql-test/suite/storage_engine/tbl_temporary.test33
-rw-r--r--mysql-test/suite/storage_engine/truncate_table.result41
-rw-r--r--mysql-test/suite/storage_engine/truncate_table.test81
-rw-r--r--mysql-test/suite/storage_engine/trx/cons_snapshot_repeatable_read.result18
-rw-r--r--mysql-test/suite/storage_engine/trx/cons_snapshot_repeatable_read.test9
-rw-r--r--mysql-test/suite/storage_engine/trx/cons_snapshot_serializable.result18
-rw-r--r--mysql-test/suite/storage_engine/trx/cons_snapshot_serializable.test9
-rw-r--r--mysql-test/suite/storage_engine/trx/consistent_snapshot.inc48
-rw-r--r--mysql-test/suite/storage_engine/trx/delete.result72
-rw-r--r--mysql-test/suite/storage_engine/trx/delete.test51
-rw-r--r--mysql-test/suite/storage_engine/trx/insert.result55
-rw-r--r--mysql-test/suite/storage_engine/trx/insert.test44
-rw-r--r--mysql-test/suite/storage_engine/trx/level_read_committed.result91
-rw-r--r--mysql-test/suite/storage_engine/trx/level_read_committed.test10
-rw-r--r--mysql-test/suite/storage_engine/trx/level_read_uncommitted.result116
-rw-r--r--mysql-test/suite/storage_engine/trx/level_read_uncommitted.test9
-rw-r--r--mysql-test/suite/storage_engine/trx/level_repeatable_read.result69
-rw-r--r--mysql-test/suite/storage_engine/trx/level_repeatable_read.test8
-rw-r--r--mysql-test/suite/storage_engine/trx/level_serializable.result56
-rw-r--r--mysql-test/suite/storage_engine/trx/level_serializable.test8
-rw-r--r--mysql-test/suite/storage_engine/trx/my.cnf7
-rw-r--r--mysql-test/suite/storage_engine/trx/select_for_update.result35
-rw-r--r--mysql-test/suite/storage_engine/trx/select_for_update.test85
-rw-r--r--mysql-test/suite/storage_engine/trx/select_lock_in_share_mode.result37
-rw-r--r--mysql-test/suite/storage_engine/trx/select_lock_in_share_mode.test80
-rw-r--r--mysql-test/suite/storage_engine/trx/support_savepoints.inc10
-rw-r--r--mysql-test/suite/storage_engine/trx/support_transactions.inc10
-rw-r--r--mysql-test/suite/storage_engine/trx/support_xa.inc12
-rw-r--r--mysql-test/suite/storage_engine/trx/transaction_isolation.inc97
-rw-r--r--mysql-test/suite/storage_engine/trx/update.result48
-rw-r--r--mysql-test/suite/storage_engine/trx/update.test50
-rw-r--r--mysql-test/suite/storage_engine/trx/xa.result96
-rw-r--r--mysql-test/suite/storage_engine/trx/xa.test116
-rw-r--r--mysql-test/suite/storage_engine/trx/xa_recovery.result29
-rw-r--r--mysql-test/suite/storage_engine/trx/xa_recovery.test74
-rw-r--r--mysql-test/suite/storage_engine/type_binary.inc52
-rw-r--r--mysql-test/suite/storage_engine/type_binary.result62
-rw-r--r--mysql-test/suite/storage_engine/type_binary.test10
-rw-r--r--mysql-test/suite/storage_engine/type_binary_indexes.result126
-rw-r--r--mysql-test/suite/storage_engine/type_binary_indexes.test154
-rw-r--r--mysql-test/suite/storage_engine/type_bit.inc76
-rw-r--r--mysql-test/suite/storage_engine/type_bit.result47
-rw-r--r--mysql-test/suite/storage_engine/type_bit.test10
-rw-r--r--mysql-test/suite/storage_engine/type_bit_indexes.result132
-rw-r--r--mysql-test/suite/storage_engine/type_bit_indexes.test175
-rw-r--r--mysql-test/suite/storage_engine/type_blob.inc65
-rw-r--r--mysql-test/suite/storage_engine/type_blob.result54
-rw-r--r--mysql-test/suite/storage_engine/type_blob.test10
-rw-r--r--mysql-test/suite/storage_engine/type_blob_indexes.result152
-rw-r--r--mysql-test/suite/storage_engine/type_blob_indexes.test188
-rw-r--r--mysql-test/suite/storage_engine/type_bool.inc81
-rw-r--r--mysql-test/suite/storage_engine/type_bool.result70
-rw-r--r--mysql-test/suite/storage_engine/type_bool.test10
-rw-r--r--mysql-test/suite/storage_engine/type_char.inc59
-rw-r--r--mysql-test/suite/storage_engine/type_char.result56
-rw-r--r--mysql-test/suite/storage_engine/type_char.test10
-rw-r--r--mysql-test/suite/storage_engine/type_char_indexes.result146
-rw-r--r--mysql-test/suite/storage_engine/type_char_indexes.test186
-rw-r--r--mysql-test/suite/storage_engine/type_date_time.inc55
-rw-r--r--mysql-test/suite/storage_engine/type_date_time.result50
-rw-r--r--mysql-test/suite/storage_engine/type_date_time.test11
-rw-r--r--mysql-test/suite/storage_engine/type_date_time_indexes.result278
-rw-r--r--mysql-test/suite/storage_engine/type_date_time_indexes.test366
-rw-r--r--mysql-test/suite/storage_engine/type_enum.inc69
-rw-r--r--mysql-test/suite/storage_engine/type_enum.result45
-rw-r--r--mysql-test/suite/storage_engine/type_enum.test10
-rw-r--r--mysql-test/suite/storage_engine/type_enum_indexes.result108
-rw-r--r--mysql-test/suite/storage_engine/type_enum_indexes.test146
-rw-r--r--mysql-test/suite/storage_engine/type_fixed.inc89
-rw-r--r--mysql-test/suite/storage_engine/type_fixed.result116
-rw-r--r--mysql-test/suite/storage_engine/type_fixed.test10
-rw-r--r--mysql-test/suite/storage_engine/type_fixed_indexes.result148
-rw-r--r--mysql-test/suite/storage_engine/type_fixed_indexes.test167
-rw-r--r--mysql-test/suite/storage_engine/type_float.inc111
-rw-r--r--mysql-test/suite/storage_engine/type_float.result294
-rw-r--r--mysql-test/suite/storage_engine/type_float.test10
-rw-r--r--mysql-test/suite/storage_engine/type_float_indexes.result146
-rw-r--r--mysql-test/suite/storage_engine/type_float_indexes.test203
-rw-r--r--mysql-test/suite/storage_engine/type_int.inc84
-rw-r--r--mysql-test/suite/storage_engine/type_int.result209
-rw-r--r--mysql-test/suite/storage_engine/type_int.test10
-rw-r--r--mysql-test/suite/storage_engine/type_int_indexes.result133
-rw-r--r--mysql-test/suite/storage_engine/type_int_indexes.test146
-rw-r--r--mysql-test/suite/storage_engine/type_set.inc69
-rw-r--r--mysql-test/suite/storage_engine/type_set.result47
-rw-r--r--mysql-test/suite/storage_engine/type_set.test10
-rw-r--r--mysql-test/suite/storage_engine/type_set_indexes.result137
-rw-r--r--mysql-test/suite/storage_engine/type_set_indexes.test167
-rw-r--r--mysql-test/suite/storage_engine/type_spatial.inc738
-rw-r--r--mysql-test/suite/storage_engine/type_spatial.result700
-rw-r--r--mysql-test/suite/storage_engine/type_spatial.test10
-rw-r--r--mysql-test/suite/storage_engine/type_spatial_indexes.result1400
-rw-r--r--mysql-test/suite/storage_engine/type_spatial_indexes.test15
-rw-r--r--mysql-test/suite/storage_engine/type_text.inc65
-rw-r--r--mysql-test/suite/storage_engine/type_text.result54
-rw-r--r--mysql-test/suite/storage_engine/type_text.test10
-rw-r--r--mysql-test/suite/storage_engine/type_text_indexes.result137
-rw-r--r--mysql-test/suite/storage_engine/type_text_indexes.test175
-rw-r--r--mysql-test/suite/storage_engine/type_varbinary.inc101
-rw-r--r--mysql-test/suite/storage_engine/type_varbinary.result91
-rw-r--r--mysql-test/suite/storage_engine/type_varbinary.test10
-rw-r--r--mysql-test/suite/storage_engine/type_varchar.inc100
-rw-r--r--mysql-test/suite/storage_engine/type_varchar.result126
-rw-r--r--mysql-test/suite/storage_engine/type_varchar.test10
-rw-r--r--mysql-test/suite/storage_engine/unexpected_result.inc50
-rw-r--r--mysql-test/suite/storage_engine/update.result50
-rw-r--r--mysql-test/suite/storage_engine/update.test43
-rw-r--r--mysql-test/suite/storage_engine/update_ignore.result54
-rw-r--r--mysql-test/suite/storage_engine/update_ignore.test43
-rw-r--r--mysql-test/suite/storage_engine/update_low_prio.result66
-rw-r--r--mysql-test/suite/storage_engine/update_low_prio.test165
-rw-r--r--mysql-test/suite/storage_engine/update_multi.result65
-rw-r--r--mysql-test/suite/storage_engine/update_multi.test44
-rw-r--r--mysql-test/suite/storage_engine/update_with_keys.result90
-rw-r--r--mysql-test/suite/storage_engine/update_with_keys.test152
-rw-r--r--mysql-test/suite/storage_engine/vcol.result69
-rw-r--r--mysql-test/suite/storage_engine/vcol.test72
288 files changed, 28453 insertions, 0 deletions
diff --git a/mysql-test/suite/storage_engine/1st.result b/mysql-test/suite/storage_engine/1st.result
new file mode 100644
index 00000000..192a8f8f
--- /dev/null
+++ b/mysql-test/suite/storage_engine/1st.result
@@ -0,0 +1,11 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW CREATE TABLE t1;
+SHOW COLUMNS IN t1;
+INSERT INTO t1 VALUES (1,'a');
+INSERT INTO t1 (a,b) VALUES (2,'b');
+SELECT a,b FROM t1;
+a b
+1 a
+2 b
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/1st.test b/mysql-test/suite/storage_engine/1st.test
new file mode 100644
index 00000000..c9ebd8b7
--- /dev/null
+++ b/mysql-test/suite/storage_engine/1st.test
@@ -0,0 +1,81 @@
+#
+# This test checks some very basic capabilities
+# which will be used in almost every other test,
+# and will not be checked through support* variables.
+# If this test does not pass, there is no point
+# at executing other ones.
+#
+# Minimal requirements:
+# - supported column types: INT, CHAR (default CHAR(8), INT(11));
+# - column attributes as declared in define_engine.inc ($default_col_opts)
+# (by default empty, which means no additional attributes apart from the type);
+# - table attributes as declared in define_engine.inc ($default_tbl_opts)
+# (by default empty, which means no additional attributes apart from ENGINE);
+# - CREATE TABLE .. (column1 <column options>, column2 <column options>) ENGINE=<storage_engine>;
+# - INSERT INTO TABLE .. VALUES (val1,val2);
+# - DROP TABLE ..
+# - SELECT a,b FROM ..
+# - SHOW CREATE TABLE ..
+# - SHOW COLUMNS IN ...
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = CREATE TABLE
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --disable_result_log
+ SHOW CREATE TABLE t1;
+ if ($mysql_errname)
+ {
+ --let $functionality = SHOW CREATE TABLE
+ --source unexpected_result.inc
+ }
+ SHOW COLUMNS IN t1;
+ if ($mysql_errname)
+ {
+ --let $functionality = SHOW COLUMNS
+ --source unexpected_result.inc
+ }
+ --enable_result_log
+
+ INSERT INTO t1 VALUES (1,'a');
+ if ($mysql_errname)
+ {
+ --let $functionality = INSERT INTO .. VALUES
+ --source unexpected_result.inc
+ }
+
+ INSERT INTO t1 (a,b) VALUES (2,'b');
+ if ($mysql_errname)
+ {
+ --let $functionality = INSERT INTO .. (column_list) VALUES
+ --source unexpected_result.inc
+ }
+
+ SELECT a,b FROM t1;
+ if ($mysql_errname)
+ {
+ --let $functionality = SELECT a,b FROM ..
+ --source unexpected_result.inc
+ }
+
+ DROP TABLE t1;
+ if ($mysql_errname)
+ {
+ --let $functionality = DROP TABLE
+ --source unexpected_result.inc
+ }
+
+}
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/alter_table.inc b/mysql-test/suite/storage_engine/alter_table.inc
new file mode 100644
index 00000000..0f78c597
--- /dev/null
+++ b/mysql-test/suite/storage_engine/alter_table.inc
@@ -0,0 +1,91 @@
+##################################
+#
+# This include file will be used for all ALTER TABLE statements in the suite.
+# If you need to add additional steps or change the logic, copy the file
+# to storage/<engine>/mysql-test/storage_engine/ folder and modify it there.
+#
+##################
+#
+# Parameters:
+#
+# --let $alter_definition = <alter definition> # mandatory, everything that goes after the table name in ALTER statement
+# --let $table_name = <table name> # optional, default t1
+# --let $error_codes = <expected error codes, as in --error> # optional, default 0
+# --let $online = [0|1] # optional, default 0 (1 adds ONLINE)
+# --let $rename_to = <new table name> # optional, default empty.
+# # If set, means we are running RENAME TO, then alter definition is ignored
+#
+# Usage examples:
+#
+# --let $alter_definition = ADD COLUMN b $char_col DEFAULT ''
+#
+
+if ($rename_to)
+{
+ --let $alter_definition = RENAME TO $rename_to
+}
+
+if (!$alter_definition)
+{
+ --die # The ALTER statement is empty
+}
+
+--let $alter_statement = ALTER
+
+if ($online)
+{
+ --let $alter_statement = $alter_statement ONLINE
+}
+
+if (!$table_name)
+{
+ --let $table_name = t1
+}
+
+--let $alter_statement = $alter_statement TABLE $table_name $alter_definition
+
+
+# We now have the complete ALTER statement in $alter_statement.
+# If your ALTER statement should be composed differently,
+# modify the logic above.
+
+#####################
+# Here you can add logic needed BEFORE the main statement
+# (e.g. base tables need to be altered, etc.).
+# Surround it by --disable_query_log/--enable_query_log
+# if you don't want it to appear in the result output.
+#####################
+
+--source obfuscate.inc
+
+eval $alter_statement;
+--source check_errors.inc
+
+# Make sure you don't add any statements between the main ALTER (above)
+# and saving mysql_errno and mysql_errname (below)
+# They are saved in case you want to add more logic after the main ALTER,
+# because we need the result code of the statement.
+# Also, do not change $alter_statement after it is executed!
+
+--let $my_errno = $mysql_errno
+--let $my_errname = $mysql_errname
+
+#####################
+# Here you can add logic needed AFTER the main statement.
+# Surround it by --disable_query_log/--enable_query_log
+# if you don't want it to appear in the result output.
+#####################
+
+# Unset the parameters, we don't want them to be accidentally reused later
+--let $alter_definition =
+--let $table_name =
+--let $error_codes =
+--let $online = 0
+--let $rename_to =
+
+# Restore the error codes of the main statement
+--let $mysql_errno = $my_errno
+--let $mysql_errname = $my_errname
+# Make sure you don't add any SQL statements after restoring
+# mysql_errno and mysql_errname (above)
+
diff --git a/mysql-test/suite/storage_engine/alter_table.result b/mysql-test/suite/storage_engine/alter_table.result
new file mode 100644
index 00000000..85db1514
--- /dev/null
+++ b/mysql-test/suite/storage_engine/alter_table.result
@@ -0,0 +1,147 @@
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (a <INT_COLUMN>, c <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,c) VALUES (1,'a'),(5,'z');
+ALTER TABLE t1 ADD COLUMN b <INT_COLUMN>;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `c` char(8) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+ALTER TABLE t1 ALTER COLUMN a SET DEFAULT '0';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT 0,
+ `c` char(8) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+ALTER TABLE t1 ALTER a DROP DEFAULT;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11),
+ `c` char(8) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+ALTER TABLE t1 CHANGE COLUMN b b1 <CHAR_COLUMN> FIRST;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `b1` char(8) DEFAULT NULL,
+ `a` int(11),
+ `c` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+ALTER TABLE t1 CHANGE b1 b <INT_COLUMN> AFTER c;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11),
+ `c` char(8) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+ALTER TABLE t1 CHANGE b b <CHAR_COLUMN>;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11),
+ `c` char(8) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+ALTER TABLE t1 MODIFY COLUMN b <INT_COLUMN>;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11),
+ `c` char(8) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+ALTER TABLE t1 MODIFY COLUMN b <CHAR_COLUMN> FIRST;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `b` char(8) DEFAULT NULL,
+ `a` int(11),
+ `c` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+ALTER TABLE t1 MODIFY COLUMN b <INT_COLUMN> AFTER a;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11),
+ `b` int(11) DEFAULT NULL,
+ `c` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+ALTER TABLE t1 DROP COLUMN b;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11),
+ `c` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+ALTER TABLE t1 RENAME TO t2;
+SHOW CREATE TABLE t1;
+ERROR 42S02: Table 'test.t1' doesn't exist
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` int(11),
+ `c` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+DROP TABLE t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,5),(2,2),(4,3);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+ALTER TABLE t1 ORDER BY b ASC, a DESC;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+SELECT a,b FROM t1;
+a b
+2 2
+4 3
+1 5
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, c <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHARACTER SET latin1 COLLATE latin1_general_cs;
+INSERT INTO t1 (a,b,c) VALUES (5,'z','t');
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) COLLATE latin1_general_cs DEFAULT NULL,
+ `c` char(8) COLLATE latin1_general_cs DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs
+ALTER TABLE t1 CONVERT TO CHARACTER SET utf8;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL,
+ `c` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=utf8
+ALTER TABLE t1 DEFAULT CHARACTER SET = latin1 COLLATE latin1_general_ci;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) CHARACTER SET utf8 DEFAULT NULL,
+ `c` char(8) CHARACTER SET utf8 DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
+ALTER TABLE t1 FORCE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) CHARACTER SET utf8 DEFAULT NULL,
+ `c` char(8) CHARACTER SET utf8 DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/alter_table.test b/mysql-test/suite/storage_engine/alter_table.test
new file mode 100644
index 00000000..f99792f5
--- /dev/null
+++ b/mysql-test/suite/storage_engine/alter_table.test
@@ -0,0 +1,148 @@
+#
+# Basic ALTER TABLE statements.
+#
+# USAGE of table options in ALTER statements
+# is covered in tbl_standard_opts and tbl_opt*.tests.
+#
+# Index operations are covered in index* tests.
+#
+# ALTER ONLINE syntax is covered in alter_online_table.test
+# ALTER OFFLINE is not covered as it is not supported, as of 5.5.23
+#
+# ALTER TABLE ... DISCARD|IMPORT TABLESPACE is covered in alter_tablespace.test
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+--let $create_definition = a $int_col, c $char_col
+--source create_table.inc
+INSERT INTO t1 (a,c) VALUES (1,'a'),(5,'z');
+
+# Column operations
+
+--let $alter_definition = ADD COLUMN b $int_col
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --source unexpected_result.inc
+}
+
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = ALTER COLUMN a SET DEFAULT '0'
+--source alter_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = ALTER a DROP DEFAULT
+--source alter_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = CHANGE COLUMN b b1 $char_col FIRST
+--source alter_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = CHANGE b1 b $int_col AFTER c
+--source alter_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = CHANGE b b $char_col
+--source alter_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = MODIFY COLUMN b $int_col
+--source alter_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = MODIFY COLUMN b $char_col FIRST
+--source alter_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = MODIFY COLUMN b $int_col AFTER a
+--source alter_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = DROP COLUMN b
+--source alter_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+
+# Rename table
+
+--let $rename_to = t2
+--source alter_table.inc
+--let $error_codes = ER_NO_SUCH_TABLE
+SHOW CREATE TABLE t1;
+--source check_errors.inc
+if ($mysql_errname != 'ER_NO_SUCH_TABLE')
+{
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+ DROP TABLE t1;
+}
+if ($mysql_errname == ER_NO_SUCH_TABLE)
+{
+ --source mask_engine.inc
+ SHOW CREATE TABLE t2;
+ DROP TABLE t2;
+}
+
+# ORDER BY
+--let $create_definition = a $int_col, b $int_col
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,5),(2,2),(4,3);
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = ORDER BY b ASC, a DESC
+--source alter_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+SELECT a,b FROM t1;
+DROP TABLE t1;
+
+# Character set, collate
+
+--let $table_options = CHARACTER SET latin1 COLLATE latin1_general_cs
+--let $create_definition = a $int_col, b $char_col, c $char_col
+--source create_table.inc
+INSERT INTO t1 (a,b,c) VALUES (5,'z','t');
+
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = CONVERT TO CHARACTER SET utf8
+--source alter_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = DEFAULT CHARACTER SET = latin1 COLLATE latin1_general_ci
+--source alter_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+# A 'null' ALTER operation
+
+--let $alter_definition = FORCE
+--source alter_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+# Cleanup
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/alter_table_online.result b/mysql-test/suite/storage_engine/alter_table_online.result
new file mode 100644
index 00000000..2a27c5d1
--- /dev/null
+++ b/mysql-test/suite/storage_engine/alter_table_online.result
@@ -0,0 +1,34 @@
+DROP TABLE IF EXISTS t1,t2,t3;
+CREATE TABLE t1 (a <INT_COLUMN>, b <INT_COLUMN>, c <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b,c) VALUES (1,100,'a'),(2,200,'b'),(3,300,'c');
+ALTER ONLINE TABLE t1 MODIFY b <INT_COLUMN> DEFAULT 5;
+ALTER ONLINE TABLE t1 CHANGE b new_name <INT_COLUMN>;
+ALTER ONLINE TABLE t1 COMMENT 'new comment';
+ALTER ONLINE TABLE t1 RENAME TO t2;
+ERROR 0A000: LOCK=NONE/SHARED is not supported for this operation. Try LOCK=EXCLUSIVE.
+DROP TABLE IF EXISTS t2;
+Warnings:
+Note 1051 Unknown table 'test.t2'
+CREATE TEMPORARY TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c');
+ALTER ONLINE TABLE t1 MODIFY b <INT_COLUMN> DEFAULT 5;
+Warnings:
+Warning 1366 Incorrect integer value: 'a' for column 'b' at row 1
+Warning 1366 Incorrect integer value: 'b' for column 'b' at row 2
+Warning 1366 Incorrect integer value: 'c' for column 'b' at row 3
+ALTER ONLINE TABLE t1 CHANGE b new_name <INT_COLUMN>;
+ALTER ONLINE TABLE t1 COMMENT 'new comment';
+ALTER ONLINE TABLE t1 RENAME TO t2;
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <INT_COLUMN>, c <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b,c) VALUES (1,100,'a'),(2,200,'b'),(3,300,'c');
+ALTER ONLINE TABLE t1 DROP COLUMN b, ADD b <INT_COLUMN>;
+ALTER ONLINE TABLE t1 MODIFY b BIGINT <CUSTOM_COL_OPTIONS>;
+ERROR 0A000: LOCK=NONE is not supported. Reason: Cannot change column type. Try LOCK=SHARED.
+ALTER ONLINE TABLE t1 ENGINE=MEMORY;
+ERROR 0A000: LOCK=NONE is not supported. Reason: COPY algorithm requires a lock. Try LOCK=SHARED.
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <INT_COLUMN>, c <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ALTER ONLINE TABLE t1 ADD INDEX (b);
+ALTER ONLINE TABLE t1 DROP INDEX b;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/alter_table_online.test b/mysql-test/suite/storage_engine/alter_table_online.test
new file mode 100644
index 00000000..0d73deaf
--- /dev/null
+++ b/mysql-test/suite/storage_engine/alter_table_online.test
@@ -0,0 +1,158 @@
+#
+# ALTER ONLINE TABLE
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2,t3;
+--enable_warnings
+
+#
+# Test of things that can be done online
+# We are repeating notification here, because for some engines
+# only a part of these ALTER ONLINE statements might be supported.
+#
+
+let $create_definition = a $int_col, b $int_col, c $char_col;
+--source create_table.inc
+
+INSERT INTO t1 (a,b,c) VALUES (1,100,'a'),(2,200,'b'),(3,300,'c');
+
+--let $online = 1
+--let $alter_definition = MODIFY b $int_col DEFAULT 5
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --source unexpected_result.inc
+}
+
+--let $online = 1
+--let $alter_definition = CHANGE b new_name $int_col
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --source unexpected_result.inc
+}
+
+--let $online = 1
+--let $alter_definition = COMMENT 'new comment'
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --source unexpected_result.inc
+}
+
+# It is here because it used to be supported as ALTER ONLINE,
+# but not anymore after the semantics changed in 10.0
+# to be the same as ALTER .. LOCK=NONE
+
+--let $error_codes = ER_ALTER_OPERATION_NOT_SUPPORTED
+--let $online = 1
+--let $rename_to = t2
+--source alter_table.inc
+if ($mysql_errname!=ER_ALTER_OPERATION_NOT_SUPPORTED)
+{
+ --source unexpected_result.inc
+ DROP TABLE t1;
+}
+DROP TABLE IF EXISTS t2;
+
+#
+# temporary table does not require locking
+#
+
+--let $temporary = 1
+--source create_table.inc
+
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c');
+
+--let $online = 1
+--let $alter_definition = MODIFY b $int_col DEFAULT 5
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --source unexpected_result.inc
+}
+
+--let $online = 1
+--let $alter_definition = CHANGE b new_name $int_col
+--source alter_table.inc
+
+--let $online = 1
+--let $alter_definition = COMMENT 'new comment'
+--source alter_table.inc
+
+--let $online = 1
+--let $rename_to = t2
+--source alter_table.inc
+
+DROP TABLE IF EXISTS t1, t2;
+
+#
+# Test of things that is not possible to do online
+#
+
+--let $create_definition = a $int_col, b $int_col, c $char_col
+--source create_table.inc
+
+INSERT INTO t1 (a,b,c) VALUES (1,100,'a'),(2,200,'b'),(3,300,'c');
+
+# It is here because it used to unsupported as ALTER ONLINE,
+# but is supported now after the semantics changed in 10.0
+# to be the same as ALTER .. LOCK=NONE
+
+--let $online = 1
+--let $alter_definition = DROP COLUMN b, ADD b $int_col
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --source unexpected_result.inc
+}
+
+--let $error_codes = ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+--let $online = 1
+--let $alter_definition = MODIFY b BIGINT $default_col_opts
+--source alter_table.inc
+
+--let $alternative_engine = `SELECT engine FROM information_schema.engines WHERE engine IN ('MEMORY','MyISAM') AND engine != '$storage_engine' ORDER BY engine LIMIT 1`
+
+--let $error_codes = ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
+--let $online = 1
+--let $alter_definition = ENGINE=$alternative_engine
+--source alter_table.inc
+
+DROP TABLE t1;
+
+--let $create_definition = a $int_col, b $int_indexed_col, c $char_col
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = Column options
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+
+ # It is here because it used to unsupported as ALTER ONLINE,
+ # but is supported now after the semantics changed in 10.0
+ # to be the same as ALTER .. LOCK=NONE
+
+ --let $online = 1
+ --let $alter_definition = ADD INDEX (b)
+ --source alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $functionality = Adding an index or ALTER ONLINE
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --let $online = 1
+ --let $alter_definition = DROP INDEX b
+ --source alter_table.inc
+ }
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
diff --git a/mysql-test/suite/storage_engine/alter_tablespace.result b/mysql-test/suite/storage_engine/alter_tablespace.result
new file mode 100644
index 00000000..ff3da9f6
--- /dev/null
+++ b/mysql-test/suite/storage_engine/alter_tablespace.result
@@ -0,0 +1,21 @@
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ALTER TABLE t1 DISCARD TABLESPACE;
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a) VALUES (1),(2);
+SELECT a FROM t1;
+a
+1
+2
+ALTER TABLE t1 DISCARD TABLESPACE;
+SELECT a FROM t1;
+ERROR HY000: Tablespace has been discarded for table `t1`
+ALTER TABLE t1 IMPORT TABLESPACE;
+Warnings:
+Warning 1810 IO Read error: (2, No such file or directory) Error opening './test/t1.cfg', will attempt to import without schema verification
+SELECT a FROM t1;
+a
+1
+2
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/alter_tablespace.test b/mysql-test/suite/storage_engine/alter_tablespace.test
new file mode 100644
index 00000000..1899da28
--- /dev/null
+++ b/mysql-test/suite/storage_engine/alter_tablespace.test
@@ -0,0 +1,102 @@
+#
+# IMPORT / DISCARD TABLESPACE
+#
+# The test might require additional engine options,
+# e.g. for InnoDB it is --innodb-file-per-table
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+--let $create_definition = a $int_col
+--source create_table.inc
+
+--let $alter_definition = DISCARD TABLESPACE
+
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = Tablespace operations
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ DROP TABLE t1;
+
+ --let $create_definition = a $int_col
+ --source create_table.inc
+ INSERT INTO t1 (a) VALUES (1),(2);
+ --sorted_result
+ SELECT a FROM t1;
+
+# http://dev.mysql.com/doc/mysql-enterprise-backup/3.5/en/partial.restoring.single.html
+# To get a "clean" backup we need to either use innobackup, or to monitor show engine innodb status,
+# and the documented conditions do not look exactly feasible. So, we will go a simple way:
+# just restart the server, and take the backup while the server is down.
+# (And we need to have a really clean backup, see MySQL:65429 / LP:1004910)
+
+ --let $datadir = `SELECT @@datadir`
+
+ --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+restart
+wait
+EOF
+
+ --enable_reconnect
+ --shutdown_server
+
+ --source include/wait_until_disconnected.inc
+
+ --replace_result $datadir <DATADIR>
+ --copy_file $datadir/test/t1.ibd $datadir/test/t1.ibd.save
+
+ --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+restart
+EOF
+
+ --source include/wait_until_connected_again.inc
+
+ --let $alter_definition = DISCARD TABLESPACE
+ --source alter_table.inc
+
+ --let $error_codes = ER_TABLESPACE_DISCARDED
+ --replace_result $storage_engine <STORAGE_ENGINE>
+ SELECT a FROM t1;
+ --source check_errors.inc
+ if ($mysql_errname != ER_TABLESPACE_DISCARDED)
+ {
+ --let $functionality = Tablespace operations
+ --source unexpected_result.inc
+ }
+
+ --move_file $datadir/test/t1.ibd.save $datadir/test/t1.ibd
+ --let $alter_definition = IMPORT TABLESPACE
+ --source alter_table.inc
+ --sorted_result
+ SELECT a FROM t1;
+
+ # Adding a warning suppression based on what InnoDB currently does
+ # when it attempts to access a table without an *.ibd file
+ --disable_query_log
+ eval CALL mtr.add_suppression('$storage_engine: Error:');
+ --enable_query_log
+
+ # The sleep below is a very bad style, but so far there seems to be
+ # no reliable way to prevent a failure on Windows, which is caused
+ # by the fact that the error message that we added the above suppression for,
+ # on Windows appears in the error log with a delay, so MTR
+ # thinks the error was raised on server shutdown, and the suppression
+ # does not work. Adding it globally is not an option because
+ # it must be caught in other tests which do not produce the failure
+ # intentionally
+
+ --sleep 1
+}
+
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/analyze_table.inc b/mysql-test/suite/storage_engine/analyze_table.inc
new file mode 100644
index 00000000..2cbfc17a
--- /dev/null
+++ b/mysql-test/suite/storage_engine/analyze_table.inc
@@ -0,0 +1,43 @@
+#
+# ANALYZE TABLE statements
+#
+# Note: the output is likely to be different for the engine under test,
+# in which case rdiff will be needed. Or, the output might say that
+# the storage engine does not support ANALYZE.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+--let $create_definition = a $int_col, b $char_col
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+--let $create_definition = a $int_col, b $char_col
+--let $table_name = t2
+--source create_table.inc
+
+INSERT INTO t1 (a,b) VALUES (3,'c');
+ANALYZE TABLE t1;
+INSERT INTO t2 (a,b) VALUES (4,'d');
+ANALYZE NO_WRITE_TO_BINLOG TABLE t2;
+INSERT INTO t1 (a,b) VALUES (5,'e');
+INSERT INTO t2 (a,b) VALUES (6,'f');
+ANALYZE LOCAL TABLE t1, t2;
+
+DROP TABLE t1, t2;
+
+--let $continue = 1
+--source have_default_index.inc
+
+if ($have_default_index)
+{
+ --let $create_definition = a $int_indexed_col, $default_index(a)
+ --source create_table.inc
+ INSERT INTO t1 (a) VALUES (1),(2),(4),(7);
+ ANALYZE TABLE t1;
+ INSERT INTO t1 (a) VALUES (8),(10),(11),(12);
+ ANALYZE TABLE t1;
+ DROP TABLE t1;
+}
+
diff --git a/mysql-test/suite/storage_engine/analyze_table.result b/mysql-test/suite/storage_engine/analyze_table.result
new file mode 100644
index 00000000..42904ed3
--- /dev/null
+++ b/mysql-test/suite/storage_engine/analyze_table.result
@@ -0,0 +1,29 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (3,'c');
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+INSERT INTO t2 (a,b) VALUES (4,'d');
+ANALYZE NO_WRITE_TO_BINLOG TABLE t2;
+Table Op Msg_type Msg_text
+test.t2 analyze status OK
+INSERT INTO t1 (a,b) VALUES (5,'e');
+INSERT INTO t2 (a,b) VALUES (6,'f');
+ANALYZE LOCAL TABLE t1, t2;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+test.t2 analyze status OK
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a <INT_COLUMN>, <CUSTOM_INDEX>(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a) VALUES (1),(2),(4),(7);
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+INSERT INTO t1 (a) VALUES (8),(10),(11),(12);
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/analyze_table.test b/mysql-test/suite/storage_engine/analyze_table.test
new file mode 100644
index 00000000..5222ec8a
--- /dev/null
+++ b/mysql-test/suite/storage_engine/analyze_table.test
@@ -0,0 +1,14 @@
+#
+# ANALYZE TABLE statements
+#
+# Note: the output is likely to be different for the engine under test,
+# in which case rdiff will be needed. Or, the output might say that
+# the storage engine does not support ANALYZE.
+#
+
+--source have_engine.inc
+
+--source analyze_table.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/autoinc_secondary.result b/mysql-test/suite/storage_engine/autoinc_secondary.result
new file mode 100644
index 00000000..28b0a406
--- /dev/null
+++ b/mysql-test/suite/storage_engine/autoinc_secondary.result
@@ -0,0 +1,40 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN> AUTO_INCREMENT, b <CHAR_COLUMN>, PRIMARY KEY (a,b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (b) VALUES ('a'),('b'),('b'),('c'),('a');
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+1
+SELECT a,b FROM t1;
+a b
+1 a
+2 b
+3 b
+4 c
+5 a
+DROP TABLE t1;
+CREATE TABLE t1 (a <CHAR_COLUMN>, b <INT_COLUMN> AUTO_INCREMENT, PRIMARY KEY (a,b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a) VALUES ('a'),('b'),('b'),('c'),('a');
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+1
+SELECT a,b FROM t1;
+a b
+a 1
+a 2
+b 1
+b 2
+c 1
+DROP TABLE t1;
+CREATE TABLE t1 (a <CHAR_COLUMN>, b <INT_COLUMN> AUTO_INCREMENT, PRIMARY KEY (a,b), <CUSTOM_INDEX>(b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a) VALUES ('a'),('b'),('b'),('c'),('a');
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+1
+SELECT a,b FROM t1;
+a b
+a 1
+a 5
+b 2
+b 3
+c 4
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/autoinc_secondary.test b/mysql-test/suite/storage_engine/autoinc_secondary.test
new file mode 100644
index 00000000..25fc0f7c
--- /dev/null
+++ b/mysql-test/suite/storage_engine/autoinc_secondary.test
@@ -0,0 +1,73 @@
+#
+# AUTO_INCREMENT on a secondary column in a multi-part key
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+#
+# AUTO_INCREMENT is the primary column in a multiple-column index
+#
+
+--let $create_definition = a $int_col AUTO_INCREMENT, b $char_col, PRIMARY KEY (a,b)
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = Multi-part keys or PK or AUTO_INCREMENT (on a primary column)
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (b) VALUES ('a'),('b'),('b'),('c'),('a');
+ SELECT LAST_INSERT_ID();
+ --sorted_result
+ SELECT a,b FROM t1;
+ DROP TABLE t1;
+}
+
+#
+# AUTO_INCREMENT is the secondary column in a multiple-column index
+#
+
+--let $create_definition = a $char_col, b $int_col AUTO_INCREMENT, PRIMARY KEY (a,b)
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = Multi-part keys or PK or AUTO_INCREMENT (on a secondary column)
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a) VALUES ('a'),('b'),('b'),('c'),('a');
+ SELECT LAST_INSERT_ID();
+ --sorted_result
+ SELECT a,b FROM t1;
+ DROP TABLE t1;
+}
+
+# AUTO_INCREMENT is the secondary column in a multiple-column index,
+# and primary in another index
+#
+
+--let $create_definition = a $char_col, b $int_indexed_col AUTO_INCREMENT, PRIMARY KEY (a,b), $default_index(b)
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = Multi-part keys or AUTO_INCREMENT (on the secondary column) or multiple keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a) VALUES ('a'),('b'),('b'),('c'),('a');
+ SELECT LAST_INSERT_ID();
+ --sorted_result
+ SELECT a,b FROM t1;
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/autoinc_vars.result b/mysql-test/suite/storage_engine/autoinc_vars.result
new file mode 100644
index 00000000..aca21dfd
--- /dev/null
+++ b/mysql-test/suite/storage_engine/autoinc_vars.result
@@ -0,0 +1,53 @@
+DROP TABLE IF EXISTS t1;
+SET auto_increment_offset = 200;
+CREATE TABLE t1 (a <INT_COLUMN> AUTO_INCREMENT, b <CHAR_COLUMN>, <CUSTOM_INDEX>(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (NULL,'a'),(NULL,'b'),(NULL,'c');
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+1
+SELECT a,b FROM t1;
+a b
+1 a
+2 b
+3 c
+SET auto_increment_increment = 300;
+INSERT INTO t1 (a,b) VALUES (NULL,'d'),(NULL,'e'),(NULL,'f');
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+200
+SELECT a,b FROM t1;
+a b
+1 a
+2 b
+200 d
+3 c
+500 e
+800 f
+SET auto_increment_increment = 50;
+INSERT INTO t1 (a,b) VALUES (NULL,'g'),(NULL,'h'),(NULL,'i');
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+850
+SELECT a,b FROM t1;
+a b
+1 a
+2 b
+200 d
+3 c
+500 e
+800 f
+850 g
+900 h
+950 i
+DROP TABLE t1;
+SET auto_increment_increment = 500;
+SET auto_increment_offset = 300;
+CREATE TABLE t1 (a TINYINT <CUSTOM_COL_OPTIONS> AUTO_INCREMENT, <CUSTOM_INDEX>(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a) VALUES (NULL);
+ERROR 22003: Out of range value for column 'a' at row 1
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+850
+SELECT a FROM t1;
+a
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/autoinc_vars.test b/mysql-test/suite/storage_engine/autoinc_vars.test
new file mode 100644
index 00000000..b154fd79
--- /dev/null
+++ b/mysql-test/suite/storage_engine/autoinc_vars.test
@@ -0,0 +1,68 @@
+#
+# auto-increment-offset and auto-increment-increment
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# auto_increment_offset
+SET auto_increment_offset = 200;
+--let $create_definition = a $int_indexed_col AUTO_INCREMENT, b $char_col, $default_index(a)
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = AUTO_INCREMENT
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ # If auto_increment_offset is greater than auto_increment_increment,
+ # the offset is ignored
+ INSERT INTO t1 (a,b) VALUES (NULL,'a'),(NULL,'b'),(NULL,'c');
+ SELECT LAST_INSERT_ID();
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ # auto_increment_increment
+
+ SET auto_increment_increment = 300;
+ # offset should not be ignored anymore
+ INSERT INTO t1 (a,b) VALUES (NULL,'d'),(NULL,'e'),(NULL,'f');
+ SELECT LAST_INSERT_ID();
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ SET auto_increment_increment = 50;
+ INSERT INTO t1 (a,b) VALUES (NULL,'g'),(NULL,'h'),(NULL,'i');
+ SELECT LAST_INSERT_ID();
+ --sorted_result
+ SELECT a,b FROM t1;
+ DROP TABLE t1;
+}
+
+# offset is greater than the max value
+
+SET auto_increment_increment = 500;
+SET auto_increment_offset = 300;
+--let $create_definition = a TINYINT $default_col_indexed_opts AUTO_INCREMENT, $default_index(a)
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = AUTO_INCREMENT
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a) VALUES (NULL);
+ SELECT LAST_INSERT_ID();
+ --sorted_result
+ SELECT a FROM t1;
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/autoincrement.result b/mysql-test/suite/storage_engine/autoincrement.result
new file mode 100644
index 00000000..541486e4
--- /dev/null
+++ b/mysql-test/suite/storage_engine/autoincrement.result
@@ -0,0 +1,133 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN> AUTO_INCREMENT, b <CHAR_COLUMN>, <CUSTOM_INDEX>(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `b` char(8) DEFAULT NULL,
+ KEY `a` (`a`)
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+INSERT INTO t1 (b) VALUES ('a'),('b');
+SELECT a,b FROM t1 ORDER BY a;
+a b
+1 a
+2 b
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+1
+INSERT INTO t1 (a,b) VALUES (NULL,'c'),(0,'d');
+SELECT a,b FROM t1 ORDER BY a;
+a b
+1 a
+2 b
+3 c
+4 d
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+3
+SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
+INSERT INTO t1 (a,b) VALUES (NULL,'e');
+SELECT a,b FROM t1 ORDER BY a;
+a b
+1 a
+2 b
+3 c
+4 d
+5 e
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+5
+INSERT INTO t1 (a,b) VALUES (0,'f');
+SELECT a,b FROM t1 ORDER BY a;
+a b
+0 f
+1 a
+2 b
+3 c
+4 d
+5 e
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+5
+SET sql_mode = '<INITIAL_SQL_MODE>';
+SHOW TABLE STATUS FROM test LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 <STORAGE_ENGINE> # # # # # # # # 6 # # # # # # # # N
+INSERT INTO t1 (a,b) VALUES (6,'g'),(7,'h');
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+5
+SHOW TABLE STATUS FROM test LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 # # # # # # # # # 8 # # # # # # # # N
+INSERT INTO t1 (a,b) VALUES (NULL,'i'),(9,'j');
+SELECT a,b FROM t1 ORDER BY a;
+a b
+0 f
+1 a
+2 b
+3 c
+4 d
+5 e
+6 g
+7 h
+8 i
+9 j
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+8
+SHOW TABLE STATUS FROM test LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 # # # # # # # # # 10 # # # # # # # # N
+INSERT INTO t1 (a,b) VALUES (20,'k');
+SHOW TABLE STATUS FROM test LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 # # # # # # # # # 21 # # # # # # # # N
+INSERT INTO t1 (a,b) VALUES (NULL,'l');
+SELECT a,b FROM t1 ORDER BY a;
+a b
+0 f
+1 a
+2 b
+3 c
+4 d
+5 e
+6 g
+7 h
+8 i
+9 j
+20 k
+21 l
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+21
+SHOW TABLE STATUS FROM test LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 # # # # # # # # # 22 # # # # # # # # N
+INSERT INTO t1 (a,b) VALUES (-5,'m');
+SELECT a,b FROM t1 ORDER BY a;
+a b
+-5 m
+0 f
+1 a
+2 b
+3 c
+4 d
+5 e
+6 g
+7 h
+8 i
+9 j
+20 k
+21 l
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN> AUTO_INCREMENT, b <CHAR_COLUMN>, <CUSTOM_INDEX>(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> AUTO_INCREMENT = 100;
+INSERT INTO t1 (a,b) VALUES (NULL,'a'),(NULL,'b');
+SELECT a,b FROM t1;
+a b
+100 a
+101 b
+SELECT LAST_INSERT_ID();
+LAST_INSERT_ID()
+100
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/autoincrement.test b/mysql-test/suite/storage_engine/autoincrement.test
new file mode 100644
index 00000000..1ca0b650
--- /dev/null
+++ b/mysql-test/suite/storage_engine/autoincrement.test
@@ -0,0 +1,114 @@
+#
+# Basic AUTO_INCREMENT capabilities
+#
+
+--source have_engine.inc
+
+--let $skip = 1
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $create_definition = a $int_indexed_col AUTO_INCREMENT, b $char_col, $default_index(a)
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = AUTO_INCREMENT
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --source mask_engine.inc
+ SHOW CREATE TABLE t1;
+
+ # Automatic values
+
+ INSERT INTO t1 (b) VALUES ('a'),('b');
+ SELECT a,b FROM t1 ORDER BY a;
+ SELECT LAST_INSERT_ID();
+
+ INSERT INTO t1 (a,b) VALUES (NULL,'c'),(0,'d');
+ SELECT a,b FROM t1 ORDER BY a;
+ SELECT LAST_INSERT_ID();
+
+ let $sql_mode = `SELECT @@sql_mode`;
+ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
+
+ INSERT INTO t1 (a,b) VALUES (NULL,'e');
+ SELECT a,b FROM t1 ORDER BY a;
+ SELECT LAST_INSERT_ID();
+
+ INSERT INTO t1 (a,b) VALUES (0,'f');
+ SELECT a,b FROM t1 ORDER BY a;
+ SELECT LAST_INSERT_ID();
+
+ --replace_result $sql_mode <INITIAL_SQL_MODE>
+ eval SET sql_mode = '$sql_mode';
+
+ # SHOW TABLE STATUS shows the auto-increment value in column 11,
+ # that's all we need here and further
+ --source mask_engine.inc
+ --replace_column 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 # 19 #
+ SHOW TABLE STATUS FROM test LIKE 't1';
+
+ # Mix of automatic and explicit values
+
+ INSERT INTO t1 (a,b) VALUES (6,'g'),(7,'h');
+ SELECT LAST_INSERT_ID();
+
+ --replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 # 19 #
+ SHOW TABLE STATUS FROM test LIKE 't1';
+
+
+ INSERT INTO t1 (a,b) VALUES (NULL,'i'),(9,'j');
+ SELECT a,b FROM t1 ORDER BY a;
+ SELECT LAST_INSERT_ID();
+
+ --replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 # 19 #
+ SHOW TABLE STATUS FROM test LIKE 't1';
+
+ # Creating a gap in the sequence
+
+ INSERT INTO t1 (a,b) VALUES (20,'k');
+
+ --replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 # 19 #
+ SHOW TABLE STATUS FROM test LIKE 't1';
+
+ INSERT INTO t1 (a,b) VALUES (NULL,'l');
+ SELECT a,b FROM t1 ORDER BY a;
+ SELECT LAST_INSERT_ID();
+
+ --replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 # 19 #
+ SHOW TABLE STATUS FROM test LIKE 't1';
+
+ # Negative values: we will try to insert one just to check that it does not cause a crash,
+ # but won't check what happens to the sequence after that, since the behavior is undefined
+
+ INSERT INTO t1 (a,b) VALUES (-5,'m');
+ SELECT a,b FROM t1 ORDER BY a;
+
+ DROP TABLE t1;
+}
+
+# Autoincrement with table option AUTO_INCREMENT
+
+--let $create_definition = a $int_indexed_col AUTO_INCREMENT, b $char_col, $default_index(a)
+--let $table_options = AUTO_INCREMENT = 100
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = AUTO_INCREMENT column or table option
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (NULL,'a'),(NULL,'b');
+ --sorted_result
+ SELECT a,b FROM t1;
+ SELECT LAST_INSERT_ID();
+ DROP TABLE t1;
+}
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/cache_index.result b/mysql-test/suite/storage_engine/cache_index.result
new file mode 100644
index 00000000..c8cf0ce2
--- /dev/null
+++ b/mysql-test/suite/storage_engine/cache_index.result
@@ -0,0 +1,69 @@
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> (a)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE t2 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> (b)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CACHE INDEX t1 INDEX (a), t2 IN <CACHE_NAME>;
+ERROR HY000: Unknown key cache '<CACHE_NAME>'
+SET GLOBAL <CACHE_NAME>.key_buffer_size=128*1024;
+CACHE INDEX t1 INDEX (a), t2 IN <CACHE_NAME>;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+test.t2 assign_to_keycache status OK
+LOAD INDEX INTO CACHE t1, t2;
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+test.t2 preload_keys status OK
+INSERT INTO t1 (a,b) VALUES (3,'c'),(4,'d');
+SET GLOBAL <CACHE_NAME>.key_buffer_size=8*1024;
+LOAD INDEX INTO CACHE t1, t2 IGNORE LEAVES;
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+test.t2 preload_keys status OK
+SET GLOBAL <CACHE_NAME>.key_cache_age_threshold = 100, <CACHE_NAME>.key_cache_block_size = 512, <CACHE_NAME>.key_cache_division_limit = 1, <CACHE_NAME>.key_cache_segments=2;
+INSERT INTO t1 (a,b) VALUES (5,'e'),(6,'f');
+LOAD INDEX INTO CACHE t1;
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+SET GLOBAL new_<CACHE_NAME>.key_buffer_size=128*1024;
+CACHE INDEX t1 IN new_<CACHE_NAME>;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
+LOAD INDEX INTO CACHE t1 IGNORE LEAVES;
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+INSERT INTO t1 (a,b) VALUES (9,'i');
+DROP TABLE t2;
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> (a),
+<CUSTOM_INDEX> (b)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CACHE INDEX t1 IN <CACHE_NAME>;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+LOAD INDEX INTO CACHE t1;
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> a_b (a,b)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CACHE INDEX t1 IN <CACHE_NAME>;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+LOAD INDEX INTO CACHE t1;
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+DROP TABLE t1;
+SET GLOBAL <CACHE_NAME>.key_buffer_size=0;
+SET GLOBAL new_<CACHE_NAME>.key_buffer_size=0;
diff --git a/mysql-test/suite/storage_engine/cache_index.test b/mysql-test/suite/storage_engine/cache_index.test
new file mode 100644
index 00000000..42ba9615
--- /dev/null
+++ b/mysql-test/suite/storage_engine/cache_index.test
@@ -0,0 +1,142 @@
+#
+# CACHE INDEX and LOAD INDEX INTO CACHE
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+
+# Due to ancient MySQL bug#16111 we need to generate a unique cache name
+--let $cache_name = `SELECT CONNECTION_ID()`
+--let $cache_name = my_cache_$cache_name
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+let $create_definition =
+ a $int_indexed_col,
+ b $char_col,
+ $default_index (a)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = Indexes on INT columns
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ let $create_definition =
+ a $int_col,
+ b $char_indexed_col,
+ $default_index (b)
+ ;
+ let $table_name = t2;
+ --source create_table.inc
+ if ($mysql_errname)
+ {
+ --let $functionality = Indexes on CHAR columns
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --replace_result $cache_name <CACHE_NAME>
+ --let $error_codes = ER_UNKNOWN_KEY_CACHE
+ eval CACHE INDEX t1 INDEX (a), t2 IN $cache_name;
+ --source check_errors.inc
+ if ($mysql_errname != ER_UNKNOWN_KEY_CACHE)
+ {
+ --let $functionality = Key cache or indexes
+ --source unexpected_result.inc
+ }
+
+ --replace_result $cache_name <CACHE_NAME>
+ eval SET GLOBAL $cache_name.key_buffer_size=128*1024;
+ --replace_result $cache_name <CACHE_NAME>
+ eval CACHE INDEX t1 INDEX (a), t2 IN $cache_name;
+ if ($mysql_errname)
+ {
+ --let $functionality = Indexes
+ --source unexpected_result.inc
+ }
+
+ LOAD INDEX INTO CACHE t1, t2;
+ if ($mysql_errname)
+ {
+ --let $functionality = Indexes
+ --source unexpected_result.inc
+ }
+
+ INSERT INTO t1 (a,b) VALUES (3,'c'),(4,'d');
+ --replace_result $cache_name <CACHE_NAME>
+ eval SET GLOBAL $cache_name.key_buffer_size=8*1024;
+ LOAD INDEX INTO CACHE t1, t2 IGNORE LEAVES;
+
+ --replace_result $cache_name <CACHE_NAME>
+ eval SET GLOBAL $cache_name.key_cache_age_threshold = 100, $cache_name.key_cache_block_size = 512, $cache_name.key_cache_division_limit = 1, $cache_name.key_cache_segments=2;
+ INSERT INTO t1 (a,b) VALUES (5,'e'),(6,'f');
+ LOAD INDEX INTO CACHE t1;
+
+ --replace_result $cache_name <CACHE_NAME>
+ eval SET GLOBAL new_$cache_name.key_buffer_size=128*1024;
+ --replace_result $cache_name <CACHE_NAME>
+ eval CACHE INDEX t1 IN new_$cache_name;
+ INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
+ LOAD INDEX INTO CACHE t1 IGNORE LEAVES;
+ INSERT INTO t1 (a,b) VALUES (9,'i');
+ DROP TABLE t2;
+ }
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ a $int_indexed_col,
+ b $char_indexed_col,
+ $default_index (a),
+ $default_index (b)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = Multiple keys or indexes on INT or CHAR columns
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_result $cache_name <CACHE_NAME>
+ eval CACHE INDEX t1 IN $cache_name;
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+ LOAD INDEX INTO CACHE t1;
+
+ DROP TABLE t1;
+ let $create_definition =
+ a $int_indexed_col,
+ b $char_indexed_col,
+ $default_index a_b (a,b)
+ ;
+ --source create_table.inc
+ if ($mysql_errname)
+ {
+ --let $functionality = Multi-part keys
+ --source unexpected_result.inc
+ }
+
+ --replace_result $cache_name <CACHE_NAME>
+ eval CACHE INDEX t1 IN $cache_name;
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+ LOAD INDEX INTO CACHE t1;
+
+ DROP TABLE t1;
+}
+
+# Cleanup
+
+--replace_result $cache_name <CACHE_NAME>
+eval SET GLOBAL $cache_name.key_buffer_size=0;
+--replace_result $cache_name <CACHE_NAME>
+eval SET GLOBAL new_$cache_name.key_buffer_size=0;
+
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/check_errors.inc b/mysql-test/suite/storage_engine/check_errors.inc
new file mode 100644
index 00000000..e38ff296
--- /dev/null
+++ b/mysql-test/suite/storage_engine/check_errors.inc
@@ -0,0 +1,80 @@
+#
+# Since we run tests in disable_abort_on_error mode, we cannot use --error command,
+# and need to check the result manually.
+# Usage in a test:
+# --let $error_codes = <comma-separated list> # optional, default ''
+# --let $mysql_errname = <error name> # optional, default current $mysql_errname (from the last SQL command)
+# --let $mysql_errno = <error code> # optional, default current $mysql_errno (from the last SQL command)
+#
+
+if ($error_codes == '0')
+{
+ --let $error_codes =
+}
+if ($error_codes == '')
+{
+ if ($mysql_errname)
+ {
+ --echo # ERROR: Statement ended with errno $mysql_errno, errname $mysql_errname (expected to succeed)
+ }
+
+ # If both error_codes and mysql_errname are false, all is good, no logic needed
+}
+
+if ($error_codes != '')
+{
+ # If mysql_errname or mysql_errno is equal to $error_codes, it's good too, nothing to do
+
+ if ($mysql_errname != $error_codes)
+ {
+ if ($mysql_errno != $error_codes)
+ {
+ --let $save_errno = $mysql_errno
+ --let $save_errname = $mysql_errname
+
+ --let $codeline = `SELECT CONCAT('\'',REPLACE('$error_codes',',','\',\''),'\'')`
+ --let $result = `SELECT '$save_errname' IN($codeline) or '$save_errno' IN ($codeline)`
+
+ --let $mysql_errno = $save_errno
+ --let $mysql_errname = $save_errname
+
+ if (!$result)
+ {
+ if ($mysql_errname)
+ {
+ --echo # ERROR: Statement ended with errno $mysql_errno, errname $mysql_errname (expected results: $error_codes)
+ }
+ if (!$mysql_errname)
+ {
+ --echo # ERROR: Statement succeeded (expected results: $error_codes)
+ }
+ }
+ # If a list contained more than one error, it could be on one of two reasons:
+ # first, we do not care which code it is, as long as it is one of the listed errors.
+ # In this case we will suggest to add an rdiff file if the message differs.
+ # Second, check_errors might be called from a generalized include file or test,
+ # which runs with different parameters and thus might produce different results for the same statement.
+ # Then, the message will be stricter, as the difference with the result file is actually a problem
+ # which needs to be checked at least.
+ if ($result)
+ {
+ if (!$strict_check)
+ {
+ --echo # Statement ended with one of expected results ($error_codes).
+ --echo # If you got a difference in error message, just add it to rdiff file
+ }
+ if ($strict_check)
+ {
+ --echo # WARNING: Statement ended with errno $mysql_errno, errname '$mysql_errname'.
+ --echo # If it differs from the result file, it might indicate a problem.
+ }
+
+ }
+ }
+ }
+}
+
+# Don't want the variables to be accidentally reused later
+--let $error_codes =
+--let $strict_check =
+
diff --git a/mysql-test/suite/storage_engine/check_table.inc b/mysql-test/suite/storage_engine/check_table.inc
new file mode 100644
index 00000000..54bdf511
--- /dev/null
+++ b/mysql-test/suite/storage_engine/check_table.inc
@@ -0,0 +1,62 @@
+#
+# CHECK TABLE statements
+#
+# Note: the output is likely to be different for the engine under test,
+# in which case rdiff will be needed. Or, the output might say that
+# the storage engine does not support CHECK.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+--let $create_definition = a $int_col, b $char_col
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+
+--let $table_name = t2
+--let $create_definition = a $int_col, b $char_col
+--source create_table.inc
+
+CHECK TABLE t1;
+INSERT INTO t1 (a,b) VALUES (3,'c');
+INSERT INTO t2 (a,b) VALUES (4,'d');
+CHECK TABLE t1, t2 FOR UPGRADE;
+INSERT INTO t2 (a,b) VALUES (5,'e');
+CHECK TABLE t2 QUICK;
+INSERT INTO t1 (a,b) VALUES (6,'f');
+CHECK TABLE t1 FAST;
+INSERT INTO t1 (a,b) VALUES (7,'g');
+INSERT INTO t2 (a,b) VALUES (8,'h');
+CHECK TABLE t2, t1 MEDIUM;
+INSERT INTO t1 (a,b) VALUES (9,'i');
+INSERT INTO t2 (a,b) VALUES (10,'j');
+CHECK TABLE t1, t2 EXTENDED;
+INSERT INTO t1 (a,b) VALUES (11,'k');
+CHECK TABLE t1 CHANGED;
+
+DROP TABLE t1, t2;
+
+--let $continue = 1
+--source have_default_index.inc
+if ($have_default_index)
+{
+ --let $create_definition = a $int_indexed_col, $default_index(a)
+ --source create_table.inc
+ INSERT INTO t1 (a) VALUES (1),(2),(5);
+ CHECK TABLE t1;
+ INSERT INTO t1 (a) VALUES (6),(8),(12);
+ CHECK TABLE t1 FOR UPGRADE;
+ INSERT INTO t1 (a) VALUES (13),(15),(16);
+ CHECK TABLE t1 QUICK;
+ INSERT INTO t1 (a) VALUES (17),(120),(132);
+ CHECK TABLE t1 FAST;
+ INSERT INTO t1 (a) VALUES (801),(900),(7714);
+ CHECK TABLE t1 MEDIUM;
+ INSERT INTO t1 (a) VALUES (8760),(10023),(12000);
+ CHECK TABLE t1 EXTENDED;
+ INSERT INTO t1 (a) VALUES (13345),(24456),(78302),(143028);
+ CHECK TABLE t1 CHANGED;
+ DROP TABLE t1;
+}
+
diff --git a/mysql-test/suite/storage_engine/check_table.result b/mysql-test/suite/storage_engine/check_table.result
new file mode 100644
index 00000000..83c32778
--- /dev/null
+++ b/mysql-test/suite/storage_engine/check_table.result
@@ -0,0 +1,68 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a,b) VALUES (3,'c');
+INSERT INTO t2 (a,b) VALUES (4,'d');
+CHECK TABLE t1, t2 FOR UPGRADE;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+test.t2 check status OK
+INSERT INTO t2 (a,b) VALUES (5,'e');
+CHECK TABLE t2 QUICK;
+Table Op Msg_type Msg_text
+test.t2 check status OK
+INSERT INTO t1 (a,b) VALUES (6,'f');
+CHECK TABLE t1 FAST;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a,b) VALUES (7,'g');
+INSERT INTO t2 (a,b) VALUES (8,'h');
+CHECK TABLE t2, t1 MEDIUM;
+Table Op Msg_type Msg_text
+test.t2 check status OK
+test.t1 check status OK
+INSERT INTO t1 (a,b) VALUES (9,'i');
+INSERT INTO t2 (a,b) VALUES (10,'j');
+CHECK TABLE t1, t2 EXTENDED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+test.t2 check status OK
+INSERT INTO t1 (a,b) VALUES (11,'k');
+CHECK TABLE t1 CHANGED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a <INT_COLUMN>, <CUSTOM_INDEX>(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a) VALUES (1),(2),(5);
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (6),(8),(12);
+CHECK TABLE t1 FOR UPGRADE;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (13),(15),(16);
+CHECK TABLE t1 QUICK;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (17),(120),(132);
+CHECK TABLE t1 FAST;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (801),(900),(7714);
+CHECK TABLE t1 MEDIUM;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (8760),(10023),(12000);
+CHECK TABLE t1 EXTENDED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (13345),(24456),(78302),(143028);
+CHECK TABLE t1 CHANGED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/check_table.test b/mysql-test/suite/storage_engine/check_table.test
new file mode 100644
index 00000000..243c8e07
--- /dev/null
+++ b/mysql-test/suite/storage_engine/check_table.test
@@ -0,0 +1,14 @@
+#
+# CHECK TABLE statements
+#
+# Note: the output is likely to be different for the engine under test,
+# in which case rdiff will be needed. Or, the output might say that
+# the storage engine does not support CHECK.
+#
+
+--source have_engine.inc
+
+--source check_table.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/checksum_table.inc b/mysql-test/suite/storage_engine/checksum_table.inc
new file mode 100644
index 00000000..d4bacce9
--- /dev/null
+++ b/mysql-test/suite/storage_engine/checksum_table.inc
@@ -0,0 +1,31 @@
+#
+# CHECKSUM TABLE statements for standard CHECKSUM properties.
+# Live checksums are covered in checksum_table_live.test
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+# For most engines CHECKSUM=0 option will be ignored,
+# but we are setting it here for those which have it 1 by default
+# (there will be another test for live checksum)
+
+--let $table_options = CHECKSUM=0
+--let $create_definition = a $int_col, b $char_col
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+
+--let $table_name = t2
+--let $table_options = CHECKSUM=0
+--let $create_definition = a $int_col, b $char_col
+--source create_table.inc
+
+CHECKSUM TABLE t1;
+CHECKSUM TABLE t2, t1;
+CHECKSUM TABLE t1, t2 QUICK;
+CHECKSUM TABLE t1, t2 EXTENDED;
+
+DROP TABLE t1, t2;
+
+
diff --git a/mysql-test/suite/storage_engine/checksum_table.result b/mysql-test/suite/storage_engine/checksum_table.result
new file mode 100644
index 00000000..02d70491
--- /dev/null
+++ b/mysql-test/suite/storage_engine/checksum_table.result
@@ -0,0 +1,20 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHECKSUM=0;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHECKSUM=0;
+CHECKSUM TABLE t1;
+Table Checksum
+test.t1 4272806499
+CHECKSUM TABLE t2, t1;
+Table Checksum
+test.t2 0
+test.t1 4272806499
+CHECKSUM TABLE t1, t2 QUICK;
+Table Checksum
+test.t1 NULL
+test.t2 NULL
+CHECKSUM TABLE t1, t2 EXTENDED;
+Table Checksum
+test.t1 4272806499
+test.t2 0
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/storage_engine/checksum_table.test b/mysql-test/suite/storage_engine/checksum_table.test
new file mode 100644
index 00000000..5693e9a1
--- /dev/null
+++ b/mysql-test/suite/storage_engine/checksum_table.test
@@ -0,0 +1,11 @@
+#
+# CHECKSUM TABLE statements for standard CHECKSUM properties.
+# Live checksums are covered in checksum_table_live.test
+#
+
+--source have_engine.inc
+
+--source checksum_table.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/checksum_table_live.inc b/mysql-test/suite/storage_engine/checksum_table_live.inc
new file mode 100644
index 00000000..9614494e
--- /dev/null
+++ b/mysql-test/suite/storage_engine/checksum_table_live.inc
@@ -0,0 +1,30 @@
+#
+# CHECKSUM TABLE statements for live CHECKSUM.
+#
+# Note: the feature is likely to be unsupported, in which case
+# instead of numeric values some CHECKSUMs will produce NULL
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+# For most engines CHECKSUM=1 option will be ignored,
+# and the results will be different
+
+--let $table_options = CHECKSUM=1
+--let $create_definition = a $int_col, b $char_col
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+--let $table_name = t2
+--let $table_options = CHECKSUM=1
+--let $create_definition = a $int_col, b $char_col
+--source create_table.inc
+
+CHECKSUM TABLE t1;
+CHECKSUM TABLE t2, t1;
+CHECKSUM TABLE t1, t2 QUICK;
+CHECKSUM TABLE t1, t2 EXTENDED;
+
+DROP TABLE t1, t2;
+
diff --git a/mysql-test/suite/storage_engine/checksum_table_live.result b/mysql-test/suite/storage_engine/checksum_table_live.result
new file mode 100644
index 00000000..59ab8f16
--- /dev/null
+++ b/mysql-test/suite/storage_engine/checksum_table_live.result
@@ -0,0 +1,20 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHECKSUM=1;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHECKSUM=1;
+CHECKSUM TABLE t1;
+Table Checksum
+test.t1 4272806499
+CHECKSUM TABLE t2, t1;
+Table Checksum
+test.t2 0
+test.t1 4272806499
+CHECKSUM TABLE t1, t2 QUICK;
+Table Checksum
+test.t1 4272806499
+test.t2 0
+CHECKSUM TABLE t1, t2 EXTENDED;
+Table Checksum
+test.t1 4272806499
+test.t2 0
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/storage_engine/checksum_table_live.test b/mysql-test/suite/storage_engine/checksum_table_live.test
new file mode 100644
index 00000000..347755f2
--- /dev/null
+++ b/mysql-test/suite/storage_engine/checksum_table_live.test
@@ -0,0 +1,13 @@
+#
+# CHECKSUM TABLE statements for live CHECKSUM.
+#
+# Note: the feature is likely to be unsupported, in which case
+# instead of numeric values some CHECKSUMs will produce NULL
+#
+
+--source have_engine.inc
+
+--source checksum_table_live.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/cleanup_engine.inc b/mysql-test/suite/storage_engine/cleanup_engine.inc
new file mode 100644
index 00000000..de3d57ee
--- /dev/null
+++ b/mysql-test/suite/storage_engine/cleanup_engine.inc
@@ -0,0 +1,11 @@
+###########################################
+#
+# This is a stub of the include file cleanup_engine.inc which
+# should be placed in storage/<engine>/mysql-test/storage_engine folder.
+#
+################################
+#
+# Here you can add whatever is needed to cleanup
+# in case your define_engine.inc created any artefacts,
+# e.g. an additional schema and/or tables.
+
diff --git a/mysql-test/suite/storage_engine/col_not_null.inc b/mysql-test/suite/storage_engine/col_not_null.inc
new file mode 100644
index 00000000..5f980b0a
--- /dev/null
+++ b/mysql-test/suite/storage_engine/col_not_null.inc
@@ -0,0 +1,92 @@
+#
+# NOT NULL attribute in columns
+#
+# Usage:
+# let $col_definition = <column type (and possibly more options)>;
+# let $col_default = <default non-null value for a column>;
+# --source col_not_null.inc
+#
+# We will add NOT NULL at the end of $col;
+#
+# Also, if $col_default is defined,
+# we will create a table with 2 columns
+# (one with DEFAULT $col_default, and one without any default),
+# and will also attempt to add a column with DEFAULT NULL.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $create_definition = c $col_definition NOT NULL
+--source create_table.inc
+if ($mysql_errname)
+{
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ SHOW COLUMNS IN t1;
+
+ --let $error_codes = ER_BAD_NULL_ERROR
+ INSERT INTO t1 (c) VALUES (NULL);
+ --source check_errors.inc
+
+ DROP TABLE t1;
+}
+
+if ($col_default != '')
+{
+ let $create_definition =
+ c $col_definition NOT NULL,
+ c2 $col_definition NOT NULL DEFAULT $col_default
+ ;
+ --source create_table.inc
+ if ($mysql_errname)
+ {
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ SHOW COLUMNS IN t1;
+
+ --let $error_codes = ER_INVALID_DEFAULT
+ --let $alter_definition = ADD COLUMN err $col_definition NOT NULL DEFAULT NULL
+ --source alter_table.inc
+ if ($mysql_errname != ER_INVALID_DEFAULT)
+ {
+ --let $functionality = ALTER or DEFAULT
+ --source unexpected_result.inc
+ }
+
+ --let $error_codes = ER_BAD_NULL_ERROR
+ INSERT INTO t1 (c) VALUES (NULL);
+ --source check_errors.inc
+ if ($mysql_errname != ER_BAD_NULL_ERROR)
+ {
+ --let $functionality = NOT NULL columns
+ --source unexpected_result.inc
+ }
+
+ # HEX should be universal for all column types
+ SELECT HEX(c), HEX(c2) FROM t1;
+
+ --let $error_codes = ER_BAD_NULL_ERROR
+ INSERT INTO t1 (c2) VALUES (NULL);
+ --source check_errors.inc
+
+ --eval INSERT INTO t1 (c) VALUES ($col_default)
+ if ($mysql_errname)
+ {
+ --let $functionality = DEFAULT
+ --source unexpected_result.inc
+ }
+ SELECT COUNT(c), COUNT(c2) FROM t1;
+
+ DROP TABLE t1;
+ }
+}
+
+# We don't want to preserve it
+let $col_default = ;
+
diff --git a/mysql-test/suite/storage_engine/col_null.inc b/mysql-test/suite/storage_engine/col_null.inc
new file mode 100644
index 00000000..6f746098
--- /dev/null
+++ b/mysql-test/suite/storage_engine/col_null.inc
@@ -0,0 +1,65 @@
+#
+# NULL attribute and DEFAULT NULL in columns
+#
+# Usage:
+# let $col_definition = <column type (and possibly more options)>;
+# let $col_default = <default non-null value for a column>;
+# --source col_null.inc
+#
+# We will add NULL at the end of $col;
+#
+# Also, if $col_default is defined,
+# we will create a table with 3 columns (one with DEFAULT NULL,
+# one with DEFAULT $col_default, and one without any default)
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $create_definition = c $col_definition NULL
+--source create_table.inc
+SHOW COLUMNS IN t1;
+if ($mysql_errname)
+{
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (c) VALUES (NULL);
+ if ($mysql_errname)
+ {
+ --let $functionality = NULLable columns
+ --source unexpected_result.inc
+ }
+ SELECT COUNT(c), COUNT(*) FROM t1;
+
+ DROP TABLE t1;
+}
+
+if ($col_default != '')
+{
+ let $create_definition =
+ c $col_definition NULL,
+ c1 $col_definition NULL DEFAULT NULL,
+ c2 $col_definition NULL DEFAULT $col_default
+ ;
+ --source create_table.inc
+ if ($mysql_errname)
+ {
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ SHOW COLUMNS IN t1;
+
+ INSERT INTO t1 (c) VALUES (NULL);
+ SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+
+ DROP TABLE t1;
+ }
+}
+
+# We don't want to preserve it
+let $col_default = ;
+
diff --git a/mysql-test/suite/storage_engine/col_opt_default.result b/mysql-test/suite/storage_engine/col_opt_default.result
new file mode 100644
index 00000000..d1f3e9d9
--- /dev/null
+++ b/mysql-test/suite/storage_engine/col_opt_default.result
@@ -0,0 +1,20 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN> DEFAULT '0') ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) # 0
+INSERT INTO t1 (a) VALUES (1);
+SELECT a FROM t1;
+a
+1
+ALTER TABLE t1 ADD COLUMN b <CHAR_COLUMN> DEFAULT '';
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) # 0
+b char(8) #
+INSERT INTO t1 (b) VALUES ('a');
+SELECT a,b FROM t1;
+a b
+0 a
+1
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/col_opt_default.test b/mysql-test/suite/storage_engine/col_opt_default.test
new file mode 100644
index 00000000..3b28def7
--- /dev/null
+++ b/mysql-test/suite/storage_engine/col_opt_default.test
@@ -0,0 +1,49 @@
+#
+# Check whether DEFAULT column attribute
+# is supported in CREATE and ALTER TABLE.
+# If the attribute is supported at all, it will be covered
+# in more details in col_option_null and col_option_not_null tests.
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $create_definition = a $int_col DEFAULT '0'
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = DEFAULT values
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 #
+ SHOW COLUMNS IN t1;
+
+ INSERT INTO t1 (a) VALUES (1);
+ --sorted_result
+ SELECT a FROM t1;
+
+ --let $alter_definition = ADD COLUMN b $char_col DEFAULT ''
+ --source alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $functionality = ALTER or DEFAULT
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --replace_column 3 #
+ SHOW COLUMNS IN t1;
+
+ INSERT INTO t1 (b) VALUES ('a');
+ --sorted_result
+ SELECT a,b FROM t1;
+ }
+ DROP TABLE t1;
+}
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/col_opt_not_null.result b/mysql-test/suite/storage_engine/col_opt_not_null.result
new file mode 100644
index 00000000..1f31d1c1
--- /dev/null
+++ b/mysql-test/suite/storage_engine/col_opt_not_null.result
@@ -0,0 +1,2073 @@
+#
+# BINARY columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (b BINARY <CUSTOM_COL_OPTIONS> NOT NULL,
+b0 BINARY(0) <CUSTOM_COL_OPTIONS> NOT NULL,
+b1 BINARY(1) <CUSTOM_COL_OPTIONS> NOT NULL,
+b20 BINARY(20) <CUSTOM_COL_OPTIONS> NOT NULL,
+b255 BINARY(255) <CUSTOM_COL_OPTIONS> NOT NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b binary(1) # # # #
+b0 binary(0) # # # #
+b1 binary(1) # # # #
+b20 binary(20) # # # #
+b255 binary(255) # # # #
+INSERT INTO t1 (b,b0,b1,b20,b255) VALUES ('','','','','');
+INSERT INTO t1 (b,b0,b1,b20,b255) VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.');
+SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255) FROM t1;
+HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255)
+00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000
+INSERT INTO t1 (b,b0,b1,b20,b255) VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256));
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b0' at row 1
+Warning 1265 Data truncated for column 'b1' at row 1
+Warning 1265 Data truncated for column 'b20' at row 1
+Warning 1265 Data truncated for column 'b255' at row 1
+INSERT INTO t1 (b,b0,b1,b20,b255) SELECT b255, b255, b255, b255, CONCAT(b255,b255) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b0' at row 1
+Warning 1265 Data truncated for column 'b1' at row 1
+Warning 1265 Data truncated for column 'b20' at row 1
+Warning 1265 Data truncated for column 'b255' at row 1
+Warning 1265 Data truncated for column 'b' at row 2
+Warning 1265 Data truncated for column 'b0' at row 2
+Warning 1265 Data truncated for column 'b1' at row 2
+Warning 1265 Data truncated for column 'b20' at row 2
+Warning 1265 Data truncated for column 'b255' at row 2
+Warning 1265 Data truncated for column 'b' at row 3
+Warning 1265 Data truncated for column 'b0' at row 3
+Warning 1265 Data truncated for column 'b1' at row 3
+Warning 1265 Data truncated for column 'b20' at row 3
+Warning 1265 Data truncated for column 'b255' at row 3
+SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255) FROM t1;
+HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255)
+00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+43 43 4372656174696E6720616E2061727469636C6520 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000
+61 61 6161616161616161616161616161616161616161 787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878
+61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000
+78 78 7878787878787878787878787878787878787878 787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878
+ALTER TABLE t1 ADD COLUMN b257 BINARY(257) <CUSTOM_COL_OPTIONS> NOT NULL;
+ERROR 42000: Column length too big for column 'b257' (max = 255); use BLOB or TEXT instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b binary(1) # # # #
+b0 binary(0) # # # #
+b1 binary(1) # # # #
+b20 binary(20) # # # #
+b255 binary(255) # # # #
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c BINARY <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c binary(1) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c BINARY <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 BINARY <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 0
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c binary(1) NO NULL
+c2 binary(1) NO 0
+ALTER TABLE t1 ADD COLUMN err BINARY <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES (0);
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+#
+# VARBINARY columns
+#
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (v0 VARBINARY(0) <CUSTOM_COL_OPTIONS> NOT NULL,
+v1 VARBINARY(1) <CUSTOM_COL_OPTIONS> NOT NULL,
+v64 VARBINARY(64) <CUSTOM_COL_OPTIONS> NOT NULL,
+v65000 VARBINARY(65000) <CUSTOM_COL_OPTIONS> NOT NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varbinary(0) # # #
+v1 varbinary(1) # # #
+v64 varbinary(64) # # #
+v65000 varbinary(65000) # # #
+CREATE TABLE t2 (v VARBINARY(65532) <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t2;
+Field Type Null Key Default Extra
+v varbinary(65532) # # #
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
+SELECT HEX(v0), HEX(v1), HEX(v64), HEX(v65000) FROM t1;
+HEX(v0) HEX(v1) HEX(v64) HEX(v65000)
+
+ 79 4F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C7265616479206578697374 486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E2057652776652070726F7669646564206C696E6B7320746F20416D617A6F6E2E636F6D206865726520666F7220636F6E76656E69656E63652C2062757420746865792063616E20626520666F756E64206174206D616E79206F7468657220626F6F6B73746F7265732C20626F7468206F6E6C696E6520616E64206F66662E0A0A2020496620796F752077616E7420746F206861766520796F7572206661766F72697465204D7953514C202F204D61726961444220626F6F6B206C697374656420686572652C20706C65617365206C65617665206120636F6D6D656E742E0A2020466F7220646576656C6F706572732077686F2077616E7420746F20636F6465206F6E204D617269614442206F72204D7953514C0A0A2020202020202A20556E6465727374616E64696E67204D7953514C20496E7465726E616C73206279205361736861205061636865762C20666F726D6572204D7953514C20646576656C6F706572206174204D7953514C2041422E0A2020202020202020202020206F205468697320697320746865206F6E6C7920626F6F6B207765206B6E6F772061626F75742074686174206465736372696265732074686520696E7465726E616C73206F66204D617269614442202F204D7953514C2E2041206D757374206861766520666F7220616E796F6E652077686F2077616E747320746F20756E6465727374616E6420616E6420646576656C6F70206F6E204D617269614442210A2020202020202020202020206F204E6F7420616C6C20746F706963732061726520636F766572656420616E6420736F6D652070617274732061726520736C696768746C79206F757464617465642C20627574207374696C6C20746865206265737420626F6F6B206F6E207468697320746F7069632E200A2020202020202A204D7953514C20352E3120506C7567696E20446576656C6F706D656E742062792053657267656920476F6C75626368696B20616E6420416E64726577204875746368696E67730A2020202020202020202020206F2041206D757374207265616420666F7220616E796F6E652077616E74696E6720746F207772697465206120706C7567696E20666F72204D6172696144422C207772697474656E20627920746865205365726765692077686F2064657369676E65642074686520706C7567696E20696E7465726661636520666F72204D7953514C20616E64204D61726961444221200A0A2020466F72204D617269614442202F204D7953514C20656E642075736572730A0A2020202020202A204D61726961444220437261736820436F757273652062792042656E20466F7274610A2020202020202020202020206F204669727374204D61726961444220626F6F6B210A2020202020202020202020206F20466F722070656F706C652077686F2077616E7420746F206C6561726E2053514C20616E642074686520626173696373206F66204D6172696144422E0A2020202020202020202020206F204E6F77207368697070696E672E20507572636861736520617420416D617A6F6E2E636F6D206F7220796F7572206661766F7269746520626F6F6B73656C6C65722E200A0A2020202020202A2053514C2D393920436F6D706C6574652C205265616C6C792062792050657465722047756C75747A616E20262054727564792050656C7A65722E0A2020202020202020202020206F2045766572797468696E6720796F752077616E74656420746F206B6E6F772061626F7574207468652053514C203939207374616E646172642E20457863656C6C656E74207265666572656E636520626F6F6B210A2020202020202020202020206F204672656520746F207265616420696E20746865204B6E6F776C656467656261736521200A0A2020202020202A204D7953514C20283474682045646974696F6E29206279205061756C204475426F69730A2020202020202020202020206F20546865202764656661756C742720626F6F6B20746F207265616420696620796F7520776F6E7420746F206C6561726E20746F20757365204D7953514C202F204D6172696144422E200A0A2020202020202A204D7953514C20436F6F6B626F6F6B206279205061756C204475426F69730A2020202020202020202020206F2041206C6F74206F66206578616D706C6573206F6620686F7720746F20757365204D7953514C2E204173207769746820616C6C206F66205061756C277320626F6F6B732C206974277320776F727468206974732077656967687420696E20676F6C6420616E64206576656E20656E6A6F7961626C652072656164696E6720666F7220737563682061202764727927207375626A6563742E200A0A2020202020202A204869676820506572666F726D616E6365204D7953514C2C205365636F6E642045646974696F6E2C204279204261726F6E20536368776172747A2C205065746572205A6169747365762C20566164696D20546B616368656E6B6F2C204A6572656D7920442E205A61776F646E792C2041726A656E204C656E747A2C20446572656B204A2E2042616C6C696E672C20657420616C2E0A2020202020202020202020206F20224869676820506572666F726D616E6365204D7953514C2069732074686520646566696E697469766520677569646520746F206275696C64696E6720666173742C2072656C6961626C652073797374656D732077697468204D7953514C2E205772697474656E206279206E6F74656420657870657274732077697468207965617273206F66207265616C2D776F726C6420657870657269656E6365206275696C64696E672076657279206C617267652073797374656D732C207468697320626F6F6B20636F7665727320657665727920617370656374206F66204D7953514C20706572666F726D616E636520696E2064657461696C2C20616E6420666F6375736573206F6E20726F627573746E6573732C2073656375726974792C20616E64206461746120696E746567726974792E204C6561726E20616476616E63656420746563686E697175657320696E20646570746820736F20796F752063616E206272696E67206F7574204D7953514C27732066756C6C20706F7765722E22202846726F6D2074686520626F6F6B206465736372697074696F6E206174204F275265696C6C7929200A0A2020202020202A204D7953514C2041646D696E20436F6F6B626F6F6B0A2020202020202020202020206F204120717569636B20737465702D62792D7374657020677569646520666F72204D7953514C20757365727320616E642064617461626173652061646D696E6973747261746F727320746F207461636B6C65207265616C2D776F726C64206368616C6C656E6765732077697468204D7953514C20636F6E66696775726174696F6E20616E642061646D696E697374726174696F6E200A0A2020202020202A204D7953514C20352E302043657274696669636174696F6E2053747564792047756964652C204279205061756C204475426F69732C2053746566616E2048696E7A2C204361727374656E20506564657273656E0A2020202020202020202020206F205468697320697320746865206F6666696369616C20677569646520746F20636F766572207468652070617373696E67206F66207468652074776F204D7953514C2043657274696669636174696F6E206578616D696E6174696F6E732E2049742069732076616C69642074696C6C2076657273696F6E20352E30206F6620746865207365727665722C20736F207768696C65206974206D697373657320616C6C2074686520666561747572657320617661696C61626C6520696E204D7953514C20352E3120616E6420677265617465722028696E636C7564696E67204D61726961444220352E3120616E642067726561746572292C2069742070726F7669646573206120676F6F6420626173696320756E6465727374616E64696E67206F66204D7953514C20666F722074686520656E642D757365722E20
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 1
+Warning 1265 Data truncated for column 'v1' at row 1
+Warning 1265 Data truncated for column 'v64' at row 1
+Warning 1265 Data truncated for column 'v65000' at row 1
+INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, v65000, CONCAT(v65000,v1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 2
+Warning 1265 Data truncated for column 'v1' at row 2
+Warning 1265 Data truncated for column 'v64' at row 2
+Warning 1265 Data truncated for column 'v0' at row 3
+Warning 1265 Data truncated for column 'v1' at row 3
+Warning 1265 Data truncated for column 'v64' at row 3
+Warning 1265 Data truncated for column 'v65000' at row 3
+SELECT HEX(v0), HEX(v1), HEX(v64), LENGTH(HEX(v65000)) FROM t1;
+HEX(v0) HEX(v1) HEX(v64) LENGTH(HEX(v65000))
+ 0
+ 0
+ 48 486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E20576527766520 5932
+ 61 61626364656667686920616263646566676869206162636465666768692061626364656667686920616263646566676869206162636465666768692061626364 130000
+ 79 4F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C7265616479206578697374 5930
+ 79 63636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363 130000
+ALTER TABLE t1 ADD COLUMN v65536 VARBINARY(65536) <CUSTOM_COL_OPTIONS> NOT NULL;
+Warnings:
+Note 1246 Converting column 'v65536' from VARBINARY to BLOB
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varbinary(0) # # #
+v1 varbinary(1) # # #
+v64 varbinary(64) # # #
+v65000 varbinary(65000) # # #
+v65536 mediumblob # # #
+DROP TABLE t1, t2;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c VARBINARY(64) <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c varbinary(64) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c VARBINARY(64) <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 VARBINARY(64) <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 'test'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c varbinary(64) NO NULL
+c2 varbinary(64) NO test
+ALTER TABLE t1 ADD COLUMN err VARBINARY(64) <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES ('test');
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+#
+# BIT columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a BIT <CUSTOM_COL_OPTIONS> NOT NULL,
+b BIT(20) <CUSTOM_COL_OPTIONS> NOT NULL,
+c BIT(64) <CUSTOM_COL_OPTIONS> NOT NULL,
+d BIT(1) <CUSTOM_COL_OPTIONS> NOT NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a bit(1) # # #
+b bit(20) # # #
+c bit(64) # # #
+d bit(1) # # #
+ALTER TABLE t1 DROP COLUMN d;
+ALTER TABLE t1 ADD COLUMN d BIT(0) <CUSTOM_COL_OPTIONS> NOT NULL;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a bit(1) # # #
+b bit(20) # # #
+c bit(64) # # #
+d bit(1) # # #
+INSERT INTO t1 (a,b,c,d) VALUES (0,POW(2,20)-1,b'1111111111111111111111111111111111111111111111111111111111111111',1);
+SELECT BIN(a), HEX(b), c+0 FROM t1 WHERE d>0;
+BIN(a) HEX(b) c+0
+0 FFFFF 18446744073709551615
+INSERT INTO t1 (a,b,c,d) VALUES (1,0,-1,0);
+SELECT a+0, b+0, c+0 FROM t1 WHERE d<100;
+a+0 b+0 c+0
+0 1048575 18446744073709551615
+1 0 18446744073709551615
+INSERT INTO t1 (a,b,c,d) VALUES (b'1', 'f', 0xFF, 0x0);
+SELECT a+0, b+0, c+0 FROM t1 WHERE d IN (0, 2);
+a+0 b+0 c+0
+1 0 18446744073709551615
+1 102 255
+INSERT INTO t1 (a,b,c,d) VALUES (0x10,0,0,1);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+SELECT a,b,c,d FROM t1;
+a b c d
+INSERT INTO t1 (a,b,c,d) VALUES (0x01,0,0x10000000000000000,0);
+Warnings:
+Warning 1264 Out of range value for column 'c' at row 1
+SELECT a,b,c,d FROM t1;
+a b c d
+DROP TABLE t1;
+CREATE TABLE t1 (a BIT(65) <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ERROR 42000: Display width out of range for 'a' (max = 64)
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c BIT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c bit(1) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c BIT <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 BIT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 1
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c bit(1) NO NULL
+c2 bit(1) NO b'1'
+ALTER TABLE t1 ADD COLUMN err BIT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES (1);
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+#
+# BLOB columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (b BLOB <CUSTOM_COL_OPTIONS> NOT NULL,
+b0 BLOB(0) <CUSTOM_COL_OPTIONS> NOT NULL,
+b1 BLOB(1) <CUSTOM_COL_OPTIONS> NOT NULL,
+b300 BLOB(300) <CUSTOM_COL_OPTIONS> NOT NULL,
+bm BLOB(65535) <CUSTOM_COL_OPTIONS> NOT NULL,
+b70k BLOB(70000) <CUSTOM_COL_OPTIONS> NOT NULL,
+b17m BLOB(17000000) <CUSTOM_COL_OPTIONS> NOT NULL,
+t TINYBLOB <CUSTOM_COL_OPTIONS> NOT NULL,
+m MEDIUMBLOB <CUSTOM_COL_OPTIONS> NOT NULL,
+l LONGBLOB <CUSTOM_COL_OPTIONS> NOT NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b blob # # #
+b0 blob # # #
+b1 tinyblob # # #
+b300 blob # # #
+bm blob # # #
+b70k mediumblob # # #
+b17m longblob # # #
+t tinyblob # # #
+m mediumblob # # #
+l longblob # # #
+INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
+('','','','','','','','','',''),
+('a','b','c','d','e','f','g','h','i','j'),
+('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
+( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), HEX(REPEAT('g',1048576)), REPEAT('h',255), REPEAT('i',1048576), HEX(REPEAT('j',1048576)) );
+SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(b) LENGTH(b0) LENGTH(b1) LENGTH(b300) LENGTH(bm) LENGTH(b70k) LENGTH(b17m) LENGTH(t) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 2097152 255 1048576 2097152
+INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
+( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b0' at row 1
+Warning 1265 Data truncated for column 'b1' at row 1
+Warning 1265 Data truncated for column 'b300' at row 1
+Warning 1265 Data truncated for column 'bm' at row 1
+Warning 1265 Data truncated for column 't' at row 1
+SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(b) LENGTH(b0) LENGTH(b1) LENGTH(b300) LENGTH(bm) LENGTH(b70k) LENGTH(b17m) LENGTH(t) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+65535 65535 255 65535 65535 1048576 2097152 255 1048576 2097152
+ALTER TABLE t1 ADD COLUMN bbb BLOB(4294967296);
+ERROR 42000: Display width out of range for 'bbb' (max = 4294967295)
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c BLOB <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c blob NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c TINYBLOB <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c tinyblob NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c MEDIUMBLOB <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c mediumblob NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c LONGBLOB <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c longblob NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+#
+# BOOL columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (b1 BOOL <CUSTOM_COL_OPTIONS> NOT NULL,
+b2 BOOLEAN <CUSTOM_COL_OPTIONS> NOT NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b1 tinyint(1) # # #
+b2 tinyint(1) # # #
+INSERT INTO t1 (b1,b2) VALUES (1,TRUE);
+SELECT b1,b2 FROM t1;
+b1 b2
+1 1
+INSERT INTO t1 (b1,b2) VALUES (FALSE,0);
+SELECT b1,b2 FROM t1;
+b1 b2
+0 0
+1 1
+INSERT INTO t1 (b1,b2) VALUES (2,3);
+SELECT b1,b2 FROM t1;
+b1 b2
+0 0
+1 1
+2 3
+INSERT INTO t1 (b1,b2) VALUES (-1,-2);
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+1 1
+2 3
+SELECT IF(b1,'true','false') AS a, IF(b2,'true','false') AS b FROM t1;
+a b
+false false
+true true
+true true
+true true
+SELECT b1,b2 FROM t1 WHERE b1 = TRUE;
+b1 b2
+1 1
+SELECT b1,b2 FROM t1 WHERE b2 = FALSE;
+b1 b2
+0 0
+INSERT INTO t1 (b1,b2) VALUES ('a','b');
+Warnings:
+Warning 1366 Incorrect integer value: 'a' for column 'b1' at row 1
+Warning 1366 Incorrect integer value: 'b' for column 'b2' at row 1
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+0 0
+1 1
+2 3
+INSERT INTO t1 (b1,b2) VALUES (128,-129);
+Warnings:
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b2' at row 1
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+0 0
+1 1
+127 -128
+2 3
+ALTER TABLE t1 ADD COLUMN b3 BOOLEAN UNSIGNED;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNSIGNED' at line 1
+ALTER TABLE t1 ADD COLUMN b3 BOOL ZEROFILL;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ZEROFILL' at line 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c BOOL <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c tinyint(1) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c BOOL <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 BOOL <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT '0'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c tinyint(1) NO NULL
+c2 tinyint(1) NO 0
+ALTER TABLE t1 ADD COLUMN err BOOL <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES ('0');
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+#
+# CHAR columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS> NOT NULL,
+c0 CHAR(0) <CUSTOM_COL_OPTIONS> NOT NULL,
+c1 CHAR(1) <CUSTOM_COL_OPTIONS> NOT NULL,
+c20 CHAR(20) <CUSTOM_COL_OPTIONS> NOT NULL,
+c255 CHAR(255) <CUSTOM_COL_OPTIONS> NOT NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c char(1) # # #
+c0 char(0) # # #
+c1 char(1) # # #
+c20 char(20) # # #
+c255 char(255) # # #
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('','','','','');
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.');
+SELECT c,c0,c1,c20,c255 FROM t1;
+c c0 c1 c20 c255
+
+a b abcdefghi klmnopqrst Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256));
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+Warning 1265 Data truncated for column 'c0' at row 1
+Warning 1265 Data truncated for column 'c1' at row 1
+Warning 1265 Data truncated for column 'c20' at row 1
+Warning 1265 Data truncated for column 'c255' at row 1
+INSERT INTO t1 (c,c0,c1,c20,c255) SELECT c255, c255, c255, c255, CONCAT(c255,c1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 2
+Warning 1265 Data truncated for column 'c0' at row 2
+Warning 1265 Data truncated for column 'c1' at row 2
+Warning 1265 Data truncated for column 'c20' at row 2
+Warning 1265 Data truncated for column 'c' at row 3
+Warning 1265 Data truncated for column 'c0' at row 3
+Warning 1265 Data truncated for column 'c1' at row 3
+Warning 1265 Data truncated for column 'c20' at row 3
+Warning 1265 Data truncated for column 'c255' at row 3
+SELECT c,c0,c1,c20,c255 FROM t1;
+c c0 c1 c20 c255
+
+
+C C Creating an article Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.b
+a a aaaaaaaaaaaaaaaaaaaa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+a b abcdefghi klmnopqrst Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.
+x x xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+SELECT DISTINCT c20, REPEAT('a',LENGTH(c20)), COUNT(*) FROM t1 GROUP BY c1, c20;
+c20 REPEAT('a',LENGTH(c20)) COUNT(*)
+ 2
+Creating an article aaaaaaaaaaaaaaaaaaa 1
+aaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa 1
+abcdefghi klmnopqrst aaaaaaaaaaaaaaaaaaaa 1
+xxxxxxxxxxxxxxxxxxxx aaaaaaaaaaaaaaaaaaaa 1
+ALTER TABLE t1 ADD COLUMN c257 CHAR(257) <CUSTOM_COL_OPTIONS> NOT NULL;
+ERROR 42000: Column length too big for column 'c257' (max = 255); use BLOB or TEXT instead
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c char(1) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 CHAR <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT '_'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c char(1) NO NULL
+c2 char(1) NO _
+ALTER TABLE t1 ADD COLUMN err CHAR <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES ('_');
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+#
+# VARCHAR columns
+#
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (v0 VARCHAR(0) <CUSTOM_COL_OPTIONS> NOT NULL,
+v1 VARCHAR(1) <CUSTOM_COL_OPTIONS> NOT NULL,
+v64 VARCHAR(64) <CUSTOM_COL_OPTIONS> NOT NULL,
+v65000 VARCHAR(65000) <CUSTOM_COL_OPTIONS> NOT NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varchar(0) # # #
+v1 varchar(1) # # #
+v64 varchar(64) # # #
+v65000 varchar(65000) # # #
+CREATE TABLE t2 (v VARCHAR(65532) <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t2;
+Field Type Null Key Default Extra
+v varchar(65532) # # #
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
+SELECT v0,v1,v64,v65000 FROM t1;
+v0 v1 v64 v65000
+
+
+
+
+
+
+
+
+
+
+
+ y Once there, double check that an article doesn't already exist Here is a list of recommended books on MariaDB and MySQL. We've provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+ o "High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL's full power." (From the book description at O'Reilly)
+ o A lot of examples of how to use MySQL. As with all of Paul's books, it's worth its weight in gold and even enjoyable reading for such a 'dry' subject.
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Free to read in the Knowledgebase!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+ o The 'default' book to read if you wont to learn to use MySQL / MariaDB.
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ * MariaDB Crash Course by Ben Forta
+ * MySQL (4th Edition) by Paul DuBois
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ * MySQL Admin Cookbook
+ * MySQL Cookbook by Paul DuBois
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ For MariaDB / MySQL end users
+ For developers who want to code on MariaDB or MySQL
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 1
+Warning 1265 Data truncated for column 'v1' at row 1
+Warning 1265 Data truncated for column 'v64' at row 1
+Warning 1265 Data truncated for column 'v65000' at row 1
+INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, v65000, CONCAT(v65000,v1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 2
+Warning 1265 Data truncated for column 'v1' at row 2
+Warning 1265 Data truncated for column 'v64' at row 2
+Warning 1265 Data truncated for column 'v0' at row 3
+Warning 1265 Data truncated for column 'v1' at row 3
+Warning 1265 Data truncated for column 'v64' at row 3
+Warning 1265 Data truncated for column 'v65000' at row 3
+SELECT v0, v1, v64, LENGTH(v65000) FROM t1;
+v0 v1 v64 LENGTH(v65000)
+ 0
+ 0
+ H Here is a list of recommended books on MariaDB and MySQL. We've 2966
+ a abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcd 65000
+ y Once there, double check that an article doesn't already exist 2965
+ y cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 65000
+ALTER TABLE t1 ADD COLUMN v65536 VARCHAR(65536) <CUSTOM_COL_OPTIONS> NOT NULL;
+Warnings:
+Note 1246 Converting column 'v65536' from VARCHAR to TEXT
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varchar(0) # # #
+v1 varchar(1) # # #
+v64 varchar(64) # # #
+v65000 varchar(65000) # # #
+v65536 mediumtext # # #
+DROP TABLE t1, t2;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c VARCHAR(64) <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c varchar(64) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c VARCHAR(64) <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 VARCHAR(64) <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 'test default'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c varchar(64) NO NULL
+c2 varchar(64) NO test default
+ALTER TABLE t1 ADD COLUMN err VARCHAR(64) <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES ('test default');
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+#
+# date and time columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (d DATE <CUSTOM_COL_OPTIONS> NOT NULL,
+dt DATETIME <CUSTOM_COL_OPTIONS> NOT NULL,
+ts TIMESTAMP <CUSTOM_COL_OPTIONS> NOT NULL,
+t TIME <CUSTOM_COL_OPTIONS> NOT NULL,
+y YEAR <CUSTOM_COL_OPTIONS> NOT NULL,
+y4 YEAR(4) <CUSTOM_COL_OPTIONS> NOT NULL,
+y2 YEAR(2) <CUSTOM_COL_OPTIONS> NOT NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+Warnings:
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+d date # # #
+dt datetime # # #
+ts timestamp # # # on update CURRENT_TIMESTAMP
+t time # # #
+y year(4) # # #
+y4 year(4) # # #
+y2 year(2) # # #
+SET @tm = '2012-04-09 05:27:00';
+INSERT INTO t1 (d,dt,ts,t,y,y4,y2) VALUES
+('1000-01-01', '1000-01-01 00:00:00', FROM_UNIXTIME(1), '-838:59:59', '1901', '1901', '00'),
+('9999-12-31', '9999-12-31 23:59:59', FROM_UNIXTIME(2147483647), '838:59:59', '2155', '2155', '99'),
+('0000-00-00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '00:00:00', '0', '0', '0'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),YEAR(@tm),YEAR(@tm));
+SELECT d,dt,ts,t,y,y4,y2 FROM t1;
+d dt ts t y y4 y2
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 2000 2000 00
+1000-01-01 1000-01-01 00:00:00 1970-01-01 00:00:01 -838:59:59 1901 1901 00
+2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 12
+9999-12-31 9999-12-31 23:59:59 2038-01-19 03:14:07 838:59:59 2155 2155 99
+INSERT INTO t1 (d,dt,ts,t,y,y4,y2) VALUES
+('999-13-32', '999-11-31 00:00:00', '0', '-839:00:00', '1900', '1900', '-1' );
+Warnings:
+Warning 1265 Data truncated for column 'd' at row 1
+Warning 1265 Data truncated for column 'dt' at row 1
+Warning 1265 Data truncated for column 'ts' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 'y' at row 1
+Warning 1264 Out of range value for column 'y4' at row 1
+Warning 1264 Out of range value for column 'y2' at row 1
+SELECT d,dt,ts,t,y,y4,y2 FROM t1;
+d dt ts t y y4 y2
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 -838:59:59 0000 0000 00
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 2000 2000 00
+1000-01-01 1000-01-01 00:00:00 1970-01-01 00:00:01 -838:59:59 1901 1901 00
+2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 12
+9999-12-31 9999-12-31 23:59:59 2038-01-19 03:14:07 838:59:59 2155 2155 99
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c DATE <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c date NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c DATE <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 DATE <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT '2012-12-21'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c date NO NULL
+c2 date NO 2012-12-21
+ALTER TABLE t1 ADD COLUMN err DATE <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES ('2012-12-21');
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c DATETIME <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c datetime NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c DATETIME <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 DATETIME <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT '2012-12-21 12:21:12'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c datetime NO NULL
+c2 datetime NO 2012-12-21 12:21:12
+ALTER TABLE t1 ADD COLUMN err DATETIME <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES ('2012-12-21 12:21:12');
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+CREATE TABLE t1 (c TIMESTAMP <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 TIMESTAMP <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT '2012-02-21 12:21:12'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ALTER TABLE t1 ADD COLUMN err TIMESTAMP <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+INSERT INTO t1 (c2) VALUES (NULL);
+SELECT c, c2 FROM t1;
+c c2
+<TIMESTAMP> <DEFAULT_TIMESTAMP>
+<TIMESTAMP> <TIMESTAMP>
+DROP TABLE t1;
+CREATE TABLE t1 (c TIMESTAMP <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c timestamp NO CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT c FROM t1;
+c
+<TIMESTAMP>
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c TIME <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c time NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c TIME <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 TIME <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT '12:21:12'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c time NO NULL
+c2 time NO 12:21:12
+ALTER TABLE t1 ADD COLUMN err TIME <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES ('12:21:12');
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c YEAR <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c year(4) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c YEAR <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 YEAR <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT '2012'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c year(4) NO NULL
+c2 year(4) NO 2012
+ALTER TABLE t1 ADD COLUMN err YEAR <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES ('2012');
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c YEAR(2) <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+Warnings:
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c year(2) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c YEAR(2) <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 YEAR(2) <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT '12'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+Warnings:
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c year(2) NO NULL
+c2 year(2) NO 12
+ALTER TABLE t1 ADD COLUMN err YEAR(2) <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES ('12');
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+#
+# ENUM columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a ENUM('') <CUSTOM_COL_OPTIONS> NOT NULL,
+b ENUM('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS> NOT NULL,
+c ENUM('1','2','3','4','5','6','7','8','9','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',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') <CUSTOM_COL_OPTIONS> NOT NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a enum('') # # #
+b enum('test1','test2','test3','test4','test5') # # #
+c enum('1','2','3','4','5','6','7','8','9','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','','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') # # #
+INSERT INTO t1 (a,b,c) VALUES ('','test2','4'),('',5,2);
+SELECT a,b,c FROM t1;
+a b c
+ test2 4
+ test5 2
+INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
+Warnings:
+Warning 1265 Data truncated for column 'a' at row 1
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+
+ test2 4
+ test5 2
+ALTER TABLE t1 ADD COLUMN e ENUM('a','A') <CUSTOM_COL_OPTIONS> NOT NULL;
+Warnings:
+Note 1291 Column 'e' has duplicated value 'a' in ENUM
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a enum('') # # #
+b enum('test1','test2','test3','test4','test5') # # #
+c enum('1','2','3','4','5','6','7','8','9','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','','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') # # #
+e enum('a','A') # # #
+INSERT INTO t1 (a,b,c,e) VALUES ('','test3','75','A');
+SELECT a,b,c,e FROM t1;
+a b c e
+ a
+ test2 4 a
+ test3 75 a
+ test5 2 a
+SELECT a,b,c,e FROM t1 WHERE b='test2' OR a != '';
+a b c e
+ test2 4 a
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c ENUM('test1','test2','test3') <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c enum('test1','test2','test3') NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c ENUM('test1','test2','test3') <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 ENUM('test1','test2','test3') <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 'test2'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c enum('test1','test2','test3') NO NULL
+c2 enum('test1','test2','test3') NO test2
+ALTER TABLE t1 ADD COLUMN err ENUM('test1','test2','test3') <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES ('test2');
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+#
+# Fixed point columns (NUMERIC, DECIMAL)
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (d DECIMAL <CUSTOM_COL_OPTIONS> NOT NULL,
+d0 DECIMAL(0) <CUSTOM_COL_OPTIONS> NOT NULL,
+d1_1 DECIMAL(1,1) <CUSTOM_COL_OPTIONS> NOT NULL,
+d10_2 DECIMAL(10,2) <CUSTOM_COL_OPTIONS> NOT NULL,
+d60_10 DECIMAL(60,10) <CUSTOM_COL_OPTIONS> NOT NULL,
+n NUMERIC <CUSTOM_COL_OPTIONS> NOT NULL,
+n0_0 NUMERIC(0,0) <CUSTOM_COL_OPTIONS> NOT NULL,
+n1 NUMERIC(1) <CUSTOM_COL_OPTIONS> NOT NULL,
+n20_4 NUMERIC(20,4) <CUSTOM_COL_OPTIONS> NOT NULL,
+n65_4 NUMERIC(65,4) <CUSTOM_COL_OPTIONS> NOT NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+d decimal(10,0) # # #
+d0 decimal(10,0) # # #
+d1_1 decimal(1,1) # # #
+d10_2 decimal(10,2) # # #
+d60_10 decimal(60,10) # # #
+n decimal(10,0) # # #
+n0_0 decimal(10,0) # # #
+n1 decimal(1,0) # # #
+n20_4 decimal(20,4) # # #
+n65_4 decimal(65,4) # # #
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (100,123456,0.3,40000.25,123456789123456789.10001,1024,7000.0,8.0,999999.9,9223372036854775807);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (9999999999.0,9999999999.0,0.9,99999999.99,99999999999999999999999999999999999999999999999999.9999999999,9999999999.0,9999999999.0,9.0,9999999999999999.9999,9999999999999999999999999999999999999999999999999999999999999.9999);
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (-100,-123456,-0.3,-40000.25,-123456789123456789.10001,-1024,-7000.0,-8.0,-999999.9,-9223372036854775807);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (-9999999999.0,-9999999999.0,-0.9,-99999999.99,-99999999999999999999999999999999999999999999999999.9999999999,-9999999999.0,-9999999999.0,-9.0,-9999999999999999.9999,-9999999999999999999999999999999999999999999999999999999999999.9999);
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1 WHERE n20_4 = 9999999999999999.9999 OR d < 100;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) SELECT n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4 FROM t1 WHERE n65_4 = ( SELECT MAX(n65_4) FROM t1 );
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (10000000000.0,10000000000.0,1.1,100000000.99,100000000000000000000000000000000000000000000000000.0,10000000000.0,10000000000.0,10.0,10000000000000000.9999,10000000000000000000000000000000000000000000000000000000000000.9999);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (9999999999.1,9999999999.1,1.9,99999999.001,99999999999999999999999999999999999999999999999999.99999999991,9999999999.1,9999999999.1,9.1,9999999999999999.00001,9999999999999999999999999999999999999999999999999999999999999.11111);
+Warnings:
+Note 1265 Data truncated for column 'd' at row 1
+Note 1265 Data truncated for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Note 1265 Data truncated for column 'd10_2' at row 1
+Note 1265 Data truncated for column 'd60_10' at row 1
+Note 1265 Data truncated for column 'n' at row 1
+Note 1265 Data truncated for column 'n0_0' at row 1
+Note 1265 Data truncated for column 'n1' at row 1
+Note 1265 Data truncated for column 'n20_4' at row 1
+Note 1265 Data truncated for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.00 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.0000 9999999999999999999999999999999999999999999999999999999999999.1111
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66);
+ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65.
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6);
+ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65.
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66);
+ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 30.
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c DECIMAL <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c decimal(10,0) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c DECIMAL <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 DECIMAL <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 1.1
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+Warnings:
+Note 1265 Data truncated for column 'c2' at row 1
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c decimal(10,0) NO NULL
+c2 decimal(10,0) NO 1
+ALTER TABLE t1 ADD COLUMN err DECIMAL <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES (1.1);
+Warnings:
+Note 1265 Data truncated for column 'c' at row 1
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c NUMERIC <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c decimal(10,0) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c NUMERIC <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 NUMERIC <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 0
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c decimal(10,0) NO NULL
+c2 decimal(10,0) NO 0
+ALTER TABLE t1 ADD COLUMN err NUMERIC <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES (0);
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+#
+# Floating point columns (FLOAT, DOUBLE)
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (f FLOAT <CUSTOM_COL_OPTIONS> NOT NULL,
+f0 FLOAT(0) <CUSTOM_COL_OPTIONS> NOT NULL,
+r1_1 REAL(1,1) <CUSTOM_COL_OPTIONS> NOT NULL,
+f23_0 FLOAT(23) <CUSTOM_COL_OPTIONS> NOT NULL,
+f20_3 FLOAT(20,3) <CUSTOM_COL_OPTIONS> NOT NULL,
+d DOUBLE <CUSTOM_COL_OPTIONS> NOT NULL,
+d1_0 DOUBLE(1,0) <CUSTOM_COL_OPTIONS> NOT NULL,
+d10_10 DOUBLE PRECISION (10,10) <CUSTOM_COL_OPTIONS> NOT NULL,
+d53 DOUBLE(53,0) <CUSTOM_COL_OPTIONS> NOT NULL,
+d53_10 DOUBLE(53,10) <CUSTOM_COL_OPTIONS> NOT NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+f float # # #
+f0 float # # #
+r1_1 double(1,1) # # #
+f23_0 float # # #
+f20_3 float(20,3) # # #
+d double # # #
+d1_0 double(1,0) # # #
+d10_10 double(10,10) # # #
+d53 double(53,0) # # #
+d53_10 double(53,10) # # #
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (12345.12345,12345.12345,0.9,123456789.123,56789.987,11111111.111,8.0,0.0123456789,1234566789123456789,99999999999999999.99999999);
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 11111111.111
+d10_10 0.0123456789
+d1_0 8
+d53 1234566789123456800
+d53_10 100000000000000000.0000000000
+f0 12345.1
+f20_3 56789.988
+f23_0 123457000
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (
+99999999999999999999999999999999999999,
+99999999999999999999999999999999999999.9999999999999999,
+0.9,
+99999999999999999999999999999999999999.9,
+99999999999999999.999,
+999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+9,
+0.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999
+);
+Warnings:
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 0
+d 11111111.111
+d 1e81
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 0
+d1_0 8
+d1_0 9
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 0
+f 1e38
+f0 0
+f0 12345.1
+f0 1e38
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (-999999999999999999999999,-99999999999.999999999999,-0.9,-999.99999999999999999999,-99999999999999999.999,-999999999999999999999999999999999999999999999999999999999999-0.999,-9,-.9999999999,-999999999999999999999999999999.99999999999999999999999,-9999999999999999999999999999999999999999999.9999999999);
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+SELECT MAX(f), MAX(f0), MAX(r1_1), MAX(f23_0), MAX(f20_3), MAX(d), MAX(d1_0), MAX(d10_10), MAX(d53), MAX(d53_10) FROM t1;
+MAX(f) 9.999999680285692e37
+MAX(d) 1e81
+MAX(d10_10) 0.9999999999
+MAX(d1_0) 9
+MAX(d53) 100000000000000000000000000000000000000000000000000000
+MAX(d53_10) 10000000000000000000000000000000000000000000.0000000000
+MAX(f0) 9.999999680285692e37
+MAX(f20_3) 99999998430674940.000
+MAX(f23_0) 9.999999680285692e37
+MAX(r1_1) 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) SELECT d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10 FROM t1 ORDER BY d53_10 DESC LIMIT 1;
+Warnings:
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e43
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 10000000000000000000000000000000000000000000.0000000000
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 10000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f 3.40282e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f0 3.40282e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+f23_0 3.40282e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (
+999999999999999999999999999999999999999,
+999999999999999999999999999999999999999.9999999999999999,
+1.9,
+999999999999999999999999999999999999999.9,
+999999999999999999.999,
+9999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+99,
+1.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999
+);
+Warnings:
+Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e43
+d 1e65
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 0.9999999999
+d10_10 10000000000000000000000000000000000000000000.0000000000
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 10000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f 3.40282e38
+f 3.40282e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f0 3.40282e38
+f0 3.40282e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+f23_0 3.40282e38
+f23_0 3.40282e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0);
+# ERROR: Statement succeeded (expected results: ER_TOO_BIG_DISPLAYWIDTH)
+# ------------ UNEXPECTED RESULT ------------
+# [ ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) ]
+# The statement|command succeeded unexpectedly.
+# ALTER TABLE or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors.
+# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def.
+# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped.
+# Also, this problem may cause a chain effect (more errors of different kinds in the test).
+# -------------------------------------------
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1);
+ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65.
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35);
+ERROR 42000: Too big scale 35 specified for 'n66_66'. Maximum is 30.
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c FLOAT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c float NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c FLOAT <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 FLOAT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 1.1
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c float NO NULL
+c2 float NO 1.1
+ALTER TABLE t1 ADD COLUMN err FLOAT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES (1.1 );
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c DOUBLE <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c double NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c DOUBLE <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 DOUBLE <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 0
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c double NO NULL
+c2 double NO 0
+ALTER TABLE t1 ADD COLUMN err DOUBLE <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES (0);
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+#
+# INT columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (i INT <CUSTOM_COL_OPTIONS> NOT NULL,
+i0 INT(0) <CUSTOM_COL_OPTIONS> NOT NULL,
+i1 INT(1) <CUSTOM_COL_OPTIONS> NOT NULL,
+i20 INT(20) <CUSTOM_COL_OPTIONS> NOT NULL,
+t TINYINT <CUSTOM_COL_OPTIONS> NOT NULL,
+t0 TINYINT(0) <CUSTOM_COL_OPTIONS> NOT NULL,
+t1 TINYINT(1) <CUSTOM_COL_OPTIONS> NOT NULL,
+t20 TINYINT(20) <CUSTOM_COL_OPTIONS> NOT NULL,
+s SMALLINT <CUSTOM_COL_OPTIONS> NOT NULL,
+s0 SMALLINT(0) <CUSTOM_COL_OPTIONS> NOT NULL,
+s1 SMALLINT(1) <CUSTOM_COL_OPTIONS> NOT NULL,
+s20 SMALLINT(20) <CUSTOM_COL_OPTIONS> NOT NULL,
+m MEDIUMINT <CUSTOM_COL_OPTIONS> NOT NULL,
+m0 MEDIUMINT(0) <CUSTOM_COL_OPTIONS> NOT NULL,
+m1 MEDIUMINT(1) <CUSTOM_COL_OPTIONS> NOT NULL,
+m20 MEDIUMINT(20) <CUSTOM_COL_OPTIONS> NOT NULL,
+b BIGINT <CUSTOM_COL_OPTIONS> NOT NULL,
+b0 BIGINT(0) <CUSTOM_COL_OPTIONS> NOT NULL,
+b1 BIGINT(1) <CUSTOM_COL_OPTIONS> NOT NULL,
+b20 BIGINT(20) <CUSTOM_COL_OPTIONS> NOT NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+i int(11) # # #
+i0 int(11) # # #
+i1 int(1) # # #
+i20 int(20) # # #
+t tinyint(4) # # #
+t0 tinyint(4) # # #
+t1 tinyint(1) # # #
+t20 tinyint(20) # # #
+s smallint(6) # # #
+s0 smallint(6) # # #
+s1 smallint(1) # # #
+s20 smallint(20) # # #
+m mediumint(9) # # #
+m0 mediumint(9) # # #
+m1 mediumint(1) # # #
+m20 mediumint(20) # # #
+b bigint(20) # # #
+b0 bigint(20) # # #
+b1 bigint(1) # # #
+b20 bigint(20) # # #
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (2147483647,2147483647,2147483647,2147483647,127,127,127,127,32767,32767,32767,32767,8388607,8388607,8388607,8388607,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807);
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483648,-2147483648,-2147483648,-2147483648,-128,-128,-128,-128,-32768,-32768,-32768,-32768,-8388608,-8388608,-8388608,-8388608,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967295,4294967295,4294967295,4294967295,255,255,255,255,65535,65535,65535,65535,16777215,16777215,16777215,16777215,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483649,-2147483649,-2147483649,-2147483649,-129,-129,-129,-129,-32769,-32769,-32769,-32769,-8388609,-8388609,-8388609,-8388609,-9223372036854775809,-9223372036854775809,-9223372036854775809,-9223372036854775809);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967296,4294967296,4294967296,4294967296,256,256,256,256,65536,65536,65536,65536,16777216,16777216,16777216,16777216,18446744073709551616,18446744073709551616,18446744073709551616,18446744073709551616);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) SELECT b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b FROM t1 WHERE b IN (-9223372036854775808,9223372036854775807,18446744073709551615);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'i' at row 2
+Warning 1264 Out of range value for column 'i0' at row 2
+Warning 1264 Out of range value for column 'i1' at row 2
+Warning 1264 Out of range value for column 'i20' at row 2
+Warning 1264 Out of range value for column 't' at row 2
+Warning 1264 Out of range value for column 't0' at row 2
+Warning 1264 Out of range value for column 't1' at row 2
+Warning 1264 Out of range value for column 't20' at row 2
+Warning 1264 Out of range value for column 's' at row 2
+Warning 1264 Out of range value for column 's0' at row 2
+Warning 1264 Out of range value for column 's1' at row 2
+Warning 1264 Out of range value for column 's20' at row 2
+Warning 1264 Out of range value for column 'm' at row 2
+Warning 1264 Out of range value for column 'm0' at row 2
+Warning 1264 Out of range value for column 'm1' at row 2
+Warning 1264 Out of range value for column 'm20' at row 2
+Warning 1264 Out of range value for column 'i' at row 3
+Warning 1264 Out of range value for column 'i0' at row 3
+Warning 1264 Out of range value for column 'i1' at row 3
+Warning 1264 Out of range value for column 'i20' at row 3
+Warning 1264 Out of range value for column 't' at row 3
+Warning 1264 Out of range value for column 't0' at row 3
+Warning 1264 Out of range value for column 't1' at row 3
+Warning 1264 Out of range value for column 't20' at row 3
+Warning 1264 Out of range value for column 's' at row 3
+Warning 1264 Out of range value for column 's0' at row 3
+Warning 1264 Out of range value for column 's1' at row 3
+Warning 1264 Out of range value for column 's20' at row 3
+Warning 1264 Out of range value for column 'm' at row 3
+Warning 1264 Out of range value for column 'm0' at row 3
+Warning 1264 Out of range value for column 'm1' at row 3
+Warning 1264 Out of range value for column 'm20' at row 3
+Warning 1264 Out of range value for column 'i' at row 4
+Warning 1264 Out of range value for column 'i0' at row 4
+Warning 1264 Out of range value for column 'i1' at row 4
+Warning 1264 Out of range value for column 'i20' at row 4
+Warning 1264 Out of range value for column 't' at row 4
+Warning 1264 Out of range value for column 't0' at row 4
+Warning 1264 Out of range value for column 't1' at row 4
+Warning 1264 Out of range value for column 't20' at row 4
+Warning 1264 Out of range value for column 's' at row 4
+Warning 1264 Out of range value for column 's0' at row 4
+Warning 1264 Out of range value for column 's1' at row 4
+Warning 1264 Out of range value for column 's20' at row 4
+Warning 1264 Out of range value for column 'm' at row 4
+Warning 1264 Out of range value for column 'm0' at row 4
+Warning 1264 Out of range value for column 'm1' at row 4
+Warning 1264 Out of range value for column 'm20' at row 4
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+ALTER TABLE t1 ADD COLUMN i257 INT(257);
+ERROR 42000: Display width out of range for 'i257' (max = 255)
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c INT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c int(11) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c INT <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 INT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 2147483647
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c int(11) NO NULL
+c2 int(11) NO 2147483647
+ALTER TABLE t1 ADD COLUMN err INT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES (2147483647);
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c TINYINT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c tinyint(4) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c TINYINT <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 TINYINT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 127
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c tinyint(4) NO NULL
+c2 tinyint(4) NO 127
+ALTER TABLE t1 ADD COLUMN err TINYINT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES (127 );
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c SMALLINT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c smallint(6) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c SMALLINT <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 SMALLINT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 0
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c smallint(6) NO NULL
+c2 smallint(6) NO 0
+ALTER TABLE t1 ADD COLUMN err SMALLINT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES (0);
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c MEDIUMINT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c mediumint(9) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c MEDIUMINT <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 MEDIUMINT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 1
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c mediumint(9) NO NULL
+c2 mediumint(9) NO 1
+ALTER TABLE t1 ADD COLUMN err MEDIUMINT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES (1);
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c BIGINT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c bigint(20) NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c BIGINT <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 BIGINT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 9223372036854775807
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c bigint(20) NO NULL
+c2 bigint(20) NO 9223372036854775807
+ALTER TABLE t1 ADD COLUMN err BIGINT <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES (9223372036854775807);
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+#
+# SET columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a SET('') <CUSTOM_COL_OPTIONS> NOT NULL,
+b SET('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS> NOT NULL,
+c SET('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','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') <CUSTOM_COL_OPTIONS> NOT NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a set('') # # #
+b set('test1','test2','test3','test4','test5') # # #
+c set('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','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') # # #
+INSERT INTO t1 (a,b,c) VALUES
+('','test2,test3','01,34,44,,23'),
+('',5,2),
+(',','test4,test2','');
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+ test1,test3 02
+ test2,test3 01,23,34,44
+ test2,test4
+INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+ 01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,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
+ test1,test3 02
+ test2,test3 01,23,34,44
+ test2,test4
+ALTER TABLE t1 ADD COLUMN e SET('a','A') <CUSTOM_COL_OPTIONS> NOT NULL;
+Warnings:
+Note 1291 Column 'e' has duplicated value 'a' in SET
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a set('') # # #
+b set('test1','test2','test3','test4','test5') # # #
+c set('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','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') # # #
+e set('a','A') # # #
+ALTER TABLE t1 ADD COLUMN f SET('1','2','3','4','5','6','7','8','9','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',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i') <CUSTOM_COL_OPTIONS> NOT NULL;
+ERROR HY000: Too many strings for column f and SET
+SELECT a,b,c,e FROM t1 WHERE FIND_IN_SET('test2',b)>0 OR a != '';
+a b c e
+ test2,test3 01,23,34,44
+ test2,test4
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c SET('test1','test2','test3') <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c set('test1','test2','test3') NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+CREATE TABLE t1 (c SET('test1','test2','test3') <CUSTOM_COL_OPTIONS> NOT NULL,
+c2 SET('test1','test2','test3') <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT 'test2,test3'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c set('test1','test2','test3') NO NULL
+c2 set('test1','test2','test3') NO test2,test3
+ALTER TABLE t1 ADD COLUMN err SET('test1','test2','test3') <CUSTOM_COL_OPTIONS> NOT NULL DEFAULT NULL;
+ERROR 42000: Invalid default value for 'err'
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+SELECT HEX(c), HEX(c2) FROM t1;
+HEX(c) HEX(c2)
+INSERT INTO t1 (c2) VALUES (NULL);
+ERROR 23000: Column 'c2' cannot be null
+INSERT INTO t1 (c) VALUES ('test2,test3');
+SELECT COUNT(c), COUNT(c2) FROM t1;
+COUNT(c) COUNT(c2)
+1 1
+DROP TABLE t1;
+#
+# TEXT columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (t TEXT <CUSTOM_COL_OPTIONS> NOT NULL,
+t0 TEXT(0) <CUSTOM_COL_OPTIONS> NOT NULL,
+t1 TEXT(1) <CUSTOM_COL_OPTIONS> NOT NULL,
+t300 TEXT(300) <CUSTOM_COL_OPTIONS> NOT NULL,
+tm TEXT(65535) <CUSTOM_COL_OPTIONS> NOT NULL,
+t70k TEXT(70000) <CUSTOM_COL_OPTIONS> NOT NULL,
+t17m TEXT(17000000) <CUSTOM_COL_OPTIONS> NOT NULL,
+tt TINYTEXT <CUSTOM_COL_OPTIONS> NOT NULL,
+m MEDIUMTEXT <CUSTOM_COL_OPTIONS> NOT NULL,
+l LONGTEXT <CUSTOM_COL_OPTIONS> NOT NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+t text # # #
+t0 text # # #
+t1 tinytext # # #
+t300 text # # #
+tm text # # #
+t70k mediumtext # # #
+t17m longtext # # #
+tt tinytext # # #
+m mediumtext # # #
+l longtext # # #
+INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
+('','','','','','','','','',''),
+('a','b','c','d','e','f','g','h','i','j'),
+('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
+( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',255), REPEAT('i',1048576), REPEAT('j',1048576) );
+SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(t) LENGTH(t0) LENGTH(t1) LENGTH(t300) LENGTH(tm) LENGTH(t70k) LENGTH(t17m) LENGTH(tt) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
+( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
+Warnings:
+Warning 1265 Data truncated for column 't' at row 1
+Warning 1265 Data truncated for column 't0' at row 1
+Warning 1265 Data truncated for column 't1' at row 1
+Warning 1265 Data truncated for column 't300' at row 1
+Warning 1265 Data truncated for column 'tm' at row 1
+Warning 1265 Data truncated for column 'tt' at row 1
+SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(t) LENGTH(t0) LENGTH(t1) LENGTH(t300) LENGTH(tm) LENGTH(t70k) LENGTH(t17m) LENGTH(tt) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+ALTER TABLE t1 ADD COLUMN ttt TEXT(4294967296);
+ERROR 42000: Display width out of range for 'ttt' (max = 4294967295)
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c TEXT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c text NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c TINYTEXT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c tinytext NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c MEDIUMTEXT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c mediumtext NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c LONGTEXT <CUSTOM_COL_OPTIONS> NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c longtext NO NULL
+INSERT INTO t1 (c) VALUES (NULL);
+ERROR 23000: Column 'c' cannot be null
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/col_opt_not_null.test b/mysql-test/suite/storage_engine/col_opt_not_null.test
new file mode 100644
index 00000000..1ec00621
--- /dev/null
+++ b/mysql-test/suite/storage_engine/col_opt_not_null.test
@@ -0,0 +1,260 @@
+#
+# NOT NULL column attribute
+#
+
+let $extra_col_opts = NOT NULL;
+
+--source have_engine.inc
+
+--echo #
+--echo # BINARY columns
+--echo #
+
+--source type_binary.inc
+--let $col_definition = BINARY $default_col_opts
+--let $col_default = 0
+--source col_not_null.inc
+
+--echo #
+--echo # VARBINARY columns
+--echo #
+
+--source type_varbinary.inc
+--let $col_definition = VARBINARY(64) $default_col_opts
+--let $col_default = 'test'
+--source col_not_null.inc
+
+--echo #
+--echo # BIT columns
+--echo #
+
+--source type_bit.inc
+--let $col_definition = BIT $default_col_opts
+--let $col_default = 1
+--source col_not_null.inc
+
+--echo #
+--echo # BLOB columns
+--echo #
+
+--source type_blob.inc
+
+--let $col_definition = BLOB $default_col_opts
+--source col_not_null.inc
+
+--let $col_definition = TINYBLOB $default_col_opts
+--source col_not_null.inc
+
+--let $col_definition = MEDIUMBLOB $default_col_opts
+--source col_not_null.inc
+
+--let $col_definition = LONGBLOB $default_col_opts
+--source col_not_null.inc
+
+--echo #
+--echo # BOOL columns
+--echo #
+
+--source type_bool.inc
+--let $col_definition = BOOL $default_col_opts
+--let $col_default = '0'
+--source col_not_null.inc
+
+--echo #
+--echo # CHAR columns
+--echo #
+
+--source type_char.inc
+--let $col_definition = CHAR $default_col_opts
+--let $col_default = '_'
+--source col_not_null.inc
+
+--echo #
+--echo # VARCHAR columns
+--echo #
+
+--source type_varchar.inc
+--let $col_definition = VARCHAR(64) $default_col_opts
+--let $col_default = 'test default'
+--source col_not_null.inc
+
+--echo #
+--echo # date and time columns
+--echo #
+
+--source type_date_time.inc
+
+--let $col_definition = DATE $default_col_opts
+--let $col_default = '2012-12-21'
+--source col_not_null.inc
+
+--let $col_definition = DATETIME $default_col_opts
+--let $col_default = '2012-12-21 12:21:12'
+--source col_not_null.inc
+
+# For TIMESTAMP the behavior is non-standard
+
+# $col_opts already contains NOT NULL part (it's set in have_engine.inc)
+
+let $create_definition =
+ c TIMESTAMP $col_opts,
+ c2 TIMESTAMP $col_opts DEFAULT '2012-02-21 12:21:12'
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = TIMESTAMP type or NOT NULL columns or DEFAULT
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --let $error_codes = ER_INVALID_DEFAULT
+ --let $alter_definition = ADD COLUMN err TIMESTAMP $col_opts DEFAULT NULL
+ --source alter_table.inc
+ if ($mysql_errname!=ER_INVALID_DEFAULT)
+ {
+ --let $functionality = ALTER or DEFAULT
+ --source unexpected_result.inc
+ }
+
+ INSERT INTO t1 (c) VALUES (NULL);
+ INSERT INTO t1 (c2) VALUES (NULL);
+ --replace_regex /2012-02-21 12:21:12/<DEFAULT_TIMESTAMP>/ /[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2} [[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}/<TIMESTAMP>/
+ SELECT c, c2 FROM t1;
+
+ DROP TABLE t1;
+}
+
+--let $create_definition = c TIMESTAMP $col_opts
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = TIMESTAMP type
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ SHOW COLUMNS IN t1;
+
+ INSERT INTO t1 (c) VALUES (NULL);
+ if ($mysql_errname)
+ {
+ --let $functionality = TIMESTAMP
+ --source unexpected_result.inc
+ }
+
+ --replace_regex /[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2} [[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}/<TIMESTAMP>/
+ SELECT c FROM t1;
+ DROP TABLE t1;
+}
+
+# End of TIMESTAMP exception
+
+
+--let $col_definition = TIME $default_col_opts
+--let $col_default = '12:21:12'
+--source col_not_null.inc
+
+--let $col_definition = YEAR $default_col_opts
+--let $col_default = '2012'
+--source col_not_null.inc
+
+--let $col_definition = YEAR(2) $default_col_opts
+--let $col_default = '12'
+--source col_not_null.inc
+
+
+--echo #
+--echo # ENUM columns
+--echo #
+
+--source type_enum.inc
+
+--let $col_definition = ENUM('test1','test2','test3') $default_col_opts
+--let $col_default = 'test2'
+--source col_not_null.inc
+
+
+--echo #
+--echo # Fixed point columns (NUMERIC, DECIMAL)
+--echo #
+
+--source type_fixed.inc
+
+--let $col_definition = DECIMAL $default_col_opts
+--let $col_default = 1.1
+--source col_not_null.inc
+
+--let $col_definition = NUMERIC $default_col_opts
+--let $col_default = 0
+--source col_not_null.inc
+
+--echo #
+--echo # Floating point columns (FLOAT, DOUBLE)
+--echo #
+
+--source type_float.inc
+
+--let $col_definition = FLOAT $default_col_opts
+--let $col_default = 1.1
+--source col_not_null.inc
+
+--let $col_definition = DOUBLE $default_col_opts
+--let $col_default = 0
+--source col_not_null.inc
+
+--echo #
+--echo # INT columns
+--echo #
+
+--source type_int.inc
+
+--let $col_definition = INT $default_col_opts
+--let $col_default = 2147483647
+--source col_not_null.inc
+
+--let $col_definition = TINYINT $default_col_opts
+--let $col_default = 127
+--source col_not_null.inc
+
+--let $col_definition = SMALLINT $default_col_opts
+--let $col_default = 0
+--source col_not_null.inc
+
+--let $col_definition = MEDIUMINT $default_col_opts
+--let $col_default = 1
+--source col_not_null.inc
+
+--let $col_definition = BIGINT $default_col_opts
+--let $col_default = 9223372036854775807
+--source col_not_null.inc
+
+--echo #
+--echo # SET columns
+--echo #
+
+--source type_set.inc
+--let $col_definition = SET('test1','test2','test3') $default_col_opts
+--let $col_default = 'test2,test3'
+--source col_not_null.inc
+
+--echo #
+--echo # TEXT columns
+--echo #
+
+--source type_text.inc
+
+--let $col_definition = TEXT $default_col_opts
+--source col_not_null.inc
+
+--let $col_definition = TINYTEXT $default_col_opts
+--source col_not_null.inc
+
+--let $col_definition = MEDIUMTEXT $default_col_opts
+--source col_not_null.inc
+
+--let $col_definition = LONGTEXT $default_col_opts
+--source col_not_null.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/col_opt_null.result b/mysql-test/suite/storage_engine/col_opt_null.result
new file mode 100644
index 00000000..17f7d51d
--- /dev/null
+++ b/mysql-test/suite/storage_engine/col_opt_null.result
@@ -0,0 +1,2003 @@
+#
+# BINARY columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (b BINARY <CUSTOM_COL_OPTIONS> NULL,
+b0 BINARY(0) <CUSTOM_COL_OPTIONS> NULL,
+b1 BINARY(1) <CUSTOM_COL_OPTIONS> NULL,
+b20 BINARY(20) <CUSTOM_COL_OPTIONS> NULL,
+b255 BINARY(255) <CUSTOM_COL_OPTIONS> NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b binary(1) # # # #
+b0 binary(0) # # # #
+b1 binary(1) # # # #
+b20 binary(20) # # # #
+b255 binary(255) # # # #
+INSERT INTO t1 (b,b0,b1,b20,b255) VALUES ('','','','','');
+INSERT INTO t1 (b,b0,b1,b20,b255) VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.');
+SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255) FROM t1;
+HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255)
+00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000
+INSERT INTO t1 (b,b0,b1,b20,b255) VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256));
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b0' at row 1
+Warning 1265 Data truncated for column 'b1' at row 1
+Warning 1265 Data truncated for column 'b20' at row 1
+Warning 1265 Data truncated for column 'b255' at row 1
+INSERT INTO t1 (b,b0,b1,b20,b255) SELECT b255, b255, b255, b255, CONCAT(b255,b255) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b0' at row 1
+Warning 1265 Data truncated for column 'b1' at row 1
+Warning 1265 Data truncated for column 'b20' at row 1
+Warning 1265 Data truncated for column 'b255' at row 1
+Warning 1265 Data truncated for column 'b' at row 2
+Warning 1265 Data truncated for column 'b0' at row 2
+Warning 1265 Data truncated for column 'b1' at row 2
+Warning 1265 Data truncated for column 'b20' at row 2
+Warning 1265 Data truncated for column 'b255' at row 2
+Warning 1265 Data truncated for column 'b' at row 3
+Warning 1265 Data truncated for column 'b0' at row 3
+Warning 1265 Data truncated for column 'b1' at row 3
+Warning 1265 Data truncated for column 'b20' at row 3
+Warning 1265 Data truncated for column 'b255' at row 3
+SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255) FROM t1;
+HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255)
+00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+43 43 4372656174696E6720616E2061727469636C6520 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000
+61 61 6161616161616161616161616161616161616161 787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878
+61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000
+78 78 7878787878787878787878787878787878787878 787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878
+ALTER TABLE t1 ADD COLUMN b257 BINARY(257) <CUSTOM_COL_OPTIONS> NULL;
+ERROR 42000: Column length too big for column 'b257' (max = 255); use BLOB or TEXT instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b binary(1) # # # #
+b0 binary(0) # # # #
+b1 binary(1) # # # #
+b20 binary(20) # # # #
+b255 binary(255) # # # #
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c BINARY <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c binary(1) YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c BINARY <CUSTOM_COL_OPTIONS> NULL,
+c1 BINARY <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 BINARY <CUSTOM_COL_OPTIONS> NULL DEFAULT 0
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c binary(1) YES NULL
+c1 binary(1) YES NULL
+c2 binary(1) YES 0
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+#
+# VARBINARY columns
+#
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (v0 VARBINARY(0) <CUSTOM_COL_OPTIONS> NULL,
+v1 VARBINARY(1) <CUSTOM_COL_OPTIONS> NULL,
+v64 VARBINARY(64) <CUSTOM_COL_OPTIONS> NULL,
+v65000 VARBINARY(65000) <CUSTOM_COL_OPTIONS> NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varbinary(0) # # #
+v1 varbinary(1) # # #
+v64 varbinary(64) # # #
+v65000 varbinary(65000) # # #
+CREATE TABLE t2 (v VARBINARY(65532) <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t2;
+Field Type Null Key Default Extra
+v varbinary(65532) # # #
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
+SELECT HEX(v0), HEX(v1), HEX(v64), HEX(v65000) FROM t1;
+HEX(v0) HEX(v1) HEX(v64) HEX(v65000)
+
+ 79 4F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C7265616479206578697374 486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E2057652776652070726F7669646564206C696E6B7320746F20416D617A6F6E2E636F6D206865726520666F7220636F6E76656E69656E63652C2062757420746865792063616E20626520666F756E64206174206D616E79206F7468657220626F6F6B73746F7265732C20626F7468206F6E6C696E6520616E64206F66662E0A0A2020496620796F752077616E7420746F206861766520796F7572206661766F72697465204D7953514C202F204D61726961444220626F6F6B206C697374656420686572652C20706C65617365206C65617665206120636F6D6D656E742E0A2020466F7220646576656C6F706572732077686F2077616E7420746F20636F6465206F6E204D617269614442206F72204D7953514C0A0A2020202020202A20556E6465727374616E64696E67204D7953514C20496E7465726E616C73206279205361736861205061636865762C20666F726D6572204D7953514C20646576656C6F706572206174204D7953514C2041422E0A2020202020202020202020206F205468697320697320746865206F6E6C7920626F6F6B207765206B6E6F772061626F75742074686174206465736372696265732074686520696E7465726E616C73206F66204D617269614442202F204D7953514C2E2041206D757374206861766520666F7220616E796F6E652077686F2077616E747320746F20756E6465727374616E6420616E6420646576656C6F70206F6E204D617269614442210A2020202020202020202020206F204E6F7420616C6C20746F706963732061726520636F766572656420616E6420736F6D652070617274732061726520736C696768746C79206F757464617465642C20627574207374696C6C20746865206265737420626F6F6B206F6E207468697320746F7069632E200A2020202020202A204D7953514C20352E3120506C7567696E20446576656C6F706D656E742062792053657267656920476F6C75626368696B20616E6420416E64726577204875746368696E67730A2020202020202020202020206F2041206D757374207265616420666F7220616E796F6E652077616E74696E6720746F207772697465206120706C7567696E20666F72204D6172696144422C207772697474656E20627920746865205365726765692077686F2064657369676E65642074686520706C7567696E20696E7465726661636520666F72204D7953514C20616E64204D61726961444221200A0A2020466F72204D617269614442202F204D7953514C20656E642075736572730A0A2020202020202A204D61726961444220437261736820436F757273652062792042656E20466F7274610A2020202020202020202020206F204669727374204D61726961444220626F6F6B210A2020202020202020202020206F20466F722070656F706C652077686F2077616E7420746F206C6561726E2053514C20616E642074686520626173696373206F66204D6172696144422E0A2020202020202020202020206F204E6F77207368697070696E672E20507572636861736520617420416D617A6F6E2E636F6D206F7220796F7572206661766F7269746520626F6F6B73656C6C65722E200A0A2020202020202A2053514C2D393920436F6D706C6574652C205265616C6C792062792050657465722047756C75747A616E20262054727564792050656C7A65722E0A2020202020202020202020206F2045766572797468696E6720796F752077616E74656420746F206B6E6F772061626F7574207468652053514C203939207374616E646172642E20457863656C6C656E74207265666572656E636520626F6F6B210A2020202020202020202020206F204672656520746F207265616420696E20746865204B6E6F776C656467656261736521200A0A2020202020202A204D7953514C20283474682045646974696F6E29206279205061756C204475426F69730A2020202020202020202020206F20546865202764656661756C742720626F6F6B20746F207265616420696620796F7520776F6E7420746F206C6561726E20746F20757365204D7953514C202F204D6172696144422E200A0A2020202020202A204D7953514C20436F6F6B626F6F6B206279205061756C204475426F69730A2020202020202020202020206F2041206C6F74206F66206578616D706C6573206F6620686F7720746F20757365204D7953514C2E204173207769746820616C6C206F66205061756C277320626F6F6B732C206974277320776F727468206974732077656967687420696E20676F6C6420616E64206576656E20656E6A6F7961626C652072656164696E6720666F7220737563682061202764727927207375626A6563742E200A0A2020202020202A204869676820506572666F726D616E6365204D7953514C2C205365636F6E642045646974696F6E2C204279204261726F6E20536368776172747A2C205065746572205A6169747365762C20566164696D20546B616368656E6B6F2C204A6572656D7920442E205A61776F646E792C2041726A656E204C656E747A2C20446572656B204A2E2042616C6C696E672C20657420616C2E0A2020202020202020202020206F20224869676820506572666F726D616E6365204D7953514C2069732074686520646566696E697469766520677569646520746F206275696C64696E6720666173742C2072656C6961626C652073797374656D732077697468204D7953514C2E205772697474656E206279206E6F74656420657870657274732077697468207965617273206F66207265616C2D776F726C6420657870657269656E6365206275696C64696E672076657279206C617267652073797374656D732C207468697320626F6F6B20636F7665727320657665727920617370656374206F66204D7953514C20706572666F726D616E636520696E2064657461696C2C20616E6420666F6375736573206F6E20726F627573746E6573732C2073656375726974792C20616E64206461746120696E746567726974792E204C6561726E20616476616E63656420746563686E697175657320696E20646570746820736F20796F752063616E206272696E67206F7574204D7953514C27732066756C6C20706F7765722E22202846726F6D2074686520626F6F6B206465736372697074696F6E206174204F275265696C6C7929200A0A2020202020202A204D7953514C2041646D696E20436F6F6B626F6F6B0A2020202020202020202020206F204120717569636B20737465702D62792D7374657020677569646520666F72204D7953514C20757365727320616E642064617461626173652061646D696E6973747261746F727320746F207461636B6C65207265616C2D776F726C64206368616C6C656E6765732077697468204D7953514C20636F6E66696775726174696F6E20616E642061646D696E697374726174696F6E200A0A2020202020202A204D7953514C20352E302043657274696669636174696F6E2053747564792047756964652C204279205061756C204475426F69732C2053746566616E2048696E7A2C204361727374656E20506564657273656E0A2020202020202020202020206F205468697320697320746865206F6666696369616C20677569646520746F20636F766572207468652070617373696E67206F66207468652074776F204D7953514C2043657274696669636174696F6E206578616D696E6174696F6E732E2049742069732076616C69642074696C6C2076657273696F6E20352E30206F6620746865207365727665722C20736F207768696C65206974206D697373657320616C6C2074686520666561747572657320617661696C61626C6520696E204D7953514C20352E3120616E6420677265617465722028696E636C7564696E67204D61726961444220352E3120616E642067726561746572292C2069742070726F7669646573206120676F6F6420626173696320756E6465727374616E64696E67206F66204D7953514C20666F722074686520656E642D757365722E20
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 1
+Warning 1265 Data truncated for column 'v1' at row 1
+Warning 1265 Data truncated for column 'v64' at row 1
+Warning 1265 Data truncated for column 'v65000' at row 1
+INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, v65000, CONCAT(v65000,v1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 2
+Warning 1265 Data truncated for column 'v1' at row 2
+Warning 1265 Data truncated for column 'v64' at row 2
+Warning 1265 Data truncated for column 'v0' at row 3
+Warning 1265 Data truncated for column 'v1' at row 3
+Warning 1265 Data truncated for column 'v64' at row 3
+Warning 1265 Data truncated for column 'v65000' at row 3
+SELECT HEX(v0), HEX(v1), HEX(v64), LENGTH(HEX(v65000)) FROM t1;
+HEX(v0) HEX(v1) HEX(v64) LENGTH(HEX(v65000))
+ 0
+ 0
+ 48 486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E20576527766520 5932
+ 61 61626364656667686920616263646566676869206162636465666768692061626364656667686920616263646566676869206162636465666768692061626364 130000
+ 79 4F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C7265616479206578697374 5930
+ 79 63636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363 130000
+ALTER TABLE t1 ADD COLUMN v65536 VARBINARY(65536) <CUSTOM_COL_OPTIONS> NULL;
+Warnings:
+Note 1246 Converting column 'v65536' from VARBINARY to BLOB
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varbinary(0) # # #
+v1 varbinary(1) # # #
+v64 varbinary(64) # # #
+v65000 varbinary(65000) # # #
+v65536 mediumblob # # #
+DROP TABLE t1, t2;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c VARBINARY(64) <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c varbinary(64) YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c VARBINARY(64) <CUSTOM_COL_OPTIONS> NULL,
+c1 VARBINARY(64) <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 VARBINARY(64) <CUSTOM_COL_OPTIONS> NULL DEFAULT 'test'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c varbinary(64) YES NULL
+c1 varbinary(64) YES NULL
+c2 varbinary(64) YES test
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+#
+# BIT columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a BIT <CUSTOM_COL_OPTIONS> NULL,
+b BIT(20) <CUSTOM_COL_OPTIONS> NULL,
+c BIT(64) <CUSTOM_COL_OPTIONS> NULL,
+d BIT(1) <CUSTOM_COL_OPTIONS> NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a bit(1) # # #
+b bit(20) # # #
+c bit(64) # # #
+d bit(1) # # #
+ALTER TABLE t1 DROP COLUMN d;
+ALTER TABLE t1 ADD COLUMN d BIT(0) <CUSTOM_COL_OPTIONS> NULL;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a bit(1) # # #
+b bit(20) # # #
+c bit(64) # # #
+d bit(1) # # #
+INSERT INTO t1 (a,b,c,d) VALUES (0,POW(2,20)-1,b'1111111111111111111111111111111111111111111111111111111111111111',1);
+SELECT BIN(a), HEX(b), c+0 FROM t1 WHERE d>0;
+BIN(a) HEX(b) c+0
+0 FFFFF 18446744073709551615
+INSERT INTO t1 (a,b,c,d) VALUES (1,0,-1,0);
+SELECT a+0, b+0, c+0 FROM t1 WHERE d<100;
+a+0 b+0 c+0
+0 1048575 18446744073709551615
+1 0 18446744073709551615
+INSERT INTO t1 (a,b,c,d) VALUES (b'1', 'f', 0xFF, 0x0);
+SELECT a+0, b+0, c+0 FROM t1 WHERE d IN (0, 2);
+a+0 b+0 c+0
+1 0 18446744073709551615
+1 102 255
+INSERT INTO t1 (a,b,c,d) VALUES (0x10,0,0,1);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+SELECT a,b,c,d FROM t1;
+a b c d
+INSERT INTO t1 (a,b,c,d) VALUES (0x01,0,0x10000000000000000,0);
+Warnings:
+Warning 1264 Out of range value for column 'c' at row 1
+SELECT a,b,c,d FROM t1;
+a b c d
+DROP TABLE t1;
+CREATE TABLE t1 (a BIT(65) <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ERROR 42000: Display width out of range for 'a' (max = 64)
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c BIT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c bit(1) YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c BIT <CUSTOM_COL_OPTIONS> NULL,
+c1 BIT <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 BIT <CUSTOM_COL_OPTIONS> NULL DEFAULT 1
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c bit(1) YES NULL
+c1 bit(1) YES NULL
+c2 bit(1) YES b'1'
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+#
+# BLOB columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (b BLOB <CUSTOM_COL_OPTIONS> NULL,
+b0 BLOB(0) <CUSTOM_COL_OPTIONS> NULL,
+b1 BLOB(1) <CUSTOM_COL_OPTIONS> NULL,
+b300 BLOB(300) <CUSTOM_COL_OPTIONS> NULL,
+bm BLOB(65535) <CUSTOM_COL_OPTIONS> NULL,
+b70k BLOB(70000) <CUSTOM_COL_OPTIONS> NULL,
+b17m BLOB(17000000) <CUSTOM_COL_OPTIONS> NULL,
+t TINYBLOB <CUSTOM_COL_OPTIONS> NULL,
+m MEDIUMBLOB <CUSTOM_COL_OPTIONS> NULL,
+l LONGBLOB <CUSTOM_COL_OPTIONS> NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b blob # # #
+b0 blob # # #
+b1 tinyblob # # #
+b300 blob # # #
+bm blob # # #
+b70k mediumblob # # #
+b17m longblob # # #
+t tinyblob # # #
+m mediumblob # # #
+l longblob # # #
+INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
+('','','','','','','','','',''),
+('a','b','c','d','e','f','g','h','i','j'),
+('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
+( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), HEX(REPEAT('g',1048576)), REPEAT('h',255), REPEAT('i',1048576), HEX(REPEAT('j',1048576)) );
+SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(b) LENGTH(b0) LENGTH(b1) LENGTH(b300) LENGTH(bm) LENGTH(b70k) LENGTH(b17m) LENGTH(t) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 2097152 255 1048576 2097152
+INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
+( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b0' at row 1
+Warning 1265 Data truncated for column 'b1' at row 1
+Warning 1265 Data truncated for column 'b300' at row 1
+Warning 1265 Data truncated for column 'bm' at row 1
+Warning 1265 Data truncated for column 't' at row 1
+SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(b) LENGTH(b0) LENGTH(b1) LENGTH(b300) LENGTH(bm) LENGTH(b70k) LENGTH(b17m) LENGTH(t) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+65535 65535 255 65535 65535 1048576 2097152 255 1048576 2097152
+ALTER TABLE t1 ADD COLUMN bbb BLOB(4294967296);
+ERROR 42000: Display width out of range for 'bbb' (max = 4294967295)
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c BLOB <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c blob YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c TINYBLOB <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c tinyblob YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c MEDIUMBLOB <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c mediumblob YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c LONGBLOB <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c longblob YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+#
+# BOOL columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (b1 BOOL <CUSTOM_COL_OPTIONS> NULL,
+b2 BOOLEAN <CUSTOM_COL_OPTIONS> NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b1 tinyint(1) # # #
+b2 tinyint(1) # # #
+INSERT INTO t1 (b1,b2) VALUES (1,TRUE);
+SELECT b1,b2 FROM t1;
+b1 b2
+1 1
+INSERT INTO t1 (b1,b2) VALUES (FALSE,0);
+SELECT b1,b2 FROM t1;
+b1 b2
+0 0
+1 1
+INSERT INTO t1 (b1,b2) VALUES (2,3);
+SELECT b1,b2 FROM t1;
+b1 b2
+0 0
+1 1
+2 3
+INSERT INTO t1 (b1,b2) VALUES (-1,-2);
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+1 1
+2 3
+SELECT IF(b1,'true','false') AS a, IF(b2,'true','false') AS b FROM t1;
+a b
+false false
+true true
+true true
+true true
+SELECT b1,b2 FROM t1 WHERE b1 = TRUE;
+b1 b2
+1 1
+SELECT b1,b2 FROM t1 WHERE b2 = FALSE;
+b1 b2
+0 0
+INSERT INTO t1 (b1,b2) VALUES ('a','b');
+Warnings:
+Warning 1366 Incorrect integer value: 'a' for column 'b1' at row 1
+Warning 1366 Incorrect integer value: 'b' for column 'b2' at row 1
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+0 0
+1 1
+2 3
+INSERT INTO t1 (b1,b2) VALUES (128,-129);
+Warnings:
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b2' at row 1
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+0 0
+1 1
+127 -128
+2 3
+ALTER TABLE t1 ADD COLUMN b3 BOOLEAN UNSIGNED;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNSIGNED' at line 1
+ALTER TABLE t1 ADD COLUMN b3 BOOL ZEROFILL;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ZEROFILL' at line 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c BOOL <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c tinyint(1) YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c BOOL <CUSTOM_COL_OPTIONS> NULL,
+c1 BOOL <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 BOOL <CUSTOM_COL_OPTIONS> NULL DEFAULT '0'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c tinyint(1) YES NULL
+c1 tinyint(1) YES NULL
+c2 tinyint(1) YES 0
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+#
+# CHAR columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS> NULL,
+c0 CHAR(0) <CUSTOM_COL_OPTIONS> NULL,
+c1 CHAR(1) <CUSTOM_COL_OPTIONS> NULL,
+c20 CHAR(20) <CUSTOM_COL_OPTIONS> NULL,
+c255 CHAR(255) <CUSTOM_COL_OPTIONS> NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c char(1) # # #
+c0 char(0) # # #
+c1 char(1) # # #
+c20 char(20) # # #
+c255 char(255) # # #
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('','','','','');
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.');
+SELECT c,c0,c1,c20,c255 FROM t1;
+c c0 c1 c20 c255
+
+a b abcdefghi klmnopqrst Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256));
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+Warning 1265 Data truncated for column 'c0' at row 1
+Warning 1265 Data truncated for column 'c1' at row 1
+Warning 1265 Data truncated for column 'c20' at row 1
+Warning 1265 Data truncated for column 'c255' at row 1
+INSERT INTO t1 (c,c0,c1,c20,c255) SELECT c255, c255, c255, c255, CONCAT(c255,c1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 2
+Warning 1265 Data truncated for column 'c0' at row 2
+Warning 1265 Data truncated for column 'c1' at row 2
+Warning 1265 Data truncated for column 'c20' at row 2
+Warning 1265 Data truncated for column 'c' at row 3
+Warning 1265 Data truncated for column 'c0' at row 3
+Warning 1265 Data truncated for column 'c1' at row 3
+Warning 1265 Data truncated for column 'c20' at row 3
+Warning 1265 Data truncated for column 'c255' at row 3
+SELECT c,c0,c1,c20,c255 FROM t1;
+c c0 c1 c20 c255
+
+
+C C Creating an article Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.b
+a a aaaaaaaaaaaaaaaaaaaa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+a b abcdefghi klmnopqrst Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.
+x x xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+SELECT DISTINCT c20, REPEAT('a',LENGTH(c20)), COUNT(*) FROM t1 GROUP BY c1, c20;
+c20 REPEAT('a',LENGTH(c20)) COUNT(*)
+ 2
+Creating an article aaaaaaaaaaaaaaaaaaa 1
+aaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa 1
+abcdefghi klmnopqrst aaaaaaaaaaaaaaaaaaaa 1
+xxxxxxxxxxxxxxxxxxxx aaaaaaaaaaaaaaaaaaaa 1
+ALTER TABLE t1 ADD COLUMN c257 CHAR(257) <CUSTOM_COL_OPTIONS> NULL;
+ERROR 42000: Column length too big for column 'c257' (max = 255); use BLOB or TEXT instead
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c char(1) YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS> NULL,
+c1 CHAR <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 CHAR <CUSTOM_COL_OPTIONS> NULL DEFAULT '_'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c char(1) YES NULL
+c1 char(1) YES NULL
+c2 char(1) YES _
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+#
+# VARCHAR columns
+#
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (v0 VARCHAR(0) <CUSTOM_COL_OPTIONS> NULL,
+v1 VARCHAR(1) <CUSTOM_COL_OPTIONS> NULL,
+v64 VARCHAR(64) <CUSTOM_COL_OPTIONS> NULL,
+v65000 VARCHAR(65000) <CUSTOM_COL_OPTIONS> NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varchar(0) # # #
+v1 varchar(1) # # #
+v64 varchar(64) # # #
+v65000 varchar(65000) # # #
+CREATE TABLE t2 (v VARCHAR(65532) <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t2;
+Field Type Null Key Default Extra
+v varchar(65532) # # #
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
+SELECT v0,v1,v64,v65000 FROM t1;
+v0 v1 v64 v65000
+
+
+
+
+
+
+
+
+
+
+
+ y Once there, double check that an article doesn't already exist Here is a list of recommended books on MariaDB and MySQL. We've provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+ o "High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL's full power." (From the book description at O'Reilly)
+ o A lot of examples of how to use MySQL. As with all of Paul's books, it's worth its weight in gold and even enjoyable reading for such a 'dry' subject.
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Free to read in the Knowledgebase!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+ o The 'default' book to read if you wont to learn to use MySQL / MariaDB.
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ * MariaDB Crash Course by Ben Forta
+ * MySQL (4th Edition) by Paul DuBois
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ * MySQL Admin Cookbook
+ * MySQL Cookbook by Paul DuBois
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ For MariaDB / MySQL end users
+ For developers who want to code on MariaDB or MySQL
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 1
+Warning 1265 Data truncated for column 'v1' at row 1
+Warning 1265 Data truncated for column 'v64' at row 1
+Warning 1265 Data truncated for column 'v65000' at row 1
+INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, v65000, CONCAT(v65000,v1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 2
+Warning 1265 Data truncated for column 'v1' at row 2
+Warning 1265 Data truncated for column 'v64' at row 2
+Warning 1265 Data truncated for column 'v0' at row 3
+Warning 1265 Data truncated for column 'v1' at row 3
+Warning 1265 Data truncated for column 'v64' at row 3
+Warning 1265 Data truncated for column 'v65000' at row 3
+SELECT v0, v1, v64, LENGTH(v65000) FROM t1;
+v0 v1 v64 LENGTH(v65000)
+ 0
+ 0
+ H Here is a list of recommended books on MariaDB and MySQL. We've 2966
+ a abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcd 65000
+ y Once there, double check that an article doesn't already exist 2965
+ y cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 65000
+ALTER TABLE t1 ADD COLUMN v65536 VARCHAR(65536) <CUSTOM_COL_OPTIONS> NULL;
+Warnings:
+Note 1246 Converting column 'v65536' from VARCHAR to TEXT
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varchar(0) # # #
+v1 varchar(1) # # #
+v64 varchar(64) # # #
+v65000 varchar(65000) # # #
+v65536 mediumtext # # #
+DROP TABLE t1, t2;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c VARCHAR(64) <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c varchar(64) YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c VARCHAR(64) <CUSTOM_COL_OPTIONS> NULL,
+c1 VARCHAR(64) <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 VARCHAR(64) <CUSTOM_COL_OPTIONS> NULL DEFAULT 'test default'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c varchar(64) YES NULL
+c1 varchar(64) YES NULL
+c2 varchar(64) YES test default
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+#
+# date and time columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (d DATE <CUSTOM_COL_OPTIONS> NULL,
+dt DATETIME <CUSTOM_COL_OPTIONS> NULL,
+ts TIMESTAMP <CUSTOM_COL_OPTIONS> NULL,
+t TIME <CUSTOM_COL_OPTIONS> NULL,
+y YEAR <CUSTOM_COL_OPTIONS> NULL,
+y4 YEAR(4) <CUSTOM_COL_OPTIONS> NULL,
+y2 YEAR(2) <CUSTOM_COL_OPTIONS> NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+Warnings:
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+d date # # #
+dt datetime # # #
+ts timestamp # # #
+t time # # #
+y year(4) # # #
+y4 year(4) # # #
+y2 year(2) # # #
+SET @tm = '2012-04-09 05:27:00';
+INSERT INTO t1 (d,dt,ts,t,y,y4,y2) VALUES
+('1000-01-01', '1000-01-01 00:00:00', FROM_UNIXTIME(1), '-838:59:59', '1901', '1901', '00'),
+('9999-12-31', '9999-12-31 23:59:59', FROM_UNIXTIME(2147483647), '838:59:59', '2155', '2155', '99'),
+('0000-00-00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '00:00:00', '0', '0', '0'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),YEAR(@tm),YEAR(@tm));
+SELECT d,dt,ts,t,y,y4,y2 FROM t1;
+d dt ts t y y4 y2
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 2000 2000 00
+1000-01-01 1000-01-01 00:00:00 1970-01-01 00:00:01 -838:59:59 1901 1901 00
+2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 12
+9999-12-31 9999-12-31 23:59:59 2038-01-19 03:14:07 838:59:59 2155 2155 99
+INSERT INTO t1 (d,dt,ts,t,y,y4,y2) VALUES
+('999-13-32', '999-11-31 00:00:00', '0', '-839:00:00', '1900', '1900', '-1' );
+Warnings:
+Warning 1265 Data truncated for column 'd' at row 1
+Warning 1265 Data truncated for column 'dt' at row 1
+Warning 1265 Data truncated for column 'ts' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 'y' at row 1
+Warning 1264 Out of range value for column 'y4' at row 1
+Warning 1264 Out of range value for column 'y2' at row 1
+SELECT d,dt,ts,t,y,y4,y2 FROM t1;
+d dt ts t y y4 y2
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 -838:59:59 0000 0000 00
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 2000 2000 00
+1000-01-01 1000-01-01 00:00:00 1970-01-01 00:00:01 -838:59:59 1901 1901 00
+2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 12
+9999-12-31 9999-12-31 23:59:59 2038-01-19 03:14:07 838:59:59 2155 2155 99
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c DATE <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c date YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c DATE <CUSTOM_COL_OPTIONS> NULL,
+c1 DATE <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 DATE <CUSTOM_COL_OPTIONS> NULL DEFAULT '2012-12-21'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c date YES NULL
+c1 date YES NULL
+c2 date YES 2012-12-21
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c DATETIME <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c datetime YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c DATETIME <CUSTOM_COL_OPTIONS> NULL,
+c1 DATETIME <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 DATETIME <CUSTOM_COL_OPTIONS> NULL DEFAULT '2012-12-21 12:21:12'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c datetime YES NULL
+c1 datetime YES NULL
+c2 datetime YES 2012-12-21 12:21:12
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c TIMESTAMP <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c timestamp YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c TIMESTAMP <CUSTOM_COL_OPTIONS> NULL,
+c1 TIMESTAMP <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 TIMESTAMP <CUSTOM_COL_OPTIONS> NULL DEFAULT '2012-12-21 12:21:12'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c timestamp YES NULL
+c1 timestamp YES NULL
+c2 timestamp YES 2012-12-21 12:21:12
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c TIME <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c time YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c TIME <CUSTOM_COL_OPTIONS> NULL,
+c1 TIME <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 TIME <CUSTOM_COL_OPTIONS> NULL DEFAULT '12:21:12'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c time YES NULL
+c1 time YES NULL
+c2 time YES 12:21:12
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c YEAR <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c year(4) YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c YEAR <CUSTOM_COL_OPTIONS> NULL,
+c1 YEAR <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 YEAR <CUSTOM_COL_OPTIONS> NULL DEFAULT '2012'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c year(4) YES NULL
+c1 year(4) YES NULL
+c2 year(4) YES 2012
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c YEAR(2) <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+Warnings:
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c year(2) YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c YEAR(2) <CUSTOM_COL_OPTIONS> NULL,
+c1 YEAR(2) <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 YEAR(2) <CUSTOM_COL_OPTIONS> NULL DEFAULT '12'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+Warnings:
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c year(2) YES NULL
+c1 year(2) YES NULL
+c2 year(2) YES 12
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+#
+# ENUM columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a ENUM('') <CUSTOM_COL_OPTIONS> NULL,
+b ENUM('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS> NULL,
+c ENUM('1','2','3','4','5','6','7','8','9','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',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') <CUSTOM_COL_OPTIONS> NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a enum('') # # #
+b enum('test1','test2','test3','test4','test5') # # #
+c enum('1','2','3','4','5','6','7','8','9','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','','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') # # #
+INSERT INTO t1 (a,b,c) VALUES ('','test2','4'),('',5,2);
+SELECT a,b,c FROM t1;
+a b c
+ test2 4
+ test5 2
+INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
+Warnings:
+Warning 1265 Data truncated for column 'a' at row 1
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+
+ test2 4
+ test5 2
+ALTER TABLE t1 ADD COLUMN e ENUM('a','A') <CUSTOM_COL_OPTIONS> NULL;
+Warnings:
+Note 1291 Column 'e' has duplicated value 'a' in ENUM
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a enum('') # # #
+b enum('test1','test2','test3','test4','test5') # # #
+c enum('1','2','3','4','5','6','7','8','9','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','','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') # # #
+e enum('a','A') # # #
+INSERT INTO t1 (a,b,c,e) VALUES ('','test3','75','A');
+SELECT a,b,c,e FROM t1;
+a b c e
+ NULL
+ test2 4 NULL
+ test3 75 a
+ test5 2 NULL
+SELECT a,b,c,e FROM t1 WHERE b='test2' OR a != '';
+a b c e
+ test2 4 NULL
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c ENUM('test1','test2','test3') <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c enum('test1','test2','test3') YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c ENUM('test1','test2','test3') <CUSTOM_COL_OPTIONS> NULL,
+c1 ENUM('test1','test2','test3') <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 ENUM('test1','test2','test3') <CUSTOM_COL_OPTIONS> NULL DEFAULT 'test2'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c enum('test1','test2','test3') YES NULL
+c1 enum('test1','test2','test3') YES NULL
+c2 enum('test1','test2','test3') YES test2
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+#
+# Fixed point columns (NUMERIC, DECIMAL)
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (d DECIMAL <CUSTOM_COL_OPTIONS> NULL,
+d0 DECIMAL(0) <CUSTOM_COL_OPTIONS> NULL,
+d1_1 DECIMAL(1,1) <CUSTOM_COL_OPTIONS> NULL,
+d10_2 DECIMAL(10,2) <CUSTOM_COL_OPTIONS> NULL,
+d60_10 DECIMAL(60,10) <CUSTOM_COL_OPTIONS> NULL,
+n NUMERIC <CUSTOM_COL_OPTIONS> NULL,
+n0_0 NUMERIC(0,0) <CUSTOM_COL_OPTIONS> NULL,
+n1 NUMERIC(1) <CUSTOM_COL_OPTIONS> NULL,
+n20_4 NUMERIC(20,4) <CUSTOM_COL_OPTIONS> NULL,
+n65_4 NUMERIC(65,4) <CUSTOM_COL_OPTIONS> NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+d decimal(10,0) # # #
+d0 decimal(10,0) # # #
+d1_1 decimal(1,1) # # #
+d10_2 decimal(10,2) # # #
+d60_10 decimal(60,10) # # #
+n decimal(10,0) # # #
+n0_0 decimal(10,0) # # #
+n1 decimal(1,0) # # #
+n20_4 decimal(20,4) # # #
+n65_4 decimal(65,4) # # #
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (100,123456,0.3,40000.25,123456789123456789.10001,1024,7000.0,8.0,999999.9,9223372036854775807);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (9999999999.0,9999999999.0,0.9,99999999.99,99999999999999999999999999999999999999999999999999.9999999999,9999999999.0,9999999999.0,9.0,9999999999999999.9999,9999999999999999999999999999999999999999999999999999999999999.9999);
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (-100,-123456,-0.3,-40000.25,-123456789123456789.10001,-1024,-7000.0,-8.0,-999999.9,-9223372036854775807);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (-9999999999.0,-9999999999.0,-0.9,-99999999.99,-99999999999999999999999999999999999999999999999999.9999999999,-9999999999.0,-9999999999.0,-9.0,-9999999999999999.9999,-9999999999999999999999999999999999999999999999999999999999999.9999);
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1 WHERE n20_4 = 9999999999999999.9999 OR d < 100;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) SELECT n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4 FROM t1 WHERE n65_4 = ( SELECT MAX(n65_4) FROM t1 );
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (10000000000.0,10000000000.0,1.1,100000000.99,100000000000000000000000000000000000000000000000000.0,10000000000.0,10000000000.0,10.0,10000000000000000.9999,10000000000000000000000000000000000000000000000000000000000000.9999);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (9999999999.1,9999999999.1,1.9,99999999.001,99999999999999999999999999999999999999999999999999.99999999991,9999999999.1,9999999999.1,9.1,9999999999999999.00001,9999999999999999999999999999999999999999999999999999999999999.11111);
+Warnings:
+Note 1265 Data truncated for column 'd' at row 1
+Note 1265 Data truncated for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Note 1265 Data truncated for column 'd10_2' at row 1
+Note 1265 Data truncated for column 'd60_10' at row 1
+Note 1265 Data truncated for column 'n' at row 1
+Note 1265 Data truncated for column 'n0_0' at row 1
+Note 1265 Data truncated for column 'n1' at row 1
+Note 1265 Data truncated for column 'n20_4' at row 1
+Note 1265 Data truncated for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.00 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.0000 9999999999999999999999999999999999999999999999999999999999999.1111
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66);
+ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65.
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6);
+ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65.
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66);
+ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 30.
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c DECIMAL <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c decimal(10,0) YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c DECIMAL <CUSTOM_COL_OPTIONS> NULL,
+c1 DECIMAL <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 DECIMAL <CUSTOM_COL_OPTIONS> NULL DEFAULT 1.1
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+Warnings:
+Note 1265 Data truncated for column 'c2' at row 1
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c decimal(10,0) YES NULL
+c1 decimal(10,0) YES NULL
+c2 decimal(10,0) YES 1
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c NUMERIC <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c decimal(10,0) YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c NUMERIC <CUSTOM_COL_OPTIONS> NULL,
+c1 NUMERIC <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 NUMERIC <CUSTOM_COL_OPTIONS> NULL DEFAULT 0
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c decimal(10,0) YES NULL
+c1 decimal(10,0) YES NULL
+c2 decimal(10,0) YES 0
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+#
+# Floating point columns (FLOAT, DOUBLE)
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (f FLOAT <CUSTOM_COL_OPTIONS> NULL,
+f0 FLOAT(0) <CUSTOM_COL_OPTIONS> NULL,
+r1_1 REAL(1,1) <CUSTOM_COL_OPTIONS> NULL,
+f23_0 FLOAT(23) <CUSTOM_COL_OPTIONS> NULL,
+f20_3 FLOAT(20,3) <CUSTOM_COL_OPTIONS> NULL,
+d DOUBLE <CUSTOM_COL_OPTIONS> NULL,
+d1_0 DOUBLE(1,0) <CUSTOM_COL_OPTIONS> NULL,
+d10_10 DOUBLE PRECISION (10,10) <CUSTOM_COL_OPTIONS> NULL,
+d53 DOUBLE(53,0) <CUSTOM_COL_OPTIONS> NULL,
+d53_10 DOUBLE(53,10) <CUSTOM_COL_OPTIONS> NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+f float # # #
+f0 float # # #
+r1_1 double(1,1) # # #
+f23_0 float # # #
+f20_3 float(20,3) # # #
+d double # # #
+d1_0 double(1,0) # # #
+d10_10 double(10,10) # # #
+d53 double(53,0) # # #
+d53_10 double(53,10) # # #
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (12345.12345,12345.12345,0.9,123456789.123,56789.987,11111111.111,8.0,0.0123456789,1234566789123456789,99999999999999999.99999999);
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 11111111.111
+d10_10 0.0123456789
+d1_0 8
+d53 1234566789123456800
+d53_10 100000000000000000.0000000000
+f0 12345.1
+f20_3 56789.988
+f23_0 123457000
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (
+99999999999999999999999999999999999999,
+99999999999999999999999999999999999999.9999999999999999,
+0.9,
+99999999999999999999999999999999999999.9,
+99999999999999999.999,
+999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+9,
+0.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999
+);
+Warnings:
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 0
+d 11111111.111
+d 1e81
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 0
+d1_0 8
+d1_0 9
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 0
+f 1e38
+f0 0
+f0 12345.1
+f0 1e38
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (-999999999999999999999999,-99999999999.999999999999,-0.9,-999.99999999999999999999,-99999999999999999.999,-999999999999999999999999999999999999999999999999999999999999-0.999,-9,-.9999999999,-999999999999999999999999999999.99999999999999999999999,-9999999999999999999999999999999999999999999.9999999999);
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+SELECT MAX(f), MAX(f0), MAX(r1_1), MAX(f23_0), MAX(f20_3), MAX(d), MAX(d1_0), MAX(d10_10), MAX(d53), MAX(d53_10) FROM t1;
+MAX(f) 9.999999680285692e37
+MAX(d) 1e81
+MAX(d10_10) 0.9999999999
+MAX(d1_0) 9
+MAX(d53) 100000000000000000000000000000000000000000000000000000
+MAX(d53_10) 10000000000000000000000000000000000000000000.0000000000
+MAX(f0) 9.999999680285692e37
+MAX(f20_3) 99999998430674940.000
+MAX(f23_0) 9.999999680285692e37
+MAX(r1_1) 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) SELECT d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10 FROM t1 ORDER BY d53_10 DESC LIMIT 1;
+Warnings:
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e43
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 10000000000000000000000000000000000000000000.0000000000
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 10000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f 3.40282e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f0 3.40282e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+f23_0 3.40282e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (
+999999999999999999999999999999999999999,
+999999999999999999999999999999999999999.9999999999999999,
+1.9,
+999999999999999999999999999999999999999.9,
+999999999999999999.999,
+9999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+99,
+1.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999
+);
+Warnings:
+Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e43
+d 1e65
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 0.9999999999
+d10_10 10000000000000000000000000000000000000000000.0000000000
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 10000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f 3.40282e38
+f 3.40282e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f0 3.40282e38
+f0 3.40282e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+f23_0 3.40282e38
+f23_0 3.40282e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0);
+# ERROR: Statement succeeded (expected results: ER_TOO_BIG_DISPLAYWIDTH)
+# ------------ UNEXPECTED RESULT ------------
+# [ ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) ]
+# The statement|command succeeded unexpectedly.
+# ALTER TABLE or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors.
+# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def.
+# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped.
+# Also, this problem may cause a chain effect (more errors of different kinds in the test).
+# -------------------------------------------
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1);
+ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65.
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35);
+ERROR 42000: Too big scale 35 specified for 'n66_66'. Maximum is 30.
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c FLOAT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c float YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c FLOAT <CUSTOM_COL_OPTIONS> NULL,
+c1 FLOAT <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 FLOAT <CUSTOM_COL_OPTIONS> NULL DEFAULT 1.1
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c float YES NULL
+c1 float YES NULL
+c2 float YES 1.1
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c DOUBLE <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c double YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c DOUBLE <CUSTOM_COL_OPTIONS> NULL,
+c1 DOUBLE <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 DOUBLE <CUSTOM_COL_OPTIONS> NULL DEFAULT 0
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c double YES NULL
+c1 double YES NULL
+c2 double YES 0
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+#
+# INT columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (i INT <CUSTOM_COL_OPTIONS> NULL,
+i0 INT(0) <CUSTOM_COL_OPTIONS> NULL,
+i1 INT(1) <CUSTOM_COL_OPTIONS> NULL,
+i20 INT(20) <CUSTOM_COL_OPTIONS> NULL,
+t TINYINT <CUSTOM_COL_OPTIONS> NULL,
+t0 TINYINT(0) <CUSTOM_COL_OPTIONS> NULL,
+t1 TINYINT(1) <CUSTOM_COL_OPTIONS> NULL,
+t20 TINYINT(20) <CUSTOM_COL_OPTIONS> NULL,
+s SMALLINT <CUSTOM_COL_OPTIONS> NULL,
+s0 SMALLINT(0) <CUSTOM_COL_OPTIONS> NULL,
+s1 SMALLINT(1) <CUSTOM_COL_OPTIONS> NULL,
+s20 SMALLINT(20) <CUSTOM_COL_OPTIONS> NULL,
+m MEDIUMINT <CUSTOM_COL_OPTIONS> NULL,
+m0 MEDIUMINT(0) <CUSTOM_COL_OPTIONS> NULL,
+m1 MEDIUMINT(1) <CUSTOM_COL_OPTIONS> NULL,
+m20 MEDIUMINT(20) <CUSTOM_COL_OPTIONS> NULL,
+b BIGINT <CUSTOM_COL_OPTIONS> NULL,
+b0 BIGINT(0) <CUSTOM_COL_OPTIONS> NULL,
+b1 BIGINT(1) <CUSTOM_COL_OPTIONS> NULL,
+b20 BIGINT(20) <CUSTOM_COL_OPTIONS> NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+i int(11) # # #
+i0 int(11) # # #
+i1 int(1) # # #
+i20 int(20) # # #
+t tinyint(4) # # #
+t0 tinyint(4) # # #
+t1 tinyint(1) # # #
+t20 tinyint(20) # # #
+s smallint(6) # # #
+s0 smallint(6) # # #
+s1 smallint(1) # # #
+s20 smallint(20) # # #
+m mediumint(9) # # #
+m0 mediumint(9) # # #
+m1 mediumint(1) # # #
+m20 mediumint(20) # # #
+b bigint(20) # # #
+b0 bigint(20) # # #
+b1 bigint(1) # # #
+b20 bigint(20) # # #
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (2147483647,2147483647,2147483647,2147483647,127,127,127,127,32767,32767,32767,32767,8388607,8388607,8388607,8388607,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807);
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483648,-2147483648,-2147483648,-2147483648,-128,-128,-128,-128,-32768,-32768,-32768,-32768,-8388608,-8388608,-8388608,-8388608,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967295,4294967295,4294967295,4294967295,255,255,255,255,65535,65535,65535,65535,16777215,16777215,16777215,16777215,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483649,-2147483649,-2147483649,-2147483649,-129,-129,-129,-129,-32769,-32769,-32769,-32769,-8388609,-8388609,-8388609,-8388609,-9223372036854775809,-9223372036854775809,-9223372036854775809,-9223372036854775809);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967296,4294967296,4294967296,4294967296,256,256,256,256,65536,65536,65536,65536,16777216,16777216,16777216,16777216,18446744073709551616,18446744073709551616,18446744073709551616,18446744073709551616);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) SELECT b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b FROM t1 WHERE b IN (-9223372036854775808,9223372036854775807,18446744073709551615);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'i' at row 2
+Warning 1264 Out of range value for column 'i0' at row 2
+Warning 1264 Out of range value for column 'i1' at row 2
+Warning 1264 Out of range value for column 'i20' at row 2
+Warning 1264 Out of range value for column 't' at row 2
+Warning 1264 Out of range value for column 't0' at row 2
+Warning 1264 Out of range value for column 't1' at row 2
+Warning 1264 Out of range value for column 't20' at row 2
+Warning 1264 Out of range value for column 's' at row 2
+Warning 1264 Out of range value for column 's0' at row 2
+Warning 1264 Out of range value for column 's1' at row 2
+Warning 1264 Out of range value for column 's20' at row 2
+Warning 1264 Out of range value for column 'm' at row 2
+Warning 1264 Out of range value for column 'm0' at row 2
+Warning 1264 Out of range value for column 'm1' at row 2
+Warning 1264 Out of range value for column 'm20' at row 2
+Warning 1264 Out of range value for column 'i' at row 3
+Warning 1264 Out of range value for column 'i0' at row 3
+Warning 1264 Out of range value for column 'i1' at row 3
+Warning 1264 Out of range value for column 'i20' at row 3
+Warning 1264 Out of range value for column 't' at row 3
+Warning 1264 Out of range value for column 't0' at row 3
+Warning 1264 Out of range value for column 't1' at row 3
+Warning 1264 Out of range value for column 't20' at row 3
+Warning 1264 Out of range value for column 's' at row 3
+Warning 1264 Out of range value for column 's0' at row 3
+Warning 1264 Out of range value for column 's1' at row 3
+Warning 1264 Out of range value for column 's20' at row 3
+Warning 1264 Out of range value for column 'm' at row 3
+Warning 1264 Out of range value for column 'm0' at row 3
+Warning 1264 Out of range value for column 'm1' at row 3
+Warning 1264 Out of range value for column 'm20' at row 3
+Warning 1264 Out of range value for column 'i' at row 4
+Warning 1264 Out of range value for column 'i0' at row 4
+Warning 1264 Out of range value for column 'i1' at row 4
+Warning 1264 Out of range value for column 'i20' at row 4
+Warning 1264 Out of range value for column 't' at row 4
+Warning 1264 Out of range value for column 't0' at row 4
+Warning 1264 Out of range value for column 't1' at row 4
+Warning 1264 Out of range value for column 't20' at row 4
+Warning 1264 Out of range value for column 's' at row 4
+Warning 1264 Out of range value for column 's0' at row 4
+Warning 1264 Out of range value for column 's1' at row 4
+Warning 1264 Out of range value for column 's20' at row 4
+Warning 1264 Out of range value for column 'm' at row 4
+Warning 1264 Out of range value for column 'm0' at row 4
+Warning 1264 Out of range value for column 'm1' at row 4
+Warning 1264 Out of range value for column 'm20' at row 4
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+ALTER TABLE t1 ADD COLUMN i257 INT(257);
+ERROR 42000: Display width out of range for 'i257' (max = 255)
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c INT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c int(11) YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c INT <CUSTOM_COL_OPTIONS> NULL,
+c1 INT <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 INT <CUSTOM_COL_OPTIONS> NULL DEFAULT 2147483647
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c int(11) YES NULL
+c1 int(11) YES NULL
+c2 int(11) YES 2147483647
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c TINYINT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c tinyint(4) YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c TINYINT <CUSTOM_COL_OPTIONS> NULL,
+c1 TINYINT <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 TINYINT <CUSTOM_COL_OPTIONS> NULL DEFAULT 127
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c tinyint(4) YES NULL
+c1 tinyint(4) YES NULL
+c2 tinyint(4) YES 127
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c SMALLINT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c smallint(6) YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c SMALLINT <CUSTOM_COL_OPTIONS> NULL,
+c1 SMALLINT <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 SMALLINT <CUSTOM_COL_OPTIONS> NULL DEFAULT 0
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c smallint(6) YES NULL
+c1 smallint(6) YES NULL
+c2 smallint(6) YES 0
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c MEDIUMINT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c mediumint(9) YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c MEDIUMINT <CUSTOM_COL_OPTIONS> NULL,
+c1 MEDIUMINT <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 MEDIUMINT <CUSTOM_COL_OPTIONS> NULL DEFAULT 1
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c mediumint(9) YES NULL
+c1 mediumint(9) YES NULL
+c2 mediumint(9) YES 1
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c BIGINT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c bigint(20) YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c BIGINT <CUSTOM_COL_OPTIONS> NULL,
+c1 BIGINT <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 BIGINT <CUSTOM_COL_OPTIONS> NULL DEFAULT 9223372036854775807
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c bigint(20) YES NULL
+c1 bigint(20) YES NULL
+c2 bigint(20) YES 9223372036854775807
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+#
+# SET columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a SET('') <CUSTOM_COL_OPTIONS> NULL,
+b SET('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS> NULL,
+c SET('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','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') <CUSTOM_COL_OPTIONS> NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a set('') # # #
+b set('test1','test2','test3','test4','test5') # # #
+c set('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','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') # # #
+INSERT INTO t1 (a,b,c) VALUES
+('','test2,test3','01,34,44,,23'),
+('',5,2),
+(',','test4,test2','');
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+ test1,test3 02
+ test2,test3 01,23,34,44
+ test2,test4
+INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+ 01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,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
+ test1,test3 02
+ test2,test3 01,23,34,44
+ test2,test4
+ALTER TABLE t1 ADD COLUMN e SET('a','A') <CUSTOM_COL_OPTIONS> NULL;
+Warnings:
+Note 1291 Column 'e' has duplicated value 'a' in SET
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a set('') # # #
+b set('test1','test2','test3','test4','test5') # # #
+c set('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','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') # # #
+e set('a','A') # # #
+ALTER TABLE t1 ADD COLUMN f SET('1','2','3','4','5','6','7','8','9','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',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i') <CUSTOM_COL_OPTIONS> NULL;
+ERROR HY000: Too many strings for column f and SET
+SELECT a,b,c,e FROM t1 WHERE FIND_IN_SET('test2',b)>0 OR a != '';
+a b c e
+ test2,test3 01,23,34,44 NULL
+ test2,test4 NULL
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c SET('test1','test2','test3') <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c set('test1','test2','test3') YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+CREATE TABLE t1 (c SET('test1','test2','test3') <CUSTOM_COL_OPTIONS> NULL,
+c1 SET('test1','test2','test3') <CUSTOM_COL_OPTIONS> NULL DEFAULT NULL,
+c2 SET('test1','test2','test3') <CUSTOM_COL_OPTIONS> NULL DEFAULT 'test2,test3'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c set('test1','test2','test3') YES NULL
+c1 set('test1','test2','test3') YES NULL
+c2 set('test1','test2','test3') YES test2,test3
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c2), COUNT(c1), COUNT(c), COUNT(*) FROM t1;
+COUNT(c2) COUNT(c1) COUNT(c) COUNT(*)
+1 0 0 1
+DROP TABLE t1;
+#
+# TEXT columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (t TEXT <CUSTOM_COL_OPTIONS> NULL,
+t0 TEXT(0) <CUSTOM_COL_OPTIONS> NULL,
+t1 TEXT(1) <CUSTOM_COL_OPTIONS> NULL,
+t300 TEXT(300) <CUSTOM_COL_OPTIONS> NULL,
+tm TEXT(65535) <CUSTOM_COL_OPTIONS> NULL,
+t70k TEXT(70000) <CUSTOM_COL_OPTIONS> NULL,
+t17m TEXT(17000000) <CUSTOM_COL_OPTIONS> NULL,
+tt TINYTEXT <CUSTOM_COL_OPTIONS> NULL,
+m MEDIUMTEXT <CUSTOM_COL_OPTIONS> NULL,
+l LONGTEXT <CUSTOM_COL_OPTIONS> NULL
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+t text # # #
+t0 text # # #
+t1 tinytext # # #
+t300 text # # #
+tm text # # #
+t70k mediumtext # # #
+t17m longtext # # #
+tt tinytext # # #
+m mediumtext # # #
+l longtext # # #
+INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
+('','','','','','','','','',''),
+('a','b','c','d','e','f','g','h','i','j'),
+('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
+( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',255), REPEAT('i',1048576), REPEAT('j',1048576) );
+SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(t) LENGTH(t0) LENGTH(t1) LENGTH(t300) LENGTH(tm) LENGTH(t70k) LENGTH(t17m) LENGTH(tt) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
+( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
+Warnings:
+Warning 1265 Data truncated for column 't' at row 1
+Warning 1265 Data truncated for column 't0' at row 1
+Warning 1265 Data truncated for column 't1' at row 1
+Warning 1265 Data truncated for column 't300' at row 1
+Warning 1265 Data truncated for column 'tm' at row 1
+Warning 1265 Data truncated for column 'tt' at row 1
+SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(t) LENGTH(t0) LENGTH(t1) LENGTH(t300) LENGTH(tm) LENGTH(t70k) LENGTH(t17m) LENGTH(tt) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+ALTER TABLE t1 ADD COLUMN ttt TEXT(4294967296);
+ERROR 42000: Display width out of range for 'ttt' (max = 4294967295)
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c TEXT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c text YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c TINYTEXT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c tinytext YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c MEDIUMTEXT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c mediumtext YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c LONGTEXT <CUSTOM_COL_OPTIONS> NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c longtext YES NULL
+INSERT INTO t1 (c) VALUES (NULL);
+SELECT COUNT(c), COUNT(*) FROM t1;
+COUNT(c) COUNT(*)
+0 1
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/col_opt_null.test b/mysql-test/suite/storage_engine/col_opt_null.test
new file mode 100644
index 00000000..29979d29
--- /dev/null
+++ b/mysql-test/suite/storage_engine/col_opt_null.test
@@ -0,0 +1,208 @@
+#
+# NULL column attribute
+#
+
+let $extra_col_opts = NULL;
+
+--source have_engine.inc
+
+--echo #
+--echo # BINARY columns
+--echo #
+
+--source type_binary.inc
+--let $col_definition = BINARY $default_col_opts
+--let $col_default = 0
+--source col_null.inc
+
+--echo #
+--echo # VARBINARY columns
+--echo #
+
+--source type_varbinary.inc
+--let $col_definition = VARBINARY(64) $default_col_opts
+--let $col_default = 'test'
+--source col_null.inc
+
+--echo #
+--echo # BIT columns
+--echo #
+
+--source type_bit.inc
+--let $col_definition = BIT $default_col_opts
+--let $col_default = 1
+--source col_null.inc
+
+--echo #
+--echo # BLOB columns
+--echo #
+
+--source type_blob.inc
+
+--let $col_definition = BLOB $default_col_opts
+--source col_null.inc
+
+--let $col_definition = TINYBLOB $default_col_opts
+--source col_null.inc
+
+--let $col_definition = MEDIUMBLOB $default_col_opts
+--source col_null.inc
+
+--let $col_definition = LONGBLOB $default_col_opts
+--source col_null.inc
+
+--echo #
+--echo # BOOL columns
+--echo #
+
+--source type_bool.inc
+--let $col_definition = BOOL $default_col_opts
+--let $col_default = '0'
+--source col_null.inc
+
+
+--echo #
+--echo # CHAR columns
+--echo #
+
+--source type_char.inc
+--let $col_definition = CHAR $default_col_opts
+--let $col_default = '_'
+--source col_null.inc
+
+--echo #
+--echo # VARCHAR columns
+--echo #
+
+
+--source type_varchar.inc
+--let $col_definition = VARCHAR(64) $default_col_opts
+--let $col_default = 'test default'
+--source col_null.inc
+
+
+--echo #
+--echo # date and time columns
+--echo #
+
+--source type_date_time.inc
+
+--let $col_definition = DATE $default_col_opts
+--let $col_default = '2012-12-21'
+--source col_null.inc
+
+--let $col_definition = DATETIME $default_col_opts
+--let $col_default = '2012-12-21 12:21:12'
+--source col_null.inc
+
+--let $col_definition = TIMESTAMP $default_col_opts
+--let $col_default = '2012-12-21 12:21:12'
+--source col_null.inc
+
+--let $col_definition = TIME $default_col_opts
+--let $col_default = '12:21:12'
+--source col_null.inc
+
+--let $col_definition = YEAR $default_col_opts
+--let $col_default = '2012'
+--source col_null.inc
+
+--let $col_definition = YEAR(2) $default_col_opts
+--let $col_default = '12'
+--source col_null.inc
+
+
+--echo #
+--echo # ENUM columns
+--echo #
+
+--source type_enum.inc
+--let $col_definition = ENUM('test1','test2','test3') $default_col_opts
+--let $col_default = 'test2'
+--source col_null.inc
+
+--echo #
+--echo # Fixed point columns (NUMERIC, DECIMAL)
+--echo #
+
+--source type_fixed.inc
+
+--let $col_definition = DECIMAL $default_col_opts
+--let $col_default = 1.1
+--source col_null.inc
+
+--let $col_definition = NUMERIC $default_col_opts
+--let $col_default = 0
+--source col_null.inc
+
+--echo #
+--echo # Floating point columns (FLOAT, DOUBLE)
+--echo #
+
+--source type_float.inc
+
+--let $col_definition = FLOAT $default_col_opts
+--let $col_default = 1.1
+--source col_null.inc
+
+--let $col_definition = DOUBLE $default_col_opts
+--let $col_default = 0
+--source col_null.inc
+
+--echo #
+--echo # INT columns
+--echo #
+
+--source type_int.inc
+
+--let $col_definition = INT $default_col_opts
+--let $col_default = 2147483647
+--source col_null.inc
+
+--let $col_definition = TINYINT $default_col_opts
+--let $col_default = 127
+--source col_null.inc
+
+--let $col_definition = SMALLINT $default_col_opts
+--let $col_default = 0
+--source col_null.inc
+
+--let $col_definition = MEDIUMINT $default_col_opts
+--let $col_default = 1
+--source col_null.inc
+
+--let $col_definition = BIGINT $default_col_opts
+--let $col_default = 9223372036854775807
+--source col_null.inc
+
+--echo #
+--echo # SET columns
+--echo #
+
+--source type_set.inc
+--let $col_definition = SET('test1','test2','test3') $default_col_opts
+--let $col_default = 'test2,test3'
+--source col_null.inc
+
+
+--echo #
+--echo # TEXT columns
+--echo #
+
+--source type_text.inc
+
+--let $col_definition = TEXT $default_col_opts
+--source col_null.inc
+
+--let $col_definition = TINYTEXT $default_col_opts
+--source col_null.inc
+
+--let $col_definition = MEDIUMTEXT $default_col_opts
+--source col_null.inc
+
+--let $col_definition = LONGTEXT $default_col_opts
+--source col_null.inc
+
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/col_opt_unsigned.result b/mysql-test/suite/storage_engine/col_opt_unsigned.result
new file mode 100644
index 00000000..b53780c7
--- /dev/null
+++ b/mysql-test/suite/storage_engine/col_opt_unsigned.result
@@ -0,0 +1,705 @@
+#
+# Fixed point columns (NUMERIC, DECIMAL)
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (d DECIMAL UNSIGNED <CUSTOM_COL_OPTIONS>,
+d0 DECIMAL(0) UNSIGNED <CUSTOM_COL_OPTIONS>,
+d1_1 DECIMAL(1,1) UNSIGNED <CUSTOM_COL_OPTIONS>,
+d10_2 DECIMAL(10,2) UNSIGNED <CUSTOM_COL_OPTIONS>,
+d60_10 DECIMAL(60,10) UNSIGNED <CUSTOM_COL_OPTIONS>,
+n NUMERIC UNSIGNED <CUSTOM_COL_OPTIONS>,
+n0_0 NUMERIC(0,0) UNSIGNED <CUSTOM_COL_OPTIONS>,
+n1 NUMERIC(1) UNSIGNED <CUSTOM_COL_OPTIONS>,
+n20_4 NUMERIC(20,4) UNSIGNED <CUSTOM_COL_OPTIONS>,
+n65_4 NUMERIC(65,4) UNSIGNED <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+d decimal(10,0) unsigned # # #
+d0 decimal(10,0) unsigned # # #
+d1_1 decimal(1,1) unsigned # # #
+d10_2 decimal(10,2) unsigned # # #
+d60_10 decimal(60,10) unsigned # # #
+n decimal(10,0) unsigned # # #
+n0_0 decimal(10,0) unsigned # # #
+n1 decimal(1,0) unsigned # # #
+n20_4 decimal(20,4) unsigned # # #
+n65_4 decimal(65,4) unsigned # # #
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (100,123456,0.3,40000.25,123456789123456789.10001,1024,7000.0,8.0,999999.9,9223372036854775807);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (9999999999.0,9999999999.0,0.9,99999999.99,99999999999999999999999999999999999999999999999999.9999999999,9999999999.0,9999999999.0,9.0,9999999999999999.9999,9999999999999999999999999999999999999999999999999999999999999.9999);
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (-100,-123456,-0.3,-40000.25,-123456789123456789.10001,-1024,-7000.0,-8.0,-999999.9,-9223372036854775807);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (-9999999999.0,-9999999999.0,-0.9,-99999999.99,-99999999999999999999999999999999999999999999999999.9999999999,-9999999999.0,-9999999999.0,-9.0,-9999999999999999.9999,-9999999999999999999999999999999999999999999999999999999999999.9999);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1 WHERE n20_4 = 9999999999999999.9999 OR d < 100;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) SELECT n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4 FROM t1 WHERE n65_4 = ( SELECT MAX(n65_4) FROM t1 );
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (10000000000.0,10000000000.0,1.1,100000000.99,100000000000000000000000000000000000000000000000000.0,10000000000.0,10000000000.0,10.0,10000000000000000.9999,10000000000000000000000000000000000000000000000000000000000000.9999);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (9999999999.1,9999999999.1,1.9,99999999.001,99999999999999999999999999999999999999999999999999.99999999991,9999999999.1,9999999999.1,9.1,9999999999999999.00001,9999999999999999999999999999999999999999999999999999999999999.11111);
+Warnings:
+Note 1265 Data truncated for column 'd' at row 1
+Note 1265 Data truncated for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Note 1265 Data truncated for column 'd10_2' at row 1
+Note 1265 Data truncated for column 'd60_10' at row 1
+Note 1265 Data truncated for column 'n' at row 1
+Note 1265 Data truncated for column 'n0_0' at row 1
+Note 1265 Data truncated for column 'n1' at row 1
+Note 1265 Data truncated for column 'n20_4' at row 1
+Note 1265 Data truncated for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.00 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.0000 9999999999999999999999999999999999999999999999999999999999999.1111
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66);
+ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65.
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6);
+ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65.
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66);
+ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 30.
+DROP TABLE t1;
+CREATE TABLE t1 (a DECIMAL UNSIGNED <CUSTOM_COL_OPTIONS>,
+b NUMERIC UNSIGNED <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a decimal(10,0) unsigned # # # #
+b decimal(10,0) unsigned # # # #
+INSERT INTO t1 (a,b) VALUES (1.0,-1.0);
+Warnings:
+Warning 1264 Out of range value for column 'b' at row 1
+INSERT INTO t1 (a,b) VALUES (-100,100);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+SELECT a,b FROM t1;
+a b
+0 100
+1 0
+DROP TABLE t1;
+#
+# Floating point columns (FLOAT, DOUBLE)
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (f FLOAT UNSIGNED <CUSTOM_COL_OPTIONS>,
+f0 FLOAT(0) UNSIGNED <CUSTOM_COL_OPTIONS>,
+r1_1 REAL(1,1) UNSIGNED <CUSTOM_COL_OPTIONS>,
+f23_0 FLOAT(23) UNSIGNED <CUSTOM_COL_OPTIONS>,
+f20_3 FLOAT(20,3) UNSIGNED <CUSTOM_COL_OPTIONS>,
+d DOUBLE UNSIGNED <CUSTOM_COL_OPTIONS>,
+d1_0 DOUBLE(1,0) UNSIGNED <CUSTOM_COL_OPTIONS>,
+d10_10 DOUBLE PRECISION (10,10) UNSIGNED <CUSTOM_COL_OPTIONS>,
+d53 DOUBLE(53,0) UNSIGNED <CUSTOM_COL_OPTIONS>,
+d53_10 DOUBLE(53,10) UNSIGNED <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+f float unsigned # # #
+f0 float unsigned # # #
+r1_1 double(1,1) unsigned # # #
+f23_0 float unsigned # # #
+f20_3 float(20,3) unsigned # # #
+d double unsigned # # #
+d1_0 double(1,0) unsigned # # #
+d10_10 double(10,10) unsigned # # #
+d53 double(53,0) unsigned # # #
+d53_10 double(53,10) unsigned # # #
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (12345.12345,12345.12345,0.9,123456789.123,56789.987,11111111.111,8.0,0.0123456789,1234566789123456789,99999999999999999.99999999);
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 11111111.111
+d10_10 0.0123456789
+d1_0 8
+d53 1234566789123456800
+d53_10 100000000000000000.0000000000
+f0 12345.1
+f20_3 56789.988
+f23_0 123457000
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (
+99999999999999999999999999999999999999,
+99999999999999999999999999999999999999.9999999999999999,
+0.9,
+99999999999999999999999999999999999999.9,
+99999999999999999.999,
+999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+9,
+0.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999
+);
+Warnings:
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 0
+d 11111111.111
+d 1e81
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 0
+d1_0 8
+d1_0 9
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 0
+f 1e38
+f0 0
+f0 12345.1
+f0 1e38
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (-999999999999999999999999,-99999999999.999999999999,-0.9,-999.99999999999999999999,-99999999999999999.999,-999999999999999999999999999999999999999999999999999999999999-0.999,-9,-.9999999999,-999999999999999999999999999999.99999999999999999999999,-9999999999999999999999999999999999999999999.9999999999);
+Warnings:
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 0
+d 0
+d 11111111.111
+d 1e81
+d10_10 0.0000000000
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 0
+d1_0 0
+d1_0 8
+d1_0 9
+d53 0
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 0.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 0
+f 0
+f 1e38
+f0 0
+f0 0
+f0 12345.1
+f0 1e38
+f20_3 0.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f23_0 0
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+r1_1 0.0
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+SELECT MAX(f), MAX(f0), MAX(r1_1), MAX(f23_0), MAX(f20_3), MAX(d), MAX(d1_0), MAX(d10_10), MAX(d53), MAX(d53_10) FROM t1;
+MAX(f) 9.999999680285692e37
+MAX(d) 1e81
+MAX(d10_10) 0.9999999999
+MAX(d1_0) 9
+MAX(d53) 100000000000000000000000000000000000000000000000000000
+MAX(d53_10) 10000000000000000000000000000000000000000000.0000000000
+MAX(f0) 9.999999680285692e37
+MAX(f20_3) 99999998430674940.000
+MAX(f23_0) 9.999999680285692e37
+MAX(r1_1) 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) SELECT d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10 FROM t1 ORDER BY d53_10 DESC LIMIT 1;
+Warnings:
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 0
+d 0
+d 11111111.111
+d 1e43
+d 1e81
+d10_10 0.0000000000
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 10000000000000000000000000000000000000000000.0000000000
+d1_0 0
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d53 0
+d53 0
+d53 10000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 0.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 0
+f 0
+f 1e38
+f 3.40282e38
+f0 0
+f0 0
+f0 12345.1
+f0 1e38
+f0 3.40282e38
+f20_3 0.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 0
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+f23_0 3.40282e38
+r1_1 0.0
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (
+999999999999999999999999999999999999999,
+999999999999999999999999999999999999999.9999999999999999,
+1.9,
+999999999999999999999999999999999999999.9,
+999999999999999999.999,
+9999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+99,
+1.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999
+);
+Warnings:
+Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 0
+d 0
+d 11111111.111
+d 1e43
+d 1e65
+d 1e81
+d10_10 0.0000000000
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 0.9999999999
+d10_10 10000000000000000000000000000000000000000000.0000000000
+d1_0 0
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d1_0 9
+d53 0
+d53 0
+d53 10000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 0.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 0
+f 0
+f 1e38
+f 3.40282e38
+f 3.40282e38
+f0 0
+f0 0
+f0 12345.1
+f0 1e38
+f0 3.40282e38
+f0 3.40282e38
+f20_3 0.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 0
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+f23_0 3.40282e38
+f23_0 3.40282e38
+r1_1 0.0
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0);
+# ERROR: Statement succeeded (expected results: ER_TOO_BIG_DISPLAYWIDTH)
+# ------------ UNEXPECTED RESULT ------------
+# [ ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) ]
+# The statement|command succeeded unexpectedly.
+# ALTER TABLE or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors.
+# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def.
+# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped.
+# Also, this problem may cause a chain effect (more errors of different kinds in the test).
+# -------------------------------------------
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1);
+ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65.
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35);
+ERROR 42000: Too big scale 35 specified for 'n66_66'. Maximum is 30.
+DROP TABLE t1;
+CREATE TABLE t1 (a DOUBLE UNSIGNED <CUSTOM_COL_OPTIONS>,
+b FLOAT UNSIGNED <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a double unsigned # # # #
+b float unsigned # # # #
+INSERT INTO t1 (a,b) VALUES (1.0,-1.0);
+Warnings:
+Warning 1264 Out of range value for column 'b' at row 1
+INSERT INTO t1 (a,b) VALUES (-100,100);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+SELECT a,b FROM t1;
+a b
+0 100
+1 0
+DROP TABLE t1;
+#
+# INT columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (i INT UNSIGNED <CUSTOM_COL_OPTIONS>,
+i0 INT(0) UNSIGNED <CUSTOM_COL_OPTIONS>,
+i1 INT(1) UNSIGNED <CUSTOM_COL_OPTIONS>,
+i20 INT(20) UNSIGNED <CUSTOM_COL_OPTIONS>,
+t TINYINT UNSIGNED <CUSTOM_COL_OPTIONS>,
+t0 TINYINT(0) UNSIGNED <CUSTOM_COL_OPTIONS>,
+t1 TINYINT(1) UNSIGNED <CUSTOM_COL_OPTIONS>,
+t20 TINYINT(20) UNSIGNED <CUSTOM_COL_OPTIONS>,
+s SMALLINT UNSIGNED <CUSTOM_COL_OPTIONS>,
+s0 SMALLINT(0) UNSIGNED <CUSTOM_COL_OPTIONS>,
+s1 SMALLINT(1) UNSIGNED <CUSTOM_COL_OPTIONS>,
+s20 SMALLINT(20) UNSIGNED <CUSTOM_COL_OPTIONS>,
+m MEDIUMINT UNSIGNED <CUSTOM_COL_OPTIONS>,
+m0 MEDIUMINT(0) UNSIGNED <CUSTOM_COL_OPTIONS>,
+m1 MEDIUMINT(1) UNSIGNED <CUSTOM_COL_OPTIONS>,
+m20 MEDIUMINT(20) UNSIGNED <CUSTOM_COL_OPTIONS>,
+b BIGINT UNSIGNED <CUSTOM_COL_OPTIONS>,
+b0 BIGINT(0) UNSIGNED <CUSTOM_COL_OPTIONS>,
+b1 BIGINT(1) UNSIGNED <CUSTOM_COL_OPTIONS>,
+b20 BIGINT(20) UNSIGNED <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+i int(10) unsigned # # #
+i0 int(10) unsigned # # #
+i1 int(1) unsigned # # #
+i20 int(20) unsigned # # #
+t tinyint(3) unsigned # # #
+t0 tinyint(3) unsigned # # #
+t1 tinyint(1) unsigned # # #
+t20 tinyint(20) unsigned # # #
+s smallint(5) unsigned # # #
+s0 smallint(5) unsigned # # #
+s1 smallint(1) unsigned # # #
+s20 smallint(20) unsigned # # #
+m mediumint(8) unsigned # # #
+m0 mediumint(8) unsigned # # #
+m1 mediumint(1) unsigned # # #
+m20 mediumint(20) unsigned # # #
+b bigint(20) unsigned # # #
+b0 bigint(20) unsigned # # #
+b1 bigint(1) unsigned # # #
+b20 bigint(20) unsigned # # #
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (2147483647,2147483647,2147483647,2147483647,127,127,127,127,32767,32767,32767,32767,8388607,8388607,8388607,8388607,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807);
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483648,-2147483648,-2147483648,-2147483648,-128,-128,-128,-128,-32768,-32768,-32768,-32768,-8388608,-8388608,-8388608,-8388608,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967295,4294967295,4294967295,4294967295,255,255,255,255,65535,65535,65535,65535,16777215,16777215,16777215,16777215,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615);
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483649,-2147483649,-2147483649,-2147483649,-129,-129,-129,-129,-32769,-32769,-32769,-32769,-8388609,-8388609,-8388609,-8388609,-9223372036854775809,-9223372036854775809,-9223372036854775809,-9223372036854775809);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967296,4294967296,4294967296,4294967296,256,256,256,256,65536,65536,65536,65536,16777216,16777216,16777216,16777216,18446744073709551616,18446744073709551616,18446744073709551616,18446744073709551616);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) SELECT b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b FROM t1 WHERE b IN (-9223372036854775808,9223372036854775807,18446744073709551615);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'i' at row 2
+Warning 1264 Out of range value for column 'i0' at row 2
+Warning 1264 Out of range value for column 'i1' at row 2
+Warning 1264 Out of range value for column 'i20' at row 2
+Warning 1264 Out of range value for column 't' at row 2
+Warning 1264 Out of range value for column 't0' at row 2
+Warning 1264 Out of range value for column 't1' at row 2
+Warning 1264 Out of range value for column 't20' at row 2
+Warning 1264 Out of range value for column 's' at row 2
+Warning 1264 Out of range value for column 's0' at row 2
+Warning 1264 Out of range value for column 's1' at row 2
+Warning 1264 Out of range value for column 's20' at row 2
+Warning 1264 Out of range value for column 'm' at row 2
+Warning 1264 Out of range value for column 'm0' at row 2
+Warning 1264 Out of range value for column 'm1' at row 2
+Warning 1264 Out of range value for column 'm20' at row 2
+Warning 1264 Out of range value for column 'i' at row 3
+Warning 1264 Out of range value for column 'i0' at row 3
+Warning 1264 Out of range value for column 'i1' at row 3
+Warning 1264 Out of range value for column 'i20' at row 3
+Warning 1264 Out of range value for column 't' at row 3
+Warning 1264 Out of range value for column 't0' at row 3
+Warning 1264 Out of range value for column 't1' at row 3
+Warning 1264 Out of range value for column 't20' at row 3
+Warning 1264 Out of range value for column 's' at row 3
+Warning 1264 Out of range value for column 's0' at row 3
+Warning 1264 Out of range value for column 's1' at row 3
+Warning 1264 Out of range value for column 's20' at row 3
+Warning 1264 Out of range value for column 'm' at row 3
+Warning 1264 Out of range value for column 'm0' at row 3
+Warning 1264 Out of range value for column 'm1' at row 3
+Warning 1264 Out of range value for column 'm20' at row 3
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+4294967295 4294967295 4294967295 4294967295 255 255 255 255 65535 65535 65535 65535 16777215 16777215 16777215 16777215 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+ALTER TABLE t1 ADD COLUMN i257 INT(257);
+ERROR 42000: Display width out of range for 'i257' (max = 255)
+DROP TABLE t1;
+CREATE TABLE t1 (t TINYINT UNSIGNED <CUSTOM_COL_OPTIONS>,
+s SMALLINT UNSIGNED <CUSTOM_COL_OPTIONS>,
+m MEDIUMINT UNSIGNED <CUSTOM_COL_OPTIONS>,
+i INT UNSIGNED <CUSTOM_COL_OPTIONS>,
+b BIGINT UNSIGNED <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+t tinyint(3) unsigned # # # #
+s smallint(5) unsigned # # # #
+m mediumint(8) unsigned # # # #
+i int(10) unsigned # # # #
+b bigint(20) unsigned # # # #
+INSERT INTO t1 (t,s,m,i,b) VALUES (255,65535,16777215,4294967295,18446744073709551615);
+INSERT INTO t1 (t,s,m,i,b) VALUES (-1,-1,-1,-1,-1);
+Warnings:
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+SELECT t,s,m,i,b FROM t1;
+t s m i b
+0 0 0 0 0
+255 65535 16777215 4294967295 18446744073709551615
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/col_opt_unsigned.test b/mysql-test/suite/storage_engine/col_opt_unsigned.test
new file mode 100644
index 00000000..62b7b29a
--- /dev/null
+++ b/mysql-test/suite/storage_engine/col_opt_unsigned.test
@@ -0,0 +1,95 @@
+#
+# UNSIGNED column attribute
+#
+
+let $extra_type_opts = UNSIGNED;
+
+--source have_engine.inc
+
+--echo #
+--echo # Fixed point columns (NUMERIC, DECIMAL)
+--echo #
+
+--source type_fixed.inc
+let $create_definition =
+ a DECIMAL $col_opts,
+ b NUMERIC $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = Fixed point types or UNSIGNED columns
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 # 6 #
+ SHOW COLUMNS IN t1;
+
+ INSERT INTO t1 (a,b) VALUES (1.0,-1.0);
+ INSERT INTO t1 (a,b) VALUES (-100,100);
+ --sorted_result
+ SELECT a,b FROM t1;
+ DROP TABLE t1;
+}
+
+--echo #
+--echo # Floating point columns (FLOAT, DOUBLE)
+--echo #
+
+--source type_float.inc
+let $create_definition =
+ a DOUBLE $col_opts,
+ b FLOAT $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = Floating point types or UNSIGNED columns
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 # 6 #
+ SHOW COLUMNS IN t1;
+
+ INSERT INTO t1 (a,b) VALUES (1.0,-1.0);
+ INSERT INTO t1 (a,b) VALUES (-100,100);
+ --sorted_result
+ SELECT a,b FROM t1;
+ DROP TABLE t1;
+}
+
+--echo #
+--echo # INT columns
+--echo #
+
+--source type_int.inc
+let $create_definition =
+ t TINYINT $col_opts,
+ s SMALLINT $col_opts,
+ m MEDIUMINT $col_opts,
+ i INT $col_opts,
+ b BIGINT $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = INT types or UNSIGNED columns
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 # 6 #
+ SHOW COLUMNS IN t1;
+
+ INSERT INTO t1 (t,s,m,i,b) VALUES (255,65535,16777215,4294967295,18446744073709551615);
+ INSERT INTO t1 (t,s,m,i,b) VALUES (-1,-1,-1,-1,-1);
+ --sorted_result
+ SELECT t,s,m,i,b FROM t1;
+ DROP TABLE t1;
+
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/col_opt_zerofill.result b/mysql-test/suite/storage_engine/col_opt_zerofill.result
new file mode 100644
index 00000000..acc97a51
--- /dev/null
+++ b/mysql-test/suite/storage_engine/col_opt_zerofill.result
@@ -0,0 +1,687 @@
+#
+# Fixed point columns (NUMERIC, DECIMAL)
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (d DECIMAL ZEROFILL <CUSTOM_COL_OPTIONS>,
+d0 DECIMAL(0) ZEROFILL <CUSTOM_COL_OPTIONS>,
+d1_1 DECIMAL(1,1) ZEROFILL <CUSTOM_COL_OPTIONS>,
+d10_2 DECIMAL(10,2) ZEROFILL <CUSTOM_COL_OPTIONS>,
+d60_10 DECIMAL(60,10) ZEROFILL <CUSTOM_COL_OPTIONS>,
+n NUMERIC ZEROFILL <CUSTOM_COL_OPTIONS>,
+n0_0 NUMERIC(0,0) ZEROFILL <CUSTOM_COL_OPTIONS>,
+n1 NUMERIC(1) ZEROFILL <CUSTOM_COL_OPTIONS>,
+n20_4 NUMERIC(20,4) ZEROFILL <CUSTOM_COL_OPTIONS>,
+n65_4 NUMERIC(65,4) ZEROFILL <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+d decimal(10,0) unsigned zerofill # # #
+d0 decimal(10,0) unsigned zerofill # # #
+d1_1 decimal(1,1) unsigned zerofill # # #
+d10_2 decimal(10,2) unsigned zerofill # # #
+d60_10 decimal(60,10) unsigned zerofill # # #
+n decimal(10,0) unsigned zerofill # # #
+n0_0 decimal(10,0) unsigned zerofill # # #
+n1 decimal(1,0) unsigned zerofill # # #
+n20_4 decimal(20,4) unsigned zerofill # # #
+n65_4 decimal(65,4) unsigned zerofill # # #
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (100,123456,0.3,40000.25,123456789123456789.10001,1024,7000.0,8.0,999999.9,9223372036854775807);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (9999999999.0,9999999999.0,0.9,99999999.99,99999999999999999999999999999999999999999999999999.9999999999,9999999999.0,9999999999.0,9.0,9999999999999999.9999,9999999999999999999999999999999999999999999999999999999999999.9999);
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000100 0000123456 0.3 00040000.25 00000000000000000000000000000000123456789123456789.1000100000 0000001024 0000007000 8 0000000000999999.9000 0000000000000000000000000000000000000000009223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (-100,-123456,-0.3,-40000.25,-123456789123456789.10001,-1024,-7000.0,-8.0,-999999.9,-9223372036854775807);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (-9999999999.0,-9999999999.0,-0.9,-99999999.99,-99999999999999999999999999999999999999999999999999.9999999999,-9999999999.0,-9999999999.0,-9.0,-9999999999999999.9999,-9999999999999999999999999999999999999999999999999999999999999.9999);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000100 0000123456 0.3 00040000.25 00000000000000000000000000000000123456789123456789.1000100000 0000001024 0000007000 8 0000000000999999.9000 0000000000000000000000000000000000000000009223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1 WHERE n20_4 = 9999999999999999.9999 OR d < 100;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) SELECT n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4 FROM t1 WHERE n65_4 = ( SELECT MAX(n65_4) FROM t1 );
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000100 0000123456 0.3 00040000.25 00000000000000000000000000000000123456789123456789.1000100000 0000001024 0000007000 8 0000000000999999.9000 0000000000000000000000000000000000000000009223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (10000000000.0,10000000000.0,1.1,100000000.99,100000000000000000000000000000000000000000000000000.0,10000000000.0,10000000000.0,10.0,10000000000000000.9999,10000000000000000000000000000000000000000000000000000000000000.9999);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000100 0000123456 0.3 00040000.25 00000000000000000000000000000000123456789123456789.1000100000 0000001024 0000007000 8 0000000000999999.9000 0000000000000000000000000000000000000000009223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (9999999999.1,9999999999.1,1.9,99999999.001,99999999999999999999999999999999999999999999999999.99999999991,9999999999.1,9999999999.1,9.1,9999999999999999.00001,9999999999999999999999999999999999999999999999999999999999999.11111);
+Warnings:
+Note 1265 Data truncated for column 'd' at row 1
+Note 1265 Data truncated for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Note 1265 Data truncated for column 'd10_2' at row 1
+Note 1265 Data truncated for column 'd60_10' at row 1
+Note 1265 Data truncated for column 'n' at row 1
+Note 1265 Data truncated for column 'n0_0' at row 1
+Note 1265 Data truncated for column 'n1' at row 1
+Note 1265 Data truncated for column 'n20_4' at row 1
+Note 1265 Data truncated for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000000 0000000000 0.0 00000000.00 00000000000000000000000000000000000000000000000000.0000000000 0000000000 0000000000 0 0000000000000000.0000 0000000000000000000000000000000000000000000000000000000000000.0000
+0000000100 0000123456 0.3 00040000.25 00000000000000000000000000000000123456789123456789.1000100000 0000001024 0000007000 8 0000000000999999.9000 0000000000000000000000000000000000000000009223372036854775807.0000
+9999999999 9999999999 0.9 99999999.00 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.0000 9999999999999999999999999999999999999999999999999999999999999.1111
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66);
+ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65.
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6);
+ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65.
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66);
+ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 30.
+DROP TABLE t1;
+CREATE TABLE t1 (a DECIMAL ZEROFILL <CUSTOM_COL_OPTIONS>,
+b NUMERIC ZEROFILL <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a decimal(10,0) unsigned zerofill # # # #
+b decimal(10,0) unsigned zerofill # # # #
+INSERT INTO t1 (a,b) VALUES (1.1,1234);
+Warnings:
+Note 1265 Data truncated for column 'a' at row 1
+SELECT a,b FROM t1;
+a b
+0000000001 0000001234
+DROP TABLE t1;
+#
+# Floating point columns (FLOAT, DOUBLE)
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (f FLOAT ZEROFILL <CUSTOM_COL_OPTIONS>,
+f0 FLOAT(0) ZEROFILL <CUSTOM_COL_OPTIONS>,
+r1_1 REAL(1,1) ZEROFILL <CUSTOM_COL_OPTIONS>,
+f23_0 FLOAT(23) ZEROFILL <CUSTOM_COL_OPTIONS>,
+f20_3 FLOAT(20,3) ZEROFILL <CUSTOM_COL_OPTIONS>,
+d DOUBLE ZEROFILL <CUSTOM_COL_OPTIONS>,
+d1_0 DOUBLE(1,0) ZEROFILL <CUSTOM_COL_OPTIONS>,
+d10_10 DOUBLE PRECISION (10,10) ZEROFILL <CUSTOM_COL_OPTIONS>,
+d53 DOUBLE(53,0) ZEROFILL <CUSTOM_COL_OPTIONS>,
+d53_10 DOUBLE(53,10) ZEROFILL <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+f float unsigned zerofill # # #
+f0 float unsigned zerofill # # #
+r1_1 double(1,1) unsigned zerofill # # #
+f23_0 float unsigned zerofill # # #
+f20_3 float(20,3) unsigned zerofill # # #
+d double unsigned zerofill # # #
+d1_0 double(1,0) unsigned zerofill # # #
+d10_10 double(10,10) unsigned zerofill # # #
+d53 double(53,0) unsigned zerofill # # #
+d53_10 double(53,10) unsigned zerofill # # #
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (12345.12345,12345.12345,0.9,123456789.123,56789.987,11111111.111,8.0,0.0123456789,1234566789123456789,99999999999999999.99999999);
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 0000012345.1
+d 000000000011111111.111
+d10_10 0.0123456789
+d1_0 8
+d53 00000000000000000000000000000000001234566789123456800
+d53_10 000000000000000000000000100000000000000000.0000000000
+f0 0000012345.1
+f20_3 0000000000056789.988
+f23_0 000123457000
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (
+99999999999999999999999999999999999999,
+99999999999999999999999999999999999999.9999999999999999,
+0.9,
+99999999999999999999999999999999999999.9,
+99999999999999999.999,
+999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+9,
+0.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999
+);
+Warnings:
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 0000012345.1
+d 0000000000000000000000
+d 0000000000000000001e81
+d 000000000011111111.111
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 0
+d1_0 8
+d1_0 9
+d53 00000000000000000000000000000000000000000000000000000
+d53 00000000000000000000000000000000001234566789123456800
+d53 100000000000000000000000000000000000000000000000000000
+d53_10 000000000000000000000000000000000000000000.0000000000
+d53_10 000000000000000000000000100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 000000000000
+f 000000001e38
+f0 000000000000
+f0 000000001e38
+f0 0000012345.1
+f20_3 0000000000000000.000
+f20_3 0000000000056789.988
+f20_3 99999998430674940.000
+f23_0 000000000000
+f23_0 000000001e38
+f23_0 000123457000
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (-999999999999999999999999,-99999999999.999999999999,-0.9,-999.99999999999999999999,-99999999999999999.999,-999999999999999999999999999999999999999999999999999999999999-0.999,-9,-.9999999999,-999999999999999999999999999999.99999999999999999999999,-9999999999999999999999999999999999999999999.9999999999);
+Warnings:
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 0000012345.1
+d 0000000000000000000000
+d 0000000000000000000000
+d 0000000000000000001e81
+d 000000000011111111.111
+d10_10 0.0000000000
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 0
+d1_0 0
+d1_0 8
+d1_0 9
+d53 00000000000000000000000000000000000000000000000000000
+d53 00000000000000000000000000000000000000000000000000000
+d53 00000000000000000000000000000000001234566789123456800
+d53 100000000000000000000000000000000000000000000000000000
+d53_10 000000000000000000000000000000000000000000.0000000000
+d53_10 000000000000000000000000000000000000000000.0000000000
+d53_10 000000000000000000000000100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 000000000000
+f 000000000000
+f 000000001e38
+f0 000000000000
+f0 000000000000
+f0 000000001e38
+f0 0000012345.1
+f20_3 0000000000000000.000
+f20_3 0000000000000000.000
+f20_3 0000000000056789.988
+f20_3 99999998430674940.000
+f23_0 000000000000
+f23_0 000000000000
+f23_0 000000001e38
+f23_0 000123457000
+r1_1 0.0
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+SELECT MAX(f), MAX(f0), MAX(r1_1), MAX(f23_0), MAX(f20_3), MAX(d), MAX(d1_0), MAX(d10_10), MAX(d53), MAX(d53_10) FROM t1;
+MAX(f) 9.999999680285692e37
+MAX(d) 1e81
+MAX(d10_10) 0.9999999999
+MAX(d1_0) 9
+MAX(d53) 100000000000000000000000000000000000000000000000000000
+MAX(d53_10) 10000000000000000000000000000000000000000000.0000000000
+MAX(f0) 9.999999680285692e37
+MAX(f20_3) 99999998430674940.000
+MAX(f23_0) 9.999999680285692e37
+MAX(r1_1) 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) SELECT d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10 FROM t1 ORDER BY d53_10 DESC LIMIT 1;
+Warnings:
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 0000012345.1
+d 0000000000000000000000
+d 0000000000000000000000
+d 0000000000000000001e43
+d 0000000000000000001e81
+d 000000000011111111.111
+d10_10 0.0000000000
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 10000000000000000000000000000000000000000000.0000000000
+d1_0 0
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d53 00000000000000000000000000000000000000000000000000000
+d53 00000000000000000000000000000000000000000000000000000
+d53 00000000000000000000000000000000001234566789123456800
+d53 00000000010000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53_10 000000000000000000000000000000000000000000.0000000000
+d53_10 000000000000000000000000000000000000000000.0000000000
+d53_10 000000000000000000000000100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 000000000000
+f 000000000000
+f 000000001e38
+f 003.40282e38
+f0 000000000000
+f0 000000000000
+f0 000000001e38
+f0 0000012345.1
+f0 003.40282e38
+f20_3 0000000000000000.000
+f20_3 0000000000000000.000
+f20_3 0000000000056789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 000000000000
+f23_0 000000000000
+f23_0 000000001e38
+f23_0 000123457000
+f23_0 003.40282e38
+r1_1 0.0
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (
+999999999999999999999999999999999999999,
+999999999999999999999999999999999999999.9999999999999999,
+1.9,
+999999999999999999999999999999999999999.9,
+999999999999999999.999,
+9999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+99,
+1.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999
+);
+Warnings:
+Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 0000012345.1
+d 0000000000000000000000
+d 0000000000000000000000
+d 0000000000000000001e43
+d 0000000000000000001e65
+d 0000000000000000001e81
+d 000000000011111111.111
+d10_10 0.0000000000
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 0.9999999999
+d10_10 10000000000000000000000000000000000000000000.0000000000
+d1_0 0
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d1_0 9
+d53 00000000000000000000000000000000000000000000000000000
+d53 00000000000000000000000000000000000000000000000000000
+d53 00000000000000000000000000000000001234566789123456800
+d53 00000000010000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53_10 000000000000000000000000000000000000000000.0000000000
+d53_10 000000000000000000000000000000000000000000.0000000000
+d53_10 000000000000000000000000100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 000000000000
+f 000000000000
+f 000000001e38
+f 003.40282e38
+f 003.40282e38
+f0 000000000000
+f0 000000000000
+f0 000000001e38
+f0 0000012345.1
+f0 003.40282e38
+f0 003.40282e38
+f20_3 0000000000000000.000
+f20_3 0000000000000000.000
+f20_3 0000000000056789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 000000000000
+f23_0 000000000000
+f23_0 000000001e38
+f23_0 000123457000
+f23_0 003.40282e38
+f23_0 003.40282e38
+r1_1 0.0
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0);
+# ERROR: Statement succeeded (expected results: ER_TOO_BIG_DISPLAYWIDTH)
+# ------------ UNEXPECTED RESULT ------------
+# [ ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) ]
+# The statement|command succeeded unexpectedly.
+# ALTER TABLE or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors.
+# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def.
+# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped.
+# Also, this problem may cause a chain effect (more errors of different kinds in the test).
+# -------------------------------------------
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1);
+ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65.
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35);
+ERROR 42000: Too big scale 35 specified for 'n66_66'. Maximum is 30.
+DROP TABLE t1;
+CREATE TABLE t1 (a DOUBLE ZEROFILL <CUSTOM_COL_OPTIONS>,
+b FLOAT ZEROFILL <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a double unsigned zerofill # # # #
+b float unsigned zerofill # # # #
+INSERT INTO t1 (a,b) VALUES (1,1234.5);
+SELECT a,b FROM t1;
+a b
+0000000000000000000001 0000001234.5
+DROP TABLE t1;
+#
+# INT columns
+#
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (i INT ZEROFILL <CUSTOM_COL_OPTIONS>,
+i0 INT(0) ZEROFILL <CUSTOM_COL_OPTIONS>,
+i1 INT(1) ZEROFILL <CUSTOM_COL_OPTIONS>,
+i20 INT(20) ZEROFILL <CUSTOM_COL_OPTIONS>,
+t TINYINT ZEROFILL <CUSTOM_COL_OPTIONS>,
+t0 TINYINT(0) ZEROFILL <CUSTOM_COL_OPTIONS>,
+t1 TINYINT(1) ZEROFILL <CUSTOM_COL_OPTIONS>,
+t20 TINYINT(20) ZEROFILL <CUSTOM_COL_OPTIONS>,
+s SMALLINT ZEROFILL <CUSTOM_COL_OPTIONS>,
+s0 SMALLINT(0) ZEROFILL <CUSTOM_COL_OPTIONS>,
+s1 SMALLINT(1) ZEROFILL <CUSTOM_COL_OPTIONS>,
+s20 SMALLINT(20) ZEROFILL <CUSTOM_COL_OPTIONS>,
+m MEDIUMINT ZEROFILL <CUSTOM_COL_OPTIONS>,
+m0 MEDIUMINT(0) ZEROFILL <CUSTOM_COL_OPTIONS>,
+m1 MEDIUMINT(1) ZEROFILL <CUSTOM_COL_OPTIONS>,
+m20 MEDIUMINT(20) ZEROFILL <CUSTOM_COL_OPTIONS>,
+b BIGINT ZEROFILL <CUSTOM_COL_OPTIONS>,
+b0 BIGINT(0) ZEROFILL <CUSTOM_COL_OPTIONS>,
+b1 BIGINT(1) ZEROFILL <CUSTOM_COL_OPTIONS>,
+b20 BIGINT(20) ZEROFILL <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+i int(10) unsigned zerofill # # #
+i0 int(10) unsigned zerofill # # #
+i1 int(1) unsigned zerofill # # #
+i20 int(20) unsigned zerofill # # #
+t tinyint(3) unsigned zerofill # # #
+t0 tinyint(3) unsigned zerofill # # #
+t1 tinyint(1) unsigned zerofill # # #
+t20 tinyint(20) unsigned zerofill # # #
+s smallint(5) unsigned zerofill # # #
+s0 smallint(5) unsigned zerofill # # #
+s1 smallint(1) unsigned zerofill # # #
+s20 smallint(20) unsigned zerofill # # #
+m mediumint(8) unsigned zerofill # # #
+m0 mediumint(8) unsigned zerofill # # #
+m1 mediumint(1) unsigned zerofill # # #
+m20 mediumint(20) unsigned zerofill # # #
+b bigint(20) unsigned zerofill # # #
+b0 bigint(20) unsigned zerofill # # #
+b1 bigint(1) unsigned zerofill # # #
+b20 bigint(20) unsigned zerofill # # #
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (2147483647,2147483647,2147483647,2147483647,127,127,127,127,32767,32767,32767,32767,8388607,8388607,8388607,8388607,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807);
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
+0000000001 0000000002 3 00000000000000000004 005 006 7 00000000000000000008 00009 00010 11 00000000000000000012 00000013 00000014 15 00000000000000000016 00000000000000000017 00000000000000000018 19 00000000000000000020
+2147483647 2147483647 2147483647 00000000002147483647 127 127 127 00000000000000000127 32767 32767 32767 00000000000000032767 08388607 08388607 8388607 00000000000008388607 09223372036854775807 09223372036854775807 9223372036854775807 09223372036854775807
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483648,-2147483648,-2147483648,-2147483648,-128,-128,-128,-128,-32768,-32768,-32768,-32768,-8388608,-8388608,-8388608,-8388608,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967295,4294967295,4294967295,4294967295,255,255,255,255,65535,65535,65535,65535,16777215,16777215,16777215,16777215,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615);
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
+0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
+0000000001 0000000002 3 00000000000000000004 005 006 7 00000000000000000008 00009 00010 11 00000000000000000012 00000013 00000014 15 00000000000000000016 00000000000000000017 00000000000000000018 19 00000000000000000020
+2147483647 2147483647 2147483647 00000000002147483647 127 127 127 00000000000000000127 32767 32767 32767 00000000000000032767 08388607 08388607 8388607 00000000000008388607 09223372036854775807 09223372036854775807 9223372036854775807 09223372036854775807
+4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483649,-2147483649,-2147483649,-2147483649,-129,-129,-129,-129,-32769,-32769,-32769,-32769,-8388609,-8388609,-8388609,-8388609,-9223372036854775809,-9223372036854775809,-9223372036854775809,-9223372036854775809);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967296,4294967296,4294967296,4294967296,256,256,256,256,65536,65536,65536,65536,16777216,16777216,16777216,16777216,18446744073709551616,18446744073709551616,18446744073709551616,18446744073709551616);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) SELECT b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b FROM t1 WHERE b IN (-9223372036854775808,9223372036854775807,18446744073709551615);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'i' at row 2
+Warning 1264 Out of range value for column 'i0' at row 2
+Warning 1264 Out of range value for column 'i1' at row 2
+Warning 1264 Out of range value for column 'i20' at row 2
+Warning 1264 Out of range value for column 't' at row 2
+Warning 1264 Out of range value for column 't0' at row 2
+Warning 1264 Out of range value for column 't1' at row 2
+Warning 1264 Out of range value for column 't20' at row 2
+Warning 1264 Out of range value for column 's' at row 2
+Warning 1264 Out of range value for column 's0' at row 2
+Warning 1264 Out of range value for column 's1' at row 2
+Warning 1264 Out of range value for column 's20' at row 2
+Warning 1264 Out of range value for column 'm' at row 2
+Warning 1264 Out of range value for column 'm0' at row 2
+Warning 1264 Out of range value for column 'm1' at row 2
+Warning 1264 Out of range value for column 'm20' at row 2
+Warning 1264 Out of range value for column 'i' at row 3
+Warning 1264 Out of range value for column 'i0' at row 3
+Warning 1264 Out of range value for column 'i1' at row 3
+Warning 1264 Out of range value for column 'i20' at row 3
+Warning 1264 Out of range value for column 't' at row 3
+Warning 1264 Out of range value for column 't0' at row 3
+Warning 1264 Out of range value for column 't1' at row 3
+Warning 1264 Out of range value for column 't20' at row 3
+Warning 1264 Out of range value for column 's' at row 3
+Warning 1264 Out of range value for column 's0' at row 3
+Warning 1264 Out of range value for column 's1' at row 3
+Warning 1264 Out of range value for column 's20' at row 3
+Warning 1264 Out of range value for column 'm' at row 3
+Warning 1264 Out of range value for column 'm0' at row 3
+Warning 1264 Out of range value for column 'm1' at row 3
+Warning 1264 Out of range value for column 'm20' at row 3
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
+0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
+0000000000 0000000000 0 00000000000000000000 000 000 0 00000000000000000000 00000 00000 0 00000000000000000000 00000000 00000000 0 00000000000000000000 00000000000000000000 00000000000000000000 0 00000000000000000000
+0000000001 0000000002 3 00000000000000000004 005 006 7 00000000000000000008 00009 00010 11 00000000000000000012 00000013 00000014 15 00000000000000000016 00000000000000000017 00000000000000000018 19 00000000000000000020
+2147483647 2147483647 2147483647 00000000002147483647 127 127 127 00000000000000000127 32767 32767 32767 00000000000000032767 08388607 08388607 8388607 00000000000008388607 09223372036854775807 09223372036854775807 9223372036854775807 09223372036854775807
+4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 09223372036854775807 09223372036854775807 9223372036854775807 09223372036854775807
+4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+4294967295 4294967295 4294967295 00000000004294967295 255 255 255 00000000000000000255 65535 65535 65535 00000000000000065535 16777215 16777215 16777215 00000000000016777215 18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+ALTER TABLE t1 ADD COLUMN i257 INT(257);
+ERROR 42000: Display width out of range for 'i257' (max = 255)
+DROP TABLE t1;
+CREATE TABLE t1 (t TINYINT ZEROFILL <CUSTOM_COL_OPTIONS>,
+s SMALLINT ZEROFILL <CUSTOM_COL_OPTIONS>,
+m MEDIUMINT ZEROFILL <CUSTOM_COL_OPTIONS>,
+i INT ZEROFILL <CUSTOM_COL_OPTIONS>,
+b BIGINT ZEROFILL <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+t tinyint(3) unsigned zerofill # # # #
+s smallint(5) unsigned zerofill # # # #
+m mediumint(8) unsigned zerofill # # # #
+i int(10) unsigned zerofill # # # #
+b bigint(20) unsigned zerofill # # # #
+INSERT INTO t1 (t,s,m,i,b) VALUES (1,10,100,1000,0);
+SELECT t,s,m,i,b FROM t1;
+t s m i b
+001 00010 00000100 0000001000 00000000000000000000
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/col_opt_zerofill.test b/mysql-test/suite/storage_engine/col_opt_zerofill.test
new file mode 100644
index 00000000..0dc1c243
--- /dev/null
+++ b/mysql-test/suite/storage_engine/col_opt_zerofill.test
@@ -0,0 +1,88 @@
+#
+# ZEROFILL column attribute
+#
+
+let $extra_type_opts = ZEROFILL;
+
+--source have_engine.inc
+
+--echo #
+--echo # Fixed point columns (NUMERIC, DECIMAL)
+--echo #
+
+--source type_fixed.inc
+let $create_definition =
+ a DECIMAL $col_opts,
+ b NUMERIC $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = Fixed point types or ZEROFILL columns
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 # 6 #
+ SHOW COLUMNS IN t1;
+
+ INSERT INTO t1 (a,b) VALUES (1.1,1234);
+ SELECT a,b FROM t1;
+ DROP TABLE t1;
+}
+
+--echo #
+--echo # Floating point columns (FLOAT, DOUBLE)
+--echo #
+
+--source type_float.inc
+let $create_definition =
+ a DOUBLE $col_opts,
+ b FLOAT $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = Floating point types or ZEROFILL columns
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 # 6 #
+ SHOW COLUMNS IN t1;
+
+ INSERT INTO t1 (a,b) VALUES (1,1234.5);
+ SELECT a,b FROM t1;
+ DROP TABLE t1;
+}
+
+--echo #
+--echo # INT columns
+--echo #
+
+--source type_int.inc
+let $create_definition =
+ t TINYINT $col_opts,
+ s SMALLINT $col_opts,
+ m MEDIUMINT $col_opts,
+ i INT $col_opts,
+ b BIGINT $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = INT types or UNSIGNED columns
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 # 6 #
+ SHOW COLUMNS IN t1;
+
+ INSERT INTO t1 (t,s,m,i,b) VALUES (1,10,100,1000,0);
+ SELECT t,s,m,i,b FROM t1;
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/create_table.inc b/mysql-test/suite/storage_engine/create_table.inc
new file mode 100644
index 00000000..9a1cba51
--- /dev/null
+++ b/mysql-test/suite/storage_engine/create_table.inc
@@ -0,0 +1,174 @@
+##################################
+#
+# This include file will be used for all CREATE TABLE statements in the suite.
+# If you need to add additional steps or change the logic, copy the file
+# to storage/<engine>/mysql-test/storage_engine/ folder and modify it there.
+#
+##################
+#
+# Parameters:
+#
+# --let $create_definition = <column names, types, indexes) # optional, default a $int_col, b $char_col (based on defaults)
+# --let $table_name = <table name> # optional, default t1
+# --let $table_options = <table options> # optional, default based on define_engine.inc
+# --let $partition_options = <partitioning definition> # optional, default none
+# --let $as_select = <SELECT statement> # optional, default empty
+# --let $error_codes = <expected error codes, as in --error> # optional, default 0
+# --let $if_not_exists = [0|1] # optional, default 0 (1 adds IF NOT EXISTS clause)
+# --let $default_engine = [0|1] # optional, default 0 (with 1 will rely on default engine, no ENGINE=)
+# --let $temporary = [0|1] # optional, default 0 (1 adds TEMPORARY)
+# --let $disable_query_log = [0|1] # optional, default 0 (1 disables logging of CREATE)
+#
+# Usage examples:
+#
+# --source create_table.inc -- creates a default table
+#
+# --let $create_definition = a INT NOT NULL, b CHAR(1) PRIMARY KEY, INDEX(a)
+# --let $table_options = AUTO_INCREMENT = 100
+# --let $partition_options = PARTITION BY HASH(a) PARTITIONS 2
+# --let $as_select = SELECT 1, 'a'
+# --source create_table.inc
+#
+# Additionally, a test can define $extra_tbl_options. The difference with $table_options
+# is that its value is persistent and will be used until it is unset explicitly, or
+# until the test ends. The purpose of it is to allow one test to call another test,
+# when the called test does not know about specific options the calling test might require,
+# and thus cannot set them on per-create basis.
+
+--let $create_statement = CREATE
+
+if ($temporary)
+{
+ --let $create_statement = $create_statement TEMPORARY
+}
+
+--let $create_statement = $create_statement TABLE
+
+if ($if_not_exists)
+{
+ --let $create_statement = $create_statement IF NOT EXISTS
+}
+
+if (!$table_name)
+{
+ --let $table_name = t1
+}
+
+--let $create_statement = $create_statement $table_name
+
+if (!$create_definition)
+{
+ # If $create_definition is not defined, and AS SELECT is requested,
+ # we should not set $create_definition to the default value,
+ # because it might be inconsistent with the SELECT.
+ if (!$as_select)
+ {
+ --let $create_definition = a $int_col, b $char_col
+ }
+}
+
+if ($create_definition)
+{
+ --let $create_statement = $create_statement ($create_definition)
+}
+
+# If $default_engine is set, we will rely on the default storage engine
+
+if (!$default_engine)
+{
+ --let $create_statement = $create_statement ENGINE=$storage_engine
+}
+
+# Default table options from define_engine.inc
+--let $create_statement = $create_statement $default_tbl_opts
+
+# The calling script could request additional table options
+if ($table_options)
+{
+ --let $create_statement = $create_statement $table_options
+}
+
+# The difference between $extra_tbl_opts and $table_options
+# is that its $extra_tbl_opts is persistent -- it will not be unset at the end of this file,
+# and will be used until it is unset explicitly by the calling test,
+# or until the test ends. The purpose of it is to allow one test to call another test,
+# when the called test does not know about specific options the calling test might require,
+# and thus cannot set them on per-create basis.
+
+if ($extra_tbl_opts)
+{
+ --let $create_statement = $create_statement $extra_tbl_opts
+}
+
+if ($as_select)
+{
+ --let $create_statement = $create_statement AS $as_select
+}
+
+if ($partition_options)
+{
+ --let $create_statement = $create_statement $partition_options
+}
+
+# We now have the complete CREATE statement in $create_statement.
+# If your CREATE statement should be composed differently,
+# modify the logic above.
+
+#####################
+# Here you can add logic needed BEFORE the main table creation
+# (e.g. the table needs a base table, a reference table, etc.).
+# Surround it by --disable_query_log/--enable_query_log
+# if you don't want it to appear in the result output.
+#####################
+
+if ($disable_query_log)
+{
+ --disable_query_log
+}
+
+--source obfuscate.inc
+
+eval $create_statement;
+--source strict_check_errors.inc
+
+# Make sure you don't add any statements between the main CREATE (above)
+# and saving mysql_errno and mysql_errname (below)
+# They are saved in case you want to add more logic after the main CREATE,
+# because we need the result code of the table creation.
+# Also, do not change $create_statement after it is executed!
+
+--let $my_errno = $mysql_errno
+--let $my_errname = $mysql_errname
+
+
+if ($disable_query_log)
+{
+ --enable_query_log
+}
+
+#####################
+# Here you can add logic needed AFTER the main table creation,
+# e.g. triggers creation.
+# Surround it by --disable_query_log/--enable_query_log
+# if you don't want it to appear in the result output.
+#####################
+
+
+# Unset the parameters, we don't want them to be accidentally reused later
+--let $create_definition =
+--let $table_name = t1
+--let $table_options =
+--let $partition_options =
+--let $as_select = 0
+--let $error_codes =
+--let $if_not_exists = 0
+--let $default_engine = 0
+--let $temporary = 0
+--let $disable_query_log = 0
+
+# Restore the error codes of the main statement
+--let $mysql_errno = $my_errno
+--let $mysql_errname = $my_errname
+# Make sure you don't add any SQL statements after restoring
+# mysql_errno and mysql_errname (above)
+
diff --git a/mysql-test/suite/storage_engine/create_table.result b/mysql-test/suite/storage_engine/create_table.result
new file mode 100644
index 00000000..a3580c45
--- /dev/null
+++ b/mysql-test/suite/storage_engine/create_table.result
@@ -0,0 +1,45 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+CREATE TABLE IF NOT EXISTS t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+Warnings:
+Note 1050 Table 't1' already exists
+CREATE TABLE t2 LIKE t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+CREATE TEMPORARY TABLE t2 LIKE t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TEMPORARY TABLE `t2` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+DROP TEMPORARY TABLE t2;
+DROP TABLE t2;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> AS SELECT 1 UNION SELECT 2;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `1` int(1) NOT NULL DEFAULT 0
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+SELECT * FROM t1;
+1
+1
+2
+DROP TABLE t1;
+SET default_storage_engine = <STORAGE_ENGINE>;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+FLUSH LOGS;
+DROP TABLE IF EXISTS t1;
diff --git a/mysql-test/suite/storage_engine/create_table.test b/mysql-test/suite/storage_engine/create_table.test
new file mode 100644
index 00000000..eae259cf
--- /dev/null
+++ b/mysql-test/suite/storage_engine/create_table.test
@@ -0,0 +1,107 @@
+#
+# Basic CREATE TABLE statements
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+# Simple create table with minimal table options
+# which are defined in have_engine.inc
+# (default empty) plus ENGINE=
+
+--let $create_definition = a $int_col
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = CREATE TABLE
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --source mask_engine.inc
+ SHOW CREATE TABLE t1;
+
+ # IF NOT EXISTS
+ --let $if_not_exists = 1
+ --let $create_definition = a $int_col
+ --source create_table.inc
+}
+
+# CREATE .. LIKE
+
+CREATE TABLE t2 LIKE t1;
+if ($mysql_errname)
+{
+ --let $functionality = CREATE TABLE .. LIKE
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --source mask_engine.inc
+ SHOW CREATE TABLE t2;
+
+ eval
+ CREATE TEMPORARY TABLE t2 LIKE t1;
+ if ($mysql_errname)
+ {
+ --let $functionality = Temporary tables
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --source mask_engine.inc
+ SHOW CREATE TABLE t2;
+
+ DROP TEMPORARY TABLE t2;
+ }
+ DROP TABLE t2;
+}
+DROP TABLE IF EXISTS t1;
+
+# CREATE .. AS SELECT
+
+--let $as_select = SELECT 1 UNION SELECT 2
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = CREATE TABLE .. AS SELECT
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --source mask_engine.inc
+ SHOW CREATE TABLE t1;
+ --sorted_result
+ SELECT * FROM t1;
+ DROP TABLE t1;
+}
+
+# Use the engine as default
+
+--source mask_engine.inc
+eval SET default_storage_engine = $storage_engine;
+
+--let $tbl_opts = $default_tbl_opts
+--let $create_definition = a $int_col
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = CREATE TABLE or using the engine as default
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --source mask_engine.inc
+ SHOW CREATE TABLE t1;
+}
+
+# Just to add FLUSH LOGS into the mix while we are in the most common test
+FLUSH LOGS;
+
+DROP TABLE IF EXISTS t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/define_engine.inc b/mysql-test/suite/storage_engine/define_engine.inc
new file mode 100644
index 00000000..33d1fc5c
--- /dev/null
+++ b/mysql-test/suite/storage_engine/define_engine.inc
@@ -0,0 +1,45 @@
+###########################################
+#
+# This is a template of the include file define_engine.inc which
+# should be placed in storage/<engine>/mysql-test/storage_engine folder.
+#
+################################
+#
+# The name of the engine under test must be defined in $ENGINE variable.
+# You can set it either here (uncomment and edit) or in your environment.
+#
+# let $ENGINE =;
+#
+################################
+#
+# The following three variables define specific options for columns and tables.
+# Normally there should be none needed, but for some engines it can be different.
+# If the engine requires specific column option for all or indexed columns,
+# set them inside the comment, e.g. /*!NOT NULL*/.
+# Do the same for table options if needed, e.g. /*!INSERT_METHOD=LAST*/
+
+let $default_col_opts = /*!*/;
+let $default_col_indexed_opts = /*!*/;
+let $default_tbl_opts = /*!*/;
+
+# INDEX, UNIQUE INDEX, PRIMARY KEY, special index type - choose the fist that the engine allows,
+# or set it to /*!*/ if none is supported
+
+let $default_index = /*!INDEX*/;
+
+# If the engine does not support the following types, replace them with the closest possible
+
+let $default_int_type = INT(11);
+let $default_char_type = CHAR(8);
+
+################################
+
+--disable_query_log
+--disable_result_log
+
+# Here you can place your custom MTR code which needs to be executed before each test,
+# e.g. creation of an additional schema or table, etc.
+# The cleanup part should be defined in cleanup_engine.inc
+
+--enable_query_log
+--enable_result_log
diff --git a/mysql-test/suite/storage_engine/delete.result b/mysql-test/suite/storage_engine/delete.result
new file mode 100644
index 00000000..d7125a34
--- /dev/null
+++ b/mysql-test/suite/storage_engine/delete.result
@@ -0,0 +1,77 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (10000,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+DELETE FROM t1 WHERE b IN ('c');
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+10000 foobar
+10000 foobar
+2 b
+2 b
+4 d
+4 d
+5 e
+5 e
+DELETE FROM t1 WHERE a < 0 OR b = 'a';
+SELECT a,b FROM t1;
+a b
+10000 foobar
+10000 foobar
+2 b
+2 b
+4 d
+4 d
+5 e
+5 e
+DELETE FROM t1 WHERE a <= 4 ORDER BY b DESC LIMIT 1;
+SELECT a,b FROM t1;
+a b
+10000 foobar
+10000 foobar
+2 b
+2 b
+4 d
+5 e
+5 e
+CREATE TABLE t2 (c <CHAR_COLUMN>, d <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+SELECT c,d FROM t2;
+c d
+b 2
+b 2
+d 4
+e 5
+e 5
+foobar 10000
+foobar 10000
+DELETE t2.* FROM t1, t2 WHERE c < b AND a + d != 1;
+SELECT a,b FROM t1;
+a b
+10000 foobar
+10000 foobar
+2 b
+2 b
+4 d
+5 e
+5 e
+SELECT c,d FROM t2;
+c d
+foobar 10000
+foobar 10000
+DELETE FROM t2, t1.* USING t2, t1 WHERE c = 'foobar' and b = c;
+SELECT a,b FROM t1;
+a b
+2 b
+2 b
+4 d
+5 e
+5 e
+SELECT c,d FROM t2;
+c d
+DELETE FROM t1;
+SELECT a,b FROM t1;
+a b
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/storage_engine/delete.test b/mysql-test/suite/storage_engine/delete.test
new file mode 100644
index 00000000..e210ec3d
--- /dev/null
+++ b/mysql-test/suite/storage_engine/delete.test
@@ -0,0 +1,68 @@
+#
+# Basic DELETE statements.
+# DELETE LOW_PRIORITY is covered in delete_low_prio test
+# DELETE QUICK is covered in delete_quick test (syntax only)
+# DELETE IGNORE is covered in delete_ignore test
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+--let $create_definition = a $int_col, b $char_col
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (10000,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+
+# Single-table DELETE
+
+DELETE FROM t1 WHERE b IN ('c');
+if ($mysql_errname)
+{
+ --let $functionality = DELETE FROM
+ --source unexpected_result.inc
+}
+--sorted_result
+SELECT a,b FROM t1;
+
+DELETE FROM t1 WHERE a < 0 OR b = 'a';
+--sorted_result
+SELECT a,b FROM t1;
+
+# ORDER BY and LIMIT
+DELETE FROM t1 WHERE a <= 4 ORDER BY b DESC LIMIT 1;
+--sorted_result
+SELECT a,b FROM t1;
+
+# Multi-table DELETE
+
+--let $create_definition = c $char_col, d $int_col
+--let $table_name = t2
+--source create_table.inc
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+--sorted_result
+SELECT c,d FROM t2;
+
+DELETE t2.* FROM t1, t2 WHERE c < b AND a + d != 1;
+--sorted_result
+SELECT a,b FROM t1;
+--sorted_result
+SELECT c,d FROM t2;
+
+DELETE FROM t2, t1.* USING t2, t1 WHERE c = 'foobar' and b = c;
+--sorted_result
+SELECT a,b FROM t1;
+--sorted_result
+SELECT c,d FROM t2;
+
+DELETE FROM t1;
+--sorted_result
+SELECT a,b FROM t1;
+
+# Cleanup
+DROP TABLE t1, t2;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/delete_ignore.result b/mysql-test/suite/storage_engine/delete_ignore.result
new file mode 100644
index 00000000..aedac761
--- /dev/null
+++ b/mysql-test/suite/storage_engine/delete_ignore.result
@@ -0,0 +1,59 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (10000,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+CREATE TABLE t2 (c <CHAR_COLUMN>, d <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+10000 foobar
+10000 foobar
+2 b
+2 b
+3 c
+3 c
+4 d
+4 d
+5 e
+5 e
+SELECT c,d FROM t2;
+c d
+a 1
+a 1
+b 2
+b 2
+c 3
+c 3
+d 4
+d 4
+e 5
+e 5
+foobar 10000
+foobar 10000
+DELETE IGNORE FROM t1 WHERE b IS NOT NULL ORDER BY a LIMIT 1;
+SELECT a,b FROM t1;
+a b
+1 a
+10000 foobar
+10000 foobar
+2 b
+2 b
+3 c
+3 c
+4 d
+4 d
+5 e
+5 e
+DELETE IGNORE t1.*, t2.* FROM t1, t2 WHERE c < b OR a != ( SELECT 1 UNION SELECT 2 );
+Warnings:
+Warning 1242 Subquery returns more than 1 row
+SELECT a,b FROM t1;
+a b
+1 a
+SELECT c,d FROM t2;
+c d
+foobar 10000
+foobar 10000
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/storage_engine/delete_ignore.test b/mysql-test/suite/storage_engine/delete_ignore.test
new file mode 100644
index 00000000..c1b1926d
--- /dev/null
+++ b/mysql-test/suite/storage_engine/delete_ignore.test
@@ -0,0 +1,44 @@
+#
+# DELETE IGNORE
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+--let $create_definition = a $int_col, b $char_col
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (10000,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+
+--let $create_definition = c $char_col, d $int_col
+--let $table_name = t2
+--source create_table.inc
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+--sorted_result
+SELECT a,b FROM t1;
+--sorted_result
+SELECT c,d FROM t2;
+
+DELETE IGNORE FROM t1 WHERE b IS NOT NULL ORDER BY a LIMIT 1;
+if ($mysql_errname)
+{
+ --let $functionality = DELETE IGNORE FROM ..
+ --source unexpected_result.inc
+}
+--sorted_result
+SELECT a,b FROM t1;
+
+DELETE IGNORE t1.*, t2.* FROM t1, t2 WHERE c < b OR a != ( SELECT 1 UNION SELECT 2 );
+--sorted_result
+SELECT a,b FROM t1;
+--sorted_result
+SELECT c,d FROM t2;
+
+# Cleanup
+DROP TABLE t1, t2;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/delete_low_prio.result b/mysql-test/suite/storage_engine/delete_low_prio.result
new file mode 100644
index 00000000..89d08db5
--- /dev/null
+++ b/mysql-test/suite/storage_engine/delete_low_prio.result
@@ -0,0 +1,59 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
+SET LOW_PRIORITY_UPDATES = 0;
+SET lock_wait_timeout = 4;
+connect con1,localhost,root,,;
+SET lock_wait_timeout = 2;
+SELECT SLEEP(1) FROM t1;
+connection default;
+DELETE FROM t1;
+connect con2,localhost,root,,;
+SET lock_wait_timeout = 3;
+SELECT SLEEP(1) FROM t1;
+SLEEP(1)
+connection con1;
+SLEEP(1)
+0
+0
+connection default;
+SELECT a,b FROM t1;
+a b
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+connection con1;
+SELECT SLEEP(1) FROM t1;
+connection default;
+DELETE LOW_PRIORITY FROM t1;
+connection con2;
+SELECT SLEEP(1) FROM t1;
+SLEEP(1)
+0
+0
+connection con1;
+SLEEP(1)
+0
+0
+connection default;
+SELECT a,b FROM t1;
+a b
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+SET LOW_PRIORITY_UPDATES = 1;
+connection con1;
+SELECT SLEEP(1) FROM t1;
+connection default;
+DELETE FROM t1;
+connection con2;
+SELECT SLEEP(1) FROM t1;
+SLEEP(1)
+0
+0
+connection con1;
+SLEEP(1)
+0
+0
+connection default;
+SELECT a,b FROM t1;
+a b
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/delete_low_prio.test b/mysql-test/suite/storage_engine/delete_low_prio.test
new file mode 100644
index 00000000..da106791
--- /dev/null
+++ b/mysql-test/suite/storage_engine/delete_low_prio.test
@@ -0,0 +1,160 @@
+#
+# DELETE LOW_PRIORITY
+#
+--source have_engine.inc
+
+--source include/count_sessions.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $create_definiiton = a $int_col, b $char_col
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
+
+# We will have 3 connections:
+# con1 will start SELECT which should give us enough time;
+# default will run DELETE
+# con2 will then start another SELECT.
+# With LOW_PRIORITY_UPDATES = 0,
+# with standard DELETE we should see all rows in con1 resultset,
+# but no rows in con2 resultset.
+# With DELETE LOW_PRIORITY we should see all rows in both resultsets.
+# Then we will set LOW_PRIORITY_UPDATES to 1.
+# Then with standard DELETE we should see all rows in both resultsets.
+
+SET LOW_PRIORITY_UPDATES = 0;
+SET lock_wait_timeout = 4;
+
+# Normal DELETE with low_priority_updates=0
+
+--connect (con1,localhost,root,,)
+SET lock_wait_timeout = 2;
+--send
+SELECT SLEEP(1) FROM t1;
+
+--connection default
+let $show_statement = SHOW PROCESSLIST;
+let $field = State;
+let $condition = = 'User sleep';
+# We don't need to wait long,
+# if the feature works, threads
+# should show up in the processlist right away
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+
+--send
+DELETE FROM t1;
+
+--connect (con2,localhost,root,,)
+SET lock_wait_timeout = 3;
+
+let $field = Info;
+let $condition = = 'DELETE FROM t1';
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+if (!$found)
+{
+ --let $mysql_errname = timeout in wait_show_condition.inc
+ --let $functionality = DELETE or table locking
+ --source unexpected_result.inc
+}
+if ($found)
+{
+ SELECT SLEEP(1) FROM t1;
+}
+
+--connection con1
+--reap
+
+--connection default
+--reap
+--sorted_result
+SELECT a,b FROM t1;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+
+
+# DELETE LOW_PRIORITY
+
+--connection con1
+--send
+SELECT SLEEP(1) FROM t1;
+
+--connection default
+let $field = State;
+let $condition = = 'User sleep';
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+--send
+DELETE LOW_PRIORITY FROM t1;
+
+--connection con2
+let $field = Info;
+let $condition = = 'DELETE LOW_PRIORITY FROM t1';
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+if (!$found)
+{
+ --let $mysql_errname = timeout in wait_show_condition.inc
+ --let $functionality = DELETE LOW_PRIORITY or table locking
+ --source unexpected_result.inc
+}
+if ($found)
+{
+ SELECT SLEEP(1) FROM t1;
+}
+
+--connection con1
+--reap
+
+--connection default
+--reap
+--sorted_result
+SELECT a,b FROM t1;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+
+SET LOW_PRIORITY_UPDATES = 1;
+
+# Normal DELETE with low_priority_updates=1
+
+--connection con1
+--send
+SELECT SLEEP(1) FROM t1;
+
+--connection default
+let $field = State;
+let $condition = = 'User sleep';
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+--send
+DELETE FROM t1;
+
+--connection con2
+let $field = Info;
+let $condition = = 'DELETE FROM t1';
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+if ($found)
+{
+ SELECT SLEEP(1) FROM t1;
+}
+
+--connection con1
+--reap
+
+--connection default
+--reap
+--sorted_result
+SELECT a,b FROM t1;
+
+--disconnect con1
+--disconnect con2
+
+# Cleanup
+DROP TABLE t1;
+
+--source include/wait_until_count_sessions.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/delete_quick.result b/mysql-test/suite/storage_engine/delete_quick.result
new file mode 100644
index 00000000..7166bcde
--- /dev/null
+++ b/mysql-test/suite/storage_engine/delete_quick.result
@@ -0,0 +1,25 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, <CUSTOM_INDEX> (a), b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+DELETE QUICK FROM t1 WHERE a = 1 OR b > 'foo';
+SELECT a,b FROM t1;
+a b
+2 b
+3 c
+4 d
+5 e
+CREATE TABLE t2 (c <CHAR_COLUMN>, d <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+SELECT c,d FROM t2;
+c d
+b 2
+c 3
+d 4
+e 5
+DELETE QUICK FROM t2, t1.* USING t2, t1 WHERE c IS NULL OR a = d;
+SELECT a,b FROM t1;
+a b
+SELECT c,d FROM t2;
+c d
+DROP TABLE t2;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/delete_quick.test b/mysql-test/suite/storage_engine/delete_quick.test
new file mode 100644
index 00000000..f96fedfd
--- /dev/null
+++ b/mysql-test/suite/storage_engine/delete_quick.test
@@ -0,0 +1,55 @@
+#
+# DELETE QUICK syntax.
+# For now we only check that the keyword is accepted,
+# without actually checking whether the feature works.
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+--let $create_definition = a $int_indexed_col, $default_index (a), b $char_col
+--source create_table.inc
+if ($mysql_errname)
+{
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+ {
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+
+ DELETE QUICK FROM t1 WHERE a = 1 OR b > 'foo';
+ if ($mysql_errname)
+ {
+ --let $functionality = DELETE or DELETE QUICK
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ --let $create_definition = c $char_col, d $int_col
+ --let $table_name = t2
+ --source create_table.inc
+ INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+ --sorted_result
+ SELECT c,d FROM t2;
+
+ DELETE QUICK FROM t2, t1.* USING t2, t1 WHERE c IS NULL OR a = d;
+ --sorted_result
+ SELECT a,b FROM t1;
+ --sorted_result
+ SELECT c,d FROM t2;
+ DROP TABLE t2;
+ }
+ DROP TABLE t1;
+}
+
+# Cleanup
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/delete_with_keys.result b/mysql-test/suite/storage_engine/delete_with_keys.result
new file mode 100644
index 00000000..e968451b
--- /dev/null
+++ b/mysql-test/suite/storage_engine/delete_with_keys.result
@@ -0,0 +1,38 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, <CUSTOM_INDEX> (b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'x'),(7,'y'),(8,'z');
+DELETE FROM t1 WHERE b > 'y';
+DELETE FROM t1 WHERE a=2;
+SELECT a,b FROM t1;
+a b
+1 a
+3 c
+4 d
+5 e
+6 x
+7 y
+DELETE FROM t1;
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN> PRIMARY KEY, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'x'),(7,'y'),(8,'z');
+DELETE FROM t1 WHERE b > 'y';
+DELETE FROM t1 WHERE a=2;
+SELECT a,b FROM t1;
+a b
+1 a
+3 c
+4 d
+5 e
+6 x
+7 y
+DELETE FROM t1;
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <INT_COLUMN>, c <INT_COLUMN>, <CUSTOM_INDEX>(a), <CUSTOM_INDEX>(b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b,c) VALUES (1,2,3),(4,5,6),(7,8,9);
+DELETE FROM t1 WHERE a = 10 OR b = 20 ORDER BY c LIMIT 1;
+SELECT a,b,c FROM t1;
+a b c
+1 2 3
+4 5 6
+7 8 9
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/delete_with_keys.test b/mysql-test/suite/storage_engine/delete_with_keys.test
new file mode 100644
index 00000000..cda0da06
--- /dev/null
+++ b/mysql-test/suite/storage_engine/delete_with_keys.test
@@ -0,0 +1,74 @@
+#
+# DELETE statements for tables with keys
+#
+--source have_engine.inc
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $create_definition = a $int_col, b $char_indexed_col, $default_index (b)
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = Index on a CHAR column
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'x'),(7,'y'),(8,'z');
+ DELETE FROM t1 WHERE b > 'y';
+ if ($mysql_errname)
+ {
+ --let $functionality = DELETE
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ DELETE FROM t1 WHERE a=2;
+
+ --sorted_result
+ SELECT a,b FROM t1;
+ DELETE FROM t1;
+ }
+ DROP TABLE t1;
+}
+
+--let $create_definition = a $int_indexed_col PRIMARY KEY, b $char_col
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = PRIMARY KEY
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'x'),(7,'y'),(8,'z');
+ DELETE FROM t1 WHERE b > 'y';
+ DELETE FROM t1 WHERE a=2;
+
+ --sorted_result
+ SELECT a,b FROM t1;
+ DELETE FROM t1;
+ DROP TABLE t1;
+}
+
+--let $create_definition = a $int_indexed_col, b $int_col, c $int_indexed_col, $default_index(a), $default_index(b)
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = Multiple indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b,c) VALUES (1,2,3),(4,5,6),(7,8,9);
+ DELETE FROM t1 WHERE a = 10 OR b = 20 ORDER BY c LIMIT 1;
+ --sorted_result
+ SELECT a,b,c FROM t1;
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/describe.result b/mysql-test/suite/storage_engine/describe.result
new file mode 100644
index 00000000..61c3d6ba
--- /dev/null
+++ b/mysql-test/suite/storage_engine/describe.result
@@ -0,0 +1,18 @@
+DROP TABLE IF EXISTS t1, t2, t3;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHARACTER SET utf8;
+INSERT INTO t1 (a,b) VALUES (100,'foo'),(2, 'b');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHARACTER SET utf8;
+INSERT INTO t2 (a,b) VALUES (1, 'bar');
+CREATE TABLE t3 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHARACTER SET utf8;
+DESCRIBE t1;
+Field Type Null Key Default Extra
+a int(11) YES NULL
+b char(8) YES NULL
+DESC t2 a;
+Field Type Null Key Default Extra
+a int(11) YES NULL
+DESCRIBE t3 '%';
+Field Type Null Key Default Extra
+a int(11) YES NULL
+b char(8) YES NULL
+DROP TABLE t1, t2, t3;
diff --git a/mysql-test/suite/storage_engine/describe.test b/mysql-test/suite/storage_engine/describe.test
new file mode 100644
index 00000000..9f792469
--- /dev/null
+++ b/mysql-test/suite/storage_engine/describe.test
@@ -0,0 +1,50 @@
+#
+# DESCRIBE statement
+#
+# Note: the output might well be different
+# (depending on default values for the engine).
+# Examine mismatch carefully and, if columns are shown
+# with correct options, add an rdiff.
+# If you create combinations (with different startup options),
+# you might have to add an rdiff for each of them.
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, t3;
+--enable_warnings
+
+--let $create_definition = a $int_col, b $char_col
+--let $table_options = CHARACTER SET utf8
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = CHARACTER SET
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (100,'foo'),(2, 'b');
+
+ --let $create_definition = a $int_col, b $char_col
+ --let $table_options = CHARACTER SET utf8
+ --let $table_name = t2
+ --source create_table.inc
+
+ INSERT INTO t2 (a,b) VALUES (1, 'bar');
+
+ --let $create_definition = a $int_col, b $char_col
+ --let $table_name = t3
+ --let $table_options = CHARACTER SET utf8
+ --source create_table.inc
+
+ DESCRIBE t1;
+ DESC t2 a;
+ DESCRIBE t3 '%';
+
+ DROP TABLE t1, t2, t3;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/disabled.def b/mysql-test/suite/storage_engine/disabled.def
new file mode 100644
index 00000000..658d0c24
--- /dev/null
+++ b/mysql-test/suite/storage_engine/disabled.def
@@ -0,0 +1,12 @@
+alter_table_online : MDEV-9705 - Field type conversion warnings have changed to worse
+col_opt_null : MDEV-10252 - Row count in 'out of range' warnings is off
+col_opt_not_null : MDEV-10252 - Row count in 'out of range' warnings is off
+col_opt_unsigned : MDEV-10252 - Row count in 'out of range' warnings is off
+col_opt_zerofill : MDEV-10252 - Row count in 'out of range' warnings is off
+type_binary : MDEV-10252 - Row count in 'out of range' warnings is off
+type_char : MDEV-10252 - Row count in 'out of range' warnings is off
+type_fixed : MDEV-10252 - Row count in 'out of range' warnings is off
+type_float : MDEV-10252 - Row count in 'out of range' warnings is off
+type_int : MDEV-10252 - Row count in 'out of range' warnings is off
+type_varbinary : MDEV-10252 - Row count in 'out of range' warnings is off
+type_varchar : MDEV-10252 - Row count in 'out of range' warnings is off
diff --git a/mysql-test/suite/storage_engine/foreign_keys.result b/mysql-test/suite/storage_engine/foreign_keys.result
new file mode 100644
index 00000000..6c4a3406
--- /dev/null
+++ b/mysql-test/suite/storage_engine/foreign_keys.result
@@ -0,0 +1,71 @@
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> (a)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE t2 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+FOREIGN KEY (a) REFERENCES t1(a)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL,
+ KEY `a` (`a`),
+ CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+INSERT INTO t2 (a,b) VALUES (1,'a'),(2,'b');
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
+INSERT INTO t1 (a,b) VALUES (1,'c'),(2,'d');
+INSERT INTO t2 (a,b) VALUES (1,'a'),(2,'b');
+UPDATE t2 SET a=a+1;
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
+UPDATE t1 SET a=3 WHERE a=2;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
+DELETE FROM t1 WHERE a=2;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
+DELETE FROM t2 WHERE a=2;
+SELECT a,b FROM t1;
+a b
+1 c
+2 d
+SELECT a,b FROM t2;
+a b
+1 a
+DROP TABLE t1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
+DROP TABLE t2;
+CREATE TABLE t2 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+FOREIGN KEY (a) REFERENCES t1(a)
+ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL,
+ KEY `a` (`a`),
+ CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+INSERT INTO t2 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d');
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`) ON DELETE CASCADE ON UPDATE CASCADE)
+INSERT INTO t1 (a,b) VALUES (3,'a'),(4,'a');
+INSERT INTO t2 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(4,'e'),(3,'a');
+UPDATE t1 SET a=a+1;
+SELECT a,b FROM t2;
+a b
+5 a
+5 a
+5 b
+5 c
+5 d
+5 e
+DELETE FROM t1 WHERE b='a' LIMIT 2;
+SELECT a,b FROM t2;
+a b
+TRUNCATE TABLE t1;
+ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `test`.`t1` (`a`))
+DROP TABLE t2;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/foreign_keys.test b/mysql-test/suite/storage_engine/foreign_keys.test
new file mode 100644
index 00000000..49918626
--- /dev/null
+++ b/mysql-test/suite/storage_engine/foreign_keys.test
@@ -0,0 +1,149 @@
+#
+# Simple foreign keys setup
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+
+let $create_definition =
+ a $int_indexed_col,
+ b $char_col,
+ $default_index (a)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ let $create_definition =
+ a $int_indexed_col,
+ b $char_col,
+ FOREIGN KEY (a) REFERENCES t1(a)
+ ;
+ --let $table_name = t2
+ --source create_table.inc
+ if ($mysql_errname)
+ {
+ --let $functionality = Foreign keys
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --source mask_engine.inc
+ SHOW CREATE TABLE t2;
+
+ --let $error_codes = ER_NO_REFERENCED_ROW_2
+ INSERT INTO t2 (a,b) VALUES (1,'a'),(2,'b');
+ --source check_errors.inc
+ if ($mysql_errname != ER_NO_REFERENCED_ROW_2)
+ {
+ --let $functionality = Foreign keys
+ --source unexpected_result.inc
+ }
+ INSERT INTO t1 (a,b) VALUES (1,'c'),(2,'d');
+ INSERT INTO t2 (a,b) VALUES (1,'a'),(2,'b');
+
+ --let $error_codes = ER_NO_REFERENCED_ROW_2
+ UPDATE t2 SET a=a+1;
+ --source check_errors.inc
+ if ($mysql_errname != ER_NO_REFERENCED_ROW_2)
+ {
+ --let $functionality = Foreign keys
+ --source unexpected_result.inc
+ }
+
+ --let $error_codes = ER_ROW_IS_REFERENCED_2
+ UPDATE t1 SET a=3 WHERE a=2;
+ --source check_errors.inc
+
+ --let $error_codes = ER_ROW_IS_REFERENCED_2
+ DELETE FROM t1 WHERE a=2;
+ --source check_errors.inc
+ if ($mysql_errname != ER_ROW_IS_REFERENCED_2)
+ {
+ --let $functionality = Foreign keys
+ --source unexpected_result.inc
+ }
+
+ DELETE FROM t2 WHERE a=2;
+
+ --sorted_result
+ SELECT a,b FROM t1;
+ --sorted_result
+ SELECT a,b FROM t2;
+
+ --let $error_codes = ER_ROW_IS_REFERENCED_2
+ DROP TABLE t1;
+ --source check_errors.inc
+ if ($mysql_errname != ER_ROW_IS_REFERENCED_2)
+ {
+ --let $functionality = Foreign keys
+ --source unexpected_result.inc
+ }
+
+ DROP TABLE t2;
+ }
+
+ let $create_definition =
+ a $int_indexed_col,
+ b $char_col,
+ FOREIGN KEY (a) REFERENCES t1(a)
+ ON DELETE CASCADE ON UPDATE CASCADE
+ ;
+ --let $table_name = t2
+ --source create_table.inc
+ if ($mysql_errname)
+ {
+ --let $functionality = Foreign keys or ON DELETE|UPDATE CASCADE
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --source mask_engine.inc
+ SHOW CREATE TABLE t2;
+
+ --let $error_codes = ER_NO_REFERENCED_ROW_2
+ INSERT INTO t2 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d');
+ --source check_errors.inc
+ INSERT INTO t1 (a,b) VALUES (3,'a'),(4,'a');
+ INSERT INTO t2 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(4,'e'),(3,'a');
+
+ UPDATE t1 SET a=a+1;
+ if ($mysql_errname)
+ {
+ --let $functionality = UPDATE
+ --source unexpected_result.inc
+ }
+ --sorted_result
+ SELECT a,b FROM t2;
+
+ DELETE FROM t1 WHERE b='a' LIMIT 2;
+ if ($mysql_errname)
+ {
+ --let $functionality = DELETE
+ --source unexpected_result.inc
+ }
+ --sorted_result
+ SELECT a,b FROM t2;
+
+ --let $error_codes = ER_TRUNCATE_ILLEGAL_FK
+ TRUNCATE TABLE t1;
+ --source check_errors.inc
+ if ($mysql_errname != ER_TRUNCATE_ILLEGAL_FK)
+ {
+ --let $functionality = Foreign keys
+ --source unexpected_result.inc
+ }
+
+ DROP TABLE t2;
+ }
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/fulltext_search.result b/mysql-test/suite/storage_engine/fulltext_search.result
new file mode 100644
index 00000000..4363d0ab
--- /dev/null
+++ b/mysql-test/suite/storage_engine/fulltext_search.result
@@ -0,0 +1,132 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (v0 VARCHAR(64) <CUSTOM_COL_OPTIONS>,
+v1 VARCHAR(16384) <CUSTOM_COL_OPTIONS>,
+v2 TEXT <CUSTOM_COL_OPTIONS>,
+FULLTEXT v1 (v1)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEXES IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 v1 1 v1 # # NULL NULL YES FULLTEXT
+INSERT INTO t1 (v0,v1,v2) VALUES ('text1','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+For developers who want to code on MariaDB or MySQL
+* Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+* MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+For MariaDB / MySQL end users
+* MariaDB Crash Course by Ben Forta
+o First MariaDB book!
+o For people who want to learn SQL and the basics of MariaDB.
+o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+* SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+o Free to read in the Knowledgebase!
+* MySQL (4th Edition) by Paul DuBois
+o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+* MySQL Cookbook by Paul DuBois
+o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+* High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ',
+'There are several reasons why contributing code is one of the easiest and most rewarding ways to contribute to MariaDB:
+
+ 1. We are very responsive toward reviews of submitted code and as soon as the review is done, the submitted code is merged into an existing MariaDB tree and made available to everyone, not just select customers.
+ 2. Code reviews are performed by the MariaDB core development team and the quality, detail, and timeliness of our reviews are better than you will find elsewhere.
+ 3. With MariaDB everyone has access to the latest code.
+ 4. If a patch is very safe and/or very useful we are willing to push it into the stable code (as long as it can\'t break any existing applications). We are willing to do this to ensure the freedom to add small, needed fixes on a stable release so users don\'t have to wait a year for something to be added which is critical to their business.
+ 5. If you are an active contributor, you can become a member of maria-captains, even if you aren\'t working for Monty Program Ab. All captains have the same rights as any other captain to accept and reject patches. Our development model is truly open for everyone.
+The Contributing Code page details many of the actual steps involved in working with the MariaDB source code. It\'s important that you use the same tools and submit patches in the same way as other developers to keep development running smoothly.'
+ ), ('text2','test1','test2');
+SELECT v0 FROM t1 WHERE MATCH(v1) AGAINST ('contributing' IN NATURAL LANGUAGE MODE);
+v0
+INSERT INTO t1 (v0,v1,v2) VALUES ('text3','test','test');
+SELECT v0, MATCH(v1) AGAINST('contributing' IN NATURAL LANGUAGE MODE) AS rating FROM t1 WHERE MATCH(v1) AGAINST ('contributing' IN NATURAL LANGUAGE MODE);
+v0 rating
+INSERT INTO t1 (v0,v1,v2) VALUES ('text4','Contributing more...','...is a good idea'),('text5','test','test');
+SELECT v0, MATCH(v1) AGAINST('contributing') AS rating FROM t1 WHERE MATCH(v1) AGAINST ('contributing');
+v0 rating
+text4 1.3705332279205322
+SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('-test1 +critical +Cook*' IN BOOLEAN MODE);
+v0
+text1
+SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('-patch +critical +Cook*' IN BOOLEAN MODE);
+v0
+SELECT v0, MATCH(v1) AGAINST('database' WITH QUERY EXPANSION) AS rating FROM t1 WHERE MATCH(v1) AGAINST ('database' WITH QUERY EXPANSION);
+v0 rating
+text1 178.11756896972656
+DROP TABLE t1;
+CREATE TABLE t1 (v0 VARCHAR(64) <CUSTOM_COL_OPTIONS>,
+v1 VARCHAR(16384) <CUSTOM_COL_OPTIONS>,
+v2 TEXT <CUSTOM_COL_OPTIONS>,
+FULLTEXT v1 (v1),
+FULLTEXT v1_v2 (v1,v2)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEXES IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 v1 1 v1 # # NULL NULL YES FULLTEXT
+t1 1 v1_v2 1 v1 # # NULL NULL YES FULLTEXT
+t1 1 v1_v2 2 v2 # # NULL NULL YES FULLTEXT
+INSERT INTO t1 (v0,v1,v2) VALUES ('text1','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+For developers who want to code on MariaDB or MySQL
+* Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+* MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+For MariaDB / MySQL end users
+* MariaDB Crash Course by Ben Forta
+o First MariaDB book!
+o For people who want to learn SQL and the basics of MariaDB.
+o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+* SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+o Free to read in the Knowledgebase!
+* MySQL (4th Edition) by Paul DuBois
+o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+* MySQL Cookbook by Paul DuBois
+o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+* High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ',
+'There are several reasons why contributing code is one of the easiest and most rewarding ways to contribute to MariaDB:
+
+ 1. We are very responsive toward reviews of submitted code and as soon as the review is done, the submitted code is merged into an existing MariaDB tree and made available to everyone, not just select customers.
+ 2. Code reviews are performed by the MariaDB core development team and the quality, detail, and timeliness of our reviews are better than you will find elsewhere.
+ 3. With MariaDB everyone has access to the latest code.
+ 4. If a patch is very safe and/or very useful we are willing to push it into the stable code (as long as it can\'t break any existing applications). We are willing to do this to ensure the freedom to add small, needed fixes on a stable release so users don\'t have to wait a year for something to be added which is critical to their business.
+ 5. If you are an active contributor, you can become a member of maria-captains, even if you aren\'t working for Monty Program Ab. All captains have the same rights as any other captain to accept and reject patches. Our development model is truly open for everyone.
+The Contributing Code page details many of the actual steps involved in working with the MariaDB source code. It\'s important that you use the same tools and submit patches in the same way as other developers to keep development running smoothly.'
+ ), ('text2','test1','test2');
+SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('contributing' IN NATURAL LANGUAGE MODE);
+v0
+INSERT INTO t1 (v0,v1,v2) VALUES ('text3','test','test');
+SELECT v0, MATCH(v1,v2) AGAINST('contributing' IN NATURAL LANGUAGE MODE) AS rating FROM t1 WHERE MATCH(v1,v2) AGAINST ('contributing' IN NATURAL LANGUAGE MODE);
+v0 rating
+text1 0.2809644043445587
+INSERT INTO t1 (v0,v1,v2) VALUES ('text4','Contributing more...','...is a good idea'),('text5','test','test');
+SELECT v0, MATCH(v1) AGAINST('contributing') AS rating FROM t1 WHERE MATCH(v1) AGAINST ('contributing');
+v0 rating
+text4 1.3705332279205322
+SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('-test1 +critical +Cook*' IN BOOLEAN MODE);
+v0
+text1
+SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('-patch +critical +Cook*' IN BOOLEAN MODE);
+v0
+SELECT v0, MATCH(v1,v2) AGAINST('database' WITH QUERY EXPANSION) AS rating FROM t1 WHERE MATCH(v1,v2) AGAINST ('database' WITH QUERY EXPANSION);
+v0 rating
+text1 190.56150817871094
+text4 1.1758291721343994
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/fulltext_search.test b/mysql-test/suite/storage_engine/fulltext_search.test
new file mode 100644
index 00000000..47857a17
--- /dev/null
+++ b/mysql-test/suite/storage_engine/fulltext_search.test
@@ -0,0 +1,187 @@
+#
+# Full-text indexes and search
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $create_definition =
+ v0 VARCHAR(64) $col_opts,
+ v1 VARCHAR(16384) $col_indexed_opts,
+ v2 TEXT $col_opts,
+ FULLTEXT v1 (v1)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = FULLTEXT indexes or VARCHAR|TEXT data types
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 #
+ SHOW INDEXES IN t1;
+
+ INSERT INTO t1 (v0,v1,v2) VALUES ('text1','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ',
+
+ 'There are several reasons why contributing code is one of the easiest and most rewarding ways to contribute to MariaDB:
+
+ 1. We are very responsive toward reviews of submitted code and as soon as the review is done, the submitted code is merged into an existing MariaDB tree and made available to everyone, not just select customers.
+ 2. Code reviews are performed by the MariaDB core development team and the quality, detail, and timeliness of our reviews are better than you will find elsewhere.
+ 3. With MariaDB everyone has access to the latest code.
+ 4. If a patch is very safe and/or very useful we are willing to push it into the stable code (as long as it can\'t break any existing applications). We are willing to do this to ensure the freedom to add small, needed fixes on a stable release so users don\'t have to wait a year for something to be added which is critical to their business.
+ 5. If you are an active contributor, you can become a member of maria-captains, even if you aren\'t working for Monty Program Ab. All captains have the same rights as any other captain to accept and reject patches. Our development model is truly open for everyone.
+
+ The Contributing Code page details many of the actual steps involved in working with the MariaDB source code. It\'s important that you use the same tools and submit patches in the same way as other developers to keep development running smoothly.'
+ ), ('text2','test1','test2');
+
+ # 50% rule -- no result if the string is represented in at least 50% rows
+ SELECT v0 FROM t1 WHERE MATCH(v1) AGAINST ('contributing' IN NATURAL LANGUAGE MODE);
+
+ # Adding a row to start getting results
+ INSERT INTO t1 (v0,v1,v2) VALUES ('text3','test','test');
+ SELECT v0, MATCH(v1) AGAINST('contributing' IN NATURAL LANGUAGE MODE) AS rating FROM t1 WHERE MATCH(v1) AGAINST ('contributing' IN NATURAL LANGUAGE MODE);
+
+ INSERT INTO t1 (v0,v1,v2) VALUES ('text4','Contributing more...','...is a good idea'),('text5','test','test');
+ SELECT v0, MATCH(v1) AGAINST('contributing') AS rating FROM t1 WHERE MATCH(v1) AGAINST ('contributing');
+
+ # Boolean mode
+
+ SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('-test1 +critical +Cook*' IN BOOLEAN MODE);
+ SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('-patch +critical +Cook*' IN BOOLEAN MODE);
+
+ # Query expansion
+
+ SELECT v0, MATCH(v1) AGAINST('database' WITH QUERY EXPANSION) AS rating FROM t1 WHERE MATCH(v1) AGAINST ('database' WITH QUERY EXPANSION);
+ DROP TABLE t1;
+}
+
+
+let $create_definition =
+ v0 VARCHAR(64) $col_opts,
+ v1 VARCHAR(16384) $col_opts,
+ v2 TEXT $col_opts,
+ FULLTEXT v1 (v1),
+ FULLTEXT v1_v2 (v1,v2)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = FULLTEXT indexes or multiple keys or VARCHAR|TEXT data types
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 #
+ SHOW INDEXES IN t1;
+
+ INSERT INTO t1 (v0,v1,v2) VALUES ('text1','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ',
+
+ 'There are several reasons why contributing code is one of the easiest and most rewarding ways to contribute to MariaDB:
+
+ 1. We are very responsive toward reviews of submitted code and as soon as the review is done, the submitted code is merged into an existing MariaDB tree and made available to everyone, not just select customers.
+ 2. Code reviews are performed by the MariaDB core development team and the quality, detail, and timeliness of our reviews are better than you will find elsewhere.
+ 3. With MariaDB everyone has access to the latest code.
+ 4. If a patch is very safe and/or very useful we are willing to push it into the stable code (as long as it can\'t break any existing applications). We are willing to do this to ensure the freedom to add small, needed fixes on a stable release so users don\'t have to wait a year for something to be added which is critical to their business.
+ 5. If you are an active contributor, you can become a member of maria-captains, even if you aren\'t working for Monty Program Ab. All captains have the same rights as any other captain to accept and reject patches. Our development model is truly open for everyone.
+
+ The Contributing Code page details many of the actual steps involved in working with the MariaDB source code. It\'s important that you use the same tools and submit patches in the same way as other developers to keep development running smoothly.'
+ ), ('text2','test1','test2');
+
+ # 50% rule -- no result if the string is represented in at least 50% rows
+ SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('contributing' IN NATURAL LANGUAGE MODE);
+
+ # Adding a row to start getting results
+ INSERT INTO t1 (v0,v1,v2) VALUES ('text3','test','test');
+ SELECT v0, MATCH(v1,v2) AGAINST('contributing' IN NATURAL LANGUAGE MODE) AS rating FROM t1 WHERE MATCH(v1,v2) AGAINST ('contributing' IN NATURAL LANGUAGE MODE);
+
+ INSERT INTO t1 (v0,v1,v2) VALUES ('text4','Contributing more...','...is a good idea'),('text5','test','test');
+ SELECT v0, MATCH(v1) AGAINST('contributing') AS rating FROM t1 WHERE MATCH(v1) AGAINST ('contributing');
+
+ # Boolean mode
+
+ SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('-test1 +critical +Cook*' IN BOOLEAN MODE);
+ SELECT v0 FROM t1 WHERE MATCH(v1,v2) AGAINST ('-patch +critical +Cook*' IN BOOLEAN MODE);
+
+ # Query expansion
+
+ SELECT v0, MATCH(v1,v2) AGAINST('database' WITH QUERY EXPANSION) AS rating FROM t1 WHERE MATCH(v1,v2) AGAINST ('database' WITH QUERY EXPANSION);
+
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/handler.result b/mysql-test/suite/storage_engine/handler.result
new file mode 100644
index 00000000..be29b98c
--- /dev/null
+++ b/mysql-test/suite/storage_engine/handler.result
@@ -0,0 +1,77 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <CHAR_COLUMN>, b <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES ('foobar',1000),('a',1),('bar',200),('foo',100);
+HANDLER t1 OPEN AS h1;
+HANDLER t1 READ FIRST;
+ERROR 42S02: Unknown table 't1' in HANDLER
+HANDLER h1 READ FIRST;
+a b
+foobar 1000
+HANDLER h1 READ NEXT;
+a b
+a 1
+HANDLER h1 READ FIRST WHERE a < 'foo';
+a b
+a 1
+HANDLER h1 READ NEXT;
+a b
+bar 200
+HANDLER h1 READ NEXT;
+a b
+foo 100
+HANDLER h1 READ NEXT;
+a b
+HANDLER h1 READ FIRST LIMIT 2;
+a b
+foobar 1000
+a 1
+HANDLER h1 READ NEXT;
+a b
+bar 200
+HANDLER h1 READ NEXT WHERE b>500 LIMIT 2;
+a b
+HANDLER t1 OPEN;
+HANDLER h1 READ FIRST WHERE b>500 LIMIT 5;
+a b
+foobar 1000
+HANDLER t1 READ NEXT;
+a b
+foobar 1000
+HANDLER h1 READ NEXT WHERE b<100;
+a b
+HANDLER t1 CLOSE;
+HANDLER h1 READ FIRST;
+a b
+foobar 1000
+HANDLER t1 CLOSE;
+ERROR 42S02: Unknown table 't1' in HANDLER
+DROP TABLE t1;
+HANDLER h1 CLOSE;
+ERROR 42S02: Unknown table 'h1' in HANDLER
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, <CUSTOM_INDEX> (a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (b,a) VALUES ('a',1),('b',200),('f',100),('b',101),('c',2);
+HANDLER t1 OPEN AS h1;
+HANDLER h1 READ a = (100);
+a b
+100 f
+HANDLER h1 READ a <= (100) WHERE b < 'f';
+a b
+2 c
+HANDLER h1 READ a > (2) WHERE b IS NOT NULL LIMIT 2;
+a b
+100 f
+101 b
+HANDLER h1 READ a FIRST;
+a b
+1 a
+HANDLER h1 READ a LAST;
+a b
+200 b
+HANDLER h1 READ a PREV;
+a b
+101 b
+HANDLER h1 READ a NEXT;
+a b
+200 b
+HANDLER h1 CLOSE;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/handler.test b/mysql-test/suite/storage_engine/handler.test
new file mode 100644
index 00000000..200ab649
--- /dev/null
+++ b/mysql-test/suite/storage_engine/handler.test
@@ -0,0 +1,81 @@
+#
+# Basic HANDLER syntax
+#
+# HANDLER .. READ <index_name> is covered in handler_index test
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $create_definition = a $char_col, b $int_col
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES ('foobar',1000),('a',1),('bar',200),('foo',100);
+
+HANDLER t1 OPEN AS h1;
+if ($mysql_errname)
+{
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --let $error_codes = ER_UNKNOWN_TABLE
+ HANDLER t1 READ FIRST;
+ --source check_errors.inc
+ HANDLER h1 READ FIRST;
+ HANDLER h1 READ NEXT;
+ HANDLER h1 READ FIRST WHERE a < 'foo';
+ HANDLER h1 READ NEXT;
+ HANDLER h1 READ NEXT;
+ HANDLER h1 READ NEXT;
+ HANDLER h1 READ FIRST LIMIT 2;
+ HANDLER h1 READ NEXT;
+ HANDLER h1 READ NEXT WHERE b>500 LIMIT 2;
+ HANDLER t1 OPEN;
+ HANDLER h1 READ FIRST WHERE b>500 LIMIT 5;
+ HANDLER t1 READ NEXT;
+ HANDLER h1 READ NEXT WHERE b<100;
+ HANDLER t1 CLOSE;
+ HANDLER h1 READ FIRST;
+ --let $error_codes = ER_UNKNOWN_TABLE
+ HANDLER t1 CLOSE;
+ --source check_errors.inc
+}
+
+DROP TABLE t1;
+
+--let $error_codes = ER_UNKNOWN_TABLE
+HANDLER h1 CLOSE;
+--source check_errors.inc
+
+--let $continue = 1
+--source have_default_index.inc
+
+if ($have_default_index)
+{
+ --let $create_definition = a $int_indexed_col, b $char_col, $default_index (a)
+ --source create_table.inc
+ INSERT INTO t1 (b,a) VALUES ('a',1),('b',200),('f',100),('b',101),('c',2);
+ if ($mysql_errname)
+ {
+ --source unexpected_result.inc
+ }
+ HANDLER t1 OPEN AS h1;
+ if (!$mysql_errname)
+ {
+ HANDLER h1 READ a = (100);
+ HANDLER h1 READ a <= (100) WHERE b < 'f';
+ HANDLER h1 READ a > (2) WHERE b IS NOT NULL LIMIT 2;
+ HANDLER h1 READ a FIRST;
+ HANDLER h1 READ a LAST;
+ HANDLER h1 READ a PREV;
+ HANDLER h1 READ a NEXT;
+ HANDLER h1 CLOSE;
+ }
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/have_default_index.inc b/mysql-test/suite/storage_engine/have_default_index.inc
new file mode 100644
index 00000000..fb5111c7
--- /dev/null
+++ b/mysql-test/suite/storage_engine/have_default_index.inc
@@ -0,0 +1,20 @@
+#
+# This include file either just prints the message, or skips the rest of the test
+# Usage:
+# --let $continue = 1; # optional
+# --source have_default_index.inc
+#
+
+--let $have_default_index = 1
+if ($default_index == '/*!*/ /*Custom index*/')
+{
+ if (!$continue)
+ {
+ --source cleanup_engine.inc
+ --skip # Configuration does not allow indexes. Check \$default_index value
+ }
+ --echo # According to the configuration, the engine does not allow indexes. Check \$default_index value
+ --let $have_default_index = 0
+ --let $continue = 0
+}
+
diff --git a/mysql-test/suite/storage_engine/have_engine.inc b/mysql-test/suite/storage_engine/have_engine.inc
new file mode 100644
index 00000000..6f95716f
--- /dev/null
+++ b/mysql-test/suite/storage_engine/have_engine.inc
@@ -0,0 +1,127 @@
+###########################################
+#
+# This include file executes define_engine.inc which belongs to the storage engine
+# and then checks and sets test options and parameters.
+#
+# The name of the engine under test must be defined in $ENGINE variable.
+# You can define it either in define_engine.inc or in your environment.
+#
+################################
+#
+# The following three variables define specific options for columns and tables.
+# Normally there should be none needed, but for some engines it can be different.
+# If the engine requires specific column option for all or indexed columns,
+# set them inside the comment, e.g. /*!NOT NULL*/.
+# Do the same for table options if needed, e.g. /*!INSERT_METHOD=LAST*/
+
+let $default_col_opts = /*!*/;
+let $default_col_indexed_opts = /*!*/;
+let $default_tbl_opts = /*!*/;
+
+# INDEX, UNIQUE INDEX, PRIMARY KEY, special index type -- choose minimal that the engine allows,
+# or set it to /*!*/ if none is supported
+
+let $default_index = /*!INDEX*/;
+
+# If the engine does not support these types, replace them with the closest possible
+
+let $default_int_type = INT(11);
+let $default_char_type = CHAR(8);
+
+################################
+#
+# Here the actual work starts
+# define_engine.inc will set the ENGINE variable
+# and possibly redefine some of default_* variables
+
+--source define_engine.inc
+
+if (!$ENGINE)
+{
+ --skip Storage engine under test is not defined, export ENGINE env variable or set it in define_engine.inc
+}
+
+# Check that the storage engine is loaded. Here we don't need to worry about the case,
+# as I_S is case-insensitive.
+
+if (!`SELECT engine FROM INFORMATION_SCHEMA.ENGINES WHERE engine = '$ENGINE' AND support IN ('YES', 'DEFAULT', 'ENABLED')`)
+{
+ --skip The test requires $ENGINE engine
+}
+
+# Further in tests we will use $storage_engine variable
+
+let $storage_engine = $ENGINE;
+
+# In case somebody removed comment tags in define_engine.inc
+if (!$default_col_opts)
+{
+ let $default_col_opts = /*!*/;
+}
+if (!$default_col_indexed_opts)
+{
+ let $default_col_indexed_opts = /*!*/;
+}
+if (!$default_tbl_opts)
+{
+ let $default_tbl_opts = /*!*/;
+}
+if (!$default_index)
+{
+ let $default_index = /*!*/;
+}
+
+# Adding a comment after default options helps later to mask the custom values in result output
+let $default_index = $default_index /*Custom index*/;
+let $default_col_opts = $default_col_opts /*Custom column options*/;
+let $default_col_indexed_opts = $default_col_indexed_opts /*Custom indexed column options*/;
+let $default_tbl_opts = $default_tbl_opts /*Custom table options*/;
+
+
+# Finally, set some variables which will make our life easier later.
+# For many tests, we need a simple INT or CHAR column, but with
+# (optional) column attributes which the engine might require.
+# Also, a test might be called by another test, and the calling test
+# might need additional attributes. So, here we are collecting them all together.
+# Example:
+# CSV engine requires all columns to be NOT NULL, so its define_engine.inc file will contain
+# let $default_col_opts = /*!NOT NULL*/;
+# Then, we have test1.test which calls have_engine.inc.
+# If it's executed directly, it will have $int_col = 'INT(11) NOT NULL' for CSV and 'INT(11)' for MyISAM.
+# Another test, test2.test might set $extra_type_opts = UNSIGNED and/or $extra_col_opts = NULL
+# and call test1.test.
+# If both are set, test1.test will be executed for MyISAM with 'INT(11) UNSIGNED NULL',
+# and for CSV INT(11) UNSIGNED NOT NULL NULL (and will fail because CSV does not support nullable columns)
+
+let $col_opts = $default_col_opts;
+let $col_indexed_opts = $default_col_indexed_opts;
+
+if ($extra_col_opts)
+{
+ let $col_opts = $col_opts $extra_col_opts;
+ let $col_indexed_opts = $col_indexed_opts $extra_col_opts;
+}
+
+if ($extra_type_opts)
+{
+ let $col_opts = $extra_type_opts $col_opts;
+ let $col_indexed_opts = $extra_type_opts $col_indexed_opts;
+}
+
+let $int_col = $default_int_type $col_opts;
+let $int_indexed_col = $default_int_type $col_indexed_opts;
+
+let $char_col = $default_char_type $col_opts;
+let $char_indexed_col = $default_char_type $col_indexed_opts;
+
+
+
+if (`SELECT @@global.log_bin = 'ON' AND @@global.binlog_format = 'STATEMENT'`)
+{
+ --disable_query_log
+ CALL mtr.add_suppression('Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT');
+ --enable_query_log
+}
+
+--disable_abort_on_error
+
diff --git a/mysql-test/suite/storage_engine/index.inc b/mysql-test/suite/storage_engine/index.inc
new file mode 100644
index 00000000..ac7632fb
--- /dev/null
+++ b/mysql-test/suite/storage_engine/index.inc
@@ -0,0 +1,194 @@
+#
+# Basic syntax related to indexes:
+# unique and non-unique keys,
+# single- and multi-column keys,
+# index option COMMENT.
+#
+# See other index* tests for operations
+# which are less likely to be supported
+#
+# PRIMARY KEY syntax is covered in index_primary test.
+# Index types BTREE|HASH -- in index_type_btree|hash tests.
+# SPATIAL -- in type_spatial_indexes test.
+# FULLTEXT -- in fulltext_search test.
+# KEY_BLOCK_SIZE -- in index_key_block_size test.
+#
+# Usage to call the test from another test:
+#
+# A calling test may define $index_type, in which case
+# USING clause will be added to the syntax.
+#
+
+let $using_index_type = ;
+if ($index_type)
+{
+ let $using_index_type = USING $index_type;
+}
+
+--source have_engine.inc
+
+--let $continue = 1
+--source have_default_index.inc
+
+if ($have_default_index)
+{
+
+ let $create_definition =
+ a $int_indexed_col,
+ b $char_col,
+ $default_index $using_index_type (a)
+ ;
+ --source create_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $create_statement
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ # Cardinality is not the exact science, so here and further
+ # we'll be masking it
+ --replace_column 6 # 7 # 10 #
+ SHOW KEYS IN t1;
+ DROP TABLE t1;
+ }
+
+ let $create_definition =
+ a $int_indexed_col,
+ b $char_indexed_col,
+ $default_index a_b $using_index_type (a,b) COMMENT 'a_b index'
+ ;
+ --source create_table.inc
+ if ($mysql_errname)
+ {
+ --let $functionality = Multi-part indexes
+ --let $my_last_stmt = $create_statement
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --replace_column 6 # 7 # 10 #
+ SHOW KEYS IN t1;
+ DROP TABLE t1;
+ }
+
+
+ let $create_definition =
+ a $int_indexed_col,
+ b $char_indexed_col,
+ $default_index $using_index_type (a),
+ $default_index $using_index_type (b)
+ ;
+ --source create_table.inc
+ if ($mysql_errname)
+ {
+ --let $functionality = Multiple indexes
+ --let $my_last_stmt = $create_statement
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --replace_column 6 # 7 # 10 #
+ SHOW KEYS IN t1;
+ DROP TABLE t1;
+ }
+
+ let $create_definition =
+ a $int_indexed_col,
+ b $char_col,
+ UNIQUE INDEX $using_index_type (a)
+ ;
+ --source create_table.inc
+ if ($mysql_errname)
+ {
+ --let $functionality = Unique indexes
+ --let $my_last_stmt = $create_statement
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --replace_column 6 # 7 # 10 #
+ SHOW KEYS IN t1;
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ INSERT INTO t1 (a,b) VALUES (1,'c');
+ --source check_errors.inc
+
+ DROP TABLE t1;
+ }
+
+
+ #
+ # ALTER TABLE
+ #
+
+ --let $create_definition = a $int_indexed_col, b $char_col
+ --source create_table.inc
+ if ($mysql_errname)
+ {
+ --let $functionality = Column options
+ --let $my_last_stmt = $create_statement
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ INSERT INTO t1 (a,b) VALUES (100,'z');
+
+ --let $alter_definition = ADD $default_index (a) $using_index_type COMMENT 'simple index on a'
+ --source alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $functionality = ALTER TABLE .. ADD INDEX
+ --let $my_last_stmt = $alter_statement
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --replace_column 6 # 7 # 10 #
+ SHOW INDEX FROM t1;
+ --let $alter_definition = DROP KEY a
+ --source alter_table.inc
+ }
+ DROP TABLE t1;
+ }
+
+ let $create_definition =
+ a $int_indexed_col,
+ b $char_col,
+ UNIQUE INDEX $using_index_type (a)
+ ;
+ --source create_table.inc
+ if ($mysql_errname)
+ {
+ --let $functionality = Unique indexes
+ --let $my_last_stmt = $create_statement
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --replace_column 6 # 7 # 10 #
+ SHOW KEYS IN t1;
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ INSERT INTO t1 (a,b) VALUES (1,'c');
+ --source check_errors.inc
+
+ --let $alter_definition = DROP INDEX a
+ --source alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $functionality = ALTER TABLE .. DROP INDEX
+ --let $my_last_stmt = $alter_statement
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ INSERT INTO t1 (a,b) VALUES (1,'c');
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ --let $alter_definition = ADD UNIQUE INDEX a(a) $using_index_type
+ --source alter_table.inc
+ }
+ DROP TABLE t1;
+ }
+}
+
diff --git a/mysql-test/suite/storage_engine/index.result b/mysql-test/suite/storage_engine/index.result
new file mode 100644
index 00000000..baf9a4d4
--- /dev/null
+++ b/mysql-test/suite/storage_engine/index.result
@@ -0,0 +1,67 @@
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> (a)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a 1 a # # NULL NULL # BTREE
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> a_b (a,b) COMMENT 'a_b index'
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a_b 1 a # # NULL NULL # BTREE a_b index
+t1 1 a_b 2 b # # NULL NULL # BTREE a_b index
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> (a),
+<CUSTOM_INDEX> (b)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a 1 a # # NULL NULL # BTREE
+t1 1 b 1 b # # NULL NULL # BTREE
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+UNIQUE INDEX (a)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 a 1 a # # NULL NULL # BTREE
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+INSERT INTO t1 (a,b) VALUES (1,'c');
+ERROR 23000: Duplicate entry '1' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (100,'z');
+ALTER TABLE t1 ADD <CUSTOM_INDEX> (a) COMMENT 'simple index on a';
+SHOW INDEX FROM t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a 1 a # # NULL NULL # BTREE simple index on a
+ALTER TABLE t1 DROP KEY a;
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+UNIQUE INDEX (a)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 a 1 a # # NULL NULL # BTREE
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+INSERT INTO t1 (a,b) VALUES (1,'c');
+ERROR 23000: Duplicate entry '1' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+ALTER TABLE t1 DROP INDEX a;
+INSERT INTO t1 (a,b) VALUES (1,'c');
+ALTER TABLE t1 ADD UNIQUE INDEX a(a) ;
+ERROR 23000: Duplicate entry '1' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/index.test b/mysql-test/suite/storage_engine/index.test
new file mode 100644
index 00000000..0dba3d1b
--- /dev/null
+++ b/mysql-test/suite/storage_engine/index.test
@@ -0,0 +1,23 @@
+#
+# Basic syntax related to indexes:
+# unique and non-unique keys,
+# single- and multi-column keys,
+# index option COMMENT.
+#
+# See other index* tests for operations
+# which are less likely to be supported
+#
+# PRIMARY KEY syntax is covered in index_primary test.
+# Index types BTREE|HASH -- in index_type_btree|hash tests.
+# SPATIAL -- in type_spatial_indexes test.
+# FULLTEXT -- in fulltext_search test.
+# KEY_BLOCK_SIZE -- in index_key_block_size test.
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+--source index.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/index_enable_disable.result b/mysql-test/suite/storage_engine/index_enable_disable.result
new file mode 100644
index 00000000..e7bb9cf3
--- /dev/null
+++ b/mysql-test/suite/storage_engine/index_enable_disable.result
@@ -0,0 +1,45 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, <CUSTOM_INDEX>(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a) VALUES (10);
+INSERT INTO t1 (a) VALUES
+(1),(2),(3),(4),(5),(6),(7),(8),(9),
+(21),(22),(23),(24),(25),(26),(27),(28),(29);
+EXPLAIN SELECT a FROM t1 ORDER BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 5 NULL # Using index
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a 1 a # # NULL NULL YES BTREE
+ALTER TABLE t1 DISABLE KEYS;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a 1 a # # NULL NULL YES BTREE disabled
+EXPLAIN SELECT a FROM t1 ORDER BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 19 Using filesort
+INSERT INTO t1 (a) VALUES
+(11),(12),(13),(14),(15),(16),(17),(18),(19),(20);
+ALTER TABLE t1 ENABLE KEYS;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a 1 a # # NULL NULL YES BTREE
+EXPLAIN SELECT a FROM t1 ORDER BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 5 NULL # Using index
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, UNIQUE INDEX(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a) VALUES
+(1),(2),(3),(4),(5),(6),(7),(8),(9),
+(21),(22),(23),(24),(25),(26),(27),(28),(29);
+ALTER TABLE t1 DISABLE KEYS;
+INSERT INTO t1 (a) VALUES (29);
+ERROR 23000: Duplicate entry '29' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 a 1 a # # NULL NULL YES BTREE
+EXPLAIN SELECT a FROM t1 ORDER BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 5 NULL # Using index
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/index_enable_disable.test b/mysql-test/suite/storage_engine/index_enable_disable.test
new file mode 100644
index 00000000..4f0297ea
--- /dev/null
+++ b/mysql-test/suite/storage_engine/index_enable_disable.test
@@ -0,0 +1,88 @@
+#
+# ENABLE KEYS / DISABLE KEYS
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+
+--let $create_definition = a $int_indexed_col, $default_index(a)
+--source create_table.inc
+INSERT INTO t1 (a) VALUES (10);
+
+INSERT INTO t1 (a) VALUES
+ (1),(2),(3),(4),(5),(6),(7),(8),(9),
+ (21),(22),(23),(24),(25),(26),(27),(28),(29);
+# Plan should use the index.
+# Masking the `rows` column as the value might vary a bit
+--replace_column 9 #
+EXPLAIN SELECT a FROM t1 ORDER BY a;
+
+--replace_column 6 # 7 #
+SHOW INDEX IN t1;
+
+--let $alter_definition = DISABLE KEYS
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER .. DISABLE KEYS
+ --source unexpected_result.inc
+}
+
+# Now comment should say 'disabled'
+--replace_column 6 # 7 #
+SHOW INDEX IN t1;
+
+# And the plan should not use the index
+EXPLAIN SELECT a FROM t1 ORDER BY a;
+INSERT INTO t1 (a) VALUES
+ (11),(12),(13),(14),(15),(16),(17),(18),(19),(20);
+
+# The index should be back active
+--let $alter_definition = ENABLE KEYS
+--source alter_table.inc
+--replace_column 6 # 7 #
+SHOW INDEX IN t1;
+--replace_column 9 #
+EXPLAIN SELECT a FROM t1 ORDER BY a;
+
+DROP TABLE t1;
+
+--let $create_definition = a $int_indexed_col, UNIQUE INDEX(a)
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Unique keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a) VALUES
+ (1),(2),(3),(4),(5),(6),(7),(8),(9),
+ (21),(22),(23),(24),(25),(26),(27),(28),(29);
+
+ # For unique indexes DISABLE KEYS has no effect
+
+ --let $alter_definition = DISABLE KEYS
+ --source alter_table.inc
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ INSERT INTO t1 (a) VALUES (29);
+ --source check_errors.inc
+ --replace_column 6 # 7 #
+ SHOW INDEX IN t1;
+ --replace_column 9 #
+ EXPLAIN SELECT a FROM t1 ORDER BY a;
+
+ DROP TABLE t1;
+}
+
+# Cleanup
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/index_key_block_size.result b/mysql-test/suite/storage_engine/index_key_block_size.result
new file mode 100644
index 00000000..0e00f02e
--- /dev/null
+++ b/mysql-test/suite/storage_engine/index_key_block_size.result
@@ -0,0 +1,43 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> (a) KEY_BLOCK_SIZE=8
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a 1 a # # NULL NULL # #
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> ind1(b ASC) KEY_BLOCK_SIZE=0
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 ind1 1 b # # NULL NULL # #
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+UNIQUE INDEX ind2(b(1) DESC) KEY_BLOCK_SIZE=32768 COMMENT 'big key_block_size value'
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 ind2 1 b # # 1 NULL # # big key_block_size value
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> a_b(a,b) KEY_BLOCK_SIZE=8192
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a_b 1 a # # NULL NULL # #
+t1 1 a_b 2 b # # NULL NULL # #
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (100,'z');
+ALTER TABLE t1 ADD <CUSTOM_INDEX>(a) KEY_BLOCK_SIZE 8192;
+SHOW INDEX FROM t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a 1 a # # NULL NULL # #
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/index_key_block_size.test b/mysql-test/suite/storage_engine/index_key_block_size.test
new file mode 100644
index 00000000..21304f03
--- /dev/null
+++ b/mysql-test/suite/storage_engine/index_key_block_size.test
@@ -0,0 +1,125 @@
+#
+# KEY_BLOCK_SIZE index option.
+#
+# The results are likely to be different
+# depending on the engine
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $create_definition =
+ a $int_indexed_col,
+ b $char_col,
+ $default_index (a) KEY_BLOCK_SIZE=8
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ # Cardinality is not the exact science, so here and further
+ # we'll be masking it
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW KEYS IN t1;
+
+ DROP TABLE t1;
+}
+
+
+let $create_definition =
+ a $int_col,
+ b $char_indexed_col,
+ $default_index ind1(b ASC) KEY_BLOCK_SIZE=0
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Indexes on CHAR columns
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ a $int_col,
+ b $char_indexed_col,
+ UNIQUE INDEX ind2(b(1) DESC) KEY_BLOCK_SIZE=32768 COMMENT 'big key_block_size value'
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Unique keys on char columns
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ a $int_indexed_col,
+ b $char_indexed_col,
+ $default_index a_b(a,b) KEY_BLOCK_SIZE=8192
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Multi-part keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+--replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ DROP TABLE t1;
+}
+
+#
+# ALTER TABLE
+#
+
+let $create_definition =
+ a $int_indexed_col,
+ b $char_col
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (100,'z');
+
+ --let $alter_definition = ADD $default_index(a) KEY_BLOCK_SIZE 8192
+ --source alter_table.inc
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX FROM t1;
+
+ DROP TABLE t1;
+}
+
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/index_primary.result b/mysql-test/suite/storage_engine/index_primary.result
new file mode 100644
index 00000000..04b114f3
--- /dev/null
+++ b/mysql-test/suite/storage_engine/index_primary.result
@@ -0,0 +1,53 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN> PRIMARY KEY,
+b <CHAR_COLUMN>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 PRIMARY 1 a # # NULL NULL # #
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+INSERT INTO t1 (a,b) VALUES (1,'c');
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN> PRIMARY KEY,
+b <CHAR_COLUMN> PRIMARY KEY
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ERROR 42000: Multiple primary key defined
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+PRIMARY KEY (a,b)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 PRIMARY 1 a # # NULL NULL # #
+t1 0 PRIMARY 2 b # # NULL NULL # #
+INSERT INTO t1 (a,b) VALUES (1,'a'),(1,'b'),(2,'a'),(2,'b');
+INSERT INTO t1 (a,b) VALUES (1,'b');
+ERROR 23000: Duplicate entry '1-b' for key 'PRIMARY'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN> KEY,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> (b)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 PRIMARY 1 a # # NULL NULL # #
+t1 1 b 1 b # # NULL NULL # #
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN> PRIMARY KEY
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 PRIMARY 1 b # # NULL NULL # #
+ALTER TABLE t1 DROP INDEX `PRIMARY`;
+ALTER TABLE t1 ADD CONSTRAINT PRIMARY KEY pk (a);
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 PRIMARY 1 a # # NULL NULL # #
+ALTER TABLE t1 DROP PRIMARY KEY;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/index_primary.test b/mysql-test/suite/storage_engine/index_primary.test
new file mode 100644
index 00000000..55671d99
--- /dev/null
+++ b/mysql-test/suite/storage_engine/index_primary.test
@@ -0,0 +1,136 @@
+#
+# Basic syntax related to primary keys
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $create_definition =
+ a $int_indexed_col PRIMARY KEY,
+ b $char_col
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = PRIMARY KEY
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW KEYS IN t1;
+
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ INSERT INTO t1 (a,b) VALUES (1,'c');
+ --source check_errors.inc
+
+ DROP TABLE t1;
+}
+
+--let $error_codes = ER_MULTIPLE_PRI_KEY
+let $create_definition =
+ a $int_indexed_col PRIMARY KEY,
+ b $char_indexed_col PRIMARY KEY
+;
+--source create_table.inc
+if ($mysql_errname != ER_MULTIPLE_PRI_KEY)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = PRIMARY KEY
+ --source unexpected_result.inc
+}
+
+let $create_definition =
+ a $int_indexed_col,
+ b $char_indexed_col,
+ PRIMARY KEY (a,b)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Multi-part keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(1,'b'),(2,'a'),(2,'b');
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ INSERT INTO t1 (a,b) VALUES (1,'b');
+ --source check_errors.inc
+ DROP TABLE t1;
+}
+
+
+--let $continue = 1
+--source have_default_index.inc
+if ($have_default_index)
+{
+ # KEY in a column definition means PK!
+ let $create_definition =
+ a $int_indexed_col KEY,
+ b $char_indexed_col,
+ $default_index (b)
+ ;
+ --source create_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Multiple keys or PK or keys on CHAR columns
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+ DROP TABLE t1;
+ }
+}
+
+let $create_definition =
+ a $int_indexed_col,
+ b $char_indexed_col PRIMARY KEY
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ --let $alter_definition = DROP INDEX `PRIMARY`
+ --source alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --let $alter_definition = ADD CONSTRAINT PRIMARY KEY pk (a)
+ --source alter_table.inc
+ --source mask_engine.inc
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW KEYS IN t1;
+ --let $alter_definition = DROP PRIMARY KEY
+ --source alter_table.inc
+ }
+
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/index_type_btree.result b/mysql-test/suite/storage_engine/index_type_btree.result
new file mode 100644
index 00000000..e0b3ac54
--- /dev/null
+++ b/mysql-test/suite/storage_engine/index_type_btree.result
@@ -0,0 +1,67 @@
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> USING BTREE (a)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a 1 a # # NULL NULL # BTREE
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> a_b USING BTREE (a,b) COMMENT 'a_b index'
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a_b 1 a # # NULL NULL # BTREE a_b index
+t1 1 a_b 2 b # # NULL NULL # BTREE a_b index
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> USING BTREE (a),
+<CUSTOM_INDEX> USING BTREE (b)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a 1 a # # NULL NULL # BTREE
+t1 1 b 1 b # # NULL NULL # BTREE
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+UNIQUE INDEX USING BTREE (a)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 a 1 a # # NULL NULL # BTREE
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+INSERT INTO t1 (a,b) VALUES (1,'c');
+ERROR 23000: Duplicate entry '1' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (100,'z');
+ALTER TABLE t1 ADD <CUSTOM_INDEX> (a) USING BTREE COMMENT 'simple index on a';
+SHOW INDEX FROM t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a 1 a # # NULL NULL # BTREE simple index on a
+ALTER TABLE t1 DROP KEY a;
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+UNIQUE INDEX USING BTREE (a)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 a 1 a # # NULL NULL # BTREE
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+INSERT INTO t1 (a,b) VALUES (1,'c');
+ERROR 23000: Duplicate entry '1' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+ALTER TABLE t1 DROP INDEX a;
+INSERT INTO t1 (a,b) VALUES (1,'c');
+ALTER TABLE t1 ADD UNIQUE INDEX a(a) USING BTREE;
+ERROR 23000: Duplicate entry '1' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/index_type_btree.test b/mysql-test/suite/storage_engine/index_type_btree.test
new file mode 100644
index 00000000..c5212218
--- /dev/null
+++ b/mysql-test/suite/storage_engine/index_type_btree.test
@@ -0,0 +1,12 @@
+#
+# Index type BTREE
+#
+
+--source have_engine.inc
+
+let $index_type = BTREE;
+
+--source index.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/index_type_hash.result b/mysql-test/suite/storage_engine/index_type_hash.result
new file mode 100644
index 00000000..f2666341
--- /dev/null
+++ b/mysql-test/suite/storage_engine/index_type_hash.result
@@ -0,0 +1,67 @@
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> USING HASH (a)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a 1 a # # NULL NULL # HASH
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> a_b USING HASH (a,b) COMMENT 'a_b index'
+ ) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a_b 1 a # # NULL NULL # HASH a_b index
+t1 1 a_b 2 b # # NULL NULL # HASH a_b index
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+<CUSTOM_INDEX> USING HASH (a),
+<CUSTOM_INDEX> USING HASH (b)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a 1 a # # NULL NULL # HASH
+t1 1 b 1 b # # NULL NULL # HASH
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+UNIQUE INDEX USING HASH (a)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 a 1 a # # NULL NULL # HASH
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+INSERT INTO t1 (a,b) VALUES (1,'c');
+ERROR 23000: Duplicate entry '1' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (100,'z');
+ALTER TABLE t1 ADD <CUSTOM_INDEX> (a) USING HASH COMMENT 'simple index on a';
+SHOW INDEX FROM t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a 1 a # # NULL NULL # HASH simple index on a
+ALTER TABLE t1 DROP KEY a;
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>,
+b <CHAR_COLUMN>,
+UNIQUE INDEX USING HASH (a)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW KEYS IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 a 1 a # # NULL NULL # HASH
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+INSERT INTO t1 (a,b) VALUES (1,'c');
+ERROR 23000: Duplicate entry '1' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+ALTER TABLE t1 DROP INDEX a;
+INSERT INTO t1 (a,b) VALUES (1,'c');
+ALTER TABLE t1 ADD UNIQUE INDEX a(a) USING HASH;
+ERROR 23000: Duplicate entry '1' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/index_type_hash.test b/mysql-test/suite/storage_engine/index_type_hash.test
new file mode 100644
index 00000000..c63f41c6
--- /dev/null
+++ b/mysql-test/suite/storage_engine/index_type_hash.test
@@ -0,0 +1,12 @@
+#
+# Index type HASH
+#
+
+--source have_engine.inc
+
+let $index_type = HASH;
+
+--source index.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/insert.result b/mysql-test/suite/storage_engine/insert.result
new file mode 100644
index 00000000..2dfe20cb
--- /dev/null
+++ b/mysql-test/suite/storage_engine/insert.result
@@ -0,0 +1,149 @@
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 VALUES (100,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+SELECT a,b FROM t1;
+a b
+1 a
+100 foobar
+2 b
+3 c
+4 d
+5 e
+INSERT t1 VALUE (10,'foo'),(11,'abc');
+SELECT a,b FROM t1;
+a b
+1 a
+10 foo
+100 foobar
+11 abc
+2 b
+3 c
+4 d
+5 e
+INSERT INTO t1 (b,a) VALUES ('test',0);
+SELECT a,b FROM t1;
+a b
+0 test
+1 a
+10 foo
+100 foobar
+11 abc
+2 b
+3 c
+4 d
+5 e
+INSERT INTO t1 VALUES (DEFAULT,DEFAULT);
+SELECT a,b FROM t1;
+a b
+0 test
+1 a
+10 foo
+100 foobar
+11 abc
+2 b
+3 c
+4 d
+5 e
+NULL NULL
+INSERT t1 (a) VALUE (10),(20);
+SELECT a,b FROM t1;
+a b
+0 test
+1 a
+10 NULL
+10 foo
+100 foobar
+11 abc
+2 b
+20 NULL
+3 c
+4 d
+5 e
+NULL NULL
+INSERT INTO t1 SET a = 11, b = 'f';
+SELECT a,b FROM t1;
+a b
+0 test
+1 a
+10 NULL
+10 foo
+100 foobar
+11 abc
+11 f
+2 b
+20 NULL
+3 c
+4 d
+5 e
+NULL NULL
+INSERT t1 SET b = DEFAULT;
+SELECT a,b FROM t1;
+a b
+0 test
+1 a
+10 NULL
+10 foo
+100 foobar
+11 abc
+11 f
+2 b
+20 NULL
+3 c
+4 d
+5 e
+NULL NULL
+NULL NULL
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t2 SELECT a,b FROM t1;
+INSERT INTO t1 (a) SELECT a FROM t2 WHERE b = 'foo';
+SELECT a,b FROM t1;
+a b
+0 test
+1 a
+10 NULL
+10 NULL
+10 foo
+100 foobar
+11 abc
+11 f
+2 b
+20 NULL
+3 c
+4 d
+5 e
+NULL NULL
+NULL NULL
+INSERT t1 (a,b) SELECT a,b FROM t1;
+SELECT a,b FROM t1;
+a b
+0 test
+0 test
+1 a
+1 a
+10 NULL
+10 NULL
+10 NULL
+10 NULL
+10 foo
+10 foo
+100 foobar
+100 foobar
+11 abc
+11 abc
+11 f
+11 f
+2 b
+2 b
+20 NULL
+20 NULL
+3 c
+3 c
+4 d
+4 d
+5 e
+5 e
+NULL NULL
+NULL NULL
+NULL NULL
+NULL NULL
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/storage_engine/insert.test b/mysql-test/suite/storage_engine/insert.test
new file mode 100644
index 00000000..1f780eba
--- /dev/null
+++ b/mysql-test/suite/storage_engine/insert.test
@@ -0,0 +1,78 @@
+#
+# Basic INSERT statements
+#
+# LOW_PRIORITY|HIGH_PRIORITY are covered in insert_high_low_prio test
+# DELAYED is covered in insert_delayed test
+# IGNORE and ON DUPLICATE KEY UPDATE are covered in insert_with_keys test
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+--source create_table.inc
+
+# INSERT [INTO] .. VALUES|VALUE ..
+
+INSERT INTO t1 VALUES (100,'foobar'),(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+if ($mysql_errname)
+{
+ --let $functionality = INSERT
+ --source unexpected_result.inc
+}
+--sorted_result
+SELECT a,b FROM t1;
+
+INSERT t1 VALUE (10,'foo'),(11,'abc');
+--sorted_result
+SELECT a,b FROM t1;
+
+INSERT INTO t1 (b,a) VALUES ('test',0);
+--sorted_result
+SELECT a,b FROM t1;
+
+INSERT INTO t1 VALUES (DEFAULT,DEFAULT);
+--sorted_result
+SELECT a,b FROM t1;
+
+INSERT t1 (a) VALUE (10),(20);
+--sorted_result
+SELECT a,b FROM t1;
+
+# INSERT [INTO] .. SET
+
+INSERT INTO t1 SET a = 11, b = 'f';
+--sorted_result
+SELECT a,b FROM t1;
+
+INSERT t1 SET b = DEFAULT;
+--sorted_result
+SELECT a,b FROM t1;
+
+
+# INSERT .. SELECT
+
+--let $table_name = t2
+--source create_table.inc
+INSERT INTO t2 SELECT a,b FROM t1;
+if ($mysql_errname)
+{
+ --let $functionality = INSERT .. SELECT
+ --source unexpected_result.inc
+}
+
+
+INSERT INTO t1 (a) SELECT a FROM t2 WHERE b = 'foo';
+--sorted_result
+SELECT a,b FROM t1;
+
+INSERT t1 (a,b) SELECT a,b FROM t1;
+--sorted_result
+SELECT a,b FROM t1;
+
+# Cleanup
+DROP TABLE t1, t2;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/insert_delayed.result b/mysql-test/suite/storage_engine/insert_delayed.result
new file mode 100644
index 00000000..528003d8
--- /dev/null
+++ b/mysql-test/suite/storage_engine/insert_delayed.result
@@ -0,0 +1,25 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
+LOCK TABLE t1 READ;
+connect con0,localhost,root,,;
+SET lock_wait_timeout = 1;
+INSERT DELAYED INTO t1 (a,b) VALUES (3,'c');
+INSERT DELAYED INTO t1 SET a=4, b='d';
+INSERT DELAYED INTO t1 (a,b) SELECT 5, 'e';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+disconnect con0;
+connection default;
+SELECT a,b FROM t1;
+a b
+1 f
+2 b
+UNLOCK TABLES;
+FLUSH TABLES;
+SELECT a,b FROM t1;
+a b
+1 f
+2 b
+3 c
+4 d
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/insert_delayed.test b/mysql-test/suite/storage_engine/insert_delayed.test
new file mode 100644
index 00000000..ece0bf3c
--- /dev/null
+++ b/mysql-test/suite/storage_engine/insert_delayed.test
@@ -0,0 +1,60 @@
+#
+# INSERT DELAYED
+#
+
+--source have_engine.inc
+
+if (`SELECT @@log_bin AND @@binlog_format IN ('statement','mixed')`)
+{
+ --source cleanup_engine.inc
+ --skip # INSERT DELAYED does not work with binlog format STATEMENT or MIXED
+}
+
+--source include/count_sessions.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $create_definition = a $int_col, b $char_col
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
+
+LOCK TABLE t1 READ;
+if ($mysql_errname)
+{
+ --let $functionality = LOCK TABLE .. READ
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --connect (con0,localhost,root,,)
+ SET lock_wait_timeout = 1;
+ INSERT DELAYED INTO t1 (a,b) VALUES (3,'c');
+ if ($mysql_errname)
+ {
+ --let $functionality = INSERT DELAYED
+ --source unexpected_result.inc
+ }
+ INSERT DELAYED INTO t1 SET a=4, b='d';
+ # DELAYED is ignored with INSERT .. SELECT
+ --let $error_codes = ER_LOCK_WAIT_TIMEOUT
+ INSERT DELAYED INTO t1 (a,b) SELECT 5, 'e';
+ --source check_errors.inc
+
+ --disconnect con0
+ --connection default
+ SELECT a,b FROM t1;
+}
+UNLOCK TABLES;
+FLUSH TABLES;
+SELECT a,b FROM t1;
+
+# Cleanup
+DROP TABLE t1;
+
+let $wait_timeout = 30;
+--source include/wait_until_count_sessions.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/insert_high_prio.result b/mysql-test/suite/storage_engine/insert_high_prio.result
new file mode 100644
index 00000000..4f5a3a44
--- /dev/null
+++ b/mysql-test/suite/storage_engine/insert_high_prio.result
@@ -0,0 +1,64 @@
+DROP TABLE IF EXISTS t1;
+SET @low_prio_updates = @@global.low_priority_updates;
+SET @concur_insert = @@global.concurrent_insert;
+SET GLOBAL concurrent_insert = NEVER;
+connect con0,localhost,root,,;
+SET lock_wait_timeout = 4;
+connect con1,localhost,root,,;
+SET lock_wait_timeout = 4;
+connect con2,localhost,root,,;
+SET lock_wait_timeout = 4;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
+SET GLOBAL LOW_PRIORITY_UPDATES = 1;
+connection con1;
+SELECT SLEEP(1) FROM t1;
+connection con0;
+INSERT INTO t1 (a,b) VALUES (3,'z');
+connection con2;
+# Should return only 2 rows
+SELECT SLEEP(1) FROM t1;
+SLEEP(1)
+0
+0
+connection con1;
+SLEEP(1)
+0
+0
+connection con0;
+SELECT a,b FROM t1;
+a b
+1 f
+2 b
+3 z
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
+connection con1;
+SELECT SLEEP(1) FROM t1;
+connection con0;
+INSERT HIGH_PRIORITY INTO t1 (a,b) VALUES (3,'z');
+connection con2;
+# Should return 3 rows
+SELECT SLEEP(1) FROM t1;
+SLEEP(1)
+0
+0
+0
+connection con1;
+SLEEP(1)
+0
+0
+connection con0;
+SELECT a,b FROM t1;
+a b
+1 f
+2 b
+3 z
+disconnect con1;
+disconnect con2;
+disconnect con0;
+connection default;
+SET GLOBAL low_priority_updates = @low_prio_updates;
+SET GLOBAL concurrent_insert = @concur_insert;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/insert_high_prio.test b/mysql-test/suite/storage_engine/insert_high_prio.test
new file mode 100644
index 00000000..7b67a90b
--- /dev/null
+++ b/mysql-test/suite/storage_engine/insert_high_prio.test
@@ -0,0 +1,141 @@
+#
+# INSERT HIGH_PRIOIRITY
+#
+--source have_engine.inc
+
+--source include/count_sessions.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# We will be changing the GLOBAL value of low_priority_updates
+# due to bug#64892
+# (Session-level low_priority_updates does not work for INSERT)
+SET @low_prio_updates = @@global.low_priority_updates;
+
+# Concurrent insert might interfere
+# with HIGH|LOW_PRIORITY logic
+SET @concur_insert = @@global.concurrent_insert;
+SET GLOBAL concurrent_insert = NEVER;
+
+# We will have 3 connections:
+# con1 will start SELECT which should give us enough time;
+# con0 will run INSERT
+# con2 will then start another SELECT.
+# With standard INSERT and low_priority_updates=1
+# we should see only old rows in both resultsets,
+# while with INSERT HIGH_PRIORITY we should see new rows in con2 resultset.
+
+--connect (con0,localhost,root,,)
+SET lock_wait_timeout = 4;
+--connect (con1,localhost,root,,)
+SET lock_wait_timeout = 4;
+--connect (con2,localhost,root,,)
+SET lock_wait_timeout = 4;
+
+
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
+
+# Normal INSERT with low_priority_updates=1
+# should work like INSERT LOW_PRIORITY
+
+SET GLOBAL LOW_PRIORITY_UPDATES = 1;
+
+--connection con1
+--send
+SELECT SLEEP(1) FROM t1;
+
+--connection con0
+let $show_statement = SHOW PROCESSLIST;
+let $field = State;
+let $condition = = 'User sleep';
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+--send
+INSERT INTO t1 (a,b) VALUES (3,'z');
+
+--connection con2
+let $condition = = 'Waiting for table level lock';
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+if (!$found)
+{
+ --let $mysql_errname = timeout in wait_show_condition.inc
+ --let $functionality = @@low_priority_updates or INSERT or table locking
+ --source unexpected_result.inc
+}
+if ($found)
+{
+ --echo # Should return only 2 rows
+ SELECT SLEEP(1) FROM t1;
+}
+
+--connection con1
+--reap
+
+--connection con0
+--reap
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
+
+# INSERT HIGH_PRIORITY should override low_priority_updates=1
+
+--connection con1
+--send
+SELECT SLEEP(1) FROM t1;
+
+--connection con0
+let $condition = = 'User sleep';
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+--send
+INSERT HIGH_PRIORITY INTO t1 (a,b) VALUES (3,'z');
+
+--connection con2
+let $condition = = 'Waiting for table level lock';
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+if (!$found)
+{
+ --let $mysql_errname = timeout in wait_show_condition.inc
+ --let $functionality = @@low_priority_updates or INSERT HIGH_PRIORITY or table locking
+ --source unexpected_result.inc
+}
+if ($found)
+{
+ --echo # Should return 3 rows
+ SELECT SLEEP(1) FROM t1;
+}
+
+--connection con1
+--reap
+
+--connection con0
+--reap
+--sorted_result
+SELECT a,b FROM t1;
+
+--disconnect con1
+--disconnect con2
+--disconnect con0
+let $wait_timeout = 30;
+
+--connection default
+
+SET GLOBAL low_priority_updates = @low_prio_updates;
+SET GLOBAL concurrent_insert = @concur_insert;
+
+# Cleanup
+DROP TABLE t1;
+
+--source include/wait_until_count_sessions.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/insert_low_prio.result b/mysql-test/suite/storage_engine/insert_low_prio.result
new file mode 100644
index 00000000..1a74a82e
--- /dev/null
+++ b/mysql-test/suite/storage_engine/insert_low_prio.result
@@ -0,0 +1,39 @@
+DROP TABLE IF EXISTS t1;
+SET @low_prio_updates = @@global.low_priority_updates;
+SET @concur_insert = @@global.concurrent_insert;
+SET GLOBAL concurrent_insert = NEVER;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
+connect con0,localhost,root,,;
+SET lock_wait_timeout = 4;
+connect con1,localhost,root,,;
+SET lock_wait_timeout = 4;
+connect con2,localhost,root,,;
+SET lock_wait_timeout = 4;
+connection con1;
+SELECT SLEEP(1) FROM t1;
+connection con0;
+INSERT LOW_PRIORITY INTO t1 (a,b) VALUES (3,'z');
+connection con2;
+# Should return only 2 rows
+SELECT SLEEP(1) FROM t1;
+SLEEP(1)
+0
+0
+connection con1;
+SLEEP(1)
+0
+0
+connection con0;
+SELECT a,b FROM t1;
+a b
+1 f
+2 b
+3 z
+disconnect con0;
+disconnect con1;
+disconnect con2;
+connection default;
+SET GLOBAL low_priority_updates = @low_prio_updates;
+SET GLOBAL concurrent_insert = @concur_insert;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/insert_low_prio.test b/mysql-test/suite/storage_engine/insert_low_prio.test
new file mode 100644
index 00000000..257b54a3
--- /dev/null
+++ b/mysql-test/suite/storage_engine/insert_low_prio.test
@@ -0,0 +1,93 @@
+#
+# INSERT LOW_PRIORITY
+#
+--source have_engine.inc
+
+--source include/count_sessions.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# We will be changing the GLOBAL value of low_priority_updates
+# due to bug#64892
+# (Session-level low_priority_updates does not work for INSERT)
+SET @low_prio_updates = @@global.low_priority_updates;
+
+# Concurrent insert might interfere
+# with HIGH|LOW_PRIORITY logic
+SET @concur_insert = @@global.concurrent_insert;
+SET GLOBAL concurrent_insert = NEVER;
+
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
+
+# We will have 3 connections:
+# con1 will start SELECT which should give us enough time;
+# con0 will run INSERT
+# con2 will then start another SELECT.
+# With INSERT LOW_PRIORITY we should see only old rows in both resultsets.
+
+--connect (con0,localhost,root,,)
+SET lock_wait_timeout = 4;
+--connect (con1,localhost,root,,)
+SET lock_wait_timeout = 4;
+--connect (con2,localhost,root,,)
+SET lock_wait_timeout = 4;
+
+--connection con1
+
+--send
+SELECT SLEEP(1) FROM t1;
+
+--connection con0
+let $show_statement = SHOW PROCESSLIST;
+let $field = State;
+let $condition = = 'User sleep';
+# We don't need to wait long,
+# thread should show up in the processlist right away
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+--send
+INSERT LOW_PRIORITY INTO t1 (a,b) VALUES (3,'z');
+
+--connection con2
+
+let $condition = = 'Waiting for table level lock';
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+if (!$found)
+{
+ --let $mysql_errname = timeout in wait_show_condition
+ --let $functionality = INSERT LOW_PRIORITY or table locking
+ --source unexpected_result.inc
+}
+if ($found)
+{
+ --echo # Should return only 2 rows
+ SELECT SLEEP(1) FROM t1;
+}
+
+--connection con1
+--reap
+
+--connection con0
+--reap
+--sorted_result
+SELECT a,b FROM t1;
+
+--disconnect con0
+--disconnect con1
+--disconnect con2
+--connection default
+
+SET GLOBAL low_priority_updates = @low_prio_updates;
+SET GLOBAL concurrent_insert = @concur_insert;
+
+# Cleanup
+DROP TABLE t1;
+
+--source include/wait_until_count_sessions.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/insert_with_keys.result b/mysql-test/suite/storage_engine/insert_with_keys.result
new file mode 100644
index 00000000..694c9139
--- /dev/null
+++ b/mysql-test/suite/storage_engine/insert_with_keys.result
@@ -0,0 +1,173 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, <CUSTOM_INDEX>(b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
+INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
+INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
+SELECT a,b FROM t1;
+a b
+0
+1 a
+1 a
+100 a
+12345 z
+2 b
+29 n
+3 a
+3 c
+30 m
+4 d
+5 e
+6 f
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, UNIQUE INDEX(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
+INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
+INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+ERROR 23000: Duplicate entry '1' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
+ERROR 23000: Duplicate entry '3' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+INSERT INTO t1 (a,b) VALUES (0,'');
+SELECT a,b FROM t1;
+a b
+0
+1 a
+100 a
+2 b
+29 n
+3 c
+30 m
+4 d
+5 e
+6 f
+INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+Warnings:
+Warning 1062 Duplicate entry '1' for key 'a'
+INSERT INTO t1 (a,b) VALUES (3,'a'),(4,'d') ON DUPLICATE KEY UPDATE a = a+10;
+SELECT a,b FROM t1;
+a b
+0
+1 a
+100 a
+12345 z
+13 c
+14 d
+2 b
+29 n
+30 m
+5 e
+6 f
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, UNIQUE INDEX(a,b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
+INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
+INSERT INTO t1 (a,b) VALUES (100,'b'), (2,'c');
+INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+ERROR 23000: Duplicate entry '1-a' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+SELECT a,b FROM t1;
+a b
+1 a
+100 a
+100 b
+2 b
+2 c
+29 n
+3 c
+30 m
+4 d
+5 e
+6 f
+INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+Warnings:
+Warning 1062 Duplicate entry '1-a' for key 'a'
+INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z') ON DUPLICATE KEY UPDATE a = a+VALUES(a);
+SELECT a,b FROM t1;
+a b
+100 a
+100 b
+2 a
+2 b
+2 c
+24690 z
+29 n
+3 c
+30 m
+4 d
+5 e
+6 f
+INSERT INTO t1 (a,b) VALUES (101,'x'),(101,'x');
+ERROR 23000: Duplicate entry '101-x' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN> PRIMARY KEY, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
+INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
+INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
+ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+INSERT INTO t1 (a,b) VALUES (0,'');
+SELECT a,b FROM t1;
+a b
+0
+1 a
+100 a
+2 b
+29 n
+3 c
+30 m
+4 d
+5 e
+6 f
+INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+Warnings:
+Warning 1062 Duplicate entry '1' for key 'PRIMARY'
+INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z') ON DUPLICATE KEY UPDATE b = CONCAT(b,b);
+SELECT a,b FROM t1;
+a b
+0
+1 aa
+100 a
+12345 zz
+2 b
+29 n
+3 c
+30 m
+4 d
+5 e
+6 f
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN> UNIQUE KEY, b <INT_COLUMN> UNIQUE KEY, c <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 VALUES(1,1,0);
+INSERT INTO t1 VALUES(2,3,0);
+INSERT INTO t1 VALUES(3,2,0);
+INSERT INTO t1 VALUES(1,1,0) ON DUPLICATE KEY UPDATE c=c+1;
+INSERT INTO t1 VALUES(2,3,0) ON DUPLICATE KEY UPDATE c=c+1;
+INSERT INTO t1 VALUES(3,2,0) ON DUPLICATE KEY UPDATE c=c+1;
+INSERT INTO t1 VALUES(2,5,0) ON DUPLICATE KEY UPDATE c=c+1;
+INSERT INTO t1 VALUES(3,5,0) ON DUPLICATE KEY UPDATE c=c+1;
+INSERT INTO t1 VALUES(5,3,0) ON DUPLICATE KEY UPDATE c=c+1;
+INSERT INTO t1 VALUES(6,2,0) ON DUPLICATE KEY UPDATE c=c+1;
+INSERT INTO t1 VALUES(1,3,0) ON DUPLICATE KEY UPDATE c=c+1;
+INSERT INTO t1 VALUES(2,2,0) ON DUPLICATE KEY UPDATE c=c+1;
+SELECT * FROM t1;
+a b c
+1 1 2
+2 3 4
+3 2 3
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/insert_with_keys.test b/mysql-test/suite/storage_engine/insert_with_keys.test
new file mode 100644
index 00000000..f6224640
--- /dev/null
+++ b/mysql-test/suite/storage_engine/insert_with_keys.test
@@ -0,0 +1,173 @@
+#
+# INSERT statements for tables with keys
+#
+--source have_engine.inc
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $create_definition = a $int_col, b $char_indexed_col, $default_index(b)
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Indexes on CHAR columns
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+ INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
+ INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+ INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
+ --sorted_result
+ SELECT a,b FROM t1;
+ DROP TABLE t1;
+}
+
+--let $create_definition = a $int_indexed_col, b $char_col, UNIQUE INDEX(a)
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Unique indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+ INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
+ INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+ --source check_errors.inc
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
+ --source check_errors.inc
+ INSERT INTO t1 (a,b) VALUES (0,'');
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+ if ($mysql_errname)
+ {
+ --source unexpected_result.inc
+ }
+ INSERT INTO t1 (a,b) VALUES (3,'a'),(4,'d') ON DUPLICATE KEY UPDATE a = a+10;
+ if ($mysql_errname)
+ {
+ --source unexpected_result.inc
+ }
+
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ DROP TABLE t1;
+}
+
+--let $create_definition = a $int_indexed_col, b $char_indexed_col, UNIQUE INDEX(a,b)
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Multi-part indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+ INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
+ INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
+ INSERT INTO t1 (a,b) VALUES (100,'b'), (2,'c');
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+ --source check_errors.inc
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z') ON DUPLICATE KEY UPDATE a = a+VALUES(a);
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ INSERT INTO t1 (a,b) VALUES (101,'x'),(101,'x');
+ --source check_errors.inc
+ DROP TABLE t1;
+}
+
+--let $create_definition = a $int_indexed_col PRIMARY KEY, b $char_col
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Primary keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+ INSERT INTO t1 (a,b) VALUES (100,'a'), (6,'f');
+ INSERT INTO t1 (a,b) VALUES (30,'m'),(29,'n');
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+ --source check_errors.inc
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ INSERT INTO t1 (a,b) VALUES (3,'a'),(0,'');
+ --source check_errors.inc
+ INSERT INTO t1 (a,b) VALUES (0,'');
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ INSERT IGNORE INTO t1 (a,b) VALUES (1,'a'),(12345,'z');
+ if ($mysql_errname)
+ {
+ --source unexpected_result.inc
+ }
+
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(12345,'z') ON DUPLICATE KEY UPDATE b = CONCAT(b,b);
+ if ($mysql_errname)
+ {
+ --source unexpected_result.inc
+ }
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ DROP TABLE t1;
+}
+
+--let $create_definition = a $int_indexed_col UNIQUE KEY, b $int_indexed_col UNIQUE KEY, c $int_col
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Multiple unique keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 VALUES(1,1,0);
+ INSERT INTO t1 VALUES(2,3,0);
+ INSERT INTO t1 VALUES(3,2,0);
+
+ INSERT INTO t1 VALUES(1,1,0) ON DUPLICATE KEY UPDATE c=c+1;
+ INSERT INTO t1 VALUES(2,3,0) ON DUPLICATE KEY UPDATE c=c+1;
+ INSERT INTO t1 VALUES(3,2,0) ON DUPLICATE KEY UPDATE c=c+1;
+
+ INSERT INTO t1 VALUES(2,5,0) ON DUPLICATE KEY UPDATE c=c+1;
+ INSERT INTO t1 VALUES(3,5,0) ON DUPLICATE KEY UPDATE c=c+1;
+ INSERT INTO t1 VALUES(5,3,0) ON DUPLICATE KEY UPDATE c=c+1;
+ INSERT INTO t1 VALUES(6,2,0) ON DUPLICATE KEY UPDATE c=c+1;
+ INSERT INTO t1 VALUES(1,3,0) ON DUPLICATE KEY UPDATE c=c+1;
+ INSERT INTO t1 VALUES(2,2,0) ON DUPLICATE KEY UPDATE c=c+1;
+
+ --sorted_result
+ SELECT * FROM t1;
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/loaddata.result b/mysql-test/suite/storage_engine/loaddata.result
new file mode 100644
index 00000000..2b25435f
--- /dev/null
+++ b/mysql-test/suite/storage_engine/loaddata.result
@@ -0,0 +1,88 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+LOAD DATA INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1
+FIELDS TERMINATED BY ',' (a,b);
+SELECT a,b FROM t1;
+a b
+1 foo
+2 bar
+3
+4 abc
+LOAD DATA LOCAL INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1
+CHARACTER SET utf8 COLUMNS TERMINATED BY ','
+ ESCAPED BY '/' (a,b);
+SELECT a,b FROM t1;
+a b
+1 foo
+1 foo
+2 bar
+2 bar
+3
+3
+4 abc
+4 abc
+LOAD DATA LOCAL INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1
+FIELDS TERMINATED BY ';'
+ (a) SET b='loaded';
+Warnings:
+Warning 1262 Row 1 was truncated; it contained more data than there were input columns
+Warning 1262 Row 2 was truncated; it contained more data than there were input columns
+Warning 1262 Row 3 was truncated; it contained more data than there were input columns
+SELECT a,b FROM t1;
+a b
+0 loaded
+1 foo
+1 foo
+102 loaded
+2 bar
+2 bar
+3
+3
+4 abc
+4 abc
+5 loaded
+LOAD DATA INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1
+FIELDS TERMINATED BY ';'
+ OPTIONALLY ENCLOSED BY ''''
+ LINES STARTING BY 'prefix:'
+IGNORE 2 LINES (a,b);
+Warnings:
+Warning 1262 Row 2 was truncated; it contained more data than there were input columns
+SELECT a,b FROM t1;
+a b
+0
+0 loaded
+1 foo
+1 foo
+100 foo
+102 loaded
+2 bar
+2 bar
+3
+3
+4 abc
+4 abc
+5 loaded
+7 test
+LOAD DATA INFILE '<DATADIR>/se_loaddata.dat' INTO TABLE t1;
+SELECT a,b FROM t1;
+a b
+0
+0 loaded
+1 foo
+1 foo
+1 foo
+100 foo
+102 loaded
+2 bar
+2 bar
+2 bar
+3
+3
+3
+4 abc
+4 abc
+4 abc
+5 loaded
+7 test
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/loaddata.test b/mysql-test/suite/storage_engine/loaddata.test
new file mode 100644
index 00000000..5a708626
--- /dev/null
+++ b/mysql-test/suite/storage_engine/loaddata.test
@@ -0,0 +1,104 @@
+#
+# Basic LOAD DATA statements
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--source create_table.inc
+
+let $datadir = `SELECT @@datadir`;
+
+--write_file $datadir/se_loaddata.dat
+1,foo,
+2,bar,
+3,,
+4,abc,
+EOF
+
+--replace_result $datadir <DATADIR>
+eval
+LOAD DATA INFILE '$datadir/se_loaddata.dat' INTO TABLE t1
+ FIELDS TERMINATED BY ',' (a,b);
+if ($mysql_errname)
+{
+ --source unexpected_result.inc
+ --remove_file $datadir/se_loaddata.dat
+}
+if (!$mysql_errname)
+{
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ --replace_result $datadir <DATADIR>
+ eval
+ LOAD DATA LOCAL INFILE '$datadir/se_loaddata.dat' INTO TABLE t1
+ CHARACTER SET utf8 COLUMNS TERMINATED BY ','
+ ESCAPED BY '/' (a,b);
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ --remove_file $datadir/se_loaddata.dat
+ --write_file $datadir/se_loaddata.dat
+5;YYY;
+102;'zzz';
+0;'test';
+EOF
+
+ --replace_result $datadir <DATADIR>
+ eval
+ LOAD DATA LOCAL INFILE '$datadir/se_loaddata.dat' INTO TABLE t1
+ FIELDS TERMINATED BY ';'
+ (a) SET b='loaded';
+
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ --remove_file $datadir/se_loaddata.dat
+ --write_file $datadir/se_loaddata.dat
+prefix:5;'foo';
+prefix:6;'';
+prefix:100;foo;
+prefix:7;'test';suffix
+101;abc;
+102;'z';
+prefix:0;;
+EOF
+
+ --replace_result $datadir <DATADIR>
+ eval
+ LOAD DATA INFILE '$datadir/se_loaddata.dat' INTO TABLE t1
+ FIELDS TERMINATED BY ';'
+ OPTIONALLY ENCLOSED BY ''''
+ LINES STARTING BY 'prefix:'
+ IGNORE 2 LINES (a,b);
+
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ --remove_file $datadir/se_loaddata.dat
+ --write_file $datadir/se_loaddata.dat
+1 foo
+2 bar
+3
+4 abc
+EOF
+
+ --replace_result $datadir <DATADIR>
+ eval
+ LOAD DATA INFILE '$datadir/se_loaddata.dat' INTO TABLE t1;
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ --remove_file $datadir/se_loaddata.dat
+
+}
+
+# Cleanup
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/lock.result b/mysql-test/suite/storage_engine/lock.result
new file mode 100644
index 00000000..f20548da
--- /dev/null
+++ b/mysql-test/suite/storage_engine/lock.result
@@ -0,0 +1,111 @@
+connect con1,localhost,root,,;
+SET lock_wait_timeout=1;
+connection default;
+DROP TABLE IF EXISTS t1, t2, t3;
+CREATE TABLE t1 (id <INT_COLUMN>, id2 <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (id,id2) VALUES (1,1),(1,2),(1,3);
+LOCK TABLE t1 LOW_PRIORITY WRITE;
+SELECT id2,COUNT(DISTINCT id) FROM t1 GROUP BY id2;
+id2 COUNT(DISTINCT id)
+1 1
+2 1
+3 1
+UPDATE t1 SET id=-1 WHERE id=1;
+connection con1;
+SELECT id,id2 FROM t1;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+LOCK TABLE t1 READ;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection default;
+LOCK TABLE t1 READ;
+UPDATE t1 SET id=1 WHERE id=1;
+ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
+connection con1;
+SELECT COUNT(DISTINCT id) FROM t1;
+COUNT(DISTINCT id)
+1
+UPDATE t1 SET id=2 WHERE id=2;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+LOCK TABLE t1 WRITE;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+LOCK TABLE t1 READ;
+UNLOCK TABLES;
+connection default;
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ERROR HY000: Table 't2' was not locked with LOCK TABLES
+CREATE TEMPORARY TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+DROP TABLE IF EXISTS t2;
+UNLOCK TABLES;
+CREATE TABLE t2 (id <INT_COLUMN>, id2 <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+LOCK TABLE t1 WRITE, t2 WRITE;
+INSERT INTO t2 (id,id2) SELECT id,id2 FROM t1;
+UPDATE t1 SET id=1 WHERE id=-1;
+DROP TABLE t1,t2;
+CREATE TABLE t1 (i1 <INT_COLUMN>, nr <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE t2 (nr <INT_COLUMN>, nm <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t2 (nr,nm) VALUES (1,3);
+INSERT INTO t2 (nr,nm) VALUES (2,4);
+lock tables t1 write, t2 read;
+INSERT INTO t1 (i1,nr) SELECT 1, nr FROM t2 WHERE nm=3;
+INSERT INTO t1 (i1,nr) SELECT 2, nr FROM t2 WHERE nm=4;
+UNLOCK TABLES;
+LOCK TABLES t1 WRITE;
+INSERT INTO t1 (i1,nr) SELECT i1, nr FROM t1;
+ERROR HY000: Table 't1' was not locked with LOCK TABLES
+UNLOCK TABLES;
+LOCK TABLES t1 WRITE, t1 AS t1_alias READ;
+INSERT INTO t1 (i1,nr) SELECT i1, nr FROM t1 AS t1_alias;
+DROP TABLE t1,t2;
+ERROR HY000: Table 't2' was not locked with LOCK TABLES
+UNLOCK TABLES;
+DROP TABLE t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE t3 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE;
+DROP TABLE t2, t3, t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE t3 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE, t1 AS t4 READ;
+ALTER TABLE t2 ADD COLUMN c2 <INT_COLUMN>;
+DROP TABLE t1, t2, t3;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+LOCK TABLE t1 READ, t2 READ;
+FLUSH TABLE t1;
+ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
+FLUSH TABLES;
+ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
+FLUSH TABLES t1, t2 WITH READ LOCK;
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
+UNLOCK TABLES;
+FLUSH TABLES t1, t2 WITH READ LOCK;
+connection con1;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection default;
+UNLOCK TABLES;
+FLUSH TABLES WITH READ LOCK;
+connection con1;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection default;
+UNLOCK TABLES;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+FLUSH TABLES WITH READ LOCK AND DISABLE CHECKPOINT;
+DROP TABLE t1, t2;
+ERROR HY000: Can't execute the query because you have a conflicting read lock
+UNLOCK TABLES;
+DROP TABLE t1, t2;
+disconnect con1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+LOCK TABLE t1 WRITE, t2 WRITE;
+CREATE TEMPORARY TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+FLUSH TABLE t1;
+DROP TEMPORARY TABLE t1;
+SELECT a,b FROM t1;
+a b
+UNLOCK TABLES;
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/storage_engine/lock.test b/mysql-test/suite/storage_engine/lock.test
new file mode 100644
index 00000000..2ee77ad9
--- /dev/null
+++ b/mysql-test/suite/storage_engine/lock.test
@@ -0,0 +1,242 @@
+# Standard table locking:
+# LOCK TABLE .. READ
+# LOCK TABLE .. [LOW_PRIORITY] WRITE
+# UNLOCK TABLES
+#
+# and global locking:
+# FLUSH TABLES [..] WITH READ LOCK
+#
+#
+--source have_engine.inc
+
+# Save the initial number of concurrent sessions.
+--source include/count_sessions.inc
+
+connect (con1,localhost,root,,);
+SET lock_wait_timeout=1;
+
+connection default;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, t3;
+--enable_warnings
+
+--let $create_definition = id $int_col, id2 $int_col
+--source create_table.inc
+
+INSERT INTO t1 (id,id2) VALUES (1,1),(1,2),(1,3);
+
+# LOW_PRIORITY has no effect, but is still syntactically correct
+LOCK TABLE t1 LOW_PRIORITY WRITE;
+SELECT id2,COUNT(DISTINCT id) FROM t1 GROUP BY id2;
+
+UPDATE t1 SET id=-1 WHERE id=1;
+if ($mysql_errname)
+{
+ --let $functionality = UPDATE
+ --source unexpected_result.inc
+}
+
+connection con1;
+# With WRITE lock held by connection 'default',
+# nobody else can access the table
+--let $error_codes = ER_LOCK_WAIT_TIMEOUT
+SELECT id,id2 FROM t1;
+--source check_errors.inc
+--let $error_codes = ER_LOCK_WAIT_TIMEOUT
+LOCK TABLE t1 READ;
+--source check_errors.inc
+
+connection default;
+LOCK TABLE t1 READ;
+--let $error_codes = ER_TABLE_NOT_LOCKED_FOR_WRITE
+UPDATE t1 SET id=1 WHERE id=1;
+--source check_errors.inc
+if ($mysql_errname != ER_TABLE_NOT_LOCKED_FOR_WRITE)
+{
+ --let $functonality = UPDATE or locking
+ --source unexpected_result.inc
+}
+
+connection con1;
+# With READ lock held by connection 'default',
+# it should be possible to read from the table
+# or acquire another READ lock,
+# but not update it or acquire WRITE lock
+SELECT COUNT(DISTINCT id) FROM t1;
+--let $error_codes = ER_LOCK_WAIT_TIMEOUT
+UPDATE t1 SET id=2 WHERE id=2;
+--source check_errors.inc
+--let $error_codes = ER_LOCK_WAIT_TIMEOUT
+LOCK TABLE t1 WRITE;
+--source check_errors.inc
+LOCK TABLE t1 READ;
+UNLOCK TABLES;
+
+
+--connection default
+
+--let $error_codes = ER_TABLE_NOT_LOCKED
+--let $table_name = t2
+--source create_table.inc
+
+--let $table_name = t2
+--let $temporary = 1
+--source create_table.inc
+
+DROP TABLE IF EXISTS t2;
+
+UNLOCK TABLES;
+
+--let $table_name = t2
+--let $create_definition = id $int_col, id2 $int_col
+--source create_table.inc
+LOCK TABLE t1 WRITE, t2 WRITE;
+INSERT INTO t2 (id,id2) SELECT id,id2 FROM t1;
+UPDATE t1 SET id=1 WHERE id=-1;
+if ($mysql_errname)
+{
+ --let $functionality = UPDATE
+ --source unexpected_result.inc
+}
+DROP TABLE t1,t2;
+
+#
+# INSERT ... SELECT with lock tables
+#
+
+--let $create_definition = i1 $int_col, nr $int_col
+--source create_table.inc
+
+--let $table_name = t2
+--let $create_definition = nr $int_col, nm $int_col
+--source create_table.inc
+
+INSERT INTO t2 (nr,nm) VALUES (1,3);
+INSERT INTO t2 (nr,nm) VALUES (2,4);
+
+lock tables t1 write, t2 read;
+INSERT INTO t1 (i1,nr) SELECT 1, nr FROM t2 WHERE nm=3;
+INSERT INTO t1 (i1,nr) SELECT 2, nr FROM t2 WHERE nm=4;
+UNLOCK TABLES;
+
+LOCK TABLES t1 WRITE;
+--let $error_codes = ER_TABLE_NOT_LOCKED
+INSERT INTO t1 (i1,nr) SELECT i1, nr FROM t1;
+--source check_errors.inc
+UNLOCK TABLES;
+LOCK TABLES t1 WRITE, t1 AS t1_alias READ;
+INSERT INTO t1 (i1,nr) SELECT i1, nr FROM t1 AS t1_alias;
+--let $error_codes = ER_TABLE_NOT_LOCKED
+DROP TABLE t1,t2;
+--source check_errors.inc
+UNLOCK TABLES;
+DROP TABLE t1,t2;
+
+#
+# Check that a dropped table is removed from a lock
+
+--source create_table.inc
+--let $table_name = t2
+--source create_table.inc
+--let $table_name = t3
+--source create_table.inc
+LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE;
+# This removes one table after the other from the lock.
+DROP TABLE t2, t3, t1;
+#
+# Check that a lock merge works
+--source create_table.inc
+--let $table_name = t2
+--source create_table.inc
+--let $table_name = t3
+--source create_table.inc
+LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE, t1 AS t4 READ;
+
+--let $alter_definition = ADD COLUMN c2 $int_col
+--let $table_name = t2
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+
+DROP TABLE t1, t2, t3;
+
+# FLUSH TABLES is not permitted when there is an active LOCK TABLES .. READ,
+# FLUSH TABLES .. WITH READ LOCK should be used instead
+# (and for other connections the table is locked)
+
+--source create_table.inc
+--let $table_name = t2
+--source create_table.inc
+
+LOCK TABLE t1 READ, t2 READ;
+--let $error_codes = ER_TABLE_NOT_LOCKED_FOR_WRITE
+FLUSH TABLE t1;
+--source check_errors.inc
+--let $error_codes = ER_TABLE_NOT_LOCKED_FOR_WRITE
+FLUSH TABLES;
+--source check_errors.inc
+--let $error_codes = ER_LOCK_OR_ACTIVE_TRANSACTION
+FLUSH TABLES t1, t2 WITH READ LOCK;
+--source check_errors.inc
+UNLOCK TABLES;
+
+FLUSH TABLES t1, t2 WITH READ LOCK;
+
+--connection con1
+--let $error_codes = ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+--source check_errors.inc
+
+--connection default
+UNLOCK TABLES;
+
+# Global lock
+
+FLUSH TABLES WITH READ LOCK;
+
+--connection con1
+--let $error_codes = ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+--source check_errors.inc
+
+--connection default
+UNLOCK TABLES;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+FLUSH TABLES WITH READ LOCK AND DISABLE CHECKPOINT;
+--let $error_codes = ER_CANT_UPDATE_WITH_READLOCK
+DROP TABLE t1, t2;
+--source check_errors.inc
+UNLOCK TABLES;
+DROP TABLE t1, t2;
+
+--disconnect con1
+
+#
+# Ensure that FLUSH TABLES doesn't substitute a base locked table
+# with a temporary one.
+#
+
+--source create_table.inc
+--let $table_name = t2
+--source create_table.inc
+LOCK TABLE t1 WRITE, t2 WRITE;
+
+--let $temporary = 1
+--source create_table.inc
+FLUSH TABLE t1;
+DROP TEMPORARY TABLE t1;
+SELECT a,b FROM t1;
+UNLOCK TABLES;
+DROP TABLE t1, t2;
+
+# Check that all connections opened by test cases in this file are really
+# gone so execution of other tests won't be affected by their presence.
+--source include/wait_until_count_sessions.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/lock_concurrent.result b/mysql-test/suite/storage_engine/lock_concurrent.result
new file mode 100644
index 00000000..9b1a1a2d
--- /dev/null
+++ b/mysql-test/suite/storage_engine/lock_concurrent.result
@@ -0,0 +1,19 @@
+SET lock_wait_timeout = 1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+LOCK TABLES t1 WRITE CONCURRENT, t1 AS t2 READ;
+connect con1,localhost,root,,;
+SET lock_wait_timeout = 1;
+LOCK TABLES t1 READ LOCAL;
+UNLOCK TABLES;
+connection default;
+UNLOCK TABLES;
+connection con1;
+LOCK TABLES t1 READ LOCAL;
+connection default;
+LOCK TABLES t1 WRITE CONCURRENT, t1 AS t2 READ;
+UNLOCK TABLES;
+connection con1;
+UNLOCK TABLES;
+disconnect con1;
+connection default;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/lock_concurrent.test b/mysql-test/suite/storage_engine/lock_concurrent.test
new file mode 100644
index 00000000..b75ccf0d
--- /dev/null
+++ b/mysql-test/suite/storage_engine/lock_concurrent.test
@@ -0,0 +1,52 @@
+#
+# READ LOCAL / WRITE CONCURRENT locks.
+# This test is separate from the main lock.test
+# because the feature is likely to be unsupported.
+#
+
+--source have_engine.inc
+
+--source include/count_sessions.inc
+
+SET lock_wait_timeout = 1;
+
+--let $create_definition = a $int_col
+--source create_table.inc
+
+LOCK TABLES t1 WRITE CONCURRENT, t1 AS t2 READ;
+
+connect (con1,localhost,root,,);
+SET lock_wait_timeout = 1;
+
+# If this statement fails with ER_LOCK_WAIT_TIMEOUT,
+# most likely the engine does not support LOCK .. WRITE CONCURRENT
+LOCK TABLES t1 READ LOCAL;
+if ($mysql_errname)
+{
+ --let $functionality = LOCK .. WRITE CONCURRENT
+ --source unexpected_result.inc
+}
+
+UNLOCK TABLES;
+
+connection default;
+UNLOCK TABLES;
+
+connection con1;
+LOCK TABLES t1 READ LOCAL;
+
+connection default;
+LOCK TABLES t1 WRITE CONCURRENT, t1 AS t2 READ;
+UNLOCK TABLES;
+
+connection con1;
+UNLOCK TABLES;
+disconnect con1;
+
+connection default;
+DROP TABLE t1;
+
+--source include/wait_until_count_sessions.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/mask_engine.inc b/mysql-test/suite/storage_engine/mask_engine.inc
new file mode 100644
index 00000000..3c00af39
--- /dev/null
+++ b/mysql-test/suite/storage_engine/mask_engine.inc
@@ -0,0 +1,14 @@
+#
+# This include file just replaces the storage engine under test by the generic string <STORAGE_ENGINE>
+# in the next statement. More masks can be added by defining $add_regex, e.g.
+# let $add_regex = /$data_dir/<DATA_DIR>/ /$index_dir/<INDEX_DIR>/
+#
+
+--let $regex = /$storage_engine/<STORAGE_ENGINE>/i
+if ($add_regex)
+{
+ --let $regex = $regex $add_regex
+}
+--let $add_regex =
+--replace_regex $regex
+
diff --git a/mysql-test/suite/storage_engine/misc.result b/mysql-test/suite/storage_engine/misc.result
new file mode 100644
index 00000000..43d6a131
--- /dev/null
+++ b/mysql-test/suite/storage_engine/misc.result
@@ -0,0 +1,100 @@
+INSERT INTO mysql.event (
+db,
+name,
+body,
+definer,
+interval_value,
+interval_field,
+originator,
+character_set_client,
+collation_connection,
+db_collation,
+body_utf8)
+values (
+database(),
+"ev1",
+"select 1",
+user(),
+100,
+"SECOND_MICROSECOND",
+1,
+'utf8',
+'utf8_general_ci',
+'utf8_general_ci',
+'select 1');
+SHOW EVENTS;
+ERROR 42000: This version of MariaDB doesn't yet support 'MICROSECOND'
+DROP EVENT ev1;
+SELECT TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
+FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE ORDER BY TABLE_NAME;
+TABLE_NAME COLUMN_NAME REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
+column_stats column_name NULL NULL
+column_stats db_name NULL NULL
+column_stats table_name NULL NULL
+columns_priv Column_name NULL NULL
+columns_priv Db NULL NULL
+columns_priv Host NULL NULL
+columns_priv Table_name NULL NULL
+columns_priv User NULL NULL
+db Db NULL NULL
+db Host NULL NULL
+db User NULL NULL
+event db NULL NULL
+event name NULL NULL
+func name NULL NULL
+gtid_slave_pos domain_id NULL NULL
+gtid_slave_pos sub_id NULL NULL
+help_category help_category_id NULL NULL
+help_category name NULL NULL
+help_keyword help_keyword_id NULL NULL
+help_keyword name NULL NULL
+help_relation help_keyword_id NULL NULL
+help_relation help_topic_id NULL NULL
+help_topic help_topic_id NULL NULL
+help_topic name NULL NULL
+host Db NULL NULL
+host Host NULL NULL
+index_stats db_name NULL NULL
+index_stats index_name NULL NULL
+index_stats prefix_arity NULL NULL
+index_stats table_name NULL NULL
+innodb_index_stats database_name NULL NULL
+innodb_index_stats index_name NULL NULL
+innodb_index_stats stat_name NULL NULL
+innodb_index_stats table_name NULL NULL
+innodb_table_stats database_name NULL NULL
+innodb_table_stats table_name NULL NULL
+plugin name NULL NULL
+proc db NULL NULL
+proc name NULL NULL
+proc type NULL NULL
+procs_priv Db NULL NULL
+procs_priv Host NULL NULL
+procs_priv Routine_name NULL NULL
+procs_priv Routine_type NULL NULL
+procs_priv User NULL NULL
+proxies_priv Host NULL NULL
+proxies_priv Proxied_host NULL NULL
+proxies_priv Proxied_user NULL NULL
+proxies_priv User NULL NULL
+roles_mapping Host NULL NULL
+roles_mapping Role NULL NULL
+roles_mapping User NULL NULL
+servers Server_name NULL NULL
+table_stats db_name NULL NULL
+table_stats table_name NULL NULL
+tables_priv Db NULL NULL
+tables_priv Host NULL NULL
+tables_priv Table_name NULL NULL
+tables_priv User NULL NULL
+time_zone Time_zone_id NULL NULL
+time_zone_leap_second Transition_time NULL NULL
+time_zone_name Name NULL NULL
+time_zone_transition Time_zone_id NULL NULL
+time_zone_transition Transition_time NULL NULL
+time_zone_transition_type Time_zone_id NULL NULL
+time_zone_transition_type Transition_type_id NULL NULL
+transaction_registry commit_id NULL NULL
+transaction_registry transaction_id NULL NULL
+user Host NULL NULL
+user User NULL NULL
diff --git a/mysql-test/suite/storage_engine/misc.test b/mysql-test/suite/storage_engine/misc.test
new file mode 100644
index 00000000..9357ea57
--- /dev/null
+++ b/mysql-test/suite/storage_engine/misc.test
@@ -0,0 +1,47 @@
+#
+# Different statements not related to an engine,
+# but added to provide function coverage for handler.cc and handler.h.
+# The test can be disabled or removed later.
+#
+
+# hits get_error_message(int, String*)
+
+--source have_engine.inc
+
+INSERT INTO mysql.event (
+ db,
+ name,
+ body,
+ definer,
+ interval_value,
+ interval_field,
+ originator,
+ character_set_client,
+ collation_connection,
+ db_collation,
+ body_utf8)
+values (
+ database(),
+ "ev1",
+ "select 1",
+ user(),
+ 100,
+ "SECOND_MICROSECOND",
+ 1,
+ 'utf8',
+ 'utf8_general_ci',
+ 'utf8_general_ci',
+ 'select 1');
+
+--let $error_codes = ER_NOT_SUPPORTED_YET
+SHOW EVENTS;
+--source check_errors.inc
+DROP EVENT ev1;
+
+# hits get_foreign_key_list(THD*, List<st_foreign_key_info>*)
+--sorted_result
+SELECT TABLE_NAME, COLUMN_NAME, REFERENCED_TABLE_NAME, REFERENCED_COLUMN_NAME
+FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE ORDER BY TABLE_NAME;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/my.cnf b/mysql-test/suite/storage_engine/my.cnf
new file mode 100644
index 00000000..dd1d0b49
--- /dev/null
+++ b/mysql-test/suite/storage_engine/my.cnf
@@ -0,0 +1,8 @@
+!include include/default_my.cnf
+
+[server]
+sql-mode=NO_ENGINE_SUBSTITUTION
+binlog-format=row
+log-bin=master-bin
+default-time-zone=UTC
+
diff --git a/mysql-test/suite/storage_engine/obfuscate.inc b/mysql-test/suite/storage_engine/obfuscate.inc
new file mode 100644
index 00000000..e1a8a5be
--- /dev/null
+++ b/mysql-test/suite/storage_engine/obfuscate.inc
@@ -0,0 +1,4 @@
+let $storage_engine_search_string = ENGINE=$storage_engine;
+
+--replace_result ' ' ' ' ' ,' ',' ' )' ')' '( ' '(' $default_tbl_opts <CUSTOM_TABLE_OPTIONS> $int_indexed_col <INT_COLUMN> $char_indexed_col <CHAR_COLUMN> $int_col <INT_COLUMN> $char_col <CHAR_COLUMN> $default_col_indexed_opts <CUSTOM_COL_OPTIONS> $default_col_opts <CUSTOM_COL_OPTIONS> $storage_engine_search_string ENGINE=<STORAGE_ENGINE> $storage_engine <STORAGE_ENGINE> $default_index <CUSTOM_INDEX>
+
diff --git a/mysql-test/suite/storage_engine/optimize_table.inc b/mysql-test/suite/storage_engine/optimize_table.inc
new file mode 100644
index 00000000..acf80de3
--- /dev/null
+++ b/mysql-test/suite/storage_engine/optimize_table.inc
@@ -0,0 +1,42 @@
+#
+# OPTIMIZE TABLE statements
+#
+# Note: the output is likely to be different for the engine under test,
+# in which case rdiff will be needed. Or, the output might say that
+# the storage engine does not support OPTIMIZE.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+--let $table_name = t2
+--source create_table.inc
+
+INSERT INTO t1 (a,b) VALUES (3,'c'),(4,'d');
+OPTIMIZE TABLE t1;
+INSERT INTO t2 (a,b) VALUES (4,'d');
+OPTIMIZE NO_WRITE_TO_BINLOG TABLE t2;
+INSERT INTO t2 (a,b) VALUES (5,'e');
+INSERT INTO t1 (a,b) VALUES (6,'f');
+OPTIMIZE LOCAL TABLE t1, t2;
+OPTIMIZE TABLE t1, t2;
+
+DROP TABLE t1, t2;
+
+# OPTIMIZE on a table with index
+
+--let $continue = 1
+--source have_default_index.inc
+if ($have_default_index)
+{
+ --let $create_definition = a $int_indexed_col, b $char_col, $default_index (a)
+ --source create_table.inc
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(100,'b'),(2,'c'),(3,'d');
+ OPTIMIZE TABLE t1;
+ DROP TABLE t1;
+}
+
+
diff --git a/mysql-test/suite/storage_engine/optimize_table.result b/mysql-test/suite/storage_engine/optimize_table.result
new file mode 100644
index 00000000..4bb0bd29
--- /dev/null
+++ b/mysql-test/suite/storage_engine/optimize_table.result
@@ -0,0 +1,29 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (3,'c'),(4,'d');
+OPTIMIZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+INSERT INTO t2 (a,b) VALUES (4,'d');
+OPTIMIZE NO_WRITE_TO_BINLOG TABLE t2;
+Table Op Msg_type Msg_text
+test.t2 optimize status OK
+INSERT INTO t2 (a,b) VALUES (5,'e');
+INSERT INTO t1 (a,b) VALUES (6,'f');
+OPTIMIZE LOCAL TABLE t1, t2;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+test.t2 optimize status OK
+OPTIMIZE TABLE t1, t2;
+Table Op Msg_type Msg_text
+test.t1 optimize status Table is already up to date
+test.t2 optimize status Table is already up to date
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, <CUSTOM_INDEX> (a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(100,'b'),(2,'c'),(3,'d');
+OPTIMIZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/optimize_table.test b/mysql-test/suite/storage_engine/optimize_table.test
new file mode 100644
index 00000000..a32a2c84
--- /dev/null
+++ b/mysql-test/suite/storage_engine/optimize_table.test
@@ -0,0 +1,14 @@
+#
+# OPTIMIZE TABLE statements
+#
+# Note: the output is likely to be different for the engine under test,
+# in which case rdiff will be needed. Or, the output might say that
+# the storage engine does not support OPTIMIZE.
+#
+
+--source have_engine.inc
+
+--source optimize_table.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/parts/alter_table.result b/mysql-test/suite/storage_engine/parts/alter_table.result
new file mode 100644
index 00000000..d94fd3d5
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/alter_table.result
@@ -0,0 +1,42 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a) VALUES (1),(2),(2),(3),(4);
+ALTER TABLE t1 ADD PARTITION PARTITIONS 2;
+EXPLAIN PARTiTIONS SELECT a FROM t1 WHERE a = 3;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p3 # # # # # # #
+ALTER TABLE t1 COALESCE PARTITION 1;
+EXPLAIN PARTiTIONS SELECT a FROM t1 WHERE a = 3;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p0 # # # # # # #
+ALTER TABLE t1 REORGANIZE PARTITION;
+EXPLAIN PARTiTIONS SELECT a FROM t1 WHERE a = 2;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p0 # # # # # # #
+ALTER TABLE t1 REBUILD PARTITION p0;
+EXPLAIN PARTiTIONS SELECT a FROM t1;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p0 # # # # # # #
+ALTER TABLE t1 REMOVE PARTITIONING;
+EXPLAIN PARTiTIONS SELECT a FROM t1;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 NULL # # # # # # #
+ALTER TABLE t1 PARTITION BY LIST(a) (PARTITION p0 VALUES IN (1,2,3), PARTITION p1 VALUES IN (101,102));
+ERROR HY000: Table has no partition for value 4
+ALTER TABLE t1 PARTITION BY LIST(a) (PARTITION p0 VALUES IN (1,2,3,4), PARTITION p1 VALUES IN (101,102));
+INSERT INTO t1 (a) VALUES (50);
+ERROR HY000: Table has no partition for value 50
+ALTER TABLE t1 ADD PARTITION (PARTITION p2 VALUES IN (50,51));
+INSERT INTO t1 (a) VALUES (50);
+ALTER TABLE t1 DROP PARTITION p1;
+ALTER TABLE t1 REORGANIZE PARTITION p0, p2 INTO (PARTITION p0 VALUES IN (1,2,3), PARTITION p1 VALUES IN (4), PARTITION p2 VALUES IN (50,51), PARTITION p3 VALUES IN (101,102));
+EXPLAIN PARTiTIONS SELECT a FROM t1 WHERE a = 2;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p0 # # # # # # #
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY LIST(a) SUBPARTITION by HASH(b) (
+PARTITION abc VALUES IN (1,2,3),
+PARTITION def VALUES IN (100,101,102)
+);
+ALTER TABLE t1 DROP PARTITION abc;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/parts/alter_table.test b/mysql-test/suite/storage_engine/parts/alter_table.test
new file mode 100644
index 00000000..48f1f3f7
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/alter_table.test
@@ -0,0 +1,107 @@
+#
+# Basic ALTER TABLE statements related to partitioning
+#
+
+--source include/have_partition.inc
+--source ../have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $create_definition = a $int_col
+--let $partition_options = PARTITION BY HASH(a) PARTITIONS 2
+--source ../create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Partitions
+ --source ../unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a) VALUES (1),(2),(2),(3),(4);
+
+ --let $alter_definition = ADD PARTITION PARTITIONS 2
+ --source ../alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source ../unexpected_result.inc
+ }
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTiTIONS SELECT a FROM t1 WHERE a = 3;
+
+ --let $alter_definition = COALESCE PARTITION 1
+ --source ../alter_table.inc
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTiTIONS SELECT a FROM t1 WHERE a = 3;
+
+ --let $alter_definition = REORGANIZE PARTITION
+ --source ../alter_table.inc
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTiTIONS SELECT a FROM t1 WHERE a = 2;
+
+ --let $alter_definition = REBUILD PARTITION p0
+ --source ../alter_table.inc
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTiTIONS SELECT a FROM t1;
+
+ --let $alter_definition = REMOVE PARTITIONING
+ --source ../alter_table.inc
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTiTIONS SELECT a FROM t1;
+
+ --let $error_codes = ER_NO_PARTITION_FOR_GIVEN_VALUE
+ --let $alter_definition = PARTITION BY LIST(a) ( PARTITION p0 VALUES IN (1,2,3), PARTITION p1 VALUES IN (101,102) )
+ --source ../alter_table.inc
+ if ($mysql_errname != ER_NO_PARTITION_FOR_GIVEN_VALUE)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $my_functionality = ALTER TABLE or INSERT
+ --source ../unexpected_result.inc
+ }
+
+ --let $alter_definition = PARTITION BY LIST(a) ( PARTITION p0 VALUES IN (1,2,3,4), PARTITION p1 VALUES IN (101,102) )
+ --source ../alter_table.inc
+
+ --let $error_codes = ER_NO_PARTITION_FOR_GIVEN_VALUE
+ INSERT INTO t1 (a) VALUES (50);
+ --source ../check_errors.inc
+ --let $alter_definition = ADD PARTITION ( PARTITION p2 VALUES IN (50,51) )
+ --source ../alter_table.inc
+ INSERT INTO t1 (a) VALUES (50);
+
+ --let $alter_definition = DROP PARTITION p1
+ --source ../alter_table.inc
+ --let $alter_definition = REORGANIZE PARTITION p0, p2 INTO ( PARTITION p0 VALUES IN (1,2,3), PARTITION p1 VALUES IN (4), PARTITION p2 VALUES IN (50,51), PARTITION p3 VALUES IN (101,102) )
+ --source ../alter_table.inc
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTiTIONS SELECT a FROM t1 WHERE a = 2;
+ DROP TABLE t1;
+}
+
+
+--let $create_definition = a $int_col, b $int_col
+let $partition_options = PARTITION BY LIST(a) SUBPARTITION by HASH(b) (
+ PARTITION abc VALUES IN (1,2,3),
+ PARTITION def VALUES IN (100,101,102)
+);
+--source ../create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Partitions or subpartitions
+ --source ../unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --let $alter_definition = DROP PARTITION abc
+ --source ../alter_table.inc
+
+ DROP TABLE t1;
+}
+
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/parts/analyze_table.result b/mysql-test/suite/storage_engine/parts/analyze_table.result
new file mode 100644
index 00000000..8cd210e4
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/analyze_table.result
@@ -0,0 +1,47 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(2,'d'),(4,'e'),(100,'f'),(101,'g');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t2 (a,b) SELECT a,b FROM t1;
+INSERT INTO t1 (a,b) VALUES (3,'c');
+ALTER TABLE t1 ANALYZE PARTITION p0;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+INSERT INTO t2 (a,b) VALUES (4,'d'), (1000,'e');
+ALTER TABLE t1 ANALYZE PARTITION LOCAL ALL;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+INSERT INTO t1 (a,b) VALUES (5,'f'),(50,'g');
+ALTER TABLE t1 ANALYZE PARTITION NO_WRITE_TO_BINLOG p1,p0;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+DROP TABLE t1, t2;
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a,b) VALUES (3,'c');
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+INSERT INTO t2 (a,b) VALUES (4,'d');
+ANALYZE NO_WRITE_TO_BINLOG TABLE t2;
+Table Op Msg_type Msg_text
+test.t2 analyze status OK
+INSERT INTO t1 (a,b) VALUES (5,'e');
+INSERT INTO t2 (a,b) VALUES (6,'f');
+ANALYZE LOCAL TABLE t1, t2;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+test.t2 analyze status OK
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a <INT_COLUMN>, <CUSTOM_INDEX>(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a) VALUES (1),(2),(4),(7);
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+INSERT INTO t1 (a) VALUES (8),(10),(11),(12);
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/parts/analyze_table.test b/mysql-test/suite/storage_engine/parts/analyze_table.test
new file mode 100644
index 00000000..2ff8fff1
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/analyze_table.test
@@ -0,0 +1,61 @@
+#
+# ANALYZE TABLE for partitioned tables and ANALYZE PARTITION
+#
+--source include/have_partition.inc
+--source ../have_engine.inc
+
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+--let $partition_options = PARTITION BY HASH(a) PARTITIONS 2
+--source ../create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Partitions
+ --source ../unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(2,'d'),(4,'e'),(100,'f'),(101,'g');
+ let $partiton_options = PARTITION BY RANGE(a) (
+ PARTITION p0 VALUES LESS THAN (100),
+ PARTITION p1 VALUES LESS THAN MAXVALUE
+ );
+ --let $table_name = t2
+ --source ../create_table.inc
+
+ INSERT INTO t2 (a,b) SELECT a,b FROM t1;
+
+ INSERT INTO t1 (a,b) VALUES (3,'c');
+
+ --let $alter_definition = ANALYZE PARTITION p0
+ --source ../alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE .. ANALYZE PARTITION
+ --source unexpected_result.inc
+ }
+
+ INSERT INTO t2 (a,b) VALUES (4,'d'), (1000,'e');
+
+ --let $alter_definition = ANALYZE PARTITION LOCAL ALL
+ --source ../alter_table.inc
+
+ INSERT INTO t1 (a,b) VALUES (5,'f'),(50,'g');
+
+ --let $alter_definition = ANALYZE PARTITION NO_WRITE_TO_BINLOG p1,p0
+ --source ../alter_table.inc
+
+ DROP TABLE t1, t2;
+}
+
+let $extra_tbl_opts = PARTITION BY HASH(a) PARTITIONS 2;
+--source ../analyze_table.inc
+let $extra_tbl_opts =;
+
+
+--source ../cleanup_engine.inc
diff --git a/mysql-test/suite/storage_engine/parts/check_table.result b/mysql-test/suite/storage_engine/parts/check_table.result
new file mode 100644
index 00000000..6bd8d68e
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/check_table.result
@@ -0,0 +1,104 @@
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(2,'d'),(4,'e'),(100,'f'),(101,'g');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY RANGE(a) (
+PARTITION p0 VALUES LESS THAN (100),
+PARTITION p1 VALUES LESS THAN MAXVALUE
+);
+INSERT INTO t2 (a,b) SELECT a, b FROM t1;
+ALTER TABLE t1 CHECK PARTITION p0;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a,b) VALUES (3,'c');
+ALTER TABLE t1 CHECK PARTITION p0, p1 FOR UPGRADE;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t2 (a,b) VALUES (10000,'e');
+ALTER TABLE t2 CHECK PARTITION p0 QUICK;
+Table Op Msg_type Msg_text
+test.t2 check status OK
+INSERT INTO t1 (a,b) VALUES (6,'f');
+ALTER TABLE t1 CHECK PARTITION p1 FAST;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t2 (a,b) VALUES (8,'h');
+ALTER TABLE t2 CHECK PARTITION p1 MEDIUM;
+Table Op Msg_type Msg_text
+test.t2 check status OK
+INSERT INTO t1 (a,b) VALUES (9,'i');
+ALTER TABLE t1 CHECK PARTITION ALL EXTENDED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a,b) VALUES (11,'k');
+ALTER TABLE t1 CHECK PARTITION p0 CHANGED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+DROP TABLE t1, t2;
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a,b) VALUES (3,'c');
+INSERT INTO t2 (a,b) VALUES (4,'d');
+CHECK TABLE t1, t2 FOR UPGRADE;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+test.t2 check status OK
+INSERT INTO t2 (a,b) VALUES (5,'e');
+CHECK TABLE t2 QUICK;
+Table Op Msg_type Msg_text
+test.t2 check status OK
+INSERT INTO t1 (a,b) VALUES (6,'f');
+CHECK TABLE t1 FAST;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a,b) VALUES (7,'g');
+INSERT INTO t2 (a,b) VALUES (8,'h');
+CHECK TABLE t2, t1 MEDIUM;
+Table Op Msg_type Msg_text
+test.t2 check status OK
+test.t1 check status OK
+INSERT INTO t1 (a,b) VALUES (9,'i');
+INSERT INTO t2 (a,b) VALUES (10,'j');
+CHECK TABLE t1, t2 EXTENDED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+test.t2 check status OK
+INSERT INTO t1 (a,b) VALUES (11,'k');
+CHECK TABLE t1 CHANGED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a <INT_COLUMN>, <CUSTOM_INDEX>(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a) VALUES (1),(2),(5);
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (6),(8),(12);
+CHECK TABLE t1 FOR UPGRADE;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (13),(15),(16);
+CHECK TABLE t1 QUICK;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (17),(120),(132);
+CHECK TABLE t1 FAST;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (801),(900),(7714);
+CHECK TABLE t1 MEDIUM;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (8760),(10023),(12000);
+CHECK TABLE t1 EXTENDED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+INSERT INTO t1 (a) VALUES (13345),(24456),(78302),(143028);
+CHECK TABLE t1 CHANGED;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/parts/check_table.test b/mysql-test/suite/storage_engine/parts/check_table.test
new file mode 100644
index 00000000..9a426203
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/check_table.test
@@ -0,0 +1,82 @@
+#
+# CHECK TABLE for partitioned tables and ANALYZE PARTITION
+#
+
+--source include/have_partition.inc
+--source ../have_engine.inc
+
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+--let $partition_options = PARTITION BY HASH(a) PARTITIONS 2
+--source ../create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Partitions
+ --source ../unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(2,'d'),(4,'e'),(100,'f'),(101,'g');
+
+ let $partition_options = PARTITION BY RANGE(a) (
+ PARTITION p0 VALUES LESS THAN (100),
+ PARTITION p1 VALUES LESS THAN MAXVALUE
+ );
+ --let $table_name = t2
+ --source ../create_table.inc
+
+ INSERT INTO t2 (a,b) SELECT a, b FROM t1;
+
+ let $alter_definition = CHECK PARTITION p0;
+ --source ../alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE .. CHECK PARTITION
+ --source ../unexpected_result.inc
+ }
+
+ INSERT INTO t1 (a,b) VALUES (3,'c');
+
+ let $alter_definition = CHECK PARTITION p0, p1 FOR UPGRADE;
+ --source ../alter_table.inc
+
+ INSERT INTO t2 (a,b) VALUES (10000,'e');
+
+ let $alter_definition = CHECK PARTITION p0 QUICK;
+ let $table_name = t2;
+ --source ../alter_table.inc
+
+ INSERT INTO t1 (a,b) VALUES (6,'f');
+
+ let $alter_definition = CHECK PARTITION p1 FAST;
+ --source ../alter_table.inc
+
+ INSERT INTO t2 (a,b) VALUES (8,'h');
+
+ let $alter_definition = CHECK PARTITION p1 MEDIUM;
+ let $table_name = t2;
+ --source ../alter_table.inc
+
+ INSERT INTO t1 (a,b) VALUES (9,'i');
+
+ let $alter_definition = CHECK PARTITION ALL EXTENDED;
+ --source ../alter_table.inc
+
+ INSERT INTO t1 (a,b) VALUES (11,'k');
+
+ let $alter_definition = CHECK PARTITION p0 CHANGED;
+ --source ../alter_table.inc
+
+ DROP TABLE t1, t2;
+}
+
+let $extra_tbl_opts = PARTITION BY HASH(a) PARTITIONS 2;
+--source ../check_table.inc
+
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/parts/checksum_table.result b/mysql-test/suite/storage_engine/parts/checksum_table.result
new file mode 100644
index 00000000..f084c426
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/checksum_table.result
@@ -0,0 +1,40 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHECKSUM=0 PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHECKSUM=0 PARTITION BY HASH(a) PARTITIONS 2;
+CHECKSUM TABLE t1;
+Table Checksum
+test.t1 4272806499
+CHECKSUM TABLE t2, t1;
+Table Checksum
+test.t2 0
+test.t1 4272806499
+CHECKSUM TABLE t1, t2 QUICK;
+Table Checksum
+test.t1 NULL
+test.t2 NULL
+CHECKSUM TABLE t1, t2 EXTENDED;
+Table Checksum
+test.t1 4272806499
+test.t2 0
+DROP TABLE t1, t2;
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHECKSUM=1 PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHECKSUM=1 PARTITION BY HASH(a) PARTITIONS 2;
+CHECKSUM TABLE t1;
+Table Checksum
+test.t1 4272806499
+CHECKSUM TABLE t2, t1;
+Table Checksum
+test.t2 0
+test.t1 4272806499
+CHECKSUM TABLE t1, t2 QUICK;
+Table Checksum
+test.t1 4272806499
+test.t2 0
+CHECKSUM TABLE t1, t2 EXTENDED;
+Table Checksum
+test.t1 4272806499
+test.t2 0
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/storage_engine/parts/checksum_table.test b/mysql-test/suite/storage_engine/parts/checksum_table.test
new file mode 100644
index 00000000..eff70e3c
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/checksum_table.test
@@ -0,0 +1,13 @@
+#
+# CHECKSUM TABLE for partitioned tables
+#
+
+--source include/have_partition.inc
+--source ../have_engine.inc
+
+let $extra_tbl_opts = PARTITION BY HASH(a) PARTITIONS 2;
+--source ../checksum_table.inc
+--source ../checksum_table_live.inc
+
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/parts/create_table.result b/mysql-test/suite/storage_engine/parts/create_table.result
new file mode 100644
index 00000000..945ed231
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/create_table.result
@@ -0,0 +1,91 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a) VALUES (1),(2),(3),(2);
+EXPLAIN PARTITIONS SELECT a FROM t1;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p0,p1 # # # # # # #
+EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a=2;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p0 # # # # # # #
+DROP TABLE t1;
+CREATE TABLE t1 (a <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY KEY(a) PARTITIONS 2;
+INSERT INTO t1 (a) VALUES ('a'),('b'),('c');
+EXPLAIN PARTITIONS SELECT a FROM t1;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p0,p1 # # # # # # #
+EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a = 'b';
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p1 # # # # # # #
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, <CUSTOM_INDEX> (a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY KEY(a) PARTITIONS 2;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a 1 a # # NULL NULL # #
+INSERT INTO t1 (a) VALUES (1),(2),(3),(5);
+EXPLAIN PARTITIONS SELECT a FROM t1;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p0,p1 # # # # # # #
+EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a IN (1,3);
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p0 # # # # # # #
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN> PRIMARY KEY) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY KEY() PARTITIONS 2;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 PRIMARY 1 a # # NULL NULL # #
+INSERT INTO t1 (a) VALUES (1),(200),(3),(2);
+EXPLAIN PARTITIONS SELECT a FROM t1;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p0,p1 # # # # # # #
+EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a=2;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p1 # # # # # # #
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY RANGE(a) (
+PARTITION p0 VALUES LESS THAN (10),
+PARTITION p1 VALUES LESS THAN (1000)
+);
+INSERT INTO t1 (a) VALUES (1),(2),(400);
+EXPLAIN PARTITIONS SELECT a FROM t1;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p0,p1 # # # # # # #
+EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a = 2;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p0 # # # # # # #
+INSERT INTO t1 (a) VALUES (10000);
+ERROR HY000: Table has no partition for value 10000
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY LIST(a) (
+PARTITION abc VALUES IN (1,2,3),
+PARTITION def VALUES IN (100,101,102)
+);
+INSERT INTO t1 (a) VALUES (1),(101),(1);
+EXPLAIN PARTITIONS SELECT a FROM t1;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 abc,def # # # # # # #
+EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a = 100;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL # # # # # # #
+INSERT INTO t1 (a) VALUES (50);
+ERROR HY000: Table has no partition for value 50
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY LIST(a) SUBPARTITION by HASH(b) (
+PARTITION abc VALUES IN (1,2,3),
+PARTITION def VALUES IN (100,101,102)
+);
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+INSERT INTO t1 (a,b) VALUES (1,1),(101,2),(1,3);
+EXPLAIN PARTITIONS SELECT a FROM t1;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 abc_abcsp0,def_defsp0 # # # # # # #
+EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a = 100;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL # # # # # # #
+SELECT TABLE_SCHEMA, TABLE_NAME, PARTITION_NAME, SUBPARTITION_NAME, PARTITION_METHOD, SUBPARTITION_METHOD
+FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 't1';
+TABLE_SCHEMA TABLE_NAME PARTITION_NAME SUBPARTITION_NAME PARTITION_METHOD SUBPARTITION_METHOD
+test t1 abc abcsp0 LIST HASH
+test t1 def defsp0 LIST HASH
+SELECT * FROM INFORMATION_SCHEMA.PARTITIONS;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/parts/create_table.test b/mysql-test/suite/storage_engine/parts/create_table.test
new file mode 100644
index 00000000..69ab51f7
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/create_table.test
@@ -0,0 +1,179 @@
+#
+# Basic CREATE TABLE .. PARTITION statements
+#
+
+--source include/have_partition.inc
+--source ../have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $create_definition = a $int_col;
+let $partition_options = PARTITION BY HASH(a) PARTITIONS 2;
+--source ../create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Partitions
+ --source ../unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a) VALUES (1),(2),(3),(2);
+ # We are only interested in partition information
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTITIONS SELECT a FROM t1;
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a=2;
+
+ DROP TABLE t1;
+}
+
+let $create_definition = a $char_col;
+let $partition_options = PARTITION BY KEY(a) PARTITIONS 2;
+--source ../create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Partitions or CHAR types
+ --source ../unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a) VALUES ('a'),('b'),('c');
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTITIONS SELECT a FROM t1;
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a = 'b';
+ DROP TABLE t1;
+}
+
+--let $continue = 1
+--source ../have_default_index.inc
+if ($have_default_index)
+{
+ let $create_definition = a $int_indexed_col, $default_index (a);
+ let $partition_options = PARTITION BY KEY(a) PARTITIONS 2;
+ --source ../create_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Partitions or indexes
+ --source ../unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --source ../mask_engine.inc
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+ INSERT INTO t1 (a) VALUES (1),(2),(3),(5);
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTITIONS SELECT a FROM t1;
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a IN (1,3);
+ DROP TABLE t1;
+ }
+}
+
+let $create_definition = a $int_indexed_col PRIMARY KEY;
+let $partition_options = PARTITION BY KEY() PARTITIONS 2;
+--source ../create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = PK
+ --source ../unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (a) VALUES (1),(200),(3),(2);
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTITIONS SELECT a FROM t1;
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a=2;
+ DROP TABLE t1;
+}
+
+
+let $create_definition = a $int_col;
+let $partition_options = PARTITION BY RANGE(a) (
+ PARTITION p0 VALUES LESS THAN (10),
+ PARTITION p1 VALUES LESS THAN (1000)
+);
+--source ../create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Partitions
+ --source ../unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a) VALUES (1),(2),(400);
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTITIONS SELECT a FROM t1;
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a = 2;
+
+ --let $error_codes = ER_NO_PARTITION_FOR_GIVEN_VALUE
+ INSERT INTO t1 (a) VALUES (10000);
+ --source ../check_errors.inc
+ DROP TABLE t1;
+
+ let $create_definition = a $int_col;
+ let $partition_options = PARTITION BY LIST(a) (
+ PARTITION abc VALUES IN (1,2,3),
+ PARTITION def VALUES IN (100,101,102)
+ );
+ --source ../create_table.inc
+
+ INSERT INTO t1 (a) VALUES (1),(101),(1);
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTITIONS SELECT a FROM t1;
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a = 100;
+ --let $error_codes = ER_NO_PARTITION_FOR_GIVEN_VALUE
+ INSERT INTO t1 (a) VALUES (50);
+ --source ../check_errors.inc
+ DROP TABLE t1;
+}
+
+let $create_definition = a $int_col, b $int_col;
+let partition_options = PARTITION BY LIST(a) SUBPARTITION by HASH(b) (
+ PARTITION abc VALUES IN (1,2,3),
+ PARTITION def VALUES IN (100,101,102)
+);
+--source ../create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Partitions or subpartitions
+ --source ../unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (a,b) VALUES (1,1),(101,2),(1,3);
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTITIONS SELECT a FROM t1;
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 # 11 #
+ EXPLAIN PARTITIONS SELECT a FROM t1 WHERE a = 100;
+
+ --sorted_result
+ SELECT TABLE_SCHEMA, TABLE_NAME, PARTITION_NAME, SUBPARTITION_NAME, PARTITION_METHOD, SUBPARTITION_METHOD
+ FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_NAME = 't1';
+ # This is just to hit some more handler functions while we are here
+ --disable_result_log
+ SELECT * FROM INFORMATION_SCHEMA.PARTITIONS;
+ --enable_result_log
+
+ DROP TABLE t1;
+}
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/parts/my.cnf b/mysql-test/suite/storage_engine/parts/my.cnf
new file mode 100644
index 00000000..d6166310
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/my.cnf
@@ -0,0 +1,9 @@
+!include include/default_my.cnf
+
+[server]
+sql-mode=NO_ENGINE_SUBSTITUTION
+binlog-format=row
+log-bin=master-bin
+partition
+
+
diff --git a/mysql-test/suite/storage_engine/parts/optimize_table.result b/mysql-test/suite/storage_engine/parts/optimize_table.result
new file mode 100644
index 00000000..da165bc1
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/optimize_table.result
@@ -0,0 +1,54 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(2,'d'),(4,'e'),(100,'f'),(101,'g');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY RANGE(a) (
+PARTITION p0 VALUES LESS THAN (100),
+PARTITION p1 VALUES LESS THAN MAXVALUE
+);
+INSERT INTO t2 (a,b) SELECT a, b FROM t1;
+INSERT INTO t1 (a,b) VALUES (3,'c'),(4,'d');
+ALTER TABLE t1 OPTIMIZE PARTITION p1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+INSERT INTO t2 (a,b) VALUES (4,'d');
+ALTER TABLE t2 OPTIMIZE PARTITION p0 NO_WRITE_TO_BINLOG;
+Table Op Msg_type Msg_text
+test.t2 optimize status OK
+INSERT INTO t1 (a,b) VALUES (6,'f');
+ALTER TABLE t1 OPTIMIZE PARTITION ALL LOCAL;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+INSERT INTO t2 (a,b) VALUES (5,'e');
+ALTER TABLE t2 OPTIMIZE PARTITION p1,p0;
+Table Op Msg_type Msg_text
+test.t2 optimize status OK
+DROP TABLE t1, t2;
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a,b) VALUES (3,'c'),(4,'d');
+OPTIMIZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+INSERT INTO t2 (a,b) VALUES (4,'d');
+OPTIMIZE NO_WRITE_TO_BINLOG TABLE t2;
+Table Op Msg_type Msg_text
+test.t2 optimize status OK
+INSERT INTO t2 (a,b) VALUES (5,'e');
+INSERT INTO t1 (a,b) VALUES (6,'f');
+OPTIMIZE LOCAL TABLE t1, t2;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+test.t2 optimize status OK
+OPTIMIZE TABLE t1, t2;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+test.t2 optimize status OK
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, <CUSTOM_INDEX> (a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(100,'b'),(2,'c'),(3,'d');
+OPTIMIZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/parts/optimize_table.test b/mysql-test/suite/storage_engine/parts/optimize_table.test
new file mode 100644
index 00000000..8c136933
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/optimize_table.test
@@ -0,0 +1,69 @@
+#
+# OPTIMIZE TABLE with partitions and OPTIMIZE PARTITIONS
+#
+
+--source include/have_partition.inc
+--source ../have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+let $partition_options = PARTITION BY HASH(a) PARTITIONS 2;
+--source ../create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Partitions
+ --source ../unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(2,'d'),(4,'e'),(100,'f'),(101,'g');
+
+ let $table_name = t2;
+ let $partition_options = PARTITION BY RANGE(a) (
+ PARTITION p0 VALUES LESS THAN (100),
+ PARTITION p1 VALUES LESS THAN MAXVALUE
+ );
+ --source ../create_table.inc
+
+ INSERT INTO t2 (a,b) SELECT a, b FROM t1;
+
+ INSERT INTO t1 (a,b) VALUES (3,'c'),(4,'d');
+
+ let $alter_definition = OPTIMIZE PARTITION p1;
+ --source ../alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE .. OPTIMIZE PARTITION
+ --source ../unexpected_result.inc
+ }
+
+ INSERT INTO t2 (a,b) VALUES (4,'d');
+
+ let $table_name = t2;
+ let $alter_definition = OPTIMIZE PARTITION p0 NO_WRITE_TO_BINLOG;
+ --source ../alter_table.inc
+
+ INSERT INTO t1 (a,b) VALUES (6,'f');
+
+ let $alter_definition = OPTIMIZE PARTITION ALL LOCAL;
+ --source ../alter_table.inc
+
+ INSERT INTO t2 (a,b) VALUES (5,'e');
+
+ let $table_name = t2;
+ let $alter_definition = OPTIMIZE PARTITION p1,p0;
+ --source ../alter_table.inc
+
+ DROP TABLE t1, t2;
+}
+
+let $extra_tbl_opts = PARTITION BY HASH(a) PARTITIONS 2;
+--source ../optimize_table.inc
+
+
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/parts/repair_table.opt b/mysql-test/suite/storage_engine/parts/repair_table.opt
new file mode 100644
index 00000000..759bf0b6
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/repair_table.opt
@@ -0,0 +1 @@
+--myisam-recover-options=DEFAULT
diff --git a/mysql-test/suite/storage_engine/parts/repair_table.result b/mysql-test/suite/storage_engine/parts/repair_table.result
new file mode 100644
index 00000000..63131250
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/repair_table.result
@@ -0,0 +1,232 @@
+call mtr.add_suppression("Table '.*t1.*' is marked as crashed and should be repaired");
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(2,'d'),(4,'e'),(100,'f'),(101,'g');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY RANGE(a) (
+PARTITION p0 VALUES LESS THAN (100),
+PARTITION p1 VALUES LESS THAN MAXVALUE
+);
+INSERT INTO t2 (a,b) SELECT a, b FROM t1;
+ALTER TABLE t1 REPAIR PARTITION p0;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+INSERT INTO t1 (a,b) VALUES (3,'c');
+ALTER TABLE t1 REPAIR PARTITION NO_WRITE_TO_BINLOG p0, p1;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+INSERT INTO t2 (a,b) VALUES (5,'e'),(6,'f');
+ALTER TABLE t2 REPAIR PARTITION LOCAL p1;
+Table Op Msg_type Msg_text
+test.t2 repair status OK
+INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
+ALTER TABLE t1 REPAIR PARTITION LOCAL ALL EXTENDED;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+INSERT INTO t1 (a,b) VALUES (10,'j');
+ALTER TABLE t1 REPAIR PARTITION p1 QUICK USE_FRM;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+INSERT INTO t2 (a,b) VALUES (12,'l');
+ALTER TABLE t2 REPAIR PARTITION NO_WRITE_TO_BINLOG ALL QUICK EXTENDED USE_FRM;
+Table Op Msg_type Msg_text
+test.t2 repair status OK
+DROP TABLE t1, t2;
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+REPAIR TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+INSERT INTO t1 (a,b) VALUES (3,'c');
+INSERT INTO t2 (a,b) VALUES (4,'d');
+REPAIR NO_WRITE_TO_BINLOG TABLE t1, t2;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+test.t2 repair status OK
+INSERT INTO t2 (a,b) VALUES (5,'e'),(6,'f');
+REPAIR LOCAL TABLE t2;
+Table Op Msg_type Msg_text
+test.t2 repair status OK
+INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
+INSERT INTO t2 (a,b) VALUES (9,'i');
+REPAIR LOCAL TABLE t2, t1 EXTENDED;
+Table Op Msg_type Msg_text
+test.t2 repair status OK
+test.t1 repair status OK
+INSERT INTO t1 (a,b) VALUES (10,'j');
+INSERT INTO t2 (a,b) VALUES (11,'k');
+REPAIR TABLE t1, t2 QUICK USE_FRM;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+test.t2 repair status OK
+INSERT INTO t1 (a,b) VALUES (12,'l');
+INSERT INTO t2 (a,b) VALUES (13,'m');
+REPAIR NO_WRITE_TO_BINLOG TABLE t1, t2 QUICK EXTENDED USE_FRM;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+test.t2 repair status OK
+FLUSH TABLE t1;
+INSERT INTO t1 (a,b) VALUES (14,'n');
+ERROR HY000: Failed to read from the .par file
+# Statement ended with one of expected results (0,130,ER_FAILED_READ_FROM_PAR_FILE,ER_OPEN_AS_READONLY).
+# If you got a difference in error message, just add it to rdiff file
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check Error Failed to read from the .par file
+test.t1 check error Corrupt
+SELECT a,b FROM t1;
+ERROR HY000: Failed to read from the .par file
+# Statement ended with one of expected results (0,130,ER_FAILED_READ_FROM_PAR_FILE,ER_OPEN_AS_READONLY).
+# If you got a difference in error message, just add it to rdiff file
+REPAIR TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 repair Error Failed to read from the .par file
+test.t1 repair error Corrupt
+DROP TABLE t1, t2;
+call mtr.add_suppression("Got an error from thread_id=.*");
+call mtr.add_suppression("MySQL thread id .*, query id .* localhost.*root Checking table");
+call mtr.add_suppression(" '\..test.t1'");
+call mtr.add_suppression("Couldn't repair table: test.t1");
+call mtr.add_suppression("Table 't1' is marked as crashed.*");
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, <CUSTOM_INDEX> (a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+REPAIR TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
+REPAIR TABLE t1 EXTENDED;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+INSERT INTO t1 (a,b) VALUES (10,'j');
+REPAIR TABLE t1 USE_FRM;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+db.opt
+t1#P#p0.MYD
+t1#P#p0.MYI
+t1#P#p1.MYD
+t1#P#p1.MYI
+t1.frm
+t1.par
+INSERT INTO t1 (a,b) VALUES (14,'n'),(15,'o');
+# Statement ended with one of expected results (0,144).
+# If you got a difference in error message, just add it to rdiff file
+FLUSH TABLE t1;
+Restoring <DATADIR>/test/t1#P#p0.MYD
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check error Size of datafile is: 26 Should be: 39
+test.t1 check error Partition p0 returned error
+test.t1 check error Corrupt
+SELECT a,b FROM t1;
+a b
+8 h
+10 j
+7 g
+15 o
+Warnings:
+Error 145 Table './test/t1#P#p0' is marked as crashed and should be repaired
+Error 1034 Number of rows changed from 3 to 2
+# Statement ended with one of expected results (0,ER_NOT_KEYFILE,144).
+# If you got a difference in error message, just add it to rdiff file
+INSERT INTO t1 (a,b) VALUES (14,'n'),(15,'o');
+# Statement ended with one of expected results (0,144).
+# If you got a difference in error message, just add it to rdiff file
+FLUSH TABLE t1;
+Restoring <DATADIR>/test/t1#P#p0.MYI
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check warning Size of datafile is: 39 Should be: 26
+test.t1 check error Record-count is not ok; is 3 Should be: 2
+test.t1 check warning Found 3 key parts. Should be: 2
+test.t1 check error Partition p0 returned error
+test.t1 check error Corrupt
+SELECT a,b FROM t1;
+a b
+8 h
+10 j
+14 n
+7 g
+15 o
+15 o
+Warnings:
+Error 145 Table './test/t1#P#p0' is marked as crashed and should be repaired
+Error 1034 Number of rows changed from 2 to 3
+# Statement ended with one of expected results (0,ER_NOT_KEYFILE,144).
+# If you got a difference in error message, just add it to rdiff file
+INSERT INTO t1 (a,b) VALUES (14,'n'),(15,'o');
+# Statement ended with one of expected results (0,144).
+# If you got a difference in error message, just add it to rdiff file
+FLUSH TABLE t1;
+Restoring <DATADIR>/test/t1#P#p1.MYD
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check error Size of datafile is: 39 Should be: 52
+test.t1 check error Partition p1 returned error
+test.t1 check error Corrupt
+SELECT a,b FROM t1;
+a b
+8 h
+10 j
+14 n
+14 n
+7 g
+15 o
+15 o
+Warnings:
+Error 145 Table './test/t1#P#p1' is marked as crashed and should be repaired
+Error 1034 Number of rows changed from 4 to 3
+# Statement ended with one of expected results (0,ER_NOT_KEYFILE,144).
+# If you got a difference in error message, just add it to rdiff file
+INSERT INTO t1 (a,b) VALUES (14,'n'),(15,'o');
+# Statement ended with one of expected results (0,144).
+# If you got a difference in error message, just add it to rdiff file
+FLUSH TABLE t1;
+Restoring <DATADIR>/test/t1#P#p1.MYI
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check warning Size of datafile is: 52 Should be: 39
+test.t1 check error Record-count is not ok; is 4 Should be: 3
+test.t1 check warning Found 4 key parts. Should be: 3
+test.t1 check error Partition p1 returned error
+test.t1 check error Corrupt
+SELECT a,b FROM t1;
+a b
+8 h
+10 j
+14 n
+14 n
+14 n
+7 g
+15 o
+15 o
+15 o
+Warnings:
+Error 145 Table './test/t1#P#p1' is marked as crashed and should be repaired
+Error 1034 Number of rows changed from 3 to 4
+# Statement ended with one of expected results (0,ER_NOT_KEYFILE,144).
+# If you got a difference in error message, just add it to rdiff file
+INSERT INTO t1 (a,b) VALUES (14,'n'),(15,'o');
+# Statement ended with one of expected results (0,144).
+# If you got a difference in error message, just add it to rdiff file
+FLUSH TABLE t1;
+Restoring <DATADIR>/test/t1.par
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+SELECT a,b FROM t1;
+a b
+8 h
+10 j
+14 n
+14 n
+14 n
+14 n
+7 g
+15 o
+15 o
+15 o
+15 o
+# Statement ended with one of expected results (0,ER_NOT_KEYFILE,144).
+# If you got a difference in error message, just add it to rdiff file
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/parts/repair_table.test b/mysql-test/suite/storage_engine/parts/repair_table.test
new file mode 100644
index 00000000..06be8de1
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/repair_table.test
@@ -0,0 +1,78 @@
+#
+# REPAIR TABLE for partitioned tables and REPAIR PARTITION
+#
+
+--source include/have_partition.inc
+--source ../have_engine.inc
+
+call mtr.add_suppression("Table '.*t1.*' is marked as crashed and should be repaired");
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+let $partition_options = PARTITION BY HASH(a) PARTITIONS 2;
+--source ../create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Partitions
+ --source ../unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(2,'d'),(4,'e'),(100,'f'),(101,'g');
+
+ let $table_name = t2;
+ let $partition_options = PARTITION BY RANGE(a) (
+ PARTITION p0 VALUES LESS THAN (100),
+ PARTITION p1 VALUES LESS THAN MAXVALUE
+ );
+ --source ../create_table.inc
+
+ INSERT INTO t2 (a,b) SELECT a, b FROM t1;
+
+ let $alter_definition = REPAIR PARTITION p0;
+ --source ../alter_table.inc
+
+ INSERT INTO t1 (a,b) VALUES (3,'c');
+
+ let $alter_definition = REPAIR PARTITION NO_WRITE_TO_BINLOG p0, p1;
+ --source ../alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source ../unexpected_result.inc
+ }
+
+ INSERT INTO t2 (a,b) VALUES (5,'e'),(6,'f');
+
+ let $table_name = t2;
+ let $alter_definition = REPAIR PARTITION LOCAL p1;
+ --source ../alter_table.inc
+
+ INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
+
+ let $alter_definition = REPAIR PARTITION LOCAL ALL EXTENDED;
+ --source ../alter_table.inc
+
+ INSERT INTO t1 (a,b) VALUES (10,'j');
+
+ let $alter_definition = REPAIR PARTITION p1 QUICK USE_FRM;
+ --source ../alter_table.inc
+
+ INSERT INTO t2 (a,b) VALUES (12,'l');
+
+ let $table_name = t2;
+ let $alter_definition = REPAIR PARTITION NO_WRITE_TO_BINLOG ALL QUICK EXTENDED USE_FRM;
+ --source ../alter_table.inc
+
+ DROP TABLE t1, t2;
+}
+
+let $extra_tbl_opts = PARTITION BY HASH(a) PARTITIONS 2;
+--source ../repair_table.inc
+
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/parts/truncate_table.result b/mysql-test/suite/storage_engine/parts/truncate_table.result
new file mode 100644
index 00000000..bfbca529
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/truncate_table.result
@@ -0,0 +1,68 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+TRUNCATE TABLE t1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c');
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN> KEY AUTO_INCREMENT, c <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `c` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+ PARTITION BY HASH (`a`)
+PARTITIONS 2
+INSERT INTO t1 (c) VALUES ('a'),('b'),('c');
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `c` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=<STORAGE_ENGINE> AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
+ PARTITION BY HASH (`a`)
+PARTITIONS 2
+TRUNCATE TABLE t1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `c` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+ PARTITION BY HASH (`a`)
+PARTITIONS 2
+INSERT INTO t1 (c) VALUES ('d');
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL AUTO_INCREMENT,
+ `c` char(8) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=<STORAGE_ENGINE> AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
+ PARTITION BY HASH (`a`)
+PARTITIONS 2
+SELECT a,c FROM t1;
+a c
+1 d
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PARTITION BY HASH(a) PARTITIONS 2;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(2,'d'),(4,'e'),(100,'f'),(101,'g');
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+SELECT a,b FROM t1;
+a b
+1 a
+101 g
+3 c
+EXPLAIN PARTITIONS SELECT a,b FROM t1;
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 p0,p1 # # # # # #
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c');
+ALTER TABLE t1 TRUNCATE PARTITION ALL;
+SELECT a,b FROM t1;
+a b
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/parts/truncate_table.test b/mysql-test/suite/storage_engine/parts/truncate_table.test
new file mode 100644
index 00000000..9d921f01
--- /dev/null
+++ b/mysql-test/suite/storage_engine/parts/truncate_table.test
@@ -0,0 +1,111 @@
+#
+# TRUNCATE TABLE with partitions and TRUNCATE PARTITION
+#
+
+--source include/have_partition.inc
+--source ../have_engine.inc
+
+# A part of the standard TRUNCATE test
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+
+# Truncate partitioned table
+
+let $partition_options = PARTITION BY HASH(a) PARTITIONS 2;
+--source ../create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Partitions
+ --source ../unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ TRUNCATE TABLE t1;
+ if ($mysql_errname)
+ {
+ --let $functionality = TRUNCATE TABLE
+ --source ../unexpected_result.inc
+ }
+
+ INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c');
+ TRUNCATE TABLE t1;
+ SELECT a,b FROM t1;
+
+ DROP TABLE t1;
+}
+
+
+# Truncate resets auto-increment value on the table
+
+let $create_definition = a $int_indexed_col KEY AUTO_INCREMENT, c $char_col;
+let $partition_options = PARTITION BY HASH(a) PARTITIONS 2;
+--source ../create_table.inc
+
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Partitions or PK or auto-increment
+ --source ../unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --source ../mask_engine.inc
+ SHOW CREATE TABLE t1;
+ INSERT INTO t1 (c) VALUES ('a'),('b'),('c');
+ --source ../mask_engine.inc
+ SHOW CREATE TABLE t1;
+ TRUNCATE TABLE t1;
+ --source ../mask_engine.inc
+ SHOW CREATE TABLE t1;
+ INSERT INTO t1 (c) VALUES ('d');
+ --source ../mask_engine.inc
+ SHOW CREATE TABLE t1;
+ SELECT a,c FROM t1;
+ DROP TABLE t1;
+}
+
+
+# Truncate partitions
+
+let $partition_options = PARTITION BY HASH(a) PARTITIONS 2;
+--source ../create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Partitions
+ --source ../unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(2,'d'),(4,'e'),(100,'f'),(101,'g');
+
+ let $alter_definition = TRUNCATE PARTITION p0;
+ --source ../alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source ../unexpected_result.inc
+ }
+
+ --sorted_result
+ SELECT a,b FROM t1;
+ --replace_column 5 # 6 # 7 # 8 # 9 # 10 #
+ EXPLAIN PARTITIONS SELECT a,b FROM t1;
+
+ INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c');
+
+ let $alter_definition = TRUNCATE PARTITION ALL;
+ --source ../alter_table.inc
+
+ SELECT a,b FROM t1;
+
+ DROP TABLE t1;
+}
+
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/repair_table.inc b/mysql-test/suite/storage_engine/repair_table.inc
new file mode 100644
index 00000000..908839e3
--- /dev/null
+++ b/mysql-test/suite/storage_engine/repair_table.inc
@@ -0,0 +1,158 @@
+#
+# REPAIR TABLE statements
+#
+# Note: the output is likely to be different for the engine under test,
+# in which case rdiff will be needed. Or, the output might say that
+# the storage engine does not support REPAIR.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+--let $table_name = t2
+--source create_table.inc
+
+REPAIR TABLE t1;
+if ($mysql_errname)
+{
+ --source unexpected_result.inc
+}
+INSERT INTO t1 (a,b) VALUES (3,'c');
+INSERT INTO t2 (a,b) VALUES (4,'d');
+REPAIR NO_WRITE_TO_BINLOG TABLE t1, t2;
+INSERT INTO t2 (a,b) VALUES (5,'e'),(6,'f');
+REPAIR LOCAL TABLE t2;
+INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
+INSERT INTO t2 (a,b) VALUES (9,'i');
+REPAIR LOCAL TABLE t2, t1 EXTENDED;
+INSERT INTO t1 (a,b) VALUES (10,'j');
+INSERT INTO t2 (a,b) VALUES (11,'k');
+REPAIR TABLE t1, t2 QUICK USE_FRM;
+INSERT INTO t1 (a,b) VALUES (12,'l');
+INSERT INTO t2 (a,b) VALUES (13,'m');
+REPAIR NO_WRITE_TO_BINLOG TABLE t1, t2 QUICK EXTENDED USE_FRM;
+FLUSH TABLE t1;
+
+let my_datadir = `SELECT @@datadir`;
+
+# Now we'll override all table files except for frm.
+# Some engines are more enduring to table files corruption
+# than others, so the result of the following INSERT and REPAIR
+# will be different for different engines
+
+--perl
+@files = glob "$ENV{my_datadir}/test/t1.*";
+foreach (@files)
+{
+ next if /.frm$/;
+ rename($_,"$_.save");
+ open(FILE,">$_") || print "Could not open $_\n" && exit;
+ print FILE "";
+ close(FILE);
+}
+EOF
+
+# We don't worry so much about the INSERT or SELECT result,
+# it's REPAIR that we are after.
+# The preceding INSERT, however, helps to trigger
+# a bit more internals
+--let $error_codes = 0,130,ER_FAILED_READ_FROM_PAR_FILE,ER_OPEN_AS_READONLY
+INSERT INTO t1 (a,b) VALUES (14,'n');
+--source check_errors.inc
+CHECK TABLE t1;
+--let $error_codes = 0,130,ER_FAILED_READ_FROM_PAR_FILE,ER_OPEN_AS_READONLY
+SELECT a,b FROM t1;
+--source check_errors.inc
+--enable_warnings
+REPAIR TABLE t1;
+
+--perl
+@files = glob "$ENV{my_datadir}/test/t1.*.save";
+foreach (@files)
+{
+ $nm = $_;
+ $nm =~ s/\.save$//;
+ rename($_,$nm);
+}
+EOF
+
+DROP TABLE t1, t2;
+
+--let $continue = 1
+--source have_default_index.inc
+
+if ($have_default_index)
+{
+ call mtr.add_suppression("Got an error from thread_id=.*");
+ call mtr.add_suppression("MariaDB thread id .*, query id .* localhost.*root Checking table");
+ call mtr.add_suppression(" '\..test.t1'");
+ call mtr.add_suppression("Couldn't repair table: test.t1");
+
+ # In 10.2 with log_warnings=2 the error message is printed to the error log
+ call mtr.add_suppression("Table 't1' is marked as crashed.*");
+
+ --let $create_definition = a $int_indexed_col, b $char_col, $default_index (a)
+ --source create_table.inc
+ REPAIR TABLE t1;
+ INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
+ REPAIR TABLE t1 EXTENDED;
+ INSERT INTO t1 (a,b) VALUES (10,'j');
+ REPAIR TABLE t1 USE_FRM;
+
+ # We will take files one by one (except for frm file),
+ # save the file, update the table, then restore the file
+ # and check the table.
+ # Results here can be very different depending on the engine.
+
+ let $my_errno = 0;
+
+ --list_files $my_datadir/test
+
+ while (!$my_errno)
+ {
+ --error 0,2
+ --perl
+ use File::Copy;
+ @files = glob "$ENV{my_datadir}/test/t1*";
+ foreach (@files)
+ {
+ next if /.(?:frm|save|done)$/;
+ next if -e "$_.done";
+ copy($_,"$_.save");
+ exit 0;
+ }
+ # No more files
+ exit 2;
+ EOF
+ let $my_errno = $errno;
+ if (!$my_errno)
+ {
+ --let $error_codes = 0,144
+ INSERT INTO t1 (a,b) VALUES (14,'n'),(15,'o');
+ --source check_errors.inc
+ FLUSH TABLE t1;
+ --replace_result $my_datadir <DATADIR>
+ --perl
+ use File::Copy;
+ @files = glob "$ENV{my_datadir}/test/t1*.save";
+ $nm = $files[0];
+ $nm =~ s/\.save$//;
+ print "Restoring $nm\n";
+ copy($files[0],"$nm.done");
+ rename($files[0],$nm);
+ EOF
+ CHECK TABLE t1;
+ --let $error_codes = 0,ER_NOT_KEYFILE,144
+ SELECT a,b FROM t1;
+ --source check_errors.inc
+ }
+ }
+ DROP TABLE t1;
+}
+
+--remove_files_wildcard $my_datadir/test t1*
+
+
diff --git a/mysql-test/suite/storage_engine/repair_table.result b/mysql-test/suite/storage_engine/repair_table.result
new file mode 100644
index 00000000..cbd86164
--- /dev/null
+++ b/mysql-test/suite/storage_engine/repair_table.result
@@ -0,0 +1,108 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+REPAIR TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+INSERT INTO t1 (a,b) VALUES (3,'c');
+INSERT INTO t2 (a,b) VALUES (4,'d');
+REPAIR NO_WRITE_TO_BINLOG TABLE t1, t2;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+test.t2 repair status OK
+INSERT INTO t2 (a,b) VALUES (5,'e'),(6,'f');
+REPAIR LOCAL TABLE t2;
+Table Op Msg_type Msg_text
+test.t2 repair status OK
+INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
+INSERT INTO t2 (a,b) VALUES (9,'i');
+REPAIR LOCAL TABLE t2, t1 EXTENDED;
+Table Op Msg_type Msg_text
+test.t2 repair status OK
+test.t1 repair status OK
+INSERT INTO t1 (a,b) VALUES (10,'j');
+INSERT INTO t2 (a,b) VALUES (11,'k');
+REPAIR TABLE t1, t2 QUICK USE_FRM;
+Table Op Msg_type Msg_text
+test.t1 repair warning Number of rows changed from 0 to 6
+test.t1 repair status OK
+test.t2 repair warning Number of rows changed from 0 to 5
+test.t2 repair status OK
+INSERT INTO t1 (a,b) VALUES (12,'l');
+INSERT INTO t2 (a,b) VALUES (13,'m');
+REPAIR NO_WRITE_TO_BINLOG TABLE t1, t2 QUICK EXTENDED USE_FRM;
+Table Op Msg_type Msg_text
+test.t1 repair warning Number of rows changed from 0 to 7
+test.t1 repair status OK
+test.t2 repair warning Number of rows changed from 0 to 6
+test.t2 repair status OK
+FLUSH TABLE t1;
+INSERT INTO t1 (a,b) VALUES (14,'n');
+ERROR HY000: Incorrect file format 't1'
+# Statement ended with one of expected results (0,130,ER_FAILED_READ_FROM_PAR_FILE,ER_OPEN_AS_READONLY).
+# If you got a difference in error message, just add it to rdiff file
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check Error Incorrect file format 't1'
+test.t1 check error Corrupt
+SELECT a,b FROM t1;
+ERROR HY000: Incorrect file format 't1'
+# Statement ended with one of expected results (0,130,ER_FAILED_READ_FROM_PAR_FILE,ER_OPEN_AS_READONLY).
+# If you got a difference in error message, just add it to rdiff file
+REPAIR TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 repair Error Incorrect file format 't1'
+test.t1 repair error Corrupt
+DROP TABLE t1, t2;
+call mtr.add_suppression("Got an error from thread_id=.*");
+call mtr.add_suppression("MySQL thread id .*, query id .* localhost.*root Checking table");
+call mtr.add_suppression(" '\..test.t1'");
+call mtr.add_suppression("Couldn't repair table: test.t1");
+call mtr.add_suppression("Table 't1' is marked as crashed.*");
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, <CUSTOM_INDEX> (a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+REPAIR TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+INSERT INTO t1 (a,b) VALUES (7,'g'),(8,'h');
+REPAIR TABLE t1 EXTENDED;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+INSERT INTO t1 (a,b) VALUES (10,'j');
+REPAIR TABLE t1 USE_FRM;
+Table Op Msg_type Msg_text
+test.t1 repair warning Number of rows changed from 0 to 3
+test.t1 repair status OK
+db.opt
+t1.MYD
+t1.MYI
+t1.frm
+INSERT INTO t1 (a,b) VALUES (14,'n'),(15,'o');
+# Statement ended with one of expected results (0,144).
+# If you got a difference in error message, just add it to rdiff file
+FLUSH TABLE t1;
+Restoring <DATADIR>/test/t1.MYD
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check error Size of datafile is: 39 Should be: 65
+test.t1 check error Corrupt
+SELECT a,b FROM t1;
+ERROR HY000: Index for table 't1' is corrupt; try to repair it
+# Statement ended with one of expected results (0,ER_NOT_KEYFILE,144).
+# If you got a difference in error message, just add it to rdiff file
+INSERT INTO t1 (a,b) VALUES (14,'n'),(15,'o');
+ERROR HY000: Table './test/t1' is marked as crashed and last (automatic?) repair failed
+# Statement ended with one of expected results (0,144).
+# If you got a difference in error message, just add it to rdiff file
+FLUSH TABLE t1;
+Restoring <DATADIR>/test/t1.MYI
+CHECK TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 check warning Table is marked as crashed and last repair failed
+test.t1 check error Size of datafile is: 39 Should be: 65
+test.t1 check error Corrupt
+SELECT a,b FROM t1;
+ERROR HY000: Table './test/t1' is marked as crashed and last (automatic?) repair failed
+# Statement ended with one of expected results (0,ER_NOT_KEYFILE,144).
+# If you got a difference in error message, just add it to rdiff file
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/repair_table.test b/mysql-test/suite/storage_engine/repair_table.test
new file mode 100644
index 00000000..5e3068b0
--- /dev/null
+++ b/mysql-test/suite/storage_engine/repair_table.test
@@ -0,0 +1,14 @@
+#
+# REPAIR TABLE statements
+#
+# Note: the output is likely to be different for the engine under test,
+# in which case rdiff will be needed. Or, the output might say that
+# the storage engine does not support REPAIR.
+#
+
+--source have_engine.inc
+
+--source repair_table.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/replace.result b/mysql-test/suite/storage_engine/replace.result
new file mode 100644
index 00000000..85988c74
--- /dev/null
+++ b/mysql-test/suite/storage_engine/replace.result
@@ -0,0 +1,47 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+REPLACE INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+SELECT a,b FROM t1;
+a b
+1 a
+2 b
+3 c
+4 d
+5 e
+REPLACE t1 (a,b) VALUE (10,'foo'),(10,'foo');
+SELECT a,b FROM t1;
+a b
+1 a
+10 foo
+10 foo
+2 b
+3 c
+4 d
+5 e
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, UNIQUE INDEX (a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+REPLACE INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c');
+INSERT INTO t1 (a,b) VALUES (2,'d');
+ERROR 23000: Duplicate entry '2' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+REPLACE INTO t1 (a,b) VALUES (2,'d');
+SELECT a,b FROM t1;
+a b
+1 a
+2 d
+3 c
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, PRIMARY KEY (b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+REPLACE INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c');
+INSERT INTO t1 (a,b) VALUES (4,'b');
+ERROR 23000: Duplicate entry 'b' for key 'PRIMARY'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+REPLACE INTO t1 (a,b) VALUES (4,'b');
+SELECT a,b FROM t1;
+a b
+1 a
+3 c
+4 b
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/replace.test b/mysql-test/suite/storage_engine/replace.test
new file mode 100644
index 00000000..0a00734a
--- /dev/null
+++ b/mysql-test/suite/storage_engine/replace.test
@@ -0,0 +1,67 @@
+#
+# Basic REPLACE statements
+#
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--source create_table.inc
+
+# When there is no duplicate key, REPLACE should work as INSERT
+
+REPLACE INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e');
+--sorted_result
+SELECT a,b FROM t1;
+
+REPLACE t1 (a,b) VALUE (10,'foo'),(10,'foo');
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
+--let $create_definition = a $int_indexed_col, b $char_col, UNIQUE INDEX (a)
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Unique keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ REPLACE INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c');
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ INSERT INTO t1 (a,b) VALUES (2,'d');
+ --source check_errors.inc
+ REPLACE INTO t1 (a,b) VALUES (2,'d');
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ DROP TABLE t1;
+}
+
+--let $create_definition = a $int_col, b $char_indexed_col, PRIMARY KEY (b)
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Primary keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ REPLACE INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c');
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ INSERT INTO t1 (a,b) VALUES (4,'b');
+ --source check_errors.inc
+ REPLACE INTO t1 (a,b) VALUES (4,'b');
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/se-innodb.out b/mysql-test/suite/storage_engine/se-innodb.out
new file mode 100644
index 00000000..406e5066
--- /dev/null
+++ b/mysql-test/suite/storage_engine/se-innodb.out
@@ -0,0 +1 @@
+Can't open perl script "./mtr": No such file or directory
diff --git a/mysql-test/suite/storage_engine/select.result b/mysql-test/suite/storage_engine/select.result
new file mode 100644
index 00000000..9bd36cff
--- /dev/null
+++ b/mysql-test/suite/storage_engine/select.result
@@ -0,0 +1,391 @@
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (100,'foobar'),(1,'z'),(200,'bar');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t2 (a,b) SELECT a, b FROM t1;
+INSERT INTO t1 (a,b) SELECT a, b FROM t2;
+SELECT * FROM t1;
+a b
+1 z
+1 z
+100 foobar
+100 foobar
+200 bar
+200 bar
+SELECT DISTINCT a FROM t1;
+a
+1
+100
+200
+SELECT ALL b, a FROM t1;
+b a
+bar 200
+bar 200
+foobar 100
+foobar 100
+z 1
+z 1
+SELECT STRAIGHT_JOIN SQL_CACHE t1.* FROM t2, t1 WHERE t1.a <> t2.a;
+a b
+1 z
+1 z
+1 z
+1 z
+100 foobar
+100 foobar
+100 foobar
+100 foobar
+200 bar
+200 bar
+200 bar
+200 bar
+SELECT SQL_SMALL_RESULT SQL_NO_CACHE t1.a FROM t1, t2;
+a
+1
+1
+1
+1
+1
+1
+100
+100
+100
+100
+100
+100
+200
+200
+200
+200
+200
+200
+SELECT SQL_BIG_RESULT SQL_CALC_FOUND_ROWS DISTINCT(t2.a)
+FROM t1 t1_1, t2, t1 t1_2;
+a
+1
+100
+200
+SELECT FOUND_ROWS();
+FOUND_ROWS()
+3
+SET GLOBAL query_cache_type = ON;
+SET query_cache_type = ON;
+SELECT SQL_CACHE * FROM t1, t2;
+a b a b
+1 z 1 z
+1 z 1 z
+1 z 100 foobar
+1 z 100 foobar
+1 z 200 bar
+1 z 200 bar
+100 foobar 1 z
+100 foobar 1 z
+100 foobar 100 foobar
+100 foobar 100 foobar
+100 foobar 200 bar
+100 foobar 200 bar
+200 bar 1 z
+200 bar 1 z
+200 bar 100 foobar
+200 bar 100 foobar
+200 bar 200 bar
+200 bar 200 bar
+SET GLOBAL query_cache_type = DEFAULT;
+SELECT a+10 AS field1, CONCAT(b,':',b) AS field2 FROM t1
+WHERE b > 'b' AND a IS NOT NULL
+GROUP BY 2 DESC, field1 ASC
+HAVING field1 < 1000
+ORDER BY field2, 1 DESC, field1*2
+LIMIT 5 OFFSET 1 ROWS EXAMINED 100000;
+field1 field2
+11 z:z
+110 foobar:foobar
+SELECT SUM(a), MAX(a), b FROM t1 GROUP BY b WITH ROLLUP;
+SUM(a) MAX(a) b
+2 1 z
+200 100 foobar
+400 200 bar
+602 200 NULL
+SELECT * FROM t2 WHERE a>0 PROCEDURE ANALYSE();
+Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
+test.t2.a 1 200 1 3 0 0 100.3333 81.2418 ENUM('1','100','200') NOT NULL
+test.t2.b bar z 1 6 0 0 3.3333 NULL ENUM('bar','foobar','z') NOT NULL
+SELECT t1.a, t2.b FROM t2, t1 WHERE t1.a = t2.a ORDER BY t2.b, t1.a
+INTO OUTFILE '<DATADIR>/select.out'
+CHARACTER SET utf8
+FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '''';
+200,'bar'
+200,'bar'
+100,'foobar'
+100,'foobar'
+1,'z'
+1,'z'
+SELECT t1.a, t2.b FROM t2, t1 WHERE t1.a = t2.a ORDER BY t2.b, t1.a
+INTO DUMPFILE '<DATADIR>/select.dump';
+ERROR 42000: Result consisted of more than one row
+SELECT t1.*, t2.* FROM t1, t2 ORDER BY t2.b, t1.a, t2.a, t1.b LIMIT 1
+INTO DUMPFILE '<DATADIR>/select.dump';
+1z200bar
+SELECT MIN(a), MAX(a) FROM t1 INTO @min, @max;
+SELECT @min, @max;
+@min @max
+1 200
+SELECT t1_1.*, t2.* FROM t2, t1 AS t1_1, t1 AS t1_2
+WHERE t1_1.a = t1_2.a AND t2.a = t1_1.a;
+a b a b
+1 z 1 z
+1 z 1 z
+1 z 1 z
+1 z 1 z
+100 foobar 100 foobar
+100 foobar 100 foobar
+100 foobar 100 foobar
+100 foobar 100 foobar
+200 bar 200 bar
+200 bar 200 bar
+200 bar 200 bar
+200 bar 200 bar
+SELECT alias1.* FROM ( SELECT a,b FROM t1 ) alias1, t2 WHERE t2.a IN (100,200);
+a b
+1 z
+1 z
+1 z
+1 z
+100 foobar
+100 foobar
+100 foobar
+100 foobar
+200 bar
+200 bar
+200 bar
+200 bar
+SELECT t1.a FROM { OJ t1 LEFT OUTER JOIN t2 ON t1.a = t2.a+10 };
+a
+1
+1
+100
+100
+200
+200
+SELECT t1.* FROM t2 INNER JOIN t1;
+a b
+1 z
+1 z
+1 z
+1 z
+1 z
+1 z
+100 foobar
+100 foobar
+100 foobar
+100 foobar
+100 foobar
+100 foobar
+200 bar
+200 bar
+200 bar
+200 bar
+200 bar
+200 bar
+SELECT t1_2.* FROM t1 t1_1 CROSS JOIN t1 t1_2 ON t1_1.b = t1_2.b;
+a b
+1 z
+1 z
+1 z
+1 z
+100 foobar
+100 foobar
+100 foobar
+100 foobar
+200 bar
+200 bar
+200 bar
+200 bar
+SELECT t1.a, t2.b FROM t2 STRAIGHT_JOIN t1 WHERE t1.b > t2.b;
+a b
+1 bar
+1 bar
+1 foobar
+1 foobar
+100 bar
+100 bar
+SELECT t1.a, t2.b FROM t2 STRAIGHT_JOIN t1 ON t1.b > t2.b ORDER BY t1.a, t2.b;
+a b
+1 bar
+1 bar
+1 foobar
+1 foobar
+100 bar
+100 bar
+SELECT t2.* FROM t1 LEFT JOIN t2 USING (a) ORDER BY t2.a, t2.b LIMIT 1;
+a b
+1 z
+SELECT t2.* FROM t2 LEFT OUTER JOIN t1 ON t1.a = t2.a WHERE t1.a IS NOT NULL;
+a b
+1 z
+1 z
+100 foobar
+100 foobar
+200 bar
+200 bar
+SELECT SUM(t2.a) FROM t1 RIGHT JOIN t2 ON t2.b = t1.b;
+SUM(t2.a)
+602
+SELECT MIN(t2.a) FROM t1 RIGHT OUTER JOIN t2 USING (b,a);
+MIN(t2.a)
+1
+SELECT alias.b FROM t1 NATURAL JOIN ( SELECT a,b FROM t1 ) alias WHERE b > '';
+b
+bar
+bar
+bar
+bar
+foobar
+foobar
+foobar
+foobar
+z
+z
+z
+z
+SELECT t2.b FROM ( SELECT a,b FROM t1 ) alias NATURAL LEFT JOIN t2 WHERE b IS NOT NULL;
+b
+bar
+bar
+foobar
+foobar
+z
+z
+SELECT t1.*, t2.* FROM t1 NATURAL LEFT OUTER JOIN t2;
+a b a b
+1 z 1 z
+1 z 1 z
+100 foobar 100 foobar
+100 foobar 100 foobar
+200 bar 200 bar
+200 bar 200 bar
+SELECT t2_2.* FROM t2 t2_1 NATURAL RIGHT JOIN t2 t2_2 WHERE t2_1.a IN ( SELECT a FROM t1 );
+a b
+1 z
+100 foobar
+200 bar
+SELECT t1_2.b FROM t1 t1_1 NATURAL RIGHT OUTER JOIN t1 t1_2 INNER JOIN t2;
+b
+bar
+bar
+bar
+bar
+bar
+bar
+bar
+bar
+bar
+bar
+bar
+bar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+foobar
+z
+z
+z
+z
+z
+z
+z
+z
+z
+z
+z
+z
+SELECT ( SELECT MIN(a) FROM ( SELECT a,b FROM t1 ) alias1 ) AS min_a FROM t2;
+min_a
+1
+1
+1
+SELECT a,b FROM t2 WHERE a = ( SELECT MIN(a) FROM t1 );
+a b
+1 z
+SELECT a,b FROM t2 WHERE b LIKE ( SELECT b FROM t1 ORDER BY b LIMIT 1 );
+a b
+200 bar
+SELECT t2.* FROM t1 t1_outer, t2 WHERE ( t1_outer.a, t2.b ) IN ( SELECT a, b FROM t2 WHERE a = t1_outer.a );
+a b
+1 z
+1 z
+100 foobar
+100 foobar
+200 bar
+200 bar
+SELECT a,b FROM t2 WHERE b = ANY ( SELECT b FROM t1 WHERE a > 1 );
+a b
+100 foobar
+200 bar
+SELECT a,b FROM t2 WHERE b > ALL ( SELECT b FROM t1 WHERE b < 'foo' );
+a b
+1 z
+100 foobar
+SELECT a,b FROM t1 WHERE ROW(a, b) = ( SELECT a, b FROM t2 ORDER BY a, b LIMIT 1 );
+a b
+1 z
+1 z
+SELECT a,b FROM t1 WHERE EXISTS ( SELECT a,b FROM t2 WHERE t2.b > t1.b );
+a b
+100 foobar
+100 foobar
+200 bar
+200 bar
+SELECT t1.* FROM t1, t2 ORDER BY ( SELECT b FROM t1 WHERE a IS NULL ORDER BY b LIMIT 1 ) DESC;
+a b
+1 z
+1 z
+1 z
+1 z
+1 z
+1 z
+100 foobar
+100 foobar
+100 foobar
+100 foobar
+100 foobar
+100 foobar
+200 bar
+200 bar
+200 bar
+200 bar
+200 bar
+200 bar
+SELECT a, b FROM t1 HAVING a IN ( SELECT a FROM t2 WHERE b = t1.b );
+a b
+1 z
+1 z
+100 foobar
+100 foobar
+200 bar
+200 bar
+SELECT a,b FROM t1 UNION SELECT a,b FROM t2 UNION DISTINCT SELECT a,b FROM t1;
+a b
+1 z
+100 foobar
+200 bar
+SELECT a,b FROM t1 UNION SELECT a,b FROM t2 UNION ALL SELECT a,b FROM t1;
+a b
+1 z
+1 z
+1 z
+100 foobar
+100 foobar
+100 foobar
+200 bar
+200 bar
+200 bar
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/storage_engine/select.test b/mysql-test/suite/storage_engine/select.test
new file mode 100644
index 00000000..9b4e1784
--- /dev/null
+++ b/mysql-test/suite/storage_engine/select.test
@@ -0,0 +1,210 @@
+#
+# Basic SELECT statements
+#
+# HIGH_PRIORITY is covered in select_high_prio test
+# FOR UPDATE - in trx/select_for_update test
+# LOCK IN SHARE MODE - in trx/select_lock_in_share_mode test
+# index hints - in type_*_indexes tests
+#
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (100,'foobar'),(1,'z'),(200,'bar');
+
+--let $table_name = t2
+--source create_table.inc
+INSERT INTO t2 (a,b) SELECT a, b FROM t1;
+INSERT INTO t1 (a,b) SELECT a, b FROM t2;
+
+--sorted_result
+SELECT * FROM t1;
+
+# Modifiers
+
+--sorted_result
+SELECT DISTINCT a FROM t1;
+
+--sorted_result
+SELECT ALL b, a FROM t1;
+
+# Optimizer and cache directives should not have any visible effect here,
+# but we will add them for completness
+
+--sorted_result
+SELECT STRAIGHT_JOIN SQL_CACHE t1.* FROM t2, t1 WHERE t1.a <> t2.a;
+
+--sorted_result
+SELECT SQL_SMALL_RESULT SQL_NO_CACHE t1.a FROM t1, t2;
+
+--sorted_result
+SELECT SQL_BIG_RESULT SQL_CALC_FOUND_ROWS DISTINCT(t2.a)
+ FROM t1 t1_1, t2, t1 t1_2;
+SELECT FOUND_ROWS();
+
+SET GLOBAL query_cache_type = ON;
+SET query_cache_type = ON;
+--sorted_result
+SELECT SQL_CACHE * FROM t1, t2;
+SET GLOBAL query_cache_type = DEFAULT;
+
+# Combination of main clauses
+
+--sorted_result
+SELECT a+10 AS field1, CONCAT(b,':',b) AS field2 FROM t1
+WHERE b > 'b' AND a IS NOT NULL
+GROUP BY 2 DESC, field1 ASC
+HAVING field1 < 1000
+ORDER BY field2, 1 DESC, field1*2
+LIMIT 5 OFFSET 1 ROWS EXAMINED 100000;
+
+# ROLLUP
+--sorted_result
+SELECT SUM(a), MAX(a), b FROM t1 GROUP BY b WITH ROLLUP;
+
+# Procedure
+
+--sorted_result
+SELECT * FROM t2 WHERE a>0 PROCEDURE ANALYSE();
+
+# SELECT INTO
+let $datadir = `SELECT @@datadir`;
+
+--replace_result $datadir <DATADIR>
+eval
+SELECT t1.a, t2.b FROM t2, t1 WHERE t1.a = t2.a ORDER BY t2.b, t1.a
+ INTO OUTFILE '$datadir/select.out'
+ CHARACTER SET utf8
+ FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '''';
+--cat_file $datadir/select.out
+--remove_file $datadir/select.out
+
+--replace_result $datadir <DATADIR>
+--let $error_codes = ER_TOO_MANY_ROWS
+eval
+SELECT t1.a, t2.b FROM t2, t1 WHERE t1.a = t2.a ORDER BY t2.b, t1.a
+ INTO DUMPFILE '$datadir/select.dump';
+--source check_errors.inc
+--remove_file $datadir/select.dump
+--replace_result $datadir <DATADIR>
+eval
+SELECT t1.*, t2.* FROM t1, t2 ORDER BY t2.b, t1.a, t2.a, t1.b LIMIT 1
+ INTO DUMPFILE '$datadir/select.dump';
+
+--cat_file $datadir/select.dump
+--echo
+--remove_file $datadir/select.dump
+
+SELECT MIN(a), MAX(a) FROM t1 INTO @min, @max;
+SELECT @min, @max;
+
+# Joins
+
+--sorted_result
+SELECT t1_1.*, t2.* FROM t2, t1 AS t1_1, t1 AS t1_2
+ WHERE t1_1.a = t1_2.a AND t2.a = t1_1.a;
+
+--sorted_result
+SELECT alias1.* FROM ( SELECT a,b FROM t1 ) alias1, t2 WHERE t2.a IN (100,200);
+
+--sorted_result
+SELECT t1.a FROM { OJ t1 LEFT OUTER JOIN t2 ON t1.a = t2.a+10 };
+
+--sorted_result
+SELECT t1.* FROM t2 INNER JOIN t1;
+
+--sorted_result
+SELECT t1_2.* FROM t1 t1_1 CROSS JOIN t1 t1_2 ON t1_1.b = t1_2.b;
+
+--sorted_result
+SELECT t1.a, t2.b FROM t2 STRAIGHT_JOIN t1 WHERE t1.b > t2.b;
+
+SELECT t1.a, t2.b FROM t2 STRAIGHT_JOIN t1 ON t1.b > t2.b ORDER BY t1.a, t2.b;
+
+SELECT t2.* FROM t1 LEFT JOIN t2 USING (a) ORDER BY t2.a, t2.b LIMIT 1;
+
+--sorted_result
+SELECT t2.* FROM t2 LEFT OUTER JOIN t1 ON t1.a = t2.a WHERE t1.a IS NOT NULL;
+
+SELECT SUM(t2.a) FROM t1 RIGHT JOIN t2 ON t2.b = t1.b;
+
+SELECT MIN(t2.a) FROM t1 RIGHT OUTER JOIN t2 USING (b,a);
+
+--sorted_result
+SELECT alias.b FROM t1 NATURAL JOIN ( SELECT a,b FROM t1 ) alias WHERE b > '';
+
+--sorted_result
+SELECT t2.b FROM ( SELECT a,b FROM t1 ) alias NATURAL LEFT JOIN t2 WHERE b IS NOT NULL;
+
+--sorted_result
+SELECT t1.*, t2.* FROM t1 NATURAL LEFT OUTER JOIN t2;
+
+--sorted_result
+SELECT t2_2.* FROM t2 t2_1 NATURAL RIGHT JOIN t2 t2_2 WHERE t2_1.a IN ( SELECT a FROM t1 );
+
+--sorted_result
+SELECT t1_2.b FROM t1 t1_1 NATURAL RIGHT OUTER JOIN t1 t1_2 INNER JOIN t2;
+
+# Subquery as scalar operand, subquery in the FROM clause
+
+--sorted_result
+SELECT ( SELECT MIN(a) FROM ( SELECT a,b FROM t1 ) alias1 ) AS min_a FROM t2;
+
+# Comparison using subqueries
+
+--sorted_result
+SELECT a,b FROM t2 WHERE a = ( SELECT MIN(a) FROM t1 );
+
+--sorted_result
+SELECT a,b FROM t2 WHERE b LIKE ( SELECT b FROM t1 ORDER BY b LIMIT 1 );
+
+# Subquery with IN, correlated subquery
+
+--sorted_result
+SELECT t2.* FROM t1 t1_outer, t2 WHERE ( t1_outer.a, t2.b ) IN ( SELECT a, b FROM t2 WHERE a = t1_outer.a );
+
+# Subquery with ANY, ALL
+
+--sorted_result
+SELECT a,b FROM t2 WHERE b = ANY ( SELECT b FROM t1 WHERE a > 1 );
+
+--sorted_result
+SELECT a,b FROM t2 WHERE b > ALL ( SELECT b FROM t1 WHERE b < 'foo' );
+
+# Row subqueries
+
+--sorted_result
+SELECT a,b FROM t1 WHERE ROW(a, b) = ( SELECT a, b FROM t2 ORDER BY a, b LIMIT 1 );
+
+# Subquery with EXISTS
+
+--sorted_result
+SELECT a,b FROM t1 WHERE EXISTS ( SELECT a,b FROM t2 WHERE t2.b > t1.b );
+
+# Subquery in ORDER BY
+
+--sorted_result
+SELECT t1.* FROM t1, t2 ORDER BY ( SELECT b FROM t1 WHERE a IS NULL ORDER BY b LIMIT 1 ) DESC;
+
+# Subquery in HAVING
+
+--sorted_result
+SELECT a, b FROM t1 HAVING a IN ( SELECT a FROM t2 WHERE b = t1.b );
+
+# Union
+
+--sorted_result
+SELECT a,b FROM t1 UNION SELECT a,b FROM t2 UNION DISTINCT SELECT a,b FROM t1;
+
+--sorted_result
+SELECT a,b FROM t1 UNION SELECT a,b FROM t2 UNION ALL SELECT a,b FROM t1;
+
+
+# Cleanup
+DROP TABLE t1, t2;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/select_high_prio.result b/mysql-test/suite/storage_engine/select_high_prio.result
new file mode 100644
index 00000000..10226ae0
--- /dev/null
+++ b/mysql-test/suite/storage_engine/select_high_prio.result
@@ -0,0 +1,45 @@
+DROP TABLE IF EXISTS t1;
+connect con0,localhost,root,,;
+SET lock_wait_timeout = 4;
+connect con1,localhost,root,,;
+SET lock_wait_timeout = 4;
+connect con2,localhost,root,,;
+SET lock_wait_timeout = 4;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
+connection con1;
+LOCK TABLE t1 READ;
+connection con0;
+UPDATE t1 SET b = CONCAT(b,b);
+connection con2;
+SELECT a,b FROM t1;
+connection con1;
+UNLOCK TABLES;
+connection con0;
+connection con2;
+# Should return the new data
+a b
+1 ff
+2 bb
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
+connection con1;
+LOCK TABLE t1 READ;
+connection con0;
+UPDATE t1 SET b = CONCAT(b,b,b);
+connection con2;
+SET lock_wait_timeout = 1;
+# Should return old data
+SELECT HIGH_PRIORITY * FROM t1;
+a b
+1 f
+2 b
+connection con1;
+UNLOCK TABLES;
+connection con0;
+disconnect con1;
+disconnect con2;
+disconnect con0;
+connection default;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/select_high_prio.test b/mysql-test/suite/storage_engine/select_high_prio.test
new file mode 100644
index 00000000..4f1d1b39
--- /dev/null
+++ b/mysql-test/suite/storage_engine/select_high_prio.test
@@ -0,0 +1,137 @@
+#
+# SELECT HIGH_PRIOIRITY
+#
+--source have_engine.inc
+
+--source include/count_sessions.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# We will have 3 connections:
+# con1 will lock a table in READ mode
+# con0 will run UPDATE (and will wait on the lock)
+# con2 will start another SELECT
+# con1 will then unlock the table
+#
+# With standard SELECT we should see updated rows in the 2nd result set,
+# while with SELECT HIGH_PRIORITY we should still see only old rows in con2 resultset
+# (and it shouldn't wait till the table is unlocked and UPDATE is executed).
+
+--connect (con0,localhost,root,,)
+SET lock_wait_timeout = 4;
+--connect (con1,localhost,root,,)
+SET lock_wait_timeout = 4;
+--connect (con2,localhost,root,,)
+SET lock_wait_timeout = 4;
+
+
+# Part 1: Standard SELECT
+# should be executed after the UPDATE
+
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
+
+--connection con1
+LOCK TABLE t1 READ;
+
+--connection con0
+--send
+UPDATE t1 SET b = CONCAT(b,b);
+
+--connection con2
+let $show_statement = SHOW PROCESSLIST;
+let $field = State;
+let $condition = LIKE 'Waiting for table%';
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+--send
+SELECT a,b FROM t1;
+
+--connection con1
+let $show_statement = SHOW PROCESSLIST;
+let $field = Info;
+let $condition = = 'SELECT a,b FROM t1';
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+if (!$found)
+{
+ --let $mysql_errname = timeout in wait_show_condition.inc
+ --let $functionality = Table locking or UPDATE
+ --source unexpected_result.inc
+}
+
+UNLOCK TABLES;
+
+--connection con0
+--reap
+if ($mysql_errname)
+{
+ --let $my_last_stmt = UPDATE t1 SET b = CONCAT(b,b)
+ --let $functionality = UPDATE
+ --source unexpected_result.inc
+}
+
+--connection con2
+--echo # Should return the new data
+--sorted_result
+--reap
+
+DROP TABLE t1;
+
+
+# Part 2: SELECT HIGH_PRIORITY
+# should be executed before the UPDATE
+
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'f'),(2,'b');
+
+--connection con1
+LOCK TABLE t1 READ;
+
+--connection con0
+--send
+UPDATE t1 SET b = CONCAT(b,b,b);
+
+--connection con2
+let $condition = LIKE 'Waiting for table%';
+let $field = State;
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+SET lock_wait_timeout = 1;
+--echo # Should return old data
+--sorted_result
+SELECT HIGH_PRIORITY * FROM t1;
+if ($mysql_errname)
+{
+ --let $functionality = SELECT HIGH_PRIORITY
+ --source unexpected_result.inc
+}
+
+--connection con1
+UNLOCK TABLES;
+
+--connection con0
+--reap
+if ($mysql_errname)
+{
+ --let $my_last_stmt = UPDATE t1 SET b = CONCAT(b,b,b)
+ --let $functionality = UPDATE
+ --source unexpected_result.inc
+}
+
+--disconnect con1
+--disconnect con2
+--disconnect con0
+let $wait_timeout = 30;
+
+--connection default
+
+# Cleanup
+DROP TABLE t1;
+
+--source include/wait_until_count_sessions.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/show_engine.result b/mysql-test/suite/storage_engine/show_engine.result
new file mode 100644
index 00000000..ab8c6b8f
--- /dev/null
+++ b/mysql-test/suite/storage_engine/show_engine.result
@@ -0,0 +1,11 @@
+# For most engines SHOW ENGINE .. STATUS produces an empty result,
+# so the default result file is empty; but returning a value here is not an error.
+# The Status column is masked, because it is likely to contain some
+# volatile data (timestamps, memory info, etc.)
+SHOW ENGINE <STORAGE_ENGINE> STATUS;
+Type Name Status
+<STORAGE_ENGINE> ### Engine status, can be long and changeable ###
+# For SHOW MUTEX even the number of lines is volatile, so the result logging is disabled,
+# the test only checks that the command does not produce any errors
+SHOW ENGINE <STORAGE_ENGINE> MUTEX;
+SHOW ENGINE ALL MUTEX;
diff --git a/mysql-test/suite/storage_engine/show_engine.test b/mysql-test/suite/storage_engine/show_engine.test
new file mode 100644
index 00000000..dca0c6b3
--- /dev/null
+++ b/mysql-test/suite/storage_engine/show_engine.test
@@ -0,0 +1,31 @@
+#
+# SHOW ENGINE STATUS command
+#
+# The result might be empty, in which case the test will require rdiff,
+# as it is optimistically expects some output from the command
+#
+
+--source have_engine.inc
+
+--echo # For most engines SHOW ENGINE .. STATUS produces an empty result,
+--echo # so the default result file is empty; but returning a value here is not an error.
+--echo # The Status column is masked, because it is likely to contain some
+--echo # volatile data (timestamps, memory info, etc.)
+
+--source mask_engine.inc
+--replace_column 3 '### Engine status, can be long and changeable ###'
+eval
+SHOW ENGINE $storage_engine STATUS;
+
+--echo # For SHOW MUTEX even the number of lines is volatile, so the result logging is disabled,
+--echo # the test only checks that the command does not produce any errors
+--disable_result_log
+--source mask_engine.inc
+eval
+SHOW ENGINE $storage_engine MUTEX;
+--source mask_engine.inc
+SHOW ENGINE ALL MUTEX;
+--enable_result_log
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/show_table_status.result b/mysql-test/suite/storage_engine/show_table_status.result
new file mode 100644
index 00000000..b020bbe6
--- /dev/null
+++ b/mysql-test/suite/storage_engine/show_table_status.result
@@ -0,0 +1,68 @@
+DROP TABLE IF EXISTS t1, t2, t3;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (100,'a'),(2,'foo');
+CREATE TABLE t2 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t2 (a,b) VALUES (1,'bar');
+CREATE TABLE t3 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHARACTER SET utf8;
+SHOW TABLE STATUS WHERE name IN ( 't1', 't2', 't3' );
+Name t1
+Engine <STORAGE_ENGINE>
+Version 10
+Row_format ###
+Rows 2
+Avg_row_length ###
+Data_length ###
+Max_data_length ###
+Index_length ###
+Data_free ###
+Auto_increment NULL
+Create_time ###
+Update_time ###
+Check_time NULL
+Collation latin1_swedish_ci
+Checksum NULL
+Create_options
+Comment
+Max_index_length ###
+Temporary N
+Name t2
+Engine <STORAGE_ENGINE>
+Version 10
+Row_format ###
+Rows 1
+Avg_row_length ###
+Data_length ###
+Max_data_length ###
+Index_length ###
+Data_free ###
+Auto_increment NULL
+Create_time ###
+Update_time ###
+Check_time NULL
+Collation latin1_swedish_ci
+Checksum NULL
+Create_options
+Comment
+Max_index_length ###
+Temporary N
+Name t3
+Engine <STORAGE_ENGINE>
+Version 10
+Row_format ###
+Rows 0
+Avg_row_length ###
+Data_length ###
+Max_data_length ###
+Index_length ###
+Data_free ###
+Auto_increment NULL
+Create_time ###
+Update_time ###
+Check_time NULL
+Collation utf8_general_ci
+Checksum NULL
+Create_options
+Comment
+Max_index_length ###
+Temporary N
+DROP TABLE t1, t2, t3;
diff --git a/mysql-test/suite/storage_engine/show_table_status.test b/mysql-test/suite/storage_engine/show_table_status.test
new file mode 100644
index 00000000..2fd5c6a7
--- /dev/null
+++ b/mysql-test/suite/storage_engine/show_table_status.test
@@ -0,0 +1,30 @@
+#
+# SHOW TABLE STATUS statement
+#
+# Note: the output might be different if even with such tiny tables
+# the number of rows is approximate. In this case rdiff will be needed
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, t3;
+--enable_warnings
+
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (100,'a'),(2,'foo');
+
+--let $table_name = t2
+--source create_table.inc
+INSERT INTO t2 (a,b) VALUES (1,'bar');
+
+--let $table_name = t3
+--let $table_options = CHARACTER SET utf8
+--source create_table.inc
+
+--replace_column 2 <STORAGE_ENGINE> 4 ### 6 ### 7 ### 8 ### 9 ### 10 ### 12 ### 13 ### 19 ###
+--query_vertical SHOW TABLE STATUS WHERE name IN ( 't1', 't2', 't3' )
+DROP TABLE t1, t2, t3;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/strict_check_errors.inc b/mysql-test/suite/storage_engine/strict_check_errors.inc
new file mode 100644
index 00000000..f28fccb0
--- /dev/null
+++ b/mysql-test/suite/storage_engine/strict_check_errors.inc
@@ -0,0 +1,23 @@
+#
+# Since we run tests in disable_abort_on_error mode, we cannot use --error command,
+# and need to check the result manually.
+# Usage in a test:
+# --let $error_codes = <comma-separated list> # optional, default ''
+# --let $mysql_errname = <error name> # optional, default current $mysql_errname (from the last SQL command)
+# --let $mysql_errno = <error code> # optional, default current $mysql_errno (from the last SQL command)
+#
+# The difference between strict_check_errors.inc and check_errors.inc is only
+# that they will produce different messages when there is a list of acceptable error codes (more than one),
+# and the statement finished with one of them.
+
+# If a list contained more than one error, it could be on one of two reasons:
+# first, we do not care which code it is, as long as it is one of the listed errors.
+# In this case we will suggest to add an rdiff file if the message differs.
+# Second, check_errors might be called from a generalized include file or test,
+# which runs with different parameters and thus might produce different results for the same statement.
+# Then, the message will be stricter, as the difference with the result file is actually a problem
+# which needs to be checked at least.
+
+--let $strict_check = 1
+--source check_errors.inc
+
diff --git a/mysql-test/suite/storage_engine/tbl_opt_ai.result b/mysql-test/suite/storage_engine/tbl_opt_ai.result
new file mode 100644
index 00000000..d83e446b
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_ai.result
@@ -0,0 +1,14 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> AUTO_INCREMENT=10;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> AUTO_INCREMENT=10 DEFAULT CHARSET=latin1
+ALTER TABLE t1 AUTO_INCREMENT=100;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> AUTO_INCREMENT=100 DEFAULT CHARSET=latin1
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/tbl_opt_ai.test b/mysql-test/suite/storage_engine/tbl_opt_ai.test
new file mode 100644
index 00000000..e0d26cd4
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_ai.test
@@ -0,0 +1,35 @@
+#
+# Check whether AUTO_INCREMENT option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $create_definition = a $int_col
+--let $table_options = AUTO_INCREMENT=10
+--source create_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = AUTO_INCREMENT=100
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/tbl_opt_avg_row_length.result b/mysql-test/suite/storage_engine/tbl_opt_avg_row_length.result
new file mode 100644
index 00000000..39debfcc
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_avg_row_length.result
@@ -0,0 +1,16 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> AVG_ROW_LENGTH=300;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 AVG_ROW_LENGTH=300
+ALTER TABLE t1 AVG_ROW_LENGTH=30000000;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 AVG_ROW_LENGTH=30000000
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/tbl_opt_avg_row_length.test b/mysql-test/suite/storage_engine/tbl_opt_avg_row_length.test
new file mode 100644
index 00000000..2ddde478
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_avg_row_length.test
@@ -0,0 +1,35 @@
+#
+# Check whether AVG_ROW_LENGTH option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $table_options = AVG_ROW_LENGTH=300
+--source create_table.inc
+
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = AVG_ROW_LENGTH=30000000
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/tbl_opt_checksum.result b/mysql-test/suite/storage_engine/tbl_opt_checksum.result
new file mode 100644
index 00000000..3f86eb08
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_checksum.result
@@ -0,0 +1,16 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CHECKSUM=1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 CHECKSUM=1
+ALTER TABLE t1 CHECKSUM=0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/tbl_opt_checksum.test b/mysql-test/suite/storage_engine/tbl_opt_checksum.test
new file mode 100644
index 00000000..04d8cf9d
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_checksum.test
@@ -0,0 +1,30 @@
+#
+# Check whether CHECKSUM option is supported
+# in CREATE and ALTER TABLE.
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $table_options = CHECKSUM=1
+--source create_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = CHECKSUM=0
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/tbl_opt_connection.result b/mysql-test/suite/storage_engine/tbl_opt_connection.result
new file mode 100644
index 00000000..e382613f
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_connection.result
@@ -0,0 +1,24 @@
+DROP TABLE IF EXISTS t1;
+CREATE DATABASE test_remote;
+CREATE SERVER test_connection FOREIGN DATA WRAPPER mysql
+OPTIONS (USER 'root', HOST 'localhost', DATABASE 'test_remote');
+CREATE SERVER test_connection2 FOREIGN DATA WRAPPER mysql
+OPTIONS (USER 'root', HOST 'localhost', DATABASE 'test_remote');
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> CONNECTION='test_connection';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 CONNECTION='test_connection'
+ALTER TABLE t1 CONNECTION='test_connection2';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 CONNECTION='test_connection2'
+DROP TABLE t1;
+DROP SERVER test_connection;
+DROP SERVER test_connection2;
+DROP DATABASE test_remote;
diff --git a/mysql-test/suite/storage_engine/tbl_opt_connection.test b/mysql-test/suite/storage_engine/tbl_opt_connection.test
new file mode 100644
index 00000000..df92df7e
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_connection.test
@@ -0,0 +1,52 @@
+#
+# Check whether CONNECTION option is supported
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE DATABASE test_remote;
+CREATE SERVER test_connection FOREIGN DATA WRAPPER mysql
+OPTIONS (USER 'root', HOST 'localhost', DATABASE 'test_remote');
+CREATE SERVER test_connection2 FOREIGN DATA WRAPPER mysql
+OPTIONS (USER 'root', HOST 'localhost', DATABASE 'test_remote');
+
+--let $table_options = CONNECTION='test_connection'
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --source mask_engine.inc
+ SHOW CREATE TABLE t1;
+ --let $alter_definition = CONNECTION='test_connection2'
+ --source alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+ }
+ --source mask_engine.inc
+ SHOW CREATE TABLE t1;
+
+ DROP TABLE t1;
+}
+
+DROP SERVER test_connection;
+DROP SERVER test_connection2;
+DROP DATABASE test_remote;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/tbl_opt_data_dir.result b/mysql-test/suite/storage_engine/tbl_opt_data_dir.result
new file mode 100644
index 00000000..19b7d539
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_data_dir.result
@@ -0,0 +1,19 @@
+DROP TABLE IF EXISTS t1;
+# Running CREATE TABLE .. DATA DIRECTORY = <>
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 DATA DIRECTORY='<DATA_DIR_1>'
+# For ALTER TABLE the option is ignored
+# Running ALTER TABLE .. DATA DIRECTORY = <>
+Warnings:
+Warning 1618 <DATA DIRECTORY> option ignored
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 DATA DIRECTORY='<DATA_DIR_1>'
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/tbl_opt_data_dir.test b/mysql-test/suite/storage_engine/tbl_opt_data_dir.test
new file mode 100644
index 00000000..434ca449
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_data_dir.test
@@ -0,0 +1,52 @@
+#
+# Check whether DATA DIRECTORY is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only that it is accepted
+#
+
+--source include/have_symlink.inc
+--source have_engine.inc
+
+--let $data_dir1 = $MYSQLTEST_VARDIR/storage_engine_data_dir1/
+--let $data_dir2 = $MYSQLTEST_VARDIR/storage_engine_data_dir2/
+--mkdir $data_dir1
+--mkdir $data_dir2
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $table_options = DATA DIRECTORY = '$data_dir1'
+# We cannot mask the folder name here and further, but we can switch off query logging
+--let $disable_query_log = 1
+--echo # Running CREATE TABLE .. DATA DIRECTORY = <>
+--source create_table.inc
+
+--source mask_engine.inc
+--replace_result $data_dir1 <DATA_DIR_1>
+SHOW CREATE TABLE t1;
+
+--echo # For ALTER TABLE the option is ignored
+
+--let $alter_definition = DATA DIRECTORY = '$data_dir2'
+--disable_query_log
+--echo # Running ALTER TABLE .. DATA DIRECTORY = <>
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+--enable_query_log
+--source mask_engine.inc
+--replace_result $data_dir1 <DATA_DIR_1>
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
+--rmdir $data_dir1
+--rmdir $data_dir2
diff --git a/mysql-test/suite/storage_engine/tbl_opt_delay_key_write.result b/mysql-test/suite/storage_engine/tbl_opt_delay_key_write.result
new file mode 100644
index 00000000..170f7b78
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_delay_key_write.result
@@ -0,0 +1,16 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> DELAY_KEY_WRITE=1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 DELAY_KEY_WRITE=1
+ALTER TABLE t1 DELAY_KEY_WRITE=0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/tbl_opt_delay_key_write.test b/mysql-test/suite/storage_engine/tbl_opt_delay_key_write.test
new file mode 100644
index 00000000..724cd9e0
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_delay_key_write.test
@@ -0,0 +1,35 @@
+#
+# Check whether DELAY_KEY_WRITE option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $table_options = DELAY_KEY_WRITE=1
+--source create_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = DELAY_KEY_WRITE=0
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/tbl_opt_index_dir.result b/mysql-test/suite/storage_engine/tbl_opt_index_dir.result
new file mode 100644
index 00000000..c7368e9a
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_index_dir.result
@@ -0,0 +1,19 @@
+DROP TABLE IF EXISTS t1;
+# Running CREATE TABLE .. INDEX DIRECTORY = <>
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 INDEX DIRECTORY='<INDEX_DIR_1>'
+# For ALTER TABLE the option is ignored
+# Running ALTER TABLE .. INDEX DIRECTORY = <>
+Warnings:
+Warning 1618 <INDEX DIRECTORY> option ignored
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 INDEX DIRECTORY='<INDEX_DIR_1>'
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/tbl_opt_index_dir.test b/mysql-test/suite/storage_engine/tbl_opt_index_dir.test
new file mode 100644
index 00000000..03d2ef2b
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_index_dir.test
@@ -0,0 +1,52 @@
+#
+# Check whether INDEX DIRECTORY is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only that it is accepted
+#
+
+--source include/have_symlink.inc
+--source have_engine.inc
+
+--let $index_dir1 = $MYSQLTEST_VARDIR/storage_engine_index_dir1/
+--let $index_dir2 = $MYSQLTEST_VARDIR/storage_engine_index_dir2/
+--mkdir $index_dir1
+--mkdir $index_dir2
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $table_options = INDEX DIRECTORY = '$index_dir1'
+# We cannot mask the folder name here and further, but we can switch off query logging
+--let $disable_query_log = 1
+--echo # Running CREATE TABLE .. INDEX DIRECTORY = <>
+--source create_table.inc
+
+--source mask_engine.inc
+--replace_result $index_dir1 <INDEX_DIR_1>
+SHOW CREATE TABLE t1;
+
+--echo # For ALTER TABLE the option is ignored
+
+--let $alter_definition = INDEX DIRECTORY = '$index_dir2'
+--disable_query_log
+--echo # Running ALTER TABLE .. INDEX DIRECTORY = <>
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+--enable_query_log
+--source mask_engine.inc
+--replace_result $index_dir1 <INDEX_DIR_1>
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
+--rmdir $index_dir1
+--rmdir $index_dir2
diff --git a/mysql-test/suite/storage_engine/tbl_opt_insert_method.result b/mysql-test/suite/storage_engine/tbl_opt_insert_method.result
new file mode 100644
index 00000000..e538c821
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_insert_method.result
@@ -0,0 +1,16 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> INSERT_METHOD=FIRST;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 INSERT_METHOD=FIRST
+ALTER TABLE t1 INSERT_METHOD=NO;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/tbl_opt_insert_method.test b/mysql-test/suite/storage_engine/tbl_opt_insert_method.test
new file mode 100644
index 00000000..29378e74
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_insert_method.test
@@ -0,0 +1,35 @@
+#
+# Check whether INSERT_METHOD option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $table_options = INSERT_METHOD=FIRST
+--source create_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = INSERT_METHOD=NO
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/tbl_opt_key_block_size.result b/mysql-test/suite/storage_engine/tbl_opt_key_block_size.result
new file mode 100644
index 00000000..f76fdb0c
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_key_block_size.result
@@ -0,0 +1,16 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> KEY_BLOCK_SIZE=8;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=8
+ALTER TABLE t1 KEY_BLOCK_SIZE=1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=1
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/tbl_opt_key_block_size.test b/mysql-test/suite/storage_engine/tbl_opt_key_block_size.test
new file mode 100644
index 00000000..9c9109a9
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_key_block_size.test
@@ -0,0 +1,35 @@
+#
+# Check whether KEY_BLOCK_SIZE option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $table_options = KEY_BLOCK_SIZE=8
+--source create_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = KEY_BLOCK_SIZE=1
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/tbl_opt_max_rows.result b/mysql-test/suite/storage_engine/tbl_opt_max_rows.result
new file mode 100644
index 00000000..977cf53a
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_max_rows.result
@@ -0,0 +1,16 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> MAX_ROWS=10000000;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 MAX_ROWS=10000000
+ALTER TABLE t1 MAX_ROWS=30000000;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 MAX_ROWS=30000000
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/tbl_opt_max_rows.test b/mysql-test/suite/storage_engine/tbl_opt_max_rows.test
new file mode 100644
index 00000000..cbf9ad93
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_max_rows.test
@@ -0,0 +1,35 @@
+#
+# Check whether MAX_ROWS option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $table_options = MAX_ROWS=10000000
+--source create_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = MAX_ROWS=30000000
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/tbl_opt_min_rows.result b/mysql-test/suite/storage_engine/tbl_opt_min_rows.result
new file mode 100644
index 00000000..0407d6b6
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_min_rows.result
@@ -0,0 +1,16 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> MIN_ROWS=1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 MIN_ROWS=1
+ALTER TABLE t1 MIN_ROWS=10000;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 MIN_ROWS=10000
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/tbl_opt_min_rows.test b/mysql-test/suite/storage_engine/tbl_opt_min_rows.test
new file mode 100644
index 00000000..75b6e7b1
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_min_rows.test
@@ -0,0 +1,35 @@
+#
+# Check whether MIN_ROWS option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $table_options = MIN_ROWS=1
+--source create_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = MIN_ROWS=10000
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/tbl_opt_pack_keys.result b/mysql-test/suite/storage_engine/tbl_opt_pack_keys.result
new file mode 100644
index 00000000..1f56c035
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_pack_keys.result
@@ -0,0 +1,16 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PACK_KEYS=1;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 PACK_KEYS=1
+ALTER TABLE t1 PACK_KEYS=0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 PACK_KEYS=0
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/tbl_opt_pack_keys.test b/mysql-test/suite/storage_engine/tbl_opt_pack_keys.test
new file mode 100644
index 00000000..f0d9387f
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_pack_keys.test
@@ -0,0 +1,35 @@
+#
+# Check whether PACK KEYS option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $table_options = PACK_KEYS=1
+--source create_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = PACK_KEYS=0
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/tbl_opt_password.result b/mysql-test/suite/storage_engine/tbl_opt_password.result
new file mode 100644
index 00000000..43c409da
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_password.result
@@ -0,0 +1,16 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> PASSWORD='password';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+ALTER TABLE t1 PASSWORD='new_password';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/tbl_opt_password.test b/mysql-test/suite/storage_engine/tbl_opt_password.test
new file mode 100644
index 00000000..471295e5
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_password.test
@@ -0,0 +1,40 @@
+#
+# Check whether PASSWORD option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+# This option is not supported by any known engines,
+# that's why the result file does not contain it;
+# but it's syntactically acceptable.
+#
+
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $table_options = PASSWORD='password'
+--source create_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = PASSWORD='new_password'
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/tbl_opt_row_format.result b/mysql-test/suite/storage_engine/tbl_opt_row_format.result
new file mode 100644
index 00000000..57000e29
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_row_format.result
@@ -0,0 +1,30 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> ROW_FORMAT=DYNAMIC;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
+ALTER TABLE t1 ROW_FORMAT=FIXED;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
+ALTER TABLE t1 ROW_FORMAT=PAGE;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 ROW_FORMAT=PAGE
+ALTER TABLE t1 ROW_FORMAT=COMPACT;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/tbl_opt_row_format.test b/mysql-test/suite/storage_engine/tbl_opt_row_format.test
new file mode 100644
index 00000000..17fe2f36
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_row_format.test
@@ -0,0 +1,59 @@
+#
+# Check whether ROW_FORMAT option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $table_options = ROW_FORMAT=DYNAMIC
+--source create_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = ROW_FORMAT=FIXED
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = ROW_FORMAT=PAGE
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+
+--let $alter_definition = ROW_FORMAT=COMPACT
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/tbl_opt_union.result b/mysql-test/suite/storage_engine/tbl_opt_union.result
new file mode 100644
index 00000000..81521eff
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_union.result
@@ -0,0 +1,14 @@
+DROP TABLE IF EXISTS t1, child1, child2;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> UNION(child1);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 UNION=(`child1`)
+ALTER TABLE t1 UNION = (child1,child2);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 UNION=(`child1`,`child2`)
+DROP TABLE t1, child1, child2;
diff --git a/mysql-test/suite/storage_engine/tbl_opt_union.test b/mysql-test/suite/storage_engine/tbl_opt_union.test
new file mode 100644
index 00000000..fa134ab8
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_opt_union.test
@@ -0,0 +1,41 @@
+#
+# Check whether UNION option
+# is supported in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the option
+# has any real effect on the table, only
+# that it's accepted
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, child1, child2;
+--enable_warnings
+
+--disable_query_log
+eval CREATE TABLE child1 (a $int_col) ENGINE=MyISAM;
+eval CREATE TABLE child2 (a $int_col) ENGINE=MyISAM;
+--enable_query_log
+
+--let $table_options = UNION(child1)
+--let $create_definition = a $int_col
+--source create_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+--let $alter_definition = UNION = (child1,child2)
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1, child1, child2;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/tbl_standard_opts.result b/mysql-test/suite/storage_engine/tbl_standard_opts.result
new file mode 100644
index 00000000..b4b183aa
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_standard_opts.result
@@ -0,0 +1,40 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS> DEFAULT CHARACTER SET = utf8
+COLLATE = utf8_general_ci
+COMMENT = 'standard table options'
+;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=utf8 COMMENT='standard table options'
+ALTER TABLE t1 COMMENT = 'table altered';
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=utf8 COMMENT='table altered'
+ALTER TABLE t1 ENGINE=MEMORY;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=MEMORY DEFAULT CHARSET=utf8 COMMENT='table altered'
+ALTER TABLE t1 ENGINE=<STORAGE_ENGINE>;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=utf8 COMMENT='table altered'
+ALTER TABLE t1 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) CHARACTER SET utf8 DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1 COMMENT='table altered'
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/tbl_standard_opts.test b/mysql-test/suite/storage_engine/tbl_standard_opts.test
new file mode 100644
index 00000000..7e723788
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_standard_opts.test
@@ -0,0 +1,60 @@
+#
+# Standard options in CREATE and ALTER TABLE
+#
+# Note: the test does not check whether the options
+# have any real effect on the table, only
+# that they are accepted
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Create table with standard options
+
+let $table_options =
+ DEFAULT CHARACTER SET = utf8
+ COLLATE = utf8_general_ci
+ COMMENT = 'standard table options'
+;
+--source create_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+
+# Alter comment
+
+--let $alter_definition = COMMENT = 'table altered'
+--source alter_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+}
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+# Alter ENGINE value
+
+--let $alter_definition = ENGINE=MEMORY
+--source alter_table.inc
+SHOW CREATE TABLE t1;
+--let $alter_definition = ENGINE=$storage_engine
+--source alter_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+# Alter character set and collation
+
+--let $alter_definition = CHARACTER SET = latin1 COLLATE = latin1_swedish_ci
+--source alter_table.inc
+--source mask_engine.inc
+SHOW CREATE TABLE t1;
+
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/tbl_temporary.result b/mysql-test/suite/storage_engine/tbl_temporary.result
new file mode 100644
index 00000000..b81fa0a7
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_temporary.result
@@ -0,0 +1,11 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c CHAR(1)) ENGINE=MyISAM;
+CREATE TEMPORARY TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TEMPORARY TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `b` char(8) DEFAULT NULL
+) ENGINE=<STORAGE_ENGINE> DEFAULT CHARSET=latin1
+DROP TEMPORARY TABLE t1;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/tbl_temporary.test b/mysql-test/suite/storage_engine/tbl_temporary.test
new file mode 100644
index 00000000..66b63fd2
--- /dev/null
+++ b/mysql-test/suite/storage_engine/tbl_temporary.test
@@ -0,0 +1,33 @@
+#
+# The test checks whether a temporary table
+# can be created with the engine under test.
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# This is a base table which we want to mask
+CREATE TABLE t1 (c CHAR(1)) ENGINE=MyISAM;
+
+--let $temporary = 1
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Temporary tables
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --source mask_engine.inc
+ SHOW CREATE TABLE t1;
+
+ DROP TEMPORARY TABLE t1;
+}
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/truncate_table.result b/mysql-test/suite/storage_engine/truncate_table.result
new file mode 100644
index 00000000..eac58272
--- /dev/null
+++ b/mysql-test/suite/storage_engine/truncate_table.result
@@ -0,0 +1,41 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+TRUNCATE TABLE t1;
+INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c');
+TRUNCATE TABLE t1;
+SELECT a,b FROM t1;
+a b
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN> KEY AUTO_INCREMENT, c <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 # # # # # # # # # 1 # # # # # # # # N
+INSERT INTO t1 (c) VALUES ('a'),('b'),('c');
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 # # # # # # # # # 4 # # # # # # # # N
+TRUNCATE TABLE t1;
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 # # # # # # # # # 1 # # # # # # # # N
+INSERT INTO t1 (c) VALUES ('d');
+SHOW TABLE STATUS LIKE 't1';
+Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
+t1 # # # # # # # # # 2 # # # # # # # # N
+SELECT a,c FROM t1;
+a c
+1 d
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c');
+HANDLER t1 OPEN AS h1;
+HANDLER h1 READ FIRST;
+a b
+1 a
+TRUNCATE TABLE t1;
+HANDLER h1 READ NEXT;
+ERROR 42S02: Unknown table 'h1' in HANDLER
+HANDLER t1 OPEN AS h2;
+HANDLER h2 READ FIRST;
+a b
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/truncate_table.test b/mysql-test/suite/storage_engine/truncate_table.test
new file mode 100644
index 00000000..6a6301f4
--- /dev/null
+++ b/mysql-test/suite/storage_engine/truncate_table.test
@@ -0,0 +1,81 @@
+#
+# TRUNCATE TABLE
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--source create_table.inc
+TRUNCATE TABLE t1;
+if ($mysql_errname)
+{
+ --let $functionality = TRUNCATE TABLE
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (1,'a'), (2,'b'), (3,'c');
+ TRUNCATE TABLE t1;
+ SELECT a,b FROM t1;
+}
+DROP TABLE t1;
+
+
+# Truncate resets auto-increment value on the table
+
+--let $create_definition = a $int_indexed_col KEY AUTO_INCREMENT, c $char_col
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = PK or AUTO_INCREMENT
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 # 19 #
+ SHOW TABLE STATUS LIKE 't1';
+
+ INSERT INTO t1 (c) VALUES ('a'),('b'),('c');
+ --replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 # 19 #
+ SHOW TABLE STATUS LIKE 't1';
+
+ TRUNCATE TABLE t1;
+ --replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 # 19 #
+ SHOW TABLE STATUS LIKE 't1';
+
+ INSERT INTO t1 (c) VALUES ('d');
+ --replace_column 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 10 # 12 # 13 # 14 # 15 # 16 # 17 # 18 # 19 #
+ SHOW TABLE STATUS LIKE 't1';
+
+ SELECT a,c FROM t1;
+ DROP TABLE t1;
+}
+
+# Truncate closes handlers
+
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c');
+HANDLER t1 OPEN AS h1;
+if ($mysql_errname)
+{
+ --let $functionality = HANDLER
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ HANDLER h1 READ FIRST;
+ TRUNCATE TABLE t1;
+ --let $error_codes = ER_UNKNOWN_TABLE
+ HANDLER h1 READ NEXT;
+ --source check_errors.inc
+ HANDLER t1 OPEN AS h2;
+ HANDLER h2 READ FIRST;
+}
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/trx/cons_snapshot_repeatable_read.result b/mysql-test/suite/storage_engine/trx/cons_snapshot_repeatable_read.result
new file mode 100644
index 00000000..3b0bdb3b
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/cons_snapshot_repeatable_read.result
@@ -0,0 +1,18 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+connection con2;
+INSERT INTO t1 (a) VALUES (1);
+connection con1;
+# If consistent read works on this isolation level (REPEATABLE READ), the following SELECT should not return the value we inserted (1)
+SELECT a FROM t1;
+a
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/trx/cons_snapshot_repeatable_read.test b/mysql-test/suite/storage_engine/trx/cons_snapshot_repeatable_read.test
new file mode 100644
index 00000000..e44e260e
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/cons_snapshot_repeatable_read.test
@@ -0,0 +1,9 @@
+--source ../have_engine.inc
+--source support_transactions.inc
+
+let $trx_isolation = REPEATABLE READ;
+
+--source consistent_snapshot.inc
+
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/trx/cons_snapshot_serializable.result b/mysql-test/suite/storage_engine/trx/cons_snapshot_serializable.result
new file mode 100644
index 00000000..691039e8
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/cons_snapshot_serializable.result
@@ -0,0 +1,18 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+connection con2;
+INSERT INTO t1 (a) VALUES (1);
+connection con1;
+# If consistent read works on this isolation level (SERIALIZABLE), the following SELECT should not return the value we inserted (1)
+SELECT a FROM t1;
+a
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/trx/cons_snapshot_serializable.test b/mysql-test/suite/storage_engine/trx/cons_snapshot_serializable.test
new file mode 100644
index 00000000..9d516066
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/cons_snapshot_serializable.test
@@ -0,0 +1,9 @@
+--source ../have_engine.inc
+--source support_transactions.inc
+
+let $trx_isolation = SERIALIZABLE;
+
+--source consistent_snapshot.inc
+
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/trx/consistent_snapshot.inc b/mysql-test/suite/storage_engine/trx/consistent_snapshot.inc
new file mode 100644
index 00000000..cbc1f063
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/consistent_snapshot.inc
@@ -0,0 +1,48 @@
+#
+# TRANSACTION WITH CONSISTENT SNAPSHOT
+#
+
+--source ../have_engine.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+
+connection con1;
+
+let $create_definition = a $int_col;
+--source ../create_table.inc
+
+eval SET SESSION TRANSACTION ISOLATION LEVEL $trx_isolation;
+
+# While a consistent snapshot transaction is executed,
+# no external inserts should be visible to the transaction.
+# But it should only work this way for REPEATABLE-READ and SERIALIZABLE
+
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+
+connection con2;
+INSERT INTO t1 (a) VALUES (1);
+if ($mysql_errname)
+{
+ --echo # INSERT finished with error $mysql_errname
+}
+
+connection con1;
+--echo # If consistent read works on this isolation level ($trx_isolation), the following SELECT should not return the value we inserted (1)
+SELECT a FROM t1;
+COMMIT;
+
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
+
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/suite/storage_engine/trx/delete.result b/mysql-test/suite/storage_engine/trx/delete.result
new file mode 100644
index 00000000..14e5389d
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/delete.result
@@ -0,0 +1,72 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'f'),(7,'g'),(8,'h'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+BEGIN;
+DELETE FROM t1 WHERE b IN ('c');
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+10000 foobar
+10000 foobar
+2 b
+2 b
+4 d
+4 d
+5 e
+5 e
+6 f
+6 f
+7 g
+7 g
+8 h
+8 h
+DELETE FROM t1 WHERE a < 0 OR b = 'a';
+COMMIT;
+SELECT a,b FROM t1;
+a b
+10000 foobar
+10000 foobar
+2 b
+2 b
+4 d
+4 d
+5 e
+5 e
+6 f
+6 f
+7 g
+7 g
+8 h
+8 h
+BEGIN;
+DELETE FROM t1 WHERE a <= 4 ORDER BY b DESC LIMIT 1;
+SAVEPOINT spt1;
+DELETE FROM t1;
+RELEASE SAVEPOINT spt1;
+ROLLBACK;
+SELECT a,b FROM t1;
+a b
+10000 foobar
+10000 foobar
+2 b
+2 b
+4 d
+4 d
+5 e
+5 e
+6 f
+6 f
+7 g
+7 g
+8 h
+8 h
+BEGIN;
+DELETE FROM t1 WHERE a <= 4 ORDER BY b DESC LIMIT 1;
+SAVEPOINT spt1;
+DELETE FROM t1;
+INSERT INTO t1 (a,b) VALUES (1,'a');
+ROLLBACK TO SAVEPOINT spt1;
+COMMIT;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/trx/delete.test b/mysql-test/suite/storage_engine/trx/delete.test
new file mode 100644
index 00000000..50da1f20
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/delete.test
@@ -0,0 +1,51 @@
+#
+# Transactional DELETE
+#
+
+--source ../have_engine.inc
+--source support_transactions.inc
+--source support_savepoints.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--source ../create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'f'),(7,'g'),(8,'h'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+
+BEGIN;
+DELETE FROM t1 WHERE b IN ('c');
+if ($mysql_errname)
+{
+ --let $functionality = DELETE
+ --source ../unexpected_result.inc
+}
+--sorted_result
+SELECT a,b FROM t1;
+DELETE FROM t1 WHERE a < 0 OR b = 'a';
+COMMIT;
+--sorted_result
+SELECT a,b FROM t1;
+
+BEGIN;
+DELETE FROM t1 WHERE a <= 4 ORDER BY b DESC LIMIT 1;
+SAVEPOINT spt1;
+DELETE FROM t1;
+RELEASE SAVEPOINT spt1;
+ROLLBACK;
+--sorted_result
+SELECT a,b FROM t1;
+
+BEGIN;
+DELETE FROM t1 WHERE a <= 4 ORDER BY b DESC LIMIT 1;
+SAVEPOINT spt1;
+DELETE FROM t1;
+INSERT INTO t1 (a,b) VALUES (1,'a');
+ROLLBACK TO SAVEPOINT spt1;
+COMMIT;
+
+DROP TABLE t1;
+
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/trx/insert.result b/mysql-test/suite/storage_engine/trx/insert.result
new file mode 100644
index 00000000..1d8aca98
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/insert.result
@@ -0,0 +1,55 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+BEGIN;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(100,'foo');
+INSERT t1 (a,b) VALUE (10,'foo'),(11,'abc');
+COMMIT;
+SELECT a,b FROM t1;
+a b
+1 a
+10 foo
+100 foo
+11 abc
+2 b
+3 c
+4 d
+5 e
+BEGIN;
+INSERT INTO t1 (b,a) VALUES ('test',0);
+SAVEPOINT spt1;
+INSERT INTO t1 (a,b) VALUES (DEFAULT,DEFAULT);
+RELEASE SAVEPOINT spt1;
+INSERT INTO t1 (a,b) VALUES (DEFAULT,DEFAULT);
+ROLLBACK;
+SELECT a,b FROM t1;
+a b
+1 a
+10 foo
+100 foo
+11 abc
+2 b
+3 c
+4 d
+5 e
+BEGIN;
+INSERT t1 (a) VALUE (10),(20);
+SAVEPOINT spt1;
+INSERT INTO t1 SET a = 11, b = 'f';
+INSERT t1 SET b = DEFAULT;
+ROLLBACK TO SAVEPOINT spt1;
+INSERT INTO t1 (b,a) VALUES ('test1',10);
+COMMIT;
+SELECT a,b FROM t1;
+a b
+1 a
+10 NULL
+10 foo
+10 test1
+100 foo
+11 abc
+2 b
+20 NULL
+3 c
+4 d
+5 e
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/trx/insert.test b/mysql-test/suite/storage_engine/trx/insert.test
new file mode 100644
index 00000000..1a736584
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/insert.test
@@ -0,0 +1,44 @@
+#
+# Transactional INSERT
+#
+--source ../have_engine.inc
+--source support_transactions.inc
+--source support_savepoints.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--source ../create_table.inc
+BEGIN;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(100,'foo');
+INSERT t1 (a,b) VALUE (10,'foo'),(11,'abc');
+COMMIT;
+--sorted_result
+SELECT a,b FROM t1;
+
+BEGIN;
+INSERT INTO t1 (b,a) VALUES ('test',0);
+SAVEPOINT spt1;
+INSERT INTO t1 (a,b) VALUES (DEFAULT,DEFAULT);
+RELEASE SAVEPOINT spt1;
+INSERT INTO t1 (a,b) VALUES (DEFAULT,DEFAULT);
+ROLLBACK;
+--sorted_result
+SELECT a,b FROM t1;
+
+BEGIN;
+INSERT t1 (a) VALUE (10),(20);
+SAVEPOINT spt1;
+INSERT INTO t1 SET a = 11, b = 'f';
+INSERT t1 SET b = DEFAULT;
+ROLLBACK TO SAVEPOINT spt1;
+INSERT INTO t1 (b,a) VALUES ('test1',10);
+COMMIT;
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/trx/level_read_committed.result b/mysql-test/suite/storage_engine/trx/level_read_committed.result
new file mode 100644
index 00000000..ce1b126d
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/level_read_committed.result
@@ -0,0 +1,91 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+connect con2,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+connection con1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+START TRANSACTION;
+SELECT a FROM t1;
+a
+connection con2;
+BEGIN;
+INSERT INTO t1 (a) VALUES(1);
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+connection con1;
+SELECT a FROM t1;
+a
+connection con2;
+INSERT INTO t1 (a) VALUES (2);
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+connection con1;
+SELECT a FROM t1;
+a
+INSERT INTO t1 (a) SELECT a+100 FROM t1;
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+SELECT a FROM t1;
+a
+connection con2;
+SELECT a FROM t1;
+a
+1
+2
+COMMIT;
+SELECT a FROM t1;
+a
+1
+2
+connection con1;
+SELECT a FROM t1;
+a
+1
+2
+INSERT INTO t1 (a) SELECT a+200 FROM t1;
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+SELECT a FROM t1;
+a
+1
+2
+201
+202
+COMMIT;
+SELECT a FROM t1;
+a
+1
+2
+201
+202
+connection con2;
+SELECT a FROM t1;
+a
+1
+2
+201
+202
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+connection con2;
+INSERT INTO t1 (a) VALUES (1);
+connection con1;
+# If consistent read works on this isolation level (READ COMMITTED), the following SELECT should not return the value we inserted (1)
+SELECT a FROM t1;
+a
+1
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/trx/level_read_committed.test b/mysql-test/suite/storage_engine/trx/level_read_committed.test
new file mode 100644
index 00000000..77bd562c
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/level_read_committed.test
@@ -0,0 +1,10 @@
+--source ../have_engine.inc
+--source support_transactions.inc
+
+let $trx_isolation = READ COMMITTED;
+
+--source transaction_isolation.inc
+--source consistent_snapshot.inc
+
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/trx/level_read_uncommitted.result b/mysql-test/suite/storage_engine/trx/level_read_uncommitted.result
new file mode 100644
index 00000000..68fbe563
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/level_read_uncommitted.result
@@ -0,0 +1,116 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+connect con2,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+connection con1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+START TRANSACTION;
+SELECT a FROM t1;
+a
+connection con2;
+BEGIN;
+INSERT INTO t1 (a) VALUES(1);
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+connection con1;
+SELECT a FROM t1;
+a
+1
+connection con2;
+INSERT INTO t1 (a) VALUES (2);
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+connection con1;
+SELECT a FROM t1;
+a
+1
+2
+INSERT INTO t1 (a) SELECT a+100 FROM t1;
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+SELECT a FROM t1;
+a
+1
+101
+102
+2
+connection con2;
+SELECT a FROM t1;
+a
+1
+101
+102
+2
+COMMIT;
+SELECT a FROM t1;
+a
+1
+101
+102
+2
+connection con1;
+SELECT a FROM t1;
+a
+1
+101
+102
+2
+INSERT INTO t1 (a) SELECT a+200 FROM t1;
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+SELECT a FROM t1;
+a
+1
+101
+102
+2
+201
+202
+301
+302
+COMMIT;
+SELECT a FROM t1;
+a
+1
+101
+102
+2
+201
+202
+301
+302
+connection con2;
+SELECT a FROM t1;
+a
+1
+101
+102
+2
+201
+202
+301
+302
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
+START TRANSACTION WITH CONSISTENT SNAPSHOT;
+connection con2;
+INSERT INTO t1 (a) VALUES (1);
+connection con1;
+# If consistent read works on this isolation level (READ UNCOMMITTED), the following SELECT should not return the value we inserted (1)
+SELECT a FROM t1;
+a
+1
+COMMIT;
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/trx/level_read_uncommitted.test b/mysql-test/suite/storage_engine/trx/level_read_uncommitted.test
new file mode 100644
index 00000000..48310fc2
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/level_read_uncommitted.test
@@ -0,0 +1,9 @@
+--source ../have_engine.inc
+--source support_transactions.inc
+
+let $trx_isolation = READ UNCOMMITTED;
+--source transaction_isolation.inc
+--source consistent_snapshot.inc
+
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/trx/level_repeatable_read.result b/mysql-test/suite/storage_engine/trx/level_repeatable_read.result
new file mode 100644
index 00000000..c828b18d
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/level_repeatable_read.result
@@ -0,0 +1,69 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+connect con2,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
+connection con1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+START TRANSACTION;
+SELECT a FROM t1;
+a
+connection con2;
+BEGIN;
+INSERT INTO t1 (a) VALUES(1);
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+connection con1;
+SELECT a FROM t1;
+a
+connection con2;
+INSERT INTO t1 (a) VALUES (2);
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+connection con1;
+SELECT a FROM t1;
+a
+INSERT INTO t1 (a) SELECT a+100 FROM t1;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# WARNING: Statement ended with errno 1205, errname 'ER_LOCK_WAIT_TIMEOUT'.
+# If it differs from the result file, it might indicate a problem.
+SELECT a FROM t1;
+a
+connection con2;
+SELECT a FROM t1;
+a
+1
+2
+COMMIT;
+SELECT a FROM t1;
+a
+1
+2
+connection con1;
+SELECT a FROM t1;
+a
+INSERT INTO t1 (a) SELECT a+200 FROM t1;
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+SELECT a FROM t1;
+a
+201
+202
+COMMIT;
+SELECT a FROM t1;
+a
+1
+2
+201
+202
+connection con2;
+SELECT a FROM t1;
+a
+1
+2
+201
+202
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/trx/level_repeatable_read.test b/mysql-test/suite/storage_engine/trx/level_repeatable_read.test
new file mode 100644
index 00000000..cb33d109
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/level_repeatable_read.test
@@ -0,0 +1,8 @@
+--source ../have_engine.inc
+--source support_transactions.inc
+
+let $trx_isolation = REPEATABLE READ;
+--source transaction_isolation.inc
+
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/trx/level_serializable.result b/mysql-test/suite/storage_engine/trx/level_serializable.result
new file mode 100644
index 00000000..3f57395f
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/level_serializable.result
@@ -0,0 +1,56 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+connect con2,localhost,root,,;
+SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE;
+connection con1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+START TRANSACTION;
+SELECT a FROM t1;
+a
+connection con2;
+BEGIN;
+INSERT INTO t1 (a) VALUES(1);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# WARNING: Statement ended with errno 1205, errname 'ER_LOCK_WAIT_TIMEOUT'.
+# If it differs from the result file, it might indicate a problem.
+connection con1;
+SELECT a FROM t1;
+a
+connection con2;
+INSERT INTO t1 (a) VALUES (2);
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+# WARNING: Statement ended with errno 1205, errname 'ER_LOCK_WAIT_TIMEOUT'.
+# If it differs from the result file, it might indicate a problem.
+connection con1;
+SELECT a FROM t1;
+a
+INSERT INTO t1 (a) SELECT a+100 FROM t1;
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+SELECT a FROM t1;
+a
+connection con2;
+SELECT a FROM t1;
+a
+COMMIT;
+SELECT a FROM t1;
+a
+connection con1;
+SELECT a FROM t1;
+a
+INSERT INTO t1 (a) SELECT a+200 FROM t1;
+# WARNING: Statement ended with errno 0, errname ''.
+# If it differs from the result file, it might indicate a problem.
+SELECT a FROM t1;
+a
+COMMIT;
+SELECT a FROM t1;
+a
+connection con2;
+SELECT a FROM t1;
+a
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/trx/level_serializable.test b/mysql-test/suite/storage_engine/trx/level_serializable.test
new file mode 100644
index 00000000..4372b489
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/level_serializable.test
@@ -0,0 +1,8 @@
+--source ../have_engine.inc
+--source support_transactions.inc
+
+let $trx_isolation = SERIALIZABLE;
+--source transaction_isolation.inc
+
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/trx/my.cnf b/mysql-test/suite/storage_engine/trx/my.cnf
new file mode 100644
index 00000000..e83954c4
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/my.cnf
@@ -0,0 +1,7 @@
+!include include/default_my.cnf
+
+[server]
+sql-mode=NO_ENGINE_SUBSTITUTION
+binlog-format=row
+log-bin=master-bin
+
diff --git a/mysql-test/suite/storage_engine/trx/select_for_update.result b/mysql-test/suite/storage_engine/trx/select_for_update.result
new file mode 100644
index 00000000..f5954489
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/select_for_update.result
@@ -0,0 +1,35 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'a');
+connect con1,localhost,root,,;
+BEGIN;
+SELECT a,b FROM t1 WHERE b='a' FOR UPDATE;
+a b
+1 a
+3 a
+connection default;
+SET lock_wait_timeout = 1;
+SELECT a,b FROM t1 WHERE b='a';
+a b
+1 a
+3 a
+SELECT a,b FROM t1 WHERE b='a' LOCK IN SHARE MODE;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+UPDATE t1 SET b='c' WHERE b='a';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection con1;
+COMMIT;
+SELECT a,b FROM t1;
+a b
+1 a
+2 b
+3 a
+disconnect con1;
+connection default;
+UPDATE t1 SET b='c' WHERE b='a';
+SELECT a,b FROM t1;
+a b
+1 c
+2 b
+3 c
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/trx/select_for_update.test b/mysql-test/suite/storage_engine/trx/select_for_update.test
new file mode 100644
index 00000000..0e5a3eee
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/select_for_update.test
@@ -0,0 +1,85 @@
+#
+# SELECT .. FOR UPDATE
+#
+# If the engine has its own lock timeouts,
+# it makes sense to set them to minimum to decrease
+# the duration of the test.
+
+--source ../have_engine.inc
+--source support_transactions.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--source include/count_sessions.inc
+
+--source ../create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'a');
+
+--connect (con1,localhost,root,,)
+BEGIN;
+--sorted_result
+SELECT a,b FROM t1 WHERE b='a' FOR UPDATE;
+if ($mysql_errname)
+{
+ --let $functionality = SELECT .. FOR UPDATE
+ --source ../unexpected_result.inc
+}
+
+--connection default
+SET lock_wait_timeout = 1;
+
+# Should still be able to select
+
+--sorted_result
+SELECT a,b FROM t1 WHERE b='a';
+if ($mysql_errname)
+{
+ --let $functionality = SELECT .. FOR UPDATE or locking
+ --source ../unexpected_result.inc
+}
+
+# ... but not with LOCK IN SHARE MODE
+
+--sorted_result
+--let $error_codes = ER_LOCK_WAIT_TIMEOUT
+SELECT a,b FROM t1 WHERE b='a' LOCK IN SHARE MODE;
+--source ../check_errors.inc
+if ($mysql_errname != ER_LOCK_WAIT_TIMEOUT)
+{
+ --let $functionality = SELECT .. FOR UPDATE or LOCK IN SHARE MODE
+ --source ../unexpected_result.inc
+}
+
+--let $error_codes = ER_LOCK_WAIT_TIMEOUT
+UPDATE t1 SET b='c' WHERE b='a';
+--source ../check_errors.inc
+if ($mysql_errname != ER_LOCK_WAIT_TIMEOUT)
+{
+ --let $functionality = UPDATE or SELECT .. FOR UPDATE
+ --source ../unexpected_result.inc
+}
+
+--connection con1
+COMMIT;
+--sorted_result
+SELECT a,b FROM t1;
+
+--disconnect con1
+--connection default
+# Now it can be updated all right
+UPDATE t1 SET b='c' WHERE b='a';
+if ($mysql_errname)
+{
+ --let $functionality = UPDATE
+ --source ../unexpected_result.inc
+}
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
+--source include/wait_until_count_sessions.inc
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/trx/select_lock_in_share_mode.result b/mysql-test/suite/storage_engine/trx/select_lock_in_share_mode.result
new file mode 100644
index 00000000..3d668d72
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/select_lock_in_share_mode.result
@@ -0,0 +1,37 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'a');
+connect con1,localhost,root,,;
+BEGIN;
+SELECT a,b FROM t1 WHERE b='a' LOCK IN SHARE MODE;
+a b
+1 a
+3 a
+connection default;
+SET lock_wait_timeout = 1;
+SELECT a,b FROM t1 WHERE b='a';
+a b
+1 a
+3 a
+SELECT a,b FROM t1 WHERE b='a' LOCK IN SHARE MODE;
+a b
+1 a
+3 a
+UPDATE t1 SET b='c' WHERE b='a';
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+connection con1;
+COMMIT;
+SELECT a,b FROM t1;
+a b
+1 a
+2 b
+3 a
+disconnect con1;
+connection default;
+UPDATE t1 SET b='c' WHERE b='a';
+SELECT a,b FROM t1;
+a b
+1 c
+2 b
+3 c
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/trx/select_lock_in_share_mode.test b/mysql-test/suite/storage_engine/trx/select_lock_in_share_mode.test
new file mode 100644
index 00000000..92061036
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/select_lock_in_share_mode.test
@@ -0,0 +1,80 @@
+#
+# SELECT .. LOCK IN SHARE MODE
+#
+# If the engine has its own lock timeouts,
+# it makes sense to set them to minimum to decrease
+# the duration of the test.
+
+--source ../have_engine.inc
+--source support_transactions.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--source include/count_sessions.inc
+
+--source ../create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'a');
+
+--connect (con1,localhost,root,,)
+BEGIN;
+--sorted_result
+SELECT a,b FROM t1 WHERE b='a' LOCK IN SHARE MODE;
+if ($mysql_errname)
+{
+ --let $functionality = LOCK IN SHARE MODE
+ --source ../unexpected_result.inc
+}
+
+--connection default
+SET lock_wait_timeout = 1;
+
+# Should still be able to select
+
+--sorted_result
+SELECT a,b FROM t1 WHERE b='a';
+if ($mysql_errname)
+{
+ --let $functionality = LOCK IN SHARE MODE
+ --source ../unexpected_result.inc
+}
+--sorted_result
+SELECT a,b FROM t1 WHERE b='a' LOCK IN SHARE MODE;
+if ($mysql_errname)
+{
+ --let $functionality = LOCK IN SHARE MODE
+ --source ../unexpected_result.inc
+}
+
+--let $error_codes = ER_LOCK_WAIT_TIMEOUT
+UPDATE t1 SET b='c' WHERE b='a';
+--source ../check_errors.inc
+if ($mysql_errname != ER_LOCK_WAIT_TIMEOUT)
+{
+ --let $functionality = LOCK IN SHARE MODE or UPDATE
+ --source ../unexpected_result.inc
+}
+
+--connection con1
+COMMIT;
+--sorted_result
+SELECT a,b FROM t1;
+
+--disconnect con1
+--connection default
+# Now it can be updated all right
+UPDATE t1 SET b='c' WHERE b='a';
+if ($mysql_errname)
+{
+ --let $functionality = UPDATE
+ --source ../unexpected_result.inc
+}
+--sorted_result
+SELECT a,b FROM t1;
+
+DROP TABLE t1;
+
+--source include/wait_until_count_sessions.inc
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/trx/support_savepoints.inc b/mysql-test/suite/storage_engine/trx/support_savepoints.inc
new file mode 100644
index 00000000..36dbfce2
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/support_savepoints.inc
@@ -0,0 +1,10 @@
+if (!`SELECT savepoints='YES' FROM INFORMATION_SCHEMA.ENGINES WHERE engine = '$storage_engine'`)
+{
+ --echo # -- WARNING ----------------------------------------------------------------
+ --echo # According to I_S.ENGINES, $storage_engine does not support savepoints.
+ --echo # If it is true, the test will most likely fail; you can
+ --echo # either create an rdiff file (recommended), or add the test to disabled.def.
+ --echo # If savepoints should be supported, check the data in Information Schema.
+ --echo # ---------------------------------------------------------------------------
+}
+
diff --git a/mysql-test/suite/storage_engine/trx/support_transactions.inc b/mysql-test/suite/storage_engine/trx/support_transactions.inc
new file mode 100644
index 00000000..ff1224c5
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/support_transactions.inc
@@ -0,0 +1,10 @@
+if (!`SELECT transactions='YES' FROM INFORMATION_SCHEMA.ENGINES WHERE engine = '$storage_engine'`)
+{
+ --echo # -- WARNING ----------------------------------------------------------------
+ --echo # According to I_S.ENGINES, $storage_engine does not support transactions.
+ --echo # If it is true, the test will most likely fail; you can
+ --echo # either create an rdiff file, or add the test to disabled.def.
+ --echo # If transactions should be supported, check the data in Information Schema.
+ --echo # ---------------------------------------------------------------------------
+}
+
diff --git a/mysql-test/suite/storage_engine/trx/support_xa.inc b/mysql-test/suite/storage_engine/trx/support_xa.inc
new file mode 100644
index 00000000..d51fc48a
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/support_xa.inc
@@ -0,0 +1,12 @@
+--let $support_xa = 1
+if (!`SELECT xa='YES' FROM INFORMATION_SCHEMA.ENGINES WHERE engine = '$storage_engine'`)
+{
+ --echo # -- WARNING ----------------------------------------------------------------
+ --echo # According to I_S.ENGINES, $storage_engine does not support XA.
+ --echo # If it is true, the test will most likely fail; you can
+ --echo # either create an rdiff file, or add the test to disabled.def.
+ --echo # If XA should be supported, check the data in Information Schema.
+ --echo # ---------------------------------------------------------------------------
+ --let $support_xa = 0
+}
+
diff --git a/mysql-test/suite/storage_engine/trx/transaction_isolation.inc b/mysql-test/suite/storage_engine/trx/transaction_isolation.inc
new file mode 100644
index 00000000..3ff214bd
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/transaction_isolation.inc
@@ -0,0 +1,97 @@
+#
+# Basic check for transaction isolation.
+# The results should be different depending on the isolation level.
+# For some isolation levels, some statements will end with a timeout.
+# If the engine has its own timeout parameters, reduce them to minimum,
+# otherwise the test will take very long.
+# If the timeout value is greater than the testcase-timeout the test is run with,
+# it might fail due to the testcase timeout.
+#
+
+--source ../have_engine.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+connect (con1,localhost,root,,);
+eval SET SESSION TRANSACTION ISOLATION LEVEL $trx_isolation;
+connect (con2,localhost,root,,);
+eval SET SESSION TRANSACTION ISOLATION LEVEL $trx_isolation;
+
+connection con1;
+
+let $create_definition = a $int_col;
+--source ../create_table.inc
+
+START TRANSACTION;
+--sorted_result
+SELECT a FROM t1; # First snapshot
+
+connection con2;
+
+BEGIN;
+--let $error_codes = 0,ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 (a) VALUES(1);
+--source ../strict_check_errors.inc
+
+connection con1;
+--sorted_result
+SELECT a FROM t1; # Second snapshot
+
+connection con2;
+--let $error_codes = 0,ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 (a) VALUES (2);
+--source ../strict_check_errors.inc
+
+connection con1;
+--sorted_result
+SELECT a FROM t1; # Third snapshot
+
+--let $error_codes = 0,ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 (a) SELECT a+100 FROM t1;
+--source ../strict_check_errors.inc
+
+--sorted_result
+SELECT a FROM t1;
+
+connection con2;
+--sorted_result
+SELECT a FROM t1; # Inside the transaction
+COMMIT;
+--sorted_result
+SELECT a FROM t1; # Outside the transaction
+
+connection con1;
+--sorted_result
+SELECT a FROM t1; # Inside the transaction
+
+# Note: INSERT .. SELECT might be tricky, for example for InnoDB
+# even with REPEATABLE-READ it works as if it is executed with READ COMMITTED.
+# The test will have a 'logical' result for repeatable read, even although
+# we currently don't have an engine which works this way.
+
+--let $error_codes = 0,ER_LOCK_WAIT_TIMEOUT
+INSERT INTO t1 (a) SELECT a+200 FROM t1;
+--source ../strict_check_errors.inc
+
+--sorted_result
+SELECT a FROM t1;
+COMMIT;
+--sorted_result
+SELECT a FROM t1; # Outside the transaction
+
+connection con2;
+--sorted_result
+SELECT a FROM t1; # After both transactions have committed
+
+connection default;
+disconnect con1;
+disconnect con2;
+DROP TABLE t1;
+
+--source include/wait_until_count_sessions.inc
+
diff --git a/mysql-test/suite/storage_engine/trx/update.result b/mysql-test/suite/storage_engine/trx/update.result
new file mode 100644
index 00000000..96867461
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/update.result
@@ -0,0 +1,48 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+BEGIN;
+UPDATE t1 SET a=a+100;
+UPDATE t1 SET a=a-50, b=DEFAULT WHERE a>100;
+COMMIT;
+SELECT a,b FROM t1;
+a b
+10050 NULL
+10050 NULL
+51 NULL
+51 NULL
+52 NULL
+52 NULL
+53 NULL
+53 NULL
+54 NULL
+54 NULL
+55 NULL
+55 NULL
+BEGIN;
+UPDATE t1 SET b = 'update' WHERE a <= 4 ORDER BY a DESC, b ASC LIMIT 3;
+UPDATE t1 SET b = '';
+ROLLBACK;
+BEGIN;
+UPDATE t1 SET b = 'update2' WHERE a <= 100;
+SAVEPOINT spt1;
+UPDATE t1 SET b = '';
+ROLLBACK TO SAVEPOINT spt1;
+UPDATE t1 SET b = 'upd' WHERE a = 10050;
+COMMIT;
+SELECT a,b FROM t1;
+a b
+10050 upd
+10050 upd
+51 update2
+51 update2
+52 update2
+52 update2
+53 update2
+53 update2
+54 update2
+54 update2
+55 update2
+55 update2
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/trx/update.test b/mysql-test/suite/storage_engine/trx/update.test
new file mode 100644
index 00000000..245b7554
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/update.test
@@ -0,0 +1,50 @@
+#
+# Transactional UPDATE
+#
+
+--source ../have_engine.inc
+--source support_transactions.inc
+--source support_savepoints.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--source ../create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+
+BEGIN;
+UPDATE t1 SET a=a+100;
+if ($mysql_errname)
+{
+ --let $functionality = UPDATE
+ --source ../unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ UPDATE t1 SET a=a-50, b=DEFAULT WHERE a>100;
+ COMMIT;
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ BEGIN;
+ UPDATE t1 SET b = 'update' WHERE a <= 4 ORDER BY a DESC, b ASC LIMIT 3;
+ UPDATE t1 SET b = '';
+ ROLLBACK;
+
+ BEGIN;
+ UPDATE t1 SET b = 'update2' WHERE a <= 100;
+ SAVEPOINT spt1;
+ UPDATE t1 SET b = '';
+ ROLLBACK TO SAVEPOINT spt1;
+ UPDATE t1 SET b = 'upd' WHERE a = 10050;
+ COMMIT;
+ --sorted_result
+ SELECT a,b FROM t1;
+}
+
+DROP TABLE t1;
+
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/trx/xa.result b/mysql-test/suite/storage_engine/trx/xa.result
new file mode 100644
index 00000000..72017018
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/xa.result
@@ -0,0 +1,96 @@
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+connection con2;
+XA START 'xa1';
+INSERT INTO t1 (a) VALUES (1);
+connection con1;
+SELECT a FROM t1;
+a
+connection con2;
+INSERT INTO t1 (a) VALUES (2);
+XA END 'xa1';
+connection con1;
+SELECT a FROM t1;
+a
+connection con2;
+XA PREPARE 'xa1';
+connection con1;
+SELECT a FROM t1;
+a
+connection con2;
+XA RECOVER;
+formatID gtrid_length bqual_length data
+1 3 0 xa1
+XA COMMIT 'xa1';
+connection con1;
+SELECT a FROM t1;
+a
+1
+2
+connection con2;
+XA START 'xa2';
+INSERT INTO t1 (a) VALUES (3);
+connection con1;
+SELECT a FROM t1;
+a
+1
+2
+connection con2;
+INSERT INTO t1 (a) VALUES (4);
+XA END 'xa2';
+connection con1;
+SELECT a FROM t1;
+a
+1
+2
+connection con2;
+XA COMMIT 'xa2' ONE PHASE;
+connection con1;
+SELECT a FROM t1;
+a
+1
+2
+3
+4
+connection con2;
+XA START 'xa3';
+INSERT INTO t1 (a) VALUES (5);
+connection con1;
+SELECT a FROM t1;
+a
+1
+2
+3
+4
+connection con2;
+INSERT INTO t1 (a) VALUES (6);
+XA END 'xa3';
+connection con1;
+SELECT a FROM t1;
+a
+1
+2
+3
+4
+connection con2;
+XA PREPARE 'xa3';
+connection con1;
+SELECT a FROM t1;
+a
+1
+2
+3
+4
+connection con2;
+XA ROLLBACK 'xa3';
+connection con1;
+SELECT a FROM t1;
+a
+1
+2
+3
+4
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/trx/xa.test b/mysql-test/suite/storage_engine/trx/xa.test
new file mode 100644
index 00000000..8dafa802
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/xa.test
@@ -0,0 +1,116 @@
+#
+# Basic XA transactions syntax
+#
+
+--source ../have_engine.inc
+--source support_xa.inc
+
+# Save the initial number of concurrent sessions
+--source include/count_sessions.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--connect (con1,localhost,root,,)
+--connect (con2,localhost,root,,)
+
+--connection con1
+--let $create_definition = a $int_col
+--source ../create_table.inc
+
+--connection con2
+
+# Two-phase COMMIT
+
+XA START 'xa1';
+INSERT INTO t1 (a) VALUES (1);
+
+--connection con1
+--sorted_result
+SELECT a FROM t1;
+
+--connection con2
+INSERT INTO t1 (a) VALUES (2);
+XA END 'xa1';
+
+--connection con1
+--sorted_result
+SELECT a FROM t1;
+
+--connection con2
+XA PREPARE 'xa1';
+
+--connection con1
+--sorted_result
+SELECT a FROM t1;
+
+--connection con2
+XA RECOVER;
+XA COMMIT 'xa1';
+
+--connection con1
+--sorted_result
+SELECT a FROM t1;
+
+# One-phase COMMIT
+
+--connection con2
+XA START 'xa2';
+INSERT INTO t1 (a) VALUES (3);
+
+--connection con1
+--sorted_result
+SELECT a FROM t1;
+
+--connection con2
+INSERT INTO t1 (a) VALUES (4);
+XA END 'xa2';
+
+--connection con1
+--sorted_result
+SELECT a FROM t1;
+
+--connection con2
+XA COMMIT 'xa2' ONE PHASE;
+
+--connection con1
+--sorted_result
+SELECT a FROM t1;
+
+# Rollback
+
+--connection con2
+XA START 'xa3';
+INSERT INTO t1 (a) VALUES (5);
+
+--connection con1
+--sorted_result
+SELECT a FROM t1;
+
+--connection con2
+INSERT INTO t1 (a) VALUES (6);
+XA END 'xa3';
+
+--connection con1
+--sorted_result
+SELECT a FROM t1;
+
+--connection con2
+XA PREPARE 'xa3';
+
+--connection con1
+--sorted_result
+SELECT a FROM t1;
+
+--connection con2
+XA ROLLBACK 'xa3';
+
+--connection con1
+--sorted_result
+SELECT a FROM t1;
+
+DROP TABLE t1;
+
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/trx/xa_recovery.result b/mysql-test/suite/storage_engine/trx/xa_recovery.result
new file mode 100644
index 00000000..a9208a6e
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/xa_recovery.result
@@ -0,0 +1,29 @@
+call mtr.add_suppression("Found 2 prepared XA transactions");
+FLUSH TABLES;
+DROP TABLE IF EXISTS t1;
+connect con1,localhost,root,,;
+connect con2,localhost,root,,;
+connection con1;
+CREATE TABLE t1 (a <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+XA START 'xa1';
+INSERT INTO t1 (a) VALUES (1),(2);
+XA END 'xa1';
+XA PREPARE 'xa1';
+connection con2;
+XA START 'xa2';
+INSERT INTO t1 (a) VALUES (3);
+INSERT INTO t1 (a) VALUES (4);
+XA END 'xa2';
+XA PREPARE 'xa2';
+connection default;
+XA RECOVER;
+formatID gtrid_length bqual_length data
+1 3 0 xa1
+1 3 0 xa2
+XA ROLLBACK 'xa1';
+XA COMMIT 'xa2';
+SELECT a FROM t1;
+a
+3
+4
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/trx/xa_recovery.test b/mysql-test/suite/storage_engine/trx/xa_recovery.test
new file mode 100644
index 00000000..f5364057
--- /dev/null
+++ b/mysql-test/suite/storage_engine/trx/xa_recovery.test
@@ -0,0 +1,74 @@
+#
+# Server restart with uncommitted XA transactions
+#
+
+--source ../have_engine.inc
+--source support_xa.inc
+
+# Before we start, we want to restart the server gracefully,
+# so GCOV information and everything else is properly stored
+
+--enable_reconnect
+--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+restart
+EOF
+--shutdown_server
+--source include/wait_until_connected_again.inc
+
+
+call mtr.add_suppression("Found 2 prepared XA transactions");
+if (!$support_xa)
+{
+ --disable_query_log
+ call mtr.add_suppression("Table '.*t1' is marked as crashed and should be repaired");
+ call mtr.add_suppression("Checking table: '.*t1'");
+ --enable_query_log
+}
+
+# Close all unused tables to prevent unrelated corruption
+FLUSH TABLES;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--connect (con1,localhost,root,,)
+--connect (con2,localhost,root,,)
+
+--connection con1
+--let $create_definition = a $int_col
+--source ../create_table.inc
+
+XA START 'xa1';
+INSERT INTO t1 (a) VALUES (1),(2);
+XA END 'xa1';
+XA PREPARE 'xa1';
+
+--connection con2
+XA START 'xa2';
+INSERT INTO t1 (a) VALUES (3);
+INSERT INTO t1 (a) VALUES (4);
+XA END 'xa2';
+XA PREPARE 'xa2';
+
+--connection default
+--enable_reconnect
+--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+wait
+EOF
+--shutdown_server 0
+--source include/wait_until_disconnected.inc
+
+--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+restart
+EOF
+--source include/wait_until_connected_again.inc
+XA RECOVER;
+XA ROLLBACK 'xa1';
+XA COMMIT 'xa2';
+--replace_result \\ /
+SELECT a FROM t1;
+DROP TABLE t1;
+
+--source ../cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_binary.inc b/mysql-test/suite/storage_engine/type_binary.inc
new file mode 100644
index 00000000..dbee1d57
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_binary.inc
@@ -0,0 +1,52 @@
+#
+# BINARY column types
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $create_definition =
+ b BINARY $col_opts,
+ b0 BINARY(0) $col_opts,
+ b1 BINARY(1) $col_opts,
+ b20 BINARY(20) $col_opts,
+ b255 BINARY(255) $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = BINARY types
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 # 6 #
+ SHOW COLUMNS IN t1;
+
+ # Valid values
+
+ INSERT INTO t1 (b,b0,b1,b20,b255) VALUES ('','','','','');
+ INSERT INTO t1 (b,b0,b1,b20,b255) VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.');
+
+ --sorted_result
+ SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255) FROM t1;
+
+ # Invalid values
+
+ INSERT INTO t1 (b,b0,b1,b20,b255) VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256));
+ INSERT INTO t1 (b,b0,b1,b20,b255) SELECT b255, b255, b255, b255, CONCAT(b255,b255) FROM t1;
+
+ --sorted_result
+ SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255) FROM t1;
+
+ --let $error_codes = ER_TOO_BIG_FIELDLENGTH
+ --let $alter_definition = ADD COLUMN b257 BINARY(257) $col_opts
+ --source alter_table.inc
+ --replace_column 3 # 4 # 5 # 6 #
+ SHOW COLUMNS IN t1;
+
+ DROP TABLE t1;
+}
+
diff --git a/mysql-test/suite/storage_engine/type_binary.result b/mysql-test/suite/storage_engine/type_binary.result
new file mode 100644
index 00000000..8da8b040
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_binary.result
@@ -0,0 +1,62 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (b BINARY <CUSTOM_COL_OPTIONS>,
+b0 BINARY(0) <CUSTOM_COL_OPTIONS>,
+b1 BINARY(1) <CUSTOM_COL_OPTIONS>,
+b20 BINARY(20) <CUSTOM_COL_OPTIONS>,
+b255 BINARY(255) <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b binary(1) # # # #
+b0 binary(0) # # # #
+b1 binary(1) # # # #
+b20 binary(20) # # # #
+b255 binary(255) # # # #
+INSERT INTO t1 (b,b0,b1,b20,b255) VALUES ('','','','','');
+INSERT INTO t1 (b,b0,b1,b20,b255) VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.');
+SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255) FROM t1;
+HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255)
+00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000
+INSERT INTO t1 (b,b0,b1,b20,b255) VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256));
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b0' at row 1
+Warning 1265 Data truncated for column 'b1' at row 1
+Warning 1265 Data truncated for column 'b20' at row 1
+Warning 1265 Data truncated for column 'b255' at row 1
+INSERT INTO t1 (b,b0,b1,b20,b255) SELECT b255, b255, b255, b255, CONCAT(b255,b255) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b0' at row 1
+Warning 1265 Data truncated for column 'b1' at row 1
+Warning 1265 Data truncated for column 'b20' at row 1
+Warning 1265 Data truncated for column 'b255' at row 1
+Warning 1265 Data truncated for column 'b' at row 2
+Warning 1265 Data truncated for column 'b0' at row 2
+Warning 1265 Data truncated for column 'b1' at row 2
+Warning 1265 Data truncated for column 'b20' at row 2
+Warning 1265 Data truncated for column 'b255' at row 2
+Warning 1265 Data truncated for column 'b' at row 3
+Warning 1265 Data truncated for column 'b0' at row 3
+Warning 1265 Data truncated for column 'b1' at row 3
+Warning 1265 Data truncated for column 'b20' at row 3
+Warning 1265 Data truncated for column 'b255' at row 3
+SELECT HEX(b), HEX(b0), HEX(b1), HEX(b20), HEX(b255) FROM t1;
+HEX(b) HEX(b0) HEX(b1) HEX(b20) HEX(b255)
+00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+00 00 0000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+43 43 4372656174696E6720616E2061727469636C6520 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000
+61 61 6161616161616161616161616161616161616161 787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878
+61 62 616263646566676869206B6C6D6E6F7071727374 4372656174696E6720616E2061727469636C6520666F7220746865204B6E6F776C65646765626173652069732073696D696C617220746F2061736B696E67207175657374696F6E732E2046697273742C206E6176696761746520746F207468652063617465676F727920776865726520796F75206665656C207468652061727469636C652073686F756C642062652E204F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C726561647920657869737420776869636820776F756C6420776F726B2E00000000000000000000000000000000000000000000000000000000000000
+78 78 7878787878787878787878787878787878787878 787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878787878
+ALTER TABLE t1 ADD COLUMN b257 BINARY(257) <CUSTOM_COL_OPTIONS>;
+ERROR 42000: Column length too big for column 'b257' (max = 255); use BLOB or TEXT instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b binary(1) # # # #
+b0 binary(0) # # # #
+b1 binary(1) # # # #
+b20 binary(20) # # # #
+b255 binary(255) # # # #
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_binary.test b/mysql-test/suite/storage_engine/type_binary.test
new file mode 100644
index 00000000..7820e3ab
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_binary.test
@@ -0,0 +1,10 @@
+#
+# BINARY column types
+#
+
+--source have_engine.inc
+
+--source type_binary.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_binary_indexes.result b/mysql-test/suite/storage_engine/type_binary_indexes.result
new file mode 100644
index 00000000..96e0d6d6
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_binary_indexes.result
@@ -0,0 +1,126 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (b BINARY <CUSTOM_COL_OPTIONS>,
+b20 BINARY(20) <CUSTOM_COL_OPTIONS>,
+v16 VARBINARY(16) <CUSTOM_COL_OPTIONS>,
+v128 VARBINARY(128) <CUSTOM_COL_OPTIONS>,
+<CUSTOM_INDEX> b20 (b20)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 # 1 b20 # # NULL NULL # #
+INSERT INTO t1 (b,b20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+SELECT HEX(b20) FROM t1 ORDER BY b20;
+HEX(b20)
+6368617231000000000000000000000000000000
+6368617232000000000000000000000000000000
+6368617233000000000000000000000000000000
+6368617234000000000000000000000000000000
+DROP TABLE t1;
+CREATE TABLE t1 (b BINARY <CUSTOM_COL_OPTIONS>,
+b20 BINARY(20) <CUSTOM_COL_OPTIONS> PRIMARY KEY,
+v16 VARBINARY(16) <CUSTOM_COL_OPTIONS>,
+v128 VARBINARY(128) <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 PRIMARY 1 b20 # # NULL NULL # #
+INSERT INTO t1 (b,b20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+EXPLAIN SELECT HEX(b20) FROM t1 ORDER BY b20;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # PRIMARY # # # #
+SELECT HEX(b20) FROM t1 ORDER BY b20;
+HEX(b20)
+6368617231000000000000000000000000000000
+6368617232000000000000000000000000000000
+6368617233000000000000000000000000000000
+6368617234000000000000000000000000000000
+EXPLAIN SELECT HEX(b20) FROM t1 IGNORE INDEX (PRIMARY) ORDER BY b20 DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # NULL # # # #
+SELECT HEX(b20) FROM t1 ORDER BY b20 DESC;
+HEX(b20)
+6368617234000000000000000000000000000000
+6368617233000000000000000000000000000000
+6368617232000000000000000000000000000000
+6368617231000000000000000000000000000000
+DROP TABLE t1;
+CREATE TABLE t1 (b BINARY <CUSTOM_COL_OPTIONS>,
+b20 BINARY(20) <CUSTOM_COL_OPTIONS>,
+v16 VARBINARY(16) <CUSTOM_COL_OPTIONS>,
+v128 VARBINARY(128) <CUSTOM_COL_OPTIONS>,
+UNIQUE INDEX b_v (b,v128)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 b_v 1 b # # NULL NULL # #
+t1 0 b_v 2 v128 # # NULL NULL # #
+INSERT INTO t1 (b,b20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+EXPLAIN SELECT HEX(b), HEX(v128) FROM t1 WHERE b != 'a' AND v128 > 'varchar';
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # b_v # # # #
+SELECT HEX(b), HEX(v128) FROM t1 WHERE b != 'a' AND v128 > 'varchar';
+HEX(b) HEX(v128)
+62 766172636861723162
+63 766172636861723362
+EXPLAIN SELECT HEX(b), HEX(v128) FROM t1 USE INDEX (b_v) WHERE b != 'a' AND v128 > 'varchar';
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # b_v # # # #
+SELECT HEX(b), HEX(v128) FROM t1 USE INDEX (b_v) WHERE b != 'a' AND v128 > 'varchar';
+HEX(b) HEX(v128)
+62 766172636861723162
+63 766172636861723362
+EXPLAIN SELECT HEX(v128), COUNT(*) FROM t1 GROUP BY HEX(v128);
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # b_v # # # #
+SELECT HEX(v128), COUNT(*) FROM t1 GROUP BY HEX(v128);
+HEX(v128) COUNT(*)
+766172636861723162 2
+766172636861723262 1
+766172636861723362 1
+DROP TABLE t1;
+CREATE TABLE t1 (b BINARY <CUSTOM_COL_OPTIONS>,
+b20 BINARY(20) <CUSTOM_COL_OPTIONS>,
+v16 VARBINARY(16) <CUSTOM_COL_OPTIONS>,
+v128 VARBINARY(128) <CUSTOM_COL_OPTIONS>,
+INDEX (v16(10))
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 v16 1 v16 # # 10 NULL # #
+INSERT INTO t1 (b,b20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b'),('d','char5','varchar4a','varchar3b'),('e','char6','varchar2a','varchar3b');
+INSERT INTO t1 (b,b20,v16,v128) SELECT b,b20,v16,v128 FROM t1;
+EXPLAIN SELECT HEX(SUBSTRING(v16,0,3)) FROM t1 WHERE v16 LIKE 'varchar%';
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # NULL # # # #
+SELECT HEX(SUBSTRING(v16,7,3)) FROM t1 WHERE v16 LIKE 'varchar%';
+HEX(SUBSTRING(v16,7,3))
+723161
+723161
+723161
+723161
+723261
+723261
+723261
+723261
+723361
+723361
+723461
+723461
+EXPLAIN SELECT HEX(SUBSTRING(v16,0,3)) FROM t1 FORCE INDEX (v16) WHERE v16 LIKE 'varchar%';
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # v16 # # # #
+SELECT HEX(SUBSTRING(v16,7,3)) FROM t1 FORCE INDEX (v16) WHERE v16 LIKE 'varchar%';
+HEX(SUBSTRING(v16,7,3))
+723161
+723161
+723161
+723161
+723261
+723261
+723261
+723261
+723361
+723361
+723461
+723461
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_binary_indexes.test b/mysql-test/suite/storage_engine/type_binary_indexes.test
new file mode 100644
index 00000000..c17b0c53
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_binary_indexes.test
@@ -0,0 +1,154 @@
+#
+# BINARY and VARBINARY columns with indexes
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Default index as set in define_engine.inc
+
+let $create_definition =
+ b BINARY $col_opts,
+ b20 BINARY(20) $col_indexed_opts,
+ v16 VARBINARY(16) $col_opts,
+ v128 VARBINARY(128) $col_opts,
+ $default_index b20 (b20)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = BINARY or VARBINARY types or indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (b,b20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+
+ SELECT HEX(b20) FROM t1 ORDER BY b20;
+ DROP TABLE t1;
+}
+
+
+# PK, UNIQUE INDEX, INDEX
+
+let $create_definition =
+ b BINARY $col_opts,
+ b20 BINARY(20) $col_indexed_opts PRIMARY KEY,
+ v16 VARBINARY(16) $col_opts,
+ v128 VARBINARY(128) $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = BINARY or VARBINARY types or PK
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (b,b20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT HEX(b20) FROM t1 ORDER BY b20;
+ SELECT HEX(b20) FROM t1 ORDER BY b20;
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT HEX(b20) FROM t1 IGNORE INDEX (PRIMARY) ORDER BY b20 DESC;
+ SELECT HEX(b20) FROM t1 ORDER BY b20 DESC;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ b BINARY $col_indexed_opts,
+ b20 BINARY(20) $col_opts,
+ v16 VARBINARY(16) $col_opts,
+ v128 VARBINARY(128) $col_indexed_opts,
+ UNIQUE INDEX b_v (b,v128)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = BINARY or VARBINARY types or unique keys or multi-part keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (b,b20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT HEX(b), HEX(v128) FROM t1 WHERE b != 'a' AND v128 > 'varchar';
+ --sorted_result
+ SELECT HEX(b), HEX(v128) FROM t1 WHERE b != 'a' AND v128 > 'varchar';
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT HEX(b), HEX(v128) FROM t1 USE INDEX (b_v) WHERE b != 'a' AND v128 > 'varchar';
+ --sorted_result
+ SELECT HEX(b), HEX(v128) FROM t1 USE INDEX (b_v) WHERE b != 'a' AND v128 > 'varchar';
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT HEX(v128), COUNT(*) FROM t1 GROUP BY HEX(v128);
+ --sorted_result
+ SELECT HEX(v128), COUNT(*) FROM t1 GROUP BY HEX(v128);
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ b BINARY $col_opts,
+ b20 BINARY(20) $col_opts,
+ v16 VARBINARY(16) $col_indexed_opts,
+ v128 VARBINARY(128) $col_opts,
+ INDEX (v16(10))
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = BINARY or VARBINARY types or non-unique keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (b,b20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b'),('d','char5','varchar4a','varchar3b'),('e','char6','varchar2a','varchar3b');
+ INSERT INTO t1 (b,b20,v16,v128) SELECT b,b20,v16,v128 FROM t1;
+ --disable_result_log
+ --disable_query_log
+ ANALYZE TABLE t1;
+ --enable_query_log
+ --enable_result_log
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT HEX(SUBSTRING(v16,0,3)) FROM t1 WHERE v16 LIKE 'varchar%';
+ --sorted_result
+ SELECT HEX(SUBSTRING(v16,7,3)) FROM t1 WHERE v16 LIKE 'varchar%';
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT HEX(SUBSTRING(v16,0,3)) FROM t1 FORCE INDEX (v16) WHERE v16 LIKE 'varchar%';
+ --sorted_result
+ SELECT HEX(SUBSTRING(v16,7,3)) FROM t1 FORCE INDEX (v16) WHERE v16 LIKE 'varchar%';
+
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_bit.inc b/mysql-test/suite/storage_engine/type_bit.inc
new file mode 100644
index 00000000..eb7920f8
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_bit.inc
@@ -0,0 +1,76 @@
+#
+# BIT column type
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Valid values
+
+let $create_definition =
+ a BIT $col_opts,
+ b BIT(20) $col_opts,
+ c BIT(64) $col_opts,
+ d BIT(1) $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = BIT types
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+
+ --let $alter_definition = DROP COLUMN d
+ --source alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --let $alter_definition = ADD COLUMN d BIT(0) $col_opts
+ --source alter_table.inc
+
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+ }
+
+ INSERT INTO t1 (a,b,c,d) VALUES (0,POW(2,20)-1,b'1111111111111111111111111111111111111111111111111111111111111111',1);
+ --sorted_result
+ SELECT BIN(a), HEX(b), c+0 FROM t1 WHERE d>0;
+
+ INSERT INTO t1 (a,b,c,d) VALUES (1,0,-1,0);
+ --sorted_result
+ SELECT a+0, b+0, c+0 FROM t1 WHERE d<100;
+
+ INSERT INTO t1 (a,b,c,d) VALUES (b'1', 'f', 0xFF, 0x0);
+ --sorted_result
+ SELECT a+0, b+0, c+0 FROM t1 WHERE d IN (0, 2);
+
+ # Out of range values
+ # (should produce warnings)
+
+ INSERT INTO t1 (a,b,c,d) VALUES (0x10,0,0,1);
+ --sorted_result
+ SELECT a,b,c,d FROM t1;
+
+ INSERT INTO t1 (a,b,c,d) VALUES (0x01,0,0x10000000000000000,0);
+ --sorted_result
+ SELECT a,b,c,d FROM t1;
+
+ DROP TABLE t1;
+
+ --let $error_codes = ER_TOO_BIG_DISPLAYWIDTH
+ --let $create_definition = a BIT(65) $col_opts
+ --source create_table.inc
+}
+
+
diff --git a/mysql-test/suite/storage_engine/type_bit.result b/mysql-test/suite/storage_engine/type_bit.result
new file mode 100644
index 00000000..3c88b297
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_bit.result
@@ -0,0 +1,47 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a BIT <CUSTOM_COL_OPTIONS>,
+b BIT(20) <CUSTOM_COL_OPTIONS>,
+c BIT(64) <CUSTOM_COL_OPTIONS>,
+d BIT(1) <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a bit(1) # # #
+b bit(20) # # #
+c bit(64) # # #
+d bit(1) # # #
+ALTER TABLE t1 DROP COLUMN d;
+ALTER TABLE t1 ADD COLUMN d BIT(0) <CUSTOM_COL_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a bit(1) # # #
+b bit(20) # # #
+c bit(64) # # #
+d bit(1) # # #
+INSERT INTO t1 (a,b,c,d) VALUES (0,POW(2,20)-1,b'1111111111111111111111111111111111111111111111111111111111111111',1);
+SELECT BIN(a), HEX(b), c+0 FROM t1 WHERE d>0;
+BIN(a) HEX(b) c+0
+0 FFFFF 18446744073709551615
+INSERT INTO t1 (a,b,c,d) VALUES (1,0,-1,0);
+SELECT a+0, b+0, c+0 FROM t1 WHERE d<100;
+a+0 b+0 c+0
+0 1048575 18446744073709551615
+1 0 18446744073709551615
+INSERT INTO t1 (a,b,c,d) VALUES (b'1', 'f', 0xFF, 0x0);
+SELECT a+0, b+0, c+0 FROM t1 WHERE d IN (0, 2);
+a+0 b+0 c+0
+1 0 18446744073709551615
+1 102 255
+INSERT INTO t1 (a,b,c,d) VALUES (0x10,0,0,1);
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+SELECT a,b,c,d FROM t1;
+a b c d
+INSERT INTO t1 (a,b,c,d) VALUES (0x01,0,0x10000000000000000,0);
+Warnings:
+Warning 1264 Out of range value for column 'c' at row 1
+SELECT a,b,c,d FROM t1;
+a b c d
+DROP TABLE t1;
+CREATE TABLE t1 (a BIT(65) <CUSTOM_COL_OPTIONS>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+ERROR 42000: Display width out of range for 'a' (max = 64)
diff --git a/mysql-test/suite/storage_engine/type_bit.test b/mysql-test/suite/storage_engine/type_bit.test
new file mode 100644
index 00000000..1670a633
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_bit.test
@@ -0,0 +1,10 @@
+#
+# BIT column type
+#
+
+--source have_engine.inc
+
+--source type_bit.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_bit_indexes.result b/mysql-test/suite/storage_engine/type_bit_indexes.result
new file mode 100644
index 00000000..af8ddf7d
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_bit_indexes.result
@@ -0,0 +1,132 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a BIT <CUSTOM_COL_OPTIONS>,
+b BIT(20) <CUSTOM_COL_OPTIONS>,
+c BIT(32) <CUSTOM_COL_OPTIONS>,
+d BIT(64) <CUSTOM_COL_OPTIONS>,
+<CUSTOM_INDEX> b (b)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 # 1 b # # NULL NULL # #
+INSERT INTO t1 (a,b,c,d) VALUES
+(0,0xFFFFF,0,1),(0,256,0xAAA,0x12345),(1,16,0,0xFFFFFFF),(0,11,12,13),
+(1,100,101,102),(0,12,13,14),(1,13,14,15),(0,101,201,202),(1,1000,1001,1002),
+(1,0xFFFF,0xFFFFFFFF,0xFFFFFFFFFFFFFFFF);
+SELECT b+0 FROM t1 ORDER BY b;
+b+0
+11
+12
+13
+16
+100
+101
+256
+1000
+65535
+1048575
+DROP TABLE t1;
+CREATE TABLE t1 (a BIT <CUSTOM_COL_OPTIONS>,
+b BIT(20) <CUSTOM_COL_OPTIONS> PRIMARY KEY,
+c BIT(32) <CUSTOM_COL_OPTIONS>,
+d BIT(64) <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 PRIMARY 1 b # # NULL NULL # #
+INSERT INTO t1 (a,b,c,d) VALUES
+(0,0xFFFFF,0,1),(0,256,0xAAA,0x12345),(1,16,0,0xFFFFFFF),(0,11,12,13),
+(1,100,101,102),(0,12,13,14),(1,13,14,15),(0,101,201,202),(1,1000,1001,1002),
+(1,0xFFFF,0xFFFFFFFF,0xFFFFFFFFFFFFFFFF);
+EXPLAIN SELECT b+0 FROM t1 ORDER BY b;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # PRIMARY # # # #
+SELECT b+0 FROM t1 ORDER BY b;
+b+0
+11
+12
+13
+16
+100
+101
+256
+1000
+65535
+1048575
+DROP TABLE t1;
+CREATE TABLE t1 (a BIT <CUSTOM_COL_OPTIONS>,
+b BIT(20) <CUSTOM_COL_OPTIONS>,
+c BIT(32) <CUSTOM_COL_OPTIONS>,
+d BIT(64) <CUSTOM_COL_OPTIONS>,
+UNIQUE INDEX b_c (b,c)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 b_c 1 b # # NULL NULL # #
+t1 0 b_c 2 c # # NULL NULL # #
+INSERT INTO t1 (a,b,c,d) VALUES
+(0,0xFFFFF,0,1),(0,256,0xAAA,0x12345),(1,16,0,0xFFFFFFF),(0,11,12,13),
+(1,100,101,102),(0,12,13,14),(1,13,14,15),(0,101,201,202),(1,1000,1001,1002),
+(1,0xFFFF,0xFFFFFFFF,0xFFFFFFFFFFFFFFFF);
+EXPLAIN SELECT HEX(b+c) FROM t1 WHERE c > 1 OR HEX(b) < 0xFFFFFF;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # b_c # # # #
+SELECT HEX(b+c) FROM t1 WHERE c > 1 OR HEX(b) < 0xFFFFFF;
+HEX(b+c)
+10
+10000FFFE
+12E
+17
+19
+1B
+7D1
+BAA
+C9
+FFFFF
+DROP TABLE t1;
+CREATE TABLE t1 (a BIT <CUSTOM_COL_OPTIONS>,
+b BIT(20) <CUSTOM_COL_OPTIONS>,
+c BIT(32) <CUSTOM_COL_OPTIONS>,
+d BIT(64) <CUSTOM_COL_OPTIONS>,
+INDEX(a)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a 1 a # # NULL NULL # #
+INSERT INTO t1 (a,b,c,d) VALUES
+(0,0xFFFFF,0,1),(0,256,0xAAA,0x12345),(1,16,0,0xFFFFFFF),(0,11,12,13),
+(1,100,101,102),(0,12,13,14),(1,13,14,15),(0,101,201,202),(1,1000,1001,1002),
+(1,0xFFFF,0xFFFFFFFF,0xFFFFFFFFFFFFFFFF);
+EXPLAIN SELECT DISTINCT a+0 FROM t1 ORDER BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # a # # # #
+SELECT DISTINCT a+0 FROM t1 ORDER BY a;
+a+0
+0
+1
+DROP TABLE t1;
+CREATE TABLE t1 (a BIT <CUSTOM_COL_OPTIONS>,
+b BIT(20) <CUSTOM_COL_OPTIONS>,
+c BIT(32) <CUSTOM_COL_OPTIONS>,
+d BIT(64) <CUSTOM_COL_OPTIONS>,
+UNIQUE INDEX (d)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 d 1 d # # NULL NULL # #
+INSERT INTO t1 (a,b,c,d) VALUES
+(0,0xFFFFF,0,1),(0,256,0xAAA,0x12345),(1,16,0,0xFFFFFFF),(0,11,12,13),
+(1,100,101,102),(0,12,13,14),(1,13,14,15),(0,101,201,202),(1,1000,1001,1002),
+(1,0xFFFF,0xFFFFFFFF,0xFFFFFFFFFFFFFFFF);
+EXPLAIN SELECT d FROM t1 WHERE d BETWEEN 1 AND 10000;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # d # # # #
+SELECT d+0 FROM t1 WHERE d BETWEEN 1 AND 10000;
+d+0
+1
+1002
+102
+13
+14
+15
+202
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_bit_indexes.test b/mysql-test/suite/storage_engine/type_bit_indexes.test
new file mode 100644
index 00000000..df88d50b
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_bit_indexes.test
@@ -0,0 +1,175 @@
+#
+# BIT columns with indexes
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+
+# Default index as set in define_engine.inc
+
+let $create_definition =
+ a BIT $col_opts,
+ b BIT(20) $col_indexed_opts,
+ c BIT(32) $col_opts,
+ d BIT(64) $col_opts,
+ $default_index b (b)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = BIT types or indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (a,b,c,d) VALUES
+ (0,0xFFFFF,0,1),(0,256,0xAAA,0x12345),(1,16,0,0xFFFFFFF),(0,11,12,13),
+ (1,100,101,102),(0,12,13,14),(1,13,14,15),(0,101,201,202),(1,1000,1001,1002),
+ (1,0xFFFF,0xFFFFFFFF,0xFFFFFFFFFFFFFFFF);
+
+ SELECT b+0 FROM t1 ORDER BY b;
+
+ DROP TABLE t1;
+}
+
+
+# PK, UNIQUE KEY, KEY
+
+
+let $create_definition =
+ a BIT $col_opts,
+ b BIT(20) $col_indexed_opts PRIMARY KEY,
+ c BIT(32) $col_opts,
+ d BIT(64) $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = BIT types or PK
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (a,b,c,d) VALUES
+ (0,0xFFFFF,0,1),(0,256,0xAAA,0x12345),(1,16,0,0xFFFFFFF),(0,11,12,13),
+ (1,100,101,102),(0,12,13,14),(1,13,14,15),(0,101,201,202),(1,1000,1001,1002),
+ (1,0xFFFF,0xFFFFFFFF,0xFFFFFFFFFFFFFFFF);
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT b+0 FROM t1 ORDER BY b;
+ SELECT b+0 FROM t1 ORDER BY b;
+
+ DROP TABLE t1;
+}
+
+
+let $create_definition =
+ a BIT $col_opts,
+ b BIT(20) $col_indexed_opts,
+ c BIT(32) $col_indexed_opts,
+ d BIT(64) $col_opts,
+UNIQUE INDEX b_c (b,c)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = BIT types or unique keys or multi-part keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (a,b,c,d) VALUES
+ (0,0xFFFFF,0,1),(0,256,0xAAA,0x12345),(1,16,0,0xFFFFFFF),(0,11,12,13),
+ (1,100,101,102),(0,12,13,14),(1,13,14,15),(0,101,201,202),(1,1000,1001,1002),
+ (1,0xFFFF,0xFFFFFFFF,0xFFFFFFFFFFFFFFFF);
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT HEX(b+c) FROM t1 WHERE c > 1 OR HEX(b) < 0xFFFFFF;
+ --sorted_result
+ SELECT HEX(b+c) FROM t1 WHERE c > 1 OR HEX(b) < 0xFFFFFF;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ a BIT $col_indexed_opts,
+ b BIT(20) $col_opts,
+ c BIT(32) $col_opts,
+ d BIT(64) $col_opts,
+INDEX(a)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = BIT types or non-unique keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (a,b,c,d) VALUES
+ (0,0xFFFFF,0,1),(0,256,0xAAA,0x12345),(1,16,0,0xFFFFFFF),(0,11,12,13),
+ (1,100,101,102),(0,12,13,14),(1,13,14,15),(0,101,201,202),(1,1000,1001,1002),
+ (1,0xFFFF,0xFFFFFFFF,0xFFFFFFFFFFFFFFFF);
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT DISTINCT a+0 FROM t1 ORDER BY a;
+ SELECT DISTINCT a+0 FROM t1 ORDER BY a;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ a BIT $col_opts,
+ b BIT(20) $col_opts,
+ c BIT(32) $col_opts,
+ d BIT(64) $col_indexed_opts,
+UNIQUE INDEX (d)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = BIT types or unique keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (a,b,c,d) VALUES
+ (0,0xFFFFF,0,1),(0,256,0xAAA,0x12345),(1,16,0,0xFFFFFFF),(0,11,12,13),
+ (1,100,101,102),(0,12,13,14),(1,13,14,15),(0,101,201,202),(1,1000,1001,1002),
+ (1,0xFFFF,0xFFFFFFFF,0xFFFFFFFFFFFFFFFF);
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT d FROM t1 WHERE d BETWEEN 1 AND 10000;
+ --sorted_result
+ SELECT d+0 FROM t1 WHERE d BETWEEN 1 AND 10000;
+
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_blob.inc b/mysql-test/suite/storage_engine/type_blob.inc
new file mode 100644
index 00000000..626c5561
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_blob.inc
@@ -0,0 +1,65 @@
+#
+# BLOB column types
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $create_definition =
+ b BLOB $col_opts,
+ b0 BLOB(0) $col_opts,
+ b1 BLOB(1) $col_opts,
+ b300 BLOB(300) $col_opts,
+ bm BLOB(65535) $col_opts,
+ b70k BLOB(70000) $col_opts,
+ b17m BLOB(17000000) $col_opts,
+ t TINYBLOB $col_opts,
+ m MEDIUMBLOB $col_opts,
+ l LONGBLOB $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = BLOB types
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+
+ # Valid values
+ # (cannot get MAX for all columns due to max_allowed_packet limitations)
+
+ INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
+ ('','','','','','','','','',''),
+ ('a','b','c','d','e','f','g','h','i','j'),
+ ('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
+ ( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), HEX(REPEAT('g',1048576)), REPEAT('h',255), REPEAT('i',1048576), HEX(REPEAT('j',1048576)) );
+
+ --sorted_result
+ SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
+
+ # Invalid values (produce warnings, except for mediumblob and longblob columns for which the values are within limits)
+
+ INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
+ ( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
+
+ --sorted_result
+ SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
+
+ --let $error_codes = ER_TOO_BIG_DISPLAYWIDTH
+ --let $alter_definition = ADD COLUMN bbb BLOB(4294967296)
+ --source alter_table.inc
+ if ($mysql_errname != ER_TOO_BIG_DISPLAYWIDTH)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+ }
+
+ DROP TABLE t1;
+}
+
diff --git a/mysql-test/suite/storage_engine/type_blob.result b/mysql-test/suite/storage_engine/type_blob.result
new file mode 100644
index 00000000..9a9e1470
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_blob.result
@@ -0,0 +1,54 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (b BLOB <CUSTOM_COL_OPTIONS>,
+b0 BLOB(0) <CUSTOM_COL_OPTIONS>,
+b1 BLOB(1) <CUSTOM_COL_OPTIONS>,
+b300 BLOB(300) <CUSTOM_COL_OPTIONS>,
+bm BLOB(65535) <CUSTOM_COL_OPTIONS>,
+b70k BLOB(70000) <CUSTOM_COL_OPTIONS>,
+b17m BLOB(17000000) <CUSTOM_COL_OPTIONS>,
+t TINYBLOB <CUSTOM_COL_OPTIONS>,
+m MEDIUMBLOB <CUSTOM_COL_OPTIONS>,
+l LONGBLOB <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b blob # # #
+b0 blob # # #
+b1 tinyblob # # #
+b300 blob # # #
+bm blob # # #
+b70k mediumblob # # #
+b17m longblob # # #
+t tinyblob # # #
+m mediumblob # # #
+l longblob # # #
+INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
+('','','','','','','','','',''),
+('a','b','c','d','e','f','g','h','i','j'),
+('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
+( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), HEX(REPEAT('g',1048576)), REPEAT('h',255), REPEAT('i',1048576), HEX(REPEAT('j',1048576)) );
+SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(b) LENGTH(b0) LENGTH(b1) LENGTH(b300) LENGTH(bm) LENGTH(b70k) LENGTH(b17m) LENGTH(t) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 2097152 255 1048576 2097152
+INSERT INTO t1 (b,b0,b1,b300,bm,b70k,b17m,t,m,l) VALUES
+( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'b0' at row 1
+Warning 1265 Data truncated for column 'b1' at row 1
+Warning 1265 Data truncated for column 'b300' at row 1
+Warning 1265 Data truncated for column 'bm' at row 1
+Warning 1265 Data truncated for column 't' at row 1
+SELECT LENGTH(b), LENGTH(b0), LENGTH(b1), LENGTH(b300), LENGTH(bm), LENGTH(b70k), LENGTH(b17m), LENGTH(t), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(b) LENGTH(b0) LENGTH(b1) LENGTH(b300) LENGTH(bm) LENGTH(b70k) LENGTH(b17m) LENGTH(t) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+65535 65535 255 65535 65535 1048576 2097152 255 1048576 2097152
+ALTER TABLE t1 ADD COLUMN bbb BLOB(4294967296);
+ERROR 42000: Display width out of range for 'bbb' (max = 4294967295)
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_blob.test b/mysql-test/suite/storage_engine/type_blob.test
new file mode 100644
index 00000000..2f8ae883
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_blob.test
@@ -0,0 +1,10 @@
+#
+# BLOB column types
+#
+
+--source have_engine.inc
+
+--source type_blob.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_blob_indexes.result b/mysql-test/suite/storage_engine/type_blob_indexes.result
new file mode 100644
index 00000000..8e732e15
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_blob_indexes.result
@@ -0,0 +1,152 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (b BLOB <CUSTOM_COL_OPTIONS>,
+t TINYBLOB <CUSTOM_COL_OPTIONS>,
+m MEDIUMBLOB <CUSTOM_COL_OPTIONS>,
+l LONGBLOB <CUSTOM_COL_OPTIONS>,
+<CUSTOM_INDEX> b (b(32))
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 # 1 b # # 32 NULL # #
+INSERT INTO t1 (b,t,m,l) VALUES
+('','','',''),
+('a','b','c','d'),
+('b','d','c','b'),
+('test1','test2','test3','test4'),
+(REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
+(HEX('abcd'),HEX('def'),HEX('a'),HEX('abc')),
+('abc','def','ghi','jkl'),
+('test2','test3','test4','test5'),
+('test3','test4','test5','test6'),
+(REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
+(REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));
+SELECT SUBSTRING(b,16) AS f FROM t1 WHERE b IN ('test1','test2') ORDER BY f;
+f
+
+
+SELECT SUBSTRING(b,16) AS f FROM t1 USE INDEX () WHERE b IN ('test1','test2') ORDER BY f;
+f
+
+
+DROP TABLE t1;
+CREATE TABLE t1 (b BLOB <CUSTOM_COL_OPTIONS>,
+t TINYBLOB <CUSTOM_COL_OPTIONS>,
+m MEDIUMBLOB <CUSTOM_COL_OPTIONS>,
+l LONGBLOB <CUSTOM_COL_OPTIONS>,
+PRIMARY KEY b (b(32))
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 PRIMARY 1 b # # 32 NULL # #
+INSERT INTO t1 (b,t,m,l) VALUES
+('','','',''),
+('a','b','c','d'),
+('b','d','c','b'),
+('test1','test2','test3','test4'),
+(REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
+(HEX('abcd'),HEX('def'),HEX('a'),HEX('abc')),
+('abc','def','ghi','jkl'),
+('test2','test3','test4','test5'),
+('test3','test4','test5','test6'),
+(REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
+(REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));
+EXPLAIN SELECT SUBSTRING(b,16) AS f FROM t1 WHERE b IN ('test1','test2') ORDER BY f;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # PRIMARY # # # #
+SELECT SUBSTRING(b,16) AS f FROM t1 WHERE b IN ('test1','test2') ORDER BY f;
+f
+
+
+EXPLAIN SELECT SUBSTRING(b,16) AS f FROM t1 USE INDEX () WHERE b IN ('test1','test2') ORDER BY f;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # NULL # # # #
+SELECT SUBSTRING(b,16) AS f FROM t1 USE INDEX () WHERE b IN ('test1','test2') ORDER BY f;
+f
+
+
+DROP TABLE t1;
+CREATE TABLE t1 (b BLOB <CUSTOM_COL_OPTIONS>,
+t TINYBLOB <CUSTOM_COL_OPTIONS>,
+m MEDIUMBLOB <CUSTOM_COL_OPTIONS>,
+l LONGBLOB <CUSTOM_COL_OPTIONS>,
+UNIQUE INDEX l_t (l(256),t(64))
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 l_t 1 l # # 256 NULL # #
+t1 0 l_t 2 t # # 64 NULL # #
+INSERT INTO t1 (b,t,m,l) VALUES
+('','','',''),
+('a','b','c','d'),
+('b','d','c','b'),
+('test1','test2','test3','test4'),
+(REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
+(HEX('abcd'),HEX('def'),HEX('a'),HEX('abc')),
+('abc','def','ghi','jkl'),
+('test2','test3','test4','test5'),
+('test3','test4','test5','test6'),
+(REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
+(REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));
+EXPLAIN SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # l_t # # # # #
+SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC;
+SUBSTRING(t,64) SUBSTRING(l,256)
+
+
+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+
+
+fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+
+
+
+EXPLAIN SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 FORCE INDEX (l_t) WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # l_t # # # # #
+SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 FORCE INDEX (l_t) WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC;
+SUBSTRING(t,64) SUBSTRING(l,256)
+
+
+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+
+
+fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+
+
+
+DROP TABLE t1;
+CREATE TABLE t1 (b BLOB <CUSTOM_COL_OPTIONS>,
+t TINYBLOB <CUSTOM_COL_OPTIONS>,
+m MEDIUMBLOB <CUSTOM_COL_OPTIONS>,
+l LONGBLOB <CUSTOM_COL_OPTIONS>,
+INDEX (m(128))
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 m 1 m # # 128 NULL # #
+INSERT INTO t1 (b,t,m,l) VALUES
+('','','',''),
+('a','b','c','d'),
+('b','d','c','b'),
+('test1','test2','test3','test4'),
+(REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
+(HEX('abcd'),HEX('def'),HEX('a'),HEX('abc')),
+('abc','def','ghi','jkl'),
+('test2','test3','test4','test5'),
+('test3','test4','test5','test6'),
+(REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
+(REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));
+EXPLAIN SELECT SUBSTRING(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # m # # # #
+SELECT SUBSTRING(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;
+f
+EXPLAIN SELECT SUBSTRING(m,128) AS f FROM t1 IGNORE INDEX FOR ORDER BY (m) WHERE m = 'test1' ORDER BY f DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # m # # # #
+SELECT SUBSTRING(m,128) AS f FROM t1 IGNORE INDEX FOR ORDER BY (m) WHERE m = 'test1' ORDER BY f DESC;
+f
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_blob_indexes.test b/mysql-test/suite/storage_engine/type_blob_indexes.test
new file mode 100644
index 00000000..7a3e0993
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_blob_indexes.test
@@ -0,0 +1,188 @@
+#
+# BLOB columns with indexes
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+
+# Default index as set in define_engine.inc
+
+let $create_definition =
+ b BLOB $col_indexed_opts,
+ t TINYBLOB $col_opts,
+ m MEDIUMBLOB $col_opts,
+ l LONGBLOB $col_opts,
+ $default_index b (b(32))
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = BLOB types or indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (b,t,m,l) VALUES
+ ('','','',''),
+ ('a','b','c','d'),
+ ('b','d','c','b'),
+ ('test1','test2','test3','test4'),
+ (REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
+ (HEX('abcd'),HEX('def'),HEX('a'),HEX('abc')),
+ ('abc','def','ghi','jkl'),
+ ('test2','test3','test4','test5'),
+ ('test3','test4','test5','test6'),
+ (REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
+ (REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));
+
+ SELECT SUBSTRING(b,16) AS f FROM t1 WHERE b IN ('test1','test2') ORDER BY f;
+ SELECT SUBSTRING(b,16) AS f FROM t1 USE INDEX () WHERE b IN ('test1','test2') ORDER BY f;
+
+ DROP TABLE t1;
+}
+
+
+
+# PK, UNIQUE INDEX, INDEX
+
+let $create_definition =
+ b BLOB $col_indexed_opts,
+ t TINYBLOB $col_opts,
+ m MEDIUMBLOB $col_opts,
+ l LONGBLOB $col_opts,
+ PRIMARY KEY b (b(32))
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = BLOB types or PK
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (b,t,m,l) VALUES
+ ('','','',''),
+ ('a','b','c','d'),
+ ('b','d','c','b'),
+ ('test1','test2','test3','test4'),
+ (REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
+ (HEX('abcd'),HEX('def'),HEX('a'),HEX('abc')),
+ ('abc','def','ghi','jkl'),
+ ('test2','test3','test4','test5'),
+ ('test3','test4','test5','test6'),
+ (REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
+ (REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT SUBSTRING(b,16) AS f FROM t1 WHERE b IN ('test1','test2') ORDER BY f;
+ SELECT SUBSTRING(b,16) AS f FROM t1 WHERE b IN ('test1','test2') ORDER BY f;
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT SUBSTRING(b,16) AS f FROM t1 USE INDEX () WHERE b IN ('test1','test2') ORDER BY f;
+ SELECT SUBSTRING(b,16) AS f FROM t1 USE INDEX () WHERE b IN ('test1','test2') ORDER BY f;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ b BLOB $col_opts,
+ t TINYBLOB $col_indexed_opts,
+ m MEDIUMBLOB $col_opts,
+ l LONGBLOB $col_indexed_opts,
+ UNIQUE INDEX l_t (l(256),t(64))
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = BLOB types or unique indexes or multi-part indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (b,t,m,l) VALUES
+ ('','','',''),
+ ('a','b','c','d'),
+ ('b','d','c','b'),
+ ('test1','test2','test3','test4'),
+ (REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
+ (HEX('abcd'),HEX('def'),HEX('a'),HEX('abc')),
+ ('abc','def','ghi','jkl'),
+ ('test2','test3','test4','test5'),
+ ('test3','test4','test5','test6'),
+ (REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
+ (REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));
+
+ # Here we are getting possible key l_t, but not the final key
+ --replace_column 1 # 2 # 3 # 4 # 6 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC;
+ SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC;
+
+ --replace_column 1 # 2 # 3 # 4 # 6 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 FORCE INDEX (l_t) WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC;
+ SELECT SUBSTRING(t,64), SUBSTRING(l,256) FROM t1 FORCE INDEX (l_t) WHERE t!=l AND l NOT IN ('test1') ORDER BY t, l DESC;
+ DROP TABLE t1;
+
+}
+
+let $create_definition =
+ b BLOB $col_opts,
+ t TINYBLOB $col_opts,
+ m MEDIUMBLOB $col_indexed_opts,
+ l LONGBLOB $col_opts,
+ INDEX (m(128))
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = BLOB types or non-unique indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (b,t,m,l) VALUES
+ ('','','',''),
+ ('a','b','c','d'),
+ ('b','d','c','b'),
+ ('test1','test2','test3','test4'),
+ (REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
+ (HEX('abcd'),HEX('def'),HEX('a'),HEX('abc')),
+ ('abc','def','ghi','jkl'),
+ ('test2','test3','test4','test5'),
+ ('test3','test4','test5','test6'),
+ (REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
+ (REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT SUBSTRING(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;
+ SELECT SUBSTRING(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT SUBSTRING(m,128) AS f FROM t1 IGNORE INDEX FOR ORDER BY (m) WHERE m = 'test1' ORDER BY f DESC;
+ SELECT SUBSTRING(m,128) AS f FROM t1 IGNORE INDEX FOR ORDER BY (m) WHERE m = 'test1' ORDER BY f DESC;
+
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_bool.inc b/mysql-test/suite/storage_engine/type_bool.inc
new file mode 100644
index 00000000..b14f658c
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_bool.inc
@@ -0,0 +1,81 @@
+#
+# BOOLEAN column type
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $create_definition =
+ b1 BOOL $col_opts,
+ b2 BOOLEAN $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = BOOLEAN types
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+
+ # Valid values
+
+ INSERT INTO t1 (b1,b2) VALUES (1,TRUE);
+ --sorted_result
+ SELECT b1,b2 FROM t1;
+
+ INSERT INTO t1 (b1,b2) VALUES (FALSE,0);
+ --sorted_result
+ SELECT b1,b2 FROM t1;
+
+ INSERT INTO t1 (b1,b2) VALUES (2,3);
+ --sorted_result
+ SELECT b1,b2 FROM t1;
+
+ INSERT INTO t1 (b1,b2) VALUES (-1,-2);
+ --sorted_result
+ SELECT b1,b2 FROM t1;
+
+ --sorted_result
+ SELECT IF(b1,'true','false') AS a, IF(b2,'true','false') AS b FROM t1;
+
+ --sorted_result
+ SELECT b1,b2 FROM t1 WHERE b1 = TRUE;
+
+ --sorted_result
+ SELECT b1,b2 FROM t1 WHERE b2 = FALSE;
+
+ # Invalid values
+
+ INSERT INTO t1 (b1,b2) VALUES ('a','b');
+ --sorted_result
+ SELECT b1,b2 FROM t1;
+
+ INSERT INTO t1 (b1,b2) VALUES (128,-129);
+ --sorted_result
+ SELECT b1,b2 FROM t1;
+
+ # This is why we don't have zerofill and unsigned tests
+ # for boolean columns:
+ --let $error_codes = ER_PARSE_ERROR
+ --let $alter_definition = ADD COLUMN b3 BOOLEAN UNSIGNED
+ --source alter_table.inc
+ if ($mysql_errname != ER_PARSE_ERROR)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+ }
+ --let $error_codes = ER_PARSE_ERROR
+ --let $alter_definition = ADD COLUMN b3 BOOL ZEROFILL
+ --source alter_table.inc
+
+ DROP TABLE t1;
+}
+
+
diff --git a/mysql-test/suite/storage_engine/type_bool.result b/mysql-test/suite/storage_engine/type_bool.result
new file mode 100644
index 00000000..10cfc081
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_bool.result
@@ -0,0 +1,70 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (b1 BOOL <CUSTOM_COL_OPTIONS>,
+b2 BOOLEAN <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+b1 tinyint(1) # # #
+b2 tinyint(1) # # #
+INSERT INTO t1 (b1,b2) VALUES (1,TRUE);
+SELECT b1,b2 FROM t1;
+b1 b2
+1 1
+INSERT INTO t1 (b1,b2) VALUES (FALSE,0);
+SELECT b1,b2 FROM t1;
+b1 b2
+0 0
+1 1
+INSERT INTO t1 (b1,b2) VALUES (2,3);
+SELECT b1,b2 FROM t1;
+b1 b2
+0 0
+1 1
+2 3
+INSERT INTO t1 (b1,b2) VALUES (-1,-2);
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+1 1
+2 3
+SELECT IF(b1,'true','false') AS a, IF(b2,'true','false') AS b FROM t1;
+a b
+false false
+true true
+true true
+true true
+SELECT b1,b2 FROM t1 WHERE b1 = TRUE;
+b1 b2
+1 1
+SELECT b1,b2 FROM t1 WHERE b2 = FALSE;
+b1 b2
+0 0
+INSERT INTO t1 (b1,b2) VALUES ('a','b');
+Warnings:
+Warning 1366 Incorrect integer value: 'a' for column `test`.`t1`.`b1` at row 1
+Warning 1366 Incorrect integer value: 'b' for column `test`.`t1`.`b2` at row 1
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+0 0
+1 1
+2 3
+INSERT INTO t1 (b1,b2) VALUES (128,-129);
+Warnings:
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b2' at row 1
+SELECT b1,b2 FROM t1;
+b1 b2
+-1 -2
+0 0
+0 0
+1 1
+127 -128
+2 3
+ALTER TABLE t1 ADD COLUMN b3 BOOLEAN UNSIGNED;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNSIGNED' at line 1
+ALTER TABLE t1 ADD COLUMN b3 BOOL ZEROFILL;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ZEROFILL' at line 1
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_bool.test b/mysql-test/suite/storage_engine/type_bool.test
new file mode 100644
index 00000000..40ef5676
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_bool.test
@@ -0,0 +1,10 @@
+#
+# BOOLEAN column type
+#
+
+--source have_engine.inc
+
+--source type_bool.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_char.inc b/mysql-test/suite/storage_engine/type_char.inc
new file mode 100644
index 00000000..8e666299
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_char.inc
@@ -0,0 +1,59 @@
+#
+# CHAR column types
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $create_definition =
+ c CHAR $col_opts,
+ c0 CHAR(0) $col_opts,
+ c1 CHAR(1) $col_opts,
+ c20 CHAR(20) $col_opts,
+ c255 CHAR(255) $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = CHAR types
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+
+ # Valid values
+
+ INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('','','','','');
+ INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.');
+
+ --sorted_result
+ SELECT c,c0,c1,c20,c255 FROM t1;
+
+ # Invalid values
+
+ INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256));
+ INSERT INTO t1 (c,c0,c1,c20,c255) SELECT c255, c255, c255, c255, CONCAT(c255,c1) FROM t1;
+
+ --sorted_result
+ SELECT c,c0,c1,c20,c255 FROM t1;
+
+ --sorted_result
+ SELECT DISTINCT c20, REPEAT('a',LENGTH(c20)), COUNT(*) FROM t1 GROUP BY c1, c20;
+
+ --let $error_codes = ER_TOO_BIG_FIELDLENGTH
+ --let $alter_definition = ADD COLUMN c257 CHAR(257) $col_opts
+ --source alter_table.inc
+ if ($mysql_errname != ER_TOO_BIG_FIELDLENGTH)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+ }
+ DROP TABLE t1;
+}
+
+
diff --git a/mysql-test/suite/storage_engine/type_char.result b/mysql-test/suite/storage_engine/type_char.result
new file mode 100644
index 00000000..ce6d6f11
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_char.result
@@ -0,0 +1,56 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS>,
+c0 CHAR(0) <CUSTOM_COL_OPTIONS>,
+c1 CHAR(1) <CUSTOM_COL_OPTIONS>,
+c20 CHAR(20) <CUSTOM_COL_OPTIONS>,
+c255 CHAR(255) <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+c char(1) # # #
+c0 char(0) # # #
+c1 char(1) # # #
+c20 char(20) # # #
+c255 char(255) # # #
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('','','','','');
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('a','','b','abcdefghi klmnopqrst', 'Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn\'t already exist which would work.');
+SELECT c,c0,c1,c20,c255 FROM t1;
+c c0 c1 c20 c255
+
+a b abcdefghi klmnopqrst Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.
+INSERT INTO t1 (c,c0,c1,c20,c255) VALUES ('abc', 'a', 'abc', REPEAT('a',21), REPEAT('x',256));
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+Warning 1265 Data truncated for column 'c0' at row 1
+Warning 1265 Data truncated for column 'c1' at row 1
+Warning 1265 Data truncated for column 'c20' at row 1
+Warning 1265 Data truncated for column 'c255' at row 1
+INSERT INTO t1 (c,c0,c1,c20,c255) SELECT c255, c255, c255, c255, CONCAT(c255,c1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 2
+Warning 1265 Data truncated for column 'c0' at row 2
+Warning 1265 Data truncated for column 'c1' at row 2
+Warning 1265 Data truncated for column 'c20' at row 2
+Warning 1265 Data truncated for column 'c' at row 3
+Warning 1265 Data truncated for column 'c0' at row 3
+Warning 1265 Data truncated for column 'c1' at row 3
+Warning 1265 Data truncated for column 'c20' at row 3
+Warning 1265 Data truncated for column 'c255' at row 3
+SELECT c,c0,c1,c20,c255 FROM t1;
+c c0 c1 c20 c255
+
+
+C C Creating an article Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.b
+a a aaaaaaaaaaaaaaaaaaaa xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+a b abcdefghi klmnopqrst Creating an article for the Knowledgebase is similar to asking questions. First, navigate to the category where you feel the article should be. Once there, double check that an article doesn't already exist which would work.
+x x xxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+SELECT DISTINCT c20, REPEAT('a',LENGTH(c20)), COUNT(*) FROM t1 GROUP BY c1, c20;
+c20 REPEAT('a',LENGTH(c20)) COUNT(*)
+ 2
+Creating an article aaaaaaaaaaaaaaaaaaa 1
+aaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaa 1
+abcdefghi klmnopqrst aaaaaaaaaaaaaaaaaaaa 1
+xxxxxxxxxxxxxxxxxxxx aaaaaaaaaaaaaaaaaaaa 1
+ALTER TABLE t1 ADD COLUMN c257 CHAR(257) <CUSTOM_COL_OPTIONS>;
+ERROR 42000: Column length too big for column 'c257' (max = 255); use BLOB or TEXT instead
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_char.test b/mysql-test/suite/storage_engine/type_char.test
new file mode 100644
index 00000000..ef552f47
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_char.test
@@ -0,0 +1,10 @@
+#
+# CHAR column types
+#
+
+--source have_engine.inc
+
+--source type_char.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_char_indexes.result b/mysql-test/suite/storage_engine/type_char_indexes.result
new file mode 100644
index 00000000..73c07686
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_char_indexes.result
@@ -0,0 +1,146 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS>,
+c20 CHAR(20) <CUSTOM_COL_OPTIONS>,
+v16 VARCHAR(16) <CUSTOM_COL_OPTIONS>,
+v128 VARCHAR(128) <CUSTOM_COL_OPTIONS>,
+<CUSTOM_INDEX> c20 (c20)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 # 1 c20 # # NULL NULL # #
+INSERT INTO t1 (c,c20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+SELECT c20 FROM t1 ORDER BY c20;
+c20
+char1
+char2
+char3
+char4
+DROP TABLE t1;
+CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS>,
+c20 CHAR(20) <CUSTOM_COL_OPTIONS>,
+v16 VARCHAR(16) <CUSTOM_COL_OPTIONS>,
+v128 VARCHAR(128) <CUSTOM_COL_OPTIONS>,
+<CUSTOM_INDEX> v16 (v16)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 # 1 v16 # # NULL NULL # #
+INSERT INTO t1 (c,c20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char1','varchar3a','varchar1b'),('c','char4','varchar4a','varchar4b');
+SELECT v16 FROM t1 ORDER BY v16;
+v16
+varchar1a
+varchar2a
+varchar3a
+varchar4a
+DROP TABLE t1;
+CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS>,
+c20 CHAR(20) <CUSTOM_COL_OPTIONS> PRIMARY KEY,
+v16 VARCHAR(16) <CUSTOM_COL_OPTIONS>,
+v128 VARCHAR(128) <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 PRIMARY 1 c20 # # NULL NULL # #
+INSERT INTO t1 (c,c20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+EXPLAIN SELECT c20 FROM t1 ORDER BY c20;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # PRIMARY # # # #
+SELECT c20 FROM t1 ORDER BY c20;
+c20
+char1
+char2
+char3
+char4
+EXPLAIN SELECT c20 FROM t1 FORCE INDEX FOR ORDER BY (PRIMARY) ORDER BY c20;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # PRIMARY # # # #
+SELECT c20 FROM t1 FORCE INDEX FOR ORDER BY (PRIMARY) ORDER BY c20;
+c20
+char1
+char2
+char3
+char4
+DROP TABLE t1;
+CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS>,
+c20 CHAR(20) <CUSTOM_COL_OPTIONS>,
+v16 VARCHAR(16) <CUSTOM_COL_OPTIONS>,
+v128 VARCHAR(128) <CUSTOM_COL_OPTIONS>,
+UNIQUE INDEX c_v (c,v128)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 c_v 1 c # # NULL NULL # #
+t1 0 c_v 2 v128 # # NULL NULL # #
+INSERT INTO t1 (c,c20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+EXPLAIN SELECT c, v128 FROM t1 WHERE c != 'a' AND v128 > 'varchar';
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # c_v # # # #
+SELECT c, v128 FROM t1 WHERE c != 'a' AND v128 > 'varchar';
+c v128
+b varchar1b
+c varchar3b
+EXPLAIN SELECT v128, COUNT(*) FROM t1 GROUP BY v128;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # c_v # # # #
+SELECT v128, COUNT(*) FROM t1 GROUP BY v128;
+v128 COUNT(*)
+varchar1b 2
+varchar2b 1
+varchar3b 1
+EXPLAIN SELECT v128, COUNT(*) FROM t1 USE INDEX FOR GROUP BY (c_v) GROUP BY v128;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # c_v # # # #
+SELECT v128, COUNT(*) FROM t1 USE INDEX FOR GROUP BY (c_v) GROUP BY v128;
+v128 COUNT(*)
+varchar1b 2
+varchar2b 1
+varchar3b 1
+SET SESSION optimizer_switch = 'engine_condition_pushdown=on';
+Warnings:
+Warning 1681 'engine_condition_pushdown=on' is deprecated and will be removed in a future release
+EXPLAIN SELECT c,c20,v16,v128 FROM t1 WHERE c > 'a';
+id select_type table type possible_keys key key_len ref rows Extra
+# # # range c_v c_v # # # Using index condition
+SELECT c,c20,v16,v128 FROM t1 WHERE c > 'a';
+c c20 v16 v128
+b char3 varchar1a varchar1b
+c char4 varchar3a varchar3b
+SET SESSION optimizer_switch = @@global.optimizer_switch;
+DROP TABLE t1;
+CREATE TABLE t1 (c CHAR <CUSTOM_COL_OPTIONS>,
+c20 CHAR(20) <CUSTOM_COL_OPTIONS>,
+v16 VARCHAR(16) <CUSTOM_COL_OPTIONS>,
+v128 VARCHAR(128) <CUSTOM_COL_OPTIONS>,
+INDEX (v16)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 v16 1 v16 # # NULL NULL # #
+INSERT INTO t1 (c,c20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+EXPLAIN SELECT SUBSTRING(v16,0,3) FROM t1 WHERE v16 LIKE 'varchar%';
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # v16 # # # #
+SELECT SUBSTRING(v16,7,3) FROM t1 WHERE v16 LIKE 'varchar%';
+SUBSTRING(v16,7,3)
+r1a
+r1a
+r2a
+r3a
+EXPLAIN SELECT SUBSTRING(v16,0,3) FROM t1 IGNORE INDEX (v16) WHERE v16 LIKE 'varchar%';
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # NULL # # # #
+SELECT SUBSTRING(v16,7,3) FROM t1 IGNORE INDEX (v16) WHERE v16 LIKE 'varchar%';
+SUBSTRING(v16,7,3)
+r1a
+r1a
+r2a
+r3a
+EXPLAIN SELECT c,c20,v16,v128 FROM t1 WHERE v16 = 'varchar1a' OR v16 = 'varchar3a' ORDER BY v16;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # range # v16 # # # #
+SELECT c,c20,v16,v128 FROM t1 WHERE v16 = 'varchar1a' OR v16 = 'varchar3a' ORDER BY v16;
+c c20 v16 v128
+a char1 varchar1a varchar1b
+b char3 varchar1a varchar1b
+c char4 varchar3a varchar3b
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_char_indexes.test b/mysql-test/suite/storage_engine/type_char_indexes.test
new file mode 100644
index 00000000..6fff8a6f
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_char_indexes.test
@@ -0,0 +1,186 @@
+#
+# CHAR and VARCHAR columns with indexes
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Default index as set in define_engine.inc
+
+let $create_definition =
+ c CHAR $col_opts,
+ c20 CHAR(20) $col_indexed_opts,
+ v16 VARCHAR(16) $col_opts,
+ v128 VARCHAR(128) $col_opts,
+ $default_index c20 (c20)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = CHAR or VARCHAR types or indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (c,c20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+
+ SELECT c20 FROM t1 ORDER BY c20;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ c CHAR $col_opts,
+ c20 CHAR(20) $col_opts,
+ v16 VARCHAR(16) $col_indexed_opts,
+ v128 VARCHAR(128) $col_opts,
+ $default_index v16 (v16)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = CHAR or VARCHAR types or indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (c,c20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char1','varchar3a','varchar1b'),('c','char4','varchar4a','varchar4b');
+
+ SELECT v16 FROM t1 ORDER BY v16;
+
+ DROP TABLE t1;
+}
+
+
+# PK, UNIQUE INDEX, INDEX
+
+let $create_definition =
+ c CHAR $col_opts,
+ c20 CHAR(20) $col_indexed_opts PRIMARY KEY,
+ v16 VARCHAR(16) $col_opts,
+ v128 VARCHAR(128) $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = CHAR or VARCHAR types or PK
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (c,c20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT c20 FROM t1 ORDER BY c20;
+ SELECT c20 FROM t1 ORDER BY c20;
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT c20 FROM t1 FORCE INDEX FOR ORDER BY (PRIMARY) ORDER BY c20;
+ SELECT c20 FROM t1 FORCE INDEX FOR ORDER BY (PRIMARY) ORDER BY c20;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ c CHAR $col_indexed_opts,
+ c20 CHAR(20) $col_opts,
+ v16 VARCHAR(16) $col_opts,
+ v128 VARCHAR(128) $col_indexed_opts,
+ UNIQUE INDEX c_v (c,v128)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = CHAR or VARCHAR types or unique keys or multi-part keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (c,c20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT c, v128 FROM t1 WHERE c != 'a' AND v128 > 'varchar';
+ --sorted_result
+ SELECT c, v128 FROM t1 WHERE c != 'a' AND v128 > 'varchar';
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT v128, COUNT(*) FROM t1 GROUP BY v128;
+ --sorted_result
+ SELECT v128, COUNT(*) FROM t1 GROUP BY v128;
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT v128, COUNT(*) FROM t1 USE INDEX FOR GROUP BY (c_v) GROUP BY v128;
+ --sorted_result
+ SELECT v128, COUNT(*) FROM t1 USE INDEX FOR GROUP BY (c_v) GROUP BY v128;
+
+ SET SESSION optimizer_switch = 'engine_condition_pushdown=on';
+ --replace_column 1 # 2 # 3 # 7 # 8 # 9 #
+ EXPLAIN SELECT c,c20,v16,v128 FROM t1 WHERE c > 'a';
+ --sorted_result
+ SELECT c,c20,v16,v128 FROM t1 WHERE c > 'a';
+ SET SESSION optimizer_switch = @@global.optimizer_switch;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ c CHAR $col_opts,
+ c20 CHAR(20) $col_opts,
+ v16 VARCHAR(16) $col_indexed_opts,
+ v128 VARCHAR(128) $col_opts,
+ INDEX (v16)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = CHAR or VARCHAR types or non-unique indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (c,c20,v16,v128) VALUES ('a','char1','varchar1a','varchar1b'),('a','char2','varchar2a','varchar2b'),('b','char3','varchar1a','varchar1b'),('c','char4','varchar3a','varchar3b');
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT SUBSTRING(v16,0,3) FROM t1 WHERE v16 LIKE 'varchar%';
+ --sorted_result
+ SELECT SUBSTRING(v16,7,3) FROM t1 WHERE v16 LIKE 'varchar%';
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT SUBSTRING(v16,0,3) FROM t1 IGNORE INDEX (v16) WHERE v16 LIKE 'varchar%';
+ --sorted_result
+ SELECT SUBSTRING(v16,7,3) FROM t1 IGNORE INDEX (v16) WHERE v16 LIKE 'varchar%';
+
+ --replace_column 1 # 2 # 3 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT c,c20,v16,v128 FROM t1 WHERE v16 = 'varchar1a' OR v16 = 'varchar3a' ORDER BY v16;
+ --sorted_result
+ SELECT c,c20,v16,v128 FROM t1 WHERE v16 = 'varchar1a' OR v16 = 'varchar3a' ORDER BY v16;
+
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_date_time.inc b/mysql-test/suite/storage_engine/type_date_time.inc
new file mode 100644
index 00000000..29bfcf63
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_date_time.inc
@@ -0,0 +1,55 @@
+#
+# Date and time column types
+# (DATE, DATETIME, TIMESTAMP, TIME, YEAR)
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $create_definition =
+ d DATE $col_opts,
+ dt DATETIME $col_opts,
+ ts TIMESTAMP $col_opts,
+ t TIME $col_opts,
+ y YEAR $col_opts,
+ y4 YEAR(4) $col_opts,
+ y2 YEAR(2) $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Date and time types
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+
+ SET @tm = '2012-04-09 05:27:00';
+
+ # Valid values
+ # '1970-01-01 00:00:01'
+ INSERT INTO t1 (d,dt,ts,t,y,y4,y2) VALUES
+ ('1000-01-01', '1000-01-01 00:00:00', FROM_UNIXTIME(1), '-838:59:59', '1901', '1901', '00'),
+ ('9999-12-31', '9999-12-31 23:59:59', FROM_UNIXTIME(2147483647), '838:59:59', '2155', '2155', '99'),
+ ('0000-00-00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '00:00:00', '0', '0', '0'),
+ (DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),YEAR(@tm),YEAR(@tm));
+
+ --sorted_result
+ SELECT d,dt,ts,t,y,y4,y2 FROM t1;
+
+ # Invalid values
+
+ INSERT INTO t1 (d,dt,ts,t,y,y4,y2) VALUES
+ ('999-13-32', '999-11-31 00:00:00', '0', '-839:00:00', '1900', '1900', '-1' );
+
+ --sorted_result
+ SELECT d,dt,ts,t,y,y4,y2 FROM t1;
+
+ DROP TABLE t1;
+}
+
+
diff --git a/mysql-test/suite/storage_engine/type_date_time.result b/mysql-test/suite/storage_engine/type_date_time.result
new file mode 100644
index 00000000..f136dd93
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_date_time.result
@@ -0,0 +1,50 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (d DATE <CUSTOM_COL_OPTIONS>,
+dt DATETIME <CUSTOM_COL_OPTIONS>,
+ts TIMESTAMP <CUSTOM_COL_OPTIONS>,
+t TIME <CUSTOM_COL_OPTIONS>,
+y YEAR <CUSTOM_COL_OPTIONS>,
+y4 YEAR(4) <CUSTOM_COL_OPTIONS>,
+y2 YEAR(2) <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+Warnings:
+Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+d date # # #
+dt datetime # # #
+ts timestamp # # # on update current_timestamp()
+t time # # #
+y year(4) # # #
+y4 year(4) # # #
+y2 year(2) # # #
+SET @tm = '2012-04-09 05:27:00';
+INSERT INTO t1 (d,dt,ts,t,y,y4,y2) VALUES
+('1000-01-01', '1000-01-01 00:00:00', FROM_UNIXTIME(1), '-838:59:59', '1901', '1901', '00'),
+('9999-12-31', '9999-12-31 23:59:59', FROM_UNIXTIME(2147483647), '838:59:59', '2155', '2155', '99'),
+('0000-00-00', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '00:00:00', '0', '0', '0'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm),YEAR(@tm),YEAR(@tm));
+SELECT d,dt,ts,t,y,y4,y2 FROM t1;
+d dt ts t y y4 y2
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 2000 2000 00
+1000-01-01 1000-01-01 00:00:00 1970-01-01 00:00:01 -838:59:59 1901 1901 00
+2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 12
+9999-12-31 9999-12-31 23:59:59 2038-01-19 03:14:07 838:59:59 2155 2155 99
+INSERT INTO t1 (d,dt,ts,t,y,y4,y2) VALUES
+('999-13-32', '999-11-31 00:00:00', '0', '-839:00:00', '1900', '1900', '-1' );
+Warnings:
+Warning 1265 Data truncated for column 'd' at row 1
+Warning 1265 Data truncated for column 'dt' at row 1
+Warning 1265 Data truncated for column 'ts' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 'y' at row 1
+Warning 1264 Out of range value for column 'y4' at row 1
+Warning 1264 Out of range value for column 'y2' at row 1
+SELECT d,dt,ts,t,y,y4,y2 FROM t1;
+d dt ts t y y4 y2
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 -838:59:59 0000 0000 00
+0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00 00:00:00 2000 2000 00
+1000-01-01 1000-01-01 00:00:00 1970-01-01 00:00:01 -838:59:59 1901 1901 00
+2012-04-09 2012-04-09 05:27:00 2012-04-09 05:27:00 05:27:00 2012 2012 12
+9999-12-31 9999-12-31 23:59:59 2038-01-19 03:14:07 838:59:59 2155 2155 99
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_date_time.test b/mysql-test/suite/storage_engine/type_date_time.test
new file mode 100644
index 00000000..7f6c325e
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_date_time.test
@@ -0,0 +1,11 @@
+#
+# Date and time column types
+# (DATE, DATETIME, TIMESTAMP, TIME, YEAR)
+#
+
+--source have_engine.inc
+
+--source type_date_time.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_date_time_indexes.result b/mysql-test/suite/storage_engine/type_date_time_indexes.result
new file mode 100644
index 00000000..f259aea2
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_date_time_indexes.result
@@ -0,0 +1,278 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (d DATE <CUSTOM_COL_OPTIONS>,
+dt DATETIME <CUSTOM_COL_OPTIONS>,
+ts TIMESTAMP <CUSTOM_COL_OPTIONS>,
+t TIME <CUSTOM_COL_OPTIONS>,
+y YEAR <CUSTOM_COL_OPTIONS>,
+<CUSTOM_INDEX> d (d)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 # 1 d # # NULL NULL # #
+SET @tm = '2012-04-09 05:27:00';
+INSERT INTO t1 (d,dt,ts,t,y) VALUES
+('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000'),
+('2012-01-22', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+SELECT d FROM t1 ORDER BY d LIMIT 3;
+d
+2011-03-31
+2012-01-12
+2012-01-22
+DROP TABLE t1;
+CREATE TABLE t1 (d DATE <CUSTOM_COL_OPTIONS>,
+dt DATETIME <CUSTOM_COL_OPTIONS>,
+ts TIMESTAMP <CUSTOM_COL_OPTIONS>,
+t TIME <CUSTOM_COL_OPTIONS>,
+y YEAR <CUSTOM_COL_OPTIONS>,
+<CUSTOM_INDEX> dt (dt)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 # 1 dt # # NULL NULL # #
+SET @tm = '2012-04-09 05:27:00';
+INSERT INTO t1 (d,dt,ts,t,y) VALUES
+('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000'),
+('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+SELECT dt FROM t1 ORDER BY dt LIMIT 3;
+dt
+2010-11-22 11:43:14
+2010-11-22 12:33:54
+2011-08-27 21:33:56
+DROP TABLE t1;
+CREATE TABLE t1 (d DATE <CUSTOM_COL_OPTIONS>,
+dt DATETIME <CUSTOM_COL_OPTIONS>,
+ts TIMESTAMP <CUSTOM_COL_OPTIONS>,
+t TIME <CUSTOM_COL_OPTIONS>,
+y YEAR <CUSTOM_COL_OPTIONS>,
+<CUSTOM_INDEX> ts (ts)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 # 1 ts # # NULL NULL # #
+SET @tm = '2012-04-09 05:27:00';
+INSERT INTO t1 (d,dt,ts,t,y) VALUES
+('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:25', '00:12:33', '2000'),
+('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+SELECT ts FROM t1 ORDER BY ts LIMIT 3;
+ts
+1997-01-31 11:54:01
+1999-03-30 19:11:08
+1999-04-30 19:11:08
+DROP TABLE t1;
+CREATE TABLE t1 (d DATE <CUSTOM_COL_OPTIONS>,
+dt DATETIME <CUSTOM_COL_OPTIONS>,
+ts TIMESTAMP <CUSTOM_COL_OPTIONS>,
+t TIME <CUSTOM_COL_OPTIONS>,
+y YEAR <CUSTOM_COL_OPTIONS>,
+<CUSTOM_INDEX> t (t)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 # 1 t # # NULL NULL # #
+SET @tm = '2012-04-09 05:27:00';
+INSERT INTO t1 (d,dt,ts,t,y) VALUES
+('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:25', '00:12:33', '2000'),
+('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+SELECT t FROM t1 ORDER BY t LIMIT 3;
+t
+00:12:32
+00:12:33
+05:27:00
+DROP TABLE t1;
+CREATE TABLE t1 (d DATE <CUSTOM_COL_OPTIONS>,
+dt DATETIME <CUSTOM_COL_OPTIONS>,
+ts TIMESTAMP <CUSTOM_COL_OPTIONS>,
+t TIME <CUSTOM_COL_OPTIONS>,
+y YEAR <CUSTOM_COL_OPTIONS>,
+<CUSTOM_INDEX> y (y)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 # 1 y # # NULL NULL # #
+SET @tm = '2012-04-09 05:27:00';
+INSERT INTO t1 (d,dt,ts,t,y) VALUES
+('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:25', '00:12:33', '2000'),
+('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+SELECT y FROM t1 ORDER BY y LIMIT 3;
+y
+1994
+1998
+1999
+DROP TABLE t1;
+CREATE TABLE t1 (d DATE <CUSTOM_COL_OPTIONS>,
+dt DATETIME <CUSTOM_COL_OPTIONS> PRIMARY KEY,
+ts TIMESTAMP <CUSTOM_COL_OPTIONS>,
+t TIME <CUSTOM_COL_OPTIONS>,
+y YEAR <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 PRIMARY 1 dt # # NULL NULL # #
+SET @tm = '2012-04-09 05:27:00';
+INSERT INTO t1 (d,dt,ts,t,y) VALUES
+('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000'),
+('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+EXPLAIN SELECT dt FROM t1 ORDER BY dt LIMIT 3;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # PRIMARY # # # #
+SELECT dt FROM t1 ORDER BY dt LIMIT 3;
+dt
+2010-11-22 11:43:14
+2010-11-22 12:33:54
+2011-08-27 21:33:56
+EXPLAIN SELECT dt FROM t1 FORCE INDEX FOR ORDER BY (PRIMARY) ORDER BY dt LIMIT 3;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # PRIMARY # # # #
+SELECT dt FROM t1 FORCE INDEX FOR ORDER BY (PRIMARY) ORDER BY dt LIMIT 3;
+dt
+2010-11-22 11:43:14
+2010-11-22 12:33:54
+2011-08-27 21:33:56
+INSERT INTO t1 (d,dt,ts,t,y) VALUES
+('2012-01-11', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000');
+ERROR 23000: Duplicate entry '2010-11-22 12:33:54' for key 'PRIMARY'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+DROP TABLE t1;
+CREATE TABLE t1 (d DATE <CUSTOM_COL_OPTIONS>,
+dt DATETIME <CUSTOM_COL_OPTIONS>,
+ts TIMESTAMP <CUSTOM_COL_OPTIONS>,
+t TIME <CUSTOM_COL_OPTIONS>,
+y YEAR <CUSTOM_COL_OPTIONS>,
+INDEX (ts)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 ts 1 ts # # NULL NULL # #
+SET @tm = '2012-04-09 05:27:00';
+INSERT INTO t1 (d,dt,ts,t,y) VALUES
+('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000'),
+('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+EXPLAIN SELECT ts FROM t1 WHERE ts > NOW();
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # ts # # # #
+SELECT ts FROM t1 WHERE ts > NOW();
+ts
+EXPLAIN SELECT ts FROM t1 USE INDEX () WHERE ts > NOW();
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # NULL # # # #
+SELECT ts FROM t1 USE INDEX () WHERE ts > NOW();
+ts
+DROP TABLE t1;
+CREATE TABLE t1 (d DATE <CUSTOM_COL_OPTIONS>,
+dt DATETIME <CUSTOM_COL_OPTIONS>,
+ts TIMESTAMP <CUSTOM_COL_OPTIONS>,
+t TIME <CUSTOM_COL_OPTIONS>,
+y YEAR <CUSTOM_COL_OPTIONS>,
+UNIQUE INDEX d_t (d,t)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 d_t 1 d # # NULL NULL # #
+t1 0 d_t 2 t # # NULL NULL # #
+SET @tm = '2012-04-09 05:27:00';
+INSERT INTO t1 (d,dt,ts,t,y) VALUES
+('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000'),
+('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+EXPLAIN SELECT d, t FROM t1 WHERE CONCAT(d,' ',t) != CURRENT_DATE();
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # d_t # # # #
+SELECT d, t FROM t1 WHERE CONCAT(d,' ',t) != CURRENT_DATE();
+d t
+2011-03-31 22:04:10
+2012-01-12 00:12:32
+2012-01-12 00:12:33
+2012-03-13 12:10:00
+2012-03-31 12:00:00
+2012-04-09 05:27:00
+EXPLAIN SELECT d, t FROM t1 IGNORE INDEX (d_t) WHERE CONCAT(d,' ',t) != CURRENT_DATE();
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # NULL # # # #
+SELECT d, t FROM t1 IGNORE INDEX (d_t) WHERE CONCAT(d,' ',t) != CURRENT_DATE();
+d t
+2011-03-31 22:04:10
+2012-01-12 00:12:32
+2012-01-12 00:12:33
+2012-03-13 12:10:00
+2012-03-31 12:00:00
+2012-04-09 05:27:00
+INSERT INTO t1 (d,dt,ts,t,y) VALUES
+('2012-01-12', '2010-11-22 12:33:53', '2011-11-14 21:45:55', '00:12:33', '2000');
+ERROR 23000: Duplicate entry '2012-01-12-00:12:33' for key 'd_t'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+DROP TABLE t1;
+CREATE TABLE t1 (d DATE <CUSTOM_COL_OPTIONS>,
+dt DATETIME <CUSTOM_COL_OPTIONS>,
+ts TIMESTAMP <CUSTOM_COL_OPTIONS>,
+t TIME <CUSTOM_COL_OPTIONS>,
+y YEAR <CUSTOM_COL_OPTIONS>,
+INDEX (y,t)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 y 1 y # # NULL NULL # #
+t1 1 y 2 t # # NULL NULL # #
+SET @tm = '2012-04-09 05:27:00';
+INSERT INTO t1 (d,dt,ts,t,y) VALUES
+('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000'),
+('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+(DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+EXPLAIN SELECT y, COUNT(*) FROM t1 GROUP BY y;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # y # # # #
+SELECT y, COUNT(*) FROM t1 GROUP BY y;
+y COUNT(*)
+1994 1
+1998 1
+1999 1
+2000 1
+2001 1
+2012 1
+EXPLAIN SELECT y, COUNT(*) FROM t1 USE INDEX FOR GROUP BY () GROUP BY y;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # y # # # #
+SELECT y, COUNT(*) FROM t1 USE INDEX FOR GROUP BY () GROUP BY y;
+y COUNT(*)
+1994 1
+1998 1
+1999 1
+2000 1
+2001 1
+2012 1
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_date_time_indexes.test b/mysql-test/suite/storage_engine/type_date_time_indexes.test
new file mode 100644
index 00000000..bb06432f
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_date_time_indexes.test
@@ -0,0 +1,366 @@
+#
+# Date and time columns with indexes
+# (DATE, DATETIME, TIMESTAMP, TIME, YEAR)
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+
+# Default index as set in define_engine.inc
+
+let $create_definition =
+ d DATE $col_indexed_opts,
+ dt DATETIME $col_opts,
+ ts TIMESTAMP $col_opts,
+ t TIME $col_opts,
+ y YEAR $col_opts,
+ $default_index d (d)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Date and time types or indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+ SET @tm = '2012-04-09 05:27:00';
+
+ INSERT INTO t1 (d,dt,ts,t,y) VALUES
+ ('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000'),
+ ('2012-01-22', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+ ('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+ ('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+ ('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+ (DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+
+ SELECT d FROM t1 ORDER BY d LIMIT 3;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ d DATE $col_opts,
+ dt DATETIME $col_indexed_opts,
+ ts TIMESTAMP $col_opts,
+ t TIME $col_opts,
+ y YEAR $col_opts,
+ $default_index dt (dt)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Date and time types or indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+ SET @tm = '2012-04-09 05:27:00';
+
+ INSERT INTO t1 (d,dt,ts,t,y) VALUES
+ ('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000'),
+ ('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+ ('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+ ('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+ ('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+ (DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+
+ SELECT dt FROM t1 ORDER BY dt LIMIT 3;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ d DATE $col_opts,
+ dt DATETIME $col_opts,
+ ts TIMESTAMP $col_indexed_opts,
+ t TIME $col_opts,
+ y YEAR $col_opts,
+ $default_index ts (ts)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Date and time types or indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+ SET @tm = '2012-04-09 05:27:00';
+
+ INSERT INTO t1 (d,dt,ts,t,y) VALUES
+ ('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:25', '00:12:33', '2000'),
+ ('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+ ('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+ ('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+ ('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+ (DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+
+ SELECT ts FROM t1 ORDER BY ts LIMIT 3;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ d DATE $col_opts,
+ dt DATETIME $col_opts,
+ ts TIMESTAMP $col_opts,
+ t TIME $col_indexed_opts,
+ y YEAR $col_opts,
+ $default_index t (t)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Date and time types or indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+ SET @tm = '2012-04-09 05:27:00';
+
+ INSERT INTO t1 (d,dt,ts,t,y) VALUES
+ ('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:25', '00:12:33', '2000'),
+ ('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+ ('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+ ('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+ ('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+ (DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+
+ SELECT t FROM t1 ORDER BY t LIMIT 3;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ d DATE $col_opts,
+ dt DATETIME $col_opts,
+ ts TIMESTAMP $col_opts,
+ t TIME $col_opts,
+ y YEAR $col_indexed_opts,
+ $default_index y (y)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Date and time types or indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+ SET @tm = '2012-04-09 05:27:00';
+
+ INSERT INTO t1 (d,dt,ts,t,y) VALUES
+ ('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:25', '00:12:33', '2000'),
+ ('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+ ('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+ ('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+ ('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+ (DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+
+ SELECT y FROM t1 ORDER BY y LIMIT 3;
+
+ DROP TABLE t1;
+}
+
+
+# PK, UNIQUE INDEX, INDEX
+
+
+let $create_definition =
+ d DATE $col_opts,
+ dt DATETIME $col_indexed_opts PRIMARY KEY,
+ ts TIMESTAMP $col_opts,
+ t TIME $col_opts,
+ y YEAR $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Date and time types or PK
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+ SET @tm = '2012-04-09 05:27:00';
+
+ INSERT INTO t1 (d,dt,ts,t,y) VALUES
+ ('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000'),
+ ('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+ ('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+ ('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+ ('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+ (DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT dt FROM t1 ORDER BY dt LIMIT 3;
+ SELECT dt FROM t1 ORDER BY dt LIMIT 3;
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT dt FROM t1 FORCE INDEX FOR ORDER BY (PRIMARY) ORDER BY dt LIMIT 3;
+ SELECT dt FROM t1 FORCE INDEX FOR ORDER BY (PRIMARY) ORDER BY dt LIMIT 3;
+
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ INSERT INTO t1 (d,dt,ts,t,y) VALUES
+ ('2012-01-11', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000');
+ --source check_errors.inc
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ d DATE $col_opts,
+ dt DATETIME $col_opts,
+ ts TIMESTAMP $col_indexed_opts,
+ t TIME $col_opts,
+ y YEAR $col_opts,
+ INDEX (ts)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Date and time types or non-unique keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+ SET @tm = '2012-04-09 05:27:00';
+
+ INSERT INTO t1 (d,dt,ts,t,y) VALUES
+ ('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000'),
+ ('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+ ('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+ ('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+ ('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+ (DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT ts FROM t1 WHERE ts > NOW();
+ --sorted_result
+ SELECT ts FROM t1 WHERE ts > NOW();
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT ts FROM t1 USE INDEX () WHERE ts > NOW();
+ --sorted_result
+ SELECT ts FROM t1 USE INDEX () WHERE ts > NOW();
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ d DATE $col_indexed_opts,
+ dt DATETIME $col_opts,
+ ts TIMESTAMP $col_opts,
+ t TIME $col_indexed_opts,
+ y YEAR $col_opts,
+ UNIQUE INDEX d_t (d,t)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Date and time types or unique keys or multi-part keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+ SET @tm = '2012-04-09 05:27:00';
+
+ INSERT INTO t1 (d,dt,ts,t,y) VALUES
+ ('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000'),
+ ('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+ ('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+ ('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+ ('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+ (DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT d, t FROM t1 WHERE CONCAT(d,' ',t) != CURRENT_DATE();
+ --sorted_result
+ SELECT d, t FROM t1 WHERE CONCAT(d,' ',t) != CURRENT_DATE();
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT d, t FROM t1 IGNORE INDEX (d_t) WHERE CONCAT(d,' ',t) != CURRENT_DATE();
+ --sorted_result
+ SELECT d, t FROM t1 IGNORE INDEX (d_t) WHERE CONCAT(d,' ',t) != CURRENT_DATE();
+
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ INSERT INTO t1 (d,dt,ts,t,y) VALUES
+ ('2012-01-12', '2010-11-22 12:33:53', '2011-11-14 21:45:55', '00:12:33', '2000');
+ --source check_errors.inc
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ d DATE $col_opts,
+ dt DATETIME $col_opts,
+ ts TIMESTAMP $col_opts,
+ t TIME $col_indexed_opts,
+ y YEAR $col_indexed_opts,
+ INDEX (y,t)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Date and time types or non-unique keys or multi-part keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+ SET @tm = '2012-04-09 05:27:00';
+
+ INSERT INTO t1 (d,dt,ts,t,y) VALUES
+ ('2012-01-12', '2010-11-22 12:33:54', '2011-11-14 21:45:55', '00:12:33', '2000'),
+ ('2012-01-12', '2010-11-22 11:43:14', '2011-11-14 21:45:55', '00:12:32', '2001'),
+ ('2012-03-31', '2011-08-28 21:33:56', '1999-04-30 19:11:08', '12:00:00', '1999'),
+ ('2012-03-13', '2011-08-27 21:33:56', '1999-03-30 19:11:08', '12:10:00', '1998'),
+ ('2011-03-31', '2011-08-28 20:33:56', '1997-01-31 11:54:01', '22:04:10', '1994'),
+ (DATE(@tm),@tm,TIMESTAMP(@tm),TIME(@tm),YEAR(@tm));
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT y, COUNT(*) FROM t1 GROUP BY y;
+ --sorted_result
+ SELECT y, COUNT(*) FROM t1 GROUP BY y;
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT y, COUNT(*) FROM t1 USE INDEX FOR GROUP BY () GROUP BY y;
+ --sorted_result
+ SELECT y, COUNT(*) FROM t1 USE INDEX FOR GROUP BY () GROUP BY y;
+
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_enum.inc b/mysql-test/suite/storage_engine/type_enum.inc
new file mode 100644
index 00000000..2e747e50
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_enum.inc
@@ -0,0 +1,69 @@
+#
+# ENUM column type
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Valid values.
+# We cannot test the maximum of 65,536 here,
+# because mysqltest has the standard limit of MAX_QUERY=256K;
+# but we can at least try 257
+
+let $create_definition =
+ a ENUM('') $col_opts,
+ b ENUM('test1','test2','test3','test4','test5') $col_opts,
+ c ENUM('1','2','3','4','5','6','7','8','9','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',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = ENUM type
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+
+ INSERT INTO t1 (a,b,c) VALUES ('','test2','4'),('',5,2);
+ --sorted_result
+ SELECT a,b,c FROM t1;
+
+ # Out of range values
+ # (should produce warnings)
+
+ INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
+ --sorted_result
+ SELECT a,b,c FROM t1;
+
+ # Non-unique values in enum
+ # (should produce a warning)
+ --let $alter_definition = ADD COLUMN e ENUM('a','A') $col_opts
+ --source alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+ }
+
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+
+ INSERT INTO t1 (a,b,c,e) VALUES ('','test3','75','A');
+ --sorted_result
+ SELECT a,b,c,e FROM t1;
+
+ # Simple comparison
+
+ --sorted_result
+ SELECT a,b,c,e FROM t1 WHERE b='test2' OR a != '';
+
+ DROP TABLE t1;
+}
+
+
+
diff --git a/mysql-test/suite/storage_engine/type_enum.result b/mysql-test/suite/storage_engine/type_enum.result
new file mode 100644
index 00000000..0d305eb6
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_enum.result
@@ -0,0 +1,45 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a ENUM('') <CUSTOM_COL_OPTIONS>,
+b ENUM('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS>,
+c ENUM('1','2','3','4','5','6','7','8','9','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',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a enum('') # # #
+b enum('test1','test2','test3','test4','test5') # # #
+c enum('1','2','3','4','5','6','7','8','9','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','','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') # # #
+INSERT INTO t1 (a,b,c) VALUES ('','test2','4'),('',5,2);
+SELECT a,b,c FROM t1;
+a b c
+ test2 4
+ test5 2
+INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
+Warnings:
+Warning 1265 Data truncated for column 'a' at row 1
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+
+ test2 4
+ test5 2
+ALTER TABLE t1 ADD COLUMN e ENUM('a','A') <CUSTOM_COL_OPTIONS>;
+Warnings:
+Note 1291 Column 'e' has duplicated value 'a' in ENUM
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a enum('') # # #
+b enum('test1','test2','test3','test4','test5') # # #
+c enum('1','2','3','4','5','6','7','8','9','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','','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i','3j','3k','3l','3m','3n','3o','3p','3q','3r','3s','3t','3u','3v','3w','3x','3y','3z','40','41','42','43','44','45','46','47','48','49','4a','4b','4c','4d','4e','4f','4g','4h','4i','4j','4k','4l','4m','4n','4o','4p','4q','4r','4s','4t','4u','4v','4w','4x','4y','4z','50','51','52','53','54','55','56','57','58','59','5a','5b','5c','5d','5e','5f','5g','5h','5i','5j','5k','5l','5m','5n','5o','5p','5q','5r','5s','5t','5u','5v','5w','5x','5y','5z','60','61','62','63','64','65','66','67','68','69','6a','6b','6c','6d','6e','6f','6g','6h','6i','6j','6k','6l','6m','6n','6o','6p','6q','6r','6s','6t','6u','6v','6w','6x','6y','6z','70','71','72','73','74','75') # # #
+e enum('a','A') # # #
+INSERT INTO t1 (a,b,c,e) VALUES ('','test3','75','A');
+SELECT a,b,c,e FROM t1;
+a b c e
+ NULL
+ test2 4 NULL
+ test3 75 a
+ test5 2 NULL
+SELECT a,b,c,e FROM t1 WHERE b='test2' OR a != '';
+a b c e
+ test2 4 NULL
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_enum.test b/mysql-test/suite/storage_engine/type_enum.test
new file mode 100644
index 00000000..3476e8a0
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_enum.test
@@ -0,0 +1,10 @@
+#
+# ENUM column type
+#
+
+--source have_engine.inc
+
+--source type_enum.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_enum_indexes.result b/mysql-test/suite/storage_engine/type_enum_indexes.result
new file mode 100644
index 00000000..f8af1aed
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_enum_indexes.result
@@ -0,0 +1,108 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a ENUM('N.America','S.America','Africa','Europe','Australia','Asia','Antarctica') <CUSTOM_COL_OPTIONS>,
+b ENUM('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS>,
+c ENUM('1a','1b','1d','1j','4a','4z','5a','5b','6v','6z') <CUSTOM_COL_OPTIONS>,
+<CUSTOM_INDEX> a (a)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b,c) VALUES
+('N.America','test1','5a'),('Europe','test1','5b'),('Europe','test2','6v'),
+('Africa','test3','4z'),('Africa','test4','1j'),('Antarctica','test4','1d');
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 # 1 a # # NULL NULL # #
+SELECT a FROM t1 WHERE b > 'test2' ORDER BY a;
+a
+Africa
+Africa
+Antarctica
+DROP TABLE t1;
+CREATE TABLE t1 (a ENUM('N.America','S.America','Africa','Europe','Australia','Asia','Antarctica') <CUSTOM_COL_OPTIONS>,
+b ENUM('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS>,
+c ENUM('1a','1b','1d','1j','4a','4z','5a','5b','6v','6z') <CUSTOM_COL_OPTIONS>,
+UNIQUE KEY a_b (a,b)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b,c) VALUES
+('N.America','test1','5a'),('Europe','test1','5b'),('Europe','test2','6v'),
+('Africa','test3','4z'),('Africa','test4','1j'),('Antarctica','test4','1d');
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 a_b 1 a # # NULL NULL # #
+t1 0 a_b 2 b # # NULL NULL # #
+EXPLAIN SELECT a FROM t1 WHERE b > 'test2' ORDER BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # a_b # # # #
+SELECT a FROM t1 WHERE b > 'test2' ORDER BY a;
+a
+Africa
+Africa
+Antarctica
+EXPLAIN SELECT a FROM t1 FORCE INDEX (a_b) WHERE b > 'test2' ORDER BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # a_b # # # #
+SELECT a FROM t1 FORCE INDEX (a_b) WHERE b > 'test2' ORDER BY a;
+a
+Africa
+Africa
+Antarctica
+DROP TABLE t1;
+CREATE TABLE t1 (a ENUM('N.America','S.America','Africa','Europe','Australia','Asia','Antarctica') <CUSTOM_COL_OPTIONS>,
+b ENUM('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS>,
+c ENUM('1a','1b','1d','1j','4a','4z','5a','5b','6v','6z') <CUSTOM_COL_OPTIONS> PRIMARY KEY
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b,c) VALUES
+('N.America','test1','5a'),('Europe','test1','5b'),('Europe','test2','6v'),
+('Africa','test3','4z'),('Africa','test4','1j'),('Antarctica','test4','1d');
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 PRIMARY 1 c # # NULL NULL # #
+EXPLAIN SELECT c FROM t1 WHERE c BETWEEN '1d' AND '6u';
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # PRIMARY # # # #
+SELECT c FROM t1 WHERE c BETWEEN '1d' AND '6u';
+c
+1d
+1j
+4z
+5a
+5b
+EXPLAIN SELECT c FROM t1 USE INDEX () WHERE c BETWEEN '1d' AND '6u';
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # NULL # # # #
+SELECT c FROM t1 USE INDEX () WHERE c BETWEEN '1d' AND '6u';
+c
+1d
+1j
+4z
+5a
+5b
+DROP TABLE t1;
+CREATE TABLE t1 (a ENUM('N.America','S.America','Africa','Europe','Australia','Asia','Antarctica') <CUSTOM_COL_OPTIONS>,
+b ENUM('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS>,
+c ENUM('1a','1b','1d','1j','4a','4z','5a','5b','6v','6z') <CUSTOM_COL_OPTIONS>,
+INDEX(b)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b,c) VALUES
+('N.America','test1','5a'),('Europe','test1','5b'),('Europe','test2','6v'),
+('Africa','test3','4z'),('Africa','test4','1j'),('Antarctica','test4','1d');
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 b 1 b # # NULL NULL # #
+EXPLAIN SELECT DISTINCT b FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # b # # # #
+SELECT DISTINCT b FROM t1;
+b
+test1
+test2
+test3
+test4
+EXPLAIN SELECT DISTINCT b FROM t1 IGNORE INDEX (b);
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # NULL # # # #
+SELECT DISTINCT b FROM t1 IGNORE INDEX (b);
+b
+test1
+test2
+test3
+test4
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_enum_indexes.test b/mysql-test/suite/storage_engine/type_enum_indexes.test
new file mode 100644
index 00000000..ba20197c
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_enum_indexes.test
@@ -0,0 +1,146 @@
+#
+# ENUM columns with indexes
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Default index as set in define_engine.inc
+
+let $create_definition =
+ a ENUM('N.America','S.America','Africa','Europe','Australia','Asia','Antarctica') $col_indexed_opts,
+ b ENUM('test1','test2','test3','test4','test5') $col_opts,
+ c ENUM('1a','1b','1d','1j','4a','4z','5a','5b','6v','6z') $col_opts,
+ $default_index a (a)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = ENUM types or indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b,c) VALUES
+ ('N.America','test1','5a'),('Europe','test1','5b'),('Europe','test2','6v'),
+ ('Africa','test3','4z'),('Africa','test4','1j'),('Antarctica','test4','1d');
+
+ --replace_column 3 # 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ SELECT a FROM t1 WHERE b > 'test2' ORDER BY a;
+ DROP TABLE t1;
+}
+
+
+# PK, UNIQUE INDEX, INDEX
+
+let $create_definition =
+ a ENUM('N.America','S.America','Africa','Europe','Australia','Asia','Antarctica') $col_indexed_opts,
+ b ENUM('test1','test2','test3','test4','test5') $col_indexed_opts,
+ c ENUM('1a','1b','1d','1j','4a','4z','5a','5b','6v','6z') $col_opts,
+ UNIQUE KEY a_b (a,b)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = ENUM types or unique keys or multi-part keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b,c) VALUES
+ ('N.America','test1','5a'),('Europe','test1','5b'),('Europe','test2','6v'),
+ ('Africa','test3','4z'),('Africa','test4','1j'),('Antarctica','test4','1d');
+
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT a FROM t1 WHERE b > 'test2' ORDER BY a;
+ SELECT a FROM t1 WHERE b > 'test2' ORDER BY a;
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT a FROM t1 FORCE INDEX (a_b) WHERE b > 'test2' ORDER BY a;
+ SELECT a FROM t1 FORCE INDEX (a_b) WHERE b > 'test2' ORDER BY a;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ a ENUM('N.America','S.America','Africa','Europe','Australia','Asia','Antarctica') $col_opts,
+ b ENUM('test1','test2','test3','test4','test5') $col_opts,
+ c ENUM('1a','1b','1d','1j','4a','4z','5a','5b','6v','6z') $col_indexed_opts PRIMARY KEY
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = ENUM types or PK
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b,c) VALUES
+ ('N.America','test1','5a'),('Europe','test1','5b'),('Europe','test2','6v'),
+ ('Africa','test3','4z'),('Africa','test4','1j'),('Antarctica','test4','1d');
+
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT c FROM t1 WHERE c BETWEEN '1d' AND '6u';
+ --sorted_result
+ SELECT c FROM t1 WHERE c BETWEEN '1d' AND '6u';
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT c FROM t1 USE INDEX () WHERE c BETWEEN '1d' AND '6u';
+ --sorted_result
+ SELECT c FROM t1 USE INDEX () WHERE c BETWEEN '1d' AND '6u';
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ a ENUM('N.America','S.America','Africa','Europe','Australia','Asia','Antarctica') $col_opts,
+ b ENUM('test1','test2','test3','test4','test5') $col_indexed_opts,
+ c ENUM('1a','1b','1d','1j','4a','4z','5a','5b','6v','6z') $col_opts,
+ INDEX(b)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = ENUM types or non-unique keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b,c) VALUES
+ ('N.America','test1','5a'),('Europe','test1','5b'),('Europe','test2','6v'),
+ ('Africa','test3','4z'),('Africa','test4','1j'),('Antarctica','test4','1d');
+
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT DISTINCT b FROM t1;
+ --sorted_result
+ SELECT DISTINCT b FROM t1;
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT DISTINCT b FROM t1 IGNORE INDEX (b);
+ --sorted_result
+ SELECT DISTINCT b FROM t1 IGNORE INDEX (b);
+
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_fixed.inc b/mysql-test/suite/storage_engine/type_fixed.inc
new file mode 100644
index 00000000..3b4ade9f
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_fixed.inc
@@ -0,0 +1,89 @@
+#
+# Fixed point types
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $create_definition =
+ d DECIMAL $col_opts,
+ d0 DECIMAL(0) $col_opts,
+ d1_1 DECIMAL(1,1) $col_opts,
+ d10_2 DECIMAL(10,2) $col_opts,
+ d60_10 DECIMAL(60,10) $col_opts,
+ n NUMERIC $col_opts,
+ n0_0 NUMERIC(0,0) $col_opts,
+ n1 NUMERIC(1) $col_opts,
+ n20_4 NUMERIC(20,4) $col_opts,
+ n65_4 NUMERIC(65,4) $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Fixed point types
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+
+ # Always valid values
+
+ INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (100,123456,0.3,40000.25,123456789123456789.10001,1024,7000.0,8.0,999999.9,9223372036854775807);
+ INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (0,0,0,0,0,0,0,0,0,0);
+ INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (9999999999.0,9999999999.0,0.9,99999999.99,99999999999999999999999999999999999999999999999999.9999999999,9999999999.0,9999999999.0,9.0,9999999999999999.9999,9999999999999999999999999999999999999999999999999999999999999.9999);
+
+ --sorted_result
+ SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+
+ # Values which can be valid or not,
+ # depending on whether columns are SIGNED or UNSIGNED
+ # (if not valid should produce warnings)
+
+ INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (-100,-123456,-0.3,-40000.25,-123456789123456789.10001,-1024,-7000.0,-8.0,-999999.9,-9223372036854775807);
+ INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (-9999999999.0,-9999999999.0,-0.9,-99999999.99,-99999999999999999999999999999999999999999999999999.9999999999,-9999999999.0,-9999999999.0,-9.0,-9999999999999999.9999,-9999999999999999999999999999999999999999999999999999999999999.9999);
+
+ --sorted_result
+ SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+
+ --sorted_result
+ SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1 WHERE n20_4 = 9999999999999999.9999 OR d < 100;
+
+ # Invalid values
+
+ INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) SELECT n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4 FROM t1 WHERE n65_4 = ( SELECT MAX(n65_4) FROM t1 );
+
+ --sorted_result
+ SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+
+ INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (10000000000.0,10000000000.0,1.1,100000000.99,100000000000000000000000000000000000000000000000000.0,10000000000.0,10000000000.0,10.0,10000000000000000.9999,10000000000000000000000000000000000000000000000000000000000000.9999);
+ --sorted_result
+ SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+
+ INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (9999999999.1,9999999999.1,1.9,99999999.001,99999999999999999999999999999999999999999999999999.99999999991,9999999999.1,9999999999.1,9.1,9999999999999999.00001,9999999999999999999999999999999999999999999999999999999999999.11111);
+ --sorted_result
+ SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+
+ --let $error_codes = ER_TOO_BIG_PRECISION
+ --let $alter_definition = ADD COLUMN n66 NUMERIC(66)
+ --source alter_table.inc
+ if ($mysql_errname != ER_TOO_BIG_PRECISION)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+ }
+
+ --let $error_codes = ER_TOO_BIG_PRECISION
+ --let $alter_definition = ADD COLUMN n66_6 DECIMAL(66,6)
+ --source alter_table.inc
+ --let $error_codes = ER_TOO_BIG_SCALE
+ --let $alter_definition = ADD COLUMN n66_66 DECIMAL(66,66)
+ --source alter_table.inc
+
+ DROP TABLE t1;
+}
+
diff --git a/mysql-test/suite/storage_engine/type_fixed.result b/mysql-test/suite/storage_engine/type_fixed.result
new file mode 100644
index 00000000..5eea911a
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_fixed.result
@@ -0,0 +1,116 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (d DECIMAL <CUSTOM_COL_OPTIONS>,
+d0 DECIMAL(0) <CUSTOM_COL_OPTIONS>,
+d1_1 DECIMAL(1,1) <CUSTOM_COL_OPTIONS>,
+d10_2 DECIMAL(10,2) <CUSTOM_COL_OPTIONS>,
+d60_10 DECIMAL(60,10) <CUSTOM_COL_OPTIONS>,
+n NUMERIC <CUSTOM_COL_OPTIONS>,
+n0_0 NUMERIC(0,0) <CUSTOM_COL_OPTIONS>,
+n1 NUMERIC(1) <CUSTOM_COL_OPTIONS>,
+n20_4 NUMERIC(20,4) <CUSTOM_COL_OPTIONS>,
+n65_4 NUMERIC(65,4) <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+d decimal(10,0) # # #
+d0 decimal(10,0) # # #
+d1_1 decimal(1,1) # # #
+d10_2 decimal(10,2) # # #
+d60_10 decimal(60,10) # # #
+n decimal(10,0) # # #
+n0_0 decimal(10,0) # # #
+n1 decimal(1,0) # # #
+n20_4 decimal(20,4) # # #
+n65_4 decimal(65,4) # # #
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (100,123456,0.3,40000.25,123456789123456789.10001,1024,7000.0,8.0,999999.9,9223372036854775807);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (9999999999.0,9999999999.0,0.9,99999999.99,99999999999999999999999999999999999999999999999999.9999999999,9999999999.0,9999999999.0,9.0,9999999999999999.9999,9999999999999999999999999999999999999999999999999999999999999.9999);
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (-100,-123456,-0.3,-40000.25,-123456789123456789.10001,-1024,-7000.0,-8.0,-999999.9,-9223372036854775807);
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (-9999999999.0,-9999999999.0,-0.9,-99999999.99,-99999999999999999999999999999999999999999999999999.9999999999,-9999999999.0,-9999999999.0,-9.0,-9999999999999999.9999,-9999999999999999999999999999999999999999999999999999999999999.9999);
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1 WHERE n20_4 = 9999999999999999.9999 OR d < 100;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) SELECT n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4, n65_4 FROM t1 WHERE n65_4 = ( SELECT MAX(n65_4) FROM t1 );
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (10000000000.0,10000000000.0,1.1,100000000.99,100000000000000000000000000000000000000000000000000.0,10000000000.0,10000000000.0,10.0,10000000000000000.9999,10000000000000000000000000000000000000000000000000000000000000.9999);
+Warnings:
+Warning 1264 Out of range value for column 'd' at row 1
+Warning 1264 Out of range value for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Warning 1264 Out of range value for column 'd10_2' at row 1
+Warning 1264 Out of range value for column 'd60_10' at row 1
+Warning 1264 Out of range value for column 'n' at row 1
+Warning 1264 Out of range value for column 'n0_0' at row 1
+Warning 1264 Out of range value for column 'n1' at row 1
+Warning 1264 Out of range value for column 'n20_4' at row 1
+Warning 1264 Out of range value for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+INSERT INTO t1 (d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4) VALUES (9999999999.1,9999999999.1,1.9,99999999.001,99999999999999999999999999999999999999999999999999.99999999991,9999999999.1,9999999999.1,9.1,9999999999999999.00001,9999999999999999999999999999999999999999999999999999999999999.11111);
+Warnings:
+Note 1265 Data truncated for column 'd' at row 1
+Note 1265 Data truncated for column 'd0' at row 1
+Warning 1264 Out of range value for column 'd1_1' at row 1
+Note 1265 Data truncated for column 'd10_2' at row 1
+Note 1265 Data truncated for column 'd60_10' at row 1
+Note 1265 Data truncated for column 'n' at row 1
+Note 1265 Data truncated for column 'n0_0' at row 1
+Note 1265 Data truncated for column 'n1' at row 1
+Note 1265 Data truncated for column 'n20_4' at row 1
+Note 1265 Data truncated for column 'n65_4' at row 1
+SELECT d,d0,d1_1,d10_2,d60_10,n,n0_0,n1,n20_4,n65_4 FROM t1;
+d d0 d1_1 d10_2 d60_10 n n0_0 n1 n20_4 n65_4
+-100 -123456 -0.3 -40000.25 -123456789123456789.1000100000 -1024 -7000 -8 -999999.9000 -9223372036854775807.0000
+-9999999999 -9999999999 -0.9 -99999999.99 -99999999999999999999999999999999999999999999999999.9999999999 -9999999999 -9999999999 -9 -9999999999999999.9999 -9999999999999999999999999999999999999999999999999999999999999.9999
+0 0 0.0 0.00 0.0000000000 0 0 0 0.0000 0.0000
+100 123456 0.3 40000.25 123456789123456789.1000100000 1024 7000 8 999999.9000 9223372036854775807.0000
+9999999999 9999999999 0.9 99999999.00 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.0000 9999999999999999999999999999999999999999999999999999999999999.1111
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+9999999999 9999999999 0.9 99999999.99 99999999999999999999999999999999999999999999999999.9999999999 9999999999 9999999999 9 9999999999999999.9999 9999999999999999999999999999999999999999999999999999999999999.9999
+ALTER TABLE t1 ADD COLUMN n66 NUMERIC(66);
+ERROR 42000: Too big precision 66 specified for 'n66'. Maximum is 65.
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(66,6);
+ERROR 42000: Too big precision 66 specified for 'n66_6'. Maximum is 65.
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(66,66);
+ERROR 42000: Too big scale 66 specified for 'n66_66'. Maximum is 30.
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_fixed.test b/mysql-test/suite/storage_engine/type_fixed.test
new file mode 100644
index 00000000..30b0f44d
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_fixed.test
@@ -0,0 +1,10 @@
+#
+# Fixed point types
+#
+
+--source have_engine.inc
+
+--source type_fixed.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_fixed_indexes.result b/mysql-test/suite/storage_engine/type_fixed_indexes.result
new file mode 100644
index 00000000..b1fe27cf
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_fixed_indexes.result
@@ -0,0 +1,148 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (d1 DECIMAL(10,2) <CUSTOM_COL_OPTIONS>,
+d2 DECIMAL(60,10) <CUSTOM_COL_OPTIONS>,
+n1 NUMERIC <CUSTOM_COL_OPTIONS>,
+n2 NUMERIC(65,4) <CUSTOM_COL_OPTIONS>,
+<CUSTOM_INDEX> d1 (d1)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 # 1 d1 # # NULL NULL # #
+INSERT INTO t1 (d1,d2,n1,n2) VALUES
+(10.22,60.12345,123456,14.3456),
+(10.0,60.12345,123456,14),
+(11.14,15,123456,13),
+(100,100,1,2),
+(0,0,0,0),
+(4540424564.23,3343303441.0,12,13),
+(15,17,23,100000);
+Warnings:
+Warning 1264 Out of range value for column 'd1' at row 6
+SELECT d1 FROM t1 ORDER BY d1 DESC;
+d1
+99999999.99
+100.00
+15.00
+11.14
+10.22
+10.00
+0.00
+DROP TABLE t1;
+CREATE TABLE t1 (d1 DECIMAL(10,2) <CUSTOM_COL_OPTIONS> PRIMARY KEY,
+d2 DECIMAL(60,10) <CUSTOM_COL_OPTIONS>,
+n1 NUMERIC <CUSTOM_COL_OPTIONS>,
+n2 NUMERIC(65,4) <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 PRIMARY 1 d1 # # NULL NULL # #
+INSERT INTO t1 (d1,d2,n1,n2) VALUES
+(10.22,60.12345,123456,14.3456),
+(10.0,60.12345,123456,14),
+(11.14,15,123456,13),
+(100,100,1,2),
+(0,0,0,0),
+(4540424564.23,3343303441.0,12,13),
+(15,17,23,100000);
+Warnings:
+Warning 1264 Out of range value for column 'd1' at row 6
+EXPLAIN SELECT d1 FROM t1 ORDER BY d1 DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # PRIMARY # # # #
+SELECT d1 FROM t1 ORDER BY d1 DESC;
+d1
+99999999.99
+100.00
+15.00
+11.14
+10.22
+10.00
+0.00
+EXPLAIN SELECT d1 FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) ORDER BY d1 DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # PRIMARY # # # #
+SELECT d1 FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) ORDER BY d1 DESC;
+d1
+99999999.99
+100.00
+15.00
+11.14
+10.22
+10.00
+0.00
+DROP TABLE t1;
+CREATE TABLE t1 (d1 DECIMAL(10,2) <CUSTOM_COL_OPTIONS>,
+d2 DECIMAL(60,10) <CUSTOM_COL_OPTIONS>,
+n1 NUMERIC <CUSTOM_COL_OPTIONS>,
+n2 NUMERIC(65,4) <CUSTOM_COL_OPTIONS>,
+UNIQUE INDEX n1_n2 (n1,n2)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 n1_n2 1 n1 # # NULL NULL # #
+t1 0 n1_n2 2 n2 # # NULL NULL # #
+INSERT INTO t1 (d1,d2,n1,n2) VALUES
+(10.22,60.12345,123456,14.3456),
+(10.0,60.12345,123456,14),
+(11.14,15,123456,13),
+(100,100,1,2),
+(0,0,0,0),
+(4540424564.23,3343303441.0,12,13),
+(15,17,23,100000);
+Warnings:
+Warning 1264 Out of range value for column 'd1' at row 6
+EXPLAIN SELECT DISTINCT n1+n2 FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # n1_n2 # # # #
+SELECT DISTINCT n1+n2 FROM t1;
+n1+n2
+0.0000
+100023.0000
+123469.0000
+123470.0000
+123470.3456
+25.0000
+3.0000
+DROP TABLE t1;
+CREATE TABLE t1 (d1 DECIMAL(10,2) <CUSTOM_COL_OPTIONS>,
+d2 DECIMAL(60,10) <CUSTOM_COL_OPTIONS>,
+n1 NUMERIC <CUSTOM_COL_OPTIONS>,
+n2 NUMERIC(65,4) <CUSTOM_COL_OPTIONS>,
+INDEX (d2)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 d2 1 d2 # # NULL NULL # #
+INSERT INTO t1 (d1,d2,n1,n2) VALUES
+(10.22,60.12345,123456,14.3456),
+(10.0,60.12345,123456,14),
+(11.14,15,123456,13),
+(100,100,1,2),
+(0,0,0,0),
+(4540424564.23,3343303441.0,12,13),
+(15,17,23,100000);
+Warnings:
+Warning 1264 Out of range value for column 'd1' at row 6
+EXPLAIN SELECT d2, COUNT(*) FROM t1 GROUP BY d2;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # d2 # # # #
+SELECT d2, COUNT(*) FROM t1 GROUP BY d2;
+d2 COUNT(*)
+0.0000000000 1
+100.0000000000 1
+15.0000000000 1
+17.0000000000 1
+3343303441.0000000000 1
+60.1234500000 2
+EXPLAIN SELECT d2, COUNT(*) FROM t1 IGNORE INDEX FOR GROUP BY (d2) GROUP BY d2;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # d2 # # # #
+SELECT d2, COUNT(*) FROM t1 IGNORE INDEX FOR GROUP BY (d2) GROUP BY d2;
+d2 COUNT(*)
+0.0000000000 1
+100.0000000000 1
+15.0000000000 1
+17.0000000000 1
+3343303441.0000000000 1
+60.1234500000 2
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_fixed_indexes.test b/mysql-test/suite/storage_engine/type_fixed_indexes.test
new file mode 100644
index 00000000..0d3e825c
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_fixed_indexes.test
@@ -0,0 +1,167 @@
+#
+# Fixed point columns with indexes
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+
+# Default index as set in define_engine.inc
+
+let $create_definition =
+ d1 DECIMAL(10,2) $col_indexed_opts,
+ d2 DECIMAL(60,10) $col_opts,
+ n1 NUMERIC $col_opts,
+ n2 NUMERIC(65,4) $col_opts,
+ $default_index d1 (d1)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Fixed point types or indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (d1,d2,n1,n2) VALUES
+ (10.22,60.12345,123456,14.3456),
+ (10.0,60.12345,123456,14),
+ (11.14,15,123456,13),
+ (100,100,1,2),
+ (0,0,0,0),
+ (4540424564.23,3343303441.0,12,13),
+ (15,17,23,100000);
+
+ SELECT d1 FROM t1 ORDER BY d1 DESC;
+
+ DROP TABLE t1;
+}
+
+
+# PK, UNIQUE INDEX, INDEX
+
+let $create_definition =
+ d1 DECIMAL(10,2) $col_indexed_opts PRIMARY KEY,
+ d2 DECIMAL(60,10) $col_opts,
+ n1 NUMERIC $col_opts,
+ n2 NUMERIC(65,4) $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Fixed point types or PK
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (d1,d2,n1,n2) VALUES
+ (10.22,60.12345,123456,14.3456),
+ (10.0,60.12345,123456,14),
+ (11.14,15,123456,13),
+ (100,100,1,2),
+ (0,0,0,0),
+ (4540424564.23,3343303441.0,12,13),
+ (15,17,23,100000);
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT d1 FROM t1 ORDER BY d1 DESC;
+ SELECT d1 FROM t1 ORDER BY d1 DESC;
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT d1 FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) ORDER BY d1 DESC;
+ SELECT d1 FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) ORDER BY d1 DESC;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ d1 DECIMAL(10,2) $col_opts,
+ d2 DECIMAL(60,10) $col_opts,
+ n1 NUMERIC $col_indexed_opts,
+ n2 NUMERIC(65,4) $col_indexed_opts,
+ UNIQUE INDEX n1_n2 (n1,n2)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Fixed point types or unique keys or multi-part keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (d1,d2,n1,n2) VALUES
+ (10.22,60.12345,123456,14.3456),
+ (10.0,60.12345,123456,14),
+ (11.14,15,123456,13),
+ (100,100,1,2),
+ (0,0,0,0),
+ (4540424564.23,3343303441.0,12,13),
+ (15,17,23,100000);
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT DISTINCT n1+n2 FROM t1;
+ --sorted_result
+ SELECT DISTINCT n1+n2 FROM t1;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ d1 DECIMAL(10,2) $col_opts,
+ d2 DECIMAL(60,10) $col_indexed_opts,
+ n1 NUMERIC $col_opts,
+ n2 NUMERIC(65,4) $col_opts,
+ INDEX (d2)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Fixed point types or non-unique keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (d1,d2,n1,n2) VALUES
+ (10.22,60.12345,123456,14.3456),
+ (10.0,60.12345,123456,14),
+ (11.14,15,123456,13),
+ (100,100,1,2),
+ (0,0,0,0),
+ (4540424564.23,3343303441.0,12,13),
+ (15,17,23,100000);
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT d2, COUNT(*) FROM t1 GROUP BY d2;
+ --sorted_result
+ SELECT d2, COUNT(*) FROM t1 GROUP BY d2;
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT d2, COUNT(*) FROM t1 IGNORE INDEX FOR GROUP BY (d2) GROUP BY d2;
+ --sorted_result
+ SELECT d2, COUNT(*) FROM t1 IGNORE INDEX FOR GROUP BY (d2) GROUP BY d2;
+
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_float.inc b/mysql-test/suite/storage_engine/type_float.inc
new file mode 100644
index 00000000..1b8f0102
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_float.inc
@@ -0,0 +1,111 @@
+#
+# Float types
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $create_definition =
+ f FLOAT $col_opts,
+ f0 FLOAT(0) $col_opts,
+ r1_1 REAL(1,1) $col_opts,
+ f23_0 FLOAT(23) $col_opts,
+ f20_3 FLOAT(20,3) $col_opts,
+ d DOUBLE $col_opts,
+ d1_0 DOUBLE(1,0) $col_opts,
+ d10_10 DOUBLE PRECISION (10,10) $col_opts,
+ d53 DOUBLE(53,0) $col_opts,
+ d53_10 DOUBLE(53,10) $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Float point types
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+
+ # Always valid values
+
+ INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (12345.12345,12345.12345,0.9,123456789.123,56789.987,11111111.111,8.0,0.0123456789,1234566789123456789,99999999999999999.99999999);
+
+ --sorted_result
+ --query_vertical SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1
+
+ INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (0,0,0,0,0,0,0,0,0,0);
+ INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (
+ 99999999999999999999999999999999999999,
+ 99999999999999999999999999999999999999.9999999999999999,
+ 0.9,
+ 99999999999999999999999999999999999999.9,
+ 99999999999999999.999,
+ 999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+ 9,
+ 0.9999999999,
+ 1999999999999999999999999999999999999999999999999999999,
+ 19999999999999999999999999999999999999999999.9999999999
+ );
+
+ --sorted_result
+ --query_vertical SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1
+
+ # Values which can be valid or not,
+ # depending on whether columns are SIGNED or UNSIGNED
+ # (if not valid should produce warnings)
+
+ INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (-999999999999999999999999,-99999999999.999999999999,-0.9,-999.99999999999999999999,-99999999999999999.999,-999999999999999999999999999999999999999999999999999999999999-0.999,-9,-.9999999999,-999999999999999999999999999999.99999999999999999999999,-9999999999999999999999999999999999999999999.9999999999);
+
+ --sorted_result
+ --query_vertical SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1
+
+ --sorted_result
+ --query_vertical SELECT MAX(f), MAX(f0), MAX(r1_1), MAX(f23_0), MAX(f20_3), MAX(d), MAX(d1_0), MAX(d10_10), MAX(d53), MAX(d53_10) FROM t1
+
+ # Invalid values
+
+ INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) SELECT d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10 FROM t1 ORDER BY d53_10 DESC LIMIT 1;
+
+ --sorted_result
+ --query_vertical SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1
+
+ INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (
+ 999999999999999999999999999999999999999,
+ 999999999999999999999999999999999999999.9999999999999999,
+ 1.9,
+ 999999999999999999999999999999999999999.9,
+ 999999999999999999.999,
+ 9999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+ 99,
+ 1.9999999999,
+ 1999999999999999999999999999999999999999999999999999999,
+ 19999999999999999999999999999999999999999999.9999999999
+ );
+
+ --sorted_result
+ --query_vertical SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1
+
+ --let $error_codes = ER_TOO_BIG_DISPLAYWIDTH
+ --let $alter_definition = ADD COLUMN d0_0 DOUBLE(0,0)
+ --source alter_table.inc
+ if ($mysql_errname != ER_TOO_BIG_DISPLAYWIDTH)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+ }
+
+ --let $error_codes = ER_TOO_BIG_PRECISION
+ --let $alter_definition = ADD COLUMN n66_6 DECIMAL(256,1)
+ --source alter_table.inc
+ --let $error_codes = ER_TOO_BIG_SCALE
+ --let $alter_definition = ADD COLUMN n66_66 DECIMAL(40,35)
+ --source alter_table.inc
+
+ DROP TABLE t1;
+}
+
diff --git a/mysql-test/suite/storage_engine/type_float.result b/mysql-test/suite/storage_engine/type_float.result
new file mode 100644
index 00000000..86509896
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_float.result
@@ -0,0 +1,294 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (f FLOAT <CUSTOM_COL_OPTIONS>,
+f0 FLOAT(0) <CUSTOM_COL_OPTIONS>,
+r1_1 REAL(1,1) <CUSTOM_COL_OPTIONS>,
+f23_0 FLOAT(23) <CUSTOM_COL_OPTIONS>,
+f20_3 FLOAT(20,3) <CUSTOM_COL_OPTIONS>,
+d DOUBLE <CUSTOM_COL_OPTIONS>,
+d1_0 DOUBLE(1,0) <CUSTOM_COL_OPTIONS>,
+d10_10 DOUBLE PRECISION (10,10) <CUSTOM_COL_OPTIONS>,
+d53 DOUBLE(53,0) <CUSTOM_COL_OPTIONS>,
+d53_10 DOUBLE(53,10) <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+f float # # #
+f0 float # # #
+r1_1 double(1,1) # # #
+f23_0 float # # #
+f20_3 float(20,3) # # #
+d double # # #
+d1_0 double(1,0) # # #
+d10_10 double(10,10) # # #
+d53 double(53,0) # # #
+d53_10 double(53,10) # # #
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (12345.12345,12345.12345,0.9,123456789.123,56789.987,11111111.111,8.0,0.0123456789,1234566789123456789,99999999999999999.99999999);
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 11111111.111
+d10_10 0.0123456789
+d1_0 8
+d53 1234566789123456800
+d53_10 100000000000000000.0000000000
+f0 12345.1
+f20_3 56789.988
+f23_0 123457000
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (
+99999999999999999999999999999999999999,
+99999999999999999999999999999999999999.9999999999999999,
+0.9,
+99999999999999999999999999999999999999.9,
+99999999999999999.999,
+999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+9,
+0.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999
+);
+Warnings:
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d 0
+d 11111111.111
+d 1e81
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 0
+d1_0 8
+d1_0 9
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f 0
+f 1e38
+f0 0
+f0 12345.1
+f0 1e38
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (-999999999999999999999999,-99999999999.999999999999,-0.9,-999.99999999999999999999,-99999999999999999.999,-999999999999999999999999999999999999999999999999999999999999-0.999,-9,-.9999999999,-999999999999999999999999999999.99999999999999999999999,-9999999999999999999999999999999999999999999.9999999999);
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+SELECT MAX(f), MAX(f0), MAX(r1_1), MAX(f23_0), MAX(f20_3), MAX(d), MAX(d1_0), MAX(d10_10), MAX(d53), MAX(d53_10) FROM t1;
+MAX(f) 9.999999680285692e37
+MAX(d) 1e81
+MAX(d10_10) 0.9999999999
+MAX(d1_0) 9
+MAX(d53) 100000000000000000000000000000000000000000000000000000
+MAX(d53_10) 10000000000000000000000000000000000000000000.0000000000
+MAX(f0) 9.999999680285692e37
+MAX(f20_3) 99999998430674940.000
+MAX(f23_0) 9.999999680285692e37
+MAX(r1_1) 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) SELECT d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10, d53_10 FROM t1 ORDER BY d53_10 DESC LIMIT 1;
+Warnings:
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e43
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 10000000000000000000000000000000000000000000.0000000000
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 10000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f 3.40282e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f0 3.40282e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+f23_0 3.40282e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10) VALUES (
+999999999999999999999999999999999999999,
+999999999999999999999999999999999999999.9999999999999999,
+1.9,
+999999999999999999999999999999999999999.9,
+999999999999999999.999,
+9999999999999999999999999999999999999999999999999999999999999999999999999999999999,
+99,
+1.9999999999,
+1999999999999999999999999999999999999999999999999999999,
+19999999999999999999999999999999999999999999.9999999999
+);
+Warnings:
+Warning 1916 Got overflow when converting '' to DECIMAL. Value truncated
+Warning 1264 Out of range value for column 'f' at row 1
+Warning 1264 Out of range value for column 'f0' at row 1
+Warning 1264 Out of range value for column 'r1_1' at row 1
+Warning 1264 Out of range value for column 'f23_0' at row 1
+Warning 1264 Out of range value for column 'f20_3' at row 1
+Warning 1264 Out of range value for column 'd1_0' at row 1
+Warning 1264 Out of range value for column 'd10_10' at row 1
+Warning 1264 Out of range value for column 'd53' at row 1
+Warning 1264 Out of range value for column 'd53_10' at row 1
+SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1;
+f 12345.1
+d -1e60
+d 0
+d 11111111.111
+d 1e43
+d 1e65
+d 1e81
+d10_10 -0.9999999999
+d10_10 0.0000000000
+d10_10 0.0123456789
+d10_10 0.9999999999
+d10_10 0.9999999999
+d10_10 10000000000000000000000000000000000000000000.0000000000
+d1_0 -9
+d1_0 0
+d1_0 8
+d1_0 9
+d1_0 9
+d1_0 9
+d53 -1000000000000000000000000000000
+d53 0
+d53 10000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 100000000000000000000000000000000000000000000000000000
+d53 1234566789123456800
+d53_10 -10000000000000000000000000000000000000000000.0000000000
+d53_10 0.0000000000
+d53_10 100000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+d53_10 10000000000000000000000000000000000000000000.0000000000
+f -1e24
+f 0
+f 1e38
+f 3.40282e38
+f 3.40282e38
+f0 -100000000000
+f0 0
+f0 12345.1
+f0 1e38
+f0 3.40282e38
+f0 3.40282e38
+f20_3 -99999998430674940.000
+f20_3 0.000
+f20_3 56789.988
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f20_3 99999998430674940.000
+f23_0 -1000
+f23_0 0
+f23_0 123457000
+f23_0 1e38
+f23_0 3.40282e38
+f23_0 3.40282e38
+r1_1 -0.9
+r1_1 0.0
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+r1_1 0.9
+ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0);
+# ERROR: Statement succeeded (expected results: ER_TOO_BIG_DISPLAYWIDTH)
+# ------------ UNEXPECTED RESULT ------------
+# [ ALTER TABLE t1 ADD COLUMN d0_0 DOUBLE(0,0) ]
+# The statement|command succeeded unexpectedly.
+# ALTER TABLE or the mix could be unsupported|malfunctioning, or the problem was caused by previous errors.
+# You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def.
+# Further in this test, the message might sometimes be suppressed; a part of the test might be skipped.
+# Also, this problem may cause a chain effect (more errors of different kinds in the test).
+# -------------------------------------------
+ALTER TABLE t1 ADD COLUMN n66_6 DECIMAL(256,1);
+ERROR 42000: Too big precision 256 specified for 'n66_6'. Maximum is 65.
+ALTER TABLE t1 ADD COLUMN n66_66 DECIMAL(40,35);
+ERROR 42000: Too big scale 35 specified for 'n66_66'. Maximum is 30.
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_float.test b/mysql-test/suite/storage_engine/type_float.test
new file mode 100644
index 00000000..eb197542
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_float.test
@@ -0,0 +1,10 @@
+#
+# Float types
+#
+
+--source have_engine.inc
+
+--source type_float.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_float_indexes.result b/mysql-test/suite/storage_engine/type_float_indexes.result
new file mode 100644
index 00000000..905c9da4
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_float_indexes.result
@@ -0,0 +1,146 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (f FLOAT <CUSTOM_COL_OPTIONS>,
+r REAL(20,3) <CUSTOM_COL_OPTIONS>,
+d DOUBLE <CUSTOM_COL_OPTIONS>,
+dp DOUBLE PRECISION (64,10) <CUSTOM_COL_OPTIONS>,
+<CUSTOM_INDEX> f (f)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 # 1 f # # NULL NULL # #
+INSERT INTO t1 (f,r,d,dp) VALUES
+(1.2345,1422.22,1.2345,1234567.89),
+(0,0,0,0),
+(-1,-1,-1,-1),
+(17.5843,4953453454.44,29229114.0,1111111.23),
+(4644,1422.22,466664.999,0.5);
+SELECT f FROM t1 ORDER BY f;
+f
+-1
+0
+1.2345
+17.5843
+4644
+DROP TABLE t1;
+CREATE TABLE t1 (f FLOAT <CUSTOM_COL_OPTIONS> PRIMARY KEY,
+r REAL(20,3) <CUSTOM_COL_OPTIONS>,
+d DOUBLE <CUSTOM_COL_OPTIONS>,
+dp DOUBLE PRECISION (64,10) <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 PRIMARY 1 f # # NULL NULL # #
+INSERT INTO t1 (f,r,d,dp) VALUES
+(1.2345,1422.22,1.2345,1234567.89),
+(0,0,0,0),
+(-1,-1,-1,-1),
+(17.5843,4953453454.44,29229114.0,1111111.23),
+(4644,1422.22,466664.999,0.5);
+EXPLAIN SELECT f FROM t1 ORDER BY f;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # PRIMARY # # # #
+SELECT f FROM t1 ORDER BY f;
+f
+-1
+0
+1.2345
+17.5843
+4644
+EXPLAIN SELECT f FROM t1 IGNORE INDEX (PRIMARY) ORDER BY f;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # NULL # # # #
+SELECT f FROM t1 IGNORE INDEX (PRIMARY) ORDER BY f;
+f
+-1
+0
+1.2345
+17.5843
+4644
+ALTER TABLE t1 DROP PRIMARY KEY;
+ALTER TABLE t1 ADD UNIQUE KEY(d);
+EXPLAIN SELECT d FROM t1 WHERE r > 0 and d > 0 ORDER BY d;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # d # # # #
+SELECT d FROM t1 WHERE r > 0 and d > 0 ORDER BY d;
+d
+1.2345
+466664.999
+29229114
+DROP TABLE t1;
+CREATE TABLE t1 (f FLOAT <CUSTOM_COL_OPTIONS>,
+r REAL(20,3) <CUSTOM_COL_OPTIONS>,
+d DOUBLE <CUSTOM_COL_OPTIONS>,
+dp DOUBLE PRECISION (64,10) <CUSTOM_COL_OPTIONS>,
+UNIQUE KEY r_dp (r,dp)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 r_dp 1 r # # NULL NULL # #
+t1 0 r_dp 2 dp # # NULL NULL # #
+INSERT INTO t1 (f,r,d,dp) VALUES
+(1.2345,1422.22,1.2345,1234567.89),
+(0,0,0,0),
+(-1,-1,-1,-1),
+(17.5843,4953453454.44,29229114.0,1111111.23),
+(4644,1422.22,466664.999,0.5);
+EXPLAIN SELECT r, dp FROM t1 WHERE r > 0 or dp > 0;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # r_dp # # # #
+SELECT r, dp FROM t1 WHERE r > 0 or dp > 0;
+r dp
+1422.220 0.5000000000
+1422.220 1234567.8900000000
+4953453454.440 1111111.2300000000
+DROP TABLE t1;
+CREATE TABLE t1 (f FLOAT <CUSTOM_COL_OPTIONS>,
+r REAL(20,3) <CUSTOM_COL_OPTIONS>,
+d DOUBLE <CUSTOM_COL_OPTIONS>,
+dp DOUBLE PRECISION (64,10) <CUSTOM_COL_OPTIONS>,
+UNIQUE KEY(d)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 d 1 d # # NULL NULL # #
+INSERT INTO t1 (f,r,d,dp) VALUES
+(1.2345,1422.22,1.2345,1234567.89),
+(0,0,0,0),
+(-1,-1,-1,-1),
+(17.5843,4953453454.44,29229114.0,1111111.23),
+(4644,1422.22,466664.999,0.5);
+EXPLAIN SELECT DISTINCT d FROM t1 ORDER BY d;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # d # # # #
+SELECT DISTINCT d FROM t1 ORDER BY d;
+d
+-1
+0
+1.2345
+466664.999
+29229114
+DROP TABLE t1;
+CREATE TABLE t1 (f FLOAT <CUSTOM_COL_OPTIONS>,
+r REAL(20,3) <CUSTOM_COL_OPTIONS>,
+d DOUBLE <CUSTOM_COL_OPTIONS>,
+dp DOUBLE PRECISION (64,10) <CUSTOM_COL_OPTIONS>,
+KEY(d)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 d 1 d # # NULL NULL # #
+INSERT INTO t1 (f,r,d,dp) VALUES
+(1.2345,1422.22,1.2345,1234567.89),
+(0,0,0,0),
+(-1,-1,-1,-1),
+(17.5843,4953453454.44,29229114.0,1111111.23),
+(4644,1422.22,466664.999,0.5);
+EXPLAIN SELECT DISTINCT d FROM t1 ORDER BY d;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # d # # # #
+SELECT DISTINCT d FROM t1 ORDER BY d;
+d
+-1
+0
+1.2345
+466664.999
+29229114
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_float_indexes.test b/mysql-test/suite/storage_engine/type_float_indexes.test
new file mode 100644
index 00000000..0f1afc60
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_float_indexes.test
@@ -0,0 +1,203 @@
+#
+# Float type columns with indexes
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Default index as set in define_engine.inc
+
+let $create_definition =
+ f FLOAT $col_indexed_opts,
+ r REAL(20,3) $col_opts,
+ d DOUBLE $col_opts,
+ dp DOUBLE PRECISION (64,10) $col_opts,
+ $default_index f (f)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Float point types or PK
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (f,r,d,dp) VALUES
+ (1.2345,1422.22,1.2345,1234567.89),
+ (0,0,0,0),
+ (-1,-1,-1,-1),
+ (17.5843,4953453454.44,29229114.0,1111111.23),
+ (4644,1422.22,466664.999,0.5);
+
+ SELECT f FROM t1 ORDER BY f;
+
+ DROP TABLE t1;
+}
+
+
+# PK, UNIQUE INDEX, INDEX
+
+let $create_definition =
+ f FLOAT $col_indexed_opts PRIMARY KEY,
+ r REAL(20,3) $col_opts,
+ d DOUBLE $col_opts,
+ dp DOUBLE PRECISION (64,10) $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Float point types or PK
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (f,r,d,dp) VALUES
+ (1.2345,1422.22,1.2345,1234567.89),
+ (0,0,0,0),
+ (-1,-1,-1,-1),
+ (17.5843,4953453454.44,29229114.0,1111111.23),
+ (4644,1422.22,466664.999,0.5);
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT f FROM t1 ORDER BY f;
+ SELECT f FROM t1 ORDER BY f;
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT f FROM t1 IGNORE INDEX (PRIMARY) ORDER BY f;
+ SELECT f FROM t1 IGNORE INDEX (PRIMARY) ORDER BY f;
+
+
+ --let $alter_definition = DROP PRIMARY KEY
+ --source alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $alter_statement
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --let $alter_definition = ADD UNIQUE KEY(d)
+ --source alter_table.inc
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT d FROM t1 WHERE r > 0 and d > 0 ORDER BY d;
+ SELECT d FROM t1 WHERE r > 0 and d > 0 ORDER BY d;
+ }
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ f FLOAT $col_opts,
+ r REAL(20,3) $col_indexed_opts,
+ d DOUBLE $col_opts,
+ dp DOUBLE PRECISION (64,10) $col_indexed_opts,
+ UNIQUE KEY r_dp (r,dp)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Float point types or unique keys or multi-part keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (f,r,d,dp) VALUES
+ (1.2345,1422.22,1.2345,1234567.89),
+ (0,0,0,0),
+ (-1,-1,-1,-1),
+ (17.5843,4953453454.44,29229114.0,1111111.23),
+ (4644,1422.22,466664.999,0.5);
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT r, dp FROM t1 WHERE r > 0 or dp > 0;
+ --sorted_result
+ SELECT r, dp FROM t1 WHERE r > 0 or dp > 0;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ f FLOAT $col_opts,
+ r REAL(20,3) $col_opts,
+ d DOUBLE $col_indexed_opts,
+ dp DOUBLE PRECISION (64,10) $col_opts,
+ UNIQUE KEY(d)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Float point types or unique keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (f,r,d,dp) VALUES
+ (1.2345,1422.22,1.2345,1234567.89),
+ (0,0,0,0),
+ (-1,-1,-1,-1),
+ (17.5843,4953453454.44,29229114.0,1111111.23),
+ (4644,1422.22,466664.999,0.5);
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT DISTINCT d FROM t1 ORDER BY d;
+ SELECT DISTINCT d FROM t1 ORDER BY d;
+
+ DROP TABLE t1;
+}
+
+
+let $create_definition =
+ f FLOAT $col_opts,
+ r REAL(20,3) $col_opts,
+ d DOUBLE $col_indexed_opts,
+ dp DOUBLE PRECISION (64,10) $col_opts,
+ KEY(d)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Float point types or non-unique keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (f,r,d,dp) VALUES
+ (1.2345,1422.22,1.2345,1234567.89),
+ (0,0,0,0),
+ (-1,-1,-1,-1),
+ (17.5843,4953453454.44,29229114.0,1111111.23),
+ (4644,1422.22,466664.999,0.5);
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT DISTINCT d FROM t1 ORDER BY d;
+ SELECT DISTINCT d FROM t1 ORDER BY d;
+
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_int.inc b/mysql-test/suite/storage_engine/type_int.inc
new file mode 100644
index 00000000..058b18a2
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_int.inc
@@ -0,0 +1,84 @@
+#
+# INT column types
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $create_definition =
+ i INT $col_opts,
+ i0 INT(0) $col_opts,
+ i1 INT(1) $col_opts,
+ i20 INT(20) $col_opts,
+ t TINYINT $col_opts,
+ t0 TINYINT(0) $col_opts,
+ t1 TINYINT(1) $col_opts,
+ t20 TINYINT(20) $col_opts,
+ s SMALLINT $col_opts,
+ s0 SMALLINT(0) $col_opts,
+ s1 SMALLINT(1) $col_opts,
+ s20 SMALLINT(20) $col_opts,
+ m MEDIUMINT $col_opts,
+ m0 MEDIUMINT(0) $col_opts,
+ m1 MEDIUMINT(1) $col_opts,
+ m20 MEDIUMINT(20) $col_opts,
+ b BIGINT $col_opts,
+ b0 BIGINT(0) $col_opts,
+ b1 BIGINT(1) $col_opts,
+ b20 BIGINT(20) $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = INT types
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+
+ # Always valid values
+
+ INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
+ INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+ INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (2147483647,2147483647,2147483647,2147483647,127,127,127,127,32767,32767,32767,32767,8388607,8388607,8388607,8388607,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807);
+ --sorted_result
+ SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+
+ # Values which can be valid or not,
+ # depending on whether columns are SIGNED or UNSIGNED
+ # (if not valid should produce warnings)
+
+ INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483648,-2147483648,-2147483648,-2147483648,-128,-128,-128,-128,-32768,-32768,-32768,-32768,-8388608,-8388608,-8388608,-8388608,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808);
+ INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967295,4294967295,4294967295,4294967295,255,255,255,255,65535,65535,65535,65535,16777215,16777215,16777215,16777215,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615);
+
+ --sorted_result
+ SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+
+ # Invalid values
+
+ INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483649,-2147483649,-2147483649,-2147483649,-129,-129,-129,-129,-32769,-32769,-32769,-32769,-8388609,-8388609,-8388609,-8388609,-9223372036854775809,-9223372036854775809,-9223372036854775809,-9223372036854775809);
+
+ INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967296,4294967296,4294967296,4294967296,256,256,256,256,65536,65536,65536,65536,16777216,16777216,16777216,16777216,18446744073709551616,18446744073709551616,18446744073709551616,18446744073709551616);
+
+ INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) SELECT b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b FROM t1 WHERE b IN (-9223372036854775808,9223372036854775807,18446744073709551615);
+
+ --sorted_result
+ SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+
+ --let $error_codes = ER_TOO_BIG_DISPLAYWIDTH
+ --let $alter_definition = ADD COLUMN i257 INT(257)
+ --source alter_table.inc
+ if ($mysql_errname != ER_TOO_BIG_DISPLAYWIDTH)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+ }
+
+ DROP TABLE t1;
+}
+
diff --git a/mysql-test/suite/storage_engine/type_int.result b/mysql-test/suite/storage_engine/type_int.result
new file mode 100644
index 00000000..8f462648
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_int.result
@@ -0,0 +1,209 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (i INT <CUSTOM_COL_OPTIONS>,
+i0 INT(0) <CUSTOM_COL_OPTIONS>,
+i1 INT(1) <CUSTOM_COL_OPTIONS>,
+i20 INT(20) <CUSTOM_COL_OPTIONS>,
+t TINYINT <CUSTOM_COL_OPTIONS>,
+t0 TINYINT(0) <CUSTOM_COL_OPTIONS>,
+t1 TINYINT(1) <CUSTOM_COL_OPTIONS>,
+t20 TINYINT(20) <CUSTOM_COL_OPTIONS>,
+s SMALLINT <CUSTOM_COL_OPTIONS>,
+s0 SMALLINT(0) <CUSTOM_COL_OPTIONS>,
+s1 SMALLINT(1) <CUSTOM_COL_OPTIONS>,
+s20 SMALLINT(20) <CUSTOM_COL_OPTIONS>,
+m MEDIUMINT <CUSTOM_COL_OPTIONS>,
+m0 MEDIUMINT(0) <CUSTOM_COL_OPTIONS>,
+m1 MEDIUMINT(1) <CUSTOM_COL_OPTIONS>,
+m20 MEDIUMINT(20) <CUSTOM_COL_OPTIONS>,
+b BIGINT <CUSTOM_COL_OPTIONS>,
+b0 BIGINT(0) <CUSTOM_COL_OPTIONS>,
+b1 BIGINT(1) <CUSTOM_COL_OPTIONS>,
+b20 BIGINT(20) <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+i int(11) # # #
+i0 int(11) # # #
+i1 int(1) # # #
+i20 int(20) # # #
+t tinyint(4) # # #
+t0 tinyint(4) # # #
+t1 tinyint(1) # # #
+t20 tinyint(20) # # #
+s smallint(6) # # #
+s0 smallint(6) # # #
+s1 smallint(1) # # #
+s20 smallint(20) # # #
+m mediumint(9) # # #
+m0 mediumint(9) # # #
+m1 mediumint(1) # # #
+m20 mediumint(20) # # #
+b bigint(20) # # #
+b0 bigint(20) # # #
+b1 bigint(1) # # #
+b20 bigint(20) # # #
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (2147483647,2147483647,2147483647,2147483647,127,127,127,127,32767,32767,32767,32767,8388607,8388607,8388607,8388607,9223372036854775807,9223372036854775807,9223372036854775807,9223372036854775807);
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483648,-2147483648,-2147483648,-2147483648,-128,-128,-128,-128,-32768,-32768,-32768,-32768,-8388608,-8388608,-8388608,-8388608,-9223372036854775808,-9223372036854775808,-9223372036854775808,-9223372036854775808);
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967295,4294967295,4294967295,4294967295,255,255,255,255,65535,65535,65535,65535,16777215,16777215,16777215,16777215,18446744073709551615,18446744073709551615,18446744073709551615,18446744073709551615);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (-2147483649,-2147483649,-2147483649,-2147483649,-129,-129,-129,-129,-32769,-32769,-32769,-32769,-8388609,-8388609,-8388609,-8388609,-9223372036854775809,-9223372036854775809,-9223372036854775809,-9223372036854775809);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) VALUES (4294967296,4294967296,4294967296,4294967296,256,256,256,256,65536,65536,65536,65536,16777216,16777216,16777216,16777216,18446744073709551616,18446744073709551616,18446744073709551616,18446744073709551616);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'b' at row 1
+Warning 1264 Out of range value for column 'b0' at row 1
+Warning 1264 Out of range value for column 'b1' at row 1
+Warning 1264 Out of range value for column 'b20' at row 1
+INSERT INTO t1 (i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20) SELECT b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b FROM t1 WHERE b IN (-9223372036854775808,9223372036854775807,18446744073709551615);
+Warnings:
+Warning 1264 Out of range value for column 'i' at row 1
+Warning 1264 Out of range value for column 'i0' at row 1
+Warning 1264 Out of range value for column 'i1' at row 1
+Warning 1264 Out of range value for column 'i20' at row 1
+Warning 1264 Out of range value for column 't' at row 1
+Warning 1264 Out of range value for column 't0' at row 1
+Warning 1264 Out of range value for column 't1' at row 1
+Warning 1264 Out of range value for column 't20' at row 1
+Warning 1264 Out of range value for column 's' at row 1
+Warning 1264 Out of range value for column 's0' at row 1
+Warning 1264 Out of range value for column 's1' at row 1
+Warning 1264 Out of range value for column 's20' at row 1
+Warning 1264 Out of range value for column 'm' at row 1
+Warning 1264 Out of range value for column 'm0' at row 1
+Warning 1264 Out of range value for column 'm1' at row 1
+Warning 1264 Out of range value for column 'm20' at row 1
+Warning 1264 Out of range value for column 'i' at row 2
+Warning 1264 Out of range value for column 'i0' at row 2
+Warning 1264 Out of range value for column 'i1' at row 2
+Warning 1264 Out of range value for column 'i20' at row 2
+Warning 1264 Out of range value for column 't' at row 2
+Warning 1264 Out of range value for column 't0' at row 2
+Warning 1264 Out of range value for column 't1' at row 2
+Warning 1264 Out of range value for column 't20' at row 2
+Warning 1264 Out of range value for column 's' at row 2
+Warning 1264 Out of range value for column 's0' at row 2
+Warning 1264 Out of range value for column 's1' at row 2
+Warning 1264 Out of range value for column 's20' at row 2
+Warning 1264 Out of range value for column 'm' at row 2
+Warning 1264 Out of range value for column 'm0' at row 2
+Warning 1264 Out of range value for column 'm1' at row 2
+Warning 1264 Out of range value for column 'm20' at row 2
+Warning 1264 Out of range value for column 'i' at row 3
+Warning 1264 Out of range value for column 'i0' at row 3
+Warning 1264 Out of range value for column 'i1' at row 3
+Warning 1264 Out of range value for column 'i20' at row 3
+Warning 1264 Out of range value for column 't' at row 3
+Warning 1264 Out of range value for column 't0' at row 3
+Warning 1264 Out of range value for column 't1' at row 3
+Warning 1264 Out of range value for column 't20' at row 3
+Warning 1264 Out of range value for column 's' at row 3
+Warning 1264 Out of range value for column 's0' at row 3
+Warning 1264 Out of range value for column 's1' at row 3
+Warning 1264 Out of range value for column 's20' at row 3
+Warning 1264 Out of range value for column 'm' at row 3
+Warning 1264 Out of range value for column 'm0' at row 3
+Warning 1264 Out of range value for column 'm1' at row 3
+Warning 1264 Out of range value for column 'm20' at row 3
+Warning 1264 Out of range value for column 'i' at row 4
+Warning 1264 Out of range value for column 'i0' at row 4
+Warning 1264 Out of range value for column 'i1' at row 4
+Warning 1264 Out of range value for column 'i20' at row 4
+Warning 1264 Out of range value for column 't' at row 4
+Warning 1264 Out of range value for column 't0' at row 4
+Warning 1264 Out of range value for column 't1' at row 4
+Warning 1264 Out of range value for column 't20' at row 4
+Warning 1264 Out of range value for column 's' at row 4
+Warning 1264 Out of range value for column 's0' at row 4
+Warning 1264 Out of range value for column 's1' at row 4
+Warning 1264 Out of range value for column 's20' at row 4
+Warning 1264 Out of range value for column 'm' at row 4
+Warning 1264 Out of range value for column 'm0' at row 4
+Warning 1264 Out of range value for column 'm1' at row 4
+Warning 1264 Out of range value for column 'm20' at row 4
+SELECT i,i0,i1,i20,t,t0,t1,t20,s,s0,s1,s20,m,m0,m1,m20,b,b0,b1,b20 FROM t1;
+i i0 i1 i20 t t0 t1 t20 s s0 s1 s20 m m0 m1 m20 b b0 b1 b20
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+-2147483648 -2147483648 -2147483648 -2147483648 -128 -128 -128 -128 -32768 -32768 -32768 -32768 -8388608 -8388608 -8388608 -8388608 -9223372036854775808 -9223372036854775808 -9223372036854775808 -9223372036854775808
+0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
+1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+2147483647 2147483647 2147483647 2147483647 127 127 127 127 32767 32767 32767 32767 8388607 8388607 8388607 8388607 9223372036854775807 9223372036854775807 9223372036854775807 9223372036854775807
+ALTER TABLE t1 ADD COLUMN i257 INT(257);
+ERROR 42000: Display width out of range for 'i257' (max = 255)
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_int.test b/mysql-test/suite/storage_engine/type_int.test
new file mode 100644
index 00000000..1e1ca368
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_int.test
@@ -0,0 +1,10 @@
+#
+# INT column types
+#
+
+--source have_engine.inc
+
+--source type_int.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_int_indexes.result b/mysql-test/suite/storage_engine/type_int_indexes.result
new file mode 100644
index 00000000..aa82d6b9
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_int_indexes.result
@@ -0,0 +1,133 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (i INT <CUSTOM_COL_OPTIONS>,
+t TINYINT <CUSTOM_COL_OPTIONS>,
+s SMALLINT <CUSTOM_COL_OPTIONS>,
+m MEDIUMINT <CUSTOM_COL_OPTIONS>,
+b BIGINT <CUSTOM_COL_OPTIONS>,
+<CUSTOM_INDEX> i (i)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 # 1 i # # NULL NULL # #
+INSERT INTO t1 (i,t,s,m,b) VALUES (1,2,3,4,5),(1000,100,10000,1000000,1000000000000000000),(5,100,10000,1000000,100000000000000000),(2,3,4,5,6),(3,4,5,6,7),(101,102,103,104,105),(10001,103,10002,10003,10004),(10,11,12,13,14),(11,12,13,14,15),(12,13,14,15,16);
+SELECT i FROM t1 ORDER BY i;
+i
+1
+2
+3
+5
+10
+11
+12
+101
+1000
+10001
+DROP TABLE t1;
+CREATE TABLE t1 (i INT <CUSTOM_COL_OPTIONS> PRIMARY KEY,
+t TINYINT <CUSTOM_COL_OPTIONS>,
+s SMALLINT <CUSTOM_COL_OPTIONS>,
+m MEDIUMINT <CUSTOM_COL_OPTIONS>,
+b BIGINT <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (i,t,s,m,b) VALUES (1,2,3,4,5),(1000,100,10000,1000000,1000000000000000000),(5,100,10000,1000000,100000000000000000),(2,3,4,5,6),(3,4,5,6,7),(101,102,103,104,105),(10001,103,10002,10003,10004),(10,11,12,13,14),(11,12,13,14,15),(12,13,14,15,16);
+EXPLAIN SELECT i FROM t1 ORDER BY i;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # PRIMARY # # # Using index
+SELECT i FROM t1 ORDER BY i;
+i
+1
+2
+3
+5
+10
+11
+12
+101
+1000
+10001
+ALTER TABLE t1 DROP PRIMARY KEY;
+ALTER TABLE t1 ADD PRIMARY KEY (i,t);
+INSERT INTO t1 (i,t,s,m,b) VALUES (1,3,2,4,5);
+EXPLAIN SELECT i, t FROM t1 ORDER BY i, t;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # PRIMARY # # # Using index
+SELECT i, t FROM t1 ORDER BY i, t;
+i t
+1 2
+1 3
+2 3
+3 4
+5 100
+10 11
+11 12
+12 13
+101 102
+1000 100
+10001 103
+DROP TABLE t1;
+CREATE TABLE t1 (i INT <CUSTOM_COL_OPTIONS>,
+t TINYINT <CUSTOM_COL_OPTIONS>,
+s SMALLINT <CUSTOM_COL_OPTIONS>,
+m MEDIUMINT <CUSTOM_COL_OPTIONS>,
+b BIGINT <CUSTOM_COL_OPTIONS>,
+INDEX s_m (s,m)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (i,t,s,m,b) VALUES (1,2,3,4,5),(1000,100,10000,1000000,1000000000000000000),(5,100,10000,1000000,100000000000000000),(2,3,4,5,6),(3,4,5,6,7),(101,102,103,104,105),(10001,103,10002,10003,10004),(10,11,12,13,14),(11,12,13,14,15),(12,13,14,15,16);
+EXPLAIN SELECT s, m FROM t1 WHERE s != 10 AND m != 1;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # s_m # # # Using where; Using index
+SELECT s, m FROM t1 WHERE s != 10 AND m != 1;
+s m
+10000 1000000
+10000 1000000
+10002 10003
+103 104
+12 13
+13 14
+14 15
+3 4
+4 5
+5 6
+DROP TABLE t1;
+CREATE TABLE t1 (i INT <CUSTOM_COL_OPTIONS>,
+t TINYINT <CUSTOM_COL_OPTIONS>,
+s SMALLINT <CUSTOM_COL_OPTIONS>,
+m MEDIUMINT <CUSTOM_COL_OPTIONS>,
+b BIGINT <CUSTOM_COL_OPTIONS>,
+UNIQUE KEY b_t (b,t)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (i,t,s,m,b) VALUES (1,2,3,4,5),(1000,100,10000,1000000,1000000000000000000),(5,100,10000,1000000,100000000000000000),(2,3,4,5,6),(3,4,5,6,7),(101,102,103,104,105),(10001,103,10002,10003,10004),(10,11,12,13,14),(11,12,13,14,15),(12,13,14,15,16);
+SELECT b+t FROM t1 WHERE (b,t) IN ( SELECT b, t FROM t1 WHERE i>1 ) ORDER BY b+t;
+b+t
+9
+11
+25
+27
+29
+207
+10107
+100000000000000100
+1000000000000000100
+SELECT b+t FROM t1 FORCE INDEX (b_t) WHERE (b,t) IN ( SELECT b, t FROM t1 WHERE i>1 ) ORDER BY b+t;
+b+t
+9
+11
+25
+27
+29
+207
+10107
+100000000000000100
+1000000000000000100
+SELECT b+t FROM t1 IGNORE INDEX (b_t) WHERE (b,t) IN ( SELECT b, t FROM t1 WHERE i>1 ) ORDER BY b+t;
+b+t
+9
+11
+25
+27
+29
+207
+10107
+100000000000000100
+1000000000000000100
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_int_indexes.test b/mysql-test/suite/storage_engine/type_int_indexes.test
new file mode 100644
index 00000000..f8270c91
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_int_indexes.test
@@ -0,0 +1,146 @@
+#
+# INT column types with indexes
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+
+# Default index as set in define_engine.inc
+
+let $create_definition =
+ i INT $col_indexed_opts,
+ t TINYINT $col_opts,
+ s SMALLINT $col_opts,
+ m MEDIUMINT $col_opts,
+ b BIGINT $col_opts,
+ $default_index i (i)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = INT types or indexes on them
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (i,t,s,m,b) VALUES (1,2,3,4,5),(1000,100,10000,1000000,1000000000000000000),(5,100,10000,1000000,100000000000000000),(2,3,4,5,6),(3,4,5,6,7),(101,102,103,104,105),(10001,103,10002,10003,10004),(10,11,12,13,14),(11,12,13,14,15),(12,13,14,15,16);
+
+ SELECT i FROM t1 ORDER BY i;
+
+ DROP TABLE t1;
+}
+
+
+# PK, UNIQUE INDEX, INDEX
+
+let $create_definition =
+ i INT $col_indexed_opts PRIMARY KEY,
+ t TINYINT $col_opts,
+ s SMALLINT $col_opts,
+ m MEDIUMINT $col_opts,
+ b BIGINT $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = INT types or PK
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (i,t,s,m,b) VALUES (1,2,3,4,5),(1000,100,10000,1000000,1000000000000000000),(5,100,10000,1000000,100000000000000000),(2,3,4,5,6),(3,4,5,6,7),(101,102,103,104,105),(10001,103,10002,10003,10004),(10,11,12,13,14),(11,12,13,14,15),(12,13,14,15,16);
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 #
+ EXPLAIN SELECT i FROM t1 ORDER BY i;
+ SELECT i FROM t1 ORDER BY i;
+
+ --let $alter_definition = DROP PRIMARY KEY
+ --source alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --let $alter_definition = ADD PRIMARY KEY (i,t)
+ --source alter_table.inc
+
+ INSERT INTO t1 (i,t,s,m,b) VALUES (1,3,2,4,5);
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 #
+ EXPLAIN SELECT i, t FROM t1 ORDER BY i, t;
+ SELECT i, t FROM t1 ORDER BY i, t;
+ }
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ i INT $col_opts,
+ t TINYINT $col_opts,
+ s SMALLINT $col_indexed_opts,
+ m MEDIUMINT $col_indexed_opts,
+ b BIGINT $col_opts,
+ INDEX s_m (s,m)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = INT types or non-unique indexes or multi-part indexes
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (i,t,s,m,b) VALUES (1,2,3,4,5),(1000,100,10000,1000000,1000000000000000000),(5,100,10000,1000000,100000000000000000),(2,3,4,5,6),(3,4,5,6,7),(101,102,103,104,105),(10001,103,10002,10003,10004),(10,11,12,13,14),(11,12,13,14,15),(12,13,14,15,16);
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 #
+ EXPLAIN SELECT s, m FROM t1 WHERE s != 10 AND m != 1;
+ --sorted_result
+ SELECT s, m FROM t1 WHERE s != 10 AND m != 1;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ i INT $col_opts,
+ t TINYINT $col_indexed_opts,
+ s SMALLINT $col_opts,
+ m MEDIUMINT $col_opts,
+ b BIGINT $col_indexed_opts,
+ UNIQUE KEY b_t (b,t)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = INT types or unique keys or multi-part keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (i,t,s,m,b) VALUES (1,2,3,4,5),(1000,100,10000,1000000,1000000000000000000),(5,100,10000,1000000,100000000000000000),(2,3,4,5,6),(3,4,5,6,7),(101,102,103,104,105),(10001,103,10002,10003,10004),(10,11,12,13,14),(11,12,13,14,15),(12,13,14,15,16);
+
+ # This query should use the index b_t, we just don't want to run EXPLAIN
+ # (to avoid mismatches due to different subquery-related plans)
+ SELECT b+t FROM t1 WHERE (b,t) IN ( SELECT b, t FROM t1 WHERE i>1 ) ORDER BY b+t;
+ SELECT b+t FROM t1 FORCE INDEX (b_t) WHERE (b,t) IN ( SELECT b, t FROM t1 WHERE i>1 ) ORDER BY b+t;
+ SELECT b+t FROM t1 IGNORE INDEX (b_t) WHERE (b,t) IN ( SELECT b, t FROM t1 WHERE i>1 ) ORDER BY b+t;
+
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_set.inc b/mysql-test/suite/storage_engine/type_set.inc
new file mode 100644
index 00000000..bc927cf8
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_set.inc
@@ -0,0 +1,69 @@
+#
+# SET column type
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Valid values.
+
+let $create_definition =
+ a SET('') $col_opts,
+ b SET('test1','test2','test3','test4','test5') $col_opts,
+ c SET('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','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') $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = SET types
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+
+ INSERT INTO t1 (a,b,c) VALUES
+ ('','test2,test3','01,34,44,,23'),
+ ('',5,2),
+ (',','test4,test2','');
+ --sorted_result
+ SELECT a,b,c FROM t1;
+
+ # Out of range values
+ # (should produce warnings)
+
+ INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
+ --sorted_result
+ SELECT a,b,c FROM t1;
+
+ # Non-unique values in set
+ # (should produce a warning)
+ --let $alter_definition = ADD COLUMN e SET('a','A') $col_opts
+ --source alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+
+ --let $error_codes = ER_TOO_BIG_SET
+ --let $alter_definition = ADD COLUMN f SET('1','2','3','4','5','6','7','8','9','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',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i') $col_opts
+ --source alter_table.inc
+ }
+
+ # Simple comparison
+
+ --sorted_result
+ SELECT a,b,c,e FROM t1 WHERE FIND_IN_SET('test2',b)>0 OR a != '';
+
+ DROP TABLE t1;
+}
+
diff --git a/mysql-test/suite/storage_engine/type_set.result b/mysql-test/suite/storage_engine/type_set.result
new file mode 100644
index 00000000..6826daf2
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_set.result
@@ -0,0 +1,47 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a SET('') <CUSTOM_COL_OPTIONS>,
+b SET('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS>,
+c SET('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','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') <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a set('') # # #
+b set('test1','test2','test3','test4','test5') # # #
+c set('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','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') # # #
+INSERT INTO t1 (a,b,c) VALUES
+('','test2,test3','01,34,44,,23'),
+('',5,2),
+(',','test4,test2','');
+Warnings:
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+ test1,test3 02
+ test2,test3 01,23,34,44
+ test2,test4
+INSERT INTO t1 (a,b,c) VALUES (0,'test6',-1);
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 1
+Warning 1265 Data truncated for column 'c' at row 1
+SELECT a,b,c FROM t1;
+a b c
+ 01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,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
+ test1,test3 02
+ test2,test3 01,23,34,44
+ test2,test4
+ALTER TABLE t1 ADD COLUMN e SET('a','A') <CUSTOM_COL_OPTIONS>;
+Warnings:
+Note 1291 Column 'e' has duplicated value 'a' in SET
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a set('') # # #
+b set('test1','test2','test3','test4','test5') # # #
+c set('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','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') # # #
+e set('a','A') # # #
+ALTER TABLE t1 ADD COLUMN f SET('1','2','3','4','5','6','7','8','9','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',' ','11','12','13','14','15','16','17','18','19','1a','1b','1c','1d','1e','1f','1g','1h','1i','1j','1k','1l','1m','1n','1o','1p','1q','1r','1s','1t','1u','1v','1w','1x','1y','1z','20','21','22','23','24','25','26','27','28','29','2a','2b','2c','2d','2e','2f','2g','2h','2i','2j','2k','2l','2m','2n','2o','2p','2q','2r','2s','2t','2u','2v','2w','2x','2y','2z','30','31','32','33','34','35','36','37','38','39','3a','3b','3c','3d','3e','3f','3g','3h','3i') <CUSTOM_COL_OPTIONS>;
+ERROR HY000: Too many strings for column f and SET
+SELECT a,b,c,e FROM t1 WHERE FIND_IN_SET('test2',b)>0 OR a != '';
+a b c e
+ test2,test3 01,23,34,44 NULL
+ test2,test4 NULL
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_set.test b/mysql-test/suite/storage_engine/type_set.test
new file mode 100644
index 00000000..7313ccaf
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_set.test
@@ -0,0 +1,10 @@
+#
+# SET column type
+#
+
+--source have_engine.inc
+
+--source type_set.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_set_indexes.result b/mysql-test/suite/storage_engine/type_set_indexes.result
new file mode 100644
index 00000000..871202d7
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_set_indexes.result
@@ -0,0 +1,137 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a SET('N.America','S.America','Africa','Antarctica','Australia','Europe','Asia') <CUSTOM_COL_OPTIONS>,
+b SET('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS>,
+c SET('01','22','23','33','34','39','40','44','50','63','64') <CUSTOM_COL_OPTIONS>,
+<CUSTOM_INDEX> c (c)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 # 1 c # # NULL NULL # #
+INSERT INTO t1 (a,b,c) VALUES
+('','test2,test3','01,34,44,23'),
+('',5,2),
+('N.America,Asia','test4,test2',''),
+('Africa,Europe,Asia','test2,test3','01'),
+('Antarctica','test3','34,44'),
+('Asia','test5','50'),
+('Europe,S.America','test1,','39');
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 7
+SELECT c FROM t1 ORDER BY c;
+c
+
+01
+22
+39
+34,44
+01,23,34,44
+50
+DROP TABLE t1;
+CREATE TABLE t1 (a SET('N.America','S.America','Africa','Antarctica','Australia','Europe','Asia') <CUSTOM_COL_OPTIONS>,
+b SET('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS>,
+c SET('01','22','23','33','34','39','40','44','50','63','64') <CUSTOM_COL_OPTIONS> PRIMARY KEY
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 PRIMARY 1 c # # NULL NULL # #
+INSERT INTO t1 (a,b,c) VALUES
+('','test2,test3','01,34,44,23'),
+('',5,2),
+('N.America,Asia','test4,test2',''),
+('Africa,Europe,Asia','test2,test3','01'),
+('Antarctica','test3','34,44'),
+('Asia','test5','50'),
+('Europe,S.America','test1,','39');
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 7
+EXPLAIN SELECT c FROM t1 ORDER BY c;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # PRIMARY # # # #
+SELECT c FROM t1 ORDER BY c;
+c
+
+01
+22
+39
+34,44
+01,23,34,44
+50
+EXPLAIN SELECT c FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) ORDER BY c;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # PRIMARY # # # #
+SELECT c FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) ORDER BY c;
+c
+
+01
+22
+39
+34,44
+01,23,34,44
+50
+INSERT INTO t1 (a,b,c) VALUES ('Antarctica','test3','02');
+ERROR 23000: Duplicate entry '22' for key 'PRIMARY'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+INSERT INTO t1 (a,b,c) VALUES ('','test1','34,44');
+ERROR 23000: Duplicate entry '34,44' for key 'PRIMARY'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+DROP TABLE t1;
+CREATE TABLE t1 (a SET('N.America','S.America','Africa','Antarctica','Australia','Europe','Asia') <CUSTOM_COL_OPTIONS>,
+b SET('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS>,
+c SET('01','22','23','33','34','39','40','44','50','63','64') <CUSTOM_COL_OPTIONS>,
+INDEX(a)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 a 1 a # # NULL NULL # #
+INSERT INTO t1 (a,b,c) VALUES
+('','test2,test3','01,34,44,23'),
+('',5,2),
+('N.America,Asia','test4,test2',''),
+('Africa,Europe,Asia','test2,test3','01'),
+('Antarctica','test3','34,44'),
+('Asia','test5','50'),
+('Europe,S.America','test1,','39');
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 7
+EXPLAIN SELECT a FROM t1 WHERE FIND_IN_SET('Europe',a) > 0;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # a # # # #
+SELECT a FROM t1 WHERE FIND_IN_SET('Europe',a) > 0;
+a
+Africa,Europe,Asia
+S.America,Europe
+DROP TABLE t1;
+CREATE TABLE t1 (a SET('N.America','S.America','Africa','Antarctica','Australia','Europe','Asia') <CUSTOM_COL_OPTIONS>,
+b SET('test1','test2','test3','test4','test5') <CUSTOM_COL_OPTIONS>,
+c SET('01','22','23','33','34','39','40','44','50','63','64') <CUSTOM_COL_OPTIONS>,
+UNIQUE INDEX b_a (b,a)
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 b_a 1 b # # NULL NULL # #
+t1 0 b_a 2 a # # NULL NULL # #
+INSERT INTO t1 (a,b,c) VALUES
+('','test2,test3','01,34,44,23'),
+('',5,2),
+('N.America,Asia','test4,test2',''),
+('Africa,Europe,Asia','test2,test3','01'),
+('Antarctica','test3','34,44'),
+('Asia','test5','50'),
+('Europe,S.America','test1,','39');
+Warnings:
+Warning 1265 Data truncated for column 'b' at row 7
+EXPLAIN SELECT DISTINCT a, b FROM t1 ORDER BY b DESC, a;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # b_a # # # #
+SELECT DISTINCT a, b FROM t1 ORDER BY b DESC, a;
+a b
+ test1,test3
+ test2,test3
+Africa,Europe,Asia test2,test3
+Antarctica test3
+Asia test5
+N.America,Asia test2,test4
+S.America,Europe test1
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_set_indexes.test b/mysql-test/suite/storage_engine/type_set_indexes.test
new file mode 100644
index 00000000..3223c957
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_set_indexes.test
@@ -0,0 +1,167 @@
+#
+# SET columns with indexes
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Default index as configured in define_engine.inc
+
+let $create_definition =
+ a SET('N.America','S.America','Africa','Antarctica','Australia','Europe','Asia') $col_opts,
+ b SET('test1','test2','test3','test4','test5') $col_opts,
+ c SET('01','22','23','33','34','39','40','44','50','63','64') $col_indexed_opts,
+ $default_index c (c)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = SET types or indexes on them
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (a,b,c) VALUES
+ ('','test2,test3','01,34,44,23'),
+ ('',5,2),
+ ('N.America,Asia','test4,test2',''),
+ ('Africa,Europe,Asia','test2,test3','01'),
+ ('Antarctica','test3','34,44'),
+ ('Asia','test5','50'),
+ ('Europe,S.America','test1,','39');
+
+ SELECT c FROM t1 ORDER BY c;
+
+ DROP TABLE t1;
+}
+
+
+# PK, UNIQUE INDEX, INDEX
+
+
+let $create_definition =
+ a SET('N.America','S.America','Africa','Antarctica','Australia','Europe','Asia') $col_opts,
+ b SET('test1','test2','test3','test4','test5') $col_opts,
+ c SET('01','22','23','33','34','39','40','44','50','63','64') $col_indexed_opts PRIMARY KEY
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = SET types or PK
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (a,b,c) VALUES
+ ('','test2,test3','01,34,44,23'),
+ ('',5,2),
+ ('N.America,Asia','test4,test2',''),
+ ('Africa,Europe,Asia','test2,test3','01'),
+ ('Antarctica','test3','34,44'),
+ ('Asia','test5','50'),
+ ('Europe,S.America','test1,','39');
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT c FROM t1 ORDER BY c;
+ SELECT c FROM t1 ORDER BY c;
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT c FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) ORDER BY c;
+ SELECT c FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY) ORDER BY c;
+
+
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ INSERT INTO t1 (a,b,c) VALUES ('Antarctica','test3','02');
+ --source check_errors.inc
+
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ INSERT INTO t1 (a,b,c) VALUES ('','test1','34,44');
+ --source check_errors.inc
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ a SET('N.America','S.America','Africa','Antarctica','Australia','Europe','Asia') $col_indexed_opts,
+ b SET('test1','test2','test3','test4','test5') $col_opts,
+ c SET('01','22','23','33','34','39','40','44','50','63','64') $col_opts,
+ INDEX(a)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = SET types or non-unique keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (a,b,c) VALUES
+ ('','test2,test3','01,34,44,23'),
+ ('',5,2),
+ ('N.America,Asia','test4,test2',''),
+ ('Africa,Europe,Asia','test2,test3','01'),
+ ('Antarctica','test3','34,44'),
+ ('Asia','test5','50'),
+ ('Europe,S.America','test1,','39');
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT a FROM t1 WHERE FIND_IN_SET('Europe',a) > 0;
+ --sorted_result
+ SELECT a FROM t1 WHERE FIND_IN_SET('Europe',a) > 0;
+
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ a SET('N.America','S.America','Africa','Antarctica','Australia','Europe','Asia') $col_indexed_opts,
+ b SET('test1','test2','test3','test4','test5') $col_indexed_opts,
+ c SET('01','22','23','33','34','39','40','44','50','63','64') $col_opts,
+ UNIQUE INDEX b_a (b,a)
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = SET types or unique keys or multi-part keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (a,b,c) VALUES
+ ('','test2,test3','01,34,44,23'),
+ ('',5,2),
+ ('N.America,Asia','test4,test2',''),
+ ('Africa,Europe,Asia','test2,test3','01'),
+ ('Antarctica','test3','34,44'),
+ ('Asia','test5','50'),
+ ('Europe,S.America','test1,','39');
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT DISTINCT a, b FROM t1 ORDER BY b DESC, a;
+ --sorted_result
+ SELECT DISTINCT a, b FROM t1 ORDER BY b DESC, a;
+
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_spatial.inc b/mysql-test/suite/storage_engine/type_spatial.inc
new file mode 100644
index 00000000..212786d6
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_spatial.inc
@@ -0,0 +1,738 @@
+#
+# Spatial objects
+#
+
+#
+# A calling test can initialize $index variable,
+# which can be SPATIAL, or INDEX, or UNIQUE INDEX;
+# Logic for creating tables with spatial and non-spatial indexes is different
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
+--enable_warnings
+
+--disable_warnings
+DROP DATABASE IF EXISTS gis_ogs;
+--enable_warnings
+
+CREATE DATABASE gis_ogs;
+
+
+if ($index=='')
+{
+ --let $table_name = gis_point
+ --let $create_definition = fid $int_col, g POINT
+ --source create_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Geometry types
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --let $table_name = gis_line
+ --let $create_definition = fid $int_col, g LINESTRING
+ --source create_table.inc
+ --let $table_name = gis_polygon
+ --let $create_definition = fid $int_col, g POLYGON
+ --source create_table.inc
+ --let $table_name = gis_multi_point
+ --let $create_definition = fid $int_col, g MULTIPOINT
+ --source create_table.inc
+ --let $table_name = gis_multi_line
+ --let $create_definition = fid $int_col, g MULTILINESTRING
+ --source create_table.inc
+ --let $table_name = gis_multi_polygon
+ --let $create_definition = fid $int_col, g MULTIPOLYGON
+ --source create_table.inc
+ --let $table_name = gis_geometrycollection
+ --let $create_definition = fid $int_col, g GEOMETRYCOLLECTION
+ --source create_table.inc
+ --let $table_name = gis_geometry
+ --let $create_definition = fid $int_col, g GEOMETRY
+ --source create_table.inc
+
+ USE gis_ogs;
+
+ --let $table_name = lakes
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ shore POLYGON;
+ --source create_table.inc
+
+ --let $table_name = road_segments
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ aliases CHAR(64) $col_opts,
+ num_lanes INT $col_opts,
+ centerline LINESTRING;
+ --source create_table.inc
+
+ --let $table_name = divided_routes
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ num_lanes INT $col_opts,
+ centerlines MULTILINESTRING;
+ --source create_table.inc
+
+ --let $table_name = forests
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ boundary MULTIPOLYGON;
+ --source create_table.inc
+
+ --let $table_name = bridges
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ position POINT;
+ --source create_table.inc
+
+ --let $table_name = streams
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ centerline LINESTRING;
+ --source create_table.inc
+
+ --let $table_name = buildings
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ position POINT,
+ footprint POLYGON;
+ --source create_table.inc
+
+ --let $table_name = ponds
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ type CHAR(64) $col_opts,
+ shores MULTIPOLYGON;
+ --source create_table.inc
+
+ --let $table_name = named_places
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ boundary POLYGON;
+ --source create_table.inc
+
+ --let $table_name = map_neatlines
+ let $create_definition =
+ fid INT $col_opts,
+ neatline POLYGON;
+ --source create_table.inc
+ }
+}
+
+if ($index == 'SPATIAL')
+{
+ --let $table_name = gis_point
+ --let $create_definition = fid $int_col, g POINT NOT NULL, SPATIAL INDEX(g)
+ --source create_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Geometry types or spatial indexes
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --let $table_name = gis_line
+ --let $create_definition = fid $int_col, g LINESTRING NOT NULL, SPATIAL INDEX(g)
+ --source create_table.inc
+ --let $table_name = gis_polygon
+ --let $create_definition = fid $int_col, g POLYGON NOT NULL, SPATIAL INDEX(g)
+ --source create_table.inc
+ --let $table_name = gis_multi_point
+ --let $create_definition = fid $int_col, g MULTIPOINT NOT NULL, SPATIAL INDEX(g)
+ --source create_table.inc
+ --let $table_name = gis_multi_line
+ --let $create_definition = fid $int_col, g MULTILINESTRING NOT NULL, SPATIAL INDEX(g)
+ --source create_table.inc
+ --let $table_name = gis_multi_polygon
+ --let $create_definition = fid $int_col, g MULTIPOLYGON NOT NULL, SPATIAL INDEX(g)
+ --source create_table.inc
+ --let $table_name = gis_geometrycollection
+ --let $create_definition = fid $int_col, g GEOMETRYCOLLECTION NOT NULL, SPATIAL INDEX(g)
+ --source create_table.inc
+ --let $table_name = gis_geometry
+ --let $create_definition = fid $int_col, g GEOMETRY NOT NULL
+ --source create_table.inc
+
+ USE gis_ogs;
+
+ --let $table_name = lakes
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ shore POLYGON NOT NULL, SPATIAL INDEX s(shore);
+ --source create_table.inc
+
+ --let $table_name = road_segments
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ aliases CHAR(64) $col_opts,
+ num_lanes INT $col_opts,
+ centerline LINESTRING NOT NULL, SPATIAL INDEX c(centerline);
+ --source create_table.inc
+
+ --let $table_name = divided_routes
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ num_lanes INT $col_opts,
+ centerlines MULTILINESTRING NOT NULL, SPATIAL INDEX c(centerlines);
+ --source create_table.inc
+
+ --let $table_name = forests
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ boundary MULTIPOLYGON NOT NULL, SPATIAL INDEX b(boundary);
+ --source create_table.inc
+
+ --let $table_name = bridges
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ position POINT NOT NULL, SPATIAL INDEX p(position);
+ --source create_table.inc
+
+ --let $table_name = streams
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ centerline LINESTRING NOT NULL, SPATIAL INDEX c(centerline);
+ --source create_table.inc
+
+ --let $table_name = buildings
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ position POINT NOT NULL,
+ footprint POLYGON NOT NULL, SPATIAL INDEX p(position), SPATIAL INDEX f(footprint);
+ --source create_table.inc
+
+ --let $table_name = ponds
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ type CHAR(64) $col_opts,
+ shores MULTIPOLYGON NOT NULL, SPATIAL INDEX s(shores);
+ --source create_table.inc
+
+ --let $table_name = named_places
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ boundary POLYGON NOT NULL, SPATIAL INDEX b(boundary);
+ --source create_table.inc
+
+ --let $table_name = map_neatlines
+ let $create_definition =
+ fid INT $col_opts,
+ neatline POLYGON NOT NULL, SPATIAL INDEX n(neatline);
+ --source create_table.inc
+ }
+ let $index =;
+}
+
+if ($index)
+{
+ --let $table_name = gis_point
+ --let $create_definition = fid $int_col, g POINT, $index g(g(128))
+ --source create_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Geometry types or indexes on them
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --let $table_name = gis_line
+ --let $create_definition = fid $int_col, g LINESTRING, $index g(g(256))
+ --source create_table.inc
+ --let $table_name = gis_polygon
+ --let $create_definition = fid $int_col, g POLYGON, $index g(g(512))
+ --source create_table.inc
+ --let $table_name = gis_multi_point
+ --let $create_definition = fid $int_col, g MULTIPOINT, $index g(g(128))
+ --source create_table.inc
+ --let $table_name = gis_multi_line
+ --let $create_definition = fid $int_col, g MULTILINESTRING, $index g(g(256))
+ --source create_table.inc
+ --let $table_name = gis_multi_polygon
+ --let $create_definition = fid $int_col, g MULTIPOLYGON
+ --source create_table.inc
+ --let $table_name = gis_geometrycollection
+ --let $create_definition = fid $int_col, g GEOMETRYCOLLECTION
+ --source create_table.inc
+ --let $table_name = gis_geometry
+ --let $create_definition = fid $int_col, g GEOMETRY
+ --source create_table.inc
+
+ USE gis_ogs;
+
+ --let $table_name = lakes
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ shore POLYGON $spatial_col_opts, $index s(shore(64));
+ --source create_table.inc
+
+ --let $table_name = road_segments
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ aliases CHAR(64) $col_opts,
+ num_lanes INT $col_opts,
+ centerline LINESTRING $spatial_col_opts, $index c(centerline(128));
+ --source create_table.inc
+
+ --let $table_name = divided_routes
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ num_lanes INT $col_opts,
+ centerlines MULTILINESTRING $spatial_col_opts, $index c(centerlines(512));
+ --source create_table.inc
+
+ --let $table_name = forests
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ boundary MULTIPOLYGON $spatial_col_opts, $index b(boundary(128));
+ --source create_table.inc
+
+ --let $table_name = bridges
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ position POINT $spatial_col_opts, $index p(`position`(64));
+ --source create_table.inc
+
+ --let $table_name = streams
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ centerline LINESTRING $spatial_col_opts, $index c(centerline(256));
+ --source create_table.inc
+
+ --let $table_name = buildings
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ position POINT $spatial_col_opts,
+ footprint POLYGON $spatial_col_opts, $index p(`position`(64)), $index f(footprint(128));
+ --source create_table.inc
+
+ --let $table_name = ponds
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ type CHAR(64) $col_opts,
+ shores MULTIPOLYGON $spatial_col_opts, $index s(shores(256));
+ --source create_table.inc
+
+ --let $table_name = named_places
+ let $create_definition =
+ fid INT $col_opts,
+ name CHAR(64) $col_opts,
+ boundary POLYGON $spatial_col_opts, $index b(boundary(512));
+ --source create_table.inc
+
+ --let $table_name = map_neatlines
+ let $create_definition =
+ fid INT $col_opts,
+ neatline POLYGON $spatial_col_opts, $index n(neatline(700));
+ --source create_table.inc
+ }
+}
+
+if (!$mysql_errname)
+{
+ USE test;
+
+ SHOW FIELDS FROM gis_point;
+ SHOW FIELDS FROM gis_line;
+ SHOW FIELDS FROM gis_polygon;
+ SHOW FIELDS FROM gis_multi_point;
+ SHOW FIELDS FROM gis_multi_line;
+ SHOW FIELDS FROM gis_multi_polygon;
+ SHOW FIELDS FROM gis_geometrycollection;
+ SHOW FIELDS FROM gis_geometry;
+
+ INSERT INTO gis_point (fid,g) VALUES
+ (101, PointFromText('POINT(10 10)')),
+ (102, PointFromText('POINT(20 10)')),
+ (103, PointFromText('POINT(20 20)')),
+ (104, PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))));
+
+ INSERT INTO gis_line (fid,g) VALUES
+ (105, LineFromText('LINESTRING(0 0,0 10,10 0)')),
+ (106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
+ (107, LineStringFromWKB(AsWKB(LineString(Point(10, 10), Point(40, 10)))));
+
+ INSERT INTO gis_polygon (fid,g) VALUES
+ (108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
+ (109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
+ (110, PolyFromWKB(AsWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))))));
+
+ INSERT INTO gis_multi_point (fid,g) VALUES
+ (111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
+ (112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
+ (113, MPointFromWKB(AsWKB(MultiPoint(Point(3, 6), Point(4, 10)))));
+
+ INSERT INTO gis_multi_line (fid,g) VALUES
+ (114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
+ (115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
+ (116, MLineFromWKB(AsWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7))))));
+
+ INSERT INTO gis_multi_polygon (fid,g) VALUES
+ (117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
+ (118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
+ (119, MPolyFromWKB(AsWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))));
+
+ INSERT INTO gis_geometrycollection (fid,g) VALUES
+ (120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
+ (121, GeometryFromWKB(AsWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))))),
+ (122, GeomFromText('GeometryCollection()')),
+ (123, GeomFromText('GeometryCollection EMPTY'));
+
+ INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_point;
+ INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_line;
+ INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_polygon;
+ INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_multi_point;
+ INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_multi_line;
+ INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_multi_polygon;
+ INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_geometrycollection;
+
+ SELECT fid, AsText(g) FROM gis_point;
+ SELECT fid, AsText(g) FROM gis_line;
+ SELECT fid, AsText(g) FROM gis_polygon;
+ SELECT fid, AsText(g) FROM gis_multi_point;
+ SELECT fid, AsText(g) FROM gis_multi_line;
+ SELECT fid, AsText(g) FROM gis_multi_polygon;
+ SELECT fid, AsText(g) FROM gis_geometrycollection;
+ SELECT fid, AsText(g) FROM gis_geometry;
+
+ SELECT fid, Dimension(g) FROM gis_geometry;
+ SELECT fid, GeometryType(g) FROM gis_geometry;
+ SELECT fid, IsEmpty(g) FROM gis_geometry;
+ SELECT fid, AsText(Envelope(g)) FROM gis_geometry;
+
+ SELECT fid, X(g) FROM gis_point;
+ SELECT fid, Y(g) FROM gis_point;
+
+ SELECT fid, AsText(StartPoint(g)) FROM gis_line;
+ SELECT fid, AsText(EndPoint(g)) FROM gis_line;
+ SELECT fid, GLength(g) FROM gis_line;
+ SELECT fid, NumPoints(g) FROM gis_line;
+ SELECT fid, AsText(PointN(g, 2)) FROM gis_line;
+ SELECT fid, IsClosed(g) FROM gis_line;
+
+ SELECT fid, AsText(Centroid(g)) FROM gis_polygon;
+ SELECT fid, Area(g) FROM gis_polygon;
+ SELECT fid, AsText(ExteriorRing(g)) FROM gis_polygon;
+ SELECT fid, NumInteriorRings(g) FROM gis_polygon;
+ SELECT fid, AsText(InteriorRingN(g, 1)) FROM gis_polygon;
+
+ SELECT fid, IsClosed(g) FROM gis_multi_line;
+
+ SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon;
+ SELECT fid, Area(g) FROM gis_multi_polygon;
+
+ SELECT fid, NumGeometries(g) from gis_multi_point;
+ SELECT fid, NumGeometries(g) from gis_multi_line;
+ SELECT fid, NumGeometries(g) from gis_multi_polygon;
+ SELECT fid, NumGeometries(g) from gis_geometrycollection;
+
+ SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point;
+ SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_line;
+ SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_polygon;
+ SELECT fid, AsText(GeometryN(g, 2)) from gis_geometrycollection;
+ SELECT fid, AsText(GeometryN(g, 1)) from gis_geometrycollection;
+
+ SELECT g1.fid as first, g2.fid as second,
+ Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
+ Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
+ Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
+ FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
+
+ DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
+
+
+ USE gis_ogs;
+
+ --echo # Lakes
+ INSERT INTO lakes (fid,name,shore) VALUES (
+ 101, 'BLUE LAKE',
+ PolyFromText(
+ 'POLYGON(
+ (52 18,66 23,73 9,48 6,52 18),
+ (59 18,67 18,67 13,59 13,59 18)
+ )',
+ 101));
+
+ --echo # Road Segments
+
+ INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(102, 'Route 5', NULL, 2,
+ LineFromText(
+ 'LINESTRING( 0 18, 10 21, 16 23, 28 26, 44 31 )' ,101));
+
+ INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(103, 'Route 5', 'Main Street', 4,
+ LineFromText(
+ 'LINESTRING( 44 31, 56 34, 70 38 )' ,101));
+
+ INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(104, 'Route 5', NULL, 2,
+ LineFromText(
+ 'LINESTRING( 70 38, 72 48 )' ,101));
+
+ INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(105, 'Main Street', NULL, 4,
+ LineFromText(
+ 'LINESTRING( 70 38, 84 42 )' ,101));
+
+ INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(106, 'Dirt Road by Green Forest', NULL,
+ 1,
+ LineFromText(
+ 'LINESTRING( 28 26, 28 0 )',101));
+
+ --echo # DividedRoutes
+
+ INSERT INTO divided_routes (fid,name,num_lanes,centerlines) VALUES(119, 'Route 75', 4,
+ MLineFromText(
+ 'MULTILINESTRING((10 48,10 21,10 0),
+ (16 0,16 23,16 48))', 101));
+
+ --echo # Forests
+
+ INSERT INTO forests (fid,name,boundary) VALUES(109, 'Green Forest',
+ MPolyFromText(
+ 'MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),
+ (52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))',
+ 101));
+
+ --echo # Bridges
+
+ INSERT INTO bridges (fid,name,position) VALUES(110, 'Cam Bridge', PointFromText(
+ 'POINT( 44 31 )', 101));
+
+ --echo # Streams
+
+ INSERT INTO streams (fid,name,centerline) VALUES(111, 'Cam Stream',
+ LineFromText(
+ 'LINESTRING( 38 48, 44 41, 41 36, 44 31, 52 18 )', 101));
+
+ INSERT INTO streams (fid,name,centerline) VALUES(112, NULL,
+ LineFromText(
+ 'LINESTRING( 76 0, 78 4, 73 9 )', 101));
+
+ --echo # Buildings
+
+ INSERT INTO buildings (fid,name,position,footprint) VALUES(113, '123 Main Street',
+ PointFromText(
+ 'POINT( 52 30 )', 101),
+ PolyFromText(
+ 'POLYGON( ( 50 31, 54 31, 54 29, 50 29, 50 31) )', 101));
+
+ INSERT INTO buildings (fid,name,position,footprint) VALUES(114, '215 Main Street',
+ PointFromText(
+ 'POINT( 64 33 )', 101),
+ PolyFromText(
+ 'POLYGON( ( 66 34, 62 34, 62 32, 66 32, 66 34) )', 101));
+
+
+ --echo # Ponds
+
+ INSERT INTO ponds (fid,name,type,shores) VALUES(120, NULL, 'Stock Pond',
+ MPolyFromText(
+ 'MULTIPOLYGON( ( ( 24 44, 22 42, 24 40, 24 44) ),
+ ( ( 26 44, 26 40, 28 42, 26 44) ) )', 101));
+
+ --echo # Named Places
+
+ INSERT INTO named_places (fid,name,boundary) VALUES(117, 'Ashton',
+ PolyFromText(
+ 'POLYGON( ( 62 48, 84 48, 84 30, 56 30, 56 34, 62 48) )', 101));
+
+ INSERT INTO named_places (fid,name,boundary) VALUES(118, 'Goose Island',
+ PolyFromText(
+ 'POLYGON( ( 67 13, 67 18, 59 18, 59 13, 67 13) )', 101));
+
+ --echo # Map Neatlines
+
+ INSERT INTO map_neatlines (fid,neatline) VALUES(115,
+ PolyFromText(
+ 'POLYGON( ( 0 0, 0 48, 84 48, 84 0, 0 0 ) )', 101));
+
+ SELECT Dimension(shore)
+ FROM lakes
+ WHERE name = 'Blue Lake';
+
+ SELECT GeometryType(centerlines)
+ FROM divided_routes
+ WHERE name = 'Route 75';
+
+ SELECT AsText(boundary)
+ FROM named_places
+ WHERE name = 'Goose Island';
+
+ SELECT AsText(PolyFromWKB(AsBinary(boundary),101))
+ FROM named_places
+ WHERE name = 'Goose Island';
+
+ SELECT SRID(boundary)
+ FROM named_places
+ WHERE name = 'Goose Island';
+
+ SELECT IsEmpty(centerline)
+ FROM road_segments
+ WHERE name = 'Route 5'
+ AND aliases = 'Main Street';
+
+ SELECT AsText(Envelope(boundary))
+ FROM named_places
+ WHERE name = 'Goose Island';
+
+ SELECT X(position)
+ FROM bridges
+ WHERE name = 'Cam Bridge';
+
+ SELECT Y(position)
+ FROM bridges
+ WHERE name = 'Cam Bridge';
+
+ SELECT AsText(StartPoint(centerline))
+ FROM road_segments
+ WHERE fid = 102;
+
+ SELECT AsText(EndPoint(centerline))
+ FROM road_segments
+ WHERE fid = 102;
+
+ SELECT GLength(centerline)
+ FROM road_segments
+ WHERE fid = 106;
+
+ SELECT NumPoints(centerline)
+ FROM road_segments
+ WHERE fid = 102;
+
+ SELECT AsText(PointN(centerline, 1))
+ FROM road_segments
+ WHERE fid = 102;
+
+ SELECT AsText(Centroid(boundary))
+ FROM named_places
+ WHERE name = 'Goose Island';
+
+ SELECT Area(boundary)
+ FROM named_places
+ WHERE name = 'Goose Island';
+
+ SELECT AsText(ExteriorRing(shore))
+ FROM lakes
+ WHERE name = 'Blue Lake';
+
+ SELECT NumInteriorRings(shore)
+ FROM lakes
+ WHERE name = 'Blue Lake';
+
+ SELECT AsText(InteriorRingN(shore, 1))
+ FROM lakes
+ WHERE name = 'Blue Lake';
+
+ SELECT NumGeometries(centerlines)
+ FROM divided_routes
+ WHERE name = 'Route 75';
+
+ SELECT AsText(GeometryN(centerlines, 2))
+ FROM divided_routes
+ WHERE name = 'Route 75';
+
+ SELECT IsClosed(centerlines)
+ FROM divided_routes
+ WHERE name = 'Route 75';
+
+ SELECT GLength(centerlines)
+ FROM divided_routes
+ WHERE name = 'Route 75';
+
+ SELECT AsText(Centroid(shores))
+ FROM ponds
+ WHERE fid = 120;
+
+ SELECT Area(shores)
+ FROM ponds
+ WHERE fid = 120;
+
+ SELECT ST_Equals(boundary,
+ PolyFromText('POLYGON( ( 67 13, 67 18, 59 18, 59 13, 67 13) )',1))
+ FROM named_places
+ WHERE name = 'Goose Island';
+
+ SELECT ST_Disjoint(centerlines, boundary)
+ FROM divided_routes, named_places
+ WHERE divided_routes.name = 'Route 75'
+ AND named_places.name = 'Ashton';
+
+ SELECT ST_Touches(centerline, shore)
+ FROM streams, lakes
+ WHERE streams.name = 'Cam Stream'
+ AND lakes.name = 'Blue Lake';
+
+ SELECT Crosses(road_segments.centerline, divided_routes.centerlines)
+ FROM road_segments, divided_routes
+ WHERE road_segments.fid = 102
+ AND divided_routes.name = 'Route 75';
+
+ SELECT ST_Intersects(road_segments.centerline, divided_routes.centerlines)
+ FROM road_segments, divided_routes
+ WHERE road_segments.fid = 102
+ AND divided_routes.name = 'Route 75';
+
+ SELECT ST_Contains(forests.boundary, named_places.boundary)
+ FROM forests, named_places
+ WHERE forests.name = 'Green Forest'
+ AND named_places.name = 'Ashton';
+
+ SELECT ST_Distance(position, boundary)
+ FROM bridges, named_places
+ WHERE bridges.name = 'Cam Bridge'
+ AND named_places.name = 'Ashton';
+
+ SELECT AsText(ST_Difference(named_places.boundary, forests.boundary))
+ FROM named_places, forests
+ WHERE named_places.name = 'Ashton'
+ AND forests.name = 'Green Forest';
+
+ SELECT AsText(ST_Union(shore, boundary))
+ FROM lakes, named_places
+ WHERE lakes.name = 'Blue Lake'
+ AND named_places.name = 'Goose Island';
+
+ SELECT AsText(ST_SymDifference(shore, boundary))
+ FROM lakes, named_places
+ WHERE lakes.name = 'Blue Lake'
+ AND named_places.name = 'Ashton';
+
+ SELECT count(*)
+ FROM buildings, bridges
+ WHERE ST_Contains(ST_Buffer(bridges.position, 15.0), buildings.footprint) = 1;
+
+}
+
+DROP DATABASE gis_ogs;
+USE test;
+
+
diff --git a/mysql-test/suite/storage_engine/type_spatial.result b/mysql-test/suite/storage_engine/type_spatial.result
new file mode 100644
index 00000000..cab19421
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_spatial.result
@@ -0,0 +1,700 @@
+DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
+DROP DATABASE IF EXISTS gis_ogs;
+CREATE DATABASE gis_ogs;
+CREATE TABLE gis_point (fid <INT_COLUMN>, g POINT) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_line (fid <INT_COLUMN>, g LINESTRING) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_polygon (fid <INT_COLUMN>, g POLYGON) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_multi_point (fid <INT_COLUMN>, g MULTIPOINT) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_multi_line (fid <INT_COLUMN>, g MULTILINESTRING) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_multi_polygon (fid <INT_COLUMN>, g MULTIPOLYGON) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_geometrycollection (fid <INT_COLUMN>, g GEOMETRYCOLLECTION) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_geometry (fid <INT_COLUMN>, g GEOMETRY) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+USE gis_ogs;
+CREATE TABLE lakes (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+shore POLYGON) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE road_segments (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+aliases CHAR(64) <CUSTOM_COL_OPTIONS>,
+num_lanes INT <CUSTOM_COL_OPTIONS>,
+centerline LINESTRING) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE divided_routes (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+num_lanes INT <CUSTOM_COL_OPTIONS>,
+centerlines MULTILINESTRING) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE forests (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+boundary MULTIPOLYGON) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE bridges (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+position POINT) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE streams (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+centerline LINESTRING) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE buildings (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+position POINT,
+footprint POLYGON) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE ponds (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+type CHAR(64) <CUSTOM_COL_OPTIONS>,
+shores MULTIPOLYGON) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE named_places (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+boundary POLYGON) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE map_neatlines (fid INT <CUSTOM_COL_OPTIONS>,
+neatline POLYGON) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+USE test;
+SHOW FIELDS FROM gis_point;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g point YES NULL
+SHOW FIELDS FROM gis_line;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g linestring YES NULL
+SHOW FIELDS FROM gis_polygon;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g polygon YES NULL
+SHOW FIELDS FROM gis_multi_point;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g multipoint YES NULL
+SHOW FIELDS FROM gis_multi_line;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g multilinestring YES NULL
+SHOW FIELDS FROM gis_multi_polygon;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g multipolygon YES NULL
+SHOW FIELDS FROM gis_geometrycollection;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g geometrycollection YES NULL
+SHOW FIELDS FROM gis_geometry;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g geometry YES NULL
+INSERT INTO gis_point (fid,g) VALUES
+(101, PointFromText('POINT(10 10)')),
+(102, PointFromText('POINT(20 10)')),
+(103, PointFromText('POINT(20 20)')),
+(104, PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))));
+INSERT INTO gis_line (fid,g) VALUES
+(105, LineFromText('LINESTRING(0 0,0 10,10 0)')),
+(106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
+(107, LineStringFromWKB(AsWKB(LineString(Point(10, 10), Point(40, 10)))));
+INSERT INTO gis_polygon (fid,g) VALUES
+(108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
+(109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
+(110, PolyFromWKB(AsWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))))));
+INSERT INTO gis_multi_point (fid,g) VALUES
+(111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
+(112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
+(113, MPointFromWKB(AsWKB(MultiPoint(Point(3, 6), Point(4, 10)))));
+INSERT INTO gis_multi_line (fid,g) VALUES
+(114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
+(115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
+(116, MLineFromWKB(AsWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7))))));
+INSERT INTO gis_multi_polygon (fid,g) VALUES
+(117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
+(118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
+(119, MPolyFromWKB(AsWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))));
+INSERT INTO gis_geometrycollection (fid,g) VALUES
+(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
+(121, GeometryFromWKB(AsWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))))),
+(122, GeomFromText('GeometryCollection()')),
+(123, GeomFromText('GeometryCollection EMPTY'));
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_point;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_line;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_polygon;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_multi_point;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_multi_line;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_multi_polygon;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_geometrycollection;
+SELECT fid, AsText(g) FROM gis_point;
+fid AsText(g)
+101 POINT(10 10)
+102 POINT(20 10)
+103 POINT(20 20)
+104 POINT(10 20)
+SELECT fid, AsText(g) FROM gis_line;
+fid AsText(g)
+105 LINESTRING(0 0,0 10,10 0)
+106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
+107 LINESTRING(10 10,40 10)
+SELECT fid, AsText(g) FROM gis_polygon;
+fid AsText(g)
+108 POLYGON((10 10,20 10,20 20,10 20,10 10))
+109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
+110 POLYGON((0 0,30 0,30 30,0 0))
+SELECT fid, AsText(g) FROM gis_multi_point;
+fid AsText(g)
+111 MULTIPOINT(0 0,10 10,10 20,20 20)
+112 MULTIPOINT(1 1,11 11,11 21,21 21)
+113 MULTIPOINT(3 6,4 10)
+SELECT fid, AsText(g) FROM gis_multi_line;
+fid AsText(g)
+114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
+115 MULTILINESTRING((10 48,10 21,10 0))
+116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
+SELECT fid, AsText(g) FROM gis_multi_polygon;
+fid AsText(g)
+117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
+118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
+119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
+SELECT fid, AsText(g) FROM gis_geometrycollection;
+fid AsText(g)
+120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
+121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
+122 GEOMETRYCOLLECTION EMPTY
+123 GEOMETRYCOLLECTION EMPTY
+SELECT fid, AsText(g) FROM gis_geometry;
+fid AsText(g)
+101 POINT(10 10)
+102 POINT(20 10)
+103 POINT(20 20)
+104 POINT(10 20)
+105 LINESTRING(0 0,0 10,10 0)
+106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
+107 LINESTRING(10 10,40 10)
+108 POLYGON((10 10,20 10,20 20,10 20,10 10))
+109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
+110 POLYGON((0 0,30 0,30 30,0 0))
+111 MULTIPOINT(0 0,10 10,10 20,20 20)
+112 MULTIPOINT(1 1,11 11,11 21,21 21)
+113 MULTIPOINT(3 6,4 10)
+114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
+115 MULTILINESTRING((10 48,10 21,10 0))
+116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
+117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
+118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
+119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
+120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
+121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
+122 GEOMETRYCOLLECTION EMPTY
+123 GEOMETRYCOLLECTION EMPTY
+SELECT fid, Dimension(g) FROM gis_geometry;
+fid Dimension(g)
+101 0
+102 0
+103 0
+104 0
+105 1
+106 1
+107 1
+108 2
+109 2
+110 2
+111 0
+112 0
+113 0
+114 1
+115 1
+116 1
+117 2
+118 2
+119 2
+120 1
+121 1
+122 0
+123 0
+SELECT fid, GeometryType(g) FROM gis_geometry;
+fid GeometryType(g)
+101 POINT
+102 POINT
+103 POINT
+104 POINT
+105 LINESTRING
+106 LINESTRING
+107 LINESTRING
+108 POLYGON
+109 POLYGON
+110 POLYGON
+111 MULTIPOINT
+112 MULTIPOINT
+113 MULTIPOINT
+114 MULTILINESTRING
+115 MULTILINESTRING
+116 MULTILINESTRING
+117 MULTIPOLYGON
+118 MULTIPOLYGON
+119 MULTIPOLYGON
+120 GEOMETRYCOLLECTION
+121 GEOMETRYCOLLECTION
+122 GEOMETRYCOLLECTION
+123 GEOMETRYCOLLECTION
+SELECT fid, IsEmpty(g) FROM gis_geometry;
+fid IsEmpty(g)
+101 0
+102 0
+103 0
+104 0
+105 0
+106 0
+107 0
+108 0
+109 0
+110 0
+111 0
+112 0
+113 0
+114 0
+115 0
+116 0
+117 0
+118 0
+119 0
+120 0
+121 0
+122 0
+123 0
+SELECT fid, AsText(Envelope(g)) FROM gis_geometry;
+fid AsText(Envelope(g))
+101 POLYGON((10 10,10 10,10 10,10 10,10 10))
+102 POLYGON((20 10,20 10,20 10,20 10,20 10))
+103 POLYGON((20 20,20 20,20 20,20 20,20 20))
+104 POLYGON((10 20,10 20,10 20,10 20,10 20))
+105 POLYGON((0 0,10 0,10 10,0 10,0 0))
+106 POLYGON((10 10,20 10,20 20,10 20,10 10))
+107 POLYGON((10 10,40 10,40 10,10 10,10 10))
+108 POLYGON((10 10,20 10,20 20,10 20,10 10))
+109 POLYGON((0 0,50 0,50 50,0 50,0 0))
+110 POLYGON((0 0,30 0,30 30,0 30,0 0))
+111 POLYGON((0 0,20 0,20 20,0 20,0 0))
+112 POLYGON((1 1,21 1,21 21,1 21,1 1))
+113 POLYGON((3 6,4 6,4 10,3 10,3 6))
+114 POLYGON((10 0,16 0,16 48,10 48,10 0))
+115 POLYGON((10 0,10 0,10 48,10 48,10 0))
+116 POLYGON((1 2,21 2,21 8,1 8,1 2))
+117 POLYGON((28 0,84 0,84 42,28 42,28 0))
+118 POLYGON((28 0,84 0,84 42,28 42,28 0))
+119 POLYGON((0 0,3 0,3 3,0 3,0 0))
+120 POLYGON((0 0,10 0,10 10,0 10,0 0))
+121 POLYGON((3 6,44 6,44 9,3 9,3 6))
+122 GEOMETRYCOLLECTION EMPTY
+123 GEOMETRYCOLLECTION EMPTY
+SELECT fid, X(g) FROM gis_point;
+fid X(g)
+101 10
+102 20
+103 20
+104 10
+SELECT fid, Y(g) FROM gis_point;
+fid Y(g)
+101 10
+102 10
+103 20
+104 20
+SELECT fid, AsText(StartPoint(g)) FROM gis_line;
+fid AsText(StartPoint(g))
+105 POINT(0 0)
+106 POINT(10 10)
+107 POINT(10 10)
+SELECT fid, AsText(EndPoint(g)) FROM gis_line;
+fid AsText(EndPoint(g))
+105 POINT(10 0)
+106 POINT(10 10)
+107 POINT(40 10)
+SELECT fid, GLength(g) FROM gis_line;
+fid GLength(g)
+105 24.14213562373095
+106 40
+107 30
+SELECT fid, NumPoints(g) FROM gis_line;
+fid NumPoints(g)
+105 3
+106 5
+107 2
+SELECT fid, AsText(PointN(g, 2)) FROM gis_line;
+fid AsText(PointN(g, 2))
+105 POINT(0 10)
+106 POINT(20 10)
+107 POINT(40 10)
+SELECT fid, IsClosed(g) FROM gis_line;
+fid IsClosed(g)
+105 0
+106 1
+107 0
+SELECT fid, AsText(Centroid(g)) FROM gis_polygon;
+fid AsText(Centroid(g))
+108 POINT(15 15)
+109 POINT(25.416666666666668 25.416666666666668)
+110 POINT(20 10)
+SELECT fid, Area(g) FROM gis_polygon;
+fid Area(g)
+108 100
+109 2400
+110 450
+SELECT fid, AsText(ExteriorRing(g)) FROM gis_polygon;
+fid AsText(ExteriorRing(g))
+108 LINESTRING(10 10,20 10,20 20,10 20,10 10)
+109 LINESTRING(0 0,50 0,50 50,0 50,0 0)
+110 LINESTRING(0 0,30 0,30 30,0 0)
+SELECT fid, NumInteriorRings(g) FROM gis_polygon;
+fid NumInteriorRings(g)
+108 0
+109 1
+110 0
+SELECT fid, AsText(InteriorRingN(g, 1)) FROM gis_polygon;
+fid AsText(InteriorRingN(g, 1))
+108 NULL
+109 LINESTRING(10 10,20 10,20 20,10 20,10 10)
+110 NULL
+SELECT fid, IsClosed(g) FROM gis_multi_line;
+fid IsClosed(g)
+114 0
+115 0
+116 0
+SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon;
+fid AsText(Centroid(g))
+117 POINT(57.98031067576927 17.854754130800433)
+118 POINT(57.98031067576927 17.854754130800433)
+119 POINT(2 2)
+SELECT fid, Area(g) FROM gis_multi_polygon;
+fid Area(g)
+117 1684.5
+118 1684.5
+119 4.5
+SELECT fid, NumGeometries(g) from gis_multi_point;
+fid NumGeometries(g)
+111 4
+112 4
+113 2
+SELECT fid, NumGeometries(g) from gis_multi_line;
+fid NumGeometries(g)
+114 2
+115 1
+116 2
+SELECT fid, NumGeometries(g) from gis_multi_polygon;
+fid NumGeometries(g)
+117 2
+118 2
+119 1
+SELECT fid, NumGeometries(g) from gis_geometrycollection;
+fid NumGeometries(g)
+120 2
+121 2
+122 0
+123 0
+SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point;
+fid AsText(GeometryN(g, 2))
+111 POINT(10 10)
+112 POINT(11 11)
+113 POINT(4 10)
+SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_line;
+fid AsText(GeometryN(g, 2))
+114 LINESTRING(16 0,16 23,16 48)
+115 NULL
+116 LINESTRING(2 5,5 8,21 7)
+SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_polygon;
+fid AsText(GeometryN(g, 2))
+117 POLYGON((59 18,67 18,67 13,59 13,59 18))
+118 POLYGON((59 18,67 18,67 13,59 13,59 18))
+119 NULL
+SELECT fid, AsText(GeometryN(g, 2)) from gis_geometrycollection;
+fid AsText(GeometryN(g, 2))
+120 LINESTRING(0 0,10 10)
+121 LINESTRING(3 6,7 9)
+122 NULL
+123 NULL
+SELECT fid, AsText(GeometryN(g, 1)) from gis_geometrycollection;
+fid AsText(GeometryN(g, 1))
+120 POINT(0 0)
+121 POINT(44 6)
+122 NULL
+123 NULL
+SELECT g1.fid as first, g2.fid as second,
+Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
+Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
+Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
+FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
+first second w c o e d t i r
+120 120 1 1 0 1 0 0 1 0
+120 121 0 0 1 0 0 0 1 0
+120 122 NULL NULL NULL NULL NULL NULL NULL NULL
+120 123 NULL NULL NULL NULL NULL NULL NULL NULL
+121 120 0 0 1 0 0 0 1 0
+121 121 1 1 0 1 0 0 1 0
+121 122 NULL NULL NULL NULL NULL NULL NULL NULL
+121 123 NULL NULL NULL NULL NULL NULL NULL NULL
+122 120 NULL NULL NULL NULL NULL NULL NULL NULL
+122 121 NULL NULL NULL NULL NULL NULL NULL NULL
+122 122 NULL NULL NULL NULL NULL NULL NULL NULL
+122 123 NULL NULL NULL NULL NULL NULL NULL NULL
+123 120 NULL NULL NULL NULL NULL NULL NULL NULL
+123 121 NULL NULL NULL NULL NULL NULL NULL NULL
+123 122 NULL NULL NULL NULL NULL NULL NULL NULL
+123 123 NULL NULL NULL NULL NULL NULL NULL NULL
+DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
+USE gis_ogs;
+# Lakes
+INSERT INTO lakes (fid,name,shore) VALUES (
+101, 'BLUE LAKE',
+PolyFromText(
+'POLYGON(
+ (52 18,66 23,73 9,48 6,52 18),
+ (59 18,67 18,67 13,59 13,59 18)
+ )',
+101));
+# Road Segments
+INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(102, 'Route 5', NULL, 2,
+LineFromText(
+'LINESTRING( 0 18, 10 21, 16 23, 28 26, 44 31 )' ,101));
+INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(103, 'Route 5', 'Main Street', 4,
+LineFromText(
+'LINESTRING( 44 31, 56 34, 70 38 )' ,101));
+INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(104, 'Route 5', NULL, 2,
+LineFromText(
+'LINESTRING( 70 38, 72 48 )' ,101));
+INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(105, 'Main Street', NULL, 4,
+LineFromText(
+'LINESTRING( 70 38, 84 42 )' ,101));
+INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(106, 'Dirt Road by Green Forest', NULL,
+1,
+LineFromText(
+'LINESTRING( 28 26, 28 0 )',101));
+# DividedRoutes
+INSERT INTO divided_routes (fid,name,num_lanes,centerlines) VALUES(119, 'Route 75', 4,
+MLineFromText(
+'MULTILINESTRING((10 48,10 21,10 0),
+ (16 0,16 23,16 48))', 101));
+# Forests
+INSERT INTO forests (fid,name,boundary) VALUES(109, 'Green Forest',
+MPolyFromText(
+'MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),
+ (52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))',
+101));
+# Bridges
+INSERT INTO bridges (fid,name,position) VALUES(110, 'Cam Bridge', PointFromText(
+'POINT( 44 31 )', 101));
+# Streams
+INSERT INTO streams (fid,name,centerline) VALUES(111, 'Cam Stream',
+LineFromText(
+'LINESTRING( 38 48, 44 41, 41 36, 44 31, 52 18 )', 101));
+INSERT INTO streams (fid,name,centerline) VALUES(112, NULL,
+LineFromText(
+'LINESTRING( 76 0, 78 4, 73 9 )', 101));
+# Buildings
+INSERT INTO buildings (fid,name,position,footprint) VALUES(113, '123 Main Street',
+PointFromText(
+'POINT( 52 30 )', 101),
+PolyFromText(
+'POLYGON( ( 50 31, 54 31, 54 29, 50 29, 50 31) )', 101));
+INSERT INTO buildings (fid,name,position,footprint) VALUES(114, '215 Main Street',
+PointFromText(
+'POINT( 64 33 )', 101),
+PolyFromText(
+'POLYGON( ( 66 34, 62 34, 62 32, 66 32, 66 34) )', 101));
+# Ponds
+INSERT INTO ponds (fid,name,type,shores) VALUES(120, NULL, 'Stock Pond',
+MPolyFromText(
+'MULTIPOLYGON( ( ( 24 44, 22 42, 24 40, 24 44) ),
+ ( ( 26 44, 26 40, 28 42, 26 44) ) )', 101));
+# Named Places
+INSERT INTO named_places (fid,name,boundary) VALUES(117, 'Ashton',
+PolyFromText(
+'POLYGON( ( 62 48, 84 48, 84 30, 56 30, 56 34, 62 48) )', 101));
+INSERT INTO named_places (fid,name,boundary) VALUES(118, 'Goose Island',
+PolyFromText(
+'POLYGON( ( 67 13, 67 18, 59 18, 59 13, 67 13) )', 101));
+# Map Neatlines
+INSERT INTO map_neatlines (fid,neatline) VALUES(115,
+PolyFromText(
+'POLYGON( ( 0 0, 0 48, 84 48, 84 0, 0 0 ) )', 101));
+SELECT Dimension(shore)
+FROM lakes
+WHERE name = 'Blue Lake';
+Dimension(shore)
+2
+SELECT GeometryType(centerlines)
+FROM divided_routes
+WHERE name = 'Route 75';
+GeometryType(centerlines)
+MULTILINESTRING
+SELECT AsText(boundary)
+FROM named_places
+WHERE name = 'Goose Island';
+AsText(boundary)
+POLYGON((67 13,67 18,59 18,59 13,67 13))
+SELECT AsText(PolyFromWKB(AsBinary(boundary),101))
+FROM named_places
+WHERE name = 'Goose Island';
+AsText(PolyFromWKB(AsBinary(boundary),101))
+POLYGON((67 13,67 18,59 18,59 13,67 13))
+SELECT SRID(boundary)
+FROM named_places
+WHERE name = 'Goose Island';
+SRID(boundary)
+101
+SELECT IsEmpty(centerline)
+FROM road_segments
+WHERE name = 'Route 5'
+AND aliases = 'Main Street';
+IsEmpty(centerline)
+0
+SELECT AsText(Envelope(boundary))
+FROM named_places
+WHERE name = 'Goose Island';
+AsText(Envelope(boundary))
+POLYGON((59 13,67 13,67 18,59 18,59 13))
+SELECT X(position)
+FROM bridges
+WHERE name = 'Cam Bridge';
+X(position)
+44
+SELECT Y(position)
+FROM bridges
+WHERE name = 'Cam Bridge';
+Y(position)
+31
+SELECT AsText(StartPoint(centerline))
+FROM road_segments
+WHERE fid = 102;
+AsText(StartPoint(centerline))
+POINT(0 18)
+SELECT AsText(EndPoint(centerline))
+FROM road_segments
+WHERE fid = 102;
+AsText(EndPoint(centerline))
+POINT(44 31)
+SELECT GLength(centerline)
+FROM road_segments
+WHERE fid = 106;
+GLength(centerline)
+26
+SELECT NumPoints(centerline)
+FROM road_segments
+WHERE fid = 102;
+NumPoints(centerline)
+5
+SELECT AsText(PointN(centerline, 1))
+FROM road_segments
+WHERE fid = 102;
+AsText(PointN(centerline, 1))
+POINT(0 18)
+SELECT AsText(Centroid(boundary))
+FROM named_places
+WHERE name = 'Goose Island';
+AsText(Centroid(boundary))
+POINT(63 15.5)
+SELECT Area(boundary)
+FROM named_places
+WHERE name = 'Goose Island';
+Area(boundary)
+40
+SELECT AsText(ExteriorRing(shore))
+FROM lakes
+WHERE name = 'Blue Lake';
+AsText(ExteriorRing(shore))
+LINESTRING(52 18,66 23,73 9,48 6,52 18)
+SELECT NumInteriorRings(shore)
+FROM lakes
+WHERE name = 'Blue Lake';
+NumInteriorRings(shore)
+1
+SELECT AsText(InteriorRingN(shore, 1))
+FROM lakes
+WHERE name = 'Blue Lake';
+AsText(InteriorRingN(shore, 1))
+LINESTRING(59 18,67 18,67 13,59 13,59 18)
+SELECT NumGeometries(centerlines)
+FROM divided_routes
+WHERE name = 'Route 75';
+NumGeometries(centerlines)
+2
+SELECT AsText(GeometryN(centerlines, 2))
+FROM divided_routes
+WHERE name = 'Route 75';
+AsText(GeometryN(centerlines, 2))
+LINESTRING(16 0,16 23,16 48)
+SELECT IsClosed(centerlines)
+FROM divided_routes
+WHERE name = 'Route 75';
+IsClosed(centerlines)
+0
+SELECT GLength(centerlines)
+FROM divided_routes
+WHERE name = 'Route 75';
+GLength(centerlines)
+96
+SELECT AsText(Centroid(shores))
+FROM ponds
+WHERE fid = 120;
+AsText(Centroid(shores))
+POINT(25 42)
+SELECT Area(shores)
+FROM ponds
+WHERE fid = 120;
+Area(shores)
+8
+SELECT ST_Equals(boundary,
+PolyFromText('POLYGON( ( 67 13, 67 18, 59 18, 59 13, 67 13) )',1))
+FROM named_places
+WHERE name = 'Goose Island';
+ST_Equals(boundary,
+PolyFromText('POLYGON( ( 67 13, 67 18, 59 18, 59 13, 67 13) )',1))
+1
+SELECT ST_Disjoint(centerlines, boundary)
+FROM divided_routes, named_places
+WHERE divided_routes.name = 'Route 75'
+AND named_places.name = 'Ashton';
+ST_Disjoint(centerlines, boundary)
+1
+SELECT ST_Touches(centerline, shore)
+FROM streams, lakes
+WHERE streams.name = 'Cam Stream'
+AND lakes.name = 'Blue Lake';
+ST_Touches(centerline, shore)
+1
+SELECT Crosses(road_segments.centerline, divided_routes.centerlines)
+FROM road_segments, divided_routes
+WHERE road_segments.fid = 102
+AND divided_routes.name = 'Route 75';
+Crosses(road_segments.centerline, divided_routes.centerlines)
+1
+SELECT ST_Intersects(road_segments.centerline, divided_routes.centerlines)
+FROM road_segments, divided_routes
+WHERE road_segments.fid = 102
+AND divided_routes.name = 'Route 75';
+ST_Intersects(road_segments.centerline, divided_routes.centerlines)
+1
+SELECT ST_Contains(forests.boundary, named_places.boundary)
+FROM forests, named_places
+WHERE forests.name = 'Green Forest'
+AND named_places.name = 'Ashton';
+ST_Contains(forests.boundary, named_places.boundary)
+0
+SELECT ST_Distance(position, boundary)
+FROM bridges, named_places
+WHERE bridges.name = 'Cam Bridge'
+AND named_places.name = 'Ashton';
+ST_Distance(position, boundary)
+12
+SELECT AsText(ST_Difference(named_places.boundary, forests.boundary))
+FROM named_places, forests
+WHERE named_places.name = 'Ashton'
+AND forests.name = 'Green Forest';
+AsText(ST_Difference(named_places.boundary, forests.boundary))
+POLYGON((56 34,62 48,84 48,84 42,56 34))
+SELECT AsText(ST_Union(shore, boundary))
+FROM lakes, named_places
+WHERE lakes.name = 'Blue Lake'
+AND named_places.name = 'Goose Island';
+AsText(ST_Union(shore, boundary))
+POLYGON((48 6,52 18,66 23,73 9,48 6))
+SELECT AsText(ST_SymDifference(shore, boundary))
+FROM lakes, named_places
+WHERE lakes.name = 'Blue Lake'
+AND named_places.name = 'Ashton';
+AsText(ST_SymDifference(shore, boundary))
+MULTIPOLYGON(((48 6,52 18,66 23,73 9,48 6),(59 13,59 18,67 18,67 13,59 13)),((56 30,56 34,62 48,84 48,84 30,56 30)))
+SELECT count(*)
+FROM buildings, bridges
+WHERE ST_Contains(ST_Buffer(bridges.position, 15.0), buildings.footprint) = 1;
+count(*)
+1
+DROP DATABASE gis_ogs;
+USE test;
diff --git a/mysql-test/suite/storage_engine/type_spatial.test b/mysql-test/suite/storage_engine/type_spatial.test
new file mode 100644
index 00000000..e71805c5
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_spatial.test
@@ -0,0 +1,10 @@
+#
+# Spatial objects
+#
+
+--source have_engine.inc
+
+--source type_spatial.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_spatial_indexes.result b/mysql-test/suite/storage_engine/type_spatial_indexes.result
new file mode 100644
index 00000000..f608366c
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_spatial_indexes.result
@@ -0,0 +1,1400 @@
+DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
+DROP DATABASE IF EXISTS gis_ogs;
+CREATE DATABASE gis_ogs;
+CREATE TABLE gis_point (fid <INT_COLUMN>, g POINT, <CUSTOM_INDEX> g(g(128))) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_line (fid <INT_COLUMN>, g LINESTRING, <CUSTOM_INDEX> g(g(256))) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_polygon (fid <INT_COLUMN>, g POLYGON, <CUSTOM_INDEX> g(g(512))) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_multi_point (fid <INT_COLUMN>, g MULTIPOINT, <CUSTOM_INDEX> g(g(128))) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_multi_line (fid <INT_COLUMN>, g MULTILINESTRING, <CUSTOM_INDEX> g(g(256))) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_multi_polygon (fid <INT_COLUMN>, g MULTIPOLYGON) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_geometrycollection (fid <INT_COLUMN>, g GEOMETRYCOLLECTION) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_geometry (fid <INT_COLUMN>, g GEOMETRY) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+USE gis_ogs;
+CREATE TABLE lakes (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+shore POLYGON, <CUSTOM_INDEX> s(shore(64))) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE road_segments (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+aliases CHAR(64) <CUSTOM_COL_OPTIONS>,
+num_lanes INT <CUSTOM_COL_OPTIONS>,
+centerline LINESTRING, <CUSTOM_INDEX> c(centerline(128))) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE divided_routes (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+num_lanes INT <CUSTOM_COL_OPTIONS>,
+centerlines MULTILINESTRING, <CUSTOM_INDEX> c(centerlines(512))) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE forests (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+boundary MULTIPOLYGON, <CUSTOM_INDEX> b(boundary(128))) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE bridges (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+position POINT, <CUSTOM_INDEX> p(`position`(64))) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE streams (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+centerline LINESTRING, <CUSTOM_INDEX> c(centerline(256))) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE buildings (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+position POINT,
+footprint POLYGON, <CUSTOM_INDEX> p(`position`(64)), <CUSTOM_INDEX> f(footprint(128))) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE ponds (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+type CHAR(64) <CUSTOM_COL_OPTIONS>,
+shores MULTIPOLYGON, <CUSTOM_INDEX> s(shores(256))) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE named_places (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+boundary POLYGON, <CUSTOM_INDEX> b(boundary(512))) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE map_neatlines (fid INT <CUSTOM_COL_OPTIONS>,
+neatline POLYGON, <CUSTOM_INDEX> n(neatline(700))) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+USE test;
+SHOW FIELDS FROM gis_point;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g point YES MUL NULL
+SHOW FIELDS FROM gis_line;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g linestring YES MUL NULL
+SHOW FIELDS FROM gis_polygon;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g polygon YES MUL NULL
+SHOW FIELDS FROM gis_multi_point;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g multipoint YES MUL NULL
+SHOW FIELDS FROM gis_multi_line;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g multilinestring YES MUL NULL
+SHOW FIELDS FROM gis_multi_polygon;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g multipolygon YES NULL
+SHOW FIELDS FROM gis_geometrycollection;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g geometrycollection YES NULL
+SHOW FIELDS FROM gis_geometry;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g geometry YES NULL
+INSERT INTO gis_point (fid,g) VALUES
+(101, PointFromText('POINT(10 10)')),
+(102, PointFromText('POINT(20 10)')),
+(103, PointFromText('POINT(20 20)')),
+(104, PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))));
+INSERT INTO gis_line (fid,g) VALUES
+(105, LineFromText('LINESTRING(0 0,0 10,10 0)')),
+(106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
+(107, LineStringFromWKB(AsWKB(LineString(Point(10, 10), Point(40, 10)))));
+INSERT INTO gis_polygon (fid,g) VALUES
+(108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
+(109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
+(110, PolyFromWKB(AsWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))))));
+INSERT INTO gis_multi_point (fid,g) VALUES
+(111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
+(112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
+(113, MPointFromWKB(AsWKB(MultiPoint(Point(3, 6), Point(4, 10)))));
+INSERT INTO gis_multi_line (fid,g) VALUES
+(114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
+(115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
+(116, MLineFromWKB(AsWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7))))));
+INSERT INTO gis_multi_polygon (fid,g) VALUES
+(117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
+(118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
+(119, MPolyFromWKB(AsWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))));
+INSERT INTO gis_geometrycollection (fid,g) VALUES
+(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
+(121, GeometryFromWKB(AsWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))))),
+(122, GeomFromText('GeometryCollection()')),
+(123, GeomFromText('GeometryCollection EMPTY'));
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_point;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_line;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_polygon;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_multi_point;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_multi_line;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_multi_polygon;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_geometrycollection;
+SELECT fid, AsText(g) FROM gis_point;
+fid AsText(g)
+101 POINT(10 10)
+102 POINT(20 10)
+103 POINT(20 20)
+104 POINT(10 20)
+SELECT fid, AsText(g) FROM gis_line;
+fid AsText(g)
+105 LINESTRING(0 0,0 10,10 0)
+106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
+107 LINESTRING(10 10,40 10)
+SELECT fid, AsText(g) FROM gis_polygon;
+fid AsText(g)
+108 POLYGON((10 10,20 10,20 20,10 20,10 10))
+109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
+110 POLYGON((0 0,30 0,30 30,0 0))
+SELECT fid, AsText(g) FROM gis_multi_point;
+fid AsText(g)
+111 MULTIPOINT(0 0,10 10,10 20,20 20)
+112 MULTIPOINT(1 1,11 11,11 21,21 21)
+113 MULTIPOINT(3 6,4 10)
+SELECT fid, AsText(g) FROM gis_multi_line;
+fid AsText(g)
+114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
+115 MULTILINESTRING((10 48,10 21,10 0))
+116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
+SELECT fid, AsText(g) FROM gis_multi_polygon;
+fid AsText(g)
+117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
+118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
+119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
+SELECT fid, AsText(g) FROM gis_geometrycollection;
+fid AsText(g)
+120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
+121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
+122 GEOMETRYCOLLECTION EMPTY
+123 GEOMETRYCOLLECTION EMPTY
+SELECT fid, AsText(g) FROM gis_geometry;
+fid AsText(g)
+101 POINT(10 10)
+102 POINT(20 10)
+103 POINT(20 20)
+104 POINT(10 20)
+105 LINESTRING(0 0,0 10,10 0)
+106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
+107 LINESTRING(10 10,40 10)
+108 POLYGON((10 10,20 10,20 20,10 20,10 10))
+109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
+110 POLYGON((0 0,30 0,30 30,0 0))
+111 MULTIPOINT(0 0,10 10,10 20,20 20)
+112 MULTIPOINT(1 1,11 11,11 21,21 21)
+113 MULTIPOINT(3 6,4 10)
+114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
+115 MULTILINESTRING((10 48,10 21,10 0))
+116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
+117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
+118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
+119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
+120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
+121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
+122 GEOMETRYCOLLECTION EMPTY
+123 GEOMETRYCOLLECTION EMPTY
+SELECT fid, Dimension(g) FROM gis_geometry;
+fid Dimension(g)
+101 0
+102 0
+103 0
+104 0
+105 1
+106 1
+107 1
+108 2
+109 2
+110 2
+111 0
+112 0
+113 0
+114 1
+115 1
+116 1
+117 2
+118 2
+119 2
+120 1
+121 1
+122 0
+123 0
+SELECT fid, GeometryType(g) FROM gis_geometry;
+fid GeometryType(g)
+101 POINT
+102 POINT
+103 POINT
+104 POINT
+105 LINESTRING
+106 LINESTRING
+107 LINESTRING
+108 POLYGON
+109 POLYGON
+110 POLYGON
+111 MULTIPOINT
+112 MULTIPOINT
+113 MULTIPOINT
+114 MULTILINESTRING
+115 MULTILINESTRING
+116 MULTILINESTRING
+117 MULTIPOLYGON
+118 MULTIPOLYGON
+119 MULTIPOLYGON
+120 GEOMETRYCOLLECTION
+121 GEOMETRYCOLLECTION
+122 GEOMETRYCOLLECTION
+123 GEOMETRYCOLLECTION
+SELECT fid, IsEmpty(g) FROM gis_geometry;
+fid IsEmpty(g)
+101 0
+102 0
+103 0
+104 0
+105 0
+106 0
+107 0
+108 0
+109 0
+110 0
+111 0
+112 0
+113 0
+114 0
+115 0
+116 0
+117 0
+118 0
+119 0
+120 0
+121 0
+122 0
+123 0
+SELECT fid, AsText(Envelope(g)) FROM gis_geometry;
+fid AsText(Envelope(g))
+101 POLYGON((10 10,10 10,10 10,10 10,10 10))
+102 POLYGON((20 10,20 10,20 10,20 10,20 10))
+103 POLYGON((20 20,20 20,20 20,20 20,20 20))
+104 POLYGON((10 20,10 20,10 20,10 20,10 20))
+105 POLYGON((0 0,10 0,10 10,0 10,0 0))
+106 POLYGON((10 10,20 10,20 20,10 20,10 10))
+107 POLYGON((10 10,40 10,40 10,10 10,10 10))
+108 POLYGON((10 10,20 10,20 20,10 20,10 10))
+109 POLYGON((0 0,50 0,50 50,0 50,0 0))
+110 POLYGON((0 0,30 0,30 30,0 30,0 0))
+111 POLYGON((0 0,20 0,20 20,0 20,0 0))
+112 POLYGON((1 1,21 1,21 21,1 21,1 1))
+113 POLYGON((3 6,4 6,4 10,3 10,3 6))
+114 POLYGON((10 0,16 0,16 48,10 48,10 0))
+115 POLYGON((10 0,10 0,10 48,10 48,10 0))
+116 POLYGON((1 2,21 2,21 8,1 8,1 2))
+117 POLYGON((28 0,84 0,84 42,28 42,28 0))
+118 POLYGON((28 0,84 0,84 42,28 42,28 0))
+119 POLYGON((0 0,3 0,3 3,0 3,0 0))
+120 POLYGON((0 0,10 0,10 10,0 10,0 0))
+121 POLYGON((3 6,44 6,44 9,3 9,3 6))
+122 GEOMETRYCOLLECTION EMPTY
+123 GEOMETRYCOLLECTION EMPTY
+SELECT fid, X(g) FROM gis_point;
+fid X(g)
+101 10
+102 20
+103 20
+104 10
+SELECT fid, Y(g) FROM gis_point;
+fid Y(g)
+101 10
+102 10
+103 20
+104 20
+SELECT fid, AsText(StartPoint(g)) FROM gis_line;
+fid AsText(StartPoint(g))
+105 POINT(0 0)
+106 POINT(10 10)
+107 POINT(10 10)
+SELECT fid, AsText(EndPoint(g)) FROM gis_line;
+fid AsText(EndPoint(g))
+105 POINT(10 0)
+106 POINT(10 10)
+107 POINT(40 10)
+SELECT fid, GLength(g) FROM gis_line;
+fid GLength(g)
+105 24.14213562373095
+106 40
+107 30
+SELECT fid, NumPoints(g) FROM gis_line;
+fid NumPoints(g)
+105 3
+106 5
+107 2
+SELECT fid, AsText(PointN(g, 2)) FROM gis_line;
+fid AsText(PointN(g, 2))
+105 POINT(0 10)
+106 POINT(20 10)
+107 POINT(40 10)
+SELECT fid, IsClosed(g) FROM gis_line;
+fid IsClosed(g)
+105 0
+106 1
+107 0
+SELECT fid, AsText(Centroid(g)) FROM gis_polygon;
+fid AsText(Centroid(g))
+108 POINT(15 15)
+109 POINT(25.416666666666668 25.416666666666668)
+110 POINT(20 10)
+SELECT fid, Area(g) FROM gis_polygon;
+fid Area(g)
+108 100
+109 2400
+110 450
+SELECT fid, AsText(ExteriorRing(g)) FROM gis_polygon;
+fid AsText(ExteriorRing(g))
+108 LINESTRING(10 10,20 10,20 20,10 20,10 10)
+109 LINESTRING(0 0,50 0,50 50,0 50,0 0)
+110 LINESTRING(0 0,30 0,30 30,0 0)
+SELECT fid, NumInteriorRings(g) FROM gis_polygon;
+fid NumInteriorRings(g)
+108 0
+109 1
+110 0
+SELECT fid, AsText(InteriorRingN(g, 1)) FROM gis_polygon;
+fid AsText(InteriorRingN(g, 1))
+108 NULL
+109 LINESTRING(10 10,20 10,20 20,10 20,10 10)
+110 NULL
+SELECT fid, IsClosed(g) FROM gis_multi_line;
+fid IsClosed(g)
+114 0
+115 0
+116 0
+SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon;
+fid AsText(Centroid(g))
+117 POINT(57.98031067576927 17.854754130800433)
+118 POINT(57.98031067576927 17.854754130800433)
+119 POINT(2 2)
+SELECT fid, Area(g) FROM gis_multi_polygon;
+fid Area(g)
+117 1684.5
+118 1684.5
+119 4.5
+SELECT fid, NumGeometries(g) from gis_multi_point;
+fid NumGeometries(g)
+111 4
+112 4
+113 2
+SELECT fid, NumGeometries(g) from gis_multi_line;
+fid NumGeometries(g)
+114 2
+115 1
+116 2
+SELECT fid, NumGeometries(g) from gis_multi_polygon;
+fid NumGeometries(g)
+117 2
+118 2
+119 1
+SELECT fid, NumGeometries(g) from gis_geometrycollection;
+fid NumGeometries(g)
+120 2
+121 2
+122 0
+123 0
+SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point;
+fid AsText(GeometryN(g, 2))
+111 POINT(10 10)
+112 POINT(11 11)
+113 POINT(4 10)
+SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_line;
+fid AsText(GeometryN(g, 2))
+114 LINESTRING(16 0,16 23,16 48)
+115 NULL
+116 LINESTRING(2 5,5 8,21 7)
+SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_polygon;
+fid AsText(GeometryN(g, 2))
+117 POLYGON((59 18,67 18,67 13,59 13,59 18))
+118 POLYGON((59 18,67 18,67 13,59 13,59 18))
+119 NULL
+SELECT fid, AsText(GeometryN(g, 2)) from gis_geometrycollection;
+fid AsText(GeometryN(g, 2))
+120 LINESTRING(0 0,10 10)
+121 LINESTRING(3 6,7 9)
+122 NULL
+123 NULL
+SELECT fid, AsText(GeometryN(g, 1)) from gis_geometrycollection;
+fid AsText(GeometryN(g, 1))
+120 POINT(0 0)
+121 POINT(44 6)
+122 NULL
+123 NULL
+SELECT g1.fid as first, g2.fid as second,
+Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
+Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
+Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
+FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
+first second w c o e d t i r
+120 120 1 1 0 1 0 0 1 0
+120 121 0 0 1 0 0 0 1 0
+120 122 NULL NULL NULL NULL NULL NULL NULL NULL
+120 123 NULL NULL NULL NULL NULL NULL NULL NULL
+121 120 0 0 1 0 0 0 1 0
+121 121 1 1 0 1 0 0 1 0
+121 122 NULL NULL NULL NULL NULL NULL NULL NULL
+121 123 NULL NULL NULL NULL NULL NULL NULL NULL
+122 120 NULL NULL NULL NULL NULL NULL NULL NULL
+122 121 NULL NULL NULL NULL NULL NULL NULL NULL
+122 122 NULL NULL NULL NULL NULL NULL NULL NULL
+122 123 NULL NULL NULL NULL NULL NULL NULL NULL
+123 120 NULL NULL NULL NULL NULL NULL NULL NULL
+123 121 NULL NULL NULL NULL NULL NULL NULL NULL
+123 122 NULL NULL NULL NULL NULL NULL NULL NULL
+123 123 NULL NULL NULL NULL NULL NULL NULL NULL
+DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
+USE gis_ogs;
+# Lakes
+INSERT INTO lakes (fid,name,shore) VALUES (
+101, 'BLUE LAKE',
+PolyFromText(
+'POLYGON(
+ (52 18,66 23,73 9,48 6,52 18),
+ (59 18,67 18,67 13,59 13,59 18)
+ )',
+101));
+# Road Segments
+INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(102, 'Route 5', NULL, 2,
+LineFromText(
+'LINESTRING( 0 18, 10 21, 16 23, 28 26, 44 31 )' ,101));
+INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(103, 'Route 5', 'Main Street', 4,
+LineFromText(
+'LINESTRING( 44 31, 56 34, 70 38 )' ,101));
+INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(104, 'Route 5', NULL, 2,
+LineFromText(
+'LINESTRING( 70 38, 72 48 )' ,101));
+INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(105, 'Main Street', NULL, 4,
+LineFromText(
+'LINESTRING( 70 38, 84 42 )' ,101));
+INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(106, 'Dirt Road by Green Forest', NULL,
+1,
+LineFromText(
+'LINESTRING( 28 26, 28 0 )',101));
+# DividedRoutes
+INSERT INTO divided_routes (fid,name,num_lanes,centerlines) VALUES(119, 'Route 75', 4,
+MLineFromText(
+'MULTILINESTRING((10 48,10 21,10 0),
+ (16 0,16 23,16 48))', 101));
+# Forests
+INSERT INTO forests (fid,name,boundary) VALUES(109, 'Green Forest',
+MPolyFromText(
+'MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),
+ (52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))',
+101));
+# Bridges
+INSERT INTO bridges (fid,name,position) VALUES(110, 'Cam Bridge', PointFromText(
+'POINT( 44 31 )', 101));
+# Streams
+INSERT INTO streams (fid,name,centerline) VALUES(111, 'Cam Stream',
+LineFromText(
+'LINESTRING( 38 48, 44 41, 41 36, 44 31, 52 18 )', 101));
+INSERT INTO streams (fid,name,centerline) VALUES(112, NULL,
+LineFromText(
+'LINESTRING( 76 0, 78 4, 73 9 )', 101));
+# Buildings
+INSERT INTO buildings (fid,name,position,footprint) VALUES(113, '123 Main Street',
+PointFromText(
+'POINT( 52 30 )', 101),
+PolyFromText(
+'POLYGON( ( 50 31, 54 31, 54 29, 50 29, 50 31) )', 101));
+INSERT INTO buildings (fid,name,position,footprint) VALUES(114, '215 Main Street',
+PointFromText(
+'POINT( 64 33 )', 101),
+PolyFromText(
+'POLYGON( ( 66 34, 62 34, 62 32, 66 32, 66 34) )', 101));
+# Ponds
+INSERT INTO ponds (fid,name,type,shores) VALUES(120, NULL, 'Stock Pond',
+MPolyFromText(
+'MULTIPOLYGON( ( ( 24 44, 22 42, 24 40, 24 44) ),
+ ( ( 26 44, 26 40, 28 42, 26 44) ) )', 101));
+# Named Places
+INSERT INTO named_places (fid,name,boundary) VALUES(117, 'Ashton',
+PolyFromText(
+'POLYGON( ( 62 48, 84 48, 84 30, 56 30, 56 34, 62 48) )', 101));
+INSERT INTO named_places (fid,name,boundary) VALUES(118, 'Goose Island',
+PolyFromText(
+'POLYGON( ( 67 13, 67 18, 59 18, 59 13, 67 13) )', 101));
+# Map Neatlines
+INSERT INTO map_neatlines (fid,neatline) VALUES(115,
+PolyFromText(
+'POLYGON( ( 0 0, 0 48, 84 48, 84 0, 0 0 ) )', 101));
+SELECT Dimension(shore)
+FROM lakes
+WHERE name = 'Blue Lake';
+Dimension(shore)
+2
+SELECT GeometryType(centerlines)
+FROM divided_routes
+WHERE name = 'Route 75';
+GeometryType(centerlines)
+MULTILINESTRING
+SELECT AsText(boundary)
+FROM named_places
+WHERE name = 'Goose Island';
+AsText(boundary)
+POLYGON((67 13,67 18,59 18,59 13,67 13))
+SELECT AsText(PolyFromWKB(AsBinary(boundary),101))
+FROM named_places
+WHERE name = 'Goose Island';
+AsText(PolyFromWKB(AsBinary(boundary),101))
+POLYGON((67 13,67 18,59 18,59 13,67 13))
+SELECT SRID(boundary)
+FROM named_places
+WHERE name = 'Goose Island';
+SRID(boundary)
+101
+SELECT IsEmpty(centerline)
+FROM road_segments
+WHERE name = 'Route 5'
+AND aliases = 'Main Street';
+IsEmpty(centerline)
+0
+SELECT AsText(Envelope(boundary))
+FROM named_places
+WHERE name = 'Goose Island';
+AsText(Envelope(boundary))
+POLYGON((59 13,67 13,67 18,59 18,59 13))
+SELECT X(position)
+FROM bridges
+WHERE name = 'Cam Bridge';
+X(position)
+44
+SELECT Y(position)
+FROM bridges
+WHERE name = 'Cam Bridge';
+Y(position)
+31
+SELECT AsText(StartPoint(centerline))
+FROM road_segments
+WHERE fid = 102;
+AsText(StartPoint(centerline))
+POINT(0 18)
+SELECT AsText(EndPoint(centerline))
+FROM road_segments
+WHERE fid = 102;
+AsText(EndPoint(centerline))
+POINT(44 31)
+SELECT GLength(centerline)
+FROM road_segments
+WHERE fid = 106;
+GLength(centerline)
+26
+SELECT NumPoints(centerline)
+FROM road_segments
+WHERE fid = 102;
+NumPoints(centerline)
+5
+SELECT AsText(PointN(centerline, 1))
+FROM road_segments
+WHERE fid = 102;
+AsText(PointN(centerline, 1))
+POINT(0 18)
+SELECT AsText(Centroid(boundary))
+FROM named_places
+WHERE name = 'Goose Island';
+AsText(Centroid(boundary))
+POINT(63 15.5)
+SELECT Area(boundary)
+FROM named_places
+WHERE name = 'Goose Island';
+Area(boundary)
+40
+SELECT AsText(ExteriorRing(shore))
+FROM lakes
+WHERE name = 'Blue Lake';
+AsText(ExteriorRing(shore))
+LINESTRING(52 18,66 23,73 9,48 6,52 18)
+SELECT NumInteriorRings(shore)
+FROM lakes
+WHERE name = 'Blue Lake';
+NumInteriorRings(shore)
+1
+SELECT AsText(InteriorRingN(shore, 1))
+FROM lakes
+WHERE name = 'Blue Lake';
+AsText(InteriorRingN(shore, 1))
+LINESTRING(59 18,67 18,67 13,59 13,59 18)
+SELECT NumGeometries(centerlines)
+FROM divided_routes
+WHERE name = 'Route 75';
+NumGeometries(centerlines)
+2
+SELECT AsText(GeometryN(centerlines, 2))
+FROM divided_routes
+WHERE name = 'Route 75';
+AsText(GeometryN(centerlines, 2))
+LINESTRING(16 0,16 23,16 48)
+SELECT IsClosed(centerlines)
+FROM divided_routes
+WHERE name = 'Route 75';
+IsClosed(centerlines)
+0
+SELECT GLength(centerlines)
+FROM divided_routes
+WHERE name = 'Route 75';
+GLength(centerlines)
+96
+SELECT AsText(Centroid(shores))
+FROM ponds
+WHERE fid = 120;
+AsText(Centroid(shores))
+POINT(25 42)
+SELECT Area(shores)
+FROM ponds
+WHERE fid = 120;
+Area(shores)
+8
+SELECT ST_Equals(boundary,
+PolyFromText('POLYGON( ( 67 13, 67 18, 59 18, 59 13, 67 13) )',1))
+FROM named_places
+WHERE name = 'Goose Island';
+ST_Equals(boundary,
+PolyFromText('POLYGON( ( 67 13, 67 18, 59 18, 59 13, 67 13) )',1))
+1
+SELECT ST_Disjoint(centerlines, boundary)
+FROM divided_routes, named_places
+WHERE divided_routes.name = 'Route 75'
+AND named_places.name = 'Ashton';
+ST_Disjoint(centerlines, boundary)
+1
+SELECT ST_Touches(centerline, shore)
+FROM streams, lakes
+WHERE streams.name = 'Cam Stream'
+AND lakes.name = 'Blue Lake';
+ST_Touches(centerline, shore)
+1
+SELECT Crosses(road_segments.centerline, divided_routes.centerlines)
+FROM road_segments, divided_routes
+WHERE road_segments.fid = 102
+AND divided_routes.name = 'Route 75';
+Crosses(road_segments.centerline, divided_routes.centerlines)
+1
+SELECT ST_Intersects(road_segments.centerline, divided_routes.centerlines)
+FROM road_segments, divided_routes
+WHERE road_segments.fid = 102
+AND divided_routes.name = 'Route 75';
+ST_Intersects(road_segments.centerline, divided_routes.centerlines)
+1
+SELECT ST_Contains(forests.boundary, named_places.boundary)
+FROM forests, named_places
+WHERE forests.name = 'Green Forest'
+AND named_places.name = 'Ashton';
+ST_Contains(forests.boundary, named_places.boundary)
+0
+SELECT ST_Distance(position, boundary)
+FROM bridges, named_places
+WHERE bridges.name = 'Cam Bridge'
+AND named_places.name = 'Ashton';
+ST_Distance(position, boundary)
+12
+SELECT AsText(ST_Difference(named_places.boundary, forests.boundary))
+FROM named_places, forests
+WHERE named_places.name = 'Ashton'
+AND forests.name = 'Green Forest';
+AsText(ST_Difference(named_places.boundary, forests.boundary))
+POLYGON((56 34,62 48,84 48,84 42,56 34))
+SELECT AsText(ST_Union(shore, boundary))
+FROM lakes, named_places
+WHERE lakes.name = 'Blue Lake'
+AND named_places.name = 'Goose Island';
+AsText(ST_Union(shore, boundary))
+POLYGON((48 6,52 18,66 23,73 9,48 6))
+SELECT AsText(ST_SymDifference(shore, boundary))
+FROM lakes, named_places
+WHERE lakes.name = 'Blue Lake'
+AND named_places.name = 'Ashton';
+AsText(ST_SymDifference(shore, boundary))
+MULTIPOLYGON(((48 6,52 18,66 23,73 9,48 6),(59 13,59 18,67 18,67 13,59 13)),((56 30,56 34,62 48,84 48,84 30,56 30)))
+SELECT count(*)
+FROM buildings, bridges
+WHERE ST_Contains(ST_Buffer(bridges.position, 15.0), buildings.footprint) = 1;
+count(*)
+1
+DROP DATABASE gis_ogs;
+USE test;
+DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
+DROP DATABASE IF EXISTS gis_ogs;
+CREATE DATABASE gis_ogs;
+CREATE TABLE gis_point (fid <INT_COLUMN>, g POINT NOT NULL, SPATIAL INDEX(g)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_line (fid <INT_COLUMN>, g LINESTRING NOT NULL, SPATIAL INDEX(g)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_polygon (fid <INT_COLUMN>, g POLYGON NOT NULL, SPATIAL INDEX(g)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_multi_point (fid <INT_COLUMN>, g MULTIPOINT NOT NULL, SPATIAL INDEX(g)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_multi_line (fid <INT_COLUMN>, g MULTILINESTRING NOT NULL, SPATIAL INDEX(g)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_multi_polygon (fid <INT_COLUMN>, g MULTIPOLYGON NOT NULL, SPATIAL INDEX(g)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_geometrycollection (fid <INT_COLUMN>, g GEOMETRYCOLLECTION NOT NULL, SPATIAL INDEX(g)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE gis_geometry (fid <INT_COLUMN>, g GEOMETRY NOT NULL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+USE gis_ogs;
+CREATE TABLE lakes (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+shore POLYGON NOT NULL, SPATIAL INDEX s(shore)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE road_segments (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+aliases CHAR(64) <CUSTOM_COL_OPTIONS>,
+num_lanes INT <CUSTOM_COL_OPTIONS>,
+centerline LINESTRING NOT NULL, SPATIAL INDEX c(centerline)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE divided_routes (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+num_lanes INT <CUSTOM_COL_OPTIONS>,
+centerlines MULTILINESTRING NOT NULL, SPATIAL INDEX c(centerlines)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE forests (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+boundary MULTIPOLYGON NOT NULL, SPATIAL INDEX b(boundary)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE bridges (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+position POINT NOT NULL, SPATIAL INDEX p(position)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE streams (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+centerline LINESTRING NOT NULL, SPATIAL INDEX c(centerline)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE buildings (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+position POINT NOT NULL,
+footprint POLYGON NOT NULL, SPATIAL INDEX p(position), SPATIAL INDEX f(footprint)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE ponds (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+type CHAR(64) <CUSTOM_COL_OPTIONS>,
+shores MULTIPOLYGON NOT NULL, SPATIAL INDEX s(shores)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE named_places (fid INT <CUSTOM_COL_OPTIONS>,
+name CHAR(64) <CUSTOM_COL_OPTIONS>,
+boundary POLYGON NOT NULL, SPATIAL INDEX b(boundary)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+CREATE TABLE map_neatlines (fid INT <CUSTOM_COL_OPTIONS>,
+neatline POLYGON NOT NULL, SPATIAL INDEX n(neatline)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+USE test;
+SHOW FIELDS FROM gis_point;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g point NO MUL NULL
+SHOW FIELDS FROM gis_line;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g linestring NO MUL NULL
+SHOW FIELDS FROM gis_polygon;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g polygon NO MUL NULL
+SHOW FIELDS FROM gis_multi_point;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g multipoint NO MUL NULL
+SHOW FIELDS FROM gis_multi_line;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g multilinestring NO MUL NULL
+SHOW FIELDS FROM gis_multi_polygon;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g multipolygon NO MUL NULL
+SHOW FIELDS FROM gis_geometrycollection;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g geometrycollection NO MUL NULL
+SHOW FIELDS FROM gis_geometry;
+Field Type Null Key Default Extra
+fid int(11) YES NULL
+g geometry NO NULL
+INSERT INTO gis_point (fid,g) VALUES
+(101, PointFromText('POINT(10 10)')),
+(102, PointFromText('POINT(20 10)')),
+(103, PointFromText('POINT(20 20)')),
+(104, PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))));
+INSERT INTO gis_line (fid,g) VALUES
+(105, LineFromText('LINESTRING(0 0,0 10,10 0)')),
+(106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
+(107, LineStringFromWKB(AsWKB(LineString(Point(10, 10), Point(40, 10)))));
+INSERT INTO gis_polygon (fid,g) VALUES
+(108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
+(109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
+(110, PolyFromWKB(AsWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))))));
+INSERT INTO gis_multi_point (fid,g) VALUES
+(111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
+(112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
+(113, MPointFromWKB(AsWKB(MultiPoint(Point(3, 6), Point(4, 10)))));
+INSERT INTO gis_multi_line (fid,g) VALUES
+(114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
+(115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
+(116, MLineFromWKB(AsWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7))))));
+INSERT INTO gis_multi_polygon (fid,g) VALUES
+(117, MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
+(118, MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
+(119, MPolyFromWKB(AsWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))));
+INSERT INTO gis_geometrycollection (fid,g) VALUES
+(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
+(121, GeometryFromWKB(AsWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))))),
+(122, GeomFromText('GeometryCollection()')),
+(123, GeomFromText('GeometryCollection EMPTY'));
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_point;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_line;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_polygon;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_multi_point;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_multi_line;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_multi_polygon;
+INSERT into gis_geometry (fid,g) SELECT fid,g FROM gis_geometrycollection;
+SELECT fid, AsText(g) FROM gis_point;
+fid AsText(g)
+101 POINT(10 10)
+102 POINT(20 10)
+103 POINT(20 20)
+104 POINT(10 20)
+SELECT fid, AsText(g) FROM gis_line;
+fid AsText(g)
+105 LINESTRING(0 0,0 10,10 0)
+106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
+107 LINESTRING(10 10,40 10)
+SELECT fid, AsText(g) FROM gis_polygon;
+fid AsText(g)
+108 POLYGON((10 10,20 10,20 20,10 20,10 10))
+109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
+110 POLYGON((0 0,30 0,30 30,0 0))
+SELECT fid, AsText(g) FROM gis_multi_point;
+fid AsText(g)
+111 MULTIPOINT(0 0,10 10,10 20,20 20)
+112 MULTIPOINT(1 1,11 11,11 21,21 21)
+113 MULTIPOINT(3 6,4 10)
+SELECT fid, AsText(g) FROM gis_multi_line;
+fid AsText(g)
+114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
+115 MULTILINESTRING((10 48,10 21,10 0))
+116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
+SELECT fid, AsText(g) FROM gis_multi_polygon;
+fid AsText(g)
+117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
+118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
+119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
+SELECT fid, AsText(g) FROM gis_geometrycollection;
+fid AsText(g)
+120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
+121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
+122 GEOMETRYCOLLECTION EMPTY
+123 GEOMETRYCOLLECTION EMPTY
+SELECT fid, AsText(g) FROM gis_geometry;
+fid AsText(g)
+101 POINT(10 10)
+102 POINT(20 10)
+103 POINT(20 20)
+104 POINT(10 20)
+105 LINESTRING(0 0,0 10,10 0)
+106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
+107 LINESTRING(10 10,40 10)
+108 POLYGON((10 10,20 10,20 20,10 20,10 10))
+109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
+110 POLYGON((0 0,30 0,30 30,0 0))
+111 MULTIPOINT(0 0,10 10,10 20,20 20)
+112 MULTIPOINT(1 1,11 11,11 21,21 21)
+113 MULTIPOINT(3 6,4 10)
+114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
+115 MULTILINESTRING((10 48,10 21,10 0))
+116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
+117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
+118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
+119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
+120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
+121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
+122 GEOMETRYCOLLECTION EMPTY
+123 GEOMETRYCOLLECTION EMPTY
+SELECT fid, Dimension(g) FROM gis_geometry;
+fid Dimension(g)
+101 0
+102 0
+103 0
+104 0
+105 1
+106 1
+107 1
+108 2
+109 2
+110 2
+111 0
+112 0
+113 0
+114 1
+115 1
+116 1
+117 2
+118 2
+119 2
+120 1
+121 1
+122 0
+123 0
+SELECT fid, GeometryType(g) FROM gis_geometry;
+fid GeometryType(g)
+101 POINT
+102 POINT
+103 POINT
+104 POINT
+105 LINESTRING
+106 LINESTRING
+107 LINESTRING
+108 POLYGON
+109 POLYGON
+110 POLYGON
+111 MULTIPOINT
+112 MULTIPOINT
+113 MULTIPOINT
+114 MULTILINESTRING
+115 MULTILINESTRING
+116 MULTILINESTRING
+117 MULTIPOLYGON
+118 MULTIPOLYGON
+119 MULTIPOLYGON
+120 GEOMETRYCOLLECTION
+121 GEOMETRYCOLLECTION
+122 GEOMETRYCOLLECTION
+123 GEOMETRYCOLLECTION
+SELECT fid, IsEmpty(g) FROM gis_geometry;
+fid IsEmpty(g)
+101 0
+102 0
+103 0
+104 0
+105 0
+106 0
+107 0
+108 0
+109 0
+110 0
+111 0
+112 0
+113 0
+114 0
+115 0
+116 0
+117 0
+118 0
+119 0
+120 0
+121 0
+122 0
+123 0
+SELECT fid, AsText(Envelope(g)) FROM gis_geometry;
+fid AsText(Envelope(g))
+101 POLYGON((10 10,10 10,10 10,10 10,10 10))
+102 POLYGON((20 10,20 10,20 10,20 10,20 10))
+103 POLYGON((20 20,20 20,20 20,20 20,20 20))
+104 POLYGON((10 20,10 20,10 20,10 20,10 20))
+105 POLYGON((0 0,10 0,10 10,0 10,0 0))
+106 POLYGON((10 10,20 10,20 20,10 20,10 10))
+107 POLYGON((10 10,40 10,40 10,10 10,10 10))
+108 POLYGON((10 10,20 10,20 20,10 20,10 10))
+109 POLYGON((0 0,50 0,50 50,0 50,0 0))
+110 POLYGON((0 0,30 0,30 30,0 30,0 0))
+111 POLYGON((0 0,20 0,20 20,0 20,0 0))
+112 POLYGON((1 1,21 1,21 21,1 21,1 1))
+113 POLYGON((3 6,4 6,4 10,3 10,3 6))
+114 POLYGON((10 0,16 0,16 48,10 48,10 0))
+115 POLYGON((10 0,10 0,10 48,10 48,10 0))
+116 POLYGON((1 2,21 2,21 8,1 8,1 2))
+117 POLYGON((28 0,84 0,84 42,28 42,28 0))
+118 POLYGON((28 0,84 0,84 42,28 42,28 0))
+119 POLYGON((0 0,3 0,3 3,0 3,0 0))
+120 POLYGON((0 0,10 0,10 10,0 10,0 0))
+121 POLYGON((3 6,44 6,44 9,3 9,3 6))
+122 GEOMETRYCOLLECTION EMPTY
+123 GEOMETRYCOLLECTION EMPTY
+SELECT fid, X(g) FROM gis_point;
+fid X(g)
+101 10
+102 20
+103 20
+104 10
+SELECT fid, Y(g) FROM gis_point;
+fid Y(g)
+101 10
+102 10
+103 20
+104 20
+SELECT fid, AsText(StartPoint(g)) FROM gis_line;
+fid AsText(StartPoint(g))
+105 POINT(0 0)
+106 POINT(10 10)
+107 POINT(10 10)
+SELECT fid, AsText(EndPoint(g)) FROM gis_line;
+fid AsText(EndPoint(g))
+105 POINT(10 0)
+106 POINT(10 10)
+107 POINT(40 10)
+SELECT fid, GLength(g) FROM gis_line;
+fid GLength(g)
+105 24.14213562373095
+106 40
+107 30
+SELECT fid, NumPoints(g) FROM gis_line;
+fid NumPoints(g)
+105 3
+106 5
+107 2
+SELECT fid, AsText(PointN(g, 2)) FROM gis_line;
+fid AsText(PointN(g, 2))
+105 POINT(0 10)
+106 POINT(20 10)
+107 POINT(40 10)
+SELECT fid, IsClosed(g) FROM gis_line;
+fid IsClosed(g)
+105 0
+106 1
+107 0
+SELECT fid, AsText(Centroid(g)) FROM gis_polygon;
+fid AsText(Centroid(g))
+108 POINT(15 15)
+109 POINT(25.416666666666668 25.416666666666668)
+110 POINT(20 10)
+SELECT fid, Area(g) FROM gis_polygon;
+fid Area(g)
+108 100
+109 2400
+110 450
+SELECT fid, AsText(ExteriorRing(g)) FROM gis_polygon;
+fid AsText(ExteriorRing(g))
+108 LINESTRING(10 10,20 10,20 20,10 20,10 10)
+109 LINESTRING(0 0,50 0,50 50,0 50,0 0)
+110 LINESTRING(0 0,30 0,30 30,0 0)
+SELECT fid, NumInteriorRings(g) FROM gis_polygon;
+fid NumInteriorRings(g)
+108 0
+109 1
+110 0
+SELECT fid, AsText(InteriorRingN(g, 1)) FROM gis_polygon;
+fid AsText(InteriorRingN(g, 1))
+108 NULL
+109 LINESTRING(10 10,20 10,20 20,10 20,10 10)
+110 NULL
+SELECT fid, IsClosed(g) FROM gis_multi_line;
+fid IsClosed(g)
+114 0
+115 0
+116 0
+SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon;
+fid AsText(Centroid(g))
+117 POINT(57.98031067576927 17.854754130800433)
+118 POINT(57.98031067576927 17.854754130800433)
+119 POINT(2 2)
+SELECT fid, Area(g) FROM gis_multi_polygon;
+fid Area(g)
+117 1684.5
+118 1684.5
+119 4.5
+SELECT fid, NumGeometries(g) from gis_multi_point;
+fid NumGeometries(g)
+111 4
+112 4
+113 2
+SELECT fid, NumGeometries(g) from gis_multi_line;
+fid NumGeometries(g)
+114 2
+115 1
+116 2
+SELECT fid, NumGeometries(g) from gis_multi_polygon;
+fid NumGeometries(g)
+117 2
+118 2
+119 1
+SELECT fid, NumGeometries(g) from gis_geometrycollection;
+fid NumGeometries(g)
+120 2
+121 2
+122 0
+123 0
+SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point;
+fid AsText(GeometryN(g, 2))
+111 POINT(10 10)
+112 POINT(11 11)
+113 POINT(4 10)
+SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_line;
+fid AsText(GeometryN(g, 2))
+114 LINESTRING(16 0,16 23,16 48)
+115 NULL
+116 LINESTRING(2 5,5 8,21 7)
+SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_polygon;
+fid AsText(GeometryN(g, 2))
+117 POLYGON((59 18,67 18,67 13,59 13,59 18))
+118 POLYGON((59 18,67 18,67 13,59 13,59 18))
+119 NULL
+SELECT fid, AsText(GeometryN(g, 2)) from gis_geometrycollection;
+fid AsText(GeometryN(g, 2))
+120 LINESTRING(0 0,10 10)
+121 LINESTRING(3 6,7 9)
+122 NULL
+123 NULL
+SELECT fid, AsText(GeometryN(g, 1)) from gis_geometrycollection;
+fid AsText(GeometryN(g, 1))
+120 POINT(0 0)
+121 POINT(44 6)
+122 NULL
+123 NULL
+SELECT g1.fid as first, g2.fid as second,
+Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
+Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
+Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
+FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
+first second w c o e d t i r
+120 120 1 1 0 1 0 0 1 0
+120 121 0 0 1 0 0 0 1 0
+120 122 NULL NULL NULL NULL NULL NULL NULL NULL
+120 123 NULL NULL NULL NULL NULL NULL NULL NULL
+121 120 0 0 1 0 0 0 1 0
+121 121 1 1 0 1 0 0 1 0
+121 122 NULL NULL NULL NULL NULL NULL NULL NULL
+121 123 NULL NULL NULL NULL NULL NULL NULL NULL
+122 120 NULL NULL NULL NULL NULL NULL NULL NULL
+122 121 NULL NULL NULL NULL NULL NULL NULL NULL
+122 122 NULL NULL NULL NULL NULL NULL NULL NULL
+122 123 NULL NULL NULL NULL NULL NULL NULL NULL
+123 120 NULL NULL NULL NULL NULL NULL NULL NULL
+123 121 NULL NULL NULL NULL NULL NULL NULL NULL
+123 122 NULL NULL NULL NULL NULL NULL NULL NULL
+123 123 NULL NULL NULL NULL NULL NULL NULL NULL
+DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
+USE gis_ogs;
+# Lakes
+INSERT INTO lakes (fid,name,shore) VALUES (
+101, 'BLUE LAKE',
+PolyFromText(
+'POLYGON(
+ (52 18,66 23,73 9,48 6,52 18),
+ (59 18,67 18,67 13,59 13,59 18)
+ )',
+101));
+# Road Segments
+INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(102, 'Route 5', NULL, 2,
+LineFromText(
+'LINESTRING( 0 18, 10 21, 16 23, 28 26, 44 31 )' ,101));
+INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(103, 'Route 5', 'Main Street', 4,
+LineFromText(
+'LINESTRING( 44 31, 56 34, 70 38 )' ,101));
+INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(104, 'Route 5', NULL, 2,
+LineFromText(
+'LINESTRING( 70 38, 72 48 )' ,101));
+INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(105, 'Main Street', NULL, 4,
+LineFromText(
+'LINESTRING( 70 38, 84 42 )' ,101));
+INSERT INTO road_segments (fid,name,aliases,num_lanes,centerline) VALUES(106, 'Dirt Road by Green Forest', NULL,
+1,
+LineFromText(
+'LINESTRING( 28 26, 28 0 )',101));
+# DividedRoutes
+INSERT INTO divided_routes (fid,name,num_lanes,centerlines) VALUES(119, 'Route 75', 4,
+MLineFromText(
+'MULTILINESTRING((10 48,10 21,10 0),
+ (16 0,16 23,16 48))', 101));
+# Forests
+INSERT INTO forests (fid,name,boundary) VALUES(109, 'Green Forest',
+MPolyFromText(
+'MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),
+ (52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))',
+101));
+# Bridges
+INSERT INTO bridges (fid,name,position) VALUES(110, 'Cam Bridge', PointFromText(
+'POINT( 44 31 )', 101));
+# Streams
+INSERT INTO streams (fid,name,centerline) VALUES(111, 'Cam Stream',
+LineFromText(
+'LINESTRING( 38 48, 44 41, 41 36, 44 31, 52 18 )', 101));
+INSERT INTO streams (fid,name,centerline) VALUES(112, NULL,
+LineFromText(
+'LINESTRING( 76 0, 78 4, 73 9 )', 101));
+# Buildings
+INSERT INTO buildings (fid,name,position,footprint) VALUES(113, '123 Main Street',
+PointFromText(
+'POINT( 52 30 )', 101),
+PolyFromText(
+'POLYGON( ( 50 31, 54 31, 54 29, 50 29, 50 31) )', 101));
+INSERT INTO buildings (fid,name,position,footprint) VALUES(114, '215 Main Street',
+PointFromText(
+'POINT( 64 33 )', 101),
+PolyFromText(
+'POLYGON( ( 66 34, 62 34, 62 32, 66 32, 66 34) )', 101));
+# Ponds
+INSERT INTO ponds (fid,name,type,shores) VALUES(120, NULL, 'Stock Pond',
+MPolyFromText(
+'MULTIPOLYGON( ( ( 24 44, 22 42, 24 40, 24 44) ),
+ ( ( 26 44, 26 40, 28 42, 26 44) ) )', 101));
+# Named Places
+INSERT INTO named_places (fid,name,boundary) VALUES(117, 'Ashton',
+PolyFromText(
+'POLYGON( ( 62 48, 84 48, 84 30, 56 30, 56 34, 62 48) )', 101));
+INSERT INTO named_places (fid,name,boundary) VALUES(118, 'Goose Island',
+PolyFromText(
+'POLYGON( ( 67 13, 67 18, 59 18, 59 13, 67 13) )', 101));
+# Map Neatlines
+INSERT INTO map_neatlines (fid,neatline) VALUES(115,
+PolyFromText(
+'POLYGON( ( 0 0, 0 48, 84 48, 84 0, 0 0 ) )', 101));
+SELECT Dimension(shore)
+FROM lakes
+WHERE name = 'Blue Lake';
+Dimension(shore)
+2
+SELECT GeometryType(centerlines)
+FROM divided_routes
+WHERE name = 'Route 75';
+GeometryType(centerlines)
+MULTILINESTRING
+SELECT AsText(boundary)
+FROM named_places
+WHERE name = 'Goose Island';
+AsText(boundary)
+POLYGON((67 13,67 18,59 18,59 13,67 13))
+SELECT AsText(PolyFromWKB(AsBinary(boundary),101))
+FROM named_places
+WHERE name = 'Goose Island';
+AsText(PolyFromWKB(AsBinary(boundary),101))
+POLYGON((67 13,67 18,59 18,59 13,67 13))
+SELECT SRID(boundary)
+FROM named_places
+WHERE name = 'Goose Island';
+SRID(boundary)
+101
+SELECT IsEmpty(centerline)
+FROM road_segments
+WHERE name = 'Route 5'
+AND aliases = 'Main Street';
+IsEmpty(centerline)
+0
+SELECT AsText(Envelope(boundary))
+FROM named_places
+WHERE name = 'Goose Island';
+AsText(Envelope(boundary))
+POLYGON((59 13,67 13,67 18,59 18,59 13))
+SELECT X(position)
+FROM bridges
+WHERE name = 'Cam Bridge';
+X(position)
+44
+SELECT Y(position)
+FROM bridges
+WHERE name = 'Cam Bridge';
+Y(position)
+31
+SELECT AsText(StartPoint(centerline))
+FROM road_segments
+WHERE fid = 102;
+AsText(StartPoint(centerline))
+POINT(0 18)
+SELECT AsText(EndPoint(centerline))
+FROM road_segments
+WHERE fid = 102;
+AsText(EndPoint(centerline))
+POINT(44 31)
+SELECT GLength(centerline)
+FROM road_segments
+WHERE fid = 106;
+GLength(centerline)
+26
+SELECT NumPoints(centerline)
+FROM road_segments
+WHERE fid = 102;
+NumPoints(centerline)
+5
+SELECT AsText(PointN(centerline, 1))
+FROM road_segments
+WHERE fid = 102;
+AsText(PointN(centerline, 1))
+POINT(0 18)
+SELECT AsText(Centroid(boundary))
+FROM named_places
+WHERE name = 'Goose Island';
+AsText(Centroid(boundary))
+POINT(63 15.5)
+SELECT Area(boundary)
+FROM named_places
+WHERE name = 'Goose Island';
+Area(boundary)
+40
+SELECT AsText(ExteriorRing(shore))
+FROM lakes
+WHERE name = 'Blue Lake';
+AsText(ExteriorRing(shore))
+LINESTRING(52 18,66 23,73 9,48 6,52 18)
+SELECT NumInteriorRings(shore)
+FROM lakes
+WHERE name = 'Blue Lake';
+NumInteriorRings(shore)
+1
+SELECT AsText(InteriorRingN(shore, 1))
+FROM lakes
+WHERE name = 'Blue Lake';
+AsText(InteriorRingN(shore, 1))
+LINESTRING(59 18,67 18,67 13,59 13,59 18)
+SELECT NumGeometries(centerlines)
+FROM divided_routes
+WHERE name = 'Route 75';
+NumGeometries(centerlines)
+2
+SELECT AsText(GeometryN(centerlines, 2))
+FROM divided_routes
+WHERE name = 'Route 75';
+AsText(GeometryN(centerlines, 2))
+LINESTRING(16 0,16 23,16 48)
+SELECT IsClosed(centerlines)
+FROM divided_routes
+WHERE name = 'Route 75';
+IsClosed(centerlines)
+0
+SELECT GLength(centerlines)
+FROM divided_routes
+WHERE name = 'Route 75';
+GLength(centerlines)
+96
+SELECT AsText(Centroid(shores))
+FROM ponds
+WHERE fid = 120;
+AsText(Centroid(shores))
+POINT(25 42)
+SELECT Area(shores)
+FROM ponds
+WHERE fid = 120;
+Area(shores)
+8
+SELECT ST_Equals(boundary,
+PolyFromText('POLYGON( ( 67 13, 67 18, 59 18, 59 13, 67 13) )',1))
+FROM named_places
+WHERE name = 'Goose Island';
+ST_Equals(boundary,
+PolyFromText('POLYGON( ( 67 13, 67 18, 59 18, 59 13, 67 13) )',1))
+1
+SELECT ST_Disjoint(centerlines, boundary)
+FROM divided_routes, named_places
+WHERE divided_routes.name = 'Route 75'
+AND named_places.name = 'Ashton';
+ST_Disjoint(centerlines, boundary)
+1
+SELECT ST_Touches(centerline, shore)
+FROM streams, lakes
+WHERE streams.name = 'Cam Stream'
+AND lakes.name = 'Blue Lake';
+ST_Touches(centerline, shore)
+1
+SELECT Crosses(road_segments.centerline, divided_routes.centerlines)
+FROM road_segments, divided_routes
+WHERE road_segments.fid = 102
+AND divided_routes.name = 'Route 75';
+Crosses(road_segments.centerline, divided_routes.centerlines)
+1
+SELECT ST_Intersects(road_segments.centerline, divided_routes.centerlines)
+FROM road_segments, divided_routes
+WHERE road_segments.fid = 102
+AND divided_routes.name = 'Route 75';
+ST_Intersects(road_segments.centerline, divided_routes.centerlines)
+1
+SELECT ST_Contains(forests.boundary, named_places.boundary)
+FROM forests, named_places
+WHERE forests.name = 'Green Forest'
+AND named_places.name = 'Ashton';
+ST_Contains(forests.boundary, named_places.boundary)
+0
+SELECT ST_Distance(position, boundary)
+FROM bridges, named_places
+WHERE bridges.name = 'Cam Bridge'
+AND named_places.name = 'Ashton';
+ST_Distance(position, boundary)
+12
+SELECT AsText(ST_Difference(named_places.boundary, forests.boundary))
+FROM named_places, forests
+WHERE named_places.name = 'Ashton'
+AND forests.name = 'Green Forest';
+AsText(ST_Difference(named_places.boundary, forests.boundary))
+POLYGON((56 34,62 48,84 48,84 42,56 34))
+SELECT AsText(ST_Union(shore, boundary))
+FROM lakes, named_places
+WHERE lakes.name = 'Blue Lake'
+AND named_places.name = 'Goose Island';
+AsText(ST_Union(shore, boundary))
+POLYGON((48 6,52 18,66 23,73 9,48 6))
+SELECT AsText(ST_SymDifference(shore, boundary))
+FROM lakes, named_places
+WHERE lakes.name = 'Blue Lake'
+AND named_places.name = 'Ashton';
+AsText(ST_SymDifference(shore, boundary))
+MULTIPOLYGON(((48 6,52 18,66 23,73 9,48 6),(59 13,59 18,67 18,67 13,59 13)),((56 30,56 34,62 48,84 48,84 30,56 30)))
+SELECT count(*)
+FROM buildings, bridges
+WHERE ST_Contains(ST_Buffer(bridges.position, 15.0), buildings.footprint) = 1;
+count(*)
+1
+DROP DATABASE gis_ogs;
+USE test;
diff --git a/mysql-test/suite/storage_engine/type_spatial_indexes.test b/mysql-test/suite/storage_engine/type_spatial_indexes.test
new file mode 100644
index 00000000..ae9fc592
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_spatial_indexes.test
@@ -0,0 +1,15 @@
+#
+# Indexes on spatial objects
+# (spatial and non-spatial indexes)
+#
+
+--source have_engine.inc
+
+--let $index = $default_index
+--source type_spatial.inc
+
+let $index = SPATIAL;
+--source type_spatial.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_text.inc b/mysql-test/suite/storage_engine/type_text.inc
new file mode 100644
index 00000000..86521e5f
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_text.inc
@@ -0,0 +1,65 @@
+#
+# TEXT column types
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $create_definition =
+ t TEXT $col_opts,
+ t0 TEXT(0) $col_opts,
+ t1 TEXT(1) $col_opts,
+ t300 TEXT(300) $col_opts,
+ tm TEXT(65535) $col_opts,
+ t70k TEXT(70000) $col_opts,
+ t17m TEXT(17000000) $col_opts,
+ tt TINYTEXT $col_opts,
+ m MEDIUMTEXT $col_opts,
+ l LONGTEXT $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = TEXT types
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+
+ # Valid values
+ # (cannot get MAX for all columns due to max_allowed_packet limitations)
+
+ INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
+ ('','','','','','','','','',''),
+ ('a','b','c','d','e','f','g','h','i','j'),
+ ('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
+ ( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',255), REPEAT('i',1048576), REPEAT('j',1048576) );
+
+ --sorted_result
+ SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
+
+ # Invalid values (produce warnings, except for mediumtext and longtext columns for which the values are within limits)
+
+ INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
+ ( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
+
+ --sorted_result
+ SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
+
+ --let $error_codes = ER_TOO_BIG_DISPLAYWIDTH
+ --let $alter_definition = ADD COLUMN ttt TEXT(4294967296)
+ --source alter_table.inc
+ if ($mysql_errname != ER_TOO_BIG_DISPLAYWIDTH)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE
+ --source unexpected_result.inc
+ }
+ DROP TABLE t1;
+}
+
+
diff --git a/mysql-test/suite/storage_engine/type_text.result b/mysql-test/suite/storage_engine/type_text.result
new file mode 100644
index 00000000..88204e22
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_text.result
@@ -0,0 +1,54 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (t TEXT <CUSTOM_COL_OPTIONS>,
+t0 TEXT(0) <CUSTOM_COL_OPTIONS>,
+t1 TEXT(1) <CUSTOM_COL_OPTIONS>,
+t300 TEXT(300) <CUSTOM_COL_OPTIONS>,
+tm TEXT(65535) <CUSTOM_COL_OPTIONS>,
+t70k TEXT(70000) <CUSTOM_COL_OPTIONS>,
+t17m TEXT(17000000) <CUSTOM_COL_OPTIONS>,
+tt TINYTEXT <CUSTOM_COL_OPTIONS>,
+m MEDIUMTEXT <CUSTOM_COL_OPTIONS>,
+l LONGTEXT <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+t text # # #
+t0 text # # #
+t1 tinytext # # #
+t300 text # # #
+tm text # # #
+t70k mediumtext # # #
+t17m longtext # # #
+tt tinytext # # #
+m mediumtext # # #
+l longtext # # #
+INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
+('','','','','','','','','',''),
+('a','b','c','d','e','f','g','h','i','j'),
+('test1','test2','test3','test4','test5','test6','test7','test8','test9','test10'),
+( REPEAT('a',65535), REPEAT('b',65535), REPEAT('c',255), REPEAT('d',65535), REPEAT('e',65535), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',255), REPEAT('i',1048576), REPEAT('j',1048576) );
+SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(t) LENGTH(t0) LENGTH(t1) LENGTH(t300) LENGTH(tm) LENGTH(t70k) LENGTH(t17m) LENGTH(tt) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+INSERT INTO t1 (t,t0,t1,t300,tm,t70k,t17m,tt,m,l) VALUES
+( REPEAT('a',65536), REPEAT('b',65536), REPEAT('c',256), REPEAT('d',65536), REPEAT('e',65536), REPEAT('f',1048576), REPEAT('g',1048576), REPEAT('h',256), REPEAT('i',1048576), REPEAT('j',1048576) );
+Warnings:
+Warning 1265 Data truncated for column 't' at row 1
+Warning 1265 Data truncated for column 't0' at row 1
+Warning 1265 Data truncated for column 't1' at row 1
+Warning 1265 Data truncated for column 't300' at row 1
+Warning 1265 Data truncated for column 'tm' at row 1
+Warning 1265 Data truncated for column 'tt' at row 1
+SELECT LENGTH(t), LENGTH(t0), LENGTH(t1), LENGTH(t300), LENGTH(tm), LENGTH(t70k), LENGTH(t17m), LENGTH(tt), LENGTH(m), LENGTH(l) FROM t1;
+LENGTH(t) LENGTH(t0) LENGTH(t1) LENGTH(t300) LENGTH(tm) LENGTH(t70k) LENGTH(t17m) LENGTH(tt) LENGTH(m) LENGTH(l)
+0 0 0 0 0 0 0 0 0 0
+1 1 1 1 1 1 1 1 1 1
+5 5 5 5 5 5 5 5 5 6
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+65535 65535 255 65535 65535 1048576 1048576 255 1048576 1048576
+ALTER TABLE t1 ADD COLUMN ttt TEXT(4294967296);
+ERROR 42000: Display width out of range for 'ttt' (max = 4294967295)
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_text.test b/mysql-test/suite/storage_engine/type_text.test
new file mode 100644
index 00000000..63e71019
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_text.test
@@ -0,0 +1,10 @@
+#
+# TEXT column types
+#
+
+--source have_engine.inc
+
+--source type_text.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_text_indexes.result b/mysql-test/suite/storage_engine/type_text_indexes.result
new file mode 100644
index 00000000..a23373e2
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_text_indexes.result
@@ -0,0 +1,137 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (t TEXT <CUSTOM_COL_OPTIONS>,
+tt TINYTEXT <CUSTOM_COL_OPTIONS>,
+m MEDIUMTEXT <CUSTOM_COL_OPTIONS>,
+l LONGTEXT <CUSTOM_COL_OPTIONS>,
+<CUSTOM_INDEX> t (t(32))
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 # 1 t # # 32 NULL # #
+INSERT INTO t1 (t,tt,m,l) VALUES
+('','','',''),
+('a','b','c','d'),
+('b','d','c','b'),
+('test1','test2','test3','test4'),
+(REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
+('abc','def','ghi','jkl'),
+('test2','test3','test4','test5'),
+('test3','test4','test5','test6'),
+(REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
+(REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));
+SELECT SUBSTRING(t,16) AS f FROM t1 WHERE t IN ('test1','test2') ORDER BY f;
+f
+
+
+DROP TABLE t1;
+CREATE TABLE t1 (t TEXT <CUSTOM_COL_OPTIONS>,
+tt TINYTEXT <CUSTOM_COL_OPTIONS>,
+m MEDIUMTEXT <CUSTOM_COL_OPTIONS>,
+l LONGTEXT <CUSTOM_COL_OPTIONS>,
+PRIMARY KEY t (t(32))
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 PRIMARY 1 t # # 32 NULL # #
+INSERT INTO t1 (t,tt,m,l) VALUES
+('','','',''),
+('a','b','c','d'),
+('b','d','c','b'),
+('test1','test2','test3','test4'),
+(REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
+('abc','def','ghi','jkl'),
+('test2','test3','test4','test5'),
+('test3','test4','test5','test6'),
+(REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
+(REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));
+EXPLAIN SELECT SUBSTRING(t,16) AS f FROM t1 WHERE t IN ('test1','test2') ORDER BY f;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # PRIMARY # # # #
+SELECT SUBSTRING(t,16) AS f FROM t1 WHERE t IN ('test1','test2') ORDER BY f;
+f
+
+
+EXPLAIN SELECT SUBSTRING(t,16) AS f FROM t1 IGNORE INDEX (PRIMARY) WHERE t IN ('test1','test2') ORDER BY f;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # NULL # # # #
+SELECT SUBSTRING(t,16) AS f FROM t1 IGNORE INDEX (PRIMARY) WHERE t IN ('test1','test2') ORDER BY f;
+f
+
+
+DROP TABLE t1;
+CREATE TABLE t1 (t TEXT <CUSTOM_COL_OPTIONS>,
+tt TINYTEXT <CUSTOM_COL_OPTIONS>,
+m MEDIUMTEXT <CUSTOM_COL_OPTIONS>,
+l LONGTEXT <CUSTOM_COL_OPTIONS>,
+UNIQUE INDEX l_tt (l(256),tt(64))
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 0 l_tt 1 l # # 256 NULL # #
+t1 0 l_tt 2 tt # # 64 NULL # #
+INSERT INTO t1 (t,tt,m,l) VALUES
+('','','',''),
+('a','b','c','d'),
+('b','d','c','b'),
+('test1','test2','test3','test4'),
+(REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
+('abc','def','ghi','jkl'),
+('test2','test3','test4','test5'),
+('test3','test4','test5','test6'),
+(REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
+(REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));
+EXPLAIN SELECT SUBSTRING(tt,64), SUBSTRING(l,256) FROM t1 WHERE tt!=l AND l NOT IN ('test1') ORDER BY tt, l DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # l_tt # # # # #
+SELECT SUBSTRING(tt,64), SUBSTRING(l,256) FROM t1 WHERE tt!=l AND l NOT IN ('test1') ORDER BY tt, l DESC;
+SUBSTRING(tt,64) SUBSTRING(l,256)
+
+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+
+
+fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+
+
+
+EXPLAIN SELECT SUBSTRING(tt,64), SUBSTRING(l,256) FROM t1 FORCE INDEX (l_t) WHERE tt!=l AND l NOT IN ('test1') ORDER BY tt, l DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # l_tt l_tt # # # #
+SELECT SUBSTRING(tt,64), SUBSTRING(l,256) FROM t1 FORCE INDEX (l_t) WHERE tt!=l AND l NOT IN ('test1') ORDER BY tt, l DESC;
+SUBSTRING(tt,64) SUBSTRING(l,256)
+
+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+
+
+fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
+
+
+
+DROP TABLE t1;
+CREATE TABLE t1 (t TEXT <CUSTOM_COL_OPTIONS>,
+tt TINYTEXT <CUSTOM_COL_OPTIONS>,
+m MEDIUMTEXT <CUSTOM_COL_OPTIONS>,
+l LONGTEXT <CUSTOM_COL_OPTIONS>,
+INDEX (m(128))
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW INDEX IN t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
+t1 1 m 1 m # # 128 NULL # #
+INSERT INTO t1 (t,tt,m,l) VALUES
+('','','',''),
+('a','b','c','d'),
+('b','d','c','b'),
+('test1','test2','test3','test4'),
+(REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
+('abc','def','ghi','jkl'),
+('test2','test3','test4','test5'),
+('test3','test4','test5','test6'),
+(REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
+(REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));
+EXPLAIN SELECT SUBSTRING(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;
+id select_type table type possible_keys key key_len ref rows Extra
+# # # # # m # # # #
+SELECT SUBSTRING(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;
+f
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/type_text_indexes.test b/mysql-test/suite/storage_engine/type_text_indexes.test
new file mode 100644
index 00000000..091717f5
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_text_indexes.test
@@ -0,0 +1,175 @@
+#
+# TEXT columns with indexes
+#
+
+--source have_engine.inc
+--source have_default_index.inc
+
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+# Default index as configured in define_engine
+
+let $create_definition =
+ t TEXT $col_indexed_opts,
+ tt TINYTEXT $col_opts,
+ m MEDIUMTEXT $col_opts,
+ l LONGTEXT $col_opts,
+ $default_index t (t(32))
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = TEXT types or indexes on them
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (t,tt,m,l) VALUES
+ ('','','',''),
+ ('a','b','c','d'),
+ ('b','d','c','b'),
+ ('test1','test2','test3','test4'),
+ (REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
+ ('abc','def','ghi','jkl'),
+ ('test2','test3','test4','test5'),
+ ('test3','test4','test5','test6'),
+ (REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
+ (REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));
+
+ SELECT SUBSTRING(t,16) AS f FROM t1 WHERE t IN ('test1','test2') ORDER BY f;
+
+ DROP TABLE t1;
+}
+
+# PK, UNIQUE INDEX, INDEX
+
+let $create_definition =
+ t TEXT $col_indexed_opts,
+ tt TINYTEXT $col_opts,
+ m MEDIUMTEXT $col_opts,
+ l LONGTEXT $col_opts,
+ PRIMARY KEY t (t(32))
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = TEXT types or PK
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (t,tt,m,l) VALUES
+ ('','','',''),
+ ('a','b','c','d'),
+ ('b','d','c','b'),
+ ('test1','test2','test3','test4'),
+ (REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
+ ('abc','def','ghi','jkl'),
+ ('test2','test3','test4','test5'),
+ ('test3','test4','test5','test6'),
+ (REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
+ (REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT SUBSTRING(t,16) AS f FROM t1 WHERE t IN ('test1','test2') ORDER BY f;
+ SELECT SUBSTRING(t,16) AS f FROM t1 WHERE t IN ('test1','test2') ORDER BY f;
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT SUBSTRING(t,16) AS f FROM t1 IGNORE INDEX (PRIMARY) WHERE t IN ('test1','test2') ORDER BY f;
+ SELECT SUBSTRING(t,16) AS f FROM t1 IGNORE INDEX (PRIMARY) WHERE t IN ('test1','test2') ORDER BY f;
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ t TEXT $col_opts,
+ tt TINYTEXT $col_indexed_opts,
+ m MEDIUMTEXT $col_opts,
+ l LONGTEXT $col_indexed_opts,
+ UNIQUE INDEX l_tt (l(256),tt(64))
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = TEXT types or unique keys or multi-part keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (t,tt,m,l) VALUES
+ ('','','',''),
+ ('a','b','c','d'),
+ ('b','d','c','b'),
+ ('test1','test2','test3','test4'),
+ (REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
+ ('abc','def','ghi','jkl'),
+ ('test2','test3','test4','test5'),
+ ('test3','test4','test5','test6'),
+ (REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
+ (REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));
+
+ # Here we are getting possible key l_t, but not the final key
+ --replace_column 1 # 2 # 3 # 4 # 6 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT SUBSTRING(tt,64), SUBSTRING(l,256) FROM t1 WHERE tt!=l AND l NOT IN ('test1') ORDER BY tt, l DESC;
+ SELECT SUBSTRING(tt,64), SUBSTRING(l,256) FROM t1 WHERE tt!=l AND l NOT IN ('test1') ORDER BY tt, l DESC;
+
+ --replace_column 1 # 2 # 3 # 4 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT SUBSTRING(tt,64), SUBSTRING(l,256) FROM t1 FORCE INDEX (l_t) WHERE tt!=l AND l NOT IN ('test1') ORDER BY tt, l DESC;
+ SELECT SUBSTRING(tt,64), SUBSTRING(l,256) FROM t1 FORCE INDEX (l_t) WHERE tt!=l AND l NOT IN ('test1') ORDER BY tt, l DESC;
+ DROP TABLE t1;
+}
+
+let $create_definition =
+ t TEXT $col_opts,
+ tt TINYTEXT $col_opts,
+ m MEDIUMTEXT $col_indexed_opts,
+ l LONGTEXT $col_opts,
+ INDEX (m(128))
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = TEXT types or non-unique keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 6 # 7 # 10 # 11 #
+ SHOW INDEX IN t1;
+
+ INSERT INTO t1 (t,tt,m,l) VALUES
+ ('','','',''),
+ ('a','b','c','d'),
+ ('b','d','c','b'),
+ ('test1','test2','test3','test4'),
+ (REPEAT('a',128),REPEAT('b',128),REPEAT('c',128),REPEAT('d',128)),
+ ('abc','def','ghi','jkl'),
+ ('test2','test3','test4','test5'),
+ ('test3','test4','test5','test6'),
+ (REPEAT('b',128),REPEAT('f',128),REPEAT('e',128),REPEAT('d',128)),
+ (REPEAT('c',128),REPEAT('b',128),REPEAT('c',128),REPEAT('e',128));
+
+ --replace_column 1 # 2 # 3 # 4 # 5 # 7 # 8 # 9 # 10 #
+ EXPLAIN SELECT SUBSTRING(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;
+ SELECT SUBSTRING(m,128) AS f FROM t1 WHERE m = 'test1' ORDER BY f DESC;
+
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_varbinary.inc b/mysql-test/suite/storage_engine/type_varbinary.inc
new file mode 100644
index 00000000..5801f228
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_varbinary.inc
@@ -0,0 +1,101 @@
+#
+# VARBINARY column types
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+let $create_definition =
+ v0 VARBINARY(0) $col_opts,
+ v1 VARBINARY(1) $col_opts,
+ v64 VARBINARY(64) $col_opts,
+ v65000 VARBINARY(65000) $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = VARBINARY types
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+
+ --let $create_definition = v VARBINARY(65532) $col_opts
+ --let $table_name = t2
+ --source create_table.inc
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t2;
+
+ # Valid values
+
+ INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
+ INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
+
+ --sorted_result
+ SELECT HEX(v0), HEX(v1), HEX(v64), HEX(v65000) FROM t1;
+
+ # Invalid values
+
+ INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
+ INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, v65000, CONCAT(v65000,v1) FROM t1;
+
+ --sorted_result
+ SELECT HEX(v0), HEX(v1), HEX(v64), LENGTH(HEX(v65000)) FROM t1;
+
+ --let $alter_definition = ADD COLUMN v65536 VARBINARY(65536) $col_opts
+ --source alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE or BLOB types
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+ }
+
+ DROP TABLE t1, t2;
+}
+
+
diff --git a/mysql-test/suite/storage_engine/type_varbinary.result b/mysql-test/suite/storage_engine/type_varbinary.result
new file mode 100644
index 00000000..41a66619
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_varbinary.result
@@ -0,0 +1,91 @@
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (v0 VARBINARY(0) <CUSTOM_COL_OPTIONS>,
+v1 VARBINARY(1) <CUSTOM_COL_OPTIONS>,
+v64 VARBINARY(64) <CUSTOM_COL_OPTIONS>,
+v65000 VARBINARY(65000) <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varbinary(0) # # #
+v1 varbinary(1) # # #
+v64 varbinary(64) # # #
+v65000 varbinary(65000) # # #
+CREATE TABLE t2 (v VARBINARY(65532) <CUSTOM_COL_OPTIONS>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t2;
+Field Type Null Key Default Extra
+v varbinary(65532) # # #
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
+SELECT HEX(v0), HEX(v1), HEX(v64), HEX(v65000) FROM t1;
+HEX(v0) HEX(v1) HEX(v64) HEX(v65000)
+
+ 79 4F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C7265616479206578697374 486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E2057652776652070726F7669646564206C696E6B7320746F20416D617A6F6E2E636F6D206865726520666F7220636F6E76656E69656E63652C2062757420746865792063616E20626520666F756E64206174206D616E79206F7468657220626F6F6B73746F7265732C20626F7468206F6E6C696E6520616E64206F66662E0A0A2020496620796F752077616E7420746F206861766520796F7572206661766F72697465204D7953514C202F204D61726961444220626F6F6B206C697374656420686572652C20706C65617365206C65617665206120636F6D6D656E742E0A2020466F7220646576656C6F706572732077686F2077616E7420746F20636F6465206F6E204D617269614442206F72204D7953514C0A0A2020202020202A20556E6465727374616E64696E67204D7953514C20496E7465726E616C73206279205361736861205061636865762C20666F726D6572204D7953514C20646576656C6F706572206174204D7953514C2041422E0A2020202020202020202020206F205468697320697320746865206F6E6C7920626F6F6B207765206B6E6F772061626F75742074686174206465736372696265732074686520696E7465726E616C73206F66204D617269614442202F204D7953514C2E2041206D757374206861766520666F7220616E796F6E652077686F2077616E747320746F20756E6465727374616E6420616E6420646576656C6F70206F6E204D617269614442210A2020202020202020202020206F204E6F7420616C6C20746F706963732061726520636F766572656420616E6420736F6D652070617274732061726520736C696768746C79206F757464617465642C20627574207374696C6C20746865206265737420626F6F6B206F6E207468697320746F7069632E200A2020202020202A204D7953514C20352E3120506C7567696E20446576656C6F706D656E742062792053657267656920476F6C75626368696B20616E6420416E64726577204875746368696E67730A2020202020202020202020206F2041206D757374207265616420666F7220616E796F6E652077616E74696E6720746F207772697465206120706C7567696E20666F72204D6172696144422C207772697474656E20627920746865205365726765692077686F2064657369676E65642074686520706C7567696E20696E7465726661636520666F72204D7953514C20616E64204D61726961444221200A0A2020466F72204D617269614442202F204D7953514C20656E642075736572730A0A2020202020202A204D61726961444220437261736820436F757273652062792042656E20466F7274610A2020202020202020202020206F204669727374204D61726961444220626F6F6B210A2020202020202020202020206F20466F722070656F706C652077686F2077616E7420746F206C6561726E2053514C20616E642074686520626173696373206F66204D6172696144422E0A2020202020202020202020206F204E6F77207368697070696E672E20507572636861736520617420416D617A6F6E2E636F6D206F7220796F7572206661766F7269746520626F6F6B73656C6C65722E200A0A2020202020202A2053514C2D393920436F6D706C6574652C205265616C6C792062792050657465722047756C75747A616E20262054727564792050656C7A65722E0A2020202020202020202020206F2045766572797468696E6720796F752077616E74656420746F206B6E6F772061626F7574207468652053514C203939207374616E646172642E20457863656C6C656E74207265666572656E636520626F6F6B210A2020202020202020202020206F204672656520746F207265616420696E20746865204B6E6F776C656467656261736521200A0A2020202020202A204D7953514C20283474682045646974696F6E29206279205061756C204475426F69730A2020202020202020202020206F20546865202764656661756C742720626F6F6B20746F207265616420696620796F7520776F6E7420746F206C6561726E20746F20757365204D7953514C202F204D6172696144422E200A0A2020202020202A204D7953514C20436F6F6B626F6F6B206279205061756C204475426F69730A2020202020202020202020206F2041206C6F74206F66206578616D706C6573206F6620686F7720746F20757365204D7953514C2E204173207769746820616C6C206F66205061756C277320626F6F6B732C206974277320776F727468206974732077656967687420696E20676F6C6420616E64206576656E20656E6A6F7961626C652072656164696E6720666F7220737563682061202764727927207375626A6563742E200A0A2020202020202A204869676820506572666F726D616E6365204D7953514C2C205365636F6E642045646974696F6E2C204279204261726F6E20536368776172747A2C205065746572205A6169747365762C20566164696D20546B616368656E6B6F2C204A6572656D7920442E205A61776F646E792C2041726A656E204C656E747A2C20446572656B204A2E2042616C6C696E672C20657420616C2E0A2020202020202020202020206F20224869676820506572666F726D616E6365204D7953514C2069732074686520646566696E697469766520677569646520746F206275696C64696E6720666173742C2072656C6961626C652073797374656D732077697468204D7953514C2E205772697474656E206279206E6F74656420657870657274732077697468207965617273206F66207265616C2D776F726C6420657870657269656E6365206275696C64696E672076657279206C617267652073797374656D732C207468697320626F6F6B20636F7665727320657665727920617370656374206F66204D7953514C20706572666F726D616E636520696E2064657461696C2C20616E6420666F6375736573206F6E20726F627573746E6573732C2073656375726974792C20616E64206461746120696E746567726974792E204C6561726E20616476616E63656420746563686E697175657320696E20646570746820736F20796F752063616E206272696E67206F7574204D7953514C27732066756C6C20706F7765722E22202846726F6D2074686520626F6F6B206465736372697074696F6E206174204F275265696C6C7929200A0A2020202020202A204D7953514C2041646D696E20436F6F6B626F6F6B0A2020202020202020202020206F204120717569636B20737465702D62792D7374657020677569646520666F72204D7953514C20757365727320616E642064617461626173652061646D696E6973747261746F727320746F207461636B6C65207265616C2D776F726C64206368616C6C656E6765732077697468204D7953514C20636F6E66696775726174696F6E20616E642061646D696E697374726174696F6E200A0A2020202020202A204D7953514C20352E302043657274696669636174696F6E2053747564792047756964652C204279205061756C204475426F69732C2053746566616E2048696E7A2C204361727374656E20506564657273656E0A2020202020202020202020206F205468697320697320746865206F6666696369616C20677569646520746F20636F766572207468652070617373696E67206F66207468652074776F204D7953514C2043657274696669636174696F6E206578616D696E6174696F6E732E2049742069732076616C69642074696C6C2076657273696F6E20352E30206F6620746865207365727665722C20736F207768696C65206974206D697373657320616C6C2074686520666561747572657320617661696C61626C6520696E204D7953514C20352E3120616E6420677265617465722028696E636C7564696E67204D61726961444220352E3120616E642067726561746572292C2069742070726F7669646573206120676F6F6420626173696320756E6465727374616E64696E67206F66204D7953514C20666F722074686520656E642D757365722E20
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 1
+Warning 1265 Data truncated for column 'v1' at row 1
+Warning 1265 Data truncated for column 'v64' at row 1
+Warning 1265 Data truncated for column 'v65000' at row 1
+INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, v65000, CONCAT(v65000,v1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 2
+Warning 1265 Data truncated for column 'v1' at row 2
+Warning 1265 Data truncated for column 'v64' at row 2
+Warning 1265 Data truncated for column 'v0' at row 3
+Warning 1265 Data truncated for column 'v1' at row 3
+Warning 1265 Data truncated for column 'v64' at row 3
+Warning 1265 Data truncated for column 'v65000' at row 3
+SELECT HEX(v0), HEX(v1), HEX(v64), LENGTH(HEX(v65000)) FROM t1;
+HEX(v0) HEX(v1) HEX(v64) LENGTH(HEX(v65000))
+ 0
+ 0
+ 48 486572652069732061206C697374206F66207265636F6D6D656E64656420626F6F6B73206F6E204D61726961444220616E64204D7953514C2E20576527766520 5932
+ 61 61626364656667686920616263646566676869206162636465666768692061626364656667686920616263646566676869206162636465666768692061626364 130000
+ 79 4F6E63652074686572652C20646F75626C6520636865636B207468617420616E2061727469636C6520646F65736E277420616C7265616479206578697374 5930
+ 79 63636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363636363 130000
+ALTER TABLE t1 ADD COLUMN v65536 VARBINARY(65536) <CUSTOM_COL_OPTIONS>;
+Warnings:
+Note 1246 Converting column 'v65536' from VARBINARY to BLOB
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varbinary(0) # # #
+v1 varbinary(1) # # #
+v64 varbinary(64) # # #
+v65000 varbinary(65000) # # #
+v65536 mediumblob # # #
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/storage_engine/type_varbinary.test b/mysql-test/suite/storage_engine/type_varbinary.test
new file mode 100644
index 00000000..65240995
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_varbinary.test
@@ -0,0 +1,10 @@
+#
+# VARBINARY column types
+#
+
+--source have_engine.inc
+
+--source type_varbinary.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/type_varchar.inc b/mysql-test/suite/storage_engine/type_varchar.inc
new file mode 100644
index 00000000..e2da3deb
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_varchar.inc
@@ -0,0 +1,100 @@
+#
+# VARCHAR column types
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+let $create_definition =
+ v0 VARCHAR(0) $col_opts,
+ v1 VARCHAR(1) $col_opts,
+ v64 VARCHAR(64) $col_opts,
+ v65000 VARCHAR(65000) $col_opts
+;
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = CHAR or VARCHAR types
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+
+ --let $table_name = t2
+ --let $create_definition = v VARCHAR(65532) $col_opts
+ --source create_table.inc
+
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t2;
+
+ # Valid values
+
+ INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
+ INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
+
+ --sorted_result
+ SELECT v0,v1,v64,v65000 FROM t1;
+
+ # Invalid values
+
+ INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
+ INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, v65000, CONCAT(v65000,v1) FROM t1;
+
+ --sorted_result
+ SELECT v0, v1, v64, LENGTH(v65000) FROM t1;
+
+ --let $alter_definition = ADD COLUMN v65536 VARCHAR(65536) $col_opts
+ --source alter_table.inc
+ if ($mysql_errname)
+ {
+ --let $my_last_stmt = $alter_statement
+ --let $functionality = ALTER TABLE or TEXT types
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --replace_column 3 # 4 # 5 #
+ SHOW COLUMNS IN t1;
+ }
+ DROP TABLE t1, t2;
+}
+
diff --git a/mysql-test/suite/storage_engine/type_varchar.result b/mysql-test/suite/storage_engine/type_varchar.result
new file mode 100644
index 00000000..d67458ac
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_varchar.result
@@ -0,0 +1,126 @@
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (v0 VARCHAR(0) <CUSTOM_COL_OPTIONS>,
+v1 VARCHAR(1) <CUSTOM_COL_OPTIONS>,
+v64 VARCHAR(64) <CUSTOM_COL_OPTIONS>,
+v65000 VARCHAR(65000) <CUSTOM_COL_OPTIONS>
+) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varchar(0) # # #
+v1 varchar(1) # # #
+v64 varchar(64) # # #
+v65000 varchar(65000) # # #
+CREATE TABLE t2 (v VARCHAR(65532) <CUSTOM_COL_OPTIONS>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t2;
+Field Type Null Key Default Extra
+v varchar(65532) # # #
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','','','');
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('','y','Once there, double check that an article doesn\'t already exist','Here is a list of recommended books on MariaDB and MySQL. We\'ve provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+ For developers who want to code on MariaDB or MySQL
+
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+
+ For MariaDB / MySQL end users
+
+ * MariaDB Crash Course by Ben Forta
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o Free to read in the Knowledgebase!
+
+ * MySQL (4th Edition) by Paul DuBois
+ o The \'default\' book to read if you wont to learn to use MySQL / MariaDB.
+
+ * MySQL Cookbook by Paul DuBois
+ o A lot of examples of how to use MySQL. As with all of Paul\'s books, it\'s worth its weight in gold and even enjoyable reading for such a \'dry\' subject.
+
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ o \"High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL\'s full power.\" (From the book description at O\'Reilly)
+
+ * MySQL Admin Cookbook
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user. ');
+SELECT v0,v1,v64,v65000 FROM t1;
+v0 v1 v64 v65000
+
+
+
+
+
+
+
+
+
+
+
+ y Once there, double check that an article doesn't already exist Here is a list of recommended books on MariaDB and MySQL. We've provided links to Amazon.com here for convenience, but they can be found at many other bookstores, both online and off.
+ o "High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity. Learn advanced techniques in depth so you can bring out MySQL's full power." (From the book description at O'Reilly)
+ o A lot of examples of how to use MySQL. As with all of Paul's books, it's worth its weight in gold and even enjoyable reading for such a 'dry' subject.
+ o A must read for anyone wanting to write a plugin for MariaDB, written by the Sergei who designed the plugin interface for MySQL and MariaDB!
+ o A quick step-by-step guide for MySQL users and database administrators to tackle real-world challenges with MySQL configuration and administration
+ o Everything you wanted to know about the SQL 99 standard. Excellent reference book!
+ o First MariaDB book!
+ o For people who want to learn SQL and the basics of MariaDB.
+ o Free to read in the Knowledgebase!
+ o Not all topics are covered and some parts are slightly outdated, but still the best book on this topic.
+ o Now shipping. Purchase at Amazon.com or your favorite bookseller.
+ o The 'default' book to read if you wont to learn to use MySQL / MariaDB.
+ o This is the official guide to cover the passing of the two MySQL Certification examinations. It is valid till version 5.0 of the server, so while it misses all the features available in MySQL 5.1 and greater (including MariaDB 5.1 and greater), it provides a good basic understanding of MySQL for the end-user.
+ o This is the only book we know about that describes the internals of MariaDB / MySQL. A must have for anyone who wants to understand and develop on MariaDB!
+ * High Performance MySQL, Second Edition, By Baron Schwartz, Peter Zaitsev, Vadim Tkachenko, Jeremy D. Zawodny, Arjen Lentz, Derek J. Balling, et al.
+ * MariaDB Crash Course by Ben Forta
+ * MySQL (4th Edition) by Paul DuBois
+ * MySQL 5.0 Certification Study Guide, By Paul DuBois, Stefan Hinz, Carsten Pedersen
+ * MySQL 5.1 Plugin Development by Sergei Golubchik and Andrew Hutchings
+ * MySQL Admin Cookbook
+ * MySQL Cookbook by Paul DuBois
+ * SQL-99 Complete, Really by Peter Gulutzan & Trudy Pelzer.
+ * Understanding MySQL Internals by Sasha Pachev, former MySQL developer at MySQL AB.
+ For MariaDB / MySQL end users
+ For developers who want to code on MariaDB or MySQL
+ If you want to have your favorite MySQL / MariaDB book listed here, please leave a comment.
+INSERT INTO t1 (v0,v1,v64,v65000) VALUES ('y', 'yy', REPEAT('c',65), REPEAT('abcdefghi ',6501));
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 1
+Warning 1265 Data truncated for column 'v1' at row 1
+Warning 1265 Data truncated for column 'v64' at row 1
+Warning 1265 Data truncated for column 'v65000' at row 1
+INSERT INTO t1 (v0,v1,v64,v65000) SELECT v65000, v65000, v65000, CONCAT(v65000,v1) FROM t1;
+Warnings:
+Warning 1265 Data truncated for column 'v0' at row 2
+Warning 1265 Data truncated for column 'v1' at row 2
+Warning 1265 Data truncated for column 'v64' at row 2
+Warning 1265 Data truncated for column 'v0' at row 3
+Warning 1265 Data truncated for column 'v1' at row 3
+Warning 1265 Data truncated for column 'v64' at row 3
+Warning 1265 Data truncated for column 'v65000' at row 3
+SELECT v0, v1, v64, LENGTH(v65000) FROM t1;
+v0 v1 v64 LENGTH(v65000)
+ 0
+ 0
+ H Here is a list of recommended books on MariaDB and MySQL. We've 2966
+ a abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcd 65000
+ y Once there, double check that an article doesn't already exist 2965
+ y cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc 65000
+ALTER TABLE t1 ADD COLUMN v65536 VARCHAR(65536) <CUSTOM_COL_OPTIONS>;
+Warnings:
+Note 1246 Converting column 'v65536' from VARCHAR to TEXT
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+v0 varchar(0) # # #
+v1 varchar(1) # # #
+v64 varchar(64) # # #
+v65000 varchar(65000) # # #
+v65536 mediumtext # # #
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/storage_engine/type_varchar.test b/mysql-test/suite/storage_engine/type_varchar.test
new file mode 100644
index 00000000..8f7c5e72
--- /dev/null
+++ b/mysql-test/suite/storage_engine/type_varchar.test
@@ -0,0 +1,10 @@
+#
+# VARCHAR column types
+#
+
+--source have_engine.inc
+
+--source type_varchar.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/unexpected_result.inc b/mysql-test/suite/storage_engine/unexpected_result.inc
new file mode 100644
index 00000000..2552988d
--- /dev/null
+++ b/mysql-test/suite/storage_engine/unexpected_result.inc
@@ -0,0 +1,50 @@
+#
+# This include file prints a standard message about possibly unsupported functionality
+# when a statement finished not as expected.
+# Usage:
+# --let $functionality = Foreign keys # optional
+# --let $my_last_stmt = INSERT INTO t VALUES (1) # optional
+
+--let $versions =
+
+if (!$functionality)
+{
+ --let $functionality = Functionality
+}
+if ($mysql_errname)
+{
+ --let $result = finished with $mysql_errname
+ if ($mysql_errname == ER_SYNTAX_ERROR)
+ {
+ --let $functionality = $functionality or the syntax
+ }
+ if ($mysql_errname == ER_ILLEGAL_HA)
+ {
+ --let $functionality = $functionality or the syntax
+ --let $versions = unsupported
+ }
+}
+if (!$mysql_errname)
+{
+ --let $result = succeeded unexpectedly
+}
+if (!$versions)
+{
+ --let $versions = unsupported|malfunctioning, or the problem was caused by previous errors
+}
+
+--echo # ------------ UNEXPECTED RESULT ------------
+if ($my_last_stmt)
+{
+ --echo # [ $my_last_stmt ]
+}
+--echo # The statement|command $result.
+--echo # $functionality or the mix could be $versions.
+--echo # You can change the engine code, or create an rdiff, or disable the test by adding it to disabled.def.
+--echo # Further in this test, the message might sometimes be suppressed; a part of the test might be skipped.
+--echo # Also, this problem may cause a chain effect (more errors of different kinds in the test).
+--echo # -------------------------------------------
+
+--let $my_last_stmt =
+--let $functionality =
+
diff --git a/mysql-test/suite/storage_engine/update.result b/mysql-test/suite/storage_engine/update.result
new file mode 100644
index 00000000..a07a1b57
--- /dev/null
+++ b/mysql-test/suite/storage_engine/update.result
@@ -0,0 +1,50 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+UPDATE t1 SET a=a+100;
+SELECT a,b FROM t1;
+a b
+101 a
+101 a
+10100 foobar
+10100 foobar
+102 b
+102 b
+103 c
+103 c
+104 d
+104 d
+105 e
+105 e
+UPDATE t1 SET a=a-100, b=DEFAULT WHERE a>100;
+SELECT a,b FROM t1;
+a b
+1 NULL
+1 NULL
+10000 NULL
+10000 NULL
+2 NULL
+2 NULL
+3 NULL
+3 NULL
+4 NULL
+4 NULL
+5 NULL
+5 NULL
+UPDATE t1 SET b = 'update' WHERE a <= 4 ORDER BY b DESC, a ASC LIMIT 1;
+SELECT a,b FROM t1;
+a b
+1 NULL
+1 update
+10000 NULL
+10000 NULL
+2 NULL
+2 NULL
+3 NULL
+3 NULL
+4 NULL
+4 NULL
+5 NULL
+5 NULL
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/update.test b/mysql-test/suite/storage_engine/update.test
new file mode 100644
index 00000000..ad36382f
--- /dev/null
+++ b/mysql-test/suite/storage_engine/update.test
@@ -0,0 +1,43 @@
+#
+# Basic UPDATE statements.
+# UPDATE LOW_PRIORITY is covered in update_low_prio test
+# UPDATE IGNORE is covered in update_ignore test
+# Multi-table update is covered in update_multi test
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+
+UPDATE t1 SET a=a+100;
+if ($mysql_errname)
+{
+ --let $functionality = UPDATE
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ UPDATE t1 SET a=a-100, b=DEFAULT WHERE a>100;
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ # ORDER BY and LIMIT
+ UPDATE t1 SET b = 'update' WHERE a <= 4 ORDER BY b DESC, a ASC LIMIT 1;
+ --sorted_result
+ SELECT a,b FROM t1;
+}
+
+# Cleanup
+DROP TABLE t1;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/update_ignore.result b/mysql-test/suite/storage_engine/update_ignore.result
new file mode 100644
index 00000000..27e62c4f
--- /dev/null
+++ b/mysql-test/suite/storage_engine/update_ignore.result
@@ -0,0 +1,54 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+CREATE TABLE t2 (c <CHAR_COLUMN>, d <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+UPDATE IGNORE t1 SET b = 'upd1' WHERE b IS NOT NULL ORDER BY a LIMIT 1;
+SELECT a,b FROM t1;
+a b
+1 a
+1 upd1
+10000 foobar
+10000 foobar
+2 b
+2 b
+3 c
+3 c
+4 d
+4 d
+5 e
+5 e
+UPDATE IGNORE t1, t2 SET b = 'upd2a', c = 'upd2b'
+WHERE c < b OR a != ( SELECT 1 UNION SELECT 2 );
+Warnings:
+Warning 1242 Subquery returns more than 1 row
+SELECT a,b FROM t1;
+a b
+1 a
+1 upd2a
+10000 upd2a
+10000 upd2a
+2 upd2a
+2 upd2a
+3 upd2a
+3 upd2a
+4 upd2a
+4 upd2a
+5 upd2a
+5 upd2a
+SELECT c,d FROM t2;
+c d
+upd2b 1
+upd2b 1
+upd2b 10000
+upd2b 10000
+upd2b 2
+upd2b 2
+upd2b 3
+upd2b 3
+upd2b 4
+upd2b 4
+upd2b 5
+upd2b 5
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/storage_engine/update_ignore.test b/mysql-test/suite/storage_engine/update_ignore.test
new file mode 100644
index 00000000..98f817b0
--- /dev/null
+++ b/mysql-test/suite/storage_engine/update_ignore.test
@@ -0,0 +1,43 @@
+#
+# UPDATE IGNORE
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+
+--let $table_name = t2
+--let $create_definition = c $char_col, d $int_col
+--source create_table.inc
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+
+UPDATE IGNORE t1 SET b = 'upd1' WHERE b IS NOT NULL ORDER BY a LIMIT 1;
+if ($mysql_errname)
+{
+ --let $functionality = UPDATE IGNORE
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ UPDATE IGNORE t1, t2 SET b = 'upd2a', c = 'upd2b'
+ WHERE c < b OR a != ( SELECT 1 UNION SELECT 2 );
+ --sorted_result
+ SELECT a,b FROM t1;
+ --sorted_result
+ SELECT c,d FROM t2;
+}
+
+# Cleanup
+DROP TABLE t1, t2;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/update_low_prio.result b/mysql-test/suite/storage_engine/update_low_prio.result
new file mode 100644
index 00000000..1e038103
--- /dev/null
+++ b/mysql-test/suite/storage_engine/update_low_prio.result
@@ -0,0 +1,66 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (11,'foobar'),(12,'b');
+SET LOW_PRIORITY_UPDATES = 0;
+SET lock_wait_timeout = 4;
+connect con1,localhost,root,,;
+SET lock_wait_timeout = 2;
+SELECT a+SLEEP(1) FROM t1;
+connection default;
+UPDATE t1 SET a=a+10;
+connect con2,localhost,root,,;
+SET lock_wait_timeout = 3;
+SELECT a+SLEEP(1) FROM t1;
+a+SLEEP(1)
+21
+22
+connection con1;
+a+SLEEP(1)
+11
+12
+connection default;
+SELECT a,b FROM t1;
+a b
+21 foobar
+22 b
+connection con1;
+SELECT a+SLEEP(1) FROM t1;
+connection default;
+UPDATE LOW_PRIORITY t1 SET a=a+20;
+connection con2;
+SELECT a+SLEEP(1) FROM t1;
+a+SLEEP(1)
+21
+22
+connection con1;
+a+SLEEP(1)
+21
+22
+connection default;
+SELECT a,b FROM t1;
+a b
+41 foobar
+42 b
+SET LOW_PRIORITY_UPDATES = 1;
+connection con1;
+SELECT a+SLEEP(1) FROM t1;
+connection default;
+UPDATE t1 SET a=a+30;
+connection con2;
+SELECT a+SLEEP(1) FROM t1;
+a+SLEEP(1)
+41
+42
+connection con1;
+a+SLEEP(1)
+41
+42
+connection default;
+SELECT a,b FROM t1;
+a b
+71 foobar
+72 b
+disconnect con1;
+disconnect con2;
+connection default;
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/update_low_prio.test b/mysql-test/suite/storage_engine/update_low_prio.test
new file mode 100644
index 00000000..d6398b7d
--- /dev/null
+++ b/mysql-test/suite/storage_engine/update_low_prio.test
@@ -0,0 +1,165 @@
+#
+# UPDATE LOW_PRIORITY
+#
+--source have_engine.inc
+
+--source include/count_sessions.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (11,'foobar'),(12,'b');
+
+# We will have 3 connections:
+# con1 will start SELECT which should give us enough time;
+# default will run UPDATE
+# con2 will then start another SELECT.
+# With LOW_PRIORITY_UPDATES = 0,
+# with standard UPDATE we should see old data in con1 resultset,
+# but new data in con2 resultset.
+# With UPDATE LOW_PRIORITY we should see old data in both resultsets.
+# Then we will set LOW_PRIORITY_UPDATES to 1.
+# Then with standard UPDATE we should also see old data in both resultsets.
+
+SET LOW_PRIORITY_UPDATES = 0;
+SET lock_wait_timeout = 4;
+
+# Normal UPDATE with low_priority_updates=0
+
+--connect (con1,localhost,root,,)
+SET lock_wait_timeout = 2;
+--send
+SELECT a+SLEEP(1) FROM t1;
+
+--connection default
+let $show_statement = SHOW PROCESSLIST;
+let $field = State;
+let $condition = = 'User sleep';
+# We don't need to wait long,
+# if the feature works, threads
+# should show up in the processlist right away
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+--send
+UPDATE t1 SET a=a+10;
+
+--connect (con2,localhost,root,,)
+SET lock_wait_timeout = 3;
+let $field = Info;
+let $condition = = 'UPDATE t1 SET a=a+10';
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+if (!$found)
+{
+ --let $mysql_errname = timeout in wait_show_condition.inc
+ --let $functionality = Table locking
+ --source unexpected_result.inc
+}
+--sorted_result
+SELECT a+SLEEP(1) FROM t1;
+
+--connection con1
+--sorted_result
+--reap
+
+--connection default
+--reap
+if ($mysql_errname)
+{
+ --let $my_last_stmt = UPDATE t1 SET a=a+10
+ --let $functionality = UPDATE
+ --source unexpected_result.inc
+}
+
+--sorted_result
+SELECT a,b FROM t1;
+
+# UPDATE LOW_PRIORITY
+
+--connection con1
+--send
+SELECT a+SLEEP(1) FROM t1;
+
+--connection default
+let $field = State;
+let $condition = = 'User sleep';
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+--send
+UPDATE LOW_PRIORITY t1 SET a=a+20;
+
+--connection con2
+let $field = Info;
+let $condition = = 'UPDATE LOW_PRIORITY t1 SET a=a+20';
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+--sorted_result
+SELECT a+SLEEP(1) FROM t1;
+
+--connection con1
+--sorted_result
+--reap
+
+--connection default
+--reap
+--sorted_result
+SELECT a,b FROM t1;
+
+SET LOW_PRIORITY_UPDATES = 1;
+
+# Normal UPDATE with low_priority_updates=1
+
+--connection con1
+--send
+SELECT a+SLEEP(1) FROM t1;
+
+--connection default
+let $field = State;
+let $condition = = 'User sleep';
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+--send
+UPDATE t1 SET a=a+30;
+
+--connection con2
+let $field = Info;
+let $condition = = 'UPDATE t1 SET a=a+30';
+let $wait_timeout = 2;
+--source include/wait_show_condition.inc
+if (!$found)
+{
+ --let $mysql_errname = timeout in wait_show_condition.inc
+ --let $functionality = Table locking
+ --source unexpected_result.inc
+}
+--sorted_result
+SELECT a+SLEEP(1) FROM t1;
+
+--connection con1
+--sorted_result
+--reap
+
+--connection default
+--reap
+if ($mysql_errname)
+{
+ --let $my_last_stmt = UPDATE t1 SET a=a+30
+ --let $functionality = UPDATE
+ --source unexpected_result.inc
+}
+--sorted_result
+SELECT a,b FROM t1;
+
+--disconnect con1
+--disconnect con2
+
+--connection default
+# Cleanup
+DROP TABLE t1;
+
+--source include/wait_until_count_sessions.inc
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/update_multi.result b/mysql-test/suite/storage_engine/update_multi.result
new file mode 100644
index 00000000..909cce82
--- /dev/null
+++ b/mysql-test/suite/storage_engine/update_multi.result
@@ -0,0 +1,65 @@
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+CREATE TABLE t2 (c <CHAR_COLUMN>, d <INT_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+UPDATE t1, t2 SET t1.a = t2.d+100, t2.c = 'multi' WHERE c < b AND a + d != 1;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar 10000
+foobar 10000
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+UPDATE t2, t1 SET t2.d = DEFAULT WHERE c = 'foobar' and b = c;
+SELECT a,b FROM t1;
+a b
+1 a
+1 a
+101 b
+101 b
+101 c
+101 c
+101 d
+101 d
+101 e
+101 e
+101 foobar
+101 foobar
+SELECT c,d FROM t2;
+c d
+foobar NULL
+foobar NULL
+multi 1
+multi 1
+multi 2
+multi 2
+multi 3
+multi 3
+multi 4
+multi 4
+multi 5
+multi 5
+DROP TABLE t1, t2;
diff --git a/mysql-test/suite/storage_engine/update_multi.test b/mysql-test/suite/storage_engine/update_multi.test
new file mode 100644
index 00000000..4820eb5d
--- /dev/null
+++ b/mysql-test/suite/storage_engine/update_multi.test
@@ -0,0 +1,44 @@
+#
+# Multi-table UPDATE statements.
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+--source create_table.inc
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(10000,'foobar');
+INSERT INTO t1 (a,b) SELECT a, b FROM t1;
+
+--let $table_name = t2
+--let $create_definition = c $char_col, d $int_col
+--source create_table.inc
+INSERT INTO t2 (c,d) SELECT b, a FROM t1;
+
+UPDATE t1, t2 SET t1.a = t2.d+100, t2.c = 'multi' WHERE c < b AND a + d != 1;
+if ($mysql_errname)
+{
+ --let $functionality = UPDATE
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --sorted_result
+ SELECT a,b FROM t1;
+ --sorted_result
+ SELECT c,d FROM t2;
+
+ UPDATE t2, t1 SET t2.d = DEFAULT WHERE c = 'foobar' and b = c;
+ --sorted_result
+ SELECT a,b FROM t1;
+ --sorted_result
+ SELECT c,d FROM t2;
+}
+
+# Cleanup
+DROP TABLE t1, t2;
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/update_with_keys.result b/mysql-test/suite/storage_engine/update_with_keys.result
new file mode 100644
index 00000000..ed62c96a
--- /dev/null
+++ b/mysql-test/suite/storage_engine/update_with_keys.result
@@ -0,0 +1,90 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, INDEX(b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'x'),(7,'y'),(8,'z');
+UPDATE t1 SET a=100, b='f' WHERE b IN ('b','c');
+UPDATE t1 SET b='m' WHERE b = 'f';
+UPDATE t1 SET b='z' WHERE a < 2;
+UPDATE t1 SET b='';
+SELECT a,b FROM t1;
+a b
+1
+100
+100
+4
+5
+6
+7
+8
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, UNIQUE INDEX(a)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(0,'f'),(100,'a');
+UPDATE t1 SET a=a+200;
+UPDATE t1 SET a=0 WHERE a > 250;
+UPDATE t1 SET a=205 WHERE a=200;
+ERROR 23000: Duplicate entry '205' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+UPDATE t1 SET a=12345 ORDER BY a, b LIMIT 1;
+SELECT a,b FROM t1;
+a b
+12345 a
+200 f
+201 a
+202 b
+203 c
+204 d
+205 e
+UPDATE t1 SET a=80 WHERE a IN (202,203);
+ERROR 23000: Duplicate entry '80' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <CHAR_COLUMN>, UNIQUE INDEX(a,b)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(100,'a'),(6,'f');
+UPDATE t1 SET a=6 WHERE a=3;
+UPDATE t1 SET a=100 WHERE a=1;
+ERROR 23000: Duplicate entry '100-a' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+UPDATE t1 SET a=4, b='d' WHERE b='f';
+ERROR 23000: Duplicate entry '4-d' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+UPDATE t1 SET a=a+1;
+SELECT a,b FROM t1;
+a b
+101 a
+2 a
+3 b
+5 d
+6 e
+7 c
+7 f
+UPDATE t1 SET b='z';
+ERROR 23000: Duplicate entry '7-z' for key 'a'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN> PRIMARY KEY, b <CHAR_COLUMN>) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(0,'f'),(100,'a');
+UPDATE t1 SET a=a+200;
+UPDATE t1 SET a=0 WHERE a > 250;
+UPDATE t1 SET a=205 WHERE a=200;
+ERROR 23000: Duplicate entry '205' for key 'PRIMARY'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+UPDATE t1 SET a=12345 ORDER BY a DESC, b LIMIT 1;
+SELECT a,b FROM t1;
+a b
+0 a
+12345 e
+200 f
+201 a
+202 b
+203 c
+204 d
+UPDATE t1 SET a=80 WHERE a IN (202,203);
+ERROR 23000: Duplicate entry '80' for key 'PRIMARY'
+# Statement ended with one of expected results (ER_DUP_ENTRY,ER_DUP_KEY).
+# If you got a difference in error message, just add it to rdiff file
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/update_with_keys.test b/mysql-test/suite/storage_engine/update_with_keys.test
new file mode 100644
index 00000000..77843365
--- /dev/null
+++ b/mysql-test/suite/storage_engine/update_with_keys.test
@@ -0,0 +1,152 @@
+#
+# UPDATE statements for tables with keys
+#
+--source have_engine.inc
+--source have_default_index.inc
+
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--let $create_definition = a $int_col, b $char_col, INDEX(b)
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Non-unique keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'x'),(7,'y'),(8,'z');
+ UPDATE t1 SET a=100, b='f' WHERE b IN ('b','c');
+ if ($mysql_errname)
+ {
+ --let $functionality = UPDATE
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ UPDATE t1 SET b='m' WHERE b = 'f';
+ UPDATE t1 SET b='z' WHERE a < 2;
+ UPDATE t1 SET b='';
+ --sorted_result
+ SELECT a,b FROM t1;
+ }
+ DROP TABLE t1;
+}
+
+--let $create_definition = a $int_col, b $char_col, UNIQUE INDEX(a)
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Unique keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(0,'f'),(100,'a');
+ UPDATE t1 SET a=a+200;
+ if ($mysql_errname)
+ {
+ --let $functionality = UPDATE
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ UPDATE t1 SET a=0 WHERE a > 250;
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ UPDATE t1 SET a=205 WHERE a=200;
+ --source check_errors.inc
+ UPDATE t1 SET a=12345 ORDER BY a, b LIMIT 1;
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ # We'll check that the next update causes an error,
+ # but won't check the result because it might be different depending
+ # on whether the engine is transactional or not
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ UPDATE t1 SET a=80 WHERE a IN (202,203);
+ --source check_errors.inc
+ }
+ DROP TABLE t1;
+}
+
+--let $create_definition = a $int_col, b $char_col, UNIQUE INDEX(a,b)
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Unique keys or multi-part keys
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(100,'a'),(6,'f');
+ UPDATE t1 SET a=6 WHERE a=3;
+ if ($mysql_errname)
+ {
+ --let $functionality = UPDATE
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ UPDATE t1 SET a=100 WHERE a=1;
+ --source check_errors.inc
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ UPDATE t1 SET a=4, b='d' WHERE b='f';
+ --source check_errors.inc
+ UPDATE t1 SET a=a+1;
+ --sorted_result
+ SELECT a,b FROM t1;
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ UPDATE t1 SET b='z';
+ --source check_errors.inc
+ }
+ DROP TABLE t1;
+}
+
+--let $create_definition = a $int_col PRIMARY KEY, b $char_col
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Primary key
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ INSERT INTO t1 (a,b) VALUES (1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(0,'f'),(100,'a');
+ UPDATE t1 SET a=a+200;
+ if ($mysql_errname)
+ {
+ --let $functionality = UPDATE
+ --source unexpected_result.inc
+ }
+ if (!$mysql_errname)
+ {
+ UPDATE t1 SET a=0 WHERE a > 250;
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ UPDATE t1 SET a=205 WHERE a=200;
+ --source check_errors.inc
+ UPDATE t1 SET a=12345 ORDER BY a DESC, b LIMIT 1;
+
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ # We'll check that the next update causes an error,
+ # but won't check the result because it might be different depending
+ # on whether the engine is transactional or not
+
+ --let $error_codes = ER_DUP_ENTRY,ER_DUP_KEY
+ UPDATE t1 SET a=80 WHERE a IN (202,203);
+ --source check_errors.inc
+ }
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+
diff --git a/mysql-test/suite/storage_engine/vcol.result b/mysql-test/suite/storage_engine/vcol.result
new file mode 100644
index 00000000..672f2080
--- /dev/null
+++ b/mysql-test/suite/storage_engine/vcol.result
@@ -0,0 +1,69 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <INT_COLUMN> GENERATED ALWAYS AS (a+1)) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) # #
+b int(11) # # VIRTUAL GENERATED
+INSERT INTO t1 (a) VALUES (1),(2);
+INSERT INTO t1 (a,b) VALUES (3,3),(4,4);
+Warnings:
+Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored
+Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored
+SELECT a,b FROM t1;
+a b
+1 2
+2 3
+3 4
+4 5
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <INT_COLUMN> GENERATED ALWAYS AS (a+1) PERSISTENT) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) # #
+b int(11) # # STORED GENERATED
+INSERT INTO t1 (a) VALUES (1),(2);
+INSERT INTO t1 (a,b) VALUES (3,3),(4,4);
+Warnings:
+Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored
+Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored
+SELECT a,b FROM t1;
+a b
+1 2
+2 3
+3 4
+4 5
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <INT_COLUMN> GENERATED ALWAYS AS (a+1) VIRTUAL) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) # #
+b int(11) # # VIRTUAL GENERATED
+INSERT INTO t1 (a) VALUES (1),(2);
+INSERT INTO t1 (a,b) VALUES (3,3),(4,4);
+Warnings:
+Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored
+Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored
+SELECT a,b FROM t1;
+a b
+1 2
+2 3
+3 4
+4 5
+DROP TABLE t1;
+CREATE TABLE t1 (a <INT_COLUMN>, b <INT_COLUMN> AS (a+1) PERSISTENT) ENGINE=<STORAGE_ENGINE> <CUSTOM_TABLE_OPTIONS>;
+SHOW COLUMNS IN t1;
+Field Type Null Key Default Extra
+a int(11) # #
+b int(11) # # STORED GENERATED
+INSERT INTO t1 (a) VALUES (1),(2);
+INSERT INTO t1 (a,b) VALUES (3,3),(4,4);
+Warnings:
+Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored
+Warning 1906 The value specified for generated column 'b' in table 't1' has been ignored
+SELECT a,b FROM t1;
+a b
+1 2
+2 3
+3 4
+4 5
+DROP TABLE t1;
diff --git a/mysql-test/suite/storage_engine/vcol.test b/mysql-test/suite/storage_engine/vcol.test
new file mode 100644
index 00000000..e6257ab3
--- /dev/null
+++ b/mysql-test/suite/storage_engine/vcol.test
@@ -0,0 +1,72 @@
+#
+# Virtual columns
+#
+
+--source have_engine.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+let $create_definition = a $int_col, b $int_col GENERATED ALWAYS AS (a+1);
+--source create_table.inc
+if ($mysql_errname)
+{
+ --let $my_last_stmt = $create_statement
+ --let $functionality = Virtual columns
+ --source unexpected_result.inc
+}
+if (!$mysql_errname)
+{
+ --replace_column 3 # 5 #
+ SHOW COLUMNS IN t1;
+
+ INSERT INTO t1 (a) VALUES (1),(2);
+ INSERT INTO t1 (a,b) VALUES (3,3),(4,4);
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ DROP TABLE t1;
+
+ let $create_definition = a $int_col, b $int_col GENERATED ALWAYS AS (a+1) PERSISTENT;
+ --source create_table.inc
+
+ --replace_column 3 # 5 #
+ SHOW COLUMNS IN t1;
+
+ INSERT INTO t1 (a) VALUES (1),(2);
+ INSERT INTO t1 (a,b) VALUES (3,3),(4,4);
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ DROP TABLE t1;
+
+ let $create_definition = a $int_col, b $int_col GENERATED ALWAYS AS (a+1) VIRTUAL;
+ --source create_table.inc
+
+ --replace_column 3 # 5 #
+ SHOW COLUMNS IN t1;
+
+ INSERT INTO t1 (a) VALUES (1),(2);
+ INSERT INTO t1 (a,b) VALUES (3,3),(4,4);
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ DROP TABLE t1;
+
+ let $create_definition = a $int_col, b $int_col AS (a+1) PERSISTENT;
+ --source create_table.inc
+
+ --replace_column 3 # 5 #
+ SHOW COLUMNS IN t1;
+
+ INSERT INTO t1 (a) VALUES (1),(2);
+ INSERT INTO t1 (a,b) VALUES (3,3),(4,4);
+ --sorted_result
+ SELECT a,b FROM t1;
+
+ DROP TABLE t1;
+}
+
+--source cleanup_engine.inc
+