summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/Makefile.am15
-rw-r--r--mysql-test/README7
-rwxr-xr-xmysql-test/create-test-result5
-rw-r--r--mysql-test/include/have_compress.inc4
-rw-r--r--mysql-test/include/have_ucs2.inc4
-rw-r--r--mysql-test/include/have_ujis.inc4
-rw-r--r--mysql-test/include/master-slave.inc13
-rw-r--r--mysql-test/include/not_embedded.inc2
-rw-r--r--mysql-test/install_test_db.sh167
-rw-r--r--mysql-test/mysql-test-run.sh60
-rw-r--r--mysql-test/r/alter_table.result70
-rw-r--r--mysql-test/r/analyse.result37
-rw-r--r--mysql-test/r/ansi.result11
-rw-r--r--mysql-test/r/auto_increment.result139
-rw-r--r--mysql-test/r/backup.result1
-rw-r--r--mysql-test/r/bdb-deadlock.result2
-rw-r--r--mysql-test/r/bdb.result45
-rw-r--r--mysql-test/r/bdb_cache.result1
-rw-r--r--mysql-test/r/bench_count_distinct.result5
-rw-r--r--mysql-test/r/bigint.result9
-rw-r--r--mysql-test/r/binary.result45
-rw-r--r--mysql-test/r/bool.result14
-rw-r--r--mysql-test/r/case.result83
-rw-r--r--mysql-test/r/cast.result87
-rw-r--r--mysql-test/r/comments.result2
-rw-r--r--mysql-test/r/compare.result4
-rw-r--r--mysql-test/r/connect.result49
-rw-r--r--mysql-test/r/convert.result17
-rw-r--r--mysql-test/r/count_distinct3.result7
-rw-r--r--mysql-test/r/create.result262
-rw-r--r--mysql-test/r/ctype_collate.result543
-rw-r--r--mysql-test/r/ctype_latin1_de.result44
-rw-r--r--mysql-test/r/ctype_many.result1808
-rw-r--r--mysql-test/r/ctype_mb.result57
-rw-r--r--mysql-test/r/ctype_recoding.result80
-rw-r--r--mysql-test/r/ctype_ucs.result272
-rw-r--r--mysql-test/r/ctype_ujis.result60
-rw-r--r--mysql-test/r/ctype_utf8.result64
-rw-r--r--mysql-test/r/date_formats.result332
-rw-r--r--mysql-test/r/delayed.result8
-rw-r--r--mysql-test/r/delete.result72
-rw-r--r--mysql-test/r/derived.result230
-rw-r--r--mysql-test/r/distinct.result104
-rw-r--r--mysql-test/r/drop.result18
-rw-r--r--mysql-test/r/drop_temp_table.result10
-rw-r--r--mysql-test/r/errors.result20
-rw-r--r--mysql-test/r/explain.result40
-rw-r--r--mysql-test/r/flush.result5
-rw-r--r--mysql-test/r/fulltext.result119
-rw-r--r--mysql-test/r/fulltext2.result208
-rw-r--r--mysql-test/r/fulltext_var.result2
-rw-r--r--mysql-test/r/func_compress.result70
-rw-r--r--mysql-test/r/func_crypt.result91
-rw-r--r--mysql-test/r/func_date_add.result20
-rw-r--r--mysql-test/r/func_default.result18
-rw-r--r--mysql-test/r/func_encrypt.result5
-rw-r--r--mysql-test/r/func_equal.result2
-rw-r--r--mysql-test/r/func_gconcat.result224
-rw-r--r--mysql-test/r/func_group.result467
-rw-r--r--mysql-test/r/func_if.result19
-rw-r--r--mysql-test/r/func_in.result145
-rw-r--r--mysql-test/r/func_like.result75
-rw-r--r--mysql-test/r/func_math.result65
-rw-r--r--mysql-test/r/func_op.result10
-rw-r--r--mysql-test/r/func_regexp.result29
-rw-r--r--mysql-test/r/func_sapdb.result200
-rw-r--r--mysql-test/r/func_set.result22
-rw-r--r--mysql-test/r/func_str.result359
-rw-r--r--mysql-test/r/func_system.result56
-rw-r--r--mysql-test/r/func_test.result98
-rw-r--r--mysql-test/r/func_time.result104
-rw-r--r--mysql-test/r/gcc296.result16
-rw-r--r--mysql-test/r/gis-rtree.result712
-rw-r--r--mysql-test/r/gis.result456
-rw-r--r--mysql-test/r/grant.result36
-rw-r--r--mysql-test/r/grant2.result23
-rw-r--r--mysql-test/r/grant_cache.result12
-rw-r--r--mysql-test/r/group_by.result67
-rw-r--r--mysql-test/r/handler.result16
-rw-r--r--mysql-test/r/have_compress.require2
-rw-r--r--mysql-test/r/have_ucs2.require2
-rw-r--r--mysql-test/r/have_ujis.require2
-rw-r--r--mysql-test/r/having.result9
-rw-r--r--mysql-test/r/heap.result40
-rw-r--r--mysql-test/r/heap_auto_increment.result41
-rw-r--r--mysql-test/r/heap_btree.result235
-rw-r--r--mysql-test/r/heap_hash.result205
-rw-r--r--mysql-test/r/help.result243
-rw-r--r--mysql-test/r/innodb-deadlock.result78
-rw-r--r--mysql-test/r/innodb.result220
-rw-r--r--mysql-test/r/innodb_cache.result8
-rw-r--r--mysql-test/r/innodb_handler.result10
-rw-r--r--mysql-test/r/insert.result4
-rw-r--r--mysql-test/r/insert_select.result17
-rw-r--r--mysql-test/r/insert_update.result69
-rw-r--r--mysql-test/r/isam.result24
-rw-r--r--mysql-test/r/join.result12
-rw-r--r--mysql-test/r/join_outer.result60
-rw-r--r--mysql-test/r/key.result12
-rw-r--r--mysql-test/r/key_cache.result259
-rw-r--r--mysql-test/r/key_diff.result6
-rw-r--r--mysql-test/r/key_primary.result8
-rw-r--r--mysql-test/r/keywords.result2
-rw-r--r--mysql-test/r/loaddata.result14
-rw-r--r--mysql-test/r/lock.result4
-rw-r--r--mysql-test/r/lock_multi.result2
-rw-r--r--mysql-test/r/lowercase_table.result9
-rw-r--r--mysql-test/r/merge.result88
-rw-r--r--mysql-test/r/mix_innodb_myisam_binlog.result103
-rw-r--r--mysql-test/r/multi_update.result54
-rw-r--r--mysql-test/r/myisam.result111
-rw-r--r--mysql-test/r/mysqlbinlog.result2
-rw-r--r--mysql-test/r/mysqldump.result53
-rw-r--r--mysql-test/r/negation_elimination.result382
-rw-r--r--mysql-test/r/null.result53
-rw-r--r--mysql-test/r/null_key.result215
-rw-r--r--mysql-test/r/odbc.result6
-rw-r--r--mysql-test/r/olap.result300
-rw-r--r--mysql-test/r/openssl_1.result8
-rw-r--r--mysql-test/r/openssl_2.result25
-rw-r--r--mysql-test/r/order_by.result142
-rw-r--r--mysql-test/r/packet.result2
-rw-r--r--mysql-test/r/preload.result167
-rw-r--r--mysql-test/r/query_cache.result141
-rw-r--r--mysql-test/r/range.result234
-rw-r--r--mysql-test/r/rename.result2
-rw-r--r--mysql-test/r/repair_part1.result (renamed from mysql-test/r/repair.result)2
-rw-r--r--mysql-test/r/repair_part2.result2
-rw-r--r--mysql-test/r/replace.result10
-rw-r--r--mysql-test/r/rollback.result19
-rw-r--r--mysql-test/r/row.result172
-rw-r--r--mysql-test/r/rpl000001.result27
-rw-r--r--mysql-test/r/rpl000002.result10
-rw-r--r--mysql-test/r/rpl000003.result17
-rw-r--r--mysql-test/r/rpl000004.result9
-rw-r--r--mysql-test/r/rpl000005.result5
-rw-r--r--mysql-test/r/rpl000006.result6
-rw-r--r--mysql-test/r/rpl000008.result32
-rw-r--r--mysql-test/r/rpl000009.result161
-rw-r--r--mysql-test/r/rpl000010.result6
-rw-r--r--mysql-test/r/rpl000011.result9
-rw-r--r--mysql-test/r/rpl000012.result14
-rw-r--r--mysql-test/r/rpl000013.result7
-rw-r--r--mysql-test/r/rpl000015.result18
-rw-r--r--mysql-test/r/rpl000017.result2
-rw-r--r--mysql-test/r/rpl000018.result8
-rw-r--r--mysql-test/r/rpl_alter.result26
-rw-r--r--mysql-test/r/rpl_do_grant.result4
-rw-r--r--mysql-test/r/rpl_empty_master_crash.result11
-rw-r--r--mysql-test/r/rpl_error_ignored_table.result10
-rw-r--r--mysql-test/r/rpl_failsafe.result8
-rw-r--r--mysql-test/r/rpl_flush_log_loop.result14
-rw-r--r--mysql-test/r/rpl_flush_tables.result40
-rw-r--r--mysql-test/r/rpl_get_lock.result15
-rw-r--r--mysql-test/r/rpl_ignore_grant.result6
-rw-r--r--mysql-test/r/rpl_insert_id.result5
-rw-r--r--mysql-test/r/rpl_loaddata.result22
-rw-r--r--mysql-test/r/rpl_loaddata_rule_m.result11
-rw-r--r--mysql-test/r/rpl_loaddata_rule_s.result4
-rw-r--r--mysql-test/r/rpl_loaddatalocal.result4
-rw-r--r--mysql-test/r/rpl_log.result124
-rw-r--r--mysql-test/r/rpl_log_pos.result40
-rw-r--r--mysql-test/r/rpl_master_pos_wait.result9
-rw-r--r--mysql-test/r/rpl_max_relay_size.result30
-rw-r--r--mysql-test/r/rpl_misc_functions.result21
-rw-r--r--mysql-test/r/rpl_mystery22.result10
-rw-r--r--mysql-test/r/rpl_openssl.result30
-rw-r--r--mysql-test/r/rpl_redirect.result7
-rw-r--r--mysql-test/r/rpl_relayrotate.result19
-rw-r--r--mysql-test/r/rpl_relayspace.result4
-rw-r--r--mysql-test/r/rpl_replicate_do.result11
-rw-r--r--mysql-test/r/rpl_reset_slave.result20
-rw-r--r--mysql-test/r/rpl_rotate_logs.result58
-rw-r--r--mysql-test/r/rpl_skip_error.result5
-rw-r--r--mysql-test/r/rpl_sporadic_master.result8
-rw-r--r--mysql-test/r/rpl_temporary.result77
-rw-r--r--mysql-test/r/rpl_trunc_binlog.result8
-rw-r--r--mysql-test/r/rpl_until.result72
-rw-r--r--mysql-test/r/rpl_user_variables.result109
-rw-r--r--mysql-test/r/sel000001.result21
-rw-r--r--mysql-test/r/sel000002.result9
-rw-r--r--mysql-test/r/sel000003.result8
-rw-r--r--mysql-test/r/sel000031.result12
-rw-r--r--mysql-test/r/sel000032.result12
-rw-r--r--mysql-test/r/sel000033.result14
-rw-r--r--mysql-test/r/sel000100.result38
-rw-r--r--mysql-test/r/select.result204
-rw-r--r--mysql-test/r/select_found.result22
-rw-r--r--mysql-test/r/select_safe.result32
-rw-r--r--mysql-test/r/show_check.result45
-rw-r--r--mysql-test/r/sql_mode.result87
-rw-r--r--mysql-test/r/subselect.result1571
-rw-r--r--mysql-test/r/subselect2.result131
-rw-r--r--mysql-test/r/subselect_innodb.result65
-rw-r--r--mysql-test/r/symlink.result4
-rw-r--r--mysql-test/r/temp_table.result8
-rw-r--r--mysql-test/r/truncate.result4
-rw-r--r--mysql-test/r/type_blob.result77
-rw-r--r--mysql-test/r/type_date.result2
-rw-r--r--mysql-test/r/type_datetime.result8
-rw-r--r--mysql-test/r/type_decimal.result87
-rw-r--r--mysql-test/r/type_enum.result4
-rw-r--r--mysql-test/r/type_float.result45
-rw-r--r--mysql-test/r/type_nchar.result50
-rw-r--r--mysql-test/r/type_ranges.result213
-rw-r--r--mysql-test/r/type_set.result6
-rw-r--r--mysql-test/r/type_time.result4
-rw-r--r--mysql-test/r/type_timestamp.result54
-rw-r--r--mysql-test/r/type_uint.result3
-rw-r--r--mysql-test/r/union.result171
-rw-r--r--mysql-test/r/update.result13
-rw-r--r--mysql-test/r/user_var.result24
-rw-r--r--mysql-test/r/varbinary.result14
-rw-r--r--mysql-test/r/variables.result109
-rw-r--r--mysql-test/r/warnings.result120
-rw-r--r--mysql-test/std_data/master-bin.000001 (renamed from mysql-test/std_data/master-bin.001)bin98 -> 98 bytes
-rw-r--r--mysql-test/std_data/trunc_binlog.000001 (renamed from mysql-test/std_data/trunc_binlog.001)bin119 -> 119 bytes
-rw-r--r--mysql-test/std_data/warnings_loaddata.dat8
-rw-r--r--mysql-test/t/alias.test3
-rw-r--r--mysql-test/t/alter_table.test42
-rw-r--r--mysql-test/t/analyse.test4
-rw-r--r--mysql-test/t/ansi-master.opt1
-rw-r--r--mysql-test/t/ansi.test9
-rw-r--r--mysql-test/t/auto_increment.test73
-rw-r--r--mysql-test/t/backup.test3
-rw-r--r--mysql-test/t/bdb-alter-table-1.test3
-rw-r--r--mysql-test/t/bdb-crash.test2
-rw-r--r--mysql-test/t/bdb-deadlock.test13
-rw-r--r--mysql-test/t/bdb.test11
-rw-r--r--mysql-test/t/bdb_cache.test5
-rw-r--r--mysql-test/t/bench_count_distinct.test7
-rw-r--r--mysql-test/t/bigint.test10
-rw-r--r--mysql-test/t/binary.test20
-rw-r--r--mysql-test/t/bool.test15
-rw-r--r--mysql-test/t/bulk_replace.test5
-rw-r--r--mysql-test/t/case.test68
-rw-r--r--mysql-test/t/cast.test54
-rw-r--r--mysql-test/t/check.test5
-rw-r--r--mysql-test/t/compare.test3
-rw-r--r--mysql-test/t/connect.test72
-rw-r--r--mysql-test/t/constraints.test2
-rw-r--r--mysql-test/t/convert.test11
-rw-r--r--mysql-test/t/count_distinct.test3
-rw-r--r--mysql-test/t/count_distinct2.test2
-rw-r--r--mysql-test/t/count_distinct3.test55
-rw-r--r--mysql-test/t/create.test173
-rw-r--r--mysql-test/t/ctype_collate.test158
-rw-r--r--mysql-test/t/ctype_latin1_de-master.opt3
-rw-r--r--mysql-test/t/ctype_latin1_de.test32
-rw-r--r--mysql-test/t/ctype_many.test216
-rw-r--r--mysql-test/t/ctype_mb.test26
-rw-r--r--mysql-test/t/ctype_recoding.test52
-rw-r--r--mysql-test/t/ctype_ucs.test194
-rw-r--r--mysql-test/t/ctype_ujis-master.opt1
-rw-r--r--mysql-test/t/ctype_ujis.test32
-rw-r--r--mysql-test/t/ctype_utf8.test37
-rw-r--r--mysql-test/t/date_formats-master.opt1
-rw-r--r--mysql-test/t/date_formats.test202
-rw-r--r--mysql-test/t/delayed.test2
-rw-r--r--mysql-test/t/delete.test39
-rw-r--r--mysql-test/t/derived.test134
-rw-r--r--mysql-test/t/dirty_close.test4
-rw-r--r--mysql-test/t/distinct.test54
-rw-r--r--mysql-test/t/drop.test16
-rw-r--r--mysql-test/t/empty_table.test3
-rw-r--r--mysql-test/t/errors.test7
-rw-r--r--mysql-test/t/explain.test2
-rw-r--r--mysql-test/t/flush.test6
-rw-r--r--mysql-test/t/foreign_key.test3
-rw-r--r--mysql-test/t/fulltext.test47
-rw-r--r--mysql-test/t/fulltext2.test176
-rw-r--r--mysql-test/t/fulltext_cache.test3
-rw-r--r--mysql-test/t/fulltext_distinct.test3
-rw-r--r--mysql-test/t/fulltext_left_join.test3
-rw-r--r--mysql-test/t/fulltext_multi.test4
-rw-r--r--mysql-test/t/fulltext_order_by.test3
-rw-r--r--mysql-test/t/fulltext_update.test2
-rw-r--r--mysql-test/t/func_compress.test37
-rw-r--r--mysql-test/t/func_concat.test3
-rw-r--r--mysql-test/t/func_crypt.test43
-rw-r--r--mysql-test/t/func_date_add.test3
-rw-r--r--mysql-test/t/func_default.test19
-rw-r--r--mysql-test/t/func_encrypt.test5
-rw-r--r--mysql-test/t/func_equal.test6
-rw-r--r--mysql-test/t/func_gconcat.test132
-rw-r--r--mysql-test/t/func_group.test239
-rw-r--r--mysql-test/t/func_if.test9
-rw-r--r--mysql-test/t/func_in.test66
-rw-r--r--mysql-test/t/func_isnull.test3
-rw-r--r--mysql-test/t/func_like.test23
-rw-r--r--mysql-test/t/func_math.test13
-rw-r--r--mysql-test/t/func_op.test2
-rw-r--r--mysql-test/t/func_regexp.test18
-rw-r--r--mysql-test/t/func_sapdb.test99
-rw-r--r--mysql-test/t/func_set.test19
-rw-r--r--mysql-test/t/func_str.test210
-rw-r--r--mysql-test/t/func_system.test22
-rw-r--r--mysql-test/t/func_test.test50
-rw-r--r--mysql-test/t/func_time.test58
-rw-r--r--mysql-test/t/func_timestamp.test3
-rw-r--r--mysql-test/t/gcc296.test19
-rw-r--r--mysql-test/t/gis-rtree.test69
-rw-r--r--mysql-test/t/gis.test161
-rw-r--r--mysql-test/t/grant.test36
-rw-r--r--mysql-test/t/grant2.test30
-rw-r--r--mysql-test/t/grant_cache.test9
-rw-r--r--mysql-test/t/group_by.test19
-rw-r--r--mysql-test/t/handler.test11
-rw-r--r--mysql-test/t/having.test9
-rw-r--r--mysql-test/t/heap.test7
-rw-r--r--mysql-test/t/heap_auto_increment.test33
-rw-r--r--mysql-test/t/heap_btree.test158
-rw-r--r--mysql-test/t/heap_hash.test143
-rw-r--r--mysql-test/t/help.test115
-rw-r--r--mysql-test/t/innodb-deadlock.test77
-rw-r--r--mysql-test/t/innodb.test146
-rw-r--r--mysql-test/t/innodb_cache.test6
-rw-r--r--mysql-test/t/innodb_handler.test5
-rw-r--r--mysql-test/t/insert.test3
-rw-r--r--mysql-test/t/insert_select.test5
-rw-r--r--mysql-test/t/insert_update.test28
-rw-r--r--mysql-test/t/isam.test16
-rw-r--r--mysql-test/t/join.test5
-rw-r--r--mysql-test/t/join_crash.test3
-rw-r--r--mysql-test/t/join_outer.test5
-rw-r--r--mysql-test/t/key.test7
-rw-r--r--mysql-test/t/key_cache-master.opt1
-rw-r--r--mysql-test/t/key_cache.test138
-rw-r--r--mysql-test/t/key_diff.test3
-rw-r--r--mysql-test/t/key_primary.test3
-rw-r--r--mysql-test/t/keywords.test3
-rw-r--r--mysql-test/t/kill.test3
-rw-r--r--mysql-test/t/limit.test3
-rw-r--r--mysql-test/t/loaddata.test2
-rw-r--r--mysql-test/t/lock.test2
-rw-r--r--mysql-test/t/lock_multi.test4
-rw-r--r--mysql-test/t/lock_tables_lost_commit.test2
-rw-r--r--mysql-test/t/lowercase_table.test8
-rw-r--r--mysql-test/t/merge.test43
-rw-r--r--mysql-test/t/mix_innodb_myisam_binlog.test3
-rw-r--r--mysql-test/t/multi_update.test53
-rw-r--r--mysql-test/t/myisam.test33
-rw-r--r--mysql-test/t/mysqlbinlog.test20
-rw-r--r--mysql-test/t/mysqldump.test18
-rw-r--r--mysql-test/t/negation_elimination.test68
-rw-r--r--mysql-test/t/null.test9
-rw-r--r--mysql-test/t/null_key.test41
-rw-r--r--mysql-test/t/odbc.test6
-rw-r--r--mysql-test/t/olap.test111
-rw-r--r--mysql-test/t/openssl_1.test2
-rw-r--r--mysql-test/t/order_by.test22
-rw-r--r--mysql-test/t/order_fill_sortbuf.test3
-rw-r--r--mysql-test/t/outfile.test5
-rw-r--r--mysql-test/t/overflow.test2
-rw-r--r--mysql-test/t/preload.test100
-rw-r--r--mysql-test/t/query_cache.test95
-rw-r--r--mysql-test/t/raid.test14
-rw-r--r--mysql-test/t/range.test121
-rw-r--r--mysql-test/t/rename.test5
-rw-r--r--mysql-test/t/repair_part1.test (renamed from mysql-test/t/repair.test)3
-rw-r--r--mysql-test/t/replace.test7
-rw-r--r--mysql-test/t/rollback.test11
-rw-r--r--mysql-test/t/row.test84
-rw-r--r--mysql-test/t/rpl000001.test14
-rw-r--r--mysql-test/t/rpl000002.test19
-rw-r--r--mysql-test/t/rpl000003.test14
-rw-r--r--mysql-test/t/rpl000004.test6
-rw-r--r--mysql-test/t/rpl000005.test2
-rw-r--r--mysql-test/t/rpl000006.test2
-rw-r--r--mysql-test/t/rpl000008-slave.opt2
-rw-r--r--mysql-test/t/rpl000008.test41
-rw-r--r--mysql-test/t/rpl000009-slave.opt2
-rw-r--r--mysql-test/t/rpl000009.test164
-rw-r--r--mysql-test/t/rpl000010.test10
-rw-r--r--mysql-test/t/rpl000011.test18
-rw-r--r--mysql-test/t/rpl000012.test8
-rw-r--r--mysql-test/t/rpl000013.test6
-rw-r--r--mysql-test/t/rpl000015.test16
-rw-r--r--mysql-test/t/rpl000016-slave.opt1
-rwxr-xr-xmysql-test/t/rpl000017-slave.sh4
-rw-r--r--mysql-test/t/rpl000017.test12
-rw-r--r--mysql-test/t/rpl000018.test14
-rw-r--r--mysql-test/t/rpl_alter.test25
-rw-r--r--mysql-test/t/rpl_empty_master_crash.test4
-rw-r--r--mysql-test/t/rpl_error_ignored_table.test1
-rw-r--r--mysql-test/t/rpl_failsafe.test8
-rw-r--r--mysql-test/t/rpl_flush_log_loop.test7
-rw-r--r--mysql-test/t/rpl_flush_tables.test35
-rw-r--r--mysql-test/t/rpl_get_lock.test4
-rw-r--r--mysql-test/t/rpl_insert_id-slave.opt1
-rw-r--r--mysql-test/t/rpl_insert_id.test1
-rw-r--r--mysql-test/t/rpl_loaddata.test8
-rw-r--r--mysql-test/t/rpl_loaddata_rule_m.test11
-rw-r--r--mysql-test/t/rpl_log.test43
-rw-r--r--mysql-test/t/rpl_log_pos.test29
-rw-r--r--mysql-test/t/rpl_master_pos_wait.test1
-rw-r--r--mysql-test/t/rpl_max_relay_size.test6
-rwxr-xr-xmysql-test/t/rpl_misc_functions-slave.sh1
-rw-r--r--mysql-test/t/rpl_misc_functions.test30
-rw-r--r--mysql-test/t/rpl_mystery22.test14
-rw-r--r--mysql-test/t/rpl_openssl.test62
-rw-r--r--mysql-test/t/rpl_redirect.test2
-rw-r--r--mysql-test/t/rpl_relayrotate-slave.opt4
-rw-r--r--mysql-test/t/rpl_relayrotate.test70
-rw-r--r--mysql-test/t/rpl_replicate_do.test10
-rw-r--r--mysql-test/t/rpl_reset_slave.test4
-rw-r--r--mysql-test/t/rpl_rotate_logs.test66
-rw-r--r--mysql-test/t/rpl_skip_error.test1
-rw-r--r--mysql-test/t/rpl_sporadic_master.test16
-rw-r--r--mysql-test/t/rpl_temporary-master.opt (renamed from mysql-test/t/README)0
-rw-r--r--mysql-test/t/rpl_temporary.test118
-rw-r--r--mysql-test/t/rpl_trunc_binlog.test13
-rw-r--r--mysql-test/t/rpl_until.test81
-rw-r--r--mysql-test/t/rpl_user_variables.test52
-rw-r--r--mysql-test/t/sel000001.test31
-rw-r--r--mysql-test/t/sel000002.test17
-rw-r--r--mysql-test/t/sel000003.test18
-rw-r--r--mysql-test/t/sel000031.test20
-rw-r--r--mysql-test/t/sel000032.test20
-rw-r--r--mysql-test/t/sel000033.test18
-rw-r--r--mysql-test/t/sel000100.test46
-rw-r--r--mysql-test/t/select.test14
-rw-r--r--mysql-test/t/select_found.test14
-rw-r--r--mysql-test/t/select_safe.test3
-rw-r--r--mysql-test/t/show_check.test8
-rw-r--r--mysql-test/t/sql_mode.test30
-rw-r--r--mysql-test/t/status.test5
-rw-r--r--mysql-test/t/subselect.test1011
-rw-r--r--mysql-test/t/subselect2.test149
-rw-r--r--mysql-test/t/subselect_innodb.test70
-rw-r--r--mysql-test/t/symlink.test3
-rw-r--r--mysql-test/t/tablelock.test3
-rw-r--r--mysql-test/t/temp_table.test6
-rw-r--r--mysql-test/t/truncate.test3
-rw-r--r--mysql-test/t/type_blob.test47
-rw-r--r--mysql-test/t/type_date.test5
-rw-r--r--mysql-test/t/type_datetime.test5
-rw-r--r--mysql-test/t/type_decimal.test10
-rw-r--r--mysql-test/t/type_enum.test3
-rw-r--r--mysql-test/t/type_float.test20
-rw-r--r--mysql-test/t/type_nchar.test35
-rw-r--r--mysql-test/t/type_ranges.test5
-rw-r--r--mysql-test/t/type_set.test5
-rw-r--r--mysql-test/t/type_time.test4
-rw-r--r--mysql-test/t/type_timestamp.test5
-rw-r--r--mysql-test/t/type_uint.test4
-rw-r--r--mysql-test/t/type_year.test3
-rw-r--r--mysql-test/t/union.test86
-rw-r--r--mysql-test/t/update.test10
-rw-r--r--mysql-test/t/user_var.test11
-rw-r--r--mysql-test/t/varbinary.test8
-rw-r--r--mysql-test/t/variables-master.opt2
-rw-r--r--mysql-test/t/variables.test45
-rw-r--r--mysql-test/t/warnings-master.opt1
-rw-r--r--mysql-test/t/warnings.test74
455 files changed, 22666 insertions, 2737 deletions
diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am
index 66f931133e3..d23a9919b48 100644
--- a/mysql-test/Makefile.am
+++ b/mysql-test/Makefile.am
@@ -21,8 +21,9 @@ benchdir_root= $(prefix)
testdir = $(benchdir_root)/mysql-test
EXTRA_SCRIPTS = mysql-test-run.sh install_test_db.sh
EXTRA_DIST = $(EXTRA_SCRIPTS)
-test_SCRIPTS = mysql-test-run install_test_db
-CLEANFILES = $(test_SCRIPTS)
+test_SCRIPTS = mysql-test-run install_test_db
+test_DATA = std_data/client-key.pem std_data/client-cert.pem std_data/cacert.pem
+CLEANFILES = $(test_SCRIPTS) $(test_DATA)
dist-hook:
mkdir -p $(distdir)/t $(distdir)/r $(distdir)/include \
@@ -30,8 +31,10 @@ dist-hook:
$(INSTALL_DATA) $(srcdir)/t/*.test $(srcdir)/t/*.opt $(srcdir)/t/*.sh $(srcdir)/t/*.slave-mi $(distdir)/t
$(INSTALL_DATA) $(srcdir)/include/*.inc $(distdir)/include
$(INSTALL_DATA) $(srcdir)/r/*.result $(srcdir)/r/*.require $(distdir)/r
- $(INSTALL_DATA) $(srcdir)/std_data/*.dat $(srcdir)/std_data/*.001 $(distdir)/std_data
+ $(INSTALL_DATA) $(srcdir)/std_data/*.dat $(srcdir)/std_data/*.000001 $(distdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/des_key_file $(distdir)/std_data
+ $(INSTALL_DATA) $(srcdir)/std_data/*.pem $(distdir)/std_data
+
install-data-local:
$(mkinstalldirs) \
@@ -49,6 +52,11 @@ install-data-local:
$(INSTALL_DATA) $(srcdir)/include/*.inc $(DESTDIR)$(testdir)/include
$(INSTALL_DATA) $(srcdir)/std_data/*.dat $(DESTDIR)$(testdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/des_key_file $(DESTDIR)$(testdir)/std_data
+ $(INSTALL_DATA) $(srcdir)/std_data/*.pem $(DESTDIR)$(testdir)/std_data
+
+std_data/%.pem:
+ @CP@ $(top_srcdir)/SSL/$(@F) $(srcdir)/std_data
+
SUFFIXES = .sh
@@ -65,6 +73,7 @@ SUFFIXES = .sh
-e 's!@''PERL''@!@PERL@!' \
-e 's!@''VERSION''@!@VERSION@!' \
-e 's!@''MYSQL_BASE_VERSION''@!@MYSQL_BASE_VERSION@!' \
+ -e 's!@''MYSQL_UNIX_ADDR''@!@MYSQL_UNIX_ADDR@!' \
-e 's!@''MYSQL_NO_DASH_VERSION''@!@MYSQL_NO_DASH_VERSION@!' \
-e 's!@''MYSQL_SERVER_SUFFIX''@!@MYSQL_SERVER_SUFFIX@!' \
$< > $@-t
diff --git a/mysql-test/README b/mysql-test/README
index c5dc3e219de..7c6efe7940e 100644
--- a/mysql-test/README
+++ b/mysql-test/README
@@ -1,6 +1,10 @@
This directory contains a test suite for mysql daemon. To run
the currently existing test cases, simply execute ./mysql-test-run in
this directory. It will fire up the newly built mysqld and test it.
+
+If you want to run the test with a running MySQL server use the --external
+option to mysql-test-run.
+
Note that you do not have to have to do make install, and you could
actually have a co-existing MySQL installation - the tests will not
conflict with it.
@@ -13,8 +17,7 @@ http://www.mysql.com/doc/M/y/MySQL_test_suite.html
You can create your own test cases. To create a test case:
- cd t
- vi test_case_name.test
+ xeamacs t/test_case_name.test
in the file, put a set of SQL commands that will create some tables,
load test data, run some queries to manipulate it.
diff --git a/mysql-test/create-test-result b/mysql-test/create-test-result
index bfd64f32fc5..b9be2300976 100755
--- a/mysql-test/create-test-result
+++ b/mysql-test/create-test-result
@@ -27,14 +27,13 @@ test_name=$1
[ -z $test_name ] && usage
result_file=$RESULT_DIR/$test_name.result
+reject_file=$RESULT_DIR/$test_name.reject
[ -f $result_file ] && die "result file $result_file has already been created"
touch $result_file
echo "Running the test case against empty file, will fail, but don't worry"
-./mysql-test-run --do-test=$test_name
-
-reject_file=$result_file.reject
+./mysql-test-run --local $test_name
if [ -f $reject_file ] ; then
echo "Below are the contents of the reject file:"
diff --git a/mysql-test/include/have_compress.inc b/mysql-test/include/have_compress.inc
new file mode 100644
index 00000000000..c042cd7452a
--- /dev/null
+++ b/mysql-test/include/have_compress.inc
@@ -0,0 +1,4 @@
+-- require r/have_compress.require
+disable_query_log;
+show variables like "have_compress";
+enable_query_log;
diff --git a/mysql-test/include/have_ucs2.inc b/mysql-test/include/have_ucs2.inc
new file mode 100644
index 00000000000..92ec9b5fb44
--- /dev/null
+++ b/mysql-test/include/have_ucs2.inc
@@ -0,0 +1,4 @@
+-- require r/have_ucs2.require
+disable_query_log;
+show collation like "ucs2_general_ci";
+enable_query_log;
diff --git a/mysql-test/include/have_ujis.inc b/mysql-test/include/have_ujis.inc
new file mode 100644
index 00000000000..ecceb7a8408
--- /dev/null
+++ b/mysql-test/include/have_ujis.inc
@@ -0,0 +1,4 @@
+-- require r/have_ujis.require
+disable_query_log;
+show collation like "ujis_japanese_ci";
+enable_query_log;
diff --git a/mysql-test/include/master-slave.inc b/mysql-test/include/master-slave.inc
index 474b1357e9e..5ec4b4379f8 100644
--- a/mysql-test/include/master-slave.inc
+++ b/mysql-test/include/master-slave.inc
@@ -3,17 +3,24 @@ connect (master1,127.0.0.1,root,,test,$MASTER_MYPORT,);
connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT,);
connect (slave1,127.0.0.1,root,,test,$SLAVE_MYPORT,);
connection slave;
---error 0,1199
-!slave stop;
+#we expect STOP SLAVE to produce a warning as the slave is stopped
+#(the server was started with skip-slave-start)
+--disable_warnings
+stop slave;
+--enable_warnings
@r/slave-stopped.result show status like 'Slave_running';
connection master;
+--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+--enable_warnings
reset master;
connection slave;
reset slave;
# Clean up old test tables
+--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+--enable_warnings
+start slave;
@r/slave-running.result show status like 'Slave_running';
# Set the default connection to 'master'
diff --git a/mysql-test/include/not_embedded.inc b/mysql-test/include/not_embedded.inc
index 52ae026ece3..fcc1756caab 100644
--- a/mysql-test/include/not_embedded.inc
+++ b/mysql-test/include/not_embedded.inc
@@ -1,5 +1,5 @@
-- require r/not_embedded.require
disable_query_log;
-select version() like "%embedded%" as "have_embedded";
+select version() like N'%embedded%' as 'have_embedded';
enable_query_log;
diff --git a/mysql-test/install_test_db.sh b/mysql-test/install_test_db.sh
index 8f90301d2d8..ca6d393e3b4 100644
--- a/mysql-test/install_test_db.sh
+++ b/mysql-test/install_test_db.sh
@@ -11,10 +11,12 @@ if [ x$1 = x"-bin" ]; then
bindir=../bin
BINARY_DIST=1
fix_bin=mysql-test
+ scriptdir=../bin
else
execdir=../sql
bindir=../client
fix_bin=.
+ scriptdir=../scripts
fi
vardir=var
@@ -60,174 +62,11 @@ basedir=.
EXTRA_ARG="--language=../sql/share/english/"
fi
-# Initialize variables
-c_d="" i_d=""
-c_h="" i_h=""
-c_u="" i_u=""
-c_f="" i_f=""
-c_t="" c_c=""
-
-# Check for old tables
-if test ! -f $mdata/db.frm
-then
- # mysqld --bootstrap wants one command/line
- c_d="$c_d CREATE TABLE db ("
- c_d="$c_d Host char(60) DEFAULT '' NOT NULL,"
- c_d="$c_d Db char(64) DEFAULT '' NOT NULL,"
- c_d="$c_d User char(16) DEFAULT '' NOT NULL,"
- c_d="$c_d Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_d="$c_d PRIMARY KEY Host (Host,Db,User),"
- c_d="$c_d KEY User (User)"
- c_d="$c_d )"
- c_d="$c_d comment='Database privileges';"
-
- i_d="INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');
- INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y');"
-fi
-
-if test ! -f $mdata/host.frm
-then
- c_h="$c_h CREATE TABLE host ("
- c_h="$c_h Host char(60) DEFAULT '' NOT NULL,"
- c_h="$c_h Db char(64) DEFAULT '' NOT NULL,"
- c_h="$c_h Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_h="$c_h PRIMARY KEY Host (Host,Db)"
- c_h="$c_h )"
- c_h="$c_h comment='Host privileges; Merged with database privileges';"
-fi
-
-if test ! -f $mdata/user.frm
-then
- c_u="$c_u CREATE TABLE user ("
- c_u="$c_u Host char(60) binary DEFAULT '' NOT NULL,"
- c_u="$c_u User char(16) binary DEFAULT '' NOT NULL,"
- c_u="$c_u Password char(16) binary DEFAULT '' NOT NULL,"
- c_u="$c_u Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Reload_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Shutdown_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Process_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u File_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u References_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Show_db_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Super_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Execute_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Repl_slave_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u Repl_client_priv enum('N','Y') DEFAULT 'N' NOT NULL,"
- c_u="$c_u ssl_type enum('','ANY','X509', 'SPECIFIED') DEFAULT '' NOT NULL,"
- c_u="$c_u ssl_cipher BLOB NOT NULL,"
- c_u="$c_u x509_issuer BLOB NOT NULL,"
- c_u="$c_u x509_subject BLOB NOT NULL,"
- c_u="$c_u max_questions int(11) unsigned DEFAULT 0 NOT NULL,"
- c_u="$c_u max_updates int(11) unsigned DEFAULT 0 NOT NULL,"
- c_u="$c_u max_connections int(11) unsigned DEFAULT 0 NOT NULL,"
- c_u="$c_u PRIMARY KEY Host (Host,User)"
- c_u="$c_u )"
- c_u="$c_u comment='Users and global privileges';"
-
- i_u="INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
- INSERT INTO user VALUES ('$hostname','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
- REPLACE INTO user VALUES ('127.0.0.1','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);
- INSERT INTO user (host,user) values ('localhost','');
- INSERT INTO user (host,user) values ('$hostname','');"
-fi
-
-if test ! -f $mdata/func.frm
-then
- c_f="$c_f CREATE TABLE func ("
- c_f="$c_f name char(64) DEFAULT '' NOT NULL,"
- c_f="$c_f ret tinyint(1) DEFAULT '0' NOT NULL,"
- c_f="$c_f dl char(128) DEFAULT '' NOT NULL,"
- c_f="$c_f type enum ('function','aggregate') NOT NULL,"
- c_f="$c_f PRIMARY KEY (name)"
- c_f="$c_f )"
- c_f="$c_f comment='User defined functions';"
-fi
-
-if test ! -f $mdata/tables_priv.frm
-then
- c_t="$c_t CREATE TABLE tables_priv ("
- c_t="$c_t Host char(60) DEFAULT '' NOT NULL,"
- c_t="$c_t Db char(64) DEFAULT '' NOT NULL,"
- c_t="$c_t User char(16) DEFAULT '' NOT NULL,"
- c_t="$c_t Table_name char(60) DEFAULT '' NOT NULL,"
- c_t="$c_t Grantor char(77) DEFAULT '' NOT NULL,"
- c_t="$c_t Timestamp timestamp(14),"
- c_t="$c_t Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL,"
- c_t="$c_t Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,"
- c_t="$c_t PRIMARY KEY (Host,Db,User,Table_name),"
- c_t="$c_t KEY Grantor (Grantor)"
- c_t="$c_t )"
- c_t="$c_t comment='Table privileges';"
-fi
-
-if test ! -f $mdata/columns_priv.frm
-then
- c_c="$c_c CREATE TABLE columns_priv ("
- c_c="$c_c Host char(60) DEFAULT '' NOT NULL,"
- c_c="$c_c Db char(64) DEFAULT '' NOT NULL,"
- c_c="$c_c User char(16) DEFAULT '' NOT NULL,"
- c_c="$c_c Table_name char(64) DEFAULT '' NOT NULL,"
- c_c="$c_c Column_name char(64) DEFAULT '' NOT NULL,"
- c_c="$c_c Timestamp timestamp(14),"
- c_c="$c_c Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,"
- c_c="$c_c PRIMARY KEY (Host,Db,User,Table_name,Column_name)"
- c_c="$c_c )"
- c_c="$c_c comment='Column privileges';"
-fi
-
mysqld_boot=" $execdir/mysqld --no-defaults --bootstrap --skip-grant-tables \
--basedir=$basedir --datadir=$ldata --skip-innodb --skip-bdb $EXTRA_ARG"
echo "running $mysqld_boot"
-if $mysqld_boot << END_OF_DATA
-use mysql;
-$c_d
-$i_d
-
-$c_h
-$i_h
-
-$c_u
-$i_u
-
-$c_f
-$i_f
-
-$c_t
-$c_c
-END_OF_DATA
+if $scriptdir/mysql_create_system_tables test $mdata $hostname | $mysqld_boot
then
exit 0
else
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index a298701dc7f..02d97d646a4 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -15,6 +15,7 @@ VERBOSE=""
USE_MANAGER=0
MY_TZ=GMT-3
TZ=$MY_TZ; export TZ # for UNIX_TIMESTAMP tests to work
+LOCAL_SOCKET=@MYSQL_UNIX_ADDR@
# For query_cache test
ulimit -n 1024
@@ -197,7 +198,7 @@ USER_TEST=
EXTRA_MASTER_OPT=""
EXTRA_MYSQL_TEST_OPT=""
-USE_RUNNING_SERVER=1
+USE_RUNNING_SERVER=""
DO_GCOV=""
DO_GDB=""
MANUAL_GDB=""
@@ -226,7 +227,7 @@ while test $# -gt 0; do
--slave-binary=*)
SLAVE_MYSQLD=`$ECHO "$1" | $SED -e "s;--slave-binary=;;"` ;;
--local) USE_RUNNING_SERVER="" ;;
- --extern) USE_RUNNING_SERVER="1" ;;
+ --extern) USE_RUNNING_SERVER="1" ;;
--tmpdir=*) MYSQL_TMP_DIR=`$ECHO "$1" | $SED -e "s;--tmpdir=;;"` ;;
--local-master)
MASTER_MYPORT=3306;
@@ -256,6 +257,7 @@ while test $# -gt 0; do
--start-and-exit)
START_AND_EXIT=1
;;
+ --socket=*) LOCAL_SOCKET=`$ECHO "$1" | $SED -e "s;--socket=;;"` ;;
--skip-rpl) NO_SLAVE=1 ;;
--skip-test=*) SKIP_TEST=`$ECHO "$1" | $SED -e "s;--skip-test=;;"`;;
--do-test=*) DO_TEST=`$ECHO "$1" | $SED -e "s;--do-test=;;"`;;
@@ -335,7 +337,7 @@ while test $# -gt 0; do
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --gdb"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --gdb"
;;
- --valgrind)
+ --valgrind | --valgrind-all)
VALGRIND=`which valgrind` # this will print an error if not found
# Give good warning to the user and stop
if [ -z "$VALGRIND" ] ; then
@@ -346,16 +348,17 @@ while test $# -gt 0; do
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-safemalloc --skip-bdb"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc --skip-bdb"
SLEEP_TIME_AFTER_RESTART=10
- SLEEP_TIME_FOR_DELETE=120
+ SLEEP_TIME_FOR_DELETE=60
USE_RUNNING_SERVER=""
+ if test "$1" = "--valgrind-all"
+ then
+ VALGRIND="$VALGRIND -v --show-reachable=yes"
+ fi
;;
--valgrind-options=*)
TMP=`$ECHO "$1" | $SED -e "s;--valgrind-options=;;"`
VALGRIND="$VALGRIND $TMP"
;;
- --valgrind-all)
- VALGRIND="$VALGRIND -v --show-reachable=yes"
- ;;
--skip-*)
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT $1"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT $1"
@@ -401,7 +404,7 @@ SLAVE_MYLOG="$MYSQL_TEST_DIR/var/log/slave.log"
SLAVE_MYERR="$MYSQL_TEST_DIR/var/log/slave.err"
CURRENT_TEST="$MYSQL_TEST_DIR/var/log/current_test"
-SMALL_SERVER="-O key_buffer_size=1M -O sort_buffer=256K -O max_heap_table_size=1M"
+SMALL_SERVER="--key_buffer_size=1M --sort_buffer=256K --max_heap_table_size=1M"
export MASTER_MYPORT
export SLAVE_MYPORT
@@ -510,7 +513,7 @@ then
fi
if [ -n "$USE_RUNNING_SERVER" ]
then
- MASTER_MYSOCK="/tmp/mysql.sock"
+ MASTER_MYSOCK=$LOCAL_SOCKET;
DBUSER=${DBUSER:-test}
else
DBUSER=${DBUSER:-root} # We want to do FLUSH xxx commands
@@ -572,7 +575,7 @@ show_failed_diff ()
$DIFF -c $result_file $reject_file
echo "-------------------------------------------------------"
echo "Please follow the instructions outlined at"
- echo "http://www.mysql.com/doc/R/e/Reporting_mysqltest_bugs.html"
+ echo "http://www.mysql.com/doc/en/Reporting_mysqltest_bugs.html"
echo "to find the reason to this problem and how to report this."
fi
}
@@ -654,13 +657,15 @@ report_stats () {
$RM -f $MY_LOG_DIR/warnings $MY_LOG_DIR/warnings.tmp
# Remove some non fatal warnings from the log files
$SED -e 's!Warning: Table:.* on delete!!g' \
- $MY_LOG_DIR/*.err > $MY_LOG_DIR/warnings.tmp
+ $MY_LOG_DIR/*.err \
+ | $SED -e 's!Warning: Table:.* on rename!!g' \
+ > $MY_LOG_DIR/warnings.tmp
found_error=0
# Find errors
for i in "^Warning:" "^Error:" "^==.* at 0x"
do
- if `$GREP "$i" $MY_LOG_DIR/warnings.tmp >> $MY_LOG_DIR/warnings`
+ if $GREP "$i" $MY_LOG_DIR/warnings.tmp >> $MY_LOG_DIR/warnings
then
found_error=1
fi
@@ -800,13 +805,13 @@ manager_launch()
ident=$1
shift
if [ $USE_MANAGER = 0 ] ; then
- $@ >> $CUR_MYERR 2>&1 &
+ $@ >> $CUR_MYERR 2>&1 &
sleep 2 #hack
return
fi
$MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT --user=$MYSQL_MANAGER_USER \
--password=$MYSQL_MANAGER_PW --port=$MYSQL_MANAGER_PORT <<EOF
-def_exec $ident $@
+def_exec $ident "$@"
set_exec_stdout $ident $CUR_MYERR
set_exec_stderr $ident $CUR_MYERR
set_exec_con $ident root localhost $CUR_MYSOCK
@@ -844,8 +849,6 @@ start_master()
if [ x$MASTER_RUNNING = x1 ] || [ x$LOCAL_MASTER = x1 ] ; then
return
fi
- # Remove old berkeley db log files that can confuse the server
- $RM -f $MASTER_MYDDIR/log.*
# Remove stale binary logs
$RM -f $MYSQL_TEST_DIR/var/log/master-bin.*
# Remove old master.info and relay-log.info files
@@ -1017,7 +1020,7 @@ start_slave()
if [ x$DO_DDD = x1 ]
then
- $ECHO "set args $master_args" > $GDB_SLAVE_INIT
+ $ECHO "set args $slave_args" > $GDB_SLAVE_INIT
manager_launch $slave_ident ddd -display $DISPLAY --debugger \
"gdb -x $GDB_SLAVE_INIT" $SLAVE_MYSQLD
elif [ x$DO_GDB = x1 ]
@@ -1308,7 +1311,7 @@ run_testcase ()
show_failed_diff $tname
$ECHO
if [ x$FORCE != x1 ] ; then
- $ECHO "Aborting. To continue, re-run with '--force'."
+ $ECHO "Aborting: $tname failed. To continue, re-run with '--force'."
$ECHO
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ]
then
@@ -1369,6 +1372,9 @@ then
# Remove files that can cause problems
$RM -f $MYSQL_TEST_DIR/var/run/* $MYSQL_TEST_DIR/var/tmp/*
+ # Remove old berkeley db log files that can confuse the server
+ $RM -f $MASTER_MYDDIR/log.*
+
wait_for_master=$SLEEP_TIME_FOR_FIRST_MASTER
wait_for_slave=$SLEEP_TIME_FOR_FIRST_SLAVE
$ECHO "Installing Test Databases"
@@ -1423,15 +1429,15 @@ $ECHO $DASH72
if [ -z "$1" ] ;
then
- if [ x$RECORD = x1 ]; then
- $ECHO "Will not run in record mode without a specific test case."
- else
- for tf in `ls -1 $TESTDIR/*.$TESTSUFFIX | $SORT`
- do
- run_testcase $tf
- done
- $RM -f $TIMEFILE # Remove for full test
- fi
+ if [ x$RECORD = x1 ]; then
+ $ECHO "Will not run in record mode without a specific test case."
+ else
+ for tf in $TESTDIR/*.$TESTSUFFIX
+ do
+ run_testcase $tf
+ done
+ $RM -f $TIMEFILE # Remove for full test
+ fi
else
while [ ! -z "$1" ]; do
tname=`$BASENAME $1 .test`
diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result
index 7ade3313abe..b82255bf652 100644
--- a/mysql-test/r/alter_table.result
+++ b/mysql-test/r/alter_table.result
@@ -50,10 +50,10 @@ PRIMARY KEY (GROUP_ID,LANG_ID),
KEY NAME (NAME));
ALTER TABLE t1 CHANGE NAME NAME CHAR(80) not null;
SHOW FULL COLUMNS FROM t1;
-Field Type Null Key Default Extra Privileges
-GROUP_ID int(10) unsigned PRI 0 select,insert,update,references
-LANG_ID smallint(5) unsigned PRI 0 select,insert,update,references
-NAME char(80) MUL select,insert,update,references
+Field Type Collation Null Key Default Extra Privileges Comment
+GROUP_ID int(10) unsigned NULL PRI 0 select,insert,update,references
+LANG_ID smallint(5) unsigned NULL PRI 0 select,insert,update,references
+NAME char(80) latin1_swedish_ci MUL select,insert,update,references
DROP TABLE t1;
create table t1 (n int);
insert into t1 values(9),(3),(12),(10);
@@ -281,6 +281,68 @@ ALTER TABLE t1 DISABLE KEYS;
INSERT DELAYED INTO t1 VALUES(1),(2),(3);
ALTER TABLE t1 ENABLE KEYS;
drop table t1;
+set names koi8r;
+create table t1 (a char(10) character set koi8r);
+insert into t1 values ('ÔÅÓÔ');
+select a,hex(a) from t1;
+a hex(a)
+ÔÅÓÔ D4C5D3D4
+alter table t1 change a a char(10) character set cp1251;
+select a,hex(a) from t1;
+a hex(a)
+ÔÅÓÔ F2E5F1F2
+alter table t1 change a a char(10) binary;
+select a,hex(a) from t1;
+a hex(a)
+òåñò F2E5F1F2
+alter table t1 change a a char(10) character set cp1251;
+select a,hex(a) from t1;
+a hex(a)
+ÔÅÓÔ F2E5F1F2
+alter table t1 change a a char(10) character set koi8r;
+select a,hex(a) from t1;
+a hex(a)
+ÔÅÓÔ D4C5D3D4
+alter table t1 change a a varchar(10) character set cp1251;
+select a,hex(a) from t1;
+a hex(a)
+ÔÅÓÔ F2E5F1F2
+alter table t1 change a a char(10) character set koi8r;
+select a,hex(a) from t1;
+a hex(a)
+ÔÅÓÔ D4C5D3D4
+alter table t1 change a a text character set cp1251;
+select a,hex(a) from t1;
+a hex(a)
+ÔÅÓÔ F2E5F1F2
+alter table t1 change a a char(10) character set koi8r;
+select a,hex(a) from t1;
+a hex(a)
+ÔÅÓÔ D4C5D3D4
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(10) character set koi8r default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+alter table t1 DEFAULT CHARACTER SET latin1;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(10) character set koi8r default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+alter table t1 CHARACTER SET latin1;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(10) default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+alter table t1 DEFAULT CHARACTER SET cp1251;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(10) character set latin1 default NULL
+) TYPE=MyISAM DEFAULT CHARSET=cp1251
+drop table t1;
CREATE TABLE t1 (
Host varchar(16) binary NOT NULL default '',
User varchar(16) binary NOT NULL default '',
diff --git a/mysql-test/r/analyse.result b/mysql-test/r/analyse.result
index 5e859bb0b7a..f18b925460c 100644
--- a/mysql-test/r/analyse.result
+++ b/mysql-test/r/analyse.result
@@ -1,26 +1,33 @@
drop table if exists t1,t2;
create table t1 (i int, j int, empty_string char(10), bool char(1), d date);
insert into t1 values (1,2,"","Y","2002-03-03"), (3,4,"","N","2002-03-04"), (5,6,"","Y","2002-03-04"), (7,8,"","N","2002-03-05");
+select count(*) from t1 procedure analyse();
+Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
+count(*) 4 4 1 1 0 0 4.0000 0.0000 ENUM('4') NOT NULL
select * from t1 procedure analyse();
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
-t1.i 1 7 1 1 0 0 4.0000 2.2361 ENUM('1','3','5','7') NOT NULL
-t1.j 2 8 1 1 0 0 5.0000 2.2361 ENUM('2','4','6','8') NOT NULL
-t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
-t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
-t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
+test.t1.i 1 7 1 1 0 0 4.0000 2.2361 ENUM('1','3','5','7') NOT NULL
+test.t1.j 2 8 1 1 0 0 5.0000 2.2361 ENUM('2','4','6','8') NOT NULL
+test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
+test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
+test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
select * from t1 procedure analyse(2);
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
-t1.i 1 7 1 1 0 0 4.0000 2.2361 TINYINT(1) UNSIGNED NOT NULL
-t1.j 2 8 1 1 0 0 5.0000 2.2361 TINYINT(1) UNSIGNED NOT NULL
-t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
-t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
-t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
+test.t1.i 1 7 1 1 0 0 4.0000 2.2361 TINYINT(1) UNSIGNED NOT NULL
+test.t1.j 2 8 1 1 0 0 5.0000 2.2361 TINYINT(1) UNSIGNED NOT NULL
+test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
+test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
+test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
create table t2 select * from t1 procedure analyse();
select * from t2;
Field_name Min_value Max_value Min_length Max_length Empties_or_zeros Nulls Avg_value_or_avg_length Std Optimal_fieldtype
-t1.i 1 7 1 1 0 0 4.0000 2.2361 ENUM('1','3','5','7') NOT NULL
-t1.j 2 8 1 1 0 0 5.0000 2.2361 ENUM('2','4','6','8') NOT NULL
-t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
-t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
-t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
+test.t1.i 1 7 1 1 0 0 4.0000 2.2361 ENUM('1','3','5','7') NOT NULL
+test.t1.j 2 8 1 1 0 0 5.0000 2.2361 ENUM('2','4','6','8') NOT NULL
+test.t1.empty_string 0 0 4 0 0.0000 NULL CHAR(0) NOT NULL
+test.t1.bool N Y 1 1 0 0 1.0000 NULL ENUM('N','Y') NOT NULL
+test.t1.d 2002-03-03 2002-03-05 10 10 0 0 10.0000 NULL ENUM('2002-03-03','2002-03-04','2002-03-05') NOT NULL
drop table t1,t2;
+EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE();
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> system NULL NULL NULL NULL 1
+2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
diff --git a/mysql-test/r/ansi.result b/mysql-test/r/ansi.result
index f9f96310b73..0b86634f67b 100644
--- a/mysql-test/r/ansi.result
+++ b/mysql-test/r/ansi.result
@@ -1,4 +1,12 @@
drop table if exists t1;
+set sql_mode="MySQL40";
+select @@sql_mode;
+@@sql_mode
+NO_FIELD_OPTIONS,MYSQL40
+set @@sql_mode="ANSI";
+select @@sql_mode;
+@@sql_mode
+REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ONLY_FULL_GROUP_BY,ANSI
SELECT 'A' || 'B';
'A' || 'B'
AB
@@ -6,5 +14,6 @@ CREATE TABLE t1 (id INT, id2 int);
SELECT id,NULL,1,1.1,'a' FROM t1 GROUP BY id;
id NULL 1 1.1 a
SELECT id FROM t1 GROUP BY id2;
-'t1.id' isn't in GROUP BY
+ERROR 42000: 'test.t1.id' isn't in GROUP BY
drop table t1;
+SET @@SQL_MODE="";
diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result
index e79e6aab56b..113c2930977 100644
--- a/mysql-test/r/auto_increment.result
+++ b/mysql-test/r/auto_increment.result
@@ -1,4 +1,5 @@
drop table if exists t1;
+SET SQL_WARNINGS=1;
create table t1 (a int not null auto_increment,b int, primary key (a)) type=myisam auto_increment=3;
insert into t1 values (1,1),(NULL,3),(NULL,4);
delete from t1 where a=4;
@@ -105,3 +106,141 @@ Table Op Msg_type Msg_text
test.t1 check warning Found row where the auto_increment column has the value 0
test.t1 check status OK
drop table t1;
+create table t1 (i tinyint unsigned not null auto_increment primary key);
+insert into t1 set i = 254;
+insert into t1 set i = null;
+select last_insert_id();
+last_insert_id()
+255
+explain extended select last_insert_id();
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority no_cache 255 AS `last_insert_id()`
+insert into t1 set i = 254;
+ERROR 23000: Duplicate entry '254' for key 1
+select last_insert_id();
+last_insert_id()
+255
+insert into t1 set i = null;
+ERROR 23000: Duplicate entry '255' for key 1
+select last_insert_id();
+last_insert_id()
+0
+drop table t1;
+create table t1 (i tinyint unsigned not null auto_increment, key (i));
+insert into t1 set i = 254;
+insert into t1 set i = null;
+select last_insert_id();
+last_insert_id()
+255
+insert into t1 set i = null;
+Warnings:
+Warning 1263 Data truncated, out of range for column 'i' at row 1
+select last_insert_id();
+last_insert_id()
+255
+drop table t1;
+create table t1 (i tinyint unsigned not null auto_increment primary key, b int, unique (b));
+insert into t1 values (NULL, 10);
+select last_insert_id();
+last_insert_id()
+1
+insert into t1 values (NULL, 15);
+select last_insert_id();
+last_insert_id()
+2
+insert into t1 values (NULL, 10);
+ERROR 23000: Duplicate entry '10' for key 2
+select last_insert_id();
+last_insert_id()
+0
+drop table t1;
+create table t1(a int auto_increment,b int null,primary key(a));
+SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
+insert into t1(a,b)values(NULL,1);
+insert into t1(a,b)values(200,2);
+insert into t1(a,b)values(0,3);
+insert into t1(b)values(4);
+insert into t1(b)values(5);
+insert into t1(b)values(6);
+insert into t1(b)values(7);
+select * from t1 order by b;
+a b
+1 1
+200 2
+0 3
+201 4
+202 5
+203 6
+204 7
+delete from t1 where a=0;
+update t1 set a=0 where b=5;
+select * from t1 order by b;
+a b
+1 1
+200 2
+201 4
+0 5
+203 6
+204 7
+delete from t1 where a=0;
+update t1 set a=NULL where b=6;
+Warnings:
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'a' at row 4
+update t1 set a=300 where b=7;
+SET SQL_MODE='';
+insert into t1(a,b)values(NULL,8);
+insert into t1(a,b)values(400,9);
+insert into t1(a,b)values(0,10);
+insert into t1(b)values(11);
+insert into t1(b)values(12);
+insert into t1(b)values(13);
+insert into t1(b)values(14);
+select * from t1 order by b;
+a b
+1 1
+200 2
+201 4
+0 6
+300 7
+301 8
+400 9
+401 10
+402 11
+403 12
+404 13
+405 14
+delete from t1 where a=0;
+update t1 set a=0 where b=12;
+select * from t1 order by b;
+a b
+1 1
+200 2
+201 4
+300 7
+301 8
+400 9
+401 10
+402 11
+0 12
+404 13
+405 14
+delete from t1 where a=0;
+update t1 set a=NULL where b=13;
+Warnings:
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'a' at row 9
+update t1 set a=500 where b=14;
+select * from t1 order by b;
+a b
+1 1
+200 2
+201 4
+300 7
+301 8
+400 9
+401 10
+402 11
+0 13
+500 14
+drop table t1;
diff --git a/mysql-test/r/backup.result b/mysql-test/r/backup.result
index 0e0a87172f2..e53c3c3eb55 100644
--- a/mysql-test/r/backup.result
+++ b/mysql-test/r/backup.result
@@ -1,4 +1,5 @@
set SQL_LOG_BIN=0;
+drop table if exists t1, t2, t3;
create table t4(n int);
backup table t4 to '../bogus';
Table Op Msg_type Msg_text
diff --git a/mysql-test/r/bdb-deadlock.result b/mysql-test/r/bdb-deadlock.result
index 55b3d3ea2a5..6606b0d9b38 100644
--- a/mysql-test/r/bdb-deadlock.result
+++ b/mysql-test/r/bdb-deadlock.result
@@ -9,7 +9,7 @@ set autocommit=0;
update t2 set x = 1 where id = 0;
select x from t1 where id = 0;
select x from t2 where id = 0;
-Deadlock found when trying to get lock; Try restarting transaction
+ERROR 40001: Deadlock found when trying to get lock; Try restarting transaction
commit;
x
1
diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result
index ebc2866183c..f619775aa97 100644
--- a/mysql-test/r/bdb.result
+++ b/mysql-test/r/bdb.result
@@ -48,7 +48,7 @@ id parent_id level
15 102 2
update t1 set id=id+1000;
update t1 set id=1024 where id=1009;
-Duplicate entry '1024' for key 1
+ERROR 23000: Duplicate entry '1024' for key 1
select * from t1;
id parent_id level
1001 100 0
@@ -139,14 +139,14 @@ id parent_id level
1010 102 2
1015 102 2
explain select level from t1 where level=1;
-table type possible_keys key key_len ref rows Extra
-t1 ref level level 1 const 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref level level 1 const 1 Using where; Using index
explain select level,id from t1 where level=1;
-table type possible_keys key key_len ref rows Extra
-t1 ref level level 1 const 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref level level 1 const 1 Using where; Using index
explain select level,id,parent_id from t1 where level=1;
-table type possible_keys key key_len ref rows Extra
-t1 ref level level 1 const 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref level level 1 const 1 Using where
select level,id from t1 where level=1;
level id
1 1002
@@ -203,7 +203,7 @@ a
2
check table t1;
Table Op Msg_type Msg_text
-test.t1 check error The handler for the table doesn't support check
+test.t1 check error The storage engine for the table doesn't support check
drop table t1;
create table t1 (a int,b varchar(20)) type=bdb;
insert into t1 values (1,""), (2,"testing");
@@ -270,7 +270,7 @@ n after commit
commit;
insert into t1 values (5);
insert into t1 values (4);
-Duplicate entry '4' for key 1
+ERROR 23000: Duplicate entry '4' for key 1
commit;
select n, "after commit" from t1;
n after commit
@@ -279,7 +279,7 @@ n after commit
set autocommit=1;
insert into t1 values (6);
insert into t1 values (4);
-Duplicate entry '4' for key 1
+ERROR 23000: Duplicate entry '4' for key 1
select n from t1;
n
4
@@ -309,7 +309,7 @@ drop table t1;
CREATE TABLE t1 (id char(8) not null primary key, val int not null) type=bdb;
insert into t1 values ('pippo', 12);
insert into t1 values ('pippo', 12);
-Duplicate entry 'pippo' for key 1
+ERROR 23000: Duplicate entry 'pippo' for key 1
delete from t1;
delete from t1 where id = 'pippo';
select * from t1;
@@ -464,9 +464,9 @@ UNIQUE ggid (ggid)
insert into t1 (ggid,passwd) values ('test1','xxx');
insert into t1 (ggid,passwd) values ('test2','yyy');
insert into t1 (ggid,passwd) values ('test2','this will fail');
-Duplicate entry 'test2' for key 2
+ERROR 23000: Duplicate entry 'test2' for key 2
insert into t1 (ggid,id) values ('this will fail',1);
-Duplicate entry '1' for key 1
+ERROR 23000: Duplicate entry '1' for key 1
select * from t1 where ggid='test1';
id ggid email passwd
1 test1 xxx
@@ -479,7 +479,7 @@ id ggid email passwd
replace into t1 (ggid,id) values ('this will work',1);
replace into t1 (ggid,passwd) values ('test2','this will work');
update t1 set id=100,ggid='test2' where id=1;
-Duplicate entry 'test2' for key 2
+ERROR 23000: Duplicate entry 'test2' for key 2
select * from t1;
id ggid email passwd
1 this will work
@@ -624,8 +624,8 @@ id parent_id level
1025 102 2
1016 102 2
explain select level from t1 where level=1;
-table type possible_keys key key_len ref rows Extra
-t1 ref level level 1 const 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref level level 1 const 1 Using where; Using index
select level,id from t1 where level=1;
level id
1 1004
@@ -797,7 +797,6 @@ select * from t1 where i=1 and j=2;
i j
1 2
drop table t1;
-drop table if exists t1, t2, t3, t4, t5, t6, t7;
create table t1
(
branch_id int auto_increment primary key,
@@ -806,7 +805,6 @@ branch_active int not null default 1,
unique branch_name(branch_name),
index branch_active(branch_active)
) type=bdb;
-drop table if exists t2 ;
create table t2
(
target_id int auto_increment primary key,
@@ -815,7 +813,6 @@ target_active int not null default 1,
unique target_name(target_name),
index target_active(target_active)
) type=bdb;
-drop table if exists t3 ;
create table t3
(
platform_id int auto_increment primary key,
@@ -824,7 +821,6 @@ platform_active int not null default 1,
unique platform_name(platform_name),
index platform_active(platform_active)
) type=bdb;
-drop table if exists t4 ;
create table t4
(
product_id int auto_increment primary key,
@@ -834,7 +830,6 @@ product_active int not null default 1,
unique product_name(product_name),
index product_active(product_active)
) type=bdb;
-drop table if exists t5 ;
create table t5
(
product_file_id int auto_increment primary key,
@@ -847,7 +842,6 @@ file_included int not null default 1,
unique product_file(product_id,file_name),
index file_included(file_included)
) type=bdb;
-drop table if exists t6 ;
create table t6
(
file_platform_id int auto_increment primary key,
@@ -860,7 +854,6 @@ build_filename varchar(255) not null,
archive_filename varchar(255) not null,
unique file_platform(product_file_id,platform_id,branch_id)
) type=bdb;
-drop table if exists t8 ;
create table t8
(
archive_id int auto_increment primary key,
@@ -872,7 +865,6 @@ status_id int not null default 1,
unique archive(branch_id,target_id,platform_id,product_id),
index status_id(status_id)
) type=bdb;
-drop table if exists t7 ;
create table t7
(
build_id int auto_increment primary key,
@@ -1016,7 +1008,7 @@ create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(3
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
LOCK TABLES t1 WRITE;
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
-Duplicate entry '1-1' for key 1
+ERROR 23000: Duplicate entry '1-1' for key 1
select id from t1;
id
0
@@ -1034,7 +1026,7 @@ insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJ
LOCK TABLES t1 WRITE;
begin;
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
-Duplicate entry '1-1' for key 1
+ERROR 23000: Duplicate entry '1-1' for key 1
select id from t1;
id
0
@@ -1057,7 +1049,6 @@ KINMU_DATE
select T1.KINMU_DATE from t1 T1 ,t2 T2 where T1.SYAIN_NO = '12345' and T1.KINMU_DATE = '200106' and T2.SYAIN_NO = T1.SYAIN_NO;
KINMU_DATE
DROP TABLE t1,t2;
-drop table if exists t1;
create table t1 (a int(11) not null, b int(11) not null, unique (a,b)) type=bdb;
insert into t1 values (1,1), (1,2);
select * from t1 where a = 1;
diff --git a/mysql-test/r/bdb_cache.result b/mysql-test/r/bdb_cache.result
index e5c6923162a..ea00feb2111 100644
--- a/mysql-test/r/bdb_cache.result
+++ b/mysql-test/r/bdb_cache.result
@@ -98,3 +98,4 @@ commit;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
+drop table if exists t1, t2, t3;
diff --git a/mysql-test/r/bench_count_distinct.result b/mysql-test/r/bench_count_distinct.result
index d414e8e466e..2b4701389db 100644
--- a/mysql-test/r/bench_count_distinct.result
+++ b/mysql-test/r/bench_count_distinct.result
@@ -3,4 +3,9 @@ create table t1(n int not null, key(n)) delay_key_write = 1;
select count(distinct n) from t1;
count(distinct n)
100
+explain extended select count(distinct n) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL n 4 NULL 200 Using index
+Warnings:
+Note 1003 select high_priority count(distinct test.t1.n) AS `count(distinct n)` from test.t1
drop table t1;
diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result
index 308adc881f2..4c6e1645451 100644
--- a/mysql-test/r/bigint.result
+++ b/mysql-test/r/bigint.result
@@ -1,11 +1,12 @@
+drop table if exists t1;
select 0,256,00000000000000065536,2147483647,-2147483648,2147483648,+4294967296;
-0 256 00000000000000065536 2147483647 -2147483648 2147483648 +4294967296
+0 256 00000000000000065536 2147483647 -2147483648 2147483648 4294967296
0 256 65536 2147483647 -2147483648 2147483648 4294967296
select 9223372036854775807,-009223372036854775808;
9223372036854775807 -009223372036854775808
9223372036854775807 -9223372036854775808
select +9999999999999999999,-9999999999999999999;
-+9999999999999999999 -9999999999999999999
+9999999999999999999 -9999999999999999999
9999999999999999999 -10000000000000000000
select cast(9223372036854775808 as unsigned)+1;
cast(9223372036854775808 as unsigned)+1
@@ -13,7 +14,9 @@ cast(9223372036854775808 as unsigned)+1
select 9223372036854775808+1;
9223372036854775808+1
9223372036854775809
-drop table if exists t1;
+select -(0-3),round(-(0-3)), round(9999999999999999999);
+-(0-3) round(-(0-3)) round(9999999999999999999)
+3 3 10000000000000000000
create table t1 (a bigint unsigned not null, primary key(a));
insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612);
select * from t1;
diff --git a/mysql-test/r/binary.result b/mysql-test/r/binary.result
index 4d5eb62cc71..5da627a30b9 100644
--- a/mysql-test/r/binary.result
+++ b/mysql-test/r/binary.result
@@ -45,29 +45,30 @@ name
drop table t1,t2;
create table t1 (a char(10) not null, b char(10) binary not null,key (a), key(b));
insert into t1 values ("hello ","hello "),("hello2 ","hello2 ");
-select * from t1 where a="hello";
-a b
-hello hello
-select * from t1 where a="hello ";
-a b
-hello hello
-select * from t1 ignore index (a) where a="hello ";
-a b
-hello hello
-select * from t1 where b="hello";
-a b
-hello hello
-select * from t1 where b="hello ";
-a b
-hello hello
-select * from t1 ignore index (b) where b="hello ";
-a b
+select concat("-",a,"-",b,"-") from t1 where a="hello";
+concat("-",a,"-",b,"-")
+-hello-hello-
+select concat("-",a,"-",b,"-") from t1 where a="hello ";
+concat("-",a,"-",b,"-")
+-hello-hello-
+select concat("-",a,"-",b,"-") from t1 ignore index (a) where a="hello ";
+concat("-",a,"-",b,"-")
+-hello-hello-
+select concat("-",a,"-",b,"-") from t1 where b="hello";
+concat("-",a,"-",b,"-")
+-hello-hello-
+select concat("-",a,"-",b,"-") from t1 where b="hello ";
+concat("-",a,"-",b,"-")
+-hello-hello-
+select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
+concat("-",a,"-",b,"-")
+-hello-hello-
alter table t1 modify b tinytext not null, drop key b, add key (b(100));
-select * from t1 where b="hello ";
-a b
-select * from t1 ignore index (b) where b="hello ";
-a b
-hello hello
+select concat("-",a,"-",b,"-") from t1 where b="hello ";
+concat("-",a,"-",b,"-")
+select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
+concat("-",a,"-",b,"-")
+-hello-hello-
drop table t1;
create table t1 (b char(8));
insert into t1 values(NULL);
diff --git a/mysql-test/r/bool.result b/mysql-test/r/bool.result
index cb82c6baa0f..a054eceec0c 100644
--- a/mysql-test/r/bool.result
+++ b/mysql-test/r/bool.result
@@ -42,14 +42,10 @@ SELECT * FROM t1 WHERE a=2 OR (NULL AND (@a:=@a+1));
a
SELECT * FROM t1 WHERE NOT(a=2 OR (NULL AND (@b:=@b+1)));
a
-SELECT @a, @b;
-@a @b
-0 6
DROP TABLE t1;
-drop table if exists t;
-create table t(a int, b int);
-insert into t values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1);
-select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t;
+create table t1 (a int, b int);
+insert into t1 values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1);
+select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t1;
A B nA nB AB n(AB) nAonB AoB n(AoB) nAnB
N N N N N N N N N N
0 N 1 N 0 1 1 N N N
@@ -60,7 +56,7 @@ N 1 N 0 N N N 1 0 0
0 1 1 0 0 1 1 1 0 0
1 0 0 1 0 1 1 1 0 0
1 1 0 0 1 0 0 1 0 0
-select ifnull(A=1, 'N') as A, ifnull(B=1, 'N') as B, ifnull(not (A=1), 'N') as nA, ifnull(not (B=1), 'N') as nB, ifnull((A=1) and (B=1), 'N') as AB, ifnull(not ((A=1) and (B=1)), 'N') as `n(AB)`, ifnull((not (A=1) or not (B=1)), 'N') as nAonB, ifnull((A=1) or (B=1), 'N') as AoB, ifnull(not((A=1) or (B=1)), 'N') as `n(AoB)`, ifnull(not (A=1) and not (B=1), 'N') as nAnB from t;
+select ifnull(A=1, 'N') as A, ifnull(B=1, 'N') as B, ifnull(not (A=1), 'N') as nA, ifnull(not (B=1), 'N') as nB, ifnull((A=1) and (B=1), 'N') as AB, ifnull(not ((A=1) and (B=1)), 'N') as `n(AB)`, ifnull((not (A=1) or not (B=1)), 'N') as nAonB, ifnull((A=1) or (B=1), 'N') as AoB, ifnull(not((A=1) or (B=1)), 'N') as `n(AoB)`, ifnull(not (A=1) and not (B=1), 'N') as nAnB from t1;
A B nA nB AB n(AB) nAonB AoB n(AoB) nAnB
N N N N N N N N N N
0 N 1 N 0 1 1 N N N
@@ -71,4 +67,4 @@ N 1 N 0 N N N 1 0 0
0 1 1 0 0 1 1 1 0 0
1 0 0 1 0 1 1 1 0 0
1 1 0 0 1 0 0 1 0 0
-drop table t;
+drop table t1;
diff --git a/mysql-test/r/case.result b/mysql-test/r/case.result
index 4c16b375400..e9d432de077 100644
--- a/mysql-test/r/case.result
+++ b/mysql-test/r/case.result
@@ -23,6 +23,11 @@ false
select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END;
CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END
one
+explain extended select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority (case 1 when 1 then _latin1'one' when 2 then _latin1'two' else _latin1'more' end) AS `CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END`
select CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END;
CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END
two
@@ -57,6 +62,11 @@ fcase count(*)
0 2
2 1
3 1
+explain extended select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using temporary; Using filesort
+Warnings:
+Note 1003 select high_priority (case test.t1.a when 1 then 2 when 2 then 3 else 0 end) AS `fcase`,count(0) AS `count(*)` from test.t1 group by (case test.t1.a when 1 then 2 when 2 then 3 else 0 end)
select case a when 1 then "one" when 2 then "two" else "nothing" end as fcase, count(*) from t1 group by fcase;
fcase count(*)
nothing 2
@@ -71,3 +81,76 @@ orange
yellow
green
drop table t1;
+SET NAMES latin1;
+CREATE TABLE t1 SELECT
+CASE WHEN 1 THEN _latin1'a' COLLATE latin1_danish_ci ELSE _latin1'a' END AS c1,
+CASE WHEN 1 THEN _latin1'a' ELSE _latin1'a' COLLATE latin1_danish_ci END AS c2,
+CASE WHEN 1 THEN 'a' ELSE 1 END AS c3,
+CASE WHEN 1 THEN 1 ELSE 'a' END AS c4,
+CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5,
+CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6,
+CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7,
+CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8,
+CASE WHEN 1 THEN 1.0 END AS c9
+;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` char(1) character set latin1 collate latin1_danish_ci NOT NULL default '',
+ `c2` char(1) character set latin1 collate latin1_danish_ci NOT NULL default '',
+ `c3` char(1) NOT NULL default '',
+ `c4` char(1) NOT NULL default '',
+ `c5` char(3) NOT NULL default '',
+ `c6` char(3) NOT NULL default '',
+ `c7` double(3,1) NOT NULL default '0.0',
+ `c8` double(3,1) NOT NULL default '0.0',
+ `c9` double(3,1) default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SELECT CASE
+WHEN 1
+THEN _latin1'a' COLLATE latin1_danish_ci
+ELSE _latin1'a' COLLATE latin1_swedish_ci
+END;
+ERROR HY000: Illegal mix of collations (latin1_danish_ci,EXPLICIT) and (latin1_swedish_ci,EXPLICIT) for operation 'case'
+SELECT CASE _latin1'a' COLLATE latin1_general_ci
+WHEN _latin1'a' COLLATE latin1_danish_ci THEN 1
+WHEN _latin1'a' COLLATE latin1_swedish_ci THEN 2
+END;
+ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_danish_ci,EXPLICIT), (latin1_swedish_ci,EXPLICIT) for operation 'case'
+SELECT
+CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END,
+CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END,
+CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END,
+CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END
+;
+CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END
+1 2 1 2
+CREATE TABLE t1 SELECT COALESCE(_latin1'a',_latin2'a');
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'coalesce'
+CREATE TABLE t1 SELECT COALESCE('a' COLLATE latin1_swedish_ci,'b' COLLATE latin1_bin);
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'coalesce'
+CREATE TABLE t1 SELECT
+COALESCE(1), COALESCE(1.0),COALESCE('a'),
+COALESCE(1,1.0), COALESCE(1,'1'),COALESCE(1.1,'1'),
+COALESCE('a' COLLATE latin1_bin,'b');
+explain extended SELECT
+COALESCE(1), COALESCE(1.0),COALESCE('a'),
+COALESCE(1,1.0), COALESCE(1,'1'),COALESCE(1.1,'1'),
+COALESCE('a' COLLATE latin1_bin,'b');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority coalesce(1) AS `COALESCE(1)`,coalesce(1.0) AS `COALESCE(1.0)`,coalesce(_latin1'a') AS `COALESCE('a')`,coalesce(1,1.0) AS `COALESCE(1,1.0)`,coalesce(1,_latin1'1') AS `COALESCE(1,'1')`,coalesce(1.1,_latin1'1') AS `COALESCE(1.1,'1')`,coalesce((_latin1'a' collate _latin1'latin1_bin'),_latin1'b') AS `COALESCE('a' COLLATE latin1_bin,'b')`
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `COALESCE(1)` int(1) NOT NULL default '0',
+ `COALESCE(1.0)` double(3,1) NOT NULL default '0.0',
+ `COALESCE('a')` char(1) NOT NULL default '',
+ `COALESCE(1,1.0)` double(3,1) NOT NULL default '0.0',
+ `COALESCE(1,'1')` char(1) NOT NULL default '',
+ `COALESCE(1.1,'1')` char(3) NOT NULL default '',
+ `COALESCE('a' COLLATE latin1_bin,'b')` char(1) character set latin1 collate latin1_bin NOT NULL default ''
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result
index 572b32c171c..43afd02169c 100644
--- a/mysql-test/r/cast.result
+++ b/mysql-test/r/cast.result
@@ -16,6 +16,11 @@ cast(-5 as unsigned) -1 cast(-5 as unsigned) + 1
select ~5, cast(~5 as signed);
~5 cast(~5 as signed)
18446744073709551610 -6
+explain extended select ~5, cast(~5 as signed);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority ~(5) AS `~5`,cast(~(5) as signed) AS `cast(~5 as signed)`
select cast(5 as unsigned) -6.0;
cast(5 as unsigned) -6.0
-1.0
@@ -24,16 +29,90 @@ cast("A" as binary) = "a" cast(BINARY "a" as CHAR) = "A"
0 1
select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
cast("2001-1-1" as DATE) cast("2001-1-1" as DATETIME)
-2001-1-1 2001-1-1
+2001-01-01 2001-01-01 00:00:00
select cast("1:2:3" as TIME);
cast("1:2:3" as TIME)
-1:2:3
+01:02:03
+set names binary;
+select cast(_latin1'test' as char character set latin2);
+cast(_latin1'test' as char character set latin2)
+test
+select cast(_koi8r'ÔÅÓÔ' as char character set cp1251);
+cast(_koi8r'ÔÅÓÔ' as char character set cp1251)
+òåñò
+create table t1 select cast(_koi8r'ÔÅÓÔ' as char character set cp1251) as t;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `t` char(4) character set cp1251 NOT NULL default ''
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select
+cast(_latin1'ab' AS char) as c1,
+cast(_latin1'a ' AS char) as c2,
+cast(_latin1'abc' AS char(2)) as c3,
+cast(_latin1'a ' AS char(2)) as c4,
+cast(_latin1'a' AS char(2)) as c5;
+c1 c2 c3 c4 c5
+ab a ab a a
+create table t1 select
+cast(_latin1'ab' AS char) as c1,
+cast(_latin1'a ' AS char) as c2,
+cast(_latin1'abc' AS char(2)) as c3,
+cast(_latin1'a ' AS char(2)) as c4,
+cast(_latin1'a' AS char(2)) as c5;
+select * from t1;
+c1 c2 c3 c4 c5
+ab a ab a a
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` char(2) binary NOT NULL default '',
+ `c2` char(2) binary NOT NULL default '',
+ `c3` char(2) binary NOT NULL default '',
+ `c4` char(2) binary NOT NULL default '',
+ `c5` char(2) binary NOT NULL default ''
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select
+cast(_koi8r'ÆÇ' AS nchar) as c1,
+cast(_koi8r'Æ ' AS nchar) as c2,
+cast(_koi8r'ÆÇÈ' AS nchar(2)) as c3,
+cast(_koi8r'Æ ' AS nchar(2)) as c4,
+cast(_koi8r'Æ' AS nchar(2)) as c5;
+c1 c2 c3 c4 c5
+фг ф фг ф ф
+create table t1 select
+cast(_koi8r'ÆÇ' AS nchar) as c1,
+cast(_koi8r'Æ ' AS nchar) as c2,
+cast(_koi8r'ÆÇÈ' AS nchar(2)) as c3,
+cast(_koi8r'Æ ' AS nchar(2)) as c4,
+cast(_koi8r'Æ' AS nchar(2)) as c5;
+select * from t1;
+c1 c2 c3 c4 c5
+фг ф фг ф ф
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` char(2) character set utf8 NOT NULL default '',
+ `c2` char(2) character set utf8 NOT NULL default '',
+ `c3` char(2) character set utf8 NOT NULL default '',
+ `c4` char(2) character set utf8 NOT NULL default '',
+ `c5` char(2) character set utf8 NOT NULL default ''
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
select cast("2001-1-1" as date) = "2001-01-01";
cast("2001-1-1" as date) = "2001-01-01"
-0
+1
select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00";
cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"
-0
+1
select cast("1:2:3" as TIME) = "1:02:03";
cast("1:2:3" as TIME) = "1:02:03"
0
+select cast(NULL as DATE);
+cast(NULL as DATE)
+NULL
+select cast(NULL as BINARY);
+cast(NULL as BINARY)
+NULL
diff --git a/mysql-test/r/comments.result b/mysql-test/r/comments.result
index 8092f789954..a9106ce0538 100644
--- a/mysql-test/r/comments.result
+++ b/mysql-test/r/comments.result
@@ -6,7 +6,7 @@ multi line comment */;
1
1
;
-Query was empty
+ERROR 42000: Query was empty
select 1 /*!32301 +1 */;
1 /*!32301 +1
2
diff --git a/mysql-test/r/compare.result b/mysql-test/r/compare.result
index afd2a1a086b..3ad3465fac0 100644
--- a/mysql-test/r/compare.result
+++ b/mysql-test/r/compare.result
@@ -2,8 +2,8 @@ drop table if exists t1;
CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id));
insert into t1 values ('000000000001'),('000000000002');
explain select * from t1 where id=000000000001;
-table type possible_keys key key_len ref rows Extra
-t1 index PRIMARY PRIMARY 12 NULL 2 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 12 NULL 2 Using where; Using index
select * from t1 where id=000000000001;
id
000000000001
diff --git a/mysql-test/r/connect.result b/mysql-test/r/connect.result
new file mode 100644
index 00000000000..c0608af0de2
--- /dev/null
+++ b/mysql-test/r/connect.result
@@ -0,0 +1,49 @@
+show tables;
+Tables_in_mysql
+columns_priv
+db
+func
+help_category
+help_keyword
+help_relation
+help_topic
+host
+tables_priv
+user
+show tables;
+Tables_in_test
+grant ALL on *.* to test@localhost identified by "gambling";
+grant ALL on *.* to test@127.0.0.1 identified by "gambling";
+show tables;
+Tables_in_mysql
+columns_priv
+db
+func
+help_category
+help_keyword
+help_relation
+help_topic
+host
+tables_priv
+user
+show tables;
+Tables_in_test
+update mysql.user set password=old_password("gambling2") where user="test";
+flush privileges;
+set password=old_password('gambling3');
+show tables;
+Tables_in_mysql
+columns_priv
+db
+func
+help_category
+help_keyword
+help_relation
+help_topic
+host
+tables_priv
+user
+show tables;
+Tables_in_test
+delete from mysql.user where user="test";
+flush privileges;
diff --git a/mysql-test/r/convert.result b/mysql-test/r/convert.result
deleted file mode 100644
index f8dad8c69ba..00000000000
--- a/mysql-test/r/convert.result
+++ /dev/null
@@ -1,17 +0,0 @@
-select @@convert_character_set;
-@@convert_character_set
-
-select @@global.convert_character_set;
-@@global.convert_character_set
-
-show variables like "%convert_character_set%";
-Variable_name Value
-convert_character_set
-SET CHARACTER SET cp1251_koi8;
-select @@convert_character_set;
-@@convert_character_set
-cp1251_koi8
-SET CHARACTER SET DEFAULT;
-select @@convert_character_set;
-@@convert_character_set
-
diff --git a/mysql-test/r/count_distinct3.result b/mysql-test/r/count_distinct3.result
new file mode 100644
index 00000000000..633bb2fa252
--- /dev/null
+++ b/mysql-test/r/count_distinct3.result
@@ -0,0 +1,7 @@
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER);
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+4181000
+SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp;
+DROP TABLE t1;
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index 627913939fb..28f06f0bf47 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -1,4 +1,4 @@
-drop table if exists t1,t2;
+drop table if exists t1,t2,t3;
create table t1 (b char(0));
insert into t1 values (""),(null);
select * from t1;
@@ -9,33 +9,40 @@ drop table if exists t1;
create table t1 (b char(0) not null);
create table if not exists t1 (b char(0) not null);
insert into t1 values (""),(null);
+Warnings:
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'b' at row 2
select * from t1;
b
-drop table if exists t1;
+drop table t1;
+create table t1 (a int not null auto_increment,primary key (a)) type=heap;
+drop table t1;
create table t2 type=heap select * from t1;
-Table 'test.t1' doesn't exist
+ERROR 42S02: Table 'test.t1' doesn't exist
create table t2 select auto+1 from t1;
-Table 'test.t1' doesn't exist
+ERROR 42S02: Table 'test.t1' doesn't exist
drop table if exists t1,t2;
+Warnings:
+Note 1051 Unknown table 't1'
+Note 1051 Unknown table 't2'
create table t1 (b char(0) not null, index(b));
-The used table handler can't index column 'b'
-create table t1 (a int not null auto_increment,primary key (a)) type=heap;
-The used table type doesn't support AUTO_INCREMENT columns
+ERROR 42000: The used storage engine can't index column 'b'
create table t1 (a int not null,b text) type=heap;
-The used table type doesn't support BLOB/TEXT columns
+ERROR 42000: The used table type doesn't support BLOB/TEXT columns
drop table if exists t1;
+Warnings:
+Note 1051 Unknown table 't1'
create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=heap;
-The used table type doesn't support AUTO_INCREMENT columns
+ERROR 42000: Incorrect table definition; There can only be one auto column and it must be defined as a key
create table not_existing_database.test (a int);
Got one of the listed errors
create table `a/a` (a int);
-Incorrect table name 'a/a'
+ERROR 42000: Incorrect table name 'a/a'
create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int);
-Incorrect table name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
+ERROR 42000: Incorrect table name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int);
-Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long
+ERROR 42000: Identifier name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' is too long
create table 1ea10 (1a20 int,1e int);
insert into 1ea10 values(1,1);
select 1ea10.1a20,1e+ 1e+10 from 1ea10;
@@ -45,6 +52,8 @@ drop table 1ea10;
create table t1 (t1.index int);
drop table t1;
drop database if exists test_$1;
+Warnings:
+Note 1008 Can't drop database 'test_$1'; database doesn't exist
create database test_$1;
create table test_$1.$test1 (a$1 int, $b int, c$ int);
insert into test_$1.$test1 values (1,2,3);
@@ -55,18 +64,19 @@ create table test_$1.test2$ (a int);
drop table test_$1.test2$;
drop database test_$1;
create table `` (a int);
-Incorrect table name ''
+ERROR 42000: Incorrect table name ''
drop table if exists ``;
-Incorrect table name ''
+ERROR 42000: Incorrect table name ''
create table t1 (`` int);
-Incorrect column name ''
-drop table if exists t1;
+ERROR 42000: Incorrect column name ''
+create table t1 (i int, index `` (i));
+ERROR 42000: Incorrect index name ''
create table t1 (a int auto_increment not null primary key, B CHAR(20));
insert into t1 (b) values ("hello"),("my"),("world");
create table t2 (key (b)) select * from t1;
explain select * from t2 where b="world";
-table type possible_keys key key_len ref rows Extra
-t2 ref B B 21 const 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref B B 21 const 1 Using where
select * from t2 where b="world";
a B
3 world
@@ -97,6 +107,40 @@ d date 0000-00-00
t time 00:00:00
dt datetime 0000-00-00 00:00:00
drop table t1,t2;
+create table t1 (a tinyint);
+create table t2 (a int) select * from t1;
+describe t1;
+Field Type Null Key Default Extra
+a tinyint(4) YES NULL
+describe t2;
+Field Type Null Key Default Extra
+a int(11) YES NULL
+drop table if exists t2;
+create table t2 (a int, a float) select * from t1;
+ERROR 42S21: Duplicate column name 'a'
+drop table if exists t2;
+Warnings:
+Note 1051 Unknown table 't2'
+create table t2 (a int) select a as b, a+1 as b from t1;
+ERROR 42S21: Duplicate column name 'b'
+drop table if exists t2;
+Warnings:
+Note 1051 Unknown table 't2'
+create table t2 (b int) select a as b, a+1 as b from t1;
+ERROR 42S21: Duplicate column name 'b'
+drop table if exists t1,t2;
+Warnings:
+Note 1051 Unknown table 't2'
+CREATE TABLE t1 (a int not null);
+INSERT INTO t1 values (1),(2),(1);
+CREATE TABLE t2 (primary key(a)) SELECT * FROM t1;
+ERROR 23000: Duplicate entry '1' for key 1
+SELECT * from t2;
+ERROR 42S02: Table 'test.t2' doesn't exist
+DROP TABLE t1;
+DROP TABLE IF EXISTS t2;
+Warnings:
+Note 1051 Unknown table 't2'
create table t1 (a int not null, b int, primary key(a), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b), key (b));
show create table t1;
Table Create Table
@@ -135,7 +179,7 @@ t1 CREATE TABLE `t1` (
KEY `b_29` (`b`),
KEY `b_30` (`b`),
KEY `b_31` (`b`)
-) TYPE=MyISAM
+) TYPE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 select if(1,'1','0'), month("2002-08-02");
drop table t1;
@@ -153,35 +197,37 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0'
-) TYPE=HEAP
+) TYPE=HEAP DEFAULT CHARSET=latin1
drop table t1;
SET SESSION table_type="gemini";
SELECT @@table_type;
@@table_type
GEMINI
CREATE TABLE t1 (a int not null);
+Warnings:
+Warning 1265 Using storage engine MYISAM for table 't1'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0'
-) TYPE=MyISAM
+) TYPE=MyISAM DEFAULT CHARSET=latin1
SET SESSION table_type=default;
drop table t1;
create table t1 ( k1 varchar(2), k2 int, primary key(k1,k2));
insert into t1 values ("a", 1), ("b", 2);
insert into t1 values ("c", NULL);
-Column 'k2' cannot be null
+ERROR 23000: Column 'k2' cannot be null
insert into t1 values (NULL, 3);
-Column 'k1' cannot be null
+ERROR 23000: Column 'k1' cannot be null
insert into t1 values (NULL, NULL);
-Column 'k1' cannot be null
+ERROR 23000: Column 'k1' cannot be null
drop table t1;
create table t1 select x'4132';
drop table t1;
create table t1 select 1,2,3;
create table if not exists t1 select 1,2;
create table if not exists t1 select 1,2,3,4;
-Column count doesn't match value count at row 1
+ERROR 21S01: Column count doesn't match value count at row 1
create table if not exists t1 select 1;
select * from t1;
1 2 3
@@ -192,7 +238,7 @@ drop table t1;
create table t1 select 1,2,3;
create table if not exists t1 select 1,2;
create table if not exists t1 select 1,2,3,4;
-Column count doesn't match value count at row 1
+ERROR 21S01: Column count doesn't match value count at row 1
create table if not exists t1 select 1;
select * from t1;
1 2 3
@@ -209,10 +255,172 @@ a b
0 2
create table if not exists t1 select 3 as 'a',4 as 'b';
create table if not exists t1 select 3 as 'a',3 as 'b';
-Duplicate entry '3' for key 1
+ERROR 23000: Duplicate entry '3' for key 1
select * from t1;
a b
1 1
0 2
3 4
drop table t1;
+create table t1 (a int, key(a));
+create table t2 (b int, foreign key(b) references t1(a), key(b));
+drop table if exists t1,t2;
+create table t1(id int not null, name char(20));
+insert into t1 values(10,'mysql'),(20,'monty- the creator');
+create table t2(id int not null);
+insert into t2 values(10),(20);
+create table t3 like t1;
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `id` int(11) NOT NULL default '0',
+ `name` char(20) default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+select * from t3;
+id name
+create table if not exists t3 like t1;
+Warnings:
+Warning 1050 Table 't3' already exists
+select @@warning_count;
+@@warning_count
+1
+create temporary table t3 like t2;
+show create table t3;
+Table Create Table
+t3 CREATE TEMPORARY TABLE `t3` (
+ `id` int(11) NOT NULL default '0'
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+select * from t3;
+id
+drop table t3;
+show create table t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `id` int(11) NOT NULL default '0',
+ `name` char(20) default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+select * from t3;
+id name
+drop table t2, t3;
+drop database if exists test_$1;
+Warnings:
+Note 1008 Can't drop database 'test_$1'; database doesn't exist
+create database test_$1;
+create table test_$1.t3 like t1;
+create temporary table t3 like test_$1.t3;
+show create table t3;
+Table Create Table
+t3 CREATE TEMPORARY TABLE `t3` (
+ `id` int(11) NOT NULL default '0',
+ `name` char(20) default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+create table t2 like t3;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `id` int(11) NOT NULL default '0',
+ `name` char(20) default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+select * from t2;
+id name
+create table t3 like t1;
+create table t3 like test_$1.t3;
+ERROR 42S01: Table 't3' already exists
+create table non_existing_database.t1 like t1;
+Got one of the listed errors
+create table t3 like non_existing_table;
+ERROR 42S02: Unknown table 'non_existing_table'
+create temporary table t3 like t1;
+ERROR 42S01: Table 't3' already exists
+create table t3 like `a/a`;
+ERROR 42000: Incorrect table name 'a/a'
+drop table t1, t2, t3;
+drop table t3;
+drop database test_$1;
+SET SESSION table_type="heap";
+SELECT @@table_type;
+@@table_type
+HEAP
+CREATE TABLE t1 (a int not null);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL default '0'
+) TYPE=HEAP DEFAULT CHARSET=latin1
+drop table t1;
+SET SESSION table_type="gemini";
+SELECT @@table_type;
+@@table_type
+GEMINI
+CREATE TABLE t1 (a int not null);
+Warnings:
+Warning 1265 Using storage engine MYISAM for table 't1'
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL default '0'
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+SET SESSION table_type=default;
+drop table t1;
+create table t1(a int,b int,c int unsigned,d date,e char,f datetime,g time,h blob);
+insert into t1(a)values(1);
+insert into t1(a,b,c,d,e,f,g,h)
+values(2,-2,2,'1825-12-14','a','2003-1-1 3:2:1','4:3:2','binary data');
+select * from t1;
+a b c d e f g h
+1 NULL NULL NULL NULL NULL NULL NULL
+2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data
+select a,
+ifnull(b,cast(-7 as signed)) as b,
+ifnull(c,cast(7 as unsigned)) as c,
+ifnull(d,cast('2000-01-01' as date)) as d,
+ifnull(e,cast('b' as char)) as e,
+ifnull(f,cast('2000-01-01' as datetime)) as f,
+ifnull(g,cast('5:4:3' as time)) as g,
+ifnull(h,cast('yet another binary data' as binary)) as h,
+addtime(cast('1:0:0' as time),cast('1:0:0' as time)) as dd
+from t1;
+a b c d e f g h dd
+1 -7 7 2000-01-01 b 2000-01-01 00:00:00 05:04:03 yet another binary data 02:00:00
+2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data 02:00:00
+create table t2
+select
+a,
+ifnull(b,cast(-7 as signed)) as b,
+ifnull(c,cast(7 as unsigned)) as c,
+ifnull(d,cast('2000-01-01' as date)) as d,
+ifnull(e,cast('b' as char)) as e,
+ifnull(f,cast('2000-01-01' as datetime)) as f,
+ifnull(g,cast('5:4:3' as time)) as g,
+ifnull(h,cast('yet another binary data' as binary)) as h,
+addtime(cast('1:0:0' as time),cast('1:0:0' as time)) as dd
+from t1;
+explain t2;
+Field Type Null Key Default Extra
+a int(11) YES NULL
+b bigint(11) 0
+c bigint(10) 0
+d date 0000-00-00
+e char(1)
+f datetime 0000-00-00 00:00:00
+g time 00:00:00
+h mediumblob
+dd time 00:00:00
+select * from t2;
+a b c d e f g h dd
+1 -7 7 2000-01-01 b 2000-01-01 00:00:00 05:04:03 yet another binary data 02:00:00
+2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data 02:00:00
+drop table t1, t2;
+drop database if exists test_$1;
+create database test_$1;
+use test_$1;
+select database();
+database()
+test_$1
+drop database test_$1;
+select database();
+database()
+NULL
+select database();
+database()
+NULL
diff --git a/mysql-test/r/ctype_collate.result b/mysql-test/r/ctype_collate.result
new file mode 100644
index 00000000000..2186b155f99
--- /dev/null
+++ b/mysql-test/r/ctype_collate.result
@@ -0,0 +1,543 @@
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1 (
+latin1_f CHAR(32) CHARACTER SET latin1 NOT NULL
+);
+CREATE TABLE t2 (
+latin1_f CHAR(32) CHARACTER SET latin1 COLLATE koi8r_general_ci NOT NULL
+);
+ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
+CREATE TABLE t2 (
+latin1_f CHAR(32) CHARACTER SET latin1 COLLATE some_non_existing_col NOT NULL
+);
+ERROR HY000: Unknown collation: 'some_non_existing_col'
+INSERT INTO t1 (latin1_f) VALUES (_latin1'A');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'a');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'AD');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ad');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'AE');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ae');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'AF');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'af');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'Ä');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ä');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'Å');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'å');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'B');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'b');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'U');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'u');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'UE');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ue');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'Ü');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ü');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'SS');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ss');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ß');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'Y');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'y');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'Z');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'z');
+SELECT latin1_f FROM t1 ORDER BY latin1_f;
+latin1_f
+A
+a
+AD
+ad
+ae
+AE
+AF
+af
+b
+B
+SS
+ss
+u
+U
+UE
+ue
+Y
+y
+Z
+z
+SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_swedish_ci;
+latin1_f
+A
+a
+AD
+ad
+ae
+AE
+AF
+af
+b
+B
+SS
+ss
+u
+U
+UE
+ue
+Y
+y
+Z
+z
+SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_german2_ci;
+latin1_f
+A
+a
+AD
+ad
+ae
+AE
+af
+AF
+b
+B
+ss
+SS
+U
+u
+ue
+UE
+Y
+y
+Z
+z
+SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_general_ci;
+latin1_f
+A
+a
+AD
+ad
+AE
+ae
+af
+AF
+b
+B
+ss
+SS
+U
+u
+UE
+ue
+Y
+y
+Z
+z
+SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_bin;
+latin1_f
+A
+AD
+AE
+AF
+B
+SS
+U
+UE
+Y
+Z
+a
+ad
+ae
+af
+b
+ss
+u
+ue
+y
+z
+SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE koi8r_general_ci;
+ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
+SELECT latin1_f COLLATE latin1_swedish_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
+latin1_f_as
+A
+a
+AD
+ad
+ae
+AE
+AF
+af
+b
+B
+SS
+ss
+u
+U
+UE
+ue
+Y
+y
+Z
+z
+SELECT latin1_f COLLATE latin1_german2_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
+latin1_f_as
+A
+a
+AD
+ad
+ae
+AE
+af
+AF
+b
+B
+ss
+SS
+U
+u
+ue
+UE
+Y
+y
+Z
+z
+SELECT latin1_f COLLATE latin1_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
+latin1_f_as
+A
+a
+AD
+ad
+AE
+ae
+af
+AF
+b
+B
+ss
+SS
+U
+u
+UE
+ue
+Y
+y
+Z
+z
+SELECT latin1_f COLLATE latin1_bin AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
+latin1_f_as
+A
+AD
+AE
+AF
+B
+SS
+U
+UE
+Y
+Z
+a
+ad
+ae
+af
+b
+ss
+u
+ue
+y
+z
+SELECT latin1_f COLLATE koi8r_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
+ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f;
+latin1_f count(*)
+A 2
+AD 2
+AE 2
+AF 2
+B 2
+SS 2
+U 2
+UE 2
+Ü 4
+Z 2
+Å 2
+Ä 2
+ß 1
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_swedish_ci;
+latin1_f count(*)
+A 2
+AD 2
+AE 2
+AF 2
+B 2
+SS 2
+U 2
+UE 2
+Ü 4
+Z 2
+Å 2
+Ä 2
+ß 1
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_german2_ci;
+latin1_f count(*)
+A 4
+AD 2
+AE 2
+Ä 2
+AF 2
+B 2
+SS 2
+ß 1
+U 2
+UE 2
+Ü 2
+Y 2
+Z 2
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_general_ci;
+latin1_f count(*)
+A 2
+AD 2
+AE 2
+AF 2
+Ä 2
+Å 2
+B 2
+SS 2
+ß 1
+U 2
+UE 2
+Ü 2
+Y 2
+Z 2
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_bin;
+latin1_f count(*)
+A 1
+AD 1
+AE 1
+AF 1
+B 1
+SS 1
+U 1
+UE 1
+Y 1
+Z 1
+a 1
+ad 1
+ae 1
+af 1
+b 1
+ss 1
+u 1
+ue 1
+y 1
+z 1
+Ä 1
+Å 1
+Ü 1
+ß 1
+ä 1
+å 1
+ü 1
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE koi8r_general_ci;
+ERROR 42000: COLLATION 'koi8r_general_ci' is not valid for CHARACTER SET 'latin1'
+SELECT DISTINCT latin1_f FROM t1;
+latin1_f
+A
+AD
+AE
+AF
+B
+U
+UE
+SS
+Z
+SELECT DISTINCT latin1_f COLLATE latin1_swedish_ci FROM t1;
+latin1_f COLLATE latin1_swedish_ci
+A
+AD
+AE
+AF
+B
+U
+UE
+SS
+Z
+SELECT DISTINCT latin1_f COLLATE latin1_german2_ci FROM t1;
+latin1_f COLLATE latin1_german2_ci
+A
+AD
+AE
+AF
+B
+U
+UE
+SS
+Y
+Z
+SELECT DISTINCT latin1_f COLLATE latin1_general_ci FROM t1;
+latin1_f COLLATE latin1_general_ci
+A
+AD
+AE
+AF
+B
+U
+UE
+SS
+Y
+Z
+SELECT DISTINCT latin1_f COLLATE latin1_bin FROM t1;
+latin1_f COLLATE latin1_bin
+A
+a
+AD
+ad
+AE
+ae
+AF
+af
+B
+b
+U
+u
+UE
+ue
+SS
+ss
+Y
+y
+Z
+z
+SELECT DISTINCT latin1_f COLLATE koi8r FROM t1;
+ERROR HY000: Unknown collation: 'koi8r'
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `latin1_f` char(32) NOT NULL default ''
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+SHOW FIELDS FROM t1;
+Field Type Null Key Default Extra
+latin1_f char(32)
+ALTER TABLE t1 CHANGE latin1_f
+latin1_f CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `latin1_f` char(32) character set latin1 collate latin1_bin default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+SHOW FIELDS FROM t1;
+Field Type Null Key Default Extra
+latin1_f char(32) YES NULL
+ALTER TABLE t1 CHARACTER SET latin1 COLLATE latin1_bin;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `latin1_f` char(32) character set latin1 collate latin1_bin default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+SHOW FIELDS FROM t1;
+Field Type Null Key Default Extra
+latin1_f char(32) YES NULL
+SET CHARACTER SET 'latin1';
+SHOW VARIABLES LIKE 'character_set_client';
+Variable_name Value
+character_set_client latin1
+SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
+charset('a') collation('a') coercibility('a') 'a'='A'
+latin1 latin1_swedish_ci 3 1
+explain extended SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority charset(_latin1'a') AS `charset('a')`,collation(_latin1'a') AS `collation('a')`,coercibility(_latin1'a') AS `coercibility('a')`,(_latin1'a' = _latin1'A') AS `'a'='A'`
+SET CHARACTER SET koi8r;
+SHOW VARIABLES LIKE 'collation_client';
+Variable_name Value
+SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
+charset('a') collation('a') coercibility('a') 'a'='A'
+latin1 latin1_swedish_ci 3 1
+SET CHARACTER SET 'DEFAULT';
+ERROR 42000: Unknown character set: 'DEFAULT'
+DROP TABLE t1;
+CREATE TABLE t1
+(s1 CHAR(5) COLLATE latin1_german1_ci,
+s2 CHAR(5) COLLATE latin1_swedish_ci);
+SELECT * FROM t1 WHERE s1 = s2;
+ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '='
+DROP TABLE t1;
diff --git a/mysql-test/r/ctype_latin1_de.result b/mysql-test/r/ctype_latin1_de.result
index 28394d9533a..f1049b81d26 100644
--- a/mysql-test/r/ctype_latin1_de.result
+++ b/mysql-test/r/ctype_latin1_de.result
@@ -1,3 +1,6 @@
+select @@collation_connection;
+@@collation_connection
+latin1_german2_ci
drop table if exists t1;
create table t1 (a char (20) not null, b int not null auto_increment, index (a,b));
insert into t1 (a) values ('ä'),('ac'),('ae'),('ad'),('Äc'),('aeb');
@@ -216,23 +219,30 @@ a
test
drop table t1;
create table t1 (word varchar(255) not null, word2 varchar(255) not null, index(word));
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `word` varchar(255) collate latin1_german2_ci NOT NULL default '',
+ `word2` varchar(255) collate latin1_german2_ci NOT NULL default '',
+ KEY `word` (`word`)
+) TYPE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci
insert into t1 (word) values ('ss'),(0xDF),(0xE4),('ae');
update t1 set word2=word;
-select word, word=0xdf as t from t1 having t > 0;
+select word, word=binary 0xdf as t from t1 having t > 0;
word t
ß 1
select word, word=cast(0xdf AS CHAR) as t from t1 having t > 0;
word t
ss 1
ß 1
-select * from t1 where word=0xDF;
+select * from t1 where word=binary 0xDF;
word word2
ß ß
select * from t1 where word=CAST(0xDF as CHAR);
word word2
ss ss
ß ß
-select * from t1 where word2=0xDF;
+select * from t1 where word2=binary 0xDF;
word word2
ß ß
select * from t1 where word2=CAST(0xDF as CHAR);
@@ -247,7 +257,7 @@ select * from t1 where word= 0xe4 or word=CAST(0xe4 as CHAR);
word word2
ä ä
ae ae
-select * from t1 where word between 0xDF and 0xDF;
+select * from t1 where word between binary 0xDF and binary 0xDF;
word word2
ß ß
select * from t1 where word between CAST(0xDF AS CHAR) and CAST(0xDF AS CHAR);
@@ -260,10 +270,34 @@ ae ae
select * from t1 where word like 'AE';
word word2
ae ae
-select * from t1 where word like 0xDF;
+select * from t1 where word like binary 0xDF;
word word2
ß ß
select * from t1 where word like CAST(0xDF as CHAR);
word word2
ß ß
drop table t1;
+CREATE TABLE t1 (
+s1 CHAR(5) CHARACTER SET latin1 COLLATE latin1_german2_ci
+);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `s1` char(5) collate latin1_german2_ci default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci
+INSERT INTO t1 VALUES ('Ü');
+INSERT INTO t1 VALUES ('ue');
+SELECT DISTINCT s1 FROM t1;
+s1
+SELECT s1,COUNT(*) FROM t1 GROUP BY s1;
+s1 COUNT(*)
+Ü 2
+SELECT COUNT(DISTINCT s1) FROM t1;
+COUNT(DISTINCT s1)
+1
+SELECT FIELD('ue',s1), FIELD('Ü',s1), s1='ue', s1='Ü' FROM t1;
+FIELD('ue',s1) FIELD('Ü',s1) s1='ue' s1='Ü'
+1 1 1 1
+1 1 1 1
+DROP TABLE t1;
diff --git a/mysql-test/r/ctype_many.result b/mysql-test/r/ctype_many.result
new file mode 100644
index 00000000000..764503f9e22
--- /dev/null
+++ b/mysql-test/r/ctype_many.result
@@ -0,0 +1,1808 @@
+DROP TABLE IF EXISTS t1;
+SET CHARACTER SET latin1;
+CREATE TABLE t1 (
+comment CHAR(32) ASCII NOT NULL,
+koi8_ru_f CHAR(32) CHARACTER SET koi8r NOT NULL
+) CHARSET=latin5;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `comment` char(32) character set latin1 NOT NULL default '',
+ `koi8_ru_f` char(32) character set koi8r NOT NULL default ''
+) TYPE=MyISAM DEFAULT CHARSET=latin5
+ALTER TABLE t1 CHANGE comment comment CHAR(32) CHARACTER SET latin2 NOT NULL;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `comment` char(32) character set latin2 NOT NULL default '',
+ `koi8_ru_f` char(32) character set koi8r NOT NULL default ''
+) TYPE=MyISAM DEFAULT CHARSET=latin5
+ALTER TABLE t1 ADD latin5_f CHAR(32) NOT NULL;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `comment` char(32) character set latin2 NOT NULL default '',
+ `koi8_ru_f` char(32) character set koi8r NOT NULL default '',
+ `latin5_f` char(32) NOT NULL default ''
+) TYPE=MyISAM DEFAULT CHARSET=latin5
+ALTER TABLE t1 DEFAULT CHARSET=latin2;
+ALTER TABLE t1 ADD latin2_f CHAR(32) NOT NULL;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `comment` char(32) NOT NULL default '',
+ `koi8_ru_f` char(32) character set koi8r NOT NULL default '',
+ `latin5_f` char(32) character set latin5 NOT NULL default '',
+ `latin2_f` char(32) NOT NULL default ''
+) TYPE=MyISAM DEFAULT CHARSET=latin2
+ALTER TABLE t1 DROP latin2_f, DROP latin5_f;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `comment` char(32) NOT NULL default '',
+ `koi8_ru_f` char(32) character set koi8r NOT NULL default ''
+) TYPE=MyISAM DEFAULT CHARSET=latin2
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('a','LAT SMALL A');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('b','LAT SMALL B');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('c','LAT SMALL C');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('d','LAT SMALL D');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('e','LAT SMALL E');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('f','LAT SMALL F');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('g','LAT SMALL G');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('h','LAT SMALL H');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('i','LAT SMALL I');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('j','LAT SMALL J');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('k','LAT SMALL K');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('l','LAT SMALL L');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('m','LAT SMALL M');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('n','LAT SMALL N');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('o','LAT SMALL O');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('p','LAT SMALL P');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('q','LAT SMALL Q');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('r','LAT SMALL R');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('s','LAT SMALL S');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('t','LAT SMALL T');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('u','LAT SMALL U');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('v','LAT SMALL V');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('w','LAT SMALL W');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('x','LAT SMALL X');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('y','LAT SMALL Y');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('z','LAT SMALL Z');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('A','LAT CAPIT A');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('B','LAT CAPIT B');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('C','LAT CAPIT C');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('D','LAT CAPIT D');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('E','LAT CAPIT E');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('F','LAT CAPIT F');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('G','LAT CAPIT G');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('H','LAT CAPIT H');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('I','LAT CAPIT I');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('J','LAT CAPIT J');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('K','LAT CAPIT K');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('L','LAT CAPIT L');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('M','LAT CAPIT M');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('N','LAT CAPIT N');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('O','LAT CAPIT O');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('P','LAT CAPIT P');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('Q','LAT CAPIT Q');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('R','LAT CAPIT R');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('S','LAT CAPIT S');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('T','LAT CAPIT T');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('U','LAT CAPIT U');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('V','LAT CAPIT V');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('W','LAT CAPIT W');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('X','LAT CAPIT X');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('Y','LAT CAPIT Y');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('Z','LAT CAPIT Z');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Á','CYR SMALL A');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Â','CYR SMALL BE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'×','CYR SMALL VE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ç','CYR SMALL GE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ä','CYR SMALL DE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Å','CYR SMALL IE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'£','CYR SMALL IO');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ö','CYR SMALL ZHE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ú','CYR SMALL ZE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'É','CYR SMALL I');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ë','CYR SMALL KA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ì','CYR SMALL EL');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Í','CYR SMALL EM');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Î','CYR SMALL EN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ï','CYR SMALL O');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ð','CYR SMALL PE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ò','CYR SMALL ER');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ó','CYR SMALL ES');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ô','CYR SMALL TE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Õ','CYR SMALL U');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Æ','CYR SMALL EF');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'È','CYR SMALL HA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ã','CYR SMALL TSE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Þ','CYR SMALL CHE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Û','CYR SMALL SHA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ý','CYR SMALL SCHA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ß','CYR SMALL HARD SIGN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ù','CYR SMALL YERU');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ø','CYR SMALL SOFT SIGN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ü','CYR SMALL E');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'À','CYR SMALL YU');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ñ','CYR SMALL YA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'á','CYR CAPIT A');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'â','CYR CAPIT BE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'÷','CYR CAPIT VE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ç','CYR CAPIT GE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ä','CYR CAPIT DE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'å','CYR CAPIT IE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'³','CYR CAPIT IO');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ö','CYR CAPIT ZHE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ú','CYR CAPIT ZE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'é','CYR CAPIT I');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ë','CYR CAPIT KA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ì','CYR CAPIT EL');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'í','CYR CAPIT EM');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'î','CYR CAPIT EN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ï','CYR CAPIT O');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ð','CYR CAPIT PE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ò','CYR CAPIT ER');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ó','CYR CAPIT ES');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ô','CYR CAPIT TE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'õ','CYR CAPIT U');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'æ','CYR CAPIT EF');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'è','CYR CAPIT HA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ã','CYR CAPIT TSE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'þ','CYR CAPIT CHE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'û','CYR CAPIT SHA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ý','CYR CAPIT SCHA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ÿ','CYR CAPIT HARD SIGN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ù','CYR CAPIT YERU');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ø','CYR CAPIT SOFT SIGN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ü','CYR CAPIT E');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'à','CYR CAPIT YU');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ñ','CYR CAPIT YA');
+SET CHARACTER SET utf8;
+SELECT koi8_ru_f,MIN(comment),COUNT(*) FROM t1 GROUP BY 1;
+koi8_ru_f MIN(comment) COUNT(*)
+a LAT CAPIT A 2
+b LAT CAPIT B 2
+c LAT CAPIT C 2
+d LAT CAPIT D 2
+e LAT CAPIT E 2
+f LAT CAPIT F 2
+g LAT CAPIT G 2
+h LAT CAPIT H 2
+i LAT CAPIT I 2
+j LAT CAPIT J 2
+k LAT CAPIT K 2
+l LAT CAPIT L 2
+m LAT CAPIT M 2
+n LAT CAPIT N 2
+o LAT CAPIT O 2
+p LAT CAPIT P 2
+q LAT CAPIT Q 2
+r LAT CAPIT R 2
+s LAT CAPIT S 2
+t LAT CAPIT T 2
+u LAT CAPIT U 2
+v LAT CAPIT V 2
+w LAT CAPIT W 2
+x LAT CAPIT X 2
+y LAT CAPIT Y 2
+z LAT CAPIT Z 2
+а CYR CAPIT A 2
+б CYR CAPIT BE 2
+в CYR CAPIT VE 2
+г CYR CAPIT GE 2
+ÐŽ CYR CAPIT DE 2
+е CYR CAPIT IE 2
+ё CYR CAPIT IO 2
+ж CYR CAPIT ZHE 2
+з CYR CAPIT ZE 2
+О CYR CAPIT I 2
+к CYR CAPIT KA 2
+л CYR CAPIT EL 2
+Ќ CYR CAPIT EM 2
+М CYR CAPIT EN 2
+П CYR CAPIT O 2
+п CYR CAPIT PE 2
+р CYR CAPIT ER 2
+с CYR CAPIT ES 2
+т CYR CAPIT TE 2
+у CYR CAPIT U 2
+ф CYR CAPIT EF 2
+х CYR CAPIT HA 2
+ц CYR CAPIT TSE 2
+ч CYR CAPIT CHE 2
+ш CYR CAPIT SHA 2
+щ CYR CAPIT SCHA 2
+ъ CYR CAPIT HARD SIGN 2
+ы CYR CAPIT YERU 2
+ь CYR CAPIT SOFT SIGN 2
+э CYR CAPIT E 2
+ю CYR CAPIT YU 2
+я CYR CAPIT YA 2
+ALTER TABLE t1 ADD utf8_f CHAR(32) CHARACTER SET utf8 NOT NULL;
+UPDATE t1 SET utf8_f=CONVERT(koi8_ru_f USING utf8);
+SET CHARACTER SET koi8r;
+SELECT * FROM t1;
+comment koi8_ru_f utf8_f
+LAT SMALL A a a
+LAT SMALL B b b
+LAT SMALL C c c
+LAT SMALL D d d
+LAT SMALL E e e
+LAT SMALL F f f
+LAT SMALL G g g
+LAT SMALL H h h
+LAT SMALL I i i
+LAT SMALL J j j
+LAT SMALL K k k
+LAT SMALL L l l
+LAT SMALL M m m
+LAT SMALL N n n
+LAT SMALL O o o
+LAT SMALL P p p
+LAT SMALL Q q q
+LAT SMALL R r r
+LAT SMALL S s s
+LAT SMALL T t t
+LAT SMALL U u u
+LAT SMALL V v v
+LAT SMALL W w w
+LAT SMALL X x x
+LAT SMALL Y y y
+LAT SMALL Z z z
+LAT CAPIT A A A
+LAT CAPIT B B B
+LAT CAPIT C C C
+LAT CAPIT D D D
+LAT CAPIT E E E
+LAT CAPIT F F F
+LAT CAPIT G G G
+LAT CAPIT H H H
+LAT CAPIT I I I
+LAT CAPIT J J J
+LAT CAPIT K K K
+LAT CAPIT L L L
+LAT CAPIT M M M
+LAT CAPIT N N N
+LAT CAPIT O O O
+LAT CAPIT P P P
+LAT CAPIT Q Q Q
+LAT CAPIT R R R
+LAT CAPIT S S S
+LAT CAPIT T T T
+LAT CAPIT U U U
+LAT CAPIT V V V
+LAT CAPIT W W W
+LAT CAPIT X X X
+LAT CAPIT Y Y Y
+LAT CAPIT Z Z Z
+CYR SMALL A Á Á
+CYR SMALL BE Â Â
+CYR SMALL VE × ×
+CYR SMALL GE Ç Ç
+CYR SMALL DE Ä Ä
+CYR SMALL IE Å Å
+CYR SMALL IO £ £
+CYR SMALL ZHE Ö Ö
+CYR SMALL ZE Ú Ú
+CYR SMALL I É É
+CYR SMALL KA Ë Ë
+CYR SMALL EL Ì Ì
+CYR SMALL EM Í Í
+CYR SMALL EN Î Î
+CYR SMALL O Ï Ï
+CYR SMALL PE Ð Ð
+CYR SMALL ER Ò Ò
+CYR SMALL ES Ó Ó
+CYR SMALL TE Ô Ô
+CYR SMALL U Õ Õ
+CYR SMALL EF Æ Æ
+CYR SMALL HA È È
+CYR SMALL TSE Ã Ã
+CYR SMALL CHE Þ Þ
+CYR SMALL SHA Û Û
+CYR SMALL SCHA Ý Ý
+CYR SMALL HARD SIGN ß ß
+CYR SMALL YERU Ù Ù
+CYR SMALL SOFT SIGN Ø Ø
+CYR SMALL E Ü Ü
+CYR SMALL YU À À
+CYR SMALL YA Ñ Ñ
+CYR CAPIT A á á
+CYR CAPIT BE â â
+CYR CAPIT VE ÷ ÷
+CYR CAPIT GE ç ç
+CYR CAPIT DE ä ä
+CYR CAPIT IE å å
+CYR CAPIT IO ³ ³
+CYR CAPIT ZHE ö ö
+CYR CAPIT ZE ú ú
+CYR CAPIT I é é
+CYR CAPIT KA ë ë
+CYR CAPIT EL ì ì
+CYR CAPIT EM í í
+CYR CAPIT EN î î
+CYR CAPIT O ï ï
+CYR CAPIT PE ð ð
+CYR CAPIT ER ò ò
+CYR CAPIT ES ó ó
+CYR CAPIT TE ô ô
+CYR CAPIT U õ õ
+CYR CAPIT EF æ æ
+CYR CAPIT HA è è
+CYR CAPIT TSE ã ã
+CYR CAPIT CHE þ þ
+CYR CAPIT SHA û û
+CYR CAPIT SCHA ý ý
+CYR CAPIT HARD SIGN ÿ ÿ
+CYR CAPIT YERU ù ù
+CYR CAPIT SOFT SIGN ø ø
+CYR CAPIT E ü ü
+CYR CAPIT YU à à
+CYR CAPIT YA ñ ñ
+select CONVERT(koi8_ru_f, 'cp1251_general_ci', 'utf8_general_ci'), comment from t1;
+CONVERT(koi8_ru_f, 'cp1251_general_ci', 'utf8_general_ci') comment
+a LAT SMALL A
+b LAT SMALL B
+c LAT SMALL C
+d LAT SMALL D
+e LAT SMALL E
+f LAT SMALL F
+g LAT SMALL G
+h LAT SMALL H
+i LAT SMALL I
+j LAT SMALL J
+k LAT SMALL K
+l LAT SMALL L
+m LAT SMALL M
+n LAT SMALL N
+o LAT SMALL O
+p LAT SMALL P
+q LAT SMALL Q
+r LAT SMALL R
+s LAT SMALL S
+t LAT SMALL T
+u LAT SMALL U
+v LAT SMALL V
+w LAT SMALL W
+x LAT SMALL X
+y LAT SMALL Y
+z LAT SMALL Z
+A LAT CAPIT A
+B LAT CAPIT B
+C LAT CAPIT C
+D LAT CAPIT D
+E LAT CAPIT E
+F LAT CAPIT F
+G LAT CAPIT G
+H LAT CAPIT H
+I LAT CAPIT I
+J LAT CAPIT J
+K LAT CAPIT K
+L LAT CAPIT L
+M LAT CAPIT M
+N LAT CAPIT N
+O LAT CAPIT O
+P LAT CAPIT P
+Q LAT CAPIT Q
+R LAT CAPIT R
+S LAT CAPIT S
+T LAT CAPIT T
+U LAT CAPIT U
+V LAT CAPIT V
+W LAT CAPIT W
+X LAT CAPIT X
+Y LAT CAPIT Y
+Z LAT CAPIT Z
+â CYR SMALL A
+÷ CYR SMALL BE
+þ CYR SMALL VE
+ú CYR SMALL GE
+ä CYR SMALL DE
+å CYR SMALL IE
+? CYR SMALL IO
+ã CYR SMALL ZHE
+ÿ CYR SMALL ZE
+ê CYR SMALL I
+ì CYR SMALL KA
+í CYR SMALL EL
+î CYR SMALL EM
+ï CYR SMALL EN
+ð CYR SMALL O
+ò CYR SMALL PE
+ô CYR SMALL ER
+õ CYR SMALL ES
+æ CYR SMALL TE
+è CYR SMALL U
+ö CYR SMALL EF
+é CYR SMALL HA
+ç CYR SMALL TSE
+à CYR SMALL CHE
+ù CYR SMALL SHA
+ü CYR SMALL SCHA
+ñ CYR SMALL HARD SIGN
+ý CYR SMALL YERU
+û CYR SMALL SOFT SIGN
+ø CYR SMALL E
+á CYR SMALL YU
+ó CYR SMALL YA
+Â CYR CAPIT A
+× CYR CAPIT BE
+Þ CYR CAPIT VE
+Ú CYR CAPIT GE
+Ä CYR CAPIT DE
+Å CYR CAPIT IE
+? CYR CAPIT IO
+Ã CYR CAPIT ZHE
+ß CYR CAPIT ZE
+Ê CYR CAPIT I
+Ì CYR CAPIT KA
+Í CYR CAPIT EL
+Î CYR CAPIT EM
+Ï CYR CAPIT EN
+Ð CYR CAPIT O
+Ò CYR CAPIT PE
+Ô CYR CAPIT ER
+Õ CYR CAPIT ES
+Æ CYR CAPIT TE
+È CYR CAPIT U
+Ö CYR CAPIT EF
+É CYR CAPIT HA
+Ç CYR CAPIT TSE
+À CYR CAPIT CHE
+Ù CYR CAPIT SHA
+Ü CYR CAPIT SCHA
+Ñ CYR CAPIT HARD SIGN
+Ý CYR CAPIT YERU
+Û CYR CAPIT SOFT SIGN
+Ø CYR CAPIT E
+Á CYR CAPIT YU
+Ó CYR CAPIT YA
+explain extended select CONVERT(koi8_ru_f, 'cp1251_general_ci', 'utf8_general_ci'), comment from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 116
+Warnings:
+Note 1003 select high_priority convert(test.t1.koi8_ru_f,_latin1'utf8_general_ci',_latin1'cp1251_general_ci') AS `CONVERT(koi8_ru_f, 'cp1251_general_ci', 'utf8_general_ci')`,test.t1.comment AS `comment` from test.t1
+ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL;
+UPDATE t1 SET bin_f=koi8_ru_f;
+SELECT COUNT(DISTINCT bin_f),COUNT(DISTINCT koi8_ru_f),COUNT(DISTINCT utf8_f) FROM t1;
+COUNT(DISTINCT bin_f) COUNT(DISTINCT koi8_ru_f) COUNT(DISTINCT utf8_f)
+116 58 57
+SELECT koi8_ru_f,MIN(comment) FROM t1 GROUP BY 1;
+koi8_ru_f MIN(comment)
+a LAT CAPIT A
+b LAT CAPIT B
+c LAT CAPIT C
+d LAT CAPIT D
+e LAT CAPIT E
+f LAT CAPIT F
+g LAT CAPIT G
+h LAT CAPIT H
+i LAT CAPIT I
+j LAT CAPIT J
+k LAT CAPIT K
+l LAT CAPIT L
+m LAT CAPIT M
+n LAT CAPIT N
+o LAT CAPIT O
+p LAT CAPIT P
+q LAT CAPIT Q
+r LAT CAPIT R
+s LAT CAPIT S
+t LAT CAPIT T
+u LAT CAPIT U
+v LAT CAPIT V
+w LAT CAPIT W
+x LAT CAPIT X
+y LAT CAPIT Y
+z LAT CAPIT Z
+Á CYR CAPIT A
+Â CYR CAPIT BE
+× CYR CAPIT VE
+Ç CYR CAPIT GE
+Ä CYR CAPIT DE
+Å CYR CAPIT IE
+£ CYR CAPIT IO
+Ö CYR CAPIT ZHE
+Ú CYR CAPIT ZE
+É CYR CAPIT I
+Ë CYR CAPIT KA
+Ì CYR CAPIT EL
+Í CYR CAPIT EM
+Î CYR CAPIT EN
+Ï CYR CAPIT O
+Ð CYR CAPIT PE
+Ò CYR CAPIT ER
+Ó CYR CAPIT ES
+Ô CYR CAPIT TE
+Õ CYR CAPIT U
+Æ CYR CAPIT EF
+È CYR CAPIT HA
+Ã CYR CAPIT TSE
+Þ CYR CAPIT CHE
+Û CYR CAPIT SHA
+Ý CYR CAPIT SCHA
+ß CYR CAPIT HARD SIGN
+Ù CYR CAPIT YERU
+Ø CYR CAPIT SOFT SIGN
+Ü CYR CAPIT E
+À CYR CAPIT YU
+Ñ CYR CAPIT YA
+SELECT utf8_f,MIN(comment) FROM t1 GROUP BY 1;
+utf8_f MIN(comment)
+a LAT CAPIT A
+b LAT CAPIT B
+c LAT CAPIT C
+d LAT CAPIT D
+e LAT CAPIT E
+f LAT CAPIT F
+g LAT CAPIT G
+h LAT CAPIT H
+i LAT CAPIT I
+j LAT CAPIT J
+k LAT CAPIT K
+l LAT CAPIT L
+m LAT CAPIT M
+n LAT CAPIT N
+o LAT CAPIT O
+p LAT CAPIT P
+q LAT CAPIT Q
+r LAT CAPIT R
+s LAT CAPIT S
+t LAT CAPIT T
+u LAT CAPIT U
+v LAT CAPIT V
+w LAT CAPIT W
+x LAT CAPIT X
+y LAT CAPIT Y
+z LAT CAPIT Z
+Á CYR CAPIT A
+Â CYR CAPIT BE
+× CYR CAPIT VE
+Ç CYR CAPIT GE
+Ä CYR CAPIT DE
+Å CYR CAPIT IE
+Ö CYR CAPIT ZHE
+Ú CYR CAPIT ZE
+É CYR CAPIT I
+Ë CYR CAPIT KA
+Ì CYR CAPIT EL
+Í CYR CAPIT EM
+Î CYR CAPIT EN
+Ï CYR CAPIT O
+Ð CYR CAPIT PE
+Ò CYR CAPIT ER
+Ó CYR CAPIT ES
+Ô CYR CAPIT TE
+Õ CYR CAPIT U
+Æ CYR CAPIT EF
+È CYR CAPIT HA
+Ã CYR CAPIT TSE
+Þ CYR CAPIT CHE
+Û CYR CAPIT SHA
+Ý CYR CAPIT SCHA
+ß CYR CAPIT HARD SIGN
+Ù CYR CAPIT YERU
+Ø CYR CAPIT SOFT SIGN
+Ü CYR CAPIT E
+À CYR CAPIT YU
+Ñ CYR CAPIT YA
+SELECT DISTINCT koi8_ru_f FROM t1;
+koi8_ru_f
+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
+SELECT DISTINCT utf8_f FROM t1;
+utf8_f
+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
+SELECT lower(koi8_ru_f) FROM t1 ORDER BY 1 DESC;
+lower(koi8_ru_f)
+z
+z
+y
+y
+x
+x
+w
+w
+v
+v
+u
+u
+t
+t
+s
+s
+r
+r
+q
+q
+p
+p
+o
+o
+n
+n
+m
+m
+l
+l
+k
+k
+j
+j
+i
+i
+h
+h
+g
+g
+f
+f
+e
+e
+d
+d
+c
+c
+b
+b
+a
+a
+SELECT lower(utf8_f) FROM t1 ORDER BY 1 DESC;
+lower(utf8_f)
+z
+z
+y
+y
+x
+x
+w
+w
+v
+v
+u
+u
+t
+t
+s
+s
+r
+r
+q
+q
+p
+p
+o
+o
+n
+n
+m
+m
+l
+l
+k
+k
+j
+j
+i
+i
+h
+h
+g
+g
+f
+f
+e
+e
+d
+d
+c
+c
+b
+b
+a
+a
+SELECT t11.comment,t12.comment
+FROM t1 t11,t1 t12 WHERE CONVERT(t11.koi8_ru_f USING utf8)=t12.utf8_f
+ORDER BY t11.koi8_ru_f,t11.comment,t12.comment;
+comment comment
+LAT CAPIT A LAT CAPIT A
+LAT CAPIT A LAT SMALL A
+LAT SMALL A LAT CAPIT A
+LAT SMALL A LAT SMALL A
+LAT CAPIT B LAT CAPIT B
+LAT CAPIT B LAT SMALL B
+LAT SMALL B LAT CAPIT B
+LAT SMALL B LAT SMALL B
+LAT CAPIT C LAT CAPIT C
+LAT CAPIT C LAT SMALL C
+LAT SMALL C LAT CAPIT C
+LAT SMALL C LAT SMALL C
+LAT CAPIT D LAT CAPIT D
+LAT CAPIT D LAT SMALL D
+LAT SMALL D LAT CAPIT D
+LAT SMALL D LAT SMALL D
+LAT CAPIT E LAT CAPIT E
+LAT CAPIT E LAT SMALL E
+LAT SMALL E LAT CAPIT E
+LAT SMALL E LAT SMALL E
+LAT CAPIT F LAT CAPIT F
+LAT CAPIT F LAT SMALL F
+LAT SMALL F LAT CAPIT F
+LAT SMALL F LAT SMALL F
+LAT CAPIT G LAT CAPIT G
+LAT CAPIT G LAT SMALL G
+LAT SMALL G LAT CAPIT G
+LAT SMALL G LAT SMALL G
+LAT CAPIT H LAT CAPIT H
+LAT CAPIT H LAT SMALL H
+LAT SMALL H LAT CAPIT H
+LAT SMALL H LAT SMALL H
+LAT CAPIT I LAT CAPIT I
+LAT CAPIT I LAT SMALL I
+LAT SMALL I LAT CAPIT I
+LAT SMALL I LAT SMALL I
+LAT CAPIT J LAT CAPIT J
+LAT CAPIT J LAT SMALL J
+LAT SMALL J LAT CAPIT J
+LAT SMALL J LAT SMALL J
+LAT CAPIT K LAT CAPIT K
+LAT CAPIT K LAT SMALL K
+LAT SMALL K LAT CAPIT K
+LAT SMALL K LAT SMALL K
+LAT CAPIT L LAT CAPIT L
+LAT CAPIT L LAT SMALL L
+LAT SMALL L LAT CAPIT L
+LAT SMALL L LAT SMALL L
+LAT CAPIT M LAT CAPIT M
+LAT CAPIT M LAT SMALL M
+LAT SMALL M LAT CAPIT M
+LAT SMALL M LAT SMALL M
+LAT CAPIT N LAT CAPIT N
+LAT CAPIT N LAT SMALL N
+LAT SMALL N LAT CAPIT N
+LAT SMALL N LAT SMALL N
+LAT CAPIT O LAT CAPIT O
+LAT CAPIT O LAT SMALL O
+LAT SMALL O LAT CAPIT O
+LAT SMALL O LAT SMALL O
+LAT CAPIT P LAT CAPIT P
+LAT CAPIT P LAT SMALL P
+LAT SMALL P LAT CAPIT P
+LAT SMALL P LAT SMALL P
+LAT CAPIT Q LAT CAPIT Q
+LAT CAPIT Q LAT SMALL Q
+LAT SMALL Q LAT CAPIT Q
+LAT SMALL Q LAT SMALL Q
+LAT CAPIT R LAT CAPIT R
+LAT CAPIT R LAT SMALL R
+LAT SMALL R LAT CAPIT R
+LAT SMALL R LAT SMALL R
+LAT CAPIT S LAT CAPIT S
+LAT CAPIT S LAT SMALL S
+LAT SMALL S LAT CAPIT S
+LAT SMALL S LAT SMALL S
+LAT CAPIT T LAT CAPIT T
+LAT CAPIT T LAT SMALL T
+LAT SMALL T LAT CAPIT T
+LAT SMALL T LAT SMALL T
+LAT CAPIT U LAT CAPIT U
+LAT CAPIT U LAT SMALL U
+LAT SMALL U LAT CAPIT U
+LAT SMALL U LAT SMALL U
+LAT CAPIT V LAT CAPIT V
+LAT CAPIT V LAT SMALL V
+LAT SMALL V LAT CAPIT V
+LAT SMALL V LAT SMALL V
+LAT CAPIT W LAT CAPIT W
+LAT CAPIT W LAT SMALL W
+LAT SMALL W LAT CAPIT W
+LAT SMALL W LAT SMALL W
+LAT CAPIT X LAT CAPIT X
+LAT CAPIT X LAT SMALL X
+LAT SMALL X LAT CAPIT X
+LAT SMALL X LAT SMALL X
+LAT CAPIT Y LAT CAPIT Y
+LAT CAPIT Y LAT SMALL Y
+LAT SMALL Y LAT CAPIT Y
+LAT SMALL Y LAT SMALL Y
+LAT CAPIT Z LAT CAPIT Z
+LAT CAPIT Z LAT SMALL Z
+LAT SMALL Z LAT CAPIT Z
+LAT SMALL Z LAT SMALL Z
+CYR CAPIT A CYR CAPIT A
+CYR CAPIT A CYR SMALL A
+CYR SMALL A CYR CAPIT A
+CYR SMALL A CYR SMALL A
+CYR CAPIT BE CYR CAPIT BE
+CYR CAPIT BE CYR SMALL BE
+CYR SMALL BE CYR CAPIT BE
+CYR SMALL BE CYR SMALL BE
+CYR CAPIT VE CYR CAPIT VE
+CYR CAPIT VE CYR SMALL VE
+CYR SMALL VE CYR CAPIT VE
+CYR SMALL VE CYR SMALL VE
+CYR CAPIT GE CYR CAPIT GE
+CYR CAPIT GE CYR SMALL GE
+CYR SMALL GE CYR CAPIT GE
+CYR SMALL GE CYR SMALL GE
+CYR CAPIT DE CYR CAPIT DE
+CYR CAPIT DE CYR SMALL DE
+CYR SMALL DE CYR CAPIT DE
+CYR SMALL DE CYR SMALL DE
+CYR CAPIT IE CYR CAPIT IE
+CYR CAPIT IE CYR CAPIT IO
+CYR CAPIT IE CYR SMALL IE
+CYR CAPIT IE CYR SMALL IO
+CYR SMALL IE CYR CAPIT IE
+CYR SMALL IE CYR CAPIT IO
+CYR SMALL IE CYR SMALL IE
+CYR SMALL IE CYR SMALL IO
+CYR CAPIT IO CYR CAPIT IE
+CYR CAPIT IO CYR CAPIT IO
+CYR CAPIT IO CYR SMALL IE
+CYR CAPIT IO CYR SMALL IO
+CYR SMALL IO CYR CAPIT IE
+CYR SMALL IO CYR CAPIT IO
+CYR SMALL IO CYR SMALL IE
+CYR SMALL IO CYR SMALL IO
+CYR CAPIT ZHE CYR CAPIT ZHE
+CYR CAPIT ZHE CYR SMALL ZHE
+CYR SMALL ZHE CYR CAPIT ZHE
+CYR SMALL ZHE CYR SMALL ZHE
+CYR CAPIT ZE CYR CAPIT ZE
+CYR CAPIT ZE CYR SMALL ZE
+CYR SMALL ZE CYR CAPIT ZE
+CYR SMALL ZE CYR SMALL ZE
+CYR CAPIT I CYR CAPIT I
+CYR CAPIT I CYR SMALL I
+CYR SMALL I CYR CAPIT I
+CYR SMALL I CYR SMALL I
+CYR CAPIT KA CYR CAPIT KA
+CYR CAPIT KA CYR SMALL KA
+CYR SMALL KA CYR CAPIT KA
+CYR SMALL KA CYR SMALL KA
+CYR CAPIT EL CYR CAPIT EL
+CYR CAPIT EL CYR SMALL EL
+CYR SMALL EL CYR CAPIT EL
+CYR SMALL EL CYR SMALL EL
+CYR CAPIT EM CYR CAPIT EM
+CYR CAPIT EM CYR SMALL EM
+CYR SMALL EM CYR CAPIT EM
+CYR SMALL EM CYR SMALL EM
+CYR CAPIT EN CYR CAPIT EN
+CYR CAPIT EN CYR SMALL EN
+CYR SMALL EN CYR CAPIT EN
+CYR SMALL EN CYR SMALL EN
+CYR CAPIT O CYR CAPIT O
+CYR CAPIT O CYR SMALL O
+CYR SMALL O CYR CAPIT O
+CYR SMALL O CYR SMALL O
+CYR CAPIT PE CYR CAPIT PE
+CYR CAPIT PE CYR SMALL PE
+CYR SMALL PE CYR CAPIT PE
+CYR SMALL PE CYR SMALL PE
+CYR CAPIT ER CYR CAPIT ER
+CYR CAPIT ER CYR SMALL ER
+CYR SMALL ER CYR CAPIT ER
+CYR SMALL ER CYR SMALL ER
+CYR CAPIT ES CYR CAPIT ES
+CYR CAPIT ES CYR SMALL ES
+CYR SMALL ES CYR CAPIT ES
+CYR SMALL ES CYR SMALL ES
+CYR CAPIT TE CYR CAPIT TE
+CYR CAPIT TE CYR SMALL TE
+CYR SMALL TE CYR CAPIT TE
+CYR SMALL TE CYR SMALL TE
+CYR CAPIT U CYR CAPIT U
+CYR CAPIT U CYR SMALL U
+CYR SMALL U CYR CAPIT U
+CYR SMALL U CYR SMALL U
+CYR CAPIT EF CYR CAPIT EF
+CYR CAPIT EF CYR SMALL EF
+CYR SMALL EF CYR CAPIT EF
+CYR SMALL EF CYR SMALL EF
+CYR CAPIT HA CYR CAPIT HA
+CYR CAPIT HA CYR SMALL HA
+CYR SMALL HA CYR CAPIT HA
+CYR SMALL HA CYR SMALL HA
+CYR CAPIT TSE CYR CAPIT TSE
+CYR CAPIT TSE CYR SMALL TSE
+CYR SMALL TSE CYR CAPIT TSE
+CYR SMALL TSE CYR SMALL TSE
+CYR CAPIT CHE CYR CAPIT CHE
+CYR CAPIT CHE CYR SMALL CHE
+CYR SMALL CHE CYR CAPIT CHE
+CYR SMALL CHE CYR SMALL CHE
+CYR CAPIT SHA CYR CAPIT SHA
+CYR CAPIT SHA CYR SMALL SHA
+CYR SMALL SHA CYR CAPIT SHA
+CYR SMALL SHA CYR SMALL SHA
+CYR CAPIT SCHA CYR CAPIT SCHA
+CYR CAPIT SCHA CYR SMALL SCHA
+CYR SMALL SCHA CYR CAPIT SCHA
+CYR SMALL SCHA CYR SMALL SCHA
+CYR CAPIT HARD SIGN CYR CAPIT HARD SIGN
+CYR CAPIT HARD SIGN CYR SMALL HARD SIGN
+CYR SMALL HARD SIGN CYR CAPIT HARD SIGN
+CYR SMALL HARD SIGN CYR SMALL HARD SIGN
+CYR CAPIT YERU CYR CAPIT YERU
+CYR CAPIT YERU CYR SMALL YERU
+CYR SMALL YERU CYR CAPIT YERU
+CYR SMALL YERU CYR SMALL YERU
+CYR CAPIT SOFT SIGN CYR CAPIT SOFT SIGN
+CYR CAPIT SOFT SIGN CYR SMALL SOFT SIGN
+CYR SMALL SOFT SIGN CYR CAPIT SOFT SIGN
+CYR SMALL SOFT SIGN CYR SMALL SOFT SIGN
+CYR CAPIT E CYR CAPIT E
+CYR CAPIT E CYR SMALL E
+CYR SMALL E CYR CAPIT E
+CYR SMALL E CYR SMALL E
+CYR CAPIT YU CYR CAPIT YU
+CYR CAPIT YU CYR SMALL YU
+CYR SMALL YU CYR CAPIT YU
+CYR SMALL YU CYR SMALL YU
+CYR CAPIT YA CYR CAPIT YA
+CYR CAPIT YA CYR SMALL YA
+CYR SMALL YA CYR CAPIT YA
+CYR SMALL YA CYR SMALL YA
+SELECT t11.comment,t12.comment
+FROM t1 t11,t1 t12
+WHERE t11.koi8_ru_f=CONVERT(t12.utf8_f USING koi8r)
+ORDER BY t12.utf8_f,t11.comment,t12.comment;
+comment comment
+LAT CAPIT A LAT CAPIT A
+LAT CAPIT A LAT SMALL A
+LAT SMALL A LAT CAPIT A
+LAT SMALL A LAT SMALL A
+LAT CAPIT B LAT CAPIT B
+LAT CAPIT B LAT SMALL B
+LAT SMALL B LAT CAPIT B
+LAT SMALL B LAT SMALL B
+LAT CAPIT C LAT CAPIT C
+LAT CAPIT C LAT SMALL C
+LAT SMALL C LAT CAPIT C
+LAT SMALL C LAT SMALL C
+LAT CAPIT D LAT CAPIT D
+LAT CAPIT D LAT SMALL D
+LAT SMALL D LAT CAPIT D
+LAT SMALL D LAT SMALL D
+LAT CAPIT E LAT CAPIT E
+LAT CAPIT E LAT SMALL E
+LAT SMALL E LAT CAPIT E
+LAT SMALL E LAT SMALL E
+LAT CAPIT F LAT CAPIT F
+LAT CAPIT F LAT SMALL F
+LAT SMALL F LAT CAPIT F
+LAT SMALL F LAT SMALL F
+LAT CAPIT G LAT CAPIT G
+LAT CAPIT G LAT SMALL G
+LAT SMALL G LAT CAPIT G
+LAT SMALL G LAT SMALL G
+LAT CAPIT H LAT CAPIT H
+LAT CAPIT H LAT SMALL H
+LAT SMALL H LAT CAPIT H
+LAT SMALL H LAT SMALL H
+LAT CAPIT I LAT CAPIT I
+LAT CAPIT I LAT SMALL I
+LAT SMALL I LAT CAPIT I
+LAT SMALL I LAT SMALL I
+LAT CAPIT J LAT CAPIT J
+LAT CAPIT J LAT SMALL J
+LAT SMALL J LAT CAPIT J
+LAT SMALL J LAT SMALL J
+LAT CAPIT K LAT CAPIT K
+LAT CAPIT K LAT SMALL K
+LAT SMALL K LAT CAPIT K
+LAT SMALL K LAT SMALL K
+LAT CAPIT L LAT CAPIT L
+LAT CAPIT L LAT SMALL L
+LAT SMALL L LAT CAPIT L
+LAT SMALL L LAT SMALL L
+LAT CAPIT M LAT CAPIT M
+LAT CAPIT M LAT SMALL M
+LAT SMALL M LAT CAPIT M
+LAT SMALL M LAT SMALL M
+LAT CAPIT N LAT CAPIT N
+LAT CAPIT N LAT SMALL N
+LAT SMALL N LAT CAPIT N
+LAT SMALL N LAT SMALL N
+LAT CAPIT O LAT CAPIT O
+LAT CAPIT O LAT SMALL O
+LAT SMALL O LAT CAPIT O
+LAT SMALL O LAT SMALL O
+LAT CAPIT P LAT CAPIT P
+LAT CAPIT P LAT SMALL P
+LAT SMALL P LAT CAPIT P
+LAT SMALL P LAT SMALL P
+LAT CAPIT Q LAT CAPIT Q
+LAT CAPIT Q LAT SMALL Q
+LAT SMALL Q LAT CAPIT Q
+LAT SMALL Q LAT SMALL Q
+LAT CAPIT R LAT CAPIT R
+LAT CAPIT R LAT SMALL R
+LAT SMALL R LAT CAPIT R
+LAT SMALL R LAT SMALL R
+LAT CAPIT S LAT CAPIT S
+LAT CAPIT S LAT SMALL S
+LAT SMALL S LAT CAPIT S
+LAT SMALL S LAT SMALL S
+LAT CAPIT T LAT CAPIT T
+LAT CAPIT T LAT SMALL T
+LAT SMALL T LAT CAPIT T
+LAT SMALL T LAT SMALL T
+LAT CAPIT U LAT CAPIT U
+LAT CAPIT U LAT SMALL U
+LAT SMALL U LAT CAPIT U
+LAT SMALL U LAT SMALL U
+LAT CAPIT V LAT CAPIT V
+LAT CAPIT V LAT SMALL V
+LAT SMALL V LAT CAPIT V
+LAT SMALL V LAT SMALL V
+LAT CAPIT W LAT CAPIT W
+LAT CAPIT W LAT SMALL W
+LAT SMALL W LAT CAPIT W
+LAT SMALL W LAT SMALL W
+LAT CAPIT X LAT CAPIT X
+LAT CAPIT X LAT SMALL X
+LAT SMALL X LAT CAPIT X
+LAT SMALL X LAT SMALL X
+LAT CAPIT Y LAT CAPIT Y
+LAT CAPIT Y LAT SMALL Y
+LAT SMALL Y LAT CAPIT Y
+LAT SMALL Y LAT SMALL Y
+LAT CAPIT Z LAT CAPIT Z
+LAT CAPIT Z LAT SMALL Z
+LAT SMALL Z LAT CAPIT Z
+LAT SMALL Z LAT SMALL Z
+CYR CAPIT A CYR CAPIT A
+CYR CAPIT A CYR SMALL A
+CYR SMALL A CYR CAPIT A
+CYR SMALL A CYR SMALL A
+CYR CAPIT BE CYR CAPIT BE
+CYR CAPIT BE CYR SMALL BE
+CYR SMALL BE CYR CAPIT BE
+CYR SMALL BE CYR SMALL BE
+CYR CAPIT VE CYR CAPIT VE
+CYR CAPIT VE CYR SMALL VE
+CYR SMALL VE CYR CAPIT VE
+CYR SMALL VE CYR SMALL VE
+CYR CAPIT GE CYR CAPIT GE
+CYR CAPIT GE CYR SMALL GE
+CYR SMALL GE CYR CAPIT GE
+CYR SMALL GE CYR SMALL GE
+CYR CAPIT DE CYR CAPIT DE
+CYR CAPIT DE CYR SMALL DE
+CYR SMALL DE CYR CAPIT DE
+CYR SMALL DE CYR SMALL DE
+CYR CAPIT IE CYR CAPIT IE
+CYR CAPIT IE CYR SMALL IE
+CYR CAPIT IO CYR CAPIT IO
+CYR CAPIT IO CYR SMALL IO
+CYR SMALL IE CYR CAPIT IE
+CYR SMALL IE CYR SMALL IE
+CYR SMALL IO CYR CAPIT IO
+CYR SMALL IO CYR SMALL IO
+CYR CAPIT ZHE CYR CAPIT ZHE
+CYR CAPIT ZHE CYR SMALL ZHE
+CYR SMALL ZHE CYR CAPIT ZHE
+CYR SMALL ZHE CYR SMALL ZHE
+CYR CAPIT ZE CYR CAPIT ZE
+CYR CAPIT ZE CYR SMALL ZE
+CYR SMALL ZE CYR CAPIT ZE
+CYR SMALL ZE CYR SMALL ZE
+CYR CAPIT I CYR CAPIT I
+CYR CAPIT I CYR SMALL I
+CYR SMALL I CYR CAPIT I
+CYR SMALL I CYR SMALL I
+CYR CAPIT KA CYR CAPIT KA
+CYR CAPIT KA CYR SMALL KA
+CYR SMALL KA CYR CAPIT KA
+CYR SMALL KA CYR SMALL KA
+CYR CAPIT EL CYR CAPIT EL
+CYR CAPIT EL CYR SMALL EL
+CYR SMALL EL CYR CAPIT EL
+CYR SMALL EL CYR SMALL EL
+CYR CAPIT EM CYR CAPIT EM
+CYR CAPIT EM CYR SMALL EM
+CYR SMALL EM CYR CAPIT EM
+CYR SMALL EM CYR SMALL EM
+CYR CAPIT EN CYR CAPIT EN
+CYR CAPIT EN CYR SMALL EN
+CYR SMALL EN CYR CAPIT EN
+CYR SMALL EN CYR SMALL EN
+CYR CAPIT O CYR CAPIT O
+CYR CAPIT O CYR SMALL O
+CYR SMALL O CYR CAPIT O
+CYR SMALL O CYR SMALL O
+CYR CAPIT PE CYR CAPIT PE
+CYR CAPIT PE CYR SMALL PE
+CYR SMALL PE CYR CAPIT PE
+CYR SMALL PE CYR SMALL PE
+CYR CAPIT ER CYR CAPIT ER
+CYR CAPIT ER CYR SMALL ER
+CYR SMALL ER CYR CAPIT ER
+CYR SMALL ER CYR SMALL ER
+CYR CAPIT ES CYR CAPIT ES
+CYR CAPIT ES CYR SMALL ES
+CYR SMALL ES CYR CAPIT ES
+CYR SMALL ES CYR SMALL ES
+CYR CAPIT TE CYR CAPIT TE
+CYR CAPIT TE CYR SMALL TE
+CYR SMALL TE CYR CAPIT TE
+CYR SMALL TE CYR SMALL TE
+CYR CAPIT U CYR CAPIT U
+CYR CAPIT U CYR SMALL U
+CYR SMALL U CYR CAPIT U
+CYR SMALL U CYR SMALL U
+CYR CAPIT EF CYR CAPIT EF
+CYR CAPIT EF CYR SMALL EF
+CYR SMALL EF CYR CAPIT EF
+CYR SMALL EF CYR SMALL EF
+CYR CAPIT HA CYR CAPIT HA
+CYR CAPIT HA CYR SMALL HA
+CYR SMALL HA CYR CAPIT HA
+CYR SMALL HA CYR SMALL HA
+CYR CAPIT TSE CYR CAPIT TSE
+CYR CAPIT TSE CYR SMALL TSE
+CYR SMALL TSE CYR CAPIT TSE
+CYR SMALL TSE CYR SMALL TSE
+CYR CAPIT CHE CYR CAPIT CHE
+CYR CAPIT CHE CYR SMALL CHE
+CYR SMALL CHE CYR CAPIT CHE
+CYR SMALL CHE CYR SMALL CHE
+CYR CAPIT SHA CYR CAPIT SHA
+CYR CAPIT SHA CYR SMALL SHA
+CYR SMALL SHA CYR CAPIT SHA
+CYR SMALL SHA CYR SMALL SHA
+CYR CAPIT SCHA CYR CAPIT SCHA
+CYR CAPIT SCHA CYR SMALL SCHA
+CYR SMALL SCHA CYR CAPIT SCHA
+CYR SMALL SCHA CYR SMALL SCHA
+CYR CAPIT HARD SIGN CYR CAPIT HARD SIGN
+CYR CAPIT HARD SIGN CYR SMALL HARD SIGN
+CYR SMALL HARD SIGN CYR CAPIT HARD SIGN
+CYR SMALL HARD SIGN CYR SMALL HARD SIGN
+CYR CAPIT YERU CYR CAPIT YERU
+CYR CAPIT YERU CYR SMALL YERU
+CYR SMALL YERU CYR CAPIT YERU
+CYR SMALL YERU CYR SMALL YERU
+CYR CAPIT SOFT SIGN CYR CAPIT SOFT SIGN
+CYR CAPIT SOFT SIGN CYR SMALL SOFT SIGN
+CYR SMALL SOFT SIGN CYR CAPIT SOFT SIGN
+CYR SMALL SOFT SIGN CYR SMALL SOFT SIGN
+CYR CAPIT E CYR CAPIT E
+CYR CAPIT E CYR SMALL E
+CYR SMALL E CYR CAPIT E
+CYR SMALL E CYR SMALL E
+CYR CAPIT YU CYR CAPIT YU
+CYR CAPIT YU CYR SMALL YU
+CYR SMALL YU CYR CAPIT YU
+CYR SMALL YU CYR SMALL YU
+CYR CAPIT YA CYR CAPIT YA
+CYR CAPIT YA CYR SMALL YA
+CYR SMALL YA CYR CAPIT YA
+CYR SMALL YA CYR SMALL YA
+SET CHARACTER SET utf8;
+ALTER TABLE t1 ADD ucs2_f CHAR(32) CHARACTER SET ucs2;
+ALTER TABLE t1 CHANGE ucs2_f ucs2_f CHAR(32) UNICODE NOT NULL;
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0391,'GREEK CAPIT ALPHA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0392,'GREEK CAPIT BETA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0393,'GREEK CAPIT GAMMA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0394,'GREEK CAPIT DELTA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0395,'GREEK CAPIT EPSILON');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B1,'GREEK SMALL ALPHA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B2,'GREEK SMALL BETA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B3,'GREEK SMALL GAMMA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B4,'GREEK SMALL DELTA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B5,'GREEK SMALL EPSILON');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0531,'ARMENIAN CAPIT AYB');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0532,'ARMENIAN CAPIT BEN');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0533,'ARMENIAN CAPIT GIM');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0534,'ARMENIAN CAPIT DA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0535,'ARMENIAN CAPIT ECH');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0536,'ARMENIAN CAPIT ZA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0561,'ARMENIAN SMALL YAB');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0562,'ARMENIAN SMALL BEN');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0563,'ARMENIAN SMALL GIM');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0564,'ARMENIAN SMALL DA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0565,'ARMENIAN SMALL ECH');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0566,'ARMENIAN SMALL ZA');
+ALTER TABLE t1 ADD armscii8_f CHAR(32) CHARACTER SET armscii8 NOT NULL;
+ALTER TABLE t1 ADD greek_f CHAR(32) CHARACTER SET greek NOT NULL;
+UPDATE t1 SET greek_f=CONVERT(ucs2_f USING greek) WHERE comment LIKE _latin2'GRE%';
+UPDATE t1 SET armscii8_f=CONVERT(ucs2_f USING armscii8) WHERE comment LIKE _latin2'ARM%';
+UPDATE t1 SET utf8_f=CONVERT(ucs2_f USING utf8) WHERE utf8_f=_utf8'';
+UPDATE t1 SET ucs2_f=CONVERT(utf8_f USING ucs2) WHERE ucs2_f=_ucs2'';
+SELECT * FROM t1;
+comment koi8_ru_f utf8_f bin_f ucs2_f armscii8_f greek_f
+LAT SMALL A a a a a
+LAT SMALL B b b b b
+LAT SMALL C c c c c
+LAT SMALL D d d d d
+LAT SMALL E e e e e
+LAT SMALL F f f f f
+LAT SMALL G g g g g
+LAT SMALL H h h h h
+LAT SMALL I i i i i
+LAT SMALL J j j j j
+LAT SMALL K k k k k
+LAT SMALL L l l l l
+LAT SMALL M m m m m
+LAT SMALL N n n n n
+LAT SMALL O o o o o
+LAT SMALL P p p p p
+LAT SMALL Q q q q q
+LAT SMALL R r r r r
+LAT SMALL S s s s s
+LAT SMALL T t t t t
+LAT SMALL U u u u u
+LAT SMALL V v v v v
+LAT SMALL W w w w w
+LAT SMALL X x x x x
+LAT SMALL Y y y y y
+LAT SMALL Z z z z z
+LAT CAPIT A A A A A
+LAT CAPIT B B B B B
+LAT CAPIT C C C C C
+LAT CAPIT D D D D D
+LAT CAPIT E E E E E
+LAT CAPIT F F F F F
+LAT CAPIT G G G G G
+LAT CAPIT H H H H H
+LAT CAPIT I I I I I
+LAT CAPIT J J J J J
+LAT CAPIT K K K K K
+LAT CAPIT L L L L L
+LAT CAPIT M M M M M
+LAT CAPIT N N N N N
+LAT CAPIT O O O O O
+LAT CAPIT P P P P P
+LAT CAPIT Q Q Q Q Q
+LAT CAPIT R R R R R
+LAT CAPIT S S S S S
+LAT CAPIT T T T T T
+LAT CAPIT U U U U U
+LAT CAPIT V V V V V
+LAT CAPIT W W W W W
+LAT CAPIT X X X X X
+LAT CAPIT Y Y Y Y Y
+LAT CAPIT Z Z Z Z Z
+CYR SMALL A а а Á а
+CYR SMALL BE б б  б
+CYR SMALL VE в в × Ð²
+CYR SMALL GE г г Ç Ð³
+CYR SMALL DE ÐŽ ÐŽ Ä ÐŽ
+CYR SMALL IE е е Šе
+CYR SMALL IO ё ё £ ё
+CYR SMALL ZHE ж ж Ö Ð¶
+CYR SMALL ZE з з Ú Ð·
+CYR SMALL I О О É Ðž
+CYR SMALL KA к к Ë Ðº
+CYR SMALL EL л л Ì Ð»
+CYR SMALL EM ÐŒ ÐŒ Í ÐŒ
+CYR SMALL EN М М ΠМ
+CYR SMALL O П П Ï ÐŸ
+CYR SMALL PE п п Рп
+CYR SMALL ER р р Ò Ñ€
+CYR SMALL ES с с Ó Ñ
+CYR SMALL TE т т Ô Ñ‚
+CYR SMALL U у у Õ Ñƒ
+CYR SMALL EF ф ф Æ Ñ„
+CYR SMALL HA х х È Ñ…
+CYR SMALL TSE ц ц à ц
+CYR SMALL CHE ч ч Þ Ñ‡
+CYR SMALL SHA ш ш Û Ñˆ
+CYR SMALL SCHA щ щ Ý Ñ‰
+CYR SMALL HARD SIGN ъ ъ ß ÑŠ
+CYR SMALL YERU ы ы ٠ы
+CYR SMALL SOFT SIGN ь ь Ø ÑŒ
+CYR SMALL E э э Ü Ñ
+CYR SMALL YU ю ю À ю
+CYR SMALL YA я я Ñ Ñ
+CYR CAPIT A А А á А
+CYR CAPIT BE Б Б â Б
+CYR CAPIT VE В В ÷ В
+CYR CAPIT GE Г Г ç Г
+CYR CAPIT DE Д Д ä Д
+CYR CAPIT IE Е Е å Е
+CYR CAPIT IO Ё Ё ³ Ё
+CYR CAPIT ZHE Ж Ж ö Ж
+CYR CAPIT ZE З З ú З
+CYR CAPIT I И И é И
+CYR CAPIT KA К К ë К
+CYR CAPIT EL Л Л ì Л
+CYR CAPIT EM М М í М
+CYR CAPIT EN Н Н î Н
+CYR CAPIT O О О ï О
+CYR CAPIT PE П П ð П
+CYR CAPIT ER Р Р ò Р
+CYR CAPIT ES С С ó С
+CYR CAPIT TE Т Т ô Т
+CYR CAPIT U У У õ У
+CYR CAPIT EF Ѐ Ѐ æ Ѐ
+CYR CAPIT HA Ð¥ Ð¥ è Ð¥
+CYR CAPIT TSE Њ Њ ã Њ
+CYR CAPIT CHE Ч Ч þ Ч
+CYR CAPIT SHA К К û К
+CYR CAPIT SCHA Щ Щ ý Щ
+CYR CAPIT HARD SIGN Ъ Ъ ÿ Ъ
+CYR CAPIT YERU Ы Ы ù Ы
+CYR CAPIT SOFT SIGN Ь Ь ø Ь
+CYR CAPIT E Э Э ü Э
+CYR CAPIT YU Ю Ю à Ю
+CYR CAPIT YA Я Я ñ Я
+GREEK CAPIT ALPHA Α Α Α
+GREEK CAPIT BETA Β Β Β
+GREEK CAPIT GAMMA Γ Γ Γ
+GREEK CAPIT DELTA Δ Δ Δ
+GREEK CAPIT EPSILON Ε Ε Ε
+GREEK SMALL ALPHA α α α
+GREEK SMALL BETA β β β
+GREEK SMALL GAMMA γ γ γ
+GREEK SMALL DELTA ÎŽ ÎŽ ÎŽ
+GREEK SMALL EPSILON ε ε ε
+ARMENIAN CAPIT AYB Ô± Ô± Ô±
+ARMENIAN CAPIT BEN Ô² Ô² Ô²
+ARMENIAN CAPIT GIM Ô³ Ô³ Ô³
+ARMENIAN CAPIT DA ÔŽ ÔŽ ÔŽ
+ARMENIAN CAPIT ECH Ôµ Ôµ Ôµ
+ARMENIAN CAPIT ZA Ô¶ Ô¶ Ô¶
+ARMENIAN SMALL YAB Õ¡ Õ¡ Õ¡
+ARMENIAN SMALL BEN Õ¢ Õ¢ Õ¢
+ARMENIAN SMALL GIM Õ£ Õ£ Õ£
+ARMENIAN SMALL DA Õ€ Õ€ Õ€
+ARMENIAN SMALL ECH Õ¥ Õ¥ Õ¥
+ARMENIAN SMALL ZA ÕŠ ÕŠ ÕŠ
+SET CHARACTER SET 'binary';
+SELECT * FROM t1;
+comment koi8_ru_f utf8_f bin_f ucs2_f armscii8_f greek_f
+LAT SMALL A a a a
+LAT SMALL B b b b
+LAT SMALL C c c c
+LAT SMALL D d d d
+LAT SMALL E e e e
+LAT SMALL F f f f
+LAT SMALL G g g g
+LAT SMALL H h h h
+LAT SMALL I i i i
+LAT SMALL J j j j
+LAT SMALL K k k k
+LAT SMALL L l l l
+LAT SMALL M m m m
+LAT SMALL N n n n
+LAT SMALL O o o o
+LAT SMALL P p p p
+LAT SMALL Q q q q
+LAT SMALL R r r r
+LAT SMALL S s s s
+LAT SMALL T t t t
+LAT SMALL U u u u
+LAT SMALL V v v v
+LAT SMALL W w w w
+LAT SMALL X x x x
+LAT SMALL Y y y y
+LAT SMALL Z z z z
+LAT CAPIT A A A A
+LAT CAPIT B B B B
+LAT CAPIT C C C C
+LAT CAPIT D D D D
+LAT CAPIT E E E E
+LAT CAPIT F F F F
+LAT CAPIT G G G G
+LAT CAPIT H H H H
+LAT CAPIT I I I I
+LAT CAPIT J J J J
+LAT CAPIT K K K K
+LAT CAPIT L L L L
+LAT CAPIT M M M M
+LAT CAPIT N N N N
+LAT CAPIT O O O O
+LAT CAPIT P P P P
+LAT CAPIT Q Q Q Q
+LAT CAPIT R R R R
+LAT CAPIT S S S S
+LAT CAPIT T T T T
+LAT CAPIT U U U U
+LAT CAPIT V V V V
+LAT CAPIT W W W W
+LAT CAPIT X X X X
+LAT CAPIT Y Y Y Y
+LAT CAPIT Z Z Z Z
+CYR SMALL A Á а Á 0
+CYR SMALL BE  б  1
+CYR SMALL VE × Ð² × 2
+CYR SMALL GE Ç Ð³ Ç 3
+CYR SMALL DE Ä ÐŽ Ä 4
+CYR SMALL IE Šе Š5
+CYR SMALL IO £ ё £ Q
+CYR SMALL ZHE Ö Ð¶ Ö 6
+CYR SMALL ZE Ú Ð· Ú 7
+CYR SMALL I É Ðž É 8
+CYR SMALL KA Ë Ðº Ë :
+CYR SMALL EL Ì Ð» Ì ;
+CYR SMALL EM Í ÐŒ Í <
+CYR SMALL EN ΠМ Π=
+CYR SMALL O Ï ÐŸ Ï >
+CYR SMALL PE Рп Р?
+CYR SMALL ER Ò Ñ€ Ò @
+CYR SMALL ES Ó Ñ Ó A
+CYR SMALL TE Ô Ñ‚ Ô B
+CYR SMALL U Õ Ñƒ Õ C
+CYR SMALL EF Æ Ñ„ Æ D
+CYR SMALL HA È Ñ… È E
+CYR SMALL TSE à ц à F
+CYR SMALL CHE Þ Ñ‡ Þ G
+CYR SMALL SHA Û Ñˆ Û H
+CYR SMALL SCHA Ý Ñ‰ Ý I
+CYR SMALL HARD SIGN ß ÑŠ ß J
+CYR SMALL YERU ٠ы ٠K
+CYR SMALL SOFT SIGN Ø ÑŒ Ø L
+CYR SMALL E Ü Ñ Ü M
+CYR SMALL YU À ю À N
+CYR SMALL YA Ñ Ñ Ñ O
+CYR CAPIT A á А á 
+CYR CAPIT BE â Б â 
+CYR CAPIT VE ÷ В ÷ 
+CYR CAPIT GE ç Г ç 
+CYR CAPIT DE ä Д ä 
+CYR CAPIT IE å Е å 
+CYR CAPIT IO ³ Ё ³ 
+CYR CAPIT ZHE ö Ж ö 
+CYR CAPIT ZE ú З ú 
+CYR CAPIT I é И é 
+CYR CAPIT KA ë К ë 
+CYR CAPIT EL ì Л ì 
+CYR CAPIT EM í М í 
+CYR CAPIT EN î Н î 
+CYR CAPIT O ï О ï 
+CYR CAPIT PE ð П ð 
+CYR CAPIT ER ò Р ò 
+CYR CAPIT ES ó С ó !
+CYR CAPIT TE ô Т ô "
+CYR CAPIT U õ У õ #
+CYR CAPIT EF æ Ѐ æ $
+CYR CAPIT HA è Ð¥ è %
+CYR CAPIT TSE ã Њ ã &
+CYR CAPIT CHE þ Ч þ '
+CYR CAPIT SHA û К û (
+CYR CAPIT SCHA ý Щ ý )
+CYR CAPIT HARD SIGN ÿ Ъ ÿ *
+CYR CAPIT YERU ù Ы ù +
+CYR CAPIT SOFT SIGN ø Ь ø ,
+CYR CAPIT E ü Э ü -
+CYR CAPIT YU à Ю à .
+CYR CAPIT YA ñ Я ñ /
+GREEK CAPIT ALPHA Α ‘ Á
+GREEK CAPIT BETA Β ’ Â
+GREEK CAPIT GAMMA Γ “ Ã
+GREEK CAPIT DELTA Δ ” Ä
+GREEK CAPIT EPSILON Ε • Å
+GREEK SMALL ALPHA α ± á
+GREEK SMALL BETA β ² â
+GREEK SMALL GAMMA γ ³ ã
+GREEK SMALL DELTA ÎŽ Ž ä
+GREEK SMALL EPSILON ε µ å
+ARMENIAN CAPIT AYB Ô± 1 ²
+ARMENIAN CAPIT BEN Ô² 2 Ž
+ARMENIAN CAPIT GIM Ô³ 3 ¶
+ARMENIAN CAPIT DA ÔŽ 4 ž
+ARMENIAN CAPIT ECH Ôµ 5 º
+ARMENIAN CAPIT ZA Ô¶ 6 Œ
+ARMENIAN SMALL YAB Õ¡ a ³
+ARMENIAN SMALL BEN Õ¢ b µ
+ARMENIAN SMALL GIM Õ£ c ·
+ARMENIAN SMALL DA Õ€ d ¹
+ARMENIAN SMALL ECH Õ¥ e »
+ARMENIAN SMALL ZA ÕŠ f œ
+SELECT min(comment),count(*) FROM t1 GROUP BY ucs2_f;
+min(comment) count(*)
+LAT CAPIT A 2
+LAT CAPIT B 2
+LAT CAPIT C 2
+LAT CAPIT D 2
+LAT CAPIT E 2
+LAT CAPIT F 2
+LAT CAPIT G 2
+LAT CAPIT H 2
+LAT CAPIT I 2
+LAT CAPIT J 2
+LAT CAPIT K 2
+LAT CAPIT L 2
+LAT CAPIT M 2
+LAT CAPIT N 2
+LAT CAPIT O 2
+LAT CAPIT P 2
+LAT CAPIT Q 2
+LAT CAPIT R 2
+LAT CAPIT S 2
+LAT CAPIT T 2
+LAT CAPIT U 2
+LAT CAPIT V 2
+LAT CAPIT W 2
+LAT CAPIT X 2
+LAT CAPIT Y 2
+LAT CAPIT Z 2
+GREEK CAPIT ALPHA 2
+GREEK CAPIT BETA 2
+GREEK CAPIT GAMMA 2
+GREEK CAPIT DELTA 2
+GREEK CAPIT EPSILON 2
+CYR CAPIT A 2
+CYR CAPIT BE 2
+CYR CAPIT VE 2
+CYR CAPIT GE 2
+CYR CAPIT DE 2
+CYR CAPIT IE 4
+CYR CAPIT ZHE 2
+CYR CAPIT ZE 2
+CYR CAPIT I 2
+CYR CAPIT KA 2
+CYR CAPIT EL 2
+CYR CAPIT EM 2
+CYR CAPIT EN 2
+CYR CAPIT O 2
+CYR CAPIT PE 2
+CYR CAPIT ER 2
+CYR CAPIT ES 2
+CYR CAPIT TE 2
+CYR CAPIT U 2
+CYR CAPIT EF 2
+CYR CAPIT HA 2
+CYR CAPIT TSE 2
+CYR CAPIT CHE 2
+CYR CAPIT SHA 2
+CYR CAPIT SCHA 2
+CYR CAPIT HARD SIGN 2
+CYR CAPIT YERU 2
+CYR CAPIT SOFT SIGN 2
+CYR CAPIT E 2
+CYR CAPIT YU 2
+CYR CAPIT YA 2
+ARMENIAN CAPIT AYB 2
+ARMENIAN CAPIT BEN 2
+ARMENIAN CAPIT GIM 2
+ARMENIAN CAPIT DA 2
+ARMENIAN CAPIT ECH 2
+ARMENIAN CAPIT ZA 2
+DROP TABLE t1;
diff --git a/mysql-test/r/ctype_mb.result b/mysql-test/r/ctype_mb.result
new file mode 100644
index 00000000000..88cd1b4f7fe
--- /dev/null
+++ b/mysql-test/r/ctype_mb.result
@@ -0,0 +1,57 @@
+drop table if exists t1;
+CREATE TABLE t1 SELECT _utf8'test' as c1, _utf8'тест' as c2;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` char(4) character set utf8 NOT NULL default '',
+ `c2` char(4) character set utf8 NOT NULL default ''
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+DELETE FROM t1;
+ALTER TABLE t1 ADD c3 CHAR(4) CHARACTER SET utf8;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` char(4) character set utf8 NOT NULL default '',
+ `c2` char(4) character set utf8 NOT NULL default '',
+ `c3` char(4) character set utf8 default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('aaaabbbbccccdddd','aaaabbbbccccdddd','aaaabbbbccccdddd');
+Warnings:
+Warning 1264 Data truncated for column 'c1' at row 1
+Warning 1264 Data truncated for column 'c2' at row 1
+Warning 1264 Data truncated for column 'c3' at row 1
+SELECT * FROM t1;
+c1 c2 c3
+aaaabbbbcccc aaaabbbbcccc aaaabbbbcccc
+DROP TABLE t1;
+CREATE TABLE t1 (a CHAR(4) CHARACTER SET utf8, KEY key_a(a(3)));
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(4) character set utf8 default NULL,
+ KEY `key_a` (`a`(3))
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+SHOW KEYS FROM t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 1 key_a 1 a A NULL 9 NULL YES BTREE
+ALTER TABLE t1 CHANGE a a CHAR(4);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(4) default NULL,
+ KEY `key_a` (`a`(3))
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+SHOW KEYS FROM t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 1 key_a 1 a A NULL 3 NULL YES BTREE
+ALTER TABLE t1 CHANGE a a CHAR(4) CHARACTER SET utf8;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(4) character set utf8 default NULL,
+ KEY `key_a` (`a`(3))
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+SHOW KEYS FROM t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 1 key_a 1 a A NULL 9 NULL YES BTREE
+DROP TABLE t1;
diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result
new file mode 100644
index 00000000000..5afd2c041c8
--- /dev/null
+++ b/mysql-test/r/ctype_recoding.result
@@ -0,0 +1,80 @@
+SET CHARACTER SET koi8r;
+DROP TABLE IF EXISTS ÔÁÂÌÉÃÁ, t1;
+SET CHARACTER SET koi8r;
+CREATE TABLE t1 (a CHAR(10) CHARACTER SET cp1251) SELECT _koi8r'ÐÒÏÂÁ' AS a;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(10) character set cp1251 default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+SELECT a FROM t1;
+a
+ÐÒÏÂÁ
+SELECT HEX(a) FROM t1;
+HEX(a)
+EFF0EEE1E0
+DROP TABLE t1;
+CREATE TABLE `ÔÁÂÌÉÃÁ`
+(
+ÐÏÌÅ CHAR(32) CHARACTER SET koi8r NOT NULL COMMENT "ËÏÍÍÅÎÔÁÒÉÊ ÐÏÌÑ"
+) COMMENT "ËÏÍÍÅÎÔÁÒÉÊ ÔÁÂÌÉÃÙ";
+SHOW TABLES;
+Tables_in_test
+ÔÁÂÌÉÃÁ
+SHOW CREATE TABLE ÔÁÂÌÉÃÁ;
+Table Create Table
+ÔÁÂÌÉÃÁ CREATE TABLE `ÔÁÂÌÉÃÁ` (
+ `ÐÏÌÅ` char(32) character set koi8r NOT NULL default '' COMMENT 'ËÏÍÍÅÎÔÁÒÉÊ ÐÏÌÑ'
+) TYPE=MyISAM DEFAULT CHARSET=latin1 COMMENT='ËÏÍÍÅÎÔÁÒÉÊ ÔÁÂÌÉÃÙ'
+SHOW FIELDS FROM ÔÁÂÌÉÃÁ;
+Field Type Null Key Default Extra
+ÐÏÌÅ char(32)
+SET CHARACTER SET cp1251;
+SHOW TABLES;
+Tables_in_test
+òàáëèöà
+SHOW CREATE TABLE òàáëèöà;
+Table Create Table
+òàáëèöà CREATE TABLE `òàáëèöà` (
+ `ïîëå` char(32) character set koi8r NOT NULL default '' COMMENT 'êîììåíòàðèé ïîëÿ'
+) TYPE=MyISAM DEFAULT CHARSET=latin1 COMMENT='êîììåíòàðèé òàáëèöû'
+SHOW FIELDS FROM òàáëèöà;
+Field Type Null Key Default Extra
+ïîëå char(32)
+SET CHARACTER SET utf8;
+SHOW TABLES;
+Tables_in_test
+таблОца
+SHOW CREATE TABLE таблОца;
+Table Create Table
+таблОца CREATE TABLE `таблОца` (
+ `пПле` char(32) character set koi8r NOT NULL default '' COMMENT 'кПЌЌеМтарОй пПля'
+) TYPE=MyISAM DEFAULT CHARSET=latin1 COMMENT='кПЌЌеМтарОй таблОцы'
+SHOW FIELDS FROM таблОца;
+Field Type Null Key Default Extra
+пПле char(32)
+SET CHARACTER SET koi8r;
+DROP TABLE ÔÁÂÌÉÃÁ;
+SET CHARACTER SET default;
+SET CHARACTER SET koi8r;
+CREATE DATABASE ÔÅÓÔ;
+USE ÔÅÓÔ;
+SHOW TABLES;
+Tables_in_ÔÅÓÔ
+SHOW TABLES IN ÔÅÓÔ;
+Tables_in_ÔÅÓÔ
+SET CHARACTER SET cp1251;
+SHOW TABLES;
+Tables_in_òåñò
+SHOW TABLES IN òåñò;
+Tables_in_òåñò
+SET CHARACTER SET koi8r;
+DROP DATABASE ÔÅÓÔ;
+SET NAMES koi8r;
+SELECT hex('ÔÅÓÔ');
+hex('ÔÅÓÔ')
+D4C5D3D4
+SET character_set_connection=cp1251;
+SELECT hex('ÔÅÓÔ');
+hex('ÔÅÓÔ')
+F2E5F1F2
diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result
new file mode 100644
index 00000000000..977797f0278
--- /dev/null
+++ b/mysql-test/r/ctype_ucs.result
@@ -0,0 +1,272 @@
+DROP TABLE IF EXISTS t1;
+SET CHARACTER SET koi8r;
+CREATE TABLE t1 (word VARCHAR(64) CHARACTER SET ucs2);
+INSERT INTO t1 VALUES (_koi8r'ò'), (X'2004');
+SELECT hex(word) FROM t1 ORDER BY word;
+hex(word)
+0420
+2004
+DELETE FROM t1;
+INSERT INTO t1 VALUES (X'042000200020'), (X'200400200020');
+SELECT hex(word) FROM t1 ORDER BY word;
+hex(word)
+0420
+2004
+DROP TABLE t1;
+SELECT LPAD(_ucs2 X'0420',10,_ucs2 X'0421');
+LPAD(_ucs2 X'0420',10,_ucs2 X'0421')
+óóóóóóóóóò
+SELECT LPAD(_ucs2 X'0420',10,_ucs2 X'04210422');
+LPAD(_ucs2 X'0420',10,_ucs2 X'04210422')
+óôóôóôóôóò
+SELECT LPAD(_ucs2 X'0420',10,_ucs2 X'042104220423');
+LPAD(_ucs2 X'0420',10,_ucs2 X'042104220423')
+óôõóôõóôõò
+SELECT LPAD(_ucs2 X'0420042104220423042404250426042704280429042A042B',10,_ucs2 X'042104220423');
+LPAD(_ucs2 X'0420042104220423042404250426042704280429042A042B',10,_ucs2 X'042104220423')
+òóôõæèãþûý
+SELECT RPAD(_ucs2 X'0420',10,_ucs2 X'0421');
+RPAD(_ucs2 X'0420',10,_ucs2 X'0421')
+òóóóóóóóóó
+SELECT RPAD(_ucs2 X'0420',10,_ucs2 X'04210422');
+RPAD(_ucs2 X'0420',10,_ucs2 X'04210422')
+òóôóôóôóôó
+SELECT RPAD(_ucs2 X'0420',10,_ucs2 X'042104220423');
+RPAD(_ucs2 X'0420',10,_ucs2 X'042104220423')
+òóôõóôõóôõ
+SELECT RPAD(_ucs2 X'0420042104220423042404250426042704280429042A042B',10,_ucs2 X'042104220423');
+RPAD(_ucs2 X'0420042104220423042404250426042704280429042A042B',10,_ucs2 X'042104220423')
+òóôõæèãþûý
+CREATE TABLE t1 SELECT
+LPAD(_ucs2 X'0420',10,_ucs2 X'0421') l,
+RPAD(_ucs2 X'0420',10,_ucs2 X'0421') r;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `l` char(10) character set ucs2 NOT NULL default '',
+ `r` char(10) character set ucs2 NOT NULL default ''
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SET NAMES koi8r;
+SET character_set_connection=ucs2;
+create table t1 (a varchar(10) character set ucs2, key(a));
+insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
+explain select * from t1 where a like 'abc%';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 21 NULL 1 Using where; Using index
+explain select * from t1 where a like concat('abc','%');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 21 NULL 1 Using where; Using index
+select * from t1 where a like "abc%";
+a
+abc
+abcd
+select * from t1 where a like concat("abc","%");
+a
+abc
+abcd
+select * from t1 where a like "ABC%";
+a
+abc
+abcd
+select * from t1 where a like "test%";
+a
+test
+select * from t1 where a like "te_t";
+a
+test
+select * from t1 where a like "%a%";
+a
+select * from t1 where a like "%abcd%";
+a
+abcd
+select * from t1 where a like "%abc\d%";
+a
+abcd
+drop table t1;
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET ucs2);
+INSERT INTO t1 VALUES ('ÆÙ×Á'),('æÙ×Á'),('Æù×Á'),('ÆÙ÷Á'),('ÆÙ×á'),('æù÷á');
+INSERT INTO t1 VALUES ('ÆÙ×ÁÐÒÏÌÄÖ'),('æÙ×ÁÐÒÏÌÄÖ'),('Æù×ÁÐÒÏÌÄÖ'),('ÆÙ÷ÁÐÒÏÌÄÖ');
+INSERT INTO t1 VALUES ('ÆÙ×áÐÒÏÌÄÖ'),('ÆÙ×ÁðÒÏÌÄÖ'),('ÆÙ×ÁÐòÏÌÄÖ'),('ÆÙ×ÁÐÒïÌÄÖ');
+INSERT INTO t1 VALUES ('ÆÙ×ÁÐÒÏìÄÖ'),('ÆÙ×ÁÐÒÏÌäÖ'),('ÆÙ×ÁÐÒÏÌÄö'),('æù÷áðòïìäö');
+SELECT * FROM t1 WHERE a LIKE '%Æù×Á%';
+a
+ÆÙ×Á
+æÙ×Á
+Æù×Á
+ÆÙ÷Á
+ÆÙ×á
+æù÷á
+ÆÙ×ÁÐÒÏÌÄÖ
+æÙ×ÁÐÒÏÌÄÖ
+Æù×ÁÐÒÏÌÄÖ
+ÆÙ÷ÁÐÒÏÌÄÖ
+ÆÙ×áÐÒÏÌÄÖ
+ÆÙ×ÁðÒÏÌÄÖ
+ÆÙ×ÁÐòÏÌÄÖ
+ÆÙ×ÁÐÒïÌÄÖ
+ÆÙ×ÁÐÒÏìÄÖ
+ÆÙ×ÁÐÒÏÌäÖ
+ÆÙ×ÁÐÒÏÌÄö
+æù÷áðòïìäö
+SELECT * FROM t1 WHERE a LIKE '%Æù×%';
+a
+ÆÙ×Á
+æÙ×Á
+Æù×Á
+ÆÙ÷Á
+ÆÙ×á
+æù÷á
+ÆÙ×ÁÐÒÏÌÄÖ
+æÙ×ÁÐÒÏÌÄÖ
+Æù×ÁÐÒÏÌÄÖ
+ÆÙ÷ÁÐÒÏÌÄÖ
+ÆÙ×áÐÒÏÌÄÖ
+ÆÙ×ÁðÒÏÌÄÖ
+ÆÙ×ÁÐòÏÌÄÖ
+ÆÙ×ÁÐÒïÌÄÖ
+ÆÙ×ÁÐÒÏìÄÖ
+ÆÙ×ÁÐÒÏÌäÖ
+ÆÙ×ÁÐÒÏÌÄö
+æù÷áðòïìäö
+SELECT * FROM t1 WHERE a LIKE 'Æù×Á%';
+a
+ÆÙ×Á
+æÙ×Á
+Æù×Á
+ÆÙ÷Á
+ÆÙ×á
+æù÷á
+ÆÙ×ÁÐÒÏÌÄÖ
+æÙ×ÁÐÒÏÌÄÖ
+Æù×ÁÐÒÏÌÄÖ
+ÆÙ÷ÁÐÒÏÌÄÖ
+ÆÙ×áÐÒÏÌÄÖ
+ÆÙ×ÁðÒÏÌÄÖ
+ÆÙ×ÁÐòÏÌÄÖ
+ÆÙ×ÁÐÒïÌÄÖ
+ÆÙ×ÁÐÒÏìÄÖ
+ÆÙ×ÁÐÒÏÌäÖ
+ÆÙ×ÁÐÒÏÌÄö
+æù÷áðòïìäö
+SELECT * FROM t1 WHERE a LIKE 'Æù×Á%' COLLATE ucs2_bin;
+a
+Æù×Á
+Æù×ÁÐÒÏÌÄÖ
+DROP TABLE t1;
+CREATE TABLE t1 (word varchar(64) NOT NULL, PRIMARY KEY (word))
+TYPE=MyISAM CHARACTER SET ucs2 COLLATE ucs2_general_ci;
+INSERT INTO t1 (word) VALUES ("cat");
+SELECT * FROM t1 WHERE word LIKE "c%";
+word
+cat
+SELECT * FROM t1 WHERE word LIKE "ca_";
+word
+cat
+SELECT * FROM t1 WHERE word LIKE "cat";
+word
+cat
+SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630025';
+word
+cat
+SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630061005F';
+word
+cat
+DROP TABLE t1;
+SET NAMES latin1;
+CREATE TABLE t1 (
+word VARCHAR(64),
+bar INT(11) default 0,
+PRIMARY KEY (word))
+TYPE=MyISAM
+CHARSET ucs2
+COLLATE ucs2_general_ci ;
+INSERT INTO t1 (word) VALUES ("aar");
+INSERT INTO t1 (word) VALUES ("a");
+INSERT INTO t1 (word) VALUES ("aardvar");
+INSERT INTO t1 (word) VALUES ("aardvark");
+INSERT INTO t1 (word) VALUES ("aardvara");
+INSERT INTO t1 (word) VALUES ("aardvarz");
+EXPLAIN SELECT * FROM t1 ORDER BY word;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
+SELECT * FROM t1 ORDER BY word;
+word bar
+a 0
+aar 0
+aardvar 0
+aardvara 0
+aardvark 0
+aardvarz 0
+EXPLAIN SELECT word FROM t1 ORDER BY word;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 128 NULL 6 Using index
+SELECT word FROM t1 ORDER by word;
+word
+a
+aar
+aardvar
+aardvara
+aardvark
+aardvarz
+DROP TABLE t1;
+CREATE TABLE t1 (
+word VARCHAR(64) ,
+PRIMARY KEY (word))
+TYPE=MyISAM
+CHARSET ucs2
+COLLATE ucs2_general_ci;
+INSERT INTO t1 (word) VALUES ("aar");
+INSERT INTO t1 (word) VALUES ("a");
+INSERT INTO t1 (word) VALUES ("aardvar");
+INSERT INTO t1 (word) VALUES ("aardvark");
+INSERT INTO t1 (word) VALUES ("aardvara");
+INSERT INTO t1 (word) VALUES ("aardvarz");
+EXPLAIN SELECT * FROM t1 ORDER BY WORD;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 128 NULL 6 Using index
+SELECT * FROM t1 ORDER BY word;
+word
+a
+aar
+aardvar
+aardvara
+aardvark
+aardvarz
+DROP TABLE t1;
+CREATE TABLE t1 (
+word TEXT,
+bar INT(11) AUTO_INCREMENT,
+PRIMARY KEY (bar))
+TYPE=MyISAM
+CHARSET ucs2
+COLLATE ucs2_general_ci ;
+INSERT INTO t1 (word) VALUES ("aar");
+INSERT INTO t1 (word) VALUES ("a" );
+INSERT INTO t1 (word) VALUES ("aardvar");
+INSERT INTO t1 (word) VALUES ("aardvark");
+INSERT INTO t1 (word) VALUES ("aardvara");
+INSERT INTO t1 (word) VALUES ("aardvarz");
+EXPLAIN SELECT * FROM t1 ORDER BY word;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
+SELECT * FROM t1 ORDER BY word;
+word bar
+a 2
+aar 1
+aardvar 3
+aardvara 5
+aardvark 4
+aardvarz 6
+EXPLAIN SELECT word FROM t1 ORDER BY word;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using filesort
+SELECT word FROM t1 ORDER BY word;
+word
+a
+aar
+aardvar
+aardvara
+aardvark
+aardvarz
+DROP TABLE t1;
diff --git a/mysql-test/r/ctype_ujis.result b/mysql-test/r/ctype_ujis.result
index 223a18f19e9..1730b17eaed 100644
--- a/mysql-test/r/ctype_ujis.result
+++ b/mysql-test/r/ctype_ujis.result
@@ -1,8 +1,66 @@
drop table if exists t1;
-create table t1 (c text);
+set names ujis;
+create table t1 (c text character set ujis);
insert into t1 values (0xa4a2),(0xa4a3);
select hex(left(c,1)) from t1 group by c;
hex(left(c,1))
A4A2
A4A3
drop table t1;
+select locate(0xa2a1,0xa1a2a1a3);
+locate(0xa2a1,0xa1a2a1a3)
+2
+select locate(_ujis 0xa2a1,_ujis 0xa1a2a1a3);
+locate(_ujis 0xa2a1,_ujis 0xa1a2a1a3)
+0
+select locate(_ujis 0xa2a1,_ujis 0xa1a2a1a3 collate ujis_bin);
+locate(_ujis 0xa2a1,_ujis 0xa1a2a1a3 collate ujis_bin)
+0
+select locate('he','hello');
+locate('he','hello')
+1
+select locate('he','hello',2);
+locate('he','hello',2)
+0
+select locate('lo','hello',2);
+locate('lo','hello',2)
+4
+select locate('HE','hello');
+locate('HE','hello')
+1
+select locate('HE','hello',2);
+locate('HE','hello',2)
+0
+select locate('LO','hello',2);
+locate('LO','hello',2)
+4
+select locate('HE','hello' collate ujis_bin);
+locate('HE','hello' collate ujis_bin)
+0
+select locate('HE','hello' collate ujis_bin,2);
+locate('HE','hello' collate ujis_bin,2)
+0
+select locate('LO','hello' collate ujis_bin,2);
+locate('LO','hello' collate ujis_bin,2)
+0
+select locate(_ujis 0xa1a3,_ujis 0xa1a2a1a3);
+locate(_ujis 0xa1a3,_ujis 0xa1a2a1a3)
+2
+select 0xa1a2a1a3 like concat(_binary'%',0xa2a1,_binary'%');
+0xa1a2a1a3 like concat(_binary'%',0xa2a1,_binary'%')
+1
+select _ujis 0xa1a2a1a3 like concat(_ujis'%',_ujis 0xa2a1, _ujis'%');
+_ujis 0xa1a2a1a3 like concat(_ujis'%',_ujis 0xa2a1, _ujis'%')
+0
+select _ujis 0xa1a2a1a3 like concat(_ujis'%',_ujis 0xa2a1, _ujis'%') collate ujis_bin;
+_ujis 0xa1a2a1a3 like concat(_ujis'%',_ujis 0xa2a1, _ujis'%') collate ujis_bin
+0
+select 'a' like 'a';
+'a' like 'a'
+1
+select 'A' like 'a';
+'A' like 'a'
+1
+select 'A' like 'a' collate ujis_bin;
+'A' like 'a' collate ujis_bin
+0
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
new file mode 100644
index 00000000000..1aef43cd570
--- /dev/null
+++ b/mysql-test/r/ctype_utf8.result
@@ -0,0 +1,64 @@
+set names utf8;
+select left(_utf8 0xD0B0D0B1D0B2,1);
+left(_utf8 0xD0B0D0B1D0B2,1)
+а
+select right(_utf8 0xD0B0D0B2D0B2,1);
+right(_utf8 0xD0B0D0B2D0B2,1)
+в
+select locate('he','hello');
+locate('he','hello')
+1
+select locate('he','hello',2);
+locate('he','hello',2)
+0
+select locate('lo','hello',2);
+locate('lo','hello',2)
+4
+select locate('HE','hello');
+locate('HE','hello')
+1
+select locate('HE','hello',2);
+locate('HE','hello',2)
+0
+select locate('LO','hello',2);
+locate('LO','hello',2)
+4
+select locate('HE','hello' collate utf8_bin);
+locate('HE','hello' collate utf8_bin)
+0
+select locate('HE','hello' collate utf8_bin,2);
+locate('HE','hello' collate utf8_bin,2)
+0
+select locate('LO','hello' collate utf8_bin,2);
+locate('LO','hello' collate utf8_bin,2)
+0
+select locate(_utf8 0xD0B1, _utf8 0xD0B0D0B1D0B2);
+locate(_utf8 0xD0B1, _utf8 0xD0B0D0B1D0B2)
+2
+select locate(_utf8 0xD091, _utf8 0xD0B0D0B1D0B2);
+locate(_utf8 0xD091, _utf8 0xD0B0D0B1D0B2)
+2
+select locate(_utf8 0xD0B1, _utf8 0xD0B0D091D0B2);
+locate(_utf8 0xD0B1, _utf8 0xD0B0D091D0B2)
+2
+select locate(_utf8 0xD091, _utf8 0xD0B0D0B1D0B2 collate utf8_bin);
+locate(_utf8 0xD091, _utf8 0xD0B0D0B1D0B2 collate utf8_bin)
+0
+select locate(_utf8 0xD0B1, _utf8 0xD0B0D091D0B2 collate utf8_bin);
+locate(_utf8 0xD0B1, _utf8 0xD0B0D091D0B2 collate utf8_bin)
+0
+select length(_utf8 0xD0B1), bit_length(_utf8 0xD0B1), char_length(_utf8 0xD0B1);
+length(_utf8 0xD0B1) bit_length(_utf8 0xD0B1) char_length(_utf8 0xD0B1)
+2 16 1
+select 'a' like 'a';
+'a' like 'a'
+1
+select 'A' like 'a';
+'A' like 'a'
+1
+select 'A' like 'a' collate utf8_bin;
+'A' like 'a' collate utf8_bin
+0
+select _utf8 0xD0B0D0B1D0B2 like concat(_utf8'%',_utf8 0xD0B1,_utf8 '%');
+_utf8 0xD0B0D0B1D0B2 like concat(_utf8'%',_utf8 0xD0B1,_utf8 '%')
+1
diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result
new file mode 100644
index 00000000000..5eb21c40a3e
--- /dev/null
+++ b/mysql-test/r/date_formats.result
@@ -0,0 +1,332 @@
+drop table if exists t1;
+Warnings:
+Note 1051 Unknown table 't1'
+SHOW GLOBAL VARIABLES LIKE "%_format%";
+Variable_name Value
+date_format %d.%m.%Y
+datetime_format %Y-%m-%d %H:%i:%s
+default_week_format 0
+time_format %H.%i.%s
+SHOW SESSION VARIABLES LIKE "%_format%";
+Variable_name Value
+date_format %d.%m.%Y
+datetime_format %Y-%m-%d %H:%i:%s
+default_week_format 0
+time_format %H.%i.%s
+SET time_format='%H%i%s';
+SET time_format='%H:%i:%s.%f';
+SET time_format='%h-%i-%s.%f%p';
+SET time_format='%h:%i:%s.%f %p';
+SET time_format='%h:%i:%s%p';
+SET date_format='%Y%m%d';
+SET date_format='%Y.%m.%d';
+SET date_format='%d.%m.%Y';
+SET date_format='%m-%d-%Y';
+set datetime_format= '%Y%m%d%H%i%s';
+set datetime_format= '%Y-%m-%d %H:%i:%s';
+set datetime_format= '%m-%d-%y %H:%i:%s.%f';
+set datetime_format= '%d-%m-%Y %h:%i:%s%p';
+set datetime_format= '%H:%i:%s %Y-%m-%d';
+set datetime_format= '%H:%i:%s.%f %m-%d-%Y';
+set datetime_format= '%h:%i:%s %p %Y-%m-%d';
+set datetime_format= '%h:%i:%s.%f %p %Y-%m-%d';
+SHOW SESSION VARIABLES LIKE "%format";
+Variable_name Value
+date_format %m-%d-%Y
+datetime_format %h:%i:%s.%f %p %Y-%m-%d
+default_week_format 0
+time_format %h:%i:%s%p
+SET time_format='%h:%i:%s';
+ERROR 42000: Variable 'time_format' can't be set to the value of '%h:%i:%s'
+SET time_format='%H %i:%s';
+ERROR 42000: Variable 'time_format' can't be set to the value of '%H %i:%s'
+SET time_format='%H::%i:%s';
+ERROR 42000: Variable 'time_format' can't be set to the value of '%H::%i:%s'
+SET time_format='%H:%i:%s%f';
+ERROR 42000: Variable 'time_format' can't be set to the value of '%H:%i:%s%f'
+SET time_format='%H:%i.%f:%s';
+ERROR 42000: Variable 'time_format' can't be set to the value of '%H:%i.%f:%s'
+SET time_format='%H:%i:%s%p';
+ERROR 42000: Variable 'time_format' can't be set to the value of '%H:%i:%s%p'
+SET time_format='%h:%i:%s.%f %p %Y-%m-%d';
+ERROR 42000: Variable 'time_format' can't be set to the value of '%h:%i:%s.%f %p %Y-%m-%d'
+SET time_format='%H%i%s.%f';
+ERROR 42000: Variable 'time_format' can't be set to the value of '%H%i%s.%f'
+SET time_format='%H:%i-%s.%f';
+ERROR 42000: Variable 'time_format' can't be set to the value of '%H:%i-%s.%f'
+SET date_format='%d.%m.%d';
+ERROR 42000: Variable 'date_format' can't be set to the value of '%d.%m.%d'
+SET datetime_format='%h.%m.%y %d.%i.%s';
+ERROR 42000: Variable 'datetime_format' can't be set to the value of '%h.%m.%y %d.%i.%s'
+set datetime_format= '%H:%i:%s.%f %p %Y-%m-%d';
+ERROR 42000: Variable 'datetime_format' can't be set to the value of '%H:%i:%s.%f %p %Y-%m-%d'
+set GLOBAL datetime_format= '%H:%i:%s %Y-%m-%d';
+SET SESSION datetime_format=default;
+select @@global.datetime_format, @@session.datetime_format;
+@@global.datetime_format @@session.datetime_format
+%H:%i:%s %Y-%m-%d %H:%i:%s %Y-%m-%d
+SET GLOBAL datetime_format=default;
+SET SESSION datetime_format=default;
+select @@global.datetime_format, @@session.datetime_format;
+@@global.datetime_format @@session.datetime_format
+%Y-%m-%d %H:%i:%s %Y-%m-%d %H:%i:%s
+SET GLOBAL date_format=default;
+SET GLOBAL time_format=default;
+SET GLOBAL datetime_format=default;
+SET time_format=default;
+SET date_format=default;
+SET datetime_format=default;
+select str_to_date(concat('15-01-2001',' 2:59:58.999'),
+concat('%d-%m-%Y',' ','%H:%i:%s.%f'));
+str_to_date(concat('15-01-2001',' 2:59:58.999'),
+concat('%d-%m-%Y',' ','%H:%i:%s.%f'))
+2001-01-15 02:59:58.000999
+create table t1 (date char(30), format char(30) not null);
+insert into t1 values
+('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'),
+('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S'),
+('2003-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'),
+('2003-01-02 01:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f%p'),
+('2003-01-02 02:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f %p'),
+('2003-01-02 12:11:12.12345 am', '%Y-%m-%d %h:%i:%S.%f%p'),
+('2003-01-02 11:11:12Pm', '%Y-%m-%d %h:%i:%S%p'),
+('10:20:10', '%H:%i:%s'),
+('10:20:10', '%h:%i:%s.%f'),
+('10:20:10AM', '%h:%i:%s%p'),
+('10:20:10.44AM', '%h:%i:%s.%f%p'),
+('15-01-2001 12:59:58', '%d-%m-%Y %H:%i:%S'),
+('15 September 2001', '%d %M %Y'),
+('15 SEPTEMB 2001', '%d %M %Y'),
+('15 MAY 2001', '%d %b %Y'),
+('Sunday 15 MAY 2001', '%W %d %b %Y'),
+('Sund 15 MAY 2001', '%W %d %b %Y'),
+('Tuesday 00 2002', '%W %U %Y'),
+('Thursday 53 1998', '%W %u %Y'),
+('15-01-2001', '%d-%m-%Y %H:%i:%S'),
+('15-01-20', '%d-%m-%y'),
+('15-2001-1', '%d-%Y-%c');
+select date,format,str_to_date(date, format) as str_to_date from t1;
+date format str_to_date
+2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
+03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S 2003-01-02 08:11:02
+2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
+2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.012345
+2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.012345
+2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.012345
+2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12
+10:20:10 %H:%i:%s 0000-00-00 10:20:10
+10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10
+10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
+10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044
+15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
+15 September 2001 %d %M %Y 2001-09-15 00:00:00
+15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00
+15 MAY 2001 %d %b %Y 2001-05-15 00:00:00
+Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
+Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
+Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00
+Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00
+15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00
+15-01-20 %d-%m-%y 2020-01-15 00:00:00
+15-2001-1 %d-%Y-%c 2001-01-15 00:00:00
+select date,format,concat('',str_to_date(date, format)) as con from t1;
+date format con
+2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
+03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S 2003-01-02 08:11:02
+2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
+2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.012345
+2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.012345
+2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.012345
+2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12
+10:20:10 %H:%i:%s 0000-00-00 10:20:10
+10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10
+10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
+10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044
+15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
+15 September 2001 %d %M %Y 2001-09-15 00:00:00
+15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00
+15 MAY 2001 %d %b %Y 2001-05-15 00:00:00
+Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
+Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
+Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00
+Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00
+15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00
+15-01-20 %d-%m-%y 2020-01-15 00:00:00
+15-2001-1 %d-%Y-%c 2001-01-15 00:00:00
+select date,format,cast(str_to_date(date, format) as datetime) as datetime from t1;
+date format datetime
+2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
+03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S 2003-01-02 08:11:02
+2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
+2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 01:11:12.012345
+2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.012345
+2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.012345
+2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12
+10:20:10 %H:%i:%s 0000-00-00 10:20:10
+10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10
+10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
+10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.000044
+15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
+15 September 2001 %d %M %Y 2001-09-15 00:00:00
+15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00
+15 MAY 2001 %d %b %Y 2001-05-15 00:00:00
+Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
+Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
+Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00
+Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00
+15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00
+15-01-20 %d-%m-%y 2020-01-15 00:00:00
+15-2001-1 %d-%Y-%c 2001-01-15 00:00:00
+select date,format,DATE(str_to_date(date, format)) as date2 from t1;
+date format date2
+2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02
+03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S 2003-01-02
+2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02
+2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 2003-01-02
+2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02
+2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02
+2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02
+10:20:10 %H:%i:%s 0000-00-00
+10:20:10 %h:%i:%s.%f 0000-00-00
+10:20:10AM %h:%i:%s%p 0000-00-00
+10:20:10.44AM %h:%i:%s.%f%p 0000-00-00
+15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15
+15 September 2001 %d %M %Y 2001-09-15
+15 SEPTEMB 2001 %d %M %Y 2001-09-15
+15 MAY 2001 %d %b %Y 2001-05-15
+Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15
+Sund 15 MAY 2001 %W %d %b %Y 2001-05-15
+Tuesday 00 2002 %W %U %Y 2002-01-01
+Thursday 53 1998 %W %u %Y 1998-12-31
+15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15
+15-01-20 %d-%m-%y 2020-01-15
+15-2001-1 %d-%Y-%c 2001-01-15
+select date,format,TIME(str_to_date(date, format)) as time from t1;
+date format time
+2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12
+03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S 08:11:02
+2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12
+2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.012345
+2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.012345
+2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.012345
+2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12
+10:20:10 %H:%i:%s 10:20:10
+10:20:10 %h:%i:%s.%f 10:20:10
+10:20:10AM %h:%i:%s%p 10:20:10
+10:20:10.44AM %h:%i:%s.%f%p 10:20:10.000044
+15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58
+15 September 2001 %d %M %Y 00:00:00
+15 SEPTEMB 2001 %d %M %Y 00:00:00
+15 MAY 2001 %d %b %Y 00:00:00
+Sunday 15 MAY 2001 %W %d %b %Y 00:00:00
+Sund 15 MAY 2001 %W %d %b %Y 00:00:00
+Tuesday 00 2002 %W %U %Y 00:00:00
+Thursday 53 1998 %W %u %Y 00:00:00
+15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00
+15-01-20 %d-%m-%y 00:00:00
+15-2001-1 %d-%Y-%c 00:00:00
+select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1;
+date format time2
+2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12
+03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S 08:11:02
+2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12
+2003-01-02 01:11:12.12345AM %Y-%m-%d %h:%i:%S.%f%p 01:11:12.012345
+2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.012345
+2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.012345
+2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12
+10:20:10 %H:%i:%s 10:20:10
+10:20:10 %h:%i:%s.%f 10:20:10
+10:20:10AM %h:%i:%s%p 10:20:10
+10:20:10.44AM %h:%i:%s.%f%p 10:20:10.000044
+15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58
+15 September 2001 %d %M %Y 00:00:00
+15 SEPTEMB 2001 %d %M %Y 00:00:00
+15 MAY 2001 %d %b %Y 00:00:00
+Sunday 15 MAY 2001 %W %d %b %Y 00:00:00
+Sund 15 MAY 2001 %W %d %b %Y 00:00:00
+Tuesday 00 2002 %W %U %Y 00:00:00
+Thursday 53 1998 %W %u %Y 00:00:00
+15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00
+15-01-20 %d-%m-%y 00:00:00
+15-2001-1 %d-%Y-%c 00:00:00
+truncate table t1;
+insert into t1 values
+('2003-01-02 10:11:12 PM', '%Y-%m-%d %H:%i:%S %p'),
+('2003-01-02 10:11:12.123456', '%Y-%m-%d %h:%i:%S %p'),
+('2003-01-02 10:11:12AM', '%Y-%m-%d %h:%i:%S.%f %p'),
+('2003-01-02 10:11:12AN', '%Y-%m-%d %h:%i:%S%p'),
+('2003-01-02 10:11:12 PM', '%y-%m-%d %H:%i:%S %p'),
+('10:20:10AM', '%H:%i:%s%p'),
+('15 Septembei 2001', '%d %M %Y'),
+('15 Ju 2001', '%d %M %Y'),
+('Sund 15 MA', '%W %d %b %Y'),
+('Sunday 01 2001', '%W %V %X'),
+('Thursdai 12 1998', '%W %u %Y'),
+(NULL, get_format(DATE,'USA')),
+('Tuesday 52 2001', '%W %V %X');
+select date,format,str_to_date(date, format) as str_to_date from t1;
+date format str_to_date
+2003-01-02 10:11:12 PM %Y-%m-%d %H:%i:%S %p NULL
+2003-01-02 10:11:12.123456 %Y-%m-%d %h:%i:%S %p NULL
+2003-01-02 10:11:12AM %Y-%m-%d %h:%i:%S.%f %p NULL
+2003-01-02 10:11:12AN %Y-%m-%d %h:%i:%S%p NULL
+2003-01-02 10:11:12 PM %y-%m-%d %H:%i:%S %p NULL
+10:20:10AM %H:%i:%s%p NULL
+15 Septembei 2001 %d %M %Y NULL
+15 Ju 2001 %d %M %Y NULL
+Sund 15 MA %W %d %b %Y NULL
+Sunday 01 2001 %W %V %X NULL
+Thursdai 12 1998 %W %u %Y NULL
+NULL %m.%d.%Y NULL
+Tuesday 52 2001 %W %V %X NULL
+select date,format,concat(str_to_date(date, format),'') as con from t1;
+date format con
+2003-01-02 10:11:12 PM %Y-%m-%d %H:%i:%S %p NULL
+2003-01-02 10:11:12.123456 %Y-%m-%d %h:%i:%S %p NULL
+2003-01-02 10:11:12AM %Y-%m-%d %h:%i:%S.%f %p NULL
+2003-01-02 10:11:12AN %Y-%m-%d %h:%i:%S%p NULL
+2003-01-02 10:11:12 PM %y-%m-%d %H:%i:%S %p NULL
+10:20:10AM %H:%i:%s%p NULL
+15 Septembei 2001 %d %M %Y NULL
+15 Ju 2001 %d %M %Y NULL
+Sund 15 MA %W %d %b %Y NULL
+Sunday 01 2001 %W %V %X NULL
+Thursdai 12 1998 %W %u %Y NULL
+NULL %m.%d.%Y NULL
+Tuesday 52 2001 %W %V %X NULL
+truncate table t1;
+insert into t1 values
+('10:20:10AM', '%h:%i:%s'),
+('2003-01-02 10:11:12', '%Y-%m-%d %h:%i:%S'),
+('03-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p');
+select date,format,str_to_date(date, format) as str_to_date from t1;
+date format str_to_date
+10:20:10AM %h:%i:%s 0000-00-00 10:20:10
+2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12
+03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 0003-01-02 22:11:12
+select date,format,concat(str_to_date(date, format),'') as con from t1;
+date format con
+10:20:10AM %h:%i:%s 0000-00-00 10:20:10
+2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12
+03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 0003-01-02 22:11:12
+drop table t1;
+select get_format(DATE, 'USA') as a;
+a
+%m.%d.%Y
+select get_format(TIME, 'internal') as a;
+a
+%H%i%s
+select get_format(DATETIME, 'eur') as a;
+a
+%Y-%m-%d %H.%i.%s
+select get_format(DATE, 'TEST') as a;
+a
+NULL
+select str_to_date('15-01-2001 12:59:59', GET_FORMAT(DATE,'USA'));
+str_to_date('15-01-2001 12:59:59', GET_FORMAT(DATE,'USA'))
+NULL
+explain extended select makedate(1997,1), addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM"),cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME), maketime(23,11,12),microsecond("1997-12-31 23:59:59.000001");
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority makedate(1997,1) AS `makedate(1997,1)`,addtime(_latin1'31.12.97 11.59.59.999999 PM',_latin1'31.12.97 11.59.59.999999 PM') AS `addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,subtime(_latin1'31.12.97 11.59.59.999999 PM',_latin1'31.12.97 11.59.59.999999 PM') AS `subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002")`,timediff(_latin1'01.01.97 11:59:59.000001 PM',_latin1'31.12.95 11:59:59.000002 PM') AS `timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM")`,cast(str_to_date(_latin1'15-01-2001 12:59:59',_latin1'%d-%m-%Y %H:%i:%S') as time) AS `cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME)`,maketime(23,11,12) AS `maketime(23,11,12)`,microsecond(_latin1'1997-12-31 23:59:59.000001') AS `microsecond("1997-12-31 23:59:59.000001")`
diff --git a/mysql-test/r/delayed.result b/mysql-test/r/delayed.result
index 9e375203e49..ceb511a7891 100644
--- a/mysql-test/r/delayed.result
+++ b/mysql-test/r/delayed.result
@@ -12,16 +12,16 @@ select * from t1 where tmsp=0;
a tmsp
select * from t1 where tmsp=19711006010203;
a tmsp
-5 19711006010203
-6 19711006010203
-8 19711006010203
+5 1971-10-06 01:02:03
+6 1971-10-06 01:02:03
+8 1971-10-06 01:02:03
drop table t1;
create table t1 (a int not null auto_increment primary key, b char(10));
insert delayed into t1 values (1,"b");
insert delayed into t1 values (null,"c");
insert delayed into t1 values (3,"d"),(null,"e");
insert delayed into t1 values (3,"this will give an","error");
-Column count doesn't match value count at row 1
+ERROR 21S01: Column count doesn't match value count at row 1
select * from t1;
a b
1 b
diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result
index abc8245e69f..62724c19576 100644
--- a/mysql-test/r/delete.result
+++ b/mysql-test/r/delete.result
@@ -1,4 +1,4 @@
-drop table if exists t1;
+drop table if exists t1,t11,t12,t2;
CREATE TABLE t1 (a tinyint(3), b tinyint(5));
INSERT INTO t1 VALUES (1,1);
INSERT LOW_PRIORITY INTO t1 VALUES (1,2);
@@ -24,6 +24,14 @@ create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a));
insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27);
delete from t1 where a=27;
drop table t1;
+CREATE TABLE `t1` (
+`i` int(10) NOT NULL default '0',
+`i2` int(10) NOT NULL default '0',
+PRIMARY KEY (`i`)
+);
+DELETE FROM t1 USING t1 WHERE post='1';
+ERROR 42S22: Unknown column 'post' in 'where clause'
+drop table t1;
CREATE TABLE t1 (
bool char(0) default NULL,
not_null varchar(20) binary NOT NULL default '',
@@ -50,3 +58,65 @@ select count(*) from t1;
count(*)
0
drop table t1;
+create table t11 (a int NOT NULL, b int, primary key (a));
+create table t12 (a int NOT NULL, b int, primary key (a));
+create table t2 (a int NOT NULL, b int, primary key (a));
+insert into t11 values (0, 10),(1, 11),(2, 12);
+insert into t12 values (33, 10),(0, 11),(2, 12);
+insert into t2 values (1, 21),(2, 12),(3, 23);
+select * from t11;
+a b
+0 10
+1 11
+2 12
+select * from t12;
+a b
+33 10
+0 11
+2 12
+select * from t2;
+a b
+1 21
+2 12
+3 23
+delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
+ERROR 21000: Subquery returns more than 1 row
+select * from t11;
+a b
+0 10
+1 11
+2 12
+select * from t12;
+a b
+33 10
+0 11
+2 12
+delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
+Warnings:
+Error 1241 Subquery returns more than 1 row
+Error 1241 Subquery returns more than 1 row
+select * from t11;
+a b
+0 10
+1 11
+select * from t12;
+a b
+33 10
+0 11
+insert into t11 values (2, 12);
+delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
+ERROR 21000: Subquery returns more than 1 row
+select * from t11;
+a b
+0 10
+1 11
+2 12
+delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
+Warnings:
+Error 1241 Subquery returns more than 1 row
+Error 1241 Subquery returns more than 1 row
+select * from t11;
+a b
+0 10
+1 11
+drop table t11, t12, t2;
diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result
new file mode 100644
index 00000000000..6d322078018
--- /dev/null
+++ b/mysql-test/r/derived.result
@@ -0,0 +1,230 @@
+drop table if exists t1,t2,t3;
+select * from (select 2 from DUAL) b;
+2
+2
+SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
+ERROR 42S22: Unknown column 'a' in 'field list'
+SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
+ERROR 42S22: Unknown column 'a' in 'field list'
+CREATE TABLE t1 (a int not null, b char (10) not null);
+insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
+CREATE TABLE t2 (a int not null, b char (10) not null);
+insert into t2 values (3,'c'),(4,'d'),(5,'f'),(6,'e');
+select t1.a,t3.y from t1,(select a as y from t2 where b='c') as t3 where t1.a = t3.y;
+a y
+3 3
+3 3
+select t1.a,t3.a from t1,(select * from t2 where b='c') as t3 where t1.a = t3.a;
+a a
+3 3
+3 3
+CREATE TABLE t3 (a int not null, b char (10) not null);
+insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c');
+select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3.a>3) as t5 where t2.b=t5.b) as t4 where t1.a = t4.y;
+a y
+3 3
+3 3
+SELECT a FROM (SELECT 1 FROM (SELECT 1) a HAVING a=1) b;
+ERROR 42S22: Unknown column 'a' in 'having clause'
+SELECT a,b as a FROM (SELECT '1' as a,'2' as b) b HAVING a=1;
+ERROR 23000: Column: 'a' in having clause is ambiguous
+SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=2;
+a a
+1 2
+SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=1;
+a a
+SELECT 1 FROM (SELECT 1) a WHERE a=2;
+ERROR 42S22: Unknown column 'a' in 'where clause'
+SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) as a;
+ERROR 42S22: Unknown column 'a' in 'having clause'
+select * from t1 as x1, (select * from t1) as x2;
+a b a b
+1 a 1 a
+2 b 1 a
+3 c 1 a
+3 c 1 a
+1 a 2 b
+2 b 2 b
+3 c 2 b
+3 c 2 b
+1 a 3 c
+2 b 3 c
+3 c 3 c
+3 c 3 c
+1 a 3 c
+2 b 3 c
+3 c 3 c
+3 c 3 c
+explain select * from t1 as x1, (select * from t1) as x2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY x1 ALL NULL NULL NULL NULL 4
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4
+2 DERIVED x1 ALL NULL NULL NULL NULL 4
+drop table if exists t2,t3;
+select * from (select 1) as a;
+1
+1
+select a from (select 1 as a) as b;
+a
+1
+select 1 from (select 1) as a;
+1
+1
+select * from (select * from t1 union select * from t1) a;
+a b
+1 a
+2 b
+3 c
+select * from (select * from t1 union all select * from t1) a;
+a b
+1 a
+2 b
+3 c
+3 c
+1 a
+2 b
+3 c
+3 c
+explain select * from (select * from t1 union select * from t1) a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
+2 DERIVED t1 ALL NULL NULL NULL NULL 4
+3 UNION t1 ALL NULL NULL NULL NULL 4
+explain select * from (select * from t1 union all select * from t1) a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 8
+2 DERIVED t1 ALL NULL NULL NULL NULL 4
+3 UNION t1 ALL NULL NULL NULL NULL 4
+CREATE TABLE t2 (a int not null);
+insert into t2 values(1);
+select * from (select * from t1 where t1.a=(select a from t2 where t2.a=t1.a)) a;
+a b
+1 a
+select * from (select * from t1 where t1.a=(select t2.a from t2 where t2.a=t1.a) union select t1.a, t1.b from t1) a;
+a b
+1 a
+2 b
+3 c
+explain select * from (select * from t1,t2 where t1.a=t2.a) t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> system NULL NULL NULL NULL 1
+2 DERIVED t2 system NULL NULL NULL NULL 1
+2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using where
+drop table t1, t2;
+create table t1(a int not null, t char(8), index(a));
+SELECT * FROM (SELECT * FROM t1) as b ORDER BY a ASC LIMIT 0,20;
+a t
+1 1
+2 2
+3 3
+4 4
+5 5
+6 6
+7 7
+8 8
+9 9
+10 10
+11 11
+12 12
+13 13
+14 14
+15 15
+16 16
+17 17
+18 18
+19 19
+20 20
+explain select count(*) from t1 as tt1, (select * from t1) as tt2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+2 DERIVED tt1 ALL NULL NULL NULL NULL 10000
+drop table t1;
+SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
+(SELECT * FROM (SELECT 1 as a) as a )
+1
+select * from (select 1 as a) b left join (select 2 as a) c using(a);
+a a
+1 NULL
+SELECT * FROM (SELECT 1 UNION SELECT a) b;
+ERROR 42S22: Unknown column 'a' in 'field list'
+SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
+ERROR 42S22: Unknown column 'a' in 'field list'
+SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
+ERROR 42S22: Unknown column 'a' in 'field list'
+select 1 from (select 2) a order by 0;
+ERROR 42S22: Unknown column '0' in 'order clause'
+create table t1 (id int);
+insert into t1 values (1),(2),(3);
+describe select * from (select * from t1 group by id) bar;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3
+2 DERIVED t1 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
+drop table t1;
+create table t1 (mat_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, matintnum CHAR(6) NOT NULL, test MEDIUMINT UNSIGNED NULL);
+create table t2 (mat_id MEDIUMINT UNSIGNED NOT NULL, pla_id MEDIUMINT UNSIGNED NOT NULL);
+insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4), (NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8), (NULL, 'i', 9);
+insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105);
+SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
+pla_id mat_id
+100 1
+101 1
+102 1
+103 2
+104 2
+105 3
+SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
+pla_id test
+100 1
+101 1
+102 1
+103 2
+104 2
+105 3
+explain SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY m2 ALL NULL NULL NULL NULL 9
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 Using where
+2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
+2 DERIVED m2 index NULL PRIMARY 3 NULL 9 Using index
+explain SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY m2 ALL NULL NULL NULL NULL 9
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 Using where
+2 DERIVED mp ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
+2 DERIVED m2 index NULL PRIMARY 3 NULL 9 Using index
+drop table t1,t2;
+SELECT a.x FROM (SELECT 1 AS x) AS a HAVING a.x = 1;
+x
+1
+create table t1 select 1 as a;
+select 2 as a from (select * from t1) b;
+ERROR 3D000: No Database Selected
+use test;
+select 2 as a from (select * from t1) b;
+a
+2
+drop table t1;
+select mail_id, if(folder.f_description!='', folder.f_description, folder.f_name) as folder_name, date, address_id, phrase, address, subject from folder, (select mail.mail_id as mail_id, date_format(mail.h_date, '%b %e, %Y %h:%i') as date, mail.folder_id, sender.address_id as address_id, sender.phrase as phrase, sender.address as address, mail.h_subject as subject from mail left join mxa as mxa_sender on mail.mail_id=mxa_sender.mail_id and mxa_sender.type='from' left join address as sender on mxa_sender.address_id=sender.address_id mxa as mxa_recipient, address as recipient, where 1 and mail.mail_id=mxa_recipient.mail_id and mxa_recipient.address_id=recipient.address_id and mxa_recipient.type='to' and match(sender.phrase, sender.address, sender.comment) against ('jeremy' in boolean mode) and match(recipient.phrase, recipient.address, recipient.comment) against ('monty' in boolean mode) order by mail.h_date desc limit 0, 25 ) as query where query.folder_id=folder.folder_id;
+ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'mxa as mxa_recipient, address as recipient, where 1 and mail.mail_id=mxa_r' at line 1
+create table t1 (a int);
+insert into t1 values (1),(2),(3);
+update (select * from t1) as t1 set a = 5;
+ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use
+delete from (select * from t1);
+ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '(select * from t1)' at line 1
+insert into (select * from t1) values (5);
+ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '(select * from t1) values (5)' at line 1
+drop table t1;
+create table t1 (E1 INTEGER UNSIGNED NOT NULL, E2 INTEGER UNSIGNED NOT NULL, E3 INTEGER UNSIGNED NOT NULL, PRIMARY KEY(E1)
+);
+insert into t1 VALUES(1,1,1), (2,2,1);
+select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2;
+count(*)
+2
+explain select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 THEMAX.E2 1 Using where
+2 DERIVED t1 ALL NULL NULL NULL NULL 2 Using where
+3 DEPENDENT SUBQUERY B ALL NULL NULL NULL NULL 2 Using where
+drop table t1;
diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result
index a0343f13394..d9beed25edf 100644
--- a/mysql-test/r/distinct.result
+++ b/mysql-test/r/distinct.result
@@ -172,10 +172,10 @@ b
INSERT INTO t2 values (1),(2),(3);
INSERT INTO t3 VALUES (1,'1'),(2,'2'),(1,'1'),(2,'2');
explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
-table type possible_keys key key_len ref rows Extra
-t3 index a a 5 NULL 6 Using index; Using temporary
-t2 index a a 4 NULL 5 Using index; Distinct
-t1 eq_ref PRIMARY PRIMARY 4 t2.a 1 Using where; Distinct
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 4 Using temporary
+1 SIMPLE t3 ref a a 5 test.t1.b 2 Using where; Using index
+1 SIMPLE t2 index a a 4 NULL 4 Using where; Using index; Distinct
SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a;
a
1
@@ -188,9 +188,9 @@ insert into t3 select * from t4;
insert into t4 select * from t3;
insert into t3 select * from t4;
explain select distinct t1.a from t1,t3 where t1.a=t3.a;
-table type possible_keys key key_len ref rows Extra
-t1 index PRIMARY PRIMARY 4 NULL 4 Using index; Using temporary
-t3 ref a a 5 t1.a 10 Using where; Using index; Distinct
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 4 Using index; Using temporary
+1 SIMPLE t3 ref a a 5 test.t1.a 10 Using where; Using index; Distinct
select distinct t1.a from t1,t3 where t1.a=t3.a;
a
1
@@ -199,29 +199,29 @@ select distinct 1 from t1,t3 where t1.a=t3.a;
1
1
explain SELECT distinct t1.a from t1;
-table type possible_keys key key_len ref rows Extra
-t1 index NULL PRIMARY 4 NULL 4 Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index
explain SELECT distinct t1.a from t1 order by a desc;
-table type possible_keys key key_len ref rows Extra
-t1 index NULL PRIMARY 4 NULL 4 Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index
explain SELECT t1.a from t1 group by a order by a desc;
-table type possible_keys key key_len ref rows Extra
-t1 index NULL PRIMARY 4 NULL 4 Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index
explain SELECT distinct t1.a from t1 order by a desc limit 1;
-table type possible_keys key key_len ref rows Extra
-t1 index NULL PRIMARY 4 NULL 4 Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index
explain SELECT distinct a from t3 order by a desc limit 2;
-table type possible_keys key key_len ref rows Extra
-t3 index NULL a 5 NULL 204 Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 index NULL a 5 NULL 204 Using index
explain SELECT distinct a,b from t3 order by a+1;
-table type possible_keys key key_len ref rows Extra
-t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort
explain SELECT distinct a,b from t3 order by a limit 10;
-table type possible_keys key key_len ref rows Extra
-t3 index NULL a 5 NULL 204 Using temporary
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 index NULL a 5 NULL 204 Using temporary
explain SELECT a,b from t3 group by a,b order by a+1;
-table type possible_keys key key_len ref rows Extra
-t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 ALL NULL NULL NULL NULL 204 Using temporary; Using filesort
drop table t1,t2,t3,t4;
CREATE TABLE t1 (name varchar(255));
INSERT INTO t1 VALUES ('aa'),('ab'),('ac'),('ad'),('ae');
@@ -298,14 +298,14 @@ on j_lj_t3.id=t3_lj.id
WHERE
((t1.id=j_lj_t2.id AND t2_lj.id IS NULL) OR (t1.id=t2.id AND t2.idx=2))
AND ((t1.id=j_lj_t3.id AND t3_lj.id IS NULL) OR (t1.id=t3.id AND t3.idx=2));
-table type possible_keys key key_len ref rows Extra
-t1 index id id 4 NULL 2 Using index; Using temporary
-t2 index id id 8 NULL 1 Using index; Distinct
-t3 index id id 8 NULL 1 Using index; Distinct
-j_lj_t2 index id id 4 NULL 2 Using where; Using index; Distinct
-t2_lj ref id id 4 j_lj_t2.id 1 Using where; Using index; Distinct
-j_lj_t3 index id id 4 NULL 2 Using where; Using index; Distinct
-t3_lj ref id id 4 j_lj_t3.id 1 Using where; Using index; Distinct
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index id id 4 NULL 2 Using index; Using temporary
+1 SIMPLE t2 index id id 8 NULL 1 Using index; Distinct
+1 SIMPLE t3 index id id 8 NULL 1 Using index; Distinct
+1 SIMPLE j_lj_t2 index id id 4 NULL 2 Using where; Using index; Distinct
+1 SIMPLE t2_lj ref id id 4 test.j_lj_t2.id 1 Using where; Using index; Distinct
+1 SIMPLE j_lj_t3 index id id 4 NULL 2 Using where; Using index; Distinct
+1 SIMPLE t3_lj ref id id 4 test.j_lj_t3.id 1 Using where; Using index; Distinct
SELECT DISTINCT
t1.id
from
@@ -326,7 +326,6 @@ AND ((t1.id=j_lj_t3.id AND t3_lj.id IS NULL) OR (t1.id=t3.id AND t3.idx=2));
id
2
drop table t1,t2,t3;
-drop table if exists t1;
create table t1 (a int not null, b int not null, t time);
insert into t1 values (1,1,"00:06:15"),(1,2,"00:06:15"),(1,2,"00:30:15"),(1,3,"00:06:15"),(1,3,"00:30:15");
select a,sec_to_time(sum(time_to_sec(t))) from t1 group by a,b;
@@ -410,7 +409,7 @@ INSERT INTO t2 VALUES (33,6,'Kevin','0','kevin@stileproject.com',1,'',0,'http://
SELECT DISTINCT t1.*, t2.* FROM t1 LEFT JOIN t2 ON (t2.userid = t1.touserid);
privatemessageid folderid userid touserid fromuserid title message dateline showsignature iconid messageread readtime receipt deleteprompt multiplerecipients userid usergroupid username password email styleid parentemail coppauser homepage icq aim yahoo signature adminemail showemail invisible usertitle customtitle joindate cookieuser daysprune lastvisit lastactivity lastpost posts timezoneoffset emailnotification buddylist ignorelist pmfolders receivepm emailonpm pmpopup avatarid avatarrevision options birthday maxposts startofweek ipaddress referrerid nosessionhash autorefresh messagepopup inforum ratenum ratetotal allowrate
128 0 33 33 8 :D 996121863 1 0 2 996122850 2 0 0 33 6 Kevin 0 kevin@stileproject.com 1 0 http://www.stileproject.com 1 1 0 Administrator 0 996120694 1 -1 1030996168 1031027028 1030599436 36 -6 0 1 0 1 0 0 15 0000-00-00 -1 1 64.0.0.0 0 1 -1 0 0 4 19 1
-DROP TABLE IF EXISTS t1,t2;
+DROP TABLE t1,t2;
CREATE TABLE t1 (a int primary key, b int, c int);
INSERT t1 VALUES (1,2,3);
CREATE TABLE t2 (a int primary key, b int, c int);
@@ -418,7 +417,7 @@ INSERT t2 VALUES (3,4,5);
SELECT DISTINCT t1.a, t2.b FROM t1, t2 WHERE t1.a=1 ORDER BY t2.c;
a b
1 4
-DROP TABLE IF EXISTS t1,t2;
+DROP TABLE t1,t2;
CREATE table t1 ( `id` int(11) NOT NULL auto_increment, `name` varchar(50) NOT NULL default '', PRIMARY KEY (`id`)) TYPE=MyISAM AUTO_INCREMENT=3 ;
INSERT INTO t1 VALUES (1, 'aaaaa');
INSERT INTO t1 VALUES (3, 'aaaaa');
@@ -428,3 +427,40 @@ name
a
e
drop table t1;
+CREATE TABLE t1 (
+ID int(11) NOT NULL auto_increment,
+NAME varchar(75) DEFAULT '' NOT NULL,
+LINK_ID int(11) DEFAULT '0' NOT NULL,
+PRIMARY KEY (ID),
+KEY NAME (NAME),
+KEY LINK_ID (LINK_ID)
+);
+INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0);
+INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (2,'Jack',0);
+INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (3,'Bill',0);
+CREATE TABLE t2 (
+ID int(11) NOT NULL auto_increment,
+NAME varchar(150) DEFAULT '' NOT NULL,
+PRIMARY KEY (ID),
+KEY NAME (NAME)
+);
+SELECT DISTINCT
+t2.id AS key_link_id,
+t2.name AS link
+FROM t1
+LEFT JOIN t2 ON t1.link_id=t2.id
+GROUP BY t1.id
+ORDER BY link;
+key_link_id link
+NULL NULL
+drop table t1,t2;
+CREATE TABLE t1 (
+html varchar(5) default NULL,
+rin int(11) default '0',
+out int(11) default '0'
+) TYPE=MyISAM;
+INSERT INTO t1 VALUES ('1',1,0);
+SELECT DISTINCT html,SUM(out)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin;
+html prod
+1 0.00
+drop table t1;
diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result
index 5c732aebbcc..3748af1b8f9 100644
--- a/mysql-test/r/drop.result
+++ b/mysql-test/r/drop.result
@@ -1,17 +1,17 @@
drop table if exists t1;
+drop database if exists mysqltest;
drop table t1;
-Unknown table 't1'
+ERROR 42S02: Unknown table 't1'
create table t1(n int);
insert into t1 values(1);
create temporary table t1( n int);
insert into t1 values(2);
create table t1(n int);
-Table 't1' already exists
+ERROR 42S01: Table 't1' already exists
drop table t1;
select * from t1;
n
1
-drop database if exists mysqltest;
create database mysqltest;
drop database if exists mysqltest;
create database mysqltest;
@@ -43,4 +43,14 @@ Database
mysql
test
drop database mysqltest;
-Can't drop database 'mysqltest'. Database doesn't exist
+ERROR HY000: Can't drop database 'mysqltest'; database doesn't exist
+drop table t1;
+flush tables with read lock;
+create table t1(n int);
+ERROR HY000: Can't execute the query because you have a conflicting read lock
+unlock tables;
+create table t1(n int);
+show tables;
+Tables_in_test
+t1
+drop table t1;
diff --git a/mysql-test/r/drop_temp_table.result b/mysql-test/r/drop_temp_table.result
index 6b18b54335d..78efc9d90e2 100644
--- a/mysql-test/r/drop_temp_table.result
+++ b/mysql-test/r/drop_temp_table.result
@@ -10,9 +10,9 @@ get_lock("a",10)
1
show binlog events;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
-master-bin.001 79 Query 1 79 use `test`; create database `drop-temp+table-test`
-master-bin.001 152 Query 1 152 use `drop-temp+table-test`; create temporary table `table:name` (a int)
-master-bin.001 246 Query 1 246 use `drop-temp+table-test`; DROP /*!40005 TEMPORARY */ TABLE `drop-temp+table-test`.`table:name`
-master-bin.001 365 Query 1 365 use `drop-temp+table-test`; DO RELEASE_LOCK("a")
+master-bin.000001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
+master-bin.000001 79 Query 1 79 use `test`; create database `drop-temp+table-test`
+master-bin.000001 152 Query 1 152 use `drop-temp+table-test`; create temporary table `table:name` (a int)
+master-bin.000001 246 Query 1 246 use `drop-temp+table-test`; DROP /*!40005 TEMPORARY */ TABLE `drop-temp+table-test`.`table:name`
+master-bin.000001 365 Query 1 365 use `drop-temp+table-test`; DO RELEASE_LOCK("a")
drop database `drop-temp+table-test`;
diff --git a/mysql-test/r/errors.result b/mysql-test/r/errors.result
index 5afecc6d600..d0011c8deb6 100644
--- a/mysql-test/r/errors.result
+++ b/mysql-test/r/errors.result
@@ -1,25 +1,25 @@
drop table if exists t1;
insert into t1 values(1);
-Table 'test.t1' doesn't exist
+ERROR 42S02: Table 'test.t1' doesn't exist
delete from t1;
-Table 'test.t1' doesn't exist
+ERROR 42S02: Table 'test.t1' doesn't exist
update t1 set a=1;
-Table 'test.t1' doesn't exist
+ERROR 42S02: Table 'test.t1' doesn't exist
create table t1 (a int);
select count(test.t1.b) from t1;
-Unknown column 'test.t1.b' in 'field list'
+ERROR 42S22: Unknown column 'test.t1.b' in 'field list'
select count(not_existing_database.t1) from t1;
-Unknown table 'not_existing_database' in field list
+ERROR 42S02: Unknown table 'not_existing_database' in field list
select count(not_existing_database.t1.a) from t1;
-Unknown table 'not_existing_database.t1' in field list
+ERROR 42S02: Unknown table 'not_existing_database.t1' in field list
select count(not_existing_database.t1.a) from not_existing_database.t1;
Got one of the listed errors
select 1 from t1 order by 2;
-Unknown column '2' in 'order clause'
+ERROR 42S22: Unknown column '2' in 'order clause'
select 1 from t1 group by 2;
-Unknown column '2' in 'group statement'
+ERROR 42S22: Unknown column '2' in 'group statement'
select 1 from t1 order by t1.b;
-Unknown column 't1.b' in 'order clause'
+ERROR 42S22: Unknown column 't1.b' in 'order clause'
select count(*),b from t1;
-Unknown column 'b' in 'field list'
+ERROR 42S22: Unknown column 'b' in 'field list'
drop table t1;
diff --git a/mysql-test/r/explain.result b/mysql-test/r/explain.result
index d433078a251..02e1ace71e1 100644
--- a/mysql-test/r/explain.result
+++ b/mysql-test/r/explain.result
@@ -1,8 +1,8 @@
drop table if exists t1;
create table t1 (id int not null, str char(10), unique(str));
explain select * from t1;
-table type possible_keys key key_len ref rows Extra
-t1 system NULL NULL NULL NULL 0 const row not found
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found
insert into t1 values (1, null),(2, null),(3, "foo"),(4, "bar");
select * from t1 where str is null;
id str
@@ -12,35 +12,35 @@ select * from t1 where str="foo";
id str
3 foo
explain select * from t1 where str is null;
-table type possible_keys key key_len ref rows Extra
-t1 ref str str 11 const 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref str str 11 const 1 Using where
explain select * from t1 where str="foo";
-table type possible_keys key key_len ref rows Extra
-t1 const str str 11 const 1
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const str str 11 const 1
explain select * from t1 ignore key (str) where str="foo";
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 4 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
explain select * from t1 use key (str,str) where str="foo";
-table type possible_keys key key_len ref rows Extra
-t1 const str str 11 const 1
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const str str 11 const 1
explain select * from t1 use key (str,str,foo) where str="foo";
-Key column 'foo' doesn't exist in table
+ERROR 42000: Key column 'foo' doesn't exist in table
explain select * from t1 ignore key (str,str,foo) where str="foo";
-Key column 'foo' doesn't exist in table
+ERROR 42000: Key column 'foo' doesn't exist in table
drop table t1;
explain select 1;
-Comment
-No tables used
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
create table t1 (a int not null);
explain select count(*) from t1;
-Comment
-Select tables optimized away
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
insert into t1 values(1);
explain select count(*) from t1;
-Comment
-Select tables optimized away
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
insert into t1 values(1);
explain select count(*) from t1;
-Comment
-Select tables optimized away
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
drop table t1;
diff --git a/mysql-test/r/flush.result b/mysql-test/r/flush.result
index 8dc73e446c7..bab9b543307 100644
--- a/mysql-test/r/flush.result
+++ b/mysql-test/r/flush.result
@@ -1,7 +1,6 @@
-drop table if exists t1;
+drop table if exists t1,t2;
drop database if exists mysqltest;
create temporary table t1(n int not null primary key);
-drop table if exists t2;
create table t2(n int);
insert into t2 values(3);
select * from t1;
@@ -9,7 +8,7 @@ n
3
flush tables with read lock;
drop table t2;
-Table 't2' was locked with a READ lock and can't be updated
+ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
drop table t2;
unlock tables;
create database mysqltest;
diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result
index df277a18615..5cb4263f649 100644
--- a/mysql-test/r/fulltext.result
+++ b/mysql-test/r/fulltext.result
@@ -9,6 +9,11 @@ select * from t1 where MATCH(a,b) AGAINST ("collections");
a b
Only MyISAM tables support collections
Full-text indexes are called collections
+explain extended select * from t1 where MATCH(a,b) AGAINST ("collections");
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 fulltext a a 0 1 Using where
+Warnings:
+Note 1003 select high_priority test.t1.a AS `a`,test.t1.b AS `b` from test.t1 where (match test.t1.a,test.t1.b against (_latin1'collections'))
select * from t1 where MATCH(a,b) AGAINST ("indexes");
a b
Full-text indexes are called collections
@@ -16,39 +21,60 @@ select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
a b
Full-text indexes are called collections
Only MyISAM tables support collections
+select * from t1 where MATCH(a,b) AGAINST ("only");
+a b
+select * from t1 where MATCH(a,b) AGAINST ("collections" WITH QUERY EXPANSION);
+a b
+Only MyISAM tables support collections
+Full-text indexes are called collections
+MySQL has now support for full-text search
+select * from t1 where MATCH(a,b) AGAINST ("indexes" WITH QUERY EXPANSION);
+a b
+Full-text indexes are called collections
+Only MyISAM tables support collections
+select * from t1 where MATCH(a,b) AGAINST ("indexes collections" WITH QUERY EXPANSION);
+a b
+Full-text indexes are called collections
+Only MyISAM tables support collections
+MySQL has now support for full-text search
explain select * from t1 where MATCH(a,b) AGAINST ("collections");
-table type possible_keys key key_len ref rows Extra
-t1 fulltext a a 0 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 fulltext a a 0 1 Using where
explain select * from t1 where MATCH(a,b) AGAINST ("collections")>0;
-table type possible_keys key key_len ref rows Extra
-t1 fulltext a a 0 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 fulltext a a 0 1 Using where
explain select * from t1 where MATCH(a,b) AGAINST ("collections")>1;
-table type possible_keys key key_len ref rows Extra
-t1 fulltext a a 0 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 fulltext a a 0 1 Using where
explain select * from t1 where MATCH(a,b) AGAINST ("collections")>=0;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 5 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
explain select * from t1 where MATCH(a,b) AGAINST ("collections")>=1;
-table type possible_keys key key_len ref rows Extra
-t1 fulltext a a 0 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 fulltext a a 0 1 Using where
explain select * from t1 where 0<MATCH(a,b) AGAINST ("collections");
-table type possible_keys key key_len ref rows Extra
-t1 fulltext a a 0 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 fulltext a a 0 1 Using where
explain select * from t1 where 1<MATCH(a,b) AGAINST ("collections");
-table type possible_keys key key_len ref rows Extra
-t1 fulltext a a 0 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 fulltext a a 0 1 Using where
explain select * from t1 where 0<=MATCH(a,b) AGAINST ("collections");
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 5 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
explain select * from t1 where 1<=MATCH(a,b) AGAINST ("collections");
-table type possible_keys key key_len ref rows Extra
-t1 fulltext a a 0 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 fulltext a a 0 1 Using where
explain select * from t1 where MATCH(a,b) AGAINST ("collections")>0 and a like '%ll%';
-table type possible_keys key key_len ref rows Extra
-t1 fulltext a a 0 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 fulltext a a 0 1 Using where
select * from t1 where MATCH(a,b) AGAINST("support -collections" IN BOOLEAN MODE);
a b
MySQL has now support for full-text search
+explain extended select * from t1 where MATCH(a,b) AGAINST("support -collections" IN BOOLEAN MODE);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 fulltext a a 0 1 Using where
+Warnings:
+Note 1003 select high_priority test.t1.a AS `a`,test.t1.b AS `b` from test.t1 where (match test.t1.a,test.t1.b against (_latin1'support -collections' in boolean mode))
select * from t1 where MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE);
a b
MySQL has now support for full-text search
@@ -112,7 +138,8 @@ a b
MySQL has now support for full-text search
select * from t1 where MATCH a,b AGAINST ('"text i"' IN BOOLEAN MODE);
a b
-Full-text indexes are called collections
+select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE);
+a b
select * from t1 where MATCH a AGAINST ("search" IN BOOLEAN MODE);
a b
Full-text search in MySQL implements vector space model
@@ -174,7 +201,7 @@ t2 CREATE TABLE `t2` (
`inhalt` text,
KEY `tig` (`ticket`),
FULLTEXT KEY `tix` (`inhalt`)
-) TYPE=MyISAM
+) TYPE=MyISAM DEFAULT CHARSET=latin1
select * from t2 where MATCH inhalt AGAINST (NULL);
ticket inhalt
select * from t2 where MATCH inhalt AGAINST ('foobar');
@@ -183,6 +210,12 @@ ticket inhalt
select * from t2 having MATCH inhalt AGAINST ('foobar');
ticket inhalt
3 foobar
+CREATE TABLE t3 (t int(11),i text,fulltext tix (t,i));
+ERROR HY000: Column 't' cannot be part of FULLTEXT index
+CREATE TABLE t3 (t int(11),i text,
+j varchar(200) CHARACTER SET latin2,
+fulltext tix (i,j));
+ERROR HY000: Column 'j' cannot be part of FULLTEXT index
CREATE TABLE t3 (
ticket int(11),
inhalt text,
@@ -190,19 +223,19 @@ KEY tig (ticket),
fulltext index tix (inhalt)
);
select * from t2 where MATCH inhalt AGAINST (t2.inhalt);
-Wrong arguments to AGAINST
+ERROR HY000: Wrong arguments to AGAINST
select * from t2 where MATCH ticket AGAINST ('foobar');
-Can't find FULLTEXT index matching the column list
+ERROR HY000: Can't find FULLTEXT index matching the column list
select * from t2,t3 where MATCH (t2.inhalt,t3.inhalt) AGAINST ('foobar');
-Wrong arguments to MATCH
+ERROR HY000: Wrong arguments to MATCH
drop table t1,t2,t3;
CREATE TABLE t1 (
id int(11) auto_increment,
title varchar(100) default '',
PRIMARY KEY (id),
-KEY ind5 (title),
-FULLTEXT KEY FT1 (title)
+KEY ind5 (title)
) TYPE=MyISAM;
+CREATE FULLTEXT INDEX ft1 ON t1(title);
insert into t1 (title) values ('this is a test');
select * from t1 where match title against ('test' in boolean mode);
id title
@@ -236,7 +269,6 @@ select 8 from t1;
8
8
drop table t1;
-drop table if exists t1;
create table t1 (a text, fulltext key (a));
insert into t1 values ('aaaa');
repair table t1;
@@ -245,7 +277,6 @@ test.t1 repair status OK
select * from t1 where match (a) against ('aaaa');
a
drop table t1;
-drop table if exists t1;
create table t1 ( ref_mag text not null, fulltext (ref_mag));
insert into t1 values ('test');
select ref_mag from t1 where match ref_mag against ('+test' in boolean mode);
@@ -269,3 +300,33 @@ t1_id name t2_id t1_id name
select * from t2 where match name against ('a* b* c* d* e* f*' in boolean mode);
t2_id t1_id name
drop table t1,t2;
+SET NAMES latin1;
+CREATE TABLE t1 (t text character set utf8 not null, fulltext(t));
+INSERT t1 VALUES ('Mit freundlichem Grüß'), ('aus Osnabrück');
+SET NAMES koi8r;
+INSERT t1 VALUES ("üÔÏ ÍÙ - ÏÐÉÌËÉ"),("ïÔÌÅÚØ, ÇÎÉÄÁ!"),
+("îÅ ×ÌÅÚÁÊ, ÕÂØÅÔ!"),("É ÂÕÄÅÔ ÐÒÁ×!");
+SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('ïðéìëé');
+t collation(t)
+üÔÏ ÍÙ - ÏÐÉÌËÉ utf8_general_ci
+SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('ðÒá*' IN BOOLEAN MODE);
+t collation(t)
+É ÂÕÄÅÔ ÐÒÁ×! utf8_general_ci
+SELECT * FROM t1 WHERE MATCH t AGAINST ('ÜÔÏ' IN BOOLEAN MODE);
+t
+SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück');
+t collation(t)
+SET NAMES latin1;
+SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück');
+t collation(t)
+aus Osnabrück utf8_general_ci
+SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrueck');
+t collation(t)
+alter table t1 modify t varchar(200) collate latin1_german2_ci not null;
+SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück');
+t collation(t)
+aus Osnabrück latin1_german2_ci
+SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrueck');
+t collation(t)
+aus Osnabrück latin1_german2_ci
+DROP TABLE t1;
diff --git a/mysql-test/r/fulltext2.result b/mysql-test/r/fulltext2.result
new file mode 100644
index 00000000000..687bc6edfa0
--- /dev/null
+++ b/mysql-test/r/fulltext2.result
@@ -0,0 +1,208 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (
+i int(10) unsigned not null auto_increment primary key,
+a varchar(255) not null,
+FULLTEXT KEY (a)
+) TYPE=MyISAM;
+repair table t1 quick;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+select count(*) from t1 where match a against ('aaaxxx');
+count(*)
+260
+select count(*) from t1 where match a against ('aaayyy');
+count(*)
+250
+select count(*) from t1 where match a against ('aaazzz');
+count(*)
+255
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+count(*)
+260
+select count(*) from t1 where match a against ('aaayyy' in boolean mode);
+count(*)
+250
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+count(*)
+255
+select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz');
+count(*)
+765
+select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz' in boolean mode);
+count(*)
+765
+select count(*) from t1 where match a against ('aaax*' in boolean mode);
+count(*)
+260
+select count(*) from t1 where match a against ('aaay*' in boolean mode);
+count(*)
+250
+select count(*) from t1 where match a against ('aaa*' in boolean mode);
+count(*)
+765
+insert t1 (a) values ('aaaxxx'),('aaayyy');
+insert t1 (a) values ('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz');
+select count(*) from t1 where match a against ('aaaxxx');
+count(*)
+261
+select count(*) from t1 where match a against ('aaayyy');
+count(*)
+251
+select count(*) from t1 where match a against ('aaazzz');
+count(*)
+260
+insert t1 (a) values ('aaaxxx 000000');
+select count(*) from t1 where match a against ('000000');
+count(*)
+1
+delete from t1 where match a against ('000000');
+select count(*) from t1 where match a against ('000000');
+count(*)
+0
+select count(*) from t1 where match a against ('aaaxxx');
+count(*)
+261
+delete from t1 where match a against ('aaazzz');
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+count(*)
+261
+select count(*) from t1 where match a against ('aaayyy' in boolean mode);
+count(*)
+251
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+count(*)
+0
+select count(*) from t1 where a = 'aaaxxx';
+count(*)
+261
+select count(*) from t1 where a = 'aaayyy';
+count(*)
+251
+select count(*) from t1 where a = 'aaazzz';
+count(*)
+0
+insert t1 (a) values ('aaaxxx 000000');
+select count(*) from t1 where match a against ('000000');
+count(*)
+1
+update t1 set a='aaazzz' where match a against ('000000');
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+count(*)
+261
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+count(*)
+1
+update t1 set a='aaazzz' where a = 'aaaxxx';
+update t1 set a='aaaxxx' where a = 'aaayyy';
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+count(*)
+251
+select count(*) from t1 where match a against ('aaayyy' in boolean mode);
+count(*)
+0
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+count(*)
+262
+drop table t1;
+CREATE TABLE t1 (
+i int(10) unsigned not null auto_increment primary key,
+a varchar(255) not null,
+FULLTEXT KEY (a)
+) TYPE=MyISAM;
+select count(*) from t1 where match a against ('aaaxxx');
+count(*)
+260
+select count(*) from t1 where match a against ('aaayyy');
+count(*)
+250
+select count(*) from t1 where match a against ('aaazzz');
+count(*)
+255
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+count(*)
+260
+select count(*) from t1 where match a against ('aaayyy' in boolean mode);
+count(*)
+250
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+count(*)
+255
+select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz');
+count(*)
+765
+select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz' in boolean mode);
+count(*)
+765
+select count(*) from t1 where match a against ('aaax*' in boolean mode);
+count(*)
+260
+select count(*) from t1 where match a against ('aaay*' in boolean mode);
+count(*)
+250
+select count(*) from t1 where match a against ('aaa*' in boolean mode);
+count(*)
+765
+insert t1 (a) values ('aaaxxx'),('aaayyy');
+insert t1 (a) values ('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz');
+select count(*) from t1 where match a against ('aaaxxx');
+count(*)
+261
+select count(*) from t1 where match a against ('aaayyy');
+count(*)
+251
+select count(*) from t1 where match a against ('aaazzz');
+count(*)
+260
+insert t1 (a) values ('aaaxxx 000000');
+select count(*) from t1 where match a against ('000000');
+count(*)
+1
+delete from t1 where match a against ('000000');
+select count(*) from t1 where match a against ('000000');
+count(*)
+0
+select count(*) from t1 where match a against ('aaaxxx');
+count(*)
+261
+delete from t1 where match a against ('aaazzz');
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+count(*)
+261
+select count(*) from t1 where match a against ('aaayyy' in boolean mode);
+count(*)
+251
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+count(*)
+0
+select count(*) from t1 where a = 'aaaxxx';
+count(*)
+261
+select count(*) from t1 where a = 'aaayyy';
+count(*)
+251
+select count(*) from t1 where a = 'aaazzz';
+count(*)
+0
+insert t1 (a) values ('aaaxxx 000000');
+select count(*) from t1 where match a against ('000000');
+count(*)
+1
+update t1 set a='aaazzz' where match a against ('000000');
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+count(*)
+261
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+count(*)
+1
+update t1 set a='aaazzz' where a = 'aaaxxx';
+update t1 set a='aaaxxx' where a = 'aaayyy';
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+count(*)
+251
+select count(*) from t1 where match a against ('aaayyy' in boolean mode);
+count(*)
+0
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+count(*)
+262
+drop table t1;
diff --git a/mysql-test/r/fulltext_var.result b/mysql-test/r/fulltext_var.result
index dda8e332fba..f45e18a9591 100644
--- a/mysql-test/r/fulltext_var.result
+++ b/mysql-test/r/fulltext_var.result
@@ -3,5 +3,5 @@ Variable_name Value
ft_boolean_syntax + -><()~*:""&|
ft_min_word_len 4
ft_max_word_len 254
-ft_max_word_len_for_sort 20
+ft_query_expansion_limit 20
ft_stopword_file (built-in)
diff --git a/mysql-test/r/func_compress.result b/mysql-test/r/func_compress.result
new file mode 100644
index 00000000000..461fc1018c1
--- /dev/null
+++ b/mysql-test/r/func_compress.result
@@ -0,0 +1,70 @@
+select @test_compress_string:='string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ';
+@test_compress_string:='string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa '
+string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+select length(@test_compress_string);
+length(@test_compress_string)
+117
+select uncompress(compress(@test_compress_string));
+uncompress(compress(@test_compress_string))
+string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+explain extended select uncompress(compress(@test_compress_string));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority no_cache uncompress(compress((@test_compress_string))) AS `uncompress(compress(@test_compress_string))`
+select uncompressed_length(compress(@test_compress_string))=length(@test_compress_string);
+uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)
+1
+explain extended select uncompressed_length(compress(@test_compress_string))=length(@test_compress_string);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority no_cache (uncompressed_length(compress((@test_compress_string))) = length((@test_compress_string))) AS `uncompressed_length(compress(@test_compress_string))=length(@test_compress_string)`
+select uncompressed_length(compress(@test_compress_string));
+uncompressed_length(compress(@test_compress_string))
+117
+select length(compress(@test_compress_string))<length(@test_compress_string);
+length(compress(@test_compress_string))<length(@test_compress_string)
+1
+create table t1 (a text, b char(255), c char(4)) type=myisam;
+insert into t1 (a,b,c) values (compress(@test_compress_string),compress(@test_compress_string),'d ');
+select uncompress(a) from t1;
+uncompress(a)
+string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+select uncompress(b) from t1;
+uncompress(b)
+string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+select concat('|',c,'|') from t1;
+concat('|',c,'|')
+|d|
+drop table t1;
+select compress("");
+compress("")
+
+select uncompress("");
+uncompress("")
+
+select uncompress(compress(""));
+uncompress(compress(""))
+
+select uncompressed_length("");
+uncompressed_length("")
+0
+create table t1 (a text);
+insert t1 values (compress(null)), ('A\0\0\0BBBBBBBB'), (compress(space(50000))), (space(50000));
+select length(a) from t1;
+length(a)
+NULL
+12
+76
+50000
+select length(uncompress(a)) from t1;
+length(uncompress(a))
+NULL
+NULL
+50000
+NULL
+Warnings:
+Error 1258 ZLIB: Input data was corrupted for zlib
+Error 1255 Too big size of uncompressed data. The maximum size is 1048576. (probably, length of uncompressed data was corrupted)
+drop table t1;
diff --git a/mysql-test/r/func_crypt.result b/mysql-test/r/func_crypt.result
index 96bbaa6cae7..70ebcf216fb 100644
--- a/mysql-test/r/func_crypt.result
+++ b/mysql-test/r/func_crypt.result
@@ -1,14 +1,8 @@
+drop table if exists t1;
select length(encrypt('foo', 'ff')) <> 0;
length(encrypt('foo', 'ff')) <> 0
1
-select old_password('test'), password('test');
-old_password('test') password('test')
-378b243e220ca493 378b243e220ca493
-select length(encrypt('test')), encrypt('test','aa');
-length(encrypt('test')) encrypt('test','aa')
-13 aaqPiZY5xR5l.
-drop table if exists t1;
-create table t1 (name varchar(50), pw varchar(16));
+create table t1 (name varchar(50), pw varchar(64));
insert into t1 values ('tom', password('my_pass'));
set @pass='my_pass';
select name from t1 where name='tom' and pw=password(@pass);
@@ -17,3 +11,84 @@ tom
select name from t1 where name='tom' and pw=password(@undefined);
name
drop table t1;
+select password('abc');
+password('abc')
+*0D3CED9BEC10A777AEC23CCC353A8C08A633045E
+select password('');
+password('')
+
+select old_password('abc');
+old_password('abc')
+7cd2b5942be28759
+select old_password('');
+old_password('')
+
+select password('gabbagabbahey');
+password('gabbagabbahey')
+*B0F99D2963660DD7E16B751EC9EE2F17B6A68FA6
+select old_password('idkfa');
+old_password('idkfa')
+5c078dc54ca0fcca
+select length(password('1'));
+length(password('1'))
+41
+select length(encrypt('test'));
+length(encrypt('test'))
+13
+select encrypt('test','aa');
+encrypt('test','aa')
+aaqPiZY5xR5l.
+select old_password(NULL);
+old_password(NULL)
+NULL
+select password(NULL);
+password(NULL)
+NULL
+set global old_passwords=on;
+select password('');
+password('')
+
+select old_password('');
+old_password('')
+
+select password('idkfa');
+password('idkfa')
+*B669C9DAC3AA6F2254B03CDEF8DFDD6B2D1054BA
+select old_password('idkfa');
+old_password('idkfa')
+5c078dc54ca0fcca
+set old_passwords=on;
+select password('idkfa');
+password('idkfa')
+5c078dc54ca0fcca
+select old_password('idkfa');
+old_password('idkfa')
+5c078dc54ca0fcca
+set global old_passwords=off;
+select password('idkfa');
+password('idkfa')
+5c078dc54ca0fcca
+select old_password('idkfa');
+old_password('idkfa')
+5c078dc54ca0fcca
+set old_passwords=off;
+select password('idkfa ');
+password('idkfa ')
+*2DC31D90647B4C1ABC9231563D2236E96C9A2DB2
+select password('idkfa');
+password('idkfa')
+*B669C9DAC3AA6F2254B03CDEF8DFDD6B2D1054BA
+select password(' idkfa');
+password(' idkfa')
+*12B099E56BB7FE8D43C78FD834A9D1D11178D045
+select old_password('idkfa');
+old_password('idkfa')
+5c078dc54ca0fcca
+select old_password(' i d k f a ');
+old_password(' i d k f a ')
+5c078dc54ca0fcca
+explain extended select password('idkfa '), old_password('idkfa');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority password(_latin1'idkfa ') AS `password('idkfa ')`,old_password(_latin1'idkfa') AS `old_password('idkfa')`
diff --git a/mysql-test/r/func_date_add.result b/mysql-test/r/func_date_add.result
index acdf2c5d7be..234fded9a68 100644
--- a/mysql-test/r/func_date_add.result
+++ b/mysql-test/r/func_date_add.result
@@ -31,17 +31,17 @@ INSERT INTO t1 VALUES (357917728,7,2,2,20000319145027);
select visitor_id,max(ts) as mts from t1 group by visitor_id
having mts < DATE_SUB(NOW(),INTERVAL 3 MONTH);
visitor_id mts
-48985536 20000319013932
-173865424 20000318233615
-357917728 20000319145027
-465931136 20000318160953
-1092858576 20000319013445
+48985536 2000-03-19 01:39:32
+173865424 2000-03-18 23:36:15
+357917728 2000-03-19 14:50:27
+465931136 2000-03-18 16:09:53
+1092858576 2000-03-19 01:34:45
select visitor_id,max(ts) as mts from t1 group by visitor_id
having DATE_ADD(mts,INTERVAL 3 MONTH) < NOW();
visitor_id mts
-48985536 20000319013932
-173865424 20000318233615
-357917728 20000319145027
-465931136 20000318160953
-1092858576 20000319013445
+48985536 2000-03-19 01:39:32
+173865424 2000-03-18 23:36:15
+357917728 2000-03-19 14:50:27
+465931136 2000-03-18 16:09:53
+1092858576 2000-03-19 01:34:45
drop table t1;
diff --git a/mysql-test/r/func_default.result b/mysql-test/r/func_default.result
new file mode 100644
index 00000000000..fe3f5b9473a
--- /dev/null
+++ b/mysql-test/r/func_default.result
@@ -0,0 +1,18 @@
+drop table if exists t1,t2;
+create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14');
+insert into t1 values ('','',0,0.0);
+select default(str), default(strnull), default(intg), default(rel) from t1;
+default(str) default(strnull) default(intg) default(rel)
+def NULL 10 3.14
+explain extended select default(str), default(strnull), default(intg), default(rel) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 1
+Warnings:
+Note 1003 select high_priority default(test.t1.str) AS `default(str)`,default(test.t1.strnull) AS `default(strnull)`,default(test.t1.intg) AS `default(intg)`,default(test.t1.rel) AS `default(rel)` from test.t1
+select * from t1 where str <> default(str);
+str strnull intg rel
+ 0 0
+explain select * from t1 where str <> default(str);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 1
+drop table t1;
diff --git a/mysql-test/r/func_encrypt.result b/mysql-test/r/func_encrypt.result
index 39c734999b2..abdfda0423f 100644
--- a/mysql-test/r/func_encrypt.result
+++ b/mysql-test/r/func_encrypt.result
@@ -134,3 +134,8 @@ NULL
select hex(des_decrypt(des_encrypt("hello","hidden")));
hex(des_decrypt(des_encrypt("hello","hidden")))
NULL
+explain extended select des_decrypt(des_encrypt("hello",4),'password2'), des_decrypt(des_encrypt("hello","hidden"));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority des_decrypt(des_encrypt(_latin1'hello',4),_latin1'password2') AS `des_decrypt(des_encrypt("hello",4),'password2')`,des_decrypt(des_encrypt(_latin1'hello',_latin1'hidden')) AS `des_decrypt(des_encrypt("hello","hidden"))`
diff --git a/mysql-test/r/func_equal.result b/mysql-test/r/func_equal.result
index 32a911eedf8..352b76f2744 100644
--- a/mysql-test/r/func_equal.result
+++ b/mysql-test/r/func_equal.result
@@ -1,3 +1,4 @@
+drop table if exists t1,t2;
select 0<=>0,0.0<=>0.0,"A"<=>"A",NULL<=>NULL;
0<=>0 0.0<=>0.0 "A"<=>"A" NULL<=>NULL
1 1 1 1
@@ -10,7 +11,6 @@ select 1.0<=>0.0,0.0<=>NULL,NULL<=>0.0;
select "A"<=>"B","A"<=>NULL,NULL<=>"A";
"A"<=>"B" "A"<=>NULL NULL<=>"A"
0 0 0
-drop table if exists t1,t2;
create table t1 (id int, value int);
create table t2 (id int, value int);
insert into t1 values (1,null);
diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result
new file mode 100644
index 00000000000..af6f7956fe3
--- /dev/null
+++ b/mysql-test/r/func_gconcat.result
@@ -0,0 +1,224 @@
+drop table if exists t1, t2;
+create table t1 (grp int, a bigint unsigned, c char(10) not null, d char(10) not null);
+insert into t1 values (1,1,"a","a");
+insert into t1 values (2,2,"b","a");
+insert into t1 values (2,3,"c","b");
+insert into t1 values (3,4,"E","a");
+insert into t1 values (3,5,"C","b");
+insert into t1 values (3,6,"D","b");
+insert into t1 values (3,7,"d","d");
+insert into t1 values (3,8,"d","d");
+insert into t1 values (3,9,"D","c");
+select grp,group_concat(c) from t1 group by grp;
+grp group_concat(c)
+1 a
+2 b,c
+3 E,C,D,d,d,D
+explain extended select grp,group_concat(c) from t1 group by grp;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 9 Using filesort
+Warnings:
+Note 1003 select high_priority test.t1.grp AS `grp`,group_concat(test.t1.c seperator ',') AS `group_concat(c)` from test.t1 group by test.t1.grp
+select grp,group_concat(a,c) from t1 group by grp;
+grp group_concat(a,c)
+1 1a
+2 2b,3c
+3 4E,5C,6D,7d,8d,9D
+select grp,group_concat("(",a,":",c,")") from t1 group by grp;
+grp group_concat("(",a,":",c,")")
+1 (1:a)
+2 (2:b),(3:c)
+3 (4:E),(5:C),(6:D),(7:d),(8:d),(9:D)
+select grp,group_concat(c separator ",") from t1 group by grp;
+grp group_concat(c separator ",")
+1 a
+2 b,c
+3 E,C,D,d,d,D
+select grp,group_concat(c separator "---->") from t1 group by grp;
+grp group_concat(c separator "---->")
+1 a
+2 b---->c
+3 E---->C---->D---->d---->d---->D
+select grp,group_concat(c order by c) from t1 group by grp;
+grp group_concat(c order by c)
+1 a
+2 b,c
+3 C,D,d,d,D,E
+select grp,group_concat(c order by c desc) from t1 group by grp;
+grp group_concat(c order by c desc)
+1 a
+2 c,b
+3 E,D,d,d,D,C
+select grp,group_concat(d order by a) from t1 group by grp;
+grp group_concat(d order by a)
+1 a
+2 a,b
+3 a,b,b,d,d,c
+select grp,group_concat(d order by a desc) from t1 group by grp;
+grp group_concat(d order by a desc)
+1 a
+2 b,a
+3 c,d,d,b,b,a
+select grp,group_concat(a order by a,d+c) from t1 group by grp;
+grp group_concat(a order by a,d+c)
+1 1
+2 2,3
+3 4,5,6,7,8,9
+select grp,group_concat(c order by 1) from t1 group by grp;
+grp group_concat(c order by 1)
+1 a
+2 b,c
+3 C,D,d,d,D,E
+select grp,group_concat(c order by "c") from t1 group by grp;
+grp group_concat(c order by "c")
+1 a
+2 b,c
+3 C,D,d,d,D,E
+select grp,group_concat(distinct c order by c) from t1 group by grp;
+grp group_concat(distinct c order by c)
+1 a
+2 b,c
+3 C,D,E
+select grp,group_concat(distinct c order by c desc) from t1 group by grp;
+grp group_concat(distinct c order by c desc)
+1 a
+2 c,b
+3 E,D,C
+explain extended select grp,group_concat(distinct c order by c desc) from t1 group by grp;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 9 Using filesort
+Warnings:
+Note 1003 select high_priority test.t1.grp AS `grp`,group_concat(distinct test.t1.c order by test.t1.c seperator ',') AS `group_concat(distinct c order by c desc)` from test.t1 group by test.t1.grp
+select grp,group_concat(c order by c separator ",") from t1 group by grp;
+grp group_concat(c order by c separator ",")
+1 a
+2 b,c
+3 C,D,d,d,D,E
+select grp,group_concat(c order by c desc separator ",") from t1 group by grp;
+grp group_concat(c order by c desc separator ",")
+1 a
+2 c,b
+3 E,D,d,d,D,C
+select grp,group_concat(distinct c order by c separator ",") from t1 group by grp;
+grp group_concat(distinct c order by c separator ",")
+1 a
+2 b,c
+3 C,D,E
+explain extended select grp,group_concat(distinct c order by c separator ",") from t1 group by grp;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 9 Using filesort
+Warnings:
+Note 1003 select high_priority test.t1.grp AS `grp`,group_concat(distinct test.t1.c order by test.t1.c seperator ',') AS `group_concat(distinct c order by c separator ",")` from test.t1 group by test.t1.grp
+select grp,group_concat(distinct c order by c desc separator ",") from t1 group by grp;
+grp group_concat(distinct c order by c desc separator ",")
+1 a
+2 c,b
+3 E,D,C
+select grp,group_concat(c order by grp desc) from t1 group by grp order by grp;
+grp group_concat(c order by grp desc)
+1 a
+2 c,b
+3 D,d,d,D,C,E
+select grp, group_concat(a separator "")+0 from t1 group by grp;
+grp group_concat(a separator "")+0
+1 1
+2 23
+3 456789
+select grp, group_concat(a separator "")+0.0 from t1 group by grp;
+grp group_concat(a separator "")+0.0
+1 1.0
+2 23.0
+3 456789.0
+select grp, ROUND(group_concat(a separator "")) from t1 group by grp;
+grp ROUND(group_concat(a separator ""))
+1 1
+2 23
+3 456789
+drop table t1;
+create table t1 (grp int, c char(10));
+insert into t1 values (1,NULL);
+insert into t1 values (2,"b");
+insert into t1 values (2,NULL);
+insert into t1 values (3,"E");
+insert into t1 values (3,NULL);
+insert into t1 values (3,"D");
+insert into t1 values (3,NULL);
+insert into t1 values (3,NULL);
+insert into t1 values (3,"D");
+insert into t1 values (4,"");
+insert into t1 values (5,NULL);
+select grp,group_concat(c order by c) from t1 group by grp;
+grp group_concat(c order by c)
+1 NULL
+2 b
+3 D,D,E
+4
+5 NULL
+set group_concat_max_len = 5;
+select grp,group_concat(c) from t1 group by grp;
+grp group_concat(c)
+1 NULL
+2 b
+3 D,D,E
+4
+5 NULL
+Warnings:
+Warning 1259 1 line(s) was(were) cut by group_concat()
+show warnings;
+Level Code Message
+Warning 1259 1 line(s) was(were) cut by group_concat()
+set group_concat_max_len = 1024;
+select group_concat(sum(a)) from t1 group by grp;
+ERROR HY000: Invalid use of group function
+select grp,group_concat(c order by 2) from t1 group by grp;
+ERROR 42S22: Unknown column '2' in 'group statement'
+drop table t1;
+create table t1 ( URL_ID int(11), URL varchar(80));
+create table t2 ( REQ_ID int(11), URL_ID int(11));
+insert into t1 values (4,'www.host.com'), (5,'www.google.com'),(5,'www.help.com');
+insert into t2 values (1,4), (5,4), (5,5);
+select REQ_ID, Group_Concat(URL) as URL from t1, t2 where
+t2.URL_ID = t1.URL_ID group by REQ_ID;
+REQ_ID URL
+1 X
+5 X,X,X
+select REQ_ID, Group_Concat(URL) as URL, Min(t1.URL_ID) urll,
+Max(t1.URL_ID) urlg from t1, t2 where t2.URL_ID = t1.URL_ID group by REQ_ID;
+REQ_ID URL urll urlg
+1 X 4 4
+5 X,X,X 4 5
+drop table t1;
+drop table t2;
+create table t1 (id int, name varchar(16));
+insert into t1 values (1,'longername'),(1,'evenlongername');
+select ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'without distinct: how it should be' from t1;
+without distinct: how it should be
+1:longername,1:evenlongername
+select distinct ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'with distinct: cutoff at length of shortname' from t1;
+with distinct: cutoff at length of shortname
+1:longername,1:evenlongername
+drop table t1;
+create table t1(id int);
+create table t2(id int);
+insert into t1 values(0),(1);
+select group_concat(t1.id) FROM t1,t2;
+group_concat(t1.id)
+NULL
+drop table t1;
+drop table t2;
+create table t1 (bar varchar(32));
+insert into t1 values('test'),('test2');
+select * from t1 having group_concat(bar)='';
+bar
+drop table t1;
+create table t1 (a int, a1 varchar(10));
+create table t2 (a0 int);
+insert into t1 values (0,"a"),(0,"b"),(1,"c");
+insert into t2 values (1),(2),(3);
+select group_concat(a1 order by (t1.a IN (select a0 from t2))) from t1;
+group_concat(a1 order by (t1.a IN (select a0 from t2)))
+b,a,c
+select group_concat(a1 order by (t1.a)) from t1;
+group_concat(a1 order by (t1.a))
+b,a,c
+drop table t1, t2;
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index 80ccb6c7bb8..7ae3bbb0608 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -42,21 +42,21 @@ insert into t1 values (null,null,'');
select count(distinct a),count(distinct grp) from t1;
count(distinct a) count(distinct grp)
6 3
-select sum(all a),count(all a),avg(all a),std(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1;
-sum(all a) count(all a) avg(all a) std(all a) bit_or(all a) bit_and(all a) min(all a) max(all a) min(all c) max(all c)
-21 6 3.5000 1.7078 7 0 1 6 E
-select grp, sum(a),count(a),avg(a),std(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp;
-grp sum(a) count(a) avg(a) std(a) bit_or(a) bit_and(a) min(a) max(a) min(c) max(c)
-NULL NULL 0 NULL NULL 0 0 NULL NULL
-1 1 1 1.0000 0.0000 1 1 1 1 a a
-2 5 2 2.5000 0.5000 3 2 2 3 b c
-3 15 3 5.0000 0.8165 7 4 4 6 C E
-select grp, sum(a)+count(a)+avg(a)+std(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp;
+select sum(all a),count(all a),avg(all a),std(all a),variance(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1;
+sum(all a) count(all a) avg(all a) std(all a) variance(all a) bit_or(all a) bit_and(all a) min(all a) max(all a) min(all c) max(all c)
+21 6 3.5000 1.7078 2.9167 7 0 1 6 E
+select grp, sum(a),count(a),avg(a),std(a),variance(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp;
+grp sum(a) count(a) avg(a) std(a) variance(a) bit_or(a) bit_and(a) min(a) max(a) min(c) max(c)
+NULL NULL 0 NULL NULL NULL 0 0 NULL NULL
+1 1 1 1.0000 0.0000 0.0000 1 1 1 1 a a
+2 5 2 2.5000 0.5000 0.2500 3 2 2 3 b c
+3 15 3 5.0000 0.8165 0.6667 7 4 4 6 C E
+select grp, sum(a)+count(a)+avg(a)+std(a)+variance(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp;
grp sum
NULL NULL
1 7
-2 20
-3 44.816496580928
+2 20.25
+3 45.483163247594
create table t2 (grp int, a bigint unsigned, c char(10));
insert into t2 select grp,max(a)+max(grp),max(c) from t1 group by grp;
replace into t2 select grp, a, c from t1 limit 2,1;
@@ -72,14 +72,14 @@ CREATE TABLE t1 (id int(11),value1 float(10,2));
INSERT INTO t1 VALUES (1,0.00),(1,1.00), (1,2.00), (2,10.00), (2,11.00), (2,12.00);
CREATE TABLE t2 (id int(11),name char(20));
INSERT INTO t2 VALUES (1,'Set One'),(2,'Set Two');
-select id, avg(value1), std(value1) from t1 group by id;
-id avg(value1) std(value1)
-1 1.000000 0.816497
-2 11.000000 0.816497
-select name, avg(value1), std(value1) from t1, t2 where t1.id = t2.id group by t1.id;
-name avg(value1) std(value1)
-Set One 1.000000 0.816497
-Set Two 11.000000 0.816497
+select id, avg(value1), std(value1), variance(value1) from t1 group by id;
+id avg(value1) std(value1) variance(value1)
+1 1.000000 0.816497 0.666667
+2 11.000000 0.816497 0.666667
+select name, avg(value1), std(value1), variance(value1) from t1, t2 where t1.id = t2.id group by t1.id;
+name avg(value1) std(value1) variance(value1)
+Set One 1.000000 0.816497 0.666667
+Set Two 11.000000 0.816497 0.666667
drop table t1,t2;
create table t1 (id int not null);
create table t2 (id int not null,rating int null);
@@ -173,12 +173,23 @@ select max(t2.a2), max(t1.a1) from t1, t2;
max(t2.a2) max(t1.a1)
NULL NULL
explain select min(a2) from t1;
-Comment
-Select tables optimized away
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
explain select max(t1.a1), max(t2.a2) from t1, t2;
-Comment
-No matching min/max row
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching min/max row
insert into t2 values('AAA', 10, 0.5);
+insert into t2 values('BBB', 20, 1.0);
+select t1.a1, t1.a2, t2.a1, t2.a2 from t1,t2;
+a1 a2 a1 a2
+10 aaa AAA 10
+10 NULL AAA 10
+10 bbb AAA 10
+20 zzz AAA 10
+10 aaa BBB 20
+10 NULL BBB 20
+10 bbb BBB 20
+20 zzz BBB 20
select max(t1.a1), max(t2.a1) from t1, t2 where t2.a2=9;
max(t1.a1) max(t2.a1)
NULL NULL
@@ -188,32 +199,379 @@ NULL NULL
select t1.a1, t1.a2, t2.a1, t2.a2 from t1 left outer join t2 on t1.a1=10;
a1 a2 a1 a2
10 aaa AAA 10
+10 aaa BBB 20
10 NULL AAA 10
+10 NULL BBB 20
10 bbb AAA 10
+10 bbb BBB 20
20 zzz NULL NULL
select max(t1.a2) from t1 left outer join t2 on t1.a1=10;
max(t1.a2)
zzz
-select max(t1.a2) from t1 left outer join t2 on t1.a1=10 where t1.a1=20;
-max(t1.a2)
-zzz
-select max(t1.a2) from t1 left outer join t2 on t1.a1=10 where t1.a1=10;
-max(t1.a2)
-bbb
+select max(t2.a1) from t2 left outer join t1 on t2.a2=10 where t2.a2=20;
+max(t2.a1)
+BBB
+select max(t2.a1) from t2 left outer join t1 on t2.a2=10 where t2.a2=10;
+max(t2.a1)
+AAA
select max(t2.a1) from t1 left outer join t2 on t1.a2=t2.a1 and 1=0 where t2.a1='AAA';
max(t2.a1)
NULL
+select max(t1.a2),max(t2.a1) from t1 left outer join t2 on t1.a1=10;
+max(t1.a2) max(t2.a1)
+zzz BBB
drop table t1,t2;
+create table t1(
+a1 char(3) primary key,
+a2 smallint,
+a3 char(3),
+a4 real,
+a5 date,
+key k1(a2,a3),
+key k2(a4 desc,a1),
+key k3(a5,a1)
+);
+create table t2(
+a1 char(3) primary key,
+a2 char(17),
+a3 char(2),
+a4 char(3),
+key k1(a3, a2),
+key k2(a4)
+);
+insert into t1 values('AME',0,'SEA',0.100,date'1942-02-19');
+insert into t1 values('HBR',1,'SEA',0.085,date'1948-03-05');
+insert into t1 values('BOT',2,'SEA',0.085,date'1951-11-29');
+insert into t1 values('BMC',3,'SEA',0.085,date'1958-09-08');
+insert into t1 values('TWU',0,'LAX',0.080,date'1969-10-05');
+insert into t1 values('BDL',0,'DEN',0.080,date'1960-11-27');
+insert into t1 values('DTX',1,'NYC',0.080,date'1961-05-04');
+insert into t1 values('PLS',1,'WDC',0.075,date'1949-01-02');
+insert into t1 values('ZAJ',2,'CHI',0.075,date'1960-06-15');
+insert into t1 values('VVV',2,'MIN',0.075,date'1959-06-28');
+insert into t1 values('GTM',3,'DAL',0.070,date'1977-09-23');
+insert into t1 values('SSJ',null,'CHI',null,date'1974-03-19');
+insert into t1 values('KKK',3,'ATL',null,null);
+insert into t1 values('XXX',null,'MIN',null,null);
+insert into t2 values('TKF','Seattle','WA','AME');
+insert into t2 values('LCC','Los Angeles','CA','TWU');
+insert into t2 values('DEN','Denver','CO','BDL');
+insert into t2 values('SDC','San Diego','CA','TWU');
+insert into t2 values('NOL','New Orleans','LA','GTM');
+insert into t2 values('LAK','Los Angeles','CA','TWU');
+select * from t1;
+a1 a2 a3 a4 a5
+AME 0 SEA 0.1 1942-02-19
+HBR 1 SEA 0.085 1948-03-05
+BOT 2 SEA 0.085 1951-11-29
+BMC 3 SEA 0.085 1958-09-08
+TWU 0 LAX 0.08 1969-10-05
+BDL 0 DEN 0.08 1960-11-27
+DTX 1 NYC 0.08 1961-05-04
+PLS 1 WDC 0.075 1949-01-02
+ZAJ 2 CHI 0.075 1960-06-15
+VVV 2 MIN 0.075 1959-06-28
+GTM 3 DAL 0.07 1977-09-23
+SSJ NULL CHI NULL 1974-03-19
+KKK 3 ATL NULL NULL
+XXX NULL MIN NULL NULL
+select * from t2;
+a1 a2 a3 a4
+TKF Seattle WA AME
+LCC Los Angeles CA TWU
+DEN Denver CO BDL
+SDC San Diego CA TWU
+NOL New Orleans LA GTM
+LAK Los Angeles CA TWU
+explain
+select min(a1) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select min(a1) from t1;
+min(a1)
+AME
+explain
+select max(a4) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select max(a4) from t1;
+max(a4)
+0.1
+explain
+select min(a5), max(a5) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select min(a5), max(a5) from t1;
+min(a5) max(a5)
+1942-02-19 1977-09-23
+explain
+select min(a3) from t1 where a2 = 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select min(a3) from t1 where a2 = 2;
+min(a3)
+CHI
+explain
+select min(a1), max(a1) from t1 where a4 = 0.080;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select min(a1), max(a1) from t1 where a4 = 0.080;
+min(a1) max(a1)
+BDL TWU
+explain
+select min(t1.a5), max(t2.a3) from t1, t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select min(t1.a5), max(t2.a3) from t1, t2;
+min(t1.a5) max(t2.a3)
+1942-02-19 WA
+explain
+select min(t1.a3), max(t2.a2) from t1, t2 where t1.a2 = 0 and t2.a3 = 'CA';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select min(t1.a3), max(t2.a2) from t1, t2 where t1.a2 = 0 and t2.a3 = 'CA';
+min(t1.a3) max(t2.a2)
+DEN San Diego
+explain
+select min(a1) from t1 where a1 > 'KKK';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select min(a1) from t1 where a1 > 'KKK';
+min(a1)
+PLS
+explain
+select min(a1) from t1 where a1 >= 'KKK';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select min(a1) from t1 where a1 >= 'KKK';
+min(a1)
+KKK
+explain
+select max(a3) from t1 where a2 = 2 and a3 < 'SEA';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select max(a3) from t1 where a2 = 2 and a3 < 'SEA';
+max(a3)
+MIN
+explain
+select max(a5) from t1 where a5 < date'1970-01-01';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select max(a5) from t1 where a5 < date'1970-01-01';
+max(a5)
+1969-10-05
+explain
+select max(a3) from t1 where a2 is null;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select max(a3) from t1 where a2 is null;
+max(a3)
+MIN
+explain
+select max(a3) from t1 where a2 = 0 and a3 between 'K' and 'Q';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select max(a3) from t1 where a2 = 0 and a3 between 'K' and 'Q';
+max(a3)
+LAX
+explain
+select min(a1), max(a1) from t1 where a1 between 'A' and 'P';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select min(a1), max(a1) from t1 where a1 between 'A' and 'P';
+min(a1) max(a1)
+AME KKK
+explain
+select max(a3) from t1 where a3 < 'SEA' and a2 = 2 and a3 <= 'MIN';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select max(a3) from t1 where a3 < 'SEA' and a2 = 2 and a3 <= 'MIN';
+max(a3)
+MIN
+explain
+select max(a3) from t1 where a3 = 'MIN' and a2 = 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select max(a3) from t1 where a3 = 'MIN' and a2 = 2;
+max(a3)
+MIN
+explain
+select max(a3) from t1 where a3 = 'DEN' and a2 = 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching min/max row
+select max(a3) from t1 where a3 = 'DEN' and a2 = 2;
+max(a3)
+NULL
+explain
+select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 = 'CA';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 = 'CA';
+max(t1.a3) min(t2.a2)
+CHI Los Angeles
+explain
+select max(a3) from t1 where a2 is null and a2 = 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+select max(a3) from t1 where a2 is null and a2 = 2;
+max(a3)
+NULL
+explain
+select max(a2) from t1 where a2 >= 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select max(a2) from t1 where a2 >= 1;
+max(a2)
+3
+explain
+select min(a3) from t1 where a2 = 2 and a3 < 'SEA';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select min(a3) from t1 where a2 = 2 and a3 < 'SEA';
+min(a3)
+CHI
+explain
+select min(a3) from t1 where a2 = 4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching min/max row
+select min(a3) from t1 where a2 = 4;
+min(a3)
+NULL
+explain
+select min(a3) from t1 where a2 = 2 and a3 > 'SEA';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching min/max row
+select min(a3) from t1 where a2 = 2 and a3 > 'SEA';
+min(a3)
+NULL
+explain
+select (min(a4)+max(a4))/2 from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select (min(a4)+max(a4))/2 from t1;
+(min(a4)+max(a4))/2
+0.085
+explain
+select min(a3) from t1 where 2 = a2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select min(a3) from t1 where 2 = a2;
+min(a3)
+CHI
+explain
+select max(a3) from t1 where a2 = 2 and 'SEA' > a3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select max(a3) from t1 where a2 = 2 and 'SEA' > a3;
+max(a3)
+MIN
+explain
+select max(a3) from t1 where a2 = 2 and 'SEA' < a3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching min/max row
+select max(a3) from t1 where a2 = 2 and 'SEA' < a3;
+max(a3)
+NULL
+explain
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI';
+min(a3)
+CHI
+explain
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 < 'SEA';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 < 'SEA';
+min(a3)
+CHI
+explain
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 = 'MIN';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 = 'MIN';
+min(a3)
+MIN
+explain
+select min(a3) from t1 where a2 = 2 and a3 >= 'SEA' and a3 = 'MIN';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+select min(a3) from t1 where a2 = 2 and a3 >= 'SEA' and a3 = 'MIN';
+min(a3)
+NULL
+explain
+select min(t1.a1), min(t2.a4) from t1,t2 where t1.a1 < 'KKK' and t2.a4 < 'KKK';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select min(t1.a1), min(t2.a4) from t1,t2 where t1.a1 < 'KKK' and t2.a4 < 'KKK';
+min(t1.a1) min(t2.a4)
+AME AME
+explain
+select min(a1) from t1 where a1 > 'KKK' or a1 < 'XXX';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 0 NULL 15 Using where; Using index
+explain
+select min(a1) from t1 where a1 != 'KKK';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 3 NULL 14 Using where; Using index
+explain
+select max(a3) from t1 where a2 < 2 and a3 < 'SEA';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range k1 k1 3 NULL 5 Using where; Using index
+explain
+select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 > 'CA';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range k1 k1 7 NULL 1 Using where; Using index
+1 SIMPLE t2 range k1 k1 3 NULL 4 Using where; Using index
+explain
+select min(a4 - 0.01) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL k2 12 NULL 14 Using index
+explain
+select max(a4 + 0.01) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL k2 12 NULL 14 Using index
+explain
+select min(a3) from t1 where (a2 +1 ) is null;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL k1 7 NULL 14 Using where; Using index
+explain
+select min(a3) from t1 where (a2 + 1) = 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL k1 7 NULL 14 Using where; Using index
+explain
+select min(a3) from t1 where 2 = (a2 + 1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL k1 7 NULL 14 Using where; Using index
+explain
+select min(a2) from t1 where a2 < 2 * a2 - 8;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL k1 7 NULL 14 Using where; Using index
+explain
+select min(a1) from t1 where a1 between a3 and 'KKK';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 14 Using where
+explain
+select min(a4) from t1 where (a4 + 0.01) between 0.07 and 0.08;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL k2 12 NULL 14 Using where; Using index
+explain
+select concat(min(t1.a1),min(t2.a4)) from t1, t2 where t2.a4 <> 'AME';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range k2 k2 4 NULL 6 Using where; Using index
+1 SIMPLE t1 index NULL PRIMARY 3 NULL 14 Using index
+drop table t1, t2;
CREATE TABLE t1 (a int, b int);
select count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1;
count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
-0 NULL NULL NULL NULL NULL -1 0
+0 NULL NULL NULL NULL NULL 18446744073709551615 0
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
insert into t1 values (1,null);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
-1 0 NULL NULL NULL NULL NULL -1 0
+1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
insert into t1 values (1,null);
insert into t1 values (2,null);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
@@ -222,8 +580,8 @@ a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
2 0 NULL NULL NULL NULL NULL 0 0
select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
-1 0 NULL NULL NULL NULL NULL -1 0
-2 0 NULL NULL NULL NULL NULL -1 0
+1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
+2 0 NULL NULL NULL NULL NULL 18446744073709551615 0
insert into t1 values (2,1);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
@@ -231,7 +589,7 @@ a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
2 1 1 1.0000 0.0000 1 1 0 1
select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
-1 0 NULL NULL NULL NULL NULL -1 0
+1 0 NULL NULL NULL NULL NULL 18446744073709551615 0
2 1 1 1.0000 0.0000 1 1 1 1
insert into t1 values (3,1);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
@@ -239,9 +597,38 @@ a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
1 0 NULL NULL NULL NULL NULL 0 0
2 1 1 1.0000 0.0000 1 1 0 1
3 1 1 1.0000 0.0000 1 1 1 1
-select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
-a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b)
-1 0 NULL NULL NULL NULL NULL -1 0
-2 1 1 1.0000 0.0000 1 1 1 1
-3 1 1 1.0000 0.0000 1 1 1 1
+select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b), bit_xor(b) from t1 group by a;
+a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) bit_xor(b)
+1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 0
+2 1 1 1.0000 0.0000 1 1 1 1 1
+3 1 1 1.0000 0.0000 1 1 1 1 1
+explain extended select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b), bit_xor(b) from t1 group by a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using filesort
+Warnings:
+Note 1003 select high_priority big_result test.t1.a AS `a`,count(test.t1.b) AS `count(b)`,sum(test.t1.b) AS `sum(b)`,avg(test.t1.b) AS `avg(b)`,std(test.t1.b) AS `std(b)`,min(test.t1.b) AS `min(b)`,max(test.t1.b) AS `max(b)`,bit_and(test.t1.b) AS `bit_and(b)`,bit_or(test.t1.b) AS `bit_or(b)`,bit_xor(test.t1.b) AS `bit_xor(b)` from test.t1 group by test.t1.a
+drop table t1;
+create table t1 (USR_ID integer not null, MAX_REQ integer not null, constraint PK_SEA_USER primary key (USR_ID)) type=InnoDB;
+insert into t1 values (1, 3);
+select count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ from t1 group by MAX_REQ;
+count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ
+1
+select Case When Count(*) < MAX_REQ Then 1 Else 0 End from t1 where t1.USR_ID = 1 group by MAX_REQ;
+Case When Count(*) < MAX_REQ Then 1 Else 0 End
+1
+drop table t1;
+create table t1 (a char(10));
+insert into t1 values ('a'),('b'),('c');
+select coercibility(max(a)) from t1;
+coercibility(max(a))
+3
+drop table t1;
+create table t1 (a int);
+insert into t1 values (1);
+select max(a) as b from t1 having b=1;
+b
+1
+select a from t1 having a=1;
+a
+1
drop table t1;
diff --git a/mysql-test/r/func_if.result b/mysql-test/r/func_if.result
index 0ab41258091..64070179395 100644
--- a/mysql-test/r/func_if.result
+++ b/mysql-test/r/func_if.result
@@ -39,6 +39,25 @@ a
a
aa
aaa
+explain extended select if(u=1,st,binary st) s from t1 where st like "%a%" order by s;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 7 Using where; Using filesort
+Warnings:
+Note 1003 select high_priority if((test.t1.u = 1),test.t1.st,(test.t1.st collate _latin1'BINARY')) AS `s` from test.t1 where (test.t1.st like _latin1'%a%') order by if((test.t1.u = 1),test.t1.st,(test.t1.st collate _latin1'BINARY'))
+select nullif(u=0, 'test') from t1;
+nullif(u=0, 'test')
+NULL
+NULL
+NULL
+NULL
+NULL
+1
+1
+explain extended select nullif(u=0, 'test') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 7
+Warnings:
+Note 1003 select high_priority nullif((test.t1.u = 0),_latin1'test') AS `nullif(u=0, 'test')` from test.t1
drop table t1;
create table t1 (num double(12,2));
insert into t1 values (144.54);
diff --git a/mysql-test/r/func_in.result b/mysql-test/r/func_in.result
index ba33ee0831d..04b6fc038b0 100644
--- a/mysql-test/r/func_in.result
+++ b/mysql-test/r/func_in.result
@@ -1,11 +1,95 @@
drop table if exists t1;
+select 1 in (1,2,3);
+1 in (1,2,3)
+1
+select 10 in (1,2,3);
+10 in (1,2,3)
+0
+select NULL in (1,2,3);
+NULL in (1,2,3)
+NULL
+select 1 in (1,NULL,3);
+1 in (1,NULL,3)
+1
+select 3 in (1,NULL,3);
+3 in (1,NULL,3)
+1
+select 10 in (1,NULL,3);
+10 in (1,NULL,3)
+NULL
+select 1.5 in (1.5,2.5,3.5);
+1.5 in (1.5,2.5,3.5)
+1
+select 10.5 in (1.5,2.5,3.5);
+10.5 in (1.5,2.5,3.5)
+0
+select NULL in (1.5,2.5,3.5);
+NULL in (1.5,2.5,3.5)
+NULL
+select 1.5 in (1.5,NULL,3.5);
+1.5 in (1.5,NULL,3.5)
+1
+select 3.5 in (1.5,NULL,3.5);
+3.5 in (1.5,NULL,3.5)
+1
+select 10.5 in (1.5,NULL,3.5);
+10.5 in (1.5,NULL,3.5)
+NULL
+CREATE TABLE t1 (a int, b int, c int);
+insert into t1 values (1,2,3), (1,NULL,3);
+select 1 in (a,b,c) from t1;
+1 in (a,b,c)
+1
+1
+select 3 in (a,b,c) from t1;
+3 in (a,b,c)
+1
+1
+select 10 in (a,b,c) from t1;
+10 in (a,b,c)
+0
+NULL
+select NULL in (a,b,c) from t1;
+NULL in (a,b,c)
+NULL
+NULL
+drop table t1;
+CREATE TABLE t1 (a float, b float, c float);
+insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5);
+select 1.5 in (a,b,c) from t1;
+1.5 in (a,b,c)
+1
+1
+select 3.5 in (a,b,c) from t1;
+3.5 in (a,b,c)
+1
+1
+select 10.5 in (a,b,c) from t1;
+10.5 in (a,b,c)
+0
+NULL
+drop table t1;
+CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10));
+insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD');
+select 'A' in (a,b,c) from t1;
+'A' in (a,b,c)
+1
+1
+select 'EFD' in (a,b,c) from t1;
+'EFD' in (a,b,c)
+1
+1
+select 'XSFGGHF' in (a,b,c) from t1;
+'XSFGGHF' in (a,b,c)
+0
+NULL
+drop table t1;
CREATE TABLE t1 (field char(1));
INSERT INTO t1 VALUES ('A'),(NULL);
SELECT * from t1 WHERE field IN (NULL);
field
SELECT * from t1 WHERE field NOT IN (NULL);
field
-A
SELECT * from t1 where field = field;
field
A
@@ -16,6 +100,7 @@ NULL
DELETE FROM t1 WHERE field NOT IN (NULL);
SELECT * FROM t1;
field
+A
NULL
drop table t1;
create table t1 (id int(10) primary key);
@@ -26,3 +111,61 @@ id
5
9
drop table t1;
+create table t1 (
+a char(1) character set latin1 collate latin1_general_ci,
+b char(1) character set latin1 collate latin1_swedish_ci,
+c char(1) character set latin1 collate latin1_danish_ci
+);
+insert into t1 values ('A','B','C');
+insert into t1 values ('a','c','c');
+select * from t1 where a in (b);
+ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation ' IN '
+select * from t1 where a in (b,c);
+ERROR HY000: Illegal mix of collations (latin1_general_ci,IMPLICIT), (latin1_swedish_ci,IMPLICIT), (latin1_danish_ci,IMPLICIT) for operation ' IN '
+select * from t1 where 'a' in (a,b,c);
+ERROR HY000: Illegal mix of collations for operation ' IN '
+select * from t1 where 'a' in (a);
+a b c
+A B C
+a c c
+select * from t1 where a in ('a');
+a b c
+A B C
+a c c
+select * from t1 where 'a' collate latin1_general_ci in (a,b,c);
+a b c
+A B C
+a c c
+select * from t1 where 'a' collate latin1_bin in (a,b,c);
+a b c
+a c c
+select * from t1 where 'a' in (a,b,c collate latin1_bin);
+a b c
+a c c
+explain extended select * from t1 where 'a' in (a,b,c collate latin1_bin);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
+Warnings:
+Note 1003 select high_priority test.t1.a AS `a`,test.t1.b AS `b`,test.t1.c AS `c` from test.t1 where (_latin1'a' in (test.t1.a,test.t1.b,(test.t1.c collate _latin1'latin1_bin')))
+drop table t1;
+select '1.0' in (1,2);
+'1.0' in (1,2)
+1
+select 1 in ('1.0',2);
+1 in ('1.0',2)
+1
+select 1 in (1,'2.0');
+1 in (1,'2.0')
+1
+select 1 in ('1.0',2.0);
+1 in ('1.0',2.0)
+1
+select 1 in (1.0,'2.0');
+1 in (1.0,'2.0')
+1
+select 1 in ('1.1',2);
+1 in ('1.1',2)
+0
+select 1 in ('1.1',2.0);
+1 in ('1.1',2.0)
+0
diff --git a/mysql-test/r/func_like.result b/mysql-test/r/func_like.result
index f923c16b2ac..cf07ba88477 100644
--- a/mysql-test/r/func_like.result
+++ b/mysql-test/r/func_like.result
@@ -2,11 +2,11 @@ drop table if exists t1;
create table t1 (a varchar(10), key(a));
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
explain select * from t1 where a like 'abc%';
-table type possible_keys key key_len ref rows Extra
-t1 range a a 11 NULL 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 11 NULL 1 Using where; Using index
explain select * from t1 where a like concat('abc','%');
-table type possible_keys key key_len ref rows Extra
-t1 range a a 11 NULL 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 11 NULL 1 Using where; Using index
select * from t1 where a like "abc%";
a
abc
@@ -37,3 +37,70 @@ select * from t1 where a like "%abc\d%";
a
abcd
drop table t1;
+SET NAMES koi8r;
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET koi8r);
+INSERT INTO t1 VALUES ('ÆÙ×Á'),('æÙ×Á'),('Æù×Á'),('ÆÙ÷Á'),('ÆÙ×á'),('æù÷á');
+INSERT INTO t1 VALUES ('ÆÙ×ÁÐÒÏÌÄÖ'),('æÙ×ÁÐÒÏÌÄÖ'),('Æù×ÁÐÒÏÌÄÖ'),('ÆÙ÷ÁÐÒÏÌÄÖ');
+INSERT INTO t1 VALUES ('ÆÙ×áÐÒÏÌÄÖ'),('ÆÙ×ÁðÒÏÌÄÖ'),('ÆÙ×ÁÐòÏÌÄÖ'),('ÆÙ×ÁÐÒïÌÄÖ');
+INSERT INTO t1 VALUES ('ÆÙ×ÁÐÒÏìÄÖ'),('ÆÙ×ÁÐÒÏÌäÖ'),('ÆÙ×ÁÐÒÏÌÄö'),('æù÷áðòïìäö');
+SELECT * FROM t1 WHERE a LIKE '%Æù×Á%';
+a
+ÆÙ×Á
+æÙ×Á
+Æù×Á
+ÆÙ÷Á
+ÆÙ×á
+æù÷á
+ÆÙ×ÁÐÒÏÌÄÖ
+æÙ×ÁÐÒÏÌÄÖ
+Æù×ÁÐÒÏÌÄÖ
+ÆÙ÷ÁÐÒÏÌÄÖ
+ÆÙ×áÐÒÏÌÄÖ
+ÆÙ×ÁðÒÏÌÄÖ
+ÆÙ×ÁÐòÏÌÄÖ
+ÆÙ×ÁÐÒïÌÄÖ
+ÆÙ×ÁÐÒÏìÄÖ
+ÆÙ×ÁÐÒÏÌäÖ
+ÆÙ×ÁÐÒÏÌÄö
+æù÷áðòïìäö
+SELECT * FROM t1 WHERE a LIKE '%Æù×%';
+a
+ÆÙ×Á
+æÙ×Á
+Æù×Á
+ÆÙ÷Á
+ÆÙ×á
+æù÷á
+ÆÙ×ÁÐÒÏÌÄÖ
+æÙ×ÁÐÒÏÌÄÖ
+Æù×ÁÐÒÏÌÄÖ
+ÆÙ÷ÁÐÒÏÌÄÖ
+ÆÙ×áÐÒÏÌÄÖ
+ÆÙ×ÁðÒÏÌÄÖ
+ÆÙ×ÁÐòÏÌÄÖ
+ÆÙ×ÁÐÒïÌÄÖ
+ÆÙ×ÁÐÒÏìÄÖ
+ÆÙ×ÁÐÒÏÌäÖ
+ÆÙ×ÁÐÒÏÌÄö
+æù÷áðòïìäö
+SELECT * FROM t1 WHERE a LIKE 'Æù×Á%';
+a
+ÆÙ×Á
+æÙ×Á
+Æù×Á
+ÆÙ÷Á
+ÆÙ×á
+æù÷á
+ÆÙ×ÁÐÒÏÌÄÖ
+æÙ×ÁÐÒÏÌÄÖ
+Æù×ÁÐÒÏÌÄÖ
+ÆÙ÷ÁÐÒÏÌÄÖ
+ÆÙ×áÐÒÏÌÄÖ
+ÆÙ×ÁðÒÏÌÄÖ
+ÆÙ×ÁÐòÏÌÄÖ
+ÆÙ×ÁÐÒïÌÄÖ
+ÆÙ×ÁÐÒÏìÄÖ
+ÆÙ×ÁÐÒÏÌäÖ
+ÆÙ×ÁÐÒÏÌÄö
+æù÷áðòïìäö
+DROP TABLE t1;
diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result
index d6596e51db4..151a2902423 100644
--- a/mysql-test/r/func_math.result
+++ b/mysql-test/r/func_math.result
@@ -1,43 +1,108 @@
select floor(5.5),floor(-5.5);
floor(5.5) floor(-5.5)
5 -6
+explain extended select floor(5.5),floor(-5.5);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority floor(5.5) AS `floor(5.5)`,floor(-(5.5)) AS `floor(-5.5)`
select ceiling(5.5),ceiling(-5.5);
ceiling(5.5) ceiling(-5.5)
6 -5
+explain extended select ceiling(5.5),ceiling(-5.5);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority ceiling(5.5) AS `ceiling(5.5)`,ceiling(-(5.5)) AS `ceiling(-5.5)`
select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1);
truncate(52.64,1) truncate(52.64,2) truncate(52.64,-1) truncate(52.64,-2) truncate(-52.64,1) truncate(-52.64,-1)
52.6 52.64 50 0 -52.6 -50
+explain extended select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority truncate(52.64,1) AS `truncate(52.64,1)`,truncate(52.64,2) AS `truncate(52.64,2)`,truncate(52.64,-(1)) AS `truncate(52.64,-1)`,truncate(52.64,-(2)) AS `truncate(52.64,-2)`,truncate(-(52.64),1) AS `truncate(-52.64,1)`,truncate(-(52.64),-(1)) AS `truncate(-52.64,-1)`
select round(5.5),round(-5.5);
round(5.5) round(-5.5)
6 -6
+explain extended select round(5.5),round(-5.5);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority round(5.5,0) AS `round(5.5)`,round(-(5.5),0) AS `round(-5.5)`
select round(5.64,1),round(5.64,2),round(5.64,-1),round(5.64,-2);
round(5.64,1) round(5.64,2) round(5.64,-1) round(5.64,-2)
5.6 5.64 10 0
select abs(-10), sign(-5), sign(5), sign(0);
abs(-10) sign(-5) sign(5) sign(0)
10 -1 1 0
+explain extended select abs(-10), sign(-5), sign(5), sign(0);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority abs(-(10)) AS `abs(-10)`,sign(-(5)) AS `sign(-5)`,sign(5) AS `sign(5)`,sign(0) AS `sign(0)`
select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
log(exp(10)) exp(log(sqrt(10))*2) log(-1) log(NULL) log(1,1) log(3,9) log(-1,2) log(NULL,2)
10.000000 10.000000 NULL NULL NULL 2.000000 NULL NULL
+explain extended select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority log(exp(10)) AS `log(exp(10))`,exp((log(sqrt(10)) * 2)) AS `exp(log(sqrt(10))*2)`,log(-(1)) AS `log(-1)`,log(NULL) AS `log(NULL)`,log(1,1) AS `log(1,1)`,log(3,9) AS `log(3,9)`,log(-(1),2) AS `log(-1,2)`,log(NULL,2) AS `log(NULL,2)`
select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
ln(exp(10)) exp(ln(sqrt(10))*2) ln(-1) ln(0) ln(NULL)
10.000000 10.000000 NULL NULL NULL
+explain extended select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority ln(exp(10)) AS `ln(exp(10))`,exp((ln(sqrt(10)) * 2)) AS `exp(ln(sqrt(10))*2)`,ln(-(1)) AS `ln(-1)`,ln(0) AS `ln(0)`,ln(NULL) AS `ln(NULL)`
select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
log2(8) log2(15) log2(-2) log2(0) log2(NULL)
3.000000 3.906891 NULL NULL NULL
+explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority log2(8) AS `log2(8)`,log2(15) AS `log2(15)`,log2(-(2)) AS `log2(-2)`,log2(0) AS `log2(0)`,log2(NULL) AS `log2(NULL)`
select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
log10(100) log10(18) log10(-4) log10(0) log10(NULL)
2.000000 1.255273 NULL NULL NULL
+explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority log10(100) AS `log10(100)`,log10(18) AS `log10(18)`,log10(-(4)) AS `log10(-4)`,log10(0) AS `log10(0)`,log10(NULL) AS `log10(NULL)`
select pow(10,log10(10)),power(2,4);
pow(10,log10(10)) power(2,4)
10.000000 16.000000
+explain extended select pow(10,log10(10)),power(2,4);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority pow(10,log10(10)) AS `pow(10,log10(10))`,pow(2,4) AS `power(2,4)`
set @@rand_seed1=10000000,@@rand_seed2=1000000;
select rand(999999),rand();
rand(999999) rand()
0.014231365187309 0.028870999839968
+explain extended select rand(999999),rand();
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority no_cache rand(999999) AS `rand(999999)`,rand() AS `rand()`
select pi(),sin(pi()/2),cos(pi()/2),abs(tan(pi())),cot(1),asin(1),acos(0),atan(1);
pi() sin(pi()/2) cos(pi()/2) abs(tan(pi())) cot(1) asin(1) acos(0) atan(1)
3.141593 1.000000 0.000000 0.000000 0.64209262 1.570796 1.570796 0.785398
+explain extended select pi(),sin(pi()/2),cos(pi()/2),abs(tan(pi())),cot(1),asin(1),acos(0),atan(1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority pi() AS `pi()`,sin((pi() / 2)) AS `sin(pi()/2)`,cos((pi() / 2)) AS `cos(pi()/2)`,abs(tan(pi())) AS `abs(tan(pi()))`,(1 / tan(1)) AS `cot(1)`,asin(1) AS `asin(1)`,acos(0) AS `acos(0)`,atan(1) AS `atan(1)`
select degrees(pi()),radians(360);
degrees(pi()) radians(360)
180 6.2831853071796
+explain extended select degrees(pi()),radians(360);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority degrees(pi()) AS `degrees(pi())`,radians(360) AS `radians(360)`
diff --git a/mysql-test/r/func_op.result b/mysql-test/r/func_op.result
index 9f49b5809df..25a7ac20b66 100644
--- a/mysql-test/r/func_op.result
+++ b/mysql-test/r/func_op.result
@@ -1,9 +1,19 @@
select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2;
1+1 1-1 1+1*2 8/5 8%5 mod(8,5) mod(8,5)|0 -(1+1)*-2
2 0 3 1.60 3 3 3 4
+explain extended select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority (1 + 1) AS `1+1`,(1 - 1) AS `1-1`,(1 + (1 * 2)) AS `1+1*2`,(8 / 5) AS `8/5`,(8 % 5) AS `8%5`,(8 % 5) AS `mod(8,5)`,((8 % 5) | 0) AS `mod(8,5)|0`,(-((1 + 1)) * -(2)) AS `-(1+1)*-2`
select 1 | (1+1),5 & 3,bit_count(7) ;
1 | (1+1) 5 & 3 bit_count(7)
3 1 3
+explain extended select 1 | (1+1),5 & 3,bit_count(7) ;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority (1 | (1 + 1)) AS `1 | (1+1)`,(5 & 3) AS `5 & 3`,bit_count(7) AS `bit_count(7)`
select 1 << 32,1 << 63, 1 << 64, 4 >> 2, 4 >> 63, 1<< 63 >> 60;
1 << 32 1 << 63 1 << 64 4 >> 2 4 >> 63 1<< 63 >> 60
4294967296 9223372036854775808 0 1 0 8
diff --git a/mysql-test/r/func_regexp.result b/mysql-test/r/func_regexp.result
index 8d22994ef2b..323642cab8c 100644
--- a/mysql-test/r/func_regexp.result
+++ b/mysql-test/r/func_regexp.result
@@ -36,6 +36,11 @@ insert into t1 (xxx) values('this is a test of some long text to see what happen
select * from t1 where xxx regexp('is a test of some long text to');
xxx
this is a test of some long text to see what happens
+explain extended select * from t1 where xxx regexp('is a test of some long text to');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 1
+Warnings:
+Note 1003 select high_priority test.t1.xxx AS `xxx` from test.t1 where (test.t1.xxx regexp _latin1'is a test of some long text to')
select * from t1 where xxx regexp('is a test of some long text to ');
xxx
this is a test of some long text to see what happens
@@ -52,3 +57,27 @@ select * from t1 where xxx REGEXP '^this is some text: to test - out\\.reg exp [
xxx
this is some text: to test - out.reg exp (22/45)
drop table t1;
+select _latin1 0xFF regexp _latin1 '[[:lower:]]' COLLATE latin1_bin;
+_latin1 0xFF regexp _latin1 '[[:lower:]]' COLLATE latin1_bin
+1
+select _koi8r 0xFF regexp _koi8r '[[:lower:]]' COLLATE koi8r_bin;
+_koi8r 0xFF regexp _koi8r '[[:lower:]]' COLLATE koi8r_bin
+0
+select _latin1 0xFF regexp _latin1 '[[:upper:]]' COLLATE latin1_bin;
+_latin1 0xFF regexp _latin1 '[[:upper:]]' COLLATE latin1_bin
+0
+select _koi8r 0xFF regexp _koi8r '[[:upper:]]' COLLATE koi8r_bin;
+_koi8r 0xFF regexp _koi8r '[[:upper:]]' COLLATE koi8r_bin
+1
+select _latin1 0xF7 regexp _latin1 '[[:alpha:]]';
+_latin1 0xF7 regexp _latin1 '[[:alpha:]]'
+0
+select _koi8r 0xF7 regexp _koi8r '[[:alpha:]]';
+_koi8r 0xF7 regexp _koi8r '[[:alpha:]]'
+1
+select _latin1'a' regexp _latin1'A' collate latin1_general_ci;
+_latin1'a' regexp _latin1'A' collate latin1_general_ci
+1
+select _latin1'a' regexp _latin1'A' collate latin1_bin;
+_latin1'a' regexp _latin1'A' collate latin1_bin
+0
diff --git a/mysql-test/r/func_sapdb.result b/mysql-test/r/func_sapdb.result
new file mode 100644
index 00000000000..e330c73727b
--- /dev/null
+++ b/mysql-test/r/func_sapdb.result
@@ -0,0 +1,200 @@
+drop table if exists t1, test;
+select extract(DAY_MICROSECOND FROM "1999-01-02 10:11:12.000123");
+extract(DAY_MICROSECOND FROM "1999-01-02 10:11:12.000123")
+2101112000123
+select extract(HOUR_MICROSECOND FROM "1999-01-02 10:11:12.000123");
+extract(HOUR_MICROSECOND FROM "1999-01-02 10:11:12.000123")
+101112000123
+select extract(MINUTE_MICROSECOND FROM "1999-01-02 10:11:12.000123");
+extract(MINUTE_MICROSECOND FROM "1999-01-02 10:11:12.000123")
+1112000123
+select extract(SECOND_MICROSECOND FROM "1999-01-02 10:11:12.000123");
+extract(SECOND_MICROSECOND FROM "1999-01-02 10:11:12.000123")
+12000123
+select extract(MICROSECOND FROM "1999-01-02 10:11:12.000123");
+extract(MICROSECOND FROM "1999-01-02 10:11:12.000123")
+123
+select date_format("1997-12-31 23:59:59.000002", "%f");
+date_format("1997-12-31 23:59:59.000002", "%f")
+000002
+select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000 99:99:99.999999" DAY_MICROSECOND);
+date_add("1997-12-31 23:59:59.000002",INTERVAL "10000 99:99:99.999999" DAY_MICROSECOND)
+2025-05-23 04:40:39.000001
+select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99:99.999999" HOUR_MICROSECOND);
+date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99:99.999999" HOUR_MICROSECOND)
+1999-02-21 17:40:39.000001
+select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99.999999" MINUTE_MICROSECOND);
+date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99.999999" MINUTE_MICROSECOND)
+1998-01-07 22:41:39.000001
+select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000.999999" SECOND_MICROSECOND);
+date_add("1997-12-31 23:59:59.000002",INTERVAL "10000.999999" SECOND_MICROSECOND)
+1998-01-01 02:46:40.000001
+select date_add("1997-12-31 23:59:59.000002",INTERVAL "999999" MICROSECOND);
+date_add("1997-12-31 23:59:59.000002",INTERVAL "999999" MICROSECOND)
+1998-01-01 00:00:00.000001
+select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1 1:1:1.000002" DAY_MICROSECOND);
+date_sub("1998-01-01 00:00:00.000001",INTERVAL "1 1:1:1.000002" DAY_MICROSECOND)
+1997-12-30 22:58:58.999999
+select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1:1.000002" HOUR_MICROSECOND);
+date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1:1.000002" HOUR_MICROSECOND)
+1997-12-31 22:58:58.999999
+select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1.000002" MINUTE_MICROSECOND);
+date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1.000002" MINUTE_MICROSECOND)
+1997-12-31 23:58:58.999999
+select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1.000002" SECOND_MICROSECOND);
+date_sub("1998-01-01 00:00:00.000001",INTERVAL "1.000002" SECOND_MICROSECOND)
+1997-12-31 23:59:58.999999
+select date_sub("1998-01-01 00:00:00.000001",INTERVAL "000002" MICROSECOND);
+date_sub("1998-01-01 00:00:00.000001",INTERVAL "000002" MICROSECOND)
+1997-12-31 23:59:59.999999
+select adddate("1997-12-31 23:59:59.000001", 10);
+adddate("1997-12-31 23:59:59.000001", 10)
+1998-01-10 23:59:59.000001
+select subdate("1997-12-31 23:59:59.000001", 10);
+subdate("1997-12-31 23:59:59.000001", 10)
+1997-12-21 23:59:59.000001
+select datediff("1997-12-31 23:59:59.000001","1997-12-30");
+datediff("1997-12-31 23:59:59.000001","1997-12-30")
+1
+select datediff("1997-11-31 23:59:59.000001","1997-12-31");
+datediff("1997-11-31 23:59:59.000001","1997-12-31")
+-30
+select datediff("1997-11-31 23:59:59.000001",null);
+datediff("1997-11-31 23:59:59.000001",null)
+NULL
+select weekofyear("1997-11-31 23:59:59.000001");
+weekofyear("1997-11-31 23:59:59.000001")
+49
+select makedate(1997,1);
+makedate(1997,1)
+1997-01-01
+select makedate(1997,0);
+makedate(1997,0)
+NULL
+select addtime("1997-12-31 23:59:59.999999", "1 1:1:1.000002");
+addtime("1997-12-31 23:59:59.999999", "1 1:1:1.000002")
+1998-01-02 01:01:01.000001
+select subtime("1997-12-31 23:59:59.000001", "1 1:1:1.000002");
+subtime("1997-12-31 23:59:59.000001", "1 1:1:1.000002")
+1997-12-30 22:58:57.999999
+select addtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999");
+addtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999")
+NULL
+select subtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999");
+subtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999")
+NULL
+select subtime("01:00:00.999999", "02:00:00.999998");
+subtime("01:00:00.999999", "02:00:00.999998")
+-00:59:59.999999
+select subtime("02:01:01.999999", "01:01:01.999999");
+subtime("02:01:01.999999", "01:01:01.999999")
+01:00:00.000000
+select timediff("1997-01-01 23:59:59.000001","1995-12-31 23:59:59.000002");
+timediff("1997-01-01 23:59:59.000001","1995-12-31 23:59:59.000002")
+8807:59:59.999999
+select timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002");
+timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002")
+46:58:57.999999
+select timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002");
+timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002")
+-23:59:59.999999
+select timediff("1997-12-31 23:59:59.000001","23:59:59.000001");
+timediff("1997-12-31 23:59:59.000001","23:59:59.000001")
+NULL
+select timediff("2000:01:01 00:00:00", "2000:01:01 00:00:00.000001");
+timediff("2000:01:01 00:00:00", "2000:01:01 00:00:00.000001")
+-00:00:00.000001
+select maketime(10,11,12);
+maketime(10,11,12)
+10:11:12
+select maketime(25,11,12);
+maketime(25,11,12)
+25:11:12
+select maketime(-25,11,12);
+maketime(-25,11,12)
+-25:11:12
+select timestamp("2001-12-01", "01:01:01.999999");
+timestamp("2001-12-01", "01:01:01.999999")
+2001-12-01 01:01:01.999999
+select timestamp("2001-13-01", "01:01:01.000001");
+timestamp("2001-13-01", "01:01:01.000001")
+NULL
+select timestamp("2001-12-01", "25:01:01");
+timestamp("2001-12-01", "25:01:01")
+2001-12-02 01:01:01
+select timestamp("2001-12-01 01:01:01.000100");
+timestamp("2001-12-01 01:01:01.000100")
+2001-12-01 01:01:01.000100
+select timestamp("2001-12-01");
+timestamp("2001-12-01")
+2001-12-01 00:00:00
+select day("1997-12-31 23:59:59.000001");
+day("1997-12-31 23:59:59.000001")
+31
+select date("1997-12-31 23:59:59.000001");
+date("1997-12-31 23:59:59.000001")
+1997-12-31
+select date("1997-13-31 23:59:59.000001");
+date("1997-13-31 23:59:59.000001")
+NULL
+select time("1997-12-31 23:59:59.000001");
+time("1997-12-31 23:59:59.000001")
+23:59:59.000001
+select time("1997-12-31 25:59:59.000001");
+time("1997-12-31 25:59:59.000001")
+NULL
+select microsecond("1997-12-31 23:59:59.000001");
+microsecond("1997-12-31 23:59:59.000001")
+1
+create table t1
+select makedate(1997,1) as f1,
+addtime(cast("1997-12-31 23:59:59.000001" as datetime), "1 1:1:1.000002") as f2,
+addtime(cast("23:59:59.999999" as time) , "1 1:1:1.000002") as f3,
+timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002") as f4,
+timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002") as f5,
+maketime(10,11,12) as f6,
+timestamp(cast("2001-12-01" as date), "01:01:01") as f7,
+date("1997-12-31 23:59:59.000001") as f8,
+time("1997-12-31 23:59:59.000001") as f9;
+describe t1;
+Field Type Null Key Default Extra
+f1 date 0000-00-00
+f2 datetime 0000-00-00 00:00:00
+f3 time 00:00:00
+f4 time 00:00:00
+f5 time 00:00:00
+f6 time 00:00:00
+f7 datetime 0000-00-00 00:00:00
+f8 date 0000-00-00
+f9 time 00:00:00
+select * from t1;
+f1 f2 f3 f4 f5 f6 f7 f8 f9
+1997-01-01 1998-01-02 01:01:00 49:01:01 46:58:57 -23:59:59 10:11:12 2001-12-01 01:01:01 1997-12-31 23:59:59
+create table test(t1 datetime, t2 time, t3 time, t4 datetime);
+insert into test values
+('2001-01-01 01:01:01', '01:01:01', null, '2001-02-01 01:01:01'),
+('2001-01-01 01:01:01', '-01:01:01', '-23:59:59', "1997-12-31 23:59:59.000001"),
+('1997-12-31 23:59:59.000001', '-23:59:59', '-01:01:01', '2001-01-01 01:01:01'),
+('2001-01-01 01:01:01', '01:01:01', '-1 01:01:01', null),
+('2001-01-01 01:01:01', null, '-1 01:01:01', null),
+(null, null, null, null),
+('2001-01-01 01:01:01', '01:01:01', '1 01:01:01', '2001-01-01 01:01:01');
+SELECT ADDTIME(t1,t2) As ttt, ADDTIME(t2, t3) As qqq from test;
+ttt qqq
+2001-01-01 02:02:02 NULL
+2001-01-01 00:00:00 -25:01:00
+1997-12-31 00:00:00 -25:01:00
+2001-01-01 02:02:02 -24:00:00
+NULL NULL
+NULL NULL
+2001-01-01 02:02:02 26:02:02
+SELECT TIMEDIFF(t1,t4) As ttt, TIMEDIFF(t2, t3) As qqq from test;
+ttt qqq
+-744:00:00 NULL
+26305:01:02 22:58:58
+-26305:01:02 -22:58:58
+NULL 26:02:02
+NULL NULL
+NULL NULL
+00:00:00 -24:00:00
+drop table t1, test;
diff --git a/mysql-test/r/func_set.result b/mysql-test/r/func_set.result
index eeeb216d142..2a3631140b0 100644
--- a/mysql-test/r/func_set.result
+++ b/mysql-test/r/func_set.result
@@ -1,6 +1,11 @@
select interval(55,10,20,30,40,50,60,70,80,90,100),interval(3,1,1+1,1+1+1+1),field("IBM","NCA","ICL","SUN","IBM","DIGITAL"),field("A","B","C"),elt(2,"ONE","TWO","THREE"),interval(0,1,2,3,4),elt(1,1,2,3)|0,elt(1,1.1,1.2,1.3)+0;
interval(55,10,20,30,40,50,60,70,80,90,100) interval(3,1,1+1,1+1+1+1) field("IBM","NCA","ICL","SUN","IBM","DIGITAL") field("A","B","C") elt(2,"ONE","TWO","THREE") interval(0,1,2,3,4) elt(1,1,2,3)|0 elt(1,1.1,1.2,1.3)+0
5 2 4 0 TWO 0 1 1.1
+explain extended select INTERVAL(55,10,20,30,40,50,60,70,80,90,100),interval(3,1,1+1,1+1+1+1),field("IBM","NCA","ICL","SUN","IBM","DIGITAL"),field("A","B","C"),elt(2,"ONE","TWO","THREE"),interval(0,1,2,3,4),elt(1,1,2,3)|0,elt(1,1.1,1.2,1.3)+0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority interval((55,10,20,30,40,50,60,70,80,90,100)) AS `INTERVAL(55,10,20,30,40,50,60,70,80,90,100)`,interval((3,1,(1 + 1),(((1 + 1) + 1) + 1))) AS `interval(3,1,1+1,1+1+1+1)`,field(_latin1'IBM',_latin1'NCA',_latin1'ICL',_latin1'SUN',_latin1'IBM',_latin1'DIGITAL') AS `field("IBM","NCA","ICL","SUN","IBM","DIGITAL")`,field(_latin1'A',_latin1'B',_latin1'C') AS `field("A","B","C")`,elt(2,_latin1'ONE',_latin1'TWO',_latin1'THREE') AS `elt(2,"ONE","TWO","THREE")`,interval((0,1,2,3,4)) AS `interval(0,1,2,3,4)`,(elt(1,1,2,3) | 0) AS `elt(1,1,2,3)|0`,(elt(1,1.1,1.2,1.3) + 0) AS `elt(1,1.1,1.2,1.3)+0`
select find_in_set("b","a,b,c"),find_in_set("c","a,b,c"),find_in_set("dd","a,bbb,dd"),find_in_set("bbb","a,bbb,dd");
find_in_set("b","a,b,c") find_in_set("c","a,b,c") find_in_set("dd","a,bbb,dd") find_in_set("bbb","a,bbb,dd")
2 3 3 2
@@ -28,3 +33,20 @@ find_in_set("abc","abc") find_in_set("ab","abc") find_in_set("abcd","abc")
select interval(null, 1, 10, 100);
interval(null, 1, 10, 100)
-1
+drop table if exists t1,t2;
+create table t1 (id int(10) not null unique);
+create table t2 (id int(10) not null primary key,
+val int(10) not null);
+insert into t1 values (1),(2),(4);
+insert into t2 values (1,1),(2,1),(3,1),(4,2);
+select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id;
+id elt(two.val,'one','two')
+1 one
+2 one
+4 two
+select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id;
+id elt(two.val,'one','two')
+1 one
+2 one
+4 two
+drop table t1,t2;
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index 0bac5111a05..64b6d7e65f9 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -1,4 +1,5 @@
drop table if exists t1;
+set names latin1;
select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo';
hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo
hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo
@@ -11,9 +12,15 @@ length('\n\t\r\b\0\_\%\\')
select bit_length('\n\t\r\b\0\_\%\\');
bit_length('\n\t\r\b\0\_\%\\')
80
-select concat('monty',' was here ','again'),length('hello'),char(ascii('h'));
-concat('monty',' was here ','again') length('hello') char(ascii('h'))
-monty was here again 5 h
+select char_length('\n\t\r\b\0\_\%\\');
+char_length('\n\t\r\b\0\_\%\\')
+10
+select length(_latin1'\n\t\n\b\0\\_\\%\\');
+length(_latin1'\n\t\n\b\0\\_\\%\\')
+10
+select concat('monty',' was here ','again'),length('hello'),char(ascii('h')),ord('h');
+concat('monty',' was here ','again') length('hello') char(ascii('h')) ord('h')
+monty was here again 5 h 104
select locate('he','hello'),locate('he','hello',2),locate('lo','hello',2) ;
locate('he','hello') locate('he','hello',2) locate('lo','hello',2)
1 0 4
@@ -80,9 +87,27 @@ this is a REAL test
select soundex(''),soundex('he'),soundex('hello all folks');
soundex('') soundex('he') soundex('hello all folks')
H000 H4142
+select 'mood' sounds like 'mud';
+'mood' sounds like 'mud'
+1
+select 'Glazgo' sounds like 'Liverpool';
+'Glazgo' sounds like 'Liverpool'
+0
+select null sounds like 'null';
+null sounds like 'null'
+NULL
+select 'null' sounds like null;
+'null' sounds like null
+NULL
+select null sounds like null;
+null sounds like null
+NULL
select md5('hello');
md5('hello')
5d41402abc4b2a76b9719d911017c592
+select crc32("123");
+crc32("123")
+2286445522
select sha('abc');
sha('abc')
a9993e364706816aba3e25717850c26c9cd0d89d
@@ -216,14 +241,14 @@ bugstatus int(10) unsigned default NULL,
submitter int(10) unsigned default NULL
) TYPE=MyISAM;
INSERT INTO t1 VALUES (1,'Link',1,1,1,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa','2001-02-28 08:40:16',20010228084016,0,4);
-SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter), '"') FROM t1;
-CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter), '"')
+SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter), '"') FROM t1;
+CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter), '"')
"Link";"1";"1";"1";"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"2001-02-28 08:40:16";"20010228084016";"0";"4"
SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugstatus,submitter), '"') FROM t1;
CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugstatus,submitter), '"')
"Link";"1";"1";"1";"0";"4"
-SELECT CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter) FROM t1;
-CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter)
+SELECT CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter) FROM t1;
+CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter)
Link";"1";"1";"1";"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"2001-02-28 08:40:16";"20010228084016";"0";"4
SELECT bugdesc, REPLACE(bugdesc, 'xxxxxxxxxxxxxxxxxxxx', 'bbbbbbbbbbbbbbbbbbbb') from t1 group by bugdesc;
bugdesc REPLACE(bugdesc, 'xxxxxxxxxxxxxxxxxxxx', 'bbbbbbbbbbbbbbbbbbbb')
@@ -234,6 +259,314 @@ INSERT INTO t1 VALUES (1, 'a545f661efdd1fb66fdee3aab79945bf');
SELECT 1 FROM t1 WHERE tmp=AES_DECRYPT(tmp,"password");
1
DROP TABLE t1;
+select 1=_latin1'1';
+1=_latin1'1'
+1
+select _latin1'1'=1;
+_latin1'1'=1
+1
+select _latin2'1'=1;
+_latin2'1'=1
+1
+select 1=_latin2'1';
+1=_latin2'1'
+1
+select _latin1'1'=_latin2'1';
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation '='
+select row('a','b','c') = row('a','b','c');
+row('a','b','c') = row('a','b','c')
+1
+select row('A','b','c') = row('a','b','c');
+row('A','b','c') = row('a','b','c')
+1
+select row('A' COLLATE latin1_bin,'b','c') = row('a','b','c');
+row('A' COLLATE latin1_bin,'b','c') = row('a','b','c')
+0
+select row('A','b','c') = row('a' COLLATE latin1_bin,'b','c');
+row('A','b','c') = row('a' COLLATE latin1_bin,'b','c')
+0
+select row('A' COLLATE latin1_general_ci,'b','c') = row('a' COLLATE latin1_bin,'b','c');
+ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation '='
+select concat(_latin1'a',_latin2'a');
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat'
+select concat(_latin1'a',_latin2'a',_latin5'a');
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin5_turkish_ci,COERCIBLE) for operation 'concat'
+select concat(_latin1'a',_latin2'a',_latin5'a',_latin7'a');
+ERROR HY000: Illegal mix of collations for operation 'concat'
+select FIELD('b','A','B');
+FIELD('b','A','B')
+2
+select FIELD('B','A','B');
+FIELD('B','A','B')
+2
+select FIELD('b' COLLATE latin1_bin,'A','B');
+FIELD('b' COLLATE latin1_bin,'A','B')
+0
+select FIELD('b','A' COLLATE latin1_bin,'B');
+FIELD('b','A' COLLATE latin1_bin,'B')
+0
+select FIELD(_latin2'b','A','B');
+ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field'
+select FIELD('b',_latin2'A','B');
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field'
+select FIELD('b',_latin2'A','B',1);
+FIELD('b',_latin2'A','B',1)
+1
+select POSITION(_latin1'B' IN _latin1'abcd');
+POSITION(_latin1'B' IN _latin1'abcd')
+2
+select POSITION(_latin1'B' IN _latin1'abcd' COLLATE latin1_bin);
+POSITION(_latin1'B' IN _latin1'abcd' COLLATE latin1_bin)
+0
+select POSITION(_latin1'B' COLLATE latin1_bin IN _latin1'abcd');
+POSITION(_latin1'B' COLLATE latin1_bin IN _latin1'abcd')
+0
+select POSITION(_latin1'B' COLLATE latin1_general_ci IN _latin1'abcd' COLLATE latin1_bin);
+ERROR HY000: Illegal mix of collations (latin1_bin,EXPLICIT) and (latin1_general_ci,EXPLICIT) for operation 'locate'
+select POSITION(_latin1'B' IN _latin2'abcd');
+ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation 'locate'
+select FIND_IN_SET(_latin1'B',_latin1'a,b,c,d');
+FIND_IN_SET(_latin1'B',_latin1'a,b,c,d')
+2
+select FIND_IN_SET(_latin1'B' COLLATE latin1_general_ci,_latin1'a,b,c,d' COLLATE latin1_bin);
+ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'find_in_set'
+select FIND_IN_SET(_latin1'B',_latin2'a,b,c,d');
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'find_in_set'
+select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd',2);
+SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd',2)
+abcdabc
+select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin2'd',2);
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'substr_index'
+select SUBSTRING_INDEX(_latin1'abcdabcdabcd' COLLATE latin1_general_ci,_latin1'd' COLLATE latin1_bin,2);
+ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'substr_index'
+select _latin1'B' between _latin1'a' and _latin1'c';
+_latin1'B' between _latin1'a' and _latin1'c'
+1
+select _latin1'B' collate latin1_bin between _latin1'a' and _latin1'c';
+_latin1'B' collate latin1_bin between _latin1'a' and _latin1'c'
+0
+select _latin1'B' between _latin1'a' collate latin1_bin and _latin1'c';
+_latin1'B' between _latin1'a' collate latin1_bin and _latin1'c'
+0
+select _latin1'B' between _latin1'a' and _latin1'c' collate latin1_bin;
+_latin1'B' between _latin1'a' and _latin1'c' collate latin1_bin
+0
+select _latin2'B' between _latin1'a' and _latin1'b';
+ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'between'
+select _latin1'B' between _latin2'a' and _latin1'b';
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'between'
+select _latin1'B' between _latin1'a' and _latin2'b';
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE) for operation 'between'
+select _latin1'B' collate latin1_general_ci between _latin1'a' collate latin1_bin and _latin1'b';
+ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_bin,EXPLICIT), (latin1_swedish_ci,COERCIBLE) for operation 'between'
+select _latin1'B' in (_latin1'a',_latin1'b');
+_latin1'B' in (_latin1'a',_latin1'b')
+1
+select _latin1'B' collate latin1_bin in (_latin1'a',_latin1'b');
+_latin1'B' collate latin1_bin in (_latin1'a',_latin1'b')
+0
+select _latin1'B' in (_latin1'a' collate latin1_bin,_latin1'b');
+_latin1'B' in (_latin1'a' collate latin1_bin,_latin1'b')
+0
+select _latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin);
+_latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin)
+0
+select _latin2'B' in (_latin1'a',_latin1'b');
+ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation ' IN '
+select _latin1'B' in (_latin2'a',_latin1'b');
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation ' IN '
+select _latin1'B' in (_latin1'a',_latin2'b');
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE) for operation ' IN '
+select _latin1'B' COLLATE latin1_general_ci in (_latin1'a' COLLATE latin1_bin,_latin1'b');
+ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_bin,EXPLICIT), (latin1_swedish_ci,COERCIBLE) for operation ' IN '
+select _latin1'B' COLLATE latin1_general_ci in (_latin1'a',_latin1'b' COLLATE latin1_bin);
+ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_swedish_ci,COERCIBLE), (latin1_bin,EXPLICIT) for operation ' IN '
+select collation(bin(130)), coercibility(bin(130));
+collation(bin(130)) coercibility(bin(130))
+latin1_swedish_ci 3
+select collation(oct(130)), coercibility(oct(130));
+collation(oct(130)) coercibility(oct(130))
+latin1_swedish_ci 3
+select collation(conv(130,16,10)), coercibility(conv(130,16,10));
+collation(conv(130,16,10)) coercibility(conv(130,16,10))
+latin1_swedish_ci 3
+select collation(hex(130)), coercibility(hex(130));
+collation(hex(130)) coercibility(hex(130))
+latin1_swedish_ci 3
+select collation(char(130)), coercibility(hex(130));
+collation(char(130)) coercibility(hex(130))
+binary 3
+select collation(format(130,10)), coercibility(format(130,10));
+collation(format(130,10)) coercibility(format(130,10))
+latin1_swedish_ci 3
+select collation(lcase(_latin2'a')), coercibility(lcase(_latin2'a'));
+collation(lcase(_latin2'a')) coercibility(lcase(_latin2'a'))
+latin2_general_ci 3
+select collation(ucase(_latin2'a')), coercibility(ucase(_latin2'a'));
+collation(ucase(_latin2'a')) coercibility(ucase(_latin2'a'))
+latin2_general_ci 3
+select collation(left(_latin2'a',1)), coercibility(left(_latin2'a',1));
+collation(left(_latin2'a',1)) coercibility(left(_latin2'a',1))
+latin2_general_ci 3
+select collation(right(_latin2'a',1)), coercibility(right(_latin2'a',1));
+collation(right(_latin2'a',1)) coercibility(right(_latin2'a',1))
+latin2_general_ci 3
+select collation(substring(_latin2'a',1,1)), coercibility(substring(_latin2'a',1,1));
+collation(substring(_latin2'a',1,1)) coercibility(substring(_latin2'a',1,1))
+latin2_general_ci 3
+select collation(concat(_latin2'a',_latin2'b')), coercibility(concat(_latin2'a',_latin2'b'));
+collation(concat(_latin2'a',_latin2'b')) coercibility(concat(_latin2'a',_latin2'b'))
+latin2_general_ci 3
+select collation(lpad(_latin2'a',4,_latin2'b')), coercibility(lpad(_latin2'a',4,_latin2'b'));
+collation(lpad(_latin2'a',4,_latin2'b')) coercibility(lpad(_latin2'a',4,_latin2'b'))
+latin2_general_ci 3
+select collation(rpad(_latin2'a',4,_latin2'b')), coercibility(rpad(_latin2'a',4,_latin2'b'));
+collation(rpad(_latin2'a',4,_latin2'b')) coercibility(rpad(_latin2'a',4,_latin2'b'))
+latin2_general_ci 3
+select collation(concat_ws(_latin2'a',_latin2'b')), coercibility(concat_ws(_latin2'a',_latin2'b'));
+collation(concat_ws(_latin2'a',_latin2'b')) coercibility(concat_ws(_latin2'a',_latin2'b'))
+latin2_general_ci 3
+select collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')), coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c'));
+collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')) coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c'))
+latin2_general_ci 3
+select collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')), coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' '));
+collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')) coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' '))
+binary 3
+select collation(trim(_latin2' a ')), coercibility(trim(_latin2' a '));
+collation(trim(_latin2' a ')) coercibility(trim(_latin2' a '))
+latin2_general_ci 3
+select collation(ltrim(_latin2' a ')), coercibility(ltrim(_latin2' a '));
+collation(ltrim(_latin2' a ')) coercibility(ltrim(_latin2' a '))
+latin2_general_ci 3
+select collation(rtrim(_latin2' a ')), coercibility(rtrim(_latin2' a '));
+collation(rtrim(_latin2' a ')) coercibility(rtrim(_latin2' a '))
+latin2_general_ci 3
+select collation(trim(LEADING _latin2' ' FROM _latin2'a')), coercibility(trim(LEADING _latin2'a' FROM _latin2'a'));
+collation(trim(LEADING _latin2' ' FROM _latin2'a')) coercibility(trim(LEADING _latin2'a' FROM _latin2'a'))
+latin2_general_ci 3
+select collation(trim(TRAILING _latin2' ' FROM _latin2'a')), coercibility(trim(TRAILING _latin2'a' FROM _latin2'a'));
+collation(trim(TRAILING _latin2' ' FROM _latin2'a')) coercibility(trim(TRAILING _latin2'a' FROM _latin2'a'))
+latin2_general_ci 3
+select collation(trim(BOTH _latin2' ' FROM _latin2'a')), coercibility(trim(BOTH _latin2'a' FROM _latin2'a'));
+collation(trim(BOTH _latin2' ' FROM _latin2'a')) coercibility(trim(BOTH _latin2'a' FROM _latin2'a'))
+latin2_general_ci 3
+select collation(repeat(_latin2'a',10)), coercibility(repeat(_latin2'a',10));
+collation(repeat(_latin2'a',10)) coercibility(repeat(_latin2'a',10))
+latin2_general_ci 3
+select collation(reverse(_latin2'ab')), coercibility(reverse(_latin2'ab'));
+collation(reverse(_latin2'ab')) coercibility(reverse(_latin2'ab'))
+latin2_general_ci 3
+select collation(quote(_latin2'ab')), coercibility(quote(_latin2'ab'));
+collation(quote(_latin2'ab')) coercibility(quote(_latin2'ab'))
+latin2_general_ci 3
+select collation(soundex(_latin2'ab')), coercibility(soundex(_latin2'ab'));
+collation(soundex(_latin2'ab')) coercibility(soundex(_latin2'ab'))
+latin2_general_ci 3
+select collation(substring(_latin2'ab',1)), coercibility(substring(_latin2'ab',1));
+collation(substring(_latin2'ab',1)) coercibility(substring(_latin2'ab',1))
+latin2_general_ci 3
+select collation(insert(_latin2'abcd',2,3,_latin2'ef')), coercibility(insert(_latin2'abcd',2,3,_latin2'ef'));
+collation(insert(_latin2'abcd',2,3,_latin2'ef')) coercibility(insert(_latin2'abcd',2,3,_latin2'ef'))
+latin2_general_ci 3
+select collation(replace(_latin2'abcd',_latin2'b',_latin2'B')), coercibility(replace(_latin2'abcd',_latin2'b',_latin2'B'));
+collation(replace(_latin2'abcd',_latin2'b',_latin2'B')) coercibility(replace(_latin2'abcd',_latin2'b',_latin2'B'))
+latin2_general_ci 3
+create table t1
+select
+bin(130),
+oct(130),
+conv(130,16,10),
+hex(130),
+char(130),
+format(130,10),
+left(_latin2'a',1),
+right(_latin2'a',1),
+lcase(_latin2'a'),
+ucase(_latin2'a'),
+substring(_latin2'a',1,1),
+concat(_latin2'a',_latin2'b'),
+lpad(_latin2'a',4,_latin2'b'),
+rpad(_latin2'a',4,_latin2'b'),
+concat_ws(_latin2'a',_latin2'b'),
+make_set(255,_latin2'a',_latin2'b',_latin2'c'),
+export_set(255,_latin2'y',_latin2'n',_latin2' '),
+trim(_latin2' a '),
+ltrim(_latin2' a '),
+rtrim(_latin2' a '),
+trim(LEADING _latin2' ' FROM _latin2' a '),
+trim(TRAILING _latin2' ' FROM _latin2' a '),
+trim(BOTH _latin2' ' FROM _latin2' a '),
+repeat(_latin2'a',10),
+reverse(_latin2'ab'),
+quote(_latin2'ab'),
+soundex(_latin2'ab'),
+substring(_latin2'ab',1),
+insert(_latin2'abcd',2,3,_latin2'ef'),
+replace(_latin2'abcd',_latin2'b',_latin2'B')
+;
+Warnings:
+Warning 1264 Data truncated for column 'format(130,10)' at row 1
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `bin(130)` char(64) NOT NULL default '',
+ `oct(130)` char(64) NOT NULL default '',
+ `conv(130,16,10)` char(64) NOT NULL default '',
+ `hex(130)` char(6) NOT NULL default '',
+ `char(130)` char(1) NOT NULL default '',
+ `format(130,10)` char(4) NOT NULL default '',
+ `left(_latin2'a',1)` char(1) character set latin2 NOT NULL default '',
+ `right(_latin2'a',1)` char(1) character set latin2 NOT NULL default '',
+ `lcase(_latin2'a')` char(1) character set latin2 NOT NULL default '',
+ `ucase(_latin2'a')` char(1) character set latin2 NOT NULL default '',
+ `substring(_latin2'a',1,1)` char(1) character set latin2 NOT NULL default '',
+ `concat(_latin2'a',_latin2'b')` char(2) character set latin2 NOT NULL default '',
+ `lpad(_latin2'a',4,_latin2'b')` char(4) character set latin2 NOT NULL default '',
+ `rpad(_latin2'a',4,_latin2'b')` char(4) character set latin2 NOT NULL default '',
+ `concat_ws(_latin2'a',_latin2'b')` char(1) character set latin2 NOT NULL default '',
+ `make_set(255,_latin2'a',_latin2'b',_latin2'c')` char(5) character set latin2 NOT NULL default '',
+ `export_set(255,_latin2'y',_latin2'n',_latin2' ')` char(127) character set latin2 NOT NULL default '',
+ `trim(_latin2' a ')` char(3) character set latin2 NOT NULL default '',
+ `ltrim(_latin2' a ')` char(3) character set latin2 NOT NULL default '',
+ `rtrim(_latin2' a ')` char(3) character set latin2 NOT NULL default '',
+ `trim(LEADING _latin2' ' FROM _latin2' a ')` char(3) character set latin2 NOT NULL default '',
+ `trim(TRAILING _latin2' ' FROM _latin2' a ')` char(3) character set latin2 NOT NULL default '',
+ `trim(BOTH _latin2' ' FROM _latin2' a ')` char(3) character set latin2 NOT NULL default '',
+ `repeat(_latin2'a',10)` char(10) character set latin2 NOT NULL default '',
+ `reverse(_latin2'ab')` char(2) character set latin2 NOT NULL default '',
+ `quote(_latin2'ab')` char(6) character set latin2 NOT NULL default '',
+ `soundex(_latin2'ab')` char(4) character set latin2 NOT NULL default '',
+ `substring(_latin2'ab',1)` char(2) character set latin2 NOT NULL default '',
+ `insert(_latin2'abcd',2,3,_latin2'ef')` char(6) character set latin2 NOT NULL default '',
+ `replace(_latin2'abcd',_latin2'b',_latin2'B')` char(4) character set latin2 NOT NULL default ''
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select SUBSTR('abcdefg',3,2);
+SUBSTR('abcdefg',3,2)
+cd
+select SUBSTRING('abcdefg',3,2);
+SUBSTRING('abcdefg',3,2)
+cd
+select SUBSTR('abcdefg',-3,2) FROM DUAL;
+SUBSTR('abcdefg',-3,2)
+ef
+select SUBSTR('abcdefg',-1,5) FROM DUAL;
+SUBSTR('abcdefg',-1,5)
+g
+select SUBSTR('abcdefg',0,0) FROM DUAL;
+SUBSTR('abcdefg',0,0)
+
+select SUBSTR('abcdefg',-1,-1) FROM DUAL;
+SUBSTR('abcdefg',-1,-1)
+
+select SUBSTR('abcdefg',1,-1) FROM DUAL;
+SUBSTR('abcdefg',1,-1)
+
+create table t7 (s1 char);
+select * from t7
+where concat(s1 collate latin1_general_ci,s1 collate latin1_swedish_ci) = 'AA';
+ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_swedish_ci,EXPLICIT) for operation 'concat'
+drop table t7;
CREATE TABLE t1 (
wid int(10) unsigned NOT NULL auto_increment,
data_podp date default NULL,
@@ -247,9 +580,7 @@ elt(status_wnio,data_podp)
NULL
NULL
DROP TABLE t1;
-CREATE TABLE t1 (
-title text
-) TYPE=MyISAM;
+CREATE TABLE t1 (title text) TYPE=MyISAM;
INSERT INTO t1 VALUES ('Congress reconvenes in September to debate welfare and adult education');
INSERT INTO t1 VALUES ('House passes the CAREERS bill');
SELECT CONCAT("</a>",RPAD("",(55 - LENGTH(title)),".")) from t1;
@@ -257,3 +588,11 @@ CONCAT("</a>",RPAD("",(55 - LENGTH(title)),"."))
NULL
</a>..........................
DROP TABLE t1;
+select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2);
+substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2) substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2)
+1abcd;2abcd 3abcd;4abcd
+explain extended select md5('hello'), sha('abc'), sha1('abc'), soundex(''), 'mood' sounds like 'mud', aes_decrypt(aes_encrypt('abc','1'),'1'),concat('*',space(5),'*'), reverse('abc'), rpad('a',4,'1'), lpad('a',4,'1'), concat_ws(',','',NULL,'a'),make_set(255,_latin2'a',_latin2'b',_latin2'c'),elt(2,1),locate("a","b",2),format(130,10),char(0),conv(130,16,10),hex(130),binary 'HE', export_set(255,_latin2'y',_latin2'n',_latin2' '),FIELD('b' COLLATE latin1_bin,'A','B'),FIND_IN_SET(_latin1'B',_latin1'a,b,c,d'),collation(conv(130,16,10)), coercibility(conv(130,16,10)),length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),concat('monty',' was here ','again'),length('hello'),char(ascii('h')),ord('h'),quote(1/0),crc32("123"),replace('aaaa','a','b'),insert('txs',2,1,'hi'),left(_latin2'a',1),right(_latin2'a',1),lcase(_latin2'a'),ucase(_latin2'a'),SUBSTR('abcdefg',3,2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),trim(_latin2' a '),ltrim(_latin2' a '),rtrim(_latin2' a '), decode(encode(repeat("a",100000),"monty"),"monty");
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority md5(_latin1'hello') AS `md5('hello')`,sha(_latin1'abc') AS `sha('abc')`,sha(_latin1'abc') AS `sha1('abc')`,soundex(_latin1'') AS `soundex('')`,(soundex(_latin1'mood') = soundex(_latin1'mud')) AS `'mood' sounds like 'mud'`,aes_decrypt(aes_encrypt(_latin1'abc',_latin1'1'),_latin1'1') AS `aes_decrypt(aes_encrypt('abc','1'),'1')`,concat(_latin1'*',repeat(_latin1' ',5),_latin1'*') AS `concat('*',space(5),'*')`,reverse(_latin1'abc') AS `reverse('abc')`,rpad(_latin1'a',4,_latin1'1') AS `rpad('a',4,'1')`,lpad(_latin1'a',4,_latin1'1') AS `lpad('a',4,'1')`,concat_ws(_latin1',',_latin1'',NULL,_latin1'a') AS `concat_ws(',','',NULL,'a')`,make_set(255,_latin2'a',_latin2'b',_latin2'c') AS `make_set(255,_latin2'a',_latin2'b',_latin2'c')`,elt(2,1) AS `elt(2,1)`,locate(_latin1'a',_latin1'b',2) AS `locate("a","b",2)`,format(130,10) AS `format(130,10)`,char(0) AS `char(0)`,conv(130,16,10) AS `conv(130,16,10)`,hex(130) AS `hex(130)`,(_latin1'HE' collate _latin1'BINARY') AS `binary 'HE'`,export_set(255,_latin2'y',_latin2'n',_latin2' ') AS `export_set(255,_latin2'y',_latin2'n',_latin2' ')`,field((_latin1'b' collate _latin1'latin1_bin'),_latin1'A',_latin1'B') AS `FIELD('b' COLLATE latin1_bin,'A','B')`,find_in_set(_latin1'B',_latin1'a,b,c,d') AS `FIND_IN_SET(_latin1'B',_latin1'a,b,c,d')`,collation(conv(130,16,10)) AS `collation(conv(130,16,10))`,coercibility(conv(130,16,10)) AS `coercibility(conv(130,16,10))`,length(_latin1'\n \r\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,concat(_latin1'monty',_latin1' was here ',_latin1'again') AS `concat('monty',' was here ','again')`,length(_latin1'hello') AS `length('hello')`,char(ascii(_latin1'h')) AS `char(ascii('h'))`,ord(_latin1'h') AS `ord('h')`,quote((1 / 0)) AS `quote(1/0)`,crc32(_latin1'123') AS `crc32("123")`,replace(_latin1'aaaa',_latin1'a',_latin1'b') AS `replace('aaaa','a','b')`,insert(_latin1'txs',2,1,_latin1'hi') AS `insert('txs',2,1,'hi')`,left(_latin2'a',1) AS `left(_latin2'a',1)`,right(_latin2'a',1) AS `right(_latin2'a',1)`,lcase(_latin2'a') AS `lcase(_latin2'a')`,ucase(_latin2'a') AS `ucase(_latin2'a')`,substr(_latin1'abcdefg',3,2) AS `SUBSTR('abcdefg',3,2)`,substr_index(_latin1'1abcd;2abcd;3abcd;4abcd',_latin1';',2) AS `substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2)`,trim(_latin2' a ') AS `trim(_latin2' a ')`,ltrim(_latin2' a ') AS `ltrim(_latin2' a ')`,rtrim(_latin2' a ') AS `rtrim(_latin2' a ')`,decode(encode(repeat(_latin1'a',100000))) AS `decode(encode(repeat("a",100000),"monty"),"monty")`
diff --git a/mysql-test/r/func_system.result b/mysql-test/r/func_system.result
index 5ea4ed5e4e0..d045d4865dc 100644
--- a/mysql-test/r/func_system.result
+++ b/mysql-test/r/func_system.result
@@ -1,6 +1,56 @@
-select database(),user() like "%@%";
-database() user() like "%@%"
-test 1
+select database();
+database()
+test
+select charset(database());
+charset(database())
+utf8
+select database() = "test";
+database() = "test"
+1
+select database() = _utf8"test";
+database() = _utf8"test"
+1
+select database() = _latin1"test";
+database() = _latin1"test"
+1
+select user() like "%@%";
+user() like "%@%"
+1
+select user() like _utf8"%@%";
+user() like _utf8"%@%"
+1
+select user() like _latin1"%@%";
+user() like _latin1"%@%"
+1
+select charset(user());
+charset(user())
+utf8
select version()>="3.23.29";
version()>="3.23.29"
1
+select version()>=_utf8"3.23.29";
+version()>=_utf8"3.23.29"
+1
+select version()>=_latin1"3.23.29";
+version()>=_latin1"3.23.29"
+1
+select charset(version());
+charset(version())
+utf8
+explain extended select database(), user();
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority no_cache database() AS `database()`,user() AS `user()`
+create table t1 (version char(40)) select database(), user(), version() as 'version';
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `database()` char(34) character set utf8 NOT NULL default '',
+ `user()` char(77) character set utf8 NOT NULL default '',
+ `version` char(40) default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+select TRUE,FALSE,NULL;
+TRUE FALSE NULL
+1 0 NULL
diff --git a/mysql-test/r/func_test.result b/mysql-test/r/func_test.result
index e11eaa0d246..4951d954abb 100644
--- a/mysql-test/r/func_test.result
+++ b/mysql-test/r/func_test.result
@@ -1,3 +1,4 @@
+drop table if exists t1,t2;
select 0=0,1>0,1>=1,1<0,1<=0,1!=0,strcmp("abc","abcd"),strcmp("b","a"),strcmp("a","a") ;
0=0 1>0 1>=1 1<0 1<=0 1!=0 strcmp("abc","abcd") strcmp("b","a") strcmp("a","a")
1 1 1 0 0 1 -1 1 0
@@ -43,13 +44,47 @@ select -1.49 or -1.49,0.6 or 0.6;
select 3 ^ 11, 1 ^ 1, 1 ^ 0, 1 ^ NULL, NULL ^ 1;
3 ^ 11 1 ^ 1 1 ^ 0 1 ^ NULL NULL ^ 1
8 0 1 NULL NULL
+explain extended select 3 ^ 11, 1 ^ 1, 1 ^ 0, 1 ^ NULL, NULL ^ 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority (3 ^ 11) AS `3 ^ 11`,(1 ^ 1) AS `1 ^ 1`,(1 ^ 0) AS `1 ^ 0`,(1 ^ NULL) AS `1 ^ NULL`,(NULL ^ 1) AS `NULL ^ 1`
select 1 XOR 1, 1 XOR 0, 0 XOR 1, 0 XOR 0, NULL XOR 1, 1 XOR NULL, 0 XOR NULL;
1 XOR 1 1 XOR 0 0 XOR 1 0 XOR 0 NULL XOR 1 1 XOR NULL 0 XOR NULL
0 1 1 0 NULL NULL NULL
+select 10 % 7, 10 mod 7, 10 div 3;
+10 % 7 10 mod 7 10 div 3
+3 3 3
+explain extended select 10 % 7, 10 mod 7, 10 div 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority (10 % 7) AS `10 % 7`,(10 % 7) AS `10 mod 7`,(10 DIV 3) AS `10 div 3`
+select (1 << 64)-1, ((1 << 64)-1) DIV 1, ((1 << 64)-1) DIV 2;
+(1 << 64)-1 ((1 << 64)-1) DIV 1 ((1 << 64)-1) DIV 2
+18446744073709551615 18446744073709551615 9223372036854775807
+explain extended select (1 << 64)-1, ((1 << 64)-1) DIV 1, ((1 << 64)-1) DIV 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority ((1 << 64) - 1) AS `(1 << 64)-1`,(((1 << 64) - 1) DIV 1) AS `((1 << 64)-1) DIV 1`,(((1 << 64) - 1) DIV 2) AS `((1 << 64)-1) DIV 2`
create table t1 (a int);
insert t1 values (1);
select * from t1 where 1 xor 1;
a
+explain extended select * from t1 where 1 xor 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+Warnings:
+Note 1003 select high_priority test.t1.a AS `a` from test.t1 where (1 xor 1)
+select - a from t1;
+- a
+-1
+explain extended select - a from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 1
+Warnings:
+Note 1003 select high_priority -(test.t1.a) AS `- a` from test.t1
drop table t1;
select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1;
5 between 0 and 10 between 0 and 1 (5 between 0 and 10) between 0 and 1
@@ -60,7 +95,68 @@ select 1 and 2 between 2 and 10, 2 between 2 and 10 and 1;
select 1 and 0 or 2, 2 or 1 and 0;
1 and 0 or 2 2 or 1 and 0
1 1
-DROP TABLE IF EXISTS t1,t2;
+select _koi8r'a' = _koi8r'A';
+_koi8r'a' = _koi8r'A'
+1
+select _koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci;
+_koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci
+1
+explain extended select _koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority (_koi8r'a' = (_koi8r'A' collate _latin1'koi8r_general_ci')) AS `_koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci`
+select _koi8r'a' = _koi8r'A' COLLATE koi8r_bin;
+_koi8r'a' = _koi8r'A' COLLATE koi8r_bin
+0
+select _koi8r'a' COLLATE koi8r_general_ci = _koi8r'A';
+_koi8r'a' COLLATE koi8r_general_ci = _koi8r'A'
+1
+select _koi8r'a' COLLATE koi8r_bin = _koi8r'A';
+_koi8r'a' COLLATE koi8r_bin = _koi8r'A'
+0
+select _koi8r'a' COLLATE koi8r_bin = _koi8r'A' COLLATE koi8r_general_ci;
+ERROR HY000: Illegal mix of collations (koi8r_bin,EXPLICIT) and (koi8r_general_ci,EXPLICIT) for operation '='
+select _koi8r'a' = _latin1'A';
+ERROR HY000: Illegal mix of collations (koi8r_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation '='
+select strcmp(_koi8r'a', _koi8r'A');
+strcmp(_koi8r'a', _koi8r'A')
+0
+select strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_general_ci);
+strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_general_ci)
+0
+select strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_bin);
+strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_bin)
+1
+select strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A');
+strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A')
+0
+select strcmp(_koi8r'a' COLLATE koi8r_bin, _koi8r'A');
+strcmp(_koi8r'a' COLLATE koi8r_bin, _koi8r'A')
+1
+select strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A' COLLATE koi8r_bin);
+ERROR HY000: Illegal mix of collations (koi8r_general_ci,EXPLICIT) and (koi8r_bin,EXPLICIT) for operation 'strcmp'
+select strcmp(_koi8r'a', _latin1'A');
+ERROR HY000: Illegal mix of collations (koi8r_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation 'strcmp'
+select _koi8r'a' LIKE _koi8r'A';
+_koi8r'a' LIKE _koi8r'A'
+1
+select _koi8r'a' LIKE _koi8r'A' COLLATE koi8r_general_ci;
+_koi8r'a' LIKE _koi8r'A' COLLATE koi8r_general_ci
+1
+select _koi8r'a' LIKE _koi8r'A' COLLATE koi8r_bin;
+_koi8r'a' LIKE _koi8r'A' COLLATE koi8r_bin
+0
+select _koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A';
+_koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A'
+1
+select _koi8r'a' COLLATE koi8r_bin LIKE _koi8r'A';
+_koi8r'a' COLLATE koi8r_bin LIKE _koi8r'A'
+0
+select _koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A' COLLATE koi8r_bin;
+ERROR HY000: Illegal mix of collations (koi8r_general_ci,EXPLICIT) and (koi8r_bin,EXPLICIT) for operation 'like'
+select _koi8r'a' LIKE _latin1'A';
+ERROR HY000: Illegal mix of collations (koi8r_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation 'like'
CREATE TABLE t1 ( faq_group_id int(11) NOT NULL default '0', faq_id int(11) NOT NULL default '0', title varchar(240) default NULL, keywords text, description longblob, solution longblob, status tinyint(4) NOT NULL default '0', access_id smallint(6) default NULL, lang_id smallint(6) NOT NULL default '0', created datetime NOT NULL default '0000-00-00 00:00:00', updated datetime default NULL, last_access datetime default NULL, last_notify datetime default NULL, solved_count int(11) NOT NULL default '0', static_solved int(11) default NULL, solved_1 int(11) default NULL, solved_2 int(11) default NULL, solved_3 int(11) default NULL, solved_4 int(11) default NULL, solved_5 int(11) default NULL, expires datetime default NULL, notes text, assigned_to smallint(6) default NULL, assigned_group smallint(6) default NULL, last_edited_by smallint(6) default NULL, orig_ref_no varchar(15) binary default NULL, c$fundstate smallint(6) default NULL, c$contributor smallint(6) default NULL, UNIQUE KEY t1$faq_id (faq_id), KEY t1$group_id$faq_id (faq_group_id,faq_id), KEY t1$c$fundstate (c$fundstate) ) TYPE=MyISAM;
INSERT INTO t1 VALUES (82,82,'How to use the DynaVox Usage Counts Feature','usages count, number, corner, white, box, button','<as-html>\r\n<table width=\"100%\" border=\"0\">\r\n <tr>\r\n <td width=\"3%\"> </td>\r\n <td width=\"97%\">\r\n <h3><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#000000\">How \r\n To</font><!-- #BeginEditable \"CS_troubleshoot_question\" --><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#000099\"><font color=\"#000000\">: \r\n Display or Hide the Usage Counts to find out how many times each button is being selected. </font></font><!-- #EndEditable --></h3>\r\n </td>\r\n </tr>\r\n</table>','<as-html>\r\n <table width=\"100%\" border=\"0\">\r\n <tr>\r\n <td width=\"3%\"> </td>\r\n \r\n<td width=\"97%\"><!-- #BeginEditable \"CS_troubleshoot_answer\" --> \r\n \r\n<p><font color=\"#000000\" face=\"Verdana, Arial, Helvetica, sans-serif\">1. Select \r\n the <i>On/Setup</i> button to access the DynaVox Setup Menu.<br>\r\n 2. Select <b>Button Features.</b><br>\r\n 3. Below the <b>OK</b> button is the <b>Usage Counts</b> button.<br>\r\n a. If it says \"Hidden\" then the Usage Counts will not be displayed.<br>\r\n b. If it says \"Displayed\" then the Usage Counts will be shown.<br>\r\n c. Select the <b>Usage Counts</b> Option Ring once and it will toggle \r\n to the alternative option.<br>\r\n 4. Once the correct setting has been chosen, select <b>OK</b> to leave the <i>Button \r\n Features</i> menu.<br>\r\n 5. Select <b>OK</b> out of the <i>Setup</i> menu and return to the communication \r\n page.</font></p>\r\n <p><font color=\"#000000\" face=\"Verdana, Arial, Helvetica, sans-serif\">For \r\n further information on <i>Usage Counts,</i> see the <i>Button Features \r\n Menu Entry</i> in the DynaVox/DynaMyte Reference Manual.</font></p>\r\n<!-- #EndEditable --></td>\r\n </tr>\r\n</table>',4,1,1,'2001-11-16 16:43:34','2002-11-25 12:09:43','2003-07-24 01:04:48',NULL,11,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,11,NULL,NULL,NULL);
CREATE TABLE t2 ( access_id smallint(6) NOT NULL default '0', name varchar(20) binary default NULL, rank smallint(6) NOT NULL default '0', KEY t2$access_id (access_id) ) TYPE=MyISAM;
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index 58a05a2336f..feaebc9b514 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -400,11 +400,111 @@ CREATE TABLE t3 (ctime1 char(19) NOT NULL, ctime2 char(19) NOT NULL);
INSERT INTO t3 VALUES ("2002-10-29 16:51:06","2002-11-05 16:47:31");
select * from t1, t2 where t1.start between t2.ctime1 and t2.ctime2;
start ctime1 ctime2
-2002-11-04 00:00:00 20021029165106 20021105164731
+2002-11-04 00:00:00 2002-10-29 16:51:06 2002-11-05 16:47:31
select * from t1, t2 where t1.start >= t2.ctime1 and t1.start <= t2.ctime2;
start ctime1 ctime2
-2002-11-04 00:00:00 20021029165106 20021105164731
+2002-11-04 00:00:00 2002-10-29 16:51:06 2002-11-05 16:47:31
select * from t1, t3 where t1.start between t3.ctime1 and t3.ctime2;
start ctime1 ctime2
2002-11-04 00:00:00 2002-10-29 16:51:06 2002-11-05 16:47:31
drop table t1,t2,t3;
+CREATE TABLE t1 (datetime datetime, timestamp timestamp, date date, time time);
+INSERT INTO t1 values ("2001-01-02 03:04:05", "2002-01-02 03:04:05", "2003-01-02", "06:07:08");
+SELECT * from t1;
+datetime timestamp date time
+2001-01-02 03:04:05 2002-01-02 03:04:05 2003-01-02 06:07:08
+select date_add("1997-12-31",INTERVAL 1 SECOND);
+date_add("1997-12-31",INTERVAL 1 SECOND)
+1997-12-31 00:00:01
+select date_add("1997-12-31",INTERVAL "1 1" YEAR_MONTH);
+date_add("1997-12-31",INTERVAL "1 1" YEAR_MONTH)
+1999-01-31
+select date_add(datetime, INTERVAL 1 SECOND) from t1;
+date_add(datetime, INTERVAL 1 SECOND)
+2001-01-02 03:04:06
+select date_add(datetime, INTERVAL 1 YEAR) from t1;
+date_add(datetime, INTERVAL 1 YEAR)
+2002-01-02 03:04:05
+select date_add(date,INTERVAL 1 SECOND) from t1;
+date_add(date,INTERVAL 1 SECOND)
+2003-01-02 00:00:01
+select date_add(date,INTERVAL 1 MINUTE) from t1;
+date_add(date,INTERVAL 1 MINUTE)
+2003-01-02 00:01:00
+select date_add(date,INTERVAL 1 HOUR) from t1;
+date_add(date,INTERVAL 1 HOUR)
+2003-01-02 01:00:00
+select date_add(date,INTERVAL 1 DAY) from t1;
+date_add(date,INTERVAL 1 DAY)
+2003-01-03
+select date_add(date,INTERVAL 1 MONTH) from t1;
+date_add(date,INTERVAL 1 MONTH)
+2003-02-02
+select date_add(date,INTERVAL 1 YEAR) from t1;
+date_add(date,INTERVAL 1 YEAR)
+2004-01-02
+select date_add(date,INTERVAL "1:1" MINUTE_SECOND) from t1;
+date_add(date,INTERVAL "1:1" MINUTE_SECOND)
+2003-01-02 00:01:01
+select date_add(date,INTERVAL "1:1" HOUR_MINUTE) from t1;
+date_add(date,INTERVAL "1:1" HOUR_MINUTE)
+2003-01-02 01:01:00
+select date_add(date,INTERVAL "1:1" DAY_HOUR) from t1;
+date_add(date,INTERVAL "1:1" DAY_HOUR)
+2003-01-03 01:00:00
+select date_add(date,INTERVAL "1 1" YEAR_MONTH) from t1;
+date_add(date,INTERVAL "1 1" YEAR_MONTH)
+2004-02-02
+select date_add(date,INTERVAL "1:1:1" HOUR_SECOND) from t1;
+date_add(date,INTERVAL "1:1:1" HOUR_SECOND)
+2003-01-02 01:01:01
+select date_add(date,INTERVAL "1 1:1" DAY_MINUTE) from t1;
+date_add(date,INTERVAL "1 1:1" DAY_MINUTE)
+2003-01-03 01:01:00
+select date_add(date,INTERVAL "1 1:1:1" DAY_SECOND) from t1;
+date_add(date,INTERVAL "1 1:1:1" DAY_SECOND)
+2003-01-03 01:01:01
+select date_add(time,INTERVAL 1 SECOND) from t1;
+date_add(time,INTERVAL 1 SECOND)
+2006-07-08 00:00:01
+drop table t1;
+select last_day('2000-02-05') as f1, last_day('2002-12-31') as f2,
+last_day('2003-03-32') as f3, last_day('2003-04-01') as f4,
+last_day('2001-01-01 01:01:01') as f5, last_day(NULL),
+last_day('2001-02-12');
+f1 f2 f3 f4 f5 last_day(NULL) last_day('2001-02-12')
+2000-02-29 2002-12-31 NULL 2003-04-30 2001-01-31 NULL 2001-02-28
+create table t1 select last_day('2000-02-05') as a;
+describe t1;
+Field Type Null Key Default Extra
+a date 0000-00-00
+select * from t1;
+a
+2000-02-29
+drop table t1;
+select last_day('2000-02-05');
+last_day('2000-02-05')
+2000-02-29
+select strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0;
+strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0
+1
+select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%T"), utc_time())=0;
+strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%T"), utc_time())=0
+1
+select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%Y-%m-%d"), utc_date())=0;
+strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%Y-%m-%d"), utc_date())=0
+1
+select strcmp(date_format(utc_timestamp(),"%T"), utc_time())=0;
+strcmp(date_format(utc_timestamp(),"%T"), utc_time())=0
+1
+select strcmp(date_format(utc_timestamp(),"%Y-%m-%d"), utc_date())=0;
+strcmp(date_format(utc_timestamp(),"%Y-%m-%d"), utc_date())=0
+1
+select strcmp(concat(utc_date(),' ',utc_time()),utc_timestamp())=0;
+strcmp(concat(utc_date(),' ',utc_time()),utc_timestamp())=0
+1
+explain extended select period_add("9602",-12),period_diff(199505,"9404"),from_days(to_days("960101")),dayofmonth("1997-01-02"), month("1997-01-02"), monthname("1972-03-04"),dayofyear("0000-00-00"),HOUR("1997-03-03 23:03:22"),MINUTE("23:03:22"),SECOND(230322),QUARTER(980303),WEEK("1998-03-03"),yearweek("2000-01-01",1),week(19950101,1),year("98-02-03"),weekday(curdate())-weekday(now()),dayname("1962-03-03"),unix_timestamp(),sec_to_time(time_to_sec("0:30:47")/6.21),curtime(),utc_time(),curdate(),utc_date(),utc_timestamp(),date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w"),from_unixtime(unix_timestamp("1994-03-02 10:11:12")),"1997-12-31 23:59:59" + INTERVAL 1 SECOND,"1998-01-01 00:00:00" - INTERVAL 1 SECOND,INTERVAL 1 DAY + "1997-12-31", extract(YEAR FROM "1999-01-02 10:11:12"),date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority no_cache period_add(_latin1'9602',-(12)) AS `period_add("9602",-12)`,period_diff(199505,_latin1'9404') AS `period_diff(199505,"9404")`,from_days(to_days(_latin1'960101')) AS `from_days(to_days("960101"))`,dayofmonth(_latin1'1997-01-02') AS `dayofmonth("1997-01-02")`,month(_latin1'1997-01-02') AS `month("1997-01-02")`,monthname(_latin1'1972-03-04') AS `monthname("1972-03-04")`,dayofyear(_latin1'0000-00-00') AS `dayofyear("0000-00-00")`,hour(_latin1'1997-03-03 23:03:22') AS `HOUR("1997-03-03 23:03:22")`,minute(_latin1'23:03:22') AS `MINUTE("23:03:22")`,second(230322) AS `SECOND(230322)`,quarter(980303) AS `QUARTER(980303)`,week(_latin1'1998-03-03',0) AS `WEEK("1998-03-03")`,yearweek(_latin1'2000-01-01',1) AS `yearweek("2000-01-01",1)`,week(19950101,1) AS `week(19950101,1)`,year(_latin1'98-02-03') AS `year("98-02-03")`,(weekday(to_days(curdate())) - weekday(to_days(now()))) AS `weekday(curdate())-weekday(now())`,dayname(to_days(_latin1'1962-03-03')) AS `dayname("1962-03-03")`,unix_timestamp() AS `unix_timestamp()`,sec_to_time((time_to_sec(_latin1'0:30:47') / 6.21)) AS `sec_to_time(time_to_sec("0:30:47")/6.21)`,curtime() AS `curtime()`,utc_time() AS `utc_time()`,curdate() AS `curdate()`,utc_date() AS `utc_date()`,utc_timestamp() AS `utc_timestamp()`,date_format(_latin1'1997-01-02 03:04:05',_latin1'%M %W %D %Y %y %m %d %h %i %s %w') AS `date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w")`,from_unixtime(unix_timestamp(_latin1'1994-03-02 10:11:12')) AS `from_unixtime(unix_timestamp("1994-03-02 10:11:12"))`,(_latin1'1997-12-31 23:59:59' + interval 1 second) AS `"1997-12-31 23:59:59" + INTERVAL 1 SECOND`,(_latin1'1998-01-01 00:00:00' - interval 1 second) AS `"1998-01-01 00:00:00" - INTERVAL 1 SECOND`,(_latin1'1997-12-31' + interval 1 day) AS `INTERVAL 1 DAY + "1997-12-31"`,extract(year from _latin1'1999-01-02 10:11:12') AS `extract(YEAR FROM "1999-01-02 10:11:12")`,(_latin1'1997-12-31 23:59:59' + interval 1 second) AS `date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND)`
diff --git a/mysql-test/r/gcc296.result b/mysql-test/r/gcc296.result
index 8f78f70cc1f..628bbbf3f93 100644
--- a/mysql-test/r/gcc296.result
+++ b/mysql-test/r/gcc296.result
@@ -1,5 +1,5 @@
-drop table if exists obory;
-CREATE TABLE obory (
+drop table if exists t1;
+CREATE TABLE t1 (
kodoboru varchar(10) default NULL,
obor tinytext,
aobor tinytext,
@@ -7,14 +7,14 @@ UNIQUE INDEX kodoboru (kodoboru),
FULLTEXT KEY obor (obor),
FULLTEXT KEY aobor (aobor)
);
-INSERT INTO obory VALUES ('0101000000','aaa','AAA');
-INSERT INTO obory VALUES ('0102000000','bbb','BBB');
-INSERT INTO obory VALUES ('0103000000','ccc','CCC');
-INSERT INTO obory VALUES ('0104000000','xxx','XXX');
-select * from obory;
+INSERT INTO t1 VALUES ('0101000000','aaa','AAA');
+INSERT INTO t1 VALUES ('0102000000','bbb','BBB');
+INSERT INTO t1 VALUES ('0103000000','ccc','CCC');
+INSERT INTO t1 VALUES ('0104000000','xxx','XXX');
+select * from t1;
kodoboru obor aobor
0101000000 aaa AAA
0102000000 bbb BBB
0103000000 ccc CCC
0104000000 xxx XXX
-drop table obory;
+drop table t1;
diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result
new file mode 100644
index 00000000000..ca54ec59938
--- /dev/null
+++ b/mysql-test/r/gis-rtree.result
@@ -0,0 +1,712 @@
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (
+fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+g GEOMETRY NOT NULL,
+SPATIAL KEY(g)
+) TYPE=MyISAM;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `fid` int(11) NOT NULL auto_increment,
+ `g` geometry NOT NULL default '',
+ PRIMARY KEY (`fid`),
+ SPATIAL KEY `g` (`g`(32))
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(150 150, 150 150)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(149 149, 151 151)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(148 148, 152 152)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(147 147, 153 153)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(146 146, 154 154)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(145 145, 155 155)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(144 144, 156 156)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(143 143, 157 157)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(142 142, 158 158)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(141 141, 159 159)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(140 140, 160 160)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(139 139, 161 161)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(138 138, 162 162)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(137 137, 163 163)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(136 136, 164 164)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(135 135, 165 165)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(134 134, 166 166)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(133 133, 167 167)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(132 132, 168 168)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(131 131, 169 169)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(130 130, 170 170)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(129 129, 171 171)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(128 128, 172 172)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(127 127, 173 173)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(126 126, 174 174)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(125 125, 175 175)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(124 124, 176 176)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(123 123, 177 177)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(122 122, 178 178)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(121 121, 179 179)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(120 120, 180 180)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(119 119, 181 181)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(118 118, 182 182)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(117 117, 183 183)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(116 116, 184 184)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(115 115, 185 185)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(114 114, 186 186)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(113 113, 187 187)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(112 112, 188 188)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(111 111, 189 189)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(110 110, 190 190)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(109 109, 191 191)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(108 108, 192 192)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(107 107, 193 193)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(106 106, 194 194)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(105 105, 195 195)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(104 104, 196 196)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(103 103, 197 197)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(102 102, 198 198)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(101 101, 199 199)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(100 100, 200 200)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(99 99, 201 201)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(98 98, 202 202)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(97 97, 203 203)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(96 96, 204 204)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(95 95, 205 205)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(94 94, 206 206)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(93 93, 207 207)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(92 92, 208 208)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(91 91, 209 209)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(90 90, 210 210)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(89 89, 211 211)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(88 88, 212 212)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(87 87, 213 213)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(86 86, 214 214)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(85 85, 215 215)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(84 84, 216 216)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(83 83, 217 217)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(82 82, 218 218)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(81 81, 219 219)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(80 80, 220 220)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(79 79, 221 221)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(78 78, 222 222)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(77 77, 223 223)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(76 76, 224 224)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(75 75, 225 225)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(74 74, 226 226)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(73 73, 227 227)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(72 72, 228 228)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(71 71, 229 229)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(70 70, 230 230)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(69 69, 231 231)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(68 68, 232 232)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(67 67, 233 233)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(66 66, 234 234)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(65 65, 235 235)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(64 64, 236 236)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(63 63, 237 237)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(62 62, 238 238)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(61 61, 239 239)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(60 60, 240 240)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(59 59, 241 241)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(58 58, 242 242)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(57 57, 243 243)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(56 56, 244 244)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(55 55, 245 245)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(54 54, 246 246)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(53 53, 247 247)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(52 52, 248 248)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(51 51, 249 249)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(50 50, 250 250)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(49 49, 251 251)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(48 48, 252 252)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(47 47, 253 253)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(46 46, 254 254)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(45 45, 255 255)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(44 44, 256 256)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(43 43, 257 257)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(42 42, 258 258)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(41 41, 259 259)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(40 40, 260 260)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(39 39, 261 261)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(38 38, 262 262)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(37 37, 263 263)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(36 36, 264 264)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(35 35, 265 265)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(34 34, 266 266)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(33 33, 267 267)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(32 32, 268 268)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(31 31, 269 269)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(30 30, 270 270)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(29 29, 271 271)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(28 28, 272 272)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(27 27, 273 273)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(26 26, 274 274)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(25 25, 275 275)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(24 24, 276 276)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(23 23, 277 277)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(22 22, 278 278)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(21 21, 279 279)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(20 20, 280 280)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(19 19, 281 281)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(18 18, 282 282)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(17 17, 283 283)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(16 16, 284 284)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(15 15, 285 285)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(14 14, 286 286)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(13 13, 287 287)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(12 12, 288 288)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(11 11, 289 289)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(10 10, 290 290)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(9 9, 291 291)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(8 8, 292 292)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(7 7, 293 293)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(6 6, 294 294)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(5 5, 295 295)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(4 4, 296 296)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(3 3, 297 297)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(2 2, 298 298)'));
+INSERT INTO t1 (g) VALUES (GeomFromText('LineString(1 1, 299 299)'));
+SELECT count(*) FROM t1;
+count(*)
+150
+EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range g g 32 NULL 4 Using where
+SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
+fid AsText(g)
+1 LINESTRING(150 150,150 150)
+11 LINESTRING(140 140,160 160)
+2 LINESTRING(149 149,151 151)
+3 LINESTRING(148 148,152 152)
+4 LINESTRING(147 147,153 153)
+5 LINESTRING(146 146,154 154)
+6 LINESTRING(145 145,155 155)
+7 LINESTRING(144 144,156 156)
+8 LINESTRING(143 143,157 157)
+9 LINESTRING(142 142,158 158)
+10 LINESTRING(141 141,159 159)
+DROP TABLE t1;
+CREATE TABLE t2 (
+fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+g GEOMETRY NOT NULL
+) TYPE=MyISAM;
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10))));
+INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10))));
+ALTER TABLE t2 ADD SPATIAL KEY(g);
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `fid` int(11) NOT NULL auto_increment,
+ `g` geometry NOT NULL default '',
+ PRIMARY KEY (`fid`),
+ SPATIAL KEY `g` (`g`(32))
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+SELECT count(*) FROM t2;
+count(*)
+100
+EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g,
+GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range g g 32 NULL 4 Using where
+SELECT fid, AsText(g) FROM t2 WHERE Within(g,
+GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
+fid AsText(g)
+45 LINESTRING(51 51,60 60)
+55 LINESTRING(41 51,50 60)
+56 LINESTRING(41 41,50 50)
+46 LINESTRING(51 41,60 50)
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 10 * 10 - 9), Point(10 * 10, 10 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+99
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 9 * 10 - 9), Point(10 * 10, 9 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+98
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 8 * 10 - 9), Point(10 * 10, 8 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+97
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 7 * 10 - 9), Point(10 * 10, 7 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+96
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 6 * 10 - 9), Point(10 * 10, 6 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+95
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 5 * 10 - 9), Point(10 * 10, 5 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+94
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 4 * 10 - 9), Point(10 * 10, 4 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+93
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 3 * 10 - 9), Point(10 * 10, 3 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+92
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 2 * 10 - 9), Point(10 * 10, 2 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+91
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(10 * 10 - 9, 1 * 10 - 9), Point(10 * 10, 1 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+90
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 10 * 10 - 9), Point(9 * 10, 10 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+89
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 9 * 10 - 9), Point(9 * 10, 9 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+88
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 8 * 10 - 9), Point(9 * 10, 8 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+87
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 7 * 10 - 9), Point(9 * 10, 7 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+86
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 6 * 10 - 9), Point(9 * 10, 6 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+85
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 5 * 10 - 9), Point(9 * 10, 5 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+84
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 4 * 10 - 9), Point(9 * 10, 4 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+83
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 3 * 10 - 9), Point(9 * 10, 3 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+82
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 2 * 10 - 9), Point(9 * 10, 2 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+81
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(9 * 10 - 9, 1 * 10 - 9), Point(9 * 10, 1 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+80
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 10 * 10 - 9), Point(8 * 10, 10 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+79
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 9 * 10 - 9), Point(8 * 10, 9 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+78
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 8 * 10 - 9), Point(8 * 10, 8 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+77
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 7 * 10 - 9), Point(8 * 10, 7 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+76
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 6 * 10 - 9), Point(8 * 10, 6 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+75
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 5 * 10 - 9), Point(8 * 10, 5 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+74
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 4 * 10 - 9), Point(8 * 10, 4 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+73
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 3 * 10 - 9), Point(8 * 10, 3 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+72
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 2 * 10 - 9), Point(8 * 10, 2 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+71
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(8 * 10 - 9, 1 * 10 - 9), Point(8 * 10, 1 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+70
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 10 * 10 - 9), Point(7 * 10, 10 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+69
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 9 * 10 - 9), Point(7 * 10, 9 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+68
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 8 * 10 - 9), Point(7 * 10, 8 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+67
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 7 * 10 - 9), Point(7 * 10, 7 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+66
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 6 * 10 - 9), Point(7 * 10, 6 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+65
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 5 * 10 - 9), Point(7 * 10, 5 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+64
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 4 * 10 - 9), Point(7 * 10, 4 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+63
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 3 * 10 - 9), Point(7 * 10, 3 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+62
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 2 * 10 - 9), Point(7 * 10, 2 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+61
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(7 * 10 - 9, 1 * 10 - 9), Point(7 * 10, 1 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+60
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 10 * 10 - 9), Point(6 * 10, 10 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+59
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 9 * 10 - 9), Point(6 * 10, 9 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+58
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 8 * 10 - 9), Point(6 * 10, 8 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+57
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 7 * 10 - 9), Point(6 * 10, 7 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+56
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 6 * 10 - 9), Point(6 * 10, 6 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+55
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 5 * 10 - 9), Point(6 * 10, 5 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+54
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 4 * 10 - 9), Point(6 * 10, 4 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+53
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 3 * 10 - 9), Point(6 * 10, 3 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+52
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 2 * 10 - 9), Point(6 * 10, 2 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+51
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(6 * 10 - 9, 1 * 10 - 9), Point(6 * 10, 1 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+50
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 10 * 10 - 9), Point(5 * 10, 10 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+49
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 9 * 10 - 9), Point(5 * 10, 9 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+48
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 8 * 10 - 9), Point(5 * 10, 8 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+47
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 7 * 10 - 9), Point(5 * 10, 7 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+46
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 6 * 10 - 9), Point(5 * 10, 6 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+45
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 5 * 10 - 9), Point(5 * 10, 5 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+44
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 4 * 10 - 9), Point(5 * 10, 4 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+43
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 3 * 10 - 9), Point(5 * 10, 3 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+42
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 2 * 10 - 9), Point(5 * 10, 2 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+41
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(5 * 10 - 9, 1 * 10 - 9), Point(5 * 10, 1 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+40
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 10 * 10 - 9), Point(4 * 10, 10 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+39
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 9 * 10 - 9), Point(4 * 10, 9 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+38
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 8 * 10 - 9), Point(4 * 10, 8 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+37
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 7 * 10 - 9), Point(4 * 10, 7 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+36
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 6 * 10 - 9), Point(4 * 10, 6 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+35
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 5 * 10 - 9), Point(4 * 10, 5 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+34
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 4 * 10 - 9), Point(4 * 10, 4 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+33
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 3 * 10 - 9), Point(4 * 10, 3 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+32
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 2 * 10 - 9), Point(4 * 10, 2 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+31
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(4 * 10 - 9, 1 * 10 - 9), Point(4 * 10, 1 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+30
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 10 * 10 - 9), Point(3 * 10, 10 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+29
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 9 * 10 - 9), Point(3 * 10, 9 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+28
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 8 * 10 - 9), Point(3 * 10, 8 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+27
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 7 * 10 - 9), Point(3 * 10, 7 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+26
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 6 * 10 - 9), Point(3 * 10, 6 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+25
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 5 * 10 - 9), Point(3 * 10, 5 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+24
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 4 * 10 - 9), Point(3 * 10, 4 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+23
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 3 * 10 - 9), Point(3 * 10, 3 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+22
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 2 * 10 - 9), Point(3 * 10, 2 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+21
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(3 * 10 - 9, 1 * 10 - 9), Point(3 * 10, 1 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+20
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 10 * 10 - 9), Point(2 * 10, 10 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+19
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 9 * 10 - 9), Point(2 * 10, 9 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+18
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 8 * 10 - 9), Point(2 * 10, 8 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+17
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 7 * 10 - 9), Point(2 * 10, 7 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+16
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 6 * 10 - 9), Point(2 * 10, 6 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+15
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 5 * 10 - 9), Point(2 * 10, 5 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+14
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 4 * 10 - 9), Point(2 * 10, 4 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+13
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 3 * 10 - 9), Point(2 * 10, 3 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+12
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 2 * 10 - 9), Point(2 * 10, 2 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+11
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(2 * 10 - 9, 1 * 10 - 9), Point(2 * 10, 1 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+10
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 10 * 10 - 9), Point(1 * 10, 10 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+9
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 9 * 10 - 9), Point(1 * 10, 9 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+8
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 8 * 10 - 9), Point(1 * 10, 8 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+7
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 7 * 10 - 9), Point(1 * 10, 7 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+6
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 6 * 10 - 9), Point(1 * 10, 6 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+5
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 5 * 10 - 9), Point(1 * 10, 5 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+4
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 4 * 10 - 9), Point(1 * 10, 4 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+3
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 3 * 10 - 9), Point(1 * 10, 3 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+2
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 2 * 10 - 9), Point(1 * 10, 2 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+1
+DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point(1 * 10 - 9, 1 * 10 - 9), Point(1 * 10, 1 * 10)))));
+SELECT count(*) FROM t2;
+count(*)
+0
+DROP TABLE t2;
diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result
new file mode 100644
index 00000000000..7ee16d54724
--- /dev/null
+++ b/mysql-test/r/gis.result
@@ -0,0 +1,456 @@
+DROP TABLE IF EXISTS pt, ls, p, mpt, mls, mp, gc, geo;
+CREATE TABLE pt (fid INTEGER NOT NULL PRIMARY KEY, g POINT);
+CREATE TABLE ls (fid INTEGER NOT NULL PRIMARY KEY, g LINESTRING);
+CREATE TABLE p (fid INTEGER NOT NULL PRIMARY KEY, g POLYGON);
+CREATE TABLE mpt (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOINT);
+CREATE TABLE mls (fid INTEGER NOT NULL PRIMARY KEY, g MULTILINESTRING);
+CREATE TABLE mp (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOLYGON);
+CREATE TABLE gc (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRYCOLLECTION);
+CREATE TABLE geo (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY);
+SHOW FIELDS FROM pt;
+Field Type Null Key Default Extra
+fid int(11) PRI 0
+g point YES NULL
+SHOW FIELDS FROM ls;
+Field Type Null Key Default Extra
+fid int(11) PRI 0
+g linestring YES NULL
+SHOW FIELDS FROM p;
+Field Type Null Key Default Extra
+fid int(11) PRI 0
+g polygon YES NULL
+SHOW FIELDS FROM mpt;
+Field Type Null Key Default Extra
+fid int(11) PRI 0
+g multipoint YES NULL
+SHOW FIELDS FROM mls;
+Field Type Null Key Default Extra
+fid int(11) PRI 0
+g multilinestring YES NULL
+SHOW FIELDS FROM mp;
+Field Type Null Key Default Extra
+fid int(11) PRI 0
+g multipolygon YES NULL
+SHOW FIELDS FROM gc;
+Field Type Null Key Default Extra
+fid int(11) PRI 0
+g geometrycollection YES NULL
+SHOW FIELDS FROM geo;
+Field Type Null Key Default Extra
+fid int(11) PRI 0
+g geometry YES NULL
+INSERT INTO pt 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 ls 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(LineString(Point(10, 10), Point(40, 10))));
+INSERT INTO p 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(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))));
+INSERT INTO mpt 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(MultiPoint(Point(3, 6), Point(4, 10))));
+INSERT INTO mls 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(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7)))));
+INSERT INTO mp 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(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))));
+INSERT INTO gc VALUES
+(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
+(121, GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))));
+INSERT into geo SELECT * FROM pt;
+INSERT into geo SELECT * FROM ls;
+INSERT into geo SELECT * FROM p;
+INSERT into geo SELECT * FROM mpt;
+INSERT into geo SELECT * FROM mls;
+INSERT into geo SELECT * FROM mp;
+INSERT into geo SELECT * FROM gc;
+SELECT fid, AsText(g) FROM pt;
+fid AsText(g)
+101 POINT(10 10)
+102 POINT(20 10)
+103 POINT(20 20)
+104 POINT(10 20)
+SELECT fid, AsText(g) FROM ls;
+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 p;
+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 mpt;
+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 mls;
+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 mp;
+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 gc;
+fid AsText(g)
+120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
+121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
+SELECT fid, AsText(g) FROM geo;
+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))
+SELECT fid, Dimension(g) FROM geo;
+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
+SELECT fid, GeometryType(g) FROM geo;
+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
+SELECT fid, IsEmpty(g) FROM geo;
+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
+SELECT fid, AsText(Envelope(g)) FROM geo;
+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))
+explain extended select Dimension(g), GeometryType(g), IsEmpty(g), AsText(Envelope(g)) from geo;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE geo ALL NULL NULL NULL NULL 21
+Warnings:
+Note 1003 select high_priority dimension(test.geo.g) AS `Dimension(g)`,geometrytype(test.geo.g) AS `GeometryType(g)`,isempty(test.geo.g) AS `IsEmpty(g)`,astext(envelope(test.geo.g)) AS `AsText(Envelope(g))` from test.geo
+SELECT fid, X(g) FROM pt;
+fid X(g)
+101 10
+102 20
+103 20
+104 10
+SELECT fid, Y(g) FROM pt;
+fid Y(g)
+101 10
+102 10
+103 20
+104 20
+explain extended select X(g),Y(g) FROM pt;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE pt ALL NULL NULL NULL NULL 4
+Warnings:
+Note 1003 select high_priority x(test.pt.g) AS `X(g)`,y(test.pt.g) AS `Y(g)` from test.pt
+SELECT fid, AsText(StartPoint(g)) FROM ls;
+fid AsText(StartPoint(g))
+105 POINT(0 0)
+106 POINT(10 10)
+107 POINT(10 10)
+SELECT fid, AsText(EndPoint(g)) FROM ls;
+fid AsText(EndPoint(g))
+105 POINT(10 0)
+106 POINT(10 10)
+107 POINT(40 10)
+SELECT fid, GLength(g) FROM ls;
+fid GLength(g)
+105 24.142135623731
+106 40
+107 30
+SELECT fid, NumPoints(g) FROM ls;
+fid NumPoints(g)
+105 3
+106 5
+107 2
+SELECT fid, AsText(PointN(g, 2)) FROM ls;
+fid AsText(PointN(g, 2))
+105 POINT(0 10)
+106 POINT(20 10)
+107 POINT(40 10)
+SELECT fid, IsClosed(g) FROM ls;
+fid IsClosed(g)
+105 0
+106 1
+107 0
+explain extended select AsText(StartPoint(g)),AsText(EndPoint(g)),GLength(g),NumPoints(g),AsText(PointN(g, 2)),IsClosed(g) FROM ls;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE ls ALL NULL NULL NULL NULL 3
+Warnings:
+Note 1003 select high_priority astext(startpoint(test.ls.g)) AS `AsText(StartPoint(g))`,astext(endpoint(test.ls.g)) AS `AsText(EndPoint(g))`,glength(test.ls.g) AS `GLength(g)`,numpoints(test.ls.g) AS `NumPoints(g)`,astext(pointn(test.ls.g,2)) AS `AsText(PointN(g, 2))`,isclosed(test.ls.g) AS `IsClosed(g)` from test.ls
+SELECT fid, AsText(Centroid(g)) FROM p;
+fid AsText(Centroid(g))
+108 POINT(15 15)
+109 POINT(25.416666666667 25.416666666667)
+110 POINT(20 10)
+SELECT fid, Area(g) FROM p;
+fid Area(g)
+108 100
+109 2400
+110 450
+SELECT fid, AsText(ExteriorRing(g)) FROM p;
+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 p;
+fid NumInteriorRings(g)
+108 0
+109 1
+110 0
+SELECT fid, AsText(InteriorRingN(g, 1)) FROM p;
+fid AsText(InteriorRingN(g, 1))
+108 NULL
+109 LINESTRING(10 10,20 10,20 20,10 20,10 10)
+110 NULL
+explain extended select AsText(Centroid(g)),Area(g),AsText(ExteriorRing(g)),NumInteriorRings(g),AsText(InteriorRingN(g, 1)) FROM p;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE p ALL NULL NULL NULL NULL 3
+Warnings:
+Note 1003 select high_priority astext(centroid(test.p.g)) AS `AsText(Centroid(g))`,area(test.p.g) AS `Area(g)`,astext(exteriorring(test.p.g)) AS `AsText(ExteriorRing(g))`,numinteriorrings(test.p.g) AS `NumInteriorRings(g)`,astext(interiorringn(test.p.g,1)) AS `AsText(InteriorRingN(g, 1))` from test.p
+SELECT fid, IsClosed(g) FROM mls;
+fid IsClosed(g)
+114 0
+115 0
+116 0
+SELECT fid, AsText(Centroid(g)) FROM mp;
+fid AsText(Centroid(g))
+117 POINT(55.588527753042 17.426536064114)
+118 POINT(55.588527753042 17.426536064114)
+119 POINT(2 2)
+SELECT fid, Area(g) FROM mp;
+fid Area(g)
+117 1684.5
+118 1684.5
+119 4.5
+SELECT fid, NumGeometries(g) from mpt;
+fid NumGeometries(g)
+111 4
+112 4
+113 2
+SELECT fid, NumGeometries(g) from mls;
+fid NumGeometries(g)
+114 2
+115 1
+116 2
+SELECT fid, NumGeometries(g) from mp;
+fid NumGeometries(g)
+117 2
+118 2
+119 1
+SELECT fid, NumGeometries(g) from gc;
+fid NumGeometries(g)
+120 2
+121 2
+explain extended SELECT fid, NumGeometries(g) from mpt;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE mpt ALL NULL NULL NULL NULL 3
+Warnings:
+Note 1003 select high_priority test.mpt.fid AS `fid`,numgeometries(test.mpt.g) AS `NumGeometries(g)` from test.mpt
+SELECT fid, AsText(GeometryN(g, 2)) from mpt;
+fid AsText(GeometryN(g, 2))
+111 POINT(10 10)
+112 POINT(11 11)
+113 POINT(4 10)
+SELECT fid, AsText(GeometryN(g, 2)) from mls;
+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 mp;
+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 gc;
+fid AsText(GeometryN(g, 2))
+120 LINESTRING(0 0,10 10)
+121 LINESTRING(3 6,7 9)
+explain extended SELECT fid, AsText(GeometryN(g, 2)) from mpt;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE mpt ALL NULL NULL NULL NULL 3
+Warnings:
+Note 1003 select high_priority test.mpt.fid AS `fid`,astext(geometryn(test.mpt.g,2)) AS `AsText(GeometryN(g, 2))` from test.mpt
+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 gc g1, gc 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 0 0 0 0 1 0
+121 120 0 0 1 0 0 0 1 0
+121 121 1 1 0 1 0 0 1 0
+explain extended 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 gc g1, gc g2 ORDER BY first, second;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE g1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
+1 SIMPLE g2 ALL NULL NULL NULL NULL 2
+Warnings:
+Note 1003 select high_priority test.g1.fid AS `first`,test.g2.fid AS `second`,within(test.g1.g,test.g2.g) AS `w`,contains(test.g1.g,test.g2.g) AS `c`,overlaps(test.g1.g,test.g2.g) AS `o`,equals(test.g1.g,test.g2.g) AS `e`,disjoint(test.g1.g,test.g2.g) AS `d`,touches(test.g1.g,test.g2.g) AS `t`,intersects(test.g1.g,test.g2.g) AS `i`,crosses(test.g1.g,test.g2.g) AS `r` from test.gc g1 join test.gc g2 order by test.g1.fid,test.g2.fid
+DROP TABLE pt, ls, p, mpt, mls, mp, gc, geo;
+CREATE TABLE g1 (
+pt point,
+ln linestring,
+pg polygon,
+mpt multipoint,
+mln multilinestring,
+mpg multipolygon,
+gc geometrycollection,
+gm geometry
+);
+SHOW FIELDS FROM g1;
+Field Type Null Key Default Extra
+pt point YES NULL
+ln linestring YES NULL
+pg polygon YES NULL
+mpt multipoint YES NULL
+mln multilinestring YES NULL
+mpg multipolygon YES NULL
+gc geometrycollection YES NULL
+gm geometry YES NULL
+ALTER TABLE g1 ADD fid INT NOT NULL;
+SHOW FIELDS FROM g1;
+Field Type Null Key Default Extra
+pt point YES NULL
+ln linestring YES NULL
+pg polygon YES NULL
+mpt multipoint YES NULL
+mln multilinestring YES NULL
+mpg multipolygon YES NULL
+gc geometrycollection YES NULL
+gm geometry YES NULL
+fid int(11) 0
+DROP TABLE g1;
+SELECT AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)'))));
+AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)'))))
+POINT(1 4)
+explain extended SELECT AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)'))));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority astext(geometryfromwkb(aswkb(geometryfromtext(_latin1'POINT(1 4)')))) AS `AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)'))))`
+explain extended SELECT AsText(GeometryFromWKB(AsWKB(PointFromText('POINT(1 4)'))));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority astext(geometryfromwkb(aswkb(geometryfromtext(_latin1'POINT(1 4)')))) AS `AsText(GeometryFromWKB(AsWKB(PointFromText('POINT(1 4)'))))`
+SELECT SRID(GeomFromText('LineString(1 1,2 2)',101));
+SRID(GeomFromText('LineString(1 1,2 2)',101))
+101
+explain extended SELECT SRID(GeomFromText('LineString(1 1,2 2)',101));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority srid(geometryfromtext(_latin1'LineString(1 1,2 2)',101)) AS `SRID(GeomFromText('LineString(1 1,2 2)',101))`
+explain extended select issimple(MultiPoint(Point(3, 6), Point(4, 10))), issimple(Point(3, 6));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority issimple(multipoint(point(3,6),point(4,10))) AS `issimple(MultiPoint(Point(3, 6), Point(4, 10)))`,issimple(point(3,6)) AS `issimple(Point(3, 6))`
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result
index 1a968fa4f2f..89426edb000 100644
--- a/mysql-test/r/grant.result
+++ b/mysql-test/r/grant.result
@@ -127,7 +127,41 @@ delete from mysql.columns_priv where user='mysqltest_1' or user="mysqltest_2" or
flush privileges;
drop table t1;
GRANT FILE on mysqltest.* to mysqltest_1@localhost;
-Wrong usage of DB GRANT and GLOBAL PRIVILEGES
+ERROR HY000: Wrong usage of DB GRANT and GLOBAL PRIVILEGES
select 1;
1
1
+create table t1 (a int);
+grant ALL PRIVILEGES on *.* to drop_user2@localhost with GRANT OPTION;
+show grants for drop_user2@localhost;
+Grants for drop_user2@localhost
+GRANT ALL PRIVILEGES ON *.* TO 'drop_user2'@'localhost' WITH GRANT OPTION
+revoke all privileges, grant from drop_user2@localhost;
+drop user drop_user2@localhost;
+grant ALL PRIVILEGES on *.* to drop_user@localhost with GRANT OPTION;
+grant ALL PRIVILEGES on test.* to drop_user@localhost with GRANT OPTION;
+grant select(a) on test.t1 to drop_user@localhost;
+show grants for drop_user@localhost;
+Grants for drop_user@localhost
+GRANT ALL PRIVILEGES ON *.* TO 'drop_user'@'localhost' WITH GRANT OPTION
+GRANT ALL PRIVILEGES ON `test`.* TO 'drop_user'@'localhost' WITH GRANT OPTION
+GRANT SELECT (a) ON `test`.`t1` TO 'drop_user'@'localhost'
+revoke all privileges, grant from drop_user@localhost;
+show grants for drop_user@localhost;
+Grants for drop_user@localhost
+GRANT USAGE ON *.* TO 'drop_user'@'localhost'
+drop user drop_user@localhost;
+revoke all privileges, grant from drop_user@localhost;
+ERROR HY000: Can't revoke all privileges, grant for one or more of the requested users
+grant select(a) on test.t1 to drop_user1@localhost;
+grant select on test.t1 to drop_user2@localhost;
+grant select on test.* to drop_user3@localhost;
+grant select on *.* to drop_user4@localhost;
+drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
+drop_user4@localhost;
+ERROR HY000: Can't drop one or more of the requested users
+revoke all privileges, grant from drop_user1@localhost, drop_user2@localhost,
+drop_user3@localhost, drop_user4@localhost;
+drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
+drop_user4@localhost;
+drop table t1;
diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result
new file mode 100644
index 00000000000..0b127188586
--- /dev/null
+++ b/mysql-test/r/grant2.result
@@ -0,0 +1,23 @@
+delete from mysql.user where user like 'mysqltest\_%';
+delete from mysql.db where user like 'mysqltest\_%';
+flush privileges;
+grant all privileges on `my\_%`.* to mysqltest_1@localhost with grant option;
+select current_user();
+current_user()
+mysqltest_1@localhost
+grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
+grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
+ERROR 42000: Access denied for user: 'mysqltest_1'@'localhost' to database 'my_%'
+show grants for mysqltest_1@localhost;
+Grants for mysqltest_1@localhost
+GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
+GRANT ALL PRIVILEGES ON `my\_%`.* TO 'mysqltest_1'@'localhost' WITH GRANT OPTION
+show grants for mysqltest_2@localhost;
+Grants for mysqltest_2@localhost
+GRANT USAGE ON *.* TO 'mysqltest_2'@'localhost'
+GRANT ALL PRIVILEGES ON `my\_1`.* TO 'mysqltest_2'@'localhost' WITH GRANT OPTION
+show grants for mysqltest_3@localhost;
+ERROR 42000: There is no such grant defined for user 'mysqltest_3' on host 'localhost'
+delete from mysql.user where user like 'mysqltest\_%';
+delete from mysql.db where user like 'mysqltest\_%';
+flush privileges;
diff --git a/mysql-test/r/grant_cache.result b/mysql-test/r/grant_cache.result
index fca6864cc63..f49db67a9f7 100644
--- a/mysql-test/r/grant_cache.result
+++ b/mysql-test/r/grant_cache.result
@@ -85,7 +85,7 @@ a b c a
1 1 1 test.t1
2 2 2 test.t1
select * from t2;
-select command denied to user: 'mysqltest_2@localhost' for table 't2'
+ERROR 42000: select command denied to user: 'mysqltest_2'@'localhost' for table 't2'
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 6
@@ -99,17 +99,17 @@ select "user3";
user3
user3
select * from t1;
-select command denied to user: 'mysqltest_3@localhost' for column 'b' in table 't1'
+ERROR 42000: select command denied to user: 'mysqltest_3'@'localhost' for column 'b' in table 't1'
select a from t1;
a
1
2
select c from t1;
-SELECT command denied to user: 'mysqltest_3@localhost' for column 'c' in table 't1'
+ERROR 42000: SELECT command denied to user: 'mysqltest_3'@'localhost' for column 'c' in table 't1'
select * from t2;
-select command denied to user: 'mysqltest_3@localhost' for table 't2'
+ERROR 42000: select command denied to user: 'mysqltest_3'@'localhost' for table 't2'
select mysqltest.t1.c from test.t1,mysqltest.t1;
-SELECT command denied to user: 'mysqltest_3@localhost' for column 'c' in table 't1'
+ERROR 42000: SELECT command denied to user: 'mysqltest_3'@'localhost' for column 'c' in table 't1'
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 6
@@ -123,7 +123,7 @@ select "user4";
user4
user4
select a from t1;
-No Database Selected
+ERROR 3D000: No Database Selected
select * from mysqltest.t1,test.t1;
a b c a
1 1 1 test.t1
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index f89cb8a6792..b9eaa81ba2a 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -1,4 +1,6 @@
drop table if exists t1,t2,t3;
+SELECT 1 FROM (SELECT 1) as a GROUP BY SUM(1);
+ERROR HY000: Invalid use of group function
CREATE TABLE t1 (
spID int(10) unsigned,
userID int(10) unsigned,
@@ -52,10 +54,10 @@ userid MIN(t1.score+0.0)
2 2.0
1 1.0
EXPLAIN SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 4 Using where; Using temporary
-t2 eq_ref PRIMARY PRIMARY 4 t1.userID 1 Using index
-drop table test.t1,test.t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where; Using temporary
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 4 test.t1.userID 1 Using index
+drop table t1,t2;
CREATE TABLE t1 (
PID int(10) unsigned NOT NULL auto_increment,
payDate date DEFAULT '0000-00-00' NOT NULL,
@@ -77,7 +79,7 @@ KEY payDate (payDate)
);
INSERT INTO t1 VALUES (1,'1970-01-01','1997-10-17 00:00:00',2529,1,21000,11886,'check',0,'F',16200,6);
SELECT COUNT(P.URID),SUM(P.amount),P.method, MIN(PP.recdate+0) > 19980501000000 AS IsNew FROM t1 AS P JOIN t1 as PP WHERE P.URID = PP.URID GROUP BY method,IsNew;
-Can't group on 'IsNew'
+ERROR 42000: Can't group on 'IsNew'
drop table t1;
CREATE TABLE t1 (
cid mediumint(9) NOT NULL auto_increment,
@@ -113,7 +115,7 @@ groupset bigint(20) DEFAULT '0' NOT NULL,
assigned_to mediumint(9) DEFAULT '0' NOT NULL,
bug_file_loc text,
bug_severity enum('blocker','critical','major','normal','minor','trivial','enhancement') DEFAULT 'blocker' NOT NULL,
-bug_status enum('NEW','ASSIGNED','REOPENED','RESOLVED','VERIFIED','CLOSED') DEFAULT 'NEW' NOT NULL,
+bug_status enum('','NEW','ASSIGNED','REOPENED','RESOLVED','VERIFIED','CLOSED') DEFAULT 'NEW' NOT NULL,
creation_ts datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
delta_ts timestamp(14),
short_desc mediumtext,
@@ -250,11 +252,11 @@ key (score)
);
INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3),(6,3,3),(7,3,3);
explain select userid,count(*) from t1 group by userid desc;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 8 Using temporary; Using filesort
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using temporary; Using filesort
explain select userid,count(*) from t1 group by userid desc order by null;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 8 Using temporary
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using temporary
select userid,count(*) from t1 group by userid desc;
userid count(*)
3 5
@@ -266,14 +268,14 @@ userid count(*)
select userid,count(*) from t1 group by userid desc having 3 IN (1,COUNT(*));
userid count(*)
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid desc;
-table type possible_keys key key_len ref rows Extra
-t1 range spID spID 5 NULL 3 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range spID spID 5 NULL 3 Using where; Using index
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid;
-table type possible_keys key key_len ref rows Extra
-t1 range spID spID 5 NULL 3 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range spID spID 5 NULL 3 Using where; Using index
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid order by null;
-table type possible_keys key key_len ref rows Extra
-t1 range spID spID 5 NULL 3 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range spID spID 5 NULL 3 Using where; Using index
select spid,count(*) from t1 where spid between 1 and 2 group by spid;
spid count(*)
1 1
@@ -282,12 +284,14 @@ select spid,count(*) from t1 where spid between 1 and 2 group by spid desc;
spid count(*)
2 2
1 1
-explain select sql_big_result spid,sum(userid) from t1 group by spid desc;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 8 Using filesort
+explain extended select sql_big_result spid,sum(userid) from t1 group by spid desc;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using filesort
+Warnings:
+Note 1003 select high_priority big_result test.t1.spID AS `spid`,sum(test.t1.userID) AS `sum(userid)` from test.t1 group by test.t1.spID desc
explain select sql_big_result spid,sum(userid) from t1 group by spid desc order by null;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 8
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 8
select sql_big_result spid,sum(userid) from t1 group by spid desc;
spid sum(userid)
7 3
@@ -298,11 +302,11 @@ spid sum(userid)
2 3
1 1
explain select sql_big_result score,count(*) from t1 group by score desc;
-table type possible_keys key key_len ref rows Extra
-t1 index NULL score 3 NULL 8 Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL score 3 NULL 8 Using index
explain select sql_big_result score,count(*) from t1 group by score desc order by null;
-table type possible_keys key key_len ref rows Extra
-t1 index NULL score 3 NULL 8 Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL score 3 NULL 8 Using index
select sql_big_result score,count(*) from t1 group by score desc;
score count(*)
3 5
@@ -422,7 +426,6 @@ CONCAT(a, b) count(*)
abcdef 1
hijklm 2
DROP TABLE t1;
-drop table if exists t1;
create table t1 (One int unsigned, Two int unsigned, Three int unsigned, Four int unsigned);
insert into t1 values (1,2,1,4),(1,2,2,4),(1,2,3,4),(1,2,4,4),(1,1,1,4),(1,1,2,4),(1,1,3,4),(1,1,4,4),(1,3,1,4),(1,3,2,4),(1,3,3,4),(1,3,4,4);
select One, Two, sum(Four) from t1 group by One,Two;
@@ -532,13 +535,13 @@ a b
2 2
1 1
explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
-t2 ALL a NULL NULL NULL 3 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
+1 SIMPLE t2 ALL a NULL NULL NULL 3 Using where
explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 6 Using temporary
-t2 ALL a NULL NULL NULL 3 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary
+1 SIMPLE t2 ALL a NULL NULL NULL 3 Using where
drop table t1,t2;
create table t1 (a int, b int);
insert into t1 values (1, 4),(10, 40),(1, 4),(10, 43),(1, 4),(10, 41),(1, 4),(10, 43),(1, 4);
diff --git a/mysql-test/r/handler.result b/mysql-test/r/handler.result
index 4af38807518..78ccf941b88 100644
--- a/mysql-test/r/handler.result
+++ b/mysql-test/r/handler.result
@@ -5,6 +5,8 @@ insert into t1 values
(14,"aaa"),(15,"bbb"),(16,"ccc"),(16,"xxx"),
(20,"ggg"),(21,"hhh"),(22,"iii");
handler t1 open as t2;
+handler t2 read a=(SELECT 1);
+ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT 1)' at line 1
handler t2 read a first;
a b
14 aaa
@@ -49,7 +51,7 @@ handler t2 read a=(16);
a b
16 ccc
handler t2 read a=(19,"fff");
-Too many key parts specified. Max 1 parts allowed
+ERROR 42000: Too many key parts specified. Max 1 parts allowed
handler t2 read b=(19,"fff");
a b
19 fff
@@ -60,7 +62,7 @@ handler t2 read b=(19);
a b
19 fff
handler t1 read a last;
-Unknown table 't1' in HANDLER
+ERROR 42S02: Unknown table 't1' in HANDLER
handler t2 read a=(11);
a b
handler t2 read a>=(11);
@@ -133,18 +135,18 @@ handler t2 read next;
a b
19 fff
handler t2 read last;
-You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
+ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
handler t2 close;
handler t1 open as t2;
drop table t1;
create table t1 (a int);
insert into t1 values (17);
handler t2 read first;
-Unknown table 't2' in HANDLER
+ERROR 42S02: Unknown table 't2' in HANDLER
handler t1 open as t2;
alter table t1 type=MyISAM;
handler t2 read first;
-Unknown table 't2' in HANDLER
+ERROR 42S02: Unknown table 't2' in HANDLER
drop table t1;
create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5),(6);
@@ -169,7 +171,7 @@ create table t1(a int, index(a));
insert into t1 values (1), (2), (3);
handler t1 open;
handler t1 read a=(W);
-Unknown column 'W' in 'field list'
+ERROR 42S22: Unknown column 'W' in 'field list'
handler t1 read a=(a);
-Wrong arguments to HANDLER ... READ
+ERROR HY000: Wrong arguments to HANDLER ... READ
drop table t1;
diff --git a/mysql-test/r/have_compress.require b/mysql-test/r/have_compress.require
new file mode 100644
index 00000000000..8bda2190fbe
--- /dev/null
+++ b/mysql-test/r/have_compress.require
@@ -0,0 +1,2 @@
+Variable_name Value
+have_compress YES
diff --git a/mysql-test/r/have_ucs2.require b/mysql-test/r/have_ucs2.require
new file mode 100644
index 00000000000..c53250aeaef
--- /dev/null
+++ b/mysql-test/r/have_ucs2.require
@@ -0,0 +1,2 @@
+Collation Charset Id Default Compiled Sortlen
+ucs2_general_ci ucs2 35 Yes Yes 1
diff --git a/mysql-test/r/have_ujis.require b/mysql-test/r/have_ujis.require
new file mode 100644
index 00000000000..43a309ad74e
--- /dev/null
+++ b/mysql-test/r/have_ujis.require
@@ -0,0 +1,2 @@
+Collation Charset Id Default Compiled Sortlen
+ujis_japanese_ci ujis 12 Yes Yes 1
diff --git a/mysql-test/r/having.result b/mysql-test/r/having.result
index d643070f7f9..7c88776579b 100644
--- a/mysql-test/r/having.result
+++ b/mysql-test/r/having.result
@@ -8,6 +8,11 @@ b
select count(a) as b from t1 where a=0 having b >=0;
b
0
+explain extended select count(a) as b from t1 where a=0 having b >=0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+Warnings:
+Note 1003 select high_priority count(test.t1.a) AS `b` from test.t1 where (test.t1.a = 0) having (count(test.t1.a) >= 0)
drop table t1;
CREATE TABLE t1 (
raw_id int(10) NOT NULL default '0',
@@ -62,6 +67,10 @@ select Fld1, max(Fld2) from t1 group by Fld1 having std(Fld2) is not null;
Fld1 max(Fld2)
1 20
3 50
+select Fld1, max(Fld2) from t1 group by Fld1 having variance(Fld2) is not null;
+Fld1 max(Fld2)
+1 20
+3 50
drop table t1;
create table t1 (id int not null, qty int not null);
insert into t1 values (1,2),(1,3),(2,4),(2,5);
diff --git a/mysql-test/r/heap.result b/mysql-test/r/heap.result
index bdf7dc225f3..6c5ef8f3441 100644
--- a/mysql-test/r/heap.result
+++ b/mysql-test/r/heap.result
@@ -65,10 +65,10 @@ a
869751
alter table t1 type=myisam;
explain select * from t1 where a in (869751,736494,226312,802616);
-table type possible_keys key key_len ref rows Extra
-t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index
drop table t1;
-create table t1 (x int not null, y int not null, key x(x), unique y(y))
+create table t1 (x int not null, y int not null, key x (x), unique y (y))
type=heap;
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
select * from t1 where x=1;
@@ -84,9 +84,9 @@ x y x y
2 5 2 2
2 6 2 2
explain select * from t1,t1 as t2 where t1.x=t2.y;
-table type possible_keys key key_len ref rows Extra
-t1 ALL x NULL NULL NULL 6
-t2 eq_ref y y 4 t1.x 1
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL x NULL NULL NULL 6
+1 SIMPLE t2 eq_ref y y 4 test.t1.x 1
drop table t1;
create table t1 (a int) type=heap;
insert into t1 values(1);
@@ -158,18 +158,18 @@ drop table t1;
create table t1 (btn char(10) not null, key(btn)) type=heap;
insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
explain select * from t1 where btn like "q%";
-table type possible_keys key key_len ref rows Extra
-t1 ALL btn NULL NULL NULL 14 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where
select * from t1 where btn like "q%";
btn
alter table t1 add column new_col char(1) not null, add key (btn,new_col), drop key btn;
-update t1 set new_col=btn;
+update t1 set new_col=left(btn,1);
explain select * from t1 where btn="a";
-table type possible_keys key key_len ref rows Extra
-t1 ALL btn NULL NULL NULL 11 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL btn NULL NULL NULL 11 Using where
explain select * from t1 where btn="a" and new_col="a";
-table type possible_keys key key_len ref rows Extra
-t1 ref btn btn 11 const,const 10 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref btn btn 11 const,const 10 Using where
drop table t1;
CREATE TABLE t1 (
a int default NULL,
@@ -181,21 +181,21 @@ INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
SELECT * FROM t1 WHERE a=NULL;
a b
explain SELECT * FROM t1 WHERE a IS NULL;
-table type possible_keys key key_len ref rows Extra
-t1 ref a a 5 const 10 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a a 5 const 10 Using where
SELECT * FROM t1 WHERE a<=>NULL;
a b
NULL 99
SELECT * FROM t1 WHERE b=NULL;
a b
explain SELECT * FROM t1 WHERE b IS NULL;
-table type possible_keys key key_len ref rows Extra
-t1 ref b b 5 const 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref b b 5 const 1 Using where
SELECT * FROM t1 WHERE b<=>NULL;
a b
99 NULL
INSERT INTO t1 VALUES (1,3);
-Duplicate entry '3' for key 1
+ERROR 23000: Duplicate entry '3' for key 1
DROP TABLE t1;
CREATE TABLE t1 (
a int default NULL,
@@ -203,8 +203,8 @@ key a (a)
) TYPE=HEAP;
INSERT INTO t1 VALUES (10), (10), (10);
EXPLAIN SELECT * FROM t1 WHERE a=10;
-table type possible_keys key key_len ref rows Extra
-t1 ref a a 5 const 10 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a a 5 const 10 Using where
SELECT * FROM t1 WHERE a=10;
a
10
diff --git a/mysql-test/r/heap_auto_increment.result b/mysql-test/r/heap_auto_increment.result
new file mode 100644
index 00000000000..9a5ed57d741
--- /dev/null
+++ b/mysql-test/r/heap_auto_increment.result
@@ -0,0 +1,41 @@
+drop table if exists t1;
+create table t1 (a int not null auto_increment,b int, primary key (a)) type=heap auto_increment=3;
+insert into t1 values (1,1),(NULL,3),(NULL,4);
+delete from t1 where a=4;
+insert into t1 values (NULL,5),(NULL,6);
+select * from t1;
+a b
+1 1
+3 3
+5 5
+6 6
+delete from t1 where a=6;
+replace t1 values (3,1);
+ALTER TABLE t1 add c int;
+replace t1 values (3,3,3);
+insert into t1 values (NULL,7,7);
+update t1 set a=8,b=b+1,c=c+1 where a=7;
+insert into t1 values (NULL,9,9);
+select * from t1;
+a b c
+1 1 NULL
+3 3 3
+5 5 NULL
+8 8 8
+9 9 9
+drop table t1;
+create table t1 (
+skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY,
+sval char(20)
+) type=heap;
+insert into t1 values (NULL, "hello");
+insert into t1 values (NULL, "hey");
+select * from t1;
+skey sval
+1 hello
+2 hey
+select _rowid,t1._rowid,skey,sval from t1;
+_rowid _rowid skey sval
+1 1 1 hello
+2 2 2 hey
+drop table t1;
diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result
new file mode 100644
index 00000000000..c42c5e60675
--- /dev/null
+++ b/mysql-test/r/heap_btree.result
@@ -0,0 +1,235 @@
+drop table if exists t1;
+create table t1 (a int not null,b int not null, primary key using BTREE (a)) type=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
+insert into t1 values(1,1),(2,2),(3,3),(4,4);
+delete from t1 where a=1 or a=0;
+show keys from t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 0 PRIMARY 1 a A NULL NULL NULL BTREE
+select * from t1;
+a b
+2 2
+3 3
+4 4
+select * from t1 where a=4;
+a b
+4 4
+update t1 set b=5 where a=4;
+update t1 set b=b+1 where a>=3;
+replace t1 values (3,3);
+select * from t1;
+a b
+2 2
+3 3
+4 6
+alter table t1 add c int not null, add key using BTREE (c,a);
+drop table t1;
+create table t1 (a int not null,b int not null, primary key using BTREE (a)) type=heap comment="testing heaps";
+insert into t1 values(-2,-2),(-1,-1),(0,0),(1,1),(2,2),(3,3),(4,4);
+delete from t1 where a > -3;
+select * from t1;
+a b
+drop table t1;
+create table t1 (a int not null,b int not null, primary key using BTREE (a)) type=heap comment="testing heaps";
+insert into t1 values(1,1),(2,2),(3,3),(4,4);
+alter table t1 modify a int not null auto_increment, type=myisam, comment="new myisam table";
+select * from t1;
+a b
+1 1
+2 2
+3 3
+4 4
+drop table t1;
+create table t1 (a int not null) type=heap;
+insert into t1 values (869751),(736494),(226312),(802616);
+select * from t1 where a > 736494;
+a
+869751
+802616
+alter table t1 add unique uniq_id using BTREE (a);
+select * from t1 where a > 736494;
+a
+802616
+869751
+select * from t1 where a = 736494;
+a
+736494
+select * from t1 where a=869751 or a=736494;
+a
+736494
+869751
+select * from t1 where a in (869751,736494,226312,802616);
+a
+226312
+736494
+802616
+869751
+alter table t1 type=myisam;
+explain select * from t1 where a in (869751,736494,226312,802616);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index
+drop table t1;
+create table t1 (x int not null, y int not null, key x using BTREE (x,y), unique y using BTREE (y))
+type=heap;
+insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
+explain select * from t1 where x=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref x x 4 const 1 Using where
+select * from t1 where x=1;
+x y
+1 1
+1 3
+select * from t1,t1 as t2 where t1.x=t2.y;
+x y x y
+1 1 1 1
+2 2 2 2
+1 3 1 1
+2 4 2 2
+2 5 2 2
+2 6 2 2
+explain select * from t1,t1 as t2 where t1.x=t2.y;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL x NULL NULL NULL 6
+1 SIMPLE t2 eq_ref y y 4 test.t1.x 1
+drop table t1;
+create table t1 (a int) type=heap;
+insert into t1 values(1);
+select max(a) from t1;
+max(a)
+1
+drop table t1;
+CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key using BTREE (a,b), key using BTREE (b) ) TYPE=HEAP;
+insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
+select * from t1 where a=1;
+a b
+1 1
+1 2
+1 3
+1 4
+1 5
+1 6
+insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
+select * from t1 where a=1;
+a b
+1 1
+1 1
+1 2
+1 2
+1 3
+1 3
+1 4
+1 4
+1 5
+1 5
+1 6
+1 6
+explain select * from tx where a=x order by a,b;
+id select_type table type possible_keys key key_len ref rows Extra
+x SIMPLE tx ref a a x const x Using where
+explain select * from tx where a=x order by b;
+id select_type table type possible_keys key key_len ref rows Extra
+x SIMPLE tx ref a a x const x Using where
+select * from t1 where b=1;
+a b
+1 1
+1 1
+explain select * from tx where b=x;
+id select_type table type possible_keys key key_len ref rows Extra
+x SIMPLE tx ref b b x const x Using where
+drop table t1;
+create table t1 (id int unsigned not null, primary key using BTREE (id)) type=HEAP;
+insert into t1 values(1);
+select max(id) from t1;
+max(id)
+1
+insert into t1 values(2);
+select max(id) from t1;
+max(id)
+2
+replace into t1 values(1);
+drop table t1;
+create table t1 (n int) type=heap;
+drop table t1;
+create table t1 (n int) type=heap;
+drop table if exists t1;
+CREATE table t1(f1 int not null,f2 char(20) not
+null,index(f2)) type=heap;
+INSERT into t1 set f1=12,f2="bill";
+INSERT into t1 set f1=13,f2="bill";
+INSERT into t1 set f1=14,f2="bill";
+INSERT into t1 set f1=15,f2="bill";
+INSERT into t1 set f1=16,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+delete from t1 where f2="bill";
+select * from t1;
+f1 f2
+16 ted
+12 ted
+12 ted
+12 ted
+12 ted
+drop table t1;
+create table t1 (btn char(10) not null, key using BTREE (btn)) type=heap;
+insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
+explain select * from t1 where btn like "q%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where
+select * from t1 where btn like "q%";
+btn
+alter table t1 add column new_col char(1) not null, add key using BTREE (btn,new_col), drop key btn;
+update t1 set new_col=left(btn,1);
+explain select * from t1 where btn="a";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref btn btn 10 const 1 Using where
+explain select * from t1 where btn="a" and new_col="a";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref btn btn 11 const,const 1 Using where
+drop table t1;
+CREATE TABLE t1 (
+a int default NULL,
+b int default NULL,
+KEY a using BTREE (a),
+UNIQUE b using BTREE (b)
+) type=heap;
+INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
+SELECT * FROM t1 WHERE a=NULL;
+a b
+explain SELECT * FROM t1 WHERE a IS NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a a 5 const 1 Using where
+SELECT * FROM t1 WHERE a<=>NULL;
+a b
+NULL 99
+SELECT * FROM t1 WHERE b=NULL;
+a b
+explain SELECT * FROM t1 WHERE b IS NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref b b 5 const 1 Using where
+SELECT * FROM t1 WHERE b<=>NULL;
+a b
+99 NULL
+INSERT INTO t1 VALUES (1,3);
+ERROR 23000: Duplicate entry '3' for key 1
+DROP TABLE t1;
+CREATE TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) type=heap;
+INSERT INTO t1 VALUES (1, NULL, NULL), (1, 1, NULL), (1, NULL, 1);
+SELECT * FROM t1 WHERE a=1 and b IS NULL;
+a b c
+1 NULL NULL
+1 NULL 1
+SELECT * FROM t1 WHERE a=1 and c IS NULL;
+a b c
+1 NULL NULL
+1 1 NULL
+SELECT * FROM t1 WHERE a=1 and b IS NULL and c IS NULL;
+a b c
+1 NULL NULL
+DROP TABLE t1;
+CREATE TABLE t1 (a int not null, primary key using BTREE (a)) type=heap;
+INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
+DELETE from t1 where a < 100;
+SELECT * from t1;
+a
+DROP TABLE t1;
diff --git a/mysql-test/r/heap_hash.result b/mysql-test/r/heap_hash.result
new file mode 100644
index 00000000000..7ecd1db7447
--- /dev/null
+++ b/mysql-test/r/heap_hash.result
@@ -0,0 +1,205 @@
+drop table if exists t1;
+create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
+insert into t1 values(1,1),(2,2),(3,3),(4,4);
+delete from t1 where a=1 or a=0;
+show keys from t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 0 PRIMARY 1 a NULL NULL NULL NULL HASH
+select * from t1;
+a b
+2 2
+3 3
+4 4
+select * from t1 where a=4;
+a b
+4 4
+update t1 set b=5 where a=4;
+update t1 set b=b+1 where a>=3;
+replace t1 values (3,3);
+select * from t1;
+a b
+2 2
+3 3
+4 6
+alter table t1 add c int not null, add key using HASH (c,a);
+drop table t1;
+create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps";
+insert into t1 values(1,1),(2,2),(3,3),(4,4);
+delete from t1 where a > 0;
+select * from t1;
+a b
+drop table t1;
+create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps";
+insert into t1 values(1,1),(2,2),(3,3),(4,4);
+alter table t1 modify a int not null auto_increment, type=myisam, comment="new myisam table";
+select * from t1;
+a b
+1 1
+2 2
+3 3
+4 4
+drop table t1;
+create table t1 (a int not null) type=heap;
+insert into t1 values (869751),(736494),(226312),(802616);
+select * from t1 where a > 736494;
+a
+869751
+802616
+alter table t1 add unique uniq_id using HASH (a);
+select * from t1 where a > 736494;
+a
+869751
+802616
+select * from t1 where a = 736494;
+a
+736494
+select * from t1 where a=869751 or a=736494;
+a
+736494
+869751
+select * from t1 where a in (869751,736494,226312,802616);
+a
+226312
+736494
+802616
+869751
+alter table t1 type=myisam;
+explain select * from t1 where a in (869751,736494,226312,802616);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range uniq_id uniq_id 4 NULL 4 Using where; Using index
+drop table t1;
+create table t1 (x int not null, y int not null, key x using HASH (x), unique y using HASH (y))
+type=heap;
+insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
+select * from t1 where x=1;
+x y
+1 3
+1 1
+select * from t1,t1 as t2 where t1.x=t2.y;
+x y x y
+1 1 1 1
+2 2 2 2
+1 3 1 1
+2 4 2 2
+2 5 2 2
+2 6 2 2
+explain select * from t1,t1 as t2 where t1.x=t2.y;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL x NULL NULL NULL 6
+1 SIMPLE t2 eq_ref y y 4 test.t1.x 1
+drop table t1;
+create table t1 (a int) type=heap;
+insert into t1 values(1);
+select max(a) from t1;
+max(a)
+1
+drop table t1;
+CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key using HASH (a), key using HASH (b) ) TYPE=HEAP;
+insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
+select * from t1 where a=1;
+a b
+1 6
+1 5
+1 4
+1 3
+1 2
+1 1
+insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
+select * from t1 where a=1;
+a b
+1 6
+1 5
+1 4
+1 3
+1 2
+1 1
+1 6
+1 5
+1 4
+1 3
+1 2
+1 1
+drop table t1;
+create table t1 (id int unsigned not null, primary key using HASH (id)) type=HEAP;
+insert into t1 values(1);
+select max(id) from t1;
+max(id)
+1
+insert into t1 values(2);
+select max(id) from t1;
+max(id)
+2
+replace into t1 values(1);
+drop table t1;
+create table t1 (n int) type=heap;
+drop table t1;
+create table t1 (n int) type=heap;
+drop table if exists t1;
+CREATE table t1(f1 int not null,f2 char(20) not
+null,index(f2)) type=heap;
+INSERT into t1 set f1=12,f2="bill";
+INSERT into t1 set f1=13,f2="bill";
+INSERT into t1 set f1=14,f2="bill";
+INSERT into t1 set f1=15,f2="bill";
+INSERT into t1 set f1=16,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+delete from t1 where f2="bill";
+select * from t1;
+f1 f2
+16 ted
+12 ted
+12 ted
+12 ted
+12 ted
+drop table t1;
+create table t1 (btn char(10) not null, key using HASH (btn)) type=heap;
+insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
+explain select * from t1 where btn like "q%";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL btn NULL NULL NULL 14 Using where
+select * from t1 where btn like "q%";
+btn
+alter table t1 add column new_col char(1) not null, add key using HASH (btn,new_col), drop key btn;
+update t1 set new_col=left(btn,1);
+explain select * from t1 where btn="a";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL btn NULL NULL NULL 11 Using where
+explain select * from t1 where btn="a" and new_col="a";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref btn btn 11 const,const 10 Using where
+drop table t1;
+CREATE TABLE t1 (
+a int default NULL,
+b int default NULL,
+KEY a using HASH (a),
+UNIQUE b using HASH (b)
+) type=heap;
+INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
+SELECT * FROM t1 WHERE a=NULL;
+a b
+explain SELECT * FROM t1 WHERE a IS NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a a 5 const 10 Using where
+SELECT * FROM t1 WHERE a<=>NULL;
+a b
+NULL 99
+SELECT * FROM t1 WHERE b=NULL;
+a b
+explain SELECT * FROM t1 WHERE b IS NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref b b 5 const 1 Using where
+SELECT * FROM t1 WHERE b<=>NULL;
+a b
+99 NULL
+INSERT INTO t1 VALUES (1,3);
+ERROR 23000: Duplicate entry '3' for key 1
+DROP TABLE t1;
+CREATE TABLE t1 (a int not null, primary key using HASH (a)) type=heap;
+INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
+DELETE from t1 where a < 100;
+SELECT * from t1;
+a
+DROP TABLE t1;
diff --git a/mysql-test/r/help.result b/mysql-test/r/help.result
new file mode 100644
index 00000000000..d22539b2bcb
--- /dev/null
+++ b/mysql-test/r/help.result
@@ -0,0 +1,243 @@
+insert into mysql.help_category(help_category_id,name)values(1,'impossible_category_1');
+select @category1_id:= 1;
+@category1_id:= 1
+1
+insert into mysql.help_category(help_category_id,name)values(2,'impossible_category_2');
+select @category2_id:= 2;
+@category2_id:= 2
+2
+insert into mysql.help_category(help_category_id,name,parent_category_id)values(3,'impossible_category_3',@category2_id);
+select @category3_id:= 3;
+@category3_id:= 3
+3
+insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(1,'impossible_function_1',@category1_id,'description of \n impossible_function1\n','example of \n impossible_function1');
+select @topic1_id:= 1;
+@topic1_id:= 1
+1
+insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(2,'impossible_function_2',@category1_id,'description of \n impossible_function2\n','example of \n impossible_function2');
+select @topic2_id:= 2;
+@topic2_id:= 2
+2
+insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(3,'impossible_function_3',@category2_id,'description of \n impossible_function3\n','example of \n impossible_function3');
+select @topic3_id:= 3;
+@topic3_id:= 3
+3
+insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(4,'impossible_function_4',@category2_id,'description of \n impossible_function4\n','example of \n impossible_function4');
+select @topic4_id:= 4;
+@topic4_id:= 4
+4
+insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(5,'impossible_function_7',@category3_id,'description of \n impossible_function5\n','example of \n impossible_function7');
+select @topic5_id:= 5;
+@topic5_id:= 5
+5
+insert into mysql.help_keyword(help_keyword_id,name)values(1,'impossible_function_1');
+select @keyword1_id:= 1;
+@keyword1_id:= 1
+1
+insert into mysql.help_keyword(help_keyword_id,name)values(2,'impossible_function_5');
+select @keyword2_id:= 2;
+@keyword2_id:= 2
+2
+insert into mysql.help_keyword(help_keyword_id,name)values(3,'impossible_function_6');
+select @keyword3_id:= 3;
+@keyword3_id:= 3
+3
+insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword1_id,@topic2_id);
+insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword2_id,@topic1_id);
+insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword3_id,@topic3_id);
+insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword3_id,@topic4_id);
+help 'function_of_my_dream';
+name is_it_category
+help '%possible_f%';
+name is_it_category
+impossible_function_1 N
+impossible_function_2 N
+impossible_function_3 N
+impossible_function_4 N
+impossible_function_7 N
+help 'impossible_func%';
+name is_it_category
+impossible_function_1 N
+impossible_function_2 N
+impossible_function_3 N
+impossible_function_4 N
+impossible_function_7 N
+help 'impossible_category%';
+name is_it_category
+impossible_category_1 Y
+impossible_category_2 Y
+impossible_category_3 Y
+help 'impossible_%';
+name is_it_category
+impossible_function_1 N
+impossible_function_2 N
+impossible_function_3 N
+impossible_function_4 N
+impossible_function_7 N
+impossible_category_1 Y
+impossible_category_2 Y
+impossible_category_3 Y
+help '%function_1';
+name description example
+impossible_function_1 description of
+ impossible_function1
+ example of
+ impossible_function1
+help '%function_2';
+name description example
+impossible_function_2 description of
+ impossible_function2
+ example of
+ impossible_function2
+help '%function_3';
+name description example
+impossible_function_3 description of
+ impossible_function3
+ example of
+ impossible_function3
+help '%function_4';
+name description example
+impossible_function_4 description of
+ impossible_function4
+ example of
+ impossible_function4
+help '%function_5';
+name description example
+impossible_function_1 description of
+ impossible_function1
+ example of
+ impossible_function1
+help '%function_6';
+name is_it_category
+impossible_function_3 N
+impossible_function_4 N
+help '%function_7';
+name description example
+impossible_function_7 description of
+ impossible_function5
+ example of
+ impossible_function7
+help '%category_2';
+source_category_name name is_it_category
+impossible_category_2 impossible_function_3 N
+impossible_category_2 impossible_function_4 N
+impossible_category_2 impossible_category_3 Y
+help 'impossible_function_1';
+name description example
+impossible_function_1 description of
+ impossible_function1
+ example of
+ impossible_function1
+help 'impossible_category_1';
+source_category_name name is_it_category
+impossible_category_1 impossible_function_1 N
+impossible_category_1 impossible_function_2 N
+alter table mysql.help_relation type=innodb;
+alter table mysql.help_keyword type=innodb;
+alter table mysql.help_topic type=innodb;
+alter table mysql.help_category type=innodb;
+help 'function_of_my_dream';
+name is_it_category
+help '%possible_f%';
+name is_it_category
+impossible_function_1 N
+impossible_function_2 N
+impossible_function_3 N
+impossible_function_4 N
+impossible_function_7 N
+help 'impossible_func%';
+name is_it_category
+impossible_function_1 N
+impossible_function_2 N
+impossible_function_3 N
+impossible_function_4 N
+impossible_function_7 N
+help 'impossible_category%';
+name is_it_category
+impossible_category_1 Y
+impossible_category_2 Y
+impossible_category_3 Y
+help 'impossible_%';
+name is_it_category
+impossible_function_1 N
+impossible_function_2 N
+impossible_function_3 N
+impossible_function_4 N
+impossible_function_7 N
+impossible_category_1 Y
+impossible_category_2 Y
+impossible_category_3 Y
+help '%function_1';
+name description example
+impossible_function_1 description of
+ impossible_function1
+ example of
+ impossible_function1
+help '%function_2';
+name description example
+impossible_function_2 description of
+ impossible_function2
+ example of
+ impossible_function2
+help '%function_3';
+name description example
+impossible_function_3 description of
+ impossible_function3
+ example of
+ impossible_function3
+help '%function_4';
+name description example
+impossible_function_4 description of
+ impossible_function4
+ example of
+ impossible_function4
+help '%function_5';
+name description example
+impossible_function_1 description of
+ impossible_function1
+ example of
+ impossible_function1
+help '%function_6';
+name is_it_category
+impossible_function_3 N
+impossible_function_4 N
+help '%function_7';
+name description example
+impossible_function_7 description of
+ impossible_function5
+ example of
+ impossible_function7
+help '%category_2';
+source_category_name name is_it_category
+impossible_category_2 impossible_function_3 N
+impossible_category_2 impossible_function_4 N
+impossible_category_2 impossible_category_3 Y
+help 'impossible_function_1';
+name description example
+impossible_function_1 description of
+ impossible_function1
+ example of
+ impossible_function1
+help 'impossible_category_1';
+source_category_name name is_it_category
+impossible_category_1 impossible_function_1 N
+impossible_category_1 impossible_function_2 N
+alter table mysql.help_relation type=myisam;
+alter table mysql.help_keyword type=myisam;
+alter table mysql.help_topic type=myisam;
+alter table mysql.help_category type=myisam;
+delete from mysql.help_topic where help_topic_id=@topic1_id;
+delete from mysql.help_topic where help_topic_id=@topic2_id;
+delete from mysql.help_topic where help_topic_id=@topic3_id;
+delete from mysql.help_topic where help_topic_id=@topic4_id;
+delete from mysql.help_topic where help_topic_id=@topic5_id;
+delete from mysql.help_category where help_category_id=@category3_id;
+delete from mysql.help_category where help_category_id=@category2_id;
+delete from mysql.help_category where help_category_id=@category1_id;
+delete from mysql.help_keyword where help_keyword_id=@keyword1_id;
+delete from mysql.help_keyword where help_keyword_id=@keyword2_id;
+delete from mysql.help_keyword where help_keyword_id=@keyword3_id;
+delete from mysql.help_relation where help_keyword_id=@keyword1_id and help_topic_id=@topic2_id;
+delete from mysql.help_relation where help_keyword_id=@keyword2_id and help_topic_id=@topic1_id;
+delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic3_id;
+delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic4_id;
diff --git a/mysql-test/r/innodb-deadlock.result b/mysql-test/r/innodb-deadlock.result
index 121bfa8c6cb..e1b3e38b243 100644
--- a/mysql-test/r/innodb-deadlock.result
+++ b/mysql-test/r/innodb-deadlock.result
@@ -1,4 +1,4 @@
-drop table if exists t1;
+drop table if exists t1,t2;
create table t1 (id integer, x integer) type=INNODB;
insert into t1 values(0, 0);
set autocommit=0;
@@ -18,3 +18,79 @@ id x
0 2
commit;
drop table t1;
+create table t1 (id integer, x integer) type=INNODB;
+create table t2 (b integer, a integer) type=INNODB;
+insert into t1 values(0, 0), (300, 300);
+insert into t2 values(0, 10), (1, 20), (2, 30);
+commit;
+set autocommit=0;
+select * from t2;
+b a
+0 10
+1 20
+2 30
+update t2 set a=100 where b=(SELECT x from t1 where id = b FOR UPDATE);
+select * from t2;
+b a
+0 100
+1 20
+2 30
+select * from t1;
+id x
+0 0
+300 300
+set autocommit=0;
+update t1 set x=2 where id = 0;
+update t1 set x=1 where id = 0;
+select * from t1;
+id x
+0 1
+300 300
+commit;
+commit;
+select * from t1;
+id x
+0 2
+300 300
+commit;
+drop table t1, t2;
+create table t1 (id integer, x integer) type=INNODB;
+create table t2 (b integer, a integer) type=INNODB;
+insert into t1 values(0, 0), (300, 300);
+insert into t2 values(0, 0), (1, 20), (2, 30);
+commit;
+select a,b from t2 UNION SELECT id, x from t1 FOR UPDATE;
+a b
+0 0
+20 1
+30 2
+300 300
+select * from t2;
+b a
+0 0
+1 20
+2 30
+select * from t1;
+id x
+0 0
+300 300
+update t2 set a=2 where b = 0;
+select * from t2;
+b a
+0 2
+1 20
+2 30
+update t1 set x=2 where id = 0;
+update t1 set x=1 where id = 0;
+select * from t1;
+id x
+0 1
+300 300
+commit;
+commit;
+select * from t1;
+id x
+0 2
+300 300
+commit;
+drop table t1, t2;
diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result
index e9cdf962022..0ebf3d50ab8 100644
--- a/mysql-test/r/innodb.result
+++ b/mysql-test/r/innodb.result
@@ -1,4 +1,4 @@
-drop table if exists t1,t2,t3;
+drop table if exists t1,t2,t3,t4;
drop database if exists mysqltest;
create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) type=innodb;
insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt');
@@ -139,6 +139,15 @@ id parent_id level
1008 102 2
1010 102 2
1015 102 2
+explain select level from t1 where level=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref level level 1 const # Using where; Using index
+explain select level,id from t1 where level=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref level level 1 const # Using where; Using index
+explain select level,id,parent_id from t1 where level=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref level level 1 const # Using where
select level,id from t1 where level=1;
level id
1 1002
@@ -158,6 +167,11 @@ level id parent_id
optimize table t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
+show keys from t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 0 PRIMARY 1 id A # NULL NULL BTREE
+t1 1 parent_id 1 parent_id A # NULL NULL BTREE
+t1 1 level 1 level A # NULL NULL BTREE
drop table t1;
CREATE TABLE t1 (
gesuchnr int(11) DEFAULT '0' NOT NULL,
@@ -196,6 +210,9 @@ insert into t1 values (3,""), (4,"testing");
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
+show keys from t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 1 skr 1 a A # NULL NULL YES BTREE
drop table t1;
create table t1 (a int,b varchar(20),key(a)) type=innodb;
insert into t1 values (1,""), (2,"testing");
@@ -217,7 +234,7 @@ n after commit
commit;
insert into t1 values (5);
insert into t1 values (4);
-Duplicate entry '4' for key 1
+ERROR 23000: Duplicate entry '4' for key 1
commit;
select n, "after commit" from t1;
n after commit
@@ -226,7 +243,7 @@ n after commit
set autocommit=1;
insert into t1 values (6);
insert into t1 values (4);
-Duplicate entry '4' for key 1
+ERROR 23000: Duplicate entry '4' for key 1
select n from t1;
n
4
@@ -234,6 +251,17 @@ n
6
rollback;
drop table t1;
+create table t1 (n int not null primary key) type=innodb;
+start transaction;
+insert into t1 values (4);
+flush tables with read lock;
+commit;
+unlock tables;
+commit;
+select * from t1;
+n
+4
+drop table t1;
create table t1 ( id int NOT NULL PRIMARY KEY, nom varchar(64)) type=innodb;
begin;
insert into t1 values(1,'hamdouni');
@@ -256,7 +284,7 @@ drop table t1;
CREATE TABLE t1 (id char(8) not null primary key, val int not null) type=innodb;
insert into t1 values ('pippo', 12);
insert into t1 values ('pippo', 12);
-Duplicate entry 'pippo' for key 1
+ERROR 23000: Duplicate entry 'pippo' for key 1
delete from t1;
delete from t1 where id = 'pippo';
select * from t1;
@@ -336,6 +364,14 @@ user_id name phone ref_email detail
drop table t1;
CREATE TABLE t1 (a int not null, b int not null,c int not null,
key(a),primary key(a,b), unique(c),key(a),unique(b));
+show index from t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 0 PRIMARY 1 a A # NULL NULL BTREE
+t1 0 PRIMARY 2 b A # NULL NULL BTREE
+t1 0 c 1 c A # NULL NULL BTREE
+t1 0 b 1 b A # NULL NULL BTREE
+t1 1 a 1 a A # NULL NULL BTREE
+t1 1 a_2 1 a A # NULL NULL BTREE
drop table t1;
create table t1 (col1 int not null, col2 char(4) not null, primary key(col1));
alter table t1 type=innodb;
@@ -412,9 +448,9 @@ UNIQUE ggid (ggid)
insert into t1 (ggid,passwd) values ('test1','xxx');
insert into t1 (ggid,passwd) values ('test2','yyy');
insert into t1 (ggid,passwd) values ('test2','this will fail');
-Duplicate entry 'test2' for key 2
+ERROR 23000: Duplicate entry 'test2' for key 2
insert into t1 (ggid,id) values ('this will fail',1);
-Duplicate entry '1' for key 1
+ERROR 23000: Duplicate entry '1' for key 1
select * from t1 where ggid='test1';
id ggid email passwd
1 test1 xxx
@@ -427,7 +463,7 @@ id ggid email passwd
replace into t1 (ggid,id) values ('this will work',1);
replace into t1 (ggid,passwd) values ('test2','this will work');
update t1 set id=100,ggid='test2' where id=1;
-Duplicate entry 'test2' for key 2
+ERROR 23000: Duplicate entry 'test2' for key 2
select * from t1;
id ggid email passwd
1 this will work
@@ -571,6 +607,9 @@ id parent_id level
1009 102 2
1025 102 2
1016 102 2
+explain select level from t1 where level=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref level level 1 const # Using where; Using index
select level,id from t1 where level=1;
level id
1 1004
@@ -698,6 +737,9 @@ hello 1
optimize table t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
+show keys from t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 0 PRIMARY 1 a A # NULL NULL BTREE
drop table t1;
create table t1 (i int, j int ) TYPE=innodb;
insert into t1 values (1,2);
@@ -727,12 +769,15 @@ a
DROP TABLE t1;
create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) type = innodb;
insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
+explain select * from t1 where a > 0 and a < 50;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL # Using where
drop table t1;
create table t1 (id int NOT NULL,id2 int NOT NULL,id3 int NOT NULL,dummy1 char(30),primary key (id,id2),index index_id3 (id3)) type=innodb;
insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJKL');
LOCK TABLES t1 WRITE;
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
-Duplicate entry '1-1' for key 1
+ERROR 23000: Duplicate entry '1-1' for key 1
select id from t1;
id
0
@@ -750,7 +795,7 @@ insert into t1 values (0,0,0,'ABCDEFGHIJ'),(2,2,2,'BCDEFGHIJK'),(1,1,1,'CDEFGHIJ
LOCK TABLES t1 WRITE;
begin;
insert into t1 values (99,1,2,'D'),(1,1,2,'D');
-Duplicate entry '1-1' for key 1
+ERROR 23000: Duplicate entry '1-1' for key 1
select id from t1;
id
0
@@ -766,6 +811,16 @@ id id3
100 2
UNLOCK TABLES;
DROP TABLE t1;
+create table t1 (a char(20), unique (a(5))) type=innodb;
+drop table t1;
+create table t1 (a char(20), index (a(5))) type=innodb;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(20) default NULL,
+ KEY `a` (`a`(5))
+) TYPE=InnoDB DEFAULT CHARSET=latin1
+drop table t1;
create temporary table t1 (a int not null auto_increment, primary key(a)) type=innodb;
insert into t1 values (NULL),(NULL),(NULL);
delete from t1 where a=3;
@@ -814,11 +869,13 @@ create table mysqltest.t3 (a int not null) type= heap;
insert into mysqltest.t3 values(1);
commit;
drop database mysqltest;
+show tables from mysqltest;
+Got one of the listed errors
set autocommit=0;
create table t1 (a int not null) type= innodb;
insert into t1 values(1),(2);
truncate table t1;
-Can't execute the given command because you have active locked tables or an active transaction
+ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction
commit;
truncate table t1;
select * from t1;
@@ -846,6 +903,30 @@ a
drop table t1;
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) type=innodb;
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
+explain select * from t1 order by a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 4 NULL #
+explain select * from t1 order by b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL b 4 NULL #
+explain select * from t1 order by c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL # Using filesort
+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 PRIMARY 4 NULL # Using index
+explain select b from t1 order by b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL b 4 NULL # Using index
+explain select a,b from t1 order by b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL b 4 NULL # Using index
+explain select a,b from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL b 4 NULL # Using index
+explain select a,b,c from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL #
drop table t1;
create table t1 (t int not null default 1, key (t)) type=innodb;
desc t1;
@@ -890,29 +971,29 @@ INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,0000000000000
INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0);
select * from t1;
number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status
-4077711111 SeanWheeler 90 2 20020111112846 500 00000000000000 -1 2 3 1
-9197722223 berry 90 3 20020111112809 500 20020102114532 501 4 10 0
-650 San Francisco 0 0 20011227111336 342 00000000000000 -1 1 24 1
-302467 Sue's Subshop 90 3 20020109113241 500 20020102115111 501 7 24 0
-6014911113 SudzCarwash 520 1 20020102115234 500 20020102115259 501 33 32768 0
-333 tubs 99 2 20020109113440 501 20020109113440 500 3 10 0
+4077711111 SeanWheeler 90 2 2002-01-11 11:28:46 500 0000-00-00 00:00:00 -1 2 3 1
+9197722223 berry 90 3 2002-01-11 11:28:09 500 2002-01-02 11:45:32 501 4 10 0
+650 San Francisco 0 0 2001-12-27 11:13:36 342 0000-00-00 00:00:00 -1 1 24 1
+302467 Sue's Subshop 90 3 2002-01-09 11:32:41 500 2002-01-02 11:51:11 501 7 24 0
+6014911113 SudzCarwash 520 1 2002-01-02 11:52:34 500 2002-01-02 11:52:59 501 33 32768 0
+333 tubs 99 2 2002-01-09 11:34:40 501 2002-01-09 11:34:40 500 3 10 0
select * from t2;
number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status
-4077711111 SeanWheeler 0 2 20020111112853 500 00000000000000 -1 2 3 1
-9197722223 berry 90 3 20020111112818 500 20020102114532 501 4 10 0
-650 San Francisco 90 0 20020109113158 342 00000000000000 -1 1 24 1
-333 tubs 99 2 20020109113453 501 20020109113453 500 3 10 0
+4077711111 SeanWheeler 0 2 2002-01-11 11:28:53 500 0000-00-00 00:00:00 -1 2 3 1
+9197722223 berry 90 3 2002-01-11 11:28:18 500 2002-01-02 11:45:32 501 4 10 0
+650 San Francisco 90 0 2002-01-09 11:31:58 342 0000-00-00 00:00:00 -1 1 24 1
+333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0
delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or (t1.carrier_id=90 and t2.number is null);
select * from t1;
number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status
-6014911113 SudzCarwash 520 1 20020102115234 500 20020102115259 501 33 32768 0
-333 tubs 99 2 20020109113440 501 20020109113440 500 3 10 0
+6014911113 SudzCarwash 520 1 2002-01-02 11:52:34 500 2002-01-02 11:52:59 501 33 32768 0
+333 tubs 99 2 2002-01-09 11:34:40 501 2002-01-09 11:34:40 500 3 10 0
select * from t2;
number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status
-333 tubs 99 2 20020109113453 501 20020109113453 500 3 10 0
+333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0
select * from t2;
number cname carrier_id privacy last_mod_date last_mod_id last_app_date last_app_id version assigned_scps status
-333 tubs 99 2 20020109113453 501 20020109113453 500 3 10 0
+333 tubs 99 2 2002-01-09 11:34:53 501 2002-01-09 11:34:53 500 3 10 0
drop table t1,t2;
create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) type=innodb;
BEGIN;
@@ -952,7 +1033,6 @@ id code name
7 4 Matt
COMMIT;
DROP TABLE t1;
-drop table if exists t1,t2;
create table t1 (n int(10), d int(10)) type=innodb;
create table t2 (n int(10), d int(10)) type=innodb;
insert into t1 values(1,1),(1,2);
@@ -1006,6 +1086,9 @@ select * from t2;
id t1_id
drop table t1,t2;
DROP TABLE IF EXISTS t1,t2;
+Warnings:
+Note 1051 Unknown table 't1'
+Note 1051 Unknown table 't2'
CREATE TABLE t1(id INT NOT NULL, PRIMARY KEY (id)) TYPE=INNODB;
CREATE TABLE t2(id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id) ) TYPE=INNODB;
INSERT INTO t1 VALUES(1);
@@ -1150,7 +1233,8 @@ SET AUTOCOMMIT=0;
INSERT INTO t1 ( B_ID ) VALUES ( 1 );
INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
ROLLBACK;
-Warning: Some non-transactional changed tables couldn't be rolled back
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
SELECT * FROM t1;
B_ID
drop table t1,t2;
@@ -1187,7 +1271,13 @@ insert into t1 (a) select b from t2;
select count(*) from t1;
count(*)
29267
+explain select * from t1 where c between 1 and 10000;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range c c 5 NULL # Using where
update t1 set c=a;
+explain select * from t1 where c between 1 and 10000;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL c NULL NULL NULL # Using where
drop table t1,t2;
create table t1 (id int primary key auto_increment, fk int, index index_fk (fk)) type=innodb;
insert into t1 (id) values (null),(null),(null),(null),(null);
@@ -1222,3 +1312,81 @@ a b
111 100
111 100
drop table t1;
+CREATE TABLE t1 (col1 int(1))TYPE=InnoDB;
+CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx
+(stamp))TYPE=InnoDB;
+insert into t1 values (1),(2),(3);
+insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 );
+SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
+'20020204120000' GROUP BY col1;
+col1
+1
+2
+3
+drop table t1,t2;
+CREATE TABLE t1 (
+`id` int(10) unsigned NOT NULL auto_increment,
+`id_object` int(10) unsigned default '0',
+`id_version` int(10) unsigned NOT NULL default '1',
+label varchar(100) NOT NULL default '',
+`description` text,
+PRIMARY KEY (`id`),
+KEY `id_object` (`id_object`),
+KEY `id_version` (`id_version`)
+) TYPE=InnoDB;
+INSERT INTO t1 VALUES("6", "3382", "9", "Test", NULL), ("7", "102", "5", "Le Pekin (Test)", NULL),("584", "1794", "4", "Test de resto", NULL),("837", "1822", "6", "Test 3", NULL),("1119", "3524", "1", "Societe Test", NULL),("1122", "3525", "1", "Fournisseur Test", NULL);
+CREATE TABLE t2 (
+`id` int(10) unsigned NOT NULL auto_increment,
+`id_version` int(10) unsigned NOT NULL default '1',
+PRIMARY KEY (`id`),
+KEY `id_version` (`id_version`)
+) TYPE=InnoDB;
+INSERT INTO t2 VALUES("3524", "1"),("3525", "1"),("1794", "4"),("102", "5"),("1822", "6"),("3382", "9");
+SELECT t2.id, t1.label FROM t2 INNER JOIN
+(SELECT t1.id_object as id_object FROM t1 WHERE t1.label LIKE '%test%') AS lbl
+ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object);
+id label
+3382 Test
+102 Le Pekin (Test)
+1794 Test de resto
+1822 Test 3
+3524 Societe Test
+3525 Fournisseur Test
+drop table t1,t2;
+create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) type=innodb;
+select * from t1;
+c1 c2 stamp
+replace delayed into t1 (c1, c2) values ( "text1","11"),( "text2","12");
+ERROR HY000: Table storage engine for 't1' doesn't have this option
+select * from t1;
+c1 c2 stamp
+replace delayed into t1 (c1, c2) values ( "text1","12"),( "text2","13"),( "text3","14", "a" ),( "text4","15", "b" );
+ERROR HY000: Table storage engine for 't1' doesn't have this option
+select * from t1;
+c1 c2 stamp
+drop table t1;
+create table t1 (a int, b varchar(200), c text not null) checksum=1 type=myisam;
+create table t2 (a int, b varchar(200), c text not null) checksum=0 type=innodb;
+create table t3 (a int, b varchar(200), c text not null) checksum=1 type=innodb;
+insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
+insert t2 select * from t1;
+insert t3 select * from t1;
+checksum table t1, t2, t3, t4 quick;
+Table Checksum
+test.t1 968604391
+test.t2 NULL
+test.t3 NULL
+test.t4 NULL
+checksum table t1, t2, t3, t4;
+Table Checksum
+test.t1 968604391
+test.t2 968604391
+test.t3 968604391
+test.t4 NULL
+checksum table t1, t2, t3, t4 extended;
+Table Checksum
+test.t1 968604391
+test.t2 968604391
+test.t3 968604391
+test.t4 NULL
+drop table t1,t2,t3;
diff --git a/mysql-test/r/innodb_cache.result b/mysql-test/r/innodb_cache.result
index 47abcb45fe5..7706e60d143 100644
--- a/mysql-test/r/innodb_cache.result
+++ b/mysql-test/r/innodb_cache.result
@@ -1,4 +1,4 @@
-drop table if exists t1, t2, t3;
+drop table if exists t1,t2,t3;
flush status;
set autocommit=0;
create table t1 (a int not null) type=innodb;
@@ -69,7 +69,7 @@ Variable_name Value
Qcache_queries_in_cache 3
show status like "Qcache_hits";
Variable_name Value
-Qcache_hits 0
+Qcache_hits 3
insert into t1 values (3);
insert into t2 values (3);
insert into t1 values (4);
@@ -90,10 +90,10 @@ a
2
show status like "Qcache_queries_in_cache";
Variable_name Value
-Qcache_queries_in_cache 3
+Qcache_queries_in_cache 1
show status like "Qcache_hits";
Variable_name Value
-Qcache_hits 0
+Qcache_hits 4
commit;
show status like "Qcache_queries_in_cache";
Variable_name Value
diff --git a/mysql-test/r/innodb_handler.result b/mysql-test/r/innodb_handler.result
index 8aa5309308f..1fadc3a61de 100644
--- a/mysql-test/r/innodb_handler.result
+++ b/mysql-test/r/innodb_handler.result
@@ -1,4 +1,4 @@
-drop table if exists t1;
+drop table if exists t1,t2;
create table t1 (a int, b char(10), key a(a), key b(a,b)) type=innodb;
insert into t1 values
(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
@@ -49,7 +49,7 @@ handler t2 read a=(16);
a b
16 ccc
handler t2 read a=(19,"fff");
-Too many key parts specified. Max 1 parts allowed
+ERROR 42000: Too many key parts specified. Max 1 parts allowed
handler t2 read b=(19,"fff");
a b
19 fff
@@ -60,7 +60,7 @@ handler t2 read b=(19);
a b
19 fff
handler t1 read a last;
-Unknown table 't1' in HANDLER
+ERROR 42S02: Unknown table 't1' in HANDLER
handler t2 read a=(11);
a b
handler t2 read a>=(11);
@@ -130,7 +130,7 @@ handler t2 read next;
a b
18 eee
handler t2 read last;
-You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
+ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
handler t2 close;
handler t1 open as t2;
handler t2 read first;
@@ -138,7 +138,7 @@ a b
17 ddd
alter table t1 type=innodb;
handler t2 read first;
-Unknown table 't2' in HANDLER
+ERROR 42S02: Unknown table 't2' in HANDLER
drop table t1;
CREATE TABLE t1 ( no1 smallint(5) NOT NULL default '0', no2 int(10) NOT NULL default '0', PRIMARY KEY (no1,no2)) TYPE=InnoDB;
INSERT INTO t1 VALUES (1,274),(1,275),(2,6),(2,8),(4,1),(4,2);
diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result
index 270994e3998..23eef0b3c59 100644
--- a/mysql-test/r/insert.result
+++ b/mysql-test/r/insert.result
@@ -60,8 +60,10 @@ test 2
drop table t1;
create table t1 (id int NOT NULL DEFAULT 8);
insert into t1 values(NULL);
-Column 'id' cannot be null
+ERROR 23000: Column 'id' cannot be null
insert into t1 values (1), (NULL), (2);
+Warnings:
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'id' at row 2
select * from t1;
id
1
diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result
index 23cb7244f48..8eecccf6fec 100644
--- a/mysql-test/r/insert_select.result
+++ b/mysql-test/r/insert_select.result
@@ -4,7 +4,7 @@ insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,
create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY);
insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1;
insert into t2 (payoutID) SELECT payoutID+10 FROM t1;
-Duplicate entry '16' for key 1
+ERROR 23000: Duplicate entry '16' for key 1
insert ignore into t2 (payoutID) SELECT payoutID+10 FROM t1;
select * from t2;
payoutID
@@ -71,13 +71,16 @@ create table t2(a int);
insert into t2 values(1),(2);
reset master;
insert into t1 select * from t2;
-Duplicate entry '2' for key 1
+ERROR 23000: Duplicate entry '2' for key 1
show binlog events;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
-master-bin.001 79 Query 1 79 use `test`; insert into t1 select * from t2
+master-bin.000001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
+master-bin.000001 79 Query 1 79 use `test`; insert into t1 select * from t2
+select * from t1;
+a
+1
+2
drop table t1, t2;
-drop table if exists t1, t2;
create table t1 (a int not null);
create table t2 (a int not null);
insert into t1 values (1);
@@ -567,14 +570,14 @@ a
5
5
insert into t1 select * from t1,t1;
-Not unique table/alias: 't1'
+ERROR 42000: Not unique table/alias: 't1'
drop table t1,t2;
create table t1 (a int not null primary key, b char(10));
create table t2 (a int not null, b char(10));
insert into t1 values (1,"t1:1"),(3,"t1:3");
insert into t2 values (2,"t2:2"), (3,"t2:3");
insert into t1 select * from t2;
-Duplicate entry '3' for key 1
+ERROR 23000: Duplicate entry '3' for key 1
select * from t1;
a b
1 t1:1
diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result
new file mode 100644
index 00000000000..3a7679ce1e3
--- /dev/null
+++ b/mysql-test/r/insert_update.result
@@ -0,0 +1,69 @@
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B));
+INSERT t1 VALUES (1,2,10), (3,4,20);
+INSERT t1 VALUES (5,6,30) ON DUPLICATE KEY UPDATE c=c+100;
+SELECT * FROM t1;
+a b c
+1 2 10
+3 4 20
+5 6 30
+INSERT t1 VALUES (5,7,40) ON DUPLICATE KEY UPDATE c=c+100;
+SELECT * FROM t1;
+a b c
+1 2 10
+3 4 20
+5 6 130
+INSERT t1 VALUES (8,4,50) ON DUPLICATE KEY UPDATE c=c+1000;
+SELECT * FROM t1;
+a b c
+1 2 10
+3 4 1020
+5 6 130
+INSERT t1 VALUES (1,4,60) ON DUPLICATE KEY UPDATE c=c+10000;
+SELECT * FROM t1;
+a b c
+1 2 10010
+3 4 1020
+5 6 130
+INSERT t1 VALUES (1,9,70) ON DUPLICATE KEY UPDATE c=c+100000, b=4;
+ERROR 23000: Duplicate entry '4' for key 2
+SELECT * FROM t1;
+a b c
+1 2 10010
+3 4 1020
+5 6 130
+TRUNCATE TABLE t1;
+INSERT t1 VALUES (1,2,10), (3,4,20);
+INSERT t1 VALUES (5,6,30), (7,4,40), (8,9,60) ON DUPLICATE KEY UPDATE c=c+100;
+SELECT * FROM t1;
+a b c
+1 2 10
+3 4 120
+5 6 30
+8 9 60
+INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0;
+SELECT * FROM t1;
+a b c
+1 2 10
+3 4 120
+5 0 30
+8 9 60
+INSERT t1 VALUES (2,1,11), (7,4,40) ON DUPLICATE KEY UPDATE c=c+VALUES(a);
+SELECT *, VALUES(a) FROM t1;
+a b c VALUES(a)
+1 2 10 NULL
+3 4 127 NULL
+5 0 30 NULL
+8 9 60 NULL
+2 1 11 NULL
+explain extended SELECT *, VALUES(a) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5
+Warnings:
+Note 1003 select high_priority test.t1.a AS `a`,test.t1.b AS `b`,test.t1.c AS `c`,values(test.t1.a) AS `VALUES(a)` from test.t1
+explain extended select * from t1 where values(a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+Warnings:
+Note 1003 select high_priority test.t1.a AS `a`,test.t1.b AS `b`,test.t1.c AS `c` from test.t1
+DROP TABLE t1;
diff --git a/mysql-test/r/isam.result b/mysql-test/r/isam.result
index 680d1d6d322..80d78bc72da 100644
--- a/mysql-test/r/isam.result
+++ b/mysql-test/r/isam.result
@@ -30,14 +30,16 @@ a b c
6 6 6
drop table t1;
create table t1 (a int,b text, index(a)) type=isam;
-Column 'a' is used with UNIQUE or INDEX but is not defined as NOT NULL
+ERROR 42000: Column 'a' is used with UNIQUE or INDEX but is not defined as NOT NULL
create table t1 (a int,b text, index(b)) type=isam;
-BLOB column 'b' can't be used in key specification with the used table type
+ERROR 42000: BLOB column 'b' can't be used in key specification with the used table type
create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=isam;
-Incorrect table definition; There can only be one auto column and it must be defined as a key
+ERROR 42000: Incorrect table definition; There can only be one auto column and it must be defined as a key
create table t1 (ordid int(8), unique (ordid)) type=isam;
-Column 'ordid' is used with UNIQUE or INDEX but is not defined as NOT NULL
+ERROR 42000: Column 'ordid' is used with UNIQUE or INDEX but is not defined as NOT NULL
drop table if exists t1;
+Warnings:
+Note 1051 Unknown table 't1'
create table t1 (a int not null primary key, b int not null,c int not null, key(b,c));
insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4);
create table t2 type=isam select * from t1;
@@ -47,14 +49,14 @@ test.t1 optimize status OK
check table t1,t2;
Table Op Msg_type Msg_text
test.t1 check status OK
-test.t2 check error The handler for the table doesn't support check
+test.t2 check error The storage engine for the table doesn't support check
repair table t1,t2;
Table Op Msg_type Msg_text
test.t1 repair status OK
-test.t2 repair error The handler for the table doesn't support repair
+test.t2 repair error The storage engine for the table doesn't support repair
check table t2,t1;
Table Op Msg_type Msg_text
-test.t2 check error The handler for the table doesn't support check
+test.t2 check error The storage engine for the table doesn't support check
test.t1 check status OK
lock tables t1 write;
check table t2,t1;
@@ -67,10 +69,10 @@ a int(11) PRI 0
b int(11) MUL 0
c int(11) 0
show full columns from t1;
-Field Type Null Key Default Extra Privileges
-a int(11) PRI 0 select,insert,update,references
-b int(11) MUL 0 select,insert,update,references
-c int(11) 0 select,insert,update,references
+Field Type Collation Null Key Default Extra Privileges Comment
+a int(11) NULL PRI 0 select,insert,update,references
+b int(11) NULL MUL 0 select,insert,update,references
+c int(11) NULL 0 select,insert,update,references
show index from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 a A 4 NULL NULL BTREE
diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result
index 039b6e1cba3..24b272a1985 100644
--- a/mysql-test/r/join.result
+++ b/mysql-test/r/join.result
@@ -61,12 +61,12 @@ select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 where t2.id=75
id id
NULL 75
explain select t1.id,t2.id from t2 left join t1 on t1.id>=74 and t1.id<=0 where t2.id=75 and t1.id is null;
-table type possible_keys key key_len ref rows Extra
-t1 const PRIMARY NULL NULL NULL 1 Impossible ON condition
-t2 ALL NULL NULL NULL NULL 3 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const PRIMARY NULL NULL NULL 1 Impossible ON condition
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
explain select t1.id, t2.id from t1, t2 where t2.id = t1.id and t1.id <0 and t1.id > 0;
-Comment
-Impossible WHERE noticed after reading const tables
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
drop table t1,t2;
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
@@ -126,7 +126,7 @@ a
1
2
select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a);
-Too many tables. MySQL can only use XX tables in a join
+ERROR HY000: Too many tables. MySQL can only use XX tables in a join
drop table t1;
CREATE TABLE t1 (
a int(11) NOT NULL,
diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result
index debec01fbdc..3a1f68fb6c1 100644
--- a/mysql-test/r/join_outer.result
+++ b/mysql-test/r/join_outer.result
@@ -90,12 +90,12 @@ grp a c id a c d
2 3 c NULL NULL NULL NULL
NULL NULL NULL NULL NULL NULL
explain select t1.*,t2.* from t1,t2 where t1.a=t2.a and isnull(t2.a)=1;
-Comment
-Impossible WHERE noticed after reading const tables
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 7
-t2 eq_ref PRIMARY PRIMARY 8 t1.a 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 7
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 8 test.t1.a 1 Using where
select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a);
grp a c id a c d a
1 1 a 1 1 a 1 1
@@ -106,11 +106,11 @@ grp a c id a c d a
3 6 D 3 6 C 6 6
NULL NULL NULL NULL NULL NULL NULL
explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a);
-Cross dependency found in OUTER JOIN. Examine your ON conditions
+ERROR 42000: Cross dependency found in OUTER JOIN. Examine your ON conditions
select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a);
-Cross dependency found in OUTER JOIN. Examine your ON conditions
+ERROR 42000: Cross dependency found in OUTER JOIN. Examine your ON conditions
select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a);
-Cross dependency found in OUTER JOIN. Examine your ON conditions
+ERROR 42000: Cross dependency found in OUTER JOIN. Examine your ON conditions
select t1.*,t2.* from t1 inner join t2 using (a);
grp a c id a c d
1 1 a 1 1 a 1
@@ -169,7 +169,7 @@ usr_id uniq_id increment usr2_id c_amount max
3 4 84676 NULL NULL NULL
INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes');
INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes');
-Duplicate entry '2-3' for key 1
+ERROR 23000: Duplicate entry '2-3' for key 1
INSERT INTO t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes');
SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 LEFT JOIN t2 ON t2.id = t1.uniq_id WHERE t1.uniq_id = 4 ORDER BY t2.c_amount;
usr_id uniq_id increment usr2_id c_amount max
@@ -181,7 +181,6 @@ SELECT t1.usr_id,t1.uniq_id,t1.increment,t2.usr2_id,t2.c_amount,t2.max FROM t1 L
usr_id uniq_id increment usr2_id c_amount max
3 4 84676 NULL NULL NULL
drop table t1,t2;
-drop table if exists t1,t2,t3,t4;
CREATE TABLE t1 (
cod_asig int(11) DEFAULT '0' NOT NULL,
desc_larga_cat varchar(80) DEFAULT '' NOT NULL,
@@ -311,13 +310,13 @@ select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where
name name id
Lilliana Angelovska NULL NULL
explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.id is null;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 3
-t2 ALL NULL NULL NULL NULL 3 Using where; Not exists
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Not exists
explain select t1.name, t2.name, t2.id from t1 left join t2 on (t1.id = t2.owner) where t2.name is null;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 3
-t2 ALL NULL NULL NULL NULL 3 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select count(*) from t1 left join t2 on (t1.id = t2.owner);
count(*)
4
@@ -331,13 +330,13 @@ select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where
name name id
Lilliana Angelovska NULL NULL
explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.id is null;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 3
-t2 ALL NULL NULL NULL NULL 3 Using where; Not exists
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where; Not exists
explain select t1.name, t2.name, t2.id from t2 right join t1 on (t1.id = t2.owner) where t2.name is null;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 3
-t2 ALL NULL NULL NULL NULL 3 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where
select count(*) from t2 right join t1 on (t1.id = t2.owner);
count(*)
4
@@ -407,7 +406,7 @@ insert into t3 values (1);
insert into t4 values (1,1);
insert into t5 values (1,1);
explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23;
-Cross dependency found in OUTER JOIN. Examine your ON conditions
+ERROR 42000: Cross dependency found in OUTER JOIN. Examine your ON conditions
drop table t1,t2,t3,t4,t5;
create table t1 (n int, m int, o int, key(n));
create table t2 (n int not null, m int, o int, primary key(n));
@@ -613,9 +612,9 @@ UNIQUE id (id,idx)
);
INSERT INTO t2 VALUES (1,1);
explain SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 2
-t2 ref id id 4 t1.id 1 Using where; Using index; Not exists
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ref id id 4 test.t1.id 1 Using where; Using index; Not exists
SELECT * from t1 left join t2 on t1.id=t2.id where t2.id IS NULL;
id name id idx
2 no NULL NULL
@@ -633,9 +632,9 @@ create table t2 (fooID smallint unsigned not null, barID smallint unsigned not n
insert into t1 (fooID) values (10),(20),(30);
insert into t2 values (10,1),(20,2),(30,3);
explain select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30;
-table type possible_keys key key_len ref rows Extra
-t2 index NULL PRIMARY 4 NULL 3 Using index
-t1 eq_ref PRIMARY PRIMARY 2 const 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL PRIMARY 4 NULL 3 Using index
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 2 const 1 Using where; Using index
select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30;
fooID barID fooID
10 1 NULL
@@ -647,7 +646,6 @@ fooID barID fooID
20 2 NULL
30 3 30
drop table t1,t2;
-drop table if exists t3;
create table t1 (i int);
create table t2 (i int);
create table t3 (i int);
@@ -665,5 +663,5 @@ create table t3 (f3 integer,f5 integer);
select * from t1
left outer join t2 using (f2)
left outer join t3 using (f3);
-Unknown column 'test.t2.f3' in 'on clause'
+ERROR 42S22: Unknown column 'test.t2.f3' in 'on clause'
drop table t1,t2,t3;
diff --git a/mysql-test/r/key.result b/mysql-test/r/key.result
index 31d35a681aa..89deab4bb1f 100644
--- a/mysql-test/r/key.result
+++ b/mysql-test/r/key.result
@@ -1,4 +1,5 @@
drop table if exists t1,t2,t3;
+SET SQL_WARNINGS=1;
CREATE TABLE t1 (
ID CHAR(32) NOT NULL,
name CHAR(32) NOT NULL,
@@ -32,6 +33,11 @@ KEY price (price,area,type,transityes,shopsyes,schoolsyes,petsyes)
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','N','N','N','N');
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','N','N','N','N');
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','','','','');
+Warnings:
+Warning 1264 Data truncated for column 'transityes' at row 1
+Warning 1264 Data truncated for column 'shopsyes' at row 1
+Warning 1264 Data truncated for column 'schoolsyes' at row 1
+Warning 1264 Data truncated for column 'petsyes' at row 1
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y');
@@ -118,7 +124,7 @@ primary key (SEQNO, MOTYPEID, MOINSTANCEID, ATTRID, VALUE )
INSERT INTO t1 VALUES (1, 1, 1, 1, 'a');
INSERT INTO t1 VALUES (1, 1, 1, 1, 'b');
INSERT INTO t1 VALUES (1, 1, 1, 1, 'a');
-Duplicate entry '1-1-1-1-a' for key 1
+ERROR 23000: Duplicate entry '1-1-1-1-a' for key 1
drop table t1;
CREATE TABLE t1 (
a tinytext NOT NULL,
@@ -146,10 +152,12 @@ t1 0 e 1 e A 0 NULL NULL BTREE
t1 0 b 1 b A NULL NULL NULL YES BTREE
t1 1 c 1 c A NULL NULL NULL YES BTREE
drop table t1;
-DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c CHAR(10) NOT NULL,i INT NOT NULL AUTO_INCREMENT,
UNIQUE (c,i));
INSERT INTO t1 (c) VALUES (NULL),(NULL);
+Warnings:
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'c' at row 1
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'c' at row 2
SELECT * FROM t1;
c i
1
diff --git a/mysql-test/r/key_cache.result b/mysql-test/r/key_cache.result
new file mode 100644
index 00000000000..4bc4cad40a4
--- /dev/null
+++ b/mysql-test/r/key_cache.result
@@ -0,0 +1,259 @@
+drop table if exists t1, t2, t3;
+SET @save_key_buffer=@@key_buffer_size;
+SELECT @@key_buffer_size, @@small.key_buffer_size;
+@@key_buffer_size @@small.key_buffer_size
+2097152 131072
+SET @@global.key_buffer_size=16*1024*1024;
+SET @@global.default.key_buffer_size=16*1024*1024;
+SET @@global.default.key_buffer_size=16*1024*1024;
+SET @@global.small.key_buffer_size=1*1024*1024;
+SET @@global.medium.key_buffer_size=4*1024*1024;
+SET @@global.medium.key_buffer_size=0;
+SET @@global.medium.key_buffer_size=0;
+SHOW VARIABLES like "key_buffer_size";
+Variable_name Value
+key_buffer_size 16777216
+SELECT @@key_buffer_size;
+@@key_buffer_size
+16777216
+SELECT @@global.key_buffer_size;
+@@global.key_buffer_size
+16777216
+SELECT @@global.default.key_buffer_size;
+@@global.default.key_buffer_size
+16777216
+SELECT @@global.default.`key_buffer_size`;
+@@global.default.key_buffer_size
+16777216
+SELECT @@global.`default`.`key_buffer_size`;
+@@global.default.key_buffer_size
+16777216
+SELECT @@`default`.key_buffer_size;
+@@default.key_buffer_size
+16777216
+SELECT @@small.key_buffer_size;
+@@small.key_buffer_size
+1048576
+SELECT @@medium.key_buffer_size;
+@@medium.key_buffer_size
+0
+SET @@global.key_buffer_size=@save_key_buffer;
+SELECT @@default.key_buffer_size;
+ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'default.key_buffer_size' at line 1
+SELECT @@skr.table_type="test";
+ERROR HY000: Variable 'table_type' is not a variable component (Can't be used as XXXX.variable_name)
+select @@keycache1.key_cache_block_size;
+@@keycache1.key_cache_block_size
+0
+select @@keycache1.key_buffer_size;
+@@keycache1.key_buffer_size
+0
+set global keycache1.key_cache_block_size=2048;
+select @@keycache1.key_buffer_size;
+@@keycache1.key_buffer_size
+0
+select @@keycache1.key_cache_block_size;
+@@keycache1.key_cache_block_size
+2048
+set global keycache1.key_buffer_size=1*1024*1024;
+select @@keycache1.key_buffer_size;
+@@keycache1.key_buffer_size
+1048576
+select @@keycache1.key_cache_block_size;
+@@keycache1.key_cache_block_size
+2048
+set global keycache2.key_buffer_size=4*1024*1024;
+select @@keycache2.key_buffer_size;
+@@keycache2.key_buffer_size
+4194304
+select @@keycache2.key_cache_block_size;
+@@keycache2.key_cache_block_size
+1024
+set global keycache1.key_buffer_size=0;
+select @@keycache1.key_buffer_size;
+@@keycache1.key_buffer_size
+0
+select @@keycache1.key_cache_block_size;
+@@keycache1.key_cache_block_size
+2048
+select @@key_buffer_size;
+@@key_buffer_size
+2097152
+select @@key_cache_block_size;
+@@key_cache_block_size
+1024
+set global keycache1.key_buffer_size=1024*1024;
+create table t1 (p int primary key, a char(10)) delay_key_write=1;
+create table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a));
+insert into t1 values (1, 'qqqq'), (11, 'yyyy');
+insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'),
+(3, 1, 'yyyy'), (4, 3, 'zzzz');
+select * from t1;
+p a
+1 qqqq
+11 yyyy
+select * from t2;
+p i a
+1 1 qqqq
+2 1 pppp
+3 1 yyyy
+4 3 zzzz
+update t1 set p=2 where p=1;
+update t2 set i=2 where i=1;
+cache index t1 keys (`primary`) in keycache1;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+explain select p from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index
+select p from t1;
+p
+2
+11
+explain select i from t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL k1 5 NULL 4 Using index
+select i from t2;
+i
+2
+2
+2
+3
+explain select count(*) from t1, t2 where t1.p = t2.i;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 2 Using index
+1 SIMPLE t2 ref k1 k1 5 test.t1.p 2 Using where; Using index
+select count(*) from t1, t2 where t1.p = t2.i;
+count(*)
+3
+cache index t2 in keycache1;
+Table Op Msg_type Msg_text
+test.t2 assign_to_keycache status OK
+update t2 set p=p+1000, i=2 where a='qqqq';
+cache index t2 in keycache2;
+Table Op Msg_type Msg_text
+test.t2 assign_to_keycache status OK
+insert into t2 values (2000, 3, 'yyyy');
+cache index t2 in keycache1;
+Table Op Msg_type Msg_text
+test.t2 assign_to_keycache status OK
+update t2 set p=3000 where a='zzzz';
+select * from t2;
+p i a
+1001 2 qqqq
+2 2 pppp
+3 2 yyyy
+3000 3 zzzz
+2000 3 yyyy
+explain select p from t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL PRIMARY 4 NULL 5 Using index
+select p from t2;
+p
+2
+3
+1001
+2000
+3000
+explain select i from t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL k1 5 NULL 5 Using index
+select i from t2;
+i
+2
+2
+2
+3
+3
+explain select a from t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL k2 11 NULL 5 Using index
+select a from t2;
+a
+pppp
+qqqq
+yyyy
+yyyy
+zzzz
+cache index t1 in unknown_key_cache;
+ERROR HY000: Unknown key cache 'unknown_key_cache'
+cache index t1 keys (unknown_key) in keycache1;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache error Key column 'unknown_key' doesn't exist in table
+test.t1 assign_to_keycache status Operation failed
+select @@keycache2.key_buffer_size;
+@@keycache2.key_buffer_size
+4194304
+select @@keycache2.key_cache_block_size;
+@@keycache2.key_cache_block_size
+1024
+set global keycache2.key_buffer_size=0;
+select @@keycache2.key_buffer_size;
+@@keycache2.key_buffer_size
+0
+select @@keycache2.key_cache_block_size;
+@@keycache2.key_cache_block_size
+1024
+set global keycache2.key_buffer_size=1024*1024;
+select @@keycache2.key_buffer_size;
+@@keycache2.key_buffer_size
+1048576
+update t2 set p=4000 where a='zzzz';
+update t1 set p=p+1;
+set global keycache1.key_buffer_size=0;
+select * from t2;
+p i a
+1001 2 qqqq
+2 2 pppp
+3 2 yyyy
+4000 3 zzzz
+2000 3 yyyy
+select p from t2;
+p
+2
+3
+1001
+2000
+4000
+explain select i from t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL k1 5 NULL 5 Using index
+select i from t2;
+i
+2
+2
+2
+3
+3
+explain select a from t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL k2 11 NULL 5 Using index
+select a from t2;
+a
+pppp
+qqqq
+yyyy
+yyyy
+zzzz
+select * from t1;
+p a
+3 qqqq
+12 yyyy
+select p from t1;
+p
+3
+12
+create table t3 (like t1);
+cache index t3 in small;
+Table Op Msg_type Msg_text
+test.t3 assign_to_keycache status OK
+insert into t3 select * from t1;
+cache index t3 in keycache2;
+Table Op Msg_type Msg_text
+test.t3 assign_to_keycache status OK
+cache index t1,t2 in default;
+Table Op Msg_type Msg_text
+test.t1 assign_to_keycache status OK
+test.t2 assign_to_keycache status OK
+drop table t1,t2,t3;
+set global keycache1.key_buffer_size=0;
diff --git a/mysql-test/r/key_diff.result b/mysql-test/r/key_diff.result
index 2d4bc19474f..c3f4f743967 100644
--- a/mysql-test/r/key_diff.result
+++ b/mysql-test/r/key_diff.result
@@ -34,9 +34,9 @@ C c a a
D E a a
a a a a
explain select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B;
-table type possible_keys key key_len ref rows Extra
-t1 ALL a NULL NULL NULL 5
-t2 ALL b NULL NULL NULL 4 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL a NULL NULL NULL 5
+1 SIMPLE t2 ALL b NULL NULL NULL 4 Using where
select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by binary t1.a,t2.a;
a b a b
A B a a
diff --git a/mysql-test/r/key_primary.result b/mysql-test/r/key_primary.result
index 87289f1cf54..14ca90b3dd2 100644
--- a/mysql-test/r/key_primary.result
+++ b/mysql-test/r/key_primary.result
@@ -12,9 +12,9 @@ select * from t1 where t1 like "a_\%";
t1
AB%
describe select * from t1 where t1="ABC";
-table type possible_keys key key_len ref rows Extra
-t1 const PRIMARY PRIMARY 3 const 1
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const PRIMARY PRIMARY 3 const 1
describe select * from t1 where t1="ABCD";
-Comment
-Impossible WHERE noticed after reading const tables
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
drop table t1;
diff --git a/mysql-test/r/keywords.result b/mysql-test/r/keywords.result
index 2ca36425841..c218379110f 100644
--- a/mysql-test/r/keywords.result
+++ b/mysql-test/r/keywords.result
@@ -3,7 +3,7 @@ create table t1 (time time, date date, timestamp timestamp);
insert into t1 values ("12:22:22","97:02:03","1997-01-02");
select * from t1;
time date timestamp
-12:22:22 1997-02-03 19970102000000
+12:22:22 1997-02-03 1997-01-02 00:00:00
select t1.time+0,t1.date+0,t1.timestamp+0,concat(date," ",time) from t1;
t1.time+0 t1.date+0 t1.timestamp+0 concat(date," ",time)
122222 19970203 19970102000000 1997-02-03 12:22:22
diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result
index 0b7925de1c5..d738431e016 100644
--- a/mysql-test/r/loaddata.result
+++ b/mysql-test/r/loaddata.result
@@ -1,6 +1,13 @@
drop table if exists t1;
create table t1 (a date, b date, c date not null, d date);
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',';
+Warnings:
+Warning 1264 Data truncated for column 'a' at row 1
+Warning 1264 Data truncated for column 'c' at row 1
+Warning 1264 Data truncated for column 'd' at row 1
+Warning 1264 Data truncated for column 'a' at row 2
+Warning 1264 Data truncated for column 'b' at row 2
+Warning 1264 Data truncated for column 'd' at row 2
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES;
SELECT * from t1;
a b c d
@@ -10,6 +17,11 @@ a b c d
2003-03-03 2003-03-03 2003-03-03 NULL
truncate table t1;
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d);
+Warnings:
+Warning 1264 Data truncated for column 'c' at row 1
+Warning 1264 Data truncated for column 'd' at row 1
+Warning 1264 Data truncated for column 'b' at row 2
+Warning 1264 Data truncated for column 'd' at row 2
SELECT * from t1;
a b c d
NULL NULL 0000-00-00 0000-00-00
@@ -18,6 +30,8 @@ NULL 2003-03-03 2003-03-03 NULL
drop table t1;
create table t1 (a text, b text);
load data infile '../../std_data/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
+Warnings:
+Warning 1260 Record count is fewer than the column count at row 3
select concat('|',a,'|'), concat('|',b,'|') from t1;
concat('|',a,'|') concat('|',b,'|')
|Field A| |Field B|
diff --git a/mysql-test/r/lock.result b/mysql-test/r/lock.result
index ad5251b9110..68feb9c44d7 100644
--- a/mysql-test/r/lock.result
+++ b/mysql-test/r/lock.result
@@ -8,9 +8,9 @@ NULL 1
update t1 set id=-1 where id=1;
LOCK TABLE t1 READ;
update t1 set id=1 where id=1;
-Table 't1' was locked with a READ lock and can't be updated
+ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
create table t2 SELECT * from t1;
-Table 't2' was not locked with LOCK TABLES
+ERROR HY000: Table 't2' was not locked with LOCK TABLES
create temporary table t2 SELECT * from t1;
drop table if exists t2;
unlock tables;
diff --git a/mysql-test/r/lock_multi.result b/mysql-test/r/lock_multi.result
index b808fca0acf..a0efce727d3 100644
--- a/mysql-test/r/lock_multi.result
+++ b/mysql-test/r/lock_multi.result
@@ -22,5 +22,5 @@ create table t2 (a int);
lock table t1 write, t2 write;
insert t1 select * from t2;
drop table t2;
-Table 'test.t2' doesn't exist
+ERROR 42S02: Table 'test.t2' doesn't exist
drop table t1;
diff --git a/mysql-test/r/lowercase_table.result b/mysql-test/r/lowercase_table.result
index 8edf43a51ad..9c6b212a4b6 100644
--- a/mysql-test/r/lowercase_table.result
+++ b/mysql-test/r/lowercase_table.result
@@ -13,7 +13,8 @@ SELECT T2.id from t1 as T2 LIMIT 1;
id
1
SELECT T2.id from t1 as t2 LIMIT 1;
-Unknown table 'T2' in field list
+id
+1
RENAME TABLE T1 TO T2;
ALTER TABLE T2 ADD new_col int not null;
ALTER TABLE T2 RENAME T3;
@@ -29,7 +30,9 @@ select count(*) from t1;
count(*)
0
select count(T1.a) from t1;
-Unknown table 'T1' in field list
+count(T1.a)
+0
select count(bags.a) from t1 as Bags;
-Unknown table 'bags' in field list
+count(bags.a)
+0
drop table t1;
diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result
index 650fdb1c77b..01635313590 100644
--- a/mysql-test/r/merge.result
+++ b/mysql-test/r/merge.result
@@ -1,4 +1,5 @@
drop table if exists t1,t2,t3,t4,t5,t6;
+drop database if exists mysqltest;
create table t1 (a int not null primary key auto_increment, message char(20));
create table t2 (a int not null primary key auto_increment, message char(20));
INSERT INTO t1 (message) VALUES ("Testing"),("table"),("t1");
@@ -34,11 +35,11 @@ insert into t2 select NULL,message from t1;
insert into t1 select NULL,message from t2;
create table t3 (a int not null, b char(20), key(a)) type=MERGE UNION=(test.t1,test.t2);
explain select * from t3 where a < 10;
-table type possible_keys key key_len ref rows Extra
-t3 range a a 4 NULL 18 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 range a a 4 NULL 18 Using where
explain select * from t3 where a > 10 and a < 20;
-table type possible_keys key key_len ref rows Extra
-t3 range a a 4 NULL 16 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 range a a 4 NULL 16 Using where
select * from t3 where a = 10;
a b
10 Testing
@@ -84,8 +85,8 @@ a b
19 Testing
19 Testing
explain select a from t3 order by a desc limit 10;
-table type possible_keys key key_len ref rows Extra
-t3 index NULL a 4 NULL 1131 Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 index NULL a 4 NULL 1131 Using index
select a from t3 order by a desc limit 10;
a
699
@@ -174,13 +175,26 @@ t3 CREATE TABLE `t3` (
`a` int(11) NOT NULL default '0',
`b` char(20) default NULL,
KEY `a` (`a`)
-) TYPE=MRG_MyISAM UNION=(t1,t2)
+) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`)
create table t4 (a int not null, b char(10), key(a)) type=MERGE UNION=(t1,t2);
select * from t4;
-Can't open file: 't4.MRG'. (errno: 143)
-create table t5 (a int not null, b char(10), key(a)) type=MERGE UNION=(test.t1,test_2.t2);
-Incorrect table definition; All MERGE tables must be in the same database
-drop table if exists t5,t4,t3,t1,t2;
+ERROR HY000: Can't open file: 't4.MRG' (errno: 143)
+alter table t4 add column c int;
+ERROR HY000: Can't open file: 't4.MRG' (errno: 143)
+create database mysqltest;
+create table mysqltest.t6 (a int not null primary key auto_increment, message char(20));
+create table t5 (a int not null, b char(20), key(a)) type=MERGE UNION=(test.t1,mysqltest.t6);
+show create table t5;
+Table Create Table
+t5 CREATE TABLE `t5` (
+ `a` int(11) NOT NULL default '0',
+ `b` char(20) default NULL,
+ KEY `a` (`a`)
+) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`mysqltest`.`t6`)
+alter table t5 type=myisam;
+drop table t5, mysqltest.t6;
+drop database mysqltest;
+drop table t4,t3,t1,t2;
create table t1 (c char(10)) type=myisam;
create table t2 (c char(10)) type=myisam;
create table t3 (c char(10)) union=(t1,t2) type=merge;
@@ -249,20 +263,19 @@ t3 CREATE TABLE `t3` (
`incr` int(11) NOT NULL default '0',
`othr` int(11) NOT NULL default '0',
PRIMARY KEY (`incr`)
-) TYPE=MRG_MyISAM UNION=(t1,t2)
+) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`)
alter table t3 drop primary key;
show create table t3;
Table Create Table
t3 CREATE TABLE `t3` (
`incr` int(11) NOT NULL default '0',
`othr` int(11) NOT NULL default '0'
-) TYPE=MRG_MyISAM UNION=(t1,t2)
+) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`)
drop table t3,t2,t1;
create table t1 (a int not null, key(a)) type=merge;
select * from t1;
a
drop table t1;
-drop table if exists t3, t2, t1;
create table t1 (a int not null, b int not null, key(a,b));
create table t2 (a int not null, b int not null, key(a,b));
create table t3 (a int not null, b int not null, key(a,b)) TYPE=MERGE UNION=(t1,t2);
@@ -274,7 +287,6 @@ a b
1 1
1 2
drop table t3,t1,t2;
-drop table if exists t6, t5, t4, t3, t2, t1;
create table t1 (a int not null, b int not null auto_increment, primary key(a,b));
create table t2 (a int not null, b int not null auto_increment, primary key(a,b));
create table t3 (a int not null, b int not null, key(a,b)) UNION=(t1,t2) INSERT_METHOD=NO;
@@ -287,28 +299,28 @@ t3 CREATE TABLE `t3` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL default '0',
KEY `a` (`a`,`b`)
-) TYPE=MyISAM
+) TYPE=MyISAM DEFAULT CHARSET=latin1
show create table t4;
Table Create Table
t4 CREATE TABLE `t4` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL default '0',
KEY `a` (`a`,`b`)
-) TYPE=MRG_MyISAM UNION=(t1,t2)
+) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`)
show create table t5;
Table Create Table
t5 CREATE TABLE `t5` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL auto_increment,
PRIMARY KEY (`a`,`b`)
-) TYPE=MRG_MyISAM INSERT_METHOD=FIRST UNION=(t1,t2)
+) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=FIRST UNION=(`t1`,`t2`)
show create table t6;
Table Create Table
t6 CREATE TABLE `t6` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL auto_increment,
PRIMARY KEY (`a`,`b`)
-) TYPE=MRG_MyISAM INSERT_METHOD=LAST UNION=(t1,t2)
+) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(`t1`,`t2`)
insert into t1 values (1,NULL),(1,NULL),(1,NULL),(1,NULL);
insert into t2 values (2,NULL),(2,NULL),(2,NULL),(2,NULL);
select * from t3 order by b,a limit 3;
@@ -373,7 +385,7 @@ t4 CREATE TABLE `t4` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL default '0',
KEY `a` (`a`,`b`)
-) TYPE=MRG_MyISAM UNION=(t1,t2,t3)
+) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`,`t3`)
select * from t4 order by a,b;
a b
1 1
@@ -399,7 +411,7 @@ t4 CREATE TABLE `t4` (
`a` int(11) NOT NULL default '0',
`b` int(11) NOT NULL default '0',
KEY `a` (`a`,`b`)
-) TYPE=MRG_MyISAM INSERT_METHOD=FIRST UNION=(t1,t2,t3)
+) TYPE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=FIRST UNION=(`t1`,`t2`,`t3`)
insert into t4 values (4,1),(4,2);
select * from t1 order by a,b;
a b
@@ -528,20 +540,23 @@ a b
6 1
6 2
6 3
-drop table if exists t6, t5, t4, t3, t2, t1;
+insert into t1 values (99,NULL);
+select * from t4 where a+0 > 90;
+a b
+99 1
+drop table t6, t5, t4, t3, t2, t1;
CREATE TABLE t1 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) TYPE=MyISAM;
INSERT INTO t1 VALUES (1,1), (2,1);
CREATE TABLE t2 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) TYPE=MyISAM;
INSERT INTO t2 VALUES (1,2), (2,2);
-CREATE TABLE t ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', KEY a (a,b)) TYPE=MRG_MyISAM UNION=(t1,t2);
-select max(b) from t where a = 2;
+CREATE TABLE t3 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', KEY a (a,b)) TYPE=MRG_MyISAM UNION=(t1,t2);
+select max(b) from t3 where a = 2;
max(b)
2
select max(b) from t1 where a = 2;
max(b)
1
-drop table if exists t,t1,t2;
-drop table if exists t1, t2, t3, t4, t5, t6;
+drop table t3,t1,t2;
create table t1 (a int not null);
create table t2 (a int not null);
insert into t1 values (1);
@@ -560,8 +575,7 @@ select * from t6;
a
1
2
-drop table if exists t1, t2, t3, t4, t5, t6;
-DROP TABLE IF EXISTS t1, t2;
+drop table t6, t3, t1, t2, t4, t5;
CREATE TABLE t1 (
fileset_id tinyint(3) unsigned NOT NULL default '0',
file_code varchar(32) NOT NULL default '',
@@ -581,21 +595,21 @@ KEY files (fileset_id,fileset_root_id)
) TYPE=MRG_MyISAM UNION=(t1);
EXPLAIN SELECT * FROM t2 IGNORE INDEX (files) WHERE fileset_id = 2
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
-table type possible_keys key key_len ref rows Extra
-t2 range PRIMARY PRIMARY 33 NULL 5 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range PRIMARY PRIMARY 33 NULL 5 Using where
EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
-table type possible_keys key key_len ref rows Extra
-t2 range PRIMARY,files PRIMARY 33 NULL 5 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range PRIMARY,files PRIMARY 33 NULL 5 Using where
EXPLAIN SELECT * FROM t1 WHERE fileset_id = 2
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
-table type possible_keys key key_len ref rows Extra
-t1 range PRIMARY,files PRIMARY 33 NULL 5 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY,files PRIMARY 33 NULL 5 Using where
EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
AND file_code = '0000000115' LIMIT 1;
-table type possible_keys key key_len ref rows Extra
-t2 const PRIMARY,files PRIMARY 33 const,const 1
-DROP TABLE IF EXISTS t1, t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 const PRIMARY,files PRIMARY 33 const,const 1
+DROP TABLE t2, t1;
create table t1 (x int, y int, index xy(x, y));
create table t2 (x int, y int, index xy(x, y));
create table t3 (x int, y int, index xy(x, y)) type=merge union=(t1,t2);
diff --git a/mysql-test/r/mix_innodb_myisam_binlog.result b/mysql-test/r/mix_innodb_myisam_binlog.result
index 7b266544c92..d6da3604fd2 100644
--- a/mysql-test/r/mix_innodb_myisam_binlog.result
+++ b/mysql-test/r/mix_innodb_myisam_binlog.result
@@ -8,10 +8,10 @@ insert into t2 select * from t1;
commit;
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 79 Query 1 79 use `test`; BEGIN
-master-bin.001 119 Query 1 79 use `test`; insert into t1 values(1)
-master-bin.001 178 Query 1 79 use `test`; insert into t2 select * from t1
-master-bin.001 244 Query 1 244 use `test`; COMMIT
+master-bin.000001 79 Query 1 79 use `test`; BEGIN
+master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(1)
+master-bin.000001 178 Query 1 79 use `test`; insert into t2 select * from t1
+master-bin.000001 244 Query 1 244 use `test`; COMMIT
delete from t1;
delete from t2;
reset master;
@@ -19,13 +19,14 @@ begin;
insert into t1 values(2);
insert into t2 select * from t1;
rollback;
-Warning: Some non-transactional changed tables couldn't be rolled back
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 79 Query 1 79 use `test`; BEGIN
-master-bin.001 119 Query 1 79 use `test`; insert into t1 values(2)
-master-bin.001 178 Query 1 79 use `test`; insert into t2 select * from t1
-master-bin.001 244 Query 1 244 use `test`; ROLLBACK
+master-bin.000001 79 Query 1 79 use `test`; BEGIN
+master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(2)
+master-bin.000001 178 Query 1 79 use `test`; insert into t2 select * from t1
+master-bin.000001 244 Query 1 244 use `test`; ROLLBACK
delete from t1;
delete from t2;
reset master;
@@ -35,17 +36,18 @@ savepoint my_savepoint;
insert into t1 values(4);
insert into t2 select * from t1;
rollback to savepoint my_savepoint;
-Warning: Some non-transactional changed tables couldn't be rolled back
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
commit;
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 79 Query 1 79 use `test`; BEGIN
-master-bin.001 119 Query 1 79 use `test`; insert into t1 values(3)
-master-bin.001 178 Query 1 79 use `test`; savepoint my_savepoint
-master-bin.001 235 Query 1 79 use `test`; insert into t1 values(4)
-master-bin.001 294 Query 1 79 use `test`; insert into t2 select * from t1
-master-bin.001 360 Query 1 79 use `test`; rollback to savepoint my_savepoint
-master-bin.001 429 Query 1 429 use `test`; COMMIT
+master-bin.000001 79 Query 1 79 use `test`; BEGIN
+master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(3)
+master-bin.000001 178 Query 1 79 use `test`; savepoint my_savepoint
+master-bin.000001 235 Query 1 79 use `test`; insert into t1 values(4)
+master-bin.000001 294 Query 1 79 use `test`; insert into t2 select * from t1
+master-bin.000001 360 Query 1 79 use `test`; rollback to savepoint my_savepoint
+master-bin.000001 429 Query 1 429 use `test`; COMMIT
delete from t1;
delete from t2;
reset master;
@@ -55,7 +57,8 @@ savepoint my_savepoint;
insert into t1 values(6);
insert into t2 select * from t1;
rollback to savepoint my_savepoint;
-Warning: Some non-transactional changed tables couldn't be rolled back
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
insert into t1 values(7);
commit;
select a from t1 order by a;
@@ -64,14 +67,14 @@ a
7
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 79 Query 1 79 use `test`; BEGIN
-master-bin.001 119 Query 1 79 use `test`; insert into t1 values(5)
-master-bin.001 178 Query 1 79 use `test`; savepoint my_savepoint
-master-bin.001 235 Query 1 79 use `test`; insert into t1 values(6)
-master-bin.001 294 Query 1 79 use `test`; insert into t2 select * from t1
-master-bin.001 360 Query 1 79 use `test`; rollback to savepoint my_savepoint
-master-bin.001 429 Query 1 79 use `test`; insert into t1 values(7)
-master-bin.001 488 Query 1 488 use `test`; COMMIT
+master-bin.000001 79 Query 1 79 use `test`; BEGIN
+master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(5)
+master-bin.000001 178 Query 1 79 use `test`; savepoint my_savepoint
+master-bin.000001 235 Query 1 79 use `test`; insert into t1 values(6)
+master-bin.000001 294 Query 1 79 use `test`; insert into t2 select * from t1
+master-bin.000001 360 Query 1 79 use `test`; rollback to savepoint my_savepoint
+master-bin.000001 429 Query 1 79 use `test`; insert into t1 values(7)
+master-bin.000001 488 Query 1 488 use `test`; COMMIT
delete from t1;
delete from t2;
reset master;
@@ -86,10 +89,10 @@ get_lock("a",10)
1
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 79 Query 1 79 use `test`; BEGIN
-master-bin.001 119 Query 1 79 use `test`; insert into t1 values(8)
-master-bin.001 178 Query 1 79 use `test`; insert into t2 select * from t1
-master-bin.001 244 Query 1 244 use `test`; ROLLBACK
+master-bin.000001 79 Query 1 79 use `test`; BEGIN
+master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(8)
+master-bin.000001 178 Query 1 79 use `test`; insert into t2 select * from t1
+master-bin.000001 244 Query 1 244 use `test`; ROLLBACK
delete from t1;
delete from t2;
reset master;
@@ -97,8 +100,8 @@ insert into t1 values(9);
insert into t2 select * from t1;
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 79 Query 1 79 use `test`; insert into t1 values(9)
-master-bin.001 138 Query 1 138 use `test`; insert into t2 select * from t1
+master-bin.000001 79 Query 1 79 use `test`; insert into t1 values(9)
+master-bin.000001 138 Query 1 138 use `test`; insert into t2 select * from t1
delete from t1;
delete from t2;
reset master;
@@ -107,17 +110,17 @@ begin;
insert into t2 select * from t1;
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 79 Query 1 79 use `test`; insert into t1 values(10)
-master-bin.001 139 Query 1 139 use `test`; insert into t2 select * from t1
+master-bin.000001 79 Query 1 79 use `test`; insert into t1 values(10)
+master-bin.000001 139 Query 1 139 use `test`; insert into t2 select * from t1
insert into t1 values(11);
commit;
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 79 Query 1 79 use `test`; insert into t1 values(10)
-master-bin.001 139 Query 1 139 use `test`; insert into t2 select * from t1
-master-bin.001 205 Query 1 205 use `test`; BEGIN
-master-bin.001 245 Query 1 205 use `test`; insert into t1 values(11)
-master-bin.001 305 Query 1 305 use `test`; COMMIT
+master-bin.000001 79 Query 1 79 use `test`; insert into t1 values(10)
+master-bin.000001 139 Query 1 139 use `test`; insert into t2 select * from t1
+master-bin.000001 205 Query 1 205 use `test`; BEGIN
+master-bin.000001 245 Query 1 205 use `test`; insert into t1 values(11)
+master-bin.000001 305 Query 1 305 use `test`; COMMIT
alter table t2 type=INNODB;
delete from t1;
delete from t2;
@@ -128,10 +131,10 @@ insert into t2 select * from t1;
commit;
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 79 Query 1 79 use `test`; BEGIN
-master-bin.001 119 Query 1 79 use `test`; insert into t1 values(12)
-master-bin.001 179 Query 1 79 use `test`; insert into t2 select * from t1
-master-bin.001 245 Query 1 245 use `test`; COMMIT
+master-bin.000001 79 Query 1 79 use `test`; BEGIN
+master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(12)
+master-bin.000001 179 Query 1 79 use `test`; insert into t2 select * from t1
+master-bin.000001 245 Query 1 245 use `test`; COMMIT
delete from t1;
delete from t2;
reset master;
@@ -153,9 +156,9 @@ rollback to savepoint my_savepoint;
commit;
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 79 Query 1 79 use `test`; BEGIN
-master-bin.001 119 Query 1 79 use `test`; insert into t1 values(14)
-master-bin.001 179 Query 1 179 use `test`; COMMIT
+master-bin.000001 79 Query 1 79 use `test`; BEGIN
+master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(14)
+master-bin.000001 179 Query 1 179 use `test`; COMMIT
delete from t1;
delete from t2;
reset master;
@@ -173,8 +176,8 @@ a
18
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 79 Query 1 79 use `test`; BEGIN
-master-bin.001 119 Query 1 79 use `test`; insert into t1 values(16)
-master-bin.001 179 Query 1 79 use `test`; insert into t1 values(18)
-master-bin.001 239 Query 1 239 use `test`; COMMIT
+master-bin.000001 79 Query 1 79 use `test`; BEGIN
+master-bin.000001 119 Query 1 79 use `test`; insert into t1 values(16)
+master-bin.000001 179 Query 1 79 use `test`; insert into t1 values(18)
+master-bin.000001 239 Query 1 239 use `test`; COMMIT
drop table t1,t2;
diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result
index 350cea420b6..b0d597f238a 100644
--- a/mysql-test/r/multi_update.result
+++ b/mysql-test/r/multi_update.result
@@ -96,7 +96,7 @@ id mydate
5 2002-05-12 00:00:00
6 2002-06-22 00:00:00
7 2002-07-22 00:00:00
-DROP TABLE IF EXISTS t1,t2,t3;
+DROP TABLE t1,t2,t3;
CREATE TABLE IF NOT EXISTS `t1` (
`id` int(11) NOT NULL auto_increment,
`tst` text,
@@ -125,7 +125,7 @@ ID ParId tst tst1
1 1 MySQL MySQL AB
2 2 MSSQL Microsoft
3 3 ORACLE ORACLE
-drop table if exists t1, t2 ;
+drop table t1, t2 ;
create table t1 (n numeric(10));
create table t2 (n numeric(10));
insert into t2 values (1),(2),(4),(8),(16),(32);
@@ -147,11 +147,11 @@ insert into t1 values(1,1);
insert into t2 values(1,10),(2,20);
LOCK TABLES t1 write, t2 read;
DELETE t1.*, t2.* FROM t1,t2 where t1.n=t2.n;
-Table 't2' was locked with a READ lock and can't be updated
+ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
-Table 't2' was locked with a READ lock and can't be updated
+ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
-Table 't2' was locked with a READ lock and can't be updated
+ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
unlock tables;
LOCK TABLES t1 write, t2 write;
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
@@ -172,7 +172,7 @@ create table t2 (n int(10), d int(10));
insert into t1 values(1,1);
insert into t2 values(1,10),(2,20);
UPDATE t1,t2 SET t1.d=t2.d WHERE t1.n=t2.n;
-You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
+ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
set sql_safe_updates=0;
drop table t1,t2;
set timestamp=1038401397;
@@ -190,7 +190,7 @@ n d unix_timestamp(t)
1 10 1038401397
2 20 1038401397
UPDATE t1,t2 SET 1=2 WHERE t1.n=t2.n;
-You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '1=2 WHERE t1.n=t2.n' at line 1
+ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '1=2 WHERE t1.n=t2.n' at line 1
drop table t1,t2;
set timestamp=0;
set sql_safe_updates=0;
@@ -235,8 +235,22 @@ select * from t2;
n d
1 30
1 30
+UPDATE t1 a ,t2 b SET a.d=b.d,b.d=30 WHERE a.n=b.n;
+select * from t1;
+n d
+1 30
+3 2
+select * from t2;
+n d
+1 30
+1 30
+DELETE t1, t2 FROM t1 a,t2 b where a.n=b.n;
+select * from t1;
+n d
+3 2
+select * from t2;
+n d
drop table t1,t2;
-drop table if exists t1,t2,t3;
CREATE TABLE t1 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT NULL default 'NEPOZNAT', PRIMARY KEY (broj)) TYPE=MyISAM;
INSERT INTO t1 VALUES (1,'jedan'),(2,'dva'),(3,'tri'),(4,'xxxxxxxxxx'),(5,'a'),(10,''),(11,''),(12,''),(13,'');
CREATE TABLE t2 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT NULL default 'NEPOZNAT', PRIMARY KEY (broj)) TYPE=MyISAM;
@@ -245,7 +259,7 @@ CREATE TABLE t3 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT
INSERT INTO t3 VALUES (1,'jedan'),(2,'dva');
update t1,t2 set t1.naziv="aaaa" where t1.broj=t2.broj;
update t1,t2,t3 set t1.naziv="bbbb", t2.naziv="aaaa" where t1.broj=t2.broj and t2.broj=t3.broj;
-drop table if exists t1,t2,t3;
+drop table t1,t2,t3;
CREATE TABLE t1 (a int not null primary key, b int not null, key (b));
CREATE TABLE t2 (a int not null primary key, b int not null, key (b));
INSERT INTO t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9);
@@ -327,3 +341,25 @@ select t1.a, t1.b,t2.a, t2.b from t1 left join t2 on t1.a=t2.a where t1.b=1 and
a b a b
2 2 NULL NULL
drop table t1,t2;
+create table t1 ( a int not null, b int not null) ;
+alter table t1 add index i1(a);
+delete from t1 where a > 2000000;
+create table t2 like t1;
+insert into t2 select * from t1;
+select 't2 rows before small delete', count(*) from t1;
+t2 rows before small delete count(*)
+t2 rows before small delete 2000000
+delete t1,t2 from t1,t2 where t1.b=t2.a and t1.a < 2;
+select 't2 rows after small delete', count(*) from t2;
+t2 rows after small delete count(*)
+t2 rows after small delete 1999999
+select 't1 rows after small delete', count(*) from t1;
+t1 rows after small delete count(*)
+t1 rows after small delete 1999999
+delete t1,t2 from t1,t2 where t1.b=t2.a and t1.a < 100*1000;
+select 't2 rows after big delete', count(*) from t2;
+t2 rows after big delete count(*)
+t2 rows after big delete 1900001
+select 't1 rows after big delete', count(*) from t1;
+t1 rows after big delete count(*)
+t1 rows after big delete 1900001
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index e113a48f4da..49475c9cbec 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -1,7 +1,8 @@
drop table if exists t1,t2;
+SET SQL_WARNINGS=1;
CREATE TABLE t1 (
STRING_DATA char(255) default NULL,
-KEY STRING_DATA (STRING_DATA)
+KEY string_data (STRING_DATA)
) TYPE=MyISAM;
INSERT INTO t1 VALUES ('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
INSERT INTO t1 VALUES ('DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD');
@@ -51,29 +52,29 @@ drop table t1;
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) type=myisam;
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
explain select * from t1 order by a;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 4 Using filesort
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort
explain select * from t1 order by b;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 4 Using filesort
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort
explain select * from t1 order by c;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 4 Using filesort
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort
explain select a from t1 order by a;
-table type possible_keys key key_len ref rows Extra
-t1 index NULL PRIMARY 4 NULL 4 Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 4 NULL 4 Using index
explain select b from t1 order by b;
-table type possible_keys key key_len ref rows Extra
-t1 index NULL b 4 NULL 4 Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL b 4 NULL 4 Using index
explain select a,b from t1 order by b;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 4 Using filesort
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort
explain select a,b from t1;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 4
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4
explain select a,b,c from t1;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 4
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4
drop table t1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1), (2), (3);
@@ -289,6 +290,12 @@ update t1 set i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
+delete from t1 where i8=1;
+select i1,i2 from t1;
+i1 i2
+check table t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
drop table t1;
CREATE TABLE `t1` (
`post_id` mediumint(8) unsigned NOT NULL auto_increment,
@@ -316,10 +323,10 @@ Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255), KEY t1 (a, b, c));
-Specified key was too long. Max key length is 500
+ERROR 42000: Specified key was too long. Max key length is 500
CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255));
ALTER TABLE t1 ADD INDEX t1 (a, b, c);
-Specified key was too long. Max key length is 500
+ERROR 42000: Specified key was too long. Max key length is 500
DROP TABLE t1;
CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a));
INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), (1,1,4);
@@ -337,31 +344,37 @@ t1 1 a 2 b A 5 NULL NULL YES BTREE
t1 1 c_2 1 c A 5 NULL NULL YES BTREE
t1 1 c_2 2 a A 5 NULL NULL BTREE
explain select * from t1,t2 where t1.a=t2.a;
-table type possible_keys key key_len ref rows Extra
-t2 ALL a NULL NULL NULL 2
-t1 ALL a NULL NULL NULL 4 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL a NULL NULL NULL 2
+1 SIMPLE t1 ALL a NULL NULL NULL 4 Using where
explain select * from t1,t2 force index(a) where t1.a=t2.a;
-table type possible_keys key key_len ref rows Extra
-t2 ALL a NULL NULL NULL 2
-t1 ALL a NULL NULL NULL 4 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL a NULL NULL NULL 2
+1 SIMPLE t1 ALL a NULL NULL NULL 4 Using where
explain select * from t1 force index(a),t2 force index(a) where t1.a=t2.a;
-table type possible_keys key key_len ref rows Extra
-t2 ALL a NULL NULL NULL 2
-t1 ref a a 4 t2.a 3
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL a NULL NULL NULL 2
+1 SIMPLE t1 ref a a 4 test.t2.a 3
explain select * from t1,t2 where t1.b=t2.b;
-table type possible_keys key key_len ref rows Extra
-t2 ALL b NULL NULL NULL 2
-t1 ref b b 5 t2.b 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL b NULL NULL NULL 2
+1 SIMPLE t1 ref b b 5 test.t2.b 1 Using where
explain select * from t1,t2 force index(c) where t1.a=t2.a;
-table type possible_keys key key_len ref rows Extra
-t2 ALL NULL NULL NULL NULL 2
-t1 ALL a NULL NULL NULL 4 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2
+1 SIMPLE t1 ALL a NULL NULL NULL 4 Using where
explain select * from t1 where a=0 or a=2;
-table type possible_keys key key_len ref rows Extra
-t1 ALL a NULL NULL NULL 5 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL a NULL NULL NULL 5 Using where
explain select * from t1 force index (a) where a=0 or a=2;
-table type possible_keys key key_len ref rows Extra
-t1 range a a 4 NULL 4 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 4 NULL 4 Using where
+explain select * from t1 where c=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref c,c_2 c 5 const 1 Using where
+explain select * from t1 use index() where c=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
drop table t1,t2;
create table t1 (a int not null auto_increment primary key, b varchar(255));
insert into t1 (b) values (repeat('a',100)),(repeat('b',100)),(repeat('c',100));
@@ -385,3 +398,25 @@ check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
+CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) TYPE=MyISAM;
+ERROR 42000: This version of MySQL doesn't yet support 'RTREE INDEX'
+create table t1 (a int, b varchar(200), c text not null) checksum=1;
+create table t2 (a int, b varchar(200), c text not null) checksum=0;
+insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
+insert t2 select * from t1;
+checksum table t1, t2, t3 quick;
+Table Checksum
+test.t1 968604391
+test.t2 NULL
+test.t3 NULL
+checksum table t1, t2, t3;
+Table Checksum
+test.t1 968604391
+test.t2 968604391
+test.t3 NULL
+checksum table t1, t2, t3 extended;
+Table Checksum
+test.t1 968604391
+test.t2 968604391
+test.t3 NULL
+drop table t1,t2;
diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result
index eeac31ba40b..92453b3e35b 100644
--- a/mysql-test/r/mysqlbinlog.result
+++ b/mysql-test/r/mysqlbinlog.result
@@ -80,4 +80,4 @@ insert into t1 values ("Alas");
use test;
SET TIMESTAMP=1000000000;
insert into t1 values ("Alas");
-drop table t1;
+drop table t1, t2;
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index 085cf2788f9..4025a01bc93 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -1,17 +1,64 @@
-DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t1, `"t"1`;
CREATE TABLE t1(a int);
INSERT INTO t1 VALUES (1), (2);
<?xml version="1.0"?>
<mysqldump>
<database name="test">
- <table name="t1">
+ <table_structure name="t1">
+ <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
+ </table_structure>
+ <table_data name="t1">
<row>
<field name="a">1</field>
</row>
<row>
<field name="a">2</field>
</row>
- </table>
+ </table_data>
+</database>
+</mysqldump>
+DROP TABLE t1;
+CREATE TABLE t1(a int, b text, c varchar(3));
+INSERT INTO t1 VALUES (1, "test", "tes"), (2, "TEST", "TES");
+<?xml version="1.0"?>
+<mysqldump>
+<database name="test">
+ <table_structure name="t1">
+ <field Field="a" Type="int(11)" Null="YES" Key="" Extra="" />
+ <field Field="b" Type="text" Null="YES" Key="" Extra="" />
+ <field Field="c" Type="char(3)" Null="YES" Key="" Extra="" />
+ </table_structure>
+ <table_data name="t1">
+ <row>
+ <field name="a">1</field>
+ <field name="b">test</field>
+ <field name="c">tes</field>
+ </row>
+ <row>
+ <field name="a">2</field>
+ <field name="b">TEST</field>
+ <field name="c">TES</field>
+ </row>
+ </table_data>
+</database>
+</mysqldump>
+DROP TABLE t1;
+CREATE TABLE t1 (`a"b"` char(2));
+INSERT INTO t1 VALUES ("1\""), ("\"2");
+<?xml version="1.0"?>
+<mysqldump>
+<database name="test">
+ <table_structure name="t1">
+ <field Field="a&quot;b&quot;" Type="char(2)" Null="YES" Key="" Extra="" />
+ </table_structure>
+ <table_data name="t1">
+ <row>
+ <field name="a&quot;b&quot;">1&quot;</field>
+ </row>
+ <row>
+ <field name="a&quot;b&quot;">&quot;2</field>
+ </row>
+ </table_data>
</database>
</mysqldump>
DROP TABLE t1;
diff --git a/mysql-test/r/negation_elimination.result b/mysql-test/r/negation_elimination.result
new file mode 100644
index 00000000000..8ca8ae2f12e
--- /dev/null
+++ b/mysql-test/r/negation_elimination.result
@@ -0,0 +1,382 @@
+drop table if exists t1;
+create table t1 (a int, key (a));
+insert into t1 values (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9),
+(10), (11), (12), (13), (14), (15), (16), (17), (18), (19);
+explain select * from t1 where not(not(a));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 5 NULL 21 Using where; Using index
+select * from t1 where not(not(a));
+a
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+explain select * from t1 where not(not(not(a > 10)));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
+select * from t1 where not(not(not(a > 10)));
+a
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+explain select * from t1 where not(not(not(a < 5) and not(a > 10)));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 5 Using where; Using index
+select * from t1 where not(not(not(a < 5) and not(a > 10)));
+a
+5
+6
+7
+8
+9
+10
+explain select * from t1 where not(a = 10);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 19 Using where; Using index
+select * from t1 where not(a = 10);
+a
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+11
+12
+13
+14
+15
+16
+17
+18
+19
+explain select * from t1 where not(a != 10);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a a 5 const 1 Using where; Using index
+select * from t1 where not(a != 1);
+a
+1
+explain select * from t1 where not(a < 10);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
+select * from t1 where not(a < 10);
+a
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+explain select * from t1 where not(a >= 10);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 9 Using where; Using index
+select * from t1 where not(a >= 10);
+a
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+explain select * from t1 where not(a > 10);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
+select * from t1 where not(a > 10);
+a
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+explain select * from t1 where not(a <= 10);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
+select * from t1 where not(a <= 10);
+a
+11
+12
+13
+14
+15
+16
+17
+18
+19
+explain select * from t1 where not(a is null);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 20 Using where; Using index
+select * from t1 where not(a is null);
+a
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+explain select * from t1 where not(a is not null);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a a 5 const 1 Using where; Using index
+select * from t1 where not(a is not null);
+a
+NULL
+explain select * from t1 where not(a < 5 or a > 15);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
+select * from t1 where not(a < 5 or a > 15);
+a
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+explain select * from t1 where not(a < 15 and a > 5);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 12 Using where; Using index
+select * from t1 where not(a < 15 and a > 5);
+a
+0
+1
+2
+3
+4
+5
+15
+16
+17
+18
+19
+explain select * from t1 where a = 2 or not(a < 10);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 12 Using where; Using index
+select * from t1 where a = 2 or not(a < 10);
+a
+2
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+explain select * from t1 where a > 5 and not(a > 10);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 4 Using where; Using index
+select * from t1 where a > 5 and not(a > 10);
+a
+6
+7
+8
+9
+10
+explain select * from t1 where a > 5 xor a < 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 5 NULL 21 Using where; Using index
+select * from t1 where a > 5 xor a < 10;
+a
+0
+1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+explain select * from t1 where a = 2 or not(a < 5 or a > 15);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
+select * from t1 where a = 2 or not(a < 5 or a > 15);
+a
+2
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+explain select * from t1 where a = 7 or not(a < 15 and a > 5);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 13 Using where; Using index
+select * from t1 where a = 7 or not(a < 15 and a > 5);
+a
+0
+1
+2
+3
+4
+5
+7
+15
+16
+17
+18
+19
+explain select * from t1 where NULL or not(a < 15 and a > 5);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 12 Using where; Using index
+select * from t1 where NULL or not(a < 15 and a > 5);
+a
+0
+1
+2
+3
+4
+5
+15
+16
+17
+18
+19
+explain select * from t1 where not(NULL and a > 5);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 6 Using where; Using index
+select * from t1 where not(NULL and a > 5);
+a
+0
+1
+2
+3
+4
+5
+explain select * from t1 where not(NULL or a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+select * from t1 where not(NULL or a);
+a
+explain select * from t1 where not(NULL and a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 5 NULL 21 Using where; Using index
+select * from t1 where not(NULL and a);
+a
+0
+explain select * from t1 where not((a < 5 or a < 10) and (not(a > 16) or a > 17));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 11 Using where; Using index
+select * from t1 where not((a < 5 or a < 10) and (not(a > 16) or a > 17));
+a
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+explain select * from t1 where not((a < 5 and a < 10) and (not(a > 16) or a > 17));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 15 Using where; Using index
+select * from t1 where not((a < 5 and a < 10) and (not(a > 16) or a > 17));
+a
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+explain select * from t1 where ((a between 5 and 15) and (not(a like 10)));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 10 Using where; Using index
+select * from t1 where ((a between 5 and 15) and (not(a like 10)));
+a
+5
+6
+7
+8
+9
+11
+12
+13
+14
+15
+drop table t1;
diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result
index ba2161d3147..9de9fdce2db 100644
--- a/mysql-test/r/null.result
+++ b/mysql-test/r/null.result
@@ -1,12 +1,18 @@
+drop table if exists t1;
select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null;
NULL NULL isnull(null) isnull(1/0) isnull(1/0 = null) ifnull(null,1) ifnull(null,"TRUE") ifnull("TRUE","ERROR") 1/0 is null 1 is not null
NULL NULL 1 1 1 1 TRUE TRUE 1 1
+explain extended select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority NULL AS `NULL`,NULL AS `NULL`,isnull(NULL) AS `isnull(null)`,isnull((1 / 0)) AS `isnull(1/0)`,isnull(((1 / 0) = NULL)) AS `isnull(1/0 = null)`,ifnull(NULL,1) AS `ifnull(null,1)`,ifnull(NULL,_latin1'TRUE') AS `ifnull(null,"TRUE")`,ifnull(_latin1'TRUE',_latin1'ERROR') AS `ifnull("TRUE","ERROR")`,isnull((1 / 0)) AS `1/0 is null`,(1 is not null) AS `1 is not null`
select 1 | NULL,1 & NULL,1+NULL,1-NULL;
1 | NULL 1 & NULL 1+NULL 1-NULL
NULL NULL NULL NULL
select NULL=NULL,NULL<>NULL,IFNULL(NULL,1.1)+0,IFNULL(NULL,1) | 0;
NULL=NULL NULL<>NULL IFNULL(NULL,1.1)+0 IFNULL(NULL,1) | 0
-NULL NULL 1 1
+NULL NULL 1.1 1
select strcmp("a",NULL),(1<NULL)+0.0,NULL regexp "a",null like "a%","a%" like null;
strcmp("a",NULL) (1<NULL)+0.0 NULL regexp "a" null like "a%" "a%" like null
NULL NULL NULL NULL NULL
@@ -22,6 +28,11 @@ field(NULL,"a","b","c")
select 2 between null and 1,2 between 3 AND NULL,NULL between 1 and 2,2 between NULL and 3, 2 between 1 AND null;
2 between null and 1 2 between 3 AND NULL NULL between 1 and 2 2 between NULL and 3 2 between 1 AND null
0 0 NULL NULL NULL
+explain extended select 2 between null and 1,2 between 3 AND NULL,NULL between 1 and 2,2 between NULL and 3, 2 between 1 AND null;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority (2 between NULL and 1) AS `2 between null and 1`,(2 between 3 and NULL) AS `2 between 3 AND NULL`,(NULL between 1 and 2) AS `NULL between 1 and 2`,(2 between NULL and 3) AS `2 between NULL and 3`,(2 between 1 and NULL) AS `2 between 1 AND null`
SELECT NULL AND NULL, 1 AND NULL, NULL AND 1, NULL OR NULL, 0 OR NULL, NULL OR 0;
NULL AND NULL 1 AND NULL NULL AND 1 NULL OR NULL 0 OR NULL NULL OR 0
NULL NULL NULL NULL NULL NULL
@@ -34,7 +45,11 @@ NULL AND 0 0 and NULL
select inet_ntoa(null),inet_aton(null),inet_aton("122.256"),inet_aton("122.226."),inet_aton("");
inet_ntoa(null) inet_aton(null) inet_aton("122.256") inet_aton("122.226.") inet_aton("")
NULL NULL NULL NULL NULL
-drop table if exists t1;
+explain extended select inet_ntoa(null),inet_aton(null),inet_aton("122.256"),inet_aton("122.226."),inet_aton("");
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority inet_ntoa(NULL) AS `inet_ntoa(null)`,inet_aton(NULL) AS `inet_aton(null)`,inet_aton(_latin1'122.256') AS `inet_aton("122.256")`,inet_aton(_latin1'122.226.') AS `inet_aton("122.226.")`,inet_aton(_latin1'') AS `inet_aton("")`
create table t1 (x int);
insert into t1 values (null);
select * from t1 where x != 0;
@@ -75,28 +90,46 @@ NULL this is null
drop table t1;
CREATE TABLE t1 (a varchar(16) NOT NULL, b smallint(6) NOT NULL, c datetime NOT NULL, d smallint(6) NOT NULL);
INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55";
+Warnings:
+Warning 1264 Data truncated for column 'd' at row 1
UPDATE t1 SET d=1/NULL;
+Warnings:
+Warning 1264 Data truncated for column 'd' at row 1
UPDATE t1 SET d=NULL;
+Warnings:
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'd' at row 1
INSERT INTO t1 (a) values (null);
-Column 'a' cannot be null
+ERROR 23000: Column 'a' cannot be null
INSERT INTO t1 (a) values (1/null);
-Column 'a' cannot be null
+ERROR 23000: Column 'a' cannot be null
INSERT INTO t1 (a) values (null),(null);
+Warnings:
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'a' at row 1
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'a' at row 2
INSERT INTO t1 (b) values (null);
-Column 'b' cannot be null
+ERROR 23000: Column 'b' cannot be null
INSERT INTO t1 (b) values (1/null);
-Column 'b' cannot be null
+ERROR 23000: Column 'b' cannot be null
INSERT INTO t1 (b) values (null),(null);
+Warnings:
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'b' at row 1
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'b' at row 2
INSERT INTO t1 (c) values (null);
-Column 'c' cannot be null
+ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) values (1/null);
-Column 'c' cannot be null
+ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) values (null),(null);
+Warnings:
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'c' at row 1
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'c' at row 2
INSERT INTO t1 (d) values (null);
-Column 'd' cannot be null
+ERROR 23000: Column 'd' cannot be null
INSERT INTO t1 (d) values (1/null);
-Column 'd' cannot be null
+ERROR 23000: Column 'd' cannot be null
INSERT INTO t1 (d) values (null),(null);
+Warnings:
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'd' at row 1
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'd' at row 2
select * from t1;
a b c d
0 0000-00-00 00:00:00 0
diff --git a/mysql-test/r/null_key.result b/mysql-test/r/null_key.result
index 009a3e06eb2..9aaea0d800b 100644
--- a/mysql-test/r/null_key.result
+++ b/mysql-test/r/null_key.result
@@ -1,39 +1,42 @@
-drop table if exists t1;
+drop table if exists t1,t2;
create table t1 (a int, b int not null,unique key (a,b),index(b)) type=myisam;
insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
explain select * from t1 where a is null;
-table type possible_keys key key_len ref rows Extra
-t1 ref a a 5 const 3 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a a 5 const 3 Using where; Using index
explain select * from t1 where a is null and b = 2;
-table type possible_keys key key_len ref rows Extra
-t1 ref a,b a 9 const,const 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a,b a 9 const,const 1 Using where; Using index
explain select * from t1 where a is null and b = 7;
-table type possible_keys key key_len ref rows Extra
-t1 ref a,b a 9 const,const 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a,b a 9 const,const 1 Using where; Using index
explain select * from t1 where a=2 and b = 2;
-table type possible_keys key key_len ref rows Extra
-t1 const a,b a 9 const,const 1
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const a,b a 9 const,const 1
explain select * from t1 where a<=>b limit 2;
-table type possible_keys key key_len ref rows Extra
-t1 index NULL a 9 NULL 12 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 9 NULL 12 Using where; Using index
explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3;
-table type possible_keys key key_len ref rows Extra
-t1 range a,b a 9 NULL 3 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a,b a 9 NULL 3 Using where; Using index
explain select * from t1 where (a is null or a = 7) and b=7;
-table type possible_keys key key_len ref rows Extra
-t1 ref a,b b 4 const 2 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref_or_null a,b a 9 const,const 2 Using where; Using index
+explain select * from t1 where (a is null or a = 7) and b=7 order by a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref_or_null a,b a 9 const,const 2 Using where; Using index; Using filesort
explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
-table type possible_keys key key_len ref rows Extra
-t1 ref a,b a 5 const 3 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a,b a 5 const 3 Using where; Using index
explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
-table type possible_keys key key_len ref rows Extra
-t1 range a,b a 9 NULL 2 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a,b a 9 NULL 2 Using where; Using index
explain select * from t1 where a > 1 and a < 3 limit 1;
-table type possible_keys key key_len ref rows Extra
-t1 range a a 5 NULL 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 1 Using where; Using index
explain select * from t1 where a > 8 and a < 9;
-table type possible_keys key key_len ref rows Extra
-t1 range a a 5 NULL 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 1 Using where; Using index
select * from t1 where a is null;
a b
NULL 7
@@ -56,53 +59,55 @@ NULL 9
NULL 9
select * from t1 where (a is null or a = 7) and b=7;
a b
-NULL 7
7 7
+NULL 7
select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
a b
NULL 7
NULL 9
NULL 9
+create table t2 like t1;
+insert into t2 select * from t1;
alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
explain select * from t1 where a is null and b = 2;
-table type possible_keys key key_len ref rows Extra
-t1 ref a,b a 5 const 3 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a,b a 5 const 3 Using where
explain select * from t1 where a is null and b = 2 and c=0;
-table type possible_keys key key_len ref rows Extra
-t1 ref a,b a 5 const 3 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a,b a 5 const 3 Using where
explain select * from t1 where a is null and b = 7 and c=0;
-table type possible_keys key key_len ref rows Extra
-t1 ref a,b a 5 const 3 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a,b a 5 const 3 Using where
explain select * from t1 where a=2 and b = 2;
-table type possible_keys key key_len ref rows Extra
-t1 ref a,b a 5 const 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a,b a 5 const 1 Using where
explain select * from t1 where a<=>b limit 2;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 12 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 12 Using where
explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 and c=0 limit 3;
-table type possible_keys key key_len ref rows Extra
-t1 range a,b a 5 NULL 5 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a,b a 5 NULL 5 Using where
explain select * from t1 where (a is null or a = 7) and b=7 and c=0;
-table type possible_keys key key_len ref rows Extra
-t1 ALL a,b NULL NULL NULL 12 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref_or_null a,b a 5 const 4 Using where
explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
-table type possible_keys key key_len ref rows Extra
-t1 ref a,b a 5 const 3 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a,b a 5 const 3 Using where
explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
-table type possible_keys key key_len ref rows Extra
-t1 ref a,b a 5 const 3 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a,b a 5 const 3 Using where
explain select * from t1 where a > 1 and a < 3 limit 1;
-table type possible_keys key key_len ref rows Extra
-t1 range a a 5 NULL 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 1 Using where
explain select * from t1 where a is null and b=7 or a > 1 and a < 3 limit 1;
-table type possible_keys key key_len ref rows Extra
-t1 range a,b a 5 NULL 4 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a,b a 5 NULL 4 Using where
explain select * from t1 where a > 8 and a < 9;
-table type possible_keys key key_len ref rows Extra
-t1 range a a 5 NULL 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 5 NULL 1 Using where
explain select * from t1 where b like "6%";
-table type possible_keys key key_len ref rows Extra
-t1 range b b 12 NULL 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range b b 12 NULL 1 Using where
select * from t1 where a is null;
a b c
NULL 7 0
@@ -125,8 +130,8 @@ NULL 9 0
NULL 9 0
select * from t1 where (a is null or a = 7) and b=7 and c=0;
a b c
-NULL 7 0
7 7 0
+NULL 7 0
select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
a b c
NULL 7 0
@@ -136,7 +141,103 @@ select * from t1 where b like "6%";
a b c
6 6 0
drop table t1;
-DROP TABLE IF EXISTS t1,t2;
+rename table t2 to t1;
+alter table t1 modify b int null;
+insert into t1 values (7,null), (8,null), (8,7);
+explain select * from t1 where a = 7 and (b=7 or b is null);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref_or_null a,b a 10 const,const 2 Using where; Using index
+select * from t1 where a = 7 and (b=7 or b is null);
+a b
+7 7
+7 NULL
+explain select * from t1 where (a = 7 or a is null) and (b=7 or b is null);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a,b a 10 NULL 3 Using where; Using index
+select * from t1 where (a = 7 or a is null) and (b=7 or b is null);
+a b
+NULL 7
+7 NULL
+7 7
+explain select * from t1 where (a = 7 or a is null) and (a = 7 or a is null);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref_or_null a a 5 const 5 Using where; Using index
+select * from t1 where (a = 7 or a is null) and (a = 7 or a is null);
+a b
+7 NULL
+7 7
+NULL 7
+NULL 9
+NULL 9
+create table t2 (a int);
+insert into t2 values (7),(8);
+explain select * from t2 straight_join t1 where t1.a=t2.a and b is null;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2
+1 SIMPLE t1 ref a,b a 10 test.t2.a,const 2 Using where; Using index
+drop index b on t1;
+explain select * from t2,t1 where t1.a=t2.a and b is null;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2
+1 SIMPLE t1 ref a a 10 test.t2.a,const 2 Using where; Using index
+select * from t2,t1 where t1.a=t2.a and b is null;
+a a b
+7 7 NULL
+8 8 NULL
+explain select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2
+1 SIMPLE t1 ref_or_null a a 10 test.t2.a,const 4 Using where; Using index
+select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
+a a b
+7 7 7
+7 7 NULL
+8 8 7
+8 8 NULL
+explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2
+1 SIMPLE t1 ref_or_null a a 10 test.t2.a,const 4 Using where; Using index
+select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7;
+a a b
+7 7 7
+7 NULL 7
+8 8 7
+8 NULL 7
+explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2
+1 SIMPLE t1 ref_or_null a a 5 test.t2.a 4 Using where; Using index
+select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null);
+a a b
+7 7 NULL
+7 7 7
+7 NULL 7
+8 8 NULL
+8 8 7
+8 NULL 7
+insert into t2 values (null),(6);
+delete from t1 where a=8;
+explain select * from t2,t1 where t1.a=t2.a or t1.a is null;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4
+1 SIMPLE t1 ref_or_null a a 5 test.t2.a 4 Using where; Using index
+explain select * from t2,t1 where t1.a<=>t2.a or (t1.a is null and t1.b <> 9);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4
+1 SIMPLE t1 ref_or_null a a 5 test.t2.a 4 Using where; Using index
+select * from t2,t1 where t1.a<=>t2.a or (t1.a is null and t1.b <> 9);
+a a b
+7 7 NULL
+7 7 7
+7 NULL 7
+8 NULL 7
+NULL NULL 7
+NULL NULL 9
+NULL NULL 9
+6 6 6
+6 NULL 7
+drop table t1,t2;
CREATE TABLE t1 (
id int(10) unsigned NOT NULL auto_increment,
uniq_id int(10) unsigned default NULL,
@@ -151,11 +252,11 @@ PRIMARY KEY (id)
INSERT INTO t1 VALUES (1,NULL),(2,NULL),(3,1),(4,2),(5,NULL),(6,NULL),(7,3),(8,4),(9,NULL),(10,NULL);
INSERT INTO t2 VALUES (1,NULL),(2,NULL),(3,1),(4,2),(5,NULL),(6,NULL),(7,3),(8,4),(9,NULL),(10,NULL);
explain select id from t1 where uniq_id is null;
-table type possible_keys key key_len ref rows Extra
-t1 ref idx1 idx1 5 const 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref idx1 idx1 5 const 1 Using where
explain select id from t1 where uniq_id =1;
-table type possible_keys key key_len ref rows Extra
-t1 const idx1 idx1 5 const 1
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const idx1 idx1 5 const 1
UPDATE t1 SET id=id+100 where uniq_id is null;
UPDATE t2 SET id=id+100 where uniq_id is null;
select id from t1 where uniq_id is null;
@@ -235,6 +336,8 @@ index (id),
index (id2)
);
insert into t1 values(null,null),(1,1);
+Warnings:
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'id2' at row 1
select * from t1;
id id2
NULL 0
diff --git a/mysql-test/r/odbc.result b/mysql-test/r/odbc.result
index 5aa163a663e..c0b2ada0053 100644
--- a/mysql-test/r/odbc.result
+++ b/mysql-test/r/odbc.result
@@ -1,7 +1,7 @@
+drop table if exists t1;
select {fn length("hello")}, { date "1997-10-20" };
{fn length("hello")} 1997-10-20
5 1997-10-20
-drop table if exists t1;
create table t1 (a int not null auto_increment,b int not null,primary key (a,b));
insert into t1 SET A=NULL,B=1;
insert into t1 SET a=null,b=2;
@@ -11,6 +11,6 @@ a b
select * from t1 where a is null;
a b
explain select * from t1 where b is null;
-Comment
-Impossible WHERE noticed after reading const tables
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
drop table t1;
diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result
index 52bd83df5ed..37e68d8b13e 100644
--- a/mysql-test/r/olap.result
+++ b/mysql-test/r/olap.result
@@ -1,27 +1,273 @@
-drop table if exists sales;
-create table sales ( product varchar(32), country varchar(32), year int, profit int);
-insert into sales values ( 'Computer', 'India',2000, 1200),
-( 'TV', 'United States', 1999, 150),
-( 'Calculator', 'United States', 1999,50),
-( 'Computer', 'United States', 1999,1500),
-( 'Computer', 'United States', 2000,1500),
-( 'TV', 'United States', 2000, 150),
-( 'TV', 'India', 2000, 100),
-( 'TV', 'India', 2000, 100),
-( 'Calculator', 'United States', 2000,75),
-( 'Calculator', 'India', 2000,75),
-( 'TV', 'India', 1999, 100),
-( 'Computer', 'India', 1999,1200),
-( 'Computer', 'United States', 2000,1500),
-( 'Calculator', 'United States', 2000,75);
-select product, country , year, sum(profit) from sales group by product, country, year with cube;
-This version of MySQL doesn't yet support 'CUBE'
-explain select product, country , year, sum(profit) from sales group by product, country, year with cube;
-This version of MySQL doesn't yet support 'CUBE'
-select product, country , year, sum(profit) from sales group by product, country, year with rollup;
-This version of MySQL doesn't yet support 'ROLLUP'
-explain select product, country , year, sum(profit) from sales group by product, country, year with rollup;
-This version of MySQL doesn't yet support 'ROLLUP'
-select product, country , year, sum(profit) from sales group by product, country, year with cube union all select product, country , year, sum(profit) from sales group by product, country, year with rollup;
-This version of MySQL doesn't yet support 'CUBE'
-drop table sales;
+drop table if exists t1,t2;
+create table t1 (product varchar(32), country_id int not null, year int, profit int);
+insert into t1 values ( 'Computer', 2,2000, 1200),
+( 'TV', 1, 1999, 150),
+( 'Calculator', 1, 1999,50),
+( 'Computer', 1, 1999,1500),
+( 'Computer', 1, 2000,1500),
+( 'TV', 1, 2000, 150),
+( 'TV', 2, 2000, 100),
+( 'TV', 2, 2000, 100),
+( 'Calculator', 1, 2000,75),
+( 'Calculator', 2, 2000,75),
+( 'TV', 1, 1999, 100),
+( 'Computer', 1, 1999,1200),
+( 'Computer', 2, 2000,1500),
+( 'Calculator', 2, 2000,75),
+( 'Phone', 3, 2003,10)
+;
+create table t2 (country_id int primary key, country char(20) not null);
+insert into t2 values (1, 'USA'),(2,'India'), (3,'Finland');
+select product, sum(profit) from t1 group by product;
+product sum(profit)
+Calculator 275
+Computer 6900
+Phone 10
+TV 600
+select product, sum(profit) from t1 group by product with rollup;
+product sum(profit)
+Calculator 275
+Computer 6900
+Phone 10
+TV 600
+NULL 7785
+select product, sum(profit) from t1 group by 1 with rollup;
+product sum(profit)
+Calculator 275
+Computer 6900
+Phone 10
+TV 600
+NULL 7785
+select product, sum(profit),avg(profit) from t1 group by product with rollup;
+product sum(profit) avg(profit)
+Calculator 275 68.7500
+Computer 6900 1380.0000
+Phone 10 10.0000
+TV 600 120.0000
+NULL 7785 519.0000
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year;
+product country_id year sum(profit)
+Calculator 1 1999 50
+Calculator 1 2000 75
+Calculator 2 2000 150
+Computer 1 1999 2700
+Computer 1 2000 1500
+Computer 2 2000 2700
+Phone 3 2003 10
+TV 1 1999 250
+TV 1 2000 150
+TV 2 2000 200
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup;
+product country_id year sum(profit)
+Calculator 1 1999 50
+Calculator 1 2000 75
+Calculator 1 NULL 125
+Calculator 2 2000 150
+Calculator 2 NULL 150
+Calculator NULL NULL 275
+Computer 1 1999 2700
+Computer 1 2000 1500
+Computer 1 NULL 4200
+Computer 2 2000 2700
+Computer 2 NULL 2700
+Computer NULL NULL 6900
+Phone 3 2003 10
+Phone 3 NULL 10
+Phone NULL NULL 10
+TV 1 1999 250
+TV 1 2000 150
+TV 1 NULL 400
+TV 2 2000 200
+TV 2 NULL 200
+TV NULL NULL 600
+NULL NULL NULL 7785
+explain extended select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 15 Using temporary; Using filesort
+Warnings:
+Note 1003 select high_priority test.t1.product AS `product`,test.t1.country_id AS `country_id`,test.t1.year AS `year`,sum(test.t1.profit) AS `sum(profit)` from test.t1 group by test.t1.product,test.t1.country_id,test.t1.year with rollup
+select product, country_id , sum(profit) from t1 group by product desc, country_id with rollup;
+product country_id sum(profit)
+TV 1 400
+TV 2 200
+TV NULL 600
+Phone 3 10
+Phone NULL 10
+Computer 1 4200
+Computer 2 2700
+Computer NULL 6900
+Calculator 1 125
+Calculator 2 150
+Calculator NULL 275
+NULL NULL 7785
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup limit 5;
+product country_id year sum(profit)
+Calculator 1 1999 50
+Calculator 1 2000 75
+Calculator 1 NULL 125
+Calculator 2 2000 150
+Calculator 2 NULL 150
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup limit 3,3;
+product country_id year sum(profit)
+Calculator 2 2000 150
+Calculator 2 NULL 150
+Calculator NULL NULL 275
+select product, country_id, count(*), count(distinct year) from t1 group by product, country_id;
+product country_id count(*) count(distinct year)
+Calculator 1 2 2
+Calculator 2 2 1
+Computer 1 3 2
+Computer 2 2 1
+Phone 3 1 1
+TV 1 3 2
+TV 2 2 1
+select product, country_id, count(*), count(distinct year) from t1 group by product, country_id with rollup;
+product country_id count(*) count(distinct year)
+Calculator 1 2 2
+Calculator 2 2 1
+Calculator NULL 4 2
+Computer 1 3 2
+Computer 2 2 1
+Computer NULL 5 2
+Phone 3 1 1
+Phone NULL 1 1
+TV 1 3 2
+TV 2 2 1
+TV NULL 5 2
+NULL NULL 15 3
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup having country_id = 1;
+product country_id year sum(profit)
+Calculator 1 1999 50
+Calculator 1 2000 75
+Calculator 1 NULL 125
+Computer 1 1999 2700
+Computer 1 2000 1500
+Computer 1 NULL 4200
+TV 1 1999 250
+TV 1 2000 150
+TV 1 NULL 400
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup having sum(profit) > 200;
+product country_id year sum(profit)
+Calculator NULL NULL 275
+Computer 1 1999 2700
+Computer 1 2000 1500
+Computer 1 NULL 4200
+Computer 2 2000 2700
+Computer 2 NULL 2700
+Computer NULL NULL 6900
+TV 1 1999 250
+TV 1 NULL 400
+TV NULL NULL 600
+NULL NULL NULL 7785
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup having sum(profit) > 7000;
+product country_id year sum(profit)
+NULL NULL NULL 7785
+select concat(product,':',country_id) as 'prod', concat(":",year,":") as 'year',1+1, sum(profit)/count(*) from t1 group by 1,2 with rollup;
+prod year 1+1 sum(profit)/count(*)
+Calculator:1 :1999: 2 50.00
+Calculator:1 :2000: 2 75.00
+Calculator:1 NULL 2 62.50
+Calculator:2 :2000: 2 75.00
+Calculator:2 NULL 2 75.00
+Computer:1 :1999: 2 1350.00
+Computer:1 :2000: 2 1500.00
+Computer:1 NULL 2 1400.00
+Computer:2 :2000: 2 1350.00
+Computer:2 NULL 2 1350.00
+Phone:3 :2003: 2 10.00
+Phone:3 NULL 2 10.00
+TV:1 :1999: 2 125.00
+TV:1 :2000: 2 150.00
+TV:1 NULL 2 133.33
+TV:2 :2000: 2 100.00
+TV:2 NULL 2 100.00
+NULL NULL 2 519.00
+select product, sum(profit)/count(*) from t1 group by product with rollup;
+product sum(profit)/count(*)
+Calculator 68.75
+Computer 1380.00
+Phone 10.00
+TV 120.00
+NULL 519.00
+select left(product,4) as prod, sum(profit)/count(*) from t1 group by prod with rollup;
+prod sum(profit)/count(*)
+Calc 68.75
+Comp 1380.00
+Phon 10.00
+TV 120.00
+NULL 519.00
+select concat(product,':',country_id), 1+1, sum(profit)/count(*) from t1 group by concat(product,':',country_id) with rollup;
+concat(product,':',country_id) 1+1 sum(profit)/count(*)
+Calculator:1 2 62.50
+Calculator:2 2 75.00
+Computer:1 2 1400.00
+Computer:2 2 1350.00
+Phone:3 2 10.00
+TV:1 2 133.33
+TV:2 2 100.00
+NULL 2 519.00
+select product, country , year, sum(profit) from t1,t2 where t1.country_id=t2.country_id group by product, country, year with rollup;
+product country year sum(profit)
+Calculator India 2000 150
+Calculator India NULL 150
+Calculator USA 1999 50
+Calculator USA 2000 75
+Calculator USA NULL 125
+Calculator NULL NULL 275
+Computer India 2000 2700
+Computer India NULL 2700
+Computer USA 1999 2700
+Computer USA 2000 1500
+Computer USA NULL 4200
+Computer NULL NULL 6900
+Phone Finland 2003 10
+Phone Finland NULL 10
+Phone NULL NULL 10
+TV India 2000 200
+TV India NULL 200
+TV USA 1999 250
+TV USA 2000 150
+TV USA NULL 400
+TV NULL NULL 600
+NULL NULL NULL 7785
+select product, `sum` from (select product, sum(profit) as 'sum' from t1 group by product with rollup) as tmp where product is null;
+product sum
+NULL 7785
+select product from t1 where exists (select product, country_id , sum(profit) from t1 as t2 where t1.product=t2.product group by product, country_id with rollup having sum(profit) > 6000);
+product
+Computer
+Computer
+Computer
+Computer
+Computer
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year having country_id is NULL;
+product country_id year sum(profit)
+select concat(':',product,':'), sum(profit),avg(profit) from t1 group by product with rollup;
+concat(':',product,':') sum(profit) avg(profit)
+:Calculator: 275 68.7500
+:Computer: 6900 1380.0000
+:Phone: 10 10.0000
+:TV: 600 120.0000
+:TV: 7785 519.0000
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube;
+ERROR 42000: This version of MySQL doesn't yet support 'CUBE'
+explain select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube;
+ERROR 42000: This version of MySQL doesn't yet support 'CUBE'
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube union all select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup;
+ERROR 42000: This version of MySQL doesn't yet support 'CUBE'
+drop table t1,t2;
+CREATE TABLE t1 (i int);
+INSERT INTO t1 VALUES(100);
+CREATE TABLE t2 (i int);
+INSERT INTO t2 VALUES (100),(200);
+SELECT i, COUNT(*) FROM t1 GROUP BY i WITH ROLLUP;
+i COUNT(*)
+100 1
+NULL 1
+SELECT t1.i, t2.i, COUNT(*) FROM t1,t2 GROUP BY t1.i,t2.i WITH ROLLUP;
+i i COUNT(*)
+100 100 1
+100 200 1
+100 NULL 2
+NULL NULL 2
+drop table t1,t2;
diff --git a/mysql-test/r/openssl_1.result b/mysql-test/r/openssl_1.result
index f6c7bf5bc79..4cf6bee6123 100644
--- a/mysql-test/r/openssl_1.result
+++ b/mysql-test/r/openssl_1.result
@@ -10,22 +10,22 @@ select * from t1;
f1
5
delete from t1;
-Access denied for user: 'ssl_user1@localhost' to database 'test'
+ERROR 42000: Access denied for user: 'ssl_user1'@'localhost' to database 'test'
select * from t1;
f1
5
delete from t1;
-Access denied for user: 'ssl_user2@localhost' to database 'test'
+ERROR 42000: Access denied for user: 'ssl_user2'@'localhost' to database 'test'
select * from t1;
f1
5
delete from t1;
-Access denied for user: 'ssl_user3@localhost' to database 'test'
+ERROR 42000: Access denied for user: 'ssl_user3'@'localhost' to database 'test'
select * from t1;
f1
5
delete from t1;
-Access denied for user: 'ssl_user4@localhost' to database 'test'
+ERROR 42000: Access denied for user: 'ssl_user4'@'localhost' to database 'test'
delete from mysql.user where user='ssl_user%';
delete from mysql.db where user='ssl_user%';
flush privileges;
diff --git a/mysql-test/r/openssl_2.result b/mysql-test/r/openssl_2.result
index b5c67dfbcb0..879c623dd40 100644
--- a/mysql-test/r/openssl_2.result
+++ b/mysql-test/r/openssl_2.result
@@ -1,2 +1,25 @@
-SHOW STATUS LIKE 'SSL%';
+SHOW STATUS LIKE 'Ssl%';
Variable_name Value
+Ssl_accepts 1
+Ssl_finished_accepts 1
+Ssl_finished_connects 0
+Ssl_accept_renegotiates 0
+Ssl_connect_renegotiates 0
+Ssl_callback_cache_hits 0
+Ssl_session_cache_hits 0
+Ssl_session_cache_misses 0
+Ssl_session_cache_timeouts 0
+Ssl_used_session_cache_entries 1
+Ssl_client_connects 0
+Ssl_session_cache_overflows 0
+Ssl_session_cache_size 128
+Ssl_session_cache_mode SERVER
+Ssl_sessions_reused 0
+Ssl_ctx_verify_mode 7
+Ssl_ctx_verify_depth 4294967295
+Ssl_verify_mode 7
+Ssl_verify_depth 4294967295
+Ssl_version TLSv1
+Ssl_cipher EDH-RSA-DES-CBC3-SHA
+Ssl_cipher_list
+Ssl_default_timeout 7200
diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result
index 076c80035b2..db747e3a7eb 100644
--- a/mysql-test/r/order_by.result
+++ b/mysql-test/r/order_by.result
@@ -222,7 +222,6 @@ DateOfAction TransactionID
1999-07-27 834
1999-07-27 840
drop table t1,t2,t3;
-drop table if exists t1;
CREATE TABLE t1 (
member_id int(11) NOT NULL auto_increment,
inschrijf_datum varchar(20) NOT NULL default '',
@@ -263,14 +262,14 @@ drop table t1;
create table t1 (a int not null, b int, c varchar(10), key (a, b, c));
insert into t1 values (1, NULL, NULL), (1, NULL, 'b'), (1, 1, NULL), (1, 1, 'b'), (1, 1, 'b'), (2, 1, 'a'), (2, 1, 'b'), (2, 2, 'a'), (2, 2, 'b'), (2, 3, 'c'),(1,3,'b');
explain select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc;
-table type possible_keys key key_len ref rows Extra
-t1 range a a 20 NULL 2 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 20 NULL 2 Using where; Using index
select * from t1 where (a = 1 and b is null and c = 'b') or (a > 2) order by a desc;
a b c
1 NULL b
explain select * from t1 where a >= 1 and a < 3 order by a desc;
-table type possible_keys key key_len ref rows Extra
-t1 range a a 4 NULL 10 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 4 NULL 10 Using where; Using index
select * from t1 where a >= 1 and a < 3 order by a desc;
a b c
2 3 c
@@ -285,8 +284,8 @@ a b c
1 NULL b
1 NULL NULL
explain select * from t1 where a = 1 order by a desc, b desc;
-table type possible_keys key key_len ref rows Extra
-t1 ref a a 4 const 5 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a a 4 const 5 Using where; Using index
select * from t1 where a = 1 order by a desc, b desc;
a b c
1 3 b
@@ -296,34 +295,34 @@ a b c
1 NULL b
1 NULL NULL
explain select * from t1 where a = 1 and b is null order by a desc, b desc;
-table type possible_keys key key_len ref rows Extra
-t1 ref a a 9 const,const 2 Using where; Using index; Using filesort
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a a 9 const,const 2 Using where; Using index; Using filesort
select * from t1 where a = 1 and b is null order by a desc, b desc;
a b c
1 NULL NULL
1 NULL b
explain select * from t1 where a >= 1 and a < 3 and b >0 order by a desc,b desc;
-table type possible_keys key key_len ref rows Extra
-t1 range a a 9 NULL 8 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 9 NULL 8 Using where; Using index
explain select * from t1 where a = 2 and b >0 order by a desc,b desc;
-table type possible_keys key key_len ref rows Extra
-t1 range a a 9 NULL 4 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 9 NULL 5 Using where; Using index
explain select * from t1 where a = 2 and b is null order by a desc,b desc;
-table type possible_keys key key_len ref rows Extra
-t1 ref a a 9 const,const 1 Using where; Using index; Using filesort
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a a 9 const,const 1 Using where; Using index; Using filesort
explain select * from t1 where a = 2 and (b is null or b > 0) order by a
desc,b desc;
-table type possible_keys key key_len ref rows Extra
-t1 range a a 9 NULL 5 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 9 NULL 6 Using where; Using index
explain select * from t1 where a = 2 and b > 0 order by a desc,b desc;
-table type possible_keys key key_len ref rows Extra
-t1 range a a 9 NULL 4 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 9 NULL 5 Using where; Using index
explain select * from t1 where a = 2 and b < 2 order by a desc,b desc;
-table type possible_keys key key_len ref rows Extra
-t1 range a a 9 NULL 2 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 9 NULL 2 Using where; Using index
explain select * from t1 where a = 1 order by b desc;
-table type possible_keys key key_len ref rows Extra
-t1 ref a a 4 const 5 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref a a 4 const 5 Using where; Using index
select * from t1 where a = 1 order by b desc;
a b c
1 3 b
@@ -333,9 +332,14 @@ a b c
1 NULL b
1 NULL NULL
alter table t1 modify b int not null, modify c varchar(10) not null;
+Warnings:
+Warning 1264 Data truncated for column 'b' at row 1
+Warning 1264 Data truncated for column 'c' at row 1
+Warning 1264 Data truncated for column 'b' at row 2
+Warning 1264 Data truncated for column 'c' at row 3
explain select * from t1 order by a, b, c;
-table type possible_keys key key_len ref rows Extra
-t1 index NULL a 18 NULL 11 Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 18 NULL 11 Using index
select * from t1 order by a, b, c;
a b c
1 0
@@ -350,8 +354,8 @@ a b c
2 2 b
2 3 c
explain select * from t1 order by a desc, b desc, c desc;
-table type possible_keys key key_len ref rows Extra
-t1 index NULL a 18 NULL 11 Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 18 NULL 11 Using index
select * from t1 order by a desc, b desc, c desc;
a b c
2 3 c
@@ -366,15 +370,15 @@ a b c
1 0 b
1 0
explain select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc;
-table type possible_keys key key_len ref rows Extra
-t1 range a a 18 NULL 3 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 18 NULL 3 Using where; Using index
select * from t1 where (a = 1 and b = 1 and c = 'b') or (a > 2) order by a desc;
a b c
1 1 b
1 1 b
explain select * from t1 where a < 2 and b <= 1 order by a desc, b desc;
-table type possible_keys key key_len ref rows Extra
-t1 range a a 4 NULL 6 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 4 NULL 6 Using where; Using index
select * from t1 where a < 2 and b <= 1 order by a desc, b desc;
a b c
1 1 b
@@ -397,8 +401,8 @@ a b c
1 1 b
1 1
explain select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc;
-table type possible_keys key key_len ref rows Extra
-t1 range a a 8 NULL 10 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 8 NULL 10 Using where; Using index
select * from t1 where a between 1 and 3 and b <= 1 order by a desc, b desc;
a b c
2 1 b
@@ -409,8 +413,8 @@ a b c
1 0 b
1 0
explain select * from t1 where a between 0 and 1 order by a desc, b desc;
-table type possible_keys key key_len ref rows Extra
-t1 range a a 4 NULL 5 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a a 4 NULL 5 Using where; Using index
select * from t1 where a between 0 and 1 order by a desc, b desc;
a b c
1 3 b
@@ -460,27 +464,27 @@ gid sid uid
104505 5 117
103853 5 250
EXPLAIN select t1.gid, t2.sid, t3.uid from t3, t2, t1 where t2.gid = t1.gid and t2.uid = t3.uid order by t1.gid, t3.uid;
-table type possible_keys key key_len ref rows Extra
-t1 index PRIMARY PRIMARY 4 NULL 6 Using index
-t2 eq_ref PRIMARY,uid PRIMARY 4 t1.gid 1
-t3 eq_ref PRIMARY PRIMARY 2 t2.uid 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 6 Using index
+1 SIMPLE t2 eq_ref PRIMARY,uid PRIMARY 4 test.t1.gid 1
+1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 test.t2.uid 1 Using where; Using index
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t1.gid,t3.skr;
-table type possible_keys key key_len ref rows Extra
-t3 ALL PRIMARY NULL NULL NULL 6 Using temporary; Using filesort
-t1 eq_ref PRIMARY PRIMARY 4 t3.uid 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 ALL PRIMARY NULL NULL NULL 6 Using temporary; Using filesort
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t3.uid 1 Using where; Using index
EXPLAIN SELECT t1.gid, t2.sid, t3.uid from t2, t1, t3 where t2.gid = t1.gid and t2.uid = t3.uid order by t3.uid, t1.gid;
-table type possible_keys key key_len ref rows Extra
-t1 index PRIMARY PRIMARY 4 NULL 6 Using index; Using temporary; Using filesort
-t2 eq_ref PRIMARY,uid PRIMARY 4 t1.gid 1
-t3 eq_ref PRIMARY PRIMARY 2 t2.uid 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 4 NULL 6 Using index; Using temporary; Using filesort
+1 SIMPLE t2 eq_ref PRIMARY,uid PRIMARY 4 test.t1.gid 1
+1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 test.t2.uid 1 Using where; Using index
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.gid = t3.uid order by t3.skr,t1.gid;
-table type possible_keys key key_len ref rows Extra
-t3 ALL PRIMARY NULL NULL NULL 6 Using temporary; Using filesort
-t1 eq_ref PRIMARY PRIMARY 4 t3.uid 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 ALL PRIMARY NULL NULL NULL 6 Using temporary; Using filesort
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t3.uid 1 Using where; Using index
EXPLAIN SELECT t1.gid, t3.uid from t1, t3 where t1.skr = t3.uid order by t1.gid,t3.skr;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
-t3 eq_ref PRIMARY PRIMARY 2 t1.skr 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort
+1 SIMPLE t3 eq_ref PRIMARY PRIMARY 2 test.t1.skr 1 Using where
drop table t1,t2,t3;
CREATE TABLE t1 (
`titre` char(80) NOT NULL default '',
@@ -542,3 +546,37 @@ a b
1 2
5 NULL
DROP TABLE t1;
+CREATE TABLE t1 (
+FieldKey varchar(36) NOT NULL default '',
+LongVal bigint(20) default NULL,
+StringVal mediumtext,
+KEY FieldKey (FieldKey),
+KEY LongField (FieldKey,LongVal),
+KEY StringField (FieldKey,StringVal(32))
+);
+INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3');
+EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref FieldKey,LongField,StringField LongField 36 const 3 Using where
+SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
+FieldKey LongVal StringVal
+1 0 2
+1 1 3
+1 2 1
+EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range FieldKey,LongField,StringField FieldKey 36 NULL 4 Using where; Using filesort
+SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal;
+FieldKey LongVal StringVal
+3 1 2
+3 2 1
+3 3 3
+EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range FieldKey,LongField,StringField LongField 36 NULL 4 Using where
+SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
+FieldKey LongVal StringVal
+3 1 2
+3 2 1
+3 3 3
+DROP TABLE t1;
diff --git a/mysql-test/r/packet.result b/mysql-test/r/packet.result
index 6733f2b142e..5729d7af166 100644
--- a/mysql-test/r/packet.result
+++ b/mysql-test/r/packet.result
@@ -12,7 +12,7 @@ select @@net_buffer_length, @@max_allowed_packet;
@@net_buffer_length @@max_allowed_packet
1024 1024
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
-Got a packet bigger than 'max_allowed_packet'
+ERROR 08S01: Got a packet bigger than 'max_allowed_packet'
set global max_allowed_packet=default;
set max_allowed_packet=default;
set global net_buffer_length=default;
diff --git a/mysql-test/r/preload.result b/mysql-test/r/preload.result
new file mode 100644
index 00000000000..bd7b828d5b9
--- /dev/null
+++ b/mysql-test/r/preload.result
@@ -0,0 +1,167 @@
+drop table if exists t1, t2;
+create table t1 (
+a int not null auto_increment,
+b char(16) not null,
+primary key (a),
+key (b)
+);
+create table t2(
+a int not null auto_increment,
+b char(16) not null,
+primary key (a),
+key (b)
+);
+insert into t1(b) values
+('test0'),
+('test1'),
+('test2'),
+('test3'),
+('test4'),
+('test5'),
+('test6'),
+('test7');
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+select count(*) from t1;
+count(*)
+33448
+select count(*) from t2;
+count(*)
+20672
+flush tables;
+flush status;
+show status like "key_read%";
+Variable_name Value
+Key_read_requests 0
+Key_reads 0
+select count(*) from t1 where b = 'test1';
+count(*)
+4181
+show status like "key_read%";
+Variable_name Value
+Key_read_requests 217
+Key_reads 45
+select count(*) from t1 where b = 'test1';
+count(*)
+4181
+show status like "key_read%";
+Variable_name Value
+Key_read_requests 434
+Key_reads 45
+flush tables;
+flush status;
+select @@preload_buffer_size;
+@@preload_buffer_size
+32768
+load index into cache t1;
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+show status like "key_read%";
+Variable_name Value
+Key_read_requests 0
+Key_reads 0
+select count(*) from t1 where b = 'test1';
+count(*)
+4181
+show status like "key_read%";
+Variable_name Value
+Key_read_requests 217
+Key_reads 45
+flush tables;
+flush status;
+show status like "key_read%";
+Variable_name Value
+Key_read_requests 0
+Key_reads 0
+set session preload_buffer_size=256*1024;
+select @@preload_buffer_size;
+@@preload_buffer_size
+262144
+load index into cache t1 ignore leaves;
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+show status like "key_read%";
+Variable_name Value
+Key_read_requests 0
+Key_reads 0
+select count(*) from t1 where b = 'test1';
+count(*)
+4181
+show status like "key_read%";
+Variable_name Value
+Key_read_requests 217
+Key_reads 45
+flush tables;
+flush status;
+show status like "key_read%";
+Variable_name Value
+Key_read_requests 0
+Key_reads 0
+set session preload_buffer_size=1*1024;
+select @@preload_buffer_size;
+@@preload_buffer_size
+1024
+load index into cache t1, t2 keys (primary,b) ignore leaves;
+Table Op Msg_type Msg_text
+test.t1 preload_keys status OK
+test.t2 preload_keys status OK
+show status like "key_read%";
+Variable_name Value
+Key_read_requests 0
+Key_reads 0
+select count(*) from t1 where b = 'test1';
+count(*)
+4181
+select count(*) from t2 where b = 'test1';
+count(*)
+2584
+show status like "key_read%";
+Variable_name Value
+Key_read_requests 351
+Key_reads 73
+flush tables;
+flush status;
+show status like "key_read%";
+Variable_name Value
+Key_read_requests 0
+Key_reads 0
+load index into cache t3, t2 keys (primary,b) ;
+Table Op Msg_type Msg_text
+test.t3 preload_keys error Table 'test.t3' doesn't exist
+test.t2 preload_keys status OK
+show status like "key_read%";
+Variable_name Value
+Key_read_requests 0
+Key_reads 0
+flush tables;
+flush status;
+show status like "key_read%";
+Variable_name Value
+Key_read_requests 0
+Key_reads 0
+load index into cache t3 keys (b), t2 keys (c) ;
+Table Op Msg_type Msg_text
+test.t3 preload_keys error Table 'test.t3' doesn't exist
+test.t2 preload_keys error Key column 'c' doesn't exist in table
+test.t2 preload_keys status Operation failed
+show status like "key_read%";
+Variable_name Value
+Key_read_requests 0
+Key_reads 0
+drop table t1, t2;
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index 83d2e439fbc..e668b9031cc 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -301,6 +301,11 @@ select USER() from t1;
USER()
select benchmark(1,1) from t1;
benchmark(1,1)
+explain extended select benchmark(1,1) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found
+Warnings:
+Note 1003 select high_priority no_cache benchmark(1,1) AS `benchmark(1,1)` from test.t1
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
@@ -375,8 +380,9 @@ drop database mysqltest;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
-create table t1 (a char(1) not null);
-insert into t1 values("á");
+create table t1 (a char(1) not null collate koi8r_general_ci);
+insert into t1 values(_koi8r"á");
+set CHARACTER SET koi8r;
select * from t1;
a
á
@@ -503,6 +509,74 @@ drop table t1;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
+show global variables like "query_cache_min_res_unit";
+Variable_name Value
+query_cache_min_res_unit 4096
+set GLOBAL query_cache_min_res_unit=1001;
+show global variables like "query_cache_min_res_unit";
+Variable_name Value
+query_cache_min_res_unit 1008
+create table t1 (a int not null);
+insert into t1 values (1),(2),(3);
+create table t2 (a int not null);
+insert into t2 values (1),(2),(3);
+select * from t1;
+a
+1
+2
+3
+select * from t1;
+a
+1
+2
+3
+select * from t2;
+a
+1
+2
+3
+select * from t2;
+a
+1
+2
+3
+show status like "Qcache_hits";
+Variable_name Value
+Qcache_hits 11
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 2
+drop table t1;
+select a from t2;
+a
+1
+2
+3
+select a from t2;
+a
+1
+2
+3
+show status like "Qcache_hits";
+Variable_name Value
+Qcache_hits 12
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 2
+drop table t2;
+set GLOBAL query_cache_min_res_unit=default;
+show global variables like "query_cache_min_res_unit";
+Variable_name Value
+query_cache_min_res_unit 4096
+create table t1 (a int not null);
+insert into t1 values (1);
+select "aaa" from t1;
+aaa
+aaa
+select "AAA" from t1;
+AAA
+AAA
+drop table t1;
create table t1 (a int);
set GLOBAL query_cache_size=1000;
show global variables like "query_cache_size";
@@ -511,24 +585,32 @@ query_cache_size 0
select * from t1;
a
set GLOBAL query_cache_size=1024;
+Warnings:
+Warning 1281 Query cache failed to set size 1024, new query cache size is 0
show global variables like "query_cache_size";
Variable_name Value
query_cache_size 0
select * from t1;
a
set GLOBAL query_cache_size=10240;
+Warnings:
+Warning 1281 Query cache failed to set size 10240, new query cache size is 0
show global variables like "query_cache_size";
Variable_name Value
query_cache_size 0
select * from t1;
a
set GLOBAL query_cache_size=20480;
+Warnings:
+Warning 1281 Query cache failed to set size 20480, new query cache size is 0
show global variables like "query_cache_size";
Variable_name Value
query_cache_size 0
select * from t1;
a
set GLOBAL query_cache_size=40960;
+Warnings:
+Warning 1281 Query cache failed to set size 40960, new query cache size is 0
show global variables like "query_cache_size";
Variable_name Value
query_cache_size 0
@@ -578,6 +660,7 @@ i
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
+update t1 set i=(select distinct 1 from (select * from t2) a);
drop table t1, t2, t3;
use mysql;
select * from db;
@@ -596,10 +679,10 @@ id
2
alter table t1 rename to t2;
select * from t1 where id=2;
-Table 'test.t1' doesn't exist
+ERROR 42S02: Table 'test.t1' doesn't exist
drop table t2;
select * from t1 where id=2;
-Table 'test.t1' doesn't exist
+ERROR 42S02: Table 'test.t1' doesn't exist
create table t1 (word char(20) not null);
select * from t1;
word
@@ -611,7 +694,6 @@ show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
drop table t1;
-drop table if exists t1;
create table t1 (a int);
insert into t1 values (1),(2),(3);
show status like "Qcache_queries_in_cache";
@@ -680,4 +762,51 @@ select * from t3;
delete from t4 where a=1;
flush query cache;
drop table t1,t2,t3,t4;
-set GLOBAL query_cache_size=0;
+SET NAMES koi8r;
+CREATE TABLE t1 (a char(1) character set koi8r);
+INSERT INTO t1 VALUES (_koi8r'á'),(_koi8r'Á');
+SELECT a,'Â','â'='Â' FROM t1;
+a  'â'='Â'
+á Â 1
+Á Â 1
+show status like "Qcache_hits";
+Variable_name Value
+Qcache_hits 6
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 1
+set collation_connection=koi8r_bin;
+SELECT a,'Â','â'='Â' FROM t1;
+a  'â'='Â'
+á Â 0
+Á Â 0
+show status like "Qcache_hits";
+Variable_name Value
+Qcache_hits 6
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 2
+set character_set_client=cp1251;
+SELECT a,'Â','â'='Â' FROM t1;
+a ÷ '×'='÷'
+á ÷ 0
+Á ÷ 0
+show status like "Qcache_hits";
+Variable_name Value
+Qcache_hits 6
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 3
+set character_set_results=cp1251;
+SELECT a,'Â','â'='Â' FROM t1;
+a  'â'='Â'
+À Â 0
+à Â 0
+show status like "Qcache_hits";
+Variable_name Value
+Qcache_hits 6
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 4
+DROP TABLE t1;
+SET GLOBAL query_cache_size=0;
diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result
index 68987009598..1b66f442a9a 100644
--- a/mysql-test/r/range.result
+++ b/mysql-test/r/range.result
@@ -1,4 +1,4 @@
-drop table if exists t1;
+drop table if exists t1, t2;
CREATE TABLE t1 (
event_date date DEFAULT '0000-00-00' NOT NULL,
type int(11) DEFAULT '0' NOT NULL,
@@ -32,8 +32,8 @@ event_date type event_id
1999-07-13 100600 26
1999-07-14 100600 10
explain select event_date,type,event_id from t1 WHERE type = 100601 and event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date;
-Comment
-Impossible WHERE
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND (type=100600 OR type=100100) or event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND type=100099;
event_date type event_id
1999-07-10 100100 24
@@ -201,7 +201,7 @@ INSERT INTO t1 (art) VALUES ('j'),('J'),('j'),('J'),('j'),('J'),('j'),('J'),('j'
('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j'),('j');
select count(*) from t1 where upper(art) = 'J';
count(*)
-602
+213
select count(*) from t1 where art = 'J' or art = 'j';
count(*)
602
@@ -215,63 +215,52 @@ select count(*) from t1 where art = 'J';
count(*)
213
drop table t1;
-create table t1 ( id1 int not null, id2 int not null, idnull int null, c char(20), primary key (id1,id2));
-insert into t1 values (0,1,NULL,"aaa"), (1,1,NULL,"aaa"), (2,1,NULL,"aaa"),
-(3,1,NULL,"aaa"), (4,1,NULL,"aaa"), (5,1,NULL,"aaa"),
-(6,1,NULL,"aaa"), (7,1,NULL,"aaa"), (8,1,NULL,"aaa"),
-(9,1,NULL,"aaa"), (10,1,NULL,"aaa"), (11,1,NULL,"aaa"),
-(12,1,NULL,"aaa"), (13,1,NULL,"aaa"), (14,1,NULL,"aaa"),
-(15,1,NULL,"aaa"), (16,1,NULL,"aaa"), (17,1,NULL,"aaa"),
-(18,1,NULL,"aaa"), (19,1,NULL,"aaa"), (20,1,NULL,"aaa");
-select a.id1, b.idnull from t1 as a, t1 as b where a.id2=1 and a.id1=1 and b.id1=a.idnull order by b.id2 desc limit 1;
-id1 idnull
-drop table t1;
create table t1 (x int, y int, index(x), index(y));
insert into t1 (x) values (1),(2),(3),(4),(5),(6),(7),(8),(9);
update t1 set y=x;
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 7 and t1.y+0;
-table type possible_keys key key_len ref rows Extra
-t1 ref y y 5 const 1 Using where
-t2 range x x 5 NULL 4 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref y y 5 const 1 Using where
+1 SIMPLE t2 range x x 5 NULL 4 Using where
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 7 and t2.x <= t1.y+0;
-table type possible_keys key key_len ref rows Extra
-t1 ref y y 5 const 1 Using where
-t2 range x x 5 NULL 4 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref y y 5 const 1 Using where
+1 SIMPLE t2 range x x 5 NULL 4 Using where
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between t1.y-1 and t1.y+1;
-table type possible_keys key key_len ref rows Extra
-t1 ref y y 5 const 1 Using where
-t2 ALL x NULL NULL NULL 9 Range checked for each record (index map: 1)
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref y y 5 const 1 Using where
+1 SIMPLE t2 ALL x NULL NULL NULL 9 Range checked for each record (index map: 0x1)
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1.y+1;
-table type possible_keys key key_len ref rows Extra
-t1 ref y y 5 const 1 Using where
-t2 ALL x NULL NULL NULL 9 Range checked for each record (index map: 1)
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref y y 5 const 1 Using where
+1 SIMPLE t2 ALL x NULL NULL NULL 9 Range checked for each record (index map: 0x1)
explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y;
-table type possible_keys key key_len ref rows Extra
-t1 ref y y 5 const 1 Using where
-t2 ALL x NULL NULL NULL 9 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref y y 5 const 1 Using where
+1 SIMPLE t2 ALL x NULL NULL NULL 9 Using where
explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y;
-table type possible_keys key key_len ref rows Extra
-t1 ref y y 5 const 1 Using where
-t2 range x x 5 NULL 2 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref y y 5 const 1 Using where
+1 SIMPLE t2 range x x 5 NULL 2 Using where
explain select count(*) from t1 where x in (1);
-table type possible_keys key key_len ref rows Extra
-t1 range x x 5 NULL 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range x x 5 NULL 1 Using where; Using index
explain select count(*) from t1 where x in (1,2);
-table type possible_keys key key_len ref rows Extra
-t1 range x x 5 NULL 2 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range x x 5 NULL 2 Using where; Using index
drop table t1;
CREATE TABLE t1 (key1 int(11) NOT NULL default '0', KEY i1 (key1), KEY i2 (key1));
INSERT INTO t1 VALUES (0),(0),(1),(1);
CREATE TABLE t2 (keya int(11) NOT NULL default '0', KEY j1 (keya));
INSERT INTO t2 VALUES (0),(0),(1),(1),(2),(2);
explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
-table type possible_keys key key_len ref rows Extra
-t2 ref j1 j1 4 const 1 Using where; Using index
-t1 ALL i1,i2 NULL NULL NULL 4 Range checked for each record (index map: 3)
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref j1 j1 4 const 1 Using where; Using index
+1 SIMPLE t1 ALL i1,i2 NULL NULL NULL 4 Range checked for each record (index map: 0x3)
explain select * from t1 force index(i2), t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
-table type possible_keys key key_len ref rows Extra
-t2 ref j1 j1 4 const 1 Using where; Using index
-t1 ALL i2 NULL NULL NULL 4 Range checked for each record (index map: 2)
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref j1 j1 4 const 1 Using where; Using index
+1 SIMPLE t1 ALL i2 NULL NULL NULL 4 Range checked for each record (index map: 0x2)
DROP TABLE t1,t2;
CREATE TABLE t1 (
a int(11) default NULL,
@@ -285,8 +274,163 @@ INSERT INTO t1 VALUES
(21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5),
(33,5),(33,5),(33,5),(33,5),(34,5),(35,5);
EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
-table type possible_keys key key_len ref rows Extra
-t1 range a,b a 5 NULL 2 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range a,b a 5 NULL 2 Using where
SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
a b
DROP TABLE t1;
+create table t1 (id int(10) primary key);
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
+select id from t1 where id in (2,5,9) ;
+id
+2
+5
+9
+select id from t1 where id=2 or id=5 or id=9 ;
+id
+2
+5
+9
+drop table t1;
+create table t1 ( id1 int not null, id2 int not null, idnull int null, c char(20), primary key (id1,id2));
+insert into t1 values (0,1,NULL,"aaa"), (1,1,NULL,"aaa"), (2,1,NULL,"aaa"),
+(3,1,NULL,"aaa"), (4,1,NULL,"aaa"), (5,1,NULL,"aaa"),
+(6,1,NULL,"aaa"), (7,1,NULL,"aaa"), (8,1,NULL,"aaa"),
+(9,1,NULL,"aaa"), (10,1,NULL,"aaa"), (11,1,NULL,"aaa"),
+(12,1,NULL,"aaa"), (13,1,NULL,"aaa"), (14,1,NULL,"aaa"),
+(15,1,NULL,"aaa"), (16,1,NULL,"aaa"), (17,1,NULL,"aaa"),
+(18,1,NULL,"aaa"), (19,1,NULL,"aaa"), (20,1,NULL,"aaa");
+select a.id1, b.idnull from t1 as a, t1 as b where a.id2=1 and a.id1=1 and b.id1=a.idnull order by b.id2 desc limit 1;
+id1 idnull
+drop table t1;
+create table t1 (
+id int not null auto_increment,
+name char(1) not null,
+uid int not null,
+primary key (id),
+index uid_index (uid));
+create table t2 (
+id int not null auto_increment,
+name char(1) not null,
+uid int not null,
+primary key (id),
+index uid_index (uid));
+insert into t1(id, uid, name) values(1, 0, ' ');
+insert into t1(uid, name) values(0, ' ');
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t2(uid, name) select uid, name from t1;
+insert into t2(uid, name) select uid, name from t1;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+delete from t2;
+insert into t2(uid, name) values
+(1, CHAR(64+1)),
+(2, CHAR(64+2)),
+(3, CHAR(64+3)),
+(4, CHAR(64+4)),
+(5, CHAR(64+5)),
+(6, CHAR(64+6)),
+(7, CHAR(64+7)),
+(8, CHAR(64+8)),
+(9, CHAR(64+9)),
+(10, CHAR(64+10)),
+(11, CHAR(64+11)),
+(12, CHAR(64+12)),
+(13, CHAR(64+13)),
+(14, CHAR(64+14)),
+(15, CHAR(64+15)),
+(16, CHAR(64+16)),
+(17, CHAR(64+17)),
+(18, CHAR(64+18)),
+(19, CHAR(64+19)),
+(20, CHAR(64+20)),
+(21, CHAR(64+21)),
+(22, CHAR(64+22)),
+(23, CHAR(64+23)),
+(24, CHAR(64+24)),
+(25, CHAR(64+25)),
+(26, CHAR(64+26));
+insert into t1(uid, name) select uid, name from t2;
+delete from t2;
+insert into t2(id, uid, name) select id, uid, name from t1;
+select count(*) from t1;
+count(*)
+1026
+select count(*) from t2;
+count(*)
+1026
+explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range uid_index uid_index 4 NULL 128 Using where
+1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
+explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range uid_index uid_index 4 NULL 129 Using where
+1 SIMPLE t2 ref uid_index uid_index 4 test.t1.uid 38
+select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
+id name uid id name uid
+1001 A 1 1001 A 1
+1002 B 2 1002 B 2
+1003 C 3 1003 C 3
+1004 D 4 1004 D 4
+1005 E 5 1005 E 5
+1006 F 6 1006 F 6
+1007 G 7 1007 G 7
+1008 H 8 1008 H 8
+1009 I 9 1009 I 9
+1010 J 10 1010 J 10
+1011 K 11 1011 K 11
+1012 L 12 1012 L 12
+1013 M 13 1013 M 13
+1014 N 14 1014 N 14
+1015 O 15 1015 O 15
+1016 P 16 1016 P 16
+1017 Q 17 1017 Q 17
+1018 R 18 1018 R 18
+1019 S 19 1019 S 19
+1020 T 20 1020 T 20
+1021 U 21 1021 U 21
+1022 V 22 1022 V 22
+1023 W 23 1023 W 23
+1024 X 24 1024 X 24
+1025 Y 25 1025 Y 25
+1026 Z 26 1026 Z 26
+select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0;
+id name uid id name uid
+1001 A 1 1001 A 1
+1002 B 2 1002 B 2
+1003 C 3 1003 C 3
+1004 D 4 1004 D 4
+1005 E 5 1005 E 5
+1006 F 6 1006 F 6
+1007 G 7 1007 G 7
+1008 H 8 1008 H 8
+1009 I 9 1009 I 9
+1010 J 10 1010 J 10
+1011 K 11 1011 K 11
+1012 L 12 1012 L 12
+1013 M 13 1013 M 13
+1014 N 14 1014 N 14
+1015 O 15 1015 O 15
+1016 P 16 1016 P 16
+1017 Q 17 1017 Q 17
+1018 R 18 1018 R 18
+1019 S 19 1019 S 19
+1020 T 20 1020 T 20
+1021 U 21 1021 U 21
+1022 V 22 1022 V 22
+1023 W 23 1023 W 23
+1024 X 24 1024 X 24
+1025 Y 25 1025 Y 25
+1026 Z 26 1026 Z 26
+drop table t1,t2;
diff --git a/mysql-test/r/rename.result b/mysql-test/r/rename.result
index b2bb659502a..e422fbe49c1 100644
--- a/mysql-test/r/rename.result
+++ b/mysql-test/r/rename.result
@@ -37,3 +37,5 @@ select * from t3;
3 table 3
3 table 3
drop table if exists t1,t2,t3,t4;
+Warnings:
+Note 1051 Unknown table 't4'
diff --git a/mysql-test/r/repair.result b/mysql-test/r/repair_part1.result
index 6c2107b2cf3..27dfdac24f0 100644
--- a/mysql-test/r/repair.result
+++ b/mysql-test/r/repair_part1.result
@@ -7,7 +7,7 @@ test.t1 repair status OK
alter table t1 TYPE=HEAP;
repair table t1 use_frm;
Table Op Msg_type Msg_text
-test.t1 repair error The handler for the table doesn't support repair
+test.t1 repair error The storage engine for the table doesn't support repair
drop table t1;
repair table t1 use_frm;
Table Op Msg_type Msg_text
diff --git a/mysql-test/r/repair_part2.result b/mysql-test/r/repair_part2.result
index 77aa98c3da9..c9cf6c019f7 100644
--- a/mysql-test/r/repair_part2.result
+++ b/mysql-test/r/repair_part2.result
@@ -1,6 +1,6 @@
repair table t1;
Table Op Msg_type Msg_text
-test.t1 repair error Can't open file: 't1.MYI'. (errno: 130)
+test.t1 repair error Can't open file: 't1.MYI' (errno: 130)
repair table t1 use_frm;
Table Op Msg_type Msg_text
test.t1 repair warning Number of rows changed from 0 to 1
diff --git a/mysql-test/r/replace.result b/mysql-test/r/replace.result
index 0aa80e18ccc..2d95343245b 100644
--- a/mysql-test/r/replace.result
+++ b/mysql-test/r/replace.result
@@ -12,15 +12,17 @@ replace into t1 (gesuchnr,benutzer_id) values (1,1);
alter table t1 type=heap;
replace into t1 (gesuchnr,benutzer_id) values (1,1);
drop table t1;
-create table t1 (a tinyint not null auto_increment primary key, b char(20));
-insert into t1 values (126,"first"),(0,"last");
+create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value");
+insert into t1 values (126,"first"),(63, "middle"),(0,"last");
insert into t1 values (0,"error");
-Duplicate entry '127' for key 1
+ERROR 23000: Duplicate entry '127' for key 1
replace into t1 values (0,"error");
-Duplicate entry '127' for key 1
+ERROR 23000: Duplicate entry '127' for key 1
replace into t1 values (126,"first updated");
+replace into t1 values (63,default);
select * from t1;
a b
126 first updated
+63 default_value
127 last
drop table t1;
diff --git a/mysql-test/r/rollback.result b/mysql-test/r/rollback.result
index a5eb6f8729f..d87aa68dce4 100644
--- a/mysql-test/r/rollback.result
+++ b/mysql-test/r/rollback.result
@@ -4,9 +4,26 @@ begin work;
insert into t1 values (4);
insert into t1 values (5);
rollback;
-Warning: Some non-transactional changed tables couldn't be rolled back
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
+select @@warning_count;
+@@warning_count
+1
+select @@error_count;
+@@error_count
+0
+show warnings;
+Level Code Message
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
+show errors;
+Level Code Message
select * from t1;
n
4
5
+select @@warning_count;
+@@warning_count
+0
+show warnings;
+Level Code Message
drop table t1;
diff --git a/mysql-test/r/row.result b/mysql-test/r/row.result
new file mode 100644
index 00000000000..37d4f1d9b26
--- /dev/null
+++ b/mysql-test/r/row.result
@@ -0,0 +1,172 @@
+drop table if exists t1;
+select (1,2,3) IN ((3,2,3), (1,2,3), (1,3,3));
+(1,2,3) IN ((3,2,3), (1,2,3), (1,3,3))
+1
+select row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3));
+row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3))
+0
+select row(1,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3));
+row(1,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3))
+1
+select row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3));
+row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3))
+0
+select row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a'));
+row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a'))
+1
+select row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3));
+row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3))
+1
+select row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3));
+row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3))
+1
+select row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3));
+row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3))
+1
+select row('b',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3));
+row('b',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3))
+0
+select row('b',1.5,3) IN (row('b',NULL,3), row('a',1.5,3), row(1,3,3));
+row('b',1.5,3) IN (row('b',NULL,3), row('a',1.5,3), row(1,3,3))
+NULL
+select row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3));
+row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3))
+0
+select (1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4)));
+(1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4)))
+1
+select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,4));
+ERROR 21000: Operand should contain 2 column(s)
+select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)));
+row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)))
+NULL
+explain extended select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority ((1,2,(3,4)) in ((3,2,(3,4)),(1,2,(3,NULL)))) AS `row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)))`
+SELECT (1,2,3)=(0,NULL,3);
+(1,2,3)=(0,NULL,3)
+0
+SELECT (1,2,3)=(1,NULL,3);
+(1,2,3)=(1,NULL,3)
+NULL
+SELECT (1,2,3)=(1,NULL,0);
+(1,2,3)=(1,NULL,0)
+NULL
+SELECT ROW(1,2,3)=ROW(1,2,3);
+ROW(1,2,3)=ROW(1,2,3)
+1
+SELECT ROW(2,2,3)=ROW(1+1,2,3);
+ROW(2,2,3)=ROW(1+1,2,3)
+1
+SELECT ROW(1,2,3)=ROW(1+1,2,3);
+ROW(1,2,3)=ROW(1+1,2,3)
+0
+SELECT ROW(1,2,3)<ROW(1+1,2,3);
+ROW(1,2,3)<ROW(1+1,2,3)
+1
+SELECT ROW(1,2,3)>ROW(1+1,2,3);
+ROW(1,2,3)>ROW(1+1,2,3)
+0
+SELECT ROW(1,2,3)<=ROW(1+1,2,3);
+ROW(1,2,3)<=ROW(1+1,2,3)
+1
+SELECT ROW(1,2,3)>=ROW(1+1,2,3);
+ROW(1,2,3)>=ROW(1+1,2,3)
+0
+SELECT ROW(1,2,3)<>ROW(1+1,2,3);
+ROW(1,2,3)<>ROW(1+1,2,3)
+1
+SELECT ROW(NULL,2,3)=ROW(NULL,2,3);
+ROW(NULL,2,3)=ROW(NULL,2,3)
+NULL
+SELECT ROW(NULL,2,3)<=>ROW(NULL,2,3);
+ROW(NULL,2,3)<=>ROW(NULL,2,3)
+1
+SELECT ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5));
+ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5))
+1
+SELECT ROW('test',2,3.33)=ROW('test',2,3.33);
+ROW('test',2,3.33)=ROW('test',2,3.33)
+1
+SELECT ROW('test',2,3.33)=ROW('test',2,3.33,4);
+ERROR 21000: Operand should contain 3 column(s)
+SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,33));
+ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,33))
+1
+SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,3));
+ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,3))
+0
+SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,NULL));
+ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,NULL))
+NULL
+SELECT ROW('test',2,ROW(3,33))=ROW('test',2,4);
+ERROR 21000: Operand should contain 2 column(s)
+create table t1 ( a int, b int, c int);
+insert into t1 values (1,2,3), (2,3,1), (3,2,1), (1,2,NULL);
+select * from t1 where ROW(1,2,3)=ROW(a,b,c);
+a b c
+1 2 3
+select * from t1 where ROW(0,2,3)=ROW(a,b,c);
+a b c
+select * from t1 where ROW(1,2,3)<ROW(a,b,c);
+a b c
+2 3 1
+3 2 1
+select ROW(a,2,3) IN(row(1,b,c), row(2,3,1)) from t1;
+ROW(a,2,3) IN(row(1,b,c), row(2,3,1))
+1
+0
+0
+NULL
+select ROW(c,2,3) IN(row(1,b,a), row(2,3,1)) from t1;
+ROW(c,2,3) IN(row(1,b,a), row(2,3,1))
+0
+0
+1
+NULL
+select ROW(a,b,c) IN(row(1,2,3), row(3,2,1)) from t1;
+ROW(a,b,c) IN(row(1,2,3), row(3,2,1))
+1
+0
+1
+NULL
+select ROW(1,2,3) IN(row(a,b,c), row(1,2,3)) from t1;
+ROW(1,2,3) IN(row(a,b,c), row(1,2,3))
+1
+1
+1
+1
+drop table t1;
+select ROW(1,1);
+ERROR 21000: Operand should contain 1 column(s)
+create table t1 (i int);
+select 1 from t1 where ROW(1,1);
+ERROR 21000: Operand should contain 1 column(s)
+select count(*) from t1 order by ROW(1,1);
+ERROR 21000: Operand should contain 1 column(s)
+select count(*) from t1 having (1,1) order by i;
+ERROR 21000: Operand should contain 1 column(s)
+drop table t1;
+create table t1 (a int, b int);
+insert into t1 values (1, 4);
+insert into t1 values (10, 40);
+insert into t1 values (1, 4);
+insert into t1 values (10, 43);
+insert into t1 values (1, 4);
+insert into t1 values (10, 41);
+insert into t1 values (1, 4);
+insert into t1 values (10, 43);
+insert into t1 values (1, 4);
+select a, MAX(b), (1, MAX(b)) = (1, 4) from t1 group by a;
+a MAX(b) (1, MAX(b)) = (1, 4)
+1 4 1
+10 43 0
+drop table t1;
+SELECT ROW(2,10) <=> ROW(3,4);
+ROW(2,10) <=> ROW(3,4)
+0
+SELECT ROW(NULL,10) <=> ROW(3,NULL);
+ROW(NULL,10) <=> ROW(3,NULL)
+0
diff --git a/mysql-test/r/rpl000001.result b/mysql-test/r/rpl000001.result
index f3b52b43b19..b8071b16c2e 100644
--- a/mysql-test/r/rpl000001.result
+++ b/mysql-test/r/rpl000001.result
@@ -1,10 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
-drop table if exists t1,t2,t3;
+start slave;
create table t1 (word char(20) not null);
load data infile '../../std_data/words.dat' into table t1;
load data local infile 'MYSQL_TEST_DIR/std_data/words.dat' into table t1;
@@ -20,9 +19,9 @@ abandoned
abandoning
abandonment
abandons
-slave stop;
+stop slave;
set password for root@"localhost" = password('foo');
-slave start;
+start slave;
set password for root@"localhost" = password('');
create table t3(n int);
insert into t3 values(1),(2);
@@ -35,16 +34,26 @@ sum(length(word))
1022
drop table t1,t3;
reset master;
-slave stop;
+stop slave;
reset slave;
create table t1(n int);
select get_lock("hold_slave",10);
get_lock("hold_slave",10)
1
-slave start;
+explain extended select get_lock("hold_slave",10);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority no_cache get_lock(_latin1'hold_slave',10) AS `get_lock("hold_slave",10)`
+start slave;
select release_lock("hold_slave");
release_lock("hold_slave")
1
+explain extended select release_lock("hold_slave");
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority no_cache release_lock(_latin1'hold_slave') AS `release_lock("hold_slave")`
unlock tables;
create table t2(id int);
insert into t2 values(connection_id());
@@ -56,9 +65,9 @@ select (@id := id) - id from t2;
0
kill @id;
drop table t2;
-Server shutdown in progress
+ERROR 08S01: Server shutdown in progress
set global sql_slave_skip_counter=1;
-slave start;
+start slave;
select count(*) from t1;
count(*)
5000
diff --git a/mysql-test/r/rpl000002.result b/mysql-test/r/rpl000002.result
index 4c2b3bdfde6..56e34b4874f 100644
--- a/mysql-test/r/rpl000002.result
+++ b/mysql-test/r/rpl000002.result
@@ -1,10 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
-drop table if exists t1;
+start slave;
create table t1 (n int auto_increment primary key);
set insert_id = 2000;
insert into t1 values (NULL),(NULL),(NULL);
@@ -17,15 +16,14 @@ show slave hosts;
Server_id Host Port Rpl_recovery_rank Master_id
2 127.0.0.1 9999 2 1
drop table t1;
-slave stop;
-drop table if exists t2;
+stop slave;
create table t2(id int auto_increment primary key, created datetime);
set timestamp=12345;
insert into t2 set created=now();
select * from t2;
id created
1 1970-01-01 06:25:45
-slave start;
+start slave;
select * from t2;
id created
1 1970-01-01 06:25:45
diff --git a/mysql-test/r/rpl000003.result b/mysql-test/r/rpl000003.result
deleted file mode 100644
index b123b3d98c5..00000000000
--- a/mysql-test/r/rpl000003.result
+++ /dev/null
@@ -1,17 +0,0 @@
-slave stop;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-reset master;
-reset slave;
-drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
-drop table if exists t1;
-create table t1(n int primary key);
-insert into t1 values (1),(2),(2);
-Duplicate entry '2' for key 1
-insert into t1 values (3);
-select * from t1;
-n
-1
-2
-3
-drop table t1;
diff --git a/mysql-test/r/rpl000004.result b/mysql-test/r/rpl000004.result
index 3142adc50d6..9abb4db7974 100644
--- a/mysql-test/r/rpl000004.result
+++ b/mysql-test/r/rpl000004.result
@@ -1,22 +1,17 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
set SQL_LOG_BIN=0;
-drop table if exists t1;
create table t1 (word char(20) not null, index(word));
load data infile '../../std_data/words.dat' into table t1;
-drop table if exists t2;
create table t2 (word char(20) not null);
load data infile '../../std_data/words.dat' into table t2;
create table t3 (word char(20) not null primary key);
-drop table if exists t1;
load table t1 from master;
-drop table if exists t2;
load table t2 from master;
-drop table if exists t3;
load table t3 from master;
check table t1;
Table Op Msg_type Msg_text
diff --git a/mysql-test/r/rpl000005.result b/mysql-test/r/rpl000005.result
index 3e9028bf2cf..0202e43dcb2 100644
--- a/mysql-test/r/rpl000005.result
+++ b/mysql-test/r/rpl000005.result
@@ -1,10 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
-drop table if exists t1;
+start slave;
CREATE TABLE t1 (name varchar(64), age smallint(3));
INSERT INTO t1 SET name='Andy', age=31;
INSERT t1 SET name='Jacob', age=2;
diff --git a/mysql-test/r/rpl000006.result b/mysql-test/r/rpl000006.result
index e7fc5151ac4..7209ec3c3d1 100644
--- a/mysql-test/r/rpl000006.result
+++ b/mysql-test/r/rpl000006.result
@@ -1,17 +1,15 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
set SQL_LOG_BIN=0,timestamp=200006;
-drop table if exists t1;
create table t1(t timestamp not null,a char(1));
insert into t1 ( a) values ('F');
select unix_timestamp(t) from t1;
unix_timestamp(t)
200006
-drop table if exists t1;
load table t1 from master;
select unix_timestamp(t) from t1;
unix_timestamp(t)
diff --git a/mysql-test/r/rpl000008.result b/mysql-test/r/rpl000008.result
index a0230d55702..a88a3c690ed 100644
--- a/mysql-test/r/rpl000008.result
+++ b/mysql-test/r/rpl000008.result
@@ -1,25 +1,23 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
use test;
-drop table if exists foo;
-create table foo (n int);
-insert into foo values(4);
+drop table if exists mysqltest_foo;
+drop table if exists mysqltest_bar;
+create table mysqltest_foo (n int);
+insert into mysqltest_foo values(4);
use test;
-drop table if exists foo;
-create table foo (n int);
-insert into foo values(5);
-drop table if exists bar;
-create table bar (m int);
-insert into bar values(15);
-drop table if exists choo;
-create table choo (k int);
-insert into choo values(55);
-select foo.n,bar.m,choo.k from foo,bar,choo;
+create table mysqltest_foo (n int);
+insert into mysqltest_foo values(5);
+create table mysqltest_bar (m int);
+insert into mysqltest_bar values(15);
+create table t1 (k int);
+insert into t1 values(55);
+select mysqltest_foo.n,mysqltest_bar.m,t1.k from mysqltest_foo,mysqltest_bar,t1;
n m k
4 15 55
-drop table if exists foo,bar,choo;
-drop table if exists foo,bar,choo;
+drop table mysqltest_foo,mysqltest_bar,t1;
+drop table mysqltest_foo,mysqltest_bar,t1;
diff --git a/mysql-test/r/rpl000009.result b/mysql-test/r/rpl000009.result
index 569dd301143..1f78a505280 100644
--- a/mysql-test/r/rpl000009.result
+++ b/mysql-test/r/rpl000009.result
@@ -1,121 +1,124 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
-drop database if exists foo;
-create database foo;
-drop database if exists bar;
-create database bar;
-create database foo;
-drop table if exists foo.foo;
-create table foo.foo (n int);
-insert into foo.foo values(4);
-drop table if exists foo.foo;
-create table foo.foo (n int);
-insert into foo.foo values(5);
-drop table if exists bar.bar;
-create table bar.bar (m int);
-insert into bar.bar values(15);
-select foo.foo.n,bar.bar.m from foo.foo,bar.bar;
+start slave;
+drop database if exists mysqltest;
+drop database if exists mysqltest2;
+drop database if exists mysqltest3;
+drop database if exists mysqltest;
+drop database if exists mysqltest2;
+drop database if exists mysqltest3;
+create database mysqltest2;
+create database mysqltest;
+create database mysqltest2;
+create table mysqltest2.foo (n int);
+insert into mysqltest2.foo values(4);
+create table mysqltest2.foo (n int);
+insert into mysqltest2.foo values(5);
+create table mysqltest.bar (m int);
+insert into mysqltest.bar values(15);
+select mysqltest2.foo.n,mysqltest.bar.m from mysqltest2.foo,mysqltest.bar;
n m
4 15
-drop database bar;
-drop database if exists foo;
-drop database bar;
-Can't drop database 'bar'. Database doesn't exist
-drop database foo;
+drop database mysqltest;
+drop database if exists mysqltest2;
+drop database mysqltest;
+ERROR HY000: Can't drop database 'mysqltest'; database doesn't exist
+drop database mysqltest2;
set sql_log_bin = 0;
-create database foo;
-create database bar;
+create database mysqltest2;
+create database mysqltest;
show databases;
Database
-bar
-foo
mysql
+mysqltest
+mysqltest2
test
-create table foo.t1(n int, s char(20));
-create table foo.t2(n int, s text);
-insert into foo.t1 values (1, 'one'), (2, 'two'), (3, 'three');
-insert into foo.t2 values (11, 'eleven'), (12, 'twelve'), (13, 'thirteen');
-create table bar.t1(n int, s char(20));
-create table bar.t2(n int, s text);
-insert into bar.t1 values (1, 'one bar'), (2, 'two bar'), (3, 'three bar');
-insert into bar.t2 values (11, 'eleven bar'), (12, 'twelve bar'),
-(13, 'thirteen bar');
+create table mysqltest2.t1(n int, s char(20));
+create table mysqltest2.t2(n int, s text);
+insert into mysqltest2.t1 values (1, 'one'), (2, 'two'), (3, 'three');
+insert into mysqltest2.t2 values (11, 'eleven'), (12, 'twelve'), (13, 'thirteen');
+create table mysqltest.t1(n int, s char(20));
+create table mysqltest.t2(n int, s text);
+insert into mysqltest.t1 values (1, 'one test'), (2, 'two test'), (3, 'three test');
+insert into mysqltest.t2 values (11, 'eleven test'), (12, 'twelve test'),
+(13, 'thirteen test');
set sql_log_bin = 1;
show databases;
Database
mysql
test
-create database foo;
-create table foo.t1(n int, s char(20));
-insert into foo.t1 values (1, 'original foo.t1');
-create table foo.t3(n int, s char(20));
-insert into foo.t3 values (1, 'original foo.t3');
-create database foo2;
-create table foo2.t1(n int, s char(20));
-insert into foo2.t1 values (1, 'original foo2.t1');
-create database bar;
-create table bar.t1(n int, s char(20));
-insert into bar.t1 values (1, 'original bar.t1');
-create table bar.t3(n int, s char(20));
-insert into bar.t3 values (1, 'original bar.t3');
+create database mysqltest2;
+create table mysqltest2.t1(n int, s char(20));
+insert into mysqltest2.t1 values (1, 'original foo.t1');
+create table mysqltest2.t3(n int, s char(20));
+insert into mysqltest2.t3 values (1, 'original foo.t3');
+create database mysqltest3;
+create table mysqltest3.t1(n int, s char(20));
+insert into mysqltest3.t1 values (1, 'original foo2.t1');
+create database mysqltest;
+create table mysqltest.t1(n int, s char(20));
+insert into mysqltest.t1 values (1, 'original bar.t1');
+create table mysqltest.t3(n int, s char(20));
+insert into mysqltest.t3 values (1, 'original bar.t3');
load data from master;
show databases;
Database
-bar
-foo
-foo2
mysql
+mysqltest
+mysqltest2
+mysqltest3
test
-use foo;
+use mysqltest2;
show tables;
-Tables_in_foo
+Tables_in_mysqltest2
t1
t3
select * from t1;
n s
1 original foo.t1
-use foo2;
+use mysqltest3;
show tables;
-Tables_in_foo2
+Tables_in_mysqltest3
t1
select * from t1;
n s
1 original foo2.t1
-use bar;
+use mysqltest;
show tables;
-Tables_in_bar
+Tables_in_mysqltest
t1
t2
t3
-select * from bar.t1;
+select * from mysqltest.t1;
n s
-1 one bar
-2 two bar
-3 three bar
-select * from bar.t2;
+1 one test
+2 two test
+3 three test
+select * from mysqltest.t2;
n s
-11 eleven bar
-12 twelve bar
-13 thirteen bar
-select * from bar.t3;
+11 eleven test
+12 twelve test
+13 thirteen test
+select * from mysqltest.t3;
n s
1 original bar.t3
-insert into bar.t1 values (4, 'four bar');
-select * from bar.t1;
+insert into mysqltest.t1 values (4, 'four test');
+select * from mysqltest.t1;
n s
-1 one bar
-2 two bar
-3 three bar
-4 four bar
+1 one test
+2 two test
+3 three test
+4 four test
+load table mysqltest.t1 from master;
+ERROR 42S01: Table 't1' already exists
+drop table mysqltest.t1;
+load table mysqltest.t1 from master;
load table bar.t1 from master;
-Table 't1' already exists
-drop table bar.t1;
-load table bar.t1 from master;
-drop database bar;
-drop database foo;
-drop database foo;
-drop database foo2;
+ERROR HY000: Error from master: 'Table 'bar.t1' doesn't exist'
+drop database mysqltest;
+drop database mysqltest2;
+drop database mysqltest2;
+drop database mysqltest3;
diff --git a/mysql-test/r/rpl000010.result b/mysql-test/r/rpl000010.result
index 49538ed148e..65191ea411f 100644
--- a/mysql-test/r/rpl000010.result
+++ b/mysql-test/r/rpl000010.result
@@ -1,11 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
-drop table if exists t1;
-drop table if exists t1;
+start slave;
create table t1 (n int not null auto_increment primary key);
insert into t1 values(NULL);
insert into t1 values(2);
diff --git a/mysql-test/r/rpl000011.result b/mysql-test/r/rpl000011.result
index 5d22c29bdba..dd0fa2fbe74 100644
--- a/mysql-test/r/rpl000011.result
+++ b/mysql-test/r/rpl000011.result
@@ -1,14 +1,13 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
-drop table if exists t1;
+start slave;
create table t1 (n int);
insert into t1 values(1);
-slave stop;
-slave start;
+stop slave;
+start slave;
insert into t1 values(2);
select * from t1;
n
diff --git a/mysql-test/r/rpl000012.result b/mysql-test/r/rpl000012.result
index 45de6502bbd..17fb53010ab 100644
--- a/mysql-test/r/rpl000012.result
+++ b/mysql-test/r/rpl000012.result
@@ -1,21 +1,19 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
-drop table if exists t1,t2,t3;
+start slave;
create table t2 (n int);
create temporary table t1 (n int);
insert into t1 values(1),(2),(3);
insert into t2 select * from t1;
-drop table if exists test.t3;
-create temporary table test.t3 (n int not null);
-alter table test.t3 add primary key(n);
+create temporary table t3 (n int not null);
+alter table t3 add primary key(n);
flush logs;
insert into t3 values (100);
insert into t2 select * from t3;
-drop table if exists test.t3;
+drop table if exists t3;
insert into t2 values (101);
create temporary table t1 (n int);
insert into t1 values (4),(5);
@@ -35,3 +33,5 @@ show status like 'Slave_open_temp_tables';
Variable_name Value
Slave_open_temp_tables 0
drop table if exists t1,t2;
+Warnings:
+Note 1051 Unknown table 't1'
diff --git a/mysql-test/r/rpl000013.result b/mysql-test/r/rpl000013.result
index 9e802da59c5..37838bb88e0 100644
--- a/mysql-test/r/rpl000013.result
+++ b/mysql-test/r/rpl000013.result
@@ -1,10 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
-drop table if exists t2;
+start slave;
create table t2(n int);
create temporary table t1 (n int);
insert into t1 values(1),(2),(3);
@@ -25,3 +24,5 @@ show status like 'Slave_open_temp_tables';
Variable_name Value
Slave_open_temp_tables 0
drop table if exists t1,t2;
+Warnings:
+Note 1051 Unknown table 't1'
diff --git a/mysql-test/r/rpl000015.result b/mysql-test/r/rpl000015.result
index 7010349e5ff..98ad998f2ed 100644
--- a/mysql-test/r/rpl000015.result
+++ b/mysql-test/r/rpl000015.result
@@ -1,23 +1,23 @@
reset master;
show master status;
File Position Binlog_do_db Binlog_ignore_db
-master-bin.001 79
+master-bin.000001 79
reset slave;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
change master to master_host='127.0.0.1';
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 test MASTER_PORT 7 4 slave-relay-bin.001 4 No No 0 0 0 4
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 test MASTER_PORT 7 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No #
change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=MASTER_PORT;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 7 4 slave-relay-bin.001 4 No No 0 0 0 4
-slave start;
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 7 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No #
+start slave;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 7 master-bin.001 79 slave-relay-bin.001 120 master-bin.001 Yes Yes 0 0 79 120
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 7 master-bin.000001 79 slave-relay-bin.000001 123 master-bin.000001 Yes Yes 0 0 79 123 None 0 No #
drop table if exists t1;
create table t1 (n int);
insert into t1 values (10),(45),(90);
diff --git a/mysql-test/r/rpl000017.result b/mysql-test/r/rpl000017.result
index bac0573165d..64e13042e9c 100644
--- a/mysql-test/r/rpl000017.result
+++ b/mysql-test/r/rpl000017.result
@@ -1,7 +1,7 @@
reset master;
grant replication slave on *.* to replicate@localhost identified by 'aaaaaaaaaaaaaaab';
grant replication slave on *.* to replicate@127.0.0.1 identified by 'aaaaaaaaaaaaaaab';
-slave start;
+start slave;
drop table if exists t1;
create table t1(n int);
insert into t1 values(24);
diff --git a/mysql-test/r/rpl000018.result b/mysql-test/r/rpl000018.result
index 282c1e492a1..b71f6492b97 100644
--- a/mysql-test/r/rpl000018.result
+++ b/mysql-test/r/rpl000018.result
@@ -1,10 +1,10 @@
reset master;
reset slave;
-slave start;
-show master logs;
+start slave;
+show binary logs;
Log_name
-master-bin.001
-master-bin.002
+master-bin.000001
+master-bin.000002
drop table if exists t1;
create table t1(n int);
insert into t1 values (3351);
diff --git a/mysql-test/r/rpl_alter.result b/mysql-test/r/rpl_alter.result
index 729c7df6808..6ef5ce3462a 100644
--- a/mysql-test/r/rpl_alter.result
+++ b/mysql-test/r/rpl_alter.result
@@ -1,21 +1,21 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
-drop database if exists test_$1;
-create database test_$1;
-create table test_$1.t1 ( n int);
-alter table test_$1.t1 add m int;
-insert into test_$1.t1 values (1,2);
-create table test_$1.t2 (n int);
-insert into test_$1.t2 values (45);
-rename table test_$1.t2 to test_$1.t3, test_$1.t1 to test_$1.t2;
-select * from test_$1.t2;
+start slave;
+drop database if exists mysqltest;
+create database mysqltest;
+create table mysqltest.t1 ( n int);
+alter table mysqltest.t1 add m int;
+insert into mysqltest.t1 values (1,2);
+create table mysqltest.t2 (n int);
+insert into mysqltest.t2 values (45);
+rename table mysqltest.t2 to mysqltest.t3, mysqltest.t1 to mysqltest.t2;
+select * from mysqltest.t2;
n m
1 2
-select * from test_$1.t3;
+select * from mysqltest.t3;
n
45
-drop database test_$1;
+drop database mysqltest;
diff --git a/mysql-test/r/rpl_do_grant.result b/mysql-test/r/rpl_do_grant.result
index fec935ae7ac..983cdf46620 100644
--- a/mysql-test/r/rpl_do_grant.result
+++ b/mysql-test/r/rpl_do_grant.result
@@ -1,9 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
delete from mysql.user where user='rpl_do_grant';
delete from mysql.db where user='rpl_do_grant';
flush privileges;
diff --git a/mysql-test/r/rpl_empty_master_crash.result b/mysql-test/r/rpl_empty_master_crash.result
index 19e2bf28dcd..41c5ebe47e1 100644
--- a/mysql-test/r/rpl_empty_master_crash.result
+++ b/mysql-test/r/rpl_empty_master_crash.result
@@ -1,13 +1,12 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
-drop table if exists t1;
+start slave;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
load table t1 from master;
-Error connecting to master: Master is not configured
+ERROR 08S01: Error connecting to master: Master is not configured
load table t1 from master;
-Error from master: 'Table 'test.t1' doesn't exist'
+ERROR HY000: Error from master: 'Table 'test.t1' doesn't exist'
diff --git a/mysql-test/r/rpl_error_ignored_table.result b/mysql-test/r/rpl_error_ignored_table.result
index e1486220542..2baa69d4aad 100644
--- a/mysql-test/r/rpl_error_ignored_table.result
+++ b/mysql-test/r/rpl_error_ignored_table.result
@@ -1,15 +1,15 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
create table t1 (a int primary key);
insert into t1 values (1),(1);
-Duplicate entry '1' for key 1
+ERROR 23000: Duplicate entry '1' for key 1
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.001 213 slave-relay-bin.002 254 master-bin.001 Yes Yes 0 0 213 254
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 213 slave-relay-bin.000002 257 master-bin.000001 Yes Yes test.t1 0 0 213 257 None 0 No #
show tables like 't1';
Tables_in_test (t1)
drop table t1;
diff --git a/mysql-test/r/rpl_failsafe.result b/mysql-test/r/rpl_failsafe.result
index 7e8aeea64f7..956555f9318 100644
--- a/mysql-test/r/rpl_failsafe.result
+++ b/mysql-test/r/rpl_failsafe.result
@@ -1,9 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
show variables like 'rpl_recovery_rank';
Variable_name Value
rpl_recovery_rank 1
@@ -18,14 +18,14 @@ rpl_recovery_rank 2
show status like 'Rpl_status';
Variable_name Value
Rpl_status ACTIVE_SLAVE
-slave start;
+start slave;
show variables like 'rpl_recovery_rank';
Variable_name Value
rpl_recovery_rank 3
show status like 'Rpl_status';
Variable_name Value
Rpl_status ACTIVE_SLAVE
-slave start;
+start slave;
show variables like 'rpl_recovery_rank';
Variable_name Value
rpl_recovery_rank 4
diff --git a/mysql-test/r/rpl_flush_log_loop.result b/mysql-test/r/rpl_flush_log_loop.result
index 18786b1931b..e0f85210616 100644
--- a/mysql-test/r/rpl_flush_log_loop.result
+++ b/mysql-test/r/rpl_flush_log_loop.result
@@ -1,17 +1,17 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=MASTER_PORT;
-slave start;
-slave stop;
+start slave;
+stop slave;
change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=SLAVE_PORT;
-slave start;
+start slave;
flush logs;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root SLAVE_PORT 60 slave-bin.001 79 relay-log.002 4 slave-bin.001 Yes Yes 0 0 79 4
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root SLAVE_PORT 60 slave-bin.000001 79 relay-log.000002 4 slave-bin.000001 Yes Yes 0 0 79 4 None 0 No #
diff --git a/mysql-test/r/rpl_flush_tables.result b/mysql-test/r/rpl_flush_tables.result
new file mode 100644
index 00000000000..6353a6101d6
--- /dev/null
+++ b/mysql-test/r/rpl_flush_tables.result
@@ -0,0 +1,40 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+create table t1 (a int);
+insert into t1 values (10);
+create table t2 (a int);
+create table t3 (a int) type=merge union(t1);
+create table t4 (a int);
+insert into t4 select * from t3;
+rename table t1 to t5, t2 to t1;
+flush no_write_to_binlog tables;
+show binlog events;
+Log_name Pos Event_type Server_id Orig_log_pos Info
+master-bin.000001 4 Start 1 4 Server ver: SERVER_VERSION, Binlog ver: 3
+master-bin.000001 79 Query 1 79 use `test`; create table t1 (a int)
+master-bin.000001 137 Query 1 137 use `test`; insert into t1 values (10)
+master-bin.000001 198 Query 1 198 use `test`; create table t2 (a int)
+master-bin.000001 256 Query 1 256 use `test`; create table t3 (a int) type=merge union(t1)
+master-bin.000001 335 Query 1 335 use `test`; create table t4 (a int)
+master-bin.000001 393 Query 1 393 use `test`; insert into t4 select * from t3
+master-bin.000001 459 Query 1 459 use `test`; rename table t1 to t5, t2 to t1
+select * from t3;
+a
+flush tables;
+show binlog events;
+Log_name Pos Event_type Server_id Orig_log_pos Info
+master-bin.000001 4 Start 1 4 Server ver: SERVER_VERSION, Binlog ver: 3
+master-bin.000001 79 Query 1 79 use `test`; create table t1 (a int)
+master-bin.000001 137 Query 1 137 use `test`; insert into t1 values (10)
+master-bin.000001 198 Query 1 198 use `test`; create table t2 (a int)
+master-bin.000001 256 Query 1 256 use `test`; create table t3 (a int) type=merge union(t1)
+master-bin.000001 335 Query 1 335 use `test`; create table t4 (a int)
+master-bin.000001 393 Query 1 393 use `test`; insert into t4 select * from t3
+master-bin.000001 459 Query 1 459 use `test`; rename table t1 to t5, t2 to t1
+master-bin.000001 525 Query 1 525 use `test`; flush tables
+select * from t3;
+a
diff --git a/mysql-test/r/rpl_get_lock.result b/mysql-test/r/rpl_get_lock.result
index a8e602be03f..8e3e335b2d0 100644
--- a/mysql-test/r/rpl_get_lock.result
+++ b/mysql-test/r/rpl_get_lock.result
@@ -1,9 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
create table t1(n int);
insert into t1 values(get_lock("lock",2));
select get_lock("lock",2);
@@ -18,9 +18,14 @@ get_lock("lock",3)
select * from t1;
n
1
-select is_free_lock("lock");
-is_free_lock("lock")
-0
+select is_free_lock("lock"), is_used_lock("lock");
+is_free_lock("lock") is_used_lock("lock")
+0 6
+explain extended select is_free_lock("lock"), is_used_lock("lock");
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority no_cache is_free_lock(_latin1'lock') AS `is_free_lock("lock")`,is_used_lock(_latin1'lock') AS `is_used_lock("lock")`
select is_free_lock("lock2");
is_free_lock("lock2")
1
diff --git a/mysql-test/r/rpl_ignore_grant.result b/mysql-test/r/rpl_ignore_grant.result
index 6cd7d5b4c00..5e970e71d0b 100644
--- a/mysql-test/r/rpl_ignore_grant.result
+++ b/mysql-test/r/rpl_ignore_grant.result
@@ -1,9 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
delete from mysql.user where user='rpl_ignore_grant';
delete from mysql.db where user='rpl_ignore_grant';
flush privileges;
@@ -17,7 +17,7 @@ Grants for rpl_ignore_grant@localhost
GRANT SELECT ON *.* TO 'rpl_ignore_grant'@'localhost'
GRANT DROP ON `test`.* TO 'rpl_ignore_grant'@'localhost'
show grants for rpl_ignore_grant@localhost;
-There is no such grant defined for user 'rpl_ignore_grant' on host 'localhost'
+ERROR 42000: There is no such grant defined for user 'rpl_ignore_grant' on host 'localhost'
select count(*) from mysql.user where user='rpl_ignore_grant';
count(*)
0
diff --git a/mysql-test/r/rpl_insert_id.result b/mysql-test/r/rpl_insert_id.result
index 889e7891770..cf70e196921 100644
--- a/mysql-test/r/rpl_insert_id.result
+++ b/mysql-test/r/rpl_insert_id.result
@@ -1,10 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
-drop table if exists t1;
+start slave;
create table t1(a int auto_increment, key(a));
create table t2(b int auto_increment, c int, key(b));
insert into t1 values (1),(2),(3);
diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result
index 268e383ce69..6ab45a369ca 100644
--- a/mysql-test/r/rpl_loaddata.result
+++ b/mysql-test/r/rpl_loaddata.result
@@ -1,9 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
reset master;
create table t1(a int not null auto_increment, b int, primary key(a) );
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
@@ -22,7 +22,7 @@ day id category name
2003-03-22 2416 a bbbbb
show master status;
File Position Binlog_do_db Binlog_ignore_db
-slave-bin.001 964
+slave-bin.000001 964
drop table t1;
drop table t2;
drop table t3;
@@ -32,8 +32,8 @@ load data infile '../../std_data/rpl_loaddata.dat' into table t1;
set global sql_slave_skip_counter=1;
start slave;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.001 1311 slave-relay-bin.002 1352 master-bin.001 Yes Yes 0 0 1311 1352
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1311 slave-relay-bin.000002 1355 master-bin.000001 Yes Yes 0 0 1311 1355 None 0 No #
set sql_log_bin=0;
delete from t1;
set sql_log_bin=1;
@@ -42,8 +42,8 @@ stop slave;
change master to master_user='test';
change master to master_user='root';
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.001 1419 slave-relay-bin.001 4 master-bin.001 No No 0 0 1419 4
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1419 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 1419 4 None 0 No #
set global sql_slave_skip_counter=1;
start slave;
set sql_log_bin=0;
@@ -53,16 +53,16 @@ load data infile '../../std_data/rpl_loaddata.dat' into table t1;
stop slave;
reset slave;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 4 slave-relay-bin.001 4 No No 0 0 0 4
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No #
reset master;
create table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60),
unique(day));
load data infile '../../std_data/rpl_loaddata2.dat' into table t2 fields
terminated by ',' optionally enclosed by '%' escaped by '@' lines terminated by
'\n##\n' starting by '>' ignore 1 lines;
-Duplicate entry '2003-03-22' for key 1
+ERROR 23000: Duplicate entry '2003-03-22' for key 1
show master status;
File Position Binlog_do_db Binlog_ignore_db
-master-bin.001 491
+master-bin.000001 491
drop table t2;
diff --git a/mysql-test/r/rpl_loaddata_rule_m.result b/mysql-test/r/rpl_loaddata_rule_m.result
index 8d8ed749c71..ed0c96bbfe1 100644
--- a/mysql-test/r/rpl_loaddata_rule_m.result
+++ b/mysql-test/r/rpl_loaddata_rule_m.result
@@ -1,14 +1,15 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
+drop database if exists mysqltest;
reset master;
-create database test2;
+create database mysqltest;
create table t1(a int, b int, unique(b));
-use test2;
+use mysqltest;
load data infile '../../std_data/rpl_loaddata.dat' into table test.t1;
show binlog events from 79;
Log_name Pos Event_type Server_id Orig_log_pos Info
-drop database test2;
+drop database mysqltest;
diff --git a/mysql-test/r/rpl_loaddata_rule_s.result b/mysql-test/r/rpl_loaddata_rule_s.result
index a84368501a9..26893cb1e9e 100644
--- a/mysql-test/r/rpl_loaddata_rule_s.result
+++ b/mysql-test/r/rpl_loaddata_rule_s.result
@@ -1,9 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
reset master;
create table t1(a int, b int, unique(b));
load data infile '../../std_data/rpl_loaddata.dat' into table test.t1;
diff --git a/mysql-test/r/rpl_loaddatalocal.result b/mysql-test/r/rpl_loaddatalocal.result
index dc98b1b5bfb..b49ea842485 100644
--- a/mysql-test/r/rpl_loaddatalocal.result
+++ b/mysql-test/r/rpl_loaddatalocal.result
@@ -1,9 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
create table t1(a int);
select * into outfile '../../var/master-data/rpl_loaddatalocal.select_outfile' from t1;
truncate table t1;
diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result
index 7e2a8df75ac..6860067a2d4 100644
--- a/mysql-test/r/rpl_log.result
+++ b/mysql-test/r/rpl_log.result
@@ -1,10 +1,10 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
-slave stop;
+start slave;
+stop slave;
reset master;
reset slave;
reset master;
@@ -19,83 +19,83 @@ count(*)
drop table t1;
show binlog events;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
-master-bin.001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key)
-master-bin.001 172 Intvar 1 172 INSERT_ID=1
-master-bin.001 200 Query 1 200 use `test`; insert into t1 values (NULL)
-master-bin.001 263 Query 1 263 use `test`; drop table t1
-master-bin.001 311 Query 1 311 use `test`; create table t1 (word char(20) not null)
-master-bin.001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581
-master-bin.001 1056 Exec_load 1 1056 ;file_id=1
-master-bin.001 1079 Query 1 1079 use `test`; drop table t1
+master-bin.000001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
+master-bin.000001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key)
+master-bin.000001 172 Intvar 1 172 INSERT_ID=1
+master-bin.000001 200 Query 1 200 use `test`; insert into t1 values (NULL)
+master-bin.000001 263 Query 1 263 use `test`; drop table t1
+master-bin.000001 311 Query 1 311 use `test`; create table t1 (word char(20) not null)
+master-bin.000001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581
+master-bin.000001 1056 Exec_load 1 1056 ;file_id=1
+master-bin.000001 1079 Query 1 1079 use `test`; drop table t1
show binlog events from 79 limit 1;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key)
+master-bin.000001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key)
show binlog events from 79 limit 2;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key)
-master-bin.001 172 Intvar 1 172 INSERT_ID=1
+master-bin.000001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key)
+master-bin.000001 172 Intvar 1 172 INSERT_ID=1
show binlog events from 79 limit 2,1;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 200 Query 1 200 use `test`; insert into t1 values (NULL)
+master-bin.000001 200 Query 1 200 use `test`; insert into t1 values (NULL)
flush logs;
create table t5 (a int);
drop table t5;
-slave start;
+start slave;
flush logs;
-slave stop;
+stop slave;
create table t1 (n int);
insert into t1 values (1);
drop table t1;
show binlog events;
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
-master-bin.001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key)
-master-bin.001 172 Intvar 1 172 INSERT_ID=1
-master-bin.001 200 Query 1 200 use `test`; insert into t1 values (NULL)
-master-bin.001 263 Query 1 263 use `test`; drop table t1
-master-bin.001 311 Query 1 311 use `test`; create table t1 (word char(20) not null)
-master-bin.001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581
-master-bin.001 1056 Exec_load 1 1056 ;file_id=1
-master-bin.001 1079 Query 1 1079 use `test`; drop table t1
-master-bin.001 1127 Rotate 1 1127 master-bin.002;pos=4
-show binlog events in 'master-bin.002';
+master-bin.000001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
+master-bin.000001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key)
+master-bin.000001 172 Intvar 1 172 INSERT_ID=1
+master-bin.000001 200 Query 1 200 use `test`; insert into t1 values (NULL)
+master-bin.000001 263 Query 1 263 use `test`; drop table t1
+master-bin.000001 311 Query 1 311 use `test`; create table t1 (word char(20) not null)
+master-bin.000001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581
+master-bin.000001 1056 Exec_load 1 1056 ;file_id=1
+master-bin.000001 1079 Query 1 1079 use `test`; drop table t1
+master-bin.000001 1127 Rotate 1 1127 master-bin.000002;pos=4
+show binlog events in 'master-bin.000002';
Log_name Pos Event_type Server_id Orig_log_pos Info
-master-bin.002 4 Query 1 4 use `test`; create table t5 (a int)
-master-bin.002 62 Query 1 62 use `test`; drop table t5
-master-bin.002 110 Query 1 110 use `test`; create table t1 (n int)
-master-bin.002 168 Query 1 168 use `test`; insert into t1 values (1)
-master-bin.002 228 Query 1 228 use `test`; drop table t1
-show master logs;
+master-bin.000002 4 Query 1 4 use `test`; create table t5 (a int)
+master-bin.000002 62 Query 1 62 use `test`; drop table t5
+master-bin.000002 110 Query 1 110 use `test`; create table t1 (n int)
+master-bin.000002 168 Query 1 168 use `test`; insert into t1 values (1)
+master-bin.000002 228 Query 1 228 use `test`; drop table t1
+show binary logs;
Log_name
-master-bin.001
-master-bin.002
-slave start;
-show master logs;
+master-bin.000001
+master-bin.000002
+start slave;
+show binary logs;
Log_name
-slave-bin.001
-slave-bin.002
-show binlog events in 'slave-bin.001' from 4;
+slave-bin.000001
+slave-bin.000002
+show binlog events in 'slave-bin.000001' from 4;
Log_name Pos Event_type Server_id Orig_log_pos Info
-slave-bin.001 4 Start 2 4 Server ver: VERSION, Binlog ver: 3
-slave-bin.001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key)
-slave-bin.001 172 Intvar 1 172 INSERT_ID=1
-slave-bin.001 200 Query 1 200 use `test`; insert into t1 values (NULL)
-slave-bin.001 263 Query 1 263 use `test`; drop table t1
-slave-bin.001 311 Query 1 311 use `test`; create table t1 (word char(20) not null)
-slave-bin.001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581
-slave-bin.001 1065 Exec_load 1 1065 ;file_id=1
-slave-bin.001 1088 Query 1 1088 use `test`; drop table t1
-slave-bin.001 1136 Query 1 1136 use `test`; create table t5 (a int)
-slave-bin.001 1194 Query 1 1194 use `test`; drop table t5
-slave-bin.001 1242 Rotate 2 1242 slave-bin.002;pos=4
-show binlog events in 'slave-bin.002' from 4;
+slave-bin.000001 4 Start 2 4 Server ver: VERSION, Binlog ver: 3
+slave-bin.000001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key)
+slave-bin.000001 172 Intvar 1 172 INSERT_ID=1
+slave-bin.000001 200 Query 1 200 use `test`; insert into t1 values (NULL)
+slave-bin.000001 263 Query 1 263 use `test`; drop table t1
+slave-bin.000001 311 Query 1 311 use `test`; create table t1 (word char(20) not null)
+slave-bin.000001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581
+slave-bin.000001 1065 Exec_load 1 1065 ;file_id=1
+slave-bin.000001 1088 Query 1 1088 use `test`; drop table t1
+slave-bin.000001 1136 Query 1 1136 use `test`; create table t5 (a int)
+slave-bin.000001 1194 Query 1 1194 use `test`; drop table t5
+slave-bin.000001 1242 Rotate 2 1242 slave-bin.000002;pos=4
+show binlog events in 'slave-bin.000002' from 4;
Log_name Pos Event_type Server_id Orig_log_pos Info
-slave-bin.002 4 Query 1 4 use `test`; create table t1 (n int)
-slave-bin.002 62 Query 1 62 use `test`; insert into t1 values (1)
-slave-bin.002 122 Query 1 122 use `test`; drop table t1
+slave-bin.000002 4 Query 1 4 use `test`; create table t1 (n int)
+slave-bin.000002 62 Query 1 62 use `test`; insert into t1 values (1)
+slave-bin.000002 122 Query 1 122 use `test`; drop table t1
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.002 276 slave-relay-bin.003 211 master-bin.002 Yes Yes 0 0 276 211
-show binlog events in 'slave-bin.005' from 4;
-Error when executing command SHOW BINLOG EVENTS: Could not find target log
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 276 slave-relay-bin.000003 214 master-bin.000002 Yes Yes 0 0 276 214 None 0 No #
+show binlog events in 'slave-bin.000005' from 4;
+ERROR HY000: Error when executing command SHOW BINLOG EVENTS: Could not find target log
diff --git a/mysql-test/r/rpl_log_pos.result b/mysql-test/r/rpl_log_pos.result
index f7e59e55577..098fb056cc6 100644
--- a/mysql-test/r/rpl_log_pos.result
+++ b/mysql-test/r/rpl_log_pos.result
@@ -1,43 +1,43 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
show master status;
File Position Binlog_do_db Binlog_ignore_db
-master-bin.001 79
+master-bin.000001 79
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.001 79 slave-relay-bin.002 120 master-bin.001 Yes Yes 0 0 79 120
-slave stop;
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 123 None 0 No #
+stop slave;
change master to master_log_pos=73;
-slave start;
-slave stop;
+start slave;
+stop slave;
change master to master_log_pos=73;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.001 73 slave-relay-bin.001 4 master-bin.001 No No 0 0 73 4
-slave start;
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 73 4 None 0 No #
+start slave;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.001 73 slave-relay-bin.001 45 master-bin.001 No Yes 0 0 73 45
-slave stop;
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 73 slave-relay-bin.000001 48 master-bin.000001 No Yes 0 0 73 48 None 0 No #
+stop slave;
change master to master_log_pos=173;
-slave start;
+start slave;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.001 173 slave-relay-bin.001 4 master-bin.001 No Yes 0 0 173 4
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 173 slave-relay-bin.000001 4 master-bin.000001 No Yes 0 0 173 4 None 0 No #
show master status;
File Position Binlog_do_db Binlog_ignore_db
-master-bin.001 79
+master-bin.000001 79
create table if not exists t1 (n int);
drop table if exists t1;
create table t1 (n int);
insert into t1 values (1),(2),(3);
-slave stop;
+stop slave;
change master to master_log_pos=79;
-slave start;
+start slave;
select * from t1;
n
1
diff --git a/mysql-test/r/rpl_master_pos_wait.result b/mysql-test/r/rpl_master_pos_wait.result
index cb6ee31a54d..ea917805560 100644
--- a/mysql-test/r/rpl_master_pos_wait.result
+++ b/mysql-test/r/rpl_master_pos_wait.result
@@ -1,12 +1,17 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
select master_pos_wait('master-bin.999999',0,2);
master_pos_wait('master-bin.999999',0,2)
-1
+explain extended select master_pos_wait('master-bin.999999',0,2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority no_cache master_pos_wait(_latin1'master-bin.999999',0,2) AS `master_pos_wait('master-bin.999999',0,2)`
select master_pos_wait('master-bin.999999',0);
stop slave sql_thread;
master_pos_wait('master-bin.999999',0)
diff --git a/mysql-test/r/rpl_max_relay_size.result b/mysql-test/r/rpl_max_relay_size.result
index 1fa3fcd1adb..2d08ca6e3a3 100644
--- a/mysql-test/r/rpl_max_relay_size.result
+++ b/mysql-test/r/rpl_max_relay_size.result
@@ -1,9 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
stop slave;
create table t1 (a int);
drop table t1;
@@ -15,8 +15,8 @@ select @@global.max_relay_log_size;
4096
start slave;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.001 50477 slave-relay-bin.014 1221 master-bin.001 Yes Yes 0 0 50477 1221
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50477 slave-relay-bin.000014 1221 master-bin.000001 Yes Yes 0 0 50477 1221 None 0 No #
stop slave;
reset slave;
set global max_relay_log_size=(5*4096);
@@ -25,8 +25,8 @@ select @@global.max_relay_log_size;
20480
start slave;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.001 50477 slave-relay-bin.004 9457 master-bin.001 Yes Yes 0 0 50477 9457
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50477 slave-relay-bin.000004 9457 master-bin.000001 Yes Yes 0 0 50477 9457 None 0 No #
stop slave;
reset slave;
set global max_relay_log_size=0;
@@ -35,27 +35,27 @@ select @@global.max_relay_log_size;
0
start slave;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.001 50477 slave-relay-bin.008 1283 master-bin.001 Yes Yes 0 0 50477 1283
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50477 slave-relay-bin.000008 1283 master-bin.000001 Yes Yes 0 0 50477 1283 None 0 No #
stop slave;
reset slave;
flush logs;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 4 slave-relay-bin.001 4 No No 0 0 0 4
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No #
reset slave;
start slave;
flush logs;
create table t1 (a int);
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.001 50535 slave-relay-bin.009 62 master-bin.001 Yes Yes 0 0 50535 62
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50535 slave-relay-bin.000009 62 master-bin.000001 Yes Yes 0 0 50535 62 None 0 No #
flush logs;
drop table t1;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.001 50583 slave-relay-bin.010 52 master-bin.001 Yes Yes 0 0 50583 52
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 50583 slave-relay-bin.000010 52 master-bin.000001 Yes Yes 0 0 50583 52 None 0 No #
flush logs;
show master status;
File Position Binlog_do_db Binlog_ignore_db
-master-bin.002 4
+master-bin.000002 4
diff --git a/mysql-test/r/rpl_misc_functions.result b/mysql-test/r/rpl_misc_functions.result
new file mode 100644
index 00000000000..a687063706d
--- /dev/null
+++ b/mysql-test/r/rpl_misc_functions.result
@@ -0,0 +1,21 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+create table t1(id int, i int, r1 int, r2 int, p varchar(100));
+insert into t1 values(1, connection_id(), 0, 0, "");
+insert into t1 values(2, 0, rand()*1000, rand()*1000, "");
+set sql_log_bin=0;
+insert into t1 values(6, 0, rand(), rand(), "");
+delete from t1 where id=6;
+set sql_log_bin=1;
+insert into t1 values(3, 0, 0, 0, password('does_this_work?'));
+insert into t1 values(4, connection_id(), rand()*1000, rand()*1000, password('does_this_still_work?'));
+select * into outfile 'rpl_misc_functions.outfile' from t1;
+create table t2 like t1;
+load data local infile './var/master-data/test/rpl_misc_functions.outfile' into table t2;
+select * from t1, t2 where (t1.id=t2.id) and not(t1.i=t2.i and t1.r1=t2.r1 and t1.r2=t2.r2 and t1.p=t2.p);
+id i r1 r2 p id i r1 r2 p
+stop slave;
diff --git a/mysql-test/r/rpl_mystery22.result b/mysql-test/r/rpl_mystery22.result
index 5dd665fe9d5..348b3211cd5 100644
--- a/mysql-test/r/rpl_mystery22.result
+++ b/mysql-test/r/rpl_mystery22.result
@@ -1,20 +1,20 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
create table t1(n int auto_increment primary key);
insert into t1 values (2);
insert into t1 values(NULL);
insert into t1 values(NULL);
delete from t1 where n = 2;
-slave start;
-slave stop;
+start slave;
+stop slave;
create table t2(n int);
drop table t2;
insert into t1 values(NULL);
-slave start;
+start slave;
select * from t1;
n
1
diff --git a/mysql-test/r/rpl_openssl.result b/mysql-test/r/rpl_openssl.result
new file mode 100644
index 00000000000..32760f2c870
--- /dev/null
+++ b/mysql-test/r/rpl_openssl.result
@@ -0,0 +1,30 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+grant replication slave on *.* to replssl@'%' require ssl;
+create table t1 (t int);
+stop slave;
+change master to master_user='replssl',master_password='';
+start slave;
+insert into t1 values (1);
+select * from t1;
+t
+stop slave;
+change master to master_ssl=1 , master_ssl_ca ='MYSQL_TEST_DIR/std_data/cacert.pem', master_ssl_cert='MYSQL_TEST_DIR/std_data/client-cert.pem', master_ssl_key='MYSQL_TEST_DIR/std_data/client-key.pem';
+start slave;
+select * from t1;
+t
+1
+show slave status;
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 replssl MASTER_MYPORT 1 master-bin.000001 289 slave-relay-bin.000001 108 master-bin.000001 Yes Yes 0 0 289 108 None 0 Yes MYSQL_TEST_DIR/std_data/cacert.pem MYSQL_TEST_DIR/std_data/client-cert.pem MYSQL_TEST_DIR/std_data/client-key.pem #
+stop slave;
+change master to master_user='root',master_password='', master_ssl=0;
+start slave;
+drop table t1;
+show slave status;
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 337 slave-relay-bin.000001 96 master-bin.000001 Yes Yes 0 0 337 96 None 0 No MYSQL_TEST_DIR/std_data/cacert.pem MYSQL_TEST_DIR/std_data/client-cert.pem MYSQL_TEST_DIR/std_data/client-key.pem #
diff --git a/mysql-test/r/rpl_redirect.result b/mysql-test/r/rpl_redirect.result
index 6103a075684..24a0b1af541 100644
--- a/mysql-test/r/rpl_redirect.result
+++ b/mysql-test/r/rpl_redirect.result
@@ -1,15 +1,14 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
SHOW SLAVE STATUS;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
SHOW SLAVE HOSTS;
Server_id Host Port Rpl_recovery_rank Master_id
2 127.0.0.1 SLAVE_PORT 2 1
-drop table if exists t1;
create table t1 ( n int);
insert into t1 values (1),(2),(3),(4);
insert into t1 values(5);
diff --git a/mysql-test/r/rpl_relayrotate.result b/mysql-test/r/rpl_relayrotate.result
new file mode 100644
index 00000000000..802be911ad7
--- /dev/null
+++ b/mysql-test/r/rpl_relayrotate.result
@@ -0,0 +1,19 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+stop slave;
+create table t1 (a int) type=innodb;
+reset slave;
+start slave;
+stop slave;
+start slave;
+select master_pos_wait('master-bin.001',3000)>=0;
+master_pos_wait('master-bin.001',3000)>=0
+1
+select * from t1 where a=8000;
+a
+8000
+drop table t1;
diff --git a/mysql-test/r/rpl_relayspace.result b/mysql-test/r/rpl_relayspace.result
index 721c6a882bd..1f2a739d3e3 100644
--- a/mysql-test/r/rpl_relayspace.result
+++ b/mysql-test/r/rpl_relayspace.result
@@ -1,9 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
stop slave;
create table t1 (a int);
drop table t1;
diff --git a/mysql-test/r/rpl_replicate_do.result b/mysql-test/r/rpl_replicate_do.result
index 372d8c07f64..271ee9cefa1 100644
--- a/mysql-test/r/rpl_replicate_do.result
+++ b/mysql-test/r/rpl_replicate_do.result
@@ -1,9 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
drop table if exists t11;
drop table if exists t11;
create table t2 (n int);
@@ -24,5 +24,8 @@ select * from t2;
n
4
select * from t11;
-Table 'test.t11' doesn't exist
-drop table if exists t1,t2,t3,t11;
+ERROR 42S02: Table 'test.t11' doesn't exist
+drop table if exists t1,t2,t11;
+show slave status;
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 1281 slave-relay-bin.000002 1325 master-bin.000001 Yes Yes test.t1 0 0 1281 1325 None 0 No #
diff --git a/mysql-test/r/rpl_reset_slave.result b/mysql-test/r/rpl_reset_slave.result
index fb931064720..e1fbf12786d 100644
--- a/mysql-test/r/rpl_reset_slave.result
+++ b/mysql-test/r/rpl_reset_slave.result
@@ -1,25 +1,25 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.001 79 slave-relay-bin.002 120 master-bin.001 Yes Yes 0 0 79 120
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 123 None 0 No #
stop slave;
change master to master_user='test';
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 test MASTER_PORT 1 master-bin.001 79 slave-relay-bin.001 4 master-bin.001 No No 0 0 79 4
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 test MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000001 4 master-bin.000001 No No 0 0 79 4 None 0 No #
reset slave;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 4 slave-relay-bin.001 4 No No 0 0 0 4
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 4 slave-relay-bin.000001 4 No No 0 0 0 4 None 0 No #
start slave;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.001 79 slave-relay-bin.002 120 master-bin.001 Yes Yes 0 0 79 120
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000001 79 slave-relay-bin.000002 123 master-bin.000001 Yes Yes 0 0 79 123 None 0 No #
stop slave;
reset slave;
start slave;
diff --git a/mysql-test/r/rpl_rotate_logs.result b/mysql-test/r/rpl_rotate_logs.result
index 07490744d81..4e31164f2ec 100644
--- a/mysql-test/r/rpl_rotate_logs.result
+++ b/mysql-test/r/rpl_rotate_logs.result
@@ -1,36 +1,35 @@
drop table if exists t1, t2, t3, t4;
drop table if exists t1, t2, t3, t4;
-slave start;
-Could not initialize master info structure, check permisions on master.info
-slave start;
-Could not initialize master info structure, check permisions on master.info
+start slave;
+ERROR HY000: Could not initialize master info structure, check permisions on master.info
+start slave;
+ERROR HY000: Could not initialize master info structure, check permisions on master.info
change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root';
-Could not initialize master info structure, check permisions on master.info
+ERROR HY000: Could not initialize master info structure, check permisions on master.info
reset slave;
change master to master_host='127.0.0.1',master_port=MASTER_PORT, master_user='root';
reset master;
-slave start;
+start slave;
create temporary table temp_table (a char(80) not null);
insert into temp_table values ("testing temporary tables");
create table t1 (s text);
insert into t1 values('Could not break slave'),('Tried hard');
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 60 master-bin.001 417 slave-relay-bin.001 458 master-bin.001 Yes Yes 0 0 417 458
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 60 master-bin.000001 417 slave-relay-bin.000001 461 master-bin.000001 Yes Yes 0 0 417 461 None 0 No #
select * from t1;
s
Could not break slave
Tried hard
flush logs;
-drop table if exists t2;
create table t2(m int not null auto_increment primary key);
insert into t2 values (34),(67),(123);
flush logs;
-show master logs;
+show binary logs;
Log_name
-master-bin.001
-master-bin.002
-master-bin.003
+master-bin.000001
+master-bin.000002
+master-bin.000003
create table t3 select * from temp_table;
select * from t3;
a
@@ -40,15 +39,25 @@ insert into t2 values(1234);
set insert_id=1234;
insert into t2 values(NULL);
set global sql_slave_skip_counter=1;
-slave start;
-purge master logs to 'master-bin.003';
+start slave;
+purge master logs to 'master-bin.000002';
show master logs;
Log_name
-master-bin.003
+master-bin.000002
+master-bin.000003
+purge binary logs to 'master-bin.000002';
+show binary logs;
+Log_name
+master-bin.000002
+master-bin.000003
+purge master logs before now();
+show binary logs;
+Log_name
+master-bin.000003
insert into t2 values (65);
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 60 master-bin.003 290 slave-relay-bin.001 1073 master-bin.003 Yes Yes 0 0 290 1073
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 60 master-bin.000003 290 slave-relay-bin.000001 1088 master-bin.000003 Yes Yes 0 0 290 1088 None 0 No #
select * from t2;
m
34
@@ -58,22 +67,21 @@ m
1234
create temporary table temp_table (a char(80) not null);
insert into temp_table values ("testing temporary tables part 2");
-drop table if exists t3;
create table t3 (n int);
create table t4 select * from temp_table;
-show master logs;
+show binary logs;
Log_name
-master-bin.003
-master-bin.004
+master-bin.000003
+master-bin.000004
show master status;
File Position Binlog_do_db Binlog_ignore_db
-master-bin.004 2886
+master-bin.000004 2886
select * from t4;
a
testing temporary tables part 2
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 60 master-bin.004 2886 slave-relay-bin.001 7870 master-bin.004 Yes Yes 0 0 2886 7870
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 60 master-bin.000004 2886 slave-relay-bin.000001 7891 master-bin.000004 Yes Yes 0 0 2886 7891 None 0 No #
lock tables t3 read;
select count(*) from t3 where n >= 4;
count(*)
diff --git a/mysql-test/r/rpl_skip_error.result b/mysql-test/r/rpl_skip_error.result
index 946d64ad7c5..e52426c381c 100644
--- a/mysql-test/r/rpl_skip_error.result
+++ b/mysql-test/r/rpl_skip_error.result
@@ -1,10 +1,9 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
-drop table if exists t1;
+start slave;
create table t1 (n int not null primary key);
insert into t1 values (1);
insert into t1 values (1);
diff --git a/mysql-test/r/rpl_sporadic_master.result b/mysql-test/r/rpl_sporadic_master.result
index a6a58515f0a..789c3bf2b2b 100644
--- a/mysql-test/r/rpl_sporadic_master.result
+++ b/mysql-test/r/rpl_sporadic_master.result
@@ -1,16 +1,16 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
create table t2(n int);
create table t1(n int not null auto_increment primary key);
insert into t1 values (NULL),(NULL);
truncate table t1;
insert into t1 values (4),(NULL);
-slave stop;
-slave start;
+stop slave;
+start slave;
insert into t1 values (NULL),(NULL);
flush logs;
truncate table t1;
diff --git a/mysql-test/r/rpl_temporary.result b/mysql-test/r/rpl_temporary.result
new file mode 100644
index 00000000000..e7b64066c37
--- /dev/null
+++ b/mysql-test/r/rpl_temporary.result
@@ -0,0 +1,77 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+reset master;
+SET @@session.pseudo_thread_id=100;
+ERROR HY000: Access denied. You need the SUPER privilege for this operation
+drop table if exists t1,t2;
+create table t1(f int);
+create table t2(f int);
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+create temporary table t3(f int);
+insert into t3 select * from t1 where f<6;
+create temporary table t3(f int);
+insert into t2 select count(*) from t3;
+insert into t3 select * from t1 where f>=4;
+drop temporary table t3;
+insert into t2 select count(*) from t3;
+drop temporary table t3;
+select * from t2;
+f
+5
+7
+show binlog events;
+Log_name Pos Event_type Server_id Orig_log_pos Info
+master-bin.000001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
+master-bin.000001 79 Query 1 79 use `test`; create table t1(f int)
+master-bin.000001 136 Query 1 136 use `test`; create table t2(f int)
+master-bin.000001 193 Query 1 193 use `test`; insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10)
+master-bin.000001 290 Query 1 290 use `test`; create temporary table t3(f int)
+master-bin.000001 357 Query 1 357 use `test`; insert into t3 select * from t1 where f<6
+master-bin.000001 433 Query 1 433 use `test`; create temporary table t3(f int)
+master-bin.000001 500 Query 1 500 use `test`; insert into t2 select count(*) from t3
+master-bin.000001 573 Query 1 573 use `test`; insert into t3 select * from t1 where f>=4
+master-bin.000001 650 Query 1 650 use `test`; drop temporary table t3
+master-bin.000001 708 Query 1 708 use `test`; insert into t2 select count(*) from t3
+master-bin.000001 781 Query 1 781 use `test`; drop temporary table t3
+drop table t1, t2;
+use test;
+SET TIMESTAMP=1040323920;
+create table t1(f int);
+SET TIMESTAMP=1040323931;
+create table t2(f int);
+SET TIMESTAMP=1040323938;
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+SET TIMESTAMP=1040323945;
+SET @@session.pseudo_thread_id=1;
+create temporary table t3(f int);
+SET TIMESTAMP=1040323952;
+SET @@session.pseudo_thread_id=1;
+insert into t3 select * from t1 where f<6;
+SET TIMESTAMP=1040324145;
+SET @@session.pseudo_thread_id=2;
+create temporary table t3(f int);
+SET TIMESTAMP=1040324186;
+SET @@session.pseudo_thread_id=1;
+insert into t2 select count(*) from t3;
+SET TIMESTAMP=1040324200;
+SET @@session.pseudo_thread_id=2;
+insert into t3 select * from t1 where f>=4;
+SET TIMESTAMP=1040324211;
+SET @@session.pseudo_thread_id=1;
+drop temporary table t3;
+SET TIMESTAMP=1040324219;
+SET @@session.pseudo_thread_id=2;
+insert into t2 select count(*) from t3;
+SET TIMESTAMP=1040324224;
+SET @@session.pseudo_thread_id=2;
+drop temporary table t3;
+select * from t2;
+f
+5
+7
+drop table t1,t2;
+create temporary table t3 (f int);
diff --git a/mysql-test/r/rpl_trunc_binlog.result b/mysql-test/r/rpl_trunc_binlog.result
index eb5dcf7c593..caca15ab4ef 100644
--- a/mysql-test/r/rpl_trunc_binlog.result
+++ b/mysql-test/r/rpl_trunc_binlog.result
@@ -1,13 +1,13 @@
-slave stop;
+stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
-slave start;
+start slave;
stop slave;
flush logs;
reset slave;
start slave;
show slave status;
-Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
-127.0.0.1 root MASTER_PORT 1 master-bin.002 4 slave-relay-bin.002 161 master-bin.001 Yes No 0 Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. Probably cause is that the master died while writing the transaction to it's binary log. 0 79 317
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_PORT 1 master-bin.000002 4 slave-relay-bin.000002 123 master-bin.000001 Yes No 0 Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. Probably cause is that the master died while writing the transaction to it's binary log. 0 79 326 None 0 No #
diff --git a/mysql-test/r/rpl_until.result b/mysql-test/r/rpl_until.result
new file mode 100644
index 00000000000..3ee902cfc09
--- /dev/null
+++ b/mysql-test/r/rpl_until.result
@@ -0,0 +1,72 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+stop slave;
+create table t1(n int not null auto_increment primary key);
+insert into t1 values (1),(2),(3),(4);
+drop table t1;
+create table t2(n int not null auto_increment primary key);
+insert into t2 values (1),(2);
+insert into t2 values (3),(4);
+drop table t2;
+show binlog events;
+Log_name Pos Event_type Server_id Orig_log_pos Info
+master-bin.000001 4 Start 1 4 Server ver: VERSION, Binlog ver: 3
+master-bin.000001 79 Query 1 79 use `test`; create table t1(n int not null auto_increment primary key)
+master-bin.000001 172 Query 1 172 use `test`; insert into t1 values (1),(2),(3),(4)
+master-bin.000001 244 Query 1 244 use `test`; drop table t1
+master-bin.000001 292 Query 1 292 use `test`; create table t2(n int not null auto_increment primary key)
+master-bin.000001 385 Query 1 385 use `test`; insert into t2 values (1),(2)
+master-bin.000001 449 Query 1 449 use `test`; insert into t2 values (3),(4)
+master-bin.000001 513 Query 1 513 use `test`; drop table t2
+start slave until master_log_file='master-bin.000001', master_log_pos=244;
+select * from t1;
+n
+1
+2
+3
+4
+show slave status;
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 332 master-bin.000001 Yes No 0 0 244 649 Master master-bin.000001 244 No #
+start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291;
+select * from t1;
+n
+1
+2
+3
+4
+show slave status;
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 332 master-bin.000001 Yes No 0 0 244 649 Master master-no-such-bin.000001 291 No #
+start slave until relay_log_file='slave-relay-bin.000002', relay_log_pos=537;
+select * from t2;
+n
+1
+2
+show slave status;
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 537 master-bin.000001 Yes No 0 0 449 649 Relay slave-relay-bin.000002 537 No #
+start slave;
+stop slave;
+start slave until master_log_file='master-bin.000001', master_log_pos=561;
+show slave status;
+Slave_IO_State Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Replicate_do_table Replicate_ignore_table Replicate_wild_do_table Replicate_wild_ignore_table Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space Until_condition Until_Log_File Until_Log_pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_behind_master
+# 127.0.0.1 root MASTER_MYPORT 1 master-bin.000001 561 slave-relay-bin.000002 649 master-bin.000001 Yes No 0 0 561 693 Master master-bin.000001 561 No #
+start slave until master_log_file='master-bin', master_log_pos=561;
+ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL
+start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12;
+ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL
+start slave until master_log_file='master-bin.000001';
+ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL
+start slave until relay_log_file='slave-relay-bin.000002';
+ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL
+start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561;
+ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL
+start slave sql_thread;
+start slave until master_log_file='master-bin.000001', master_log_pos=561;
+Warnings:
+Note 1253 Slave is already running
diff --git a/mysql-test/r/rpl_user_variables.result b/mysql-test/r/rpl_user_variables.result
new file mode 100644
index 00000000000..71147772ac4
--- /dev/null
+++ b/mysql-test/r/rpl_user_variables.result
@@ -0,0 +1,109 @@
+stop slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+reset master;
+reset slave;
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
+start slave;
+reset master;
+create table t1(n char(30));
+set @i1:=12345678901234, @i2:=-12345678901234, @i3:=0, @i4:=-1;
+set @s1:='This is a test', @r1:=12.5, @r2:=-12.5;
+set @n1:=null;
+set @s2:='', @s3:='abc\'def', @s4:= 'abc\\def', @s5:= 'abc''def';
+insert into t1 values (@i1), (@i2), (@i3), (@i4);
+insert into t1 values (@r1), (@r2);
+insert into t1 values (@s1), (@s2), (@s3), (@s4), (@s5);
+insert into t1 values (@n1);
+insert into t1 values (@n2);
+insert into t1 values (@a:=0), (@a:=@a+1), (@a:=@a+1);
+insert into t1 values (@a+(@b:=@a+1));
+set @q:='abc';
+insert t1 values (@q), (@q:=concat(@q, 'n1')), (@q:=concat(@q, 'n2'));
+set @a:=5;
+insert into t1 values (@a),(@a);
+insert into t1 values (@a),(@a),(@a*5);
+select * from t1;
+n
+12345678901234
+-12345678901234
+0
+-1
+12.5
+-12.5
+This is a test
+
+abc'def
+abc\def
+abc'def
+NULL
+NULL
+0
+1
+2
+5
+abc
+abcn1
+abcn1n2
+5
+5
+NULL
+NULL
+NULL
+select * from t1;
+n
+12345678901234
+-12345678901234
+0
+-1
+12.5
+-12.5
+This is a test
+
+abc'def
+abc\def
+abc'def
+NULL
+NULL
+0
+1
+2
+5
+abc
+abcn1
+abcn1n2
+5
+5
+NULL
+NULL
+NULL
+show binlog events from 141;
+Log_name Pos Event_type Server_id Orig_log_pos Info
+slave-bin.000001 141 User var 2 141 @i1=12345678901234
+slave-bin.000001 184 User var 2 184 @i2=-12345678901234
+slave-bin.000001 227 User var 2 227 @i3=0
+slave-bin.000001 270 User var 2 270 @i4=-1
+slave-bin.000001 313 Query 1 313 use `test`; insert into t1 values (@i1), (@i2), (@i3), (@i4)
+slave-bin.000001 396 User var 2 396 @r1=12.5
+slave-bin.000001 439 User var 2 439 @r2=-12.5
+slave-bin.000001 482 Query 1 482 use `test`; insert into t1 values (@r1), (@r2)
+slave-bin.000001 551 User var 2 551 @s1='This is a test'
+slave-bin.000001 600 User var 2 600 @s2=''
+slave-bin.000001 635 User var 2 635 @s3='abc'def'
+slave-bin.000001 677 User var 2 677 @s4='abc\def'
+slave-bin.000001 719 User var 2 719 @s5='abc'def'
+slave-bin.000001 761 Query 1 761 use `test`; insert into t1 values (@s1), (@s2), (@s3), (@s4), (@s5)
+slave-bin.000001 851 User var 2 851 @n1=NULL
+slave-bin.000001 877 Query 1 877 use `test`; insert into t1 values (@n1)
+slave-bin.000001 939 User var 2 939 @n2=NULL
+slave-bin.000001 965 Query 1 965 use `test`; insert into t1 values (@n2)
+slave-bin.000001 1027 Query 1 1027 use `test`; insert into t1 values (@a:=0), (@a:=@a+1), (@a:=@a+1)
+slave-bin.000001 1115 User var 2 1115 @a=2
+slave-bin.000001 1157 Query 1 1157 use `test`; insert into t1 values (@a+(@b:=@a+1))
+slave-bin.000001 1229 User var 2 1229 @q='abc'
+slave-bin.000001 1266 Query 1 1266 use `test`; insert t1 values (@q), (@q:=concat(@q, 'n1')), (@q:=concat(@q, 'n2'))
+slave-bin.000001 1370 User var 2 1370 @a=5
+slave-bin.000001 1412 Query 1 1412 use `test`; insert into t1 values (@a),(@a)
+slave-bin.000001 1478 User var 2 1478 @a=NULL
+slave-bin.000001 1503 Query 1 1503 use `test`; insert into t1 values (@a),(@a),(@a*5)
+drop table t1;
+stop slave;
diff --git a/mysql-test/r/sel000001.result b/mysql-test/r/sel000001.result
deleted file mode 100644
index 6b6b9b7dffc..00000000000
--- a/mysql-test/r/sel000001.result
+++ /dev/null
@@ -1,21 +0,0 @@
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (s CHAR(20) PRIMARY KEY, id INT);
-INSERT INTO t1 VALUES ('cat', 1), ('mouse', 3), ('dog', 2), ('snake', 77);
-SELECT s, id FROM t1 WHERE s = 'mouse';
-s id
-mouse 3
-drop table t1;
-CREATE TABLE t1 (
-node int(11) NOT NULL default '0',
-maxchild int(11) NOT NULL default '0',
-PRIMARY KEY (`node`)
-);
-INSERT INTO t1 (node, maxchild) VALUES (4,4),(5,5),(1,244);
-SELECT * FROM t1 g1, t1 g2
-WHERE g1.node <= g2.node and g2.node <= g1.maxchild and g2.node = g2.maxchild;
-node maxchild node maxchild
-4 4 4 4
-5 5 5 5
-1 244 4 4
-1 244 5 5
-DROP TABLE t1;
diff --git a/mysql-test/r/sel000002.result b/mysql-test/r/sel000002.result
deleted file mode 100644
index b824de8de4a..00000000000
--- a/mysql-test/r/sel000002.result
+++ /dev/null
@@ -1,9 +0,0 @@
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (n INT);
-INSERT INTO t1 VALUES (1), (2), (3);
-SELECT * FROM t1;
-n
-1
-2
-3
-drop table t1;
diff --git a/mysql-test/r/sel000003.result b/mysql-test/r/sel000003.result
deleted file mode 100644
index c3853832f87..00000000000
--- a/mysql-test/r/sel000003.result
+++ /dev/null
@@ -1,8 +0,0 @@
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (name CHAR(20) NOT NULL PRIMARY KEY, score SMALLINT NOT NULL, KEY(score));
-INSERT INTO t1 VALUES ('Sasha', 20), ('Matt', 20), ('Monty', 10), ('David', 10), ('Tim', 10), ('Jeremy', 10);
-SELECT COUNT(*) as n, score FROM t1 GROUP BY score;
-n score
-4 10
-2 20
-drop table t1;
diff --git a/mysql-test/r/sel000031.result b/mysql-test/r/sel000031.result
deleted file mode 100644
index d3f01ab687f..00000000000
--- a/mysql-test/r/sel000031.result
+++ /dev/null
@@ -1,12 +0,0 @@
-drop table if exists t1,t2;
-create table t1 (id int(10) not null unique);
-create table t2 (id int(10) not null primary key,
-val int(10) not null);
-insert into t1 values (1),(2),(4);
-insert into t2 values (1,1),(2,1),(3,1),(4,2);
-select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id;
-id elt(two.val,'one','two')
-1 one
-2 one
-4 two
-drop table t1,t2;
diff --git a/mysql-test/r/sel000032.result b/mysql-test/r/sel000032.result
deleted file mode 100644
index 4cca245d75b..00000000000
--- a/mysql-test/r/sel000032.result
+++ /dev/null
@@ -1,12 +0,0 @@
-drop table if exists t1,t2;
-create table t1 (id int(10) not null unique);
-create table t2 (id int(10) not null primary key,
-val int(10) not null);
-insert into t1 values (1),(2),(4);
-insert into t2 values (1,1),(2,1),(3,1),(4,2);
-select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id;
-id elt(two.val,'one','two')
-1 one
-2 one
-4 two
-drop table t1,t2;
diff --git a/mysql-test/r/sel000033.result b/mysql-test/r/sel000033.result
deleted file mode 100644
index 1bfafaf5b27..00000000000
--- a/mysql-test/r/sel000033.result
+++ /dev/null
@@ -1,14 +0,0 @@
-drop table if exists t1;
-create table t1 (id int(10) primary key);
-insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
-select id from t1 where id in (2,5,9) ;
-id
-2
-5
-9
-select id from t1 where id=2 or id=5 or id=9 ;
-id
-2
-5
-9
-drop table t1;
diff --git a/mysql-test/r/sel000100.result b/mysql-test/r/sel000100.result
deleted file mode 100644
index 3ffa4004b84..00000000000
--- a/mysql-test/r/sel000100.result
+++ /dev/null
@@ -1,38 +0,0 @@
-DROP TABLE IF EXISTS t1,t2;
-CREATE TABLE t1 (
-ID int(11) NOT NULL auto_increment,
-NAME varchar(75) DEFAULT '' NOT NULL,
-LINK_ID int(11) DEFAULT '0' NOT NULL,
-PRIMARY KEY (ID),
-KEY NAME (NAME),
-KEY LINK_ID (LINK_ID)
-);
-INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0);
-INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (2,'Jack',0);
-INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (3,'Bill',0);
-CREATE TABLE t2 (
-ID int(11) NOT NULL auto_increment,
-NAME varchar(150) DEFAULT '' NOT NULL,
-PRIMARY KEY (ID),
-KEY NAME (NAME)
-);
-SELECT DISTINCT
-t2.id AS key_link_id,
-t2.name AS link
-FROM t1
-LEFT JOIN t2 ON t1.link_id=t2.id
-GROUP BY t1.id
-ORDER BY link;
-key_link_id link
-NULL NULL
-drop table t1,t2;
-CREATE TABLE t1 (
-html varchar(5) default NULL,
-rin int(11) default '0',
-out int(11) default '0'
-) TYPE=MyISAM;
-INSERT INTO t1 VALUES ('1',1,0);
-SELECT DISTINCT html,SUM(out)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin;
-html prod
-1 0.00
-drop table t1;
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 9cc5ad76ff0..8edd0182dec 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -127,31 +127,31 @@ fld3
select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%';
fld3
explain select t2.fld3 from t2 where fld3 = 'honeysuckle';
-table type possible_keys key key_len ref rows Extra
-t2 ref fld3 fld3 30 const 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index
explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle';
-table type possible_keys key key_len ref rows Extra
-t2 ALL NULL NULL NULL NULL 1199 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle';
-table type possible_keys key key_len ref rows Extra
-t2 ALL NULL NULL NULL NULL 1199 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle';
-table type possible_keys key key_len ref rows Extra
-t2 ref fld3 fld3 30 const 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index
explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle';
-table type possible_keys key key_len ref rows Extra
-t2 ref fld3 fld3 30 const 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index
explain select fld3 from t2 ignore index (fld3,not_used);
-Key column 'not_used' doesn't exist in table
+ERROR 42000: Key column 'not_used' doesn't exist in table
explain select fld3 from t2 use index (not_used);
-Key column 'not_used' doesn't exist in table
+ERROR 42000: Key column 'not_used' doesn't exist in table
select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
fld3
honeysuckle
honoring
explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
-table type possible_keys key key_len ref rows Extra
-t2 range fld3 fld3 30 NULL 2 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range fld3 fld3 30 NULL 2 Using where; Using index
select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
fld1 fld3
148504 Colombo
@@ -170,8 +170,8 @@ fld1
250501
250502
explain select fld1 from t2 where fld1=250501 or fld1="250502";
-table type possible_keys key key_len ref rows Extra
-t2 range fld1 fld1 4 NULL 2 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range fld1 fld1 4 NULL 2 Using where; Using index
select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;
fld1
250501
@@ -179,8 +179,8 @@ fld1
250505
250601
explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;
-table type possible_keys key key_len ref rows Extra
-t2 range fld1 fld1 4 NULL 4 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 range fld1 fld1 4 NULL 4 Using where; Using index
select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%';
fld1 fld3
218401 faithful
@@ -596,21 +596,21 @@ companynr rtrim(space(512+companynr))
select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3;
fld3
explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;
-table type possible_keys key key_len ref rows Extra
-t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
-t3 eq_ref PRIMARY PRIMARY 4 t2.fld1 1 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
+1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
-table type possible_keys key key_len ref rows Extra
-t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort
-t3 ref period period 4 t1.period 4181
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using temporary; Using filesort
+1 SIMPLE t3 ref period period 4 test.t1.period 4181
explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
-table type possible_keys key key_len ref rows Extra
-t3 index period period 4 NULL 41810
-t1 ref period period 4 t3.period 4181
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 index period period 4 NULL 41810
+1 SIMPLE t1 ref period period 4 test.t3.period 4181
explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
-table type possible_keys key key_len ref rows Extra
-t1 index period period 4 NULL 41810
-t3 ref period period 4 t1.period 4181
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index period period 4 NULL 41810
+1 SIMPLE t3 ref period period 4 test.t1.period 4181
select period from t1;
period
9410
@@ -623,9 +623,9 @@ select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.
fld3 period
breaking 1001
explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
-table type possible_keys key key_len ref rows Extra
-t2 const fld1 fld1 4 const 1
-t3 const PRIMARY,period PRIMARY 4 const 1
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 const fld1 fld1 4 const 1
+1 SIMPLE t3 const PRIMARY,period PRIMARY 4 const 1
select fld3,period from t2,t1 where companynr*10 = 37*10;
fld3 period
breaking 9410
@@ -1283,7 +1283,6 @@ fld1 fld3 period price price2
018601 vacuuming 1001 5987435 234724
018801 inch 1001 5987435 234724
018811 repetitions 1001 5987435 234724
-drop table if exists company;
create table t4 (
companynr tinyint(2) unsigned zerofill NOT NULL default '00',
companyname char(30) NOT NULL default '',
@@ -1356,46 +1355,46 @@ select count(*) from t2 left join t4 using (companynr) where t4.companynr is not
count(*)
1199
explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
-table type possible_keys key key_len ref rows Extra
-t2 ALL NULL NULL NULL NULL 1200
-t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 Using where; Not exists
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1200
+1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 Using where; Not exists
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null;
-table type possible_keys key key_len ref rows Extra
-t4 ALL NULL NULL NULL NULL 12
-t2 ALL NULL NULL NULL NULL 1200 Using where; Not exists
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 ALL NULL NULL NULL NULL 12
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where; Not exists
delete from t2 where fld1=999999;
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
-table type possible_keys key key_len ref rows Extra
-t2 ALL NULL NULL NULL NULL 1199 Using where
-t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
+1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0;
-table type possible_keys key key_len ref rows Extra
-t2 ALL NULL NULL NULL NULL 1199 Using where
-t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
+1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0;
-table type possible_keys key key_len ref rows Extra
-t2 ALL NULL NULL NULL NULL 1199 Using where
-t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
+1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 Using where
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
-table type possible_keys key key_len ref rows Extra
-t4 ALL NULL NULL NULL NULL 12
-t2 ALL NULL NULL NULL NULL 1199 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 ALL NULL NULL NULL NULL 12
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0;
-table type possible_keys key key_len ref rows Extra
-t4 ALL PRIMARY NULL NULL NULL 12
-t2 ALL NULL NULL NULL NULL 1199 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0;
-table type possible_keys key key_len ref rows Extra
-t4 ALL NULL NULL NULL NULL 12
-t2 ALL NULL NULL NULL NULL 1199 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t4 ALL NULL NULL NULL NULL 12
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
companynr companynr
37 36
41 40
explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
-table type possible_keys key key_len ref rows Extra
-t2 ALL NULL NULL NULL NULL 1199 Using temporary
-t4 index NULL PRIMARY 1 NULL 12 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using temporary
+1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using where; Using index
select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
fld1 companynr fld3 period
038008 37 reporters 1008
@@ -1464,14 +1463,19 @@ companynr count(*)
58 23
53 4
50 11
-select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1) from t2 where companynr = 34 and fld4<>"";
-count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1)
-70 absentee vest 17788966 254128.0857 3272.5940
-select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1) from t2 group by companynr limit 3;
-companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1)
-00 82 Anthony windmills 10355753 126289.6707 115550.9757
-29 95 abut wetness 14473298 152350.5053 8368.5480
-34 70 absentee vest 17788966 254128.0857 3272.5940
+select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
+count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1)
+70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069
+explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
+Warnings:
+Note 1003 select high_priority count(0) AS `count(*)`,min(test.t2.fld4) AS `min(fld4)`,max(test.t2.fld4) AS `max(fld4)`,sum(test.t2.fld1) AS `sum(fld1)`,avg(test.t2.fld1) AS `avg(fld1)`,std(test.t2.fld1) AS `std(fld1)`,variance(test.t2.fld1) AS `variance(fld1)` from test.t2 where ((test.t2.companynr = 34) and (test.t2.fld4 <> _latin1''))
+select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
+companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1)
+00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087
+29 95 abut wetness 14473298 152350.5053 8368.5480 70032594.9026
+34 70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069
select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10;
companynr t2nr count(price) sum(price) min(price) max(price) avg(price)
37 1 1 5987435 5987435 5987435 5987435.0000
@@ -1904,11 +1908,11 @@ select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr =
fld1 sum(price)
038008 234298
explain select fld3 from t2 where 1>2 or 2>3;
-Comment
-Impossible WHERE
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
explain select fld3 from t2 where fld1=fld1;
-table type possible_keys key key_len ref rows Extra
-t2 ALL NULL NULL NULL NULL 1199
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502;
companynr fld1
34 250501
@@ -1959,8 +1963,8 @@ select count(*) from t3 where companynr=512 and price2=76234234;
count(*)
4181
explain select min(fld1),max(fld1),count(*) from t2;
-Comment
-Select tables optimized away
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
select min(fld1),max(fld1),count(*) from t2;
min(fld1) max(fld1) count(*)
0 1232609 1199
@@ -2027,23 +2031,23 @@ Tables_in_test (s%)
show tables from test like "t?";
Tables_in_test (t?)
show full columns from t2;
-Field Type Null Key Default Extra Privileges
-auto int(11) PRI NULL auto_increment select,insert,update,references
-fld1 int(6) unsigned zerofill UNI 000000 select,insert,update,references
-companynr tinyint(2) unsigned zerofill 00 select,insert,update,references
-fld3 char(30) MUL select,insert,update,references
-fld4 char(35) select,insert,update,references
-fld5 char(35) select,insert,update,references
-fld6 char(4) select,insert,update,references
+Field Type Collation Null Key Default Extra Privileges Comment
+auto int(11) NULL PRI NULL auto_increment select,insert,update,references
+fld1 int(6) unsigned zerofill NULL UNI 000000 select,insert,update,references
+companynr tinyint(2) unsigned zerofill NULL 00 select,insert,update,references
+fld3 char(30) latin1_swedish_ci MUL select,insert,update,references
+fld4 char(35) latin1_swedish_ci select,insert,update,references
+fld5 char(35) latin1_swedish_ci select,insert,update,references
+fld6 char(4) latin1_swedish_ci select,insert,update,references
show full columns from t2 from test like 'f%';
-Field Type Null Key Default Extra Privileges
-fld1 int(6) unsigned zerofill UNI 000000 select,insert,update,references
-fld3 char(30) MUL select,insert,update,references
-fld4 char(35) select,insert,update,references
-fld5 char(35) select,insert,update,references
-fld6 char(4) select,insert,update,references
+Field Type Collation Null Key Default Extra Privileges Comment
+fld1 int(6) unsigned zerofill NULL UNI 000000 select,insert,update,references
+fld3 char(30) latin1_swedish_ci MUL select,insert,update,references
+fld4 char(35) latin1_swedish_ci select,insert,update,references
+fld5 char(35) latin1_swedish_ci select,insert,update,references
+fld6 char(4) latin1_swedish_ci select,insert,update,references
show full columns from t2 from test like 's%';
-Field Type Null Key Default Extra Privileges
+Field Type Collation Null Key Default Extra Privileges Comment
show keys from t2;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE
@@ -2085,6 +2089,16 @@ select wss_type from t1 where wss_type =102935229216544093;
wss_type
102935229216544093
drop table t1;
+select 1+2,"aaaa",3.13*2.0 into @a,@b,@c;
+select @a;
+@a
+3
+select @b;
+@b
+aaaa
+select @c;
+@c
+6.26
create table t1 (a int not null auto_increment primary key);
insert into t1 values ();
insert into t1 values ();
@@ -2297,11 +2311,11 @@ insert into t2 values (1);
insert into t4 values (1,1);
explain select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3
left join t4 on id3 = id4 where id2 = 1 or id4 = 1;
-table type possible_keys key key_len ref rows Extra
-t3 system NULL NULL NULL NULL 0 const row not found
-t1 ALL NULL NULL NULL NULL 2
-t2 ALL NULL NULL NULL NULL 1
-t4 ALL id4 NULL NULL NULL 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t3 system NULL NULL NULL NULL 0 const row not found
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2
+1 SIMPLE t2 ALL NULL NULL NULL NULL 1
+1 SIMPLE t4 ALL id4 NULL NULL NULL 1 Using where
select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3
left join t4 on id3 = id4 where id2 = 1 or id4 = 1;
id1 id2 id3 id4 id44
diff --git a/mysql-test/r/select_found.result b/mysql-test/r/select_found.result
index 0a7f464cf7b..d79f45a9334 100644
--- a/mysql-test/r/select_found.result
+++ b/mysql-test/r/select_found.result
@@ -136,7 +136,7 @@ email104
email105
email106
email107
-INSERT INTO `t1` (`id`, `kid`) VALUES ('', '150');
+INSERT INTO `t1` (`id`, `kid`) VALUES ('0', '150');
SELECT SQL_CALC_FOUND_ROWS DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL LIMIT 10;
email
email1
@@ -168,4 +168,24 @@ test2 2 2
SELECT FOUND_ROWS();
FOUND_ROWS()
2
+SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) as a LIMIT 0;
+1
+SELECT FOUND_ROWS();
+FOUND_ROWS()
+1
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE numeropost > 1 LIMIT 0;
+titre numeropost maxnumrep
+SELECT FOUND_ROWS();
+FOUND_ROWS()
+2
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 0;
+titre numeropost maxnumrep
+SELECT FOUND_ROWS();
+FOUND_ROWS()
+3
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 ORDER BY numeropost LIMIT 0;
+titre numeropost maxnumrep
+SELECT FOUND_ROWS();
+FOUND_ROWS()
+3
drop table t1;
diff --git a/mysql-test/r/select_safe.result b/mysql-test/r/select_safe.result
index 1ee1368d029..6bffdd85aa4 100644
--- a/mysql-test/r/select_safe.result
+++ b/mysql-test/r/select_safe.result
@@ -20,17 +20,17 @@ select 1 from t1,t1 as t2,t1 as t3;
1
1
update t1 set b="a";
-You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
+ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
update t1 set b="a" where b="test";
-You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
+ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
delete from t1;
-You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
+ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
delete from t1 where b="test";
-You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
+ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
delete from t1 where a+0=1;
-You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
+ERROR HY000: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
select 1 from t1,t1 as t2,t1 as t3,t1 as t4,t1 as t5;
-The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok
+ERROR 42000: The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok
update t1 set b="a" limit 1;
update t1 set b="a" where b="b" limit 2;
delete from t1 where b="test" limit 1;
@@ -38,11 +38,11 @@ delete from t1 where a+0=1 limit 2;
alter table t1 add key b (b);
SET MAX_JOIN_SIZE=2;
SELECT @@MAX_JOIN_SIZE, @@SQL_BIG_SELECTS;
-@@max_join_size @@sql_big_selects
+@@MAX_JOIN_SIZE @@SQL_BIG_SELECTS
2 0
insert into t1 values (null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a");
SELECT * from t1 order by a;
-The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok
+ERROR 42000: The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok
SET SQL_BIG_SELECTS=1;
SELECT * from t1 order by a;
a b
@@ -52,7 +52,7 @@ a b
5 a
SET MAX_JOIN_SIZE=2;
SELECT * from t1;
-The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok
+ERROR 42000: The SELECT would examine more rows than MAX_JOIN_SIZE. Check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is ok
SET MAX_JOIN_SIZE=DEFAULT;
SELECT * from t1;
a b
@@ -61,21 +61,21 @@ a b
4 a
5 a
SELECT @@MAX_SEEKS_FOR_KEY;
-@@max_seeks_for_key
+@@MAX_SEEKS_FOR_KEY
4294967295
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
insert into t1 values (null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a");
explain select STRAIGHT_JOIN * from t1,t1 as t2 where t1.b=t2.b;
-table type possible_keys key key_len ref rows Extra
-t1 ALL b NULL NULL NULL 21
-t2 ref b b 21 t1.b 6 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL b NULL NULL NULL 21
+1 SIMPLE t2 ref b b 21 test.t1.b 6 Using where
set MAX_SEEKS_FOR_KEY=1;
explain select STRAIGHT_JOIN * from t1,t1 as t2 where t1.b=t2.b;
-table type possible_keys key key_len ref rows Extra
-t1 ALL b NULL NULL NULL 21
-t2 ref b b 21 t1.b 6 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL b NULL NULL NULL 21
+1 SIMPLE t2 ref b b 21 test.t1.b 6 Using where
SET MAX_SEEKS_FOR_KEY=DEFAULT;
drop table t1;
SET SQL_SAFE_UPDATES=0,SQL_SELECT_LIMIT=DEFAULT, SQL_MAX_JOIN_SIZE=DEFAULT;
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index f40b0693585..2f29dcfdb47 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -26,7 +26,7 @@ t1 0 PRIMARY 1 a A 5 NULL NULL BTREE
t1 1 b 1 b A 1 NULL NULL BTREE
t1 1 b 2 c A 5 NULL NULL BTREE
insert into t1 values (5,5,5);
-Duplicate entry '5' for key 1
+ERROR 23000: Duplicate entry '5' for key 1
optimize table t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
@@ -43,7 +43,7 @@ wait_timeout 28800
show variables like "this_doesn't_exists%";
Variable_name Value
show table status from test like "this_doesn't_exists%";
-Name Type Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Create_options Comment
+Name Type 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
show databases;
Database
mysql
@@ -77,24 +77,31 @@ show create table t1;
Table Create Table
t1 CREATE TEMPORARY TABLE `t1` (
`a` int(11) NOT NULL default '0'
-) TYPE=MyISAM
+) TYPE=MyISAM DEFAULT CHARSET=latin1
alter table t1 rename t2;
show create table t2;
Table Create Table
t2 CREATE TEMPORARY TABLE `t2` (
`a` int(11) NOT NULL default '0'
-) TYPE=MyISAM
+) TYPE=MyISAM DEFAULT CHARSET=latin1
drop table t2;
create table t1 (
test_set set( 'val1', 'val2', 'val3' ) not null default '',
-name char(20) default 'O''Brien'
+name char(20) default 'O''Brien' comment 'O''Brien as default',
+c int not null comment 'int column'
) comment = 'it\'s a table' ;
show create table t1 ;
Table Create Table
t1 CREATE TABLE `t1` (
`test_set` set('val1','val2','val3') NOT NULL default '',
- `name` char(20) default 'O''Brien'
-) TYPE=MyISAM COMMENT='it''s a table'
+ `name` char(20) default 'O''Brien' COMMENT 'O''Brien as default',
+ `c` int(11) NOT NULL default '0' COMMENT 'int column'
+) TYPE=MyISAM DEFAULT CHARSET=latin1 COMMENT='it''s a table'
+show full columns from t1;
+Field Type Collation Null Key Default Extra Privileges Comment
+test_set set('val1','val2','val3') latin1_swedish_ci select,insert,update,references
+name char(20) latin1_swedish_ci YES O'Brien select,insert,update,references O'Brien as default
+c int(11) NULL 0 select,insert,update,references int column
drop table t1;
create table t1 (a int not null, unique aa (a));
show create table t1;
@@ -102,7 +109,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0',
UNIQUE KEY `aa` (`a`)
-) TYPE=MyISAM
+) TYPE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a int not null, primary key (a));
show create table t1;
@@ -110,7 +117,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0',
PRIMARY KEY (`a`)
-) TYPE=MyISAM
+) TYPE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
flush tables;
show open tables;
@@ -128,7 +135,7 @@ t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0',
`b` char(10) default NULL,
KEY `b` (`b`)
-) TYPE=MyISAM MIN_ROWS=10 MAX_ROWS=100 AVG_ROW_LENGTH=10 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED COMMENT='test'
+) TYPE=MyISAM DEFAULT CHARSET=latin1 MIN_ROWS=10 MAX_ROWS=100 AVG_ROW_LENGTH=10 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED COMMENT='test'
alter table t1 MAX_ROWS=200 ROW_FORMAT=dynamic PACK_KEYS=0;
show create table t1;
Table Create Table
@@ -136,7 +143,7 @@ t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0',
`b` varchar(10) default NULL,
KEY `b` (`b`)
-) TYPE=MyISAM MIN_ROWS=10 MAX_ROWS=200 AVG_ROW_LENGTH=10 PACK_KEYS=0 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC COMMENT='test'
+) TYPE=MyISAM DEFAULT CHARSET=latin1 MIN_ROWS=10 MAX_ROWS=200 AVG_ROW_LENGTH=10 PACK_KEYS=0 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC COMMENT='test'
ALTER TABLE t1 AVG_ROW_LENGTH=0 CHECKSUM=0 COMMENT="" MIN_ROWS=0 MAX_ROWS=0 PACK_KEYS=DEFAULT DELAY_KEY_WRITE=0 ROW_FORMAT=default;
show create table t1;
Table Create Table
@@ -144,7 +151,7 @@ t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL default '0',
`b` varchar(10) default NULL,
KEY `b` (`b`)
-) TYPE=MyISAM
+) TYPE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a decimal(9,2), b decimal (9,0), e double(9,2), f double(5,0), h float(3,2), i float(3,0));
show columns from t1;
@@ -155,6 +162,14 @@ e double(9,2) YES NULL
f double(5,0) YES NULL
h float(3,2) YES NULL
i float(3,0) YES NULL
+show full columns from t1;
+Field Type Collation Null Key Default Extra Privileges Comment
+a decimal(9,2) NULL YES NULL select,insert,update,references
+b decimal(9,0) NULL YES NULL select,insert,update,references
+e double(9,2) NULL YES NULL select,insert,update,references
+f double(5,0) NULL YES NULL select,insert,update,references
+h float(3,2) NULL YES NULL select,insert,update,references
+i float(3,0) NULL YES NULL select,insert,update,references
drop table t1;
create table t1 (
type_bool bool not null,
@@ -193,7 +208,7 @@ t1 CREATE TABLE `t1` (
`empty_char` char(0) default NULL,
`type_char` char(2) default NULL,
`type_varchar` varchar(10) default NULL,
- `type_timestamp` timestamp(14) NOT NULL,
+ `type_timestamp` timestamp NOT NULL,
`type_date` date NOT NULL default '0000-00-00',
`type_time` time NOT NULL default '00:00:00',
`type_datetime` datetime NOT NULL default '0000-00-00 00:00:00',
@@ -206,11 +221,11 @@ t1 CREATE TABLE `t1` (
`type_long_blob` longblob,
PRIMARY KEY (`type_tiny`),
KEY `type_short` (`type_short`)
-) TYPE=MyISAM MIN_ROWS=10 MAX_ROWS=100 AVG_ROW_LENGTH=10 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED COMMENT='test'
+) TYPE=MyISAM DEFAULT CHARSET=latin1 MIN_ROWS=10 MAX_ROWS=100 AVG_ROW_LENGTH=10 PACK_KEYS=1 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=FIXED COMMENT='test'
insert into t1 (type_timestamp) values ("2003-02-07 10:00:01");
select * from t1;
type_bool type_tiny type_short type_mediumint type_bigint type_decimal type_numeric empty_char type_char type_varchar type_timestamp type_date type_time type_datetime type_year type_enum type_set type_tinyblob type_blob type_medium_blob type_long_blob
-0 1 NULL NULL NULL NULL NULL NULL NULL NULL 20030207100001 0000-00-00 00:00:00 0000-00-00 00:00:00 NULL NULL NULL NULL NULL NULL NULL
+0 1 NULL NULL NULL NULL NULL NULL NULL NULL 2003-02-07 10:00:01 0000-00-00 00:00:00 0000-00-00 00:00:00 NULL NULL NULL NULL NULL NULL NULL
drop table t1;
create table t1 (a int not null);
create table t2 select max(a) from t1;
diff --git a/mysql-test/r/sql_mode.result b/mysql-test/r/sql_mode.result
new file mode 100644
index 00000000000..dddfe2432ee
--- /dev/null
+++ b/mysql-test/r/sql_mode.result
@@ -0,0 +1,87 @@
+drop table if exists t1;
+CREATE TABLE `t1` (
+a int not null auto_increment,
+`pseudo` varchar(35) character set latin2 NOT NULL default '',
+`email` varchar(60) character set latin2 NOT NULL default '',
+PRIMARY KEY (a),
+UNIQUE KEY `email` USING BTREE (`email`)
+) TYPE=HEAP CHARSET=latin1 ROW_FORMAT DYNAMIC;
+set @@sql_mode="";
+show variables like 'sql_mode';
+Variable_name Value
+sql_mode
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL auto_increment,
+ `pseudo` varchar(35) character set latin2 NOT NULL default '',
+ `email` varchar(60) character set latin2 NOT NULL default '',
+ PRIMARY KEY (`a`),
+ UNIQUE KEY `email` TYPE BTREE (`email`)
+) TYPE=HEAP DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
+set @@sql_mode="ansi_quotes";
+show variables like 'sql_mode';
+Variable_name Value
+sql_mode ANSI_QUOTES
+show create table t1;
+Table Create Table
+t1 CREATE TABLE "t1" (
+ "a" int(11) NOT NULL auto_increment,
+ "pseudo" varchar(35) character set latin2 NOT NULL default '',
+ "email" varchar(60) character set latin2 NOT NULL default '',
+ PRIMARY KEY ("a"),
+ UNIQUE KEY "email" TYPE BTREE ("email")
+) TYPE=HEAP DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
+set @@sql_mode="no_table_options";
+show variables like 'sql_mode';
+Variable_name Value
+sql_mode NO_TABLE_OPTIONS
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL auto_increment,
+ `pseudo` varchar(35) character set latin2 NOT NULL default '',
+ `email` varchar(60) character set latin2 NOT NULL default '',
+ PRIMARY KEY (`a`),
+ UNIQUE KEY `email` TYPE BTREE (`email`)
+)
+set @@sql_mode="no_key_options";
+show variables like 'sql_mode';
+Variable_name Value
+sql_mode NO_KEY_OPTIONS
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL auto_increment,
+ `pseudo` varchar(35) character set latin2 NOT NULL default '',
+ `email` varchar(60) character set latin2 NOT NULL default '',
+ PRIMARY KEY (`a`),
+ UNIQUE KEY `email` (`email`)
+) TYPE=HEAP DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC
+set @@sql_mode="no_field_options,mysql323,mysql40";
+show variables like 'sql_mode';
+Variable_name Value
+sql_mode NO_FIELD_OPTIONS,MYSQL323,MYSQL40
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) NOT NULL auto_increment,
+ `pseudo` varchar(35) NOT NULL default '',
+ `email` varchar(60) NOT NULL default '',
+ PRIMARY KEY (`a`),
+ UNIQUE KEY `email` (`email`)
+) TYPE=HEAP ROW_FORMAT=DYNAMIC
+set sql_mode="postgresql,oracle,mssql,db2,maxdb";
+select @@sql_mode;
+@@sql_mode
+PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,POSTGRESQL,ORACLE,MSSQL,DB2,MAXDB,NO_KEY_OPTIONS,NO_TABLE_OPTIONS,NO_FIELD_OPTIONS
+show create table t1;
+Table Create Table
+t1 CREATE TABLE "t1" (
+ "a" int(11) NOT NULL,
+ "pseudo" varchar(35) NOT NULL default '',
+ "email" varchar(60) NOT NULL default '',
+ PRIMARY KEY ("a"),
+ UNIQUE KEY "email" ("email")
+)
+drop table t1;
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
new file mode 100644
index 00000000000..95638cbee41
--- /dev/null
+++ b/mysql-test/r/subselect.result
@@ -0,0 +1,1571 @@
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t11,t12;
+select (select 2);
+(select 2)
+2
+explain extended select (select 2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1248 Select 2 was reduced during optimisation
+Note 1003 select high_priority 2 AS `(select 2)`
+SELECT (SELECT 1) UNION SELECT (SELECT 2);
+(SELECT 1)
+1
+2
+explain extended SELECT (SELECT 1) UNION SELECT (SELECT 2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1248 Select 2 was reduced during optimisation
+Note 1248 Select 4 was reduced during optimisation
+Note 1003 select high_priority 1 AS `(SELECT 1)` union select 2 AS `(SELECT 2)`
+SELECT (SELECT (SELECT 0 UNION SELECT 0));
+(SELECT (SELECT 0 UNION SELECT 0))
+0
+explain extended SELECT (SELECT (SELECT 0 UNION SELECT 0));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+4 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1248 Select 2 was reduced during optimisation
+Note 1003 select high_priority (select 0 AS `0` union select 0 AS `0`) AS `(SELECT (SELECT 0 UNION SELECT 0))`
+SELECT (SELECT 1 FROM (SELECT 1) as b HAVING a=1) as a;
+ERROR 42S22: Reference 'a' not supported (forward reference in item list)
+SELECT (SELECT 1 FROM (SELECT 1) as b HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) as c HAVING a=1) as b;
+ERROR 42S22: Reference 'b' not supported (forward reference in item list)
+SELECT (SELECT 1),MAX(1) FROM (SELECT 1) as a;
+(SELECT 1) MAX(1)
+1 1
+SELECT (SELECT a) as a;
+ERROR 42S22: Reference 'a' not supported (forward reference in item list)
+EXPLAIN EXTENDED SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> system NULL NULL NULL NULL 1
+3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1275 Field or reference 'a' of SELECT #3 was resolved in SELECT #1
+Note 1275 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1
+Note 1003 select high_priority 1 AS `1` from (select 1 AS `a`) b having ((select b.a AS `a`) = 1)
+SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
+1
+1
+SELECT (SELECT 1), a;
+ERROR 42S22: Unknown column 'a' in 'checking transformed subquery'
+SELECT 1 as a FROM (SELECT 1) as b HAVING (SELECT a)=1;
+a
+1
+SELECT 1 FROM (SELECT (SELECT a) b) c;
+ERROR 42S22: Unknown column 'a' in 'field list'
+SELECT * FROM (SELECT 1 as id) b WHERE id IN (SELECT * FROM (SELECT 1 as id) c ORDER BY id);
+id
+1
+SELECT * FROM (SELECT 1) a WHERE 1 IN (SELECT 1,1);
+ERROR 21000: Operand should contain 1 column(s)
+SELECT 1 IN (SELECT 1);
+1 IN (SELECT 1)
+1
+SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
+1
+1
+select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
+ERROR HY000: Wrong usage of PROCEDURE and subquery
+SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
+ERROR HY000: Incorrect parameters to procedure 'ANALYSE'
+SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
+a
+SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
+a
+1
+SELECT (SELECT 1,2,3) = ROW(1,2,3);
+(SELECT 1,2,3) = ROW(1,2,3)
+1
+SELECT (SELECT 1,2,3) = ROW(1,2,1);
+(SELECT 1,2,3) = ROW(1,2,1)
+0
+SELECT (SELECT 1,2,3) < ROW(1,2,1);
+(SELECT 1,2,3) < ROW(1,2,1)
+0
+SELECT (SELECT 1,2,3) > ROW(1,2,1);
+(SELECT 1,2,3) > ROW(1,2,1)
+1
+SELECT (SELECT 1,2,3) = ROW(1,2,NULL);
+(SELECT 1,2,3) = ROW(1,2,NULL)
+NULL
+SELECT ROW(1,2,3) = (SELECT 1,2,3);
+ROW(1,2,3) = (SELECT 1,2,3)
+1
+SELECT ROW(1,2,3) = (SELECT 1,2,1);
+ROW(1,2,3) = (SELECT 1,2,1)
+0
+SELECT ROW(1,2,3) < (SELECT 1,2,1);
+ROW(1,2,3) < (SELECT 1,2,1)
+0
+SELECT ROW(1,2,3) > (SELECT 1,2,1);
+ROW(1,2,3) > (SELECT 1,2,1)
+1
+SELECT ROW(1,2,3) = (SELECT 1,2,NULL);
+ROW(1,2,3) = (SELECT 1,2,NULL)
+NULL
+SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a');
+(SELECT 1.5,2,'a') = ROW(1.5,2,'a')
+1
+SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b');
+(SELECT 1.5,2,'a') = ROW(1.5,2,'b')
+0
+SELECT (SELECT 1.5,2,'a') = ROW('b',2,'b');
+(SELECT 1.5,2,'a') = ROW('b',2,'b')
+0
+SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a');
+(SELECT 'b',2,'a') = ROW(1.5,2,'a')
+0
+SELECT (SELECT 1.5,2,'a') = ROW(1.5,'c','a');
+(SELECT 1.5,2,'a') = ROW(1.5,'c','a')
+0
+SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a');
+(SELECT 1.5,'c','a') = ROW(1.5,2,'a')
+0
+SELECT (SELECT * FROM (SELECT 'test' a,'test' b) a);
+ERROR 21000: Operand should contain 1 column(s)
+SELECT 1 as a,(SELECT a+a) b,(SELECT b);
+a b (SELECT b)
+1 2 2
+create table t1 (a int);
+create table t2 (a int, b int);
+create table t3 (a int);
+create table t4 (a int not null, b int not null);
+insert into t1 values (2);
+insert into t2 values (1,7),(2,7);
+insert into t4 values (4,8),(3,8),(5,9);
+select (select a from t1 where t1.a = a1) as a2, (select b from t2 where t2.b=a2) as a1;
+ERROR 42S22: Reference 'a1' not supported (forward reference in item list)
+select (select a from t1 where t1.a=t2.a), a from t2;
+(select a from t1 where t1.a=t2.a) a
+NULL 1
+2 2
+select (select a from t1 where t1.a=t2.b), a from t2;
+(select a from t1 where t1.a=t2.b) a
+NULL 1
+NULL 2
+select (select a from t1), a from t2;
+(select a from t1) a
+2 1
+2 2
+select (select a from t3), a from t2;
+(select a from t3) a
+NULL 1
+NULL 2
+select * from t2 where t2.a=(select a from t1);
+a b
+2 7
+insert into t3 values (6),(7),(3);
+select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1);
+a b
+1 7
+2 7
+(select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 order by a limit 2) limit 3;
+a b
+1 7
+2 7
+3 8
+(select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a);
+a b
+1 7
+2 7
+3 8
+4 8
+explain extended (select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
+2 SUBQUERY t3 ALL NULL NULL NULL NULL 3 Using filesort
+3 UNION t4 ALL NULL NULL NULL NULL 3 Using where; Using filesort
+4 SUBQUERY t2 ALL NULL NULL NULL NULL 2
+Warnings:
+Note 1003 (select high_priority test.t2.a AS `a`,test.t2.b AS `b` from test.t2 where (test.t2.b = (select test.t3.a AS `a` from test.t3 order by test.t3.a desc limit 1))) union (select test.t4.a AS `a`,test.t4.b AS `b` from test.t4 where (test.t4.b = (select (max(test.t2.a) * 4) AS `max(t2.a)*4` from test.t2)) order by test.t4.a)
+select (select a from t3 where a<t2.a*4 order by 1 desc limit 1), a from t2;
+(select a from t3 where a<t2.a*4 order by 1 desc limit 1) a
+3 1
+7 2
+select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
+(select * from t2 where a>1) as tt;
+(select t3.a from t3 where a<8 order by 1 desc limit 1) a
+7 2
+explain extended select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
+(select * from t2 where a>1) as tt;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived3> system NULL NULL NULL NULL 1
+3 DERIVED t2 ALL NULL NULL NULL NULL 2 Using where
+2 SUBQUERY t3 ALL NULL NULL NULL NULL 3 Using where; Using filesort
+Warnings:
+Note 1003 select high_priority (select test.t3.a AS `a` from test.t3 where (test.t3.a < 8) order by test.t3.a desc limit 1) AS `(select t3.a from t3 where a<8 order by 1 desc limit 1)`,tt.a AS `a` from (select test.t2.a AS `a`,test.t2.b AS `b` from test.t2 where (test.t2.a > 1)) tt
+select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3) order by 1 desc limit 1);
+a
+2
+select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a > t1.a) order by 1 desc limit 1);
+a
+2
+select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a < t1.a) order by 1 desc limit 1);
+a
+select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4;
+b (select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)
+8 7.5000
+8 4.5000
+9 7.5000
+explain extended select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t4 ALL NULL NULL NULL NULL 3
+2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2
+3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 Using where
+Warnings:
+Note 1275 Field or reference 't4.a' of SELECT #3 was resolved in SELECT #1
+Note 1003 select high_priority test.t4.b AS `b`,(select avg((test.t2.a + (select min(test.t3.a) AS `min(t3.a)` from test.t3 where (test.t3.a >= test.t4.a)))) AS `avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a))` from test.t2) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from test.t4
+select * from t3 where exists (select * from t2 where t2.b=t3.a);
+a
+7
+select * from t3 where not exists (select * from t2 where t2.b=t3.a);
+a
+6
+3
+select * from t3 where a in (select b from t2);
+a
+7
+select * from t3 where a not in (select b from t2);
+a
+6
+3
+select * from t3 where a = some (select b from t2);
+a
+7
+select * from t3 where a <> any (select b from t2);
+a
+6
+3
+select * from t3 where a = all (select b from t2);
+a
+7
+select * from t3 where a <> all (select b from t2);
+a
+6
+3
+insert into t2 values (100, 5);
+select * from t3 where a < any (select b from t2);
+a
+6
+3
+select * from t3 where a < all (select b from t2);
+a
+3
+select * from t3 where a >= any (select b from t2);
+a
+6
+7
+explain extended select * from t3 where a >= any (select b from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 3
+Warnings:
+Note 1003 select high_priority test.t3.a AS `a` from test.t3 where (test.t3.a >= (select min(test.t2.b) from test.t2 limit 1))
+select * from t3 where a >= all (select b from t2);
+a
+7
+delete from t2 where a=100;
+select * from t3 where a in (select a,b from t2);
+ERROR 21000: Operand should contain 1 column(s)
+select * from t3 where a in (select * from t2);
+ERROR 21000: Operand should contain 1 column(s)
+insert into t4 values (12,7),(1,7),(10,9),(9,6),(7,6),(3,9),(1,10);
+select b,max(a) as ma from t4 group by b having b < (select max(t2.a) from t2 where t2.b=t4.b);
+b ma
+insert into t2 values (2,10);
+select b,max(a) as ma from t4 group by b having ma < (select max(t2.a) from t2 where t2.b=t4.b);
+b ma
+10 1
+delete from t2 where a=2 and b=10;
+select b,max(a) as ma from t4 group by b having b >= (select max(t2.a) from t2 where t2.b=t4.b);
+b ma
+7 12
+create table t5 (a int);
+select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2;
+(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a
+NULL 1
+2 2
+insert into t5 values (5);
+select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2;
+(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a
+NULL 1
+2 2
+insert into t5 values (2);
+select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2;
+(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a
+NULL 1
+2 2
+explain extended select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2
+2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1
+3 DEPENDENT UNION t5 ALL NULL NULL NULL NULL 2 Using where
+Warnings:
+Note 1275 Field or reference 't2.a' of SELECT #2 was resolved in SELECT #1
+Note 1275 Field or reference 't2.a' of SELECT #3 was resolved in SELECT #1
+Note 1003 select high_priority (select test.t1.a AS `a` from test.t1 where (test.t1.a = test.t2.a) union select test.t5.a AS `a` from test.t5 where (test.t5.a = test.t2.a)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,test.t2.a AS `a` from test.t2
+select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
+ERROR 21000: Subquery returns more than 1 row
+create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq));
+create table t7( uq int primary key, name char(25));
+insert into t7 values(1,"Oblastnaia bolnitsa"),(2,"Bolnitsa Krasnogo Kresta");
+insert into t6 values (1,1),(1,2),(2,2),(1,3);
+select * from t6 where exists (select * from t7 where uq = clinic_uq);
+patient_uq clinic_uq
+1 1
+1 2
+2 2
+explain extended select * from t6 where exists (select * from t7 where uq = clinic_uq);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t6 ALL NULL NULL NULL NULL 4 Using where
+2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1
+Warnings:
+Note 1275 Field or reference 'clinic_uq' of SELECT #2 was resolved in SELECT #1
+Note 1003 select high_priority test.t6.patient_uq AS `patient_uq`,test.t6.clinic_uq AS `clinic_uq` from test.t6 where exists(select test.t7.uq AS `uq`,test.t7.name AS `name` from test.t7 where (test.t7.uq = test.t6.clinic_uq) limit 1)
+select * from t1 where a= (select a from t2,t4 where t2.b=t4.b);
+ERROR 23000: Column: 'a' in field list is ambiguous
+drop table if exists t1,t2,t3;
+CREATE TABLE t3 (a varchar(20),b char(1) NOT NULL default '0');
+INSERT INTO t3 VALUES ('W','a'),('A','c'),('J','b');
+CREATE TABLE t2 (a varchar(20),b int NOT NULL default '0');
+INSERT INTO t2 VALUES ('W','1'),('A','3'),('J','2');
+CREATE TABLE t1 (a varchar(20),b date NOT NULL default '0000-00-00');
+INSERT INTO t1 VALUES ('W','1732-02-22'),('A','1735-10-30'),('J','1743-04-13');
+SELECT * FROM t1 WHERE b = (SELECT MIN(b) FROM t1);
+a b
+W 1732-02-22
+SELECT * FROM t2 WHERE b = (SELECT MIN(b) FROM t2);
+a b
+W 1
+SELECT * FROM t3 WHERE b = (SELECT MIN(b) FROM t3);
+a b
+W a
+CREATE TABLE `t8` (
+`pseudo` varchar(35) character set latin1 NOT NULL default '',
+`email` varchar(60) character set latin1 NOT NULL default '',
+PRIMARY KEY (`pseudo`),
+UNIQUE KEY `email` (`email`)
+) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC;
+INSERT INTO t8 (pseudo,email) VALUES ('joce','test');
+INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1');
+INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1');
+EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t8 const PRIMARY PRIMARY 35 const 1
+4 SUBQUERY t8 const PRIMARY PRIMARY 35 1
+2 SUBQUERY t8 const PRIMARY PRIMARY 35 const 1
+3 SUBQUERY t8 const PRIMARY PRIMARY 35 1
+Warnings:
+Note 1003 select high_priority test.t8.pseudo AS `pseudo`,(select test.t8.email AS `email` from test.t8 where (test.t8.pseudo = (select test.t8.pseudo AS `pseudo` from test.t8 where (test.t8.pseudo = _latin1'joce')))) AS `(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'))` from test.t8 where (test.t8.pseudo = (select test.t8.pseudo AS `pseudo` from test.t8 where (test.t8.pseudo = _latin1'joce')))
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
+t8 WHERE pseudo='joce');
+ERROR 21000: Operand should contain 1 column(s)
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE
+pseudo='joce');
+ERROR 21000: Operand should contain 1 column(s)
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
+pseudo
+joce
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo LIKE '%joce%');
+ERROR 21000: Subquery returns more than 1 row
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
+CREATE TABLE `t1` (
+`topic` mediumint(8) unsigned NOT NULL default '0',
+`date` date NOT NULL default '0000-00-00',
+`pseudo` varchar(35) character set latin1 NOT NULL default '',
+PRIMARY KEY (`pseudo`,`date`,`topic`),
+KEY `topic` (`topic`)
+) TYPE=MyISAM ROW_FORMAT=DYNAMIC;
+INSERT INTO t1 (topic,date,pseudo) VALUES
+('43506','2002-10-02','joce'),('40143','2002-08-03','joce');
+EXPLAIN EXTENDED SELECT DISTINCT date FROM t1 WHERE date='2002-08-03';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 41 NULL 2 Using where; Using index
+Warnings:
+Note 1003 select high_priority distinct test.t1.date AS `date` from test.t1 where (test.t1.date = 20020803)
+EXPLAIN EXTENDED SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 SUBQUERY t1 index NULL PRIMARY 41 NULL 2 Using where; Using index
+Warnings:
+Note 1003 select high_priority (select distinct test.t1.date AS `date` from test.t1 where (test.t1.date = 20020803)) AS `(SELECT DISTINCT date FROM t1 WHERE date='2002-08-03')`
+SELECT DISTINCT date FROM t1 WHERE date='2002-08-03';
+date
+2002-08-03
+SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03');
+(SELECT DISTINCT date FROM t1 WHERE date='2002-08-03')
+2002-08-03
+SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1) UNION ALL SELECT 1;
+1
+1
+1
+1
+SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1) UNION SELECT 1;
+ERROR 21000: Subquery returns more than 1 row
+EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL topic 3 NULL 2 Using index
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority 1 AS `1` from test.t1
+drop table t1;
+CREATE TABLE `t1` (
+`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
+`maxnumrep` int(10) unsigned NOT NULL default '0',
+PRIMARY KEY (`numeropost`),
+UNIQUE KEY `maxnumrep` (`maxnumrep`)
+) TYPE=MyISAM ROW_FORMAT=FIXED;
+INSERT INTO t1 (numeropost,maxnumrep) VALUES (40143,1),(43506,2);
+CREATE TABLE `t2` (
+`mot` varchar(30) NOT NULL default '',
+`topic` mediumint(8) unsigned NOT NULL default '0',
+`date` date NOT NULL default '0000-00-00',
+`pseudo` varchar(35) NOT NULL default '',
+PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`)
+) TYPE=MyISAM ROW_FORMAT=DYNAMIC;
+INSERT INTO t2 (mot,topic,date,pseudo) VALUES ('joce','40143','2002-10-22','joce'), ('joce','43506','2002-10-22','joce');
+select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
+a
+40143
+SELECT numeropost,maxnumrep FROM t1 WHERE exists (SELECT 1 FROM t2 WHERE (mot='joce') AND date >= '2002-10-21' AND t1.numeropost = t2.topic) ORDER BY maxnumrep DESC LIMIT 0, 20;
+numeropost maxnumrep
+43506 2
+40143 1
+SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) b;
+ERROR 42S22: Unknown column 'a' in 'having clause'
+SELECT 1 IN (SELECT 1 FROM t2 HAVING a);
+ERROR 42S22: Unknown column 'a' in 'having clause'
+SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic);
+mot topic date pseudo
+joce 40143 2002-10-22 joce
+joce 43506 2002-10-22 joce
+SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100);
+mot topic date pseudo
+SELECT * from t2 where topic IN (SELECT SUM(topic) FROM t1);
+mot topic date pseudo
+SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic);
+mot topic date pseudo
+joce 40143 2002-10-22 joce
+joce 43506 2002-10-22 joce
+SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100);
+mot topic date pseudo
+SELECT * from t2 where topic = any (SELECT SUM(topic) FROM t1);
+mot topic date pseudo
+SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic);
+mot topic date pseudo
+SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100);
+mot topic date pseudo
+joce 40143 2002-10-22 joce
+joce 43506 2002-10-22 joce
+SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) from t2;
+mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100)
+joce 40143 2002-10-22 joce 1
+joce 43506 2002-10-22 joce 1
+SELECT * from t2 where topic = all (SELECT SUM(topic) FROM t2);
+mot topic date pseudo
+SELECT * from t2 where topic <> any (SELECT SUM(topic) FROM t2);
+mot topic date pseudo
+joce 40143 2002-10-22 joce
+joce 43506 2002-10-22 joce
+SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000);
+mot topic date pseudo
+joce 40143 2002-10-22 joce
+SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000);
+mot topic date pseudo
+joce 40143 2002-10-22 joce
+SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000);
+mot topic date pseudo
+joce 40143 2002-10-22 joce
+SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) from t2;
+mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000)
+joce 40143 2002-10-22 joce 1
+joce 43506 2002-10-22 joce 0
+drop table t1,t2;
+CREATE TABLE `t1` (
+`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
+`maxnumrep` int(10) unsigned NOT NULL default '0',
+PRIMARY KEY (`numeropost`),
+UNIQUE KEY `maxnumrep` (`maxnumrep`)
+) TYPE=MyISAM ROW_FORMAT=FIXED;
+INSERT INTO t1 (numeropost,maxnumrep) VALUES (1,0),(2,1);
+select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
+ERROR 21000: Subquery returns more than 1 row
+select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1);
+ERROR 21000: Subquery returns more than 1 row
+drop table t1;
+create table t1 (a int);
+insert into t1 values (1),(2),(3);
+(select * from t1) union (select * from t1) order by (select a from t1 limit 1);
+a
+1
+2
+3
+drop table t1;
+CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b');
+INSERT INTO t1 VALUES ();
+SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) a HAVING field='b');
+ERROR 21000: Subquery returns more than 1 row
+drop table t1;
+CREATE TABLE `t1` (
+`numeropost` mediumint(8) unsigned NOT NULL default '0',
+`numreponse` int(10) unsigned NOT NULL auto_increment,
+`pseudo` varchar(35) NOT NULL default '',
+PRIMARY KEY (`numeropost`,`numreponse`),
+UNIQUE KEY `numreponse` (`numreponse`),
+KEY `pseudo` (`pseudo`,`numeropost`)
+) TYPE=MyISAM;
+SELECT (SELECT numeropost FROM t1 HAVING numreponse=a),numreponse FROM (SELECT * FROM t1) as a;
+ERROR 42S22: Reference 'numreponse' not supported (forward reference in item list)
+SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=a) FROM (SELECT * FROM t1) as a;
+ERROR 42S22: Unknown column 'a' in 'having clause'
+SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT * FROM t1) as a;
+numreponse (SELECT numeropost FROM t1 HAVING numreponse=1)
+INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test');
+EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1');
+ERROR 21000: Subquery returns more than 1 row
+EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+Warnings:
+Note 1003 select high_priority max(test.t1.numreponse) AS `MAX(numreponse)` from test.t1 where (test.t1.numeropost = _latin1'1')
+EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1');
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 const PRIMARY,numreponse PRIMARY 7 const,const 1
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+Warnings:
+Note 1003 select high_priority test.t1.numreponse AS `numreponse` from test.t1 where ((test.t1.numeropost = _latin1'1') and (test.t1.numreponse = 3))
+drop table t1;
+CREATE TABLE t1 (a int(1));
+INSERT INTO t1 VALUES (1);
+SELECT 1 FROM (SELECT a FROM t1) b HAVING (SELECT b.a)=1;
+1
+1
+drop table t1;
+create table t1 (a int NOT NULL, b int, primary key (a));
+create table t2 (a int NOT NULL, b int, primary key (a));
+insert into t1 values (0, 10),(1, 11),(2, 12);
+insert into t2 values (1, 21),(2, 22),(3, 23);
+select * from t1;
+a b
+0 10
+1 11
+2 12
+update t1 set b= (select b from t1);
+ERROR HY000: You can't specify target table 't1' for update in FROM clause
+update t1 set b= (select b from t2);
+ERROR 21000: Subquery returns more than 1 row
+update t1 set b= (select b from t2 where t1.a = t2.a);
+select * from t1;
+a b
+0 NULL
+1 21
+2 22
+drop table t1, t2;
+create table t1 (a int NOT NULL, b int, primary key (a));
+create table t2 (a int NOT NULL, b int, primary key (a));
+insert into t1 values (0, 10),(1, 11),(2, 12);
+insert into t2 values (1, 21),(2, 12),(3, 23);
+select * from t1;
+a b
+0 10
+1 11
+2 12
+select * from t1 where b = (select b from t2 where t1.a = t2.a);
+a b
+2 12
+delete from t1 where b = (select b from t1);
+ERROR HY000: You can't specify target table 't1' for update in FROM clause
+delete from t1 where b = (select b from t2);
+ERROR 21000: Subquery returns more than 1 row
+delete from t1 where b = (select b from t2 where t1.a = t2.a);
+select * from t1;
+a b
+0 10
+1 11
+drop table t1, t2;
+create table t11 (a int NOT NULL, b int, primary key (a));
+create table t12 (a int NOT NULL, b int, primary key (a));
+create table t2 (a int NOT NULL, b int, primary key (a));
+insert into t11 values (0, 10),(1, 11),(2, 12);
+insert into t12 values (33, 10),(22, 11),(2, 12);
+insert into t2 values (1, 21),(2, 12),(3, 23);
+select * from t11;
+a b
+0 10
+1 11
+2 12
+select * from t12;
+a b
+33 10
+22 11
+2 12
+delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
+ERROR HY000: You can't specify target table 't12' for update in FROM clause
+delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
+ERROR 21000: Subquery returns more than 1 row
+delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
+select * from t11;
+a b
+0 10
+1 11
+select * from t12;
+a b
+33 10
+22 11
+drop table t11, t12, t2;
+CREATE TABLE t1 (x int);
+create table t2 (a int);
+create table t3 (b int);
+insert into t2 values (1);
+insert into t3 values (1),(2);
+INSERT INTO t1 (x) VALUES ((SELECT x FROM t1));
+ERROR HY000: You can't specify target table 't1' for update in FROM clause
+INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
+ERROR 21000: Subquery returns more than 1 row
+INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
+select * from t1;
+x
+1
+insert into t2 values (1);
+INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
+select * from t1;
+x
+1
+2
+INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2;
+select * from t1;
+x
+1
+2
+3
+3
+INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2;
+INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2));
+ERROR 42S22: Unknown column 'x' in 'field list'
+INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
+select * from t1;
+x
+1
+2
+3
+3
+11
+11
+2
+drop table t1, t2, t3;
+CREATE TABLE t1 (x int not null, y int, primary key (x));
+create table t2 (a int);
+create table t3 (a int);
+insert into t2 values (1);
+insert into t3 values (1),(2);
+select * from t1;
+x y
+replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2));
+ERROR HY000: You can't specify target table 't1' for update in FROM clause
+replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
+ERROR 21000: Subquery returns more than 1 row
+replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
+select * from t1;
+x y
+1 2
+replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+2 FROM t2));
+select * from t1;
+x y
+1 3
+replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a FROM t2));
+select * from t1;
+x y
+1 3
+4 1
+replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a+1 FROM t2));
+select * from t1;
+x y
+1 3
+4 2
+replace LOW_PRIORITY into t1 (x, y) VALUES ((SELECT a+1 FROM t2), (SELECT a FROM t2));
+select * from t1;
+x y
+1 3
+4 2
+2 1
+drop table t1, t2, t3;
+SELECT * FROM (SELECT 1) b WHERE 1 IN (SELECT *);
+ERROR HY000: No tables used
+CREATE TABLE t2 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t2 VALUES (1),(2);
+SELECT * FROM t2 WHERE id IN (SELECT 1);
+id
+1
+EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ref id id 5 const 1 Using where; Using index
+Warnings:
+Note 1248 Select 2 was reduced during optimisation
+Note 1003 select high_priority test.t2.id AS `id` from test.t2 where (test.t2.id = 1)
+SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3);
+id
+1
+SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1));
+id
+2
+EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1));
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ref id id 5 const 1 Using where; Using index
+Warnings:
+Note 1248 Select 3 was reduced during optimisation
+Note 1248 Select 2 was reduced during optimisation
+Note 1003 select high_priority test.t2.id AS `id` from test.t2 where (test.t2.id = (1 + 1))
+EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 index NULL id 5 NULL 2 Using where; Using index
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 DEPENDENT UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority test.t2.id AS `id` from test.t2 where <in_optimizer>(test.t2.id,<exists>(select 1 AS `Not_used` having (<cache>(test.t2.id) = <null_helper>(1)) limit 1 union select 1 AS `Not_used` having (<cache>(test.t2.id) = <null_helper>(3)) limit 1))
+SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3);
+id
+SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
+id
+2
+INSERT INTO t2 VALUES ((SELECT * FROM t2));
+ERROR HY000: You can't specify target table 't2' for update in FROM clause
+INSERT INTO t2 VALUES ((SELECT id FROM t2));
+ERROR HY000: You can't specify target table 't2' for update in FROM clause
+SELECT * FROM t2;
+id
+1
+2
+CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 values (1),(1);
+UPDATE t2 SET id=(SELECT * FROM t1);
+ERROR 21000: Subquery returns more than 1 row
+drop table t2, t1;
+create table t1 (a int);
+insert into t1 values (1),(2),(3);
+select 1 IN (SELECT * from t1);
+1 IN (SELECT * from t1)
+1
+select 10 IN (SELECT * from t1);
+10 IN (SELECT * from t1)
+0
+select NULL IN (SELECT * from t1);
+NULL IN (SELECT * from t1)
+NULL
+update t1 set a=NULL where a=2;
+select 1 IN (SELECT * from t1);
+1 IN (SELECT * from t1)
+1
+select 3 IN (SELECT * from t1);
+3 IN (SELECT * from t1)
+1
+select 10 IN (SELECT * from t1);
+10 IN (SELECT * from t1)
+NULL
+select 1 > ALL (SELECT * from t1);
+1 > ALL (SELECT * from t1)
+0
+select 10 > ALL (SELECT * from t1);
+10 > ALL (SELECT * from t1)
+NULL
+select 1 > ANY (SELECT * from t1);
+1 > ANY (SELECT * from t1)
+NULL
+select 10 > ANY (SELECT * from t1);
+10 > ANY (SELECT * from t1)
+1
+drop table t1;
+create table t1 (a varchar(20));
+insert into t1 values ('A'),('BC'),('DEF');
+select 'A' IN (SELECT * from t1);
+'A' IN (SELECT * from t1)
+1
+select 'XYZS' IN (SELECT * from t1);
+'XYZS' IN (SELECT * from t1)
+0
+select NULL IN (SELECT * from t1);
+NULL IN (SELECT * from t1)
+NULL
+update t1 set a=NULL where a='BC';
+select 'A' IN (SELECT * from t1);
+'A' IN (SELECT * from t1)
+1
+select 'DEF' IN (SELECT * from t1);
+'DEF' IN (SELECT * from t1)
+1
+select 'XYZS' IN (SELECT * from t1);
+'XYZS' IN (SELECT * from t1)
+NULL
+select 'A' > ALL (SELECT * from t1);
+'A' > ALL (SELECT * from t1)
+0
+select 'XYZS' > ALL (SELECT * from t1);
+'XYZS' > ALL (SELECT * from t1)
+NULL
+select 'A' > ANY (SELECT * from t1);
+'A' > ANY (SELECT * from t1)
+NULL
+select 'XYZS' > ANY (SELECT * from t1);
+'XYZS' > ANY (SELECT * from t1)
+1
+drop table t1;
+create table t1 (a float);
+insert into t1 values (1.5),(2.5),(3.5);
+select 1.5 IN (SELECT * from t1);
+1.5 IN (SELECT * from t1)
+1
+select 10.5 IN (SELECT * from t1);
+10.5 IN (SELECT * from t1)
+0
+select NULL IN (SELECT * from t1);
+NULL IN (SELECT * from t1)
+NULL
+update t1 set a=NULL where a=2.5;
+select 1.5 IN (SELECT * from t1);
+1.5 IN (SELECT * from t1)
+1
+select 3.5 IN (SELECT * from t1);
+3.5 IN (SELECT * from t1)
+1
+select 10.5 IN (SELECT * from t1);
+10.5 IN (SELECT * from t1)
+NULL
+select 1.5 > ALL (SELECT * from t1);
+1.5 > ALL (SELECT * from t1)
+0
+select 10.5 > ALL (SELECT * from t1);
+10.5 > ALL (SELECT * from t1)
+NULL
+select 1.5 > ANY (SELECT * from t1);
+1.5 > ANY (SELECT * from t1)
+NULL
+select 10.5 > ANY (SELECT * from t1);
+10.5 > ANY (SELECT * from t1)
+1
+explain extended select (select a+1) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3
+Warnings:
+Note 1275 Field or reference 'a' of SELECT #2 was resolved in SELECT #1
+Note 1248 Select 2 was reduced during optimisation
+Note 1003 select high_priority (test.t1.a + 1) AS `(select a+1)` from test.t1
+select (select a+1) from t1;
+(select a+1)
+2.5
+NULL
+4.5
+drop table t1;
+CREATE TABLE t1 (a int(11) NOT NULL default '0', PRIMARY KEY (a));
+CREATE TABLE t2 (a int(11) default '0', INDEX (a));
+INSERT INTO t1 VALUES (1),(2),(3),(4);
+INSERT INTO t2 VALUES (1),(2),(3);
+SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
+a t1.a in (select t2.a from t2)
+1 1
+2 1
+3 1
+4 0
+explain extended SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 Using index
+2 DEPENDENT SUBQUERY t2 index_subquery a a 5 func 2 Using index
+Warnings:
+Note 1003 select high_priority test.t1.a AS `a`,<in_optimizer>(test.t1.a,<exists>(<index_lookup>(<cache>(test.t1.a) in t2 on a chicking NULL))) AS `t1.a in (select t2.a from t2)` from test.t1
+CREATE TABLE t3 (a int(11) default '0');
+INSERT INTO t3 VALUES (1),(2),(3);
+SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1;
+a t1.a in (select t2.a from t2,t3 where t3.a=t2.a)
+1 1
+2 1
+3 1
+4 0
+explain extended SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 Using index
+2 DEPENDENT SUBQUERY t2 ref_or_null a a 5 func 2 Using where; Using index
+2 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 Using where
+Warnings:
+Note 1003 select high_priority test.t1.a AS `a`,<in_optimizer>(test.t1.a,<exists>(select 1 AS `Not_used` from test.t2 join test.t3 where ((test.t3.a = test.t2.a) and ((<cache>(test.t1.a) = test.t2.a) or isnull(test.t2.a))) having <is_not_null_test>(test.t2.a) limit 1)) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from test.t1
+drop table t1,t2,t3;
+create table t1 (a float);
+select 10.5 IN (SELECT * from t1 LIMIT 1);
+ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
+select 10.5 IN (SELECT * from t1 LIMIT 1 UNION SELECT 1.5);
+ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
+drop table t1;
+create table t1 (a int, b int, c varchar(10));
+create table t2 (a int);
+insert into t1 values (1,2,'a'),(2,3,'b'),(3,4,'c');
+insert into t2 values (1),(2),(NULL);
+select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,2,'a'),(select c from t1 where a=t2.a) from t2;
+a (select a,b,c from t1 where t1.a=t2.a) = ROW(a,2,'a') (select c from t1 where a=t2.a)
+1 1 a
+2 0 b
+NULL NULL NULL
+select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,3,'b'),(select c from t1 where a=t2.a) from t2;
+a (select a,b,c from t1 where t1.a=t2.a) = ROW(a,3,'b') (select c from t1 where a=t2.a)
+1 0 a
+2 1 b
+NULL NULL NULL
+select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,4,'c'),(select c from t1 where a=t2.a) from t2;
+a (select a,b,c from t1 where t1.a=t2.a) = ROW(a,4,'c') (select c from t1 where a=t2.a)
+1 0 a
+2 0 b
+NULL NULL NULL
+drop table t1,t2;
+create table t1 (a int, b real, c varchar(10));
+insert into t1 values (1, 1, 'a'), (2,2,'b'), (NULL, 2, 'b');
+select ROW(1, 1, 'a') IN (select a,b,c from t1);
+ROW(1, 1, 'a') IN (select a,b,c from t1)
+1
+select ROW(1, 2, 'a') IN (select a,b,c from t1);
+ROW(1, 2, 'a') IN (select a,b,c from t1)
+NULL
+select ROW(1, 1, 'a') IN (select b,a,c from t1);
+ROW(1, 1, 'a') IN (select b,a,c from t1)
+1
+select ROW(1, 1, 'a') IN (select a,b,c from t1 where a is not null);
+ROW(1, 1, 'a') IN (select a,b,c from t1 where a is not null)
+1
+select ROW(1, 2, 'a') IN (select a,b,c from t1 where a is not null);
+ROW(1, 2, 'a') IN (select a,b,c from t1 where a is not null)
+0
+select ROW(1, 1, 'a') IN (select b,a,c from t1 where a is not null);
+ROW(1, 1, 'a') IN (select b,a,c from t1 where a is not null)
+1
+select ROW(1, 1, 'a') IN (select a,b,c from t1 where c='b' or c='a');
+ROW(1, 1, 'a') IN (select a,b,c from t1 where c='b' or c='a')
+1
+select ROW(1, 2, 'a') IN (select a,b,c from t1 where c='b' or c='a');
+ROW(1, 2, 'a') IN (select a,b,c from t1 where c='b' or c='a')
+NULL
+select ROW(1, 1, 'a') IN (select b,a,c from t1 where c='b' or c='a');
+ROW(1, 1, 'a') IN (select b,a,c from t1 where c='b' or c='a')
+1
+select ROW(1, 1, 'a') IN (select b,a,c from t1 limit 2);
+ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
+drop table t1;
+create table t1 (a int);
+insert into t1 values (1);
+do @a:=(SELECT a from t1);
+select @a;
+@a
+1
+set @a:=2;
+set @a:=(SELECT a from t1);
+select @a;
+@a
+1
+drop table t1;
+do (SELECT a from t1);
+ERROR 42S02: Table 'test.t1' doesn't exist
+set @a:=(SELECT a from t1);
+ERROR 42S02: Table 'test.t1' doesn't exist
+CREATE TABLE t1 (a int, KEY(a));
+HANDLER t1 OPEN;
+HANDLER t1 READ a=((SELECT 1));
+ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use
+HANDLER t1 CLOSE;
+drop table t1;
+create table t1 (a int);
+create table t2 (b int);
+insert into t1 values (1),(2);
+insert into t2 values (1);
+select a from t1 where a in (select a from t1 where a in (select b from t2));
+a
+1
+drop table t1, t2;
+create table t1 (a int, b int);
+create table t2 like t1;
+insert into t1 values (1,2),(1,3),(1,4),(1,5);
+insert into t2 values (1,2),(1,3);
+select * from t1 where row(a,b) in (select a,b from t2);
+a b
+1 2
+1 3
+drop table t1, t2;
+CREATE TABLE `t1` (`i` int(11) NOT NULL default '0',PRIMARY KEY (`i`)) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES (1);
+UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i));
+ERROR HY000: Invalid use of group function
+drop table t1;
+CREATE TABLE t1 (a int(1));
+EXPLAIN EXTENDED SELECT (SELECT RAND() FROM t1) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
+2 UNCACHEABLE SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found
+Warnings:
+Note 1003 select high_priority no_cache (select no_cache rand() AS `RAND()` from test.t1) AS `(SELECT RAND() FROM t1)` from test.t1
+EXPLAIN EXTENDED SELECT (SELECT ENCRYPT('test') FROM t1) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
+2 UNCACHEABLE SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found
+Warnings:
+Note 1003 select high_priority no_cache (select no_cache ecrypt(_latin1'test') AS `ENCRYPT('test')` from test.t1) AS `(SELECT ENCRYPT('test') FROM t1)` from test.t1
+EXPLAIN EXTENDED SELECT (SELECT BENCHMARK(1,1) FROM t1) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system NULL NULL NULL NULL 0 const row not found
+2 UNCACHEABLE SUBQUERY t1 system NULL NULL NULL NULL 0 const row not found
+Warnings:
+Note 1003 select high_priority no_cache (select no_cache benchmark(1,1) AS `BENCHMARK(1,1)` from test.t1) AS `(SELECT BENCHMARK(1,1) FROM t1)` from test.t1
+drop table t1;
+CREATE TABLE `t1` (
+`mot` varchar(30) character set latin1 NOT NULL default '',
+`topic` mediumint(8) unsigned NOT NULL default '0',
+`date` date NOT NULL default '0000-00-00',
+`pseudo` varchar(35) character set latin1 NOT NULL default '',
+PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`),
+KEY `pseudo` (`pseudo`,`date`,`topic`),
+KEY `topic` (`topic`)
+) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC;
+CREATE TABLE `t2` (
+`mot` varchar(30) character set latin1 NOT NULL default '',
+`topic` mediumint(8) unsigned NOT NULL default '0',
+`date` date NOT NULL default '0000-00-00',
+`pseudo` varchar(35) character set latin1 NOT NULL default '',
+PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`),
+KEY `pseudo` (`pseudo`,`date`,`topic`),
+KEY `topic` (`topic`)
+) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC;
+CREATE TABLE `t3` (
+`numeropost` mediumint(8) unsigned NOT NULL auto_increment,
+`maxnumrep` int(10) unsigned NOT NULL default '0',
+PRIMARY KEY (`numeropost`),
+UNIQUE KEY `maxnumrep` (`maxnumrep`)
+) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES ('joce','1','','joce'),('test','2','','test');
+Warnings:
+Warning 1264 Data truncated for column 'date' at row 1
+Warning 1264 Data truncated for column 'date' at row 2
+INSERT INTO t2 VALUES ('joce','1','','joce'),('test','2','','test');
+Warnings:
+Warning 1264 Data truncated for column 'date' at row 1
+Warning 1264 Data truncated for column 'date' at row 2
+INSERT INTO t3 VALUES (1,1);
+SELECT DISTINCT topic FROM t2 WHERE NOT EXISTS(SELECT * FROM t3 WHERE
+numeropost=topic);
+topic
+2
+select * from t1;
+mot topic date pseudo
+joce 1 0000-00-00 joce
+test 2 0000-00-00 test
+DELETE FROM t1 WHERE topic IN (SELECT DISTINCT topic FROM t2 WHERE NOT
+EXISTS(SELECT * FROM t3 WHERE numeropost=topic));
+select * from t1;
+mot topic date pseudo
+joce 1 0000-00-00 joce
+drop table t1, t2, t3;
+SELECT * FROM (SELECT 1 as a,(SELECT a)) a;
+a (SELECT a)
+1 1
+CREATE TABLE t1 SELECT * FROM (SELECT 1 as a,(SELECT 1)) a;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(1) NOT NULL default '0',
+ `(SELECT 1)` bigint(1) NOT NULL default '0'
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+CREATE TABLE t1 SELECT * FROM (SELECT 1 as a,(SELECT a)) a;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(1) NOT NULL default '0',
+ `(SELECT a)` bigint(1) NOT NULL default '0'
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+CREATE TABLE t1 SELECT * FROM (SELECT 1 as a,(SELECT a+0)) a;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(1) NOT NULL default '0',
+ `(SELECT a+0)` bigint(17) NOT NULL default '0'
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+CREATE TABLE t1 SELECT (SELECT 1 as a UNION SELECT 1+1 limit 1,1) as a;
+select * from t1;
+a
+2
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` bigint(17) NOT NULL default '0'
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (a int);
+insert into t1 values (1), (2), (3);
+explain extended select a,(select (select rand() from t1 limit 1) from t1 limit 1)
+from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3
+2 UNCACHEABLE SUBQUERY t1 ALL NULL NULL NULL NULL 3
+3 UNCACHEABLE SUBQUERY t1 ALL NULL NULL NULL NULL 3
+Warnings:
+Note 1003 select high_priority no_cache test.t1.a AS `a`,(select no_cache (select no_cache rand() AS `rand()` from test.t1 limit 1) AS `(select rand() from t1 limit 1)` from test.t1 limit 1) AS `(select (select rand() from t1 limit 1) from t1 limit 1)` from test.t1
+drop table t1;
+select t1.Continent, t2.Name, t2.Population from t1 LEFT JOIN t2 ON t1.Code = t2.Country where t2.Population IN (select max(t2.Population) AS Population from t2, t1 where t2.Country = t1.Code group by Continent);
+ERROR 42S02: Table 'test.t1' doesn't exist
+CREATE TABLE t1 (
+ID int(11) NOT NULL auto_increment,
+name char(35) NOT NULL default '',
+t2 char(3) NOT NULL default '',
+District char(20) NOT NULL default '',
+Population int(11) NOT NULL default '0',
+PRIMARY KEY (ID)
+) TYPE=MyISAM;
+INSERT INTO t1 VALUES (130,'Sydney','AUS','New South Wales',3276207);
+INSERT INTO t1 VALUES (131,'Melbourne','AUS','Victoria',2865329);
+INSERT INTO t1 VALUES (132,'Brisbane','AUS','Queensland',1291117);
+CREATE TABLE t2 (
+Code char(3) NOT NULL default '',
+Name char(52) NOT NULL default '',
+Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL default 'Asia',
+Region char(26) NOT NULL default '',
+SurfaceArea float(10,2) NOT NULL default '0.00',
+IndepYear smallint(6) default NULL,
+Population int(11) NOT NULL default '0',
+LifeExpectancy float(3,1) default NULL,
+GNP float(10,2) default NULL,
+GNPOld float(10,2) default NULL,
+LocalName char(45) NOT NULL default '',
+GovernmentForm char(45) NOT NULL default '',
+HeadOfState char(60) default NULL,
+Capital int(11) default NULL,
+Code2 char(2) NOT NULL default '',
+PRIMARY KEY (Code)
+) TYPE=MyISAM;
+INSERT INTO t2 VALUES ('AUS','Australia','Oceania','Australia and New Zealand',7741220.00,1901,18886000,79.8,351182.00,392911.00,'Australia','Constitutional Monarchy, Federation','Elisabeth II',135,'AU');
+INSERT INTO t2 VALUES ('AZE','Azerbaijan','Asia','Middle East',86600.00,1991,7734000,62.9,4127.00,4100.00,'Azärbaycan','Federal Republic','Heydär Äliyev',144,'AZ');
+select t2.Continent, t1.Name, t1.Population from t2 LEFT JOIN t1 ON t2.Code = t1.t2 where t1.Population IN (select max(t1.Population) AS Population from t1, t2 where t1.t2 = t2.Code group by Continent);
+Continent Name Population
+Oceania Sydney 3276207
+drop table t1, t2;
+CREATE TABLE `t1` (
+`id` mediumint(8) unsigned NOT NULL auto_increment,
+`pseudo` varchar(35) character set latin1 NOT NULL default '',
+PRIMARY KEY (`id`),
+UNIQUE KEY `pseudo` (`pseudo`),
+) TYPE=MyISAM PACK_KEYS=1 ROW_FORMAT=DYNAMIC;
+INSERT INTO t1 (pseudo) VALUES ('test');
+SELECT 0 IN (SELECT 1 FROM t1 a);
+0 IN (SELECT 1 FROM t1 a)
+0
+EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+Warnings:
+Note 1003 select high_priority <in_optimizer>(0,<exists>(select 1 AS `Not_used` from test.t1 a where isnull(1) having <is_not_null_test>(1) limit 1)) AS `0 IN (SELECT 1 FROM t1 a)`
+INSERT INTO t1 (pseudo) VALUES ('test1');
+SELECT 0 IN (SELECT 1 FROM t1 a);
+0 IN (SELECT 1 FROM t1 a)
+0
+EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+Warnings:
+Note 1003 select high_priority <in_optimizer>(0,<exists>(select 1 AS `Not_used` from test.t1 a where isnull(1) having <is_not_null_test>(1) limit 1)) AS `0 IN (SELECT 1 FROM t1 a)`
+drop table t1;
+CREATE TABLE `t1` (
+`i` int(11) NOT NULL default '0',
+PRIMARY KEY (`i`)
+) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES (1);
+UPDATE t1 SET i=i+(SELECT MAX(i) FROM (SELECT 1) t) WHERE i=(SELECT MAX(i));
+ERROR HY000: Invalid use of group function
+UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i));
+ERROR HY000: Invalid use of group function
+UPDATE t1 SET t.i=i+(SELECT MAX(i) FROM (SELECT 1) t);
+ERROR 42S02: Unknown table 't' in field list
+drop table t1;
+CREATE TABLE t1 (
+id int(11) default NULL
+) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES (1),(1),(2),(2),(1),(3);
+CREATE TABLE t2 (
+id int(11) default NULL,
+name varchar(15) default NULL
+) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t2 VALUES (4,'vita'), (1,'vita'), (2,'vita'), (1,'vita');
+update t1, t2 set t2.name='lenka' where t2.id in (select id from t1);
+select * from t2;
+id name
+4 vita
+1 lenka
+2 lenka
+1 lenka
+drop table t1,t2;
+create table t1 (a int, unique index indexa (a));
+insert into t1 values (-1), (-4), (-2), (NULL);
+select -10 IN (select a from t1 FORCE INDEX (indexa));
+-10 IN (select a from t1 FORCE INDEX (indexa))
+NULL
+drop table t1;
+create table t1 (id int not null auto_increment primary key, salary int, key(salary));
+insert into t1 (salary) values (100),(1000),(10000),(10),(500),(5000),(50000);
+explain extended SELECT id FROM t1 where salary = (SELECT MAX(salary) FROM t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref salary salary 5 const 1 Using where
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+Warnings:
+Note 1003 select high_priority test.t1.id AS `id` from test.t1 where (test.t1.salary = (select max(test.t1.salary) AS `MAX(salary)` from test.t1))
+drop table t1;
+CREATE TABLE t1 (
+ID int(10) unsigned NOT NULL auto_increment,
+SUB_ID int(3) unsigned NOT NULL default '0',
+REF_ID int(10) unsigned default NULL,
+REF_SUB int(3) unsigned default '0',
+PRIMARY KEY (ID,SUB_ID),
+UNIQUE KEY t1_PK (ID,SUB_ID),
+KEY t1_FK (REF_ID,REF_SUB),
+KEY t1_REFID (REF_ID)
+) TYPE=MyISAM CHARSET=cp1251;
+INSERT INTO t1 VALUES (1,0,NULL,NULL),(2,0,NULL,NULL);
+SELECT DISTINCT REF_ID FROM t1 WHERE ID= (SELECT DISTINCT REF_ID FROM t1 WHERE ID=2);
+REF_ID
+DROP TABLE t1;
+create table t1 (a int, b int);
+create table t2 (a int, b int);
+insert into t1 values (1,0), (2,0), (3,0);
+insert into t2 values (1,1), (2,1), (3,1), (2,2);
+update ignore t1 set b=(select b from t2 where t1.a=t2.a);
+Warnings:
+Error 1241 Subquery returns more than 1 row
+select * from t1;
+a b
+1 1
+2 NULL
+3 1
+drop table t1, t2;
+create table t1(City VARCHAR(30),Location geometry);
+insert into t1 values("Paris",GeomFromText('POINT(2.33 48.87)'));
+select City from t1 where (select intersects(GeomFromText(AsText(Location)),GeomFromText('Polygon((2 50, 2.5 50, 2.5 47, 2 47, 2 50))'))=0);
+City
+drop table t1;
+CREATE TABLE `t1` (
+`id` mediumint(8) unsigned NOT NULL auto_increment,
+`pseudo` varchar(35) NOT NULL default '',
+`email` varchar(60) NOT NULL default '',
+PRIMARY KEY (`id`),
+UNIQUE KEY `email` (`email`),
+UNIQUE KEY `pseudo` (`pseudo`),
+) TYPE=MyISAM CHARSET=latin1 PACK_KEYS=1 ROW_FORMAT=DYNAMIC;
+INSERT INTO t1 (id,pseudo,email) VALUES (1,'test','test'),(2,'test1','test1');
+SELECT pseudo as a, pseudo as b FROM t1 GROUP BY (SELECT a) ORDER BY (SELECT id*1);
+a b
+test test
+test1 test1
+drop table if exists t1;
+(SELECT 1 as a) UNION (SELECT 1) ORDER BY (SELECT a+0);
+a
+1
+create table t1 (a int not null, b int, primary key (a));
+create table t2 (a int not null, primary key (a));
+create table t3 (a int not null, b int, primary key (a));
+insert into t1 values (1,10), (2,20), (3,30), (4,40);
+insert into t2 values (2), (3), (4), (5);
+insert into t3 values (10,3), (20,4), (30,5);
+select * from t2 where t2.a in (select a from t1);
+a
+2
+3
+4
+explain extended select * from t2 where t2.a in (select a from t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 Using where; Using index
+2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 Using index
+Warnings:
+Note 1003 select high_priority test.t2.a AS `a` from test.t2 where <in_optimizer>(test.t2.a,<exists>(<primary_index_lookup>(<cache>(test.t2.a) in t1 on PRIMARY)))
+select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+a
+2
+4
+explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 Using where; Using index
+2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 Using index; Using where
+Warnings:
+Note 1003 select high_priority test.t2.a AS `a` from test.t2 where <in_optimizer>(test.t2.a,<exists>(<primary_index_lookup>(<cache>(test.t2.a) in t1 on PRIMARY where (test.t1.b <> 30))))
+select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
+a
+2
+3
+explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 index NULL PRIMARY 4 NULL 4 Using where; Using index
+2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 func 1 Using where
+2 DEPENDENT SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 Using where; Using index
+Warnings:
+Note 1003 select high_priority test.t2.a AS `a` from test.t2 where <in_optimizer>(test.t2.a,<exists>(select 1 AS `Not_used` from test.t1 join test.t3 where ((test.t1.b = test.t3.a) and (<cache>(test.t2.a) = test.t1.a)) limit 1))
+drop table t1, t2, t3;
+create table t1 (a int, b int, index a (a,b));
+create table t2 (a int, index a (a));
+create table t3 (a int, b int, index a (a));
+insert into t1 values (1,10), (2,20), (3,30), (4,40);
+insert into t2 values (2), (3), (4), (5);
+insert into t3 values (10,3), (20,4), (30,5);
+select * from t2 where t2.a in (select a from t1);
+a
+2
+3
+4
+explain extended select * from t2 where t2.a in (select a from t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
+2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 Using index
+Warnings:
+Note 1003 select high_priority test.t2.a AS `a` from test.t2 where <in_optimizer>(test.t2.a,<exists>(<index_lookup>(<cache>(test.t2.a) in t1 on a)))
+select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+a
+2
+4
+explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
+2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 Using index; Using where
+Warnings:
+Note 1003 select high_priority test.t2.a AS `a` from test.t2 where <in_optimizer>(test.t2.a,<exists>(<index_lookup>(<cache>(test.t2.a) in t1 on a where (test.t1.b <> 30))))
+select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
+a
+2
+3
+explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
+2 DEPENDENT SUBQUERY t3 index a a 5 NULL 3 Using index
+2 DEPENDENT SUBQUERY t1 ref a a 10 func,test.t3.a 1000 Using where; Using index
+Warnings:
+Note 1003 select high_priority test.t2.a AS `a` from test.t2 where <in_optimizer>(test.t2.a,<exists>(select 1 AS `Not_used` from test.t1 join test.t3 where ((test.t1.b = test.t3.a) and (<cache>(test.t2.a) = test.t1.a)) limit 1))
+insert into t1 values (3,31);
+select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+a
+2
+3
+4
+select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31);
+a
+2
+4
+explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 index NULL a 5 NULL 4 Using where; Using index
+2 DEPENDENT SUBQUERY t1 index_subquery a a 5 func 1001 Using index; Using where
+Warnings:
+Note 1003 select high_priority test.t2.a AS `a` from test.t2 where <in_optimizer>(test.t2.a,<exists>(<index_lookup>(<cache>(test.t2.a) in t1 on a where (test.t1.b <> 30))))
+drop table t1, t2, t3;
+create table t1 (a int, b int);
+create table t2 (a int, b int);
+create table t3 (a int, b int);
+insert into t1 values (0,100),(1,2), (1,3), (2,2), (2,7), (2,-1), (3,10);
+insert into t2 values (0,0), (1,1), (2,1), (3,1), (4,1);
+insert into t3 values (3,3), (2,2), (1,1);
+select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) from t3;
+a (select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1)
+3 1
+2 2
+1 2
+drop table t1,t2,t3;
+create table t1 (s1 int);
+create table t2 (s1 int);
+insert into t1 values (1);
+insert into t2 values (1);
+select * from t1 where exists (select s1 from t2 having max(t2.s1)=t1.s1);
+s1
+1
+drop table t1,t2;
+create table t1 (s1 int);
+create table t2 (s1 int);
+insert into t1 values (1);
+insert into t2 values (1);
+update t1 set s1 = s1 + 1 where 1 = (select x.s1 as A from t2 WHERE t2.s1 > t1.s1 order by A);
+ERROR 42S22: Unknown column 'x.s1' in 'field list'
+DROP TABLE t1, t2;
+CREATE TABLE t1 (s1 CHAR(5) COLLATE latin1_german1_ci,
+s2 CHAR(5) COLLATE latin1_swedish_ci);
+INSERT INTO t1 VALUES ('z','?');
+select * from t1 where s1 > (select max(s2) from t1);
+ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '>'
+select * from t1 where s1 > any (select max(s2) from t1);
+ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '>'
+drop table t1;
+create table t1(toid int,rd int);
+create table t2(userid int,pmnew int,pmtotal int);
+insert into t2 values(1,0,0),(2,0,0);
+insert into t1 values(1,0),(1,0),(1,0),(1,12),(1,15),(1,123),(1,12312),(1,12312),(1,123),(2,0),(2,0),(2,1),(2,2);
+select userid,pmtotal,pmnew, (select count(rd) from t1 where toid=t2.userid) calc_total, (select count(rd) from t1 where rd=0 and toid=t2.userid) calc_new from t2 where userid in (select distinct toid from t1);
+userid pmtotal pmnew calc_total calc_new
+1 0 0 9 3
+2 0 0 4 2
+drop table t1, t2;
+create table t1 (s1 char(5));
+select (select 'a','b' from t1 union select 'a','b' from t1) from t1;
+ERROR 21000: Operand should contain 1 column(s)
+insert into t1 values ('tttt');
+select * from t1 where ('a','b')=(select 'a','b' from t1 union select 'a','b' from t1);
+s1
+tttt
+explain extended (select * from t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 1
+Warnings:
+Note 1003 (select high_priority test.t1.s1 AS `s1` from test.t1)
+(select * from t1);
+s1
+tttt
+drop table t1;
+create table t1 (s1 char(5), index s1(s1));
+create table t2 (s1 char(5), index s1(s1));
+insert into t1 values ('a1'),('a2'),('a3');
+insert into t2 values ('a1'),('a2');
+select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
+s1 s1 NOT IN (SELECT s1 FROM t2)
+a1 0
+a2 0
+a3 1
+select s1, s1 = ANY (SELECT s1 FROM t2) from t1;
+s1 s1 = ANY (SELECT s1 FROM t2)
+a1 1
+a2 1
+a3 0
+select s1, s1 <> ALL (SELECT s1 FROM t2) from t1;
+s1 s1 <> ALL (SELECT s1 FROM t2)
+a1 0
+a2 0
+a3 1
+select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
+s1 s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')
+a1 0
+a2 1
+a3 1
+explain extended select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL s1 6 NULL 3 Using index
+2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index
+Warnings:
+Note 1003 select high_priority test.t1.s1 AS `s1`,not(<in_optimizer>(test.t1.s1,<exists>(<index_lookup>(<cache>(test.t1.s1) in t2 on s1 chicking NULL)))) AS `s1 NOT IN (SELECT s1 FROM t2)` from test.t1
+explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL s1 6 NULL 3 Using index
+2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index
+Warnings:
+Note 1003 select high_priority test.t1.s1 AS `s1`,<in_optimizer>(test.t1.s1,<exists>(<index_lookup>(<cache>(test.t1.s1) in t2 on s1 chicking NULL))) AS `s1 = ANY (SELECT s1 FROM t2)` from test.t1
+explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL s1 6 NULL 3 Using index
+2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 2 Using index
+Warnings:
+Note 1003 select high_priority test.t1.s1 AS `s1`,not(<in_optimizer>(test.t1.s1,<exists>(<index_lookup>(<cache>(test.t1.s1) in t2 on s1 chicking NULL)))) AS `s1 <> ALL (SELECT s1 FROM t2)` from test.t1
+explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL s1 6 NULL 3 Using index
+2 DEPENDENT SUBQUERY t2 index_subquery s1 s1 6 func 1 Using index; Using where
+Warnings:
+Note 1003 select high_priority test.t1.s1 AS `s1`,not(<in_optimizer>(test.t1.s1,<exists>(<index_lookup>(<cache>(test.t1.s1) in t2 on s1 chicking NULL where (test.t2.s1 < _latin1'a2'))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from test.t1
+drop table t1,t2;
+create table t2 (a int, b int);
+create table t3 (a int);
+insert into t3 values (6),(7),(3);
+select * from t3 where a >= all (select b from t2);
+a
+6
+7
+3
+explain extended select * from t3 where a >= all (select b from t2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 system NULL NULL NULL NULL 0 const row not found
+Warnings:
+Note 1003 select high_priority test.t3.a AS `a` from test.t3 where <not>((test.t3.a < (select max(test.t2.b) from test.t2 limit 1)))
+insert into t2 values (2,2), (2,1), (3,3), (3,1);
+select * from t3 where a > all (select max(b) from t2 group by a);
+a
+6
+7
+explain extended select * from t3 where a > all (select max(b) from t2 group by a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using temporary; Using filesort
+Warnings:
+Note 1003 select high_priority test.t3.a AS `a` from test.t3 where <not>((test.t3.a <= <max>(select max(test.t2.b) AS `max(b)` from test.t2 group by test.t2.a)))
+drop table t2, t3;
+CREATE TABLE `t1` ( `id` mediumint(9) NOT NULL auto_increment, `taskid` bigint(20) NOT NULL default '0', `dbid` int(11) NOT NULL default '0', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', `last_update` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) TYPE=MyISAM CHARSET=latin1 AUTO_INCREMENT=3 ;
+INSERT INTO `t1` (`id`, `taskid`, `dbid`, `create_date`,`last_update`) VALUES (1, 1, 15, '2003-09-29 10:31:36', '2003-09-29 10:31:36'), (2, 1, 21, now(), now());
+CREATE TABLE `t2` (`db_id` int(11) NOT NULL auto_increment,`name` varchar(200) NOT NULL default '',`primary_uid` smallint(6) NOT NULL default '0',`secondary_uid` smallint(6) NOT NULL default '0',PRIMARY KEY (`db_id`),UNIQUE KEY `name_2` (`name`),FULLTEXT KEY `name` (`name`)) TYPE=MyISAM CHARSET=latin1 AUTO_INCREMENT=2147483647;
+INSERT INTO `t2` (`db_id`, `name`, `primary_uid`, `secondary_uid`) VALUES (18, 'Not Set 1', 0, 0),(19, 'Valid', 1, 2),(20, 'Valid 2', 1, 2),(21, 'Should Not Return', 1, 2),(26, 'Not Set 2', 0, 0),(-1, 'ALL DB\'S', 0, 0);
+CREATE TABLE `t3` (`taskgenid` mediumint(9) NOT NULL auto_increment,`dbid` int(11) NOT NULL default '0',`taskid` int(11) NOT NULL default '0',`mon` tinyint(4) NOT NULL default '1',`tues` tinyint(4) NOT NULL default '1',`wed` tinyint(4) NOT NULL default '1',`thur` tinyint(4) NOT NULL default '1',`fri` tinyint(4) NOT NULL default '1',`sat` tinyint(4) NOT NULL default '0',`sun` tinyint(4) NOT NULL default '0',`how_often` smallint(6) NOT NULL default '1',`userid` smallint(6) NOT NULL default '0',`active` tinyint(4) NOT NULL default '1',PRIMARY KEY (`taskgenid`)) TYPE=MyISAM CHARSET=latin1 AUTO_INCREMENT=2 ;
+INSERT INTO `t3` (`taskgenid`, `dbid`, `taskid`, `mon`, `tues`,`wed`, `thur`, `fri`, `sat`, `sun`, `how_often`, `userid`, `active`) VALUES (1,-1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1);
+CREATE TABLE `t4` (`task_id` smallint(6) NOT NULL default '0',`description` varchar(200) NOT NULL default '') TYPE=MyISAM CHARSET=latin1;
+INSERT INTO `t4` (`task_id`, `description`) VALUES (1, 'Daily Check List'),(2, 'Weekly Status');
+select dbid, name, (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') from t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND t4.task_id = taskid;
+dbid name (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01')
+-1 Valid 1
+-1 Valid 2 1
+-1 Should Not Return 0
+SELECT dbid, name FROM t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND ((date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01')) AND t4.task_id = taskid;
+dbid name
+-1 Valid
+-1 Valid 2
+drop table t1,t2,t3,t4;
+CREATE TABLE t1 (id int(11) default NULL) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES (1),(5);
+CREATE TABLE t2 (id int(11) default NULL) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t2 VALUES (2),(6);
+select * from t1 where (1,2,6) in (select * from t2);
+ERROR 21000: Operand should contain 3 column(s)
+DROP TABLE t1,t2;
+create table t1 (s1 int);
+insert into t1 values (1);
+insert into t1 values (2);
+set sort_buffer_size = (select s1 from t1);
+ERROR 21000: Subquery returns more than 1 row
+do (select * from t1);
+drop table t1;
+create table t1 (s1 char);
+insert into t1 values ('e');
+select * from t1 where 'f' > any (select s1 from t1);
+s1
+e
+select * from t1 where 'f' > any (select s1 from t1 union select s1 from t1);
+s1
+e
+explain select * from t1 where 'f' > any (select s1 from t1 union select s1 from t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system NULL NULL NULL NULL 1
+2 SUBQUERY t1 system NULL NULL NULL NULL 1
+3 UNION t1 system NULL NULL NULL NULL 1
+drop table t1;
+CREATE TABLE t1 (number char(11) NOT NULL default '') TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
+CREATE TABLE t2 (code char(5) NOT NULL default '',UNIQUE KEY code (code)) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t2 VALUES ('1'),('1226'),('1245'),('1862'),('18623'),('1874'),('1967'),('6');
+select c.number as phone,(select p.code from t2 p where c.number like concat(p.code, '%') order by length(p.code) desc limit 1) as code from t1 c;
+phone code
+69294728265 6
+18621828126 1862
+89356874041 NULL
+95895001874 NULL
+drop table t1, t2;
+create table t1 (s1 int);
+create table t2 (s1 int);
+select * from t1 where (select count(*) from t2 where t1.s2) = 1;
+ERROR 42S22: Unknown column 't1.s2' in 'where clause'
+select * from t1 where (select count(*) from t2 group by t1.s2) = 1;
+ERROR 42S22: Unknown column 't1.s2' in 'group statement'
+select count(*) from t2 group by t1.s2;
+ERROR 42S02: Unknown table 't1' in group statement
+drop table t1, t2;
+CREATE TABLE t1(COLA FLOAT NOT NULL,COLB FLOAT NOT NULL,COLC VARCHAR(20) DEFAULT NULL,PRIMARY KEY (COLA, COLB));
+CREATE TABLE t2(COLA FLOAT NOT NULL,COLB FLOAT NOT NULL,COLC CHAR(1) NOT NULL,PRIMARY KEY (COLA));
+INSERT INTO t1 VALUES (1,1,'1A3240'), (1,2,'4W2365');
+INSERT INTO t2 VALUES (100, 200, 'C');
+SELECT DISTINCT COLC FROM t1 WHERE COLA = (SELECT COLA FROM t2 WHERE COLB = 200 AND COLC ='C' LIMIT 1);
+COLC
+DROP TABLE t1, t2;
diff --git a/mysql-test/r/subselect2.result b/mysql-test/r/subselect2.result
new file mode 100644
index 00000000000..98df44553d2
--- /dev/null
+++ b/mysql-test/r/subselect2.result
@@ -0,0 +1,131 @@
+drop table if exists t1, t2, t3, t4;
+CREATE TABLE t1
+(
+DOCID VARCHAR(32)BINARY NOT NULL
+, UUID VARCHAR(32)BINARY NOT NULL
+, MIMETYPE VARCHAR(80)BINARY
+, CONTENTDATA LONGBLOB
+, CONTENTSIZE INTEGER
+, VERSIONID INTEGER
+, REPID VARCHAR(32)BINARY
+, MODIFIED TIMESTAMP
+, MODIFIER VARCHAR(255)BINARY
+, ORIGINATOR INTEGER
+, PRIMARY KEY ( DOCID )
+) TYPE=InnoDB
+;
+CREATE TABLE t2
+(
+DOCID VARCHAR(32)BINARY NOT NULL
+, DOCNAME VARCHAR(255)BINARY NOT NULL
+, DOCTYPEID VARCHAR(32)BINARY NOT NULL
+, FOLDERID VARCHAR(32)BINARY NOT NULL
+, AUTHOR VARCHAR(255)BINARY
+, CREATED TIMESTAMP NOT NULL
+, TITLE VARCHAR(255)BINARY
+, SUBTITLE VARCHAR(255)BINARY
+, DOCABSTRACT LONGBLOB
+, PUBLISHDATE TIMESTAMP
+, EXPIRATIONDATE TIMESTAMP
+, LOCKEDBY VARCHAR(80)BINARY
+, STATUS VARCHAR(80)BINARY
+, PARENTDOCID VARCHAR(32)BINARY
+, REPID VARCHAR(32)BINARY
+, MODIFIED TIMESTAMP NOT NULL
+, MODIFIER VARCHAR(255)BINARY NOT NULL
+, PUBLISHSTATUS INTEGER
+, ORIGINATOR INTEGER
+, PRIMARY KEY ( DOCID )
+) TYPE=InnoDB
+;
+CREATE INDEX DDOCTYPEID_IDX ON t2 (DOCTYPEID);
+CREATE INDEX DFOLDERID_IDX ON t2 (FOLDERID);
+CREATE TABLE t3
+(
+FOLDERID VARCHAR(32)BINARY NOT NULL
+, FOLDERNAME VARCHAR(255)BINARY NOT NULL
+, CREATOR VARCHAR(255)BINARY
+, CREATED TIMESTAMP NOT NULL
+, DESCRIPTION VARCHAR(255)BINARY
+, FOLDERTYPE INTEGER NOT NULL
+, MODIFIED TIMESTAMP
+, MODIFIER VARCHAR(255)BINARY
+, FOLDERSIZE INTEGER NOT NULL
+, PARENTID VARCHAR(32)BINARY
+, REPID VARCHAR(32)BINARY
+, ORIGINATOR INTEGER
+, PRIMARY KEY ( FOLDERID )
+) TYPE=InnoDB;
+CREATE INDEX FFOLDERID_IDX ON t3 (FOLDERID);
+CREATE INDEX CMFLDRPARNT_IDX ON t3 (PARENTID);
+CREATE TABLE t4
+(
+DOCTYPEID VARCHAR(32)BINARY NOT NULL
+, DOCTYPENAME VARCHAR(80)BINARY NOT NULL
+, DESCRIPTION VARCHAR(255)BINARY
+, EXTNDATA LONGBLOB
+, MODIFIED TIMESTAMP
+, MODIFIER VARCHAR(255)BINARY
+, ORIGINATOR INTEGER
+, PRIMARY KEY ( DOCTYPEID )
+) TYPE=InnoDB;
+INSERT INTO t2 VALUES("c373e9f59cf15a6c3e57444553544200", "c373e9f59cf15a6c3e57444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-06 07:48:42", NULL, NULL, NULL, "2003-06-06 07:48:42", "2003-06-06 07:48:42", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-06 07:48:42", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5a472f43ba45e444553544200", "c373e9f5a472f43ba45e444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-07 18:50:12", NULL, NULL, NULL, "2003-06-07 18:50:12", "2003-06-07 18:50:12", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-07 18:50:12", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5a4a0f56014eb444553544200", "c373e9f5a4a0f56014eb444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-07 19:39:26", NULL, NULL, NULL, "2003-06-07 19:39:26", "2003-06-07 19:39:26", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-07 19:39:26", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5a4a0f8fa4a86444553544200", "c373e9f5a4a0f8fa4a86444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-07 19:43:05", NULL, NULL, NULL, "2003-06-07 19:43:05", "2003-06-07 19:43:05", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-07 19:43:05", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5ac7b537205ce444553544200", "c373e9f5ac7b537205ce444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-09 08:15:24", NULL, NULL, NULL, "2003-06-09 08:15:24", "2003-06-09 08:15:24", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-09 08:15:24", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5ad0792012454444553544200", "c373e9f5ad0792012454444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-09 10:51:44", NULL, NULL, NULL, "2003-06-09 10:51:44", "2003-06-09 10:51:44", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-09 10:51:44", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5ad079821ef34444553544200", "First Discussion", "c373e9f5ad079174ff17444553544200", "c373e9f5ad0796c0eca4444553544200", "Goldilocks", "2003-06-09 11:16:50", "Title: First Discussion", NULL, NULL, "2003-06-09 10:51:26", "2003-06-09 10:51:26", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-09 11:16:50", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5ad07993f3859444553544200", "Last Discussion", "c373e9f5ad079174ff17444553544200", "c373e9f5ad0796c0eca4444553544200", "Goldilocks", "2003-06-09 11:21:06", "Title: Last Discussion", NULL, "Setting new abstract and keeping doc checked out", "2003-06-09 10:51:26", "2003-06-09 10:51:26", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-09 11:21:06", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5ad079a3219c4444553544200", "testdoclayout", "340d243c45f111d497b00010a4ef934d", "c373e9f5ad0796c0eca4444553544200", "Goldilocks", "2003-06-09 11:25:31", "Title: Test doc layout", "Subtitle: test doc layout", NULL, "2003-06-09 10:51:27", "2003-06-09 10:51:27", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-09 11:25:31", "admin", "0", NULL);
+INSERT INTO t3 VALUES("0c9aab05b15048c59bc35c8461507deb", "System", "System", "2003-06-05 16:30:00", "The system content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "9c9aab05b15048c59bc35c8461507deb", "1");
+INSERT INTO t3 VALUES("2f6161e879db43c1a5b82c21ddc49089", "Default", "System", "2003-06-09 10:52:02", "The default content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "03eea05112b845949f3fd03278b5fe43", "1");
+INSERT INTO t3 VALUES("c373e9f5ad0791724315444553544200", "AddDocumentTest", "admin", "2003-06-09 10:51:25", "Movie Reviews", "0", "2003-06-09 10:51:25", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad07919e1963444553544200", "NewDestDirectory", "admin", "2003-06-09 10:51:28", "Adding new directory", "128", "2003-06-09 10:51:28", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad07919fe525444553544200", "SubDestDirectory", "admin", "2003-06-09 10:51:28", "Adding new directory", "128", "2003-06-09 10:51:28", "admin", "0", "c373e9f5ad07919e1963444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a0dab5444553544200", "Level1", "admin", "2003-06-09 10:51:29", NULL, "0", "2003-06-09 10:51:29", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a14669444553544200", "Level2", "admin", "2003-06-09 10:51:29", NULL, "0", "2003-06-09 10:51:29", "admin", "0", "c373e9f5ad0791a0dab5444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a23c0e444553544200", "Level3", "admin", "2003-06-09 10:51:29", NULL, "0", "2003-06-09 10:51:29", "admin", "0", "c373e9f5ad0791a14669444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a6b11f444553544200", "Dir1", "admin", "2003-06-09 10:51:30", NULL, "0", "2003-06-09 10:51:30", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a897d6444553544200", "Dir2", "admin", "2003-06-09 10:51:30", NULL, "0", "2003-06-09 10:51:30", "admin", "0", "c373e9f5ad0791a6b11f444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a9a063444553544200", "NewDestDirectory", "admin", "2003-06-09 10:51:31", NULL, "0", "2003-06-09 10:51:31", "admin", "0", "c373e9f5ad0791a897d6444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791aa73e3444553544200", "LevelA", "admin", "2003-06-09 10:51:31", NULL, "0", "2003-06-09 10:51:31", "admin", "0", "c373e9f5ad0791a0dab5444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791ab034b444553544200", "LevelB", "admin", "2003-06-09 10:51:31", NULL, "0", "2003-06-09 10:51:31", "admin", "0", "c373e9f5ad0791aa73e3444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791ac7311444553544200", "LevelC", "admin", "2003-06-09 10:51:32", NULL, "0", "2003-06-09 10:51:32", "admin", "0", "c373e9f5ad0791ab034b444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791ad66cf444553544200", "test2", "admin", "2003-06-09 10:51:32", NULL, "0", "2003-06-09 10:51:32", "admin", "0", "c373e9f5ad0791724315444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791aebd87444553544200", "test3", "admin", "2003-06-09 10:51:33", NULL, "0", "2003-06-09 10:51:33", "admin", "0", "c373e9f5ad0791ad66cf444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791dbaac4444553544200", "Special Café Folder", "admin", "2003-06-09 10:51:43", "test folder names with special chars", "0", "2003-06-09 10:51:43", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0796bf913f444553544200", "CopiedFolder", "admin", "2003-06-09 11:09:05", "Movie Reviews", "0", "2003-06-09 11:09:05", "admin", "0", "c373e9f5ad0791a23c0e444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0796c0eca4444553544200", "Movie Reviews", "admin", "2003-06-09 11:09:13", "Movie Reviews", "0", "2003-06-09 11:09:13", "admin", "33", "c373e9f5ad0796bf913f444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0796d9b895444553544200", "NewBookFolder", "admin", "2003-06-09 11:12:41", "NewBooks - folder", "0", "2003-06-09 11:12:41", "admin", "0", "c373e9f5ad0796c0eca4444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad079b4c9355444553544200", "CopiedFolder", "admin", "2003-06-09 11:26:34", "Movie Reviews", "0", "2003-06-09 11:26:34", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t4 VALUES("340d243c45f111d497b00010a4ef934d", "Document Layout", "The system Document Layouts Document Type", NULL, "2003-06-05 16:30:00", "System", "1");
+INSERT INTO t4 VALUES("340d243d45f111d497b00010a4ef934d", "Default", "The default system Document Type", NULL, "2003-06-05 16:30:00", "System", "1");
+INSERT INTO t4 VALUES("4d09dd60850711d4998a204c4f4f5020", "__SystemResourceType", "The type for all the uploaded resources", NULL, "2003-06-05 16:30:00", "System", "1");
+INSERT INTO t4 VALUES("91d4d595478211d497b40010a4ef934d", "__PmcSystemDefaultType", "The type for all the default available fields", NULL, "2003-06-05 16:30:00", "System", "1");
+INSERT INTO t4 VALUES("c373e9f59cf15a59b08a444553544200", "NoFieldDocType", "plain doc type", NULL, "2003-06-06 07:48:40", "admin", NULL);
+INSERT INTO t4 VALUES("c373e9f59cf15a5c6a99444553544200", "Movie Review", "This doc type is for movie reviews", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<props autocheckin=\"false\" autopublish=\"false\" binary=\"choice\" categories=\"none\" cleanup=\"false\" folder=\"none\"><![CDATA[Doc type for cm tests]]></props>\r\n", "2003-06-06 07:48:40", "admin", NULL);
+INSERT INTO t4 VALUES("c373e9f59cf15a6116a5444553544200", "Special DocÃu20A4u20A4u0113ééøÉu016BType", "test special chars xxxé in doc type", NULL, "2003-06-06 07:48:41", "admin", NULL);
+INSERT INTO t4 VALUES("c373e9f59cf15a695d47444553544200", "Movie", NULL, NULL, "2003-06-06 07:48:41", "admin", NULL);
+INSERT INTO t4 VALUES("c373e9f5ad079174ff17444553544200", "Discussion", NULL, NULL, "2003-06-09 10:51:25", "admin", NULL);
+INSERT INTO t4 VALUES("c373e9f5ad0791da7e2b444553544200", "Books", "list of recommended books", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<props autocheckin=\"false\" autopublish=\"false\" binary=\"choice\" categories=\"none\" cleanup=\"false\" folder=\"none\"><![CDATA[Doc type for cm tests]]><![CDATA[Doc type for book tests]]></props>\r\n", "2003-06-09 10:51:40", "admin", NULL);
+ALTER TABLE t2 ADD FOREIGN KEY FK_DCMNTS_DCTYPES ( DOCTYPEID)
+REFERENCES t4 (DOCTYPEID );
+ALTER TABLE t2 ADD FOREIGN KEY FK_DCMNTS_FLDRS ( FOLDERID)
+REFERENCES t3 (FOLDERID );
+ALTER TABLE t3 ADD FOREIGN KEY FK_FLDRS_PRNTID ( PARENTID)
+REFERENCES t3 (FOLDERID );
+SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3.FOLDERNAME = 'Level1') AND t3.FOLDERNAME = 'Level2') AND t3.FOLDERNAME = 'Level3') AND t3.FOLDERNAME = 'CopiedFolder') AND t3.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion';
+DOCID DOCNAME DOCTYPEID FOLDERID AUTHOR CREATED TITLE SUBTITLE DOCABSTRACT PUBLISHDATE EXPIRATIONDATE LOCKEDBY STATUS PARENTDOCID REPID MODIFIED MODIFIER PUBLISHSTATUS ORIGINATOR DOCTYPENAME CONTENTSIZE MIMETYPE
+c373e9f5ad07993f3859444553544200 Last Discussion c373e9f5ad079174ff17444553544200 c373e9f5ad0796c0eca4444553544200 Goldilocks 2003-06-09 11:21:06 Title: Last Discussion NULL Setting new abstract and keeping doc checked out 2003-06-09 10:51:26 2003-06-09 10:51:26 NULL NULL NULL 03eea05112b845949f3fd03278b5fe43 2003-06-09 11:21:06 admin 0 NULL Discussion NULL NULL
+EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3.FOLDERNAME = 'Level1') AND t3.FOLDERNAME = 'Level2') AND t3.FOLDERNAME = 'Level3') AND t3.FOLDERNAME = 'CopiedFolder') AND t3.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion';
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system PRIMARY NULL NULL NULL 0 const row not found
+1 PRIMARY t2 ALL DDOCTYPEID_IDX NULL NULL NULL 9 Using where
+1 PRIMARY t4 eq_ref PRIMARY PRIMARY 32 test.t2.DOCTYPEID 1
+2 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
+3 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
+4 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
+5 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 32 func 1 Using index; Using where
+6 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 32 func 1 Using index; Using where
+drop table t1, t2, t3, t4;
diff --git a/mysql-test/r/subselect_innodb.result b/mysql-test/r/subselect_innodb.result
new file mode 100644
index 00000000000..2f5b92fd05d
--- /dev/null
+++ b/mysql-test/r/subselect_innodb.result
@@ -0,0 +1,65 @@
+drop table if exists t1,t2,t3;
+CREATE TABLE t1
+(
+FOLDERID VARCHAR(32)BINARY NOT NULL
+, FOLDERNAME VARCHAR(255)BINARY NOT NULL
+, CREATOR VARCHAR(255)BINARY
+, CREATED TIMESTAMP NOT NULL
+, DESCRIPTION VARCHAR(255)BINARY
+, FOLDERTYPE INTEGER NOT NULL
+, MODIFIED TIMESTAMP
+, MODIFIER VARCHAR(255)BINARY
+, FOLDERSIZE INTEGER NOT NULL
+, PARENTID VARCHAR(32)BINARY
+, REPID VARCHAR(32)BINARY
+, ORIGINATOR INTEGER
+, PRIMARY KEY ( FOLDERID )
+) TYPE=InnoDB;
+CREATE INDEX FFOLDERID_IDX ON t1 (FOLDERID);
+CREATE INDEX CMFLDRPARNT_IDX ON t1 (PARENTID);
+INSERT INTO t1 VALUES("0c9aab05b15048c59bc35c8461507deb", "System", "System", "2003-06-05 16:30:00", "The system content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "9c9aab05b15048c59bc35c8461507deb", "1");
+INSERT INTO t1 VALUES("2f6161e879db43c1a5b82c21ddc49089", "Default", "System", "2003-06-09 10:52:02", "The default content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "03eea05112b845949f3fd03278b5fe43", "1");
+INSERT INTO t1 VALUES("c373e9f5ad0791724315444553544200", "AddDocumentTest", "admin", "2003-06-09 10:51:25", "Movie Reviews", "0", "2003-06-09 10:51:25", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+SELECT 'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t1.FOLDERNAME = 'Level1');
+'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t1.FOLDERNAME = 'Level1')
+0
+drop table t1;
+create table t1 (a int) type=innodb;
+create table t2 (a int) type=innodb;
+create table t3 (a int) type=innodb;
+insert into t1 values (1),(2),(3),(4);
+insert into t2 values (10),(20),(30),(40);
+insert into t3 values (1),(2),(10),(50);
+select a from t3 where t3.a in (select a from t1 where a <= 3 union select * from t2 where a <= 30);
+a
+1
+2
+10
+drop table t1,t2,t3;
+CREATE TABLE t1 (
+processor_id INTEGER NOT NULL,
+PRIMARY KEY (processor_id)
+) TYPE=InnoDB;
+CREATE TABLE t3 (
+yod_id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
+login_processor INTEGER UNSIGNED ,
+PRIMARY KEY (yod_id)
+) TYPE=InnoDB;
+CREATE TABLE t2 (
+processor_id INTEGER NOT NULL,
+yod_id BIGINT UNSIGNED NOT NULL,
+PRIMARY KEY (processor_id, yod_id),
+INDEX (processor_id),
+INDEX (yod_id),
+FOREIGN KEY (processor_id) REFERENCES t1(processor_id),
+FOREIGN KEY (yod_id) REFERENCES t3(yod_id)
+) TYPE=InnoDB;
+INSERT INTO t1 VALUES (1),(2),(3);
+INSERT INTO t3 VALUES (1,1),(2,2),(3,3);
+INSERT INTO t2 VALUES (1,1),(2,2),(3,3);
+SELECT distinct p1.processor_id, (SELECT y.yod_id FROM t1 p2, t2 y WHERE p2.processor_id = p1.processor_id and p2.processor_id = y.processor_id) FROM t1 p1;
+processor_id (SELECT y.yod_id FROM t1 p2, t2 y WHERE p2.processor_id = p1.processor_id and p2.processor_id = y.processor_id)
+1 1
+2 1
+3 1
+drop table t1,t2,t3;
diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result
index 2deecae7243..a56fe3e1462 100644
--- a/mysql-test/r/symlink.result
+++ b/mysql-test/r/symlink.result
@@ -40,7 +40,7 @@ t9 CREATE TABLE `t9` (
`b` char(16) NOT NULL default '',
`c` int(11) NOT NULL default '0',
PRIMARY KEY (`a`)
-) TYPE=MyISAM DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/'
+) TYPE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/'
alter table t9 rename t8, add column d int not null;
alter table t8 rename t7;
rename table t7 to t9;
@@ -62,5 +62,5 @@ t9 CREATE TABLE `t9` (
`c` int(11) NOT NULL default '0',
`d` int(11) NOT NULL default '0',
PRIMARY KEY (`a`)
-) TYPE=MyISAM DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/'
+) TYPE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/'
drop database mysqltest;
diff --git a/mysql-test/r/temp_table.result b/mysql-test/r/temp_table.result
index 7c8d10cf0a6..fbc5c234256 100644
--- a/mysql-test/r/temp_table.result
+++ b/mysql-test/r/temp_table.result
@@ -24,9 +24,9 @@ a b
create TEMPORARY TABLE t2 type=heap select * from t1;
create TEMPORARY TABLE IF NOT EXISTS t2 (a int) type=heap;
CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
-Table 't1' already exists
+ERROR 42S01: Table 't1' already exists
ALTER TABLE t1 RENAME t2;
-Table 't2' already exists
+ERROR 42S01: Table 't2' already exists
select * from t2;
a b
4 e
@@ -48,7 +48,6 @@ c d e
3 b 2
drop table t1;
drop table t1;
-drop table if exists t1;
CREATE TABLE t1 (pkCrash INTEGER PRIMARY KEY,strCrash VARCHAR(255));
INSERT INTO t1 ( pkCrash, strCrash ) VALUES ( 1, '1');
SELECT CONCAT_WS(pkCrash, strCrash) FROM t1;
@@ -75,9 +74,8 @@ drop table t1,t2;
create temporary table t1 (a int not null);
insert into t1 values (1),(1);
alter table t1 add primary key (a);
-Duplicate entry '1' for key 1
+ERROR 23000: Duplicate entry '1' for key 1
drop table t1;
-drop table if exists t1;
CREATE TABLE t1 (
d datetime default NULL
) TYPE=MyISAM;
diff --git a/mysql-test/r/truncate.result b/mysql-test/r/truncate.result
index ad390c9fa92..0e256c1bf8e 100644
--- a/mysql-test/r/truncate.result
+++ b/mysql-test/r/truncate.result
@@ -14,7 +14,7 @@ select * from t1;
a b c1
drop table t1;
select count(*) from t1;
-Table 'test.t1' doesn't exist
+ERROR 42S02: Table 'test.t1' doesn't exist
create temporary table t1 (n int);
insert into t1 values (1),(2),(3);
truncate table t1;
@@ -22,4 +22,4 @@ select * from t1;
n
drop table t1;
truncate non_existing_table;
-Table 'test.non_existing_table' doesn't exist
+ERROR 42S02: Table 'test.non_existing_table' doesn't exist
diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result
index d7c41743bf3..d1147e55119 100644
--- a/mysql-test/r/type_blob.result
+++ b/mysql-test/r/type_blob.result
@@ -1,4 +1,36 @@
drop table if exists t1,t2,t3,t4,t5,t6,t7;
+CREATE TABLE t1 (a blob, b text, c blob(250), d text(70000), e text(70000000));
+show columns from t1;
+Field Type Null Key Default Extra
+a blob YES NULL
+b text YES NULL
+c blob YES NULL
+d mediumtext YES NULL
+e longtext YES NULL
+CREATE TABLE t2 (a char(257), b varchar(70000) binary, c varchar(70000000));
+Warnings:
+Warning 1245 Converting column 'a' from CHAR to TEXT
+Warning 1245 Converting column 'b' from CHAR to BLOB
+Warning 1245 Converting column 'c' from CHAR to TEXT
+show columns from t2;
+Field Type Null Key Default Extra
+a text YES NULL
+b mediumblob YES NULL
+c longtext YES NULL
+create table t3 (a long, b long byte);
+show create TABLE t3;
+Table Create Table
+t3 CREATE TABLE `t3` (
+ `a` mediumtext,
+ `b` mediumblob
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+drop table t1,t2,t3
+#;
+CREATE TABLE t1 (a char(257) default "hello");
+ERROR 42000: Too big column length for column 'a' (max = 255). Use BLOB instead
+CREATE TABLE t2 (a blob default "hello");
+ERROR 42000: BLOB/TEXT column 'a' can't have a default value
+drop table if exists t1,t2;
create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
insert into t1 values (null,"a","A");
insert into t1 values (null,"bbb","BBB");
@@ -37,18 +69,18 @@ insert into t1 values (NULL,NULL,NULL,NULL);
update t1 set c="",b=null where c="1";
lock tables t1 READ;
show full fields from t1;
-Field Type Null Key Default Extra Privileges
-t text YES NULL select,insert,update,references
-c varchar(10) YES NULL select,insert,update,references
-b blob YES NULL select,insert,update,references
-d varchar(10) binary YES NULL select,insert,update,references
+Field Type Collation Null Key Default Extra Privileges Comment
+t text latin1_swedish_ci YES NULL select,insert,update,references
+c varchar(10) latin1_swedish_ci YES NULL select,insert,update,references
+b blob NULL YES NULL select,insert,update,references
+d varchar(10) binary YES NULL select,insert,update,references
lock tables t1 WRITE;
show full fields from t1;
-Field Type Null Key Default Extra Privileges
-t text YES NULL select,insert,update,references
-c varchar(10) YES NULL select,insert,update,references
-b blob YES NULL select,insert,update,references
-d varchar(10) binary YES NULL select,insert,update,references
+Field Type Collation Null Key Default Extra Privileges Comment
+t text latin1_swedish_ci YES NULL select,insert,update,references
+c varchar(10) latin1_swedish_ci YES NULL select,insert,update,references
+b blob NULL YES NULL select,insert,update,references
+d varchar(10) binary YES NULL select,insert,update,references
unlock tables;
select t from t1 where t like "hello";
t
@@ -98,6 +130,10 @@ select d from t1 having d like "%HELLO%";
d
HELLO
HELLO MY
+select d from t1 having d like "%HE%LLO%";
+d
+HELLO
+HELLO MY
select t from t1 order by t;
t
NULL
@@ -311,7 +347,7 @@ a 1
hello 1
drop table t1;
create table t1 (a text, key (a(300)));
-Incorrect sub part key. The used key part isn't a string, the used length is longer than the key part or the table handler doesn't support unique sub keys
+ERROR HY000: Incorrect sub part key. The used key part isn't a string, the used length is longer than the key part or the storage engine doesn't support unique sub keys
create table t1 (a text, key (a(255)));
drop table t1;
CREATE TABLE t1 (
@@ -450,8 +486,27 @@ fish 10
drop table t1;
create table t1 (id integer auto_increment unique,imagem LONGBLOB not null);
insert into t1 (id) values (1);
+select
+charset(load_file('../../std_data/words.dat')),
+collation(load_file('../../std_data/words.dat')),
+coercibility(load_file('../../std_data/words.dat'));
+charset(load_file('../../std_data/words.dat')) collation(load_file('../../std_data/words.dat')) coercibility(load_file('../../std_data/words.dat'))
+binary binary 3
+explain extended select
+charset(load_file('../../std_data/words.dat')),
+collation(load_file('../../std_data/words.dat')),
+coercibility(load_file('../../std_data/words.dat'));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority no_cache charset(load_file(_latin1'../../std_data/words.dat')) AS `charset(load_file('../../std_data/words.dat'))`,collation(load_file(_latin1'../../std_data/words.dat')) AS `collation(load_file('../../std_data/words.dat'))`,coercibility(load_file(_latin1'../../std_data/words.dat')) AS `coercibility(load_file('../../std_data/words.dat'))`
update t1 set imagem=load_file('../../std_data/words.dat') where id=1;
select if(imagem is null, "ERROR", "OK"),length(imagem) from t1 where id = 1;
if(imagem is null, "ERROR", "OK") length(imagem)
OK 581
drop table t1;
+create table t1 select load_file('../../std_data/words.dat');
+show full fields from t1;
+Field Type Collation Null Key Default Extra Privileges Comment
+load_file('../../std_data/words.dat') mediumblob NULL YES NULL select,insert,update,references
+drop table t1;
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result
index 8dfe14bc1a2..cebd005c2c8 100644
--- a/mysql-test/r/type_date.result
+++ b/mysql-test/r/type_date.result
@@ -1,3 +1,4 @@
+drop table if exists t1,t2;
create table t1 (a char(16), b date, c datetime);
insert into t1 SET a='test 2000-01-01', b='2000-01-01', c='2000-01-01';
select * from t1 where c = '2000-01-01';
@@ -7,7 +8,6 @@ select * from t1 where b = '2000-01-01';
a b c
test 2000-01-01 2000-01-01 2000-01-01 00:00:00
drop table t1;
-drop table if exists t1,t2;
CREATE TABLE t1 (name char(6),cdate date);
INSERT INTO t1 VALUES ('name1','1998-01-01');
INSERT INTO t1 VALUES ('name2','1998-01-01');
diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result
index 5df4f355cfb..95e64a2a70e 100644
--- a/mysql-test/r/type_datetime.result
+++ b/mysql-test/r/type_datetime.result
@@ -41,8 +41,8 @@ t
drop table t1;
CREATE TABLE t1 (a timestamp, b date, c time, d datetime);
insert into t1 (b,c,d) values(now(),curtime(),now());
-select date_format(a,"%Y-%m-%d")=b,right(a,6)=c+0,a=d+0 from t1;
-date_format(a,"%Y-%m-%d")=b right(a,6)=c+0 a=d+0
+select date_format(a,"%Y-%m-%d")=b,right(a+0,6)=c+0,a=d+0 from t1;
+date_format(a,"%Y-%m-%d")=b right(a+0,6)=c+0 a=d+0
1 1 1
drop table t1;
CREATE TABLE t1 (a datetime not null);
@@ -82,8 +82,8 @@ date numfacture expedition
0000-00-00 00:00:00 0 0001-00-00 00:00:00
0000-00-00 00:00:00 1212 0001-00-00 00:00:00
EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00';
-table type possible_keys key key_len ref rows Extra
-t1 ref expedition expedition 8 const 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref expedition expedition 8 const 1 Using where
drop table t1;
create table t1 (a datetime not null, b datetime not null);
insert into t1 values (now(), now());
diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result
index b74765696a2..da25394eb08 100644
--- a/mysql-test/r/type_decimal.result
+++ b/mysql-test/r/type_decimal.result
@@ -1,4 +1,5 @@
DROP TABLE IF EXISTS t1;
+SET SQL_WARNINGS=1;
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
datatype_id int(11) DEFAULT '0' NOT NULL,
@@ -156,8 +157,18 @@ insert into t1 values ("-.1"),("+.1"),(".1");
insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001");
insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11");
insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11");
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 1
+Warning 1263 Data truncated, out of range for column 'a' at row 2
+Warning 1263 Data truncated, out of range for column 'a' at row 3
insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 1
+Warning 1264 Data truncated for column 'a' at row 2
+Warning 1263 Data truncated, out of range for column 'a' at row 3
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
+Warnings:
+Warning 1264 Data truncated for column 'a' at row 3
select * from t1;
a
0.00
@@ -189,12 +200,33 @@ a
drop table t1;
create table t1 (a decimal(10,2) unsigned);
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 2
+Warning 1263 Data truncated, out of range for column 'a' at row 6
insert into t1 values ("-.1"),("+.1"),(".1");
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 1
insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001");
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 3
insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11");
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 1
+Warning 1263 Data truncated, out of range for column 'a' at row 2
+Warning 1263 Data truncated, out of range for column 'a' at row 3
insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11");
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 1
+Warning 1263 Data truncated, out of range for column 'a' at row 2
+Warning 1263 Data truncated, out of range for column 'a' at row 3
insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 1
+Warning 1264 Data truncated for column 'a' at row 2
+Warning 1263 Data truncated, out of range for column 'a' at row 3
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
+Warnings:
+Warning 1264 Data truncated for column 'a' at row 3
select * from t1;
a
0.00
@@ -226,12 +258,33 @@ a
drop table t1;
create table t1 (a decimal(10,2) zerofill);
insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0");
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 2
+Warning 1263 Data truncated, out of range for column 'a' at row 6
insert into t1 values ("-.1"),("+.1"),(".1");
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 1
insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001");
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 3
insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11");
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 1
+Warning 1263 Data truncated, out of range for column 'a' at row 2
+Warning 1263 Data truncated, out of range for column 'a' at row 3
insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11");
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 1
+Warning 1263 Data truncated, out of range for column 'a' at row 2
+Warning 1263 Data truncated, out of range for column 'a' at row 3
insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000");
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 1
+Warning 1264 Data truncated for column 'a' at row 2
+Warning 1263 Data truncated, out of range for column 'a' at row 3
insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0");
+Warnings:
+Warning 1264 Data truncated for column 'a' at row 3
select * from t1;
a
00000000.00
@@ -267,7 +320,14 @@ insert into t1 values (-.1),(+.1),(.1);
insert into t1 values (00000000000001),(+0000000000001),(-0000000000001);
insert into t1 values (+111111111.11),(111111111.11),(-11111111.11);
insert into t1 values (-111111111.11),(+1111111111.11),(1111111111.11);
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 1
+Warning 1263 Data truncated, out of range for column 'a' at row 2
+Warning 1263 Data truncated, out of range for column 'a' at row 3
insert into t1 values (1e+100),(1e-100),(-1e+100);
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 1
+Warning 1263 Data truncated, out of range for column 'a' at row 3
insert into t1 values (123.4e0),(123.4e+2),(123.4e-2),(123e1),(123e+0);
select * from t1;
a
@@ -300,6 +360,9 @@ a
drop table t1;
create table t1 (a decimal);
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+12345678901'),(99999999999999);
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 1
+Warning 1263 Data truncated, out of range for column 'a' at row 7
select * from t1;
a
-9999999999
@@ -312,6 +375,10 @@ a
drop table t1;
create table t1 (a decimal unsigned);
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999);
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 1
+Warning 1263 Data truncated, out of range for column 'a' at row 2
+Warning 1263 Data truncated, out of range for column 'a' at row 7
select * from t1;
a
0
@@ -324,6 +391,10 @@ a
drop table t1;
create table t1 (a decimal zerofill);
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999);
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 1
+Warning 1263 Data truncated, out of range for column 'a' at row 2
+Warning 1263 Data truncated, out of range for column 'a' at row 7
select * from t1;
a
0000000000
@@ -336,6 +407,10 @@ a
drop table t1;
create table t1 (a decimal unsigned zerofill);
insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999);
+Warnings:
+Warning 1263 Data truncated, out of range for column 'a' at row 1
+Warning 1263 Data truncated, out of range for column 'a' at row 2
+Warning 1263 Data truncated, out of range for column 'a' at row 7
select * from t1;
a
0000000000
@@ -348,18 +423,24 @@ a
drop table t1;
create table t1(a decimal(10,0));
insert into t1 values ("1e4294967295");
+Warnings:
+Warning 1264 Data truncated for column 'a' at row 1
+Warning 1263 Data truncated, out of range for column 'a' at row 1
select * from t1;
a
99999999999
delete from t1;
insert into t1 values("1e4294967297");
+Warnings:
+Warning 1264 Data truncated for column 'a' at row 1
+Warning 1263 Data truncated, out of range for column 'a' at row 1
select * from t1;
a
99999999999
drop table t1;
CREATE TABLE t1 (a_dec DECIMAL(-1,0));
-Too big column length for column 'a_dec' (max = 255). Use BLOB instead
+ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '-1,0))' at line 1
CREATE TABLE t1 (a_dec DECIMAL(-2,1));
-Too big column length for column 'a_dec' (max = 255). Use BLOB instead
+ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '-2,1))' at line 1
CREATE TABLE t1 (a_dec DECIMAL(-1,1));
-Too big column length for column 'a_dec' (max = 255). Use BLOB instead
+ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '-1,1))' at line 1
diff --git a/mysql-test/r/type_enum.result b/mysql-test/r/type_enum.result
index ee3bd077798..f30feb4c0e6 100644
--- a/mysql-test/r/type_enum.result
+++ b/mysql-test/r/type_enum.result
@@ -1627,12 +1627,12 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` enum('','a','b') NOT NULL default ''
-) TYPE=MyISAM
+) TYPE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a enum (' ','a','b ') not null default 'b ');
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` enum('','a','b') NOT NULL default 'b'
-) TYPE=MyISAM
+) TYPE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result
index e85bced353a..2a461942853 100644
--- a/mysql-test/r/type_float.result
+++ b/mysql-test/r/type_float.result
@@ -1,3 +1,4 @@
+drop table if exists t1;
SELECT 10,10.0,10.,.1e+2,100.0e-1;
10 10.0 10. .1e+2 100.0e-1
10 10.0 10 10 10
@@ -7,13 +8,15 @@ SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000;
SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1;
1e1 1.e1 1.0e1 1e+1 1.e+1 1.0e+1 1e-1 1.e-1 1.0e-1
10 10 10 10 10 10 0.1 0.1 0.1
-drop table if exists t1;
create table t1 (f1 float(24),f2 float(52));
show full columns from t1;
-Field Type Null Key Default Extra Privileges
-f1 float YES NULL select,insert,update,references
-f2 double YES NULL select,insert,update,references
+Field Type Collation Null Key Default Extra Privileges Comment
+f1 float NULL YES NULL select,insert,update,references
+f2 double NULL YES NULL select,insert,update,references
insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150);
+Warnings:
+Warning 1263 Data truncated, out of range for column 'f1' at row 7
+Warning 1263 Data truncated, out of range for column 'f1' at row 8
insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150);
select * from t1;
f1 f2
@@ -67,21 +70,27 @@ select min(a) from t1;
min(a)
-0.010
drop table t1;
+create table t1 (a float);
+insert into t1 values (1);
+select max(a),min(a),avg(a) from t1;
+max(a) min(a) avg(a)
+1 1 1
+drop table t1;
create table t1 (f float, f2 float(24), f3 float(6,2), d double, d2 float(53), d3 double(10,3), de decimal, de2 decimal(6), de3 decimal(5,2), n numeric, n2 numeric(8), n3 numeric(5,6));
show full columns from t1;
-Field Type Null Key Default Extra Privileges
-f float YES NULL select,insert,update,references
-f2 float YES NULL select,insert,update,references
-f3 float(6,2) YES NULL select,insert,update,references
-d double YES NULL select,insert,update,references
-d2 double YES NULL select,insert,update,references
-d3 double(10,3) YES NULL select,insert,update,references
-de decimal(10,0) YES NULL select,insert,update,references
-de2 decimal(6,0) YES NULL select,insert,update,references
-de3 decimal(5,2) YES NULL select,insert,update,references
-n decimal(10,0) YES NULL select,insert,update,references
-n2 decimal(8,0) YES NULL select,insert,update,references
-n3 decimal(7,6) YES NULL select,insert,update,references
+Field Type Collation Null Key Default Extra Privileges Comment
+f float NULL YES NULL select,insert,update,references
+f2 float NULL YES NULL select,insert,update,references
+f3 float(6,2) NULL YES NULL select,insert,update,references
+d double NULL YES NULL select,insert,update,references
+d2 double NULL YES NULL select,insert,update,references
+d3 double(10,3) NULL YES NULL select,insert,update,references
+de decimal(10,0) NULL YES NULL select,insert,update,references
+de2 decimal(6,0) NULL YES NULL select,insert,update,references
+de3 decimal(5,2) NULL YES NULL select,insert,update,references
+n decimal(10,0) NULL YES NULL select,insert,update,references
+n2 decimal(8,0) NULL YES NULL select,insert,update,references
+n3 decimal(7,6) NULL YES NULL select,insert,update,references
drop table t1;
create table t1 (a decimal(7,3) not null, key (a));
insert into t1 values ("0"),("-0.00"),("-0.01"),("-0.002"),("1");
@@ -97,5 +106,5 @@ min(a)
-0.010
drop table t1;
create table t1 (f float(54));
-Incorrect column specifier for column 'f'
+ERROR 42000: Incorrect column specifier for column 'f'
drop table if exists t1;
diff --git a/mysql-test/r/type_nchar.result b/mysql-test/r/type_nchar.result
new file mode 100644
index 00000000000..63193418f77
--- /dev/null
+++ b/mysql-test/r/type_nchar.result
@@ -0,0 +1,50 @@
+drop table if exists t1;
+create table t1 (c nchar(10));
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c` char(10) character set utf8 default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (c national char(10));
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c` char(10) character set utf8 default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (c national varchar(10));
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c` varchar(10) character set utf8 default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (c nvarchar(10));
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c` varchar(10) character set utf8 default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (c nchar varchar(10));
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c` varchar(10) character set utf8 default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (c national character varying(10));
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c` varchar(10) character set utf8 default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 (c nchar varying(10));
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c` varchar(10) character set utf8 default NULL
+) TYPE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result
index 4f4b4eb43eb..b665f78bbce 100644
--- a/mysql-test/r/type_ranges.result
+++ b/mysql-test/r/type_ranges.result
@@ -1,4 +1,5 @@
drop table if exists t1,t2,t3;
+SET SQL_WARNINGS=1;
CREATE TABLE t1 (
auto int(5) unsigned NOT NULL auto_increment,
string char(10) default "hello",
@@ -38,31 +39,31 @@ KEY (ulonglong,ulong),
KEY (options,flags)
);
show full fields from t1;
-Field Type Null Key Default Extra Privileges
-auto int(5) unsigned PRI NULL auto_increment select,insert,update,references
-string varchar(10) YES hello select,insert,update,references
-tiny tinyint(4) MUL 0 select,insert,update,references
-short smallint(6) MUL 1 select,insert,update,references
-medium mediumint(8) MUL 0 select,insert,update,references
-long_int int(11) 0 select,insert,update,references
-longlong bigint(13) MUL 0 select,insert,update,references
-real_float float(13,1) MUL 0.0 select,insert,update,references
-real_double double(16,4) YES NULL select,insert,update,references
-utiny tinyint(3) unsigned MUL 0 select,insert,update,references
-ushort smallint(5) unsigned zerofill MUL 00000 select,insert,update,references
-umedium mediumint(8) unsigned MUL 0 select,insert,update,references
-ulong int(11) unsigned MUL 0 select,insert,update,references
-ulonglong bigint(13) unsigned MUL 0 select,insert,update,references
-time_stamp timestamp(14) YES NULL select,insert,update,references
-date_field date YES NULL select,insert,update,references
-time_field time YES NULL select,insert,update,references
-date_time datetime YES NULL select,insert,update,references
-blob_col blob YES NULL select,insert,update,references
-tinyblob_col tinyblob YES NULL select,insert,update,references
-mediumblob_col mediumblob select,insert,update,references
-longblob_col longblob select,insert,update,references
-options enum('one','two','tree') MUL one select,insert,update,references
-flags set('one','two','tree') select,insert,update,references
+Field Type Collation Null Key Default Extra Privileges Comment
+auto int(5) unsigned NULL PRI NULL auto_increment select,insert,update,references
+string varchar(10) latin1_swedish_ci YES hello select,insert,update,references
+tiny tinyint(4) NULL MUL 0 select,insert,update,references
+short smallint(6) NULL MUL 1 select,insert,update,references
+medium mediumint(8) NULL MUL 0 select,insert,update,references
+long_int int(11) NULL 0 select,insert,update,references
+longlong bigint(13) NULL MUL 0 select,insert,update,references
+real_float float(13,1) NULL MUL 0.0 select,insert,update,references
+real_double double(16,4) NULL YES NULL select,insert,update,references
+utiny tinyint(3) unsigned NULL MUL 0 select,insert,update,references
+ushort smallint(5) unsigned zerofill NULL MUL 00000 select,insert,update,references
+umedium mediumint(8) unsigned NULL MUL 0 select,insert,update,references
+ulong int(11) unsigned NULL MUL 0 select,insert,update,references
+ulonglong bigint(13) unsigned NULL MUL 0 select,insert,update,references
+time_stamp timestamp NULL YES NULL select,insert,update,references
+date_field date NULL YES NULL select,insert,update,references
+time_field time NULL YES NULL select,insert,update,references
+date_time datetime NULL YES NULL select,insert,update,references
+blob_col blob NULL YES NULL select,insert,update,references
+tinyblob_col tinyblob NULL YES NULL select,insert,update,references
+mediumblob_col mediumblob NULL select,insert,update,references
+longblob_col longblob NULL select,insert,update,references
+options enum('one','two','tree') latin1_swedish_ci MUL one select,insert,update,references
+flags set('one','two','tree') latin1_swedish_ci select,insert,update,references
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 0 PRIMARY 1 auto A 0 NULL NULL BTREE
@@ -85,10 +86,37 @@ CREATE INDEX test3 on t1 ( medium ) ;
DROP INDEX test ON t1;
insert into t1 values (10, 1,1,1,1,1,1,1,1,1,1,1,1,1,NULL,0,0,0,1,1,1,1,'one','one');
insert into t1 values (NULL,2,2,2,2,2,2,2,2,2,2,2,2,2,NULL,NULL,NULL,NULL,NULL,NULL,2,2,'two','two,one');
-insert into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303 101010','','','','3',3,3);
+insert into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303101010','','','','3',3,3);
insert into t1 values (0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,NULL,19970807,080706,19970403090807,-1,-1,-1,'-1',-1,-1);
+Warnings:
+Warning 1263 Data truncated, out of range for column 'utiny' at row 1
+Warning 1263 Data truncated, out of range for column 'ushort' at row 1
+Warning 1263 Data truncated, out of range for column 'umedium' at row 1
+Warning 1263 Data truncated, out of range for column 'ulong' at row 1
+Warning 1264 Data truncated for column 'options' at row 1
+Warning 1264 Data truncated for column 'flags' at row 1
insert into t1 values (0,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,NULL,0,0,0,-4294967295,-4294967295,-4294967295,'-4294967295',0,"one,two,tree");
+Warnings:
+Warning 1264 Data truncated for column 'string' at row 1
+Warning 1263 Data truncated, out of range for column 'tiny' at row 1
+Warning 1263 Data truncated, out of range for column 'short' at row 1
+Warning 1263 Data truncated, out of range for column 'medium' at row 1
+Warning 1263 Data truncated, out of range for column 'long_int' at row 1
+Warning 1263 Data truncated, out of range for column 'utiny' at row 1
+Warning 1263 Data truncated, out of range for column 'ushort' at row 1
+Warning 1263 Data truncated, out of range for column 'umedium' at row 1
+Warning 1263 Data truncated, out of range for column 'ulong' at row 1
+Warning 1264 Data truncated for column 'options' at row 1
insert into t1 values (0,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,NULL,0,0,0,4294967295,4294967295,4294967295,'4294967295',0,0);
+Warnings:
+Warning 1263 Data truncated, out of range for column 'tiny' at row 1
+Warning 1263 Data truncated, out of range for column 'short' at row 1
+Warning 1263 Data truncated, out of range for column 'medium' at row 1
+Warning 1263 Data truncated, out of range for column 'long_int' at row 1
+Warning 1263 Data truncated, out of range for column 'utiny' at row 1
+Warning 1263 Data truncated, out of range for column 'ushort' at row 1
+Warning 1263 Data truncated, out of range for column 'umedium' at row 1
+Warning 1264 Data truncated for column 'options' at row 1
insert into t1 (tiny) values (1);
select auto,string,tiny,short,medium,long_int,longlong,real_float,real_double,utiny,ushort,umedium,ulong,ulonglong,mod(floor(time_stamp/1000000),1000000)-mod(curdate(),1000000),date_field,time_field,date_time,blob_col,tinyblob_col,mediumblob_col,longblob_col from t1;
auto string tiny short medium long_int longlong real_float real_double utiny ushort umedium ulong ulonglong mod(floor(time_stamp/1000000),1000000)-mod(curdate(),1000000) date_field time_field date_time blob_col tinyblob_col mediumblob_col longblob_col
@@ -136,6 +164,13 @@ new_field char(2),
PRIMARY KEY (auto)
);
INSERT INTO t2 (string,mediumblob_col,new_field) SELECT string,mediumblob_col,new_field from t1 where auto > 10;
+Warnings:
+Warning 1264 Data truncated for column 'new_field' at row 2
+Warning 1264 Data truncated for column 'new_field' at row 3
+Warning 1264 Data truncated for column 'new_field' at row 4
+Warning 1264 Data truncated for column 'new_field' at row 5
+Warning 1264 Data truncated for column 'new_field' at row 6
+Warning 1264 Data truncated for column 'new_field' at row 7
select * from t2;
auto string mediumblob_col new_field
1 2 2 ne
@@ -166,59 +201,63 @@ options flags
one one
drop table t2;
create table t2 select * from t1;
+Warnings:
+Warning 1264 Data truncated for column 'options' at row 4
+Warning 1264 Data truncated for column 'options' at row 5
+Warning 1264 Data truncated for column 'options' at row 6
update t2 set string="changed" where auto=16;
show full columns from t1;
-Field Type Null Key Default Extra Privileges
-auto int(5) unsigned MUL NULL auto_increment select,insert,update,references
-string varchar(10) YES new defaul select,insert,update,references
-tiny tinyint(4) MUL 0 select,insert,update,references
-short smallint(6) MUL 0 select,insert,update,references
-medium mediumint(8) MUL 0 select,insert,update,references
-long_int int(11) 0 select,insert,update,references
-longlong bigint(13) MUL 0 select,insert,update,references
-real_float float(13,1) MUL 0.0 select,insert,update,references
-real_double double(16,4) YES NULL select,insert,update,references
-utiny tinyint(3) unsigned 0 select,insert,update,references
-ushort smallint(5) unsigned zerofill 00000 select,insert,update,references
-umedium mediumint(8) unsigned MUL 0 select,insert,update,references
-ulong int(11) unsigned MUL 0 select,insert,update,references
-ulonglong bigint(13) unsigned MUL 0 select,insert,update,references
-time_stamp timestamp(14) YES NULL select,insert,update,references
-date_field varchar(10) YES NULL select,insert,update,references
-time_field time YES NULL select,insert,update,references
-date_time datetime YES NULL select,insert,update,references
-new_blob_col varchar(20) YES NULL select,insert,update,references
-tinyblob_col tinyblob YES NULL select,insert,update,references
-mediumblob_col mediumblob select,insert,update,references
-options enum('one','two','tree') MUL one select,insert,update,references
-flags set('one','two','tree') select,insert,update,references
-new_field varchar(10) new select,insert,update,references
+Field Type Collation Null Key Default Extra Privileges Comment
+auto int(5) unsigned NULL MUL NULL auto_increment select,insert,update,references
+string varchar(10) latin1_swedish_ci YES new defaul select,insert,update,references
+tiny tinyint(4) NULL MUL 0 select,insert,update,references
+short smallint(6) NULL MUL 0 select,insert,update,references
+medium mediumint(8) NULL MUL 0 select,insert,update,references
+long_int int(11) NULL 0 select,insert,update,references
+longlong bigint(13) NULL MUL 0 select,insert,update,references
+real_float float(13,1) NULL MUL 0.0 select,insert,update,references
+real_double double(16,4) NULL YES NULL select,insert,update,references
+utiny tinyint(3) unsigned NULL 0 select,insert,update,references
+ushort smallint(5) unsigned zerofill NULL 00000 select,insert,update,references
+umedium mediumint(8) unsigned NULL MUL 0 select,insert,update,references
+ulong int(11) unsigned NULL MUL 0 select,insert,update,references
+ulonglong bigint(13) unsigned NULL MUL 0 select,insert,update,references
+time_stamp timestamp NULL YES NULL select,insert,update,references
+date_field varchar(10) latin1_swedish_ci YES NULL select,insert,update,references
+time_field time NULL YES NULL select,insert,update,references
+date_time datetime NULL YES NULL select,insert,update,references
+new_blob_col varchar(20) latin1_swedish_ci YES NULL select,insert,update,references
+tinyblob_col tinyblob NULL YES NULL select,insert,update,references
+mediumblob_col mediumblob NULL select,insert,update,references
+options enum('one','two','tree') latin1_swedish_ci MUL one select,insert,update,references
+flags set('one','two','tree') latin1_swedish_ci select,insert,update,references
+new_field varchar(10) latin1_swedish_ci new select,insert,update,references
show full columns from t2;
-Field Type Null Key Default Extra Privileges
-auto int(5) unsigned 0 select,insert,update,references
-string varchar(10) YES new defaul select,insert,update,references
-tiny tinyint(4) 0 select,insert,update,references
-short smallint(6) 0 select,insert,update,references
-medium mediumint(8) 0 select,insert,update,references
-long_int int(11) 0 select,insert,update,references
-longlong bigint(13) 0 select,insert,update,references
-real_float float(13,1) 0.0 select,insert,update,references
-real_double double(16,4) YES NULL select,insert,update,references
-utiny tinyint(3) unsigned 0 select,insert,update,references
-ushort smallint(5) unsigned zerofill 00000 select,insert,update,references
-umedium mediumint(8) unsigned 0 select,insert,update,references
-ulong int(11) unsigned 0 select,insert,update,references
-ulonglong bigint(13) unsigned 0 select,insert,update,references
-time_stamp timestamp(14) YES NULL select,insert,update,references
-date_field varchar(10) YES NULL select,insert,update,references
-time_field time YES NULL select,insert,update,references
-date_time datetime YES NULL select,insert,update,references
-new_blob_col varchar(20) YES NULL select,insert,update,references
-tinyblob_col tinyblob YES NULL select,insert,update,references
-mediumblob_col mediumblob select,insert,update,references
-options enum('one','two','tree') one select,insert,update,references
-flags set('one','two','tree') select,insert,update,references
-new_field varchar(10) new select,insert,update,references
+Field Type Collation Null Key Default Extra Privileges Comment
+auto int(5) unsigned NULL 0 select,insert,update,references
+string varchar(10) latin1_swedish_ci YES new defaul select,insert,update,references
+tiny tinyint(4) NULL 0 select,insert,update,references
+short smallint(6) NULL 0 select,insert,update,references
+medium mediumint(8) NULL 0 select,insert,update,references
+long_int int(11) NULL 0 select,insert,update,references
+longlong bigint(13) NULL 0 select,insert,update,references
+real_float float(13,1) NULL 0.0 select,insert,update,references
+real_double double(16,4) NULL YES NULL select,insert,update,references
+utiny tinyint(3) unsigned NULL 0 select,insert,update,references
+ushort smallint(5) unsigned zerofill NULL 00000 select,insert,update,references
+umedium mediumint(8) unsigned NULL 0 select,insert,update,references
+ulong int(11) unsigned NULL 0 select,insert,update,references
+ulonglong bigint(13) unsigned NULL 0 select,insert,update,references
+time_stamp timestamp NULL YES NULL select,insert,update,references
+date_field varchar(10) latin1_swedish_ci YES NULL select,insert,update,references
+time_field time NULL YES NULL select,insert,update,references
+date_time datetime NULL YES NULL select,insert,update,references
+new_blob_col varchar(20) latin1_swedish_ci YES NULL select,insert,update,references
+tinyblob_col tinyblob NULL YES NULL select,insert,update,references
+mediumblob_col mediumblob NULL select,insert,update,references
+options enum('one','two','tree') latin1_swedish_ci one select,insert,update,references
+flags set('one','two','tree') latin1_swedish_ci select,insert,update,references
+new_field varchar(10) latin1_swedish_ci new select,insert,update,references
select t1.auto,t2.auto from t1,t2 where t1.auto=t2.auto and ((t1.string<>t2.string and (t1.string is not null or t2.string is not null)) or (t1.tiny<>t2.tiny and (t1.tiny is not null or t2.tiny is not null)) or (t1.short<>t2.short and (t1.short is not null or t2.short is not null)) or (t1.medium<>t2.medium and (t1.medium is not null or t2.medium is not null)) or (t1.long_int<>t2.long_int and (t1.long_int is not null or t2.long_int is not null)) or (t1.longlong<>t2.longlong and (t1.longlong is not null or t2.longlong is not null)) or (t1.real_float<>t2.real_float and (t1.real_float is not null or t2.real_float is not null)) or (t1.real_double<>t2.real_double and (t1.real_double is not null or t2.real_double is not null)) or (t1.utiny<>t2.utiny and (t1.utiny is not null or t2.utiny is not null)) or (t1.ushort<>t2.ushort and (t1.ushort is not null or t2.ushort is not null)) or (t1.umedium<>t2.umedium and (t1.umedium is not null or t2.umedium is not null)) or (t1.ulong<>t2.ulong and (t1.ulong is not null or t2.ulong is not null)) or (t1.ulonglong<>t2.ulonglong and (t1.ulonglong is not null or t2.ulonglong is not null)) or (t1.time_stamp<>t2.time_stamp and (t1.time_stamp is not null or t2.time_stamp is not null)) or (t1.date_field<>t2.date_field and (t1.date_field is not null or t2.date_field is not null)) or (t1.time_field<>t2.time_field and (t1.time_field is not null or t2.time_field is not null)) or (t1.date_time<>t2.date_time and (t1.date_time is not null or t2.date_time is not null)) or (t1.new_blob_col<>t2.new_blob_col and (t1.new_blob_col is not null or t2.new_blob_col is not null)) or (t1.tinyblob_col<>t2.tinyblob_col and (t1.tinyblob_col is not null or t2.tinyblob_col is not null)) or (t1.mediumblob_col<>t2.mediumblob_col and (t1.mediumblob_col is not null or t2.mediumblob_col is not null)) or (t1.options<>t2.options and (t1.options is not null or t2.options is not null)) or (t1.flags<>t2.flags and (t1.flags is not null or t2.flags is not null)) or (t1.new_field<>t2.new_field and (t1.new_field is not null or t2.new_field is not null)));
auto auto
16 16
@@ -228,12 +267,12 @@ auto auto
drop table t2;
create table t2 (primary key (auto)) select auto+1 as auto,1 as t1, "a" as t2, repeat("a",256) as t3, binary repeat("b",256) as t4 from t1;
show full columns from t2;
-Field Type Null Key Default Extra Privileges
-auto bigint(17) unsigned PRI 0 select,insert,update,references
-t1 bigint(1) 0 select,insert,update,references
-t2 char(1) select,insert,update,references
-t3 mediumtext select,insert,update,references
-t4 mediumblob select,insert,update,references
+Field Type Collation Null Key Default Extra Privileges Comment
+auto bigint(17) unsigned NULL PRI 0 select,insert,update,references
+t1 bigint(1) NULL 0 select,insert,update,references
+t2 char(1) latin1_swedish_ci select,insert,update,references
+t3 mediumtext latin1_swedish_ci select,insert,update,references
+t4 mediumtext latin1_bin select,insert,update,references
select * from t2;
auto t1 t2 t3 t4
11 1 a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
@@ -248,13 +287,13 @@ create table t1 (c int);
insert into t1 values(1),(2);
create table t2 select * from t1;
create table t3 select * from t1, t2;
-Duplicate column name 'c'
+ERROR 42S21: Duplicate column name 'c'
create table t3 select t1.c AS c1, t2.c AS c2,1 as "const" from t1, t2;
show full columns from t3;
-Field Type Null Key Default Extra Privileges
-c1 int(11) YES NULL select,insert,update,references
-c2 int(11) YES NULL select,insert,update,references
-const bigint(1) 0 select,insert,update,references
+Field Type Collation Null Key Default Extra Privileges Comment
+c1 int(11) NULL YES NULL select,insert,update,references
+c2 int(11) NULL YES NULL select,insert,update,references
+const bigint(1) NULL 0 select,insert,update,references
drop table t1,t2,t3;
create table t1 ( myfield INT NOT NULL, UNIQUE INDEX (myfield), unique (myfield), index(myfield));
drop table t1;
diff --git a/mysql-test/r/type_set.result b/mysql-test/r/type_set.result
index 59f8744e2ec..e98ec2c3fc4 100644
--- a/mysql-test/r/type_set.result
+++ b/mysql-test/r/type_set.result
@@ -4,12 +4,14 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` set('','a','b') NOT NULL default ''
-) TYPE=MyISAM
+) TYPE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a set (' ','a','b ') not null default 'b ');
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` set('','a','b') NOT NULL default 'b'
-) TYPE=MyISAM
+) TYPE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
+CREATE TABLE t1 ( user varchar(64) NOT NULL default '', path varchar(255) NOT NULL default '', privilege set('select','RESERVED30','RESERVED29','RESERVED28','RESERVED27','RESERVED26', 'RESERVED25','RESERVED24','data.delete','RESERVED22','RESERVED21', 'RESERVED20','data.insert.none','data.insert.approve', 'data.insert.delete','data.insert.move','data.insert.propose', 'data.insert.reject','RESERVED13','RESERVED12','RESERVED11','RESERVED10', 'RESERVED09','data.update','RESERVED07','RESERVED06','RESERVED05', 'RESERVED04','metadata.delete','metadata.put','RESERVED01','RESERVED00') NOT NULL default '', KEY user (user) ) TYPE=MyISAM CHARSET=utf8;
+DROP TABLE t1;
diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result
index bacc3ec0176..5666e865518 100644
--- a/mysql-test/r/type_time.result
+++ b/mysql-test/r/type_time.result
@@ -24,6 +24,10 @@ t
12:30:35
36:30:31
insert into t1 values("10.22.22"),(1234567),(123456789),(123456789.10),("10 22:22"),("12.45a");
+Warnings:
+Warning 1263 Data truncated, out of range for column 't' at row 2
+Warning 1263 Data truncated, out of range for column 't' at row 3
+Warning 1263 Data truncated, out of range for column 't' at row 4
select * from t1;
t
10:22:33
diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result
index 3d5d74709c1..0c75155146d 100644
--- a/mysql-test/r/type_timestamp.result
+++ b/mysql-test/r/type_timestamp.result
@@ -15,26 +15,26 @@ SET TIMESTAMP=1238;
insert into t1 (a) select a+1 from t2 where a=8;
select * from t1;
a t
-1 19700101032034
-2 20020303000000
-3 19700101032035
-4 19700101032036
-5 20020304000000
-6 19700101032037
-7 20020305000000
-8 00000000000000
-9 19700101032038
+1 1970-01-01 03:20:34
+2 2002-03-03 00:00:00
+3 1970-01-01 03:20:35
+4 1970-01-01 03:20:36
+5 2002-03-04 00:00:00
+6 1970-01-01 03:20:37
+7 2002-03-05 00:00:00
+8 0000-00-00 00:00:00
+9 1970-01-01 03:20:38
drop table t1,t2;
SET TIMESTAMP=1234;
CREATE TABLE t1 (value TEXT NOT NULL, id VARCHAR(32) NOT NULL, stamp timestamp, PRIMARY KEY (id));
INSERT INTO t1 VALUES ("my value", "myKey","1999-04-02 00:00:00");
SELECT stamp FROM t1 WHERE id="myKey";
stamp
-19990402000000
+1999-04-02 00:00:00
UPDATE t1 SET value="my value" WHERE id="myKey";
SELECT stamp FROM t1 WHERE id="myKey";
stamp
-19990402000000
+1999-04-02 00:00:00
drop table t1;
create table t1 (a timestamp);
insert into t1 values (now());
@@ -44,8 +44,8 @@ date_format(a,"%Y %y") year(a) year(now())
drop table t1;
create table t1 (ix timestamp);
insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000);
-select * from t1;
-ix
+select ix+0 from t1;
+ix+0
19991101000000
19990102030405
19990630232922
@@ -71,18 +71,18 @@ INSERT INTO t1 VALUES ("2005-01-01","2005-01-01 00:00:00",20050101000000);
INSERT INTO t1 VALUES ("2030-01-01","2030-01-01 00:00:00",20300101000000);
SELECT * FROM t1;
date date_time time_stamp
-1998-12-31 1998-12-31 23:59:59 19981231235959
-1999-01-01 1999-01-01 00:00:00 19990101000000
-1999-09-09 1999-09-09 23:59:59 19990909235959
-2000-01-01 2000-01-01 00:00:00 20000101000000
-2000-02-28 2000-02-28 00:00:00 20000228000000
-2000-02-29 2000-02-29 00:00:00 20000229000000
-2000-03-01 2000-03-01 00:00:00 20000301000000
-2000-12-31 2000-12-31 23:59:59 20001231235959
-2001-01-01 2001-01-01 00:00:00 20010101000000
-2004-12-31 2004-12-31 23:59:59 20041231235959
-2005-01-01 2005-01-01 00:00:00 20050101000000
-2030-01-01 2030-01-01 00:00:00 20300101000000
+1998-12-31 1998-12-31 23:59:59 1998-12-31 23:59:59
+1999-01-01 1999-01-01 00:00:00 1999-01-01 00:00:00
+1999-09-09 1999-09-09 23:59:59 1999-09-09 23:59:59
+2000-01-01 2000-01-01 00:00:00 2000-01-01 00:00:00
+2000-02-28 2000-02-28 00:00:00 2000-02-28 00:00:00
+2000-02-29 2000-02-29 00:00:00 2000-02-29 00:00:00
+2000-03-01 2000-03-01 00:00:00 2000-03-01 00:00:00
+2000-12-31 2000-12-31 23:59:59 2000-12-31 23:59:59
+2001-01-01 2001-01-01 00:00:00 2001-01-01 00:00:00
+2004-12-31 2004-12-31 23:59:59 2004-12-31 23:59:59
+2005-01-01 2005-01-01 00:00:00 2005-01-01 00:00:00
+2030-01-01 2030-01-01 00:00:00 2030-01-01 00:00:00
drop table t1;
show variables like 'new';
Variable_name Value
@@ -96,8 +96,8 @@ insert t1 values (0,0,0,0,0,0,0),
"1997-12-31 23:47:59");
select * from t1;
t2 t4 t6 t8 t10 t12 t14
-00 0000 000000 00000000 0000000000 000000000000 00000000000000
-97 9712 971231 19971231 9712312347 971231234759 19971231234759
+0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00
+1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59
set new=1;
select * from t1;
t2 t4 t6 t8 t10 t12 t14
diff --git a/mysql-test/r/type_uint.result b/mysql-test/r/type_uint.result
index 1acfc700d3a..d948ca47972 100644
--- a/mysql-test/r/type_uint.result
+++ b/mysql-test/r/type_uint.result
@@ -1,7 +1,10 @@
drop table if exists t1;
+SET SQL_WARNINGS=1;
create table t1 (this int unsigned);
insert into t1 values (1);
insert into t1 values (-1);
+Warnings:
+Warning 1263 Data truncated, out of range for column 'this' at row 1
select * from t1;
this
1
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index 9899b8279e2..00eddd596cf 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -84,11 +84,14 @@ a b
3 c
2 b
1 a
-explain (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 4
-t2 ALL NULL NULL NULL NULL 4 Using filesort
-t1 ALL NULL NULL NULL NULL 4
+(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by t1.b;
+ERROR 42000: Table 't1' from one of SELECT's can not be used in global ORDER clause
+explain extended (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4
+2 UNION t2 ALL NULL NULL NULL NULL 4 Using filesort
+Warnings:
+Note 1003 (select high_priority test.t1.a AS `a`,test.t1.b AS `b` from test.t1 limit 2) union all (select test.t2.a AS `a`,test.t2.b AS `b` from test.t2 order by test.t2.a limit 1) order by b desc
(select sql_calc_found_rows a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 2;
a b
1 a
@@ -104,44 +107,61 @@ select found_rows();
found_rows()
8
explain select a,b from t1 union all select a,b from t2;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 4
-t2 ALL NULL NULL NULL NULL 4
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4
+2 UNION t2 ALL NULL NULL NULL NULL 4
explain select xx from t1 union select 1;
-Unknown column 'xx' in 'field list'
+ERROR 42S22: Unknown column 'xx' in 'field list'
explain select a,b from t1 union select 1;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 4
- 0 0 No tables used
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 4
+2 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
explain select 1 union select a,b from t1 union select 1;
-table type possible_keys key key_len ref rows Extra
- 0 0 No tables used
-t1 ALL NULL NULL NULL NULL 4
- 0 0 No tables used
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used
+2 UNION t1 ALL NULL NULL NULL NULL 4
+3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
explain select a,b from t1 union select 1 limit 0;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 4
- 0 0 Impossible WHERE
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 UNION NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
select a,b from t1 into outfile 'skr' union select a,b from t2;
-Wrong usage of UNION and INTO
+ERROR HY000: Wrong usage of UNION and INTO
select a,b from t1 order by a union select a,b from t2;
-Wrong usage of UNION and ORDER BY
+ERROR HY000: Wrong usage of UNION and ORDER BY
insert into t3 select a from t1 order by a union select a from t2;
-Wrong usage of UNION and ORDER BY
+ERROR HY000: Wrong usage of UNION and ORDER BY
create table t3 select a,b from t1 union select a from t2;
-The used SELECT statements have a different number of columns
+ERROR 21000: The used SELECT statements have a different number of columns
select a,b from t1 union select a from t2;
-The used SELECT statements have a different number of columns
+ERROR 21000: The used SELECT statements have a different number of columns
select * from t1 union select a from t2;
-The used SELECT statements have a different number of columns
+ERROR 21000: The used SELECT statements have a different number of columns
select a from t1 union select * from t2;
-The used SELECT statements have a different number of columns
+ERROR 21000: The used SELECT statements have a different number of columns
select * from t1 union select SQL_BUFFER_RESULT * from t2;
-Wrong usage/placement of 'SQL_BUFFER_RESULT'
+ERROR 42000: Wrong usage/placement of 'SQL_BUFFER_RESULT'
create table t3 select a,b from t1 union all select a,b from t2;
insert into t3 select a,b from t1 union all select a,b from t2;
replace into t3 select a,b as c from t1 union all select a,b from t2;
drop table t1,t2,t3;
+select * union select 1;
+ERROR HY000: No tables used
+select 1 as a,(select a union select a);
+a (select a union select a)
+1 1
+(select 1) union (select 2) order by 0;
+ERROR 42S22: Unknown column '0' in 'order clause'
+SELECT @a:=1 UNION SELECT @a:=@a+1;
+@a:=1
+1
+2
+(SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a);
+ERROR 42S22: Unknown column 'a' in 'field list'
+(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2);
+1 3
+1 3
+2 1
CREATE TABLE t1 (
`pseudo` char(35) NOT NULL default '',
`pseudo1` char(35) NOT NULL default '',
@@ -180,7 +200,6 @@ testtt
tsestset
1
drop table t1;
-drop table if exists t1,t2;
create table t1 (a int);
create table t2 (a int);
insert into t1 values (1),(2),(3),(4),(5);
@@ -331,11 +350,7 @@ select found_rows();
found_rows()
4
(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION SELECT * FROM t2 LIMIT 1;
-a
-1
-select found_rows();
-found_rows()
-4
+ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION all SELECT * FROM t2 LIMIT 2;
a
1
@@ -418,5 +433,93 @@ a
3
3
(SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1;
-Wrong usage/placement of 'SQL_CALC_FOUND_ROWS'
+ERROR 42000: Wrong usage/placement of 'SQL_CALC_FOUND_ROWS'
+drop table t1,t2;
+CREATE TABLE t1 ( id int(3) unsigned default '0') TYPE=MyISAM;
+INSERT INTO t1 (id) VALUES("1");
+CREATE TABLE t2 ( id int(3) unsigned default '0', id_master int(5) default '0', text1 varchar(5) default NULL, text2 varchar(5) default NULL) TYPE=MyISAM;
+INSERT INTO t2 (id, id_master, text1, text2) VALUES("1", "1",
+"foo1", "bar1");
+INSERT INTO t2 (id, id_master, text1, text2) VALUES("2", "1",
+"foo2", "bar2");
+INSERT INTO t2 (id, id_master, text1, text2) VALUES("3", "1", NULL,
+"bar3");
+INSERT INTO t2 (id, id_master, text1, text2) VALUES("4", "1",
+"foo4", "bar4");
+SELECT 1 AS id_master, 1 AS id, NULL AS text1, 'ABCDE' AS text2 UNION SELECT id_master, t2.id, text1, text2 FROM t1 LEFT JOIN t2 ON t1.id = t2.id_master;
+id_master id text1 text2
+1 1 NULL ABCDE
+1 1 bar1
+1 2 bar2
+1 3 NULL bar3
+1 4 bar4
+SELECT 1 AS id_master, 1 AS id, 'ABCDE' AS text1, 'ABCDE' AS text2 UNION SELECT id_master, t2.id, text1, text2 FROM t1 LEFT JOIN t2 ON t1.id = t2.id_master;
+id_master id text1 text2
+1 1 ABCDE ABCDE
+1 1 foo1 bar1
+1 2 foo2 bar2
+1 3 NULL bar3
+1 4 foo4 bar4
+drop table if exists t1,t2;
+create table t1 (a int not null primary key auto_increment, b int, key(b));
+create table t2 (a int not null primary key auto_increment, b int);
+insert into t1 (b) values (1),(2),(2),(3);
+insert into t2 (b) values (10),(11),(12),(13);
+explain extended (select * from t1 where a=1) union (select * from t2 where a=1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1
+2 UNION t2 const PRIMARY PRIMARY 4 const 1
+Warnings:
+Note 1003 (select high_priority test.t1.a AS `a`,test.t1.b AS `b` from test.t1 where (test.t1.a = 1)) union (select test.t2.a AS `a`,test.t2.b AS `b` from test.t2 where (test.t2.a = 1))
+(select * from t1 where a=5) union (select * from t2 where a=1);
+a b
+1 10
+(select * from t1 where a=5 and a=6) union (select * from t2 where a=1);
+a b
+1 10
+(select t1.a,t1.b from t1,t2 where t1.a=5) union (select * from t2 where a=1);
+a b
+1 10
+(select * from t1 where a=1) union (select t1.a,t2.a from t1,t2 where t1.a=t2.a);
+a b
+1 1
+2 2
+3 3
+4 4
+explain (select * from t1 where a=1 and b=10) union (select straight_join t1.a,t2.a from t1,t2 where t1.a=t2.a);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+2 UNION t1 index PRIMARY PRIMARY 4 NULL 4 Using index
+2 UNION t2 index PRIMARY PRIMARY 4 NULL 3 Using where; Using index
+explain (select * from t1 where a=1) union (select * from t1 where b=1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1
+2 UNION t1 ref b b 5 const 1 Using where
drop table t1,t2;
+create table t1 ( id int not null auto_increment, primary key (id) ,user_name text );
+create table t2 ( id int not null auto_increment, primary key (id) ,group_name text );
+create table t3 ( id int not null auto_increment, primary key (id) ,user_id int ,index user_idx (user_id) ,foreign key (user_id) references users(id) ,group_id int ,index group_idx (group_id) ,foreign key (group_id) references groups(id) );
+insert into t1 (user_name) values ('Tester');
+insert into t2 (group_name) values ('Group A');
+insert into t2 (group_name) values ('Group B');
+insert into t3 (user_id, group_id) values (1,1);
+select 1 'is_in_group', a.user_name, c.group_name, b.id from t1 a, t3 b, t2 c where a.id = b.user_id and b.group_id = c.id UNION select 0 'is_in_group', a.user_name, c.group_name, null from t1 a, t2 c;
+is_in_group user_name group_name id
+1 Tester Group A 1
+0 Tester Group A NULL
+0 Tester Group B NULL
+drop table t1, t2, t3;
+create table t1 (mat_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, matintnum CHAR(6) NOT NULL, test MEDIUMINT UNSIGNED NULL);
+create table t2 (mat_id MEDIUMINT UNSIGNED NOT NULL, pla_id MEDIUMINT UNSIGNED NOT NULL);
+insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4), (NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8), (NULL, 'i', 9);
+insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105);
+SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id union SELECT 0, 0;
+pla_id matintnum
+100 a
+101 a
+102 a
+103 b
+104 b
+105 c
+0 0
+drop table t1, t2;
diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result
index 11aff8fe50a..a0370272396 100644
--- a/mysql-test/r/update.result
+++ b/mysql-test/r/update.result
@@ -1,15 +1,15 @@
-drop table if exists t1;
+drop table if exists t1,t2;
create table t1 (a int auto_increment , primary key (a));
insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
update t1 set a=a+10 where a > 34;
update t1 set a=a+100 where a > 0;
update t1 set a=a+100 where a=1 and a=2;
update t1 set a=b+100 where a=1 and a=2;
-Unknown column 'b' in 'field list'
+ERROR 42S22: Unknown column 'b' in 'field list'
update t1 set a=b+100 where c=1 and a=2;
-Unknown column 'c' in 'where clause'
+ERROR 42S22: Unknown column 'c' in 'where clause'
update t1 set d=a+100 where a=1;
-Unknown column 'd' in 'field list'
+ERROR 42S22: Unknown column 'd' in 'field list'
select * from t1;
a
101
@@ -137,7 +137,10 @@ a b
13 2
111 100
111 100
-drop table t1;
+create table t2 (a int not null, b int not null);
+insert into t2 values (1,1),(1,2),(1,3);
+update t1 set b=(select distinct 1 from (select * from t2) a);
+drop table t1,t2;
CREATE TABLE t1 (
`id_param` smallint(3) unsigned NOT NULL default '0',
`nom_option` char(40) NOT NULL default '',
diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result
index 3e83438b273..fc3dc4eddcd 100644
--- a/mysql-test/r/user_var.result
+++ b/mysql-test/r/user_var.result
@@ -1,10 +1,14 @@
+drop table if exists t1,t2;
set @a := foo;
-Unknown column 'foo' in 'field list'
+ERROR 42S22: Unknown column 'foo' in 'field list'
set @a := connection_id() + 3;
select @a - connection_id();
@a - connection_id()
3
-drop table if exists t1,t2;
+set @b := 1;
+select @b;
+@b
+1
CREATE TABLE t1 ( i int not null, v int not null,index (i));
insert into t1 values (1,1),(1,3),(2,1);
create table t2 (i int not null, unique (i));
@@ -18,17 +22,17 @@ i @vv1:=if(sv1.i,1,0) @vv2:=if(sv2.i,1,0) @vv3:=if(sv3.i,1,0) @vv1+@vv2+@vv3
1 1 0 1 2
2 1 0 0 1
explain select * from t1 where i=@vv1;
-table type possible_keys key key_len ref rows Extra
-t1 ref i i 4 const 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref i i 4 const 1 Using where
explain select * from t1 where @vv1:=@vv1+1 and i=@vv1;
-table type possible_keys key key_len ref rows Extra
-t1 ALL NULL NULL NULL NULL 3 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
explain select @vv1:=i from t1 where i=@vv1;
-table type possible_keys key key_len ref rows Extra
-t1 index NULL i 4 NULL 3 Using where; Using index
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL i 4 NULL 3 Using where; Using index
explain select * from t1 where i=@vv1;
-table type possible_keys key key_len ref rows Extra
-t1 ref i i 4 const 1 Using where
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref i i 4 const 1 Using where
drop table t1,t2;
set @a=0,@b=0;
select @a:=10, @b:=1, @a > @b, @a < @b;
diff --git a/mysql-test/r/varbinary.result b/mysql-test/r/varbinary.result
index 4eb34ebfd63..cf001158ae2 100644
--- a/mysql-test/r/varbinary.result
+++ b/mysql-test/r/varbinary.result
@@ -1,3 +1,4 @@
+drop table if exists t1;
select 0x41,0x41+0,0x41 | 0x7fffffffffffffff | 0,0xffffffffffffffff | 0 ;
0x41 0x41+0 0x41 | 0x7fffffffffffffff | 0 0xffffffffffffffff | 0
A 65 9223372036854775807 18446744073709551615
@@ -7,18 +8,19 @@ select 0x31+1,concat(0x31)+1,-0xf;
select x'31',X'ffff'+0;
x'31' X'ffff'+0
1 65535
-drop table if exists t1;
create table t1 (ID int(8) unsigned zerofill not null auto_increment,UNIQ bigint(21) unsigned zerofill not null,primary key (ID),unique (UNIQ) );
insert into t1 set UNIQ=0x38afba1d73e6a18a;
insert into t1 set UNIQ=123;
-explain select * from t1 where UNIQ=0x38afba1d73e6a18a;
-table type possible_keys key key_len ref rows Extra
-t1 const UNIQ UNIQ 8 const 1
+explain extended select * from t1 where UNIQ=0x38afba1d73e6a18a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const UNIQ UNIQ 8 const 1
+Warnings:
+Note 1003 select high_priority test.t1.ID AS `ID`,test.t1.UNIQ AS `UNIQ` from test.t1 where (test.t1.UNIQ = 4084688022709641610)
drop table t1;
select x'hello';
-You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'x'hello'' at line 1
+ERROR 42000: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'x'hello'' at line 1
select 0xfg;
-Unknown column '0xfg' in 'field list'
+ERROR 42S22: Unknown column '0xfg' in 'field list'
create table t1 select 1 as x, 2 as xx;
select x,xx from t1;
x xx
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index 8afdced206b..90654bece2e 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -1,4 +1,4 @@
-drop table if exists t1;
+drop table if exists t1,t2;
set @`test`=1,@TEST=3,@select=2,@t5=1.23456;
select @test,@`select`,@TEST,@not_used;
@test @`select` @TEST @not_used
@@ -22,6 +22,11 @@ NULL NULL NULL NULL
select @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
@t1:=(@t2:=1)+@t3:=4 @t1 @t2 @t3
5 5 1 4
+explain extended select @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority no_cache (@t1:=((@t2:=1) + (@t3:=4))) AS `@t1:=(@t2:=1)+@t3:=4`,(@t1) AS `@t1`,(@t2) AS `@t2`,(@t3) AS `@t3`
select @t5;
@t5
1.23456
@@ -50,7 +55,7 @@ Variable_name Value
max_join_size 100
show global variables like 'max_join_size';
Variable_name Value
-max_join_size HA_POS_ERROR
+max_join_size 10
set GLOBAL max_join_size=2000;
show global variables like 'max_join_size';
Variable_name Value
@@ -76,9 +81,19 @@ select @@VERSION=version();
select last_insert_id(345);
last_insert_id(345)
345
+explain extended select last_insert_id(345);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority no_cache last_insert_id(345) AS `last_insert_id(345)`
select @@IDENTITY,last_insert_id(), @@identity;
-@@identity last_insert_id() @@identity
+@@IDENTITY last_insert_id() @@identity
345 345 345
+explain extended select @@IDENTITY,last_insert_id(), @@identity;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
+Warnings:
+Note 1003 select high_priority no_cache 345 AS `@@IDENTITY`,345 AS `last_insert_id()`,345 AS `@@identity`
set big_tables=OFF, big_tables=ON, big_tables=0, big_tables=1, big_tables="OFF", big_tables="ON";
set global concurrent_insert=ON;
show variables like 'concurrent_insert';
@@ -152,18 +167,10 @@ set net_buffer_length=2000000000;
show variables like 'net_buffer_length';
Variable_name Value
net_buffer_length 1048576
-set GLOBAL character set cp1251_koi8;
-show global variables like "convert_character_set";
-Variable_name Value
-convert_character_set cp1251_koi8
set character set cp1251_koi8;
-show variables like "convert_character_set";
+show variables like "character_set_client";
Variable_name Value
-convert_character_set cp1251_koi8
-set global character set default, session character set default;
-show variables like "convert_character_set";
-Variable_name Value
-convert_character_set cp1251_koi8
+character_set_client cp1251
select @@timestamp>0;
@@timestamp>0
1
@@ -204,48 +211,46 @@ range_alloc_block_size 2048
transaction_alloc_block_size 8192
transaction_prealloc_size 4096
set big_tables=OFFF;
-Variable 'big_tables' can't be set to the value of 'OFFF'
+ERROR 42000: Variable 'big_tables' can't be set to the value of 'OFFF'
set big_tables="OFFF";
-Variable 'big_tables' can't be set to the value of 'OFFF'
+ERROR 42000: Variable 'big_tables' can't be set to the value of 'OFFF'
set unknown_variable=1;
-Unknown system variable 'unknown_variable'
+ERROR HY000: Unknown system variable 'unknown_variable'
set max_join_size="hello";
-Wrong argument type to variable 'max_join_size'
+ERROR 42000: Wrong argument type to variable 'max_join_size'
set table_type=UNKNOWN_TABLE_TYPE;
-Variable 'table_type' can't be set to the value of 'UNKNOWN_TABLE_TYPE'
+ERROR 42000: Variable 'table_type' can't be set to the value of 'UNKNOWN_TABLE_TYPE'
set table_type=INNODB, big_tables=2;
-Variable 'big_tables' can't be set to the value of '2'
+ERROR 42000: Variable 'big_tables' can't be set to the value of '2'
show local variables like 'table_type';
Variable_name Value
table_type HEAP
set SESSION query_cache_size=10000;
-Variable 'query_cache_size' is a GLOBAL variable and should be set with SET GLOBAL
+ERROR HY000: Variable 'query_cache_size' is a GLOBAL variable and should be set with SET GLOBAL
set GLOBAL table_type=DEFAULT;
-Variable 'table_type' doesn't have a default value
-set convert_character_set=UNKNOWN_CHARACTER_SET;
-Unknown character set: 'UNKNOWN_CHARACTER_SET'
-set character set unknown;
-Unknown character set: 'unknown'
-set character set 0;
-Wrong argument type to variable 'convert_character_set'
+ERROR 42000: Variable 'table_type' doesn't have a default value
+set character_set_client=UNKNOWN_CHARACTER_SET;
+ERROR 42000: Unknown character set: 'UNKNOWN_CHARACTER_SET'
+set collation_connection=UNKNOWN_COLLATION;
+ERROR HY000: Unknown collation: 'UNKNOWN_COLLATION'
set global autocommit=1;
-Variable 'autocommit' is a LOCAL variable and can't be used with SET GLOBAL
+ERROR HY000: Variable 'autocommit' is a LOCAL variable and can't be used with SET GLOBAL
select @@global.timestamp;
-Variable 'timestamp' is a LOCAL variable and can't be used with SET GLOBAL
+ERROR HY000: Variable 'timestamp' is a LOCAL variable and can't be used with SET GLOBAL
set @@version='';
-Unknown system variable 'version'
+ERROR HY000: Unknown system variable 'version'
set @@concurrent_insert=1;
-Variable 'concurrent_insert' is a GLOBAL variable and should be set with SET GLOBAL
+ERROR HY000: Variable 'concurrent_insert' is a GLOBAL variable and should be set with SET GLOBAL
set @@global.sql_auto_is_null=1;
-Variable 'sql_auto_is_null' is a LOCAL variable and can't be used with SET GLOBAL
+ERROR HY000: Variable 'sql_auto_is_null' is a LOCAL variable and can't be used with SET GLOBAL
select @@global.sql_auto_is_null;
-Variable 'sql_auto_is_null' is a LOCAL variable and can't be used with SET GLOBAL
+ERROR HY000: Variable 'sql_auto_is_null' is a LOCAL variable and can't be used with SET GLOBAL
set myisam_max_sort_file_size=100;
-Variable 'myisam_max_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL
+ERROR HY000: Variable 'myisam_max_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL
set myisam_max_extra_sort_file_size=100;
-Variable 'myisam_max_extra_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL
+ERROR HY000: Variable 'myisam_max_extra_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL
set @@SQL_WARNINGS=NULL;
-Variable 'sql_warnings' can't be set to the value of 'NULL'
+ERROR 42000: Variable 'sql_warnings' can't be set to the value of 'NULL'
set autocommit=1;
set big_tables=1;
select @@autocommit, @@big_tables;
@@ -253,8 +258,8 @@ select @@autocommit, @@big_tables;
1 1
set global binlog_cache_size=100;
set bulk_insert_buffer_size=100;
-set convert_character_set=cp1251_koi8;
-set convert_character_set=default;
+set character set cp1251_koi8;
+set character set default;
set @@global.concurrent_insert=1;
set global connect_timeout=100;
select @@delay_key_write;
@@ -350,7 +355,6 @@ set tmp_table_size=100;
set tx_isolation="READ-COMMITTED";
set wait_timeout=100;
set log_warnings=1;
-DROP TABLE IF EXISTS t1,t2;
create table t1 (a int not null auto_increment, primary key(a));
create table t2 (a int not null auto_increment, primary key(a));
insert into t1 values(null),(null),(null);
@@ -369,9 +373,34 @@ check table t1,t2;
Table Op Msg_type Msg_text
test.t1 check status OK
test.t2 check status OK
+select max(a) +1, max(a) +2 into @xx,@yy from t1;
drop table t1,t2;
select @@xxxxxxxxxx;
-Unknown system variable 'xxxxxxxxxx'
+ERROR HY000: Unknown system variable 'xxxxxxxxxx'
select 1;
1
1
+select @@global.max_user_connections,@@local.max_join_size;
+@@global.max_user_connections @@session.max_join_size
+100 200
+set @svc=@@global.max_user_connections, @svj=@@local.max_join_size;
+select @@global.max_user_connections,@@local.max_join_size;
+@@global.max_user_connections @@session.max_join_size
+100 200
+set @@global.max_user_connections=111,@@local.max_join_size=222;
+select @@global.max_user_connections,@@local.max_join_size;
+@@global.max_user_connections @@session.max_join_size
+111 222
+set @@global.max_user_connections=@@local.max_join_size,@@local.max_join_size=@@global.max_user_connections;
+select @@global.max_user_connections,@@local.max_join_size;
+@@global.max_user_connections @@session.max_join_size
+222 111
+set @@global.max_user_connections=@svc, @@local.max_join_size=@svj;
+select @@global.max_user_connections,@@local.max_join_size;
+@@global.max_user_connections @@session.max_join_size
+100 200
+set @a=1, @b=2;
+set @a=@b, @b=@a;
+select @a, @b;
+@a @b
+2 1
diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result
index e5713718db0..26353785733 100644
--- a/mysql-test/r/warnings.result
+++ b/mysql-test/r/warnings.result
@@ -1,10 +1,128 @@
-drop table if exists t1;
+drop table if exists t1, t2;
+Warnings:
+Note 1051 Unknown table 't1'
+Note 1051 Unknown table 't2'
+SET SQL_WARNINGS=1;
create table t1 (a int);
insert into t1 values (1);
insert into t1 values ("hej");
+Warnings:
+Warning 1264 Data truncated for column 'a' at row 1
insert into t1 values ("hej"),("då");
+Warnings:
+Warning 1264 Data truncated for column 'a' at row 1
+Warning 1264 Data truncated for column 'a' at row 2
set SQL_WARNINGS=1;
insert into t1 values ("hej");
+Warnings:
+Warning 1264 Data truncated for column 'a' at row 1
insert into t1 values ("hej"),("då");
+Warnings:
+Warning 1264 Data truncated for column 'a' at row 1
+Warning 1264 Data truncated for column 'a' at row 2
drop table t1;
set SQL_WARNINGS=0;
+drop temporary table if exists not_exists;
+Warnings:
+Note 1051 Unknown table 'not_exists'
+drop table if exists not_exists_table;
+Warnings:
+Note 1051 Unknown table 'not_exists_table'
+show warnings limit 1;
+Level Code Message
+Note 1051 Unknown table 'not_exists_table'
+drop database if exists not_exists_db;
+Warnings:
+Note 1008 Can't drop database 'not_exists_db'; database doesn't exist
+show count(*) warnings;
+@@session.warning_count
+1
+create table t1(id int);
+create table if not exists t1(id int);
+select @@warning_count;
+@@warning_count
+0
+drop table t1;
+create table t1(a tinyint, b int not null, c date, d char(5));
+load data infile '../../std_data/warnings_loaddata.dat' into table t1 fields terminated by ',';
+Warnings:
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'b' at row 2
+Warning 1264 Data truncated for column 'd' at row 3
+Warning 1264 Data truncated for column 'c' at row 4
+Warning 1260 Record count is fewer than the column count at row 5
+Warning 1264 Data truncated for column 'b' at row 6
+Warning 1261 Record count is more than the column count at row 7
+Warning 1263 Data truncated, out of range for column 'a' at row 8
+select @@warning_count;
+@@warning_count
+7
+drop table t1;
+create table t1(a tinyint NOT NULL, b tinyint unsigned, c char(5));
+insert into t1 values(NULL,100,'mysql'),(10,-1,'mysql ab'),(500,256,'open source'),(20,NULL,'test');
+Warnings:
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'a' at row 1
+Warning 1263 Data truncated, out of range for column 'b' at row 2
+Warning 1264 Data truncated for column 'c' at row 2
+Warning 1263 Data truncated, out of range for column 'a' at row 3
+Warning 1263 Data truncated, out of range for column 'b' at row 3
+Warning 1264 Data truncated for column 'c' at row 3
+alter table t1 modify c char(4);
+Warnings:
+Warning 1264 Data truncated for column 'c' at row 1
+Warning 1264 Data truncated for column 'c' at row 2
+alter table t1 add d char(2);
+update t1 set a=NULL where a=10;
+Warnings:
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'a' at row 2
+update t1 set c='mysql ab' where c='test';
+Warnings:
+Warning 1264 Data truncated for column 'c' at row 4
+update t1 set d=c;
+Warnings:
+Warning 1264 Data truncated for column 'd' at row 1
+Warning 1264 Data truncated for column 'd' at row 2
+Warning 1264 Data truncated for column 'd' at row 3
+Warning 1264 Data truncated for column 'd' at row 4
+create table t2(a tinyint NOT NULL, b char(3));
+insert into t2 select b,c from t1;
+Warnings:
+Warning 1264 Data truncated for column 'b' at row 1
+Warning 1264 Data truncated for column 'b' at row 2
+Warning 1264 Data truncated for column 'b' at row 3
+Warning 1262 Data truncated, NULL supplied to NOT NULL column 'a' at row 4
+Warning 1264 Data truncated for column 'b' at row 4
+insert into t2(b) values('mysqlab');
+Warnings:
+Warning 1264 Data truncated for column 'b' at row 1
+set sql_warnings=1;
+insert into t2(b) values('mysqlab');
+Warnings:
+Warning 1264 Data truncated for column 'b' at row 1
+set sql_warnings=0;
+drop table t1, t2;
+create table t1(a char(10));
+alter table t1 add b char;
+set max_error_count=10;
+update t1 set b=a;
+Warnings:
+Warning 1264 Data truncated for column 'b' at row 1
+Warning 1264 Data truncated for column 'b' at row 2
+Warning 1264 Data truncated for column 'b' at row 3
+Warning 1264 Data truncated for column 'b' at row 4
+Warning 1264 Data truncated for column 'b' at row 5
+Warning 1264 Data truncated for column 'b' at row 6
+Warning 1264 Data truncated for column 'b' at row 7
+Warning 1264 Data truncated for column 'b' at row 8
+Warning 1264 Data truncated for column 'b' at row 9
+Warning 1264 Data truncated for column 'b' at row 10
+select @@warning_count;
+@@warning_count
+50
+drop table t1;
+create table t1 (id int) type=isam;
+Warnings:
+Warning 1265 Using storage engine MYISAM for table 't1'
+alter table t1 type=isam;
+Warnings:
+Warning 1265 Using storage engine MYISAM for table 't1'
+drop table t1;
diff --git a/mysql-test/std_data/master-bin.001 b/mysql-test/std_data/master-bin.000001
index 2ec2397acdd..2ec2397acdd 100644
--- a/mysql-test/std_data/master-bin.001
+++ b/mysql-test/std_data/master-bin.000001
Binary files differ
diff --git a/mysql-test/std_data/trunc_binlog.001 b/mysql-test/std_data/trunc_binlog.000001
index 2c2b4ec6ce4..2c2b4ec6ce4 100644
--- a/mysql-test/std_data/trunc_binlog.001
+++ b/mysql-test/std_data/trunc_binlog.000001
Binary files differ
diff --git a/mysql-test/std_data/warnings_loaddata.dat b/mysql-test/std_data/warnings_loaddata.dat
new file mode 100644
index 00000000000..e645de775ab
--- /dev/null
+++ b/mysql-test/std_data/warnings_loaddata.dat
@@ -0,0 +1,8 @@
+10,20,2003-04-21,mysql
+20,\N,2003-04-22,MySQL
+30,40,2003-04-23,MySQL is Open Source Database
+40,50,monty,30
+50,60,2003-04-24
+60,67 abc,2003-04-25,mysql
+70,80,2003-04-26,mysql,open,source
+500,90,2003-04-27,mysql
diff --git a/mysql-test/t/alias.test b/mysql-test/t/alias.test
index 57b46181fa1..e0fa10d56d5 100644
--- a/mysql-test/t/alias.test
+++ b/mysql-test/t/alias.test
@@ -1,4 +1,7 @@
+--disable_warnings
DROP TABLE IF EXISTS t1;
+--enable_warnings
+
CREATE TABLE t1 (
cont_nr int(11) NOT NULL auto_increment,
ver_nr int(11) NOT NULL default '0',
diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test
index d438f2d5825..11fe997e789 100644
--- a/mysql-test/t/alter_table.test
+++ b/mysql-test/t/alter_table.test
@@ -1,8 +1,10 @@
#
# Test of alter table
#
-
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (
col1 int not null auto_increment primary key,
col2 varchar(30) not null,
@@ -144,6 +146,44 @@ ALTER TABLE t1 ENABLE KEYS;
drop table t1;
#
+# Test that data get converted when character set is changed
+# Test that data doesn't get converted when src or dst is BINARY/BLOB
+#
+set names koi8r;
+create table t1 (a char(10) character set koi8r);
+insert into t1 values ('ÔÅÓÔ');
+select a,hex(a) from t1;
+alter table t1 change a a char(10) character set cp1251;
+select a,hex(a) from t1;
+alter table t1 change a a char(10) binary;
+select a,hex(a) from t1;
+alter table t1 change a a char(10) character set cp1251;
+select a,hex(a) from t1;
+alter table t1 change a a char(10) character set koi8r;
+select a,hex(a) from t1;
+alter table t1 change a a varchar(10) character set cp1251;
+select a,hex(a) from t1;
+alter table t1 change a a char(10) character set koi8r;
+select a,hex(a) from t1;
+alter table t1 change a a text character set cp1251;
+select a,hex(a) from t1;
+alter table t1 change a a char(10) character set koi8r;
+select a,hex(a) from t1;
+
+#
+# Test ALTER TABLE .. CHARACTER SET ..
+#
+show create table t1;
+alter table t1 DEFAULT CHARACTER SET latin1;
+show create table t1;
+alter table t1 CHARACTER SET latin1;
+show create table t1;
+alter table t1 DEFAULT CHARACTER SET cp1251;
+show create table t1;
+
+drop table t1;
+
+#
# Test ALTER TABLE ENABLE/DISABLE keys when things are locked
#
diff --git a/mysql-test/t/analyse.test b/mysql-test/t/analyse.test
index 9bf737c9515..6aca345b282 100644
--- a/mysql-test/t/analyse.test
+++ b/mysql-test/t/analyse.test
@@ -2,12 +2,16 @@
# Test of procedure analyse
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
create table t1 (i int, j int, empty_string char(10), bool char(1), d date);
insert into t1 values (1,2,"","Y","2002-03-03"), (3,4,"","N","2002-03-04"), (5,6,"","Y","2002-03-04"), (7,8,"","N","2002-03-05");
+select count(*) from t1 procedure analyse();
select * from t1 procedure analyse();
select * from t1 procedure analyse(2);
create table t2 select * from t1 procedure analyse();
select * from t2;
drop table t1,t2;
+EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE();
diff --git a/mysql-test/t/ansi-master.opt b/mysql-test/t/ansi-master.opt
deleted file mode 100644
index 6bf7a4f30e2..00000000000
--- a/mysql-test/t/ansi-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---ansi
diff --git a/mysql-test/t/ansi.test b/mysql-test/t/ansi.test
index e1ac8ffd4f9..faf20f1e57e 100644
--- a/mysql-test/t/ansi.test
+++ b/mysql-test/t/ansi.test
@@ -2,7 +2,14 @@
# Test of ansi mode
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
+set sql_mode="MySQL40";
+select @@sql_mode;
+set @@sql_mode="ANSI";
+select @@sql_mode;
# Test some functions that works different in ansi mode
@@ -15,3 +22,5 @@ SELECT id,NULL,1,1.1,'a' FROM t1 GROUP BY id;
--error 1055
SELECT id FROM t1 GROUP BY id2;
drop table t1;
+
+SET @@SQL_MODE="";
diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test
index 5fba4bb9234..d02850f6745 100644
--- a/mysql-test/t/auto_increment.test
+++ b/mysql-test/t/auto_increment.test
@@ -1,8 +1,11 @@
#
# Test of auto_increment; The test for BDB tables is in bdb.test
#
-
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+SET SQL_WARNINGS=1;
+
create table t1 (a int not null auto_increment,b int, primary key (a)) type=myisam auto_increment=3;
insert into t1 values (1,1),(NULL,3),(NULL,4);
delete from t1 where a=4;
@@ -70,3 +73,71 @@ select * from t1;
check table t1;
drop table t1;
+#
+# last_insert_id() madness
+#
+create table t1 (i tinyint unsigned not null auto_increment primary key);
+insert into t1 set i = 254;
+insert into t1 set i = null;
+select last_insert_id();
+explain extended select last_insert_id();
+--error 1062
+insert into t1 set i = 254;
+select last_insert_id();
+--error 1062
+insert into t1 set i = null;
+select last_insert_id();
+drop table t1;
+
+create table t1 (i tinyint unsigned not null auto_increment, key (i));
+insert into t1 set i = 254;
+insert into t1 set i = null;
+select last_insert_id();
+insert into t1 set i = null;
+select last_insert_id();
+drop table t1;
+
+create table t1 (i tinyint unsigned not null auto_increment primary key, b int, unique (b));
+insert into t1 values (NULL, 10);
+select last_insert_id();
+insert into t1 values (NULL, 15);
+select last_insert_id();
+--error 1062
+insert into t1 values (NULL, 10);
+select last_insert_id();
+
+drop table t1;
+
+create table t1(a int auto_increment,b int null,primary key(a));
+SET SQL_MODE=NO_AUTO_VALUE_ON_ZERO;
+insert into t1(a,b)values(NULL,1);
+insert into t1(a,b)values(200,2);
+insert into t1(a,b)values(0,3);
+insert into t1(b)values(4);
+insert into t1(b)values(5);
+insert into t1(b)values(6);
+insert into t1(b)values(7);
+select * from t1 order by b;
+delete from t1 where a=0;
+update t1 set a=0 where b=5;
+select * from t1 order by b;
+delete from t1 where a=0;
+update t1 set a=NULL where b=6;
+update t1 set a=300 where b=7;
+SET SQL_MODE='';
+insert into t1(a,b)values(NULL,8);
+insert into t1(a,b)values(400,9);
+insert into t1(a,b)values(0,10);
+insert into t1(b)values(11);
+insert into t1(b)values(12);
+insert into t1(b)values(13);
+insert into t1(b)values(14);
+select * from t1 order by b;
+delete from t1 where a=0;
+update t1 set a=0 where b=12;
+select * from t1 order by b;
+delete from t1 where a=0;
+update t1 set a=NULL where b=13;
+update t1 set a=500 where b=14;
+select * from t1 order by b;
+drop table t1;
diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test
index 650b85477f5..ed24161bef5 100644
--- a/mysql-test/t/backup.test
+++ b/mysql-test/t/backup.test
@@ -6,6 +6,9 @@ connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
set SQL_LOG_BIN=0;
+--disable_warnings
+drop table if exists t1, t2, t3;
+--enable_warnings
create table t4(n int);
--replace_result "errno: 1" "errno: X" "errno: 2" "errno: X" "errno: 22" "errno: X" "errno: 23" "errno: X"
backup table t4 to '../bogus';
diff --git a/mysql-test/t/bdb-alter-table-1.test b/mysql-test/t/bdb-alter-table-1.test
index 5861c2fe0bf..7537cc358e8 100644
--- a/mysql-test/t/bdb-alter-table-1.test
+++ b/mysql-test/t/bdb-alter-table-1.test
@@ -2,7 +2,10 @@
# Test of problem when shutting down mysqld at once after ALTER TABLE
#
-- source include/have_bdb.inc
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1(objid BIGINT not null, tablename varchar(64), oid BIGINT not null, test BIGINT, PRIMARY KEY (objid), UNIQUE(tablename)) type=BDB;
insert into t1 values(1, 't1',4,9);
insert into t1 values(2, 'metatable',1,9);
diff --git a/mysql-test/t/bdb-crash.test b/mysql-test/t/bdb-crash.test
index 4575a612728..d77de901a30 100644
--- a/mysql-test/t/bdb-crash.test
+++ b/mysql-test/t/bdb-crash.test
@@ -2,7 +2,9 @@
# test for bug reported by Mark Steele
+--disable_warnings
drop table if exists t1;
+--enable_warnings
CREATE TABLE t1 (
ChargeID int(10) unsigned NOT NULL auto_increment,
ServiceID int(10) unsigned DEFAULT '0' NOT NULL,
diff --git a/mysql-test/t/bdb-deadlock.test b/mysql-test/t/bdb-deadlock.test
index b32b50c715b..2453c42e49a 100644
--- a/mysql-test/t/bdb-deadlock.test
+++ b/mysql-test/t/bdb-deadlock.test
@@ -11,7 +11,9 @@
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
connection con1;
create table t1 (id integer, x integer) type=BDB;
create table t2 (id integer, x integer) type=BDB;
@@ -30,13 +32,19 @@ select x from t1 where id = 0;
connection con1;
# This should generate a deadlock as we are trying to access a locked row
---error 1213
+--send
select x from t2 where id = 0;
-commit;
connection con2;
+--error 1213
reap;
commit;
+
+connection con1;
+reap;
+commit;
+
+connection con2;
select * from t1;
select * from t2;
commit;
@@ -45,4 +53,5 @@ connection con1;
select * from t1;
select * from t2;
commit;
+
drop table t1,t2;
diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test
index d0cc63a9389..a0fbc56a9da 100644
--- a/mysql-test/t/bdb.test
+++ b/mysql-test/t/bdb.test
@@ -4,7 +4,9 @@
# Small basic test with ignore
#
+--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
+--enable_warnings
create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) type=bdb;
insert into t1 (code, name) values (1, 'Tim'), (1, 'Monty'), (2, 'David'), (2, 'Erik'), (3, 'Sasha'), (3, 'Jeremy'), (4, 'Matt');
@@ -441,7 +443,6 @@ drop table t1;
# This gave a wrong result because the row information was freed too early
#
-drop table if exists t1, t2, t3, t4, t5, t6, t7;
create table t1
(
branch_id int auto_increment primary key,
@@ -451,7 +452,6 @@ create table t1
unique branch_name(branch_name),
index branch_active(branch_active)
) type=bdb;
-drop table if exists t2 ;
create table t2
(
target_id int auto_increment primary key,
@@ -461,7 +461,6 @@ create table t2
unique target_name(target_name),
index target_active(target_active)
) type=bdb;
-drop table if exists t3 ;
create table t3
(
platform_id int auto_increment primary key,
@@ -471,7 +470,6 @@ create table t3
unique platform_name(platform_name),
index platform_active(platform_active)
) type=bdb;
-drop table if exists t4 ;
create table t4
(
product_id int auto_increment primary key,
@@ -482,7 +480,6 @@ create table t4
unique product_name(product_name),
index product_active(product_active)
) type=bdb;
-drop table if exists t5 ;
create table t5
(
product_file_id int auto_increment primary key,
@@ -496,7 +493,6 @@ create table t5
unique product_file(product_id,file_name),
index file_included(file_included)
) type=bdb;
-drop table if exists t6 ;
create table t6
(
file_platform_id int auto_increment primary key,
@@ -510,7 +506,6 @@ create table t6
unique file_platform(product_file_id,platform_id,branch_id)
) type=bdb;
-drop table if exists t8 ;
create table t8
(
archive_id int auto_increment primary key,
@@ -523,7 +518,6 @@ create table t8
unique archive(branch_id,target_id,platform_id,product_id),
index status_id(status_id)
) type=bdb;
-drop table if exists t7 ;
create table t7
(
build_id int auto_increment primary key,
@@ -727,7 +721,6 @@ DROP TABLE t1,t2;
# Test problem with joining table to itself on a multi-part unique key
#
-drop table if exists t1;
create table t1 (a int(11) not null, b int(11) not null, unique (a,b)) type=bdb;
insert into t1 values (1,1), (1,2);
select * from t1 where a = 1;
diff --git a/mysql-test/t/bdb_cache.test b/mysql-test/t/bdb_cache.test
index aa5572886c5..0d7de75ccf6 100644
--- a/mysql-test/t/bdb_cache.test
+++ b/mysql-test/t/bdb_cache.test
@@ -4,7 +4,9 @@
#
# Without auto_commit.
#
+--disable_warnings
drop table if exists t1, t2, t3;
+--enable_warnings
flush status;
set autocommit=0;
create table t1 (a int not null) type=bdb;
@@ -47,4 +49,5 @@ select * from t3;
show status like "Qcache_queries_in_cache";
show status like "Qcache_hits";
commit;
-show status like "Qcache_queries_in_cache"; \ No newline at end of file
+show status like "Qcache_queries_in_cache";
+drop table if exists t1, t2, t3;
diff --git a/mysql-test/t/bench_count_distinct.test b/mysql-test/t/bench_count_distinct.test
index 9059428bea4..3ffb95a69c2 100644
--- a/mysql-test/t/bench_count_distinct.test
+++ b/mysql-test/t/bench_count_distinct.test
@@ -1,4 +1,10 @@
+#
+# Test of count(distinct ..)
+#
+
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1(n int not null, key(n)) delay_key_write = 1;
let $1=100;
disable_query_log;
@@ -10,4 +16,5 @@ while ($1)
}
enable_query_log;
select count(distinct n) from t1;
+explain extended select count(distinct n) from t1;
drop table t1;
diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test
index f21f821e45c..5c977983087 100644
--- a/mysql-test/t/bigint.test
+++ b/mysql-test/t/bigint.test
@@ -1,4 +1,11 @@
#
+# Initialize
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+#
# Test of reading of bigint values
#
select 0,256,00000000000000065536,2147483647,-2147483648,2147483648,+4294967296;
@@ -6,13 +13,14 @@ select 9223372036854775807,-009223372036854775808;
select +9999999999999999999,-9999999999999999999;
select cast(9223372036854775808 as unsigned)+1;
select 9223372036854775808+1;
+select -(0-3),round(-(0-3)), round(9999999999999999999);
+
#
# In 3.23 we have to disable the test of column to bigint as
# this fails on AIX powerpc (the resolution for double is not good enough)
# This will work on 4.0 as we then have internal handling of bigint variables.
#
-drop table if exists t1;
create table t1 (a bigint unsigned not null, primary key(a));
insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612);
select * from t1;
diff --git a/mysql-test/t/binary.test b/mysql-test/t/binary.test
index 95815cda60f..48912a390ed 100644
--- a/mysql-test/t/binary.test
+++ b/mysql-test/t/binary.test
@@ -1,8 +1,10 @@
#
# test sort,min and max on binary fields
#
-
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (name char(20) not null, primary key (name));
create table t2 (name char(20) binary not null, primary key (name));
insert into t1 values ("å");
@@ -28,16 +30,16 @@ drop table t1,t2;
create table t1 (a char(10) not null, b char(10) binary not null,key (a), key(b));
insert into t1 values ("hello ","hello "),("hello2 ","hello2 ");
-select * from t1 where a="hello";
-select * from t1 where a="hello ";
-select * from t1 ignore index (a) where a="hello ";
-select * from t1 where b="hello";
-select * from t1 where b="hello ";
-select * from t1 ignore index (b) where b="hello ";
+select concat("-",a,"-",b,"-") from t1 where a="hello";
+select concat("-",a,"-",b,"-") from t1 where a="hello ";
+select concat("-",a,"-",b,"-") from t1 ignore index (a) where a="hello ";
+select concat("-",a,"-",b,"-") from t1 where b="hello";
+select concat("-",a,"-",b,"-") from t1 where b="hello ";
+select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
# blob test
alter table t1 modify b tinytext not null, drop key b, add key (b(100));
-select * from t1 where b="hello ";
-select * from t1 ignore index (b) where b="hello ";
+select concat("-",a,"-",b,"-") from t1 where b="hello ";
+select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello ";
drop table t1;
#
diff --git a/mysql-test/t/bool.test b/mysql-test/t/bool.test
index 10f97fefb73..b263ecfded2 100644
--- a/mysql-test/t/bool.test
+++ b/mysql-test/t/bool.test
@@ -2,7 +2,9 @@
# Test of boolean operations with NULL
#
+--disable_warnings
DROP TABLE IF EXISTS t1;
+--enable_warnings
SELECT IF(NULL AND 1, 1, 2), IF(1 AND NULL, 1, 2);
SELECT NULL AND 1, 1 AND NULL, 0 AND NULL, NULL and 0;
@@ -24,7 +26,6 @@ SELECT * FROM t1 WHERE NULL AND (@a:=@a+1);
SELECT * FROM t1 WHERE NOT(a>=0 AND NULL AND (@b:=@b+1));
SELECT * FROM t1 WHERE a=2 OR (NULL AND (@a:=@a+1));
SELECT * FROM t1 WHERE NOT(a=2 OR (NULL AND (@b:=@b+1)));
-SELECT @a, @b;
DROP TABLE t1;
@@ -33,19 +34,17 @@ DROP TABLE t1;
# Read nA as !A, AB as A && B, AoB as A || B
# Result table makes ANSI happy
-drop table if exists t;
-create table t(a int, b int);
-insert into t values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1);
+create table t1 (a int, b int);
+insert into t1 values(null, null), (0, null), (1, null), (null, 0), (null, 1), (0, 0), (0, 1), (1, 0), (1, 1);
# Below test is valid untill we have True/False implemented as 1/0
# To comply to all rules it must show that: n(AB) = nAonB, n(AoB) = nAnB
-select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t;
+select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnull(not B, 'N') as nB, ifnull(A and B, 'N') as AB, ifnull(not (A and B), 'N') as `n(AB)`, ifnull((not A or not B), 'N') as nAonB, ifnull(A or B, 'N') as AoB, ifnull(not(A or B), 'N') as `n(AoB)`, ifnull(not A and not B, 'N') as nAnB from t1;
# This should work with any internal representation of True/False
# Result must be same as above
-select ifnull(A=1, 'N') as A, ifnull(B=1, 'N') as B, ifnull(not (A=1), 'N') as nA, ifnull(not (B=1), 'N') as nB, ifnull((A=1) and (B=1), 'N') as AB, ifnull(not ((A=1) and (B=1)), 'N') as `n(AB)`, ifnull((not (A=1) or not (B=1)), 'N') as nAonB, ifnull((A=1) or (B=1), 'N') as AoB, ifnull(not((A=1) or (B=1)), 'N') as `n(AoB)`, ifnull(not (A=1) and not (B=1), 'N') as nAnB from t;
+select ifnull(A=1, 'N') as A, ifnull(B=1, 'N') as B, ifnull(not (A=1), 'N') as nA, ifnull(not (B=1), 'N') as nB, ifnull((A=1) and (B=1), 'N') as AB, ifnull(not ((A=1) and (B=1)), 'N') as `n(AB)`, ifnull((not (A=1) or not (B=1)), 'N') as nAonB, ifnull((A=1) or (B=1), 'N') as AoB, ifnull(not((A=1) or (B=1)), 'N') as `n(AoB)`, ifnull(not (A=1) and not (B=1), 'N') as nAnB from t1;
-
-drop table t;
+drop table t1;
diff --git a/mysql-test/t/bulk_replace.test b/mysql-test/t/bulk_replace.test
index d366004c16f..755d34083f8 100644
--- a/mysql-test/t/bulk_replace.test
+++ b/mysql-test/t/bulk_replace.test
@@ -1,11 +1,10 @@
#
# this is a test of bulk-insert code
-# as used by REPLACE
-#
-# by Monty
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
CREATE TABLE t1 (a int, unique (a), b int not null, unique(b), c int not null, index(c));
replace into t1 values (1,1,1),(2,2,2),(3,1,3);
select * from t1;
diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test
index 3ba3a292c77..9377c6c4aef 100644
--- a/mysql-test/t/case.test
+++ b/mysql-test/t/case.test
@@ -2,7 +2,9 @@
# Testing of CASE
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
select CASE "b" when "a" then 1 when "b" then 2 END;
select CASE "c" when "a" then 1 when "b" then 2 END;
@@ -12,6 +14,7 @@ select CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END;
select CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end;
select CASE when 1=0 then "true" else "false" END;
select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END;
+explain extended select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END;
select CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END;
select (CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0;
select (CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0;
@@ -28,6 +31,7 @@ select case when 1<0 then "TRUE" else "FALSE" END;
create table t1 (a int);
insert into t1 values(1),(2),(3),(4);
select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase;
+explain extended select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase;
select case a when 1 then "one" when 2 then "two" else "nothing" end as fcase, count(*) from t1 group by fcase;
drop table t1;
@@ -39,3 +43,67 @@ create table t1 (row int not null, col int not null, val varchar(255) not null);
insert into t1 values (1,1,'orange'),(1,2,'large'),(2,1,'yellow'),(2,2,'medium'),(3,1,'green'),(3,2,'small');
select max(case col when 1 then val else null end) as color from t1 group by row;
drop table t1;
+
+SET NAMES latin1;
+
+#
+# CASE and argument types/collations aggregation into result
+#
+CREATE TABLE t1 SELECT
+ CASE WHEN 1 THEN _latin1'a' COLLATE latin1_danish_ci ELSE _latin1'a' END AS c1,
+ CASE WHEN 1 THEN _latin1'a' ELSE _latin1'a' COLLATE latin1_danish_ci END AS c2,
+ CASE WHEN 1 THEN 'a' ELSE 1 END AS c3,
+ CASE WHEN 1 THEN 1 ELSE 'a' END AS c4,
+ CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5,
+ CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6,
+ CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7,
+ CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8,
+ CASE WHEN 1 THEN 1.0 END AS c9
+;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+--error 1266
+SELECT CASE
+ WHEN 1
+ THEN _latin1'a' COLLATE latin1_danish_ci
+ ELSE _latin1'a' COLLATE latin1_swedish_ci
+ END;
+
+--error 1269
+SELECT CASE _latin1'a' COLLATE latin1_general_ci
+ WHEN _latin1'a' COLLATE latin1_danish_ci THEN 1
+ WHEN _latin1'a' COLLATE latin1_swedish_ci THEN 2
+ END;
+
+SELECT
+CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END,
+CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END,
+CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END,
+CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END
+;
+
+#
+# COALESCE is a CASE abbrevation:
+#
+# COALESCE(v1,v2) == CASE WHEN v1 IS NOT NULL THEN v1 ELSE v2 END
+#
+# COALESCE(V1, V2, . . . ,Vn ) =
+# CASE WHEN V1 IS NOT NULL THEN V1 ELSE COALESCE (V2, . . . ,Vn) END
+#
+# Check COALESCE argument types aggregation
+
+--error 1266
+CREATE TABLE t1 SELECT COALESCE(_latin1'a',_latin2'a');
+--error 1266
+CREATE TABLE t1 SELECT COALESCE('a' COLLATE latin1_swedish_ci,'b' COLLATE latin1_bin);
+CREATE TABLE t1 SELECT
+ COALESCE(1), COALESCE(1.0),COALESCE('a'),
+ COALESCE(1,1.0), COALESCE(1,'1'),COALESCE(1.1,'1'),
+ COALESCE('a' COLLATE latin1_bin,'b');
+explain extended SELECT
+ COALESCE(1), COALESCE(1.0),COALESCE('a'),
+ COALESCE(1,1.0), COALESCE(1,'1'),COALESCE(1.1,'1'),
+ COALESCE('a' COLLATE latin1_bin,'b');
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test
index 7a120ef5005..dd17904effb 100644
--- a/mysql-test/t/cast.test
+++ b/mysql-test/t/cast.test
@@ -8,15 +8,69 @@ select CONVERT('-1',UNSIGNED);
select cast(-5 as unsigned) | 1, cast(-5 as unsigned) & -1;
select cast(-5 as unsigned) -1, cast(-5 as unsigned) + 1;
select ~5, cast(~5 as signed);
+explain extended select ~5, cast(~5 as signed);
select cast(5 as unsigned) -6.0;
select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A";
select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
select cast("1:2:3" as TIME);
#
+# Character set convertion
+#
+set names binary;
+select cast(_latin1'test' as char character set latin2);
+select cast(_koi8r'ÔÅÓÔ' as char character set cp1251);
+create table t1 select cast(_koi8r'ÔÅÓÔ' as char character set cp1251) as t;
+show create table t1;
+drop table t1;
+
+#
+# CAST to CHAR with/without length
+#
+select
+ cast(_latin1'ab' AS char) as c1,
+ cast(_latin1'a ' AS char) as c2,
+ cast(_latin1'abc' AS char(2)) as c3,
+ cast(_latin1'a ' AS char(2)) as c4,
+ cast(_latin1'a' AS char(2)) as c5;
+
+create table t1 select
+ cast(_latin1'ab' AS char) as c1,
+ cast(_latin1'a ' AS char) as c2,
+ cast(_latin1'abc' AS char(2)) as c3,
+ cast(_latin1'a ' AS char(2)) as c4,
+ cast(_latin1'a' AS char(2)) as c5;
+select * from t1;
+show create table t1;
+drop table t1;
+
+#
+# CAST to NCHAR with/without length
+#
+select
+ cast(_koi8r'ÆÇ' AS nchar) as c1,
+ cast(_koi8r'Æ ' AS nchar) as c2,
+ cast(_koi8r'ÆÇÈ' AS nchar(2)) as c3,
+ cast(_koi8r'Æ ' AS nchar(2)) as c4,
+ cast(_koi8r'Æ' AS nchar(2)) as c5;
+
+create table t1 select
+ cast(_koi8r'ÆÇ' AS nchar) as c1,
+ cast(_koi8r'Æ ' AS nchar) as c2,
+ cast(_koi8r'ÆÇÈ' AS nchar(2)) as c3,
+ cast(_koi8r'Æ ' AS nchar(2)) as c4,
+ cast(_koi8r'Æ' AS nchar(2)) as c5;
+select * from t1;
+show create table t1;
+drop table t1;
+
+
+#
# The following should be fixed in 4.1
#
select cast("2001-1-1" as date) = "2001-01-01";
select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00";
select cast("1:2:3" as TIME) = "1:02:03";
+select cast(NULL as DATE);
+select cast(NULL as BINARY);
diff --git a/mysql-test/t/check.test b/mysql-test/t/check.test
index 947566e725b..bc61aea2d66 100644
--- a/mysql-test/t/check.test
+++ b/mysql-test/t/check.test
@@ -1,8 +1,11 @@
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
+--disable_warnings
drop table if exists t1;
-#add a lot of keys to slow down check
+--enable_warnings
+
+# Add a lot of keys to slow down check
create table t1(n int not null, key(n), key(n), key(n), key(n));
let $1=10000;
disable_query_log;
diff --git a/mysql-test/t/compare.test b/mysql-test/t/compare.test
index 450d9c0961c..e5a2e310866 100644
--- a/mysql-test/t/compare.test
+++ b/mysql-test/t/compare.test
@@ -2,7 +2,10 @@
# Bug when using comparions of strings and integers.
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
CREATE TABLE t1 (id CHAR(12) not null, PRIMARY KEY (id));
insert into t1 values ('000000000001'),('000000000002');
explain select * from t1 where id=000000000001;
diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test
new file mode 100644
index 00000000000..7585ff0f608
--- /dev/null
+++ b/mysql-test/t/connect.test
@@ -0,0 +1,72 @@
+# This test is to check various cases of connections
+# with right and wrong password, with and without database
+# Unfortunately the check is incomplete as we can't handle errors on connect
+# Also we can't connect without database
+
+#connect (con1,localhost,root,,"");
+#show tables;
+connect (con1,localhost,root,,mysql);
+show tables;
+connect (con1,localhost,root,,test);
+show tables;
+
+# Re enable this one day if error handling on connect will take place
+
+#connect (con1,localhost,root,z,test2);
+#--error 1045
+#connect (con1,localhost,root,z,);
+#--error 1045
+
+grant ALL on *.* to test@localhost identified by "gambling";
+grant ALL on *.* to test@127.0.0.1 identified by "gambling";
+
+# Now check this user with different databases
+
+#connect (con1,localhost,test,gambling,"");
+#show tables;
+connect (con1,localhost,test,gambling,mysql);
+show tables;
+connect (con1,localhost,test,gambling,test);
+show tables;
+
+# Re enable this one day if error handling on connect will take place
+
+#connect (con1,localhost,test,,test2);
+#--error 1045
+#connect (con1,localhost,test,,"");
+#--error 1045
+#connect (con1,localhost,test,zorro,test2);
+#--error 1045
+#connect (con1,localhost,test,zorro,);
+#--error 1045
+
+
+# check if old password version also works
+update mysql.user set password=old_password("gambling2") where user="test";
+flush privileges;
+
+#connect (con1,localhost,test,gambling2,"");
+#show tables;
+connect (con1,localhost,test,gambling2,mysql);
+set password=old_password('gambling3');
+show tables;
+connect (con1,localhost,test,gambling3,test);
+show tables;
+
+# Re enable this one day if error handling on connect will take place
+
+#connect (con1,localhost,test,,test2);
+#--error 1045
+#connect (con1,localhost,test,,);
+#--error 1045
+#connect (con1,localhost,test,zorro,test2);
+#--error 1045
+#connect (con1,localhost,test,zorro,);
+#--error 1045
+
+
+# remove user 'test' so that other tests which may use 'test'
+# do not depend on this test.
+
+delete from mysql.user where user="test";
+flush privileges;
diff --git a/mysql-test/t/constraints.test b/mysql-test/t/constraints.test
index 8682cdc42a2..cc796e0abd2 100644
--- a/mysql-test/t/constraints.test
+++ b/mysql-test/t/constraints.test
@@ -2,7 +2,9 @@
# Testing of constraints
# Currently MySQL only ignores the syntax.
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1 (a int check (a>0));
insert into t1 values (1);
diff --git a/mysql-test/t/convert.test b/mysql-test/t/convert.test
deleted file mode 100644
index f26ef3a8c72..00000000000
--- a/mysql-test/t/convert.test
+++ /dev/null
@@ -1,11 +0,0 @@
-# Test of character set conversions
-
-# Test that SET DEFAULT works
-
-select @@convert_character_set;
-select @@global.convert_character_set;
-show variables like "%convert_character_set%";
-SET CHARACTER SET cp1251_koi8;
-select @@convert_character_set;
-SET CHARACTER SET DEFAULT;
-select @@convert_character_set;
diff --git a/mysql-test/t/count_distinct.test b/mysql-test/t/count_distinct.test
index cb84d0211d7..1f0404876cb 100644
--- a/mysql-test/t/count_distinct.test
+++ b/mysql-test/t/count_distinct.test
@@ -2,7 +2,10 @@
# Problem with count(distinct)
#
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
+
create table t1 (libname varchar(21) not null, city text, primary key (libname));
create table t2 (isbn varchar(21) not null, author text, title text, primary key (isbn));
create table t3 (isbn varchar(21) not null, libname varchar(21) not null, quantity int ,primary key (isbn,libname));
diff --git a/mysql-test/t/count_distinct2.test b/mysql-test/t/count_distinct2.test
index d1bea7614c8..9100f622dec 100644
--- a/mysql-test/t/count_distinct2.test
+++ b/mysql-test/t/count_distinct2.test
@@ -1,4 +1,6 @@
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1(n1 int, n2 int, s char(20), vs varchar(20), t text);
insert into t1 values (1,11, 'one','eleven', 'eleven'),
diff --git a/mysql-test/t/count_distinct3.test b/mysql-test/t/count_distinct3.test
new file mode 100644
index 00000000000..e6cc98d47df
--- /dev/null
+++ b/mysql-test/t/count_distinct3.test
@@ -0,0 +1,55 @@
+#
+# this is a test for error 1032 in count(distinct) + group by, introduced in
+# mysql-4.1
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER);
+
+--disable_query_log
+SET @rnd_max= 2147483647;
+let $1 = 1000;
+while ($1)
+{
+ SET @rnd= RAND();
+ SET @id = CAST(@rnd * @rnd_max AS UNSIGNED);
+ SET @id_rev= @rnd_max - @id;
+ SET @grp= CAST(128.0 * @rnd AS UNSIGNED);
+ INSERT INTO t1 (id, grp, id_rev) VALUES (@id, @grp, @id_rev);
+ dec $1;
+}
+CREATE TABLE t2 SELECT * FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2;
+INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1;
+DROP TABLE t2;
+--enable_query_log
+
+SELECT COUNT(*) FROM t1;
+
+# As t1 contains random numbers, results are different from test to test.
+# That's okay, because we test only that select doesn't yield an
+# error. Note, that --disable_result_log doesn't suppress error output.
+
+--disable_result_log
+SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp;
+--enable_result_log
+DROP TABLE t1;
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index 8aee586268f..0c1280751bc 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -2,7 +2,10 @@
# Check some special create statements.
#
-drop table if exists t1,t2;
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
create table t1 (b char(0));
insert into t1 values (""),(null);
select * from t1;
@@ -12,7 +15,10 @@ create table t1 (b char(0) not null);
create table if not exists t1 (b char(0) not null);
insert into t1 values (""),(null);
select * from t1;
-drop table if exists t1;
+drop table t1;
+
+create table t1 (a int not null auto_increment,primary key (a)) type=heap;
+drop table t1;
#
# Test of some CREATE TABLE'S that should fail
@@ -25,13 +31,11 @@ create table t2 select auto+1 from t1;
drop table if exists t1,t2;
--error 1167
create table t1 (b char(0) not null, index(b));
---error 1164
-create table t1 (a int not null auto_increment,primary key (a)) type=heap;
--error 1163
create table t1 (a int not null,b text) type=heap;
drop table if exists t1;
---error 1164
+--error 1075
create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=heap;
-- error 1044,1
@@ -68,7 +72,8 @@ create table `` (a int);
drop table if exists ``;
--error 1166
create table t1 (`` int);
-drop table if exists t1;
+--error 1279
+create table t1 (i int, index `` (i));
#
# Test of CREATE ... SELECT with indexes
@@ -98,6 +103,38 @@ describe t2;
drop table t1,t2;
#
+# Test of CREATE ... SELECT with duplicate fields
+#
+
+create table t1 (a tinyint);
+create table t2 (a int) select * from t1;
+describe t1;
+describe t2;
+drop table if exists t2;
+--error 1060
+create table t2 (a int, a float) select * from t1;
+drop table if exists t2;
+--error 1060
+create table t2 (a int) select a as b, a+1 as b from t1;
+drop table if exists t2;
+--error 1060
+create table t2 (b int) select a as b, a+1 as b from t1;
+drop table if exists t1,t2;
+
+#
+# Test CREATE ... SELECT when insert fails
+#
+
+CREATE TABLE t1 (a int not null);
+INSERT INTO t1 values (1),(2),(1);
+--error 1062
+CREATE TABLE t2 (primary key(a)) SELECT * FROM t1;
+--error 1146
+SELECT * from t2;
+DROP TABLE t1;
+DROP TABLE IF EXISTS t2;
+
+#
# Test of primary key with 32 index
#
@@ -141,7 +178,7 @@ insert into t1 values (NULL, NULL);
drop table t1;
#
-# Bug #801
+# Bug # 801
#
create table t1 select x'4132';
@@ -179,3 +216,125 @@ create table if not exists t1 select 3 as 'a',4 as 'b';
create table if not exists t1 select 3 as 'a',3 as 'b';
select * from t1;
drop table t1;
+
+#
+# Test create with foreign keys
+#
+
+create table t1 (a int, key(a));
+create table t2 (b int, foreign key(b) references t1(a), key(b));
+drop table if exists t1,t2;
+
+#
+# Test for CREATE TABLE .. LIKE ..
+#
+
+create table t1(id int not null, name char(20));
+insert into t1 values(10,'mysql'),(20,'monty- the creator');
+create table t2(id int not null);
+insert into t2 values(10),(20);
+create table t3 like t1;
+show create table t3;
+select * from t3;
+create table if not exists t3 like t1;
+select @@warning_count;
+create temporary table t3 like t2;
+show create table t3;
+select * from t3;
+drop table t3;
+show create table t3;
+select * from t3;
+drop table t2, t3;
+drop database if exists test_$1;
+create database test_$1;
+create table test_$1.t3 like t1;
+create temporary table t3 like test_$1.t3;
+show create table t3;
+create table t2 like t3;
+show create table t2;
+select * from t2;
+create table t3 like t1;
+--error 1050
+create table t3 like test_$1.t3;
+--error 1044,1
+create table non_existing_database.t1 like t1;
+--error 1051
+create table t3 like non_existing_table;
+--error 1050
+create temporary table t3 like t1;
+--error 1103
+create table t3 like `a/a`;
+drop table t1, t2, t3;
+drop table t3;
+drop database test_$1;
+
+#
+# Test default table type
+#
+SET SESSION table_type="heap";
+SELECT @@table_type;
+CREATE TABLE t1 (a int not null);
+show create table t1;
+drop table t1;
+# Test what happens when using a non existing table type
+SET SESSION table_type="gemini";
+SELECT @@table_type;
+CREATE TABLE t1 (a int not null);
+show create table t1;
+SET SESSION table_type=default;
+drop table t1;
+
+#
+# Test types of data for create select with functions
+#
+
+create table t1(a int,b int,c int unsigned,d date,e char,f datetime,g time,h blob);
+insert into t1(a)values(1);
+insert into t1(a,b,c,d,e,f,g,h)
+values(2,-2,2,'1825-12-14','a','2003-1-1 3:2:1','4:3:2','binary data');
+select * from t1;
+select a,
+ ifnull(b,cast(-7 as signed)) as b,
+ ifnull(c,cast(7 as unsigned)) as c,
+ ifnull(d,cast('2000-01-01' as date)) as d,
+ ifnull(e,cast('b' as char)) as e,
+ ifnull(f,cast('2000-01-01' as datetime)) as f,
+ ifnull(g,cast('5:4:3' as time)) as g,
+ ifnull(h,cast('yet another binary data' as binary)) as h,
+ addtime(cast('1:0:0' as time),cast('1:0:0' as time)) as dd
+from t1;
+
+create table t2
+select
+ a,
+ ifnull(b,cast(-7 as signed)) as b,
+ ifnull(c,cast(7 as unsigned)) as c,
+ ifnull(d,cast('2000-01-01' as date)) as d,
+ ifnull(e,cast('b' as char)) as e,
+ ifnull(f,cast('2000-01-01' as datetime)) as f,
+ ifnull(g,cast('5:4:3' as time)) as g,
+ ifnull(h,cast('yet another binary data' as binary)) as h,
+ addtime(cast('1:0:0' as time),cast('1:0:0' as time)) as dd
+from t1;
+explain t2;
+
+select * from t2;
+
+drop table t1, t2;
+
+#
+# Bug #1209
+#
+
+--disable_warnings
+drop database if exists test_$1;
+--enable_warnings
+create database test_$1;
+use test_$1;
+select database();
+drop database test_$1;
+select database();
+
+# Connect without a database
+connect (user4,localhost,mysqltest_1,,*NO-ONE*);
+select database();
diff --git a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test
new file mode 100644
index 00000000000..2d9a4be5b36
--- /dev/null
+++ b/mysql-test/t/ctype_collate.test
@@ -0,0 +1,158 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+CREATE TABLE t1 (
+ latin1_f CHAR(32) CHARACTER SET latin1 NOT NULL
+);
+
+--error 1252
+CREATE TABLE t2 (
+ latin1_f CHAR(32) CHARACTER SET latin1 COLLATE koi8r_general_ci NOT NULL
+);
+
+--error 1272
+CREATE TABLE t2 (
+ latin1_f CHAR(32) CHARACTER SET latin1 COLLATE some_non_existing_col NOT NULL
+);
+
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'A');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'a');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'AD');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ad');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'AE');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ae');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'AF');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'af');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'Ä');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ä');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'Å');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'å');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'B');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'b');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'U');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'u');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'UE');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ue');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'Ü');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ü');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'SS');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ss');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'ß');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'Y');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'y');
+
+INSERT INTO t1 (latin1_f) VALUES (_latin1'Z');
+INSERT INTO t1 (latin1_f) VALUES (_latin1'z');
+
+
+-- ORDER BY
+
+SELECT latin1_f FROM t1 ORDER BY latin1_f;
+SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_swedish_ci;
+SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_german2_ci;
+SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_general_ci;
+SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_bin;
+--error 1252
+SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE koi8r_general_ci;
+
+--SELECT latin1_f COLLATE koi8r FROM t1 ;
+
+-- AS + ORDER BY
+SELECT latin1_f COLLATE latin1_swedish_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
+SELECT latin1_f COLLATE latin1_german2_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
+SELECT latin1_f COLLATE latin1_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
+SELECT latin1_f COLLATE latin1_bin AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
+--error 1252
+SELECT latin1_f COLLATE koi8r_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as;
+
+
+-- GROUP BY
+
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f;
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_swedish_ci;
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_german2_ci;
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_general_ci;
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_bin;
+--error 1252
+SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE koi8r_general_ci;
+
+
+-- DISTINCT
+
+SELECT DISTINCT latin1_f FROM t1;
+SELECT DISTINCT latin1_f COLLATE latin1_swedish_ci FROM t1;
+SELECT DISTINCT latin1_f COLLATE latin1_german2_ci FROM t1;
+SELECT DISTINCT latin1_f COLLATE latin1_general_ci FROM t1;
+SELECT DISTINCT latin1_f COLLATE latin1_bin FROM t1;
+--error 1272
+SELECT DISTINCT latin1_f COLLATE koi8r FROM t1;
+
+
+-- Aggregates
+--SELECT MAX(k COLLATE latin1_german2_ci)
+--FROM t1
+
+
+-- WHERE
+--SELECT *
+--FROM t1
+--WHERE (_latin1'Mu"ller' COLLATE latin1_german2_ci) = k
+
+--HAVING
+--SELECT *
+--FROM t1
+--HAVING (_latin1'Mu"ller' COLLATE latin1_german2_ci) = k
+
+
+#
+# Check that SHOW displays COLLATE clause
+#
+
+SHOW CREATE TABLE t1;
+SHOW FIELDS FROM t1;
+ALTER TABLE t1 CHANGE latin1_f
+latin1_f CHAR(32) CHARACTER SET latin1 COLLATE latin1_bin;
+SHOW CREATE TABLE t1;
+SHOW FIELDS FROM t1;
+ALTER TABLE t1 CHARACTER SET latin1 COLLATE latin1_bin;
+SHOW CREATE TABLE t1;
+SHOW FIELDS FROM t1;
+
+#
+# Check SET CHARACTER SET
+#
+
+SET CHARACTER SET 'latin1';
+SHOW VARIABLES LIKE 'character_set_client';
+SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
+explain extended SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
+
+SET CHARACTER SET koi8r;
+SHOW VARIABLES LIKE 'collation_client';
+SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
+
+--error 1115
+SET CHARACTER SET 'DEFAULT';
+
+DROP TABLE t1;
+
+CREATE TABLE t1
+(s1 CHAR(5) COLLATE latin1_german1_ci,
+ s2 CHAR(5) COLLATE latin1_swedish_ci);
+--error 1266
+SELECT * FROM t1 WHERE s1 = s2;
+DROP TABLE t1;
diff --git a/mysql-test/t/ctype_latin1_de-master.opt b/mysql-test/t/ctype_latin1_de-master.opt
index 895a62364d6..79fdb1c63dc 100644
--- a/mysql-test/t/ctype_latin1_de-master.opt
+++ b/mysql-test/t/ctype_latin1_de-master.opt
@@ -1,2 +1 @@
---default-character-set=latin1_de --new
-
+--default-character-set=latin1 --default-collation=latin1_german2_ci
diff --git a/mysql-test/t/ctype_latin1_de.test b/mysql-test/t/ctype_latin1_de.test
index 3a0f2658969..a5d0c29baf6 100644
--- a/mysql-test/t/ctype_latin1_de.test
+++ b/mysql-test/t/ctype_latin1_de.test
@@ -1,7 +1,13 @@
#
# Test latin_de character set
#
+
+select @@collation_connection;
+
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (a char (20) not null, b int not null auto_increment, index (a,b));
insert into t1 (a) values ('ä'),('ac'),('ae'),('ad'),('Äc'),('aeb');
insert into t1 (a) values ('üc'),('uc'),('ue'),('ud'),('Ü'),('ueb'),('uf');
@@ -54,21 +60,37 @@ drop table t1;
# Test bug report #152 (problem with index on latin1_de)
#
+#
+# The below checks both binary and character comparisons.
+#
create table t1 (word varchar(255) not null, word2 varchar(255) not null, index(word));
+show create table t1;
insert into t1 (word) values ('ss'),(0xDF),(0xE4),('ae');
update t1 set word2=word;
-select word, word=0xdf as t from t1 having t > 0;
+select word, word=binary 0xdf as t from t1 having t > 0;
select word, word=cast(0xdf AS CHAR) as t from t1 having t > 0;
-select * from t1 where word=0xDF;
+select * from t1 where word=binary 0xDF;
select * from t1 where word=CAST(0xDF as CHAR);
-select * from t1 where word2=0xDF;
+select * from t1 where word2=binary 0xDF;
select * from t1 where word2=CAST(0xDF as CHAR);
select * from t1 where word='ae';
select * from t1 where word= 0xe4 or word=CAST(0xe4 as CHAR);
-select * from t1 where word between 0xDF and 0xDF;
+select * from t1 where word between binary 0xDF and binary 0xDF;
select * from t1 where word between CAST(0xDF AS CHAR) and CAST(0xDF AS CHAR);
select * from t1 where word like 'ae';
select * from t1 where word like 'AE';
-select * from t1 where word like 0xDF;
+select * from t1 where word like binary 0xDF;
select * from t1 where word like CAST(0xDF as CHAR);
drop table t1;
+
+CREATE TABLE t1 (
+s1 CHAR(5) CHARACTER SET latin1 COLLATE latin1_german2_ci
+);
+show create table t1;
+INSERT INTO t1 VALUES ('Ü');
+INSERT INTO t1 VALUES ('ue');
+SELECT DISTINCT s1 FROM t1;
+SELECT s1,COUNT(*) FROM t1 GROUP BY s1;
+SELECT COUNT(DISTINCT s1) FROM t1;
+SELECT FIELD('ue',s1), FIELD('Ü',s1), s1='ue', s1='Ü' FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/ctype_many.test b/mysql-test/t/ctype_many.test
new file mode 100644
index 00000000000..7b44439aa50
--- /dev/null
+++ b/mysql-test/t/ctype_many.test
@@ -0,0 +1,216 @@
+-- source include/have_ucs2.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+SET CHARACTER SET latin1;
+
+CREATE TABLE t1 (
+ comment CHAR(32) ASCII NOT NULL,
+ koi8_ru_f CHAR(32) CHARACTER SET koi8r NOT NULL
+) CHARSET=latin5;
+
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 CHANGE comment comment CHAR(32) CHARACTER SET latin2 NOT NULL;
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 ADD latin5_f CHAR(32) NOT NULL;
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 DEFAULT CHARSET=latin2;
+ALTER TABLE t1 ADD latin2_f CHAR(32) NOT NULL;
+SHOW CREATE TABLE t1;
+ALTER TABLE t1 DROP latin2_f, DROP latin5_f;
+SHOW CREATE TABLE t1;
+
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('a','LAT SMALL A');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('b','LAT SMALL B');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('c','LAT SMALL C');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('d','LAT SMALL D');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('e','LAT SMALL E');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('f','LAT SMALL F');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('g','LAT SMALL G');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('h','LAT SMALL H');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('i','LAT SMALL I');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('j','LAT SMALL J');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('k','LAT SMALL K');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('l','LAT SMALL L');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('m','LAT SMALL M');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('n','LAT SMALL N');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('o','LAT SMALL O');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('p','LAT SMALL P');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('q','LAT SMALL Q');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('r','LAT SMALL R');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('s','LAT SMALL S');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('t','LAT SMALL T');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('u','LAT SMALL U');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('v','LAT SMALL V');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('w','LAT SMALL W');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('x','LAT SMALL X');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('y','LAT SMALL Y');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('z','LAT SMALL Z');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('A','LAT CAPIT A');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('B','LAT CAPIT B');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('C','LAT CAPIT C');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('D','LAT CAPIT D');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('E','LAT CAPIT E');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('F','LAT CAPIT F');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('G','LAT CAPIT G');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('H','LAT CAPIT H');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('I','LAT CAPIT I');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('J','LAT CAPIT J');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('K','LAT CAPIT K');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('L','LAT CAPIT L');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('M','LAT CAPIT M');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('N','LAT CAPIT N');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('O','LAT CAPIT O');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('P','LAT CAPIT P');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('Q','LAT CAPIT Q');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('R','LAT CAPIT R');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('S','LAT CAPIT S');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('T','LAT CAPIT T');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('U','LAT CAPIT U');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('V','LAT CAPIT V');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('W','LAT CAPIT W');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('X','LAT CAPIT X');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('Y','LAT CAPIT Y');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES ('Z','LAT CAPIT Z');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Á','CYR SMALL A');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Â','CYR SMALL BE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'×','CYR SMALL VE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ç','CYR SMALL GE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ä','CYR SMALL DE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Å','CYR SMALL IE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'£','CYR SMALL IO');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ö','CYR SMALL ZHE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ú','CYR SMALL ZE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'É','CYR SMALL I');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ë','CYR SMALL KA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ì','CYR SMALL EL');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Í','CYR SMALL EM');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Î','CYR SMALL EN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ï','CYR SMALL O');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ð','CYR SMALL PE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ò','CYR SMALL ER');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ó','CYR SMALL ES');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ô','CYR SMALL TE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Õ','CYR SMALL U');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Æ','CYR SMALL EF');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'È','CYR SMALL HA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ã','CYR SMALL TSE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Þ','CYR SMALL CHE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Û','CYR SMALL SHA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ý','CYR SMALL SCHA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ß','CYR SMALL HARD SIGN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ù','CYR SMALL YERU');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ø','CYR SMALL SOFT SIGN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ü','CYR SMALL E');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'À','CYR SMALL YU');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'Ñ','CYR SMALL YA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'á','CYR CAPIT A');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'â','CYR CAPIT BE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'÷','CYR CAPIT VE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ç','CYR CAPIT GE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ä','CYR CAPIT DE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'å','CYR CAPIT IE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'³','CYR CAPIT IO');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ö','CYR CAPIT ZHE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ú','CYR CAPIT ZE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'é','CYR CAPIT I');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ë','CYR CAPIT KA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ì','CYR CAPIT EL');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'í','CYR CAPIT EM');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'î','CYR CAPIT EN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ï','CYR CAPIT O');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ð','CYR CAPIT PE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ò','CYR CAPIT ER');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ó','CYR CAPIT ES');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ô','CYR CAPIT TE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'õ','CYR CAPIT U');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'æ','CYR CAPIT EF');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'è','CYR CAPIT HA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ã','CYR CAPIT TSE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'þ','CYR CAPIT CHE');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'û','CYR CAPIT SHA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ý','CYR CAPIT SCHA');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ÿ','CYR CAPIT HARD SIGN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ù','CYR CAPIT YERU');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ø','CYR CAPIT SOFT SIGN');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ü','CYR CAPIT E');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'à','CYR CAPIT YU');
+INSERT INTO t1 (koi8_ru_f,comment) VALUES (_koi8r'ñ','CYR CAPIT YA');
+
+SET CHARACTER SET utf8;
+SELECT koi8_ru_f,MIN(comment),COUNT(*) FROM t1 GROUP BY 1;
+
+ALTER TABLE t1 ADD utf8_f CHAR(32) CHARACTER SET utf8 NOT NULL;
+UPDATE t1 SET utf8_f=CONVERT(koi8_ru_f USING utf8);
+SET CHARACTER SET koi8r;
+SELECT * FROM t1;
+
+#
+# codecovarage for Item_func_conv_charset3
+#
+select CONVERT(koi8_ru_f, 'cp1251_general_ci', 'utf8_general_ci'), comment from t1;
+explain extended select CONVERT(koi8_ru_f, 'cp1251_general_ci', 'utf8_general_ci'), comment from t1;
+
+ALTER TABLE t1 ADD bin_f CHAR(32) BYTE NOT NULL;
+UPDATE t1 SET bin_f=koi8_ru_f;
+SELECT COUNT(DISTINCT bin_f),COUNT(DISTINCT koi8_ru_f),COUNT(DISTINCT utf8_f) FROM t1;
+
+SELECT koi8_ru_f,MIN(comment) FROM t1 GROUP BY 1;
+SELECT utf8_f,MIN(comment) FROM t1 GROUP BY 1;
+SELECT DISTINCT koi8_ru_f FROM t1;
+SELECT DISTINCT utf8_f FROM t1;
+SELECT lower(koi8_ru_f) FROM t1 ORDER BY 1 DESC;
+SELECT lower(utf8_f) FROM t1 ORDER BY 1 DESC;
+
+SELECT t11.comment,t12.comment
+FROM t1 t11,t1 t12 WHERE CONVERT(t11.koi8_ru_f USING utf8)=t12.utf8_f
+ORDER BY t11.koi8_ru_f,t11.comment,t12.comment;
+
+SELECT t11.comment,t12.comment
+FROM t1 t11,t1 t12
+WHERE t11.koi8_ru_f=CONVERT(t12.utf8_f USING koi8r)
+ORDER BY t12.utf8_f,t11.comment,t12.comment;
+
+SET CHARACTER SET utf8;
+ALTER TABLE t1 ADD ucs2_f CHAR(32) CHARACTER SET ucs2;
+
+--disable_warnings
+ALTER TABLE t1 CHANGE ucs2_f ucs2_f CHAR(32) UNICODE NOT NULL;
+--enable_warnings
+
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0391,'GREEK CAPIT ALPHA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0392,'GREEK CAPIT BETA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0393,'GREEK CAPIT GAMMA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0394,'GREEK CAPIT DELTA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0395,'GREEK CAPIT EPSILON');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B1,'GREEK SMALL ALPHA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B2,'GREEK SMALL BETA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B3,'GREEK SMALL GAMMA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B4,'GREEK SMALL DELTA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x03B5,'GREEK SMALL EPSILON');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0531,'ARMENIAN CAPIT AYB');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0532,'ARMENIAN CAPIT BEN');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0533,'ARMENIAN CAPIT GIM');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0534,'ARMENIAN CAPIT DA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0535,'ARMENIAN CAPIT ECH');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0536,'ARMENIAN CAPIT ZA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0561,'ARMENIAN SMALL YAB');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0562,'ARMENIAN SMALL BEN');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0563,'ARMENIAN SMALL GIM');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0564,'ARMENIAN SMALL DA');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0565,'ARMENIAN SMALL ECH');
+INSERT INTO t1 (ucs2_f,comment) VALUES (0x0566,'ARMENIAN SMALL ZA');
+
+ALTER TABLE t1 ADD armscii8_f CHAR(32) CHARACTER SET armscii8 NOT NULL;
+ALTER TABLE t1 ADD greek_f CHAR(32) CHARACTER SET greek NOT NULL;
+UPDATE t1 SET greek_f=CONVERT(ucs2_f USING greek) WHERE comment LIKE _latin2'GRE%';
+UPDATE t1 SET armscii8_f=CONVERT(ucs2_f USING armscii8) WHERE comment LIKE _latin2'ARM%';
+UPDATE t1 SET utf8_f=CONVERT(ucs2_f USING utf8) WHERE utf8_f=_utf8'';
+UPDATE t1 SET ucs2_f=CONVERT(utf8_f USING ucs2) WHERE ucs2_f=_ucs2'';
+SELECT * FROM t1;
+SET CHARACTER SET 'binary';
+SELECT * FROM t1;
+SELECT min(comment),count(*) FROM t1 GROUP BY ucs2_f;
+DROP TABLE t1;
diff --git a/mysql-test/t/ctype_mb.test b/mysql-test/t/ctype_mb.test
new file mode 100644
index 00000000000..b0ccab8e345
--- /dev/null
+++ b/mysql-test/t/ctype_mb.test
@@ -0,0 +1,26 @@
+#
+# Test of alter table
+#
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+CREATE TABLE t1 SELECT _utf8'test' as c1, _utf8'тест' as c2;
+SHOW CREATE TABLE t1;
+DELETE FROM t1;
+ALTER TABLE t1 ADD c3 CHAR(4) CHARACTER SET utf8;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('aaaabbbbccccdddd','aaaabbbbccccdddd','aaaabbbbccccdddd');
+SELECT * FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a CHAR(4) CHARACTER SET utf8, KEY key_a(a(3)));
+SHOW CREATE TABLE t1;
+SHOW KEYS FROM t1;
+ALTER TABLE t1 CHANGE a a CHAR(4);
+SHOW CREATE TABLE t1;
+SHOW KEYS FROM t1;
+ALTER TABLE t1 CHANGE a a CHAR(4) CHARACTER SET utf8;
+SHOW CREATE TABLE t1;
+SHOW KEYS FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test
new file mode 100644
index 00000000000..2f08e021df2
--- /dev/null
+++ b/mysql-test/t/ctype_recoding.test
@@ -0,0 +1,52 @@
+SET CHARACTER SET koi8r;
+
+--disable_warnings
+DROP TABLE IF EXISTS ÔÁÂÌÉÃÁ, t1;
+--enable_warnings
+
+SET CHARACTER SET koi8r;
+CREATE TABLE t1 (a CHAR(10) CHARACTER SET cp1251) SELECT _koi8r'ÐÒÏÂÁ' AS a;
+SHOW CREATE TABLE t1;
+SELECT a FROM t1;
+SELECT HEX(a) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE `ÔÁÂÌÉÃÁ`
+(
+ ÐÏÌÅ CHAR(32) CHARACTER SET koi8r NOT NULL COMMENT "ËÏÍÍÅÎÔÁÒÉÊ ÐÏÌÑ"
+) COMMENT "ËÏÍÍÅÎÔÁÒÉÊ ÔÁÂÌÉÃÙ";
+
+SHOW TABLES;
+SHOW CREATE TABLE ÔÁÂÌÉÃÁ;
+SHOW FIELDS FROM ÔÁÂÌÉÃÁ;
+
+SET CHARACTER SET cp1251;
+SHOW TABLES;
+SHOW CREATE TABLE òàáëèöà;
+SHOW FIELDS FROM òàáëèöà;
+
+
+SET CHARACTER SET utf8;
+SHOW TABLES;
+SHOW CREATE TABLE таблОца;
+SHOW FIELDS FROM таблОца;
+
+SET CHARACTER SET koi8r;
+DROP TABLE ÔÁÂÌÉÃÁ;
+SET CHARACTER SET default;
+
+SET CHARACTER SET koi8r;
+CREATE DATABASE ÔÅÓÔ;
+USE ÔÅÓÔ;
+SHOW TABLES;
+SHOW TABLES IN ÔÅÓÔ;
+SET CHARACTER SET cp1251;
+SHOW TABLES;
+SHOW TABLES IN òåñò;
+SET CHARACTER SET koi8r;
+DROP DATABASE ÔÅÓÔ;
+
+SET NAMES koi8r;
+SELECT hex('ÔÅÓÔ');
+SET character_set_connection=cp1251;
+SELECT hex('ÔÅÓÔ');
diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test
new file mode 100644
index 00000000000..0457c204e32
--- /dev/null
+++ b/mysql-test/t/ctype_ucs.test
@@ -0,0 +1,194 @@
+-- source include/have_ucs2.inc
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+SET CHARACTER SET koi8r;
+
+#
+# Check that 0x20 is only trimmed when it is
+# a part of real SPACE character, not just a part
+# of a multibyte sequence.
+# Note, CYRILLIC LETTER ER is used as an example, which
+# is stored as 0x0420 in UCS2, thus contains 0x20 in the
+# low byte. The second character is THREE-PER-M, U+2004,
+# which contains 0x20 in the high byte.
+#
+
+CREATE TABLE t1 (word VARCHAR(64) CHARACTER SET ucs2);
+INSERT INTO t1 VALUES (_koi8r'ò'), (X'2004');
+SELECT hex(word) FROM t1 ORDER BY word;
+DELETE FROM t1;
+
+#
+# Check that real spaces are correctly trimmed.
+#
+
+INSERT INTO t1 VALUES (X'042000200020'), (X'200400200020');
+SELECT hex(word) FROM t1 ORDER BY word;
+DROP TABLE t1;
+
+#
+# Check LPAD/RPAD
+#
+SELECT LPAD(_ucs2 X'0420',10,_ucs2 X'0421');
+SELECT LPAD(_ucs2 X'0420',10,_ucs2 X'04210422');
+SELECT LPAD(_ucs2 X'0420',10,_ucs2 X'042104220423');
+SELECT LPAD(_ucs2 X'0420042104220423042404250426042704280429042A042B',10,_ucs2 X'042104220423');
+
+SELECT RPAD(_ucs2 X'0420',10,_ucs2 X'0421');
+SELECT RPAD(_ucs2 X'0420',10,_ucs2 X'04210422');
+SELECT RPAD(_ucs2 X'0420',10,_ucs2 X'042104220423');
+SELECT RPAD(_ucs2 X'0420042104220423042404250426042704280429042A042B',10,_ucs2 X'042104220423');
+
+CREATE TABLE t1 SELECT
+LPAD(_ucs2 X'0420',10,_ucs2 X'0421') l,
+RPAD(_ucs2 X'0420',10,_ucs2 X'0421') r;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+######################################################
+#
+# Test of like
+#
+
+SET NAMES koi8r;
+SET character_set_connection=ucs2;
+
+create table t1 (a varchar(10) character set ucs2, key(a));
+insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
+explain select * from t1 where a like 'abc%';
+explain select * from t1 where a like concat('abc','%');
+select * from t1 where a like "abc%";
+select * from t1 where a like concat("abc","%");
+select * from t1 where a like "ABC%";
+select * from t1 where a like "test%";
+select * from t1 where a like "te_t";
+select * from t1 where a like "%a%";
+select * from t1 where a like "%abcd%";
+select * from t1 where a like "%abc\d%";
+drop table t1;
+
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET ucs2);
+INSERT INTO t1 VALUES ('ÆÙ×Á'),('æÙ×Á'),('Æù×Á'),('ÆÙ÷Á'),('ÆÙ×á'),('æù÷á');
+INSERT INTO t1 VALUES ('ÆÙ×ÁÐÒÏÌÄÖ'),('æÙ×ÁÐÒÏÌÄÖ'),('Æù×ÁÐÒÏÌÄÖ'),('ÆÙ÷ÁÐÒÏÌÄÖ');
+INSERT INTO t1 VALUES ('ÆÙ×áÐÒÏÌÄÖ'),('ÆÙ×ÁðÒÏÌÄÖ'),('ÆÙ×ÁÐòÏÌÄÖ'),('ÆÙ×ÁÐÒïÌÄÖ');
+INSERT INTO t1 VALUES ('ÆÙ×ÁÐÒÏìÄÖ'),('ÆÙ×ÁÐÒÏÌäÖ'),('ÆÙ×ÁÐÒÏÌÄö'),('æù÷áðòïìäö');
+SELECT * FROM t1 WHERE a LIKE '%Æù×Á%';
+SELECT * FROM t1 WHERE a LIKE '%Æù×%';
+SELECT * FROM t1 WHERE a LIKE 'Æù×Á%';
+SELECT * FROM t1 WHERE a LIKE 'Æù×Á%' COLLATE ucs2_bin;
+DROP TABLE t1;
+
+#
+# Bug 1181
+#
+CREATE TABLE t1 (word varchar(64) NOT NULL, PRIMARY KEY (word))
+TYPE=MyISAM CHARACTER SET ucs2 COLLATE ucs2_general_ci;
+INSERT INTO t1 (word) VALUES ("cat");
+SELECT * FROM t1 WHERE word LIKE "c%";
+SELECT * FROM t1 WHERE word LIKE "ca_";
+SELECT * FROM t1 WHERE word LIKE "cat";
+SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630025';
+SELECT * FROM t1 WHERE word LIKE _ucs2 x'00630061005F';
+DROP TABLE t1;
+
+######################################################
+
+#
+# Bug 1264
+#
+# Description:
+#
+# When using a ucs2 table in MySQL,
+# either with ucs2_general_ci or ucs2_bin collation,
+# words are returned in an incorrect order when using ORDER BY
+# on an _indexed_ CHAR or VARCHAR column. They are sorted with
+# the longest word *first* instead of last. I.E. The word "aardvark"
+# is in the results before the word "a".
+#
+# If there is no index for the column, the problem does not occur.
+#
+# Interestingly, if there is no second column, the words are returned
+# in the correct order.
+#
+# According to EXPLAIN, it looks like when the output includes columns that
+# are not part of the index sorted on, it does a filesort, which fails.
+# Using a straight index yields correct results.
+
+SET NAMES latin1;
+
+#
+# Two fields, index
+#
+
+CREATE TABLE t1 (
+ word VARCHAR(64),
+ bar INT(11) default 0,
+ PRIMARY KEY (word))
+ TYPE=MyISAM
+ CHARSET ucs2
+ COLLATE ucs2_general_ci ;
+
+INSERT INTO t1 (word) VALUES ("aar");
+INSERT INTO t1 (word) VALUES ("a");
+INSERT INTO t1 (word) VALUES ("aardvar");
+INSERT INTO t1 (word) VALUES ("aardvark");
+INSERT INTO t1 (word) VALUES ("aardvara");
+INSERT INTO t1 (word) VALUES ("aardvarz");
+EXPLAIN SELECT * FROM t1 ORDER BY word;
+SELECT * FROM t1 ORDER BY word;
+EXPLAIN SELECT word FROM t1 ORDER BY word;
+SELECT word FROM t1 ORDER by word;
+DROP TABLE t1;
+
+#
+# One field, index
+#
+
+CREATE TABLE t1 (
+ word VARCHAR(64) ,
+ PRIMARY KEY (word))
+ TYPE=MyISAM
+ CHARSET ucs2
+ COLLATE ucs2_general_ci;
+
+INSERT INTO t1 (word) VALUES ("aar");
+INSERT INTO t1 (word) VALUES ("a");
+INSERT INTO t1 (word) VALUES ("aardvar");
+INSERT INTO t1 (word) VALUES ("aardvark");
+INSERT INTO t1 (word) VALUES ("aardvara");
+INSERT INTO t1 (word) VALUES ("aardvarz");
+EXPLAIN SELECT * FROM t1 ORDER BY WORD;
+SELECT * FROM t1 ORDER BY word;
+DROP TABLE t1;
+
+
+#
+# Two fields, no index
+#
+
+CREATE TABLE t1 (
+ word TEXT,
+ bar INT(11) AUTO_INCREMENT,
+ PRIMARY KEY (bar))
+ TYPE=MyISAM
+ CHARSET ucs2
+ COLLATE ucs2_general_ci ;
+INSERT INTO t1 (word) VALUES ("aar");
+INSERT INTO t1 (word) VALUES ("a" );
+INSERT INTO t1 (word) VALUES ("aardvar");
+INSERT INTO t1 (word) VALUES ("aardvark");
+INSERT INTO t1 (word) VALUES ("aardvara");
+INSERT INTO t1 (word) VALUES ("aardvarz");
+EXPLAIN SELECT * FROM t1 ORDER BY word;
+SELECT * FROM t1 ORDER BY word;
+EXPLAIN SELECT word FROM t1 ORDER BY word;
+SELECT word FROM t1 ORDER BY word;
+DROP TABLE t1;
+
+#
+# END OF Bug 1264 test
+#
+########################################################
+
diff --git a/mysql-test/t/ctype_ujis-master.opt b/mysql-test/t/ctype_ujis-master.opt
deleted file mode 100644
index 1f4183d5027..00000000000
--- a/mysql-test/t/ctype_ujis-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---default-character-set=ujis
diff --git a/mysql-test/t/ctype_ujis.test b/mysql-test/t/ctype_ujis.test
index cd1dc965000..bcf6507b4c7 100644
--- a/mysql-test/t/ctype_ujis.test
+++ b/mysql-test/t/ctype_ujis.test
@@ -1,13 +1,43 @@
+-- source include/have_ujis.inc
+
#
# Tests with the ujis character set
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
+set names ujis;
#
# Test problem with LEFT()
#
-create table t1 (c text);
+create table t1 (c text character set ujis);
insert into t1 values (0xa4a2),(0xa4a3);
select hex(left(c,1)) from t1 group by c;
drop table t1;
+
+#
+#
+#
+select locate(0xa2a1,0xa1a2a1a3);
+select locate(_ujis 0xa2a1,_ujis 0xa1a2a1a3);
+select locate(_ujis 0xa2a1,_ujis 0xa1a2a1a3 collate ujis_bin);
+select locate('he','hello');
+select locate('he','hello',2);
+select locate('lo','hello',2);
+select locate('HE','hello');
+select locate('HE','hello',2);
+select locate('LO','hello',2);
+select locate('HE','hello' collate ujis_bin);
+select locate('HE','hello' collate ujis_bin,2);
+select locate('LO','hello' collate ujis_bin,2);
+select locate(_ujis 0xa1a3,_ujis 0xa1a2a1a3);
+
+select 0xa1a2a1a3 like concat(_binary'%',0xa2a1,_binary'%');
+select _ujis 0xa1a2a1a3 like concat(_ujis'%',_ujis 0xa2a1, _ujis'%');
+select _ujis 0xa1a2a1a3 like concat(_ujis'%',_ujis 0xa2a1, _ujis'%') collate ujis_bin;
+select 'a' like 'a';
+select 'A' like 'a';
+select 'A' like 'a' collate ujis_bin;
diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
new file mode 100644
index 00000000000..54d934b66db
--- /dev/null
+++ b/mysql-test/t/ctype_utf8.test
@@ -0,0 +1,37 @@
+#
+# Tests with the utf8 character set
+#
+
+set names utf8;
+
+select left(_utf8 0xD0B0D0B1D0B2,1);
+select right(_utf8 0xD0B0D0B2D0B2,1);
+
+select locate('he','hello');
+select locate('he','hello',2);
+select locate('lo','hello',2);
+select locate('HE','hello');
+select locate('HE','hello',2);
+select locate('LO','hello',2);
+select locate('HE','hello' collate utf8_bin);
+select locate('HE','hello' collate utf8_bin,2);
+select locate('LO','hello' collate utf8_bin,2);
+
+select locate(_utf8 0xD0B1, _utf8 0xD0B0D0B1D0B2);
+select locate(_utf8 0xD091, _utf8 0xD0B0D0B1D0B2);
+select locate(_utf8 0xD0B1, _utf8 0xD0B0D091D0B2);
+select locate(_utf8 0xD091, _utf8 0xD0B0D0B1D0B2 collate utf8_bin);
+select locate(_utf8 0xD0B1, _utf8 0xD0B0D091D0B2 collate utf8_bin);
+
+select length(_utf8 0xD0B1), bit_length(_utf8 0xD0B1), char_length(_utf8 0xD0B1);
+
+select 'a' like 'a';
+select 'A' like 'a';
+select 'A' like 'a' collate utf8_bin;
+select _utf8 0xD0B0D0B1D0B2 like concat(_utf8'%',_utf8 0xD0B1,_utf8 '%');
+
+#
+# Fix this, it should return 1:
+#
+#select _utf8 0xD0B0D0B1D0B2 like concat(_utf8'%',_utf8 0xD091,_utf8 '%');
+#
diff --git a/mysql-test/t/date_formats-master.opt b/mysql-test/t/date_formats-master.opt
new file mode 100644
index 00000000000..ab243fe729c
--- /dev/null
+++ b/mysql-test/t/date_formats-master.opt
@@ -0,0 +1 @@
+--date-format=%d.%m.%Y --time-format=%H.%i.%s
diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test
new file mode 100644
index 00000000000..d9219d3ac2e
--- /dev/null
+++ b/mysql-test/t/date_formats.test
@@ -0,0 +1,202 @@
+#
+# Test of date format functions
+#
+
+--disable-warnings
+drop table if exists t1;
+--enable-warnings
+
+SHOW GLOBAL VARIABLES LIKE "%_format%";
+SHOW SESSION VARIABLES LIKE "%_format%";
+
+#
+# Test setting a lot of different formats to see which formats are accepted and
+# which aren't
+#
+
+SET time_format='%H%i%s';
+SET time_format='%H:%i:%s.%f';
+SET time_format='%h-%i-%s.%f%p';
+SET time_format='%h:%i:%s.%f %p';
+SET time_format='%h:%i:%s%p';
+
+SET date_format='%Y%m%d';
+SET date_format='%Y.%m.%d';
+SET date_format='%d.%m.%Y';
+SET date_format='%m-%d-%Y';
+
+set datetime_format= '%Y%m%d%H%i%s';
+set datetime_format= '%Y-%m-%d %H:%i:%s';
+set datetime_format= '%m-%d-%y %H:%i:%s.%f';
+set datetime_format= '%d-%m-%Y %h:%i:%s%p';
+set datetime_format= '%H:%i:%s %Y-%m-%d';
+set datetime_format= '%H:%i:%s.%f %m-%d-%Y';
+set datetime_format= '%h:%i:%s %p %Y-%m-%d';
+set datetime_format= '%h:%i:%s.%f %p %Y-%m-%d';
+
+SHOW SESSION VARIABLES LIKE "%format";
+
+--error 1231
+SET time_format='%h:%i:%s';
+--error 1231
+SET time_format='%H %i:%s';
+--error 1231
+SET time_format='%H::%i:%s';
+--error 1231
+SET time_format='%H:%i:%s%f';
+--error 1231
+SET time_format='%H:%i.%f:%s';
+--error 1231
+SET time_format='%H:%i:%s%p';
+--error 1231
+SET time_format='%h:%i:%s.%f %p %Y-%m-%d';
+--error 1231
+SET time_format='%H%i%s.%f';
+--error 1231
+SET time_format='%H:%i-%s.%f';
+--error 1231
+SET date_format='%d.%m.%d';
+--error 1231
+SET datetime_format='%h.%m.%y %d.%i.%s';
+--error 1231
+set datetime_format= '%H:%i:%s.%f %p %Y-%m-%d';
+
+#
+# Test GLOBAL values
+
+set GLOBAL datetime_format= '%H:%i:%s %Y-%m-%d';
+SET SESSION datetime_format=default;
+select @@global.datetime_format, @@session.datetime_format;
+SET GLOBAL datetime_format=default;
+SET SESSION datetime_format=default;
+select @@global.datetime_format, @@session.datetime_format;
+
+SET GLOBAL date_format=default;
+SET GLOBAL time_format=default;
+SET GLOBAL datetime_format=default;
+SET time_format=default;
+SET date_format=default;
+SET datetime_format=default;
+
+#
+# The following tests will work only when we at some point will enable
+# dynamic changing of formats
+#
+
+# SET date_format='%d.%m.%Y';
+# select CAST('01.01.2001' as DATE) as a;
+# SET datetime_format='%d.%m.%Y %H.%i.%s';
+# select CAST('01.01.2001 05.12.06' as DATETIME) as a;
+# SET time_format='%H.%i.%s';
+# select CAST('05.12.06' as TIME) as a;
+#
+# SET datetime_format='%d.%m.%Y %h:%i:%s %p';
+# select CAST('01.01.2001 05:12:06AM' as DATETIME) as a;
+# select CAST('01.01.2001 05:12:06 PM' as DATETIME) as a;
+#
+# SET time_format='%h:%i:%s %p';
+# select CAST('05:12:06 AM' as TIME) as a;
+# select CAST('05:12:06.1234PM' as TIME) as a;
+#
+# SET time_format='%h.%i.%s %p';
+# SET date_format='%d.%m.%y';
+# SET datetime_format='%d.%m.%y %h.%i.%s %p';
+# select CAST('12-12-06' as DATE) as a;
+#
+# select adddate('01.01.97 11.59.59.000001 PM', 10);
+# select datediff('31.12.97 11.59:59.000001 PM','01.01.98');
+# select weekofyear('31.11.97 11:59:59.000001 PM');
+# select makedate(1997,1);
+# select addtime('31.12.97 11.59.59.999999 PM', '1 1.1.1.000002');
+# select maketime(23,11,12);
+# select timediff('01.01.97 11:59:59.000001 PM','31.12.95 11:59:59.000002 PM');
+#
+# SET time_format='%i:%s:%H';
+# select cast(str_to_date('15-01-2001 12:59:59', '%d-%m-%Y %H:%i:%S') as TIME);
+
+#
+# Test of str_to_date
+#
+
+select str_to_date(concat('15-01-2001',' 2:59:58.999'),
+ concat('%d-%m-%Y',' ','%H:%i:%s.%f'));
+
+create table t1 (date char(30), format char(30) not null);
+insert into t1 values
+('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'),
+('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S'),
+('2003-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'),
+('2003-01-02 01:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f%p'),
+('2003-01-02 02:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f %p'),
+('2003-01-02 12:11:12.12345 am', '%Y-%m-%d %h:%i:%S.%f%p'),
+('2003-01-02 11:11:12Pm', '%Y-%m-%d %h:%i:%S%p'),
+('10:20:10', '%H:%i:%s'),
+('10:20:10', '%h:%i:%s.%f'),
+('10:20:10AM', '%h:%i:%s%p'),
+('10:20:10.44AM', '%h:%i:%s.%f%p'),
+('15-01-2001 12:59:58', '%d-%m-%Y %H:%i:%S'),
+('15 September 2001', '%d %M %Y'),
+('15 SEPTEMB 2001', '%d %M %Y'),
+('15 MAY 2001', '%d %b %Y'),
+('Sunday 15 MAY 2001', '%W %d %b %Y'),
+('Sund 15 MAY 2001', '%W %d %b %Y'),
+('Tuesday 00 2002', '%W %U %Y'),
+('Thursday 53 1998', '%W %u %Y'),
+('15-01-2001', '%d-%m-%Y %H:%i:%S'),
+('15-01-20', '%d-%m-%y'),
+('15-2001-1', '%d-%Y-%c');
+
+# Use through protocol functions
+select date,format,str_to_date(date, format) as str_to_date from t1;
+# Use as a string
+select date,format,concat('',str_to_date(date, format)) as con from t1;
+# Use as datetime
+select date,format,cast(str_to_date(date, format) as datetime) as datetime from t1;
+select date,format,DATE(str_to_date(date, format)) as date2 from t1;
+select date,format,TIME(str_to_date(date, format)) as time from t1;
+select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1;
+
+# Test wrong dates
+
+truncate table t1;
+insert into t1 values
+('2003-01-02 10:11:12 PM', '%Y-%m-%d %H:%i:%S %p'),
+('2003-01-02 10:11:12.123456', '%Y-%m-%d %h:%i:%S %p'),
+('2003-01-02 10:11:12AM', '%Y-%m-%d %h:%i:%S.%f %p'),
+('2003-01-02 10:11:12AN', '%Y-%m-%d %h:%i:%S%p'),
+('2003-01-02 10:11:12 PM', '%y-%m-%d %H:%i:%S %p'),
+('10:20:10AM', '%H:%i:%s%p'),
+('15 Septembei 2001', '%d %M %Y'),
+('15 Ju 2001', '%d %M %Y'),
+('Sund 15 MA', '%W %d %b %Y'),
+('Sunday 01 2001', '%W %V %X'),
+('Thursdai 12 1998', '%W %u %Y'),
+(NULL, get_format(DATE,'USA')),
+('Tuesday 52 2001', '%W %V %X');
+select date,format,str_to_date(date, format) as str_to_date from t1;
+select date,format,concat(str_to_date(date, format),'') as con from t1;
+
+# Test 'maybe' date formats and 'strange but correct' results
+
+truncate table t1;
+insert into t1 values
+('10:20:10AM', '%h:%i:%s'),
+('2003-01-02 10:11:12', '%Y-%m-%d %h:%i:%S'),
+('03-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p');
+
+select date,format,str_to_date(date, format) as str_to_date from t1;
+select date,format,concat(str_to_date(date, format),'') as con from t1;
+
+drop table t1;
+
+#
+# Test of get_format
+#
+
+select get_format(DATE, 'USA') as a;
+select get_format(TIME, 'internal') as a;
+select get_format(DATETIME, 'eur') as a;
+select get_format(DATE, 'TEST') as a;
+select str_to_date('15-01-2001 12:59:59', GET_FORMAT(DATE,'USA'));
+
+explain extended select makedate(1997,1), addtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),subtime("31.12.97 11.59.59.999999 PM", "1 1.1.1.000002"),timediff("01.01.97 11:59:59.000001 PM","31.12.95 11:59:59.000002 PM"),cast(str_to_date("15-01-2001 12:59:59", "%d-%m-%Y %H:%i:%S") as TIME), maketime(23,11,12),microsecond("1997-12-31 23:59:59.000001");
diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test
index 67111ea1734..4cf26b330c6 100644
--- a/mysql-test/t/delayed.test
+++ b/mysql-test/t/delayed.test
@@ -3,7 +3,9 @@
# (Can't be tested with purify :( )
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1 (a char(10), tmsp timestamp);
insert into t1 set a = 1;
insert delayed into t1 set a = 2;
diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test
index 904d959d148..c529994f31b 100644
--- a/mysql-test/t/delete.test
+++ b/mysql-test/t/delete.test
@@ -2,7 +2,9 @@
# Check for problems with delete
#
-drop table if exists t1;
+--disable_warnings
+drop table if exists t1,t11,t12,t2;
+--enable_warnings
CREATE TABLE t1 (a tinyint(3), b tinyint(5));
INSERT INTO t1 VALUES (1,1);
INSERT LOW_PRIORITY INTO t1 VALUES (1,2);
@@ -36,6 +38,15 @@ insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(2
delete from t1 where a=27;
drop table t1;
+CREATE TABLE `t1` (
+ `i` int(10) NOT NULL default '0',
+ `i2` int(10) NOT NULL default '0',
+ PRIMARY KEY (`i`)
+);
+-- error 1054
+DELETE FROM t1 USING t1 WHERE post='1';
+drop table t1;
+
#
# CHAR(0) bug - not actually DELETE bug, but anyway...
#
@@ -61,3 +72,29 @@ select count(*) from t1;
drop table t1;
+#
+# IGNORE option
+#
+create table t11 (a int NOT NULL, b int, primary key (a));
+create table t12 (a int NOT NULL, b int, primary key (a));
+create table t2 (a int NOT NULL, b int, primary key (a));
+insert into t11 values (0, 10),(1, 11),(2, 12);
+insert into t12 values (33, 10),(0, 11),(2, 12);
+insert into t2 values (1, 21),(2, 12),(3, 23);
+select * from t11;
+select * from t12;
+select * from t2;
+-- error 1241
+delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
+select * from t11;
+select * from t12;
+delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a);
+select * from t11;
+select * from t12;
+insert into t11 values (2, 12);
+-- error 1241
+delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
+select * from t11;
+delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a);
+select * from t11;
+drop table t11, t12, t2;
diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test
new file mode 100644
index 00000000000..ee50ffda476
--- /dev/null
+++ b/mysql-test/t/derived.test
@@ -0,0 +1,134 @@
+# Initialize
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
+select * from (select 2 from DUAL) b;
+-- error 1054
+SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
+-- error 1054
+SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
+CREATE TABLE t1 (a int not null, b char (10) not null);
+insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
+CREATE TABLE t2 (a int not null, b char (10) not null);
+insert into t2 values (3,'c'),(4,'d'),(5,'f'),(6,'e');
+select t1.a,t3.y from t1,(select a as y from t2 where b='c') as t3 where t1.a = t3.y;
+select t1.a,t3.a from t1,(select * from t2 where b='c') as t3 where t1.a = t3.a;
+CREATE TABLE t3 (a int not null, b char (10) not null);
+insert into t3 values (3,'f'),(4,'y'),(5,'z'),(6,'c');
+select t1.a,t4.y from t1,(select t2.a as y from t2,(select t3.b from t3 where t3.a>3) as t5 where t2.b=t5.b) as t4 where t1.a = t4.y;
+--error 1054
+SELECT a FROM (SELECT 1 FROM (SELECT 1) a HAVING a=1) b;
+--error 1052
+SELECT a,b as a FROM (SELECT '1' as a,'2' as b) b HAVING a=1;
+SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=2;
+SELECT a,2 as a FROM (SELECT '1' as a) b HAVING a=1;
+--error 1054
+SELECT 1 FROM (SELECT 1) a WHERE a=2;
+--error 1054
+SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) as a;
+select * from t1 as x1, (select * from t1) as x2;
+explain select * from t1 as x1, (select * from t1) as x2;
+drop table if exists t2,t3;
+select * from (select 1) as a;
+select a from (select 1 as a) as b;
+select 1 from (select 1) as a;
+select * from (select * from t1 union select * from t1) a;
+select * from (select * from t1 union all select * from t1) a;
+explain select * from (select * from t1 union select * from t1) a;
+explain select * from (select * from t1 union all select * from t1) a;
+CREATE TABLE t2 (a int not null);
+insert into t2 values(1);
+select * from (select * from t1 where t1.a=(select a from t2 where t2.a=t1.a)) a;
+select * from (select * from t1 where t1.a=(select t2.a from t2 where t2.a=t1.a) union select t1.a, t1.b from t1) a;
+explain select * from (select * from t1,t2 where t1.a=t2.a) t1;
+drop table t1, t2;
+create table t1(a int not null, t char(8), index(a));
+disable_query_log;
+let $1 = 10000;
+while ($1)
+ {
+ eval insert into t1 values ($1,'$1');
+ dec $1;
+ }
+enable_query_log;
+SELECT * FROM (SELECT * FROM t1) as b ORDER BY a ASC LIMIT 0,20;
+explain select count(*) from t1 as tt1, (select * from t1) as tt2;
+drop table t1;
+SELECT * FROM (SELECT (SELECT * FROM (SELECT 1 as a) as a )) as b;
+select * from (select 1 as a) b left join (select 2 as a) c using(a);
+--error 1054
+SELECT * FROM (SELECT 1 UNION SELECT a) b;
+--error 1054
+SELECT 1 as a FROM (SELECT a UNION SELECT 1) b;
+--error 1054
+SELECT 1 as a FROM (SELECT 1 UNION SELECT a) b;
+--error 1054
+select 1 from (select 2) a order by 0;
+
+#
+# Test of explain (bug #251)
+#
+
+create table t1 (id int);
+insert into t1 values (1),(2),(3);
+describe select * from (select * from t1 group by id) bar;
+drop table t1;
+
+#
+# test->used_keys test for derived tables
+#
+create table t1 (mat_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, matintnum CHAR(6) NOT NULL, test MEDIUMINT UNSIGNED NULL);
+create table t2 (mat_id MEDIUMINT UNSIGNED NOT NULL, pla_id MEDIUMINT UNSIGNED NOT NULL);
+insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4), (NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8), (NULL, 'i', 9);
+insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105);
+
+SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
+SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
+
+explain SELECT STRAIGHT_JOIN d.pla_id, m2.mat_id FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
+explain SELECT STRAIGHT_JOIN d.pla_id, m2.test FROM t1 m2 INNER JOIN (SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id) d ON d.matintnum=m2.matintnum;
+drop table t1,t2;
+
+#
+# derived table reference
+#
+SELECT a.x FROM (SELECT 1 AS x) AS a HAVING a.x = 1;
+
+#
+# Test for select if database is not selected.
+#
+# Connect without a database
+create table t1 select 1 as a;
+connect (con1,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,master.sock);
+connection con1;
+--error 1046
+select 2 as a from (select * from t1) b;
+use test;
+select 2 as a from (select * from t1) b;
+drop table t1;
+--error 1064
+select mail_id, if(folder.f_description!='', folder.f_description, folder.f_name) as folder_name, date, address_id, phrase, address, subject from folder, (select mail.mail_id as mail_id, date_format(mail.h_date, '%b %e, %Y %h:%i') as date, mail.folder_id, sender.address_id as address_id, sender.phrase as phrase, sender.address as address, mail.h_subject as subject from mail left join mxa as mxa_sender on mail.mail_id=mxa_sender.mail_id and mxa_sender.type='from' left join address as sender on mxa_sender.address_id=sender.address_id mxa as mxa_recipient, address as recipient, where 1 and mail.mail_id=mxa_recipient.mail_id and mxa_recipient.address_id=recipient.address_id and mxa_recipient.type='to' and match(sender.phrase, sender.address, sender.comment) against ('jeremy' in boolean mode) and match(recipient.phrase, recipient.address, recipient.comment) against ('monty' in boolean mode) order by mail.h_date desc limit 0, 25 ) as query where query.folder_id=folder.folder_id;
+
+#
+# UPDATE/DELETE/INSERT of derived tables
+#
+create table t1 (a int);
+insert into t1 values (1),(2),(3);
+-- error 1149
+update (select * from t1) as t1 set a = 5;
+-- error 1064
+delete from (select * from t1);
+-- error 1064
+insert into (select * from t1) values (5);
+drop table t1;
+
+#
+# deived tables with subquery inside all by one table
+#
+create table t1 (E1 INTEGER UNSIGNED NOT NULL, E2 INTEGER UNSIGNED NOT NULL, E3 INTEGER UNSIGNED NOT NULL, PRIMARY KEY(E1)
+);
+insert into t1 VALUES(1,1,1), (2,2,1);
+select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2;
+explain select count(*) from t1 INNER JOIN (SELECT A.E1, A.E2, A.E3 FROM t1 AS A WHERE A.E3 = (SELECT MAX(B.E3) FROM t1 AS B WHERE A.E2 = B.E2)) AS THEMAX ON t1.E1 = THEMAX.E2 AND t1.E1 = t1.E2;
+drop table t1;
diff --git a/mysql-test/t/dirty_close.test b/mysql-test/t/dirty_close.test
index 3ed22f26d5b..f965df8cfea 100644
--- a/mysql-test/t/dirty_close.test
+++ b/mysql-test/t/dirty_close.test
@@ -3,7 +3,11 @@ connect (con2,localhost,root,,);
connection con1;
dirty_close con1;
connection con2;
+
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (n int);
insert into t1 values (1),(2),(3);
select * from t1;
diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test
index 79770a17baa..56c00e7501c 100644
--- a/mysql-test/t/distinct.test
+++ b/mysql-test/t/distinct.test
@@ -3,7 +3,9 @@
# Bug with group by and not used fields
#
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
CREATE TABLE t1 (id int,facility char(20));
CREATE TABLE t2 (facility char(20));
@@ -198,7 +200,6 @@ drop table t1,t2,t3;
# This also test the case when one doesn't use all fields in GROUP BY.
#
-drop table if exists t1;
create table t1 (a int not null, b int not null, t time);
insert into t1 values (1,1,"00:06:15"),(1,2,"00:06:15"),(1,2,"00:30:15"),(1,3,"00:06:15"),(1,3,"00:30:15");
select a,sec_to_time(sum(time_to_sec(t))) from t1 group by a,b;
@@ -261,7 +262,7 @@ INSERT INTO t1 VALUES (128,0,33,33,8,':D','',996121863,1,0,2,996122850,2,0,0);
CREATE TABLE t2 (userid int(10) unsigned NOT NULL auto_increment, usergroupid smallint(5) unsigned NOT NULL default '0', username varchar(50) NOT NULL default '', password varchar(50) NOT NULL default '', email varchar(50) NOT NULL default '', styleid smallint(5) unsigned NOT NULL default '0', parentemail varchar(50) NOT NULL default '', coppauser smallint(6) NOT NULL default '0', homepage varchar(100) NOT NULL default '', icq varchar(20) NOT NULL default '', aim varchar(20) NOT NULL default '', yahoo varchar(20) NOT NULL default '', signature mediumtext NOT NULL, adminemail smallint(6) NOT NULL default '0', showemail smallint(6) NOT NULL default '0', invisible smallint(6) NOT NULL default '0', usertitle varchar(250) NOT NULL default '', customtitle smallint(6) NOT NULL default '0', joindate int(10) unsigned NOT NULL default '0', cookieuser smallint(6) NOT NULL default '0', daysprune smallint(6) NOT NULL default '0', lastvisit int(10) unsigned NOT NULL default '0', lastactivity int(10) unsigned NOT NULL default '0', lastpost int(10) unsigned NOT NULL default '0', posts smallint(5) unsigned NOT NULL default '0', timezoneoffset varchar(4) NOT NULL default '', emailnotification smallint(6) NOT NULL default '0', buddylist mediumtext NOT NULL, ignorelist mediumtext NOT NULL, pmfolders mediumtext NOT NULL, receivepm smallint(6) NOT NULL default '0', emailonpm smallint(6) NOT NULL default '0', pmpopup smallint(6) NOT NULL default '0', avatarid smallint(6) NOT NULL default '0', avatarrevision int(6) unsigned NOT NULL default '0', options smallint(6) NOT NULL default '15', birthday date NOT NULL default '0000-00-00', maxposts smallint(6) NOT NULL default '-1', startofweek smallint(6) NOT NULL default '1', ipaddress varchar(20) NOT NULL default '', referrerid int(10) unsigned NOT NULL default '0', nosessionhash smallint(6) NOT NULL default '0', autorefresh smallint(6) NOT NULL default '-1', messagepopup tinyint(2) NOT NULL default '0', inforum smallint(5) unsigned NOT NULL default '0', ratenum smallint(5) unsigned NOT NULL default '0', ratetotal smallint(5) unsigned NOT NULL default '0', allowrate smallint(5) unsigned NOT NULL default '1', PRIMARY KEY (userid), KEY usergroupid (usergroupid), KEY username (username), KEY inforum (inforum)) TYPE=MyISAM;
INSERT INTO t2 VALUES (33,6,'Kevin','0','kevin@stileproject.com',1,'',0,'http://www.stileproject.com','','','','',1,1,0,'Administrator',0,996120694,1,-1,1030996168,1031027028,1030599436,36,'-6',0,'','','',1,0,1,0,0,15,'0000-00-00',-1,1,'64.0.0.0',0,1,-1,0,0,4,19,1);
SELECT DISTINCT t1.*, t2.* FROM t1 LEFT JOIN t2 ON (t2.userid = t1.touserid);
-DROP TABLE IF EXISTS t1,t2;
+DROP TABLE t1,t2;
#
# test with const_item in ORDER BY
@@ -272,7 +273,7 @@ INSERT t1 VALUES (1,2,3);
CREATE TABLE t2 (a int primary key, b int, c int);
INSERT t2 VALUES (3,4,5);
SELECT DISTINCT t1.a, t2.b FROM t1, t2 WHERE t1.a=1 ORDER BY t2.c;
-DROP TABLE IF EXISTS t1,t2;
+DROP TABLE t1,t2;
#
# Test of LEFT() with distinct
@@ -284,3 +285,50 @@ INSERT INTO t1 VALUES (3, 'aaaaa');
INSERT INTO t1 VALUES (2, 'eeeeeee');
select distinct left(name,1) as name from t1;
drop table t1;
+
+#
+# Test case from sel000100
+#
+
+CREATE TABLE t1 (
+ ID int(11) NOT NULL auto_increment,
+ NAME varchar(75) DEFAULT '' NOT NULL,
+ LINK_ID int(11) DEFAULT '0' NOT NULL,
+ PRIMARY KEY (ID),
+ KEY NAME (NAME),
+ KEY LINK_ID (LINK_ID)
+);
+
+INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0);
+INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (2,'Jack',0);
+INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (3,'Bill',0);
+
+CREATE TABLE t2 (
+ ID int(11) NOT NULL auto_increment,
+ NAME varchar(150) DEFAULT '' NOT NULL,
+ PRIMARY KEY (ID),
+ KEY NAME (NAME)
+);
+
+SELECT DISTINCT
+ t2.id AS key_link_id,
+ t2.name AS link
+FROM t1
+LEFT JOIN t2 ON t1.link_id=t2.id
+GROUP BY t1.id
+ORDER BY link;
+drop table t1,t2;
+
+#
+# test case for #674
+#
+
+CREATE TABLE t1 (
+ html varchar(5) default NULL,
+ rin int(11) default '0',
+ out int(11) default '0'
+) TYPE=MyISAM;
+
+INSERT INTO t1 VALUES ('1',1,0);
+SELECT DISTINCT html,SUM(out)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin;
+drop table t1;
diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test
index 2f3fa99bac0..43329a849f8 100644
--- a/mysql-test/t/drop.test
+++ b/mysql-test/t/drop.test
@@ -1,4 +1,9 @@
+# Initialise
+--disable_warnings
drop table if exists t1;
+drop database if exists mysqltest;
+--enable_warnings
+
--error 1051;
drop table t1;
create table t1(n int);
@@ -13,7 +18,6 @@ select * from t1;
# now test for a bug in drop database - it is important that the name
# of the table is the same as the name of the database - in the original
# code this triggered a bug
-drop database if exists mysqltest;
create database mysqltest;
drop database if exists mysqltest;
create database mysqltest;
@@ -39,3 +43,13 @@ drop database mysqltest;
show databases;
--error 1008
drop database mysqltest;
+
+# test create table and FLUSH TABLES WITH READ LOCK
+drop table t1;
+flush tables with read lock;
+--error 1223;
+create table t1(n int);
+unlock tables;
+create table t1(n int);
+show tables;
+drop table t1;
diff --git a/mysql-test/t/empty_table.test b/mysql-test/t/empty_table.test
index 9ea79ee157f..db0a8e6a247 100644
--- a/mysql-test/t/empty_table.test
+++ b/mysql-test/t/empty_table.test
@@ -2,7 +2,10 @@
# Some special cases with empty tables
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
select count(*) from t1;
select * from t1;
diff --git a/mysql-test/t/errors.test b/mysql-test/t/errors.test
index afb0cce9005..b558c90b0c6 100644
--- a/mysql-test/t/errors.test
+++ b/mysql-test/t/errors.test
@@ -2,23 +2,22 @@
# Test some error conditions
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
--error 1146
insert into t1 values(1);
--error 1146
delete from t1;
--error 1146
update t1 set a=1;
-
-#
-
create table t1 (a int);
--error 1054
select count(test.t1.b) from t1;
--error 1109
select count(not_existing_database.t1) from t1;
--error 1109
- select count(not_existing_database.t1.a) from t1;
+select count(not_existing_database.t1.a) from t1;
--error 1044,1146
select count(not_existing_database.t1.a) from not_existing_database.t1;
--error 1054
diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test
index 045598e97df..ff1803368b9 100644
--- a/mysql-test/t/explain.test
+++ b/mysql-test/t/explain.test
@@ -1,7 +1,9 @@
#
# Test of different EXPLAIN's
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1 (id int not null, str char(10), unique(str));
explain select * from t1;
insert into t1 values (1, null),(2, null),(3, "foo"),(4, "bar");
diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test
index 7754fc2e197..9ee6b5d76b8 100644
--- a/mysql-test/t/flush.test
+++ b/mysql-test/t/flush.test
@@ -9,11 +9,13 @@
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
-drop table if exists t1;
+
+--disable_warnings
+drop table if exists t1,t2;
drop database if exists mysqltest;
+--enable_warnings
create temporary table t1(n int not null primary key);
-drop table if exists t2;
create table t2(n int);
insert into t2 values(3);
let $1=100;
diff --git a/mysql-test/t/foreign_key.test b/mysql-test/t/foreign_key.test
index 1afcb546f6a..8c35fd65f74 100644
--- a/mysql-test/t/foreign_key.test
+++ b/mysql-test/t/foreign_key.test
@@ -2,7 +2,10 @@
# Test syntax of foreign keys
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (
a int not null references t2,
b int not null references t2 (c),
diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test
index 69c69794f4f..a0292740c8d 100644
--- a/mysql-test/t/fulltext.test
+++ b/mysql-test/t/fulltext.test
@@ -2,7 +2,9 @@
# Test of fulltext index
#
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b));
INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
@@ -14,9 +16,16 @@ INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
# nl search
select * from t1 where MATCH(a,b) AGAINST ("collections");
+explain extended select * from t1 where MATCH(a,b) AGAINST ("collections");
select * from t1 where MATCH(a,b) AGAINST ("indexes");
select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
+select * from t1 where MATCH(a,b) AGAINST ("only");
+# query expansion
+
+select * from t1 where MATCH(a,b) AGAINST ("collections" WITH QUERY EXPANSION);
+select * from t1 where MATCH(a,b) AGAINST ("indexes" WITH QUERY EXPANSION);
+select * from t1 where MATCH(a,b) AGAINST ("indexes collections" WITH QUERY EXPANSION);
# add_ft_keys() tests
@@ -34,6 +43,7 @@ explain select * from t1 where MATCH(a,b) AGAINST ("collections")>0 and a like '
# boolean search
select * from t1 where MATCH(a,b) AGAINST("support -collections" IN BOOLEAN MODE);
+explain extended select * from t1 where MATCH(a,b) AGAINST("support -collections" IN BOOLEAN MODE);
select * from t1 where MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE);
select * from t1 where MATCH(a,b) AGAINST("support +collections" IN BOOLEAN MODE);
select * from t1 where MATCH(a,b) AGAINST("sear*" IN BOOLEAN MODE);
@@ -52,6 +62,7 @@ select * from t1 where MATCH a,b AGAINST ('"text search" "now support"' IN BOOL
select * from t1 where MATCH a,b AGAINST ('"text search" -"now support"' IN BOOLEAN MODE);
select * from t1 where MATCH a,b AGAINST ('"text search" +"now support"' IN BOOLEAN MODE);
select * from t1 where MATCH a,b AGAINST ('"text i"' IN BOOLEAN MODE);
+select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE);
# boolean w/o index:
@@ -59,7 +70,6 @@ select * from t1 where MATCH a AGAINST ("search" IN BOOLEAN MODE);
select * from t1 where MATCH b AGAINST ("sear*" IN BOOLEAN MODE);
# UNION of fulltext's
-
select * from t1 where MATCH(a,b) AGAINST ("collections") UNION ALL select * from t1 where MATCH(a,b) AGAINST ("indexes");
#update/delete with fulltext index
@@ -123,6 +133,13 @@ select * from t2 having MATCH inhalt AGAINST ('foobar');
# check of fulltext errors
#
+--error 1282
+CREATE TABLE t3 (t int(11),i text,fulltext tix (t,i));
+--error 1282
+CREATE TABLE t3 (t int(11),i text,
+ j varchar(200) CHARACTER SET latin2,
+ fulltext tix (i,j));
+
CREATE TABLE t3 (
ticket int(11),
inhalt text,
@@ -147,10 +164,10 @@ CREATE TABLE t1 (
id int(11) auto_increment,
title varchar(100) default '',
PRIMARY KEY (id),
- KEY ind5 (title),
- FULLTEXT KEY FT1 (title)
+ KEY ind5 (title)
) TYPE=MyISAM;
+CREATE FULLTEXT INDEX ft1 ON t1(title);
insert into t1 (title) values ('this is a test');
select * from t1 where match title against ('test' in boolean mode);
update t1 set title='this is A test' where id=1;
@@ -181,7 +198,6 @@ drop table t1;
# ERROR 1030: Got error 127 from table handler
#
-drop table if exists t1;
create table t1 (a text, fulltext key (a));
insert into t1 values ('aaaa');
repair table t1;
@@ -193,7 +209,6 @@ drop table t1;
# FULLTEXT index on a TEXT filed converted to a CHAR field doesn't work anymore
#
-drop table if exists t1;
create table t1 ( ref_mag text not null, fulltext (ref_mag));
insert into t1 values ('test');
select ref_mag from t1 where match ref_mag against ('+test' in boolean mode);
@@ -221,3 +236,25 @@ select * from t2 where match name against ('a* b* c* d* e* f*' in boolean mode);
drop table t1,t2;
+#
+# UTF8
+#
+SET NAMES latin1;
+CREATE TABLE t1 (t text character set utf8 not null, fulltext(t));
+INSERT t1 VALUES ('Mit freundlichem Grüß'), ('aus Osnabrück');
+SET NAMES koi8r;
+INSERT t1 VALUES ("üÔÏ ÍÙ - ÏÐÉÌËÉ"),("ïÔÌÅÚØ, ÇÎÉÄÁ!"),
+ ("îÅ ×ÌÅÚÁÊ, ÕÂØÅÔ!"),("É ÂÕÄÅÔ ÐÒÁ×!");
+SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('ïðéìëé');
+SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('ðÒá*' IN BOOLEAN MODE);
+SELECT * FROM t1 WHERE MATCH t AGAINST ('ÜÔÏ' IN BOOLEAN MODE);
+SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück');
+SET NAMES latin1;
+SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück');
+SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrueck');
+#alter table t1 modify t text character set latin1 collate latin1_german2_ci not null;
+alter table t1 modify t varchar(200) collate latin1_german2_ci not null;
+SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück');
+SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrueck');
+DROP TABLE t1;
+
diff --git a/mysql-test/t/fulltext2.test b/mysql-test/t/fulltext2.test
new file mode 100644
index 00000000000..a01ec3a59c9
--- /dev/null
+++ b/mysql-test/t/fulltext2.test
@@ -0,0 +1,176 @@
+#
+# test of new fulltext search features
+#
+
+#
+# two-level tree
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (
+ i int(10) unsigned not null auto_increment primary key,
+ a varchar(255) not null,
+ FULLTEXT KEY (a)
+) TYPE=MyISAM;
+
+# two-level entry, second-level tree with depth 2
+--disable_query_log
+let $1=260;
+while ($1)
+{
+ eval insert t1 (a) values ('aaaxxx');
+ dec $1;
+}
+
+# two-level entry, second-level tree has only one page
+let $1=255;
+while ($1)
+{
+ eval insert t1 (a) values ('aaazzz');
+ dec $1;
+}
+
+# one-level entry (entries)
+let $1=250;
+while ($1)
+{
+ eval insert t1 (a) values ('aaayyy');
+ dec $1;
+}
+--enable_query_log
+
+# converting to two-level
+repair table t1 quick;
+
+select count(*) from t1 where match a against ('aaaxxx');
+select count(*) from t1 where match a against ('aaayyy');
+select count(*) from t1 where match a against ('aaazzz');
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+select count(*) from t1 where match a against ('aaayyy' in boolean mode);
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz');
+select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz' in boolean mode);
+
+select count(*) from t1 where match a against ('aaax*' in boolean mode);
+select count(*) from t1 where match a against ('aaay*' in boolean mode);
+select count(*) from t1 where match a against ('aaa*' in boolean mode);
+
+# mi_write:
+
+insert t1 (a) values ('aaaxxx'),('aaayyy');
+# call to enlarge_root() below
+insert t1 (a) values ('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz');
+select count(*) from t1 where match a against ('aaaxxx');
+select count(*) from t1 where match a against ('aaayyy');
+select count(*) from t1 where match a against ('aaazzz');
+
+# mi_delete
+insert t1 (a) values ('aaaxxx 000000');
+select count(*) from t1 where match a against ('000000');
+delete from t1 where match a against ('000000');
+select count(*) from t1 where match a against ('000000');
+select count(*) from t1 where match a against ('aaaxxx');
+delete from t1 where match a against ('aaazzz');
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+select count(*) from t1 where match a against ('aaayyy' in boolean mode);
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+# double-check without index
+select count(*) from t1 where a = 'aaaxxx';
+select count(*) from t1 where a = 'aaayyy';
+select count(*) from t1 where a = 'aaazzz';
+
+# update
+insert t1 (a) values ('aaaxxx 000000');
+select count(*) from t1 where match a against ('000000');
+update t1 set a='aaazzz' where match a against ('000000');
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+update t1 set a='aaazzz' where a = 'aaaxxx';
+update t1 set a='aaaxxx' where a = 'aaayyy';
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+select count(*) from t1 where match a against ('aaayyy' in boolean mode);
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+
+drop table t1;
+
+CREATE TABLE t1 (
+ i int(10) unsigned not null auto_increment primary key,
+ a varchar(255) not null,
+ FULLTEXT KEY (a)
+) TYPE=MyISAM;
+
+# two-level entry, second-level tree with depth 2
+--disable_query_log
+let $1=260;
+while ($1)
+{
+ eval insert t1 (a) values ('aaaxxx');
+ dec $1;
+}
+let $1=255;
+while ($1)
+{
+ eval insert t1 (a) values ('aaazzz');
+ dec $1;
+}
+let $1=250;
+while ($1)
+{
+ eval insert t1 (a) values ('aaayyy');
+ dec $1;
+}
+--enable_query_log
+
+select count(*) from t1 where match a against ('aaaxxx');
+select count(*) from t1 where match a against ('aaayyy');
+select count(*) from t1 where match a against ('aaazzz');
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+select count(*) from t1 where match a against ('aaayyy' in boolean mode);
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz');
+select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz' in boolean mode);
+
+select count(*) from t1 where match a against ('aaax*' in boolean mode);
+select count(*) from t1 where match a against ('aaay*' in boolean mode);
+select count(*) from t1 where match a against ('aaa*' in boolean mode);
+
+# mi_write:
+
+insert t1 (a) values ('aaaxxx'),('aaayyy');
+insert t1 (a) values ('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz');
+select count(*) from t1 where match a against ('aaaxxx');
+select count(*) from t1 where match a against ('aaayyy');
+select count(*) from t1 where match a against ('aaazzz');
+
+# mi_delete
+insert t1 (a) values ('aaaxxx 000000');
+select count(*) from t1 where match a against ('000000');
+delete from t1 where match a against ('000000');
+select count(*) from t1 where match a against ('000000');
+select count(*) from t1 where match a against ('aaaxxx');
+delete from t1 where match a against ('aaazzz');
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+select count(*) from t1 where match a against ('aaayyy' in boolean mode);
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+# double-check without index
+select count(*) from t1 where a = 'aaaxxx';
+select count(*) from t1 where a = 'aaayyy';
+select count(*) from t1 where a = 'aaazzz';
+
+# update
+insert t1 (a) values ('aaaxxx 000000');
+select count(*) from t1 where match a against ('000000');
+update t1 set a='aaazzz' where match a against ('000000');
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+update t1 set a='aaazzz' where a = 'aaaxxx';
+update t1 set a='aaaxxx' where a = 'aaayyy';
+select count(*) from t1 where match a against ('aaaxxx' in boolean mode);
+select count(*) from t1 where match a against ('aaayyy' in boolean mode);
+select count(*) from t1 where match a against ('aaazzz' in boolean mode);
+
+drop table t1;
+
diff --git a/mysql-test/t/fulltext_cache.test b/mysql-test/t/fulltext_cache.test
index 0b15e57a97b..15f32fdb5a0 100644
--- a/mysql-test/t/fulltext_cache.test
+++ b/mysql-test/t/fulltext_cache.test
@@ -2,7 +2,10 @@
# Bugreport due to Roy Nasser <roy@vem.ca>
#
+--disable_warnings
drop table if exists t1, t2;
+--enable_warnings
+
CREATE TABLE t1 (
id int(10) unsigned NOT NULL auto_increment,
q varchar(255) default NULL,
diff --git a/mysql-test/t/fulltext_distinct.test b/mysql-test/t/fulltext_distinct.test
index 86e2f7ca1b4..2ccfb94c819 100644
--- a/mysql-test/t/fulltext_distinct.test
+++ b/mysql-test/t/fulltext_distinct.test
@@ -3,7 +3,10 @@
# bug reported by Tibor Simko <tibor.simko@cern.ch>
#
+--disable_warnings
DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
CREATE TABLE t1 (
id mediumint unsigned NOT NULL auto_increment,
tag char(6) NOT NULL default '',
diff --git a/mysql-test/t/fulltext_left_join.test b/mysql-test/t/fulltext_left_join.test
index da4df13bc0c..855649923c4 100644
--- a/mysql-test/t/fulltext_left_join.test
+++ b/mysql-test/t/fulltext_left_join.test
@@ -2,7 +2,10 @@
# Test for bug from Jean-Cédric COSTA <jean-cedric.costa@ensmp.fr>
#
+--disable_warnings
drop table if exists t1, t2;
+--enable_warnings
+
CREATE TABLE t1 (
id VARCHAR(255) NOT NULL PRIMARY KEY,
sujet VARCHAR(255),
diff --git a/mysql-test/t/fulltext_multi.test b/mysql-test/t/fulltext_multi.test
index f71704e1bb9..c312a5938b2 100644
--- a/mysql-test/t/fulltext_multi.test
+++ b/mysql-test/t/fulltext_multi.test
@@ -1,6 +1,8 @@
# several FULLTEXT indexes in one table test
-
+--disable_warnings
DROP TABLE IF EXISTS t1;
+--enable_warnings
+
CREATE TABLE t1 (
a int(11) NOT NULL auto_increment,
b text,
diff --git a/mysql-test/t/fulltext_order_by.test b/mysql-test/t/fulltext_order_by.test
index 8c34230cfe3..f8afe49d95d 100644
--- a/mysql-test/t/fulltext_order_by.test
+++ b/mysql-test/t/fulltext_order_by.test
@@ -1,4 +1,7 @@
+--disable_warnings
DROP TABLE IF EXISTS t1;
+--enable_warnings
+
CREATE TABLE t1 (
a INT AUTO_INCREMENT PRIMARY KEY,
message CHAR(20),
diff --git a/mysql-test/t/fulltext_update.test b/mysql-test/t/fulltext_update.test
index 9e2ce3ccba5..a1d133ba3fe 100644
--- a/mysql-test/t/fulltext_update.test
+++ b/mysql-test/t/fulltext_update.test
@@ -2,7 +2,9 @@
# Test for bug by voi@ims.at
#
+--disable_warnings
drop table if exists test;
+--enable_warnings
CREATE TABLE test (
gnr INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
url VARCHAR(80) DEFAULT '' NOT NULL,
diff --git a/mysql-test/t/func_compress.test b/mysql-test/t/func_compress.test
new file mode 100644
index 00000000000..06ebb388517
--- /dev/null
+++ b/mysql-test/t/func_compress.test
@@ -0,0 +1,37 @@
+-- source include/have_compress.inc
+#
+# Test for compress and uncompress functions:
+#
+
+select @test_compress_string:='string for test compress function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ';
+select length(@test_compress_string);
+
+select uncompress(compress(@test_compress_string));
+explain extended select uncompress(compress(@test_compress_string));
+select uncompressed_length(compress(@test_compress_string))=length(@test_compress_string);
+explain extended select uncompressed_length(compress(@test_compress_string))=length(@test_compress_string);
+select uncompressed_length(compress(@test_compress_string));
+select length(compress(@test_compress_string))<length(@test_compress_string);
+
+create table t1 (a text, b char(255), c char(4)) type=myisam;
+insert into t1 (a,b,c) values (compress(@test_compress_string),compress(@test_compress_string),'d ');
+select uncompress(a) from t1;
+select uncompress(b) from t1;
+select concat('|',c,'|') from t1;
+drop table t1;
+
+select compress("");
+select uncompress("");
+select uncompress(compress(""));
+select uncompressed_length("");
+
+#
+# errors
+#
+
+create table t1 (a text);
+insert t1 values (compress(null)), ('A\0\0\0BBBBBBBB'), (compress(space(50000))), (space(50000));
+select length(a) from t1;
+select length(uncompress(a)) from t1;
+drop table t1;
+
diff --git a/mysql-test/t/func_concat.test b/mysql-test/t/func_concat.test
index d6da1d6a603..147367a6d27 100644
--- a/mysql-test/t/func_concat.test
+++ b/mysql-test/t/func_concat.test
@@ -2,7 +2,10 @@
# Test of problem with CONCAT_WS() and long separators.
#
+--disable_warnings
DROP TABLE IF EXISTS t1;
+--enable_warnings
+
CREATE TABLE t1 ( number INT NOT NULL, alpha CHAR(6) NOT NULL );
INSERT INTO t1 VALUES (1413006,'idlfmv'),
(1413065,'smpsfz'),(1413127,'sljrhx'),(1413304,'qerfnd');
diff --git a/mysql-test/t/func_crypt.test b/mysql-test/t/func_crypt.test
index e612405c5e9..f352a98e3cd 100644
--- a/mysql-test/t/func_crypt.test
+++ b/mysql-test/t/func_crypt.test
@@ -1,15 +1,50 @@
-- source include/have_crypt.inc
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
select length(encrypt('foo', 'ff')) <> 0;
--replace_result $1$aa$4OSUA5cjdx0RUQ08opV27/ aaqPiZY5xR5l.
-select old_password('test'), password('test');
-select length(encrypt('test')), encrypt('test','aa');
-drop table if exists t1;
-create table t1 (name varchar(50), pw varchar(16));
+create table t1 (name varchar(50), pw varchar(64));
insert into t1 values ('tom', password('my_pass'));
set @pass='my_pass';
select name from t1 where name='tom' and pw=password(@pass);
select name from t1 where name='tom' and pw=password(@undefined);
drop table t1;
+# Test new and old password handling functions
+
+select password('abc');
+select password('');
+select old_password('abc');
+select old_password('');
+select password('gabbagabbahey');
+select old_password('idkfa');
+select length(password('1'));
+select length(encrypt('test'));
+select encrypt('test','aa');
+select old_password(NULL);
+select password(NULL);
+set global old_passwords=on;
+select password('');
+select old_password('');
+select password('idkfa');
+select old_password('idkfa');
+set old_passwords=on;
+select password('idkfa');
+select old_password('idkfa');
+set global old_passwords=off;
+select password('idkfa');
+select old_password('idkfa');
+
+# this test shows that new scrambles honor spaces in passwords:
+set old_passwords=off;
+select password('idkfa ');
+select password('idkfa');
+select password(' idkfa');
+select old_password('idkfa');
+select old_password(' i d k f a ');
+
+explain extended select password('idkfa '), old_password('idkfa');
diff --git a/mysql-test/t/func_date_add.test b/mysql-test/t/func_date_add.test
index c0250c6ece4..35acfe84bee 100644
--- a/mysql-test/t/func_date_add.test
+++ b/mysql-test/t/func_date_add.test
@@ -2,7 +2,10 @@
# Test of DATE_ADD
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
CREATE TABLE t1 (
visitor_id int(10) unsigned DEFAULT '0' NOT NULL,
group_id int(10) unsigned DEFAULT '0' NOT NULL,
diff --git a/mysql-test/t/func_default.test b/mysql-test/t/func_default.test
new file mode 100644
index 00000000000..6ae9f088f92
--- /dev/null
+++ b/mysql-test/t/func_default.test
@@ -0,0 +1,19 @@
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+
+create table t1(str varchar(10) default 'def',strnull varchar(10),intg int default '10',rel double default '3.14');
+
+insert into t1 values ('','',0,0.0);
+select default(str), default(strnull), default(intg), default(rel) from t1;
+explain extended select default(str), default(strnull), default(intg), default(rel) from t1;
+select * from t1 where str <> default(str);
+explain select * from t1 where str <> default(str);
+
+#TODO: uncomment when bug will be fixed
+#create table t2 select default(str), default(strnull), default(intg), default(rel) from t1;
+#show create table from t1;
+#insert into t2 select select default(str), default(strnull), default(intg), default(rel) from t1;
+
+drop table t1; \ No newline at end of file
diff --git a/mysql-test/t/func_encrypt.test b/mysql-test/t/func_encrypt.test
index 3b6acc54ec9..fe81a814dda 100644
--- a/mysql-test/t/func_encrypt.test
+++ b/mysql-test/t/func_encrypt.test
@@ -1,6 +1,9 @@
-- source include/have_openssl.inc
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (x blob);
insert into t1 values (des_encrypt('The quick red fox jumped over the lazy brown dog','The quick red fox jumped over the lazy brown dog'));
insert into t1 values (des_encrypt('a','The quick red fox jumped over the lazy brown dog'));
@@ -65,3 +68,5 @@ select @a = des_decrypt(des_encrypt("hello"));
select hex("hello");
select hex(des_decrypt(des_encrypt("hello",4),'password2'));
select hex(des_decrypt(des_encrypt("hello","hidden")));
+
+explain extended select des_decrypt(des_encrypt("hello",4),'password2'), des_decrypt(des_encrypt("hello","hidden"));
diff --git a/mysql-test/t/func_equal.test b/mysql-test/t/func_equal.test
index 0d7a4ed9778..cbf589ffcc2 100644
--- a/mysql-test/t/func_equal.test
+++ b/mysql-test/t/func_equal.test
@@ -1,3 +1,8 @@
+# Initialise
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
#
# Testing of the <=> operator
#
@@ -15,7 +20,6 @@ select "A"<=>"B","A"<=>NULL,NULL<=>"A";
# Test with tables
#
-drop table if exists t1,t2;
create table t1 (id int, value int);
create table t2 (id int, value int);
diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test
new file mode 100644
index 00000000000..d004c81f14e
--- /dev/null
+++ b/mysql-test/t/func_gconcat.test
@@ -0,0 +1,132 @@
+#
+# simple test of group_concat function
+#
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+
+create table t1 (grp int, a bigint unsigned, c char(10) not null, d char(10) not null);
+insert into t1 values (1,1,"a","a");
+insert into t1 values (2,2,"b","a");
+insert into t1 values (2,3,"c","b");
+insert into t1 values (3,4,"E","a");
+insert into t1 values (3,5,"C","b");
+insert into t1 values (3,6,"D","b");
+insert into t1 values (3,7,"d","d");
+insert into t1 values (3,8,"d","d");
+insert into t1 values (3,9,"D","c");
+
+# Test of MySQL simple request
+select grp,group_concat(c) from t1 group by grp;
+explain extended select grp,group_concat(c) from t1 group by grp;
+select grp,group_concat(a,c) from t1 group by grp;
+select grp,group_concat("(",a,":",c,")") from t1 group by grp;
+
+# Test of MySQL with options
+select grp,group_concat(c separator ",") from t1 group by grp;
+select grp,group_concat(c separator "---->") from t1 group by grp;
+select grp,group_concat(c order by c) from t1 group by grp;
+select grp,group_concat(c order by c desc) from t1 group by grp;
+select grp,group_concat(d order by a) from t1 group by grp;
+select grp,group_concat(d order by a desc) from t1 group by grp;
+select grp,group_concat(a order by a,d+c) from t1 group by grp;
+select grp,group_concat(c order by 1) from t1 group by grp;
+select grp,group_concat(c order by "c") from t1 group by grp;
+select grp,group_concat(distinct c order by c) from t1 group by grp;
+select grp,group_concat(distinct c order by c desc) from t1 group by grp;
+explain extended select grp,group_concat(distinct c order by c desc) from t1 group by grp;
+select grp,group_concat(c order by c separator ",") from t1 group by grp;
+select grp,group_concat(c order by c desc separator ",") from t1 group by grp;
+select grp,group_concat(distinct c order by c separator ",") from t1 group by grp;
+explain extended select grp,group_concat(distinct c order by c separator ",") from t1 group by grp;
+select grp,group_concat(distinct c order by c desc separator ",") from t1 group by grp;
+
+# Test of SQL_LIST objects
+select grp,group_concat(c order by grp desc) from t1 group by grp order by grp;
+
+
+# Test transfer to real values
+
+select grp, group_concat(a separator "")+0 from t1 group by grp;
+select grp, group_concat(a separator "")+0.0 from t1 group by grp;
+select grp, ROUND(group_concat(a separator "")) from t1 group by grp;
+
+# Test NULL values
+
+drop table t1;
+create table t1 (grp int, c char(10));
+insert into t1 values (1,NULL);
+insert into t1 values (2,"b");
+insert into t1 values (2,NULL);
+insert into t1 values (3,"E");
+insert into t1 values (3,NULL);
+insert into t1 values (3,"D");
+insert into t1 values (3,NULL);
+insert into t1 values (3,NULL);
+insert into t1 values (3,"D");
+insert into t1 values (4,"");
+insert into t1 values (5,NULL);
+select grp,group_concat(c order by c) from t1 group by grp;
+
+# Test warnings
+
+set group_concat_max_len = 5;
+select grp,group_concat(c) from t1 group by grp;
+show warnings;
+set group_concat_max_len = 1024;
+
+# Test errors
+
+--error 1111
+select group_concat(sum(a)) from t1 group by grp;
+--error 1054
+select grp,group_concat(c order by 2) from t1 group by grp;
+
+drop table t1;
+
+# Test variable length
+
+create table t1 ( URL_ID int(11), URL varchar(80));
+create table t2 ( REQ_ID int(11), URL_ID int(11));
+insert into t1 values (4,'www.host.com'), (5,'www.google.com'),(5,'www.help.com');
+insert into t2 values (1,4), (5,4), (5,5);
+# Make this order independent
+--replace_result www.help.com X www.host.com X www.google.com X
+select REQ_ID, Group_Concat(URL) as URL from t1, t2 where
+t2.URL_ID = t1.URL_ID group by REQ_ID;
+# check min/max function
+--replace_result www.help.com X www.host.com X www.google.com X
+select REQ_ID, Group_Concat(URL) as URL, Min(t1.URL_ID) urll,
+Max(t1.URL_ID) urlg from t1, t2 where t2.URL_ID = t1.URL_ID group by REQ_ID;
+
+drop table t1;
+drop table t2;
+
+create table t1 (id int, name varchar(16));
+insert into t1 values (1,'longername'),(1,'evenlongername');
+select ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'without distinct: how it should be' from t1;
+select distinct ifnull(group_concat(concat(t1.id, ':', t1.name)), 'shortname') as 'with distinct: cutoff at length of shortname' from t1;
+drop table t1;
+
+# check zero rows
+create table t1(id int);
+create table t2(id int);
+insert into t1 values(0),(1);
+select group_concat(t1.id) FROM t1,t2;
+drop table t1;
+drop table t2;
+
+# check having
+create table t1 (bar varchar(32));
+insert into t1 values('test'),('test2');
+select * from t1 having group_concat(bar)='';
+drop table t1;
+
+# ORDER BY fix_fields()
+create table t1 (a int, a1 varchar(10));
+create table t2 (a0 int);
+insert into t1 values (0,"a"),(0,"b"),(1,"c");
+insert into t2 values (1),(2),(3);
+select group_concat(a1 order by (t1.a IN (select a0 from t2))) from t1;
+select group_concat(a1 order by (t1.a)) from t1;
+drop table t1, t2; \ No newline at end of file
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index 40d829d3e70..9e0184d35ce 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -2,7 +2,10 @@
# simple test of all group functions
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (grp int, a bigint unsigned, c char(10) not null);
insert into t1 values (1,1,"a");
insert into t1 values (2,2,"b");
@@ -21,9 +24,9 @@ select count(distinct a),count(distinct grp) from t1;
insert into t1 values (null,null,'');
select count(distinct a),count(distinct grp) from t1;
-select sum(all a),count(all a),avg(all a),std(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1;
-select grp, sum(a),count(a),avg(a),std(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp;
-select grp, sum(a)+count(a)+avg(a)+std(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp;
+select sum(all a),count(all a),avg(all a),std(all a),variance(all a),bit_or(all a),bit_and(all a),min(all a),max(all a),min(all c),max(all c) from t1;
+select grp, sum(a),count(a),avg(a),std(a),variance(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp;
+select grp, sum(a)+count(a)+avg(a)+std(a)+variance(a)+bit_or(a)+bit_and(a)+min(a)+max(a)+min(c)+max(c) as sum from t1 group by grp;
create table t2 (grp int, a bigint unsigned, c char(10));
insert into t2 select grp,max(a)+max(grp),max(c) from t1 group by grp;
@@ -40,8 +43,8 @@ CREATE TABLE t1 (id int(11),value1 float(10,2));
INSERT INTO t1 VALUES (1,0.00),(1,1.00), (1,2.00), (2,10.00), (2,11.00), (2,12.00);
CREATE TABLE t2 (id int(11),name char(20));
INSERT INTO t2 VALUES (1,'Set One'),(2,'Set Two');
-select id, avg(value1), std(value1) from t1 group by id;
-select name, avg(value1), std(value1) from t1, t2 where t1.id = t2.id group by t1.id;
+select id, avg(value1), std(value1), variance(value1) from t1 group by id;
+select name, avg(value1), std(value1), variance(value1) from t1, t2 where t1.id = t2.id group by t1.id;
drop table t1,t2;
#
@@ -118,15 +121,213 @@ explain select min(a2) from t1;
explain select max(t1.a1), max(t2.a2) from t1, t2;
insert into t2 values('AAA', 10, 0.5);
+insert into t2 values('BBB', 20, 1.0);
+select t1.a1, t1.a2, t2.a1, t2.a2 from t1,t2;
+
select max(t1.a1), max(t2.a1) from t1, t2 where t2.a2=9;
select max(t2.a1), max(t1.a1) from t1, t2 where t2.a2=9;
select t1.a1, t1.a2, t2.a1, t2.a2 from t1 left outer join t2 on t1.a1=10;
select max(t1.a2) from t1 left outer join t2 on t1.a1=10;
-select max(t1.a2) from t1 left outer join t2 on t1.a1=10 where t1.a1=20;
-select max(t1.a2) from t1 left outer join t2 on t1.a1=10 where t1.a1=10;
+select max(t2.a1) from t2 left outer join t1 on t2.a2=10 where t2.a2=20;
+select max(t2.a1) from t2 left outer join t1 on t2.a2=10 where t2.a2=10;
select max(t2.a1) from t1 left outer join t2 on t1.a2=t2.a1 and 1=0 where t2.a1='AAA';
+select max(t1.a2),max(t2.a1) from t1 left outer join t2 on t1.a1=10;
drop table t1,t2;
+
+#
+# Tests to check MIN/MAX query optimization
+#
+
+# Create database schema
+create table t1(
+ a1 char(3) primary key,
+ a2 smallint,
+ a3 char(3),
+ a4 real,
+ a5 date,
+ key k1(a2,a3),
+ key k2(a4 desc,a1),
+ key k3(a5,a1)
+);
+create table t2(
+ a1 char(3) primary key,
+ a2 char(17),
+ a3 char(2),
+ a4 char(3),
+ key k1(a3, a2),
+ key k2(a4)
+);
+
+# Populate table t1
+insert into t1 values('AME',0,'SEA',0.100,date'1942-02-19');
+insert into t1 values('HBR',1,'SEA',0.085,date'1948-03-05');
+insert into t1 values('BOT',2,'SEA',0.085,date'1951-11-29');
+insert into t1 values('BMC',3,'SEA',0.085,date'1958-09-08');
+insert into t1 values('TWU',0,'LAX',0.080,date'1969-10-05');
+insert into t1 values('BDL',0,'DEN',0.080,date'1960-11-27');
+insert into t1 values('DTX',1,'NYC',0.080,date'1961-05-04');
+insert into t1 values('PLS',1,'WDC',0.075,date'1949-01-02');
+insert into t1 values('ZAJ',2,'CHI',0.075,date'1960-06-15');
+insert into t1 values('VVV',2,'MIN',0.075,date'1959-06-28');
+insert into t1 values('GTM',3,'DAL',0.070,date'1977-09-23');
+insert into t1 values('SSJ',null,'CHI',null,date'1974-03-19');
+insert into t1 values('KKK',3,'ATL',null,null);
+insert into t1 values('XXX',null,'MIN',null,null);
+
+# Populate table t2
+insert into t2 values('TKF','Seattle','WA','AME');
+insert into t2 values('LCC','Los Angeles','CA','TWU');
+insert into t2 values('DEN','Denver','CO','BDL');
+insert into t2 values('SDC','San Diego','CA','TWU');
+insert into t2 values('NOL','New Orleans','LA','GTM');
+insert into t2 values('LAK','Los Angeles','CA','TWU');
+
+# Show the table contents
+select * from t1;
+select * from t2;
+
+# Queries with min/max functions
+# which regular min/max optimization are applied to
+
+explain
+select min(a1) from t1;
+select min(a1) from t1;
+explain
+select max(a4) from t1;
+select max(a4) from t1;
+explain
+select min(a5), max(a5) from t1;
+select min(a5), max(a5) from t1;
+explain
+select min(a3) from t1 where a2 = 2;
+select min(a3) from t1 where a2 = 2;
+explain
+select min(a1), max(a1) from t1 where a4 = 0.080;
+select min(a1), max(a1) from t1 where a4 = 0.080;
+
+explain
+select min(t1.a5), max(t2.a3) from t1, t2;
+select min(t1.a5), max(t2.a3) from t1, t2;
+explain
+select min(t1.a3), max(t2.a2) from t1, t2 where t1.a2 = 0 and t2.a3 = 'CA';
+select min(t1.a3), max(t2.a2) from t1, t2 where t1.a2 = 0 and t2.a3 = 'CA';
+
+# Queries with min/max functions
+# which extended min/max optimization are applied to
+
+explain
+select min(a1) from t1 where a1 > 'KKK';
+select min(a1) from t1 where a1 > 'KKK';
+explain
+select min(a1) from t1 where a1 >= 'KKK';
+select min(a1) from t1 where a1 >= 'KKK';
+explain
+select max(a3) from t1 where a2 = 2 and a3 < 'SEA';
+select max(a3) from t1 where a2 = 2 and a3 < 'SEA';
+explain
+select max(a5) from t1 where a5 < date'1970-01-01';
+select max(a5) from t1 where a5 < date'1970-01-01';
+explain
+select max(a3) from t1 where a2 is null;
+select max(a3) from t1 where a2 is null;
+explain
+select max(a3) from t1 where a2 = 0 and a3 between 'K' and 'Q';
+select max(a3) from t1 where a2 = 0 and a3 between 'K' and 'Q';
+explain
+select min(a1), max(a1) from t1 where a1 between 'A' and 'P';
+select min(a1), max(a1) from t1 where a1 between 'A' and 'P';
+explain
+select max(a3) from t1 where a3 < 'SEA' and a2 = 2 and a3 <= 'MIN';
+select max(a3) from t1 where a3 < 'SEA' and a2 = 2 and a3 <= 'MIN';
+explain
+select max(a3) from t1 where a3 = 'MIN' and a2 = 2;
+select max(a3) from t1 where a3 = 'MIN' and a2 = 2;
+explain
+select max(a3) from t1 where a3 = 'DEN' and a2 = 2;
+select max(a3) from t1 where a3 = 'DEN' and a2 = 2;
+
+explain
+select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 = 'CA';
+select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 = 'CA';
+
+explain
+select max(a3) from t1 where a2 is null and a2 = 2;
+select max(a3) from t1 where a2 is null and a2 = 2;
+
+explain
+select max(a2) from t1 where a2 >= 1;
+select max(a2) from t1 where a2 >= 1;
+explain
+select min(a3) from t1 where a2 = 2 and a3 < 'SEA';
+select min(a3) from t1 where a2 = 2 and a3 < 'SEA';
+
+explain
+select min(a3) from t1 where a2 = 4;
+select min(a3) from t1 where a2 = 4;
+explain
+select min(a3) from t1 where a2 = 2 and a3 > 'SEA';
+select min(a3) from t1 where a2 = 2 and a3 > 'SEA';
+explain
+select (min(a4)+max(a4))/2 from t1;
+select (min(a4)+max(a4))/2 from t1;
+explain
+select min(a3) from t1 where 2 = a2;
+select min(a3) from t1 where 2 = a2;
+explain
+select max(a3) from t1 where a2 = 2 and 'SEA' > a3;
+select max(a3) from t1 where a2 = 2 and 'SEA' > a3;
+explain
+select max(a3) from t1 where a2 = 2 and 'SEA' < a3;
+select max(a3) from t1 where a2 = 2 and 'SEA' < a3;
+explain
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI';
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI';
+explain
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 < 'SEA';
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 < 'SEA';
+explain
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 = 'MIN';
+select min(a3) from t1 where a2 = 2 and a3 >= 'CHI' and a3 = 'MIN';
+explain
+select min(a3) from t1 where a2 = 2 and a3 >= 'SEA' and a3 = 'MIN';
+select min(a3) from t1 where a2 = 2 and a3 >= 'SEA' and a3 = 'MIN';
+
+explain
+select min(t1.a1), min(t2.a4) from t1,t2 where t1.a1 < 'KKK' and t2.a4 < 'KKK';
+select min(t1.a1), min(t2.a4) from t1,t2 where t1.a1 < 'KKK' and t2.a4 < 'KKK';
+
+# Queries to which max/min optimization is not applied
+
+explain
+select min(a1) from t1 where a1 > 'KKK' or a1 < 'XXX';
+explain
+select min(a1) from t1 where a1 != 'KKK';
+explain
+select max(a3) from t1 where a2 < 2 and a3 < 'SEA';
+explain
+select max(t1.a3), min(t2.a2) from t1, t2 where t1.a2 = 2 and t1.a3 < 'MIN' and t2.a3 > 'CA';
+
+explain
+select min(a4 - 0.01) from t1;
+explain
+select max(a4 + 0.01) from t1;
+explain
+select min(a3) from t1 where (a2 +1 ) is null;
+explain
+select min(a3) from t1 where (a2 + 1) = 2;
+explain
+select min(a3) from t1 where 2 = (a2 + 1);
+explain
+select min(a2) from t1 where a2 < 2 * a2 - 8;
+explain
+select min(a1) from t1 where a1 between a3 and 'KKK';
+explain
+select min(a4) from t1 where (a4 + 0.01) between 0.07 and 0.08;
+explain
+select concat(min(t1.a1),min(t2.a4)) from t1, t2 where t2.a4 <> 'AME';
+drop table t1, t2;
+
#
# Test of group function and NULL values
#
@@ -145,5 +346,27 @@ select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b)
select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
insert into t1 values (3,1);
select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
-select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a;
+select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b), bit_xor(b) from t1 group by a;
+explain extended select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b), bit_xor(b) from t1 group by a;
+drop table t1;
+--disable_warnings
+create table t1 (USR_ID integer not null, MAX_REQ integer not null, constraint PK_SEA_USER primary key (USR_ID)) type=InnoDB;
+--enable_warnings
+insert into t1 values (1, 3);
+select count(*) + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ + MAX_REQ - MAX_REQ from t1 group by MAX_REQ;
+select Case When Count(*) < MAX_REQ Then 1 Else 0 End from t1 where t1.USR_ID = 1 group by MAX_REQ;
+drop table t1;
+
+create table t1 (a char(10));
+insert into t1 values ('a'),('b'),('c');
+select coercibility(max(a)) from t1;
+drop table t1;
+
+#
+# aggregate functions on static tables
+#
+create table t1 (a int);
+insert into t1 values (1);
+select max(a) as b from t1 having b=1;
+select a from t1 having a=1;
drop table t1;
diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test
index 85553d1a2fd..7842df4fd0a 100644
--- a/mysql-test/t/func_if.test
+++ b/mysql-test/t/func_if.test
@@ -1,7 +1,9 @@
#
# Init section
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
#
# Simple IF tests
@@ -18,6 +20,13 @@ select if(1,st,st) s from t1 order by s;
select if(u=1,st,st) s from t1 order by s;
select if(u=1,binary st,st) s from t1 order by s;
select if(u=1,st,binary st) s from t1 where st like "%a%" order by s;
+explain extended select if(u=1,st,binary st) s from t1 where st like "%a%" order by s;
+
+#
+# NULLIF test
+#
+select nullif(u=0, 'test') from t1;
+explain extended select nullif(u=0, 'test') from t1;
drop table t1;
#
diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test
index e5d42ec25c4..9ff768ec76b 100644
--- a/mysql-test/t/func_in.test
+++ b/mysql-test/t/func_in.test
@@ -1,8 +1,44 @@
+# Initialise
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
#
# test of IN (NULL)
#
-drop table if exists t1;
+select 1 in (1,2,3);
+select 10 in (1,2,3);
+select NULL in (1,2,3);
+select 1 in (1,NULL,3);
+select 3 in (1,NULL,3);
+select 10 in (1,NULL,3);
+select 1.5 in (1.5,2.5,3.5);
+select 10.5 in (1.5,2.5,3.5);
+select NULL in (1.5,2.5,3.5);
+select 1.5 in (1.5,NULL,3.5);
+select 3.5 in (1.5,NULL,3.5);
+select 10.5 in (1.5,NULL,3.5);
+
+CREATE TABLE t1 (a int, b int, c int);
+insert into t1 values (1,2,3), (1,NULL,3);
+select 1 in (a,b,c) from t1;
+select 3 in (a,b,c) from t1;
+select 10 in (a,b,c) from t1;
+select NULL in (a,b,c) from t1;
+drop table t1;
+CREATE TABLE t1 (a float, b float, c float);
+insert into t1 values (1.5,2.5,3.5), (1.5,NULL,3.5);
+select 1.5 in (a,b,c) from t1;
+select 3.5 in (a,b,c) from t1;
+select 10.5 in (a,b,c) from t1;
+drop table t1;
+CREATE TABLE t1 (a varchar(10), b varchar(10), c varchar(10));
+insert into t1 values ('A','BC','EFD'), ('A',NULL,'EFD');
+select 'A' in (a,b,c) from t1;
+select 'EFD' in (a,b,c) from t1;
+select 'XSFGGHF' in (a,b,c) from t1;
+drop table t1;
+
CREATE TABLE t1 (field char(1));
INSERT INTO t1 VALUES ('A'),(NULL);
SELECT * from t1 WHERE field IN (NULL);
@@ -18,3 +54,31 @@ insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
select * from t1 where id in (2,5,9);
drop table t1;
+create table t1 (
+a char(1) character set latin1 collate latin1_general_ci,
+b char(1) character set latin1 collate latin1_swedish_ci,
+c char(1) character set latin1 collate latin1_danish_ci
+);
+insert into t1 values ('A','B','C');
+insert into t1 values ('a','c','c');
+--error 1266
+select * from t1 where a in (b);
+--error 1269
+select * from t1 where a in (b,c);
+--error 1270
+select * from t1 where 'a' in (a,b,c);
+select * from t1 where 'a' in (a);
+select * from t1 where a in ('a');
+select * from t1 where 'a' collate latin1_general_ci in (a,b,c);
+select * from t1 where 'a' collate latin1_bin in (a,b,c);
+select * from t1 where 'a' in (a,b,c collate latin1_bin);
+explain extended select * from t1 where 'a' in (a,b,c collate latin1_bin);
+drop table t1;
+
+select '1.0' in (1,2);
+select 1 in ('1.0',2);
+select 1 in (1,'2.0');
+select 1 in ('1.0',2.0);
+select 1 in (1.0,'2.0');
+select 1 in ('1.1',2);
+select 1 in ('1.1',2.0);
diff --git a/mysql-test/t/func_isnull.test b/mysql-test/t/func_isnull.test
index bd3bcd8d04c..506efada0eb 100644
--- a/mysql-test/t/func_isnull.test
+++ b/mysql-test/t/func_isnull.test
@@ -2,7 +2,10 @@
# test of ISNULL()
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (id int auto_increment primary key not null, mydate date not null);
insert into t1 values (0,"2002-05-01"),(0,"2002-05-01"),(0,"2002-05-01");
flush tables;
diff --git a/mysql-test/t/func_like.test b/mysql-test/t/func_like.test
index a5d1193fd74..0cd85385df4 100644
--- a/mysql-test/t/func_like.test
+++ b/mysql-test/t/func_like.test
@@ -2,7 +2,10 @@
# Test of like
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (a varchar(10), key(a));
insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test");
explain select * from t1 where a like 'abc%';
@@ -21,3 +24,23 @@ select * from t1 where a like "%abcd%";
select * from t1 where a like "%abc\d%";
drop table t1;
+
+
+#
+# Test like with non-default character set
+#
+
+SET NAMES koi8r;
+
+CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET koi8r);
+
+INSERT INTO t1 VALUES ('ÆÙ×Á'),('æÙ×Á'),('Æù×Á'),('ÆÙ÷Á'),('ÆÙ×á'),('æù÷á');
+INSERT INTO t1 VALUES ('ÆÙ×ÁÐÒÏÌÄÖ'),('æÙ×ÁÐÒÏÌÄÖ'),('Æù×ÁÐÒÏÌÄÖ'),('ÆÙ÷ÁÐÒÏÌÄÖ');
+INSERT INTO t1 VALUES ('ÆÙ×áÐÒÏÌÄÖ'),('ÆÙ×ÁðÒÏÌÄÖ'),('ÆÙ×ÁÐòÏÌÄÖ'),('ÆÙ×ÁÐÒïÌÄÖ');
+INSERT INTO t1 VALUES ('ÆÙ×ÁÐÒÏìÄÖ'),('ÆÙ×ÁÐÒÏÌäÖ'),('ÆÙ×ÁÐÒÏÌÄö'),('æù÷áðòïìäö');
+
+SELECT * FROM t1 WHERE a LIKE '%Æù×Á%';
+SELECT * FROM t1 WHERE a LIKE '%Æù×%';
+SELECT * FROM t1 WHERE a LIKE 'Æù×Á%';
+
+DROP TABLE t1;
diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test
index bd125dafd53..b6e2d3bd725 100644
--- a/mysql-test/t/func_math.test
+++ b/mysql-test/t/func_math.test
@@ -3,17 +3,30 @@
#
select floor(5.5),floor(-5.5);
+explain extended select floor(5.5),floor(-5.5);
select ceiling(5.5),ceiling(-5.5);
+explain extended select ceiling(5.5),ceiling(-5.5);
select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1);
+explain extended select truncate(52.64,1),truncate(52.64,2),truncate(52.64,-1),truncate(52.64,-2), truncate(-52.64,1),truncate(-52.64,-1);
select round(5.5),round(-5.5);
+explain extended select round(5.5),round(-5.5);
select round(5.64,1),round(5.64,2),round(5.64,-1),round(5.64,-2);
select abs(-10), sign(-5), sign(5), sign(0);
+explain extended select abs(-10), sign(-5), sign(5), sign(0);
select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
+explain extended select log(exp(10)),exp(log(sqrt(10))*2),log(-1),log(NULL),log(1,1),log(3,9),log(-1,2),log(NULL,2);
select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
+explain extended select ln(exp(10)),exp(ln(sqrt(10))*2),ln(-1),ln(0),ln(NULL);
select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
+explain extended select log2(8),log2(15),log2(-2),log2(0),log2(NULL);
select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
+explain extended select log10(100),log10(18),log10(-4),log10(0),log10(NULL);
select pow(10,log10(10)),power(2,4);
+explain extended select pow(10,log10(10)),power(2,4);
set @@rand_seed1=10000000,@@rand_seed2=1000000;
select rand(999999),rand();
+explain extended select rand(999999),rand();
select pi(),sin(pi()/2),cos(pi()/2),abs(tan(pi())),cot(1),asin(1),acos(0),atan(1);
+explain extended select pi(),sin(pi()/2),cos(pi()/2),abs(tan(pi())),cot(1),asin(1),acos(0),atan(1);
select degrees(pi()),radians(360);
+explain extended select degrees(pi()),radians(360);
diff --git a/mysql-test/t/func_op.test b/mysql-test/t/func_op.test
index 778c8406b8d..cb6ca58f193 100644
--- a/mysql-test/t/func_op.test
+++ b/mysql-test/t/func_op.test
@@ -3,5 +3,7 @@
# Simple operands and arithmetic grouping
select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2;
+explain extended select 1+1,1-1,1+1*2,8/5,8%5,mod(8,5),mod(8,5)|0,-(1+1)*-2;
select 1 | (1+1),5 & 3,bit_count(7) ;
+explain extended select 1 | (1+1),5 & 3,bit_count(7) ;
select 1 << 32,1 << 63, 1 << 64, 4 >> 2, 4 >> 63, 1<< 63 >> 60;
diff --git a/mysql-test/t/func_regexp.test b/mysql-test/t/func_regexp.test
index 7fbe4000cfc..edfa9afcfa6 100644
--- a/mysql-test/t/func_regexp.test
+++ b/mysql-test/t/func_regexp.test
@@ -2,7 +2,10 @@
# Some regexp tests
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (s1 char(64),s2 char(64));
insert into t1 values('aaa','aaa');
@@ -33,6 +36,7 @@ drop table t1;
create table t1 (xxx char(128));
insert into t1 (xxx) values('this is a test of some long text to see what happens');
select * from t1 where xxx regexp('is a test of some long text to');
+explain extended select * from t1 where xxx regexp('is a test of some long text to');
select * from t1 where xxx regexp('is a test of some long text to ');
select * from t1 where xxx regexp('is a test of some long text to s');
select * from t1 where xxx regexp('is a test of some long text to se');
@@ -42,3 +46,17 @@ create table t1 (xxx char(128));
insert into t1 (xxx) values('this is some text: to test - out.reg exp (22/45)');
select * from t1 where xxx REGEXP '^this is some text: to test - out\\.reg exp [[(][0-9]+[/\\][0-9]+[])][ ]*$';
drop table t1;
+
+#
+# Check with different character sets and collations
+#
+select _latin1 0xFF regexp _latin1 '[[:lower:]]' COLLATE latin1_bin;
+select _koi8r 0xFF regexp _koi8r '[[:lower:]]' COLLATE koi8r_bin;
+select _latin1 0xFF regexp _latin1 '[[:upper:]]' COLLATE latin1_bin;
+select _koi8r 0xFF regexp _koi8r '[[:upper:]]' COLLATE koi8r_bin;
+
+select _latin1 0xF7 regexp _latin1 '[[:alpha:]]';
+select _koi8r 0xF7 regexp _koi8r '[[:alpha:]]';
+
+select _latin1'a' regexp _latin1'A' collate latin1_general_ci;
+select _latin1'a' regexp _latin1'A' collate latin1_bin;
diff --git a/mysql-test/t/func_sapdb.test b/mysql-test/t/func_sapdb.test
new file mode 100644
index 00000000000..afd84fe9630
--- /dev/null
+++ b/mysql-test/t/func_sapdb.test
@@ -0,0 +1,99 @@
+--disable_warnings
+drop table if exists t1, test;
+--enable_warnings
+
+
+#
+# time functions
+#
+select extract(DAY_MICROSECOND FROM "1999-01-02 10:11:12.000123");
+select extract(HOUR_MICROSECOND FROM "1999-01-02 10:11:12.000123");
+select extract(MINUTE_MICROSECOND FROM "1999-01-02 10:11:12.000123");
+select extract(SECOND_MICROSECOND FROM "1999-01-02 10:11:12.000123");
+select extract(MICROSECOND FROM "1999-01-02 10:11:12.000123");
+select date_format("1997-12-31 23:59:59.000002", "%f");
+
+select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000 99:99:99.999999" DAY_MICROSECOND);
+select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99:99.999999" HOUR_MICROSECOND);
+select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99.999999" MINUTE_MICROSECOND);
+select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000.999999" SECOND_MICROSECOND);
+select date_add("1997-12-31 23:59:59.000002",INTERVAL "999999" MICROSECOND);
+
+select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1 1:1:1.000002" DAY_MICROSECOND);
+select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1:1.000002" HOUR_MICROSECOND);
+select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1.000002" MINUTE_MICROSECOND);
+select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1.000002" SECOND_MICROSECOND);
+select date_sub("1998-01-01 00:00:00.000001",INTERVAL "000002" MICROSECOND);
+
+#Date functions
+select adddate("1997-12-31 23:59:59.000001", 10);
+select subdate("1997-12-31 23:59:59.000001", 10);
+
+select datediff("1997-12-31 23:59:59.000001","1997-12-30");
+select datediff("1997-11-31 23:59:59.000001","1997-12-31");
+select datediff("1997-11-31 23:59:59.000001",null);
+
+select weekofyear("1997-11-31 23:59:59.000001");
+
+select makedate(1997,1);
+select makedate(1997,0);
+
+#Time functions
+
+select addtime("1997-12-31 23:59:59.999999", "1 1:1:1.000002");
+select subtime("1997-12-31 23:59:59.000001", "1 1:1:1.000002");
+select addtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999");
+select subtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999");
+select subtime("01:00:00.999999", "02:00:00.999998");
+select subtime("02:01:01.999999", "01:01:01.999999");
+
+select timediff("1997-01-01 23:59:59.000001","1995-12-31 23:59:59.000002");
+select timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002");
+select timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002");
+select timediff("1997-12-31 23:59:59.000001","23:59:59.000001");
+select timediff("2000:01:01 00:00:00", "2000:01:01 00:00:00.000001");
+
+select maketime(10,11,12);
+select maketime(25,11,12);
+select maketime(-25,11,12);
+
+#Extraction functions
+select timestamp("2001-12-01", "01:01:01.999999");
+select timestamp("2001-13-01", "01:01:01.000001");
+select timestamp("2001-12-01", "25:01:01");
+select timestamp("2001-12-01 01:01:01.000100");
+select timestamp("2001-12-01");
+select day("1997-12-31 23:59:59.000001");
+select date("1997-12-31 23:59:59.000001");
+select date("1997-13-31 23:59:59.000001");
+select time("1997-12-31 23:59:59.000001");
+select time("1997-12-31 25:59:59.000001");
+select microsecond("1997-12-31 23:59:59.000001");
+
+create table t1
+select makedate(1997,1) as f1,
+ addtime(cast("1997-12-31 23:59:59.000001" as datetime), "1 1:1:1.000002") as f2,
+ addtime(cast("23:59:59.999999" as time) , "1 1:1:1.000002") as f3,
+ timediff("1997-12-31 23:59:59.000001","1997-12-30 01:01:01.000002") as f4,
+ timediff("1997-12-30 23:59:59.000001","1997-12-31 23:59:59.000002") as f5,
+ maketime(10,11,12) as f6,
+ timestamp(cast("2001-12-01" as date), "01:01:01") as f7,
+ date("1997-12-31 23:59:59.000001") as f8,
+ time("1997-12-31 23:59:59.000001") as f9;
+describe t1;
+select * from t1;
+
+create table test(t1 datetime, t2 time, t3 time, t4 datetime);
+insert into test values
+('2001-01-01 01:01:01', '01:01:01', null, '2001-02-01 01:01:01'),
+('2001-01-01 01:01:01', '-01:01:01', '-23:59:59', "1997-12-31 23:59:59.000001"),
+('1997-12-31 23:59:59.000001', '-23:59:59', '-01:01:01', '2001-01-01 01:01:01'),
+('2001-01-01 01:01:01', '01:01:01', '-1 01:01:01', null),
+('2001-01-01 01:01:01', null, '-1 01:01:01', null),
+(null, null, null, null),
+('2001-01-01 01:01:01', '01:01:01', '1 01:01:01', '2001-01-01 01:01:01');
+
+SELECT ADDTIME(t1,t2) As ttt, ADDTIME(t2, t3) As qqq from test;
+SELECT TIMEDIFF(t1,t4) As ttt, TIMEDIFF(t2, t3) As qqq from test;
+
+drop table t1, test;
diff --git a/mysql-test/t/func_set.test b/mysql-test/t/func_set.test
index 81f561989d5..7d24140c75d 100644
--- a/mysql-test/t/func_set.test
+++ b/mysql-test/t/func_set.test
@@ -3,6 +3,7 @@
#
select interval(55,10,20,30,40,50,60,70,80,90,100),interval(3,1,1+1,1+1+1+1),field("IBM","NCA","ICL","SUN","IBM","DIGITAL"),field("A","B","C"),elt(2,"ONE","TWO","THREE"),interval(0,1,2,3,4),elt(1,1,2,3)|0,elt(1,1.1,1.2,1.3)+0;
+explain extended select INTERVAL(55,10,20,30,40,50,60,70,80,90,100),interval(3,1,1+1,1+1+1+1),field("IBM","NCA","ICL","SUN","IBM","DIGITAL"),field("A","B","C"),elt(2,"ONE","TWO","THREE"),interval(0,1,2,3,4),elt(1,1,2,3)|0,elt(1,1.1,1.2,1.3)+0;
select find_in_set("b","a,b,c"),find_in_set("c","a,b,c"),find_in_set("dd","a,bbb,dd"),find_in_set("bbb","a,bbb,dd");
select find_in_set("d","a,b,c"),find_in_set("dd","a,bbb,d"),find_in_set("bb","a,bbb,dd");
select make_set(0,'a','b','c'),make_set(-1,'a','b','c'),make_set(1,'a','b','c'),make_set(2,'a','b','c'),make_set(1+2,concat('a','b'),'c');
@@ -16,3 +17,21 @@ select elt(2,1),field(NULL,"a","b","c");
select find_in_set("","a,b,c"),find_in_set("","a,b,c,"),find_in_set("",",a,b,c");
select find_in_set("abc","abc"),find_in_set("ab","abc"),find_in_set("abcd","abc");
select interval(null, 1, 10, 100);
+
+#
+# test for a bug with elt()
+#
+
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+create table t1 (id int(10) not null unique);
+create table t2 (id int(10) not null primary key,
+val int(10) not null);
+insert into t1 values (1),(2),(4);
+insert into t2 values (1,1),(2,1),(3,1),(4,2);
+
+select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id;
+select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id;
+drop table t1,t2;
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index 5ea3654134b..4ae586256ae 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -4,13 +4,19 @@
# -----------
# Testing string functions
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
+set names latin1;
select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo';
select 'hello' 'monty';
select length('\n\t\r\b\0\_\%\\');
select bit_length('\n\t\r\b\0\_\%\\');
-select concat('monty',' was here ','again'),length('hello'),char(ascii('h'));
+select char_length('\n\t\r\b\0\_\%\\');
+select length(_latin1'\n\t\n\b\0\\_\\%\\');
+select concat('monty',' was here ','again'),length('hello'),char(ascii('h')),ord('h');
select locate('he','hello'),locate('he','hello',2),locate('lo','hello',2) ;
select instr('hello','HE'), instr('hello',binary 'HE'), instr(binary 'hello','HE');
select position(binary 'll' in 'hello'),position('a' in binary 'hello');
@@ -36,7 +42,13 @@ select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c');
select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') ;
select soundex(''),soundex('he'),soundex('hello all folks');
+select 'mood' sounds like 'mud';
+select 'Glazgo' sounds like 'Liverpool';
+select null sounds like 'null';
+select 'null' sounds like null;
+select null sounds like null;
select md5('hello');
+select crc32("123");
select sha('abc');
select sha1('abc');
select aes_decrypt(aes_encrypt('abc','1'),'1');
@@ -111,9 +123,9 @@ CREATE TABLE t1 (
) TYPE=MyISAM;
INSERT INTO t1 VALUES (1,'Link',1,1,1,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa','2001-02-28 08:40:16',20010228084016,0,4);
-SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter), '"') FROM t1;
+SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter), '"') FROM t1;
SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugstatus,submitter), '"') FROM t1;
-SELECT CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter) FROM t1;
+SELECT CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter) FROM t1;
SELECT bugdesc, REPLACE(bugdesc, 'xxxxxxxxxxxxxxxxxxxx', 'bbbbbbbbbbbbbbbbbbbb') from t1 group by bugdesc;
drop table t1;
@@ -126,6 +138,187 @@ INSERT INTO t1 VALUES (1, 'a545f661efdd1fb66fdee3aab79945bf');
SELECT 1 FROM t1 WHERE tmp=AES_DECRYPT(tmp,"password");
DROP TABLE t1;
+#
+# Test collation and coercibility
+#
+
+select 1=_latin1'1';
+select _latin1'1'=1;
+select _latin2'1'=1;
+select 1=_latin2'1';
+--error 1266
+select _latin1'1'=_latin2'1';
+select row('a','b','c') = row('a','b','c');
+select row('A','b','c') = row('a','b','c');
+select row('A' COLLATE latin1_bin,'b','c') = row('a','b','c');
+select row('A','b','c') = row('a' COLLATE latin1_bin,'b','c');
+--error 1266
+select row('A' COLLATE latin1_general_ci,'b','c') = row('a' COLLATE latin1_bin,'b','c');
+
+--error 1266
+select concat(_latin1'a',_latin2'a');
+--error 1269
+select concat(_latin1'a',_latin2'a',_latin5'a');
+--error 1270
+select concat(_latin1'a',_latin2'a',_latin5'a',_latin7'a');
+
+
+#
+# Test FIELD() and collations
+#
+select FIELD('b','A','B');
+select FIELD('B','A','B');
+select FIELD('b' COLLATE latin1_bin,'A','B');
+select FIELD('b','A' COLLATE latin1_bin,'B');
+--error 1269
+select FIELD(_latin2'b','A','B');
+--error 1269
+select FIELD('b',_latin2'A','B');
+select FIELD('b',_latin2'A','B',1);
+
+
+select POSITION(_latin1'B' IN _latin1'abcd');
+select POSITION(_latin1'B' IN _latin1'abcd' COLLATE latin1_bin);
+select POSITION(_latin1'B' COLLATE latin1_bin IN _latin1'abcd');
+--error 1266
+select POSITION(_latin1'B' COLLATE latin1_general_ci IN _latin1'abcd' COLLATE latin1_bin);
+--error 1266
+select POSITION(_latin1'B' IN _latin2'abcd');
+
+select FIND_IN_SET(_latin1'B',_latin1'a,b,c,d');
+--fix this:
+--select FIND_IN_SET(_latin1'B',_latin1'a,b,c,d' COLLATE latin1_bin);
+--select FIND_IN_SET(_latin1'B' COLLATE latin1_bin,_latin1'a,b,c,d');
+--error 1266
+select FIND_IN_SET(_latin1'B' COLLATE latin1_general_ci,_latin1'a,b,c,d' COLLATE latin1_bin);
+--error 1266
+select FIND_IN_SET(_latin1'B',_latin2'a,b,c,d');
+
+select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd',2);
+--fix this:
+--select SUBSTRING_INDEX(_latin1'abcdabcdabcd' COLLATE latin1_bin,_latin1'd',2);
+--select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd' COLLATE latin1_bin,2);
+--error 1266
+select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin2'd',2);
+--error 1266
+select SUBSTRING_INDEX(_latin1'abcdabcdabcd' COLLATE latin1_general_ci,_latin1'd' COLLATE latin1_bin,2);
+
+select _latin1'B' between _latin1'a' and _latin1'c';
+select _latin1'B' collate latin1_bin between _latin1'a' and _latin1'c';
+select _latin1'B' between _latin1'a' collate latin1_bin and _latin1'c';
+select _latin1'B' between _latin1'a' and _latin1'c' collate latin1_bin;
+--error 1269
+select _latin2'B' between _latin1'a' and _latin1'b';
+--error 1269
+select _latin1'B' between _latin2'a' and _latin1'b';
+--error 1269
+select _latin1'B' between _latin1'a' and _latin2'b';
+--error 1269
+select _latin1'B' collate latin1_general_ci between _latin1'a' collate latin1_bin and _latin1'b';
+
+select _latin1'B' in (_latin1'a',_latin1'b');
+select _latin1'B' collate latin1_bin in (_latin1'a',_latin1'b');
+select _latin1'B' in (_latin1'a' collate latin1_bin,_latin1'b');
+select _latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin);
+--error 1269
+select _latin2'B' in (_latin1'a',_latin1'b');
+--error 1269
+select _latin1'B' in (_latin2'a',_latin1'b');
+--error 1269
+select _latin1'B' in (_latin1'a',_latin2'b');
+--error 1269
+select _latin1'B' COLLATE latin1_general_ci in (_latin1'a' COLLATE latin1_bin,_latin1'b');
+--error 1269
+select _latin1'B' COLLATE latin1_general_ci in (_latin1'a',_latin1'b' COLLATE latin1_bin);
+
+select collation(bin(130)), coercibility(bin(130));
+select collation(oct(130)), coercibility(oct(130));
+select collation(conv(130,16,10)), coercibility(conv(130,16,10));
+select collation(hex(130)), coercibility(hex(130));
+select collation(char(130)), coercibility(hex(130));
+select collation(format(130,10)), coercibility(format(130,10));
+select collation(lcase(_latin2'a')), coercibility(lcase(_latin2'a'));
+select collation(ucase(_latin2'a')), coercibility(ucase(_latin2'a'));
+select collation(left(_latin2'a',1)), coercibility(left(_latin2'a',1));
+select collation(right(_latin2'a',1)), coercibility(right(_latin2'a',1));
+select collation(substring(_latin2'a',1,1)), coercibility(substring(_latin2'a',1,1));
+select collation(concat(_latin2'a',_latin2'b')), coercibility(concat(_latin2'a',_latin2'b'));
+select collation(lpad(_latin2'a',4,_latin2'b')), coercibility(lpad(_latin2'a',4,_latin2'b'));
+select collation(rpad(_latin2'a',4,_latin2'b')), coercibility(rpad(_latin2'a',4,_latin2'b'));
+select collation(concat_ws(_latin2'a',_latin2'b')), coercibility(concat_ws(_latin2'a',_latin2'b'));
+select collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')), coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c'));
+select collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')), coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' '));
+select collation(trim(_latin2' a ')), coercibility(trim(_latin2' a '));
+select collation(ltrim(_latin2' a ')), coercibility(ltrim(_latin2' a '));
+select collation(rtrim(_latin2' a ')), coercibility(rtrim(_latin2' a '));
+select collation(trim(LEADING _latin2' ' FROM _latin2'a')), coercibility(trim(LEADING _latin2'a' FROM _latin2'a'));
+select collation(trim(TRAILING _latin2' ' FROM _latin2'a')), coercibility(trim(TRAILING _latin2'a' FROM _latin2'a'));
+select collation(trim(BOTH _latin2' ' FROM _latin2'a')), coercibility(trim(BOTH _latin2'a' FROM _latin2'a'));
+select collation(repeat(_latin2'a',10)), coercibility(repeat(_latin2'a',10));
+select collation(reverse(_latin2'ab')), coercibility(reverse(_latin2'ab'));
+select collation(quote(_latin2'ab')), coercibility(quote(_latin2'ab'));
+select collation(soundex(_latin2'ab')), coercibility(soundex(_latin2'ab'));
+select collation(substring(_latin2'ab',1)), coercibility(substring(_latin2'ab',1));
+select collation(insert(_latin2'abcd',2,3,_latin2'ef')), coercibility(insert(_latin2'abcd',2,3,_latin2'ef'));
+select collation(replace(_latin2'abcd',_latin2'b',_latin2'B')), coercibility(replace(_latin2'abcd',_latin2'b',_latin2'B'));
+
+create table t1
+select
+ bin(130),
+ oct(130),
+ conv(130,16,10),
+ hex(130),
+ char(130),
+ format(130,10),
+ left(_latin2'a',1),
+ right(_latin2'a',1),
+ lcase(_latin2'a'),
+ ucase(_latin2'a'),
+ substring(_latin2'a',1,1),
+ concat(_latin2'a',_latin2'b'),
+ lpad(_latin2'a',4,_latin2'b'),
+ rpad(_latin2'a',4,_latin2'b'),
+ concat_ws(_latin2'a',_latin2'b'),
+ make_set(255,_latin2'a',_latin2'b',_latin2'c'),
+ export_set(255,_latin2'y',_latin2'n',_latin2' '),
+ trim(_latin2' a '),
+ ltrim(_latin2' a '),
+ rtrim(_latin2' a '),
+ trim(LEADING _latin2' ' FROM _latin2' a '),
+ trim(TRAILING _latin2' ' FROM _latin2' a '),
+ trim(BOTH _latin2' ' FROM _latin2' a '),
+ repeat(_latin2'a',10),
+ reverse(_latin2'ab'),
+ quote(_latin2'ab'),
+ soundex(_latin2'ab'),
+ substring(_latin2'ab',1),
+ insert(_latin2'abcd',2,3,_latin2'ef'),
+ replace(_latin2'abcd',_latin2'b',_latin2'B')
+;
+show create table t1;
+drop table t1;
+
+#
+# test for SUBSTR
+#
+select SUBSTR('abcdefg',3,2);
+select SUBSTRING('abcdefg',3,2);
+select SUBSTR('abcdefg',-3,2) FROM DUAL;
+select SUBSTR('abcdefg',-1,5) FROM DUAL;
+select SUBSTR('abcdefg',0,0) FROM DUAL;
+select SUBSTR('abcdefg',-1,-1) FROM DUAL;
+select SUBSTR('abcdefg',1,-1) FROM DUAL;
+
+#
+# Test that fix_fields doesn't follow to upper level (to comparison)
+# when an error on a lower level (in concat) has accured:
+#
+create table t7 (s1 char);
+--error 1266
+select * from t7
+where concat(s1 collate latin1_general_ci,s1 collate latin1_swedish_ci) = 'AA';
+drop table t7;
+
CREATE TABLE t1 (
wid int(10) unsigned NOT NULL auto_increment,
data_podp date default NULL,
@@ -141,13 +334,12 @@ DROP TABLE t1;
#
# test for #739
-CREATE TABLE t1 (
- title text
-) TYPE=MyISAM;
-
+CREATE TABLE t1 (title text) TYPE=MyISAM;
INSERT INTO t1 VALUES ('Congress reconvenes in September to debate welfare and adult education');
INSERT INTO t1 VALUES ('House passes the CAREERS bill');
-
SELECT CONCAT("</a>",RPAD("",(55 - LENGTH(title)),".")) from t1;
-
DROP TABLE t1;
+
+select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2);
+
+explain extended select md5('hello'), sha('abc'), sha1('abc'), soundex(''), 'mood' sounds like 'mud', aes_decrypt(aes_encrypt('abc','1'),'1'),concat('*',space(5),'*'), reverse('abc'), rpad('a',4,'1'), lpad('a',4,'1'), concat_ws(',','',NULL,'a'),make_set(255,_latin2'a',_latin2'b',_latin2'c'),elt(2,1),locate("a","b",2),format(130,10),char(0),conv(130,16,10),hex(130),binary 'HE', export_set(255,_latin2'y',_latin2'n',_latin2' '),FIELD('b' COLLATE latin1_bin,'A','B'),FIND_IN_SET(_latin1'B',_latin1'a,b,c,d'),collation(conv(130,16,10)), coercibility(conv(130,16,10)),length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),concat('monty',' was here ','again'),length('hello'),char(ascii('h')),ord('h'),quote(1/0),crc32("123"),replace('aaaa','a','b'),insert('txs',2,1,'hi'),left(_latin2'a',1),right(_latin2'a',1),lcase(_latin2'a'),ucase(_latin2'a'),SUBSTR('abcdefg',3,2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),trim(_latin2' a '),ltrim(_latin2' a '),rtrim(_latin2' a '), decode(encode(repeat("a",100000),"monty"),"monty");
diff --git a/mysql-test/t/func_system.test b/mysql-test/t/func_system.test
index 052e0530cf6..f3b9b4ffc3f 100644
--- a/mysql-test/t/func_system.test
+++ b/mysql-test/t/func_system.test
@@ -2,5 +2,25 @@
# system functions
#
-select database(),user() like "%@%";
+select database();
+select charset(database());
+select database() = "test";
+select database() = _utf8"test";
+select database() = _latin1"test";
+
+select user() like "%@%";
+select user() like _utf8"%@%";
+select user() like _latin1"%@%";
+select charset(user());
+
select version()>="3.23.29";
+select version()>=_utf8"3.23.29";
+select version()>=_latin1"3.23.29";
+select charset(version());
+explain extended select database(), user();
+
+create table t1 (version char(40)) select database(), user(), version() as 'version';
+show create table t1;
+drop table t1;
+
+select TRUE,FALSE,NULL;
diff --git a/mysql-test/t/func_test.test b/mysql-test/t/func_test.test
index e03d0dd0f0f..86e0ee2637b 100644
--- a/mysql-test/t/func_test.test
+++ b/mysql-test/t/func_test.test
@@ -1,3 +1,6 @@
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
#
# Testing of comparison functions
#
@@ -16,11 +19,19 @@ select 'b' between 'a' and 'c', 'B' between 'a' and 'c';
select 2 in (3,2,5,9,5,1),"monty" in ("david","monty","allan"), 1.2 in (1.4,1.2,1.0);
select -1.49 or -1.49,0.6 or 0.6;
select 3 ^ 11, 1 ^ 1, 1 ^ 0, 1 ^ NULL, NULL ^ 1;
+explain extended select 3 ^ 11, 1 ^ 1, 1 ^ 0, 1 ^ NULL, NULL ^ 1;
select 1 XOR 1, 1 XOR 0, 0 XOR 1, 0 XOR 0, NULL XOR 1, 1 XOR NULL, 0 XOR NULL;
+select 10 % 7, 10 mod 7, 10 div 3;
+explain extended select 10 % 7, 10 mod 7, 10 div 3;
+select (1 << 64)-1, ((1 << 64)-1) DIV 1, ((1 << 64)-1) DIV 2;
+explain extended select (1 << 64)-1, ((1 << 64)-1) DIV 1, ((1 << 64)-1) DIV 2;
create table t1 (a int);
insert t1 values (1);
select * from t1 where 1 xor 1;
+explain extended select * from t1 where 1 xor 1;
+select - a from t1;
+explain extended select - a from t1;
drop table t1;
#
@@ -30,7 +41,44 @@ drop table t1;
select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1;
select 1 and 2 between 2 and 10, 2 between 2 and 10 and 1;
select 1 and 0 or 2, 2 or 1 and 0;
-DROP TABLE IF EXISTS t1,t2;
+
+#
+# Coercibility
+#
+select _koi8r'a' = _koi8r'A';
+select _koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci;
+explain extended select _koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci;
+select _koi8r'a' = _koi8r'A' COLLATE koi8r_bin;
+select _koi8r'a' COLLATE koi8r_general_ci = _koi8r'A';
+select _koi8r'a' COLLATE koi8r_bin = _koi8r'A';
+--error 1266
+select _koi8r'a' COLLATE koi8r_bin = _koi8r'A' COLLATE koi8r_general_ci;
+--error 1266
+select _koi8r'a' = _latin1'A';
+
+select strcmp(_koi8r'a', _koi8r'A');
+select strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_general_ci);
+select strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_bin);
+select strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A');
+select strcmp(_koi8r'a' COLLATE koi8r_bin, _koi8r'A');
+--error 1266
+select strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A' COLLATE koi8r_bin);
+--error 1266
+select strcmp(_koi8r'a', _latin1'A');
+
+select _koi8r'a' LIKE _koi8r'A';
+select _koi8r'a' LIKE _koi8r'A' COLLATE koi8r_general_ci;
+select _koi8r'a' LIKE _koi8r'A' COLLATE koi8r_bin;
+select _koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A';
+select _koi8r'a' COLLATE koi8r_bin LIKE _koi8r'A';
+--error 1266
+select _koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A' COLLATE koi8r_bin;
+--error 1266
+select _koi8r'a' LIKE _latin1'A';
+
+#
+# Test for LEAST() BUG in LEFT JOIN
+#
CREATE TABLE t1 ( faq_group_id int(11) NOT NULL default '0', faq_id int(11) NOT NULL default '0', title varchar(240) default NULL, keywords text, description longblob, solution longblob, status tinyint(4) NOT NULL default '0', access_id smallint(6) default NULL, lang_id smallint(6) NOT NULL default '0', created datetime NOT NULL default '0000-00-00 00:00:00', updated datetime default NULL, last_access datetime default NULL, last_notify datetime default NULL, solved_count int(11) NOT NULL default '0', static_solved int(11) default NULL, solved_1 int(11) default NULL, solved_2 int(11) default NULL, solved_3 int(11) default NULL, solved_4 int(11) default NULL, solved_5 int(11) default NULL, expires datetime default NULL, notes text, assigned_to smallint(6) default NULL, assigned_group smallint(6) default NULL, last_edited_by smallint(6) default NULL, orig_ref_no varchar(15) binary default NULL, c$fundstate smallint(6) default NULL, c$contributor smallint(6) default NULL, UNIQUE KEY t1$faq_id (faq_id), KEY t1$group_id$faq_id (faq_group_id,faq_id), KEY t1$c$fundstate (c$fundstate) ) TYPE=MyISAM;
INSERT INTO t1 VALUES (82,82,'How to use the DynaVox Usage Counts Feature','usages count, number, corner, white, box, button','<as-html>\r\n<table width=\"100%\" border=\"0\">\r\n <tr>\r\n <td width=\"3%\"> </td>\r\n <td width=\"97%\">\r\n <h3><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#000000\">How \r\n To</font><!-- #BeginEditable \"CS_troubleshoot_question\" --><font face=\"Verdana, Arial, Helvetica, sans-serif\" color=\"#000099\"><font color=\"#000000\">: \r\n Display or Hide the Usage Counts to find out how many times each button is being selected. </font></font><!-- #EndEditable --></h3>\r\n </td>\r\n </tr>\r\n</table>','<as-html>\r\n <table width=\"100%\" border=\"0\">\r\n <tr>\r\n <td width=\"3%\"> </td>\r\n \r\n<td width=\"97%\"><!-- #BeginEditable \"CS_troubleshoot_answer\" --> \r\n \r\n<p><font color=\"#000000\" face=\"Verdana, Arial, Helvetica, sans-serif\">1. Select \r\n the <i>On/Setup</i> button to access the DynaVox Setup Menu.<br>\r\n 2. Select <b>Button Features.</b><br>\r\n 3. Below the <b>OK</b> button is the <b>Usage Counts</b> button.<br>\r\n a. If it says \"Hidden\" then the Usage Counts will not be displayed.<br>\r\n b. If it says \"Displayed\" then the Usage Counts will be shown.<br>\r\n c. Select the <b>Usage Counts</b> Option Ring once and it will toggle \r\n to the alternative option.<br>\r\n 4. Once the correct setting has been chosen, select <b>OK</b> to leave the <i>Button \r\n Features</i> menu.<br>\r\n 5. Select <b>OK</b> out of the <i>Setup</i> menu and return to the communication \r\n page.</font></p>\r\n <p><font color=\"#000000\" face=\"Verdana, Arial, Helvetica, sans-serif\">For \r\n further information on <i>Usage Counts,</i> see the <i>Button Features \r\n Menu Entry</i> in the DynaVox/DynaMyte Reference Manual.</font></p>\r\n<!-- #EndEditable --></td>\r\n </tr>\r\n</table>',4,1,1,'2001-11-16 16:43:34','2002-11-25 12:09:43','2003-07-24 01:04:48',NULL,11,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,11,NULL,NULL,NULL);
CREATE TABLE t2 ( access_id smallint(6) NOT NULL default '0', name varchar(20) binary default NULL, rank smallint(6) NOT NULL default '0', KEY t2$access_id (access_id) ) TYPE=MyISAM;
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index a51869e7d76..f1a24a4c3cb 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -1,10 +1,13 @@
#
# time functions
#
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
select from_days(to_days("960101")),to_days(960201)-to_days("19960101"),to_days(date_add(curdate(), interval 1 day))-to_days(curdate()),weekday("1997-11-29");
select period_add("9602",-12),period_diff(199505,"9404") ;
+
select now()-now(),weekday(curdate())-weekday(now()),unix_timestamp()-unix_timestamp(now());
select from_unixtime(unix_timestamp("1994-03-02 10:11:12")),from_unixtime(unix_timestamp("1994-03-02 10:11:12"),"%Y-%m-%d %h:%i:%s"),from_unixtime(unix_timestamp("1994-03-02 10:11:12"))+0;
select sec_to_time(9001),sec_to_time(9001)+0,time_to_sec("15:12:22"),
@@ -189,3 +192,58 @@ select * from t1, t2 where t1.start between t2.ctime1 and t2.ctime2;
select * from t1, t2 where t1.start >= t2.ctime1 and t1.start <= t2.ctime2;
select * from t1, t3 where t1.start between t3.ctime1 and t3.ctime2;
drop table t1,t2,t3;
+
+#
+# Test types from + INTERVAL
+#
+
+CREATE TABLE t1 (datetime datetime, timestamp timestamp, date date, time time);
+INSERT INTO t1 values ("2001-01-02 03:04:05", "2002-01-02 03:04:05", "2003-01-02", "06:07:08");
+SELECT * from t1;
+select date_add("1997-12-31",INTERVAL 1 SECOND);
+select date_add("1997-12-31",INTERVAL "1 1" YEAR_MONTH);
+
+select date_add(datetime, INTERVAL 1 SECOND) from t1;
+select date_add(datetime, INTERVAL 1 YEAR) from t1;
+
+select date_add(date,INTERVAL 1 SECOND) from t1;
+select date_add(date,INTERVAL 1 MINUTE) from t1;
+select date_add(date,INTERVAL 1 HOUR) from t1;
+select date_add(date,INTERVAL 1 DAY) from t1;
+select date_add(date,INTERVAL 1 MONTH) from t1;
+select date_add(date,INTERVAL 1 YEAR) from t1;
+select date_add(date,INTERVAL "1:1" MINUTE_SECOND) from t1;
+select date_add(date,INTERVAL "1:1" HOUR_MINUTE) from t1;
+select date_add(date,INTERVAL "1:1" DAY_HOUR) from t1;
+select date_add(date,INTERVAL "1 1" YEAR_MONTH) from t1;
+select date_add(date,INTERVAL "1:1:1" HOUR_SECOND) from t1;
+select date_add(date,INTERVAL "1 1:1" DAY_MINUTE) from t1;
+select date_add(date,INTERVAL "1 1:1:1" DAY_SECOND) from t1;
+
+# The following is not as one would expect...
+select date_add(time,INTERVAL 1 SECOND) from t1;
+drop table t1;
+
+# test for last_day
+select last_day('2000-02-05') as f1, last_day('2002-12-31') as f2,
+ last_day('2003-03-32') as f3, last_day('2003-04-01') as f4,
+ last_day('2001-01-01 01:01:01') as f5, last_day(NULL),
+ last_day('2001-02-12');
+
+create table t1 select last_day('2000-02-05') as a;
+describe t1;
+select * from t1;
+drop table t1;
+select last_day('2000-02-05');
+
+
+# Test SAPDB UTC_% functions. This part is TZ dependant (It is supposed that
+# TZ variable set to GMT-3
+select strcmp(date_sub(localtimestamp(), interval 3 hour), utc_timestamp())=0;
+select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%T"), utc_time())=0;
+select strcmp(date_format(date_sub(localtimestamp(), interval 3 hour),"%Y-%m-%d"), utc_date())=0;
+select strcmp(date_format(utc_timestamp(),"%T"), utc_time())=0;
+select strcmp(date_format(utc_timestamp(),"%Y-%m-%d"), utc_date())=0;
+select strcmp(concat(utc_date(),' ',utc_time()),utc_timestamp())=0;
+
+explain extended select period_add("9602",-12),period_diff(199505,"9404"),from_days(to_days("960101")),dayofmonth("1997-01-02"), month("1997-01-02"), monthname("1972-03-04"),dayofyear("0000-00-00"),HOUR("1997-03-03 23:03:22"),MINUTE("23:03:22"),SECOND(230322),QUARTER(980303),WEEK("1998-03-03"),yearweek("2000-01-01",1),week(19950101,1),year("98-02-03"),weekday(curdate())-weekday(now()),dayname("1962-03-03"),unix_timestamp(),sec_to_time(time_to_sec("0:30:47")/6.21),curtime(),utc_time(),curdate(),utc_date(),utc_timestamp(),date_format("1997-01-02 03:04:05", "%M %W %D %Y %y %m %d %h %i %s %w"),from_unixtime(unix_timestamp("1994-03-02 10:11:12")),"1997-12-31 23:59:59" + INTERVAL 1 SECOND,"1998-01-01 00:00:00" - INTERVAL 1 SECOND,INTERVAL 1 DAY + "1997-12-31", extract(YEAR FROM "1999-01-02 10:11:12"),date_add("1997-12-31 23:59:59",INTERVAL 1 SECOND);
diff --git a/mysql-test/t/func_timestamp.test b/mysql-test/t/func_timestamp.test
index 74e541f782d..8583c16073d 100644
--- a/mysql-test/t/func_timestamp.test
+++ b/mysql-test/t/func_timestamp.test
@@ -2,7 +2,10 @@
# Tests that depend on the timestamp and the TZ variable
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (Zeit time, Tag tinyint not null, Monat tinyint not null,
Jahr smallint not null, index(Tag), index(Monat), index(Jahr) );
insert into t1 values ("09:26:00",16,9,1998),("09:26:00",16,9,1998);
diff --git a/mysql-test/t/gcc296.test b/mysql-test/t/gcc296.test
index 7c72b57ca54..ebca4dbc897 100644
--- a/mysql-test/t/gcc296.test
+++ b/mysql-test/t/gcc296.test
@@ -1,6 +1,9 @@
#try to crash gcc 2.96
-drop table if exists obory;
-CREATE TABLE obory (
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+CREATE TABLE t1 (
kodoboru varchar(10) default NULL,
obor tinytext,
aobor tinytext,
@@ -8,10 +11,10 @@ CREATE TABLE obory (
FULLTEXT KEY obor (obor),
FULLTEXT KEY aobor (aobor)
);
-INSERT INTO obory VALUES ('0101000000','aaa','AAA');
-INSERT INTO obory VALUES ('0102000000','bbb','BBB');
-INSERT INTO obory VALUES ('0103000000','ccc','CCC');
-INSERT INTO obory VALUES ('0104000000','xxx','XXX');
+INSERT INTO t1 VALUES ('0101000000','aaa','AAA');
+INSERT INTO t1 VALUES ('0102000000','bbb','BBB');
+INSERT INTO t1 VALUES ('0103000000','ccc','CCC');
+INSERT INTO t1 VALUES ('0104000000','xxx','XXX');
-select * from obory;
-drop table obory;
+select * from t1;
+drop table t1;
diff --git a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test
new file mode 100644
index 00000000000..0368ddb41cb
--- /dev/null
+++ b/mysql-test/t/gis-rtree.test
@@ -0,0 +1,69 @@
+#
+# test of rtree (using with spatial data)
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+
+CREATE TABLE t1 (
+ fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ g GEOMETRY NOT NULL,
+ SPATIAL KEY(g)
+) TYPE=MyISAM;
+
+SHOW CREATE TABLE t1;
+
+let $1=150;
+let $2=150;
+while ($1)
+{
+ eval INSERT INTO t1 (g) VALUES (GeomFromText('LineString($1 $1, $2 $2)'));
+ dec $1;
+ inc $2;
+}
+
+SELECT count(*) FROM t1;
+EXPLAIN SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
+SELECT fid, AsText(g) FROM t1 WHERE Within(g, GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))'));
+
+DROP TABLE t1;
+
+CREATE TABLE t2 (
+ fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ g GEOMETRY NOT NULL
+) TYPE=MyISAM;
+
+let $1=10;
+while ($1)
+{
+ let $2=10;
+ while ($2)
+ {
+ eval INSERT INTO t2 (g) VALUES (GeometryFromWKB(LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10))));
+ dec $2;
+ }
+ dec $1;
+}
+
+ALTER TABLE t2 ADD SPATIAL KEY(g);
+SHOW CREATE TABLE t2;
+SELECT count(*) FROM t2;
+EXPLAIN SELECT fid, AsText(g) FROM t2 WHERE Within(g,
+ GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
+SELECT fid, AsText(g) FROM t2 WHERE Within(g,
+ GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
+
+let $1=10;
+while ($1)
+{
+ let $2=10;
+ while ($2)
+ {
+ eval DELETE FROM t2 WHERE Within(g, Envelope(GeometryFromWKB(LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10)))));
+ SELECT count(*) FROM t2;
+ dec $2;
+ }
+ dec $1;
+}
+
+DROP TABLE t2;
diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test
new file mode 100644
index 00000000000..c8f50e968ab
--- /dev/null
+++ b/mysql-test/t/gis.test
@@ -0,0 +1,161 @@
+#
+# Spatial objects
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS pt, ls, p, mpt, mls, mp, gc, geo;
+--enable_warnings
+
+CREATE TABLE pt (fid INTEGER NOT NULL PRIMARY KEY, g POINT);
+CREATE TABLE ls (fid INTEGER NOT NULL PRIMARY KEY, g LINESTRING);
+CREATE TABLE p (fid INTEGER NOT NULL PRIMARY KEY, g POLYGON);
+CREATE TABLE mpt (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOINT);
+CREATE TABLE mls (fid INTEGER NOT NULL PRIMARY KEY, g MULTILINESTRING);
+CREATE TABLE mp (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOLYGON);
+CREATE TABLE gc (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRYCOLLECTION);
+CREATE TABLE geo (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY);
+
+SHOW FIELDS FROM pt;
+SHOW FIELDS FROM ls;
+SHOW FIELDS FROM p;
+SHOW FIELDS FROM mpt;
+SHOW FIELDS FROM mls;
+SHOW FIELDS FROM mp;
+SHOW FIELDS FROM gc;
+SHOW FIELDS FROM geo;
+
+
+INSERT INTO pt 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 ls 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(LineString(Point(10, 10), Point(40, 10))));
+
+INSERT INTO p 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(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))));
+
+INSERT INTO mpt 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(MultiPoint(Point(3, 6), Point(4, 10))));
+
+INSERT INTO mls 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(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7)))));
+
+
+INSERT INTO mp 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(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))));
+
+INSERT INTO gc VALUES
+(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
+(121, GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))));
+
+INSERT into geo SELECT * FROM pt;
+INSERT into geo SELECT * FROM ls;
+INSERT into geo SELECT * FROM p;
+INSERT into geo SELECT * FROM mpt;
+INSERT into geo SELECT * FROM mls;
+INSERT into geo SELECT * FROM mp;
+INSERT into geo SELECT * FROM gc;
+
+SELECT fid, AsText(g) FROM pt;
+SELECT fid, AsText(g) FROM ls;
+SELECT fid, AsText(g) FROM p;
+SELECT fid, AsText(g) FROM mpt;
+SELECT fid, AsText(g) FROM mls;
+SELECT fid, AsText(g) FROM mp;
+SELECT fid, AsText(g) FROM gc;
+SELECT fid, AsText(g) FROM geo;
+
+SELECT fid, Dimension(g) FROM geo;
+SELECT fid, GeometryType(g) FROM geo;
+SELECT fid, IsEmpty(g) FROM geo;
+SELECT fid, AsText(Envelope(g)) FROM geo;
+explain extended select Dimension(g), GeometryType(g), IsEmpty(g), AsText(Envelope(g)) from geo;
+
+SELECT fid, X(g) FROM pt;
+SELECT fid, Y(g) FROM pt;
+explain extended select X(g),Y(g) FROM pt;
+
+SELECT fid, AsText(StartPoint(g)) FROM ls;
+SELECT fid, AsText(EndPoint(g)) FROM ls;
+SELECT fid, GLength(g) FROM ls;
+SELECT fid, NumPoints(g) FROM ls;
+SELECT fid, AsText(PointN(g, 2)) FROM ls;
+SELECT fid, IsClosed(g) FROM ls;
+explain extended select AsText(StartPoint(g)),AsText(EndPoint(g)),GLength(g),NumPoints(g),AsText(PointN(g, 2)),IsClosed(g) FROM ls;
+
+SELECT fid, AsText(Centroid(g)) FROM p;
+SELECT fid, Area(g) FROM p;
+SELECT fid, AsText(ExteriorRing(g)) FROM p;
+SELECT fid, NumInteriorRings(g) FROM p;
+SELECT fid, AsText(InteriorRingN(g, 1)) FROM p;
+explain extended select AsText(Centroid(g)),Area(g),AsText(ExteriorRing(g)),NumInteriorRings(g),AsText(InteriorRingN(g, 1)) FROM p;
+
+SELECT fid, IsClosed(g) FROM mls;
+
+SELECT fid, AsText(Centroid(g)) FROM mp;
+SELECT fid, Area(g) FROM mp;
+
+SELECT fid, NumGeometries(g) from mpt;
+SELECT fid, NumGeometries(g) from mls;
+SELECT fid, NumGeometries(g) from mp;
+SELECT fid, NumGeometries(g) from gc;
+explain extended SELECT fid, NumGeometries(g) from mpt;
+
+SELECT fid, AsText(GeometryN(g, 2)) from mpt;
+SELECT fid, AsText(GeometryN(g, 2)) from mls;
+SELECT fid, AsText(GeometryN(g, 2)) from mp;
+SELECT fid, AsText(GeometryN(g, 2)) from gc;
+explain extended SELECT fid, AsText(GeometryN(g, 2)) from mpt;
+
+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 gc g1, gc g2 ORDER BY first, second;
+explain extended 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 gc g1, gc g2 ORDER BY first, second;
+
+DROP TABLE pt, ls, p, mpt, mls, mp, gc, geo;
+
+#
+# Check that ALTER TABLE doesn't loose geometry type
+#
+CREATE TABLE g1 (
+ pt point,
+ ln linestring,
+ pg polygon,
+ mpt multipoint,
+ mln multilinestring,
+ mpg multipolygon,
+ gc geometrycollection,
+ gm geometry
+);
+
+SHOW FIELDS FROM g1;
+ALTER TABLE g1 ADD fid INT NOT NULL;
+SHOW FIELDS FROM g1;
+DROP TABLE g1;
+
+SELECT AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)'))));
+explain extended SELECT AsText(GeometryFromWKB(AsWKB(GeometryFromText('POINT(1 4)'))));
+explain extended SELECT AsText(GeometryFromWKB(AsWKB(PointFromText('POINT(1 4)'))));
+SELECT SRID(GeomFromText('LineString(1 1,2 2)',101));
+explain extended SELECT SRID(GeomFromText('LineString(1 1,2 2)',101));
+#select issimple(MultiPoint(Point(3, 6), Point(4, 10))), issimple(Point(3, 6)),issimple(PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),issimple(GeometryFromText('POINT(1 4)')), issimple(AsWKB(GeometryFromText('POINT(1 4)')));
+explain extended select issimple(MultiPoint(Point(3, 6), Point(4, 10))), issimple(Point(3, 6));
diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test
index 598a7186a6e..78221fa4e40 100644
--- a/mysql-test/t/grant.test
+++ b/mysql-test/t/grant.test
@@ -1,3 +1,6 @@
+# Test of GRANT commands
+
+# Cleanup
--disable_warnings
drop table if exists t1;
--enable_warnings
@@ -89,3 +92,36 @@ drop table t1;
--error 1221
GRANT FILE on mysqltest.* to mysqltest_1@localhost;
select 1; -- To test that the previous command didn't cause problems
+
+#
+# Test for 'drop user', 'revoke privileges, grant'
+#
+
+create table t1 (a int);
+grant ALL PRIVILEGES on *.* to drop_user2@localhost with GRANT OPTION;
+show grants for drop_user2@localhost;
+revoke all privileges, grant from drop_user2@localhost;
+drop user drop_user2@localhost;
+
+grant ALL PRIVILEGES on *.* to drop_user@localhost with GRANT OPTION;
+grant ALL PRIVILEGES on test.* to drop_user@localhost with GRANT OPTION;
+grant select(a) on test.t1 to drop_user@localhost;
+show grants for drop_user@localhost;
+revoke all privileges, grant from drop_user@localhost;
+show grants for drop_user@localhost;
+drop user drop_user@localhost;
+--error 1268
+revoke all privileges, grant from drop_user@localhost;
+
+grant select(a) on test.t1 to drop_user1@localhost;
+grant select on test.t1 to drop_user2@localhost;
+grant select on test.* to drop_user3@localhost;
+grant select on *.* to drop_user4@localhost;
+--error 1267
+drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
+drop_user4@localhost;
+revoke all privileges, grant from drop_user1@localhost, drop_user2@localhost,
+drop_user3@localhost, drop_user4@localhost;
+drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost,
+drop_user4@localhost;
+drop table t1;
diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test
new file mode 100644
index 00000000000..148c4d3da21
--- /dev/null
+++ b/mysql-test/t/grant2.test
@@ -0,0 +1,30 @@
+#
+# GRANT tests that require several connections
+# (usually it's GRANT, reconnect as another user, try something)
+#
+
+
+#
+# wild_compare fun
+#
+
+delete from mysql.user where user like 'mysqltest\_%';
+delete from mysql.db where user like 'mysqltest\_%';
+flush privileges;
+grant all privileges on `my\_%`.* to mysqltest_1@localhost with grant option;
+connect (user1,localhost,mysqltest_1,,);
+connection user1;
+select current_user();
+grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
+--error 1044
+grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
+disconnect user1;
+connection default;
+show grants for mysqltest_1@localhost;
+show grants for mysqltest_2@localhost;
+--error 1141
+show grants for mysqltest_3@localhost;
+delete from mysql.user where user like 'mysqltest\_%';
+delete from mysql.db where user like 'mysqltest\_%';
+flush privileges;
+
diff --git a/mysql-test/t/grant_cache.test b/mysql-test/t/grant_cache.test
index 95989d1ee99..9ba845d6baa 100644
--- a/mysql-test/t/grant_cache.test
+++ b/mysql-test/t/grant_cache.test
@@ -1,17 +1,20 @@
-- source include/have_query_cache.inc
-drop table if exists test.t1,mysqltest.t1,mysqltest.t2;
-drop database if exists mysqltest;
-
#
# Test grants with query cache
#
+--disable_warnings
+drop table if exists test.t1,mysqltest.t1,mysqltest.t2;
+drop database if exists mysqltest;
+--enable_warnings
reset query cache;
flush status;
connect (root,localhost,root,,test,$MASTER_MYPORT,master.sock);
connection root;
+--disable_warnings
create database if not exists mysqltest;
+--enable_warnings
create table mysqltest.t1 (a int,b int,c int);
create table mysqltest.t2 (a int,b int,c int);
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index df99bc2a9dc..705e32c82df 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -1,8 +1,18 @@
+# Initialise
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
+#
+# Simple test without tables
+
+-- error 1111
+SELECT 1 FROM (SELECT 1) as a GROUP BY SUM(1);
+
#
# Test of group (Failed for Lars Hoss <lh@pbm.de>)
#
-drop table if exists t1,t2,t3;
CREATE TABLE t1 (
spID int(10) unsigned,
userID int(10) unsigned,
@@ -43,7 +53,7 @@ SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spI
SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid;
SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL;
EXPLAIN SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL;
-drop table test.t1,test.t2;
+drop table t1,t2;
#
# Bug in GROUP BY, by Nikki Chumakov <nikki@saddam.cityline.ru>
@@ -122,7 +132,7 @@ CREATE TABLE t1 (
assigned_to mediumint(9) DEFAULT '0' NOT NULL,
bug_file_loc text,
bug_severity enum('blocker','critical','major','normal','minor','trivial','enhancement') DEFAULT 'blocker' NOT NULL,
- bug_status enum('NEW','ASSIGNED','REOPENED','RESOLVED','VERIFIED','CLOSED') DEFAULT 'NEW' NOT NULL,
+ bug_status enum('','NEW','ASSIGNED','REOPENED','RESOLVED','VERIFIED','CLOSED') DEFAULT 'NEW' NOT NULL,
creation_ts datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
delta_ts timestamp(14),
short_desc mediumtext,
@@ -250,7 +260,7 @@ explain select spid,count(*) from t1 where spid between 1 and 2 group by spid;
explain select spid,count(*) from t1 where spid between 1 and 2 group by spid order by null;
select spid,count(*) from t1 where spid between 1 and 2 group by spid;
select spid,count(*) from t1 where spid between 1 and 2 group by spid desc;
-explain select sql_big_result spid,sum(userid) from t1 group by spid desc;
+explain extended select sql_big_result spid,sum(userid) from t1 group by spid desc;
explain select sql_big_result spid,sum(userid) from t1 group by spid desc order by null;
select sql_big_result spid,sum(userid) from t1 group by spid desc;
explain select sql_big_result score,count(*) from t1 group by score desc;
@@ -302,7 +312,6 @@ SELECT 1 FROM t1 GROUP BY CONCAT(a, b);
INSERT INTO t1 values ('hij','klm');
SELECT CONCAT(a, b),count(*) FROM t1 GROUP BY 1;
DROP TABLE t1;
-drop table if exists t1;
#
# Test problem with ORDER BY on a SUM() column
diff --git a/mysql-test/t/handler.test b/mysql-test/t/handler.test
index 737b220c805..99ca858990c 100644
--- a/mysql-test/t/handler.test
+++ b/mysql-test/t/handler.test
@@ -2,13 +2,18 @@
# test of HANDLER ...
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (a int, b char(10), key a(a), key b(a,b));
insert into t1 values
(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
(14,"aaa"),(15,"bbb"),(16,"ccc"),(16,"xxx"),
(20,"ggg"),(21,"hhh"),(22,"iii");
handler t1 open as t2;
+-- error 1064
+handler t2 read a=(SELECT 1);
handler t2 read a first;
handler t2 read a next;
handler t2 read a next;
@@ -81,9 +86,8 @@ handler t2 read first;
drop table t1;
#
-# test case for the bug #787
+# Test case for the bug #787
#
-
create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5),(6);
delete from t1 limit 2;
@@ -96,7 +100,7 @@ handler t1 read first;
drop table t1;
#
-#test for #751
+# Test for #751
#
create table t1(a int, index(a));
insert into t1 values (1), (2), (3);
@@ -106,4 +110,3 @@ handler t1 read a=(W);
--error 1210
handler t1 read a=(a);
drop table t1;
-
diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test
index cb6fa85ffde..7e4cbe76cca 100644
--- a/mysql-test/t/having.test
+++ b/mysql-test/t/having.test
@@ -1,12 +1,16 @@
# test of problems with having (Reported by Mark Rogers)
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (a int);
select count(a) as b from t1 where a=0 having b > 0;
insert into t1 values (null);
select count(a) as b from t1 where a=0 having b > 0;
select count(a) as b from t1 where a=0 having b >=0;
+explain extended select count(a) as b from t1 where a=0 having b >=0;
drop table t1;
#
@@ -59,7 +63,12 @@ select Fld1, max(Fld2) as q from t1 group by Fld1 having q is not null;
select Fld1, max(Fld2) from t1 group by Fld1 having max(Fld2) is not null;
select Fld1, max(Fld2) from t1 group by Fld1 having avg(Fld2) is not null;
select Fld1, max(Fld2) from t1 group by Fld1 having std(Fld2) is not null;
+select Fld1, max(Fld2) from t1 group by Fld1 having variance(Fld2) is not null;
drop table t1;
+
+#
+# Test problem with count(distinct) in having
+#
create table t1 (id int not null, qty int not null);
insert into t1 values (1,2),(1,3),(2,4),(2,5);
select id, sum(qty) as sqty from t1 group by id having sqty>2;
diff --git a/mysql-test/t/heap.test b/mysql-test/t/heap.test
index b2de58ca083..797472e7769 100644
--- a/mysql-test/t/heap.test
+++ b/mysql-test/t/heap.test
@@ -2,7 +2,10 @@
# Test of heap tables.
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (a int not null,b int not null, primary key (a)) type=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
insert into t1 values(1,1),(2,2),(3,3),(4,4);
delete from t1 where a=1 or a=0;
@@ -42,7 +45,7 @@ alter table t1 type=myisam;
explain select * from t1 where a in (869751,736494,226312,802616);
drop table t1;
-create table t1 (x int not null, y int not null, key x(x), unique y(y))
+create table t1 (x int not null, y int not null, key x (x), unique y (y))
type=heap;
insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
select * from t1 where x=1;
@@ -102,7 +105,7 @@ insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("
explain select * from t1 where btn like "q%";
select * from t1 where btn like "q%";
alter table t1 add column new_col char(1) not null, add key (btn,new_col), drop key btn;
-update t1 set new_col=btn;
+update t1 set new_col=left(btn,1);
explain select * from t1 where btn="a";
explain select * from t1 where btn="a" and new_col="a";
drop table t1;
diff --git a/mysql-test/t/heap_auto_increment.test b/mysql-test/t/heap_auto_increment.test
new file mode 100644
index 00000000000..6f392f6830d
--- /dev/null
+++ b/mysql-test/t/heap_auto_increment.test
@@ -0,0 +1,33 @@
+#
+# Test of auto_increment; The test for BDB tables is in bdb.test
+#
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (a int not null auto_increment,b int, primary key (a)) type=heap auto_increment=3;
+insert into t1 values (1,1),(NULL,3),(NULL,4);
+delete from t1 where a=4;
+insert into t1 values (NULL,5),(NULL,6);
+select * from t1;
+delete from t1 where a=6;
+#show table status like "t1";
+replace t1 values (3,1);
+ALTER TABLE t1 add c int;
+replace t1 values (3,3,3);
+insert into t1 values (NULL,7,7);
+update t1 set a=8,b=b+1,c=c+1 where a=7;
+insert into t1 values (NULL,9,9);
+select * from t1;
+drop table t1;
+
+create table t1 (
+ skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY,
+ sval char(20)
+) type=heap;
+insert into t1 values (NULL, "hello");
+insert into t1 values (NULL, "hey");
+select * from t1;
+select _rowid,t1._rowid,skey,sval from t1;
+drop table t1;
diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test
new file mode 100644
index 00000000000..34aeeec0a11
--- /dev/null
+++ b/mysql-test/t/heap_btree.test
@@ -0,0 +1,158 @@
+#
+# Test of heap tables.
+#
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (a int not null,b int not null, primary key using BTREE (a)) type=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
+insert into t1 values(1,1),(2,2),(3,3),(4,4);
+delete from t1 where a=1 or a=0;
+#show table status like "t1";
+show keys from t1;
+select * from t1;
+select * from t1 where a=4;
+update t1 set b=5 where a=4;
+update t1 set b=b+1 where a>=3;
+replace t1 values (3,3);
+select * from t1;
+alter table t1 add c int not null, add key using BTREE (c,a);
+drop table t1;
+
+create table t1 (a int not null,b int not null, primary key using BTREE (a)) type=heap comment="testing heaps";
+insert into t1 values(-2,-2),(-1,-1),(0,0),(1,1),(2,2),(3,3),(4,4);
+delete from t1 where a > -3;
+select * from t1;
+drop table t1;
+
+create table t1 (a int not null,b int not null, primary key using BTREE (a)) type=heap comment="testing heaps";
+insert into t1 values(1,1),(2,2),(3,3),(4,4);
+alter table t1 modify a int not null auto_increment, type=myisam, comment="new myisam table";
+#show table status like "t1";
+select * from t1;
+drop table t1;
+
+create table t1 (a int not null) type=heap;
+insert into t1 values (869751),(736494),(226312),(802616);
+select * from t1 where a > 736494;
+alter table t1 add unique uniq_id using BTREE (a);
+select * from t1 where a > 736494;
+select * from t1 where a = 736494;
+select * from t1 where a=869751 or a=736494;
+select * from t1 where a in (869751,736494,226312,802616);
+alter table t1 type=myisam;
+explain select * from t1 where a in (869751,736494,226312,802616);
+drop table t1;
+
+create table t1 (x int not null, y int not null, key x using BTREE (x,y), unique y using BTREE (y))
+type=heap;
+insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
+explain select * from t1 where x=1;
+select * from t1 where x=1;
+select * from t1,t1 as t2 where t1.x=t2.y;
+explain select * from t1,t1 as t2 where t1.x=t2.y;
+drop table t1;
+
+create table t1 (a int) type=heap;
+insert into t1 values(1);
+select max(a) from t1;
+drop table t1;
+
+CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key using BTREE (a,b), key using BTREE (b) ) TYPE=HEAP;
+insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
+select * from t1 where a=1;
+insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
+select * from t1 where a=1;
+--replace_result 0 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12 x 13 x 14 x
+explain select * from t1 where a=1 order by a,b;
+--replace_result 0 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12 x 13 x 14 x
+explain select * from t1 where a=1 order by b;
+select * from t1 where b=1;
+--replace_result 0 x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10 x 11 x 12 x 13 x 14 x
+explain select * from t1 where b=1;
+drop table t1;
+
+create table t1 (id int unsigned not null, primary key using BTREE (id)) type=HEAP;
+insert into t1 values(1);
+select max(id) from t1;
+insert into t1 values(2);
+select max(id) from t1;
+replace into t1 values(1);
+drop table t1;
+
+create table t1 (n int) type=heap;
+drop table t1;
+
+create table t1 (n int) type=heap;
+drop table if exists t1;
+
+# Test of non unique index
+
+CREATE table t1(f1 int not null,f2 char(20) not
+null,index(f2)) type=heap;
+INSERT into t1 set f1=12,f2="bill";
+INSERT into t1 set f1=13,f2="bill";
+INSERT into t1 set f1=14,f2="bill";
+INSERT into t1 set f1=15,f2="bill";
+INSERT into t1 set f1=16,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+delete from t1 where f2="bill";
+select * from t1;
+drop table t1;
+
+#
+# Test when using part key searches
+#
+
+create table t1 (btn char(10) not null, key using BTREE (btn)) type=heap;
+insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
+explain select * from t1 where btn like "q%";
+select * from t1 where btn like "q%";
+alter table t1 add column new_col char(1) not null, add key using BTREE (btn,new_col), drop key btn;
+update t1 set new_col=left(btn,1);
+explain select * from t1 where btn="a";
+explain select * from t1 where btn="a" and new_col="a";
+drop table t1;
+
+#
+# Test of NULL keys
+#
+
+CREATE TABLE t1 (
+ a int default NULL,
+ b int default NULL,
+ KEY a using BTREE (a),
+ UNIQUE b using BTREE (b)
+) type=heap;
+INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
+SELECT * FROM t1 WHERE a=NULL;
+explain SELECT * FROM t1 WHERE a IS NULL;
+SELECT * FROM t1 WHERE a<=>NULL;
+SELECT * FROM t1 WHERE b=NULL;
+explain SELECT * FROM t1 WHERE b IS NULL;
+SELECT * FROM t1 WHERE b<=>NULL;
+
+--error 1062
+INSERT INTO t1 VALUES (1,3);
+DROP TABLE t1;
+
+CREATE TABLE t1 (a int, b int, c int, key using BTREE (a, b, c)) type=heap;
+INSERT INTO t1 VALUES (1, NULL, NULL), (1, 1, NULL), (1, NULL, 1);
+SELECT * FROM t1 WHERE a=1 and b IS NULL;
+SELECT * FROM t1 WHERE a=1 and c IS NULL;
+SELECT * FROM t1 WHERE a=1 and b IS NULL and c IS NULL;
+DROP TABLE t1;
+
+#
+# Test when deleting all rows
+#
+
+CREATE TABLE t1 (a int not null, primary key using BTREE (a)) type=heap;
+INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
+DELETE from t1 where a < 100;
+SELECT * from t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/heap_hash.test b/mysql-test/t/heap_hash.test
new file mode 100644
index 00000000000..f339a10efc6
--- /dev/null
+++ b/mysql-test/t/heap_hash.test
@@ -0,0 +1,143 @@
+#
+# Test of heap tables.
+#
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
+insert into t1 values(1,1),(2,2),(3,3),(4,4);
+delete from t1 where a=1 or a=0;
+#show table status like "t1";
+show keys from t1;
+select * from t1;
+select * from t1 where a=4;
+update t1 set b=5 where a=4;
+update t1 set b=b+1 where a>=3;
+replace t1 values (3,3);
+select * from t1;
+alter table t1 add c int not null, add key using HASH (c,a);
+drop table t1;
+
+create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps";
+insert into t1 values(1,1),(2,2),(3,3),(4,4);
+delete from t1 where a > 0;
+select * from t1;
+drop table t1;
+
+create table t1 (a int not null,b int not null, primary key using HASH (a)) type=heap comment="testing heaps";
+insert into t1 values(1,1),(2,2),(3,3),(4,4);
+alter table t1 modify a int not null auto_increment, type=myisam, comment="new myisam table";
+#show table status like "t1";
+select * from t1;
+drop table t1;
+
+create table t1 (a int not null) type=heap;
+insert into t1 values (869751),(736494),(226312),(802616);
+select * from t1 where a > 736494;
+alter table t1 add unique uniq_id using HASH (a);
+select * from t1 where a > 736494;
+select * from t1 where a = 736494;
+select * from t1 where a=869751 or a=736494;
+select * from t1 where a in (869751,736494,226312,802616);
+alter table t1 type=myisam;
+explain select * from t1 where a in (869751,736494,226312,802616);
+drop table t1;
+
+create table t1 (x int not null, y int not null, key x using HASH (x), unique y using HASH (y))
+type=heap;
+insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
+select * from t1 where x=1;
+select * from t1,t1 as t2 where t1.x=t2.y;
+explain select * from t1,t1 as t2 where t1.x=t2.y;
+drop table t1;
+
+create table t1 (a int) type=heap;
+insert into t1 values(1);
+select max(a) from t1;
+drop table t1;
+
+CREATE TABLE t1 ( a int not null default 0, b int not null default 0, key using HASH (a), key using HASH (b) ) TYPE=HEAP;
+insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
+select * from t1 where a=1;
+insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
+select * from t1 where a=1;
+drop table t1;
+
+create table t1 (id int unsigned not null, primary key using HASH (id)) type=HEAP;
+insert into t1 values(1);
+select max(id) from t1;
+insert into t1 values(2);
+select max(id) from t1;
+replace into t1 values(1);
+drop table t1;
+
+create table t1 (n int) type=heap;
+drop table t1;
+
+create table t1 (n int) type=heap;
+drop table if exists t1;
+
+# Test of non unique index
+
+CREATE table t1(f1 int not null,f2 char(20) not
+null,index(f2)) type=heap;
+INSERT into t1 set f1=12,f2="bill";
+INSERT into t1 set f1=13,f2="bill";
+INSERT into t1 set f1=14,f2="bill";
+INSERT into t1 set f1=15,f2="bill";
+INSERT into t1 set f1=16,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+INSERT into t1 set f1=12,f2="ted";
+delete from t1 where f2="bill";
+select * from t1;
+drop table t1;
+
+#
+# Test when using part key searches
+#
+
+create table t1 (btn char(10) not null, key using HASH (btn)) type=heap;
+insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
+explain select * from t1 where btn like "q%";
+select * from t1 where btn like "q%";
+alter table t1 add column new_col char(1) not null, add key using HASH (btn,new_col), drop key btn;
+update t1 set new_col=left(btn,1);
+explain select * from t1 where btn="a";
+explain select * from t1 where btn="a" and new_col="a";
+drop table t1;
+
+#
+# Test of NULL keys
+#
+
+CREATE TABLE t1 (
+ a int default NULL,
+ b int default NULL,
+ KEY a using HASH (a),
+ UNIQUE b using HASH (b)
+) type=heap;
+INSERT INTO t1 VALUES (NULL,99),(99,NULL),(1,1),(2,2),(1,3);
+SELECT * FROM t1 WHERE a=NULL;
+explain SELECT * FROM t1 WHERE a IS NULL;
+SELECT * FROM t1 WHERE a<=>NULL;
+SELECT * FROM t1 WHERE b=NULL;
+explain SELECT * FROM t1 WHERE b IS NULL;
+SELECT * FROM t1 WHERE b<=>NULL;
+
+--error 1062
+INSERT INTO t1 VALUES (1,3);
+DROP TABLE t1;
+
+#
+# Test when deleting all rows
+#
+
+CREATE TABLE t1 (a int not null, primary key using HASH (a)) type=heap;
+INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11);
+DELETE from t1 where a < 100;
+SELECT * from t1;
+DROP TABLE t1;
diff --git a/mysql-test/t/help.test b/mysql-test/t/help.test
new file mode 100644
index 00000000000..82312340336
--- /dev/null
+++ b/mysql-test/t/help.test
@@ -0,0 +1,115 @@
+-- source include/have_innodb.inc
+
+# category: topic: keyword:
+#
+# impossible_category_1
+# impossible_function_1
+# impossible_function_5
+# impossible_function_2
+# impossible_function_1
+# impossible_category_2
+# impossible_function_3
+# impossible_function_6
+# impossible_function_4
+# impossible_function_6
+# impossible_category_3
+# impossible_function_7
+
+insert into mysql.help_category(help_category_id,name)values(1,'impossible_category_1');
+select @category1_id:= 1;
+insert into mysql.help_category(help_category_id,name)values(2,'impossible_category_2');
+select @category2_id:= 2;
+insert into mysql.help_category(help_category_id,name,parent_category_id)values(3,'impossible_category_3',@category2_id);
+select @category3_id:= 3;
+
+insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(1,'impossible_function_1',@category1_id,'description of \n impossible_function1\n','example of \n impossible_function1');
+select @topic1_id:= 1;
+insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(2,'impossible_function_2',@category1_id,'description of \n impossible_function2\n','example of \n impossible_function2');
+select @topic2_id:= 2;
+insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(3,'impossible_function_3',@category2_id,'description of \n impossible_function3\n','example of \n impossible_function3');
+select @topic3_id:= 3;
+insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(4,'impossible_function_4',@category2_id,'description of \n impossible_function4\n','example of \n impossible_function4');
+select @topic4_id:= 4;
+insert into mysql.help_topic(help_topic_id,name,help_category_id,description,example)values(5,'impossible_function_7',@category3_id,'description of \n impossible_function5\n','example of \n impossible_function7');
+select @topic5_id:= 5;
+
+insert into mysql.help_keyword(help_keyword_id,name)values(1,'impossible_function_1');
+select @keyword1_id:= 1;
+insert into mysql.help_keyword(help_keyword_id,name)values(2,'impossible_function_5');
+select @keyword2_id:= 2;
+insert into mysql.help_keyword(help_keyword_id,name)values(3,'impossible_function_6');
+select @keyword3_id:= 3;
+
+insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword1_id,@topic2_id);
+insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword2_id,@topic1_id);
+insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword3_id,@topic3_id);
+insert into mysql.help_relation(help_keyword_id,help_topic_id)values(@keyword3_id,@topic4_id);
+
+##############
+help 'function_of_my_dream';
+help '%possible_f%';
+help 'impossible_func%';
+help 'impossible_category%';
+help 'impossible_%';
+
+help '%function_1';
+help '%function_2';
+help '%function_3';
+help '%function_4';
+help '%function_5';
+help '%function_6';
+help '%function_7';
+
+help '%category_2';
+help 'impossible_function_1';
+help 'impossible_category_1';
+##############
+
+alter table mysql.help_relation type=innodb;
+alter table mysql.help_keyword type=innodb;
+alter table mysql.help_topic type=innodb;
+alter table mysql.help_category type=innodb;
+
+##############
+help 'function_of_my_dream';
+help '%possible_f%';
+help 'impossible_func%';
+help 'impossible_category%';
+help 'impossible_%';
+
+help '%function_1';
+help '%function_2';
+help '%function_3';
+help '%function_4';
+help '%function_5';
+help '%function_6';
+help '%function_7';
+
+help '%category_2';
+help 'impossible_function_1';
+help 'impossible_category_1';
+##############
+
+alter table mysql.help_relation type=myisam;
+alter table mysql.help_keyword type=myisam;
+alter table mysql.help_topic type=myisam;
+alter table mysql.help_category type=myisam;
+
+delete from mysql.help_topic where help_topic_id=@topic1_id;
+delete from mysql.help_topic where help_topic_id=@topic2_id;
+delete from mysql.help_topic where help_topic_id=@topic3_id;
+delete from mysql.help_topic where help_topic_id=@topic4_id;
+delete from mysql.help_topic where help_topic_id=@topic5_id;
+
+delete from mysql.help_category where help_category_id=@category3_id;
+delete from mysql.help_category where help_category_id=@category2_id;
+delete from mysql.help_category where help_category_id=@category1_id;
+
+delete from mysql.help_keyword where help_keyword_id=@keyword1_id;
+delete from mysql.help_keyword where help_keyword_id=@keyword2_id;
+delete from mysql.help_keyword where help_keyword_id=@keyword3_id;
+
+delete from mysql.help_relation where help_keyword_id=@keyword1_id and help_topic_id=@topic2_id;
+delete from mysql.help_relation where help_keyword_id=@keyword2_id and help_topic_id=@topic1_id;
+delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic3_id;
+delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic4_id;
diff --git a/mysql-test/t/innodb-deadlock.test b/mysql-test/t/innodb-deadlock.test
index bc2839bfb3a..ba4ec4a9ae4 100644
--- a/mysql-test/t/innodb-deadlock.test
+++ b/mysql-test/t/innodb-deadlock.test
@@ -2,7 +2,10 @@
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
-drop table if exists t1;
+
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
#
# Testing of FOR UPDATE
@@ -36,3 +39,75 @@ select * from t1;
commit;
drop table t1;
+#
+# Testing of FOR UPDATE
+#
+
+connection con1;
+create table t1 (id integer, x integer) type=INNODB;
+create table t2 (b integer, a integer) type=INNODB;
+insert into t1 values(0, 0), (300, 300);
+insert into t2 values(0, 10), (1, 20), (2, 30);
+commit;
+set autocommit=0;
+select * from t2;
+update t2 set a=100 where b=(SELECT x from t1 where id = b FOR UPDATE);
+select * from t2;
+select * from t1;
+
+connection con2;
+set autocommit=0;
+
+# The following query should hang because con1 is locking the page
+--send
+update t1 set x=2 where id = 0;
+--sleep 2;
+
+connection con1;
+update t1 set x=1 where id = 0;
+select * from t1;
+commit;
+
+connection con2;
+reap;
+commit;
+
+connection con1;
+select * from t1;
+commit;
+
+drop table t1, t2;
+create table t1 (id integer, x integer) type=INNODB;
+create table t2 (b integer, a integer) type=INNODB;
+insert into t1 values(0, 0), (300, 300);
+insert into t2 values(0, 0), (1, 20), (2, 30);
+commit;
+
+connection con1;
+select a,b from t2 UNION SELECT id, x from t1 FOR UPDATE;
+select * from t2;
+select * from t1;
+
+connection con2;
+
+# The following query should hang because con1 is locking the page
+update t2 set a=2 where b = 0;
+select * from t2;
+--send
+update t1 set x=2 where id = 0;
+--sleep 2;
+
+connection con1;
+update t1 set x=1 where id = 0;
+select * from t1;
+commit;
+
+connection con2;
+reap;
+commit;
+
+connection con1;
+select * from t1;
+commit;
+
+drop table t1, t2;
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index e46f5801418..3349ea21c45 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -4,8 +4,10 @@
# Small basic test with ignore
#
-drop table if exists t1,t2,t3;
+--disable_warnings
+drop table if exists t1,t2,t3,t4;
drop database if exists mysqltest;
+--enable_warnings
create table t1 (id int unsigned not null auto_increment, code tinyint unsigned not null, name char(20) not null, primary key (id), key (code), unique (name)) type=innodb;
@@ -21,6 +23,8 @@ drop table t1;
#
# A bit bigger test
+# The 'replace_column' statements are needed because the cardinality calculated
+# by innodb is not always the same between runs
#
CREATE TABLE t1 (
@@ -42,12 +46,17 @@ update ignore t1 set id=id+1; # This will change all rows
select * from t1;
update ignore t1 set id=1023 where id=1010;
select * from t1 where parent_id=102;
-# explain select level from t1 where level=1;
-# explain select level,id from t1 where level=1;
-# explain select level,id,parent_id from t1 where level=1;
+--replace_column 9 #
+explain select level from t1 where level=1;
+--replace_column 9 #
+explain select level,id from t1 where level=1;
+--replace_column 9 #
+explain select level,id,parent_id from t1 where level=1;
select level,id from t1 where level=1;
select level,id,parent_id from t1 where level=1;
optimize table t1;
+--replace_column 7 #
+show keys from t1;
drop table t1;
#
@@ -85,6 +94,8 @@ select * from t1;
create index skr on t1 (a);
insert into t1 values (3,""), (4,"testing");
analyze table t1;
+--replace_column 7 #
+show keys from t1;
drop table t1;
@@ -123,6 +134,23 @@ rollback;
drop table t1;
#
+# Test for commit and FLUSH TABLES WITH READ LOCK
+#
+
+create table t1 (n int not null primary key) type=innodb;
+start transaction;
+insert into t1 values (4);
+flush tables with read lock;
+#
+# Current code can't handle a read lock in middle of transaction
+#--error 1223;
+commit;
+unlock tables;
+commit;
+select * from t1;
+drop table t1;
+
+#
# Testing transactions
#
@@ -222,6 +250,8 @@ drop table t1;
CREATE TABLE t1 (a int not null, b int not null,c int not null,
key(a),primary key(a,b), unique(c),key(a),unique(b));
+--replace_column 7 #
+show index from t1;
drop table t1;
#
@@ -338,7 +368,8 @@ update ignore t1 set id=id+1; # This will change all rows
select * from t1;
update ignore t1 set id=1023 where id=1010;
select * from t1 where parent_id=102;
-# explain select level from t1 where level=1;
+--replace_column 9 #
+explain select level from t1 where level=1;
select level,id from t1 where level=1;
select level,id,parent_id from t1 where level=1;
select level,id from t1 where level=1 order by id;
@@ -395,6 +426,8 @@ create table t1 (a varchar(100) not null, primary key(a), b int not null) type=i
insert into t1 values("hello",1),("world",2);
select * from t1 order by b desc;
optimize table t1;
+--replace_column 7 #
+show keys from t1;
drop table t1;
#
@@ -439,6 +472,8 @@ DROP TABLE t1;
create table t1 (a int primary key,b int, c int, d int, e int, f int, g int, h int, i int, j int, k int, l int, m int, n int, o int, p int, q int, r int, s int, t int, u int, v int, w int, x int, y int, z int, a1 int, a2 int, a3 int, a4 int, a5 int, a6 int, a7 int, a8 int, a9 int, b1 int, b2 int, b3 int, b4 int, b5 int, b6 int) type = innodb;
insert into t1 values (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
+--replace_column 9 #
+explain select * from t1 where a > 0 and a < 50;
drop table t1;
#
@@ -469,6 +504,15 @@ UNLOCK TABLES;
DROP TABLE t1;
#
+# Test prefix key
+#
+create table t1 (a char(20), unique (a(5))) type=innodb;
+drop table t1;
+create table t1 (a char(20), index (a(5))) type=innodb;
+show create table t1;
+drop table t1;
+
+#
# Test using temporary table and auto_increment
#
@@ -516,6 +560,8 @@ insert into mysqltest.t3 values(1);
commit;
drop database mysqltest;
# Don't check error message
+--error 12,12
+show tables from mysqltest;
#
# Test truncate table with and without auto_commit
@@ -553,6 +599,22 @@ drop table t1;
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) type=innodb;
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
+--replace_column 9 #
+explain select * from t1 order by a;
+--replace_column 9 #
+explain select * from t1 order by b;
+--replace_column 9 #
+explain select * from t1 order by c;
+--replace_column 9 #
+explain select a from t1 order by a;
+--replace_column 9 #
+explain select b from t1 order by b;
+--replace_column 9 #
+explain select a,b from t1 order by b;
+--replace_column 9 #
+explain select a,b from t1;
+--replace_column 9 #
+explain select a,b,c from t1;
drop table t1;
#
@@ -642,7 +704,6 @@ DROP TABLE t1;
#
# Test of multi-table-update
#
-drop table if exists t1,t2;
create table t1 (n int(10), d int(10)) type=innodb;
create table t2 (n int(10), d int(10)) type=innodb;
insert into t1 values(1,1),(1,2);
@@ -780,7 +841,6 @@ CREATE TABLE t1 ( B_ID INTEGER NOT NULL PRIMARY KEY) TYPE=InnoDB;
SET AUTOCOMMIT=0;
INSERT INTO t1 ( B_ID ) VALUES ( 1 );
INSERT INTO t2 ( NEXT_T ) VALUES ( 1 );
--- error 1196
ROLLBACK;
SELECT * FROM t1;
drop table t1,t2;
@@ -792,7 +852,6 @@ drop table t1;
#
# Test that MySQL priorities clustered indexes
#
-
create table t1 (a int not null auto_increment primary key, b int, c int, key(c)) type=innodb;
create table t2 (a int not null auto_increment primary key, b int);
insert into t1 (b) values (null),(null),(null),(null),(null),(null),(null);
@@ -815,7 +874,11 @@ insert into t1 (a) select b from t2;
insert into t2 (a) select b from t1;
insert into t1 (a) select b from t2;
select count(*) from t1;
+--replace_column 9 #
+explain select * from t1 where c between 1 and 10000;
update t1 set c=a;
+--replace_column 9 #
+explain select * from t1 where c between 1 and 10000;
drop table t1,t2;
#
@@ -838,3 +901,70 @@ update t1 set b=100 where a=1 order by b desc limit 2;
update t1 set a=a+10+b where a=1 order by b;
select * from t1 order by a,b;
drop table t1;
+
+
+CREATE TABLE t1 (col1 int(1))TYPE=InnoDB;
+CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx
+(stamp))TYPE=InnoDB;
+insert into t1 values (1),(2),(3);
+insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 );
+SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp <
+'20020204120000' GROUP BY col1;
+drop table t1,t2;
+
+#
+# Test by Francois MASUREL
+#
+
+CREATE TABLE t1 (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `id_object` int(10) unsigned default '0',
+ `id_version` int(10) unsigned NOT NULL default '1',
+ label varchar(100) NOT NULL default '',
+ `description` text,
+ PRIMARY KEY (`id`),
+ KEY `id_object` (`id_object`),
+ KEY `id_version` (`id_version`)
+) TYPE=InnoDB;
+
+INSERT INTO t1 VALUES("6", "3382", "9", "Test", NULL), ("7", "102", "5", "Le Pekin (Test)", NULL),("584", "1794", "4", "Test de resto", NULL),("837", "1822", "6", "Test 3", NULL),("1119", "3524", "1", "Societe Test", NULL),("1122", "3525", "1", "Fournisseur Test", NULL);
+
+CREATE TABLE t2 (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `id_version` int(10) unsigned NOT NULL default '1',
+ PRIMARY KEY (`id`),
+ KEY `id_version` (`id_version`)
+) TYPE=InnoDB;
+
+INSERT INTO t2 VALUES("3524", "1"),("3525", "1"),("1794", "4"),("102", "5"),("1822", "6"),("3382", "9");
+
+SELECT t2.id, t1.label FROM t2 INNER JOIN
+(SELECT t1.id_object as id_object FROM t1 WHERE t1.label LIKE '%test%') AS lbl
+ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object);
+drop table t1,t2;
+
+#
+# Bug #1078
+#
+create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) type=innodb;
+select * from t1;
+--error 1031
+replace delayed into t1 (c1, c2) values ( "text1","11"),( "text2","12");
+select * from t1;
+--error 1031
+replace delayed into t1 (c1, c2) values ( "text1","12"),( "text2","13"),( "text3","14", "a" ),( "text4","15", "b" );
+select * from t1;
+drop table t1;
+
+create table t1 (a int, b varchar(200), c text not null) checksum=1 type=myisam;
+create table t2 (a int, b varchar(200), c text not null) checksum=0 type=innodb;
+create table t3 (a int, b varchar(200), c text not null) checksum=1 type=innodb;
+insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
+insert t2 select * from t1;
+insert t3 select * from t1;
+checksum table t1, t2, t3, t4 quick;
+checksum table t1, t2, t3, t4;
+checksum table t1, t2, t3, t4 extended;
+#show table status;
+drop table t1,t2,t3;
+
diff --git a/mysql-test/t/innodb_cache.test b/mysql-test/t/innodb_cache.test
index 9066a5f19ba..8a08c19703d 100644
--- a/mysql-test/t/innodb_cache.test
+++ b/mysql-test/t/innodb_cache.test
@@ -1,10 +1,14 @@
-- source include/have_innodb.inc
-- source include/have_query_cache.inc
+# Initialise
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
#
# Without auto_commit.
#
-drop table if exists t1, t2, t3;
flush status;
set autocommit=0;
create table t1 (a int not null) type=innodb;
diff --git a/mysql-test/t/innodb_handler.test b/mysql-test/t/innodb_handler.test
index 6777e4f49bd..cf6ac9870ce 100644
--- a/mysql-test/t/innodb_handler.test
+++ b/mysql-test/t/innodb_handler.test
@@ -4,7 +4,10 @@
# test of HANDLER ...
#
-drop table if exists t1;
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (a int, b char(10), key a(a), key b(a,b)) type=innodb;
insert into t1 values
(17,"ddd"),(18,"eee"),(19,"fff"),(19,"yyy"),
diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test
index fbb9134ff7f..62d277bfad5 100644
--- a/mysql-test/t/insert.test
+++ b/mysql-test/t/insert.test
@@ -2,7 +2,10 @@
# Test of refering to old values
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (a int not null);
insert into t1 values (1);
insert into t1 values (a+2);
diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test
index 5c63f3b3bb7..4effed9b6de 100644
--- a/mysql-test/t/insert_select.test
+++ b/mysql-test/t/insert_select.test
@@ -2,7 +2,10 @@
# Problem with INSERT ... SELECT
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (bandID MEDIUMINT UNSIGNED NOT NULL PRIMARY KEY, payoutID SMALLINT UNSIGNED NOT NULL);
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12);
create table t2 (payoutID SMALLINT UNSIGNED NOT NULL PRIMARY KEY);
@@ -83,8 +86,8 @@ insert into t1 select * from t2;
let $VERSION=`select version()`;
--replace_result $VERSION VERSION
show binlog events;
+select * from t1;
drop table t1, t2;
-drop table if exists t1, t2;
#
# Test of insert ... select from same table
diff --git a/mysql-test/t/insert_update.test b/mysql-test/t/insert_update.test
new file mode 100644
index 00000000000..550bce867cd
--- /dev/null
+++ b/mysql-test/t/insert_update.test
@@ -0,0 +1,28 @@
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (a INT, b INT, c INT, UNIQUE (A), UNIQUE(B));
+INSERT t1 VALUES (1,2,10), (3,4,20);
+INSERT t1 VALUES (5,6,30) ON DUPLICATE KEY UPDATE c=c+100;
+SELECT * FROM t1;
+INSERT t1 VALUES (5,7,40) ON DUPLICATE KEY UPDATE c=c+100;
+SELECT * FROM t1;
+INSERT t1 VALUES (8,4,50) ON DUPLICATE KEY UPDATE c=c+1000;
+SELECT * FROM t1;
+INSERT t1 VALUES (1,4,60) ON DUPLICATE KEY UPDATE c=c+10000;
+SELECT * FROM t1;
+-- error 1062
+INSERT t1 VALUES (1,9,70) ON DUPLICATE KEY UPDATE c=c+100000, b=4;
+SELECT * FROM t1;
+TRUNCATE TABLE t1;
+INSERT t1 VALUES (1,2,10), (3,4,20);
+INSERT t1 VALUES (5,6,30), (7,4,40), (8,9,60) ON DUPLICATE KEY UPDATE c=c+100;
+SELECT * FROM t1;
+INSERT t1 SET a=5 ON DUPLICATE KEY UPDATE b=0;
+SELECT * FROM t1;
+INSERT t1 VALUES (2,1,11), (7,4,40) ON DUPLICATE KEY UPDATE c=c+VALUES(a);
+SELECT *, VALUES(a) FROM t1;
+explain extended SELECT *, VALUES(a) FROM t1;
+explain extended select * from t1 where values(a);
+DROP TABLE t1;
diff --git a/mysql-test/t/isam.test b/mysql-test/t/isam.test
index e807112dab4..e35ed0dfd4a 100644
--- a/mysql-test/t/isam.test
+++ b/mysql-test/t/isam.test
@@ -1,6 +1,8 @@
-- source include/have_isam.inc
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
#
# Test possible problem with rows that are about 65535 bytes long
@@ -10,12 +12,14 @@ create table t1 (a tinyint not null auto_increment, b blob not null, primary key
let $1=100;
disable_query_log;
+--disable_warnings
while ($1)
{
eval insert into t1 (b) values(repeat(char(65+$1),65540-$1));
dec $1;
}
enable_query_log;
+--enable_warnings
delete from t1 where (a & 1);
select sum(length(b)) from t1;
drop table t1;
@@ -41,10 +45,14 @@ drop table t1;
#
# Test of some CREATE TABLE's that should fail
#
-!$1121 create table t1 (a int,b text, index(a)) type=isam;
-!$1073 create table t1 (a int,b text, index(b)) type=isam;
-!$1075 create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=isam;
-!$1121 create table t1 (ordid int(8), unique (ordid)) type=isam;
+--error 1121
+create table t1 (a int,b text, index(a)) type=isam;
+--error 1073
+create table t1 (a int,b text, index(b)) type=isam;
+--error 1075
+create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) type=isam;
+--error 1121
+create table t1 (ordid int(8), unique (ordid)) type=isam;
drop table if exists t1;
#
diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test
index 19e04d2aa7e..8cef925cc24 100644
--- a/mysql-test/t/join.test
+++ b/mysql-test/t/join.test
@@ -1,6 +1,8 @@
#
# Initialization
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
#
# Test different join syntaxes
@@ -25,7 +27,6 @@ drop table t1,t2;
# This failed for lia Perminov
#
-
create table t1 (id int primary key);
create table t2 (id int);
insert into t1 values (75);
@@ -111,7 +112,7 @@ drop table t1, t2;
create table t1 (a int primary key);
insert into t1 values(1),(2);
select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a);
---replace_result "31 tables" "XX tables" "63 tables" "XX tables"
+--replace_result "31 tables" "XX tables" "61 tables" "XX tables"
--error 1116
select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a);
drop table t1;
diff --git a/mysql-test/t/join_crash.test b/mysql-test/t/join_crash.test
index 4606b23f726..ada6e56e664 100644
--- a/mysql-test/t/join_crash.test
+++ b/mysql-test/t/join_crash.test
@@ -2,7 +2,10 @@
# This test gave a core dump
#
+--disable_warnings
DROP TABLE IF EXISTS t1,t2,t3,t4;
+--enable_warnings
+
CREATE TABLE t1 (
project_id int(11) NOT NULL auto_increment,
project_row_lock int(11) NOT NULL default '0',
diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test
index ee7d55d2a4e..a63defff540 100644
--- a/mysql-test/t/join_outer.test
+++ b/mysql-test/t/join_outer.test
@@ -2,7 +2,9 @@
# test of left outer join
#
+--disable_warnings
drop table if exists t1,t2,t3,t4,t5;
+--enable_warnings
CREATE TABLE t1 (
grp int(11) default NULL,
@@ -109,7 +111,6 @@ drop table t1,t2;
# Test of LEFT JOIN with const tables (failed for frankie@etsetb.upc.es)
#
-drop table if exists t1,t2,t3,t4;
CREATE TABLE t1 (
cod_asig int(11) DEFAULT '0' NOT NULL,
desc_larga_cat varchar(80) DEFAULT '' NOT NULL,
@@ -416,7 +417,7 @@ explain select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30;
select * from t2 left join t1 on t1.fooID = t2.fooID and t1.fooID = 30;
select * from t2 left join t1 ignore index(primary) on t1.fooID = t2.fooID and t1.fooID = 30;
drop table t1,t2;
-drop table if exists t3;
+
create table t1 (i int);
create table t2 (i int);
create table t3 (i int);
diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test
index cb80d88aee8..3b4cd7358cc 100644
--- a/mysql-test/t/key.test
+++ b/mysql-test/t/key.test
@@ -1,8 +1,12 @@
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+SET SQL_WARNINGS=1;
+
#
# This failed for Elizabeth Mattijsen
#
-drop table if exists t1,t2,t3;
CREATE TABLE t1 (
ID CHAR(32) NOT NULL,
name CHAR(32) NOT NULL,
@@ -173,7 +177,6 @@ drop table t1;
# Problem with UNIQUE() with NULL parts and auto increment
#
-DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (c CHAR(10) NOT NULL,i INT NOT NULL AUTO_INCREMENT,
UNIQUE (c,i));
INSERT INTO t1 (c) VALUES (NULL),(NULL);
diff --git a/mysql-test/t/key_cache-master.opt b/mysql-test/t/key_cache-master.opt
new file mode 100644
index 00000000000..66e19c18a8a
--- /dev/null
+++ b/mysql-test/t/key_cache-master.opt
@@ -0,0 +1 @@
+--key_buffer_size=2M --small.key_buffer_size=256K --small.key_buffer_size=128K
diff --git a/mysql-test/t/key_cache.test b/mysql-test/t/key_cache.test
new file mode 100644
index 00000000000..a3b8bca847d
--- /dev/null
+++ b/mysql-test/t/key_cache.test
@@ -0,0 +1,138 @@
+#
+# Test of multiple key caches
+#
+--disable_warnings
+drop table if exists t1, t2, t3;
+--enable_warnings
+
+SET @save_key_buffer=@@key_buffer_size;
+
+SELECT @@key_buffer_size, @@small.key_buffer_size;
+
+# Change default key cache size
+SET @@global.key_buffer_size=16*1024*1024;
+SET @@global.default.key_buffer_size=16*1024*1024;
+SET @@global.default.key_buffer_size=16*1024*1024;
+
+SET @@global.small.key_buffer_size=1*1024*1024;
+SET @@global.medium.key_buffer_size=4*1024*1024;
+# Drop buffer
+SET @@global.medium.key_buffer_size=0;
+# Test double drop
+SET @@global.medium.key_buffer_size=0;
+
+# Print key buffer with different syntaxes
+SHOW VARIABLES like "key_buffer_size";
+SELECT @@key_buffer_size;
+SELECT @@global.key_buffer_size;
+SELECT @@global.default.key_buffer_size;
+SELECT @@global.default.`key_buffer_size`;
+SELECT @@global.`default`.`key_buffer_size`;
+SELECT @@`default`.key_buffer_size;
+
+SELECT @@small.key_buffer_size;
+SELECT @@medium.key_buffer_size;
+
+SET @@global.key_buffer_size=@save_key_buffer;
+
+#
+# Errors
+#
+
+--error 1064
+SELECT @@default.key_buffer_size;
+--error 1271
+SELECT @@skr.table_type="test";
+
+select @@keycache1.key_cache_block_size;
+select @@keycache1.key_buffer_size;
+set global keycache1.key_cache_block_size=2048;
+select @@keycache1.key_buffer_size;
+select @@keycache1.key_cache_block_size;
+set global keycache1.key_buffer_size=1*1024*1024;
+select @@keycache1.key_buffer_size;
+select @@keycache1.key_cache_block_size;
+set global keycache2.key_buffer_size=4*1024*1024;
+select @@keycache2.key_buffer_size;
+select @@keycache2.key_cache_block_size;
+set global keycache1.key_buffer_size=0;
+select @@keycache1.key_buffer_size;
+select @@keycache1.key_cache_block_size;
+select @@key_buffer_size;
+select @@key_cache_block_size;
+
+set global keycache1.key_buffer_size=1024*1024;
+
+create table t1 (p int primary key, a char(10)) delay_key_write=1;
+create table t2 (p int primary key, i int, a char(10), key k1(i), key k2(a));
+
+insert into t1 values (1, 'qqqq'), (11, 'yyyy');
+insert into t2 values (1, 1, 'qqqq'), (2, 1, 'pppp'),
+ (3, 1, 'yyyy'), (4, 3, 'zzzz');
+select * from t1;
+select * from t2;
+
+update t1 set p=2 where p=1;
+update t2 set i=2 where i=1;
+
+cache index t1 keys (`primary`) in keycache1;
+
+explain select p from t1;
+select p from t1;
+explain select i from t2;
+select i from t2;
+explain select count(*) from t1, t2 where t1.p = t2.i;
+select count(*) from t1, t2 where t1.p = t2.i;
+
+cache index t2 in keycache1;
+update t2 set p=p+1000, i=2 where a='qqqq';
+cache index t2 in keycache2;
+insert into t2 values (2000, 3, 'yyyy');
+cache index t2 in keycache1;
+update t2 set p=3000 where a='zzzz';
+select * from t2;
+explain select p from t2;
+select p from t2;
+explain select i from t2;
+select i from t2;
+explain select a from t2;
+select a from t2;
+
+# Test some error conditions
+--error 1283
+cache index t1 in unknown_key_cache;
+cache index t1 keys (unknown_key) in keycache1;
+
+select @@keycache2.key_buffer_size;
+select @@keycache2.key_cache_block_size;
+set global keycache2.key_buffer_size=0;
+select @@keycache2.key_buffer_size;
+select @@keycache2.key_cache_block_size;
+set global keycache2.key_buffer_size=1024*1024;
+select @@keycache2.key_buffer_size;
+
+update t2 set p=4000 where a='zzzz';
+update t1 set p=p+1;
+
+set global keycache1.key_buffer_size=0;
+select * from t2;
+select p from t2;
+explain select i from t2;
+select i from t2;
+explain select a from t2;
+select a from t2;
+
+select * from t1;
+select p from t1;
+
+# Use the 'small' key cache
+create table t3 (like t1);
+cache index t3 in small;
+insert into t3 select * from t1;
+cache index t3 in keycache2;
+cache index t1,t2 in default;
+drop table t1,t2,t3;
+
+# Cleanup
+# We don't reset keycache2 as we want to ensure that mysqld will reset it
+set global keycache1.key_buffer_size=0;
diff --git a/mysql-test/t/key_diff.test b/mysql-test/t/key_diff.test
index 60afb5f81a4..b4e4339ae33 100644
--- a/mysql-test/t/key_diff.test
+++ b/mysql-test/t/key_diff.test
@@ -1,7 +1,10 @@
#
# Check on condition on different length keys.
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
CREATE TABLE t1 (
a char(5) NOT NULL,
b char(4) NOT NULL,
diff --git a/mysql-test/t/key_primary.test b/mysql-test/t/key_primary.test
index 2cdb117128f..816365c517c 100644
--- a/mysql-test/t/key_primary.test
+++ b/mysql-test/t/key_primary.test
@@ -2,7 +2,10 @@
# test of primary key conversions
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (t1 char(3) primary key);
insert into t1 values("ABC");
insert into t1 values("ABA");
diff --git a/mysql-test/t/keywords.test b/mysql-test/t/keywords.test
index 3bd757aa069..e7ec63afe54 100644
--- a/mysql-test/t/keywords.test
+++ b/mysql-test/t/keywords.test
@@ -2,7 +2,10 @@
# Test keywords as fields
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (time time, date date, timestamp timestamp);
insert into t1 values ("12:22:22","97:02:03","1997-01-02");
select * from t1;
diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test
index 6bcc43ac916..65d4f27059f 100644
--- a/mysql-test/t/kill.test
+++ b/mysql-test/t/kill.test
@@ -11,7 +11,10 @@ connect (con2, localhost, root,,);
#remember id of con1
connection con1;
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (kill_id int);
insert into t1 values(connection_id());
diff --git a/mysql-test/t/limit.test b/mysql-test/t/limit.test
index d4f6ce186cf..88a9831aa68 100644
--- a/mysql-test/t/limit.test
+++ b/mysql-test/t/limit.test
@@ -2,7 +2,10 @@
# Test of update and delete with limit
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (a int primary key, b int not null);
insert into t1 () values (); -- Testing default values
insert into t1 values (1,1),(2,1),(3,1);
diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test
index 732ed248702..1720ae69bbb 100644
--- a/mysql-test/t/loaddata.test
+++ b/mysql-test/t/loaddata.test
@@ -2,7 +2,9 @@
# Some simple test of load data
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1 (a date, b date, c date not null, d date);
load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',';
diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test
index 385713174d2..0868cf2c4b1 100644
--- a/mysql-test/t/lock.test
+++ b/mysql-test/t/lock.test
@@ -2,7 +2,9 @@
# Testing of table locking
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
CREATE TABLE t1 ( `id` int(11) NOT NULL default '0', `id2` int(11) NOT NULL default '0', `id3` int(11) NOT NULL default '0', `dummy1` char(30) default NULL, PRIMARY KEY (`id`,`id2`), KEY `index_id3` (`id3`)) TYPE=MyISAM;
insert into t1 (id,id2) values (1,1),(1,2),(1,3);
LOCK TABLE t1 WRITE;
diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test
index 0295fca29e7..fa095275182 100644
--- a/mysql-test/t/lock_multi.test
+++ b/mysql-test/t/lock_multi.test
@@ -6,9 +6,11 @@
#
-- source include/not_embedded.inc
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
-# test to see if select will get the lock ahead of low priority update
+# Test to see if select will get the lock ahead of low priority update
connect (locker,localhost,root,,);
connect (reader,localhost,root,,);
diff --git a/mysql-test/t/lock_tables_lost_commit.test b/mysql-test/t/lock_tables_lost_commit.test
index a12ee7369cb..d8301017801 100644
--- a/mysql-test/t/lock_tables_lost_commit.test
+++ b/mysql-test/t/lock_tables_lost_commit.test
@@ -4,8 +4,10 @@ connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
connection con1;
+--disable_warnings
drop table if exists t1;
create table t1(a int) type=innodb;
+--enable_warnings
lock tables t1 write;
insert into t1 values(10);
disconnect con1;
diff --git a/mysql-test/t/lowercase_table.test b/mysql-test/t/lowercase_table.test
index 86ea2918fd2..28e45bde5c5 100644
--- a/mysql-test/t/lowercase_table.test
+++ b/mysql-test/t/lowercase_table.test
@@ -2,28 +2,28 @@
# Test of --lower-case-table-names
#
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
+
create table T1 (id int primary key, Word varchar(40) not null, Index(Word));
INSERT INTO T1 VALUES (1, 'a'), (2, 'b'), (3, 'c');
SELECT * FROM t1;
SELECT T1.id from T1 LIMIT 1;
SELECT T2.id from t1 as T2 LIMIT 1;
---error 1109
+# This gave an error in 4.0, but it's fixed in 4.1
SELECT T2.id from t1 as t2 LIMIT 1;
RENAME TABLE T1 TO T2;
ALTER TABLE T2 ADD new_col int not null;
ALTER TABLE T2 RENAME T3;
show tables like 't_';
drop table t3;
-
#
# Test alias
#
create table t1 (a int);
select count(*) from T1;
select count(*) from t1;
---error 1109
select count(T1.a) from t1;
---error 1109
select count(bags.a) from t1 as Bags;
drop table t1;
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index b625e780f1f..c3bffa4f2fb 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -2,7 +2,11 @@
# test of MERGE TABLES
#
+--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6;
+drop database if exists mysqltest;
+--enable_warnings
+
create table t1 (a int not null primary key auto_increment, message char(20));
create table t2 (a int not null primary key auto_increment, message char(20));
INSERT INTO t1 (message) VALUES ("Testing"),("table"),("t1");
@@ -45,12 +49,23 @@ show create table t3;
create table t4 (a int not null, b char(10), key(a)) type=MERGE UNION=(t1,t2);
--error 1016
select * from t4;
---error 1212
-create table t5 (a int not null, b char(10), key(a)) type=MERGE UNION=(test.t1,test_2.t2);
+--error 1016
+alter table t4 add column c int;
-# Because of windows, it's important that we drop the merge tables first!
-drop table if exists t5,t4,t3,t1,t2;
+#
+# Test tables in different databases
+#
+create database mysqltest;
+create table mysqltest.t6 (a int not null primary key auto_increment, message char(20));
+create table t5 (a int not null, b char(20), key(a)) type=MERGE UNION=(test.t1,mysqltest.t6);
+show create table t5;
+alter table t5 type=myisam;
+drop table t5, mysqltest.t6;
+drop database mysqltest;
+# Because of windows, it's important that we drop the merge tables first!
+drop table t4,t3,t1,t2;
+
create table t1 (c char(10)) type=myisam;
create table t2 (c char(10)) type=myisam;
create table t3 (c char(10)) union=(t1,t2) type=merge;
@@ -110,10 +125,9 @@ select * from t1;
drop table t1;
#
-# Bug found by Monty.
+# Bug in flush tables combined with MERGE tables
#
-drop table if exists t3, t2, t1;
create table t1 (a int not null, b int not null, key(a,b));
create table t2 (a int not null, b int not null, key(a,b));
create table t3 (a int not null, b int not null, key(a,b)) TYPE=MERGE UNION=(t1,t2);
@@ -127,7 +141,6 @@ drop table t3,t1,t2;
# [phi] testing INSERT_METHOD stuff
#
-drop table if exists t6, t5, t4, t3, t2, t1;
# first testing of common stuff with new parameters
create table t1 (a int not null, b int not null auto_increment, primary key(a,b));
create table t2 (a int not null, b int not null auto_increment, primary key(a,b));
@@ -175,21 +188,22 @@ select * from t1 order by a,b;
select * from t2 order by a,b;
select * from t5 order by a,b;
select * from t6 order by a,b;
-drop table if exists t6, t5, t4, t3, t2, t1;
+insert into t1 values (99,NULL);
+select * from t4 where a+0 > 90;
+drop table t6, t5, t4, t3, t2, t1;
CREATE TABLE t1 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) TYPE=MyISAM;
INSERT INTO t1 VALUES (1,1), (2,1);
CREATE TABLE t2 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) TYPE=MyISAM;
INSERT INTO t2 VALUES (1,2), (2,2);
-CREATE TABLE t ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', KEY a (a,b)) TYPE=MRG_MyISAM UNION=(t1,t2);
-select max(b) from t where a = 2;
+CREATE TABLE t3 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', KEY a (a,b)) TYPE=MRG_MyISAM UNION=(t1,t2);
+select max(b) from t3 where a = 2;
select max(b) from t1 where a = 2;
-drop table if exists t,t1,t2;
+drop table t3,t1,t2;
#
# temporary merge tables
#
-drop table if exists t1, t2, t3, t4, t5, t6;
create table t1 (a int not null);
create table t2 (a int not null);
insert into t1 values (1);
@@ -202,13 +216,12 @@ insert into t4 values (1);
insert into t5 values (2);
create temporary table t6 (a int not null) TYPE=MERGE UNION=(t4,t5);
select * from t6;
-drop table if exists t1, t2, t3, t4, t5, t6;
+drop table t6, t3, t1, t2, t4, t5;
#
# testing merge::records_in_range and optimizer
#
-DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (
fileset_id tinyint(3) unsigned NOT NULL default '0',
file_code varchar(32) NOT NULL default '',
@@ -235,7 +248,7 @@ EXPLAIN SELECT * FROM t1 WHERE fileset_id = 2
AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1;
EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2
AND file_code = '0000000115' LIMIT 1;
-DROP TABLE IF EXISTS t1, t2;
+DROP TABLE t2, t1;
#
# Test of ORDER BY DESC on key (Bug #515)
diff --git a/mysql-test/t/mix_innodb_myisam_binlog.test b/mysql-test/t/mix_innodb_myisam_binlog.test
index be45c2c3133..314587feda6 100644
--- a/mysql-test/t/mix_innodb_myisam_binlog.test
+++ b/mysql-test/t/mix_innodb_myisam_binlog.test
@@ -35,7 +35,6 @@ begin;
insert into t1 values(2);
insert into t2 select * from t1;
# should say some changes to non-transact1onal tables couldn't be rolled back
---error 1196
rollback;
show binlog events from 79;
@@ -49,7 +48,6 @@ insert into t1 values(3);
savepoint my_savepoint;
insert into t1 values(4);
insert into t2 select * from t1;
---error 1196
rollback to savepoint my_savepoint;
commit;
@@ -64,7 +62,6 @@ insert into t1 values(5);
savepoint my_savepoint;
insert into t1 values(6);
insert into t2 select * from t1;
---error 1196
rollback to savepoint my_savepoint;
insert into t1 values(7);
commit;
diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test
index 7aa4e74cec0..b3c742e0b30 100644
--- a/mysql-test/t/multi_update.test
+++ b/mysql-test/t/multi_update.test
@@ -2,7 +2,10 @@
# Test of update statement that uses many tables.
#
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
+
create table t1(id1 int not null auto_increment primary key, t char(12));
create table t2(id2 int not null, t char(12));
create table t3(id3 int not null, t char(12), index(id3));
@@ -99,7 +102,7 @@ INSERT INTO t3 VALUES (1,'2002-02-04 00:00:00'),(3,'2002-05-12 00:00:00'),(5,'20
00:00:00'),(7,'2002-07-22 00:00:00');
delete t1,t2,t3 from t1,t2,t3 where to_days(now())-to_days(t3.mydate)>=30 and t3.id=t1.id and t3.id=t2.id;
select * from t3;
-DROP TABLE IF EXISTS t1,t2,t3;
+DROP TABLE t1,t2,t3;
CREATE TABLE IF NOT EXISTS `t1` (
`id` int(11) NOT NULL auto_increment,
@@ -127,8 +130,7 @@ select * from t2;
UPDATE t2, t1 SET t2.tst = t1.tst, t2.tst1 = t1.tst1 WHERE t2.ParId = t1.Id;
select * from t2;
-
-drop table if exists t1, t2 ;
+drop table t1, t2 ;
create table t1 (n numeric(10));
create table t2 (n numeric(10));
@@ -213,8 +215,14 @@ insert into t2 values(1,10),(1,20);
UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n;
select * from t1;
select * from t2;
+UPDATE t1 a ,t2 b SET a.d=b.d,b.d=30 WHERE a.n=b.n;
+select * from t1;
+select * from t2;
+DELETE t1, t2 FROM t1 a,t2 b where a.n=b.n;
+select * from t1;
+select * from t2;
drop table t1,t2;
-drop table if exists t1,t2,t3;
+
CREATE TABLE t1 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT NULL default 'NEPOZNAT', PRIMARY KEY (broj)) TYPE=MyISAM;
INSERT INTO t1 VALUES (1,'jedan'),(2,'dva'),(3,'tri'),(4,'xxxxxxxxxx'),(5,'a'),(10,''),(11,''),(12,''),(13,'');
CREATE TABLE t2 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT NULL default 'NEPOZNAT', PRIMARY KEY (broj)) TYPE=MyISAM;
@@ -223,7 +231,7 @@ CREATE TABLE t3 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT
INSERT INTO t3 VALUES (1,'jedan'),(2,'dva');
update t1,t2 set t1.naziv="aaaa" where t1.broj=t2.broj;
update t1,t2,t3 set t1.naziv="bbbb", t2.naziv="aaaa" where t1.broj=t2.broj and t2.broj=t3.broj;
-drop table if exists t1,t2,t3;
+drop table t1,t2,t3;
#
# Test multi update with different join methods
@@ -267,3 +275,38 @@ insert into t2 values (1,1), (3,1);
update t1 left join t2 on t1.a=t2.a set t1.b=2, t2.b=2 where t1.b=1 and t2.b=1 or t2.a is NULL;
select t1.a, t1.b,t2.a, t2.b from t1 left join t2 on t1.a=t2.a where t1.b=1 and t2.b=1 or t2.a is NULL;
drop table t1,t2;
+
+#
+# Test for bug #1820.
+#
+
+create table t1 ( a int not null, b int not null) ;
+--disable_query_log
+insert into t1 values (1,1),(2,2),(3,3),(4,4);
+let $1=19;
+set @d=4;
+while ($1)
+{
+ eval insert into t1 select a+@d,b+@d from t1;
+ eval set @d=@d*2;
+ dec $1;
+}
+
+--enable_query_log
+alter table t1 add index i1(a);
+delete from t1 where a > 2000000;
+create table t2 like t1;
+insert into t2 select * from t1;
+
+select 't2 rows before small delete', count(*) from t1;
+delete t1,t2 from t1,t2 where t1.b=t2.a and t1.a < 2;
+select 't2 rows after small delete', count(*) from t2;
+select 't1 rows after small delete', count(*) from t1;
+
+## Try deleting many rows
+
+delete t1,t2 from t1,t2 where t1.b=t2.a and t1.a < 100*1000;
+select 't2 rows after big delete', count(*) from t2;
+select 't1 rows after big delete', count(*) from t1;
+
+#drop table t1,t2;
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index 12853cd67ca..5dceb2b4598 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -3,7 +3,10 @@
#
# Initialise
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+SET SQL_WARNINGS=1;
#
# Test problem with CHECK TABLE;
@@ -11,7 +14,7 @@ drop table if exists t1,t2;
CREATE TABLE t1 (
STRING_DATA char(255) default NULL,
- KEY STRING_DATA (STRING_DATA)
+ KEY string_data (STRING_DATA)
) TYPE=MyISAM;
INSERT INTO t1 VALUES ('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
@@ -31,11 +34,15 @@ create table t1 (a tinyint not null auto_increment, b blob not null, primary key
let $1=100;
disable_query_log;
+--disable_warnings
+SET SQL_WARNINGS=0;
while ($1)
{
eval insert into t1 (b) values(repeat(char(65+$1),65550-$1));
dec $1;
}
+SET SQL_WARNINGS=1;
+--enable_warnings
enable_query_log;
check table t1;
repair table t1;
@@ -293,6 +300,9 @@ insert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
update t1 set b=repeat('a',256);
update t1 set i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0;
check table t1;
+delete from t1 where i8=1;
+select i1,i2 from t1;
+check table t1;
drop table t1;
#
@@ -350,6 +360,8 @@ explain select * from t1,t2 where t1.b=t2.b;
explain select * from t1,t2 force index(c) where t1.a=t2.a;
explain select * from t1 where a=0 or a=2;
explain select * from t1 force index (a) where a=0 or a=2;
+explain select * from t1 where c=1;
+explain select * from t1 use index() where c=1;
drop table t1,t2;
#
@@ -385,3 +397,22 @@ insert into t1 (b) values (repeat('z',100));
update t1 set b="test" where left(b,1) > 'n';
check table t1;
drop table t1;
+
+#
+# Test RTREE index
+#
+--error 1235
+CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) TYPE=MyISAM;
+# INSERT INTO t1 VALUES (1,1),(1,1);
+# DELETE FROM rt WHERE a<1;
+# DROP TABLE IF EXISTS t1;
+
+create table t1 (a int, b varchar(200), c text not null) checksum=1;
+create table t2 (a int, b varchar(200), c text not null) checksum=0;
+insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
+insert t2 select * from t1;
+checksum table t1, t2, t3 quick;
+checksum table t1, t2, t3;
+checksum table t1, t2, t3 extended;
+#show table status;
+drop table t1,t2;
diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test
index e22a37fabfd..2d1277a1cbc 100644
--- a/mysql-test/t/mysqlbinlog.test
+++ b/mysql-test/t/mysqlbinlog.test
@@ -39,28 +39,28 @@ select "--- Local --" as "";
#
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ $MYSQL_TEST_DIR/var/log/master-bin.001
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ $MYSQL_TEST_DIR/var/log/master-bin.000001
# this should not fail but shouldn't produce any working statements
--disable_query_log
select "--- Broken LOAD DATA --" as "";
--enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ $MYSQL_TEST_DIR/var/log/master-bin.002
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ $MYSQL_TEST_DIR/var/log/master-bin.000002
# this should show almost nothing
--disable_query_log
select "--- --database --" as "";
--enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --database=nottest $MYSQL_TEST_DIR/var/log/master-bin.001
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --database=nottest $MYSQL_TEST_DIR/var/log/master-bin.000001
# this test for position option
--disable_query_log
select "--- --position --" as "";
--enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --position=27 $MYSQL_TEST_DIR/var/log/master-bin.002
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --position=27 $MYSQL_TEST_DIR/var/log/master-bin.000002
# These are tests for remote binlog.
# They should return the same as previous test.
@@ -74,30 +74,30 @@ select "--- Remote --" as "";
--enable_query_log
# This is broken now
-# By the way it seems that remote version fetches all events with name >= master-bin.001
+# By the way it seems that remote version fetches all events with name >= master-bin.000001
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.001
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001
# This is broken too
--disable_query_log
select "--- Broken LOAD DATA --" as "";
--enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.002
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
# And this too ! (altough it is documented)
--disable_query_log
select "--- --database --" as "";
--enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --database=nottest master-bin.001
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --database=nottest master-bin.000001
# Strangely but this works
--disable_query_log
select "--- --position --" as "";
--enable_query_log
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --position=27 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.002
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQL_TEST_DIR/var/tmp/ --read-from-remote-server --position=27 --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
# clean up
-drop table t1;
+drop table t1, t2;
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index c98fd4050f2..954fdcb925a 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -1,10 +1,24 @@
--disable_warnings
-DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t1, `"t"1`;
--enable_warnings
# XML output
CREATE TABLE t1(a int);
INSERT INTO t1 VALUES (1), (2);
---exec $MYSQL_DUMP -X test t1
+--exec $MYSQL_DUMP --skip-all -X test t1
+DROP TABLE t1;
+
+CREATE TABLE t1(a int, b text, c varchar(3));
+INSERT INTO t1 VALUES (1, "test", "tes"), (2, "TEST", "TES");
+--exec $MYSQL_DUMP --skip-all -X test t1
+DROP TABLE t1;
+
+#
+# Bug #1707
+#
+
+CREATE TABLE t1 (`a"b"` char(2));
+INSERT INTO t1 VALUES ("1\""), ("\"2");
+--exec $MYSQL_DUMP --skip-all -X test t1
DROP TABLE t1;
diff --git a/mysql-test/t/negation_elimination.test b/mysql-test/t/negation_elimination.test
new file mode 100644
index 00000000000..49428cc238b
--- /dev/null
+++ b/mysql-test/t/negation_elimination.test
@@ -0,0 +1,68 @@
+#
+# Test negation elimination
+#
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (a int, key (a));
+insert into t1 values (NULL), (0), (1), (2), (3), (4), (5), (6), (7), (8), (9),
+(10), (11), (12), (13), (14), (15), (16), (17), (18), (19);
+
+explain select * from t1 where not(not(a));
+select * from t1 where not(not(a));
+explain select * from t1 where not(not(not(a > 10)));
+select * from t1 where not(not(not(a > 10)));
+explain select * from t1 where not(not(not(a < 5) and not(a > 10)));
+select * from t1 where not(not(not(a < 5) and not(a > 10)));
+explain select * from t1 where not(a = 10);
+select * from t1 where not(a = 10);
+explain select * from t1 where not(a != 10);
+select * from t1 where not(a != 1);
+explain select * from t1 where not(a < 10);
+select * from t1 where not(a < 10);
+explain select * from t1 where not(a >= 10);
+select * from t1 where not(a >= 10);
+explain select * from t1 where not(a > 10);
+select * from t1 where not(a > 10);
+explain select * from t1 where not(a <= 10);
+select * from t1 where not(a <= 10);
+explain select * from t1 where not(a is null);
+select * from t1 where not(a is null);
+explain select * from t1 where not(a is not null);
+select * from t1 where not(a is not null);
+explain select * from t1 where not(a < 5 or a > 15);
+select * from t1 where not(a < 5 or a > 15);
+explain select * from t1 where not(a < 15 and a > 5);
+select * from t1 where not(a < 15 and a > 5);
+
+explain select * from t1 where a = 2 or not(a < 10);
+select * from t1 where a = 2 or not(a < 10);
+explain select * from t1 where a > 5 and not(a > 10);
+select * from t1 where a > 5 and not(a > 10);
+explain select * from t1 where a > 5 xor a < 10;
+select * from t1 where a > 5 xor a < 10;
+
+explain select * from t1 where a = 2 or not(a < 5 or a > 15);
+select * from t1 where a = 2 or not(a < 5 or a > 15);
+explain select * from t1 where a = 7 or not(a < 15 and a > 5);
+select * from t1 where a = 7 or not(a < 15 and a > 5);
+
+explain select * from t1 where NULL or not(a < 15 and a > 5);
+select * from t1 where NULL or not(a < 15 and a > 5);
+explain select * from t1 where not(NULL and a > 5);
+select * from t1 where not(NULL and a > 5);
+explain select * from t1 where not(NULL or a);
+select * from t1 where not(NULL or a);
+explain select * from t1 where not(NULL and a);
+select * from t1 where not(NULL and a);
+
+explain select * from t1 where not((a < 5 or a < 10) and (not(a > 16) or a > 17));
+select * from t1 where not((a < 5 or a < 10) and (not(a > 16) or a > 17));
+explain select * from t1 where not((a < 5 and a < 10) and (not(a > 16) or a > 17));
+select * from t1 where not((a < 5 and a < 10) and (not(a > 16) or a > 17));
+explain select * from t1 where ((a between 5 and 15) and (not(a like 10)));
+select * from t1 where ((a between 5 and 15) and (not(a like 10)));
+
+drop table t1;
diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test
index 6fea7f0d10d..0be755ba7ad 100644
--- a/mysql-test/t/null.test
+++ b/mysql-test/t/null.test
@@ -1,8 +1,14 @@
+# Initialise
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
#
# Testing of NULL in a lot of different places
#
select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null;
+explain extended select null,\N,isnull(null),isnull(1/0),isnull(1/0 = null),ifnull(null,1),ifnull(null,"TRUE"),ifnull("TRUE","ERROR"),1/0 is null,1 is not null;
select 1 | NULL,1 & NULL,1+NULL,1-NULL;
select NULL=NULL,NULL<>NULL,IFNULL(NULL,1.1)+0,IFNULL(NULL,1) | 0;
select strcmp("a",NULL),(1<NULL)+0.0,NULL regexp "a",null like "a%","a%" like null;
@@ -10,12 +16,13 @@ select concat("a",NULL),replace(NULL,"a","b"),replace("string","i",NULL),replace
select repeat("a",0),repeat("ab",5+5),repeat("ab",-1),reverse(NULL);
select field(NULL,"a","b","c");
select 2 between null and 1,2 between 3 AND NULL,NULL between 1 and 2,2 between NULL and 3, 2 between 1 AND null;
+explain extended select 2 between null and 1,2 between 3 AND NULL,NULL between 1 and 2,2 between NULL and 3, 2 between 1 AND null;
SELECT NULL AND NULL, 1 AND NULL, NULL AND 1, NULL OR NULL, 0 OR NULL, NULL OR 0;
SELECT (NULL OR NULL) IS NULL;
select NULL AND 0, 0 and NULL;
select inet_ntoa(null),inet_aton(null),inet_aton("122.256"),inet_aton("122.226."),inet_aton("");
+explain extended select inet_ntoa(null),inet_aton(null),inet_aton("122.256"),inet_aton("122.226."),inet_aton("");
-drop table if exists t1;
create table t1 (x int);
insert into t1 values (null);
select * from t1 where x != 0;
diff --git a/mysql-test/t/null_key.test b/mysql-test/t/null_key.test
index b1cbd5cdfb0..7d9500e90dd 100644
--- a/mysql-test/t/null_key.test
+++ b/mysql-test/t/null_key.test
@@ -1,7 +1,10 @@
#
# Check null keys
-drop table if exists t1;
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (a int, b int not null,unique key (a,b),index(b)) type=myisam;
insert ignore into t1 values (1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(null,7),(9,9),(8,8),(7,7),(null,9),(null,9),(6,6);
explain select * from t1 where a is null;
@@ -11,6 +14,7 @@ explain select * from t1 where a=2 and b = 2;
explain select * from t1 where a<=>b limit 2;
explain select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3;
explain select * from t1 where (a is null or a = 7) and b=7;
+explain select * from t1 where (a is null or a = 7) and b=7 order by a;
explain select * from t1 where (a is null and b>a) or a is null and b=7 limit 2;
explain select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
explain select * from t1 where a > 1 and a < 3 limit 1;
@@ -22,6 +26,8 @@ select * from t1 where (a is null or a > 0 and a < 3) and b < 5 limit 3;
select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3;
select * from t1 where (a is null or a = 7) and b=7;
select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
+create table t2 like t1;
+insert into t2 select * from t1;
alter table t1 modify b blob not null, add c int not null, drop key a, add unique key (a,b(20),c), drop key b, add key (b(10));
explain select * from t1 where a is null and b = 2;
explain select * from t1 where a is null and b = 2 and c=0;
@@ -44,14 +50,43 @@ select * from t1 where (a is null or a > 0 and a < 3) and b > 7 limit 3;
select * from t1 where (a is null or a = 7) and b=7 and c=0;
select * from t1 where a is null and b=9 or a is null and b=7 limit 3;
select * from t1 where b like "6%";
-drop table t1;
+#
+# Test ref_or_null optimization
+#
+drop table t1;
+rename table t2 to t1;
+alter table t1 modify b int null;
+insert into t1 values (7,null), (8,null), (8,7);
+explain select * from t1 where a = 7 and (b=7 or b is null);
+select * from t1 where a = 7 and (b=7 or b is null);
+explain select * from t1 where (a = 7 or a is null) and (b=7 or b is null);
+select * from t1 where (a = 7 or a is null) and (b=7 or b is null);
+explain select * from t1 where (a = 7 or a is null) and (a = 7 or a is null);
+select * from t1 where (a = 7 or a is null) and (a = 7 or a is null);
+create table t2 (a int);
+insert into t2 values (7),(8);
+explain select * from t2 straight_join t1 where t1.a=t2.a and b is null;
+drop index b on t1;
+explain select * from t2,t1 where t1.a=t2.a and b is null;
+select * from t2,t1 where t1.a=t2.a and b is null;
+explain select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
+select * from t2,t1 where t1.a=t2.a and (b= 7 or b is null);
+explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7;
+select * from t2,t1 where (t1.a=t2.a or t1.a is null) and b= 7;
+explain select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null);
+select * from t2,t1 where (t1.a=t2.a or t1.a is null) and (b= 7 or b is null);
+insert into t2 values (null),(6);
+delete from t1 where a=8;
+explain select * from t2,t1 where t1.a=t2.a or t1.a is null;
+explain select * from t2,t1 where t1.a<=>t2.a or (t1.a is null and t1.b <> 9);
+select * from t2,t1 where t1.a<=>t2.a or (t1.a is null and t1.b <> 9);
+drop table t1,t2;
#
# The following failed for Matt Loschert
#
-DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (
id int(10) unsigned NOT NULL auto_increment,
uniq_id int(10) unsigned default NULL,
diff --git a/mysql-test/t/odbc.test b/mysql-test/t/odbc.test
index 3e0fc214d3e..9aac5948359 100644
--- a/mysql-test/t/odbc.test
+++ b/mysql-test/t/odbc.test
@@ -1,3 +1,8 @@
+# Initialise
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
#
# Test some ODBC compatibility
#
@@ -8,7 +13,6 @@ select {fn length("hello")}, { date "1997-10-20" };
# Test retreiving row with last insert_id value.
#
-drop table if exists t1;
create table t1 (a int not null auto_increment,b int not null,primary key (a,b));
insert into t1 SET A=NULL,B=1;
insert into t1 SET a=null,b=2;
diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test
index 8fe547db615..7443aeee6f4 100644
--- a/mysql-test/t/olap.test
+++ b/mysql-test/t/olap.test
@@ -1,27 +1,90 @@
-drop table if exists sales;
-create table sales ( product varchar(32), country varchar(32), year int, profit int);
-insert into sales values ( 'Computer', 'India',2000, 1200),
-( 'TV', 'United States', 1999, 150),
-( 'Calculator', 'United States', 1999,50),
-( 'Computer', 'United States', 1999,1500),
-( 'Computer', 'United States', 2000,1500),
-( 'TV', 'United States', 2000, 150),
-( 'TV', 'India', 2000, 100),
-( 'TV', 'India', 2000, 100),
-( 'Calculator', 'United States', 2000,75),
-( 'Calculator', 'India', 2000,75),
-( 'TV', 'India', 1999, 100),
-( 'Computer', 'India', 1999,1200),
-( 'Computer', 'United States', 2000,1500),
-( 'Calculator', 'United States', 2000,75);
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+create table t1 (product varchar(32), country_id int not null, year int, profit int);
+insert into t1 values ( 'Computer', 2,2000, 1200),
+( 'TV', 1, 1999, 150),
+( 'Calculator', 1, 1999,50),
+( 'Computer', 1, 1999,1500),
+( 'Computer', 1, 2000,1500),
+( 'TV', 1, 2000, 150),
+( 'TV', 2, 2000, 100),
+( 'TV', 2, 2000, 100),
+( 'Calculator', 1, 2000,75),
+( 'Calculator', 2, 2000,75),
+( 'TV', 1, 1999, 100),
+( 'Computer', 1, 1999,1200),
+( 'Computer', 2, 2000,1500),
+( 'Calculator', 2, 2000,75),
+( 'Phone', 3, 2003,10)
+;
+
+create table t2 (country_id int primary key, country char(20) not null);
+insert into t2 values (1, 'USA'),(2,'India'), (3,'Finland');
+
+# First simple rollups, with just grand total
+select product, sum(profit) from t1 group by product;
+select product, sum(profit) from t1 group by product with rollup;
+select product, sum(profit) from t1 group by 1 with rollup;
+select product, sum(profit),avg(profit) from t1 group by product with rollup;
+
+# Sub totals
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year;
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup;
+explain extended select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup;
+select product, country_id , sum(profit) from t1 group by product desc, country_id with rollup;
+
+# limit
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup limit 5;
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup limit 3,3;
+
+select product, country_id, count(*), count(distinct year) from t1 group by product, country_id;
+select product, country_id, count(*), count(distinct year) from t1 group by product, country_id with rollup;
+
+# Test of having
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup having country_id = 1;
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup having sum(profit) > 200;
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup having sum(profit) > 7000;
+
+# Functions
+select concat(product,':',country_id) as 'prod', concat(":",year,":") as 'year',1+1, sum(profit)/count(*) from t1 group by 1,2 with rollup;
+select product, sum(profit)/count(*) from t1 group by product with rollup;
+select left(product,4) as prod, sum(profit)/count(*) from t1 group by prod with rollup;
+select concat(product,':',country_id), 1+1, sum(profit)/count(*) from t1 group by concat(product,':',country_id) with rollup;
+
+# Joins
+select product, country , year, sum(profit) from t1,t2 where t1.country_id=t2.country_id group by product, country, year with rollup;
+
+# Derived tables and sub selects
+select product, `sum` from (select product, sum(profit) as 'sum' from t1 group by product with rollup) as tmp where product is null;
+select product from t1 where exists (select product, country_id , sum(profit) from t1 as t2 where t1.product=t2.product group by product, country_id with rollup having sum(profit) > 6000);
+
+# The following doesn't return the expected answer, but this is a limitation
+# in the implementation so we should just document it
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year having country_id is NULL;
+select concat(':',product,':'), sum(profit),avg(profit) from t1 group by product with rollup;
+
+# Error handling
+
+# Cube is not yet implemented
--error 1235
-select product, country , year, sum(profit) from sales group by product, country, year with cube;
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube;
--error 1235
-explain select product, country , year, sum(profit) from sales group by product, country, year with cube;
+explain select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube;
--error 1235
-select product, country , year, sum(profit) from sales group by product, country, year with rollup;
---error 1235
-explain select product, country , year, sum(profit) from sales group by product, country, year with rollup;
---error 1235
-select product, country , year, sum(profit) from sales group by product, country, year with cube union all select product, country , year, sum(profit) from sales group by product, country, year with rollup;
-drop table sales;
+select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube union all select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup;
+
+drop table t1,t2;
+
+#
+# Test bug with const tables
+#
+
+CREATE TABLE t1 (i int);
+INSERT INTO t1 VALUES(100);
+CREATE TABLE t2 (i int);
+INSERT INTO t2 VALUES (100),(200);
+SELECT i, COUNT(*) FROM t1 GROUP BY i WITH ROLLUP;
+SELECT t1.i, t2.i, COUNT(*) FROM t1,t2 GROUP BY t1.i,t2.i WITH ROLLUP;
+drop table t1,t2;
diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test
index 25790f24738..39612f680f3 100644
--- a/mysql-test/t/openssl_1.test
+++ b/mysql-test/t/openssl_1.test
@@ -2,7 +2,9 @@
# Use mysql-test-run with --with-openssl option.
-- source include/have_openssl_1.inc
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1(f1 int);
insert into t1 values (5);
diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test
index 1fb83509ebb..702feedc3ce 100644
--- a/mysql-test/t/order_by.test
+++ b/mysql-test/t/order_by.test
@@ -2,7 +2,9 @@
# Bug with order by
#
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
CREATE TABLE t1 (
id int(6) DEFAULT '0' NOT NULL,
@@ -168,7 +170,6 @@ drop table t1,t2,t3;
#bug reported by Wouter de Jong
-drop table if exists t1;
CREATE TABLE t1 (
member_id int(11) NOT NULL auto_increment,
inschrijf_datum varchar(20) NOT NULL default '',
@@ -345,3 +346,22 @@ SELECT * FROM t1 ORDER BY (a + b);
SELECT * FROM t1 ORDER BY (a + b) DESC;
DROP TABLE t1;
+#
+# Test of test_if_subkey() function
+#
+CREATE TABLE t1 (
+ FieldKey varchar(36) NOT NULL default '',
+ LongVal bigint(20) default NULL,
+ StringVal mediumtext,
+ KEY FieldKey (FieldKey),
+ KEY LongField (FieldKey,LongVal),
+ KEY StringField (FieldKey,StringVal(32))
+);
+INSERT INTO t1 VALUES ('0',3,'0'),('0',2,'1'),('0',1,'2'),('1',2,'1'),('1',1,'3'), ('1',0,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('2',3,'0'),('2',2,'1'),('2',1,'2'),('3',2,'1'),('3',1,'2'),('3','3','3');
+EXPLAIN SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
+SELECT * FROM t1 WHERE FieldKey = '1' ORDER BY LongVal;
+EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal;
+SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY LongVal;
+EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
+SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
+DROP TABLE t1;
diff --git a/mysql-test/t/order_fill_sortbuf.test b/mysql-test/t/order_fill_sortbuf.test
index 6419f2a93df..37620ebe331 100644
--- a/mysql-test/t/order_fill_sortbuf.test
+++ b/mysql-test/t/order_fill_sortbuf.test
@@ -3,7 +3,10 @@
# rows MySQL needs to use a merge during the sort phase.
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
CREATE TABLE `t1` (
`id` int(11) NOT NULL default '0',
`id2` int(11) NOT NULL default '0',
diff --git a/mysql-test/t/outfile.test b/mysql-test/t/outfile.test
index c126d221bd2..a944df01051 100644
--- a/mysql-test/t/outfile.test
+++ b/mysql-test/t/outfile.test
@@ -21,3 +21,8 @@
#select * into dumpfile "/tmp/select-test.99" from t1;
#select load_file("/tmp/select-test.not-exist");
#drop table t1;
+#drop table if exists t;
+#CREATE TABLE t ( t timestamp NOT NULL, c char(200) character set latin1 NOT NULL default '', i int(11), v varchar(200), b blob, KEY t (t)) TYPE=MyISAM;
+#INSERT INTO t VALUES ('2002-12-20 12:01:20','',1,"aaa","bbb");
+#select * from t into outfile "check";
+#drop table if exists t;
diff --git a/mysql-test/t/overflow.test b/mysql-test/t/overflow.test
index 6619a87cabb..17e443d51f8 100644
--- a/mysql-test/t/overflow.test
+++ b/mysql-test/t/overflow.test
@@ -1,4 +1,4 @@
connect (con1,localhost,boo,,);
connection con1;
--- error 1064,1102
+-- error 1064,1102,1280
drop database AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA;
diff --git a/mysql-test/t/preload.test b/mysql-test/t/preload.test
new file mode 100644
index 00000000000..7eff5cee08f
--- /dev/null
+++ b/mysql-test/t/preload.test
@@ -0,0 +1,100 @@
+#
+# Testing of PRELOAD
+#
+
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+
+
+create table t1 (
+ a int not null auto_increment,
+ b char(16) not null,
+ primary key (a),
+ key (b)
+);
+
+create table t2(
+ a int not null auto_increment,
+ b char(16) not null,
+ primary key (a),
+ key (b)
+);
+
+insert into t1(b) values
+ ('test0'),
+ ('test1'),
+ ('test2'),
+ ('test3'),
+ ('test4'),
+ ('test5'),
+ ('test6'),
+ ('test7');
+
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+insert into t2(b) select b from t1;
+insert into t1(b) select b from t2;
+
+select count(*) from t1;
+select count(*) from t2;
+
+flush tables; flush status;
+show status like "key_read%";
+
+select count(*) from t1 where b = 'test1';
+show status like "key_read%";
+select count(*) from t1 where b = 'test1';
+show status like "key_read%";
+
+flush tables; flush status;
+select @@preload_buffer_size;
+load index into cache t1;
+show status like "key_read%";
+select count(*) from t1 where b = 'test1';
+show status like "key_read%";
+
+flush tables; flush status;
+show status like "key_read%";
+set session preload_buffer_size=256*1024;
+select @@preload_buffer_size;
+load index into cache t1 ignore leaves;
+show status like "key_read%";
+select count(*) from t1 where b = 'test1';
+show status like "key_read%";
+
+flush tables; flush status;
+show status like "key_read%";
+set session preload_buffer_size=1*1024;
+select @@preload_buffer_size;
+load index into cache t1, t2 keys (primary,b) ignore leaves;
+show status like "key_read%";
+select count(*) from t1 where b = 'test1';
+select count(*) from t2 where b = 'test1';
+show status like "key_read%";
+
+flush tables; flush status;
+show status like "key_read%";
+load index into cache t3, t2 keys (primary,b) ;
+show status like "key_read%";
+
+flush tables; flush status;
+show status like "key_read%";
+load index into cache t3 keys (b), t2 keys (c) ;
+show status like "key_read%";
+
+drop table t1, t2;
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index 2ab5504f84b..14cbf4c906d 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -11,8 +11,10 @@ flush query cache; # This crashed in some versions
flush query cache; # This crashed in some versions
reset query cache;
flush status;
+--disable_warnings
drop table if exists t1,t2,t3,t4,t11,t21;
drop database if exists mysqltest;
+--enable_warnings
#
# First simple test
@@ -183,6 +185,7 @@ select RAND() from t1;
select UNIX_TIMESTAMP() from t1;
select USER() from t1;
select benchmark(1,1) from t1;
+explain extended select benchmark(1,1) from t1;
show status like "Qcache_queries_in_cache";
#
# Tests when the cache is filled
@@ -259,8 +262,9 @@ show status like "Qcache_queries_in_cache";
#
# Charset convertion (cp1251_koi8 always present)
#
-create table t1 (a char(1) not null);
-insert into t1 values("á");
+create table t1 (a char(1) not null collate koi8r_general_ci);
+insert into t1 values(_koi8r"á");
+set CHARACTER SET koi8r;
select * from t1;
set CHARACTER SET cp1251_koi8;
select * from t1;
@@ -343,6 +347,40 @@ drop table t1;
show status like "Qcache_queries_in_cache";
#
+# Test of min result data unit size changing
+#
+show global variables like "query_cache_min_res_unit";
+set GLOBAL query_cache_min_res_unit=1001;
+show global variables like "query_cache_min_res_unit";
+create table t1 (a int not null);
+insert into t1 values (1),(2),(3);
+create table t2 (a int not null);
+insert into t2 values (1),(2),(3);
+select * from t1;
+select * from t1;
+select * from t2;
+select * from t2;
+show status like "Qcache_hits";
+show status like "Qcache_queries_in_cache";
+drop table t1;
+select a from t2;
+select a from t2;
+show status like "Qcache_hits";
+show status like "Qcache_queries_in_cache";
+drop table t2;
+set GLOBAL query_cache_min_res_unit=default;
+show global variables like "query_cache_min_res_unit";
+
+#
+# Case sensitive test
+#
+create table t1 (a int not null);
+insert into t1 values (1);
+select "aaa" from t1;
+select "AAA" from t1;
+drop table t1;
+
+#
# Test of query cache resizing
#
create table t1 (a int);
@@ -388,6 +426,7 @@ select * from t2;
show status like "Qcache_queries_in_cache";
select * from t3;
show status like "Qcache_queries_in_cache";
+update t1 set i=(select distinct 1 from (select * from t2) a);
drop table t1, t2, t3;
#
@@ -430,7 +469,6 @@ drop table t1;
#
# INTO OUTFILE/DUMPFILE test
#
-drop table if exists t1;
create table t1 (a int);
insert into t1 values (1),(2),(3);
show status like "Qcache_queries_in_cache";
@@ -452,7 +490,6 @@ show status like "Qcache_queries_in_cache";
SET OPTION SQL_SELECT_LIMIT=DEFAULT;
drop table t1;
-
#
# query cache crash on using same table twice in one query test
#
@@ -461,7 +498,6 @@ reset query cache;
flush status;
set GLOBAL query_cache_size=1048576;
-
create table t1 (a int not null);
insert into t1 values (1),(2),(3);
create table t2 (a text not null);
@@ -502,4 +538,51 @@ delete from t4 where a=1;
flush query cache;
drop table t1,t2,t3,t4;
-set GLOBAL query_cache_size=0;
+
+#
+# Test character set related variables:
+# character_set_result
+# character_set_client
+# charactet_set_connection/collation_connection
+# If at least one of the above variables has changed,
+# the cached query can't be reused. In the below test
+# absolutely the same query is used several times,
+# SELECT should fetch different results for every instance.
+# No hits should be produced.
+# New cache entry should appear for every SELECT.
+#
+SET NAMES koi8r;
+CREATE TABLE t1 (a char(1) character set koi8r);
+INSERT INTO t1 VALUES (_koi8r'á'),(_koi8r'Á');
+#
+# Run select
+#
+SELECT a,'Â','â'='Â' FROM t1;
+show status like "Qcache_hits";
+show status like "Qcache_queries_in_cache";
+#
+# Change collation_connection and run the same query again
+#
+set collation_connection=koi8r_bin;
+SELECT a,'Â','â'='Â' FROM t1;
+show status like "Qcache_hits";
+show status like "Qcache_queries_in_cache";
+#
+# Now change character_set_client and run the same query again
+#
+set character_set_client=cp1251;
+SELECT a,'Â','â'='Â' FROM t1;
+show status like "Qcache_hits";
+show status like "Qcache_queries_in_cache";
+#
+# And finally change character_set_results and run the same query again
+#
+set character_set_results=cp1251;
+SELECT a,'Â','â'='Â' FROM t1;
+show status like "Qcache_hits";
+show status like "Qcache_queries_in_cache";
+#
+# Keep things tidy
+#
+DROP TABLE t1;
+SET GLOBAL query_cache_size=0;
diff --git a/mysql-test/t/raid.test b/mysql-test/t/raid.test
index 4032993f2da..395a04615cb 100644
--- a/mysql-test/t/raid.test
+++ b/mysql-test/t/raid.test
@@ -7,10 +7,18 @@ enable_query_log;
# Test of raided tables
#
-create database test_raid;
-create table test_raid.r1 (i int) raid_type=1;
-drop database test_raid;
+--disable_warnings
DROP TABLE IF EXISTS t1,t2;
+--enable_warnings
+
+#
+# Test dropping database with raid tables
+#
+
+create database test_$1;
+create table test_$1.r1 (i int) raid_type=1;
+drop database test_$1;
+
CREATE TABLE t1 (
id int unsigned not null auto_increment primary key,
c char(255) not null
diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test
index e09fa73256b..75cbb756998 100644
--- a/mysql-test/t/range.test
+++ b/mysql-test/t/range.test
@@ -2,7 +2,10 @@
# Problem with range optimizer
#
-drop table if exists t1;
+--disable_warnings
+drop table if exists t1, t2;
+--enable_warnings
+
CREATE TABLE t1 (
event_date date DEFAULT '0000-00-00' NOT NULL,
type int(11) DEFAULT '0' NOT NULL,
@@ -171,18 +174,6 @@ select count(*) from t1 where art = 'j' or art = 'J';
select count(*) from t1 where art = 'j';
select count(*) from t1 where art = 'J';
drop table t1;
-
-create table t1 ( id1 int not null, id2 int not null, idnull int null, c char(20), primary key (id1,id2));
-insert into t1 values (0,1,NULL,"aaa"), (1,1,NULL,"aaa"), (2,1,NULL,"aaa"),
- (3,1,NULL,"aaa"), (4,1,NULL,"aaa"), (5,1,NULL,"aaa"),
- (6,1,NULL,"aaa"), (7,1,NULL,"aaa"), (8,1,NULL,"aaa"),
- (9,1,NULL,"aaa"), (10,1,NULL,"aaa"), (11,1,NULL,"aaa"),
- (12,1,NULL,"aaa"), (13,1,NULL,"aaa"), (14,1,NULL,"aaa"),
- (15,1,NULL,"aaa"), (16,1,NULL,"aaa"), (17,1,NULL,"aaa"),
- (18,1,NULL,"aaa"), (19,1,NULL,"aaa"), (20,1,NULL,"aaa");
-select a.id1, b.idnull from t1 as a, t1 as b where a.id2=1 and a.id1=1 and b.id1=a.idnull order by b.id2 desc limit 1;
-drop table t1;
-
#
# BETWEEN problems
#
@@ -214,6 +205,7 @@ explain select * from t1, t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
explain select * from t1 force index(i2), t2 where (t1.key1 <t2.keya + 1) and t2.keya=3;
DROP TABLE t1,t2;
+#
# bug #1724: use RANGE on more selective column instead of REF on less
# selective
@@ -231,9 +223,110 @@ INSERT INTO t1 VALUES
(21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5),
(33,5),(33,5),(33,5),(33,5),(34,5),(35,5);
+# we expect that optimizer will choose index on A
EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
SELECT * FROM t1 WHERE a IN(1,2) AND b=5;
DROP TABLE t1;
-# we expect that optimizer will choose index on A
+# test for a bug with in() and unique key
+
+create table t1 (id int(10) primary key);
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+select id from t1 where id in (2,5,9) ;
+select id from t1 where id=2 or id=5 or id=9 ;
+drop table t1;
+create table t1 ( id1 int not null, id2 int not null, idnull int null, c char(20), primary key (id1,id2));
+insert into t1 values (0,1,NULL,"aaa"), (1,1,NULL,"aaa"), (2,1,NULL,"aaa"),
+ (3,1,NULL,"aaa"), (4,1,NULL,"aaa"), (5,1,NULL,"aaa"),
+ (6,1,NULL,"aaa"), (7,1,NULL,"aaa"), (8,1,NULL,"aaa"),
+ (9,1,NULL,"aaa"), (10,1,NULL,"aaa"), (11,1,NULL,"aaa"),
+ (12,1,NULL,"aaa"), (13,1,NULL,"aaa"), (14,1,NULL,"aaa"),
+ (15,1,NULL,"aaa"), (16,1,NULL,"aaa"), (17,1,NULL,"aaa"),
+ (18,1,NULL,"aaa"), (19,1,NULL,"aaa"), (20,1,NULL,"aaa");
+select a.id1, b.idnull from t1 as a, t1 as b where a.id2=1 and a.id1=1 and b.id1=a.idnull order by b.id2 desc limit 1;
+drop table t1;
+
+
+#
+# Problem with optimizing !=
+#
+
+create table t1 (
+ id int not null auto_increment,
+ name char(1) not null,
+ uid int not null,
+ primary key (id),
+ index uid_index (uid));
+
+create table t2 (
+ id int not null auto_increment,
+ name char(1) not null,
+ uid int not null,
+ primary key (id),
+ index uid_index (uid));
+
+insert into t1(id, uid, name) values(1, 0, ' ');
+insert into t1(uid, name) values(0, ' ');
+
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t2(uid, name) select uid, name from t1;
+insert into t2(uid, name) select uid, name from t1;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+
+delete from t2;
+insert into t2(uid, name) values
+ (1, CHAR(64+1)),
+ (2, CHAR(64+2)),
+ (3, CHAR(64+3)),
+ (4, CHAR(64+4)),
+ (5, CHAR(64+5)),
+ (6, CHAR(64+6)),
+ (7, CHAR(64+7)),
+ (8, CHAR(64+8)),
+ (9, CHAR(64+9)),
+ (10, CHAR(64+10)),
+ (11, CHAR(64+11)),
+ (12, CHAR(64+12)),
+ (13, CHAR(64+13)),
+ (14, CHAR(64+14)),
+ (15, CHAR(64+15)),
+ (16, CHAR(64+16)),
+ (17, CHAR(64+17)),
+ (18, CHAR(64+18)),
+ (19, CHAR(64+19)),
+ (20, CHAR(64+20)),
+ (21, CHAR(64+21)),
+ (22, CHAR(64+22)),
+ (23, CHAR(64+23)),
+ (24, CHAR(64+24)),
+ (25, CHAR(64+25)),
+ (26, CHAR(64+26));
+
+insert into t1(uid, name) select uid, name from t2;
+
+delete from t2;
+insert into t2(id, uid, name) select id, uid, name from t1;
+
+select count(*) from t1;
+select count(*) from t2;
+
+explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
+explain select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0;
+
+select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
+select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0;
+
+drop table t1,t2;
diff --git a/mysql-test/t/rename.test b/mysql-test/t/rename.test
index ce4651d8de3..48a9cb401d9 100644
--- a/mysql-test/t/rename.test
+++ b/mysql-test/t/rename.test
@@ -2,7 +2,10 @@
# Test of rename table
#
+--disable_warnings
drop table if exists t0,t1,t2,t3,t4;
+--enable_warnings
+
create table t0 SELECT 1,"table 1";
create table t2 SELECT 2,"table 2";
create table t3 SELECT 3,"table 3";
@@ -29,4 +32,6 @@ rename table t3 to t4, t5 to t3, t1 to t2, t4 to t1;
select * from t1;
select * from t2;
select * from t3;
+
+# This should give a warning for t4
drop table if exists t1,t2,t3,t4;
diff --git a/mysql-test/t/repair.test b/mysql-test/t/repair_part1.test
index 159fc090653..2657f91cd02 100644
--- a/mysql-test/t/repair.test
+++ b/mysql-test/t/repair_part1.test
@@ -2,7 +2,10 @@
# Test of repair table
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 SELECT 1,"table 1";
repair table t1 use_frm;
alter table t1 TYPE=HEAP;
diff --git a/mysql-test/t/replace.test b/mysql-test/t/replace.test
index e9e01615a62..2afce2fcc84 100644
--- a/mysql-test/t/replace.test
+++ b/mysql-test/t/replace.test
@@ -4,7 +4,9 @@
# Test of REPLACE with ISAM and MyISAM and HEAP
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
CREATE TABLE t1 (
gesuchnr int(11) DEFAULT '0' NOT NULL,
@@ -25,12 +27,13 @@ drop table t1;
# Test when using replace on a key that has used up it's whole range
#
-create table t1 (a tinyint not null auto_increment primary key, b char(20));
-insert into t1 values (126,"first"),(0,"last");
+create table t1 (a tinyint not null auto_increment primary key, b char(20) default "default_value");
+insert into t1 values (126,"first"),(63, "middle"),(0,"last");
--error 1062
insert into t1 values (0,"error");
--error 1062
replace into t1 values (0,"error");
replace into t1 values (126,"first updated");
+replace into t1 values (63,default);
select * from t1;
drop table t1;
diff --git a/mysql-test/t/rollback.test b/mysql-test/t/rollback.test
index 6ea2cca887f..1673f1648d3 100644
--- a/mysql-test/t/rollback.test
+++ b/mysql-test/t/rollback.test
@@ -2,13 +2,20 @@
# This test should fail as MyISAM doesn't have rollback
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1 (n int not null primary key) type=myisam;
begin work;
insert into t1 values (4);
insert into t1 values (5);
-# Should give an error
-!$1196 rollback;
+rollback;
+select @@warning_count;
+select @@error_count;
+show warnings;
+show errors;
select * from t1;
+select @@warning_count;
+show warnings;
drop table t1;
diff --git a/mysql-test/t/row.test b/mysql-test/t/row.test
new file mode 100644
index 00000000000..ecb0c6adfc1
--- /dev/null
+++ b/mysql-test/t/row.test
@@ -0,0 +1,84 @@
+# Initialise
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+select (1,2,3) IN ((3,2,3), (1,2,3), (1,3,3));
+select row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3));
+select row(1,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3));
+select row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3));
+select row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a'));
+select row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3));
+select row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3));
+select row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3));
+select row('b',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3));
+select row('b',1.5,3) IN (row('b',NULL,3), row('a',1.5,3), row(1,3,3));
+select row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3));
+select (1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4)));
+-- error 1240
+select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,4));
+select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)));
+explain extended select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL)));
+
+SELECT (1,2,3)=(0,NULL,3);
+SELECT (1,2,3)=(1,NULL,3);
+# here's something for Sanja to fix :)
+SELECT (1,2,3)=(1,NULL,0);
+
+SELECT ROW(1,2,3)=ROW(1,2,3);
+SELECT ROW(2,2,3)=ROW(1+1,2,3);
+SELECT ROW(1,2,3)=ROW(1+1,2,3);
+SELECT ROW(1,2,3)<ROW(1+1,2,3);
+SELECT ROW(1,2,3)>ROW(1+1,2,3);
+SELECT ROW(1,2,3)<=ROW(1+1,2,3);
+SELECT ROW(1,2,3)>=ROW(1+1,2,3);
+SELECT ROW(1,2,3)<>ROW(1+1,2,3);
+SELECT ROW(NULL,2,3)=ROW(NULL,2,3);
+SELECT ROW(NULL,2,3)<=>ROW(NULL,2,3);
+SELECT ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5));
+SELECT ROW('test',2,3.33)=ROW('test',2,3.33);
+-- error 1240
+SELECT ROW('test',2,3.33)=ROW('test',2,3.33,4);
+SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,33));
+SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,3));
+SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,NULL));
+-- error 1240
+SELECT ROW('test',2,ROW(3,33))=ROW('test',2,4);
+
+create table t1 ( a int, b int, c int);
+insert into t1 values (1,2,3), (2,3,1), (3,2,1), (1,2,NULL);
+select * from t1 where ROW(1,2,3)=ROW(a,b,c);
+select * from t1 where ROW(0,2,3)=ROW(a,b,c);
+select * from t1 where ROW(1,2,3)<ROW(a,b,c);
+select ROW(a,2,3) IN(row(1,b,c), row(2,3,1)) from t1;
+select ROW(c,2,3) IN(row(1,b,a), row(2,3,1)) from t1;
+select ROW(a,b,c) IN(row(1,2,3), row(3,2,1)) from t1;
+select ROW(1,2,3) IN(row(a,b,c), row(1,2,3)) from t1;
+drop table t1;
+
+-- error 1240
+select ROW(1,1);
+
+create table t1 (i int);
+-- error 1240
+select 1 from t1 where ROW(1,1);
+-- error 1240
+select count(*) from t1 order by ROW(1,1);
+-- error 1240
+select count(*) from t1 having (1,1) order by i;
+drop table t1;
+
+create table t1 (a int, b int);
+insert into t1 values (1, 4);
+insert into t1 values (10, 40);
+insert into t1 values (1, 4);
+insert into t1 values (10, 43);
+insert into t1 values (1, 4);
+insert into t1 values (10, 41);
+insert into t1 values (1, 4);
+insert into t1 values (10, 43);
+insert into t1 values (1, 4);
+select a, MAX(b), (1, MAX(b)) = (1, 4) from t1 group by a;
+drop table t1;
+SELECT ROW(2,10) <=> ROW(3,4);
+SELECT ROW(NULL,10) <=> ROW(3,NULL);
diff --git a/mysql-test/t/rpl000001.test b/mysql-test/t/rpl000001.test
index ebce3d0ac94..445bd579279 100644
--- a/mysql-test/t/rpl000001.test
+++ b/mysql-test/t/rpl000001.test
@@ -1,5 +1,5 @@
source include/master-slave.inc;
-drop table if exists t1,t2,t3;
+
create table t1 (word char(20) not null);
load data infile '../../std_data/words.dat' into table t1;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
@@ -12,11 +12,11 @@ select * from t1 limit 10;
save_master_pos;
connection slave;
sync_with_master;
-slave stop;
+stop slave;
connection master;
set password for root@"localhost" = password('foo');
connection slave;
-slave start;
+start slave;
connection master;
#
# Give slave time to do at last one failed connect retry
@@ -43,7 +43,7 @@ sync_with_master;
connection master;
reset master;
connection slave;
-slave stop;
+stop slave;
reset slave;
connection master;
@@ -62,10 +62,12 @@ enable_query_log;
# Try to cause a large relay log lag on the slave
connection slave;
select get_lock("hold_slave",10);
-slave start;
+explain extended select get_lock("hold_slave",10);
+start slave;
#hope this is long enough for I/O thread to fetch over 16K relay log data
sleep 3;
select release_lock("hold_slave");
+explain extended select release_lock("hold_slave");
unlock tables;
connection master;
@@ -100,7 +102,7 @@ wait_for_slave_to_stop;
# show slave status;
set global sql_slave_skip_counter=1;
-slave start;
+start slave;
select count(*) from t1;
connection master1;
drop table t1;
diff --git a/mysql-test/t/rpl000002.test b/mysql-test/t/rpl000002.test
index caf0b4ef6d8..803eb069b66 100644
--- a/mysql-test/t/rpl000002.test
+++ b/mysql-test/t/rpl000002.test
@@ -1,33 +1,26 @@
source include/master-slave.inc;
-drop table if exists t1;
+
create table t1 (n int auto_increment primary key);
set insert_id = 2000;
insert into t1 values (NULL),(NULL),(NULL);
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from t1;
connection master;
--replace_result $SLAVE_MYPORT 9999
show slave hosts;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
-slave stop;
+sync_slave_with_master;
+stop slave;
connection master;
-drop table if exists t2;
create table t2(id int auto_increment primary key, created datetime);
set timestamp=12345;
insert into t2 set created=now();
select * from t2;
save_master_pos;
connection slave;
-slave start;
+start slave;
sync_with_master;
select * from t2;
connection master;
drop table t2;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl000003.test b/mysql-test/t/rpl000003.test
deleted file mode 100644
index f994ed94371..00000000000
--- a/mysql-test/t/rpl000003.test
+++ /dev/null
@@ -1,14 +0,0 @@
-source include/master-slave.inc;
-drop table if exists t1;
-create table t1(n int primary key);
-!insert into t1 values (1),(2),(2);
-insert into t1 values (3);
-save_master_pos;
-connection slave;
-sync_with_master;
-select * from t1;
-connection master;
-drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
diff --git a/mysql-test/t/rpl000004.test b/mysql-test/t/rpl000004.test
index 705e0d51b7b..8fc2977faab 100644
--- a/mysql-test/t/rpl000004.test
+++ b/mysql-test/t/rpl000004.test
@@ -1,18 +1,14 @@
source include/master-slave.inc;
+
set SQL_LOG_BIN=0;
-drop table if exists t1;
create table t1 (word char(20) not null, index(word));
load data infile '../../std_data/words.dat' into table t1;
-drop table if exists t2;
create table t2 (word char(20) not null);
load data infile '../../std_data/words.dat' into table t2;
create table t3 (word char(20) not null primary key);
connection slave;
-drop table if exists t1;
load table t1 from master;
-drop table if exists t2;
load table t2 from master;
-drop table if exists t3;
load table t3 from master;
check table t1;
select count(*) from t2;
diff --git a/mysql-test/t/rpl000005.test b/mysql-test/t/rpl000005.test
index 1cfea242b69..ae713633df3 100644
--- a/mysql-test/t/rpl000005.test
+++ b/mysql-test/t/rpl000005.test
@@ -1,5 +1,5 @@
source include/master-slave.inc;
-drop table if exists t1;
+
CREATE TABLE t1 (name varchar(64), age smallint(3));
INSERT INTO t1 SET name='Andy', age=31;
INSERT t1 SET name='Jacob', age=2;
diff --git a/mysql-test/t/rpl000006.test b/mysql-test/t/rpl000006.test
index ad8622c2a81..c6438062bb7 100644
--- a/mysql-test/t/rpl000006.test
+++ b/mysql-test/t/rpl000006.test
@@ -5,12 +5,10 @@ source include/master-slave.inc;
# Don't log table creating to the slave as we want to test LOAD TABLE
set SQL_LOG_BIN=0,timestamp=200006;
-drop table if exists t1;
create table t1(t timestamp not null,a char(1));
insert into t1 ( a) values ('F');
select unix_timestamp(t) from t1;
connection slave;
-drop table if exists t1;
load table t1 from master;
select unix_timestamp(t) from t1;
diff --git a/mysql-test/t/rpl000008-slave.opt b/mysql-test/t/rpl000008-slave.opt
index 79b3bf6174b..177f89e0910 100644
--- a/mysql-test/t/rpl000008-slave.opt
+++ b/mysql-test/t/rpl000008-slave.opt
@@ -1 +1 @@
---replicate-ignore-table=test.foo
+--replicate-ignore-table=test.mysqltest_foo
diff --git a/mysql-test/t/rpl000008.test b/mysql-test/t/rpl000008.test
index 12760008b6d..ea782b99d28 100644
--- a/mysql-test/t/rpl000008.test
+++ b/mysql-test/t/rpl000008.test
@@ -1,29 +1,36 @@
-#this one assumes we are ignoring updates on table foo, but doing
-#the ones on all other tables
+# This one assumes we are ignoring updates on table mysqltest_foo, but doing
+# the ones on all other tables
+
source include/master-slave.inc;
connection slave;
+
+#
+# For this test we must be in the test database
+#
use test;
-drop table if exists foo;
-create table foo (n int);
-insert into foo values(4);
+
+--disable_warnings
+drop table if exists mysqltest_foo;
+drop table if exists mysqltest_bar;
+--enable_warnings
+
+create table mysqltest_foo (n int);
+insert into mysqltest_foo values(4);
connection master;
use test;
-drop table if exists foo;
-create table foo (n int);
-insert into foo values(5);
-drop table if exists bar;
-create table bar (m int);
-insert into bar values(15);
-drop table if exists choo;
-create table choo (k int);
-insert into choo values(55);
+create table mysqltest_foo (n int);
+insert into mysqltest_foo values(5);
+create table mysqltest_bar (m int);
+insert into mysqltest_bar values(15);
+create table t1 (k int);
+insert into t1 values(55);
save_master_pos;
connection slave;
sync_with_master;
-select foo.n,bar.m,choo.k from foo,bar,choo;
+select mysqltest_foo.n,mysqltest_bar.m,t1.k from mysqltest_foo,mysqltest_bar,t1;
connection master;
-drop table if exists foo,bar,choo;
+drop table mysqltest_foo,mysqltest_bar,t1;
save_master_pos;
connection slave;
sync_with_master;
-drop table if exists foo,bar,choo;
+drop table mysqltest_foo,mysqltest_bar,t1;
diff --git a/mysql-test/t/rpl000009-slave.opt b/mysql-test/t/rpl000009-slave.opt
index 245e310c5d8..c015c02ba78 100644
--- a/mysql-test/t/rpl000009-slave.opt
+++ b/mysql-test/t/rpl000009-slave.opt
@@ -1 +1 @@
---replicate-wild-do-table=bar.%
+--replicate-wild-do-table=mysqltest.%
diff --git a/mysql-test/t/rpl000009.test b/mysql-test/t/rpl000009.test
index e019e1fc3a7..cd318efa2b6 100644
--- a/mysql-test/t/rpl000009.test
+++ b/mysql-test/t/rpl000009.test
@@ -1,38 +1,44 @@
-# This one assumes we are ignoring updates on tables in database foo, but doing
-# the ones in database bar
+# This one assumes we are ignoring updates on tables in database mysqltest2,
+# but doing the ones in database mysqltest
source include/master-slave.inc;
-drop database if exists foo;
-create database foo;
-drop database if exists bar;
-create database bar;
+--disable_warnings
+drop database if exists mysqltest;
+drop database if exists mysqltest2;
+drop database if exists mysqltest3;
+connection slave;
+drop database if exists mysqltest;
+drop database if exists mysqltest2;
+drop database if exists mysqltest3;
+connection master;
+create database mysqltest2;
+create database mysqltest;
+--enable_warnings
+
save_master_pos;
connection slave;
sync_with_master;
-create database foo;
-drop table if exists foo.foo;
-create table foo.foo (n int);
-insert into foo.foo values(4);
+create database mysqltest2;
+create table mysqltest2.foo (n int);
+insert into mysqltest2.foo values(4);
connection master;
-drop table if exists foo.foo;
-create table foo.foo (n int);
-insert into foo.foo values(5);
-drop table if exists bar.bar;
-create table bar.bar (m int);
-insert into bar.bar values(15);
+create table mysqltest2.foo (n int);
+insert into mysqltest2.foo values(5);
+create table mysqltest.bar (m int);
+insert into mysqltest.bar values(15);
save_master_pos;
connection slave;
sync_with_master;
-select foo.foo.n,bar.bar.m from foo.foo,bar.bar;
+select mysqltest2.foo.n,mysqltest.bar.m from mysqltest2.foo,mysqltest.bar;
connection master;
-drop database bar;
-drop database if exists foo;
+drop database mysqltest;
+drop database if exists mysqltest2;
save_master_pos;
connection slave;
sync_with_master;
--error 1008
-drop database bar;
-drop database foo;
+drop database mysqltest;
+drop database mysqltest2;
# Now let's test load data from master
@@ -40,19 +46,19 @@ drop database foo;
connection master;
set sql_log_bin = 0;
-create database foo;
-create database bar;
+create database mysqltest2;
+create database mysqltest;
show databases;
-create table foo.t1(n int, s char(20));
-create table foo.t2(n int, s text);
-insert into foo.t1 values (1, 'one'), (2, 'two'), (3, 'three');
-insert into foo.t2 values (11, 'eleven'), (12, 'twelve'), (13, 'thirteen');
-
-create table bar.t1(n int, s char(20));
-create table bar.t2(n int, s text);
-insert into bar.t1 values (1, 'one bar'), (2, 'two bar'), (3, 'three bar');
-insert into bar.t2 values (11, 'eleven bar'), (12, 'twelve bar'),
- (13, 'thirteen bar');
+create table mysqltest2.t1(n int, s char(20));
+create table mysqltest2.t2(n int, s text);
+insert into mysqltest2.t1 values (1, 'one'), (2, 'two'), (3, 'three');
+insert into mysqltest2.t2 values (11, 'eleven'), (12, 'twelve'), (13, 'thirteen');
+
+create table mysqltest.t1(n int, s char(20));
+create table mysqltest.t2(n int, s text);
+insert into mysqltest.t1 values (1, 'one test'), (2, 'two test'), (3, 'three test');
+insert into mysqltest.t2 values (11, 'eleven test'), (12, 'twelve test'),
+ (13, 'thirteen test');
set sql_log_bin = 1;
save_master_pos;
connection slave;
@@ -60,70 +66,79 @@ sync_with_master;
# This should show that the slave is empty at this point
show databases;
-# Create foo and foo2 on slave; we expect that LOAD DATA FROM MASTER will
-# neither touch database foo nor foo2.
-create database foo;
-create table foo.t1(n int, s char(20));
-insert into foo.t1 values (1, 'original foo.t1');
-create table foo.t3(n int, s char(20));
-insert into foo.t3 values (1, 'original foo.t3');
-create database foo2;
-create table foo2.t1(n int, s char(20));
-insert into foo2.t1 values (1, 'original foo2.t1');
-# Create bar, and bar.t1, to check that it gets replaced,
-# and bar.t3 to check that it is not touched (there is no bar.t3 on master)
-create database bar;
-create table bar.t1(n int, s char(20));
-insert into bar.t1 values (1, 'original bar.t1');
-create table bar.t3(n int, s char(20));
-insert into bar.t3 values (1, 'original bar.t3');
+# Create mysqltest2 and mysqltest3 on slave; we expect that LOAD DATA FROM
+# MASTER will neither touch database mysqltest nor mysqltest3
+create database mysqltest2;
+create table mysqltest2.t1(n int, s char(20));
+insert into mysqltest2.t1 values (1, 'original foo.t1');
+create table mysqltest2.t3(n int, s char(20));
+insert into mysqltest2.t3 values (1, 'original foo.t3');
+create database mysqltest3;
+create table mysqltest3.t1(n int, s char(20));
+insert into mysqltest3.t1 values (1, 'original foo2.t1');
+
+# Create mysqltest, and mysqltest.t1, to check that it gets replaced,
+# and mysqltest.t3 to check that it is not touched (there is no
+# mysqltest.t3 on master)
+create database mysqltest;
+create table mysqltest.t1(n int, s char(20));
+insert into mysqltest.t1 values (1, 'original bar.t1');
+create table mysqltest.t3(n int, s char(20));
+insert into mysqltest.t3 values (1, 'original bar.t3');
load data from master;
# Now let's check if we have the right tables and the right data in them
show databases;
-use foo;
-# LOAD DATA FROM MASTER uses only replicate_*_db rules to decide which databases
-# have to be copied. So it thinks "foo" has to be copied. Before 4.0.16 it would
-# first drop "foo", then create "foo". This "drop" is a bug; in that case t3
-# would disappear.
-# So here the effect of this bug (BUG#1248) would be to leave an empty "foo" on
-# the slave.
+use mysqltest2;
+
+# LOAD DATA FROM MASTER uses only replicate_*_db rules to decide which
+# databases have to be copied. So it thinks "mysqltest" has to be
+# copied. Before 4.0.16 it would first drop "mysqltest", then create
+# "mysqltest". This "drop" is a bug; in that case t3 would disappear. So
+# here the effect of this bug (BUG#1248) would be to leave an empty
+# "mysqltest" on the slave.
+
show tables; # should be t1 & t3
select * from t1; # should be slave's original
-use foo2;
+use mysqltest3;
show tables; # should be t1
select * from t1; # should be slave's original
-use bar;
+use mysqltest;
show tables; # should contain master's copied t1&t2, slave's original t3
-select * from bar.t1;
-select * from bar.t2;
-select * from bar.t3;
+select * from mysqltest.t1;
+select * from mysqltest.t2;
+select * from mysqltest.t3;
# Now let's see if replication works
connection master;
-insert into bar.t1 values (4, 'four bar');
+insert into mysqltest.t1 values (4, 'four test');
save_master_pos;
connection slave;
sync_with_master;
-select * from bar.t1;
+select * from mysqltest.t1;
# Check that LOAD DATA FROM MASTER reports the error if it can't drop a
# table to be overwritten.
# DISABLED FOR NOW AS chmod IS NOT PORTABLE ON NON-UNIX
-# insert into bar.t1 values(10, 'should be there');
+# insert into mysqltest.t1 values(10, 'should be there');
# flush tables;
-# system chmod 500 var/slave-data/bar/;
+# system chmod 500 var/slave-data/mysqltest/;
# --error 6
# load data from master; # should fail (errno 13)
-# system chmod 700 var/slave-data/bar/;
-# select * from bar.t1; # should contain the row (10, ...)
+# system chmod 700 var/slave-data/mysqltest/;
+# select * from mysqltest.t1; # should contain the row (10, ...)
# Check that LOAD TABLE FROM MASTER fails if the table exists on slave
--error 1050
-load table bar.t1 from master;
-drop table bar.t1;
+load table mysqltest.t1 from master;
+drop table mysqltest.t1;
+load table mysqltest.t1 from master;
+
+# Check what happens when requestion not existing table
+#
+--error 1188
load table bar.t1 from master;
# as LOAD DATA FROM MASTER failed it did not restart slave threads
@@ -132,10 +147,11 @@ load table bar.t1 from master;
# Now time for cleanup
connection master;
-drop database bar;
-drop database foo;
+drop database mysqltest;
+drop database mysqltest2;
save_master_pos;
connection slave;
sync_with_master;
-drop database foo;
-drop database foo2;
+# These has to be droped on slave as they are not replicated
+drop database mysqltest2;
+drop database mysqltest3;
diff --git a/mysql-test/t/rpl000010.test b/mysql-test/t/rpl000010.test
index 05a211fbd85..0725214694a 100644
--- a/mysql-test/t/rpl000010.test
+++ b/mysql-test/t/rpl000010.test
@@ -1,10 +1,8 @@
-#this tests the offset off by 22 mystery bug
-#must run slave with --disconnect-slave-event-count=1 --master-connect-retry=1
+# This tests the offset off by 22 mystery bug
+# Must run slave with --disconnect-slave-event-count=1 --master-connect-retry=1
+
source include/master-slave.inc;
-connection slave;
-drop table if exists t1;
-connection master;
-drop table if exists t1;
+
create table t1 (n int not null auto_increment primary key);
insert into t1 values(NULL);
insert into t1 values(2);
diff --git a/mysql-test/t/rpl000011.test b/mysql-test/t/rpl000011.test
index d75937e3f81..3b00afe10e4 100644
--- a/mysql-test/t/rpl000011.test
+++ b/mysql-test/t/rpl000011.test
@@ -1,21 +1,15 @@
source include/master-slave.inc;
-drop table if exists t1;
+
create table t1 (n int);
insert into t1 values(1);
-save_master_pos;
-connection slave;
-sync_with_master;
-slave stop;
-slave start;
+sync_slave_with_master;
+stop slave;
+start slave;
connection master;
insert into t1 values(2);
-save_master_pos;
-connection slave;
#let slave catch up
-sync_with_master;
+sync_slave_with_master;
select * from t1;
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl000012.test b/mysql-test/t/rpl000012.test
index 9f8ba9a4f91..7f440eaaa13 100644
--- a/mysql-test/t/rpl000012.test
+++ b/mysql-test/t/rpl000012.test
@@ -1,18 +1,16 @@
source include/master-slave.inc;
connection master;
-drop table if exists t1,t2,t3;
create table t2 (n int);
create temporary table t1 (n int);
insert into t1 values(1),(2),(3);
insert into t2 select * from t1;
-drop table if exists test.t3;
-create temporary table test.t3 (n int not null);
-alter table test.t3 add primary key(n);
+create temporary table t3 (n int not null);
+alter table t3 add primary key(n);
flush logs;
insert into t3 values (100);
insert into t2 select * from t3;
-drop table if exists test.t3;
+drop table if exists t3;
insert into t2 values (101);
connection master1;
create temporary table t1 (n int);
diff --git a/mysql-test/t/rpl000013.test b/mysql-test/t/rpl000013.test
index 14619796e01..94d5feb3925 100644
--- a/mysql-test/t/rpl000013.test
+++ b/mysql-test/t/rpl000013.test
@@ -3,7 +3,7 @@ save_master_pos;
connection slave;
sync_with_master;
connection master;
-drop table if exists t2;
+
create table t2(n int);
create temporary table t1 (n int);
insert into t1 values(1),(2),(3);
@@ -31,6 +31,10 @@ show status like 'Slave_open_temp_tables';
#
connect (master2,localhost,root,,);
connection master2;
+
+# We will get a warning for t1 as this is a temporary table that doesn't
+# exist in this connection.
+
drop table if exists t1,t2;
save_master_pos;
connection slave;
diff --git a/mysql-test/t/rpl000015.test b/mysql-test/t/rpl000015.test
index 26d32ea3e11..38e0d1bff6c 100644
--- a/mysql-test/t/rpl000015.test
+++ b/mysql-test/t/rpl000015.test
@@ -7,31 +7,33 @@ save_master_pos;
connection slave;
reset slave;
--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
change master to master_host='127.0.0.1';
# The following needs to be cleaned up when change master is fixed
--replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
--replace_result $MASTER_MYPORT MASTER_PORT
eval change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=$MASTER_MYPORT;
--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
-slave start;
+start slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
connection master;
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1 (n int);
insert into t1 values (10),(45),(90);
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from t1;
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl000016-slave.opt b/mysql-test/t/rpl000016-slave.opt
deleted file mode 100644
index f27601e0d7d..00000000000
--- a/mysql-test/t/rpl000016-slave.opt
+++ /dev/null
@@ -1 +0,0 @@
--O max_binlog_size=2048
diff --git a/mysql-test/t/rpl000017-slave.sh b/mysql-test/t/rpl000017-slave.sh
index 066b4880cc1..4dbbaec31ce 100755
--- a/mysql-test/t/rpl000017-slave.sh
+++ b/mysql-test/t/rpl000017-slave.sh
@@ -1,11 +1,11 @@
rm -f $MYSQL_TEST_DIR/var/log/*relay*
rm -f $MYSQL_TEST_DIR/var/slave-data/relay-log.info
cat > $MYSQL_TEST_DIR/var/slave-data/master.info <<EOF
-master-bin.001
+master-bin.000001
4
127.0.0.1
replicate
-aaaaaaaaaaaaaaabthispartofthepasswordisnotused
+aaaaaaaaaaaaaaab
$MASTER_MYPORT
1
0
diff --git a/mysql-test/t/rpl000017.test b/mysql-test/t/rpl000017.test
index d4f41f1e374..cf808a2cbc0 100644
--- a/mysql-test/t/rpl000017.test
+++ b/mysql-test/t/rpl000017.test
@@ -5,17 +5,15 @@ reset master;
grant replication slave on *.* to replicate@localhost identified by 'aaaaaaaaaaaaaaab';
grant replication slave on *.* to replicate@127.0.0.1 identified by 'aaaaaaaaaaaaaaab';
connection slave;
-slave start;
+start slave;
connection master;
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1(n int);
insert into t1 values(24);
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from t1;
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl000018.test b/mysql-test/t/rpl000018.test
index 3bd5fd0ef09..884ec9727d2 100644
--- a/mysql-test/t/rpl000018.test
+++ b/mysql-test/t/rpl000018.test
@@ -12,18 +12,16 @@ server_stop master;
server_start master;
connection slave;
reset slave;
-slave start;
+start slave;
connection master;
-show master logs;
+show binary logs;
+--disable_warnings
drop table if exists t1;
+--enable_warnings
create table t1(n int);
insert into t1 values (3351);
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from t1;
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl_alter.test b/mysql-test/t/rpl_alter.test
index f1fbf60776b..a913f01cd81 100644
--- a/mysql-test/t/rpl_alter.test
+++ b/mysql-test/t/rpl_alter.test
@@ -1,19 +1,22 @@
source include/master-slave.inc;
-drop database if exists test_$1;
-create database test_$1;
-create table test_$1.t1 ( n int);
-alter table test_$1.t1 add m int;
-insert into test_$1.t1 values (1,2);
-create table test_$1.t2 (n int);
-insert into test_$1.t2 values (45);
-rename table test_$1.t2 to test_$1.t3, test_$1.t1 to test_$1.t2;
+--disable_warnings
+drop database if exists mysqltest;
+--enable_warnings
+create database mysqltest;
+
+create table mysqltest.t1 ( n int);
+alter table mysqltest.t1 add m int;
+insert into mysqltest.t1 values (1,2);
+create table mysqltest.t2 (n int);
+insert into mysqltest.t2 values (45);
+rename table mysqltest.t2 to mysqltest.t3, mysqltest.t1 to mysqltest.t2;
save_master_pos;
connection slave;
sync_with_master;
-select * from test_$1.t2;
-select * from test_$1.t3;
+select * from mysqltest.t2;
+select * from mysqltest.t3;
connection master;
-drop database test_$1;
+drop database mysqltest;
save_master_pos;
connection slave;
sync_with_master;
diff --git a/mysql-test/t/rpl_empty_master_crash.test b/mysql-test/t/rpl_empty_master_crash.test
index afa76ce10bb..bee9ef72dc4 100644
--- a/mysql-test/t/rpl_empty_master_crash.test
+++ b/mysql-test/t/rpl_empty_master_crash.test
@@ -1,6 +1,8 @@
source include/master-slave.inc;
-drop table if exists t1;
+
+--replace_column 1 # 33 #
show slave status;
+
#
# Load table should not succeed on the master as this is not a slave
#
diff --git a/mysql-test/t/rpl_error_ignored_table.test b/mysql-test/t/rpl_error_ignored_table.test
index 686472433eb..aacdb506107 100644
--- a/mysql-test/t/rpl_error_ignored_table.test
+++ b/mysql-test/t/rpl_error_ignored_table.test
@@ -15,6 +15,7 @@ sync_with_master;
# The port number is different when doing the release build with
# Do-compile, hence we have to replace the port number here accordingly
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
# check that the table has been ignored, because otherwise the test is nonsense
show tables like 't1';
diff --git a/mysql-test/t/rpl_failsafe.test b/mysql-test/t/rpl_failsafe.test
index 866efbce5bf..ae61b061153 100644
--- a/mysql-test/t/rpl_failsafe.test
+++ b/mysql-test/t/rpl_failsafe.test
@@ -7,18 +7,16 @@ show variables like 'rpl_recovery_rank';
show status like 'Rpl_status';
create table t1(n int);
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
show variables like 'rpl_recovery_rank';
show status like 'Rpl_status';
connection slave_sec;
-slave start;
+start slave;
sync_with_master;
show variables like 'rpl_recovery_rank';
show status like 'Rpl_status';
connection slave_ter;
-slave start;
+start slave;
sync_with_master;
show variables like 'rpl_recovery_rank';
show status like 'Rpl_status';
diff --git a/mysql-test/t/rpl_flush_log_loop.test b/mysql-test/t/rpl_flush_log_loop.test
index 8a3da1a2b02..74920722868 100644
--- a/mysql-test/t/rpl_flush_log_loop.test
+++ b/mysql-test/t/rpl_flush_log_loop.test
@@ -7,15 +7,16 @@ connection slave;
--replace_result $MASTER_MYPORT MASTER_PORT
eval change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=$MASTER_MYPORT;
-slave start;
+start slave;
connection master;
-slave stop;
+stop slave;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval change master to master_host='127.0.0.1',master_user='root',
master_password='',master_port=$SLAVE_MYPORT;
-slave start;
+start slave;
sleep 5;
flush logs;
sleep 5;
--replace_result $SLAVE_MYPORT SLAVE_PORT
+--replace_column 1 # 33 #
show slave status;
diff --git a/mysql-test/t/rpl_flush_tables.test b/mysql-test/t/rpl_flush_tables.test
new file mode 100644
index 00000000000..67720343e83
--- /dev/null
+++ b/mysql-test/t/rpl_flush_tables.test
@@ -0,0 +1,35 @@
+#
+# Test of replicating FLUSH TABLES to make
+# RENAME TABLE work with MERGE tables on the slave.
+# Test of FLUSH NO_WRITE_TO_BINLOG by the way.
+#
+source include/master-slave.inc;
+
+create table t1 (a int);
+insert into t1 values (10);
+create table t2 (a int);
+create table t3 (a int) type=merge union(t1);
+create table t4 (a int);
+# We force the slave to open t3 (because we want to try confusing him) with this :
+insert into t4 select * from t3;
+rename table t1 to t5, t2 to t1;
+# RENAME may have confused the master (this is a known bug): so FLUSH tables,
+# first don't write it to the binlog, to test the NO_WRITE_TO_BINLOG keyword.
+flush no_write_to_binlog tables;
+# Check that it's not in the binlog.
+--replace_result $SERVER_VERSION SERVER_VERSION
+show binlog events;
+# Check that the master is not confused.
+select * from t3;
+# This FLUSH should go into the binlog to not confuse the slave.
+flush tables;
+# Check that it's in the binlog.
+--replace_result $SERVER_VERSION SERVER_VERSION
+show binlog events;
+save_master_pos;
+connection slave;
+sync_with_master;
+# Check that the slave is not confused.
+select * from t3;
+# Note that all this confusion may cause warnings 'table xx is open on rename'
+# in the .err files; these are not fatal and are not reported by mysql-test-run.
diff --git a/mysql-test/t/rpl_get_lock.test b/mysql-test/t/rpl_get_lock.test
index e93268e6074..c3b033fb03a 100644
--- a/mysql-test/t/rpl_get_lock.test
+++ b/mysql-test/t/rpl_get_lock.test
@@ -5,6 +5,7 @@ insert into t1 values(get_lock("lock",2));
dirty_close master;
connection master1;
select get_lock("lock",2);
+
select release_lock("lock");
#ignore
disable_query_log;
@@ -21,7 +22,8 @@ connection slave;
sync_with_master;
select get_lock("lock",3);
select * from t1;
-select is_free_lock("lock");
+select is_free_lock("lock"), is_used_lock("lock");
+explain extended select is_free_lock("lock"), is_used_lock("lock");
# Check lock functions
select is_free_lock("lock2");
select is_free_lock(NULL);
diff --git a/mysql-test/t/rpl_insert_id-slave.opt b/mysql-test/t/rpl_insert_id-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_insert_id-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_insert_id.test b/mysql-test/t/rpl_insert_id.test
index 49fefae72b8..b2b92dec7aa 100644
--- a/mysql-test/t/rpl_insert_id.test
+++ b/mysql-test/t/rpl_insert_id.test
@@ -6,7 +6,6 @@
source include/master-slave.inc;
source include/have_innodb.inc
connection master;
-drop table if exists t1;
create table t1(a int auto_increment, key(a));
create table t2(b int auto_increment, c int, key(b));
insert into t1 values (1),(2),(3);
diff --git a/mysql-test/t/rpl_loaddata.test b/mysql-test/t/rpl_loaddata.test
index a3bb8c9aec9..10213644836 100644
--- a/mysql-test/t/rpl_loaddata.test
+++ b/mysql-test/t/rpl_loaddata.test
@@ -2,13 +2,14 @@
# Honours autoincrement values
# i.e. if the master and slave have the same sequence
#
-# check replication of load data for temporary tables with additional parameters
+# check replication of load data for temporary tables with additional
+# parameters
#
# check if duplicate entries trigger an error (they should unless IGNORE or
# REPLACE was used on the master) (bug 571).
#
# check if START SLAVE, RESET SLAVE, CHANGE MASTER reset Last_slave_error and
-# Last_slave_errno in SHOW SLAVE STATUS (1st and 3rd commands did not: bug 986).
+# Last_slave_errno in SHOW SLAVE STATUS (1st and 3rd commands did not: bug 986)
source include/master-slave.inc;
@@ -71,6 +72,7 @@ set global sql_slave_skip_counter=1;
start slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
# Trigger error again to test CHANGE MASTER
@@ -90,6 +92,7 @@ stop slave;
change master to master_user='test';
change master to master_user='root';
--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
# Trigger error again to test RESET SLAVE
@@ -111,6 +114,7 @@ wait_for_slave_to_stop;
stop slave;
reset slave;
--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
# Finally, see if logging is done ok on master for a failing LOAD DATA INFILE
diff --git a/mysql-test/t/rpl_loaddata_rule_m.test b/mysql-test/t/rpl_loaddata_rule_m.test
index 18f295f8ce2..ec3a9259e32 100644
--- a/mysql-test/t/rpl_loaddata_rule_m.test
+++ b/mysql-test/t/rpl_loaddata_rule_m.test
@@ -3,6 +3,11 @@
# This is for BUG#1100 (LOAD DATA INFILE was half-logged).
source include/master-slave.inc;
+
+--disable_warnings
+drop database if exists mysqltest;
+--enable_warnings
+
connection slave;
reset master;
@@ -10,9 +15,9 @@ reset master;
connection master;
# 'test' is the current database
-create database test2;
+create database mysqltest;
create table t1(a int, b int, unique(b));
-use test2;
+use mysqltest;
load data infile '../../std_data/rpl_loaddata.dat' into table test.t1;
show binlog events from 79; # should be nothing
-drop database test2;
+drop database mysqltest;
diff --git a/mysql-test/t/rpl_log.test b/mysql-test/t/rpl_log.test
index e01b3e4e09c..7ae0a4dc3c2 100644
--- a/mysql-test/t/rpl_log.test
+++ b/mysql-test/t/rpl_log.test
@@ -1,8 +1,18 @@
source include/master-slave.inc;
-#clean up slave binlogs
+# Clean up old slave's binlogs.
+# The slave is started with --log-slave-updates
+# and this test does SHOW BINLOG EVENTS on the slave's
+# binlog. But previous tests can influence the current test's
+# binlog (e.g. a temporary table in the previous test has not
+# been explicitly deleted, and at the beginning of the current
+# test the slave immediately writes DROP TEMPORARY TABLE this_old_table).
+# We wait for the slave to have written all he wants to the binlog
+# (otherwise RESET MASTER may come too early).
+save_master_pos;
connection slave;
-slave stop;
+sync_with_master;
+stop slave;
reset master;
reset slave;
# We are going to read the slave's binlog which contains file_id (for some LOAD
@@ -59,10 +69,10 @@ connection slave;
# Note that the above 'slave start' will cause a 3rd rotate event (a fake one)
# to go into the relay log (the master always sends a fake one when replication
# starts).
-slave start;
+start slave;
sync_with_master;
flush logs;
-slave stop;
+stop slave;
connection master;
# Create some entries for second log
@@ -72,27 +82,28 @@ insert into t1 values (1);
drop table t1;
--replace_result $VERSION VERSION
show binlog events;
-show binlog events in 'master-bin.002';
-show master logs;
+show binlog events in 'master-bin.000002';
+show binary logs;
save_master_pos;
connection slave;
-slave start;
+start slave;
sync_with_master;
-show master logs;
+show binary logs;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT $VERSION VERSION
-show binlog events in 'slave-bin.001' from 4;
+show binlog events in 'slave-bin.000001' from 4;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT $VERSION VERSION
-show binlog events in 'slave-bin.002' from 4;
+show binlog events in 'slave-bin.000002' from 4;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
# Need to recode the following
-#show new master for slave with master_log_file='master-bin.001' and master_log_pos=4 and master_server_id=1;
-#show new master for slave with master_log_file='master-bin.001' and master_log_pos=79 and master_server_id=1;
-#show new master for slave with master_log_file='master-bin.001' and master_log_pos=311 and master_server_id=1;
-#show new master for slave with master_log_file='master-bin.002' and master_log_pos=4 and master_server_id=1;
-#show new master for slave with master_log_file='master-bin.002' and master_log_pos=122 and master_server_id=1;
+#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=4 and master_server_id=1;
+#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=79 and master_server_id=1;
+#show new master for slave with master_log_file='master-bin.000001' and master_log_pos=311 and master_server_id=1;
+#show new master for slave with master_log_file='master-bin.000002' and master_log_pos=4 and master_server_id=1;
+#show new master for slave with master_log_file='master-bin.000002' and master_log_pos=122 and master_server_id=1;
--error 1220
-show binlog events in 'slave-bin.005' from 4;
+show binlog events in 'slave-bin.000005' from 4;
diff --git a/mysql-test/t/rpl_log_pos.test b/mysql-test/t/rpl_log_pos.test
index e11ba92cfa7..b32f68844a2 100644
--- a/mysql-test/t/rpl_log_pos.test
+++ b/mysql-test/t/rpl_log_pos.test
@@ -3,29 +3,32 @@
#
source include/master-slave.inc;
show master status;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
-slave stop;
+stop slave;
change master to master_log_pos=73;
-slave start;
+start slave;
sleep 5;
-slave stop;
+stop slave;
change master to master_log_pos=73;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
-slave start;
+start slave;
sleep 5;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
-slave stop;
+stop slave;
change master to master_log_pos=173;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
-slave start;
+start slave;
sleep 2;
+--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
connection master;
show master status;
@@ -35,13 +38,11 @@ create table t1 (n int);
insert into t1 values (1),(2),(3);
save_master_pos;
connection slave;
-slave stop;
+stop slave;
change master to master_log_pos=79;
-slave start;
+start slave;
sync_with_master;
select * from t1;
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl_master_pos_wait.test b/mysql-test/t/rpl_master_pos_wait.test
index 24479636c91..4d4d51b04ab 100644
--- a/mysql-test/t/rpl_master_pos_wait.test
+++ b/mysql-test/t/rpl_master_pos_wait.test
@@ -7,6 +7,7 @@ sync_with_master;
# Ask for a master log that has certainly not been reached yet
# timeout= 2 seconds
select master_pos_wait('master-bin.999999',0,2);
+explain extended select master_pos_wait('master-bin.999999',0,2);
# Testcase for bug 651 (master_pos_wait() hangs if slave idle and STOP SLAVE).
send select master_pos_wait('master-bin.999999',0);
connection slave1;
diff --git a/mysql-test/t/rpl_max_relay_size.test b/mysql-test/t/rpl_max_relay_size.test
index a2167b1ef36..99f0a9fdde6 100644
--- a/mysql-test/t/rpl_max_relay_size.test
+++ b/mysql-test/t/rpl_max_relay_size.test
@@ -29,6 +29,7 @@ select @@global.max_relay_log_size;
start slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
stop slave;
reset slave;
@@ -37,6 +38,7 @@ select @@global.max_relay_log_size;
start slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
stop slave;
reset slave;
@@ -45,6 +47,7 @@ select @@global.max_relay_log_size;
start slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
# Tests below are mainly to ensure that we have not coded with wrong assumptions
@@ -55,6 +58,7 @@ reset slave;
# (to make sure it does not crash).
flush logs;
--replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
reset slave;
@@ -70,6 +74,7 @@ save_master_pos;
connection slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
# one more rotation, to be sure Relay_log_space is correctly updated
flush logs;
@@ -79,6 +84,7 @@ save_master_pos;
connection slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT 3306 MASTER_PORT 3334 MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
connection master;
diff --git a/mysql-test/t/rpl_misc_functions-slave.sh b/mysql-test/t/rpl_misc_functions-slave.sh
new file mode 100755
index 00000000000..c293715e16f
--- /dev/null
+++ b/mysql-test/t/rpl_misc_functions-slave.sh
@@ -0,0 +1 @@
+rm -f $MYSQL_TEST_DIR/var/master-data/test/rpl_misc_functions.outfile
diff --git a/mysql-test/t/rpl_misc_functions.test b/mysql-test/t/rpl_misc_functions.test
new file mode 100644
index 00000000000..12eadbb25ed
--- /dev/null
+++ b/mysql-test/t/rpl_misc_functions.test
@@ -0,0 +1,30 @@
+#
+# Test of replicating some difficult functions
+#
+source include/master-slave.inc;
+
+create table t1(id int, i int, r1 int, r2 int, p varchar(100));
+insert into t1 values(1, connection_id(), 0, 0, "");
+# don't put rand and password in the same query, to see if they replicate
+# independently
+# Pure rand test
+insert into t1 values(2, 0, rand()*1000, rand()*1000, "");
+# change the rand suite on the master (we do this because otherwise password()
+# benefits from the fact that the above rand() is well replicated :
+# it picks the same sequence element, which hides a possible bug in password() replication.
+set sql_log_bin=0;
+insert into t1 values(6, 0, rand(), rand(), "");
+delete from t1 where id=6;
+set sql_log_bin=1;
+# Pure password test
+insert into t1 values(3, 0, 0, 0, password('does_this_work?'));
+# "altogether now"
+insert into t1 values(4, connection_id(), rand()*1000, rand()*1000, password('does_this_still_work?'));
+select * into outfile 'rpl_misc_functions.outfile' from t1;
+sync_slave_with_master;
+create table t2 like t1;
+# read the values from the master table
+load data local infile './var/master-data/test/rpl_misc_functions.outfile' into table t2;
+# compare them with the replica; the SELECT below should return no row
+select * from t1, t2 where (t1.id=t2.id) and not(t1.i=t2.i and t1.r1=t2.r1 and t1.r2=t2.r2 and t1.p=t2.p);
+stop slave;
diff --git a/mysql-test/t/rpl_mystery22.test b/mysql-test/t/rpl_mystery22.test
index 5280cb360dd..d49f1a210f4 100644
--- a/mysql-test/t/rpl_mystery22.test
+++ b/mysql-test/t/rpl_mystery22.test
@@ -4,9 +4,7 @@ source include/master-slave.inc;
# first, cause a duplicate key problem on the slave
create table t1(n int auto_increment primary key);
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
insert into t1 values (2);
connection master;
insert into t1 values(NULL);
@@ -16,11 +14,11 @@ connection slave;
sleep 3; # there is no way around this sleep - we have to wait until
# the slave tries to run the query, fails and aborts slave thread
delete from t1 where n = 2;
-slave start;
+start slave;
sync_with_master;
#now the buggy slave would be confused on the offset but it can replicate
#in order to make it break, we need to stop/start the slave one more time
-slave stop;
+stop slave;
connection master;
# to be able to really confuse the slave, we need some non-auto-increment
# events in the log
@@ -29,7 +27,7 @@ drop table t2;
insert into t1 values(NULL);
save_master_pos;
connection slave;
-slave start;
+start slave;
#now the truth comes out - if the slave is buggy, it will never sync because
#the slave thread is not able to read events
sync_with_master;
@@ -37,7 +35,5 @@ select * from t1;
#clean up
connection master;
drop table t1;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl_openssl.test b/mysql-test/t/rpl_openssl.test
new file mode 100644
index 00000000000..8a36904f4d4
--- /dev/null
+++ b/mysql-test/t/rpl_openssl.test
@@ -0,0 +1,62 @@
+source include/have_openssl_1.inc;
+source include/master-slave.inc;
+
+# We don't test all types of ssl auth params here since it's a bit hard
+# until problems with OpenSSL 0.9.7 are unresolved
+
+# creating replication user for whom ssl auth is required
+# preparing playground
+connection master;
+grant replication slave on *.* to replssl@'%' require ssl;
+create table t1 (t int);
+save_master_pos;
+
+#syncing with master
+connection slave;
+sync_with_master;
+
+#trying to use this user without ssl
+stop slave;
+change master to master_user='replssl',master_password='';
+start slave;
+
+#showing that replication don't work
+connection master;
+insert into t1 values (1);
+#reasonable timeout for changes to propagate to slave
+sleep 3;
+connection slave;
+select * from t1;
+
+#showing that replication could work with ssl params
+stop slave;
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+eval change master to master_ssl=1 , master_ssl_ca ='$MYSQL_TEST_DIR/std_data/cacert.pem', master_ssl_cert='$MYSQL_TEST_DIR/std_data/client-cert.pem', master_ssl_key='$MYSQL_TEST_DIR/std_data/client-key.pem';
+start slave;
+
+#avoiding unneeded sleeps
+connection master;
+save_master_pos;
+connection slave;
+sync_with_master;
+
+#checking that replication is ok
+select * from t1;
+
+#checking show slave status
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT
+--replace_column 1 # 33 #
+show slave status;
+
+#checking if replication works without ssl also performing clean up
+stop slave;
+change master to master_user='root',master_password='', master_ssl=0;
+start slave;
+connection master;
+drop table t1;
+save_master_pos;
+connection slave;
+sync_with_master;
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT
+--replace_column 1 # 33 #
+show slave status;
diff --git a/mysql-test/t/rpl_redirect.test b/mysql-test/t/rpl_redirect.test
index 4082542f295..3b5ad6ba88d 100644
--- a/mysql-test/t/rpl_redirect.test
+++ b/mysql-test/t/rpl_redirect.test
@@ -12,6 +12,7 @@ sync_with_master;
#discover slaves
connection master;
--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 33 #
SHOW SLAVE STATUS;
--replace_result $SLAVE_MYPORT SLAVE_PORT
SHOW SLAVE HOSTS;
@@ -19,7 +20,6 @@ rpl_probe;
#turn on master/slave query direction auto-magic
enable_rpl_parse;
-drop table if exists t1;
create table t1 ( n int);
insert into t1 values (1),(2),(3),(4);
disable_rpl_parse;
diff --git a/mysql-test/t/rpl_relayrotate-slave.opt b/mysql-test/t/rpl_relayrotate-slave.opt
new file mode 100644
index 00000000000..8b671423363
--- /dev/null
+++ b/mysql-test/t/rpl_relayrotate-slave.opt
@@ -0,0 +1,4 @@
+-O max_binlog_size=16384
+--innodb
+--log-warnings
+
diff --git a/mysql-test/t/rpl_relayrotate.test b/mysql-test/t/rpl_relayrotate.test
new file mode 100644
index 00000000000..7a572740b3a
--- /dev/null
+++ b/mysql-test/t/rpl_relayrotate.test
@@ -0,0 +1,70 @@
+# When the relay log gets rotated while the I/O thread
+# is reading a transaction, the transaction spans on two or more
+# relay logs. If STOP SLAVE occurs while the SQL thread is
+# executing a part of the transaction in the non-first relay logs,
+# we test if START SLAVE will resume in the beginning of the
+# transaction (i.e., step back to the first relay log)
+
+# The slave is started with max_binlog_size=16384 bytes,
+# to force many rotations (approximately 30 rotations)
+
+# If the master or slave does not support InnoDB, this test will pass
+
+source include/master-slave.inc;
+connection slave;
+stop slave;
+connection master;
+--disable_warnings
+create table t1 (a int) type=innodb;
+--enable_warnings
+let $1=8000;
+disable_query_log;
+begin;
+while ($1)
+{
+# eval means expand $ expressions
+ eval insert into t1 values( $1 );
+ dec $1;
+}
+commit;
+# This will generate a 500kB master's binlog,
+# which corresponds to 30 slave's relay logs.
+enable_query_log;
+save_master_pos;
+connection slave;
+reset slave;
+start slave;
+# We wait 1 sec for the SQL thread to be somewhere in
+# the middle of the transaction, hopefully not in
+# the first relay log, and hopefully before the COMMIT.
+# Usually it stops when the SQL thread is around the 15th relay log.
+# We cannot use MASTER_POS_WAIT() as master's position
+# increases only when the slave executes the COMMIT.
+# Note that except when using Valgrind, 1 second is enough for the I/O slave
+# thread to fetch the whole master's binlog.
+sleep 1;
+stop slave;
+# We suppose the SQL thread stopped before COMMIT.
+# If so the transaction was rolled back
+# and the table is now empty.
+# Now restart
+start slave;
+# And see if the table contains '8000'
+# which proves that the transaction restarted at
+# the right place.
+# We must wait for the transaction to commit before
+# reading, MASTER_POS_WAIT() will do it for sure
+# (the only statement with position>=3000 is COMMIT).
+select master_pos_wait('master-bin.001',3000)>=0;
+select * from t1 where a=8000;
+
+# The following DROP is a very important cleaning task:
+# imagine the next test is run with --skip-innodb: it will do
+# DROP TABLE IF EXISTS t1; but this will delete the frm and leave
+# some data in the InnoDB datafile (because at that time mysqld
+# does not know about InnoDB : --skip-innodb). So if later in the
+# test suite a test wants to create an InnoDB table called t1, it
+# will fail with
+# InnoDB: Error: table t1 already exists in InnoDB internal
+# InnoDB: data dictionary. Have you deleted the .frm file etc
+drop table t1;
diff --git a/mysql-test/t/rpl_replicate_do.test b/mysql-test/t/rpl_replicate_do.test
index 0800062dc05..7066f6e53d8 100644
--- a/mysql-test/t/rpl_replicate_do.test
+++ b/mysql-test/t/rpl_replicate_do.test
@@ -2,9 +2,12 @@
# updates on t1
source include/master-slave.inc;
+--disable_warnings
drop table if exists t11;
connection slave;
drop table if exists t11;
+--enable_warnings
+
create table t2 (n int);
insert into t2 values(4);
connection master;
@@ -24,7 +27,12 @@ select * from t2;
--error 1146
select * from t11;
connection master;
-drop table if exists t1,t2,t3,t11;
+drop table if exists t1,t2,t11;
save_master_pos;
connection slave;
sync_with_master;
+# show slave status, just to see of it prints replicate-do-table
+--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 33 #
+show slave status;
+
diff --git a/mysql-test/t/rpl_reset_slave.test b/mysql-test/t/rpl_reset_slave.test
index 083492c3fc0..d58e9c711d1 100644
--- a/mysql-test/t/rpl_reset_slave.test
+++ b/mysql-test/t/rpl_reset_slave.test
@@ -11,20 +11,24 @@ save_master_pos;
connection slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
stop slave;
change master to master_user='test';
--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
reset slave;
--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
start slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
# test of crash with temp tables & RESET SLAVE
diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test
index c4dc5de38da..7560d56af1c 100644
--- a/mysql-test/t/rpl_rotate_logs.test
+++ b/mysql-test/t/rpl_rotate_logs.test
@@ -1,5 +1,5 @@
#
-# Test are run with max_binlog_size=2048 to force automatic rotation of the
+# Test is run with max_binlog_size=2048 to force automatic rotation of the
# binary log
# Tests done:
# - Check that slaves reports correct failures if master.info has strange
@@ -8,26 +8,33 @@
# - Ensure that temporary tables works over flush logs and binary log
# changes
# - Test creating a duplicate key error and recover from it
-#
+
connect (master,localhost,root,,test,$MASTER_MYPORT,master.sock);
+--disable_warnings
drop table if exists t1, t2, t3, t4;
+--enable_warnings
connect (slave,localhost,root,,test,$SLAVE_MYPORT,slave.sock);
system cat /dev/null > var/slave-data/master.info;
system chmod 000 var/slave-data/master.info;
connection slave;
+--disable_warnings
drop table if exists t1, t2, t3, t4;
-# START SLAVE will fail because it can't read the file (mode 000) (system error 13)
+--enable_warnings
+
+# START SLAVE will fail because it can't read the file (mode 000)
+# (system error 13)
--error 1201
-slave start;
+start slave;
system chmod 600 var/slave-data/master.info;
# It will fail again because the file is empty so the slave cannot get valuable
# info about how to connect to the master from it (failure in
# init_strvar_from_file() in init_master_info()).
--error 1201
-slave start;
+start slave;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
-# CHANGE MASTER will fail because it first parses master.info before changing it
-# (so when master.info is bad, people have to use RESET SLAVE first).
+
+# CHANGE MASTER will fail because it first parses master.info before changing
+# it (so when master.info is bad, people have to use RESET SLAVE first).
--error 1201
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root';
reset slave;
@@ -36,7 +43,7 @@ eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master
connection master;
reset master;
connection slave;
-slave start;
+start slave;
connection master;
#
@@ -46,24 +53,20 @@ create temporary table temp_table (a char(80) not null);
insert into temp_table values ("testing temporary tables");
create table t1 (s text);
insert into t1 values('Could not break slave'),('Tried hard');
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
select * from t1;
connection master;
flush logs;
-drop table if exists t2;
create table t2(m int not null auto_increment primary key);
insert into t2 values (34),(67),(123);
flush logs;
-show master logs;
+show binary logs;
create table t3 select * from temp_table;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from t3;
connection master;
@@ -86,22 +89,26 @@ wait_for_slave_to_stop;
#restart slave skipping one event
set global sql_slave_skip_counter=1;
-slave start;
+start slave;
connection master;
-save_master_pos;
#let slave catch up
-connection slave;
-sync_with_master;
+sync_slave_with_master;
connection master;
-purge master logs to 'master-bin.003';
+purge master logs to 'master-bin.000002';
show master logs;
+# we just tests if synonyms are accepted
+purge binary logs to 'master-bin.000002';
+show binary logs;
+# sleeping 10 seconds or more would make the slave believe connection is down
+--real_sleep 1;
+purge master logs before now();
+show binary logs;
insert into t2 values (65);
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
select * from t2;
@@ -113,7 +120,7 @@ connection master;
create temporary table temp_table (a char(80) not null);
insert into temp_table values ("testing temporary tables part 2");
let $1=100;
-drop table if exists t3;
+
create table t3 (n int);
disable_query_log;
while ($1)
@@ -124,16 +131,15 @@ while ($1)
}
enable_query_log;
create table t4 select * from temp_table;
-show master logs;
+show binary logs;
show master status;
save_master_pos;
connection slave;
-#slave stop;
-#slave start;
sync_with_master;
select * from t4;
--replace_result 3306 MASTER_PORT 9306 MASTER_PORT 3334 MASTER_PORT 3336 MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
# because of concurrent insert, the table may not be up to date
# if we do not lock
@@ -143,6 +149,4 @@ unlock tables;
#clean up
connection master;
drop table if exists t1,t2,t3,t4;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl_skip_error.test b/mysql-test/t/rpl_skip_error.test
index d43c59ef024..86c89c70314 100644
--- a/mysql-test/t/rpl_skip_error.test
+++ b/mysql-test/t/rpl_skip_error.test
@@ -1,5 +1,4 @@
source include/master-slave.inc;
-drop table if exists t1;
create table t1 (n int not null primary key);
save_master_pos;
diff --git a/mysql-test/t/rpl_sporadic_master.test b/mysql-test/t/rpl_sporadic_master.test
index e59b93b4475..b24901c62a9 100644
--- a/mysql-test/t/rpl_sporadic_master.test
+++ b/mysql-test/t/rpl_sporadic_master.test
@@ -9,22 +9,16 @@ insert into t1 values (NULL),(NULL);
truncate table t1;
# We have to use 4 in the following to make this test work with all table types
insert into t1 values (4),(NULL);
-save_master_pos;
-connection slave;
-sync_with_master;
-slave stop;
-slave start;
+sync_slave_with_master;
+stop slave;
+start slave;
connection master;
insert into t1 values (NULL),(NULL);
flush logs;
truncate table t1;
insert into t1 values (10),(NULL),(NULL),(NULL),(NULL),(NULL);
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
select * from t1;
connection master;
drop table t1,t2;
-save_master_pos;
-connection slave;
-sync_with_master;
+sync_slave_with_master;
diff --git a/mysql-test/t/README b/mysql-test/t/rpl_temporary-master.opt
index e69de29bb2d..e69de29bb2d 100644
--- a/mysql-test/t/README
+++ b/mysql-test/t/rpl_temporary-master.opt
diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test
new file mode 100644
index 00000000000..0df8ceb6377
--- /dev/null
+++ b/mysql-test/t/rpl_temporary.test
@@ -0,0 +1,118 @@
+source include/master-slave.inc;
+
+# Clean up old slave's binlogs.
+# The slave is started with --log-slave-updates
+# and this test does SHOW BINLOG EVENTS on the slave's
+# binlog. But previous tests can influence the current test's
+# binlog (e.g. a temporary table in the previous test has not
+# been explicitly deleted, or it has but the slave hasn't had
+# enough time to catch it before STOP SLAVE,
+# and at the beginning of the current
+# test the slave immediately writes DROP TEMPORARY TABLE this_old_table).
+# We wait for the slave to have written all he wants to the binlog
+# (otherwise RESET MASTER may come too early).
+save_master_pos;
+connection slave;
+sync_with_master;
+reset master;
+connection master;
+
+connect (con1,localhost,root,,);
+connect (con2,localhost,root,,);
+# We want to connect as an unprivileged user. But if we use user="" then this
+# will pick the Unix login, which will cause problems if you're running the test
+# as root.
+connect (con3,localhost,zedjzlcsjhd,,);
+
+# We are going to use SET PSEUDO_THREAD_ID in this test;
+# check that it requires the SUPER privilege.
+
+connection con3;
+--error 1227
+SET @@session.pseudo_thread_id=100;
+
+let $VERSION=`select version()`;
+
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+create table t1(f int);
+create table t2(f int);
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+
+connection con1;
+create temporary table t3(f int);
+insert into t3 select * from t1 where f<6;
+sleep 1;
+
+connection con2;
+create temporary table t3(f int);
+sleep 1;
+
+connection con1;
+insert into t2 select count(*) from t3;
+sleep 1;
+
+connection con2;
+insert into t3 select * from t1 where f>=4;
+sleep 1;
+
+connection con1;
+drop temporary table t3;
+sleep 1;
+
+connection con2;
+insert into t2 select count(*) from t3;
+drop temporary table t3;
+
+select * from t2;
+
+--replace_result $VERSION VERSION
+show binlog events;
+
+drop table t1, t2;
+
+use test;
+SET TIMESTAMP=1040323920;
+create table t1(f int);
+SET TIMESTAMP=1040323931;
+create table t2(f int);
+SET TIMESTAMP=1040323938;
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
+
+SET TIMESTAMP=1040323945;
+SET @@session.pseudo_thread_id=1;
+create temporary table t3(f int);
+SET TIMESTAMP=1040323952;
+SET @@session.pseudo_thread_id=1;
+insert into t3 select * from t1 where f<6;
+SET TIMESTAMP=1040324145;
+SET @@session.pseudo_thread_id=2;
+create temporary table t3(f int);
+SET TIMESTAMP=1040324186;
+SET @@session.pseudo_thread_id=1;
+insert into t2 select count(*) from t3;
+SET TIMESTAMP=1040324200;
+SET @@session.pseudo_thread_id=2;
+insert into t3 select * from t1 where f>=4;
+SET TIMESTAMP=1040324211;
+SET @@session.pseudo_thread_id=1;
+drop temporary table t3;
+SET TIMESTAMP=1040324219;
+SET @@session.pseudo_thread_id=2;
+insert into t2 select count(*) from t3;
+SET TIMESTAMP=1040324224;
+SET @@session.pseudo_thread_id=2;
+drop temporary table t3;
+
+select * from t2;
+drop table t1,t2;
+
+# Create last a temporary table that is not dropped at end to ensure that we
+# don't get any memory leaks for this
+
+create temporary table t3 (f int);
+sync_with_master;
+
+# The server will now close done
diff --git a/mysql-test/t/rpl_trunc_binlog.test b/mysql-test/t/rpl_trunc_binlog.test
index 2c34b7a442f..32052af9184 100644
--- a/mysql-test/t/rpl_trunc_binlog.test
+++ b/mysql-test/t/rpl_trunc_binlog.test
@@ -1,7 +1,7 @@
-# We are testing if a binlog which contains BEGIN but not COMMIT (the master did
-# while writing the transaction to the binlog) triggers an error on slave.
-# So we use such a truncated binlog and simulate that the master restarted after
-# this.
+# We are testing if a binlog which contains BEGIN but not COMMIT (the
+# master did while writing the transaction to the binlog) triggers an
+# error on slave. So we use such a truncated binlog and simulate that
+# the master restarted after this.
source include/master-slave.inc;
@@ -13,12 +13,13 @@ source include/have_bdb.inc;
stop slave;
connection master;
flush logs;
-system mv -f var/log/master-bin.001 var/log/master-bin.002;
-system cp std_data/trunc_binlog.001 var/log/master-bin.001;
+system mv -f var/log/master-bin.000001 var/log/master-bin.000002;
+system cp std_data/trunc_binlog.000001 var/log/master-bin.000001;
connection slave;
reset slave;
start slave;
# can't sync_with_master so we must sleep
sleep 3;
--replace_result $MASTER_MYPORT MASTER_PORT
+--replace_column 1 # 33 #
show slave status;
diff --git a/mysql-test/t/rpl_until.test b/mysql-test/t/rpl_until.test
new file mode 100644
index 00000000000..8b20a493826
--- /dev/null
+++ b/mysql-test/t/rpl_until.test
@@ -0,0 +1,81 @@
+source include/master-slave.inc;
+
+# prepare version for substitutions
+let $VERSION=`select version()`;
+
+# stop slave before he will start replication also sync with master
+# for avoiding undetermenistic behaviour
+save_master_pos;
+connection slave;
+sync_with_master;
+stop slave;
+
+connection master;
+# create some events on master
+create table t1(n int not null auto_increment primary key);
+insert into t1 values (1),(2),(3),(4);
+drop table t1;
+create table t2(n int not null auto_increment primary key);
+insert into t2 values (1),(2);
+insert into t2 values (3),(4);
+drop table t2;
+--replace_result $VERSION VERSION
+show binlog events;
+
+# try to replicate all queries until drop of t1
+connection slave;
+start slave until master_log_file='master-bin.000001', master_log_pos=244;
+sleep 2;
+# here table should be still not deleted
+select * from t1;
+--replace_result $MASTER_MYPORT MASTER_MYPORT
+--replace_column 1 # 33 #
+show slave status;
+
+# this should fail right after start
+start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291;
+# again this table should be still not deleted
+select * from t1;
+sleep 2;
+--replace_result $MASTER_MYPORT MASTER_MYPORT
+--replace_column 1 # 33 #
+show slave status;
+
+# try replicate all until second insert to t2;
+start slave until relay_log_file='slave-relay-bin.000002', relay_log_pos=537;
+sleep 2;
+select * from t2;
+--replace_result $MASTER_MYPORT MASTER_MYPORT
+--replace_column 1 # 33 #
+show slave status;
+
+# clean up
+start slave;
+connection master;
+save_master_pos;
+connection slave;
+sync_with_master;
+stop slave;
+
+# this should stop immideately
+start slave until master_log_file='master-bin.000001', master_log_pos=561;
+sleep 2;
+# here the sql slave thread should be stopped
+--replace_result $MASTER_MYPORT MASTER_MYPORT
+--replace_column 1 # 33 #
+show slave status;
+
+#testing various error conditions
+--error 1276
+start slave until master_log_file='master-bin', master_log_pos=561;
+--error 1276
+start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12;
+--error 1276
+start slave until master_log_file='master-bin.000001';
+--error 1276
+start slave until relay_log_file='slave-relay-bin.000002';
+--error 1276
+start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561;
+
+start slave sql_thread;
+start slave until master_log_file='master-bin.000001', master_log_pos=561;
diff --git a/mysql-test/t/rpl_user_variables.test b/mysql-test/t/rpl_user_variables.test
new file mode 100644
index 00000000000..35fbec72ac8
--- /dev/null
+++ b/mysql-test/t/rpl_user_variables.test
@@ -0,0 +1,52 @@
+#
+# Test of replicating user variables
+#
+source include/master-slave.inc;
+
+# Clean up old slave's binlogs.
+# The slave is started with --log-slave-updates
+# and this test does SHOW BINLOG EVENTS on the slave's
+# binlog. But previous tests can influence the current test's
+# binlog (e.g. a temporary table in the previous test has not
+# been explicitly deleted, or it has but the slave hasn't had
+# enough time to catch it before STOP SLAVE,
+# and at the beginning of the current
+# test the slave immediately writes DROP TEMPORARY TABLE this_old_table).
+# We wait for the slave to have written all he wants to the binlog
+# (otherwise RESET MASTER may come too early).
+save_master_pos;
+connection slave;
+sync_with_master;
+reset master;
+connection master;
+
+create table t1(n char(30));
+set @i1:=12345678901234, @i2:=-12345678901234, @i3:=0, @i4:=-1;
+set @s1:='This is a test', @r1:=12.5, @r2:=-12.5;
+set @n1:=null;
+set @s2:='', @s3:='abc\'def', @s4:= 'abc\\def', @s5:= 'abc''def';
+insert into t1 values (@i1), (@i2), (@i3), (@i4);
+insert into t1 values (@r1), (@r2);
+insert into t1 values (@s1), (@s2), (@s3), (@s4), (@s5);
+insert into t1 values (@n1);
+insert into t1 values (@n2); # not explicitely set before
+insert into t1 values (@a:=0), (@a:=@a+1), (@a:=@a+1);
+insert into t1 values (@a+(@b:=@a+1));
+set @q:='abc';
+insert t1 values (@q), (@q:=concat(@q, 'n1')), (@q:=concat(@q, 'n2'));
+set @a:=5;
+insert into t1 values (@a),(@a);
+connection master1; # see if variable is reset in binlog when thread changes
+insert into t1 values (@a),(@a),(@a*5);
+select * from t1;
+save_master_pos;
+connection slave;
+sync_with_master;
+select * from t1;
+show binlog events from 141;
+connection master;
+drop table t1;
+save_master_pos;
+connection slave;
+sync_with_master;
+stop slave;
diff --git a/mysql-test/t/sel000001.test b/mysql-test/t/sel000001.test
deleted file mode 100644
index ad4af1f92fb..00000000000
--- a/mysql-test/t/sel000001.test
+++ /dev/null
@@ -1,31 +0,0 @@
-# sel000001
-#
-# Versions
-# --------
-# 3.22
-# 3.23
-#
-# Description
-# -----------
-# This test is just a simple select.
-# Testing WHERE clause.
-#
-
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (s CHAR(20) PRIMARY KEY, id INT);
-INSERT INTO t1 VALUES ('cat', 1), ('mouse', 3), ('dog', 2), ('snake', 77);
-SELECT s, id FROM t1 WHERE s = 'mouse';
-drop table t1;
-
-#
-#test for bug #717
-#
-CREATE TABLE t1 (
- node int(11) NOT NULL default '0',
- maxchild int(11) NOT NULL default '0',
- PRIMARY KEY (`node`)
-);
-INSERT INTO t1 (node, maxchild) VALUES (4,4),(5,5),(1,244);
-SELECT * FROM t1 g1, t1 g2
- WHERE g1.node <= g2.node and g2.node <= g1.maxchild and g2.node = g2.maxchild;
-DROP TABLE t1;
diff --git a/mysql-test/t/sel000002.test b/mysql-test/t/sel000002.test
deleted file mode 100644
index 9a89db2821c..00000000000
--- a/mysql-test/t/sel000002.test
+++ /dev/null
@@ -1,17 +0,0 @@
-# sel000002
-#
-# Versions
-# --------
-# 3.22
-# 3.23
-#
-# Description
-# -----------
-# This test is just a simple select.
-#
-
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (n INT);
-INSERT INTO t1 VALUES (1), (2), (3);
-SELECT * FROM t1;
-drop table t1;
diff --git a/mysql-test/t/sel000003.test b/mysql-test/t/sel000003.test
deleted file mode 100644
index a3f6a7337c2..00000000000
--- a/mysql-test/t/sel000003.test
+++ /dev/null
@@ -1,18 +0,0 @@
-# sel000003
-#
-# Versions
-# --------
-# 3.22
-# 3.23
-#
-# Description
-# -----------
-# This test is just a simple select.
-# Testing count() function and GROUP BY clause.
-#
-
-DROP TABLE IF EXISTS t1;
-CREATE TABLE t1 (name CHAR(20) NOT NULL PRIMARY KEY, score SMALLINT NOT NULL, KEY(score));
-INSERT INTO t1 VALUES ('Sasha', 20), ('Matt', 20), ('Monty', 10), ('David', 10), ('Tim', 10), ('Jeremy', 10);
-SELECT COUNT(*) as n, score FROM t1 GROUP BY score;
-drop table t1;
diff --git a/mysql-test/t/sel000031.test b/mysql-test/t/sel000031.test
deleted file mode 100644
index 29bafbb3040..00000000000
--- a/mysql-test/t/sel000031.test
+++ /dev/null
@@ -1,20 +0,0 @@
-# sel000031
-#
-# Versions
-# --------
-# 3.22
-# 3.23
-#
-# Description
-# -----------
-# test for a bug with elt() and order by
-
-drop table if exists t1,t2;
-create table t1 (id int(10) not null unique);
-create table t2 (id int(10) not null primary key,
-val int(10) not null);
-insert into t1 values (1),(2),(4);
-insert into t2 values (1,1),(2,1),(3,1),(4,2);
-
-select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id;
-drop table t1,t2;
diff --git a/mysql-test/t/sel000032.test b/mysql-test/t/sel000032.test
deleted file mode 100644
index d31ba69e9d8..00000000000
--- a/mysql-test/t/sel000032.test
+++ /dev/null
@@ -1,20 +0,0 @@
-# sel000032
-#
-# Versions
-# --------
-# 3.22
-# 3.23
-#
-# Description
-# -----------
-# test for a bug with elt()
-
-drop table if exists t1,t2;
-create table t1 (id int(10) not null unique);
-create table t2 (id int(10) not null primary key,
-val int(10) not null);
-insert into t1 values (1),(2),(4);
-insert into t2 values (1,1),(2,1),(3,1),(4,2);
-
-select one.id, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id;
-drop table t1,t2;
diff --git a/mysql-test/t/sel000033.test b/mysql-test/t/sel000033.test
deleted file mode 100644
index 165e43ad9f8..00000000000
--- a/mysql-test/t/sel000033.test
+++ /dev/null
@@ -1,18 +0,0 @@
-# sel000033
-#
-# Versions
-# --------
-# 3.22
-# 3.23
-#
-# Description
-# -----------
-# test for a bug with in() and unique key
-
-drop table if exists t1;
-create table t1 (id int(10) primary key);
-insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
-
-select id from t1 where id in (2,5,9) ;
-select id from t1 where id=2 or id=5 or id=9 ;
-drop table t1;
diff --git a/mysql-test/t/sel000100.test b/mysql-test/t/sel000100.test
deleted file mode 100644
index d587fa4ebd0..00000000000
--- a/mysql-test/t/sel000100.test
+++ /dev/null
@@ -1,46 +0,0 @@
-DROP TABLE IF EXISTS t1,t2;
-
-CREATE TABLE t1 (
- ID int(11) NOT NULL auto_increment,
- NAME varchar(75) DEFAULT '' NOT NULL,
- LINK_ID int(11) DEFAULT '0' NOT NULL,
- PRIMARY KEY (ID),
- KEY NAME (NAME),
- KEY LINK_ID (LINK_ID)
-);
-
-INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0);
-INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (2,'Jack',0);
-INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (3,'Bill',0);
-
-CREATE TABLE t2 (
- ID int(11) NOT NULL auto_increment,
- NAME varchar(150) DEFAULT '' NOT NULL,
- PRIMARY KEY (ID),
- KEY NAME (NAME)
-);
-
-SELECT DISTINCT
- t2.id AS key_link_id,
- t2.name AS link
-FROM t1
-LEFT JOIN t2 ON t1.link_id=t2.id
-GROUP BY t1.id
-ORDER BY link;
-
-drop table t1,t2;
-
-#
-# test case for #674
-#
-CREATE TABLE t1 (
- html varchar(5) default NULL,
- rin int(11) default '0',
- out int(11) default '0'
-) TYPE=MyISAM;
-
-INSERT INTO t1 VALUES ('1',1,0);
-
-SELECT DISTINCT html,SUM(out)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin;
-
-drop table t1;
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 3e23fa1a3f2..b817544bfb9 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -6,7 +6,9 @@
# Simple select test
#
+--disable_warnings
drop table if exists t1,t2,t3,t4;
+--enable_warnings
CREATE TABLE t1 (
Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
@@ -1491,8 +1493,6 @@ select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.
# We need another table for join stuff..
#
-drop table if exists company;
-
create table t4 (
companynr tinyint(2) unsigned zerofill NOT NULL default '00',
companyname char(30) NOT NULL default '',
@@ -1595,8 +1595,9 @@ select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld
select count(*) from t1;
select companynr,count(*),sum(fld1) from t2 group by companynr;
select companynr,count(*) from t2 group by companynr order by companynr desc limit 5;
-select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1) from t2 where companynr = 34 and fld4<>"";
-select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1) from t2 group by companynr limit 3;
+select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
+explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
+select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10;
select /*! SQL_SMALL_RESULT */ companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10;
select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ;
@@ -1785,6 +1786,10 @@ select wss_type from t1 where wss_type ='102935229216544104';
select wss_type from t1 where wss_type ='102935229216544093';
select wss_type from t1 where wss_type =102935229216544093;
drop table t1;
+select 1+2,"aaaa",3.13*2.0 into @a,@b,@c;
+select @a;
+select @b;
+select @c;
#
# Test of removing redundant braces in the FROM part
@@ -1857,4 +1862,3 @@ select * from t1 left join t2 on id1 = id2 left join t3 on id1 = id3
left join t4 on id3 = id4 where id2 = 1 or id4 = 1;
drop table t1,t2,t3,t4;
-
diff --git a/mysql-test/t/select_found.test b/mysql-test/t/select_found.test
index 0a483c860cb..e8be902606c 100644
--- a/mysql-test/t/select_found.test
+++ b/mysql-test/t/select_found.test
@@ -1,8 +1,10 @@
#
# Testing of found_rows()
#
-
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (a int not null auto_increment, b int not null, primary key(a));
insert into t1 (b) values (2),(3),(5),(5),(5),(6),(7),(9);
select SQL_CALC_FOUND_ROWS * from t1;
@@ -62,7 +64,7 @@ SELECT FOUND_ROWS();
SELECT DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL LIMIT 10;
SELECT DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL ORDER BY email LIMIT 10;
-INSERT INTO `t1` (`id`, `kid`) VALUES ('', '150');
+INSERT INTO `t1` (`id`, `kid`) VALUES ('0', '150');
SELECT SQL_CALC_FOUND_ROWS DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL LIMIT 10;
SELECT FOUND_ROWS();
@@ -84,4 +86,12 @@ INSERT INTO t1 (titre,maxnumrep) VALUES
('test1','1'),('test2','2'),('test3','3');
SELECT SQL_CALC_FOUND_ROWS titre,numeropost,maxnumrep FROM t1 WHERE numeropost IN (1,2) ORDER BY maxnumrep DESC LIMIT 0, 1;
SELECT FOUND_ROWS();
+SELECT SQL_CALC_FOUND_ROWS 1 FROM (SELECT 1) as a LIMIT 0;
+SELECT FOUND_ROWS();
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE numeropost > 1 LIMIT 0;
+SELECT FOUND_ROWS();
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 0;
+SELECT FOUND_ROWS();
+SELECT SQL_CALC_FOUND_ROWS * FROM t1 ORDER BY numeropost LIMIT 0;
+SELECT FOUND_ROWS();
drop table t1;
diff --git a/mysql-test/t/select_safe.test b/mysql-test/t/select_safe.test
index 904479635c2..3cafd31a879 100644
--- a/mysql-test/t/select_safe.test
+++ b/mysql-test/t/select_safe.test
@@ -2,7 +2,10 @@
# test of safe selects
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
SET SQL_SAFE_UPDATES=1,SQL_SELECT_LIMIT=4, SQL_MAX_JOIN_SIZE=9;
create table t1 (a int auto_increment primary key, b char(20));
insert into t1 values(1,"test");
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index 2cd2012d109..633826186be 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -2,7 +2,10 @@
# Test of some show commands
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (a int not null primary key, b int not null,c int not null, key(b,c));
insert into t1 values (1,2,2),(2,2,3),(3,2,4),(4,2,4);
check table t1 fast;
@@ -49,9 +52,11 @@ drop table t2;
create table t1 (
test_set set( 'val1', 'val2', 'val3' ) not null default '',
- name char(20) default 'O''Brien'
+ name char(20) default 'O''Brien' comment 'O''Brien as default',
+ c int not null comment 'int column'
) comment = 'it\'s a table' ;
show create table t1 ;
+show full columns from t1;
drop table t1;
create table t1 (a int not null, unique aa (a));
@@ -78,6 +83,7 @@ drop table t1;
create table t1 (a decimal(9,2), b decimal (9,0), e double(9,2), f double(5,0), h float(3,2), i float(3,0));
show columns from t1;
+show full columns from t1;
drop table t1;
#
diff --git a/mysql-test/t/sql_mode.test b/mysql-test/t/sql_mode.test
new file mode 100644
index 00000000000..d96fd030207
--- /dev/null
+++ b/mysql-test/t/sql_mode.test
@@ -0,0 +1,30 @@
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+CREATE TABLE `t1` (
+ a int not null auto_increment,
+ `pseudo` varchar(35) character set latin2 NOT NULL default '',
+ `email` varchar(60) character set latin2 NOT NULL default '',
+ PRIMARY KEY (a),
+ UNIQUE KEY `email` USING BTREE (`email`)
+) TYPE=HEAP CHARSET=latin1 ROW_FORMAT DYNAMIC;
+set @@sql_mode="";
+show variables like 'sql_mode';
+show create table t1;
+set @@sql_mode="ansi_quotes";
+show variables like 'sql_mode';
+show create table t1;
+set @@sql_mode="no_table_options";
+show variables like 'sql_mode';
+show create table t1;
+set @@sql_mode="no_key_options";
+show variables like 'sql_mode';
+show create table t1;
+set @@sql_mode="no_field_options,mysql323,mysql40";
+show variables like 'sql_mode';
+show create table t1;
+set sql_mode="postgresql,oracle,mssql,db2,maxdb";
+select @@sql_mode;
+show create table t1;
+drop table t1;
diff --git a/mysql-test/t/status.test b/mysql-test/t/status.test
index cffca437cf1..30edcc79d9e 100644
--- a/mysql-test/t/status.test
+++ b/mysql-test/t/status.test
@@ -4,7 +4,7 @@
# This would work if mysqltest run would be threaded and handle each
# connection in a separate thread.
#
--- source include/not_embedded.inc
+--source include/not_embedded.inc
connect (con1,localhost,root,,);
connect (con2,localhost,root,,);
@@ -13,7 +13,10 @@ flush status;
show status like 'Table_lock%';
connection con1;
SET SQL_LOG_BIN=0;
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1(n int) type=myisam;
insert into t1 values(1);
connection con2;
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
new file mode 100644
index 00000000000..75ca521d24e
--- /dev/null
+++ b/mysql-test/t/subselect.test
@@ -0,0 +1,1011 @@
+# Initialise
+--disable_warnings
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t11,t12;
+--enable_warnings
+
+select (select 2);
+explain extended select (select 2);
+SELECT (SELECT 1) UNION SELECT (SELECT 2);
+explain extended SELECT (SELECT 1) UNION SELECT (SELECT 2);
+SELECT (SELECT (SELECT 0 UNION SELECT 0));
+explain extended SELECT (SELECT (SELECT 0 UNION SELECT 0));
+-- error 1246
+SELECT (SELECT 1 FROM (SELECT 1) as b HAVING a=1) as a;
+-- error 1246
+SELECT (SELECT 1 FROM (SELECT 1) as b HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) as c HAVING a=1) as b;
+SELECT (SELECT 1),MAX(1) FROM (SELECT 1) as a;
+-- error 1246
+SELECT (SELECT a) as a;
+EXPLAIN EXTENDED SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
+SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1;
+-- error 1054
+SELECT (SELECT 1), a;
+SELECT 1 as a FROM (SELECT 1) as b HAVING (SELECT a)=1;
+-- error 1054
+SELECT 1 FROM (SELECT (SELECT a) b) c;
+SELECT * FROM (SELECT 1 as id) b WHERE id IN (SELECT * FROM (SELECT 1 as id) c ORDER BY id);
+-- error 1240
+SELECT * FROM (SELECT 1) a WHERE 1 IN (SELECT 1,1);
+SELECT 1 IN (SELECT 1);
+SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
+-- error 1221
+select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
+-- error 1108
+SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
+SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
+SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
+SELECT (SELECT 1,2,3) = ROW(1,2,3);
+SELECT (SELECT 1,2,3) = ROW(1,2,1);
+SELECT (SELECT 1,2,3) < ROW(1,2,1);
+SELECT (SELECT 1,2,3) > ROW(1,2,1);
+SELECT (SELECT 1,2,3) = ROW(1,2,NULL);
+SELECT ROW(1,2,3) = (SELECT 1,2,3);
+SELECT ROW(1,2,3) = (SELECT 1,2,1);
+SELECT ROW(1,2,3) < (SELECT 1,2,1);
+SELECT ROW(1,2,3) > (SELECT 1,2,1);
+SELECT ROW(1,2,3) = (SELECT 1,2,NULL);
+SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a');
+SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b');
+SELECT (SELECT 1.5,2,'a') = ROW('b',2,'b');
+SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a');
+SELECT (SELECT 1.5,2,'a') = ROW(1.5,'c','a');
+SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a');
+
+-- error 1240
+SELECT (SELECT * FROM (SELECT 'test' a,'test' b) a);
+
+SELECT 1 as a,(SELECT a+a) b,(SELECT b);
+
+create table t1 (a int);
+create table t2 (a int, b int);
+create table t3 (a int);
+create table t4 (a int not null, b int not null);
+insert into t1 values (2);
+insert into t2 values (1,7),(2,7);
+insert into t4 values (4,8),(3,8),(5,9);
+-- error 1246
+select (select a from t1 where t1.a = a1) as a2, (select b from t2 where t2.b=a2) as a1;
+select (select a from t1 where t1.a=t2.a), a from t2;
+select (select a from t1 where t1.a=t2.b), a from t2;
+select (select a from t1), a from t2;
+select (select a from t3), a from t2;
+select * from t2 where t2.a=(select a from t1);
+insert into t3 values (6),(7),(3);
+select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1);
+(select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 order by a limit 2) limit 3;
+(select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a);
+explain extended (select * from t2 where t2.b=(select a from t3 order by 1 desc limit 1)) union (select * from t4 where t4.b=(select max(t2.a)*4 from t2) order by a);
+select (select a from t3 where a<t2.a*4 order by 1 desc limit 1), a from t2;
+select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
+(select * from t2 where a>1) as tt;
+explain extended select (select t3.a from t3 where a<8 order by 1 desc limit 1), a from
+(select * from t2 where a>1) as tt;
+select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3) order by 1 desc limit 1);
+select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a > t1.a) order by 1 desc limit 1);
+select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a < t1.a) order by 1 desc limit 1);
+select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4;
+explain extended select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4;
+select * from t3 where exists (select * from t2 where t2.b=t3.a);
+select * from t3 where not exists (select * from t2 where t2.b=t3.a);
+select * from t3 where a in (select b from t2);
+select * from t3 where a not in (select b from t2);
+select * from t3 where a = some (select b from t2);
+select * from t3 where a <> any (select b from t2);
+
+# Rewrite: select * from t3 where not exists (select b from t2 where a <> b);
+select * from t3 where a = all (select b from t2);
+
+select * from t3 where a <> all (select b from t2);
+insert into t2 values (100, 5);
+select * from t3 where a < any (select b from t2);
+select * from t3 where a < all (select b from t2);
+select * from t3 where a >= any (select b from t2);
+explain extended select * from t3 where a >= any (select b from t2);
+select * from t3 where a >= all (select b from t2);
+delete from t2 where a=100;
+-- error 1240
+select * from t3 where a in (select a,b from t2);
+-- error 1240
+select * from t3 where a in (select * from t2);
+insert into t4 values (12,7),(1,7),(10,9),(9,6),(7,6),(3,9),(1,10);
+-- empty set
+select b,max(a) as ma from t4 group by b having b < (select max(t2.a) from t2 where t2.b=t4.b);
+insert into t2 values (2,10);
+select b,max(a) as ma from t4 group by b having ma < (select max(t2.a) from t2 where t2.b=t4.b);
+delete from t2 where a=2 and b=10;
+select b,max(a) as ma from t4 group by b having b >= (select max(t2.a) from t2 where t2.b=t4.b);
+create table t5 (a int);
+select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2;
+insert into t5 values (5);
+select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2;
+insert into t5 values (2);
+select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2;
+explain extended select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2;
+-- error 1241
+select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2;
+create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq));
+create table t7( uq int primary key, name char(25));
+insert into t7 values(1,"Oblastnaia bolnitsa"),(2,"Bolnitsa Krasnogo Kresta");
+insert into t6 values (1,1),(1,2),(2,2),(1,3);
+select * from t6 where exists (select * from t7 where uq = clinic_uq);
+explain extended select * from t6 where exists (select * from t7 where uq = clinic_uq);
+
+# not unique fields
+-- error 1052
+select * from t1 where a= (select a from t2,t4 where t2.b=t4.b);
+
+# different tipes & group functions
+drop table if exists t1,t2,t3;
+
+CREATE TABLE t3 (a varchar(20),b char(1) NOT NULL default '0');
+INSERT INTO t3 VALUES ('W','a'),('A','c'),('J','b');
+CREATE TABLE t2 (a varchar(20),b int NOT NULL default '0');
+INSERT INTO t2 VALUES ('W','1'),('A','3'),('J','2');
+CREATE TABLE t1 (a varchar(20),b date NOT NULL default '0000-00-00');
+INSERT INTO t1 VALUES ('W','1732-02-22'),('A','1735-10-30'),('J','1743-04-13');
+SELECT * FROM t1 WHERE b = (SELECT MIN(b) FROM t1);
+SELECT * FROM t2 WHERE b = (SELECT MIN(b) FROM t2);
+SELECT * FROM t3 WHERE b = (SELECT MIN(b) FROM t3);
+
+CREATE TABLE `t8` (
+ `pseudo` varchar(35) character set latin1 NOT NULL default '',
+ `email` varchar(60) character set latin1 NOT NULL default '',
+ PRIMARY KEY (`pseudo`),
+ UNIQUE KEY `email` (`email`)
+) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC;
+
+INSERT INTO t8 (pseudo,email) VALUES ('joce','test');
+INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1');
+INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1');
+EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
+-- error 1240
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM
+t8 WHERE pseudo='joce');
+-- error 1240
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE
+pseudo='joce');
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce');
+-- error 1241
+SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo LIKE '%joce%');
+
+drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
+
+#searchconthardwarefr3 forumconthardwarefr7
+CREATE TABLE `t1` (
+ `topic` mediumint(8) unsigned NOT NULL default '0',
+ `date` date NOT NULL default '0000-00-00',
+ `pseudo` varchar(35) character set latin1 NOT NULL default '',
+ PRIMARY KEY (`pseudo`,`date`,`topic`),
+ KEY `topic` (`topic`)
+) TYPE=MyISAM ROW_FORMAT=DYNAMIC;
+INSERT INTO t1 (topic,date,pseudo) VALUES
+('43506','2002-10-02','joce'),('40143','2002-08-03','joce');
+EXPLAIN EXTENDED SELECT DISTINCT date FROM t1 WHERE date='2002-08-03';
+EXPLAIN EXTENDED SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03');
+SELECT DISTINCT date FROM t1 WHERE date='2002-08-03';
+SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03');
+SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1) UNION ALL SELECT 1;
+-- error 1241
+SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1) UNION SELECT 1;
+EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1);
+drop table t1;
+
+#forumconthardwarefr7 searchconthardwarefr7
+CREATE TABLE `t1` (
+ `numeropost` mediumint(8) unsigned NOT NULL auto_increment,
+ `maxnumrep` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`numeropost`),
+ UNIQUE KEY `maxnumrep` (`maxnumrep`)
+) TYPE=MyISAM ROW_FORMAT=FIXED;
+
+INSERT INTO t1 (numeropost,maxnumrep) VALUES (40143,1),(43506,2);
+
+CREATE TABLE `t2` (
+ `mot` varchar(30) NOT NULL default '',
+ `topic` mediumint(8) unsigned NOT NULL default '0',
+ `date` date NOT NULL default '0000-00-00',
+ `pseudo` varchar(35) NOT NULL default '',
+ PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`)
+ ) TYPE=MyISAM ROW_FORMAT=DYNAMIC;
+
+INSERT INTO t2 (mot,topic,date,pseudo) VALUES ('joce','40143','2002-10-22','joce'), ('joce','43506','2002-10-22','joce');
+select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
+SELECT numeropost,maxnumrep FROM t1 WHERE exists (SELECT 1 FROM t2 WHERE (mot='joce') AND date >= '2002-10-21' AND t1.numeropost = t2.topic) ORDER BY maxnumrep DESC LIMIT 0, 20;
+-- error 1054
+SELECT (SELECT 1) as a FROM (SELECT 1 FROM t1 HAVING a=1) b;
+-- error 1054
+SELECT 1 IN (SELECT 1 FROM t2 HAVING a);
+
+SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic);
+SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100);
+SELECT * from t2 where topic IN (SELECT SUM(topic) FROM t1);
+SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic);
+SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100);
+SELECT * from t2 where topic = any (SELECT SUM(topic) FROM t1);
+SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic);
+SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100);
+SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) from t2;
+SELECT * from t2 where topic = all (SELECT SUM(topic) FROM t2);
+SELECT * from t2 where topic <> any (SELECT SUM(topic) FROM t2);
+SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000);
+SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000);
+SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000);
+SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) from t2;
+drop table t1,t2;
+
+#forumconthardwarefr7
+CREATE TABLE `t1` (
+ `numeropost` mediumint(8) unsigned NOT NULL auto_increment,
+ `maxnumrep` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`numeropost`),
+ UNIQUE KEY `maxnumrep` (`maxnumrep`)
+) TYPE=MyISAM ROW_FORMAT=FIXED;
+
+INSERT INTO t1 (numeropost,maxnumrep) VALUES (1,0),(2,1);
+-- error 1241
+select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1);
+-- error 1241
+select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1);
+drop table t1;
+
+create table t1 (a int);
+insert into t1 values (1),(2),(3);
+(select * from t1) union (select * from t1) order by (select a from t1 limit 1);
+drop table t1;
+
+#iftest
+CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b');
+INSERT INTO t1 VALUES ();
+-- error 1241
+SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) a HAVING field='b');
+drop table t1;
+
+# threadhardwarefr7
+CREATE TABLE `t1` (
+ `numeropost` mediumint(8) unsigned NOT NULL default '0',
+ `numreponse` int(10) unsigned NOT NULL auto_increment,
+ `pseudo` varchar(35) NOT NULL default '',
+ PRIMARY KEY (`numeropost`,`numreponse`),
+ UNIQUE KEY `numreponse` (`numreponse`),
+ KEY `pseudo` (`pseudo`,`numeropost`)
+) TYPE=MyISAM;
+-- error 1246
+SELECT (SELECT numeropost FROM t1 HAVING numreponse=a),numreponse FROM (SELECT * FROM t1) as a;
+-- error 1054
+SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=a) FROM (SELECT * FROM t1) as a;
+SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT * FROM t1) as a;
+INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test');
+-- error 1241
+EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1');
+EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1';
+EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1');
+drop table t1;
+
+CREATE TABLE t1 (a int(1));
+INSERT INTO t1 VALUES (1);
+SELECT 1 FROM (SELECT a FROM t1) b HAVING (SELECT b.a)=1;
+drop table t1;
+
+#update with subselects
+create table t1 (a int NOT NULL, b int, primary key (a));
+create table t2 (a int NOT NULL, b int, primary key (a));
+insert into t1 values (0, 10),(1, 11),(2, 12);
+insert into t2 values (1, 21),(2, 22),(3, 23);
+select * from t1;
+-- error 1093
+update t1 set b= (select b from t1);
+-- error 1241
+update t1 set b= (select b from t2);
+update t1 set b= (select b from t2 where t1.a = t2.a);
+select * from t1;
+drop table t1, t2;
+
+#delete with subselects
+create table t1 (a int NOT NULL, b int, primary key (a));
+create table t2 (a int NOT NULL, b int, primary key (a));
+insert into t1 values (0, 10),(1, 11),(2, 12);
+insert into t2 values (1, 21),(2, 12),(3, 23);
+select * from t1;
+select * from t1 where b = (select b from t2 where t1.a = t2.a);
+-- error 1093
+delete from t1 where b = (select b from t1);
+-- error 1241
+delete from t1 where b = (select b from t2);
+delete from t1 where b = (select b from t2 where t1.a = t2.a);
+select * from t1;
+drop table t1, t2;
+
+#multi-delete with subselects
+
+create table t11 (a int NOT NULL, b int, primary key (a));
+create table t12 (a int NOT NULL, b int, primary key (a));
+create table t2 (a int NOT NULL, b int, primary key (a));
+insert into t11 values (0, 10),(1, 11),(2, 12);
+insert into t12 values (33, 10),(22, 11),(2, 12);
+insert into t2 values (1, 21),(2, 12),(3, 23);
+select * from t11;
+select * from t12;
+-- error 1093
+delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a);
+-- error 1241
+delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2);
+delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a);
+select * from t11;
+select * from t12;
+drop table t11, t12, t2;
+
+#insert with subselects
+CREATE TABLE t1 (x int);
+create table t2 (a int);
+create table t3 (b int);
+insert into t2 values (1);
+insert into t3 values (1),(2);
+-- error 1093
+INSERT INTO t1 (x) VALUES ((SELECT x FROM t1));
+-- error 1241
+INSERT INTO t1 (x) VALUES ((SELECT b FROM t3));
+INSERT INTO t1 (x) VALUES ((SELECT a FROM t2));
+select * from t1;
+insert into t2 values (1);
+INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
+-- sleep 1
+select * from t1;
+INSERT INTO t1 (x) select (SELECT SUM(a)+1 FROM t2) FROM t2;
+select * from t1;
+INSERT INTO t1 (x) select (SELECT SUM(x)+2 FROM t1) FROM t2;
+-- error 1054
+INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(x) FROM t2));
+INSERT DELAYED INTO t1 (x) VALUES ((SELECT SUM(a) FROM t2));
+-- sleep 1
+select * from t1;
+#
+#TODO: should be uncommented after bug 380 fix pushed
+#INSERT INTO t1 (x) SELECT (SELECT SUM(a)+b FROM t2) from t3;
+#select * from t1;
+drop table t1, t2, t3;
+
+#replace with subselects
+CREATE TABLE t1 (x int not null, y int, primary key (x));
+create table t2 (a int);
+create table t3 (a int);
+insert into t2 values (1);
+insert into t3 values (1),(2);
+select * from t1;
+-- error 1093
+replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2));
+-- error 1241
+replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2));
+replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2));
+select * from t1;
+replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+2 FROM t2));
+select * from t1;
+replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a FROM t2));
+-- sleep 1
+select * from t1;
+replace DELAYED into t1 (x, y) VALUES ((SELECT a+3 FROM t2), (SELECT a+1 FROM t2));
+-- sleep 1
+select * from t1;
+replace LOW_PRIORITY into t1 (x, y) VALUES ((SELECT a+1 FROM t2), (SELECT a FROM t2));
+select * from t1;
+drop table t1, t2, t3;
+
+-- error 1096
+SELECT * FROM (SELECT 1) b WHERE 1 IN (SELECT *);
+
+CREATE TABLE t2 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t2 VALUES (1),(2);
+SELECT * FROM t2 WHERE id IN (SELECT 1);
+EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1);
+SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3);
+SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1));
+EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1));
+EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3);
+SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3);
+SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
+-- error 1093
+INSERT INTO t2 VALUES ((SELECT * FROM t2));
+-- error 1093
+INSERT INTO t2 VALUES ((SELECT id FROM t2));
+SELECT * FROM t2;
+CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 values (1),(1);
+-- error 1241
+UPDATE t2 SET id=(SELECT * FROM t1);
+drop table t2, t1;
+
+#NULL test
+create table t1 (a int);
+insert into t1 values (1),(2),(3);
+select 1 IN (SELECT * from t1);
+select 10 IN (SELECT * from t1);
+select NULL IN (SELECT * from t1);
+update t1 set a=NULL where a=2;
+select 1 IN (SELECT * from t1);
+select 3 IN (SELECT * from t1);
+select 10 IN (SELECT * from t1);
+select 1 > ALL (SELECT * from t1);
+select 10 > ALL (SELECT * from t1);
+select 1 > ANY (SELECT * from t1);
+select 10 > ANY (SELECT * from t1);
+drop table t1;
+create table t1 (a varchar(20));
+insert into t1 values ('A'),('BC'),('DEF');
+select 'A' IN (SELECT * from t1);
+select 'XYZS' IN (SELECT * from t1);
+select NULL IN (SELECT * from t1);
+update t1 set a=NULL where a='BC';
+select 'A' IN (SELECT * from t1);
+select 'DEF' IN (SELECT * from t1);
+select 'XYZS' IN (SELECT * from t1);
+select 'A' > ALL (SELECT * from t1);
+select 'XYZS' > ALL (SELECT * from t1);
+select 'A' > ANY (SELECT * from t1);
+select 'XYZS' > ANY (SELECT * from t1);
+drop table t1;
+create table t1 (a float);
+insert into t1 values (1.5),(2.5),(3.5);
+select 1.5 IN (SELECT * from t1);
+select 10.5 IN (SELECT * from t1);
+select NULL IN (SELECT * from t1);
+update t1 set a=NULL where a=2.5;
+select 1.5 IN (SELECT * from t1);
+select 3.5 IN (SELECT * from t1);
+select 10.5 IN (SELECT * from t1);
+select 1.5 > ALL (SELECT * from t1);
+select 10.5 > ALL (SELECT * from t1);
+select 1.5 > ANY (SELECT * from t1);
+select 10.5 > ANY (SELECT * from t1);
+explain extended select (select a+1) from t1;
+select (select a+1) from t1;
+drop table t1;
+
+#
+# Null with keys
+#
+
+CREATE TABLE t1 (a int(11) NOT NULL default '0', PRIMARY KEY (a));
+CREATE TABLE t2 (a int(11) default '0', INDEX (a));
+INSERT INTO t1 VALUES (1),(2),(3),(4);
+INSERT INTO t2 VALUES (1),(2),(3);
+SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
+explain extended SELECT t1.a, t1.a in (select t2.a from t2) FROM t1;
+CREATE TABLE t3 (a int(11) default '0');
+INSERT INTO t3 VALUES (1),(2),(3);
+SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1;
+explain extended SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1;
+drop table t1,t2,t3;
+
+#LIMIT is not supported now
+create table t1 (a float);
+-- error 1235
+select 10.5 IN (SELECT * from t1 LIMIT 1);
+-- error 1235
+select 10.5 IN (SELECT * from t1 LIMIT 1 UNION SELECT 1.5);
+drop table t1;
+
+create table t1 (a int, b int, c varchar(10));
+create table t2 (a int);
+insert into t1 values (1,2,'a'),(2,3,'b'),(3,4,'c');
+insert into t2 values (1),(2),(NULL);
+select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,2,'a'),(select c from t1 where a=t2.a) from t2;
+select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,3,'b'),(select c from t1 where a=t2.a) from t2;
+select a, (select a,b,c from t1 where t1.a=t2.a) = ROW(a,4,'c'),(select c from t1 where a=t2.a) from t2;
+drop table t1,t2;
+
+create table t1 (a int, b real, c varchar(10));
+insert into t1 values (1, 1, 'a'), (2,2,'b'), (NULL, 2, 'b');
+select ROW(1, 1, 'a') IN (select a,b,c from t1);
+select ROW(1, 2, 'a') IN (select a,b,c from t1);
+select ROW(1, 1, 'a') IN (select b,a,c from t1);
+select ROW(1, 1, 'a') IN (select a,b,c from t1 where a is not null);
+select ROW(1, 2, 'a') IN (select a,b,c from t1 where a is not null);
+select ROW(1, 1, 'a') IN (select b,a,c from t1 where a is not null);
+select ROW(1, 1, 'a') IN (select a,b,c from t1 where c='b' or c='a');
+select ROW(1, 2, 'a') IN (select a,b,c from t1 where c='b' or c='a');
+select ROW(1, 1, 'a') IN (select b,a,c from t1 where c='b' or c='a');
+-- error 1235
+select ROW(1, 1, 'a') IN (select b,a,c from t1 limit 2);
+drop table t1;
+
+create table t1 (a int);
+insert into t1 values (1);
+do @a:=(SELECT a from t1);
+select @a;
+set @a:=2;
+set @a:=(SELECT a from t1);
+select @a;
+drop table t1;
+-- error 1146
+do (SELECT a from t1);
+-- error 1146
+set @a:=(SELECT a from t1);
+
+CREATE TABLE t1 (a int, KEY(a));
+HANDLER t1 OPEN;
+-- error 1149
+HANDLER t1 READ a=((SELECT 1));
+HANDLER t1 CLOSE;
+drop table t1;
+
+create table t1 (a int);
+create table t2 (b int);
+insert into t1 values (1),(2);
+insert into t2 values (1);
+select a from t1 where a in (select a from t1 where a in (select b from t2));
+drop table t1, t2;
+
+create table t1 (a int, b int);
+create table t2 like t1;
+insert into t1 values (1,2),(1,3),(1,4),(1,5);
+insert into t2 values (1,2),(1,3);
+select * from t1 where row(a,b) in (select a,b from t2);
+drop table t1, t2;
+
+CREATE TABLE `t1` (`i` int(11) NOT NULL default '0',PRIMARY KEY (`i`)) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES (1);
+-- error 1111
+UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i));
+drop table t1;
+
+#test of uncacheable subqueries
+CREATE TABLE t1 (a int(1));
+EXPLAIN EXTENDED SELECT (SELECT RAND() FROM t1) FROM t1;
+EXPLAIN EXTENDED SELECT (SELECT ENCRYPT('test') FROM t1) FROM t1;
+EXPLAIN EXTENDED SELECT (SELECT BENCHMARK(1,1) FROM t1) FROM t1;
+drop table t1;
+
+
+CREATE TABLE `t1` (
+ `mot` varchar(30) character set latin1 NOT NULL default '',
+ `topic` mediumint(8) unsigned NOT NULL default '0',
+ `date` date NOT NULL default '0000-00-00',
+ `pseudo` varchar(35) character set latin1 NOT NULL default '',
+ PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`),
+ KEY `pseudo` (`pseudo`,`date`,`topic`),
+ KEY `topic` (`topic`)
+) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC;
+
+CREATE TABLE `t2` (
+ `mot` varchar(30) character set latin1 NOT NULL default '',
+ `topic` mediumint(8) unsigned NOT NULL default '0',
+ `date` date NOT NULL default '0000-00-00',
+ `pseudo` varchar(35) character set latin1 NOT NULL default '',
+ PRIMARY KEY (`mot`,`pseudo`,`date`,`topic`),
+ KEY `pseudo` (`pseudo`,`date`,`topic`),
+ KEY `topic` (`topic`)
+) TYPE=MyISAM CHARSET=latin1 ROW_FORMAT=DYNAMIC;
+
+CREATE TABLE `t3` (
+ `numeropost` mediumint(8) unsigned NOT NULL auto_increment,
+ `maxnumrep` int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`numeropost`),
+ UNIQUE KEY `maxnumrep` (`maxnumrep`)
+) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES ('joce','1','','joce'),('test','2','','test');
+
+INSERT INTO t2 VALUES ('joce','1','','joce'),('test','2','','test');
+
+INSERT INTO t3 VALUES (1,1);
+
+SELECT DISTINCT topic FROM t2 WHERE NOT EXISTS(SELECT * FROM t3 WHERE
+numeropost=topic);
+select * from t1;
+DELETE FROM t1 WHERE topic IN (SELECT DISTINCT topic FROM t2 WHERE NOT
+EXISTS(SELECT * FROM t3 WHERE numeropost=topic));
+select * from t1;
+
+drop table t1, t2, t3;
+
+SELECT * FROM (SELECT 1 as a,(SELECT a)) a;
+CREATE TABLE t1 SELECT * FROM (SELECT 1 as a,(SELECT 1)) a;
+SHOW CREATE TABLE t1;
+drop table t1;
+CREATE TABLE t1 SELECT * FROM (SELECT 1 as a,(SELECT a)) a;
+SHOW CREATE TABLE t1;
+drop table t1;
+CREATE TABLE t1 SELECT * FROM (SELECT 1 as a,(SELECT a+0)) a;
+SHOW CREATE TABLE t1;
+drop table t1;
+CREATE TABLE t1 SELECT (SELECT 1 as a UNION SELECT 1+1 limit 1,1) as a;
+select * from t1;
+SHOW CREATE TABLE t1;
+drop table t1;
+
+create table t1 (a int);
+insert into t1 values (1), (2), (3);
+explain extended select a,(select (select rand() from t1 limit 1) from t1 limit 1)
+from t1;
+drop table t1;
+
+#
+# error in IN
+#
+-- error 1146
+select t1.Continent, t2.Name, t2.Population from t1 LEFT JOIN t2 ON t1.Code = t2.Country where t2.Population IN (select max(t2.Population) AS Population from t2, t1 where t2.Country = t1.Code group by Continent);
+
+#
+# complex subquery
+#
+
+CREATE TABLE t1 (
+ ID int(11) NOT NULL auto_increment,
+ name char(35) NOT NULL default '',
+ t2 char(3) NOT NULL default '',
+ District char(20) NOT NULL default '',
+ Population int(11) NOT NULL default '0',
+ PRIMARY KEY (ID)
+) TYPE=MyISAM;
+
+INSERT INTO t1 VALUES (130,'Sydney','AUS','New South Wales',3276207);
+INSERT INTO t1 VALUES (131,'Melbourne','AUS','Victoria',2865329);
+INSERT INTO t1 VALUES (132,'Brisbane','AUS','Queensland',1291117);
+
+CREATE TABLE t2 (
+ Code char(3) NOT NULL default '',
+ Name char(52) NOT NULL default '',
+ Continent enum('Asia','Europe','North America','Africa','Oceania','Antarctica','South America') NOT NULL default 'Asia',
+ Region char(26) NOT NULL default '',
+ SurfaceArea float(10,2) NOT NULL default '0.00',
+ IndepYear smallint(6) default NULL,
+ Population int(11) NOT NULL default '0',
+ LifeExpectancy float(3,1) default NULL,
+ GNP float(10,2) default NULL,
+ GNPOld float(10,2) default NULL,
+ LocalName char(45) NOT NULL default '',
+ GovernmentForm char(45) NOT NULL default '',
+ HeadOfState char(60) default NULL,
+ Capital int(11) default NULL,
+ Code2 char(2) NOT NULL default '',
+ PRIMARY KEY (Code)
+) TYPE=MyISAM;
+
+INSERT INTO t2 VALUES ('AUS','Australia','Oceania','Australia and New Zealand',7741220.00,1901,18886000,79.8,351182.00,392911.00,'Australia','Constitutional Monarchy, Federation','Elisabeth II',135,'AU');
+INSERT INTO t2 VALUES ('AZE','Azerbaijan','Asia','Middle East',86600.00,1991,7734000,62.9,4127.00,4100.00,'Azärbaycan','Federal Republic','Heydär Äliyev',144,'AZ');
+
+select t2.Continent, t1.Name, t1.Population from t2 LEFT JOIN t1 ON t2.Code = t1.t2 where t1.Population IN (select max(t1.Population) AS Population from t1, t2 where t1.t2 = t2.Code group by Continent);
+
+drop table t1, t2;
+
+#
+# constants in IN
+#
+CREATE TABLE `t1` (
+ `id` mediumint(8) unsigned NOT NULL auto_increment,
+ `pseudo` varchar(35) character set latin1 NOT NULL default '',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `pseudo` (`pseudo`),
+) TYPE=MyISAM PACK_KEYS=1 ROW_FORMAT=DYNAMIC;
+INSERT INTO t1 (pseudo) VALUES ('test');
+SELECT 0 IN (SELECT 1 FROM t1 a);
+EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
+INSERT INTO t1 (pseudo) VALUES ('test1');
+SELECT 0 IN (SELECT 1 FROM t1 a);
+EXPLAIN EXTENDED SELECT 0 IN (SELECT 1 FROM t1 a);
+drop table t1;
+
+CREATE TABLE `t1` (
+ `i` int(11) NOT NULL default '0',
+ PRIMARY KEY (`i`)
+) TYPE=MyISAM CHARSET=latin1;
+
+INSERT INTO t1 VALUES (1);
+-- error 1111
+UPDATE t1 SET i=i+(SELECT MAX(i) FROM (SELECT 1) t) WHERE i=(SELECT MAX(i));
+-- error 1111
+UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i));
+-- error 1109
+UPDATE t1 SET t.i=i+(SELECT MAX(i) FROM (SELECT 1) t);
+drop table t1;
+
+#
+# Multi update test
+#
+CREATE TABLE t1 (
+ id int(11) default NULL
+) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES (1),(1),(2),(2),(1),(3);
+CREATE TABLE t2 (
+ id int(11) default NULL,
+ name varchar(15) default NULL
+) TYPE=MyISAM CHARSET=latin1;
+
+INSERT INTO t2 VALUES (4,'vita'), (1,'vita'), (2,'vita'), (1,'vita');
+update t1, t2 set t2.name='lenka' where t2.id in (select id from t1);
+select * from t2;
+drop table t1,t2;
+
+#
+# correct NULL in <CONSTANT> IN (SELECT ...)
+#
+create table t1 (a int, unique index indexa (a));
+insert into t1 values (-1), (-4), (-2), (NULL);
+select -10 IN (select a from t1 FORCE INDEX (indexa));
+drop table t1;
+
+#
+# Test optimization for sub selects
+#
+create table t1 (id int not null auto_increment primary key, salary int, key(salary));
+insert into t1 (salary) values (100),(1000),(10000),(10),(500),(5000),(50000);
+explain extended SELECT id FROM t1 where salary = (SELECT MAX(salary) FROM t1);
+drop table t1;
+
+CREATE TABLE t1 (
+ ID int(10) unsigned NOT NULL auto_increment,
+ SUB_ID int(3) unsigned NOT NULL default '0',
+ REF_ID int(10) unsigned default NULL,
+ REF_SUB int(3) unsigned default '0',
+ PRIMARY KEY (ID,SUB_ID),
+ UNIQUE KEY t1_PK (ID,SUB_ID),
+ KEY t1_FK (REF_ID,REF_SUB),
+ KEY t1_REFID (REF_ID)
+) TYPE=MyISAM CHARSET=cp1251;
+INSERT INTO t1 VALUES (1,0,NULL,NULL),(2,0,NULL,NULL);
+SELECT DISTINCT REF_ID FROM t1 WHERE ID= (SELECT DISTINCT REF_ID FROM t1 WHERE ID=2);
+DROP TABLE t1;
+
+#
+# uninterruptable update
+#
+create table t1 (a int, b int);
+create table t2 (a int, b int);
+
+insert into t1 values (1,0), (2,0), (3,0);
+insert into t2 values (1,1), (2,1), (3,1), (2,2);
+
+update ignore t1 set b=(select b from t2 where t1.a=t2.a);
+select * from t1;
+
+drop table t1, t2;
+
+#
+# correct behavoiur for function from reduced subselect
+#
+create table t1(City VARCHAR(30),Location geometry);
+insert into t1 values("Paris",GeomFromText('POINT(2.33 48.87)'));
+select City from t1 where (select intersects(GeomFromText(AsText(Location)),GeomFromText('Polygon((2 50, 2.5 50, 2.5 47, 2 47, 2 50))'))=0);
+drop table t1;
+
+#
+# reduced subselect in ORDER BY & GROUP BY clauses
+#
+
+CREATE TABLE `t1` (
+ `id` mediumint(8) unsigned NOT NULL auto_increment,
+ `pseudo` varchar(35) NOT NULL default '',
+ `email` varchar(60) NOT NULL default '',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `email` (`email`),
+ UNIQUE KEY `pseudo` (`pseudo`),
+) TYPE=MyISAM CHARSET=latin1 PACK_KEYS=1 ROW_FORMAT=DYNAMIC;
+INSERT INTO t1 (id,pseudo,email) VALUES (1,'test','test'),(2,'test1','test1');
+SELECT pseudo as a, pseudo as b FROM t1 GROUP BY (SELECT a) ORDER BY (SELECT id*1);
+drop table if exists t1;
+
+(SELECT 1 as a) UNION (SELECT 1) ORDER BY (SELECT a+0);
+
+#
+# IN subselect optimization test
+#
+create table t1 (a int not null, b int, primary key (a));
+create table t2 (a int not null, primary key (a));
+create table t3 (a int not null, b int, primary key (a));
+insert into t1 values (1,10), (2,20), (3,30), (4,40);
+insert into t2 values (2), (3), (4), (5);
+insert into t3 values (10,3), (20,4), (30,5);
+select * from t2 where t2.a in (select a from t1);
+explain extended select * from t2 where t2.a in (select a from t1);
+select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
+explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
+drop table t1, t2, t3;
+create table t1 (a int, b int, index a (a,b));
+create table t2 (a int, index a (a));
+create table t3 (a int, b int, index a (a));
+insert into t1 values (1,10), (2,20), (3,30), (4,40);
+disable_query_log;
+# making table large enough
+let $1 = 10000;
+while ($1)
+ {
+ eval insert into t1 values (rand()*100000+200,rand()*100000);
+ dec $1;
+ }
+enable_query_log;
+insert into t2 values (2), (3), (4), (5);
+insert into t3 values (10,3), (20,4), (30,5);
+select * from t2 where t2.a in (select a from t1);
+explain extended select * from t2 where t2.a in (select a from t1);
+select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
+explain extended select * from t2 where t2.a in (select t1.a from t1,t3 where t1.b=t3.a);
+insert into t1 values (3,31);
+select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+select * from t2 where t2.a in (select a from t1 where t1.b <> 30 and t1.b <> 31);
+explain extended select * from t2 where t2.a in (select a from t1 where t1.b <> 30);
+drop table t1, t2, t3;
+
+#
+# alloc_group_fields() working
+#
+create table t1 (a int, b int);
+create table t2 (a int, b int);
+create table t3 (a int, b int);
+insert into t1 values (0,100),(1,2), (1,3), (2,2), (2,7), (2,-1), (3,10);
+insert into t2 values (0,0), (1,1), (2,1), (3,1), (4,1);
+insert into t3 values (3,3), (2,2), (1,1);
+select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) from t3;
+drop table t1,t2,t3;
+
+#
+# aggregate functions in HAVING test
+#
+create table t1 (s1 int);
+create table t2 (s1 int);
+insert into t1 values (1);
+insert into t2 values (1);
+select * from t1 where exists (select s1 from t2 having max(t2.s1)=t1.s1);
+drop table t1,t2;
+
+#
+# update subquery with wrong field (to force name resolving
+# in UPDATE name space)
+#
+create table t1 (s1 int);
+create table t2 (s1 int);
+insert into t1 values (1);
+insert into t2 values (1);
+-- error 1054
+update t1 set s1 = s1 + 1 where 1 = (select x.s1 as A from t2 WHERE t2.s1 > t1.s1 order by A);
+DROP TABLE t1, t2;
+
+#
+# collation test
+#
+CREATE TABLE t1 (s1 CHAR(5) COLLATE latin1_german1_ci,
+ s2 CHAR(5) COLLATE latin1_swedish_ci);
+INSERT INTO t1 VALUES ('z','?');
+-- error 1266
+select * from t1 where s1 > (select max(s2) from t1);
+-- error 1266
+select * from t1 where s1 > any (select max(s2) from t1);
+drop table t1;
+
+#
+# aggregate functions reinitialization
+#
+create table t1(toid int,rd int);
+create table t2(userid int,pmnew int,pmtotal int);
+insert into t2 values(1,0,0),(2,0,0);
+insert into t1 values(1,0),(1,0),(1,0),(1,12),(1,15),(1,123),(1,12312),(1,12312),(1,123),(2,0),(2,0),(2,1),(2,2);
+select userid,pmtotal,pmnew, (select count(rd) from t1 where toid=t2.userid) calc_total, (select count(rd) from t1 where rd=0 and toid=t2.userid) calc_new from t2 where userid in (select distinct toid from t1);
+drop table t1, t2;
+
+#
+# row union
+#
+create table t1 (s1 char(5));
+-- error 1240
+select (select 'a','b' from t1 union select 'a','b' from t1) from t1;
+insert into t1 values ('tttt');
+select * from t1 where ('a','b')=(select 'a','b' from t1 union select 'a','b' from t1);
+explain extended (select * from t1);
+(select * from t1);
+drop table t1;
+
+#
+# IN optimisation test results
+#
+create table t1 (s1 char(5), index s1(s1));
+create table t2 (s1 char(5), index s1(s1));
+insert into t1 values ('a1'),('a2'),('a3');
+insert into t2 values ('a1'),('a2');
+select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
+select s1, s1 = ANY (SELECT s1 FROM t2) from t1;
+select s1, s1 <> ALL (SELECT s1 FROM t2) from t1;
+select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
+explain extended select s1, s1 NOT IN (SELECT s1 FROM t2) from t1;
+explain extended select s1, s1 = ANY (SELECT s1 FROM t2) from t1;
+explain extended select s1, s1 <> ALL (SELECT s1 FROM t2) from t1;
+explain extended select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1;
+drop table t1,t2;
+
+#
+# correct ALL optimisation
+#
+create table t2 (a int, b int);
+create table t3 (a int);
+insert into t3 values (6),(7),(3);
+select * from t3 where a >= all (select b from t2);
+explain extended select * from t3 where a >= all (select b from t2);
+
+#
+# optimized static ALL/ANY with grouping
+#
+insert into t2 values (2,2), (2,1), (3,3), (3,1);
+select * from t3 where a > all (select max(b) from t2 group by a);
+explain extended select * from t3 where a > all (select max(b) from t2 group by a);
+drop table t2, t3;
+
+#
+# correct used_tables()
+#
+
+CREATE TABLE `t1` ( `id` mediumint(9) NOT NULL auto_increment, `taskid` bigint(20) NOT NULL default '0', `dbid` int(11) NOT NULL default '0', `create_date` datetime NOT NULL default '0000-00-00 00:00:00', `last_update` datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (`id`)) TYPE=MyISAM CHARSET=latin1 AUTO_INCREMENT=3 ;
+INSERT INTO `t1` (`id`, `taskid`, `dbid`, `create_date`,`last_update`) VALUES (1, 1, 15, '2003-09-29 10:31:36', '2003-09-29 10:31:36'), (2, 1, 21, now(), now());
+CREATE TABLE `t2` (`db_id` int(11) NOT NULL auto_increment,`name` varchar(200) NOT NULL default '',`primary_uid` smallint(6) NOT NULL default '0',`secondary_uid` smallint(6) NOT NULL default '0',PRIMARY KEY (`db_id`),UNIQUE KEY `name_2` (`name`),FULLTEXT KEY `name` (`name`)) TYPE=MyISAM CHARSET=latin1 AUTO_INCREMENT=2147483647;
+INSERT INTO `t2` (`db_id`, `name`, `primary_uid`, `secondary_uid`) VALUES (18, 'Not Set 1', 0, 0),(19, 'Valid', 1, 2),(20, 'Valid 2', 1, 2),(21, 'Should Not Return', 1, 2),(26, 'Not Set 2', 0, 0),(-1, 'ALL DB\'S', 0, 0);
+CREATE TABLE `t3` (`taskgenid` mediumint(9) NOT NULL auto_increment,`dbid` int(11) NOT NULL default '0',`taskid` int(11) NOT NULL default '0',`mon` tinyint(4) NOT NULL default '1',`tues` tinyint(4) NOT NULL default '1',`wed` tinyint(4) NOT NULL default '1',`thur` tinyint(4) NOT NULL default '1',`fri` tinyint(4) NOT NULL default '1',`sat` tinyint(4) NOT NULL default '0',`sun` tinyint(4) NOT NULL default '0',`how_often` smallint(6) NOT NULL default '1',`userid` smallint(6) NOT NULL default '0',`active` tinyint(4) NOT NULL default '1',PRIMARY KEY (`taskgenid`)) TYPE=MyISAM CHARSET=latin1 AUTO_INCREMENT=2 ;
+INSERT INTO `t3` (`taskgenid`, `dbid`, `taskid`, `mon`, `tues`,`wed`, `thur`, `fri`, `sat`, `sun`, `how_often`, `userid`, `active`) VALUES (1,-1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1);
+CREATE TABLE `t4` (`task_id` smallint(6) NOT NULL default '0',`description` varchar(200) NOT NULL default '') TYPE=MyISAM CHARSET=latin1;
+INSERT INTO `t4` (`task_id`, `description`) VALUES (1, 'Daily Check List'),(2, 'Weekly Status');
+select dbid, name, (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') from t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND t4.task_id = taskid;
+SELECT dbid, name FROM t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND ((date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01')) AND t4.task_id = taskid;
+drop table t1,t2,t3,t4;
+
+#
+# cardinality check
+#
+CREATE TABLE t1 (id int(11) default NULL) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES (1),(5);
+CREATE TABLE t2 (id int(11) default NULL) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t2 VALUES (2),(6);
+-- error 1240
+select * from t1 where (1,2,6) in (select * from t2);
+DROP TABLE t1,t2;
+
+#
+# DO and SET with errors
+#
+create table t1 (s1 int);
+insert into t1 values (1);
+insert into t1 values (2);
+-- error 1241
+set sort_buffer_size = (select s1 from t1);
+do (select * from t1);
+drop table t1;
+
+#
+# optimized ALL/ANY with union
+#
+create table t1 (s1 char);
+insert into t1 values ('e');
+select * from t1 where 'f' > any (select s1 from t1);
+select * from t1 where 'f' > any (select s1 from t1 union select s1 from t1);
+explain select * from t1 where 'f' > any (select s1 from t1 union select s1 from t1);
+drop table t1;
+
+#
+# filesort in subquery (restoring join_tab)
+#
+CREATE TABLE t1 (number char(11) NOT NULL default '') TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t1 VALUES ('69294728265'),('18621828126'),('89356874041'),('95895001874');
+CREATE TABLE t2 (code char(5) NOT NULL default '',UNIQUE KEY code (code)) TYPE=MyISAM CHARSET=latin1;
+INSERT INTO t2 VALUES ('1'),('1226'),('1245'),('1862'),('18623'),('1874'),('1967'),('6');
+select c.number as phone,(select p.code from t2 p where c.number like concat(p.code, '%') order by length(p.code) desc limit 1) as code from t1 c;
+drop table t1, t2;
+
+#
+# unresolved field error
+#
+create table t1 (s1 int);
+create table t2 (s1 int);
+-- error 1054
+select * from t1 where (select count(*) from t2 where t1.s2) = 1;
+-- error 1054
+select * from t1 where (select count(*) from t2 group by t1.s2) = 1;
+-- error 1109
+select count(*) from t2 group by t1.s2;
+drop table t1, t2;
+
+#
+# fix_fields() in add_ref_to_table_cond()
+#
+CREATE TABLE t1(COLA FLOAT NOT NULL,COLB FLOAT NOT NULL,COLC VARCHAR(20) DEFAULT NULL,PRIMARY KEY (COLA, COLB));
+CREATE TABLE t2(COLA FLOAT NOT NULL,COLB FLOAT NOT NULL,COLC CHAR(1) NOT NULL,PRIMARY KEY (COLA));
+INSERT INTO t1 VALUES (1,1,'1A3240'), (1,2,'4W2365');
+INSERT INTO t2 VALUES (100, 200, 'C');
+SELECT DISTINCT COLC FROM t1 WHERE COLA = (SELECT COLA FROM t2 WHERE COLB = 200 AND COLC ='C' LIMIT 1);
+DROP TABLE t1, t2;
diff --git a/mysql-test/t/subselect2.test b/mysql-test/t/subselect2.test
new file mode 100644
index 00000000000..151e285e6d4
--- /dev/null
+++ b/mysql-test/t/subselect2.test
@@ -0,0 +1,149 @@
+-- source include/have_innodb.inc
+
+#
+# test of big query with a lot of IN subqueries.
+#
+
+--disable_warnings
+drop table if exists t1, t2, t3, t4;
+--enable_warnings
+
+CREATE TABLE t1
+(
+DOCID VARCHAR(32)BINARY NOT NULL
+, UUID VARCHAR(32)BINARY NOT NULL
+, MIMETYPE VARCHAR(80)BINARY
+, CONTENTDATA LONGBLOB
+, CONTENTSIZE INTEGER
+, VERSIONID INTEGER
+, REPID VARCHAR(32)BINARY
+, MODIFIED TIMESTAMP
+, MODIFIER VARCHAR(255)BINARY
+, ORIGINATOR INTEGER
+
+, PRIMARY KEY ( DOCID )
+) TYPE=InnoDB
+;
+
+CREATE TABLE t2
+(
+DOCID VARCHAR(32)BINARY NOT NULL
+, DOCNAME VARCHAR(255)BINARY NOT NULL
+, DOCTYPEID VARCHAR(32)BINARY NOT NULL
+, FOLDERID VARCHAR(32)BINARY NOT NULL
+, AUTHOR VARCHAR(255)BINARY
+, CREATED TIMESTAMP NOT NULL
+, TITLE VARCHAR(255)BINARY
+, SUBTITLE VARCHAR(255)BINARY
+, DOCABSTRACT LONGBLOB
+, PUBLISHDATE TIMESTAMP
+, EXPIRATIONDATE TIMESTAMP
+, LOCKEDBY VARCHAR(80)BINARY
+, STATUS VARCHAR(80)BINARY
+, PARENTDOCID VARCHAR(32)BINARY
+, REPID VARCHAR(32)BINARY
+, MODIFIED TIMESTAMP NOT NULL
+, MODIFIER VARCHAR(255)BINARY NOT NULL
+, PUBLISHSTATUS INTEGER
+, ORIGINATOR INTEGER
+
+, PRIMARY KEY ( DOCID )
+) TYPE=InnoDB
+;
+CREATE INDEX DDOCTYPEID_IDX ON t2 (DOCTYPEID);
+CREATE INDEX DFOLDERID_IDX ON t2 (FOLDERID);
+CREATE TABLE t3
+(
+FOLDERID VARCHAR(32)BINARY NOT NULL
+, FOLDERNAME VARCHAR(255)BINARY NOT NULL
+, CREATOR VARCHAR(255)BINARY
+, CREATED TIMESTAMP NOT NULL
+, DESCRIPTION VARCHAR(255)BINARY
+, FOLDERTYPE INTEGER NOT NULL
+, MODIFIED TIMESTAMP
+, MODIFIER VARCHAR(255)BINARY
+, FOLDERSIZE INTEGER NOT NULL
+, PARENTID VARCHAR(32)BINARY
+, REPID VARCHAR(32)BINARY
+, ORIGINATOR INTEGER
+
+, PRIMARY KEY ( FOLDERID )
+) TYPE=InnoDB;
+
+CREATE INDEX FFOLDERID_IDX ON t3 (FOLDERID);
+CREATE INDEX CMFLDRPARNT_IDX ON t3 (PARENTID);
+
+CREATE TABLE t4
+(
+DOCTYPEID VARCHAR(32)BINARY NOT NULL
+, DOCTYPENAME VARCHAR(80)BINARY NOT NULL
+, DESCRIPTION VARCHAR(255)BINARY
+, EXTNDATA LONGBLOB
+, MODIFIED TIMESTAMP
+, MODIFIER VARCHAR(255)BINARY
+, ORIGINATOR INTEGER
+
+, PRIMARY KEY ( DOCTYPEID )
+) TYPE=InnoDB;
+
+INSERT INTO t2 VALUES("c373e9f59cf15a6c3e57444553544200", "c373e9f59cf15a6c3e57444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-06 07:48:42", NULL, NULL, NULL, "2003-06-06 07:48:42", "2003-06-06 07:48:42", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-06 07:48:42", "admin", "0", NULL);
+
+INSERT INTO t2 VALUES("c373e9f5a472f43ba45e444553544200", "c373e9f5a472f43ba45e444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-07 18:50:12", NULL, NULL, NULL, "2003-06-07 18:50:12", "2003-06-07 18:50:12", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-07 18:50:12", "admin", "0", NULL);
+
+
+INSERT INTO t2 VALUES("c373e9f5a4a0f56014eb444553544200", "c373e9f5a4a0f56014eb444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-07 19:39:26", NULL, NULL, NULL, "2003-06-07 19:39:26", "2003-06-07 19:39:26", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-07 19:39:26", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5a4a0f8fa4a86444553544200", "c373e9f5a4a0f8fa4a86444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-07 19:43:05", NULL, NULL, NULL, "2003-06-07 19:43:05", "2003-06-07 19:43:05", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-07 19:43:05", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5ac7b537205ce444553544200", "c373e9f5ac7b537205ce444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-09 08:15:24", NULL, NULL, NULL, "2003-06-09 08:15:24", "2003-06-09 08:15:24", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-09 08:15:24", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5ad0792012454444553544200", "c373e9f5ad0792012454444553544200", "340d243d45f111d497b00010a4ef934d", "2f6161e879db43c1a5b82c21ddc49089", NULL, "2003-06-09 10:51:44", NULL, NULL, NULL, "2003-06-09 10:51:44", "2003-06-09 10:51:44", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-09 10:51:44", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5ad079821ef34444553544200", "First Discussion", "c373e9f5ad079174ff17444553544200", "c373e9f5ad0796c0eca4444553544200", "Goldilocks", "2003-06-09 11:16:50", "Title: First Discussion", NULL, NULL, "2003-06-09 10:51:26", "2003-06-09 10:51:26", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-09 11:16:50", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5ad07993f3859444553544200", "Last Discussion", "c373e9f5ad079174ff17444553544200", "c373e9f5ad0796c0eca4444553544200", "Goldilocks", "2003-06-09 11:21:06", "Title: Last Discussion", NULL, "Setting new abstract and keeping doc checked out", "2003-06-09 10:51:26", "2003-06-09 10:51:26", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-09 11:21:06", "admin", "0", NULL);
+INSERT INTO t2 VALUES("c373e9f5ad079a3219c4444553544200", "testdoclayout", "340d243c45f111d497b00010a4ef934d", "c373e9f5ad0796c0eca4444553544200", "Goldilocks", "2003-06-09 11:25:31", "Title: Test doc layout", "Subtitle: test doc layout", NULL, "2003-06-09 10:51:27", "2003-06-09 10:51:27", NULL, NULL, NULL, "03eea05112b845949f3fd03278b5fe43", "2003-06-09 11:25:31", "admin", "0", NULL);
+
+
+
+INSERT INTO t3 VALUES("0c9aab05b15048c59bc35c8461507deb", "System", "System", "2003-06-05 16:30:00", "The system content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "9c9aab05b15048c59bc35c8461507deb", "1");
+INSERT INTO t3 VALUES("2f6161e879db43c1a5b82c21ddc49089", "Default", "System", "2003-06-09 10:52:02", "The default content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "03eea05112b845949f3fd03278b5fe43", "1");
+INSERT INTO t3 VALUES("c373e9f5ad0791724315444553544200", "AddDocumentTest", "admin", "2003-06-09 10:51:25", "Movie Reviews", "0", "2003-06-09 10:51:25", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad07919e1963444553544200", "NewDestDirectory", "admin", "2003-06-09 10:51:28", "Adding new directory", "128", "2003-06-09 10:51:28", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad07919fe525444553544200", "SubDestDirectory", "admin", "2003-06-09 10:51:28", "Adding new directory", "128", "2003-06-09 10:51:28", "admin", "0", "c373e9f5ad07919e1963444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a0dab5444553544200", "Level1", "admin", "2003-06-09 10:51:29", NULL, "0", "2003-06-09 10:51:29", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a14669444553544200", "Level2", "admin", "2003-06-09 10:51:29", NULL, "0", "2003-06-09 10:51:29", "admin", "0", "c373e9f5ad0791a0dab5444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a23c0e444553544200", "Level3", "admin", "2003-06-09 10:51:29", NULL, "0", "2003-06-09 10:51:29", "admin", "0", "c373e9f5ad0791a14669444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a6b11f444553544200", "Dir1", "admin", "2003-06-09 10:51:30", NULL, "0", "2003-06-09 10:51:30", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a897d6444553544200", "Dir2", "admin", "2003-06-09 10:51:30", NULL, "0", "2003-06-09 10:51:30", "admin", "0", "c373e9f5ad0791a6b11f444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791a9a063444553544200", "NewDestDirectory", "admin", "2003-06-09 10:51:31", NULL, "0", "2003-06-09 10:51:31", "admin", "0", "c373e9f5ad0791a897d6444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791aa73e3444553544200", "LevelA", "admin", "2003-06-09 10:51:31", NULL, "0", "2003-06-09 10:51:31", "admin", "0", "c373e9f5ad0791a0dab5444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791ab034b444553544200", "LevelB", "admin", "2003-06-09 10:51:31", NULL, "0", "2003-06-09 10:51:31", "admin", "0", "c373e9f5ad0791aa73e3444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791ac7311444553544200", "LevelC", "admin", "2003-06-09 10:51:32", NULL, "0", "2003-06-09 10:51:32", "admin", "0", "c373e9f5ad0791ab034b444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791ad66cf444553544200", "test2", "admin", "2003-06-09 10:51:32", NULL, "0", "2003-06-09 10:51:32", "admin", "0", "c373e9f5ad0791724315444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791aebd87444553544200", "test3", "admin", "2003-06-09 10:51:33", NULL, "0", "2003-06-09 10:51:33", "admin", "0", "c373e9f5ad0791ad66cf444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0791dbaac4444553544200", "Special Café Folder", "admin", "2003-06-09 10:51:43", "test folder names with special chars", "0", "2003-06-09 10:51:43", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0796bf913f444553544200", "CopiedFolder", "admin", "2003-06-09 11:09:05", "Movie Reviews", "0", "2003-06-09 11:09:05", "admin", "0", "c373e9f5ad0791a23c0e444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0796c0eca4444553544200", "Movie Reviews", "admin", "2003-06-09 11:09:13", "Movie Reviews", "0", "2003-06-09 11:09:13", "admin", "33", "c373e9f5ad0796bf913f444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad0796d9b895444553544200", "NewBookFolder", "admin", "2003-06-09 11:12:41", "NewBooks - folder", "0", "2003-06-09 11:12:41", "admin", "0", "c373e9f5ad0796c0eca4444553544200", "03eea05112b845949f3fd03278b5fe43", NULL);
+INSERT INTO t3 VALUES("c373e9f5ad079b4c9355444553544200", "CopiedFolder", "admin", "2003-06-09 11:26:34", "Movie Reviews", "0", "2003-06-09 11:26:34", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+
+
+INSERT INTO t4 VALUES("340d243c45f111d497b00010a4ef934d", "Document Layout", "The system Document Layouts Document Type", NULL, "2003-06-05 16:30:00", "System", "1");
+INSERT INTO t4 VALUES("340d243d45f111d497b00010a4ef934d", "Default", "The default system Document Type", NULL, "2003-06-05 16:30:00", "System", "1");
+INSERT INTO t4 VALUES("4d09dd60850711d4998a204c4f4f5020", "__SystemResourceType", "The type for all the uploaded resources", NULL, "2003-06-05 16:30:00", "System", "1");
+INSERT INTO t4 VALUES("91d4d595478211d497b40010a4ef934d", "__PmcSystemDefaultType", "The type for all the default available fields", NULL, "2003-06-05 16:30:00", "System", "1");
+INSERT INTO t4 VALUES("c373e9f59cf15a59b08a444553544200", "NoFieldDocType", "plain doc type", NULL, "2003-06-06 07:48:40", "admin", NULL);
+INSERT INTO t4 VALUES("c373e9f59cf15a5c6a99444553544200", "Movie Review", "This doc type is for movie reviews", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<props autocheckin=\"false\" autopublish=\"false\" binary=\"choice\" categories=\"none\" cleanup=\"false\" folder=\"none\"><![CDATA[Doc type for cm tests]]></props>\r\n", "2003-06-06 07:48:40", "admin", NULL);
+INSERT INTO t4 VALUES("c373e9f59cf15a6116a5444553544200", "Special DocÃu20A4u20A4u0113ééøÉu016BType", "test special chars xxxé in doc type", NULL, "2003-06-06 07:48:41", "admin", NULL);
+INSERT INTO t4 VALUES("c373e9f59cf15a695d47444553544200", "Movie", NULL, NULL, "2003-06-06 07:48:41", "admin", NULL);
+INSERT INTO t4 VALUES("c373e9f5ad079174ff17444553544200", "Discussion", NULL, NULL, "2003-06-09 10:51:25", "admin", NULL);
+INSERT INTO t4 VALUES("c373e9f5ad0791da7e2b444553544200", "Books", "list of recommended books", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<props autocheckin=\"false\" autopublish=\"false\" binary=\"choice\" categories=\"none\" cleanup=\"false\" folder=\"none\"><![CDATA[Doc type for cm tests]]><![CDATA[Doc type for book tests]]></props>\r\n", "2003-06-09 10:51:40", "admin", NULL);
+
+ALTER TABLE t2 ADD FOREIGN KEY FK_DCMNTS_DCTYPES ( DOCTYPEID)
+ REFERENCES t4 (DOCTYPEID );
+ALTER TABLE t2 ADD FOREIGN KEY FK_DCMNTS_FLDRS ( FOLDERID)
+ REFERENCES t3 (FOLDERID );
+ALTER TABLE t3 ADD FOREIGN KEY FK_FLDRS_PRNTID ( PARENTID)
+ REFERENCES t3 (FOLDERID );
+
+SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3.FOLDERNAME = 'Level1') AND t3.FOLDERNAME = 'Level2') AND t3.FOLDERNAME = 'Level3') AND t3.FOLDERNAME = 'CopiedFolder') AND t3.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion';
+
+EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3.FOLDERNAME = 'Level1') AND t3.FOLDERNAME = 'Level2') AND t3.FOLDERNAME = 'Level3') AND t3.FOLDERNAME = 'CopiedFolder') AND t3.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion';
+
+drop table t1, t2, t3, t4; \ No newline at end of file
diff --git a/mysql-test/t/subselect_innodb.test b/mysql-test/t/subselect_innodb.test
new file mode 100644
index 00000000000..5e274ecbd5c
--- /dev/null
+++ b/mysql-test/t/subselect_innodb.test
@@ -0,0 +1,70 @@
+-- source include/have_innodb.inc
+
+--disable_warnings
+drop table if exists t1,t2,t3;
+--enable_warnings
+
+#
+# key field overflow test
+#
+CREATE TABLE t1
+(
+FOLDERID VARCHAR(32)BINARY NOT NULL
+, FOLDERNAME VARCHAR(255)BINARY NOT NULL
+, CREATOR VARCHAR(255)BINARY
+, CREATED TIMESTAMP NOT NULL
+, DESCRIPTION VARCHAR(255)BINARY
+, FOLDERTYPE INTEGER NOT NULL
+, MODIFIED TIMESTAMP
+, MODIFIER VARCHAR(255)BINARY
+, FOLDERSIZE INTEGER NOT NULL
+, PARENTID VARCHAR(32)BINARY
+, REPID VARCHAR(32)BINARY
+, ORIGINATOR INTEGER
+
+, PRIMARY KEY ( FOLDERID )
+) TYPE=InnoDB;
+CREATE INDEX FFOLDERID_IDX ON t1 (FOLDERID);
+CREATE INDEX CMFLDRPARNT_IDX ON t1 (PARENTID);
+INSERT INTO t1 VALUES("0c9aab05b15048c59bc35c8461507deb", "System", "System", "2003-06-05 16:30:00", "The system content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "9c9aab05b15048c59bc35c8461507deb", "1");
+INSERT INTO t1 VALUES("2f6161e879db43c1a5b82c21ddc49089", "Default", "System", "2003-06-09 10:52:02", "The default content repository folder.", "3", "2003-06-05 16:30:00", "System", "0", NULL, "03eea05112b845949f3fd03278b5fe43", "1");
+INSERT INTO t1 VALUES("c373e9f5ad0791724315444553544200", "AddDocumentTest", "admin", "2003-06-09 10:51:25", "Movie Reviews", "0", "2003-06-09 10:51:25", "admin", "0", "2f6161e879db43c1a5b82c21ddc49089", "03eea05112b845949f3fd03278b5fe43", NULL);
+SELECT 'c373e9f5ad0791a0dab5444553544200' IN(SELECT t1.FOLDERID FROM t1 WHERE t1.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t1.FOLDERNAME = 'Level1');
+drop table t1;
+
+#
+# UNION unlocking test
+#
+create table t1 (a int) type=innodb;
+create table t2 (a int) type=innodb;
+create table t3 (a int) type=innodb;
+insert into t1 values (1),(2),(3),(4);
+insert into t2 values (10),(20),(30),(40);
+insert into t3 values (1),(2),(10),(50);
+select a from t3 where t3.a in (select a from t1 where a <= 3 union select * from t2 where a <= 30);
+drop table t1,t2,t3;
+
+
+CREATE TABLE t1 (
+ processor_id INTEGER NOT NULL,
+ PRIMARY KEY (processor_id)
+) TYPE=InnoDB;
+CREATE TABLE t3 (
+ yod_id BIGINT UNSIGNED AUTO_INCREMENT NOT NULL,
+ login_processor INTEGER UNSIGNED ,
+ PRIMARY KEY (yod_id)
+) TYPE=InnoDB;
+CREATE TABLE t2 (
+ processor_id INTEGER NOT NULL,
+ yod_id BIGINT UNSIGNED NOT NULL,
+ PRIMARY KEY (processor_id, yod_id),
+ INDEX (processor_id),
+ INDEX (yod_id),
+ FOREIGN KEY (processor_id) REFERENCES t1(processor_id),
+ FOREIGN KEY (yod_id) REFERENCES t3(yod_id)
+) TYPE=InnoDB;
+INSERT INTO t1 VALUES (1),(2),(3);
+INSERT INTO t3 VALUES (1,1),(2,2),(3,3);
+INSERT INTO t2 VALUES (1,1),(2,2),(3,3);
+SELECT distinct p1.processor_id, (SELECT y.yod_id FROM t1 p2, t2 y WHERE p2.processor_id = p1.processor_id and p2.processor_id = y.processor_id) FROM t1 p1;
+drop table t1,t2,t3; \ No newline at end of file
diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test
index 5e1fe313a7e..f618c342936 100644
--- a/mysql-test/t/symlink.test
+++ b/mysql-test/t/symlink.test
@@ -3,12 +3,15 @@ disable_query_log;
show variables like "have_symlink";
enable_query_log;
+--disable_warnings
drop table if exists t1,t2,t7,t8,t9;
drop database if exists mysqltest;
+--enable_warnings
#
# First create little data to play with
#
+
create table t1 (a int not null auto_increment, b char(16) not null, primary key (a));
create table t2 (a int not null auto_increment, b char(16) not null, primary key (a));
insert into t1 (b) values ("test"),("test1"),("test2"),("test3");
diff --git a/mysql-test/t/tablelock.test b/mysql-test/t/tablelock.test
index fa8c4f03675..fbc5d685096 100644
--- a/mysql-test/t/tablelock.test
+++ b/mysql-test/t/tablelock.test
@@ -2,7 +2,10 @@
# Test of lock tables
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
create table t1 ( n int auto_increment primary key);
lock tables t1 write;
insert into t1 values(NULL);
diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test
index 665e690a322..03b6fa35bfa 100644
--- a/mysql-test/t/temp_table.test
+++ b/mysql-test/t/temp_table.test
@@ -2,7 +2,10 @@
# Test of temporary tables
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
CREATE TABLE t1 (c int not null, d char (10) not null);
insert into t1 values(1,""),(2,"a"),(3,"b");
CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
@@ -34,7 +37,6 @@ drop table t1;
# Test CONCAT_WS with temporary tables
#
-drop table if exists t1;
CREATE TABLE t1 (pkCrash INTEGER PRIMARY KEY,strCrash VARCHAR(255));
INSERT INTO t1 ( pkCrash, strCrash ) VALUES ( 1, '1');
SELECT CONCAT_WS(pkCrash, strCrash) FROM t1;
@@ -74,8 +76,6 @@ drop table t1;
# In MySQL 4.0.4 doing a GROUP BY on a NULL column created a disk based
# temporary table when a memory based one would be good enough.
-drop table if exists t1;
-
CREATE TABLE t1 (
d datetime default NULL
) TYPE=MyISAM;
diff --git a/mysql-test/t/truncate.test b/mysql-test/t/truncate.test
index eeb79f497fa..dd80baba269 100644
--- a/mysql-test/t/truncate.test
+++ b/mysql-test/t/truncate.test
@@ -1,7 +1,10 @@
#
# Test of truncate
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (a integer, b integer,c1 CHAR(10));
insert into t1 (a) values (1),(2);
truncate table t1;
diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test
index 4132b1f48a4..c9c3284fe0d 100644
--- a/mysql-test/t/type_blob.test
+++ b/mysql-test/t/type_blob.test
@@ -3,10 +3,43 @@
#
#
+# Basic cleanup
+#
+--disable_warnings
+drop table if exists t1,t2,t3,t4,t5,t6,t7;
+--enable_warnings
+
+
+#
+# Check syntax for creating BLOB/TEXT
+#
+
+CREATE TABLE t1 (a blob, b text, c blob(250), d text(70000), e text(70000000));
+show columns from t1;
+CREATE TABLE t2 (a char(257), b varchar(70000) binary, c varchar(70000000));
+show columns from t2;
+create table t3 (a long, b long byte);
+show create TABLE t3;
+drop table t1,t2,t3
+
+#
+# Check errors with blob
+#
+
+--error 1074
+CREATE TABLE t1 (a char(257) default "hello");
+--error 1101
+CREATE TABLE t2 (a blob default "hello");
+
+# Safety to be able to continue with other tests if above fails
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+#
# test of full join with blob
#
-drop table if exists t1,t2,t3,t4,t5,t6,t7;
create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr));
insert into t1 values (null,"a","A");
insert into t1 values (null,"bbb","BBB");
@@ -58,6 +91,7 @@ select b from t1 where b like "%HELLO%";
select d from t1 where d like "%HELLO%";
select c from t1 having c like "%HELLO%";
select d from t1 having d like "%HELLO%";
+select d from t1 having d like "%HE%LLO%";
select t from t1 order by t;
select c from t1 order by c;
select b from t1 order by b;
@@ -260,6 +294,17 @@ drop table t1;
create table t1 (id integer auto_increment unique,imagem LONGBLOB not null);
insert into t1 (id) values (1);
+select
+ charset(load_file('../../std_data/words.dat')),
+ collation(load_file('../../std_data/words.dat')),
+ coercibility(load_file('../../std_data/words.dat'));
+explain extended select
+ charset(load_file('../../std_data/words.dat')),
+ collation(load_file('../../std_data/words.dat')),
+ coercibility(load_file('../../std_data/words.dat'));
update t1 set imagem=load_file('../../std_data/words.dat') where id=1;
select if(imagem is null, "ERROR", "OK"),length(imagem) from t1 where id = 1;
drop table t1;
+create table t1 select load_file('../../std_data/words.dat');
+show full fields from t1;
+drop table t1;
diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test
index bd6d8c49c22..5a53c635e6e 100644
--- a/mysql-test/t/type_date.test
+++ b/mysql-test/t/type_date.test
@@ -1,6 +1,10 @@
#
# test of problem with date fields
#
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (a char(16), b date, c datetime);
insert into t1 SET a='test 2000-01-01', b='2000-01-01', c='2000-01-01';
select * from t1 where c = '2000-01-01';
@@ -11,7 +15,6 @@ drop table t1;
# problem with date conversions
#
-drop table if exists t1,t2;
CREATE TABLE t1 (name char(6),cdate date);
INSERT INTO t1 VALUES ('name1','1998-01-01');
INSERT INTO t1 VALUES ('name2','1998-01-01');
diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test
index 51b65d00243..d2611973101 100644
--- a/mysql-test/t/type_datetime.test
+++ b/mysql-test/t/type_datetime.test
@@ -2,7 +2,10 @@
# testing different DATETIME ranges
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (t datetime);
insert into t1 values(101),(691231),(700101),(991231),(10000101),(99991231),(101000000),(691231000000),(700101000000),(991231235959),(10000101000000),(99991231235959);
select * from t1;
@@ -19,7 +22,7 @@ drop table t1;
CREATE TABLE t1 (a timestamp, b date, c time, d datetime);
insert into t1 (b,c,d) values(now(),curtime(),now());
-select date_format(a,"%Y-%m-%d")=b,right(a,6)=c+0,a=d+0 from t1;
+select date_format(a,"%Y-%m-%d")=b,right(a+0,6)=c+0,a=d+0 from t1;
drop table t1;
#
diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test
index 7aedc051905..36bd8eb48e4 100644
--- a/mysql-test/t/type_decimal.test
+++ b/mysql-test/t/type_decimal.test
@@ -1,6 +1,10 @@
# bug in decimal() with negative numbers by kaido@tradenet.ee
+--disable_warnings
DROP TABLE IF EXISTS t1;
+--enable_warnings
+SET SQL_WARNINGS=1;
+
CREATE TABLE t1 (
id int(11) NOT NULL auto_increment,
datatype_id int(11) DEFAULT '0' NOT NULL,
@@ -234,9 +238,9 @@ drop table t1;
# Test of wrong decimal type
#
---error 1074
+--error 1064
CREATE TABLE t1 (a_dec DECIMAL(-1,0));
---error 1074
+--error 1064
CREATE TABLE t1 (a_dec DECIMAL(-2,1));
---error 1074
+--error 1064
CREATE TABLE t1 (a_dec DECIMAL(-1,1));
diff --git a/mysql-test/t/type_enum.test b/mysql-test/t/type_enum.test
index 8f399e4364e..49ba73acaa8 100644
--- a/mysql-test/t/type_enum.test
+++ b/mysql-test/t/type_enum.test
@@ -2,7 +2,10 @@
# Problem with many enums
#
+--disable_warnings
DROP TABLE if exists t1;
+--enable_warnings
+
CREATE TABLE t1 (
field enum('001001','001004','001010','001018','001019','001020','001021','001027','001028','001029','001030','001031','001100','002003','002004','002005','002007','002008','002009','002012','002013','002014','003002','003003','003004','003005','003006','003007','003008','003009','003010','003011','003012','003013','003014','003015','003016','003017','003018','003019','004002','004003','004005','004006','004007','004008','004010','004012','004014','004016','004017','004020','004021','004022','004023','004024','004025','004026','006002','006004','006006','006010','006011','006012','006013','006014','007001','007002','007003','007004','007005','007006','007007','007008','007009','007010','007011','007012','007013','007014','007015','007016','007017','007018','007019','007020','007021','007022','007023','007024','007025','007026','007027','007028','007029','007030','007031','007032','007033','007034','007035','007036','007037','007038','007039','007040','007043','007044','009001','009002','009004','009005','009006','009007','009008','009009','009010','009011','009012','009013','010002','010003','010004','010005','010006','010007','010008','010009','010010','010011','010012','010013','010015','010016','010017','010018','010019','010020','010021','010022','010023','010024','010025','010026','010027','010028','011001','011002','011003','011004','011006','011012','011013','011014','011015','011016','012017','012018','012019','012023','012027','012028','012029','012030','012031','012032','012033','012034','012035','012036','012037','012038','012039','014001','016002','016003','016004','016007','016010','016011','016016','016019','016020','016021','016022','016023','016024','016026','016027','016028','016029','016030','016031','016032','016033','016034','017002','018001','019002','019004','020001','020003','020004','020005','020006','020007','020008','020009','022001','022002','022003','023001','023002','023003','023004','023005','023006','023007','023008','023010','023011','023012','023017','023019','023020','023021','023025','023026','023027','023028','023029','023030','023031','023032','023033','023034','023035','025001','025003','025004','025005','025006','025007','025008','025009','025010','025011','025012','025013','025014','025015','025016','025017','025018','025019','025020','025021','025022','025023','025024','025025','025026','025027','025028','025029','025030','025031','025032','025033','025034','025035','025036','025037','025038','025039','025040','025041','025042','025043','025044','025045','025046','025047','025048','025049','025050','025051','025052','025053','025054','025055','025056','025057','025058','025059','025060','025061','025062','025063','027001','027002','027011','035008','035012','036001','037001','037003','037004','037005','037006','037007','037008','037009','038004','038005','038006','038007','038009','039001','039002','039003','039004','039005','039006','046001','046002','046003','046004','046005','046007','046008','046009','046010','046011','046012','046013','046014','047001','047002','048001','051001','051002','051003','051004','052001','052002','052005','053015','053016','053019','053020','053023','053024','053026','053028','053029','053033','053034','053036','053037','053038','053039','053041','053042','053043','053045','053046','053047','053048','053051','053052','053054','053055','053056','053057','053068','053069','053070','053073','053074','053075','053086','053094','053095','053096','053097','053098','053099','053100','053101','053102','053103','053104','053105','053107','053122','053123','053124','053125','053127','053128','054001','054002','054003','054004','054005','054006','054007','054009','054010','056001','056002','056003','056004','056005','056006','056009','056010','056011','056016','056017','056018','056019','056020','056021','056022','057001','057002','057003','057004','058002','058003','058004','058005','060001','060003','060004','060005','060006','060007','061002','061003','061004','061005','061006','069006','069007','069010','069011','069012','069013','069014','069015','069016','069017','069018','069020','069021','069022','069023','069024','071002','071003','071004','071005','071006','071008','071011','071013','071020','071021','071022','072001','073001','073002','073003','073004','074001','074002','074003','074004','074005','074006','074007','074008','074009','074010','074011','074012','075001','075007','076101','076102','076103','077001','077002','077003','077004','077006','077007','077008','077009','078005','079002','079003','079004','079005','079006','079007','081001','082006','082007','082011','082013','082014','082015','082016','082017','082021','082022','082023','082024','082025','082026','082027','082028','082029','082030','082031','082032','082033','082034','082035','082036','082037','082038','082039','082040','082041','082042','082043','082044','084001','084002','084003','084004','084005','084007','084008','084009','084011','084013','084014','084016','084017','084027','084031','084032','084033','084035','084036','084037','084038','084039','084040','084041','084042','084043','084044','084045','084046','084047','084048','084049','084050','084051','085001','085002','085003','085004','085005','085006','085007','085009','085011','085012','085013','085014','085015','085016','085017','085018','085019','085020','085021','085022','085023','085028','085029','085030','085031','085033','085034','085035','085036','085037','085038','085040','085041','085042','085043','085044','085045','085046','085047','085048','085063','085064','085065','085068','085070','085071','085073','085082','085083','085086','085088','085089','085090','085091','085092','085093','085094','085095','085096','085097','085098','085099','085100','085101','085102','085103','085104','085105','085106','085107','085108','085109','085110','085111','085112','085113','085115','085119','085120','085121','085122','085123','085124','085125','085126','085127','085128','085129','085130','085132','085133','085134','085135','085136','085137','086001','086002','086003','086004','086005','088001','088003','088005','088006','088007','088008','088009','089001','090001','090002','090003','090004','090005','090006','090007','090008','090009','090010','090013','090015','090016','090017','090018','090019','090022','090027','090028','091001','091002','091005','091008','091009','091010','091011','091012','091013','091014','091015','091016','091017','091018','093001','093003','093098','093100','093102','093104','093141','093142','093146','093151','093153','093167','093168','093176','094001','094002','094004','094005','095004','099001','099002','100001','101001','102002','102003','105001','105002','106001','113001','113002','113003','113004','113005','113006','113007','113008','113009','113010','113011','113012','113013','113014','113015','113016','113017','113018','113019','113020','113021','113022','113023','113024','113025','113026','113027','113028','114001','115001','115002','115003','115004','115005','115006','115007','115008','115009','115010','115011','115012','115013','115014','115015','115016','115017','115018','115020','115021','115022','115023','115025','115026','115027','115028','115029','115030','115031','115032','115033','115034','115035','115036','115039','115040','115041','115042','115043','115044','115045','115046','115047','115048','115049','115050','115051','115052','115053','115054','115055','115056','115057','115059','115060','115061','115062','115063','115064','115065','115066','115067','115068','115069','115070','115071','115072','115073','115075','115076','115081','115082','115085','115086','115087','115088','115095','115096','115097','115098','115099','115101','115102','115103','115104','115105','115106','115108','115109','115110','115111','115112','115113','115114','115115','115116','115117','115118','115119','115120','115121','115122','116001','116002','116003','116004','116005','116006','116007','116008','116009','116010','116011','116012','117001','117002','117003','123001','124010','124014','124015','124019','124024','124025','124026','124027','124028','124029','124030','124031','124032','124033','124035','124036','124037','124038','124039','124040','124041','124042','124043','124044','124045','124046','124047','124048','124049','124050','124051','124052','124053','124054','124055','124056','124057','124058','124059','124060','124061','124062','124063','124064','124065','126001','126002','126003','126004','126005','126006','126007','126008','126009','126010','126011','126012','130001','132001','132002','132003','133001','133008','133009','133010','133011','133012','133013','133014','133015','133016','133017','133018','133019','133020','133021','133022','133023','133024','133025','133027','133028','133029','133030','133031','134001','135001','135002','135003','135004','135005','135006','135007','135008','135009','135010','136001','137009','137010','137011','137012','137013','137014','137015','137016','137017','137018','137019','138001','138002','138003','138004','139001','139003','140001','141001','141002','141003','141006','141007','141008','141009','141011','141012','141014','141015','141016','141017','141018','141019','141020','141021','141022','141023','141024','141025','141026','141027','141028','142001','142002','142003','142004','142005','142006','142007','142008','142010','142011','142012','144001','145001','145002','145003','145004','145005','145006','145007','145008','145009','145010','145011','145012','145013','145014','145015','145016','147001','150003','150005','150009','150013','150014','150015','150016','150017','150020','150021','152001','152002','152003','152004','152005','152006','152007','154001','154002','154003','155001','155002','155003','155004','155005','155006','159001','159002','159003','159004','160001','160002','160003','161001','162001','162002','162003','162004','162007','162010','162011','162012','163001','163002','163003','163005','163010','163011','163014','163015','163016','165001','165002','165003','165004','165005','165006','165007','165008','165009','165010','165011','165012','165013','165014','165015','165016','165017','165018','165019','165020','165021','165022','165023','165024','165025','165026','165027','165028','165029','165030','165031','165032','165033','165034','165035','165036','167001','168001','168002','168003','168004','168005','168007','168008','168009','168010','168011','168012','168013','168014','169001','169002','169003','169007','169008','169009','169010','170001','171001','171002','171003','171004','171005','171006','171007','171008','171009','172001','174001','174002','174003','176001','176002','176003','177001','177002','179001','179002','179003','179004','179005','179006','179007','179008','179009','179010','179011','179012','179013','179014','179015','179016','179017','179018','179019','179020','179021','179022','179023','179024','179025','179026','179027','179028','179029','179030','179031','179032','179033','179034','179035','179036','179037','179038','179039','179040','179041','179042','179043','179044','179045','179046','179047','180001','180010','180012','180013','180014','180015','180016','180017','180018','180019','180020','180021','180022','180023','180024','180025','180026','180027','180028','180030','180031','180032','180033','180034','180035','180036','180037','180038','180039','180041','180042','180043','180044','180045','180046','180047','180048','180049','180050','180051','180052','180053','180054','180055','180056','180057','180058','180059','180060','180061','180062','180063','180064','180065','180066','180067','180068','180069','180070','180071','182001','184001','184002','184005','184006','184007','184008','184009','184010','184011','185001','185003','187001','188001','188002','188003','188004','188005','188006','188007','188008','188009','188010','188011','191001','191002','192002','194001','194002','194003','194004','194005','194006','194007','195001','195002','195003','195004','195005','195006','195007','196001','196002','197001','197002','197003','197004','197005','197006','198001','198003','198004','198005','198006','198007','198008','198009','198010','198011','198012','198013','198014','198015','198016','198017','201001','201002','201005','202001','203001','203002','203003','203017','203018','203019','204001','204002','204003','205001','208001','208002','208003','208004','208005','209001','209002','209003','210001','210002','210003','210004','210005','210006','210007','210008','210009','210010','210011','210012','210013','211017','212001','212002','212003','212004','212005','212006','212007','212008','212009','212010','212011','212012','212013','218001','218003','218004','218006','218007','218008','218009','218011','218015','218016','218017','218018','218019','218020','218021','218022','218023','218024','218025','218026','218027','218028','218029','218030','218031','218032','218033','218034','218035','218036','221001','221002','221003','221004','221005','221006','221007','221008','221009','221010','221011','221012','221013','223001','223002','223003','224001','224002','224003','224006','224007','224008','225001','225002','225003','225004','225005','225006','225007','225008','225009','225010','225011','225012','225013','226001','226002','226003','226004','226005','226006','226007','226008','226009','227001','227002','227003','227004','227005','227006','227007','227008','227009','227010','227011','227012','227013','227014','227015','227016','227017','227018','227019','227020','227021','227022','227023','227024','227025','227026','227027','227028','227029','227030','227031','227032','227033','227034','227035','227036','227037','227038','227039','227040','227041','227042','227043','227044','227045','227046','227047','227048','227049','227050','227051','227052','227053','227054','227055','227056','227057','227058','227059','227060','227061','227062','227063','227064','227065','227066','227067','227068','227069','227070','227071','227072','227073','227074','227075','227076','227077','227078','227079','227080','227081','227082','227083','227084','227085','227086','227087','227088','227089','227090','227091','227092','227093','227094','227095','227096','227097','227098','227099','227100','227101','227102','227103','227104','227105','227106','227107','227108','227109','227110','227111','227112','227113','227114','227115','227116','227117','227118','227119','227120','227122','227123','227124','227125','227126','227127','227128','227129','227130','227131','227132','227133','227134','227135','227136','227137','227138','227139','227140','227141','227142','227143','227144','227145','227146','227147','227148','227149','227150','227151','227152','228001','229001','229002','229003','229004','229005','230001','230002','232001','233001','233002','233003','233004','233005','233006','233007','233008','234001','234002','234003','234004','234005','234006','234007','234008','234009','234010','234011','234012','234013','234014','234015','234016','234017','234018','234019','234020','234021','234022','234023','234024','234025','234026','234027','234028','234029','234030','235001','235002','235003','235004','235005','236001','236002','236003','237001','238002','238003','238004','238005','238006','238007','238008','333013','333014','333015','333016','333017','333018','333019','333020','333021','333022','333023','333024','333025','333030','333031','333032','333033','333034','333035','334001','334002','334003','334004','334005','334006','334007','336004','337001','337002','337003','337004','339001','339002','343001','344001','344002','344003','344004','344005','345001','345002','345003','347001','347002','348001','348002','348003','348004','348005','349001','349002','349003','350001','353001','353002','353003','353004','355001','355002','355003','355004','355005','355006','356001','358001','359001','359002','360001','360002','360003','360004','360005','366001','366002','366003','366004','369001','373001','373002','373003','373004','373005','373006','373007','373008','373009','373010','373011','373012','373013','373014','373015','373016','373017','373018','373019','373020','373021','374001','374002','374003','374004','374005','374006','374007','374008','374009','374010','374011','374012','374013','374014','374015','374016','376001','376002','376003','376004','376005','376006','376007','376008','376009','376010','376011','376012','376013','376016','376017','376018','376019','376020','376021','379003','382001','382002','383001','384001','384002','385001','385002','386001','386002','386003','386004','386005','386006','386007','386008','386009','386010','386011','386012','386013','386014','387001','389001','389002','389003','389004','392001','393001','393002','393003','393004','395001','396001','397001','397002','399001','399002','399003','400001','400002','401001','401002','401003','402001','402002','402003','402004','402005','403001','403002','403003','504001','504002','504004','504005','504006','504007','504008','504009','504010','504011','504012','504013','504014','504017','504018','504019','504021','504022','504023','504024','504025','506001','506002','508001','508002','511001','511002','511003','511004','511005','511006','511007','511008','511009','511010','511011','511012','511013','511014','511017','511018','511020','511021','511022','511024','511028','511029','513001','513002','513003','513004','514001','515001','515002','515003','515007','515008','515009','515010','515011','515012','515013','515014','515015','518001','518002','518003','520001','520002','521001','521002','521003','521004','521005','521006','521007','521008','521009','521010','521011','521012','521013','521014','521015','521016','523001','523002','523003','523004','523005','523006','523007','524001','700001','701001','701002','701003','702001','702002','702003','702004','702005','702006','702007','702008','703001','703002','703003','704001','704002','704003','704004','705001','706001','706002','707001','707002','707003','708001','709001','709002','710001','710002','711001','711002','712001','713001','713002','714001','714002','715001','716001','718001','718002','719001','719002','991001','991002','991003','991004','991005','991006','991007','991008','992001','995001','996001','996002','996003','998001','998002','998003','998004','998005','998006','998007','999001','999002','011017','011018','034001','034002','071010','208006','239001','519001','519003','126013','184012','053071','374017','374018','374019','374020','374021','404001','405002','405001','405003','405007','405006','405005','405004','240011','240010','240009','240008','240007','240006','240005','240004','240003','240002','240001','240012','240013','240014','240015','240016','240017','357001','235006','235007','712002','355008','355007','056023','999999','046015','019005','126014','241003','241002','241001','240018','240020','240019','242001','242002','242003','242004','242005','242006','089002','406001','406002','406003','406004','406005','406006','243001','243002','243003','243004','243005','243006','243007','243008','010030','010029','407001','407006','407005','407004','407003','407002','408001','366005','133032','016035','077010','996004','025064','011019','407007','407008','407009','409001','115123','504026','039007','039009','039008','039010','039011','039012','180072','240021','240023','408002','405008','235008','525001','525002','525003','525004','410001','410002','410003','410004','410005','410006','410007','410008','410009','410010','410011','410012','410013','410014','410015','410016','344006','240031','240030','240029','240028','240027','240026','240025','240024','240034','240033','240032','410017','410018','411001','411002','411003','411004','411005','411006','411007','411008','203020','203021','203022','412001','412002','412003','412004','069025','244001','244002','244009','244008','244007','244006','244005','244004','244003','244015','244014','244013','244012','244011','244010','244016','244017','240042','240041','240040','240039','240038','240037','240036','240035','405009','405010','240043','504034','504033','504032','504031','504030','504029','504028','504027','504042','504041','504040','504039','504038','504037','504036','504035','800001','410019','410020','410021','244018','244019','244020','399004','413001','504043','198018','198019','344007','082045','010031','010032','010033','010034','010035','504044','515016','801002','801003','801004','801005','802001','801001','414001','414002','414003','141029','141030','803001','803002','803003','803004','803005','803006','803007','803008','803009','803010','803011','803012','803013','803014','803015','803016','803017','410022','410023','803018','803019','803020','415002','415001','244021','011020','011023','011022','011021','025065','165037','165038','165039','416001','416002','416003','417001','418001','504045','803022','803021','240022','419001','420001','804010','804009','804008','804007','804006','804005','804004','804003','804002','804001','804020','804019','804018','804017','804016','804015','804014','804013','804012','804011','804024','804021','804023','804022','511019','511016','511015','511032','511031','511030','511027','511026','511025','511033','511023','133034','133033','169011','344008','344009','244022','244026','244025','244030','244023','244024','244027','244028','244029','244031','082046','082047','082048','126015','126016','416004','416005','421001','421002','016037','016036','115124','115125','115126','240049','240048','240047','240046','240045','240044','244032','244033','422001','422002','422003','422004','422005','184013','239002','805001','805002','805003','805004','805005','056024','423001','344010','235009','212014','056025','056026','802002','244034','244035','244036','244037','244038','244039','515017','504046','203015','245002','245001','071023','056027','056028','056029','056030','056031','056032','424001','056034','056033','805006','805007','805008','805009','805010','422008','422007','422006','422010','422009','422011','209004','150022','150023','100002','056035','023036','185004','185005','246001','247001','247002','425001','416006','165042','165041','165040','165043','010040','010039','010038','010037','010036','422012','422013','422014','422015','426000','248001','248002','248003','248004','248005','249001','249002','249003','249004','249005','249006','250007','250001','250002','250003','250004','250005','250006','250008','250009','250010','250011','250012','250013','251001','251002','422016','422017','422018','806001','806002','116013','235010','235011','091026','091027','091028','091029','091019','091020','091021','091022','091023','091024','091025','252001','243009','249007','249008','249009','011024','011025','427001','428002','428001','169012','429001','429002','429003') DEFAULT '001001' NOT NULL,
KEY field (field)
diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test
index 23941ad2913..caccf31b32a 100644
--- a/mysql-test/t/type_float.test
+++ b/mysql-test/t/type_float.test
@@ -2,11 +2,14 @@
# -----------
# Numeric floating point.
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
SELECT 10,10.0,10.,.1e+2,100.0e-1;
SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000;
SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1;
-drop table if exists t1;
create table t1 (f1 float(24),f2 float(52));
show full columns from t1;
insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150);
@@ -28,6 +31,15 @@ select a from t1 order by a;
select min(a) from t1;
drop table t1;
+# Bug #1022: When a table contains a 'float' field,
+# and one of the functions MAX, MIN, or AVG is used on that field,
+# the system crashes.
+
+create table t1 (a float);
+insert into t1 values (1);
+select max(a),min(a),avg(a) from t1;
+drop table t1;
+
#
# FLOAT/DOUBLE/DECIMAL handling
#
@@ -44,6 +56,8 @@ drop table t1;
# Errors
-!$1063 create table t1 (f float(54)); # Should give an error
+--error 1063
+create table t1 (f float(54)); # Should give an error
+--disable_warnings
drop table if exists t1;
-
+--enable_warnings
diff --git a/mysql-test/t/type_nchar.test b/mysql-test/t/type_nchar.test
new file mode 100644
index 00000000000..e85609e3f0c
--- /dev/null
+++ b/mysql-test/t/type_nchar.test
@@ -0,0 +1,35 @@
+#
+# Test nchar/nvarchar
+#
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (c nchar(10));
+show create table t1;
+drop table t1;
+
+create table t1 (c national char(10));
+show create table t1;
+drop table t1;
+
+create table t1 (c national varchar(10));
+show create table t1;
+drop table t1;
+
+create table t1 (c nvarchar(10));
+show create table t1;
+drop table t1;
+
+create table t1 (c nchar varchar(10));
+show create table t1;
+drop table t1;
+
+create table t1 (c national character varying(10));
+show create table t1;
+drop table t1;
+
+create table t1 (c nchar varying(10));
+show create table t1;
+drop table t1;
+
diff --git a/mysql-test/t/type_ranges.test b/mysql-test/t/type_ranges.test
index 63bbe43512d..09b5867e7a8 100644
--- a/mysql-test/t/type_ranges.test
+++ b/mysql-test/t/type_ranges.test
@@ -2,7 +2,10 @@
# Test ranges for all types and some other basic tests
#
+--disable_warnings
drop table if exists t1,t2,t3;
+--enable_warnings
+SET SQL_WARNINGS=1;
CREATE TABLE t1 (
auto int(5) unsigned NOT NULL auto_increment,
@@ -53,7 +56,7 @@ DROP INDEX test ON t1;
insert into t1 values (10, 1,1,1,1,1,1,1,1,1,1,1,1,1,NULL,0,0,0,1,1,1,1,'one','one');
insert into t1 values (NULL,2,2,2,2,2,2,2,2,2,2,2,2,2,NULL,NULL,NULL,NULL,NULL,NULL,2,2,'two','two,one');
-insert into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303 101010','','','','3',3,3);
+insert into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303101010','','','','3',3,3);
insert into t1 values (0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,NULL,19970807,080706,19970403090807,-1,-1,-1,'-1',-1,-1);
insert into t1 values (0,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,NULL,0,0,0,-4294967295,-4294967295,-4294967295,'-4294967295',0,"one,two,tree");
insert into t1 values (0,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,NULL,0,0,0,4294967295,4294967295,4294967295,'4294967295',0,0);
diff --git a/mysql-test/t/type_set.test b/mysql-test/t/type_set.test
index 7f1a75e5dbd..6c0f162dc86 100644
--- a/mysql-test/t/type_set.test
+++ b/mysql-test/t/type_set.test
@@ -2,10 +2,15 @@
# Test of SET with space
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (a set (' ','a','b') not null);
show create table t1;
drop table t1;
create table t1 (a set (' ','a','b ') not null default 'b ');
show create table t1;
drop table t1;
+CREATE TABLE t1 ( user varchar(64) NOT NULL default '', path varchar(255) NOT NULL default '', privilege set('select','RESERVED30','RESERVED29','RESERVED28','RESERVED27','RESERVED26', 'RESERVED25','RESERVED24','data.delete','RESERVED22','RESERVED21', 'RESERVED20','data.insert.none','data.insert.approve', 'data.insert.delete','data.insert.move','data.insert.propose', 'data.insert.reject','RESERVED13','RESERVED12','RESERVED11','RESERVED10', 'RESERVED09','data.update','RESERVED07','RESERVED06','RESERVED05', 'RESERVED04','metadata.delete','metadata.put','RESERVED01','RESERVED00') NOT NULL default '', KEY user (user) ) TYPE=MyISAM CHARSET=utf8;
+DROP TABLE t1;
diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test
index 2496ec36915..2f342f8bf67 100644
--- a/mysql-test/t/type_time.test
+++ b/mysql-test/t/type_time.test
@@ -1,7 +1,11 @@
#
# testing of the TIME column type
#
+
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (t time);
insert into t1 values("10:22:33"),("12:34:56.78"),(10),(1234),(123456.78),(1234559.99),("1"),("1:23"),("1:23:45"), ("10.22"), ("-10 1:22:33.45"),("20 10:22:33"),("1999-02-03 20:33:34");
insert t1 values (30),(1230),("1230"),("12:30"),("12:30:35"),("1 12:30:31.32");
diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test
index eb0def74a17..cd76dbe6ab0 100644
--- a/mysql-test/t/type_timestamp.test
+++ b/mysql-test/t/type_timestamp.test
@@ -2,7 +2,10 @@
# Test timestamp
#
+--disable_warnings
drop table if exists t1,t2;
+--enable_warnings
+
CREATE TABLE t1 (a int, t timestamp);
CREATE TABLE t2 (a int, t datetime);
SET TIMESTAMP=1234;
@@ -35,7 +38,7 @@ drop table t1;
create table t1 (ix timestamp);
insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000);
-select * from t1;
+select ix+0 from t1;
drop table t1;
CREATE TABLE t1 (date date, date_time datetime, time_stamp timestamp);
diff --git a/mysql-test/t/type_uint.test b/mysql-test/t/type_uint.test
index 32bcd61ecdb..ee5f5e8123b 100644
--- a/mysql-test/t/type_uint.test
+++ b/mysql-test/t/type_uint.test
@@ -2,7 +2,11 @@
# test of unsigned int
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+SET SQL_WARNINGS=1;
+
create table t1 (this int unsigned);
insert into t1 values (1);
insert into t1 values (-1);
diff --git a/mysql-test/t/type_year.test b/mysql-test/t/type_year.test
index 8f4f23badb4..9922df447fc 100644
--- a/mysql-test/t/type_year.test
+++ b/mysql-test/t/type_year.test
@@ -1,7 +1,10 @@
#
# Test year
#
+--disable_warnings
drop table if exists t1;
+--enable_warnings
+
create table t1 (y year,y2 year(2));
insert into t1 values (0,0),(1999,1999),(2000,2000),(2001,2001),(70,70),(69,69);
select * from t1;
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index ea7bdb4ee1b..3cfdc14b0b8 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -2,7 +2,10 @@
# Test of unions
#
+--disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6;
+--enable_warnings
+
CREATE TABLE t1 (a int not null, b char (10) not null);
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
CREATE TABLE t2 (a int not null, b char (10) not null);
@@ -20,7 +23,9 @@ select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 g
(select a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 4;
(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1);
(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc;
-explain (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc;
+--error 1249
+(select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by t1.b;
+explain extended (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc;
(select sql_calc_found_rows a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 2;
select found_rows();
select sql_calc_found_rows a,b from t1 union all select a,b from t2 limit 2;
@@ -70,6 +75,19 @@ replace into t3 select a,b as c from t1 union all select a,b from t2;
drop table t1,t2,t3;
#
+# Test some unions without tables
+#
+--error 1096
+select * union select 1;
+select 1 as a,(select a union select a);
+--error 1054
+(select 1) union (select 2) order by 0;
+SELECT @a:=1 UNION SELECT @a:=@a+1;
+--error 1054
+(SELECT 1) UNION (SELECT 2) ORDER BY (SELECT a);
+(SELECT 1,3) UNION (SELECT 2,1) ORDER BY (SELECT 2);
+
+#
# Test bug reported by joc@presence-pc.com
#
@@ -88,7 +106,7 @@ SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION SELECT pseudo FROM t1 WHERE pse
SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION ALL SELECT pseudo FROM t1 WHERE pseudo1='joce';
SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION SELECT 1;
drop table t1;
-drop table if exists t1,t2;
+
create table t1 (a int);
create table t2 (a int);
insert into t1 values (1),(2),(3),(4),(5);
@@ -157,8 +175,12 @@ INSERT INTO t6 VALUES (1,'test',8);
SELECT t4.uid, t5.rl, t3.gn as g1, t4.cid, t4.gid as gg FROM t3, t6, t1, t4 left join t5 on t5.rid = t4.rid left join t2 on t2.cid = t4.cid WHERE t3.gid=t4.gid AND t6.uid = t4.uid AND t6.uc = t1.cid AND t1.cv = "dummy" AND t6.un = "test";
SELECT t4.uid, t5.rl, t3.gn as g1, t4.cid, t4.gid as gg FROM t3, t6, t1, t4 left join t5 on t5.rid = t4.rid left join t2 on t2.cid = t4.cid WHERE t3.gid=t4.gid AND t6.uid = t4.uid AND t3.must IS NOT NULL AND t6.uc = t1.cid AND t1.cv = "dummy" AND t6.un = "test";
(SELECT t4.uid, t5.rl, t3.gn as g1, t4.cid, t4.gid as gg FROM t3, t6, t1, t4 left join t5 on t5.rid = t4.rid left join t2 on t2.cid = t4.cid WHERE t3.gid=t4.gid AND t6.uid = t4.uid AND t3.must IS NOT NULL AND t6.uc = t1.cid AND t1.cv = "dummy" AND t6.un = "test") UNION (SELECT t4.uid, t5.rl, t3.gn as g1, t4.cid, t4.gid as gg FROM t3, t6, t1, t4 left join t5 on t5.rid = t4.rid left join t2 on t2.cid = t4.cid WHERE t3.gid=t4.gid AND t6.uid = t4.uid AND t6.uc = t1.cid AND t1.cv = "dummy" AND t6.un = "test");
-
drop table t1,t2,t3,t4,t5,t6;
+
+#
+# Test insert ... SELECT with UNION
+#
+
CREATE TABLE t1 (a int not null, b char (10) not null);
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
CREATE TABLE t2 (a int not null, b char (10) not null);
@@ -190,8 +212,10 @@ select found_rows();
select found_rows();
(SELECT SQL_CALC_FOUND_ROWS * FROM t1) UNION all (SELECT * FROM t2 LIMIT 1);
select found_rows();
+# This used to work in 4.0 but not anymore in 4.1
+--error 1149
(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION SELECT * FROM t2 LIMIT 1;
-select found_rows();
+#select found_rows();
# In these case found_rows() should work
SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION all SELECT * FROM t2 LIMIT 2;
@@ -224,3 +248,57 @@ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc LIMIT 1;
(SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1;
drop table t1,t2;
+
+#
+# Test for another bug with UNION and LEFT JOIN
+#
+CREATE TABLE t1 ( id int(3) unsigned default '0') TYPE=MyISAM;
+INSERT INTO t1 (id) VALUES("1");
+CREATE TABLE t2 ( id int(3) unsigned default '0', id_master int(5) default '0', text1 varchar(5) default NULL, text2 varchar(5) default NULL) TYPE=MyISAM;
+INSERT INTO t2 (id, id_master, text1, text2) VALUES("1", "1",
+"foo1", "bar1");
+INSERT INTO t2 (id, id_master, text1, text2) VALUES("2", "1",
+"foo2", "bar2");
+INSERT INTO t2 (id, id_master, text1, text2) VALUES("3", "1", NULL,
+"bar3");
+INSERT INTO t2 (id, id_master, text1, text2) VALUES("4", "1",
+"foo4", "bar4");
+SELECT 1 AS id_master, 1 AS id, NULL AS text1, 'ABCDE' AS text2 UNION SELECT id_master, t2.id, text1, text2 FROM t1 LEFT JOIN t2 ON t1.id = t2.id_master;
+SELECT 1 AS id_master, 1 AS id, 'ABCDE' AS text1, 'ABCDE' AS text2 UNION SELECT id_master, t2.id, text1, text2 FROM t1 LEFT JOIN t2 ON t1.id = t2.id_master;
+drop table if exists t1,t2;
+
+#
+# Test of bug when using the same table multiple times
+#
+create table t1 (a int not null primary key auto_increment, b int, key(b));
+create table t2 (a int not null primary key auto_increment, b int);
+insert into t1 (b) values (1),(2),(2),(3);
+insert into t2 (b) values (10),(11),(12),(13);
+
+explain extended (select * from t1 where a=1) union (select * from t2 where a=1);
+(select * from t1 where a=5) union (select * from t2 where a=1);
+(select * from t1 where a=5 and a=6) union (select * from t2 where a=1);
+(select t1.a,t1.b from t1,t2 where t1.a=5) union (select * from t2 where a=1);
+(select * from t1 where a=1) union (select t1.a,t2.a from t1,t2 where t1.a=t2.a);
+explain (select * from t1 where a=1 and b=10) union (select straight_join t1.a,t2.a from t1,t2 where t1.a=t2.a);
+explain (select * from t1 where a=1) union (select * from t1 where b=1);
+drop table t1,t2;
+create table t1 ( id int not null auto_increment, primary key (id) ,user_name text );
+create table t2 ( id int not null auto_increment, primary key (id) ,group_name text );
+create table t3 ( id int not null auto_increment, primary key (id) ,user_id int ,index user_idx (user_id) ,foreign key (user_id) references users(id) ,group_id int ,index group_idx (group_id) ,foreign key (group_id) references groups(id) );
+insert into t1 (user_name) values ('Tester');
+insert into t2 (group_name) values ('Group A');
+insert into t2 (group_name) values ('Group B');
+insert into t3 (user_id, group_id) values (1,1);
+select 1 'is_in_group', a.user_name, c.group_name, b.id from t1 a, t3 b, t2 c where a.id = b.user_id and b.group_id = c.id UNION select 0 'is_in_group', a.user_name, c.group_name, null from t1 a, t2 c;
+drop table t1, t2, t3;
+
+#
+# fix_fields problem
+#
+create table t1 (mat_id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, matintnum CHAR(6) NOT NULL, test MEDIUMINT UNSIGNED NULL);
+create table t2 (mat_id MEDIUMINT UNSIGNED NOT NULL, pla_id MEDIUMINT UNSIGNED NOT NULL);
+insert into t1 values (NULL, 'a', 1), (NULL, 'b', 2), (NULL, 'c', 3), (NULL, 'd', 4), (NULL, 'e', 5), (NULL, 'f', 6), (NULL, 'g', 7), (NULL, 'h', 8), (NULL, 'i', 9);
+insert into t2 values (1, 100), (1, 101), (1, 102), (2, 100), (2, 103), (2, 104), (3, 101), (3, 102), (3, 105);
+SELECT mp.pla_id, MIN(m1.matintnum) AS matintnum FROM t2 mp INNER JOIN t1 m1 ON mp.mat_id=m1.mat_id GROUP BY mp.pla_id union SELECT 0, 0;
+drop table t1, t2;
diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test
index a455b308158..485af981fb4 100644
--- a/mysql-test/t/update.test
+++ b/mysql-test/t/update.test
@@ -2,7 +2,10 @@
# test of updating of keys
#
-drop table if exists t1;
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
create table t1 (a int auto_increment , primary key (a));
insert into t1 values (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL);
update t1 set a=a+10 where a > 34;
@@ -90,7 +93,10 @@ select * from t1 order by a,b;
update t1 set b=100 where a=1 order by b desc limit 2;
update t1 set a=a+10+b where a=1 order by b;
select * from t1 order by a,b;
-drop table t1;
+create table t2 (a int not null, b int not null);
+insert into t2 values (1,1),(1,2),(1,3);
+update t1 set b=(select distinct 1 from (select * from t2) a);
+drop table t1,t2;
#
# Test with limit (Bug #393)
diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test
index 9cb5d5e1eb0..39742d20c7c 100644
--- a/mysql-test/t/user_var.test
+++ b/mysql-test/t/user_var.test
@@ -1,11 +1,18 @@
-error 1054;
+# Initialise
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+--error 1054
set @a := foo;
set @a := connection_id() + 3;
select @a - connection_id();
+set @b := 1;
+select @b;
+
# Check using and setting variables with SELECT DISTINCT
-drop table if exists t1,t2;
CREATE TABLE t1 ( i int not null, v int not null,index (i));
insert into t1 values (1,1),(1,3),(2,1);
create table t2 (i int not null, unique (i));
diff --git a/mysql-test/t/varbinary.test b/mysql-test/t/varbinary.test
index cc9ee99b7f9..9425bd7bd99 100644
--- a/mysql-test/t/varbinary.test
+++ b/mysql-test/t/varbinary.test
@@ -1,3 +1,8 @@
+# Initialise
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
#
# varbinary as string and number
#
@@ -10,11 +15,10 @@ select x'31',X'ffff'+0;
# Test of hex constants in WHERE:
#
-drop table if exists t1;
create table t1 (ID int(8) unsigned zerofill not null auto_increment,UNIQ bigint(21) unsigned zerofill not null,primary key (ID),unique (UNIQ) );
insert into t1 set UNIQ=0x38afba1d73e6a18a;
insert into t1 set UNIQ=123;
-explain select * from t1 where UNIQ=0x38afba1d73e6a18a;
+explain extended select * from t1 where UNIQ=0x38afba1d73e6a18a;
drop table t1;
#
diff --git a/mysql-test/t/variables-master.opt b/mysql-test/t/variables-master.opt
index 5851d32ec31..a0577107f74 100644
--- a/mysql-test/t/variables-master.opt
+++ b/mysql-test/t/variables-master.opt
@@ -1 +1 @@
-max_join_size=10
+--max_join_size=10
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 8e38160c60b..6365ad77c57 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -1,7 +1,10 @@
#
# test variables
#
-drop table if exists t1;
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
set @`test`=1,@TEST=3,@select=2,@t5=1.23456;
select @test,@`select`,@TEST,@not_used;
set @test_int=10,@test_double=1e-10,@test_string="abcdeghi",@test_string2="abcdefghij",@select=NULL;
@@ -13,6 +16,7 @@ select @test_int,@test_double,@test_string,@test_string2;
set @test_int=null,@test_double=null,@test_string=null,@test_string2=null;
select @test_int,@test_double,@test_string,@test_string2;
select @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
+explain extended select @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
select @t5;
#
@@ -49,7 +53,9 @@ select @@local.max_join_size, @@global.max_join_size;
select @@identity, length(@@version)>0;
select @@VERSION=version();
select last_insert_id(345);
+explain extended select last_insert_id(345);
select @@IDENTITY,last_insert_id(), @@identity;
+explain extended select @@IDENTITY,last_insert_id(), @@identity;
set big_tables=OFF, big_tables=ON, big_tables=0, big_tables=1, big_tables="OFF", big_tables="ON";
@@ -88,12 +94,8 @@ show variables like 'net_buffer_length';
set net_buffer_length=2000000000;
show variables like 'net_buffer_length';
-set GLOBAL character set cp1251_koi8;
-show global variables like "convert_character_set";
set character set cp1251_koi8;
-show variables like "convert_character_set";
-set global character set default, session character set default;
-show variables like "convert_character_set";
+show variables like "character_set_client";
select @@timestamp>0;
set @@rand_seed1=10000000,@@rand_seed2=1000000;
@@ -132,11 +134,9 @@ set SESSION query_cache_size=10000;
--error 1230
set GLOBAL table_type=DEFAULT;
--error 1115
-set convert_character_set=UNKNOWN_CHARACTER_SET;
---error 1115
-set character set unknown;
---error 1232
-set character set 0;
+set character_set_client=UNKNOWN_CHARACTER_SET;
+--error 1272
+set collation_connection=UNKNOWN_COLLATION;
--error 1228
set global autocommit=1;
--error 1228
@@ -163,8 +163,8 @@ set big_tables=1;
select @@autocommit, @@big_tables;
set global binlog_cache_size=100;
set bulk_insert_buffer_size=100;
-set convert_character_set=cp1251_koi8;
-set convert_character_set=default;
+set character set cp1251_koi8;
+set character set default;
set @@global.concurrent_insert=1;
set global connect_timeout=100;
select @@delay_key_write;
@@ -247,7 +247,6 @@ set log_warnings=1;
# key buffer
#
-DROP TABLE IF EXISTS t1,t2;
create table t1 (a int not null auto_increment, primary key(a));
create table t2 (a int not null auto_increment, primary key(a));
insert into t1 values(null),(null),(null);
@@ -257,6 +256,7 @@ select @@key_buffer_size;
select * from t1 where a=2;
select * from t2 where a=3;
check table t1,t2;
+select max(a) +1, max(a) +2 into @xx,@yy from t1;
drop table t1,t2;
#
@@ -266,3 +266,20 @@ drop table t1,t2;
--error 1193
select @@xxxxxxxxxx;
select 1;
+
+#
+# swap
+#
+select @@global.max_user_connections,@@local.max_join_size;
+set @svc=@@global.max_user_connections, @svj=@@local.max_join_size;
+select @@global.max_user_connections,@@local.max_join_size;
+set @@global.max_user_connections=111,@@local.max_join_size=222;
+select @@global.max_user_connections,@@local.max_join_size;
+set @@global.max_user_connections=@@local.max_join_size,@@local.max_join_size=@@global.max_user_connections;
+select @@global.max_user_connections,@@local.max_join_size;
+set @@global.max_user_connections=@svc, @@local.max_join_size=@svj;
+select @@global.max_user_connections,@@local.max_join_size;
+set @a=1, @b=2;
+set @a=@b, @b=@a;
+select @a, @b;
+
diff --git a/mysql-test/t/warnings-master.opt b/mysql-test/t/warnings-master.opt
new file mode 100644
index 00000000000..3b8baeddb14
--- /dev/null
+++ b/mysql-test/t/warnings-master.opt
@@ -0,0 +1 @@
+--skip-isam
diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test
index 5fb536def71..050449f0f5b 100644
--- a/mysql-test/t/warnings.test
+++ b/mysql-test/t/warnings.test
@@ -1,7 +1,11 @@
#
# Test some warnings
#
-drop table if exists t1;
+--disable-warnings
+drop table if exists t1, t2;
+--enable-warnings
+SET SQL_WARNINGS=1;
+
create table t1 (a int);
insert into t1 values (1);
insert into t1 values ("hej");
@@ -11,3 +15,71 @@ insert into t1 values ("hej");
insert into t1 values ("hej"),("då");
drop table t1;
set SQL_WARNINGS=0;
+
+#
+# Test other warnings
+#
+
+drop temporary table if exists not_exists;
+drop table if exists not_exists_table;
+show warnings limit 1;
+drop database if exists not_exists_db;
+show count(*) warnings;
+create table t1(id int);
+create table if not exists t1(id int);
+select @@warning_count;
+drop table t1;
+
+#
+# Test warnings for LOAD DATA INFILE
+#
+
+create table t1(a tinyint, b int not null, c date, d char(5));
+load data infile '../../std_data/warnings_loaddata.dat' into table t1 fields terminated by ',';
+select @@warning_count;
+drop table t1;
+
+#
+# Warnings from basic INSERT, UPDATE and ALTER commands
+#
+
+create table t1(a tinyint NOT NULL, b tinyint unsigned, c char(5));
+insert into t1 values(NULL,100,'mysql'),(10,-1,'mysql ab'),(500,256,'open source'),(20,NULL,'test');
+alter table t1 modify c char(4);
+alter table t1 add d char(2);
+update t1 set a=NULL where a=10;
+update t1 set c='mysql ab' where c='test';
+update t1 set d=c;
+create table t2(a tinyint NOT NULL, b char(3));
+insert into t2 select b,c from t1;
+insert into t2(b) values('mysqlab');
+set sql_warnings=1;
+insert into t2(b) values('mysqlab');
+set sql_warnings=0;
+drop table t1, t2;
+
+#
+# Test for max_error_count
+#
+
+create table t1(a char(10));
+let $1=50;
+disable_query_log;
+while ($1)
+{
+ eval insert into t1 values('mysql ab');
+ dec $1;
+}
+enable_query_log;
+alter table t1 add b char;
+set max_error_count=10;
+update t1 set b=a;
+select @@warning_count;
+
+#
+# Test for handler type
+#
+drop table t1;
+create table t1 (id int) type=isam;
+alter table t1 type=isam;
+drop table t1;