summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/Makefile.am8
-rw-r--r--mysql-test/include/have_case_sensitive_file_system.inc4
-rw-r--r--mysql-test/include/im_check_env.inc25
-rw-r--r--mysql-test/include/im_check_os.inc7
-rw-r--r--mysql-test/include/loaddata_autocom.inc21
-rw-r--r--mysql-test/include/strict_autoinc.inc28
-rw-r--r--mysql-test/lib/mtr_cases.pl58
-rw-r--r--mysql-test/lib/mtr_io.pl38
-rw-r--r--mysql-test/lib/mtr_misc.pl18
-rw-r--r--mysql-test/lib/mtr_process.pl839
-rwxr-xr-xmysql-test/mysql-test-run.pl311
-rw-r--r--mysql-test/r/analyse.result24
-rw-r--r--mysql-test/r/auto_increment.result4
-rw-r--r--mysql-test/r/bigint.result2
-rw-r--r--mysql-test/r/case_sensitive_file_system.require2
-rw-r--r--mysql-test/r/cast.result11
-rw-r--r--mysql-test/r/client_xml.result2
-rw-r--r--mysql-test/r/compare.result7
-rw-r--r--mysql-test/r/create.result10
-rw-r--r--mysql-test/r/csv.result10
-rw-r--r--mysql-test/r/ctype_cp1250_ch.result8
-rw-r--r--mysql-test/r/ctype_gbk.result10
-rw-r--r--mysql-test/r/ctype_recoding.result11
-rw-r--r--mysql-test/r/ctype_ucs.result40
-rw-r--r--mysql-test/r/ctype_utf8.result90
-rw-r--r--mysql-test/r/date_formats.result10
-rw-r--r--mysql-test/r/delete.result14
-rw-r--r--mysql-test/r/derived.result2
-rw-r--r--mysql-test/r/distinct.result11
-rw-r--r--mysql-test/r/drop.result13
-rw-r--r--mysql-test/r/federated.result82
-rw-r--r--mysql-test/r/fulltext_distinct.result2
-rw-r--r--mysql-test/r/fulltext_update.result2
-rw-r--r--mysql-test/r/func_compress.result28
-rw-r--r--mysql-test/r/func_gconcat.result17
-rw-r--r--mysql-test/r/func_group.result41
-rw-r--r--mysql-test/r/func_misc.result5
-rw-r--r--mysql-test/r/func_str.result78
-rw-r--r--mysql-test/r/func_time.result137
-rw-r--r--mysql-test/r/gis-rtree.result6
-rw-r--r--mysql-test/r/gis.result11
-rw-r--r--mysql-test/r/grant.result106
-rw-r--r--mysql-test/r/grant2.result10
-rw-r--r--mysql-test/r/group_by.result34
-rw-r--r--mysql-test/r/group_min_max.result43
-rw-r--r--mysql-test/r/have_perror.require2
-rw-r--r--mysql-test/r/heap_btree.result36
-rw-r--r--mysql-test/r/heap_hash.result2
-rw-r--r--mysql-test/r/im_daemon_life_cycle.result4
-rw-r--r--mysql-test/r/im_life_cycle.result12
-rw-r--r--mysql-test/r/im_options_set.result6
-rw-r--r--mysql-test/r/im_options_unset.result6
-rw-r--r--mysql-test/r/im_utils.result4
-rw-r--r--mysql-test/r/index_merge.result31
-rw-r--r--mysql-test/r/information_schema.result72
-rw-r--r--mysql-test/r/information_schema_db.result47
-rw-r--r--mysql-test/r/innodb.result4
-rw-r--r--mysql-test/r/innodb_mysql.result77
-rw-r--r--mysql-test/r/insert.result2
-rw-r--r--mysql-test/r/insert_select.result114
-rw-r--r--mysql-test/r/insert_update.result26
-rw-r--r--mysql-test/r/join_outer.result25
-rw-r--r--mysql-test/r/key.result4
-rw-r--r--mysql-test/r/limit.result14
-rw-r--r--mysql-test/r/loaddata_autocom_innodb.result21
-rw-r--r--mysql-test/r/loaddata_autocom_ndb.result23
-rw-r--r--mysql-test/r/lowercase_fs_off.result11
-rw-r--r--mysql-test/r/merge.result12
-rw-r--r--mysql-test/r/myisam.result28
-rw-r--r--mysql-test/r/mysql.result57
-rw-r--r--mysql-test/r/mysqlcheck.result7
-rw-r--r--mysql-test/r/mysqldump-max.result12
-rw-r--r--mysql-test/r/mysqldump.result809
-rw-r--r--mysql-test/r/mysqlshow.result49
-rw-r--r--mysql-test/r/mysqltest.result6
-rw-r--r--mysql-test/r/ndb_basic.result1
-rw-r--r--mysql-test/r/ndb_condition_pushdown.result4
-rw-r--r--mysql-test/r/ndb_lock.result15
-rw-r--r--mysql-test/r/null.result18
-rw-r--r--mysql-test/r/null_key.result2
-rw-r--r--mysql-test/r/odbc.result11
-rw-r--r--mysql-test/r/olap.result6
-rw-r--r--mysql-test/r/openssl_1.result9
-rw-r--r--mysql-test/r/order_by.result39
-rw-r--r--mysql-test/r/perror.result1
-rw-r--r--mysql-test/r/ps.result291
-rw-r--r--mysql-test/r/ps_1general.result2
-rw-r--r--mysql-test/r/ps_2myisam.result6
-rw-r--r--mysql-test/r/ps_3innodb.result6
-rw-r--r--mysql-test/r/ps_4heap.result6
-rw-r--r--mysql-test/r/ps_5merge.result12
-rw-r--r--mysql-test/r/ps_6bdb.result6
-rw-r--r--mysql-test/r/ps_7ndb.result6
-rw-r--r--mysql-test/r/query_cache.result6
-rw-r--r--mysql-test/r/range.result111
-rw-r--r--mysql-test/r/repair.result11
-rw-r--r--mysql-test/r/row.result125
-rw-r--r--mysql-test/r/rpl_insert_id.result40
-rw-r--r--mysql-test/r/rpl_max_relay_size.result246
-rw-r--r--mysql-test/r/rpl_ndb_innodb_trans.result103
-rw-r--r--mysql-test/r/rpl_sp.result44
-rw-r--r--mysql-test/r/rpl_trigger.result47
-rw-r--r--mysql-test/r/rpl_view.result53
-rw-r--r--mysql-test/r/select.result126
-rw-r--r--mysql-test/r/show_check.result4
-rw-r--r--mysql-test/r/sp-code.result11
-rw-r--r--mysql-test/r/sp-error.result52
-rw-r--r--mysql-test/r/sp-security.result52
-rw-r--r--mysql-test/r/sp.result406
-rw-r--r--mysql-test/r/sp.result.orig4853
-rw-r--r--mysql-test/r/strict.result38
-rw-r--r--mysql-test/r/strict_autoinc_1myisam.result27
-rw-r--r--mysql-test/r/strict_autoinc_2innodb.result27
-rw-r--r--mysql-test/r/strict_autoinc_3heap.result27
-rw-r--r--mysql-test/r/strict_autoinc_4bdb.result27
-rw-r--r--mysql-test/r/strict_autoinc_5ndb.result27
-rw-r--r--mysql-test/r/subselect.result234
-rw-r--r--mysql-test/r/subselect2.result12
-rw-r--r--mysql-test/r/trigger.result86
-rw-r--r--mysql-test/r/type_bit.result30
-rw-r--r--mysql-test/r/type_blob.result20
-rw-r--r--mysql-test/r/type_date.result10
-rw-r--r--mysql-test/r/type_datetime.result15
-rw-r--r--mysql-test/r/type_newdecimal.result6
-rw-r--r--mysql-test/r/type_ranges.result13
-rw-r--r--mysql-test/r/type_timestamp.result33
-rw-r--r--mysql-test/r/type_varchar.result31
-rw-r--r--mysql-test/r/udf.result12
-rw-r--r--mysql-test/r/union.result38
-rw-r--r--mysql-test/r/user_var.result45
-rw-r--r--mysql-test/r/variables.result6
-rw-r--r--mysql-test/r/view.result242
-rw-r--r--mysql-test/r/view_grant.result6
-rw-r--r--mysql-test/r/warnings.result15
-rw-r--r--mysql-test/std_data/14897.frmbin0 -> 8608 bytes
-rw-r--r--mysql-test/t/case.test3
-rw-r--r--mysql-test/t/cast.test14
-rw-r--r--mysql-test/t/compare.test9
-rw-r--r--mysql-test/t/create.test6
-rw-r--r--mysql-test/t/csv.test24
-rw-r--r--mysql-test/t/ctype_cp1250_ch.test10
-rw-r--r--mysql-test/t/ctype_gbk.test10
-rw-r--r--mysql-test/t/ctype_recoding.test14
-rw-r--r--mysql-test/t/ctype_ucs.test48
-rw-r--r--mysql-test/t/ctype_utf8.test80
-rw-r--r--mysql-test/t/date_formats.test8
-rw-r--r--mysql-test/t/delete.test21
-rw-r--r--mysql-test/t/derived.test2
-rw-r--r--mysql-test/t/distinct.test11
-rw-r--r--mysql-test/t/drop.test41
-rw-r--r--mysql-test/t/federated.test119
-rw-r--r--mysql-test/t/func_compress.test14
-rw-r--r--mysql-test/t/func_gconcat.test14
-rw-r--r--mysql-test/t/func_group.test40
-rw-r--r--mysql-test/t/func_misc.test12
-rw-r--r--mysql-test/t/func_str.test59
-rw-r--r--mysql-test/t/func_test.test5
-rw-r--r--mysql-test/t/func_time.test101
-rw-r--r--mysql-test/t/gis.test8
-rw-r--r--mysql-test/t/grant.test183
-rw-r--r--mysql-test/t/grant2.test18
-rw-r--r--mysql-test/t/group_by.test35
-rw-r--r--mysql-test/t/group_min_max.test48
-rw-r--r--mysql-test/t/handler.test1
-rw-r--r--mysql-test/t/heap_btree.test22
-rw-r--r--mysql-test/t/im_daemon_life_cycle.imtest17
-rw-r--r--mysql-test/t/im_life_cycle.imtest67
-rw-r--r--mysql-test/t/im_options_set.imtest28
-rw-r--r--mysql-test/t/im_options_unset.imtest28
-rw-r--r--mysql-test/t/im_utils.imtest32
-rw-r--r--mysql-test/t/index_merge.test32
-rw-r--r--mysql-test/t/information_schema.test43
-rw-r--r--mysql-test/t/information_schema_db.test57
-rw-r--r--mysql-test/t/innodb.test2
-rw-r--r--mysql-test/t/innodb_mysql.test79
-rw-r--r--mysql-test/t/insert_select.test156
-rw-r--r--mysql-test/t/insert_update.test23
-rw-r--r--mysql-test/t/join_outer.test21
-rw-r--r--mysql-test/t/limit.test10
-rw-r--r--mysql-test/t/loaddata_autocom_innodb.test4
-rw-r--r--mysql-test/t/loaddata_autocom_ndb.test4
-rw-r--r--mysql-test/t/lowercase_fs_off.test27
-rw-r--r--mysql-test/t/merge.test17
-rw-r--r--mysql-test/t/myisam.test36
-rw-r--r--mysql-test/t/mysql.test82
-rw-r--r--mysql-test/t/mysql_client_test.test4
-rw-r--r--mysql-test/t/mysqlbinlog.test10
-rw-r--r--mysql-test/t/mysqlcheck.test14
-rw-r--r--mysql-test/t/mysqldump.test619
-rw-r--r--mysql-test/t/mysqlshow.test9
-rw-r--r--mysql-test/t/mysqltest.test15
-rw-r--r--mysql-test/t/ndb_basic.test10
-rw-r--r--mysql-test/t/ndb_lock.test15
-rw-r--r--mysql-test/t/odbc.test10
-rw-r--r--mysql-test/t/openssl_1.test10
-rw-r--r--mysql-test/t/order_by.test32
-rw-r--r--mysql-test/t/perror.test19
-rw-r--r--mysql-test/t/ps.test348
-rw-r--r--mysql-test/t/ps_1general.test1
-rw-r--r--mysql-test/t/range.test84
-rw-r--r--mysql-test/t/repair.test11
-rw-r--r--mysql-test/t/row.test47
-rw-r--r--mysql-test/t/rpl_insert_id.test62
-rw-r--r--mysql-test/t/rpl_max_relay_size.test46
-rw-r--r--mysql-test/t/rpl_ndb_innodb_trans-slave.opt1
-rw-r--r--mysql-test/t/rpl_ndb_innodb_trans.test66
-rw-r--r--mysql-test/t/rpl_sp.test80
-rw-r--r--mysql-test/t/rpl_trigger.test92
-rw-r--r--mysql-test/t/rpl_view.test105
-rw-r--r--mysql-test/t/select.test97
-rw-r--r--mysql-test/t/show_check.test11
-rw-r--r--mysql-test/t/sp-code.test22
-rw-r--r--mysql-test/t/sp-error.test61
-rw-r--r--mysql-test/t/sp-security.test78
-rw-r--r--mysql-test/t/sp.test427
-rw-r--r--mysql-test/t/sp.test.orig5716
-rw-r--r--mysql-test/t/strict.test18
-rw-r--r--mysql-test/t/strict_autoinc_1myisam.test8
-rw-r--r--mysql-test/t/strict_autoinc_2innodb.test10
-rw-r--r--mysql-test/t/strict_autoinc_3heap.test8
-rw-r--r--mysql-test/t/strict_autoinc_4bdb.test10
-rw-r--r--mysql-test/t/strict_autoinc_5ndb.test10
-rw-r--r--mysql-test/t/subselect.test201
-rw-r--r--mysql-test/t/subselect2.test18
-rw-r--r--mysql-test/t/system_mysql_db_fix.test3
-rw-r--r--mysql-test/t/trigger.test120
-rw-r--r--mysql-test/t/type_bit.test15
-rw-r--r--mysql-test/t/type_blob.test15
-rw-r--r--mysql-test/t/type_date.test11
-rw-r--r--mysql-test/t/type_datetime.test11
-rw-r--r--mysql-test/t/type_newdecimal.test8
-rw-r--r--mysql-test/t/type_timestamp.test11
-rw-r--r--mysql-test/t/type_varchar.test41
-rw-r--r--mysql-test/t/udf.test20
-rw-r--r--mysql-test/t/union.test19
-rw-r--r--mysql-test/t/user_var.test46
-rw-r--r--mysql-test/t/variables.test11
-rw-r--r--mysql-test/t/view.test261
-rw-r--r--mysql-test/t/warnings-master.opt2
-rw-r--r--mysql-test/t/warnings.test4
240 files changed, 10130 insertions, 12139 deletions
diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am
index 39fc425bf06..9f54b4fe192 100644
--- a/mysql-test/Makefile.am
+++ b/mysql-test/Makefile.am
@@ -34,7 +34,7 @@ benchdir_root= $(prefix)
testdir = $(benchdir_root)/mysql-test
EXTRA_SCRIPTS = mysql-test-run.sh install_test_db.sh valgrind.supp $(PRESCRIPTS)
EXTRA_DIST = $(EXTRA_SCRIPTS)
-GENSCRIPTS = mysql-test-run install_test_db
+GENSCRIPTS = mysql-test-run install_test_db mtr
PRESCRIPTS = mysql-test-run.pl
test_SCRIPTS = $(GENSCRIPTS) $(PRESCRIPTS)
test_DATA = std_data/client-key.pem std_data/client-cert.pem std_data/cacert.pem \
@@ -89,6 +89,7 @@ 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/*.*001 $(DESTDIR)$(testdir)/std_data
+ $(INSTALL_DATA) $(srcdir)/std_data/*.cnf $(DESTDIR)$(testdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/des_key_file $(DESTDIR)$(testdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/Moscow_leap $(DESTDIR)$(testdir)/std_data
$(INSTALL_DATA) $(srcdir)/std_data/*.pem $(DESTDIR)$(testdir)/std_data
@@ -111,6 +112,11 @@ std_data/server-cert.pem: $(top_srcdir)/SSL/$(@F)
std_data/server-key.pem: $(top_srcdir)/SSL/$(@F)
@RM@ -f $@; @CP@ $(top_srcdir)/SSL/$(@F) $(srcdir)/std_data
+# mtr - a shortcut for executing mysql-test-run.pl
+mtr:
+ $(RM) -f mtr
+ $(LN_S) mysql-test-run.pl mtr
+
SUFFIXES = .sh
.sh:
diff --git a/mysql-test/include/have_case_sensitive_file_system.inc b/mysql-test/include/have_case_sensitive_file_system.inc
new file mode 100644
index 00000000000..730af975497
--- /dev/null
+++ b/mysql-test/include/have_case_sensitive_file_system.inc
@@ -0,0 +1,4 @@
+--require r/case_sensitive_file_system.require
+--disable_query_log
+show variables like "lower_case_file_system";
+--enable_query_log
diff --git a/mysql-test/include/im_check_env.inc b/mysql-test/include/im_check_env.inc
new file mode 100644
index 00000000000..019e0984614
--- /dev/null
+++ b/mysql-test/include/im_check_env.inc
@@ -0,0 +1,25 @@
+# This file is intended to be used in each IM-test. It contains stamements,
+# that ensure that starting conditions (environment) for the IM-test are as
+# expected.
+
+# Check the running instances.
+
+--connect (mysql1_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
+
+--connection mysql1_con
+
+SHOW VARIABLES LIKE 'server_id';
+
+--source include/not_windows.inc
+
+--connection default
+
+# Let IM detect that mysqld1 is online. This delay should be longer than
+# monitoring interval.
+
+--sleep 2
+
+# Check that IM understands that mysqld1 is online, while mysqld2 is
+# offline.
+
+SHOW INSTANCES;
diff --git a/mysql-test/include/im_check_os.inc b/mysql-test/include/im_check_os.inc
deleted file mode 100644
index 9465115feb5..00000000000
--- a/mysql-test/include/im_check_os.inc
+++ /dev/null
@@ -1,7 +0,0 @@
---connect (dflt_server_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
---connection dflt_server_con
-
---source include/not_windows.inc
-
---connection default
---disconnect dflt_server_con
diff --git a/mysql-test/include/loaddata_autocom.inc b/mysql-test/include/loaddata_autocom.inc
new file mode 100644
index 00000000000..e5071c73c49
--- /dev/null
+++ b/mysql-test/include/loaddata_autocom.inc
@@ -0,0 +1,21 @@
+# Test if the engine does autocommit in LOAD DATA INFILE, or not
+# (NDB wants to do, others don't).
+
+eval SET SESSION STORAGE_ENGINE = $engine_type;
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (a text, b text);
+start transaction;
+load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
+commit;
+select count(*) from t1;
+truncate table t1;
+start transaction;
+load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
+rollback;
+select count(*) from t1;
+
+drop table t1;
diff --git a/mysql-test/include/strict_autoinc.inc b/mysql-test/include/strict_autoinc.inc
new file mode 100644
index 00000000000..6960440f3a7
--- /dev/null
+++ b/mysql-test/include/strict_autoinc.inc
@@ -0,0 +1,28 @@
+#
+# Test for strict-mode autoincrement
+#
+
+set @org_mode=@@sql_mode;
+eval create table t1
+(
+ `a` tinyint(4) NOT NULL auto_increment,
+ primary key (`a`)
+) engine = $type ;
+set @@sql_mode='strict_all_tables';
+--error ER_WARN_DATA_OUT_OF_RANGE
+insert into t1 values(1000);
+select count(*) from t1;
+
+set auto_increment_increment=1000;
+set auto_increment_offset=700;
+--error ER_WARN_DATA_OUT_OF_RANGE
+insert into t1 values(null);
+select count(*) from t1;
+
+set @@sql_mode=@org_mode;
+insert into t1 values(null);
+select * from t1;
+
+drop table t1;
+
+# End of test
diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl
index ed0395abd9d..009269f382e 100644
--- a/mysql-test/lib/mtr_cases.pl
+++ b/mysql-test/lib/mtr_cases.pl
@@ -82,7 +82,7 @@ sub collect_test_cases ($) {
if ( $mysqld_test_exists and $im_test_exists )
{
- mtr_error("Ambiguos test case name ($tname)");
+ mtr_error("Ambiguous test case name ($tname)");
}
elsif ( ! $mysqld_test_exists and ! $im_test_exists )
{
@@ -154,34 +154,38 @@ sub collect_test_cases ($) {
if ( $::opt_reorder )
{
- @$cases = sort {
- if ( ! $a->{'master_restart'} and ! $b->{'master_restart'} )
- {
- return $a->{'name'} cmp $b->{'name'};
- }
- if ( $a->{'master_restart'} and $b->{'master_restart'} )
- {
- my $cmp= mtr_cmp_opts($a->{'master_opt'}, $b->{'master_opt'});
- if ( $cmp == 0 )
- {
- return $a->{'name'} cmp $b->{'name'};
- }
- else
- {
- return $cmp;
- }
- }
+ my %sort_criteria;
+ my $tinfo;
- if ( $a->{'master_restart'} )
- {
- return 1; # Is greater
- }
- else
- {
- return -1; # Is less
- }
- } @$cases;
+ # Make a mapping of test name to a string that represents how that test
+ # should be sorted among the other tests. Put the most important criterion
+ # first, then a sub-criterion, then sub-sub-criterion, et c.
+ foreach $tinfo (@$cases)
+ {
+ my @this_criteria = ();
+
+ # Append the criteria for sorting, in order of importance.
+ push(@this_criteria, join("!", sort @{$tinfo->{'master_opt'}}) . "~"); # Ending with "~" makes empty sort later than filled
+ push(@this_criteria, "ndb=" . ($tinfo->{'ndb_test'} ? "1" : "0"));
+ push(@this_criteria, "restart=" . ($tinfo->{'master_restart'} ? "1" : "0"));
+ push(@this_criteria, "big_test=" . ($tinfo->{'big_test'} ? "1" : "0"));
+ push(@this_criteria, join("|", sort keys %{$tinfo})); # Group similar things together. The values may differ substantially. FIXME?
+ push(@this_criteria, $tinfo->{'name'}); # Finally, order by the name
+
+ $sort_criteria{$tinfo->{"name"}} = join(" ", @this_criteria);
+ }
+
+ @$cases = sort { $sort_criteria{$a->{"name"}} cmp $sort_criteria{$b->{"name"}}; } @$cases;
+
+### For debugging the sort-order
+# foreach $tinfo (@$cases)
+# {
+# print $sort_criteria{$tinfo->{"name"}};
+# print " -> \t";
+# print $tinfo->{"name"};
+# print "\n";
+# }
}
return $cases;
diff --git a/mysql-test/lib/mtr_io.pl b/mysql-test/lib/mtr_io.pl
index b3da6d97664..bdf91212b59 100644
--- a/mysql-test/lib/mtr_io.pl
+++ b/mysql-test/lib/mtr_io.pl
@@ -19,13 +19,39 @@ sub mtr_tonewfile($@);
##############################################################################
sub mtr_get_pid_from_file ($) {
- my $file= shift;
+ my $pid_file_path= shift;
+ my $TOTAL_ATTEMPTS= 30;
+ my $timeout= 1;
- open(FILE,"<",$file) or mtr_error("can't open file \"$file\": $!");
- my $pid= <FILE>;
- chomp($pid);
- close FILE;
- return $pid;
+ # We should read from the file until we get correct pid. As it is
+ # stated in BUG#21884, pid file can be empty at some moment. So, we should
+ # read it until we get valid data.
+
+ for (my $cur_attempt= 1; $cur_attempt <= $TOTAL_ATTEMPTS; ++$cur_attempt)
+ {
+ mtr_debug("Reading pid file '$pid_file_path' " .
+ "($cur_attempt of $TOTAL_ATTEMPTS)...");
+
+ open(FILE, '<', $pid_file_path)
+ or mtr_error("can't open file \"$pid_file_path\": $!");
+
+ my $pid= <FILE>;
+
+ chomp($pid) if defined $pid;
+
+ close FILE;
+
+ return $pid if defined $pid && $pid ne '';
+
+ mtr_debug("Pid file '$pid_file_path' is empty. " .
+ "Sleeping $timeout second(s)...");
+
+ sleep(1);
+ }
+
+ mtr_error("Pid file '$pid_file_path' is corrupted. " .
+ "Can not retrieve PID in " .
+ ($timeout * $TOTAL_ATTEMPTS) . " seconds.");
}
sub mtr_get_opts_from_file ($) {
diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl
index b5a2e5a4a68..0ab09a40b37 100644
--- a/mysql-test/lib/mtr_misc.pl
+++ b/mysql-test/lib/mtr_misc.pl
@@ -83,7 +83,14 @@ sub mtr_path_exists (@) {
sub mtr_script_exists (@) {
foreach my $path ( @_ )
{
- return $path if -x $path;
+ if($::glob_win32)
+ {
+ return $path if -f $path;
+ }
+ else
+ {
+ return $path if -x $path;
+ }
}
if ( @_ == 1 )
{
@@ -108,7 +115,14 @@ sub mtr_exe_exists (@) {
map {$_.= ".exe"} @path if $::glob_win32;
foreach my $path ( @path )
{
- return $path if -x $path;
+ if($::glob_win32)
+ {
+ return $path if -f $path;
+ }
+ else
+ {
+ return $path if -x $path;
+ }
}
if ( @path == 1 )
{
diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl
index 0ca16b61fc2..bf869ca91c4 100644
--- a/mysql-test/lib/mtr_process.pl
+++ b/mysql-test/lib/mtr_process.pl
@@ -20,7 +20,29 @@ sub mtr_record_dead_children ();
sub mtr_exit ($);
sub sleep_until_file_created ($$$);
sub mtr_kill_processes ($);
-sub mtr_kill_process ($$$$);
+sub mtr_ping_mysqld_server ($);
+
+# Private IM-related operations.
+
+sub mtr_im_kill_process ($$$$);
+sub mtr_im_load_pids ($);
+sub mtr_im_terminate ($);
+sub mtr_im_check_alive ($);
+sub mtr_im_check_main_alive ($);
+sub mtr_im_check_angel_alive ($);
+sub mtr_im_check_mysqlds_alive ($);
+sub mtr_im_check_mysqld_alive ($$);
+sub mtr_im_cleanup ($);
+sub mtr_im_rm_file ($);
+sub mtr_im_errlog ($);
+sub mtr_im_kill ($);
+sub mtr_im_wait_for_connection ($$$);
+sub mtr_im_wait_for_mysqld($$$);
+
+# Public IM-related operations.
+
+sub mtr_im_start ($$);
+sub mtr_im_stop ($);
# static in C
sub spawn_impl ($$$$$$$$);
@@ -359,40 +381,54 @@ sub mtr_process_exit_status {
sub mtr_kill_leftovers () {
- # First, kill all masters and slaves that would conflict with
- # this run. Make sure to remove the PID file, if any.
- # FIXME kill IM manager first, else it will restart the servers, how?!
+ mtr_debug("mtr_kill_leftovers(): started.");
+
+ mtr_im_stop($::instance_manager);
+
+ # Kill mysqld servers (masters and slaves) that would conflict with this
+ # run. Make sure to remove the PID file, if any.
+ # Don't touch IM-managed mysqld instances -- they should be stopped by
+ # mtr_im_stop().
+
+ mtr_debug("Collecting mysqld-instances to shutdown...");
my @args;
- for ( my $idx; $idx < 2; $idx++ )
+ for ( my $idx= 0; $idx < 2; $idx++ )
{
- push(@args,{
- pid => 0, # We don't know the PID
- pidfile => $::instance_manager->{'instances'}->[$idx]->{'path_pid'},
- sockfile => $::instance_manager->{'instances'}->[$idx]->{'path_sock'},
- port => $::instance_manager->{'instances'}->[$idx]->{'port'},
- });
- }
+ my $pidfile= $::master->[$idx]->{'path_mypid'};
+ my $sockfile= $::master->[$idx]->{'path_mysock'};
+ my $port= $::master->[$idx]->{'path_myport'};
- for ( my $idx; $idx < 2; $idx++ )
- {
push(@args,{
pid => 0, # We don't know the PID
- pidfile => $::master->[$idx]->{'path_mypid'},
- sockfile => $::master->[$idx]->{'path_mysock'},
- port => $::master->[$idx]->{'path_myport'},
+ pidfile => $pidfile,
+ sockfile => $sockfile,
+ port => $port,
});
+
+ mtr_debug(" - Master mysqld " .
+ "(idx: $idx; pid: '$pidfile'; socket: '$sockfile'; port: $port)");
+ $::master->[$idx]->{'pid'}= 0; # Assume we are done with it
}
- for ( my $idx; $idx < 3; $idx++ )
+ for ( my $idx= 0; $idx < 3; $idx++ )
{
+ my $pidfile= $::slave->[$idx]->{'path_mypid'};
+ my $sockfile= $::slave->[$idx]->{'path_mysock'};
+ my $port= $::slave->[$idx]->{'path_myport'};
+
push(@args,{
pid => 0, # We don't know the PID
- pidfile => $::slave->[$idx]->{'path_mypid'},
- sockfile => $::slave->[$idx]->{'path_mysock'},
- port => $::slave->[$idx]->{'path_myport'},
+ pidfile => $pidfile,
+ sockfile => $sockfile,
+ port => $port,
});
+
+ mtr_debug(" - Slave mysqld " .
+ "(idx: $idx; pid: '$pidfile'; socket: '$sockfile'; port: $port)");
+
+ $::slave->[$idx]->{'pid'}= 0; # Assume we are done with it
}
mtr_mysqladmin_shutdown(\@args, 20);
@@ -413,6 +449,8 @@ sub mtr_kill_leftovers () {
# FIXME $path_run_dir or something
my $rundir= "$::opt_vardir/run";
+ mtr_debug("Processing PID files in directory '$rundir'...");
+
if ( -d $rundir )
{
opendir(RUNDIR, $rundir)
@@ -426,8 +464,12 @@ sub mtr_kill_leftovers () {
if ( -f $pidfile )
{
+ mtr_debug("Processing PID file: '$pidfile'...");
+
my $pid= mtr_get_pid_from_file($pidfile);
+ mtr_debug("Got pid: $pid from file '$pidfile'");
+
# Race, could have been removed between I tested with -f
# and the unlink() below, so I better check again with -f
@@ -438,14 +480,24 @@ sub mtr_kill_leftovers () {
if ( $::glob_cygwin_perl or kill(0, $pid) )
{
+ mtr_debug("There is process with pid $pid -- scheduling for kill.");
push(@pids, $pid); # We know (cygwin guess) it exists
}
+ else
+ {
+ mtr_debug("There is no process with pid $pid -- skipping.");
+ }
}
}
closedir(RUNDIR);
if ( @pids )
{
+ mtr_debug("Killing the following processes with PID files: " .
+ join(' ', @pids) . "...");
+
+ start_reap_all();
+
if ( $::glob_cygwin_perl )
{
# We have no (easy) way of knowing the Cygwin controlling
@@ -459,6 +511,7 @@ sub mtr_kill_leftovers () {
my $retries= 10; # 10 seconds
do
{
+ mtr_debug("Sending SIGKILL to pids: " . join(' ', @pids));
kill(9, @pids);
mtr_debug("Sleep 1 second waiting for processes to die");
sleep(1) # Wait one second
@@ -469,19 +522,29 @@ sub mtr_kill_leftovers () {
mtr_warning("can't kill process(es) " . join(" ", @pids));
}
}
+
+ stop_reap_all();
}
}
+ else
+ {
+ mtr_debug("Directory for PID files ($rundir) does not exist.");
+ }
# We may have failed everything, bug we now check again if we have
# the listen ports free to use, and if they are free, just go for it.
+ mtr_debug("Checking known mysqld servers...");
+
foreach my $srv ( @args )
{
- if ( mtr_ping_mysqld_server($srv->{'port'}, $srv->{'sockfile'}) )
+ if ( mtr_ping_mysqld_server($srv->{'port'}) )
{
mtr_warning("can't kill old mysqld holding port $srv->{'port'}");
}
}
+
+ mtr_debug("mtr_kill_leftovers(): finished.");
}
##############################################################################
@@ -653,10 +716,15 @@ sub mtr_mysqladmin_shutdown {
my %mysql_admin_pids;
my @to_kill_specs;
+ mtr_debug("mtr_mysqladmin_shutdown(): starting...");
+ mtr_debug("Collecting mysqld-instances to shutdown...");
+
foreach my $srv ( @$spec )
{
- if ( mtr_ping_mysqld_server($srv->{'port'}, $srv->{'sockfile'}) )
+ if ( mtr_ping_mysqld_server($srv->{'port'}) )
{
+ mtr_debug("Mysqld (port: $srv->{port}) needs to be stopped.");
+
push(@to_kill_specs, $srv);
}
}
@@ -688,6 +756,9 @@ sub mtr_mysqladmin_shutdown {
mtr_add_arg($args, "--shutdown_timeout=$adm_shutdown_tmo");
mtr_add_arg($args, "shutdown");
+ mtr_debug("Shutting down mysqld " .
+ "(port: $srv->{port}; socket: '$srv->{sockfile}')...");
+
my $path_mysqladmin_log= "$::opt_vardir/log/mysqladmin.log";
my $pid= mtr_spawn($::exe_mysqladmin, $args,
"", $path_mysqladmin_log, $path_mysqladmin_log, "",
@@ -719,14 +790,18 @@ sub mtr_mysqladmin_shutdown {
my $res= 1; # If we just fall through, we are done
# in the sense that the servers don't
# listen to their ports any longer
+
+ mtr_debug("Waiting for mysqld servers to stop...");
+
TIME:
while ( $timeout-- )
{
foreach my $srv ( @to_kill_specs )
{
$res= 1; # We are optimistic
- if ( mtr_ping_mysqld_server($srv->{'port'}, $srv->{'sockfile'}) )
+ if ( mtr_ping_mysqld_server($srv->{'port'}) )
{
+ mtr_debug("Mysqld (port: $srv->{port}) is still alive.");
mtr_debug("Sleep 1 second waiting for processes to stop using port");
sleep(1); # One second
$res= 0;
@@ -736,7 +811,14 @@ sub mtr_mysqladmin_shutdown {
last; # If we got here, we are done
}
- $timeout or mtr_debug("At least one server is still listening to its port");
+ if ($res)
+ {
+ mtr_debug("mtr_mysqladmin_shutdown(): All mysqld instances are down.");
+ }
+ else
+ {
+ mtr_debug("mtr_mysqladmin_shutdown(): At least one server is alive.");
+ }
return $res;
}
@@ -795,7 +877,7 @@ sub stop_reap_all {
$SIG{CHLD}= 'DEFAULT';
}
-sub mtr_ping_mysqld_server () {
+sub mtr_ping_mysqld_server ($) {
my $port= shift;
my $remote= "localhost";
@@ -810,13 +892,18 @@ sub mtr_ping_mysqld_server () {
{
mtr_error("can't create socket: $!");
}
+
+ mtr_debug("Pinging server (port: $port)...");
+
if ( connect(SOCK, $paddr) )
{
+ mtr_debug("Server (port: $port) is alive.");
close(SOCK); # FIXME check error?
return 1;
}
else
{
+ mtr_debug("Server (port: $port) is dead.");
return 0;
}
}
@@ -886,34 +973,6 @@ sub mtr_kill_processes ($) {
}
}
-
-sub mtr_kill_process ($$$$) {
- my $pid= shift;
- my $signal= shift;
- my $total_retries= shift;
- my $timeout= shift;
-
- for (my $cur_attempt= 1; $cur_attempt <= $total_retries; ++$cur_attempt)
- {
- mtr_debug("Sending $signal to $pid...");
-
- kill($signal, $pid);
-
- unless (kill (0, $pid))
- {
- mtr_debug("Process $pid died.");
- return;
- }
-
- mtr_debug("Sleeping $timeout second(s) waiting for processes to die...");
-
- sleep($timeout);
- }
-
- mtr_debug("Process $pid is still alive after $total_retries " .
- "of sending signal $signal.");
-}
-
##############################################################################
#
# When we exit, we kill off all children
@@ -943,4 +1002,676 @@ sub mtr_exit ($) {
exit($code);
}
+##############################################################################
+#
+# Instance Manager management routines.
+#
+##############################################################################
+
+sub mtr_im_kill_process ($$$$) {
+ my $pid_lst= shift;
+ my $signal= shift;
+ my $total_retries= shift;
+ my $timeout= shift;
+
+ my %pids;
+
+ foreach my $pid (@{$pid_lst})
+ {
+ $pids{$pid}= 1;
+ }
+
+ for (my $cur_attempt= 1; $cur_attempt <= $total_retries; ++$cur_attempt)
+ {
+ foreach my $pid (keys %pids)
+ {
+ mtr_debug("Sending $signal to $pid...");
+
+ kill($signal, $pid);
+
+ unless (kill (0, $pid))
+ {
+ mtr_debug("Process $pid died.");
+ delete $pids{$pid};
+ }
+ }
+
+ return if scalar keys %pids == 0;
+
+ mtr_debug("Sleeping $timeout second(s) waiting for processes to die...");
+
+ sleep($timeout);
+ }
+
+ mtr_debug("Process(es) " .
+ join(' ', keys %pids) .
+ " is still alive after $total_retries " .
+ "of sending signal $signal.");
+}
+
+###########################################################################
+
+sub mtr_im_load_pids($) {
+ my $instance_manager= shift;
+
+ mtr_debug("Loading PID files...");
+
+ # Obtain mysqld-process pids.
+
+ my $instances = $instance_manager->{'instances'};
+
+ for (my $idx= 0; $idx < 2; ++$idx)
+ {
+ mtr_debug("IM-guarded mysqld[$idx] PID file: '" .
+ $instances->[$idx]->{'path_pid'} . "'.");
+
+ my $mysqld_pid;
+
+ if (-r $instances->[$idx]->{'path_pid'})
+ {
+ $mysqld_pid= mtr_get_pid_from_file($instances->[$idx]->{'path_pid'});
+ mtr_debug("IM-guarded mysqld[$idx] PID: $mysqld_pid.");
+ }
+ else
+ {
+ $mysqld_pid= undef;
+ mtr_debug("IM-guarded mysqld[$idx]: no PID file.");
+ }
+
+ $instances->[$idx]->{'pid'}= $mysqld_pid;
+ }
+
+ # Re-read Instance Manager PIDs from the file, since during tests Instance
+ # Manager could have been restarted, so its PIDs could have been changed.
+
+ # - IM-main
+
+ mtr_debug("IM-main PID file: '$instance_manager->{path_pid}'.");
+
+ if (-f $instance_manager->{'path_pid'})
+ {
+ $instance_manager->{'pid'} =
+ mtr_get_pid_from_file($instance_manager->{'path_pid'});
+
+ mtr_debug("IM-main PID: $instance_manager->{pid}.");
+ }
+ else
+ {
+ mtr_debug("IM-main: no PID file.");
+ $instance_manager->{'pid'}= undef;
+ }
+
+ # - IM-angel
+
+ mtr_debug("IM-angel PID file: '$instance_manager->{path_angel_pid}'.");
+
+ if (-f $instance_manager->{'path_angel_pid'})
+ {
+ $instance_manager->{'angel_pid'} =
+ mtr_get_pid_from_file($instance_manager->{'path_angel_pid'});
+
+ mtr_debug("IM-angel PID: $instance_manager->{'angel_pid'}.");
+ }
+ else
+ {
+ mtr_debug("IM-angel: no PID file.");
+ $instance_manager->{'angel_pid'} = undef;
+ }
+}
+
+###########################################################################
+
+sub mtr_im_terminate($) {
+ my $instance_manager= shift;
+
+ # Load pids from pid-files. We should do it first of all, because IM deletes
+ # them on shutdown.
+
+ mtr_im_load_pids($instance_manager);
+
+ mtr_debug("Shutting Instance Manager down...");
+
+ # Ignoring SIGCHLD so that all children could rest in peace.
+
+ start_reap_all();
+
+ # Send SIGTERM to IM-main.
+
+ if (defined $instance_manager->{'pid'})
+ {
+ mtr_debug("IM-main pid: $instance_manager->{pid}.");
+ mtr_debug("Stopping IM-main...");
+
+ mtr_im_kill_process([ $instance_manager->{'pid'} ], 'TERM', 10, 1);
+ }
+ else
+ {
+ mtr_debug("IM-main pid: n/a.");
+ }
+
+ # If IM-angel was alive, wait for it to die.
+
+ if (defined $instance_manager->{'angel_pid'})
+ {
+ mtr_debug("IM-angel pid: $instance_manager->{'angel_pid'}.");
+ mtr_debug("Waiting for IM-angel to die...");
+
+ my $total_attempts= 10;
+
+ for (my $cur_attempt=1; $cur_attempt <= $total_attempts; ++$cur_attempt)
+ {
+ unless (kill (0, $instance_manager->{'angel_pid'}))
+ {
+ mtr_debug("IM-angel died.");
+ last;
+ }
+
+ sleep(1);
+ }
+ }
+ else
+ {
+ mtr_debug("IM-angel pid: n/a.");
+ }
+
+ stop_reap_all();
+
+ # Re-load PIDs.
+
+ mtr_im_load_pids($instance_manager);
+}
+
+###########################################################################
+
+sub mtr_im_check_alive($) {
+ my $instance_manager= shift;
+
+ mtr_debug("Checking whether IM-components are alive...");
+
+ return 1 if mtr_im_check_main_alive($instance_manager);
+
+ return 1 if mtr_im_check_angel_alive($instance_manager);
+
+ return 1 if mtr_im_check_mysqlds_alive($instance_manager);
+
+ return 0;
+}
+
+###########################################################################
+
+sub mtr_im_check_main_alive($) {
+ my $instance_manager= shift;
+
+ # Check that the process, that we know to be IM's, is dead.
+
+ if (defined $instance_manager->{'pid'})
+ {
+ if (kill (0, $instance_manager->{'pid'}))
+ {
+ mtr_debug("IM-main (PID: $instance_manager->{pid}) is alive.");
+ return 1;
+ }
+ else
+ {
+ mtr_debug("IM-main (PID: $instance_manager->{pid}) is dead.");
+ }
+ }
+ else
+ {
+ mtr_debug("No PID file for IM-main.");
+ }
+
+ # Check that IM does not accept client connections.
+
+ if (mtr_ping_mysqld_server($instance_manager->{'port'}))
+ {
+ mtr_debug("IM-main (port: $instance_manager->{port}) " .
+ "is accepting connections.");
+
+ mtr_im_errlog("IM-main is accepting connections on port " .
+ "$instance_manager->{port}, but there is no " .
+ "process information.");
+ return 1;
+ }
+ else
+ {
+ mtr_debug("IM-main (port: $instance_manager->{port}) " .
+ "does not accept connections.");
+ return 0;
+ }
+}
+
+###########################################################################
+
+sub mtr_im_check_angel_alive($) {
+ my $instance_manager= shift;
+
+ # Check that the process, that we know to be the Angel, is dead.
+
+ if (defined $instance_manager->{'angel_pid'})
+ {
+ if (kill (0, $instance_manager->{'angel_pid'}))
+ {
+ mtr_debug("IM-angel (PID: $instance_manager->{angel_pid}) is alive.");
+ return 1;
+ }
+ else
+ {
+ mtr_debug("IM-angel (PID: $instance_manager->{angel_pid}) is dead.");
+ return 0;
+ }
+ }
+ else
+ {
+ mtr_debug("No PID file for IM-angel.");
+ return 0;
+ }
+}
+
+###########################################################################
+
+sub mtr_im_check_mysqlds_alive($) {
+ my $instance_manager= shift;
+
+ mtr_debug("Checking for IM-guarded mysqld instances...");
+
+ my $instances = $instance_manager->{'instances'};
+
+ for (my $idx= 0; $idx < 2; ++$idx)
+ {
+ mtr_debug("Checking mysqld[$idx]...");
+
+ return 1
+ if mtr_im_check_mysqld_alive($instance_manager, $instances->[$idx]);
+ }
+}
+
+###########################################################################
+
+sub mtr_im_check_mysqld_alive($$) {
+ my $instance_manager= shift;
+ my $mysqld_instance= shift;
+
+ # Check that the process is dead.
+
+ if (defined $instance_manager->{'pid'})
+ {
+ if (kill (0, $instance_manager->{'pid'}))
+ {
+ mtr_debug("Mysqld instance (PID: $mysqld_instance->{pid}) is alive.");
+ return 1;
+ }
+ else
+ {
+ mtr_debug("Mysqld instance (PID: $mysqld_instance->{pid}) is dead.");
+ }
+ }
+ else
+ {
+ mtr_debug("No PID file for mysqld instance.");
+ }
+
+ # Check that mysqld does not accept client connections.
+
+ if (mtr_ping_mysqld_server($mysqld_instance->{'port'}))
+ {
+ mtr_debug("Mysqld instance (port: $mysqld_instance->{port}) " .
+ "is accepting connections.");
+
+ mtr_im_errlog("Mysqld is accepting connections on port " .
+ "$mysqld_instance->{port}, but there is no " .
+ "process information.");
+ return 1;
+ }
+ else
+ {
+ mtr_debug("Mysqld instance (port: $mysqld_instance->{port}) " .
+ "does not accept connections.");
+ return 0;
+ }
+}
+
+###########################################################################
+
+sub mtr_im_cleanup($) {
+ my $instance_manager= shift;
+
+ mtr_im_rm_file($instance_manager->{'path_pid'});
+ mtr_im_rm_file($instance_manager->{'path_sock'});
+
+ mtr_im_rm_file($instance_manager->{'path_angel_pid'});
+
+ for (my $idx= 0; $idx < 2; ++$idx)
+ {
+ mtr_im_rm_file($instance_manager->{'instances'}->[$idx]->{'path_pid'});
+ mtr_im_rm_file($instance_manager->{'instances'}->[$idx]->{'path_sock'});
+ }
+}
+
+###########################################################################
+
+sub mtr_im_rm_file($)
+{
+ my $file_path= shift;
+
+ if (-f $file_path)
+ {
+ mtr_debug("Removing '$file_path'...");
+
+ mtr_warning("Can not remove '$file_path'.")
+ unless unlink($file_path);
+ }
+ else
+ {
+ mtr_debug("File '$file_path' does not exist already.");
+ }
+}
+
+###########################################################################
+
+sub mtr_im_errlog($) {
+ my $msg= shift;
+
+ # Complain in error log so that a warning will be shown.
+ #
+ # TODO: unless BUG#20761 is fixed, we will print the warning to stdout, so
+ # that it can be seen on console and does not produce pushbuild error.
+
+ # my $errlog= "$opt_vardir/log/mysql-test-run.pl.err";
+ #
+ # open (ERRLOG, ">>$errlog") ||
+ # mtr_error("Can not open error log ($errlog)");
+ #
+ # my $ts= localtime();
+ # print ERRLOG
+ # "Warning: [$ts] $msg\n";
+ #
+ # close ERRLOG;
+
+ my $ts= localtime();
+ print "Warning: [$ts] $msg\n";
+}
+
+###########################################################################
+
+sub mtr_im_kill($) {
+ my $instance_manager= shift;
+
+ # Re-load PIDs. That can be useful because some processes could have been
+ # restarted.
+
+ mtr_im_load_pids($instance_manager);
+
+ # Ignoring SIGCHLD so that all children could rest in peace.
+
+ start_reap_all();
+
+ # Kill IM-angel first of all.
+
+ if (defined $instance_manager->{'angel_pid'})
+ {
+ mtr_debug("Killing IM-angel (PID: $instance_manager->{angel_pid})...");
+ mtr_im_kill_process([ $instance_manager->{'angel_pid'} ], 'KILL', 10, 1)
+ }
+ else
+ {
+ mtr_debug("IM-angel is dead.");
+ }
+
+ # Re-load PIDs again.
+
+ mtr_im_load_pids($instance_manager);
+
+ # Kill IM-main.
+
+ if (defined $instance_manager->{'pid'})
+ {
+ mtr_debug("Killing IM-main (PID: $instance_manager->pid})...");
+ mtr_im_kill_process([ $instance_manager->{'pid'} ], 'KILL', 10, 1);
+ }
+ else
+ {
+ mtr_debug("IM-main is dead.");
+ }
+
+ # Re-load PIDs again.
+
+ mtr_im_load_pids($instance_manager);
+
+ # Kill guarded mysqld instances.
+
+ my @mysqld_pids;
+
+ mtr_debug("Collecting PIDs of mysqld instances to kill...");
+
+ for (my $idx= 0; $idx < 2; ++$idx)
+ {
+ my $pid= $instance_manager->{'instances'}->[$idx]->{'pid'};
+
+ next unless defined $pid;
+
+ mtr_debug(" - IM-guarded mysqld[$idx] PID: $pid.");
+
+ push (@mysqld_pids, $pid);
+ }
+
+ if (scalar @mysqld_pids > 0)
+ {
+ mtr_debug("Killing IM-guarded mysqld instances...");
+ mtr_im_kill_process(\@mysqld_pids, 'KILL', 10, 1);
+ }
+
+ # That's all.
+
+ stop_reap_all();
+}
+
+##############################################################################
+
+sub mtr_im_wait_for_connection($$$) {
+ my $instance_manager= shift;
+ my $total_attempts= shift;
+ my $connect_timeout= shift;
+
+ mtr_debug("Waiting for IM on port $instance_manager->{port} " .
+ "to start accepting connections...");
+
+ for (my $cur_attempt= 1; $cur_attempt <= $total_attempts; ++$cur_attempt)
+ {
+ mtr_debug("Trying to connect to IM ($cur_attempt of $total_attempts)...");
+
+ if (mtr_ping_mysqld_server($instance_manager->{'port'}))
+ {
+ mtr_debug("IM is accepting connections " .
+ "on port $instance_manager->{port}.");
+ return 1;
+ }
+
+ mtr_debug("Sleeping $connect_timeout...");
+ sleep($connect_timeout);
+ }
+
+ mtr_debug("IM does not accept connections " .
+ "on port $instance_manager->{port} after " .
+ ($total_attempts * $connect_timeout) . " seconds.");
+
+ return 0;
+}
+
+##############################################################################
+
+sub mtr_im_wait_for_mysqld($$$) {
+ my $mysqld= shift;
+ my $total_attempts= shift;
+ my $connect_timeout= shift;
+
+ mtr_debug("Waiting for IM-guarded mysqld on port $mysqld->{port} " .
+ "to start accepting connections...");
+
+ for (my $cur_attempt= 1; $cur_attempt <= $total_attempts; ++$cur_attempt)
+ {
+ mtr_debug("Trying to connect to mysqld " .
+ "($cur_attempt of $total_attempts)...");
+
+ if (mtr_ping_mysqld_server($mysqld->{'port'}))
+ {
+ mtr_debug("Mysqld is accepting connections " .
+ "on port $mysqld->{port}.");
+ return 1;
+ }
+
+ mtr_debug("Sleeping $connect_timeout...");
+ sleep($connect_timeout);
+ }
+
+ mtr_debug("Mysqld does not accept connections " .
+ "on port $mysqld->{port} after " .
+ ($total_attempts * $connect_timeout) . " seconds.");
+
+ return 0;
+}
+
+##############################################################################
+
+sub mtr_im_start($$) {
+ my $instance_manager = shift;
+ my $opts = shift;
+
+ mtr_debug("Starting Instance Manager...");
+
+ my $args;
+ mtr_init_args(\$args);
+ mtr_add_arg($args, "--defaults-file=%s",
+ $instance_manager->{'defaults_file'});
+
+ foreach my $opt (@{$opts})
+ {
+ mtr_add_arg($args, $opt);
+ }
+
+ $instance_manager->{'pid'} =
+ mtr_spawn(
+ $::exe_im, # path to the executable
+ $args, # cmd-line args
+ '', # stdin
+ $instance_manager->{'path_log'}, # stdout
+ $instance_manager->{'path_err'}, # stderr
+ '', # pid file path (not used)
+ { append_log_file => 1 } # append log files
+ );
+
+ if ( ! $instance_manager->{'pid'} )
+ {
+ mtr_report('Could not start Instance Manager');
+ return;
+ }
+
+ # Instance Manager can be run in daemon mode. In this case, it creates
+ # several processes and the parent process, created by mtr_spawn(), exits just
+ # after start. So, we have to obtain Instance Manager PID from the PID file.
+
+ if ( ! sleep_until_file_created(
+ $instance_manager->{'path_pid'},
+ $instance_manager->{'start_timeout'},
+ -1)) # real PID is still unknown
+ {
+ mtr_report("Instance Manager PID file is missing");
+ return;
+ }
+
+ $instance_manager->{'pid'} =
+ mtr_get_pid_from_file($instance_manager->{'path_pid'});
+
+ mtr_debug("Instance Manager started. PID: $instance_manager->{pid}.");
+
+ # Wait until we can connect to IM.
+
+ my $IM_CONNECT_TIMEOUT= 30;
+
+ unless (mtr_im_wait_for_connection($instance_manager,
+ $IM_CONNECT_TIMEOUT, 1))
+ {
+ mtr_debug("Can not connect to Instance Manager " .
+ "in $IM_CONNECT_TIMEOUT seconds after start.");
+ mtr_debug("Aborting test suite...");
+
+ mtr_kill_leftovers();
+
+ mtr_error("Can not connect to Instance Manager " .
+ "in $IM_CONNECT_TIMEOUT seconds after start.");
+ }
+
+ # Wait until we can connect to guarded mysqld-instances
+ # (in other words -- wait for IM to start guarded instances).
+
+ for (my $idx= 0; $idx < 2; ++$idx)
+ {
+ my $mysqld= $instance_manager->{'instances'}->[$idx];
+
+ next if exists $mysqld->{'nonguarded'};
+
+ mtr_debug("Waiting for mysqld[$idx] to start...");
+
+ unless (mtr_im_wait_for_mysqld($mysqld, 30, 1))
+ {
+ mtr_debug("Can not connect to mysqld[$idx] " .
+ "in $IM_CONNECT_TIMEOUT seconds after start.");
+ mtr_debug("Aborting test suite...");
+
+ mtr_kill_leftovers();
+
+ mtr_error("Can not connect to mysqld[$idx] " .
+ "in $IM_CONNECT_TIMEOUT seconds after start.");
+ }
+
+ mtr_debug("mysqld[$idx] started.");
+ }
+
+ mtr_debug("Instance Manager started.");
+}
+
+##############################################################################
+
+sub mtr_im_stop($) {
+ my $instance_manager= shift;
+
+ mtr_debug("Stopping Instance Manager...");
+
+ # Try graceful shutdown.
+
+ mtr_im_terminate($instance_manager);
+
+ # Check that all processes died.
+
+ unless (mtr_im_check_alive($instance_manager))
+ {
+ mtr_debug("Instance Manager has been stopped successfully.");
+ mtr_im_cleanup($instance_manager);
+ return 1;
+ }
+
+ # Instance Manager don't want to die. We should kill it.
+
+ mtr_im_errlog("Instance Manager did not shutdown gracefully.");
+
+ mtr_im_kill($instance_manager);
+
+ # Check again that all IM-related processes have been killed.
+
+ my $im_is_alive= mtr_im_check_alive($instance_manager);
+
+ mtr_im_cleanup($instance_manager);
+
+ if ($im_is_alive)
+ {
+ mtr_error("Can not kill Instance Manager or its children.");
+ return 0;
+ }
+
+ mtr_debug("Instance Manager has been killed successfully.");
+ return 1;
+}
+
+###########################################################################
+
1;
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 91a9a758d1d..f0eb7f3bda4 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -133,7 +133,6 @@ our @mysqld_src_dirs=
our $glob_win32= 0; # OS and native Win32 executables
our $glob_win32_perl= 0; # ActiveState Win32 Perl
our $glob_cygwin_perl= 0; # Cygwin Perl
-our $glob_cygwin_shell= undef;
our $glob_mysql_test_dir= undef;
our $glob_mysql_bench_dir= undef;
our $glob_hostname= undef;
@@ -187,6 +186,7 @@ our $exe_mysqltest;
our $exe_slave_mysqld;
our $exe_im;
our $exe_my_print_defaults;
+our $exe_perror;
our $lib_udf_example;
our $exe_libtool;
@@ -335,7 +335,7 @@ sub snapshot_setup ();
sub executable_setup ();
sub environment_setup ();
sub kill_running_server ();
-sub kill_and_cleanup ();
+sub cleanup_stale_files ();
sub check_ssl_support ();
sub check_running_as_root();
sub check_ndbcluster_support ();
@@ -355,8 +355,6 @@ sub mysqld_arguments ($$$$$$);
sub stop_masters_slaves ();
sub stop_masters ();
sub stop_slaves ();
-sub im_start ($$);
-sub im_stop ($);
sub run_mysqltest ($);
sub usage ($);
@@ -465,10 +463,7 @@ sub initial_setup () {
{
# Windows programs like 'mysqld' needs Windows paths
$glob_mysql_test_dir= `cygpath -m "$glob_mysql_test_dir"`;
- my $shell= $ENV{'SHELL'} || "/bin/bash";
- $glob_cygwin_shell= `cygpath -w "$shell"`; # The Windows path c:\...
chomp($glob_mysql_test_dir);
- chomp($glob_cygwin_shell);
}
$glob_basedir= dirname($glob_mysql_test_dir);
$glob_mysql_bench_dir= "$glob_basedir/mysql-bench"; # FIXME make configurable
@@ -498,7 +493,7 @@ sub command_line_setup () {
my $opt_master_myport= 9306;
my $opt_slave_myport= 9308;
$opt_ndbcluster_port= 9350;
- my $im_port= 9310;
+ my $im_port= 9311;
my $im_mysqld1_port= 9312;
my $im_mysqld2_port= 9314;
@@ -811,6 +806,13 @@ sub command_line_setup () {
$opt_with_ndbcluster= 0;
}
+ # Check IM arguments
+ if ( $glob_win32 )
+ {
+ mtr_report("Disable Instance manager - not supported on Windows");
+ $opt_skip_im= 1;
+ }
+
# Check valgrind arguments
if ( $opt_valgrind or $opt_valgrind_path or defined $opt_valgrind_options)
{
@@ -1036,18 +1038,30 @@ sub executable_setup () {
if ( $glob_win32 )
{
$path_client_bindir= mtr_path_exists("$glob_basedir/client_release",
- "$glob_basedir/client_debug",
+ "$glob_basedir/client_debug",
+ "$glob_basedir/client/release",
+ "$glob_basedir/client/debug",
"$glob_basedir/bin",);
$exe_mysqld= mtr_exe_exists ("$path_client_bindir/mysqld-max-nt",
"$path_client_bindir/mysqld-max",
"$path_client_bindir/mysqld-nt",
"$path_client_bindir/mysqld",
"$path_client_bindir/mysqld-debug",
- "$path_client_bindir/mysqld-max");
- $path_language= mtr_path_exists("$glob_basedir/share/english/");
- $path_charsetsdir= mtr_path_exists("$glob_basedir/share/charsets");
+ "$path_client_bindir/mysqld-max",
+ "$glob_basedir/sql/release/mysqld",
+ "$glob_basedir/sql/debug/mysqld");
+ $path_language= mtr_path_exists("$glob_basedir/share/english/",
+ "$glob_basedir/sql/share/english/");
+ $path_charsetsdir= mtr_path_exists("$glob_basedir/share/charsets",
+ "$glob_basedir/sql/share/charsets/");
$exe_my_print_defaults=
- mtr_exe_exists("$path_client_bindir/my_print_defaults");
+ mtr_exe_exists("$path_client_bindir/my_print_defaults",
+ "$glob_basedir/extra/release/my_print_defaults",
+ "$glob_basedir/extra/debug/my_print_defaults");
+ $exe_perror=
+ mtr_exe_exists("$path_client_bindir/perror",
+ "$glob_basedir/extra/release/perror",
+ "$glob_basedir/extra/debug/perror");
}
else
{
@@ -1060,6 +1074,8 @@ sub executable_setup () {
"$glob_basedir/server-tools/instance-manager/mysqlmanager");
$exe_my_print_defaults=
mtr_exe_exists("$glob_basedir/extra/my_print_defaults");
+ $exe_perror=
+ mtr_exe_exists("$glob_basedir/extra/perror");
}
if ( $glob_use_embedded_server )
@@ -1076,6 +1092,9 @@ sub executable_setup () {
$exe_mysql_client_test=
mtr_exe_exists("$glob_basedir/tests/mysql_client_test",
"$path_client_bindir/mysql_client_test",
+ "$glob_basedir/tests/release/mysql_client_test",
+ "$glob_basedir/tests/debug/mysql_client_test",
+ "$path_client_bindir/mysql_client_test",
"/usr/bin/false");
}
$exe_mysqlcheck= mtr_exe_exists("$path_client_bindir/mysqlcheck");
@@ -1086,7 +1105,8 @@ sub executable_setup () {
$exe_mysqladmin= mtr_exe_exists("$path_client_bindir/mysqladmin");
$exe_mysql= mtr_exe_exists("$path_client_bindir/mysql");
$exe_mysql_fix_system_tables=
- mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables");
+ mtr_script_exists("$glob_basedir/scripts/mysql_fix_privilege_tables",
+ "/usr/bin/false");
$path_ndb_tools_dir= mtr_path_exists("$glob_basedir/ndb/tools");
$exe_ndb_mgm= "$glob_basedir/ndb/src/mgmclient/ndb_mgm";
$lib_udf_example=
@@ -1104,9 +1124,12 @@ sub executable_setup () {
$exe_mysql= mtr_exe_exists("$path_client_bindir/mysql");
$exe_mysql_fix_system_tables=
mtr_script_exists("$path_client_bindir/mysql_fix_privilege_tables",
- "$glob_basedir/scripts/mysql_fix_privilege_tables");
+ "$glob_basedir/scripts/mysql_fix_privilege_tables",
+ "/usr/bin/false");
$exe_my_print_defaults=
mtr_exe_exists("$path_client_bindir/my_print_defaults");
+ $exe_perror=
+ mtr_exe_exists("$path_client_bindir/perror");
$path_language= mtr_path_exists("$glob_basedir/share/mysql/english/",
"$glob_basedir/share/english/");
@@ -1136,7 +1159,9 @@ sub executable_setup () {
}
else
{
- $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest");
+ $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest",
+ "$glob_basedir/client/release/mysqltest",
+ "$glob_basedir/client/debug/mysqltest");
$exe_mysql_client_test=
mtr_exe_exists("$path_client_bindir/mysql_client_test",
"/usr/bin/false"); # FIXME temporary
@@ -1164,28 +1189,33 @@ sub executable_setup () {
sub environment_setup () {
+ my $extra_ld_library_paths;
+
# --------------------------------------------------------------------------
- # We might not use a standard installation directory, like /usr/lib.
- # Set LD_LIBRARY_PATH to make sure we find our installed libraries.
+ # Setup LD_LIBRARY_PATH so the libraries from this distro/clone
+ # are used in favor of the system installed ones
# --------------------------------------------------------------------------
-
- unless ( $opt_source_dist )
+ if ( $opt_source_dist )
+ {
+ $extra_ld_library_paths= "$glob_basedir/libmysql/.libs/";
+ }
+ else
{
- $ENV{'LD_LIBRARY_PATH'}=
- "$glob_basedir/lib" .
- ($ENV{'LD_LIBRARY_PATH'} ? ":$ENV{'LD_LIBRARY_PATH'}" : "");
- $ENV{'DYLD_LIBRARY_PATH'}=
- "$glob_basedir/lib" .
- ($ENV{'DYLD_LIBRARY_PATH'} ? ":$ENV{'DYLD_LIBRARY_PATH'}" : "");
+ $extra_ld_library_paths= "$glob_basedir/lib";
}
# --------------------------------------------------------------------------
# Add the path where mysqld will find udf_example.so
# --------------------------------------------------------------------------
+ $extra_ld_library_paths .= ":" .
+ ($lib_udf_example ? dirname($lib_udf_example) : "");
+
$ENV{'LD_LIBRARY_PATH'}=
- ($lib_udf_example ? dirname($lib_udf_example) : "") .
+ "$extra_ld_library_paths" .
($ENV{'LD_LIBRARY_PATH'} ? ":$ENV{'LD_LIBRARY_PATH'}" : "");
-
+ $ENV{'DYLD_LIBRARY_PATH'}=
+ "$extra_ld_library_paths" .
+ ($ENV{'DYLD_LIBRARY_PATH'} ? ":$ENV{'DYLD_LIBRARY_PATH'}" : "");
# --------------------------------------------------------------------------
# Also command lines in .opt files may contain env vars
@@ -1284,6 +1314,7 @@ sub kill_running_server () {
mtr_report("Killing Possible Leftover Processes");
mkpath("$opt_vardir/log"); # Needed for mysqladmin log
+
mtr_kill_leftovers();
$using_ndbcluster_master= $opt_with_ndbcluster;
@@ -1292,9 +1323,7 @@ sub kill_running_server () {
}
}
-sub kill_and_cleanup () {
-
- kill_running_server ();
+sub cleanup_stale_files () {
mtr_report("Removing Stale Files");
@@ -1673,13 +1702,11 @@ sub run_suite () {
sub initialize_servers () {
if ( ! $glob_use_running_server )
{
- if ( $opt_start_dirty )
- {
- kill_running_server();
- }
- else
+ kill_running_server();
+
+ unless ( $opt_start_dirty )
{
- kill_and_cleanup();
+ cleanup_stale_files();
mysql_install_db();
if ( $opt_force )
{
@@ -2081,7 +2108,7 @@ sub run_testcase ($) {
im_create_defaults_file($instance_manager);
- im_start($instance_manager, $tinfo->{im_opts});
+ mtr_im_start($instance_manager, $tinfo->{im_opts});
}
# ----------------------------------------------------------------------
@@ -2176,10 +2203,9 @@ sub run_testcase ($) {
# Stop Instance Manager if we are processing an IM-test case.
# ----------------------------------------------------------------------
- if ( ! $glob_use_running_server and $tinfo->{'component_id'} eq 'im' and
- $instance_manager->{'pid'} )
+ if ( ! $glob_use_running_server and $tinfo->{'component_id'} eq 'im' )
{
- im_stop($instance_manager);
+ mtr_im_stop($instance_manager);
}
}
@@ -2707,11 +2733,8 @@ sub stop_masters_slaves () {
print "Ending Tests\n";
- if ( $instance_manager->{'pid'} )
- {
- print "Shutting-down Instance Manager\n";
- im_stop($instance_manager);
- }
+ print "Shutting-down Instance Manager\n";
+ mtr_im_stop($instance_manager);
print "Shutting-down MySQL daemon\n\n";
stop_masters();
@@ -2773,201 +2796,6 @@ sub stop_slaves () {
mtr_stop_mysqld_servers(\@args);
}
-##############################################################################
-#
-# Instance Manager management routines.
-#
-##############################################################################
-
-sub im_start($$) {
- my $instance_manager = shift;
- my $opts = shift;
-
- my $args;
- mtr_init_args(\$args);
- mtr_add_arg($args, "--defaults-file=%s",
- $instance_manager->{'defaults_file'});
-
- foreach my $opt (@{$opts})
- {
- mtr_add_arg($args, $opt);
- }
-
- $instance_manager->{'pid'} =
- mtr_spawn(
- $exe_im, # path to the executable
- $args, # cmd-line args
- '', # stdin
- $instance_manager->{'path_log'}, # stdout
- $instance_manager->{'path_err'}, # stderr
- '', # pid file path (not used)
- { append_log_file => 1 } # append log files
- );
-
- if ( ! $instance_manager->{'pid'} )
- {
- mtr_report('Could not start Instance Manager');
- return;
- }
-
- # Instance Manager can be run in daemon mode. In this case, it creates
- # several processes and the parent process, created by mtr_spawn(), exits just
- # after start. So, we have to obtain Instance Manager PID from the PID file.
-
- if ( ! sleep_until_file_created(
- $instance_manager->{'path_pid'},
- $instance_manager->{'start_timeout'},
- -1)) # real PID is still unknown
- {
- mtr_report("Instance Manager PID file is missing");
- return;
- }
-
- $instance_manager->{'pid'} =
- mtr_get_pid_from_file($instance_manager->{'path_pid'});
-}
-
-
-sub im_stop($) {
- my $instance_manager = shift;
-
- # Obtain mysqld-process pids before we start stopping IM (it can delete pid
- # files).
-
- my @mysqld_pids = ();
- my $instances = $instance_manager->{'instances'};
-
- push(@mysqld_pids, mtr_get_pid_from_file($instances->[0]->{'path_pid'}))
- if -r $instances->[0]->{'path_pid'};
-
- push(@mysqld_pids, mtr_get_pid_from_file($instances->[1]->{'path_pid'}))
- if -r $instances->[1]->{'path_pid'};
-
- # Re-read pid from the file, since during tests Instance Manager could have
- # been restarted, so its pid could have been changed.
-
- $instance_manager->{'pid'} =
- mtr_get_pid_from_file($instance_manager->{'path_pid'})
- if -f $instance_manager->{'path_pid'};
-
- if (-f $instance_manager->{'path_angel_pid'})
- {
- $instance_manager->{'angel_pid'} =
- mtr_get_pid_from_file($instance_manager->{'path_angel_pid'})
- }
- else
- {
- $instance_manager->{'angel_pid'} = undef;
- }
-
- # Inspired from mtr_stop_mysqld_servers().
-
- start_reap_all();
-
- # Try graceful shutdown.
-
- mtr_debug("IM-main pid: $instance_manager->{'pid'}");
- mtr_debug("Stopping IM-main...");
-
- mtr_kill_process($instance_manager->{'pid'}, 'TERM', 10, 1);
-
- # If necessary, wait for angel process to die.
-
- if (defined $instance_manager->{'angel_pid'})
- {
- mtr_debug("IM-angel pid: $instance_manager->{'angel_pid'}");
- mtr_debug("Waiting for IM-angel to die...");
-
- my $total_attempts= 10;
-
- for (my $cur_attempt=1; $cur_attempt <= $total_attempts; ++$cur_attempt)
- {
- unless (kill (0, $instance_manager->{'angel_pid'}))
- {
- mtr_debug("IM-angel died.");
- last;
- }
-
- sleep(1);
- }
- }
-
- # Check that all processes died.
-
- my $clean_shutdown= 0;
-
- while (1)
- {
- if (kill (0, $instance_manager->{'pid'}))
- {
- mtr_debug("IM-main is still alive.");
- last;
- }
-
- if (defined $instance_manager->{'angel_pid'} &&
- kill (0, $instance_manager->{'angel_pid'}))
- {
- mtr_debug("IM-angel is still alive.");
- last;
- }
-
- foreach my $pid (@mysqld_pids)
- {
- if (kill (0, $pid))
- {
- mtr_debug("Guarded mysqld ($pid) is still alive.");
- last;
- }
- }
-
- $clean_shutdown= 1;
- last;
- }
-
- # Kill leftovers (the order is important).
-
- unless ($clean_shutdown)
- {
-
- if (defined $instance_manager->{'angel_pid'})
- {
- mtr_debug("Killing IM-angel...");
- mtr_kill_process($instance_manager->{'angel_pid'}, 'KILL', 10, 1)
- }
-
- mtr_debug("Killing IM-main...");
- mtr_kill_process($instance_manager->{'pid'}, 'KILL', 10, 1);
-
- # Shutdown managed mysqld-processes. Some of them may be nonguarded, so IM
- # will not stop them on shutdown. So, we should firstly try to end them
- # legally.
-
- mtr_debug("Killing guarded mysqld(s)...");
- mtr_kill_processes(\@mysqld_pids);
-
- # Complain in error log so that a warning will be shown.
-
- my $errlog= "$opt_vardir/log/mysql-test-run.pl.err";
-
- open (ERRLOG, ">>$errlog") ||
- mtr_error("Can not open error log ($errlog)");
-
- my $ts= localtime();
- print ERRLOG
- "Warning: [$ts] Instance Manager did not shutdown gracefully.\n";
-
- close ERRLOG;
- }
-
- # That's all.
-
- stop_reap_all();
-
- $instance_manager->{'pid'} = undef;
- $instance_manager->{'angel_pid'} = undef;
-}
-
-
#
# Run include/check-testcase.test
# Before a testcase, run in record mode, save result file to var
@@ -3103,6 +2931,7 @@ sub run_mysqltest ($) {
$ENV{'MYSQL_MY_PRINT_DEFAULTS'}= $exe_my_print_defaults;
$ENV{'UDF_EXAMPLE_LIB'}=
($lib_udf_example ? basename($lib_udf_example) : "");
+ $ENV{'MY_PERROR'}= $exe_perror;
$ENV{'NDB_MGM'}= $exe_ndb_mgm;
$ENV{'NDB_BACKUP_DIR'}= $path_ndb_data_dir;
diff --git a/mysql-test/r/analyse.result b/mysql-test/r/analyse.result
index f4e547dbc66..56f67cce4d6 100644
--- a/mysql-test/r/analyse.result
+++ b/mysql-test/r/analyse.result
@@ -39,10 +39,10 @@ t2 CREATE TABLE `t2` (
`Field_name` varbinary(255) NOT NULL default '',
`Min_value` varbinary(255) default NULL,
`Max_value` varbinary(255) default NULL,
- `Min_length` bigint(11) NOT NULL default '0',
- `Max_length` bigint(11) NOT NULL default '0',
- `Empties_or_zeros` bigint(11) NOT NULL default '0',
- `Nulls` bigint(11) NOT NULL default '0',
+ `Min_length` int(11) NOT NULL default '0',
+ `Max_length` int(11) NOT NULL default '0',
+ `Empties_or_zeros` int(11) NOT NULL default '0',
+ `Nulls` int(11) NOT NULL default '0',
`Avg_value_or_avg_length` varbinary(255) NOT NULL default '',
`Std` varbinary(255) default NULL,
`Optimal_fieldtype` varbinary(64) NOT NULL default ''
@@ -58,10 +58,10 @@ t2 CREATE TABLE `t2` (
`Field_name` varbinary(255) NOT NULL default '',
`Min_value` varbinary(255) default NULL,
`Max_value` varbinary(255) default NULL,
- `Min_length` bigint(11) NOT NULL default '0',
- `Max_length` bigint(11) NOT NULL default '0',
- `Empties_or_zeros` bigint(11) NOT NULL default '0',
- `Nulls` bigint(11) NOT NULL default '0',
+ `Min_length` int(11) NOT NULL default '0',
+ `Max_length` int(11) NOT NULL default '0',
+ `Empties_or_zeros` int(11) NOT NULL default '0',
+ `Nulls` int(11) NOT NULL default '0',
`Avg_value_or_avg_length` varbinary(255) NOT NULL default '',
`Std` varbinary(255) default NULL,
`Optimal_fieldtype` varbinary(64) NOT NULL default ''
@@ -81,10 +81,10 @@ t2 CREATE TABLE `t2` (
`Field_name` varbinary(255) NOT NULL default '',
`Min_value` varbinary(255) default NULL,
`Max_value` varbinary(255) default NULL,
- `Min_length` bigint(11) NOT NULL default '0',
- `Max_length` bigint(11) NOT NULL default '0',
- `Empties_or_zeros` bigint(11) NOT NULL default '0',
- `Nulls` bigint(11) NOT NULL default '0',
+ `Min_length` int(11) NOT NULL default '0',
+ `Max_length` int(11) NOT NULL default '0',
+ `Empties_or_zeros` int(11) NOT NULL default '0',
+ `Nulls` int(11) NOT NULL default '0',
`Avg_value_or_avg_length` varbinary(255) NOT NULL default '',
`Std` varbinary(255) default NULL,
`Optimal_fieldtype` varbinary(64) NOT NULL default ''
diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result
index afbff905699..d0058118e4c 100644
--- a/mysql-test/r/auto_increment.result
+++ b/mysql-test/r/auto_increment.result
@@ -232,7 +232,7 @@ a b
delete from t1 where a=0;
update t1 set a=NULL where b=6;
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' at row 4
+Warning 1263 Column was set to data type implicit default; NULL supplied for 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);
@@ -274,7 +274,7 @@ a b
delete from t1 where a=0;
update t1 set a=NULL where b=13;
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' at row 9
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'a' at row 9
update t1 set a=500 where b=14;
select * from t1 order by b;
a b
diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result
index 3cdf4b17027..edc18319603 100644
--- a/mysql-test/r/bigint.result
+++ b/mysql-test/r/bigint.result
@@ -174,7 +174,7 @@ create table t1 select 1 as 'a';
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `a` bigint(1) NOT NULL default '0'
+ `a` int(1) NOT NULL default '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 select 9223372036854775809 as 'a';
diff --git a/mysql-test/r/case_sensitive_file_system.require b/mysql-test/r/case_sensitive_file_system.require
new file mode 100644
index 00000000000..d0bdc6bf4ce
--- /dev/null
+++ b/mysql-test/r/case_sensitive_file_system.require
@@ -0,0 +1,2 @@
+Variable_name Value
+lower_case_file_system OFF
diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result
index d60efa083e0..a07ca21652b 100644
--- a/mysql-test/r/cast.result
+++ b/mysql-test/r/cast.result
@@ -381,3 +381,14 @@ DROP TABLE t1;
select cast(NULL as decimal(6)) as t1;
t1
NULL
+set names latin1;
+select hex(cast('a' as char(2) binary));
+hex(cast('a' as char(2) binary))
+61
+select hex(cast('a' as binary(2)));
+hex(cast('a' as binary(2)))
+6100
+select hex(cast('a' as char(2) binary));
+hex(cast('a' as char(2) binary))
+61
+End of 5.0 tests
diff --git a/mysql-test/r/client_xml.result b/mysql-test/r/client_xml.result
index 24c05c7f9d6..7395b2433e8 100644
--- a/mysql-test/r/client_xml.result
+++ b/mysql-test/r/client_xml.result
@@ -68,7 +68,7 @@ insert into t1 values (1, 2, 'a&b a<b a>b');
<resultset statement="select null from dual
">
<row>
- <field name="NULL">NULL</field>
+ <field name="NULL" xsi:nil="true" />
</row>
</resultset>
drop table t1;
diff --git a/mysql-test/r/compare.result b/mysql-test/r/compare.result
index 6f667aabac0..da0ca8ddba1 100644
--- a/mysql-test/r/compare.result
+++ b/mysql-test/r/compare.result
@@ -42,3 +42,10 @@ CHAR(31) = '' '' = CHAR(31)
SELECT CHAR(30) = '', '' = CHAR(30);
CHAR(30) = '' '' = CHAR(30)
0 0
+create table t1 (a tinyint(1),b binary(1));
+insert into t1 values (0x01,0x01);
+select * from t1 where a=b;
+a b
+select * from t1 where a=b and b=0x01;
+a b
+drop table if exists t1;
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index c5b77ea4925..5f885ad199b 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -13,7 +13,7 @@ Warnings:
Note 1050 Table 't1' already exists
insert into t1 values (""),(null);
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'b' at row 2
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'b' at row 2
select * from t1;
b
@@ -452,7 +452,7 @@ t2 CREATE TABLE `t2` (
`ifnull(h,h)` decimal(5,4) default NULL,
`ifnull(i,i)` year(4) default NULL,
`ifnull(j,j)` date default NULL,
- `ifnull(k,k)` datetime NOT NULL default '0000-00-00 00:00:00',
+ `ifnull(k,k)` timestamp NOT NULL default '0000-00-00 00:00:00',
`ifnull(l,l)` datetime default NULL,
`ifnull(m,m)` varchar(1) default NULL,
`ifnull(n,n)` varchar(3) default NULL,
@@ -668,7 +668,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`b` int(11) NOT NULL,
`a` varchar(12) character set utf8 collate utf8_bin NOT NULL,
- `c` bigint(1) NOT NULL default '0',
+ `c` int(1) NOT NULL default '0',
PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
@@ -681,7 +681,7 @@ Table Create Table
t1 CREATE TABLE `t1` (
`b` int(11) default NULL,
`a` varchar(12) character set utf8 collate utf8_bin NOT NULL,
- `c` bigint(1) NOT NULL default '0',
+ `c` int(1) NOT NULL default '0',
PRIMARY KEY (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
@@ -773,3 +773,5 @@ Warnings:
Warning 1071 Specified key was too long; max key length is 765 bytes
insert into t1 values('aaa');
drop table t1;
+create table t1 (upgrade int);
+drop table t1;
diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result
index 3c87c1f4b92..f3e91a663b8 100644
--- a/mysql-test/r/csv.result
+++ b/mysql-test/r/csv.result
@@ -5000,3 +5000,13 @@ insert t1 values (1),(2),(3),(4),(5);
truncate table t1;
affected rows: 0
drop table t1;
+create table bug15205 (val int(11) default null) engine=csv;
+create table bug15205_2 (val int(11) default null) engine=csv;
+select * from bug15205;
+ERROR HY000: Got error 1 from storage engine
+select * from bug15205_2;
+val
+select * from bug15205;
+val
+drop table bug15205;
+drop table bug15205_2;
diff --git a/mysql-test/r/ctype_cp1250_ch.result b/mysql-test/r/ctype_cp1250_ch.result
index 533bfb8cb53..b55849e4e12 100644
--- a/mysql-test/r/ctype_cp1250_ch.result
+++ b/mysql-test/r/ctype_cp1250_ch.result
@@ -42,3 +42,11 @@ id str
6 aaaaaa
7 aaaaaaa
drop table t1;
+set names cp1250;
+create table t1 (a varchar(15) collate cp1250_czech_cs NOT NULL, primary key(a));
+insert into t1 values("abcdefghá");
+insert into t1 values("ááèè");
+select a from t1 where a like "abcdefghá";
+a
+abcdefghá
+drop table t1;
diff --git a/mysql-test/r/ctype_gbk.result b/mysql-test/r/ctype_gbk.result
index 241539ecf42..3f5d8b0d8c6 100644
--- a/mysql-test/r/ctype_gbk.result
+++ b/mysql-test/r/ctype_gbk.result
@@ -168,3 +168,13 @@ DROP TABLE t1;
select hex(convert(_gbk 0xA14041 using ucs2));
hex(convert(_gbk 0xA14041 using ucs2))
003F0041
+create table t1 (c1 text not null, c2 text not null) character set gbk;
+alter table t1 change c1 c1 mediumtext character set gbk not null;
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` mediumtext NOT NULL,
+ `c2` text NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=gbk
+drop table t1;
+End of 5.0 tests
diff --git a/mysql-test/r/ctype_recoding.result b/mysql-test/r/ctype_recoding.result
index 996f6fa8645..4e145346081 100644
--- a/mysql-test/r/ctype_recoding.result
+++ b/mysql-test/r/ctype_recoding.result
@@ -248,3 +248,14 @@ select rpad(c1,3,'ö'), rpad('ö',3,c1) from t1;
rpad(c1,3,'ö') rpad('ö',3,c1)
ßöö ößß
drop table t1;
+set names koi8r;
+create table t1(a char character set cp1251 default _koi8r 0xFF);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(1) character set cp1251 default 'ÿ'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1(a char character set latin1 default _cp1251 0xFF);
+ERROR 42000: Invalid default value for 'a'
+End of 4.1 tests
diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result
index 890cdfd5cfc..3b6bfa6d776 100644
--- a/mysql-test/r/ctype_ucs.result
+++ b/mysql-test/r/ctype_ucs.result
@@ -730,6 +730,45 @@ id MIN(s)
1 ZZZ
2 ZZZ
DROP TABLE t1;
+drop table if exists bug20536;
+set names latin1;
+create table bug20536 (id bigint not null auto_increment primary key, name
+varchar(255) character set ucs2 not null);
+insert into `bug20536` (`id`,`name`) values (1, _latin1 x'7465737431'), (2, "'test\\_2'");
+select md5(name) from bug20536;
+md5(name)
+f4b7ce8b45a20e3c4e84bef515d1525c
+48d95db0d8305c2fe11548a3635c9385
+select sha1(name) from bug20536;
+sha1(name)
+e0b52f38deddb9f9e8d5336b153592794cb49baf
+677d4d505355eb5b0549b865fcae4b7f0c28aef5
+select make_set(3, name, upper(name)) from bug20536;
+make_set(3, name, upper(name))
+test1,TEST1
+'test\_2','TEST\_2'
+select export_set(5, name, upper(name)) from bug20536;
+export_set(5, name, upper(name))
+test1,TEST1,test1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1,TEST1
+'test\_2','TEST\_2','test\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2','TEST\_2'
+select export_set(5, name, upper(name), ",", 5) from bug20536;
+export_set(5, name, upper(name), ",", 5)
+test1,TEST1,test1,TEST1,TEST1
+'test\_2','TEST\_2','test\_2','TEST\_2','TEST\_2'
+select password(name) from bug20536;
+password(name)
+????????????????????
+????????????????????
+select old_password(name) from bug20536;
+old_password(name)
+????????
+????????
+select quote(name) from bug20536;
+quote(name)
+????????
+????????????????
+drop table bug20536;
+End of 4.1 tests
CREATE TABLE t1 (a varchar(64) character set ucs2, b decimal(10,3));
INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0);
update t1 set b=a;
@@ -765,3 +804,4 @@ blob 65535 65535
text 65535 65535
text 65535 32767
drop table t1;
+End of 5.0 tests
diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result
index 934f56877ac..4267df8d176 100644
--- a/mysql-test/r/ctype_utf8.result
+++ b/mysql-test/r/ctype_utf8.result
@@ -924,6 +924,37 @@ NULL
select ifnull(NULL, _utf8'string');
ifnull(NULL, _utf8'string')
string
+set names utf8;
+create table t1 (s1 char(5) character set utf8 collate utf8_lithuanian_ci);
+insert into t1 values ('I'),('K'),('Y');
+select * from t1 where s1 < 'K' and s1 = 'Y';
+s1
+I
+Y
+select * from t1 where 'K' > s1 and s1 = 'Y';
+s1
+I
+Y
+drop table t1;
+create table t1 (s1 char(5) character set utf8 collate utf8_czech_ci);
+insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i');
+select * from t1 where s1 > 'd' and s1 = 'CH';
+s1
+ch
+CH
+Ch
+select * from t1 where 'd' < s1 and s1 = 'CH';
+s1
+ch
+CH
+Ch
+select * from t1 where s1 = 'cH' and s1 <> 'ch';
+s1
+cH
+select * from t1 where 'cH' = s1 and s1 <> 'ch';
+s1
+cH
+drop table t1;
create table t1 (a varchar(255)) default character set utf8;
insert into t1 values (1.0);
drop table t1;
@@ -1066,6 +1097,18 @@ LENGTH(bug)
100
DROP TABLE t2;
DROP TABLE t1;
+CREATE TABLE t1 (item varchar(255)) default character set utf8;
+INSERT INTO t1 VALUES (N'\\');
+INSERT INTO t1 VALUES (_utf8'\\');
+INSERT INTO t1 VALUES (N'Cote d\'Ivoire');
+INSERT INTO t1 VALUES (_utf8'Cote d\'Ivoire');
+SELECT item FROM t1 ORDER BY item;
+item
+Cote d'Ivoire
+Cote d'Ivoire
+\
+\
+DROP TABLE t1;
SET NAMES utf8;
DROP TABLE IF EXISTS t1;
Warnings:
@@ -1281,6 +1324,35 @@ id tid val
42749 72 VOLNÝ ADSL
44205 72 VOLNÝ ADSL
DROP TABLE t1;
+create table t1(a char(200) collate utf8_unicode_ci NOT NULL default '')
+default charset=utf8 collate=utf8_unicode_ci;
+insert into t1 values (unhex('65')), (unhex('C3A9')), (unhex('65'));
+explain select distinct a from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using temporary
+select distinct a from t1;
+a
+e
+explain select a 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 3 Using temporary; Using filesort
+select a from t1 group by a;
+a
+e
+drop table t1;
+set names utf8;
+grant select on test.* to юзер_юзер@localhost;
+user()
+юзер_юзер@localhost
+revoke all on test.* from юзер_юзер@localhost;
+drop user юзер_юзер@localhost;
+create database имÑ_базы_в_кодировке_утф8_длиной_больше_чем_45;
+use имÑ_базы_в_кодировке_утф8_длиной_больше_чем_45;
+select database();
+database()
+имÑ_базы_в_кодировке_утф8_длиной_больше_чем_45
+drop database имÑ_базы_в_кодировке_утф8_длиной_больше_чем_45;
+use test;
CREATE TABLE t1(id varchar(20) NOT NULL) DEFAULT CHARSET=utf8;
INSERT INTO t1 VALUES ('xxx'), ('aa'), ('yyy'), ('aa');
SELECT id FROM t1;
@@ -1390,3 +1462,21 @@ set @a:=null;
execute my_stmt using @a;
a b
drop table if exists t1;
+CREATE TABLE t1 (
+colA int(11) NOT NULL,
+colB varchar(255) character set utf8 NOT NULL,
+PRIMARY KEY (colA)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+INSERT INTO t1 (colA, colB) VALUES (1, 'foo'), (2, 'foo bar');
+CREATE TABLE t2 (
+colA int(11) NOT NULL,
+colB varchar(255) character set utf8 NOT NULL,
+KEY bad (colA,colB(3))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar');
+SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB
+WHERE t1.colA < 3;
+colA colB colA colB
+1 foo 1 foo
+2 foo bar 2 foo bar
+DROP TABLE t1, t2;
diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result
index 45078800910..bbe3aee1fb0 100644
--- a/mysql-test/r/date_formats.result
+++ b/mysql-test/r/date_formats.result
@@ -449,6 +449,8 @@ create table t1 select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%
str_to_date("10:11:12.0012", "%H:%i:%S.%f") as f2,
str_to_date("2003-01-02", "%Y-%m-%d") as f3,
str_to_date("02", "%d") as f4, str_to_date("02 10", "%d %H") as f5;
+Warnings:
+Warning 1265 Data truncated for column 'f4' at row 1
describe t1;
Field Type Null Key Default Extra
f1 datetime YES NULL
@@ -458,7 +460,7 @@ f4 date YES NULL
f5 time YES NULL
select * from t1;
f1 f2 f3 f4 f5
-2003-01-02 10:11:12 10:11:12 2003-01-02 0000-00-02 58:00:00
+2003-01-02 10:11:12 10:11:12 2003-01-02 0000-00-00 58:00:00
drop table t1;
create table t1 select "02 10" as a, "%d %H" as b;
select str_to_date(a,b) from t1;
@@ -564,3 +566,9 @@ TIME_FORMAT("24:00:00", '%l %p')
SELECT TIME_FORMAT("25:00:00", '%l %p');
TIME_FORMAT("25:00:00", '%l %p')
1 AM
+SELECT DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896);
+DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896)
+NULL
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '%Y-%m-%d %H:%i:%s'
+"End of 4.1 tests"
diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result
index 05f1c967e77..9d337a1ed34 100644
--- a/mysql-test/r/delete.result
+++ b/mysql-test/r/delete.result
@@ -172,6 +172,10 @@ a
0
2
DROP TABLE t1;
+create table t1 (a int);
+delete `4.t1` from t1 as `4.t1` where `4.t1`.a = 5;
+delete FROM `4.t1` USING t1 as `4.t1` where `4.t1`.a = 5;
+drop table t1;
CREATE TABLE t1 (a int not null,b int not null);
CREATE TABLE t2 (a int not null, b int not null, primary key (a,b));
CREATE TABLE t3 (a int not null, b int not null, primary key (a,b));
@@ -192,3 +196,13 @@ delete t2.*,t3.* from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
select * from t3;
a b
drop table t1,t2,t3;
+create table t1(a date not null);
+insert into t1 values (0);
+select * from t1 where a is null;
+a
+0000-00-00
+delete from t1 where a is null;
+select count(*) from t1;
+count(*)
+0
+drop table t1;
diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result
index 19325731d35..8c7e39e0e90 100644
--- a/mysql-test/r/derived.result
+++ b/mysql-test/r/derived.result
@@ -276,7 +276,7 @@ select * from t1;
N M
3 0
delete P1.*,p2.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS p2 ON P1.N = p2.N;
-ERROR HY000: The target table p2 of the DELETE is not updatable
+ERROR 42S02: Unknown table 'p2' in MULTI DELETE
delete P1.* from `t1` AS P1 INNER JOIN (SELECT aaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
ERROR 42S22: Unknown column 'aaa' in 'field list'
drop table t1;
diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result
index a3d1e8bf3bb..86ab2141e2d 100644
--- a/mysql-test/r/distinct.result
+++ b/mysql-test/r/distinct.result
@@ -563,6 +563,17 @@ id IFNULL(dsc, '-')
2 line number two
3 line number three
drop table t1;
+CREATE TABLE t1 (a int primary key, b int);
+INSERT INTO t1 (a,b) values (1,1), (2,3), (3,2);
+explain SELECT DISTINCT a, b FROM t1 ORDER BY b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using filesort
+SELECT DISTINCT a, b FROM t1 ORDER BY b;
+a b
+1 1
+3 2
+2 3
+DROP TABLE t1;
CREATE TABLE t1 (
ID int(11) NOT NULL auto_increment,
x varchar(20) default NULL,
diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result
index 979e5d48871..d122dabc4ec 100644
--- a/mysql-test/r/drop.result
+++ b/mysql-test/r/drop.result
@@ -72,3 +72,16 @@ show tables;
Tables_in_test
t1
drop table t1;
+drop database if exists mysqltest;
+drop table if exists t1;
+create table t1 (i int);
+lock tables t1 read;
+create database mysqltest;
+ drop table t1;
+show open tables;
+ drop database mysqltest;
+select 1;
+1
+1
+unlock tables;
+End of 5.0 tests
diff --git a/mysql-test/r/federated.result b/mysql-test/r/federated.result
index 709e44579e2..2b44fc8bd7e 100644
--- a/mysql-test/r/federated.result
+++ b/mysql-test/r/federated.result
@@ -967,6 +967,8 @@ CREATE TABLE federated.t1 (
`blurb` text default '',
PRIMARY KEY (blurb_id))
DEFAULT CHARSET=latin1;
+Warnings:
+Warning 1101 BLOB/TEXT column 'blurb' can't have a default value
DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1 (
`blurb_id` int NOT NULL DEFAULT 0,
@@ -975,6 +977,8 @@ PRIMARY KEY (blurb_id))
ENGINE="FEDERATED"
DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1';
+Warnings:
+Warning 1101 BLOB/TEXT column 'blurb' can't have a default value
INSERT INTO federated.t1 VALUES (1, " MySQL supports a number of column types in several categories: numeric types, date and time types, and string (character) types. This chapter first gives an overview of these column types, and then provides a more detailed description of the properties of the types in each category, and a summary of the column type storage requirements. The overview is intentionally brief. The more detailed descriptions should be consulted for additional information about particular column types, such as the allowable formats in which you can specify values.");
INSERT INTO federated.t1 VALUES (2, "All arithmetic is done using signed BIGINT or DOUBLE values, so you should not use unsigned big integers larger than 9223372036854775807 (63 bits) except with bit functions! If you do that, some of the last digits in the result may be wrong because of rounding errors when converting a BIGINT value to a DOUBLE.");
INSERT INTO federated.t1 VALUES (3, " A floating-point number. p represents the precision. It can be from 0 to 24 for a single-precision floating-point number and from 25 to 53 for a double-precision floating-point number. These types are like the FLOAT and DOUBLE types described immediately following. FLOAT(p) has the same range as the corresponding FLOAT and DOUBLE types, but the display size and number of decimals are undefined. ");
@@ -1689,6 +1693,44 @@ id c1 c2
9 abc ppc
drop table federated.t1, federated.t2;
drop table federated.t1, federated.t2;
+DROP TABLE IF EXISTS federated.test;
+CREATE TABLE federated.test (
+`id` int(11) NOT NULL,
+`val1` varchar(255) NOT NULL,
+`val2` varchar(255) NOT NULL,
+PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+DROP TABLE IF EXISTS federated.test_local;
+DROP TABLE IF EXISTS federated.test_remote;
+CREATE TABLE federated.test_local (
+`id` int(11) NOT NULL,
+`val1` varchar(255) NOT NULL,
+`val2` varchar(255) NOT NULL,
+PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+INSERT INTO federated.test_local VALUES (1, 'foo', 'bar'),
+(2, 'bar', 'foo');
+CREATE TABLE federated.test_remote (
+`id` int(11) NOT NULL,
+`val1` varchar(255) NOT NULL,
+`val2` varchar(255) NOT NULL,
+PRIMARY KEY (`id`)
+) ENGINE=FEDERATED DEFAULT CHARSET=latin1
+CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/test';
+insert into federated.test_remote select * from federated.test_local;
+select * from federated.test_remote;
+id val1 val2
+1 foo bar
+2 bar foo
+delete from federated.test_remote where id in (1,2);
+insert into federated.test_remote select * from federated.test_local;
+select * from federated.test_remote;
+id val1 val2
+2 bar foo
+1 foo bar
+DROP TABLE federated.test_local;
+DROP TABLE federated.test_remote;
+DROP TABLE federated.test;
drop table if exists federated.t1;
create table federated.t1 (a int, b int, c int);
drop table if exists federated.t1;
@@ -1733,6 +1775,46 @@ id val
2 0
drop table t1;
drop table t1;
+create table t1 (a longblob not null);
+create table t1
+(a longblob not null) engine=federated
+connection='mysql://root@127.0.0.1:SLAVE_PORT/test/t1';
+insert into t1 values (repeat('a',5000));
+select length(a) from t1;
+length(a)
+5000
+select length(a) from t1;
+length(a)
+5000
+drop table t1;
+drop table t1;
+DROP TABLE IF EXISTS federated.test;
+CREATE TABLE federated.test (
+`i` int(11) NOT NULL,
+`j` int(11) NOT NULL,
+`c` varchar(30) default NULL,
+PRIMARY KEY (`i`,`j`),
+UNIQUE KEY `i` (`i`,`c`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+DROP TABLE IF EXISTS federated.test1;
+DROP TABLE IF EXISTS federated.test2;
+create table federated.test1 (
+i int not null,
+j int not null,
+c varchar(30),
+primary key (i,j),
+unique key (i, c))
+engine = federated
+connection='mysql://root@127.0.0.1:SLAVE_PORT/federated/test';
+create table federated.test2 (
+i int default null,
+j int not null,
+c varchar(30),
+key (i))
+engine = federated
+connection='mysql://root@127.0.0.1:SLAVE_PORT/federated/test';
+drop table federated.test1, federated.test2;
+drop table federated.test;
DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1;
diff --git a/mysql-test/r/fulltext_distinct.result b/mysql-test/r/fulltext_distinct.result
index de0668ff28c..7fd42fab646 100644
--- a/mysql-test/r/fulltext_distinct.result
+++ b/mysql-test/r/fulltext_distinct.result
@@ -8,6 +8,8 @@ KEY kt(tag),
KEY kv(value(15)),
FULLTEXT KEY kvf(value)
) ENGINE=MyISAM;
+Warnings:
+Warning 1101 BLOB/TEXT column 'value' can't have a default value
CREATE TABLE t2 (
id_t2 mediumint unsigned NOT NULL default '0',
id_t1 mediumint unsigned NOT NULL default '0',
diff --git a/mysql-test/r/fulltext_update.result b/mysql-test/r/fulltext_update.result
index 5d3f95b318c..4a615c88fdd 100644
--- a/mysql-test/r/fulltext_update.result
+++ b/mysql-test/r/fulltext_update.result
@@ -9,6 +9,8 @@ name VARCHAR(80) DEFAULT '' NOT NULL,
FULLTEXT(url,description,shortdesc,longdesc),
PRIMARY KEY(gnr)
);
+Warnings:
+Warning 1101 BLOB/TEXT column 'longdesc' can't have a default value
insert into test (url,shortdesc,longdesc,description,name) VALUES
("http:/test.at", "kurz", "lang","desc", "name");
insert into test (url,shortdesc,longdesc,description,name) VALUES
diff --git a/mysql-test/r/func_compress.result b/mysql-test/r/func_compress.result
index e3d31566741..00d5ebfc351 100644
--- a/mysql-test/r/func_compress.result
+++ b/mysql-test/r/func_compress.result
@@ -79,3 +79,31 @@ uncompress(a) uncompressed_length(a)
NULL NULL
a 1
drop table t1;
+create table t1 (a varchar(32) not null);
+insert into t1 values ('foo');
+explain select * from t1 where uncompress(a) is null;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 system NULL NULL NULL NULL 1
+Warnings:
+Error 1259 ZLIB: Input data corrupted
+select * from t1 where uncompress(a) is null;
+a
+foo
+Warnings:
+Error 1259 ZLIB: Input data corrupted
+explain select *, uncompress(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
+select *, uncompress(a) from t1;
+a uncompress(a)
+foo NULL
+Warnings:
+Error 1259 ZLIB: Input data corrupted
+select *, uncompress(a), uncompress(a) is null from t1;
+a uncompress(a) uncompress(a) is null
+foo NULL 1
+Warnings:
+Error 1259 ZLIB: Input data corrupted
+Error 1259 ZLIB: Input data corrupted
+drop table t1;
+End of 5.0 tests
diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result
index d8a539da3fe..6617ccc671e 100644
--- a/mysql-test/r/func_gconcat.result
+++ b/mysql-test/r/func_gconcat.result
@@ -566,14 +566,14 @@ COUNT(*) GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |')
DROP TABLE t1,t2;
select * from (select group_concat('c') from DUAL) t;
group_concat('c')
-NULL
+c
create table t1 ( a int not null default 0);
select * from (select group_concat(a) from t1) t2;
group_concat(a)
NULL
select group_concat('x') UNION ALL select 1;
group_concat('x')
-NULL
+x
1
drop table t1;
CREATE TABLE t1 (id int, a varchar(9));
@@ -641,3 +641,16 @@ select charset(group_concat(c1 order by c2)) from t1;
charset(group_concat(c1 order by c2))
latin1
drop table t1;
+CREATE TABLE t1 (a INT(10), b LONGTEXT, PRIMARY KEY (a));
+SET GROUP_CONCAT_MAX_LEN = 20000000;
+INSERT INTO t1 VALUES (1,REPEAT(CONCAT('A',CAST(CHAR(0) AS BINARY),'B'), 40000));
+INSERT INTO t1 SELECT a + 1, b FROM t1;
+SELECT a, CHAR_LENGTH(b) FROM t1;
+a CHAR_LENGTH(b)
+1 120000
+2 120000
+SELECT CHAR_LENGTH( GROUP_CONCAT(b) ) FROM t1;
+CHAR_LENGTH( GROUP_CONCAT(b) )
+240001
+SET GROUP_CONCAT_MAX_LEN = 1024;
+DROP TABLE t1;
diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result
index f693c6190d5..98eb9e9e2b3 100644
--- a/mysql-test/r/func_group.result
+++ b/mysql-test/r/func_group.result
@@ -856,6 +856,22 @@ EXPLAIN SELECT MAX(b) FROM t1;
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, b INT);
+INSERT INTO t1 VALUES (1,1),(1,2),(2,3);
+SELECT (SELECT COUNT(DISTINCT t1.b)) FROM t1 GROUP BY t1.a;
+(SELECT COUNT(DISTINCT t1.b))
+0
+2
+SELECT (SELECT COUNT(DISTINCT 12)) FROM t1 GROUP BY t1.a;
+(SELECT COUNT(DISTINCT 12))
+1
+1
+SELECT AVG(2), BIT_AND(2), BIT_OR(2), BIT_XOR(2), COUNT(*), COUNT(12),
+COUNT(DISTINCT 12), MIN(2),MAX(2),STD(2), VARIANCE(2),SUM(2),
+GROUP_CONCAT(2),GROUP_CONCAT(DISTINCT 2);
+AVG(2) BIT_AND(2) BIT_OR(2) BIT_XOR(2) COUNT(*) COUNT(12) COUNT(DISTINCT 12) MIN(2) MAX(2) STD(2) VARIANCE(2) SUM(2) GROUP_CONCAT(2) GROUP_CONCAT(DISTINCT 2)
+2.00000 2 2 2 1 1 1 2 2 0.00000 0.00000 2 2 2
+DROP TABLE t1;
create table t2 (ff double);
insert into t2 values (2.2);
select cast(sum(distinct ff) as decimal(5,2)) from t2;
@@ -988,3 +1004,28 @@ SUM(a)
6
DROP TABLE t1;
set div_precision_increment= @sav_dpi;
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT);
+INSERT INTO t1 VALUES (1,1), (2,2);
+CREATE TABLE t2 (a INT PRIMARY KEY, b INT);
+INSERT INTO t2 VALUES (1,1), (3,3);
+SELECT SQL_NO_CACHE
+(SELECT SUM(c.a) FROM t1 ttt, t2 ccc
+WHERE ttt.a = ccc.b AND ttt.a = t.a GROUP BY ttt.a) AS minid
+FROM t1 t, t2 c WHERE t.a = c.b;
+minid
+NULL
+DROP TABLE t1,t2;
+create table t1 select variance(0);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `variance(0)` double(8,4) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1 select stddev(0);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `stddev(0)` double(8,4) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result
index 33e642c74c4..f0262acd71e 100644
--- a/mysql-test/r/func_misc.result
+++ b/mysql-test/r/func_misc.result
@@ -87,6 +87,10 @@ SELECT IS_USED_LOCK('bug16501');
IS_USED_LOCK('bug16501')
NULL
DROP TABLE t1;
+select export_set(3, _latin1'foo', _utf8'bar', ',', 4);
+export_set(3, _latin1'foo', _utf8'bar', ',', 4)
+foo,foo,bar,bar
+End of 4.1 tests
create table t1 as select uuid(), length(uuid());
show create table t1;
Table Create Table
@@ -130,3 +134,4 @@ timediff(b, a) >= '00:00:03'
drop table t2;
drop table t1;
set global query_cache_size=default;
+End of 5.0 tests
diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result
index 1042840fe04..00642e1a570 100644
--- a/mysql-test/r/func_str.result
+++ b/mysql-test/r/func_str.result
@@ -1041,6 +1041,49 @@ select * from t1 where f1='test' and (f2= sha("TEST") or f2= sha("test"));
f1 f2
test a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
drop table t1;
+CREATE TABLE t1 (a varchar(10));
+INSERT INTO t1 VALUES ('abc'), ('xyz');
+SELECT a, CONCAT(a,' ',a) AS c FROM t1
+HAVING LEFT(c,LENGTH(c)-INSTR(REVERSE(c)," ")) = a;
+a c
+abc abc abc
+xyz xyz xyz
+SELECT a, CONCAT(a,' ',a) AS c FROM t1
+HAVING LEFT(CONCAT(a,' ',a),
+LENGTH(CONCAT(a,' ',a))-
+INSTR(REVERSE(CONCAT(a,' ',a))," ")) = a;
+a c
+abc abc abc
+xyz xyz xyz
+DROP TABLE t1;
+CREATE TABLE t1 (s varchar(10));
+INSERT INTO t1 VALUES ('yadda'), ('yaddy');
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(s) > 'ab';
+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 `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(`test`.`t1`.`s`) > _latin1'ab')
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM('y' FROM s) > 'ab';
+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 `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(both _latin1'y' from `test`.`t1`.`s`) > _latin1'ab')
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(LEADING 'y' FROM s) > 'ab';
+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 `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(leading _latin1'y' from `test`.`t1`.`s`) > _latin1'ab')
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(TRAILING 'y' FROM s) > 'ab';
+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 `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(trailing _latin1'y' from `test`.`t1`.`s`) > _latin1'ab')
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(BOTH 'y' FROM s) > 'ab';
+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 `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(both _latin1'y' from `test`.`t1`.`s`) > _latin1'ab')
+DROP TABLE t1;
End of 4.1 tests
create table t1 (d decimal default null);
insert into t1 values (null);
@@ -1070,4 +1113,39 @@ conv("18383815659218730760",10,10) + 0
select "18383815659218730760" + 0;
"18383815659218730760" + 0
1.8383815659219e+19
+CREATE TABLE t1 (code varchar(10));
+INSERT INTO t1 VALUES ('a12'), ('A12'), ('a13');
+SELECT ASCII(code), code FROM t1 WHERE code='A12';
+ASCII(code) code
+97 a12
+65 A12
+SELECT ASCII(code), code FROM t1 WHERE code='A12' AND ASCII(code)=65;
+ASCII(code) code
+65 A12
+INSERT INTO t1 VALUES ('a12 '), ('A12 ');
+SELECT LENGTH(code), code FROM t1 WHERE code='A12';
+LENGTH(code) code
+3 a12
+3 A12
+4 a12
+5 A12
+SELECT LENGTH(code), code FROM t1 WHERE code='A12' AND LENGTH(code)=5;
+LENGTH(code) code
+5 A12
+ALTER TABLE t1 ADD INDEX (code);
+CREATE TABLE t2 (id varchar(10) PRIMARY KEY);
+INSERT INTO t2 VALUES ('a11'), ('a12'), ('a13'), ('a14');
+SELECT * FROM t1 INNER JOIN t2 ON t1.code=t2.id
+WHERE t2.id='a12' AND (LENGTH(code)=5 OR code < 'a00');
+code id
+A12 a12
+EXPLAIN EXTENDED
+SELECT * FROM t1 INNER JOIN t2 ON code=id
+WHERE id='a12' AND (LENGTH(code)=5 OR code < 'a00');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref code code 13 const 3 Using where; Using index
+1 SIMPLE t2 ref PRIMARY PRIMARY 12 const 1 Using where; Using index
+Warnings:
+Note 1003 select `test`.`t1`.`code` AS `code`,`test`.`t2`.`id` AS `id` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`code` = _latin1'a12') and (`test`.`t2`.`id` = _latin1'a12') and (length(`test`.`t1`.`code`) = 5))
+DROP TABLE t1,t2;
End of 5.0 tests
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result
index 66fe355ffce..9fea857e4e5 100644
--- a/mysql-test/r/func_time.result
+++ b/mysql-test/r/func_time.result
@@ -667,6 +667,78 @@ timestampdiff(SQL_TSI_DAY, '1996-02-01', '1996-03-01') as a3,
timestampdiff(SQL_TSI_DAY, '2000-02-01', '2000-03-01') as a4;
a1 a2 a3 a4
28 28 29 29
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:27');
+TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:27')
+0
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:28');
+TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:28')
+1
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:29');
+TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:29')
+1
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:27');
+TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:27')
+1
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:28');
+TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:28')
+2
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:29');
+TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:29')
+2
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:27');
+TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:27')
+0
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:28');
+TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:28')
+1
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:29');
+TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:29')
+1
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:27');
+TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:27')
+1
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:28');
+TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:28')
+2
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:29');
+TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:29')
+2
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:27');
+TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:27')
+0
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:28');
+TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:28')
+1
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:29');
+TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:29')
+1
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:27');
+TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:27')
+1
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:28');
+TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:28')
+2
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:29');
+TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:29')
+2
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:27');
+TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:27')
+0
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:28');
+TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:28')
+1
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:29');
+TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:29')
+1
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:27');
+TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:27')
+1
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:28');
+TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:28')
+2
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29');
+TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29')
+2
select date_add(time,INTERVAL 1 SECOND) from t1;
date_add(time,INTERVAL 1 SECOND)
NULL
@@ -758,42 +830,48 @@ select monthname(str_to_date(null, '%m')), monthname(str_to_date(null, '%m')),
monthname(str_to_date(1, '%m')), monthname(str_to_date(0, '%m'));
monthname(str_to_date(null, '%m')) monthname(str_to_date(null, '%m')) monthname(str_to_date(1, '%m')) monthname(str_to_date(0, '%m'))
NULL NULL January NULL
+set time_zone='-6:00';
+create table t1(a timestamp);
+insert into t1 values (19691231190001);
+select * from t1;
+a
+1969-12-31 19:00:01
+drop table t1;
create table t1(f1 date, f2 time, f3 datetime);
insert into t1 values ("2006-01-01", "12:01:01", "2006-01-01 12:01:01");
insert into t1 values ("2006-01-02", "12:01:02", "2006-01-02 12:01:02");
-select f1 from t1 where f1 between "2006-1-1" and 20060101;
+select f1 from t1 where f1 between CAST("2006-1-1" as date) and CAST(20060101 as date);
f1
2006-01-01
-select f1 from t1 where f1 between "2006-1-1" and "2006.1.1";
+select f1 from t1 where f1 between cast("2006-1-1" as date) and cast("2006.1.1" as date);
f1
2006-01-01
-select f1 from t1 where date(f1) between "2006-1-1" and "2006.1.1";
+select f1 from t1 where date(f1) between cast("2006-1-1" as date) and cast("2006.1.1" as date);
f1
2006-01-01
-select f2 from t1 where f2 between "12:1:2" and "12:2:2";
+select f2 from t1 where f2 between cast("12:1:2" as time) and cast("12:2:2" as time);
f2
12:01:02
-select f2 from t1 where time(f2) between "12:1:2" and "12:2:2";
+select f2 from t1 where time(f2) between cast("12:1:2" as time) and cast("12:2:2" as time);
f2
12:01:02
-select f3 from t1 where f3 between "2006-1-1 12:1:1" and "2006-1-1 12:1:2";
+select f3 from t1 where f3 between cast("2006-1-1 12:1:1" as datetime) and cast("2006-1-1 12:1:2" as datetime);
f3
2006-01-01 12:01:01
-select f3 from t1 where timestamp(f3) between "2006-1-1 12:1:1" and "2006-1-1 12:1:2";
+select f3 from t1 where timestamp(f3) between cast("2006-1-1 12:1:1" as datetime) and cast("2006-1-1 12:1:2" as datetime);
f3
2006-01-01 12:01:01
-select f1 from t1 where "2006-1-1" between f1 and f3;
+select f1 from t1 where cast("2006-1-1" as date) between f1 and f3;
f1
2006-01-01
-select f1 from t1 where "2006-1-1" between date(f1) and date(f3);
+select f1 from t1 where cast("2006-1-1" as date) between date(f1) and date(f3);
f1
2006-01-01
-select f1 from t1 where "2006-1-1" between f1 and 'zzz';
+select f1 from t1 where cast("2006-1-1" as date) between f1 and cast('zzz' as date);
f1
Warnings:
-Warning 1292 Incorrect date value: 'zzz' for column 'f1' at row 1
-Warning 1292 Truncated incorrect DOUBLE value: 'zzz'
-Warning 1292 Truncated incorrect DOUBLE value: 'zzz'
+Warning 1292 Truncated incorrect datetime value: 'zzz'
+Warning 1292 Truncated incorrect datetime value: 'zzz'
select f1 from t1 where makedate(2006,1) between date(f1) and date(f3);
f1
2006-01-01
@@ -812,6 +890,27 @@ t1 CREATE TABLE `t1` (
`from_unixtime(1) + 0` double(23,6) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H)
+union
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H);
+H
+120
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H)
+union
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H);
+H
+120
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H)
+union
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H);
+H
+05
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H)
+union
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H);
+H
+5
+End of 4.1 tests
explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,
timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2;
id select_type table type possible_keys key key_len ref rows Extra
@@ -953,3 +1052,15 @@ id day id day
3 2005-07-01 3 2005-07-15
DROP TABLE t1,t2;
set time_zone= @@global.time_zone;
+SET NAMES latin1;
+SET character_set_results = NULL;
+SHOW VARIABLES LIKE 'character_set_results';
+Variable_name Value
+character_set_results
+CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32) CHARACTER SET BINARY);
+INSERT INTO testBug8868 VALUES ('2006-09-04', 'abcd');
+SELECT DATE_FORMAT(field1,'%b-%e %l:%i%p') as fmtddate, field2 FROM testBug8868;
+fmtddate field2
+Sep-4 12:00AM abcd
+DROP TABLE testBug8868;
+SET NAMES DEFAULT;
diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result
index 28c59053435..b283d64395d 100644
--- a/mysql-test/r/gis-rtree.result
+++ b/mysql-test/r/gis-rtree.result
@@ -804,6 +804,8 @@ INSERT INTO t2 SELECT GeomFromText(st) FROM t1;
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1, t2;
CREATE TABLE t1 (`geometry` geometry NOT NULL default '',SPATIAL KEY `gndx` (`geometry`(32))) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+Warnings:
+Warning 1101 BLOB/TEXT column 'geometry' can't have a default value
INSERT INTO t1 (geometry) VALUES
(PolygonFromText('POLYGON((-18.6086111000 -66.9327777000, -18.6055555000
-66.8158332999, -18.7186111000 -66.8102777000, -18.7211111000 -66.9269443999,
@@ -820,6 +822,8 @@ CREATE TABLE t1 (
c1 geometry NOT NULL default '',
SPATIAL KEY i1 (c1(32))
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+Warnings:
+Warning 1101 BLOB/TEXT column 'c1' can't have a default value
INSERT INTO t1 (c1) VALUES (
PolygonFromText('POLYGON((-18.6086111000 -66.9327777000,
-18.6055555000 -66.8158332999,
@@ -834,6 +838,8 @@ CREATE TABLE t1 (
c1 geometry NOT NULL default '',
SPATIAL KEY i1 (c1(32))
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+Warnings:
+Warning 1101 BLOB/TEXT column 'c1' can't have a default value
INSERT INTO t1 (c1) VALUES (
PolygonFromText('POLYGON((-18.6086111000 -66.9327777000,
-18.6055555000 -66.8158332999,
diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result
index 7a0f689df36..46aecde2cc5 100644
--- a/mysql-test/r/gis.result
+++ b/mysql-test/r/gis.result
@@ -574,15 +574,17 @@ INSERT INTO t1 VALUES(GeomFromText('POINT(367894677 368542487)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(580848489 219587743)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(11247614 782797569)'));
drop table t1;
-create table t1 select POINT(1,3);
+create table t1 select GeomFromWKB(POINT(1,3));
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `POINT(1,3)` longblob NOT NULL
+ `GeomFromWKB(POINT(1,3))` geometry NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
CREATE TABLE `t1` (`object_id` bigint(20) unsigned NOT NULL default '0', `geo`
geometry NOT NULL default '') ENGINE=MyISAM ;
+Warnings:
+Warning 1101 BLOB/TEXT column 'geo' can't have a default value
insert into t1 values ('85984',GeomFromText('MULTIPOLYGON(((-115.006363
36.305435,-114.992394 36.305202,-114.991219 36.305975,-114.991163
36.306845,-114.989432 36.309452,-114.978275 36.312642,-114.977363
@@ -704,3 +706,8 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is
def asbinary(g) 252 8192 0 Y 128 0 63
asbinary(g)
drop table t1;
+create table t1 select GeomFromText('point(1 1)');
+desc t1;
+Field Type Null Key Default Extra
+GeomFromText('point(1 1)') geometry NO
+drop table t1;
diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result
index 3f3325354ee..2f417a41652 100644
--- a/mysql-test/r/grant.result
+++ b/mysql-test/r/grant.result
@@ -426,6 +426,7 @@ revoke all on mysqltest_2.t1 from mysqltest_3@localhost;
revoke all on mysqltest_2.t2 from mysqltest_3@localhost;
grant all on mysqltest_2.* to mysqltest_3@localhost;
grant select on *.* to mysqltest_3@localhost;
+grant select on mysqltest_2.t1 to mysqltest_3@localhost;
flush privileges;
use mysqltest_1;
update mysqltest_2.t1, mysqltest_2.t2 set c=500,d=600;
@@ -525,7 +526,7 @@ Db char(64) NO PRI
User char(16) NO PRI
Table_name char(64) NO PRI
Grantor char(77) NO MUL
-Timestamp timestamp YES CURRENT_TIMESTAMP
+Timestamp timestamp NO CURRENT_TIMESTAMP
Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') NO
Column_priv set('Select','Insert','Update','References') NO
use test;
@@ -867,3 +868,106 @@ insert into mysql.user select * from t2;
flush privileges;
drop table t2;
drop table t1;
+CREATE DATABASE mysqltest3;
+use mysqltest3;
+CREATE TABLE t_nn (c1 INT);
+CREATE VIEW v_nn AS SELECT * FROM t_nn;
+CREATE DATABASE mysqltest2;
+use mysqltest2;
+CREATE TABLE t_nn (c1 INT);
+CREATE VIEW v_nn AS SELECT * FROM t_nn;
+CREATE VIEW v_yn AS SELECT * FROM t_nn;
+CREATE VIEW v_gy AS SELECT * FROM t_nn;
+CREATE VIEW v_ny AS SELECT * FROM t_nn;
+CREATE VIEW v_yy AS SELECT * FROM t_nn WHERE c1=55;
+GRANT SHOW VIEW ON mysqltest2.v_ny TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
+GRANT SELECT ON mysqltest2.v_yn TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
+GRANT SELECT ON mysqltest2.* TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
+GRANT SHOW VIEW,SELECT ON mysqltest2.v_yy TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
+SHOW CREATE VIEW mysqltest2.v_nn;
+ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v_nn'
+SHOW CREATE TABLE mysqltest2.v_nn;
+ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v_nn'
+SHOW CREATE VIEW mysqltest2.v_yn;
+ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v_yn'
+SHOW CREATE TABLE mysqltest2.v_yn;
+ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v_yn'
+SHOW CREATE TABLE mysqltest2.v_ny;
+View Create View
+v_ny CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_ny` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn`
+SHOW CREATE VIEW mysqltest2.v_ny;
+View Create View
+v_ny CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_ny` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn`
+SHOW CREATE TABLE mysqltest3.t_nn;
+ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't_nn'
+SHOW CREATE VIEW mysqltest3.t_nn;
+ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't_nn'
+SHOW CREATE VIEW mysqltest3.v_nn;
+ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v_nn'
+SHOW CREATE TABLE mysqltest3.v_nn;
+ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 'v_nn'
+SHOW CREATE TABLE mysqltest2.t_nn;
+Table Create Table
+t_nn CREATE TABLE `t_nn` (
+ `c1` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SHOW CREATE VIEW mysqltest2.t_nn;
+ERROR HY000: 'mysqltest2.t_nn' is not VIEW
+SHOW CREATE VIEW mysqltest2.v_yy;
+View Create View
+v_yy CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_yy` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn` where (`mysqltest2`.`t_nn`.`c1` = 55)
+SHOW CREATE TABLE mysqltest2.v_yy;
+View Create View
+v_yy CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest2`.`v_yy` AS select `mysqltest2`.`t_nn`.`c1` AS `c1` from `mysqltest2`.`t_nn` where (`mysqltest2`.`t_nn`.`c1` = 55)
+SHOW CREATE TABLE mysqltest2.v_nn;
+View Create View
+v_nn CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_nn` AS select `t_nn`.`c1` AS `c1` from `t_nn`
+SHOW CREATE VIEW mysqltest2.v_nn;
+View Create View
+v_nn CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v_nn` AS select `t_nn`.`c1` AS `c1` from `t_nn`
+SHOW CREATE TABLE mysqltest2.t_nn;
+Table Create Table
+t_nn CREATE TABLE `t_nn` (
+ `c1` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+SHOW CREATE VIEW mysqltest2.t_nn;
+ERROR HY000: 'mysqltest2.t_nn' is not VIEW
+DROP VIEW mysqltest2.v_nn;
+DROP VIEW mysqltest2.v_yn;
+DROP VIEW mysqltest2.v_ny;
+DROP VIEW mysqltest2.v_yy;
+DROP TABLE mysqltest2.t_nn;
+DROP DATABASE mysqltest2;
+DROP VIEW mysqltest3.v_nn;
+DROP TABLE mysqltest3.t_nn;
+DROP DATABASE mysqltest3;
+REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysqltest_1'@'localhost';
+DROP USER 'mysqltest_1'@'localhost';
+use test;
+create user mysqltest1_thisisreallytoolong;
+ERROR HY000: String 'mysqltest1_thisisreallytoolong' is too long for user name (should be no longer than 16)
+GRANT CREATE ON mysqltest.* TO 1234567890abcdefGHIKL@localhost;
+ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16)
+GRANT CREATE ON mysqltest.* TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60)
+REVOKE CREATE ON mysqltest.* FROM 1234567890abcdefGHIKL@localhost;
+ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16)
+REVOKE CREATE ON mysqltest.* FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60)
+GRANT CREATE ON t1 TO 1234567890abcdefGHIKL@localhost;
+ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16)
+GRANT CREATE ON t1 TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60)
+REVOKE CREATE ON t1 FROM 1234567890abcdefGHIKL@localhost;
+ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16)
+REVOKE CREATE ON t1 FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60)
+GRANT EXECUTE ON PROCEDURE p1 TO 1234567890abcdefGHIKL@localhost;
+ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16)
+GRANT EXECUTE ON PROCEDURE p1 TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60)
+REVOKE EXECUTE ON PROCEDURE p1 FROM 1234567890abcdefGHIKL@localhost;
+ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16)
+REVOKE EXECUTE ON PROCEDURE t1 FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60)
+End of 5.0 tests
diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result
index eb9e95c40bd..2700426257b 100644
--- a/mysql-test/r/grant2.result
+++ b/mysql-test/r/grant2.result
@@ -118,6 +118,16 @@ flush privileges;
drop user mysqltest_3@host3;
drop user mysqltest_1@host1, mysqltest_2@host2, mysqltest_4@host4,
mysqltest_5@host5, mysqltest_6@host6, mysqltest_7@host7;
+create database mysqltest_1;
+grant select, insert, update on `mysqltest\_1`.* to mysqltest_1@localhost;
+set sql_log_off = 1;
+ERROR 42000: Access denied; you need the SUPER privilege for this operation
+set sql_log_bin = 0;
+ERROR 42000: Access denied; you need the SUPER privilege for this operation
+delete from mysql.user where user like 'mysqltest\_1';
+delete from mysql.db where user like 'mysqltest\_1';
+drop database mysqltest_1;
+flush privileges;
set sql_mode='maxdb';
drop table if exists t1, t2;
create table t1(c1 int);
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result
index 7bc886022cc..ef057e04d1a 100644
--- a/mysql-test/r/group_by.result
+++ b/mysql-test/r/group_by.result
@@ -796,3 +796,37 @@ aaa
show warnings;
Level Code Message
drop table t1, t2;
+CREATE TABLE t1 (a tinyint(3), b varchar(255), PRIMARY KEY (a));
+INSERT INTO t1 VALUES (1,'-----'), (6,'Allemagne'), (17,'Autriche'),
+(25,'Belgique'), (54,'Danemark'), (62,'Espagne'), (68,'France');
+CREATE TABLE t2 (a tinyint(3), b tinyint(3), PRIMARY KEY (a), KEY b (b));
+INSERT INTO t2 VALUES (1,1), (2,1), (6,6), (18,17), (15,25), (16,25),
+(17,25), (10,54), (5,62),(3,68);
+CREATE VIEW v1 AS select t1.a, concat(t1.b,'') AS b, t1.b as real_b from t1;
+explain
+SELECT straight_join sql_no_cache v1.a, v1.b, v1.real_b from t2, v1
+where t2.b=v1.a GROUP BY t2.b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index b b 2 NULL 10 Using index
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 1 test.t2.b 1
+SELECT straight_join sql_no_cache v1.a, v1.b, v1.real_b from t2, v1
+where t2.b=v1.a GROUP BY t2.b;
+a b real_b
+1 ----- -----
+6 Allemagne Allemagne
+17 Autriche Autriche
+25 Belgique Belgique
+54 Danemark Danemark
+62 Espagne Espagne
+68 France France
+DROP VIEW v1;
+DROP TABLE t1,t2;
+CREATE TABLE t1 (a INT, b INT, KEY(a));
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3,3), (4,4);
+EXPLAIN SELECT a, SUM(b) FROM t1 GROUP BY a LIMIT 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL a 5 NULL 4
+EXPLAIN SELECT a, SUM(b) FROM t1 IGNORE INDEX (a) GROUP BY a LIMIT 2;
+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
+DROP TABLE t1;
diff --git a/mysql-test/r/group_min_max.result b/mysql-test/r/group_min_max.result
index d62586dba85..fe6f7c4ca55 100644
--- a/mysql-test/r/group_min_max.result
+++ b/mysql-test/r/group_min_max.result
@@ -2099,3 +2099,46 @@ SOUTH EAST SOUTH EAST
SOUTH WEST SOUTH WEST
WESTERN WESTERN
DROP TABLE t1;
+CREATE TABLE t1 (id1 INT, id2 INT);
+CREATE TABLE t2 (id2 INT, id3 INT, id5 INT);
+CREATE TABLE t3 (id3 INT, id4 INT);
+CREATE TABLE t4 (id4 INT);
+CREATE TABLE t5 (id5 INT, id6 INT);
+CREATE TABLE t6 (id6 INT);
+INSERT INTO t1 VALUES(1,1);
+INSERT INTO t2 VALUES(1,1,1);
+INSERT INTO t3 VALUES(1,1);
+INSERT INTO t4 VALUES(1);
+INSERT INTO t5 VALUES(1,1);
+INSERT INTO t6 VALUES(1);
+SELECT * FROM
+t1
+NATURAL JOIN
+(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6)
+ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5));
+id2 id1 id3 id5 id4 id3 id6 id5
+1 1 1 1 1 1 1 1
+SELECT * FROM
+t1
+NATURAL JOIN
+(((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6) on t3.id4 = t5.id5) JOIN t2
+ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5));
+id2 id1 id4 id3 id6 id5 id3 id5
+1 1 1 1 1 1 1 1
+SELECT * FROM t1 NATURAL JOIN ((t3 join (t5 NATURAL JOIN t6)) JOIN t2);
+id2 id1 id3 id4 id6 id5 id3 id5
+1 1 1 1 1 1 1 1
+SELECT * FROM
+(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6)
+ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5))
+NATURAL JOIN
+t1;
+id2 id3 id5 id4 id3 id6 id5 id1
+1 1 1 1 1 1 1 1
+SELECT * FROM
+(t2 JOIN ((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6)))
+NATURAL JOIN
+t1;
+id2 id3 id5 id4 id3 id6 id5 id1
+1 1 1 1 1 1 1 1
+DROP TABLE t1,t2,t3,t4,t5,t6;
diff --git a/mysql-test/r/have_perror.require b/mysql-test/r/have_perror.require
new file mode 100644
index 00000000000..260687c87f0
--- /dev/null
+++ b/mysql-test/r/have_perror.require
@@ -0,0 +1,2 @@
+have_perror
+1
diff --git a/mysql-test/r/heap_btree.result b/mysql-test/r/heap_btree.result
index 4b05e8f44e1..5b9c7f2244f 100644
--- a/mysql-test/r/heap_btree.result
+++ b/mysql-test/r/heap_btree.result
@@ -246,6 +246,41 @@ DELETE from t1 where a < 100;
SELECT * from t1;
a
DROP TABLE t1;
+create table t1(a int not null, key using btree(a)) engine=heap;
+insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3);
+select a from t1 where a > 2 order by a;
+a
+3
+3
+3
+3
+delete from t1 where a < 4;
+select a from t1 order by a;
+a
+insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3);
+select a from t1 where a > 4 order by a;
+a
+delete from t1 where a > 4;
+select a from t1 order by a;
+a
+1
+1
+2
+2
+2
+3
+3
+3
+3
+select a from t1 where a > 3 order by a;
+a
+delete from t1 where a >= 2;
+select a from t1 order by a;
+a
+1
+1
+drop table t1;
+End of 4.1 tests
CREATE TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory;
INSERT INTO t1 VALUES(0);
SELECT INDEX_LENGTH FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t1';
@@ -259,3 +294,4 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY;
INSERT INTO t1 VALUES(NULL),(NULL);
DROP TABLE t1;
+End of 5.0 tests
diff --git a/mysql-test/r/heap_hash.result b/mysql-test/r/heap_hash.result
index e0835bbf8d6..80abcebbfea 100644
--- a/mysql-test/r/heap_hash.result
+++ b/mysql-test/r/heap_hash.result
@@ -354,7 +354,7 @@ t3 1 a 2 b NULL 13 NULL NULL HASH
explain select * from t1 ignore key(btree_idx), t3 where t1.name='matt' and t3.a = concat('',t1.name) and t3.b=t1.name;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref heap_idx heap_idx 22 const 7 Using where
-1 SIMPLE t3 ref a a 44 const,const 7 Using where
+1 SIMPLE t3 ref a a 44 func,const 7 Using where
drop table t1, t2, t3;
create temporary table t1 ( a int, index (a) ) engine=memory;
insert into t1 values (1),(2),(3),(4),(5);
diff --git a/mysql-test/r/im_daemon_life_cycle.result b/mysql-test/r/im_daemon_life_cycle.result
index ea27fcb6db1..b805bdc9166 100644
--- a/mysql-test/r/im_daemon_life_cycle.result
+++ b/mysql-test/r/im_daemon_life_cycle.result
@@ -1,4 +1,6 @@
-Success: the process has been started.
+SHOW VARIABLES LIKE 'server_id';
+Variable_name Value
+server_id 1
SHOW INSTANCES;
instance_name status
mysqld1 online
diff --git a/mysql-test/r/im_life_cycle.result b/mysql-test/r/im_life_cycle.result
index 211a82eb9cf..69f6bb5a490 100644
--- a/mysql-test/r/im_life_cycle.result
+++ b/mysql-test/r/im_life_cycle.result
@@ -1,8 +1,6 @@
-
---------------------------------------------------------------------
--- 1.1.1.
---------------------------------------------------------------------
-Success: the process has been started.
+SHOW VARIABLES LIKE 'server_id';
+Variable_name Value
+server_id 1
SHOW INSTANCES;
instance_name status
mysqld1 online
@@ -40,10 +38,6 @@ ERROR HY000: Bad instance name. Check that the instance with such a name exists
--------------------------------------------------------------------
-- 1.1.6.
--------------------------------------------------------------------
-SHOW INSTANCES;
-instance_name status
-mysqld1 online
-mysqld2 offline
Killing the process...
Sleeping...
Success: the process was restarted.
diff --git a/mysql-test/r/im_options_set.result b/mysql-test/r/im_options_set.result
index 5e6c740624e..f7b7e8eaef7 100644
--- a/mysql-test/r/im_options_set.result
+++ b/mysql-test/r/im_options_set.result
@@ -1,8 +1,10 @@
-server_id = 1
-server_id = 2
SHOW VARIABLES LIKE 'server_id';
Variable_name Value
server_id 1
+SHOW INSTANCES;
+instance_name status
+mysqld1 online
+mysqld2 offline
SET mysqld1.server_id = 11;
server_id =11
server_id = 2
diff --git a/mysql-test/r/im_options_unset.result b/mysql-test/r/im_options_unset.result
index bf54025edb7..2ab775e611a 100644
--- a/mysql-test/r/im_options_unset.result
+++ b/mysql-test/r/im_options_unset.result
@@ -1,8 +1,10 @@
-server_id = 1
-server_id = 2
SHOW VARIABLES LIKE 'server_id';
Variable_name Value
server_id 1
+SHOW INSTANCES;
+instance_name status
+mysqld1 online
+mysqld2 offline
UNSET mysqld1.server_id;
server_id = 2
SHOW VARIABLES LIKE 'server_id';
diff --git a/mysql-test/r/im_utils.result b/mysql-test/r/im_utils.result
index e6a5e007ed4..f671089d31d 100644
--- a/mysql-test/r/im_utils.result
+++ b/mysql-test/r/im_utils.result
@@ -1,4 +1,6 @@
-Success: the process has been started.
+SHOW VARIABLES LIKE 'server_id';
+Variable_name Value
+server_id 1
SHOW INSTANCES;
instance_name status
mysqld1 online
diff --git a/mysql-test/r/index_merge.result b/mysql-test/r/index_merge.result
index 3a69f56cbd3..3f3360e2da0 100644
--- a/mysql-test/r/index_merge.result
+++ b/mysql-test/r/index_merge.result
@@ -424,3 +424,34 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t3 index_merge a,b a,b 5,5 NULL # Using intersect(a,b); Using where
drop table t3;
drop table t0, t1, t2;
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES(1);
+CREATE TABLE t2(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b));
+INSERT INTO t2(a,b) VALUES
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(1,2);
+LOCK TABLES t1 WRITE, t2 WRITE;
+INSERT INTO t2(a,b) VALUES(1,2);
+SELECT t2.a FROM t1,t2 WHERE t2.b=2 AND t2.a=1;
+a
+1
+1
+UNLOCK TABLES;
+DROP TABLE t1, t2;
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index a2feba7ad5d..407f8a040b7 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -337,7 +337,7 @@ mysql
test
explain select * from v0;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY # ALL NULL NULL NULL NULL 2
+1 SIMPLE # ALL NULL NULL NULL NULL 2
create view v1 (c) as select table_name from information_schema.tables
where table_name="v1";
select * from v1;
@@ -1170,3 +1170,73 @@ f1()
DROP FUNCTION f1;
DROP PROCEDURE p1;
DROP USER mysql_bug20230@localhost;
+SELECT t.table_name, c1.column_name
+FROM information_schema.tables t
+INNER JOIN
+information_schema.columns c1
+ON t.table_schema = c1.table_schema AND
+t.table_name = c1.table_name
+WHERE t.table_schema = 'information_schema' AND
+c1.ordinal_position =
+( SELECT COALESCE(MIN(c2.ordinal_position),1)
+FROM information_schema.columns c2
+WHERE c2.table_schema = t.table_schema AND
+c2.table_name = t.table_name AND
+c2.column_name LIKE '%SCHEMA%'
+ );
+table_name column_name
+CHARACTER_SETS CHARACTER_SET_NAME
+COLLATIONS COLLATION_NAME
+COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
+COLUMNS TABLE_SCHEMA
+COLUMN_PRIVILEGES TABLE_SCHEMA
+KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
+ROUTINES ROUTINE_SCHEMA
+SCHEMATA SCHEMA_NAME
+SCHEMA_PRIVILEGES TABLE_SCHEMA
+STATISTICS TABLE_SCHEMA
+TABLES TABLE_SCHEMA
+TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
+TABLE_PRIVILEGES TABLE_SCHEMA
+TRIGGERS TRIGGER_SCHEMA
+USER_PRIVILEGES GRANTEE
+VIEWS TABLE_SCHEMA
+SELECT t.table_name, c1.column_name
+FROM information_schema.tables t
+INNER JOIN
+information_schema.columns c1
+ON t.table_schema = c1.table_schema AND
+t.table_name = c1.table_name
+WHERE t.table_schema = 'information_schema' AND
+c1.ordinal_position =
+( SELECT COALESCE(MIN(c2.ordinal_position),1)
+FROM information_schema.columns c2
+WHERE c2.table_schema = 'information_schema' AND
+c2.table_name = t.table_name AND
+c2.column_name LIKE '%SCHEMA%'
+ );
+table_name column_name
+CHARACTER_SETS CHARACTER_SET_NAME
+COLLATIONS COLLATION_NAME
+COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
+COLUMNS TABLE_SCHEMA
+COLUMN_PRIVILEGES TABLE_SCHEMA
+KEY_COLUMN_USAGE CONSTRAINT_SCHEMA
+ROUTINES ROUTINE_SCHEMA
+SCHEMATA SCHEMA_NAME
+SCHEMA_PRIVILEGES TABLE_SCHEMA
+STATISTICS TABLE_SCHEMA
+TABLES TABLE_SCHEMA
+TABLE_CONSTRAINTS CONSTRAINT_SCHEMA
+TABLE_PRIVILEGES TABLE_SCHEMA
+TRIGGERS TRIGGER_SCHEMA
+USER_PRIVILEGES GRANTEE
+VIEWS TABLE_SCHEMA
+SELECT MAX(table_name) FROM information_schema.tables;
+MAX(table_name)
+VIEWS
+SELECT table_name from information_schema.tables
+WHERE table_name=(SELECT MAX(table_name)
+FROM information_schema.tables);
+table_name
+VIEWS
diff --git a/mysql-test/r/information_schema_db.result b/mysql-test/r/information_schema_db.result
index 61a10c5f72c..40773a7afc1 100644
--- a/mysql-test/r/information_schema_db.result
+++ b/mysql-test/r/information_schema_db.result
@@ -97,3 +97,50 @@ v2 VIEW View 'test.v2' references invalid table(s) or column(s) or function(s) o
drop function f1;
drop function f2;
drop view v1, v2;
+create database testdb_1;
+create user testdb_1@localhost;
+grant all on testdb_1.* to testdb_1@localhost with grant option;
+create user testdb_2@localhost;
+grant all on test.* to testdb_2@localhost with grant option;
+use testdb_1;
+create table t1 (f1 char(4));
+create view v1 as select f1 from t1;
+grant insert on v1 to testdb_2@localhost;
+create table t3 (f1 char(4), f2 char(4));
+create view v3 as select f1,f2 from t3;
+grant insert(f1), insert(f2) on v3 to testdb_2@localhost;
+create view v2 as select f1 from testdb_1.v1;
+create view v4 as select f1,f2 from testdb_1.v3;
+revoke insert(f1) on v3 from testdb_2@localhost;
+show create view v4;
+ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
+show fields from v4;
+ERROR HY000: EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
+show fields from v2;
+Field Type Null Key Default Extra
+f1 char(4) YES NULL
+show fields from testdb_1.v1;
+Field Type Null Key Default Extra
+f1 char(4) YES NULL
+show create view v2;
+View Create View
+v2 CREATE ALGORITHM=UNDEFINED DEFINER=`testdb_2`@`localhost` SQL SECURITY DEFINER VIEW `test`.`v2` AS select `v1`.`f1` AS `f1` from `testdb_1`.`v1`
+show create view testdb_1.v1;
+ERROR 42000: SHOW VIEW command denied to user 'testdb_2'@'localhost' for table 'v1'
+select table_name from information_schema.columns a
+where a.table_name = 'v2';
+table_name
+v2
+select view_definition from information_schema.views a
+where a.table_name = 'v2';
+view_definition
+/* ALGORITHM=UNDEFINED */ select `v1`.`f1` AS `f1` from `testdb_1`.`v1`
+select view_definition from information_schema.views a
+where a.table_name = 'testdb_1.v1';
+view_definition
+select * from v2;
+ERROR HY000: View 'test.v2' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
+drop view testdb_1.v1,v2, testdb_1.v3, v4;
+drop database testdb_1;
+drop user testdb_1@localhost;
+drop user testdb_2@localhost;
diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result
index 77046cc1fd1..1d1f26e4b01 100644
--- a/mysql-test/r/innodb.result
+++ b/mysql-test/r/innodb.result
@@ -1473,8 +1473,8 @@ Error 1146 Table 'test.t4' doesn't exist
drop table t1,t2,t3;
create table t1 (id int, name char(10) not null, name2 char(10) not null) engine=innodb;
insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
-select name2 from t1 union all select name from t1 union all select id from t1;
-name2
+select trim(name2) from t1 union all select trim(name) from t1 union all select trim(id) from t1;
+trim(name2)
fff
sss
ttt
diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result
index 8dbfa906fe1..b4101e037f2 100644
--- a/mysql-test/r/innodb_mysql.result
+++ b/mysql-test/r/innodb_mysql.result
@@ -54,6 +54,56 @@ c.c_id = 218 and expiredate is null;
slai_id
12
drop table t1, t2;
+CREATE TABLE t1 (a int, b int, KEY b (b)) Engine=InnoDB;
+CREATE TABLE t2 (a int, b int, PRIMARY KEY (a,b)) Engine=InnoDB;
+CREATE TABLE t3 (a int, b int, c int, PRIMARY KEY (a),
+UNIQUE KEY b (b,c), KEY a (a,b,c)) Engine=InnoDB;
+INSERT INTO t1 VALUES (1, 1);
+INSERT INTO t1 SELECT a + 1, b + 1 FROM t1;
+INSERT INTO t1 SELECT a + 2, b + 2 FROM t1;
+INSERT INTO t2 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8);
+INSERT INTO t2 SELECT a + 1, b FROM t2;
+DELETE FROM t2 WHERE a = 1 AND b < 2;
+INSERT INTO t3 VALUES (1,1,1),(2,1,2);
+INSERT INTO t3 SELECT a + 2, a + 2, 3 FROM t3;
+INSERT INTO t3 SELECT a + 4, a + 4, 3 FROM t3;
+SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
+t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
+ORDER BY t1.b LIMIT 2;
+b a
+1 1
+2 2
+SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
+t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
+ORDER BY t1.b LIMIT 5;
+b a
+1 1
+2 2
+2 2
+3 3
+3 3
+DROP TABLE t1, t2, t3;
+CREATE TABLE `t1` (`id1` INT) ;
+INSERT INTO `t1` (`id1`) VALUES (1),(5),(2);
+CREATE TABLE `t2` (
+`id1` INT,
+`id2` INT NOT NULL,
+`id3` INT,
+`id4` INT NOT NULL,
+UNIQUE (`id2`,`id4`),
+KEY (`id1`)
+) ENGINE=InnoDB;
+INSERT INTO `t2`(`id1`,`id2`,`id3`,`id4`) VALUES
+(1,1,1,0),
+(1,1,2,1),
+(5,1,2,2),
+(6,1,2,3),
+(1,2,2,2),
+(1,2,1,1);
+SELECT `id1` FROM `t1` WHERE `id1` NOT IN (SELECT `id1` FROM `t2` WHERE `id2` = 1 AND `id3` = 2);
+id1
+2
+DROP TABLE t1, t2;
create table t1m (a int) engine=myisam;
create table t1i (a int) engine=innodb;
create table t2m (a int) engine=myisam;
@@ -68,7 +118,7 @@ min(7)
NULL
select min(7) from DUAL;
min(7)
-NULL
+7
explain select min(7) from t2m join t1m;
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
@@ -83,7 +133,7 @@ max(7)
NULL
select max(7) from DUAL;
max(7)
-NULL
+7
explain select max(7) from t2m join t1m;
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
@@ -122,7 +172,7 @@ min(7)
NULL
select min(7) from DUAL;
min(7)
-NULL
+7
explain select min(7) from t2i join t1i;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
@@ -138,7 +188,7 @@ max(7)
NULL
select max(7) from DUAL;
max(7)
-NULL
+7
explain select max(7) from t2i join t1i;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2i ALL NULL NULL NULL NULL 1
@@ -268,3 +318,22 @@ explain select distinct f1, f2 from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range NULL PRIMARY 5 NULL 3 Using index for group-by; Using temporary
drop table t1;
+CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20),
+INDEX (name)) ENGINE=InnoDB;
+CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11),
+FOREIGN KEY (fkey) REFERENCES t2(id)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B');
+INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3);
+EXPLAIN
+SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
+WHERE t1.name LIKE 'A%';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index
+1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using where; Using index
+EXPLAIN
+SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
+WHERE t1.name LIKE 'A%' OR FALSE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index NULL fkey 5 NULL 5 Using index
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.fkey 1 Using where
+DROP TABLE t1,t2;
diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result
index 82fad8e912c..80723d68b5a 100644
--- a/mysql-test/r/insert.result
+++ b/mysql-test/r/insert.result
@@ -63,7 +63,7 @@ insert into t1 values(NULL);
ERROR 23000: Column 'id' cannot be null
insert into t1 values (1), (NULL), (2);
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'id' at row 2
+Warning 1263 Column was set to data type implicit default; NULL supplied for 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 49d9c3594db..0af48d27cd5 100644
--- a/mysql-test/r/insert_select.result
+++ b/mysql-test/r/insert_select.result
@@ -606,8 +606,8 @@ NULL 2 100
create table t2(No int not null, Field int not null, Count int not null);
insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2;
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'No' at row 1
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'No' at row 2
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'No' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'No' at row 2
select * from t2;
No Field Count
0 1 100
@@ -695,3 +695,113 @@ CREATE TABLE t2 (z int, y int);
CREATE TABLE t3 (a int, b int);
INSERT INTO t3 (SELECT x, y FROM t1 JOIN t2 USING (y) WHERE z = 1);
DROP TABLE IF EXISTS t1,t2,t3;
+CREATE DATABASE bug21774_1;
+CREATE DATABASE bug21774_2;
+CREATE TABLE bug21774_1.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
+CREATE TABLE bug21774_2.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
+CREATE TABLE bug21774_1.t2(id VARCHAR(10) NOT NULL,label VARCHAR(255));
+INSERT INTO bug21774_2.t1 SELECT t1.* FROM bug21774_1.t1;
+use bug21774_1;
+INSERT INTO bug21774_2.t1 SELECT t1.* FROM t1;
+DROP DATABASE bug21774_1;
+DROP DATABASE bug21774_2;
+CREATE DATABASE meow;
+CREATE TABLE table_target ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
+CREATE TABLE table_target2 ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
+CREATE TABLE table_target3 ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
+CREATE VIEW view_target2 AS SELECT mexs_id,messzeit FROM table_target2;
+CREATE SQL SECURITY INVOKER VIEW view_target3 AS SELECT mexs_id,messzeit FROM table_target3;
+CREATE TABLE table_stations ( mexs_id VARCHAR(8), icao VARCHAR(4), country CHAR(2), PRIMARY KEY (mexs_id), UNIQUE KEY icao (icao), KEY country (country), CONSTRAINT stations_ibfk_8 FOREIGN KEY (country) REFERENCES countries (country) ON UPDATE CASCADE);
+INSERT INTO table_stations VALUES ('87654321','XXXX','YY');
+CREATE TABLE table_countries ( country CHAR(2), iso_short_en VARCHAR(64), PRIMARY KEY (country));
+INSERT INTO table_countries VALUES ('YY','Entenhausen');
+CREATE ALGORITHM=MERGE SQL SECURITY INVOKER VIEW view_stations AS select table_stations.mexs_id AS mexs_id, table_stations.icao AS icao, table_stations.country AS landescode from (table_stations join table_countries on((table_stations.country = table_countries.country)));
+CREATE TABLE table_source ( id varchar(4), datetime TIMESTAMP, PRIMARY KEY (id));
+INSERT INTO table_source VALUES ('XXXX','2006-07-12 07:50:00');
+GRANT SELECT ON table_source TO user20989@localhost;
+GRANT SELECT ON table_countries TO user20989@localhost;
+GRANT SELECT ON table_stations TO user20989@localhost;
+GRANT SELECT ON view_stations TO user20989@localhost;
+GRANT SELECT ON table_target TO user20989@localhost;
+GRANT SELECT ON table_target2 TO user20989@localhost;
+GRANT INSERT,DELETE,SELECT ON view_target3 TO user20989@localhost;
+REPLACE INTO table_target
+SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
+FROM table_source
+INNER JOIN view_stations AS stations
+ON table_source.id = stations.icao
+LEFT JOIN table_target AS old
+USING (mexs_id);
+ERROR 42000: INSERT,DELETE command denied to user 'user20989'@'localhost' for table 'table_target'
+REPLACE INTO view_target2
+SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
+FROM table_source
+INNER JOIN view_stations AS stations
+ON table_source.id = stations.icao
+LEFT JOIN view_target2 AS old
+USING (mexs_id);
+ERROR 42000: INSERT,DELETE command denied to user 'user20989'@'localhost' for table 'view_target2'
+REPLACE INTO view_target3
+SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
+FROM table_source
+INNER JOIN view_stations AS stations
+ON table_source.id = stations.icao
+LEFT JOIN view_target3 AS old
+USING (mexs_id);
+ERROR HY000: View 'meow.view_target3' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
+GRANT INSERT,DELETE ON table_target TO user20989@localhost;
+GRANT INSERT,DELETE,SELECT ON view_target2 TO user20989@localhost;
+GRANT INSERT,DELETE,SELECT ON table_target3 TO user20989@localhost;
+REPLACE INTO table_target
+SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
+FROM table_source
+INNER JOIN view_stations AS stations
+ON table_source.id = stations.icao
+LEFT JOIN table_target AS old
+USING (mexs_id);
+REPLACE INTO table_target2 VALUES ('00X45Y78','2006-07-12 07:50:00');
+ERROR 42000: INSERT,DELETE command denied to user 'user20989'@'localhost' for table 'table_target2'
+REPLACE INTO view_target2 VALUES ('12X45Y78','2006-07-12 07:50:00');
+SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
+FROM table_source
+INNER JOIN view_stations AS stations
+ON table_source.id = stations.icao
+LEFT JOIN view_target2 AS old
+USING (mexs_id);
+mexs_id messzeit
+87654321 2006-07-12 07:50:00
+REPLACE INTO view_target2
+SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
+FROM table_source
+INNER JOIN view_stations AS stations
+ON table_source.id = stations.icao
+LEFT JOIN view_target2 AS old
+USING (mexs_id);
+REPLACE INTO view_target3
+SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
+FROM table_source
+INNER JOIN view_stations AS stations
+ON table_source.id = stations.icao
+LEFT JOIN view_target3 AS old
+USING (mexs_id);
+SELECT * FROM table_target;
+mexs_id messzeit
+87654321 2006-07-12 07:50:00
+SELECT * FROM view_target2;
+mexs_id messzeit
+12X45Y78 2006-07-12 07:50:00
+87654321 2006-07-12 07:50:00
+SELECT * FROM view_target3;
+mexs_id messzeit
+87654321 2006-07-12 07:50:00
+DROP VIEW view_stations;
+DROP TABLE table_source;
+DROP TABLE table_countries;
+DROP TABLE table_stations;
+DROP TABLE table_target;
+DROP TABLE table_target2;
+DROP TABLE table_target3;
+DROP VIEW view_target2;
+DROP VIEW view_target3;
+DROP USER user20989@localhost;
+DROP DATABASE meow;
diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result
index dbe5d600a95..6be37450835 100644
--- a/mysql-test/r/insert_update.result
+++ b/mysql-test/r/insert_update.result
@@ -63,9 +63,9 @@ Warnings:
Note 1003 select `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
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
Warnings:
-Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1`
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where values(`test`.`t1`.`a`)
DROP TABLE t1;
create table t1(a int primary key, b int);
insert into t1 values(1,1),(2,2),(3,3),(4,4),(5,5);
@@ -197,3 +197,25 @@ PRIMARY KEY (a)
) ENGINE=MyISAM;
INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a) ;
DROP TABLE t1;
+CREATE TABLE t1
+(
+a BIGINT UNSIGNED,
+b BIGINT UNSIGNED,
+PRIMARY KEY (a)
+);
+INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b =
+IF(VALUES(b) > t1.b, VALUES(b), t1.b);
+SELECT * FROM t1;
+a b
+45 1
+INSERT INTO t1 VALUES (45, 2) ON DUPLICATE KEY UPDATE b =
+IF(VALUES(b) > t1.b, VALUES(b), t1.b);
+SELECT * FROM t1;
+a b
+45 2
+INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b =
+IF(VALUES(b) > t1.b, VALUES(b), t1.b);
+SELECT * FROM t1;
+a b
+45 2
+DROP TABLE t1;
diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result
index eae023813b5..89bb26c4b3f 100644
--- a/mysql-test/r/join_outer.result
+++ b/mysql-test/r/join_outer.result
@@ -598,6 +598,8 @@ id int(11) DEFAULT '0' NOT NULL,
name tinytext DEFAULT '' NOT NULL,
UNIQUE id (id)
);
+Warnings:
+Warning 1101 BLOB/TEXT column 'name' can't have a default value
INSERT INTO t1 VALUES (1,'yes'),(2,'no');
CREATE TABLE t2 (
id int(11) DEFAULT '0' NOT NULL,
@@ -735,7 +737,7 @@ explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from
(t2 s left join t1 m on m.match_id = 1)
order by m.match_id desc;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE s ALL NULL NULL NULL NULL 10
+1 SIMPLE s ALL NULL NULL NULL NULL 10 Using temporary; Using filesort
1 SIMPLE m const match_id,match_id_2 match_id 1 const 1
explain select s.*, '*', m.*, (s.match_1_h - m.home) UUX from
(t2 s left join t1 m on m.match_id = 1)
@@ -1124,7 +1126,7 @@ a b a b
7 8 7 5
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a = t2.a OR t1.a = t2.b;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 4 Using where
+1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 4
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1
EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a IN(t2.a, t2.b);
id select_type table type possible_keys key key_len ref rows Extra
@@ -1135,25 +1137,6 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 4 Using where
1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.a 1
DROP TABLE t1,t2;
-CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20),
-INDEX (name)) ENGINE=InnoDB;
-CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11),
-FOREIGN KEY (fkey) REFERENCES t2(id)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B');
-INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3);
-EXPLAIN
-SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
-WHERE t1.name LIKE 'A%';
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index PRIMARY,name name 23 NULL 3 Using where; Using index
-1 SIMPLE t2 ref fkey fkey 5 test.t1.id 1 Using where; Using index
-EXPLAIN
-SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
-WHERE t1.name LIKE 'A%' OR FALSE;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 index NULL fkey 5 NULL 5 Using index
-1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.fkey 1 Using where
-DROP TABLE t1,t2;
DROP VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (a int);
diff --git a/mysql-test/r/key.result b/mysql-test/r/key.result
index 0174ea45935..eea884e4294 100644
--- a/mysql-test/r/key.result
+++ b/mysql-test/r/key.result
@@ -159,8 +159,8 @@ 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 1263 Column set to default value; NULL supplied to NOT NULL column 'c' at row 1
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'c' at row 2
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'c' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'c' at row 2
SELECT * FROM t1;
c i
1
diff --git a/mysql-test/r/limit.result b/mysql-test/r/limit.result
index 1e38f762dd1..be2776ef533 100644
--- a/mysql-test/r/limit.result
+++ b/mysql-test/r/limit.result
@@ -76,3 +76,17 @@ a
a
1
drop table t1;
+create table t1 (a int);
+insert into t1 values (1),(2),(3),(4),(5),(6),(7);
+explain select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
+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 temporary
+select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
+c
+7
+explain select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
+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 temporary
+select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
+c
+28
diff --git a/mysql-test/r/loaddata_autocom_innodb.result b/mysql-test/r/loaddata_autocom_innodb.result
new file mode 100644
index 00000000000..10da6b5dde7
--- /dev/null
+++ b/mysql-test/r/loaddata_autocom_innodb.result
@@ -0,0 +1,21 @@
+SET SESSION STORAGE_ENGINE = InnoDB;
+drop table if exists t1;
+create table t1 (a text, b text);
+start transaction;
+load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
+Warnings:
+Warning 1261 Row 3 doesn't contain data for all columns
+commit;
+select count(*) from t1;
+count(*)
+4
+truncate table t1;
+start transaction;
+load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
+Warnings:
+Warning 1261 Row 3 doesn't contain data for all columns
+rollback;
+select count(*) from t1;
+count(*)
+0
+drop table t1;
diff --git a/mysql-test/r/loaddata_autocom_ndb.result b/mysql-test/r/loaddata_autocom_ndb.result
new file mode 100644
index 00000000000..94e5f825fa2
--- /dev/null
+++ b/mysql-test/r/loaddata_autocom_ndb.result
@@ -0,0 +1,23 @@
+SET SESSION STORAGE_ENGINE = ndbcluster;
+drop table if exists t1;
+create table t1 (a text, b text);
+start transaction;
+load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
+Warnings:
+Warning 1261 Row 3 doesn't contain data for all columns
+commit;
+select count(*) from t1;
+count(*)
+4
+truncate table t1;
+start transaction;
+load data infile '../std_data_ln/loaddata2.dat' into table t1 fields terminated by ',' enclosed by '''';
+Warnings:
+Warning 1261 Row 3 doesn't contain data for all columns
+rollback;
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
+select count(*) from t1;
+count(*)
+4
+drop table t1;
diff --git a/mysql-test/r/lowercase_fs_off.result b/mysql-test/r/lowercase_fs_off.result
new file mode 100644
index 00000000000..f610b959a47
--- /dev/null
+++ b/mysql-test/r/lowercase_fs_off.result
@@ -0,0 +1,11 @@
+create database d1;
+grant all on d1.* to 'sample'@'localhost' identified by 'password';
+flush privileges;
+select database();
+database()
+d1
+create database d2;
+ERROR 42000: Access denied for user 'sample'@'localhost' to database 'd2'
+create database D1;
+ERROR 42000: Access denied for user 'sample'@'localhost' to database 'D1'
+drop database if exists d1;
diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result
index b1abe16a091..b8fdd24be74 100644
--- a/mysql-test/r/merge.result
+++ b/mysql-test/r/merge.result
@@ -774,3 +774,15 @@ create table tm (b bit(1)) engine = merge union = (t1,t2);
select * from tm;
b
drop table tm, t1, t2;
+create table t1 (a int) insert_method = last engine = merge;
+insert into t1 values (1);
+ERROR HY000: Table 't1' is read only
+create table t2 (a int) engine = myisam;
+alter table t1 union (t2);
+insert into t1 values (1);
+alter table t1 insert_method = no;
+insert into t1 values (1);
+ERROR HY000: Table 't1' is read only
+drop table t2;
+drop table t1;
+End of 5.0 tests
diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result
index c7d8f5c128d..0021e6717ee 100644
--- a/mysql-test/r/myisam.result
+++ b/mysql-test/r/myisam.result
@@ -515,6 +515,34 @@ select c1 from t1 order by c1 limit 1;
c1
a
drop table t1;
+create table t1 (a int not null, primary key(a));
+create table t2 (a int not null, b int not null, primary key(a,b));
+insert into t1 values (1),(2),(3),(4),(5),(6);
+insert into t2 values (1,1),(2,1);
+lock tables t1 read local, t2 read local;
+select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
+a a b
+1 1 1
+2 2 1
+insert into t2 values(2,0);
+select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
+a a b
+1 1 1
+2 2 1
+drop table t1,t2;
+CREATE TABLE t1 (c1 varchar(250) NOT NULL);
+CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1));
+INSERT INTO t1 VALUES ('test000001'), ('test000002'), ('test000003');
+INSERT INTO t2 VALUES ('test000002'), ('test000003'), ('test000004');
+LOCK TABLES t1 READ LOCAL, t2 READ LOCAL;
+SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
+WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
+t1c1 t2c1
+INSERT INTO t2 VALUES ('test000001'), ('test000005');
+SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
+WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
+t1c1 t2c1
+DROP TABLE t1,t2;
CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) ENGINE=MyISAM;
Got one of the listed errors
create table t1 (a int, b varchar(200), c text not null) checksum=1;
diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result
index 4b7084e813c..7dbff4beca5 100644
--- a/mysql-test/r/mysql.result
+++ b/mysql-test/r/mysql.result
@@ -36,19 +36,19 @@ Tables_in_test
t1
t2
t3
-
+_
Test delimiter : from command line
a
1
-
+_
Test delimiter :; from command line
a
1
-
+_
Test 'go' command(vertical output) G
*************************** 1. row ***************************
a: 1
-
+_
Test 'go' command g
a
1
@@ -59,16 +59,16 @@ database()
test
unlock tables;
drop table t1;
-ソ
-ソ
+ƒ\
+ƒ\
c_cp932
+ƒ\
+ƒ\
+ƒ\
ソ
ソ
-ソ
-ソ
-ソ
-ソ
-ソ
+ƒ\
+ƒ\
+----------------------+------------+--------+
| concat('>',col1,'<') | col2 | col3 |
+----------------------+------------+--------+
@@ -85,6 +85,12 @@ c_cp932
| NULL | NULL | Τη γλώσσα |
| NULL | NULL | á›–áš´ áš·á›–á› |
+------+------+---------------------------+
+i j k
+NULL 1 NULL
+Field Type Null Key Default Extra
+i int(11) YES NULL
+j int(11) NO
+k int(11) YES NULL
+------+---+------+
| i | j | k |
+------+---+------+
@@ -97,6 +103,10 @@ c_cp932
| j | int(11) | NO | | | |
| k | int(11) | YES | | NULL | |
+-------+---------+------+-----+---------+-------+
+i s1
+1 x
+2 NULL
+3
+------+------+
| i | s1 |
+------+------+
@@ -104,4 +114,29 @@ c_cp932
| 2 | NULL |
| 3 | |
+------+------+
+unhex('zz')
+NULL
++-------------+
+| unhex('zz') |
++-------------+
+| NULL |
++-------------+
+create table t1(a int, b varchar(255), c int);
+Field Type Null Key Default Extra
+a int(11) YES NULL
+b varchar(255) YES NULL
+c int(11) YES NULL
+Field Type Null Key Default Extra
+a int(11) YES NULL
+b varchar(255) YES NULL
+c int(11) YES NULL
+drop table t1;
+1
+1
+ERROR 1064 (42000) at line 3: 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 at line 1: USE must be followed by a database name
+\
+\\
+';
+';
End of 5.0 tests
diff --git a/mysql-test/r/mysqlcheck.result b/mysql-test/r/mysqlcheck.result
index 8c98e18aa9b..df0835b830c 100644
--- a/mysql-test/r/mysqlcheck.result
+++ b/mysql-test/r/mysqlcheck.result
@@ -32,3 +32,10 @@ mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
+create table t1 (a int);
+create view v1 as select * from t1;
+test.t1 OK
+test.t1 OK
+drop view v1;
+drop table t1;
+End of 5.0 tests
diff --git a/mysql-test/r/mysqldump-max.result b/mysql-test/r/mysqldump-max.result
index 39d607910aa..78867d1e430 100644
--- a/mysql-test/r/mysqldump-max.result
+++ b/mysql-test/r/mysqldump-max.result
@@ -115,7 +115,6 @@ CREATE TABLE `t1` (
`name` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
@@ -125,7 +124,6 @@ CREATE TABLE `t2` (
`name` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
@@ -135,7 +133,6 @@ CREATE TABLE `t3` (
`name` varchar(32) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
-
/*!40000 ALTER TABLE `t3` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t3` ENABLE KEYS */;
@@ -145,7 +142,6 @@ CREATE TABLE `t4` (
`name` varchar(32) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
-
/*!40000 ALTER TABLE `t4` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t4` ENABLE KEYS */;
@@ -155,7 +151,6 @@ CREATE TABLE `t5` (
`name` varchar(32) default NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
-
/*!40000 ALTER TABLE `t5` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t5` ENABLE KEYS */;
@@ -165,7 +160,6 @@ CREATE TABLE `t6` (
`name` varchar(32) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-
/*!40000 ALTER TABLE `t6` DISABLE KEYS */;
INSERT IGNORE INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t6` ENABLE KEYS */;
@@ -200,7 +194,6 @@ CREATE TABLE `t1` (
`name` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT DELAYED INTO `t1` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
@@ -210,7 +203,6 @@ CREATE TABLE `t2` (
`name` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
INSERT DELAYED INTO `t2` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
@@ -220,7 +212,6 @@ CREATE TABLE `t3` (
`name` varchar(32) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
-
/*!40000 ALTER TABLE `t3` DISABLE KEYS */;
INSERT DELAYED INTO `t3` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t3` ENABLE KEYS */;
@@ -230,7 +221,6 @@ CREATE TABLE `t4` (
`name` varchar(32) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1;
-
/*!40000 ALTER TABLE `t4` DISABLE KEYS */;
INSERT DELAYED INTO `t4` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t4` ENABLE KEYS */;
@@ -240,7 +230,6 @@ CREATE TABLE `t5` (
`name` varchar(32) default NULL
) ENGINE=ARCHIVE DEFAULT CHARSET=latin1;
-
/*!40000 ALTER TABLE `t5` DISABLE KEYS */;
INSERT DELAYED INTO `t5` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t5` ENABLE KEYS */;
@@ -250,7 +239,6 @@ CREATE TABLE `t6` (
`name` varchar(32) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-
/*!40000 ALTER TABLE `t6` DISABLE KEYS */;
INSERT INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first value'),(4,'first value'),(5,'first value');
/*!40000 ALTER TABLE `t6` ENABLE KEYS */;
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index dc5886107ed..ee50fc42203 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -22,6 +22,9 @@ INSERT INTO t1 VALUES (1), (2);
</database>
</mysqldump>
DROP TABLE t1;
+#
+# Bug #2005
+#
CREATE TABLE t1 (a decimal(64, 20));
INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"),
("0987654321098765432109876543210987654321");
@@ -30,6 +33,9 @@ CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `t1` VALUES ('1234567890123456789012345678901234567890.00000000000000000000'),('987654321098765432109876543210987654321.00000000000000000000');
DROP TABLE t1;
+#
+# Bug #2055
+#
CREATE TABLE t1 (a double);
INSERT INTO t1 VALUES ('-9e999999');
Warnings:
@@ -39,6 +45,9 @@ CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `t1` VALUES (RES);
DROP TABLE t1;
+#
+# Bug #3361 mysqldump quotes DECIMAL values inconsistently
+#
CREATE TABLE t1 (a DECIMAL(10,5), b FLOAT);
INSERT INTO t1 VALUES (1.2345, 2.3456);
INSERT INTO t1 VALUES ('1.2345', 2.3456);
@@ -76,12 +85,11 @@ CREATE TABLE `t1` (
`b` float default NULL
);
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES ('1.23450',2.3456),('1.23450',2.3456),('1.23450',2.3456),('1.23450',2.3456),('1.23450',2.3456);
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -137,6 +145,9 @@ INSERT INTO t1 VALUES (1, "test", "tes"), (2, "TEST", "TES");
</database>
</mysqldump>
DROP TABLE t1;
+#
+# Bug #1707
+#
CREATE TABLE t1 (`a"b"` char(2));
INSERT INTO t1 VALUES ("1\""), ("\"2");
<?xml version="1.0"?>
@@ -156,6 +167,10 @@ INSERT INTO t1 VALUES ("1\""), ("\"2");
</database>
</mysqldump>
DROP TABLE t1;
+#
+# Bug #1994
+# Bug #4261
+#
CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET koi8r;
INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5'), (NULL);
@@ -174,13 +189,12 @@ CREATE TABLE `t1` (
`a` varchar(255) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=koi8r;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES ('абцде');
INSERT INTO `t1` VALUES (NULL);
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -192,6 +206,9 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
DROP TABLE t1;
+#
+# Bug #2634
+#
CREATE TABLE t1 (a int) ENGINE=MYISAM;
INSERT INTO t1 VALUES (1), (2);
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
@@ -205,12 +222,11 @@ CREATE TABLE `t1` (
`a` int(11) default NULL
) TYPE=MyISAM;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (1),(2);
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -229,12 +245,11 @@ CREATE TABLE `t1` (
`a` int(11) default NULL
) TYPE=MyISAM;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (1),(2);
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -243,11 +258,17 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
DROP TABLE t1;
+#
+# Bug #2592 'mysqldump doesn't quote "tricky" names correctly'
+#
create table ```a` (i int);
CREATE TABLE ```a` (
`i` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
drop table ```a`;
+#
+# Bug #2591 "mysqldump quotes names inconsistently"
+#
create table t1(a int);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
@@ -265,11 +286,10 @@ CREATE TABLE `t1` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
-UNLOCK TABLES;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -291,11 +311,10 @@ CREATE TABLE "t1" (
"a" int(11) default NULL
);
-
-/*!40000 ALTER TABLE "t1" DISABLE KEYS */;
LOCK TABLES "t1" WRITE;
-UNLOCK TABLES;
+/*!40000 ALTER TABLE "t1" DISABLE KEYS */;
/*!40000 ALTER TABLE "t1" ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -320,11 +339,10 @@ CREATE TABLE `t1` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
-UNLOCK TABLES;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -346,11 +364,10 @@ CREATE TABLE "t1" (
"a" int(11) default NULL
);
-
-/*!40000 ALTER TABLE "t1" DISABLE KEYS */;
LOCK TABLES "t1" WRITE;
-UNLOCK TABLES;
+/*!40000 ALTER TABLE "t1" DISABLE KEYS */;
/*!40000 ALTER TABLE "t1" ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -360,6 +377,9 @@ UNLOCK TABLES;
set global sql_mode='';
drop table t1;
+#
+# Bug #2705 'mysqldump --tab extra output'
+#
create table t1(a int);
insert into t1 values (1),(2),(3);
@@ -388,6 +408,9 @@ CREATE TABLE `t1` (
2
3
drop table t1;
+#
+# Bug #6101: create database problem
+#
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -440,6 +463,12 @@ USE `mysqldump_test_db`;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop database mysqldump_test_db;
+#
+# Bug #7020
+# Check that we don't dump in UTF8 in compatible mode by default,
+# but use the default compiled values, or the values given in
+# --default-character-set=xxx. However, we should dump in UTF8
+# if it is explicitely set.
CREATE TABLE t1 (a CHAR(10));
INSERT INTO t1 VALUES (_latin1 'ÄÖÜß');
@@ -458,12 +487,11 @@ CREATE TABLE `t1` (
`a` char(10) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES ('ÄÖÜß');
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -474,6 +502,13 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+#
+# Bug#8063: make test mysqldump [ fail ]
+# We cannot tes this command because its output depends
+# on --default-character-set incompiled into "mysqldump" program.
+# If the future we can move this command into a separate test with
+# checking that "mysqldump" is compiled with "latin1"
+#
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -485,12 +520,11 @@ CREATE TABLE `t1` (
`a` char(10) default NULL
) TYPE=MyISAM;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES ('Ž™šá');
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -509,12 +543,11 @@ CREATE TABLE `t1` (
`a` char(10) default NULL
) TYPE=MyISAM;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES ('Ž™šá');
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -533,12 +566,11 @@ CREATE TABLE `t1` (
`a` char(10) default NULL
) TYPE=MyISAM;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES ('ÄÖÜß');
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -547,6 +579,9 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
DROP TABLE t1;
+#
+# WL #2319: Exclude Tables from dump
+#
CREATE TABLE t1 (a int);
CREATE TABLE t2 (a int);
INSERT INTO t1 VALUES (1),(2),(3);
@@ -567,12 +602,11 @@ CREATE TABLE `t2` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
LOCK TABLES `t2` WRITE;
+/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
INSERT INTO `t2` VALUES (4),(5),(6);
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -585,6 +619,9 @@ UNLOCK TABLES;
DROP TABLE t1;
DROP TABLE t2;
+#
+# Bug #8830
+#
CREATE TABLE t1 (`b` blob);
INSERT INTO `t1` VALUES (0x602010000280100005E71A);
@@ -603,12 +640,11 @@ CREATE TABLE `t1` (
`b` blob
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (0x602010000280100005E71A);
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -620,6 +656,9 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
DROP TABLE t1;
+#
+# Test for --insert-ignore
+#
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1),(2),(3);
INSERT INTO t1 VALUES (4),(5),(6);
@@ -639,12 +678,11 @@ CREATE TABLE `t1` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6);
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -671,7 +709,6 @@ CREATE TABLE `t1` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT DELAYED IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6);
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
@@ -686,6 +723,10 @@ INSERT DELAYED IGNORE INTO `t1` VALUES (1),(2),(3),(4),(5),(6);
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
DROP TABLE t1;
+#
+# Bug #10286: mysqldump -c crashes on table that has many fields with long
+# names
+#
create table t1 (
F_c4ca4238a0b923820dcc509a6f75849b int,
F_c81e728d9d4c2f636f067f89cc14862c int,
@@ -1363,12 +1404,11 @@ CREATE TABLE `t1` (
`F_fe73f687e5bc5280214e0486b273a5f9` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` (`F_c4ca4238a0b923820dcc509a6f75849b`, `F_c81e728d9d4c2f636f067f89cc14862c`, `F_eccbc87e4b5ce2fe28308fd9f2a7baf3`, `F_a87ff679a2f3e71d9181a67b7542122c`, `F_e4da3b7fbbce2345d7772b0674a318d5`, `F_1679091c5a880faf6fb5e6087eb1b2dc`, `F_8f14e45fceea167a5a36dedd4bea2543`, `F_c9f0f895fb98ab9159f51fd0297e236d`, `F_45c48cce2e2d7fbdea1afc51c7c6ad26`, `F_d3d9446802a44259755d38e6d163e820`, `F_6512bd43d9caa6e02c990b0a82652dca`, `F_c20ad4d76fe97759aa27a0c99bff6710`, `F_c51ce410c124a10e0db5e4b97fc2af39`, `F_aab3238922bcc25a6f606eb525ffdc56`, `F_9bf31c7ff062936a96d3c8bd1f8f2ff3`, `F_c74d97b01eae257e44aa9d5bade97baf`, `F_70efdf2ec9b086079795c442636b55fb`, `F_6f4922f45568161a8cdf4ad2299f6d23`, `F_1f0e3dad99908345f7439f8ffabdffc4`, `F_98f13708210194c475687be6106a3b84`, `F_3c59dc048e8850243be8079a5c74d079`, `F_b6d767d2f8ed5d21a44b0e5886680cb9`, `F_37693cfc748049e45d87b8c7d8b9aacd`, `F_1ff1de774005f8da13f42943881c655f`, `F_8e296a067a37563370ded05f5a3bf3ec`, `F_4e732ced3463d06de0ca9a15b6153677`, `F_02e74f10e0327ad868d138f2b4fdd6f0`, `F_33e75ff09dd601bbe69f351039152189`, `F_6ea9ab1baa0efb9e19094440c317e21b`, `F_34173cb38f07f89ddbebc2ac9128303f`, `F_c16a5320fa475530d9583c34fd356ef5`, `F_6364d3f0f495b6ab9dcf8d3b5c6e0b01`, `F_182be0c5cdcd5072bb1864cdee4d3d6e`, `F_e369853df766fa44e1ed0ff613f563bd`, `F_1c383cd30b7c298ab50293adfecb7b18`, `F_19ca14e7ea6328a42e0eb13d585e4c22`, `F_a5bfc9e07964f8dddeb95fc584cd965d`, `F_a5771bce93e200c36f7cd9dfd0e5deaa`, `F_d67d8ab4f4c10bf22aa353e27879133c`, `F_d645920e395fedad7bbbed0eca3fe2e0`, `F_3416a75f4cea9109507cacd8e2f2aefc`, `F_a1d0c6e83f027327d8461063f4ac58a6`, `F_17e62166fc8586dfa4d1bc0e1742c08b`, `F_f7177163c833dff4b38fc8d2872f1ec6`, `F_6c8349cc7260ae62e3b1396831a8398f`, `F_d9d4f495e875a2e075a1a4a6e1b9770f`, `F_67c6a1e7ce56d3d6fa748ab6d9af3fd7`, `F_642e92efb79421734881b53e1e1b18b6`, `F_f457c545a9ded88f18ecee47145a72c0`, `F_c0c7c76d30bd3dcaefc96f40275bdc0a`, `F_2838023a778dfaecdc212708f721b788`, `F_9a1158154dfa42caddbd0694a4e9bdc8`, `F_d82c8d1619ad8176d665453cfb2e55f0`, `F_a684eceee76fc522773286a895bc8436`, `F_b53b3a3d6ab90ce0268229151c9bde11`, `F_9f61408e3afb633e50cdf1b20de6f466`, `F_72b32a1f754ba1c09b3695e0cb6cde7f`, `F_66f041e16a60928b05a7e228a89c3799`, `F_093f65e080a295f8076b1c5722a46aa2`, `F_072b030ba126b2f4b2374f342be9ed44`, `F_7f39f8317fbdb1988ef4c628eba02591`, `F_44f683a84163b3523afe57c2e008bc8c`, `F_03afdbd66e7929b125f8597834fa83a4`, `F_ea5d2f1c4608232e07d3aa3d998e5135`, `F_fc490ca45c00b1249bbe3554a4fdf6fb`, `F_3295c76acbf4caaed33c36b1b5fc2cb1`, `F_735b90b4568125ed6c3f678819b6e058`, `F_a3f390d88e4c41f2747bfa2f1b5f87db`, `F_14bfa6bb14875e45bba028a21ed38046`, `F_7cbbc409ec990f19c78c75bd1e06f215`, `F_e2c420d928d4bf8ce0ff2ec19b371514`, `F_32bb90e8976aab5298d5da10fe66f21d`, `F_d2ddea18f00665ce8623e36bd4e3c7c5`, `F_ad61ab143223efbc24c7d2583be69251`, `F_d09bf41544a3365a46c9077ebb5e35c3`, `F_fbd7939d674997cdb4692d34de8633c4`, `F_28dd2c7955ce926456240b2ff0100bde`, `F_35f4a8d465e6e1edc05f3d8ab658c551`, `F_d1fe173d08e959397adf34b1d77e88d7`, `F_f033ab37c30201f73f142449d037028d`, `F_43ec517d68b6edd3015b3edc9a11367b`, `F_9778d5d219c5080b9a6a17bef029331c`, `F_fe9fc289c3ff0af142b6d3bead98a923`, `F_68d30a9594728bc39aa24be94b319d21`, `F_3ef815416f775098fe977004015c6193`, `F_93db85ed909c13838ff95ccfa94cebd9`, `F_c7e1249ffc03eb9ded908c236bd1996d`, `F_2a38a4a9316c49e5a833517c45d31070`, `F_7647966b7343c29048673252e490f736`, `F_8613985ec49eb8f757ae6439e879bb2a`, `F_54229abfcfa5649e7003b83dd4755294`, `F_92cc227532d17e56e07902b254dfad10`, `F_98dce83da57b0395e163467c9dae521b`, `F_f4b9ec30ad9f68f89b29639786cb62ef`, `F_812b4ba287f5ee0bc9d43bbf5bbe87fb`, `F_26657d5ff9020d2abefe558796b99584`, `F_e2ef524fbf3d9fe611d5a8e90fefdc9c`, `F_ed3d2c21991e3bef5e069713af9fa6ca`, `F_ac627ab1ccbdb62ec96e702f07f6425b`, `F_f899139df5e1059396431415e770c6dd`, `F_38b3eff8baf56627478ec76a704e9b52`, `F_ec8956637a99787bd197eacd77acce5e`, `F_6974ce5ac660610b44d9b9fed0ff9548`, `F_c9e1074f5b3f9fc8ea15d152add07294`, `F_65b9eea6e1cc6bb9f0cd2a47751a186f`, `F_f0935e4cd5920aa6c7c996a5ee53a70f`, `F_a97da629b098b75c294dffdc3e463904`, `F_a3c65c2974270fd093ee8a9bf8ae7d0b`, `F_2723d092b63885e0d7c260cc007e8b9d`, `F_5f93f983524def3dca464469d2cf9f3e`, `F_698d51a19d8a121ce581499d7b701668`, `F_7f6ffaa6bb0b408017b62254211691b5`, `F_73278a4a86960eeb576a8fd4c9ec6997`, `F_5fd0b37cd7dbbb00f97ba6ce92bf5add`, `F_2b44928ae11fb9384c4cf38708677c48`, `F_c45147dee729311ef5b5c3003946c48f`, `F_eb160de1de89d9058fcb0b968dbbbd68`, `F_5ef059938ba799aaa845e1c2e8a762bd`, `F_07e1cd7dca89a1678042477183b7ac3f`, `F_da4fb5c6e93e74d3df8527599fa62642`, `F_4c56ff4ce4aaf9573aa5dff913df997a`, `F_a0a080f42e6f13b3a2df133f073095dd`, `F_202cb962ac59075b964b07152d234b70`, `F_c8ffe9a587b126f152ed3d89a146b445`, `F_3def184ad8f4755ff269862ea77393dd`, `F_069059b7ef840f0c74a814ec9237b6ec`, `F_ec5decca5ed3d6b8079e2e7e7bacc9f2`, `F_76dc611d6ebaafc66cc0879c71b5db5c`, `F_d1f491a404d6854880943e5c3cd9ca25`, `F_9b8619251a19057cff70779273e95aa6`, `F_1afa34a7f984eeabdbb0a7d494132ee5`, `F_65ded5353c5ee48d0b7d48c591b8f430`, `F_9fc3d7152ba9336a670e36d0ed79bc43`, `F_02522a2b2726fb0a03bb19f2d8d9524d`, `F_7f1de29e6da19d22b51c68001e7e0e54`, `F_42a0e188f5033bc65bf8d78622277c4e`, `F_3988c7f88ebcb58c6ce932b957b6f332`, `F_013d407166ec4fa56eb1e1f8cbe183b9`, `F_e00da03b685a0dd18fb6a08af0923de0`, `F_1385974ed5904a438616ff7bdb3f7439`, `F_0f28b5d49b3020afeecd95b4009adf4c`, `F_a8baa56554f96369ab93e4f3bb068c22`, `F_903ce9225fca3e988c2af215d4e544d3`, `F_0a09c8844ba8f0936c20bd791130d6b6`, `F_2b24d495052a8ce66358eb576b8912c8`, `F_a5e00132373a7031000fd987a3c9f87b`, `F_8d5e957f297893487bd98fa830fa6413`, `F_47d1e990583c9c67424d369f3414728e`, `F_f2217062e9a397a1dca429e7d70bc6ca`, `F_7ef605fc8dba5425d6965fbd4c8fbe1f`, `F_a8f15eda80c50adb0e71943adc8015cf`, `F_37a749d808e46495a8da1e5352d03cae`, `F_b3e3e393c77e35a4a3f3cbd1e429b5dc`, `F_1d7f7abc18fcb43975065399b0d1e48e`, `F_2a79ea27c279e471f4d180b08d62b00a`, `F_1c9ac0159c94d8d0cbedc973445af2da`, `F_6c4b761a28b734fe93831e3fb400ce87`, `F_06409663226af2f3114485aa4e0a23b4`, `F_140f6969d5213fd0ece03148e62e461e`, `F_b73ce398c39f506af761d2277d853a92`, `F_bd4c9ab730f5513206b999ec0d90d1fb`, `F_82aa4b0af34c2313a562076992e50aa3`, `F_0777d5c17d4066b82ab86dff8a46af6f`, `F_fa7cdfad1a5aaf8370ebeda47a1ff1c3`, `F_9766527f2b5d3e95d4a733fcfb77bd7e`, `F_7e7757b1e12abcb736ab9a754ffb617a`, `F_5878a7ab84fb43402106c575658472fa`, `F_006f52e9102a8d3be2fe5614f42ba989`, `F_3636638817772e42b59d74cff571fbb3`, `F_149e9677a5989fd342ae44213df68868`, `F_a4a042cf4fd6bfb47701cbc8a1653ada`, `F_1ff8a7b5dc7a7d1f0ed65aaa29c04b1e`, `F_f7e6c85504ce6e82442c770f7c8606f0`, `F_bf8229696f7a3bb4700cfddef19fa23f`, `F_82161242827b703e6acf9c726942a1e4`, `F_38af86134b65d0f10fe33d30dd76442e`, `F_96da2f590cd7246bbde0051047b0d6f7`, `F_8f85517967795eeef66c225f7883bdcb`, `F_8f53295a73878494e9bc8dd6c3c7104f`, `F_045117b0e0a11a242b9765e79cbf113f`, `F_fc221309746013ac554571fbd180e1c8`, `F_4c5bde74a8f110656874902f07378009`, `F_cedebb6e872f539bef8c3f919874e9d7`, `F_6cdd60ea0045eb7a6ec44c54d29ed402`, `F_eecca5b6365d9607ee5a9d336962c534`, `F_9872ed9fc22fc182d371c3e9ed316094`, `F_31fefc0e570cb3860f2a6d4b38c6490d`, `F_9dcb88e0137649590b755372b040afad`, `F_a2557a7b2e94197ff767970b67041697`, `F_cfecdb276f634854f3ef915e2e980c31`, `F_0aa1883c6411f7873cb83dacb17b0afc`, `F_58a2fc6ed39fd083f55d4182bf88826d`, `F_bd686fd640be98efaae0091fa301e613`, `F_a597e50502f5ff68e3e25b9114205d4a`, `F_0336dcbab05b9d5ad24f4333c7658a0e`, `F_084b6fbb10729ed4da8c3d3f5a3ae7c9`, `F_85d8ce590ad8981ca2c8286f79f59954`, `F_0e65972dce68dad4d52d063967f0a705`, `F_84d9ee44e457ddef7f2c4f25dc8fa865`, `F_3644a684f98ea8fe223c713b77189a77`, `F_757b505cfd34c64c85ca5b5690ee5293`, `F_854d6fae5ee42911677c739ee1734486`, `F_e2c0be24560d78c5e599c2a9c9d0bbd2`, `F_274ad4786c3abca69fa097b85867d9a4`, `F_eae27d77ca20db309e056e3d2dcd7d69`, `F_7eabe3a1649ffa2b3ff8c02ebfd5659f`, `F_69adc1e107f7f7d035d7baf04342e1ca`, `F_091d584fced301b442654dd8c23b3fc9`, `F_b1d10e7bafa4421218a51b1e1f1b0ba2`, `F_6f3ef77ac0e3619e98159e9b6febf557`, `F_eb163727917cbba1eea208541a643e74`, `F_1534b76d325a8f591b52d302e7181331`, `F_979d472a84804b9f647bc185a877a8b5`, `F_ca46c1b9512a7a8315fa3c5a946e8265`, `F_3b8a614226a953a8cd9526fca6fe9ba5`, `F_45fbc6d3e05ebd93369ce542e8f2322d`, `F_63dc7ed1010d3c3b8269faf0ba7491d4`, `F_e96ed478dab8595a7dbda4cbcbee168f`, `F_c0e190d8267e36708f955d7ab048990d`, `F_ec8ce6abb3e952a85b8551ba726a1227`, `F_060ad92489947d410d897474079c1477`, `F_bcbe3365e6ac95ea2c0343a2395834dd`, `F_115f89503138416a242f40fb7d7f338e`, `F_13fe9d84310e77f13a6d184dbf1232f3`, `F_d1c38a09acc34845c6be3a127a5aacaf`, `F_9cfdf10e8fc047a44b08ed031e1f0ed1`, `F_705f2172834666788607efbfca35afb3`, `F_74db120f0a8e5646ef5a30154e9f6deb`, `F_57aeee35c98205091e18d1140e9f38cf`, `F_6da9003b743b65f4c0ccd295cc484e57`, `F_9b04d152845ec0a378394003c96da594`, `F_be83ab3ecd0db773eb2dc1b0a17836a1`, `F_e165421110ba03099a1c0393373c5b43`, `F_289dff07669d7a23de0ef88d2f7129e7`, `F_577ef1154f3240ad5b9b413aa7346a1e`, `F_01161aaa0b6d1345dd8fe4e481144d84`, `F_539fd53b59e3bb12d203f45a912eeaf2`, `F_ac1dd209cbcc5e5d1c6e28598e8cbbe8`, `F_555d6702c950ecb729a966504af0a635`, `F_335f5352088d7d9bf74191e006d8e24c`, `F_f340f1b1f65b6df5b5e3f94d95b11daf`, `F_e4a6222cdb5b34375400904f03d8e6a5`, `F_cb70ab375662576bd1ac5aaf16b3fca4`, `F_9188905e74c28e489b44e954ec0b9bca`, `F_0266e33d3f546cb5436a10798e657d97`, `F_38db3aed920cf82ab059bfccbd02be6a`, `F_3cec07e9ba5f5bb252d13f5f431e4bbb`, `F_621bf66ddb7c962aa0d22ac97d69b793`, `F_077e29b11be80ab57e1a2ecabb7da330`, `F_6c9882bbac1c7093bd25041881277658`, `F_19f3cd308f1455b3fa09a282e0d496f4`, `F_03c6b06952c750899bb03d998e631860`, `F_c24cd76e1ce41366a4bbe8a49b02a028`, `F_c52f1bd66cc19d05628bd8bf27af3ad6`, `F_fe131d7f5a6b38b23cc967316c13dae2`, `F_f718499c1c8cef6730f9fd03c8125cab`, `F_d96409bf894217686ba124d7356686c9`, `F_502e4a16930e414107ee22b6198c578f`, `F_cfa0860e83a4c3a763a7e62d825349f7`, `F_a4f23670e1833f3fdb077ca70bbd5d66`, `F_b1a59b315fc9a3002ce38bbe070ec3f5`, `F_36660e59856b4de58a219bcf4e27eba3`, `F_8c19f571e251e61cb8dd3612f26d5ecf`, `F_d6baf65e0b240ce177cf70da146c8dc8`, `F_e56954b4f6347e897f954495eab16a88`, `F_f7664060cc52bc6f3d620bcedc94a4b6`, `F_eda80a3d5b344bc40f3bc04f65b7a357`, `F_8f121ce07d74717e0b1f21d122e04521`, `F_06138bc5af6023646ede0e1f7c1eac75`, `F_39059724f73a9969845dfe4146c5660e`, `F_7f100b7b36092fb9b06dfb4fac360931`, `F_7a614fd06c325499f1680b9896beedeb`, `F_4734ba6f3de83d861c3176a6273cac6d`, `F_d947bf06a885db0d477d707121934ff8`, `F_63923f49e5241343aa7acb6a06a751e7`, `F_db8e1af0cb3aca1ae2d0018624204529`, `F_20f07591c6fcb220ffe637cda29bb3f6`, `F_07cdfd23373b17c6b337251c22b7ea57`, `F_d395771085aab05244a4fb8fd91bf4ee`, `F_92c8c96e4c37100777c7190b76d28233`, `F_e3796ae838835da0b6f6ea37bcf8bcb7`, `F_6a9aeddfc689c1d0e3b9ccc3ab651bc5`, `F_0f49c89d1e7298bb9930789c8ed59d48`, `F_46ba9f2a6976570b0353203ec4474217`, `F_0e01938fc48a2cfb5f2217fbfb00722d`, `F_16a5cdae362b8d27a1d8f8c7b78b4330`, `F_918317b57931b6b7a7d29490fe5ec9f9`, `F_48aedb8880cab8c45637abc7493ecddd`, `F_839ab46820b524afda05122893c2fe8e`, `F_f90f2aca5c640289d0a29417bcb63a37`, `F_9c838d2e45b2ad1094d42f4ef36764f6`, `F_1700002963a49da13542e0726b7bb758`, `F_53c3bce66e43be4f209556518c2fcb54`, `F_6883966fd8f918a4aa29be29d2c386fb`, `F_49182f81e6a13cf5eaa496d51fea6406`, `F_d296c101daa88a51f6ca8cfc1ac79b50`, `F_9fd81843ad7f202f26c1a174c7357585`, `F_26e359e83860db1d11b6acca57d8ea88`, `F_ef0d3930a7b6c95bd2b32ed45989c61f`, `F_94f6d7e04a4d452035300f18b984988c`, `F_34ed066df378efacc9b924ec161e7639`, `F_577bcc914f9e55d5e4e4f82f9f00e7d4`, `F_11b9842e0a271ff252c1903e7132cd68`, `F_37bc2f75bf1bcfe8450a1a41c200364c`, `F_496e05e1aea0a9c4655800e8a7b9ea28`, `F_b2eb7349035754953b57a32e2841bda5`, `F_8e98d81f8217304975ccb23337bb5761`, `F_a8c88a0055f636e4a163a5e3d16adab7`, `F_eddea82ad2755b24c4e168c5fc2ebd40`, `F_06eb61b839a0cefee4967c67ccb099dc`, `F_9dfcd5e558dfa04aaf37f137a1d9d3e5`, `F_950a4152c2b4aa3ad78bdd6b366cc179`, `F_158f3069a435b314a80bdcb024f8e422`, `F_758874998f5bd0c393da094e1967a72b`, `F_ad13a2a07ca4b7642959dc0c4c740ab6`, `F_3fe94a002317b5f9259f82690aeea4cd`, `F_5b8add2a5d98b1a652ea7fd72d942dac`, `F_432aca3a1e345e339f35a30c8f65edce`, `F_8d3bba7425e7c98c50f52ca1b52d3735`, `F_320722549d1751cf3f247855f937b982`, `F_caf1a3dfb505ffed0d024130f58c5cfa`, `F_5737c6ec2e0716f3d8a7a5c4e0de0d9a`, `F_bc6dc48b743dc5d013b1abaebd2faed2`, `F_f2fc990265c712c49d51a18a32b39f0c`, `F_89f0fd5c927d466d6ec9a21b9ac34ffa`, `F_a666587afda6e89aec274a3657558a27`, `F_b83aac23b9528732c23cc7352950e880`, `F_cd00692c3bfe59267d5ecfac5310286c`, `F_6faa8040da20ef399b63a72d0e4ab575`, `F_fe73f687e5bc5280214e0486b273a5f9`) 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,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,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,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,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,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,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,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,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,1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -1380,6 +1420,9 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop table t1;
+#
+# Test for --add-drop-database
+#
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1),(2),(3);
@@ -1404,69 +1447,11 @@ CREATE TABLE `t1` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (1),(2),(3);
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
-/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
-
-/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
-/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
-/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
-/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
-/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
-/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
-/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-
-DROP TABLE t1;
-create database db1;
-use db1;
-CREATE TABLE t2 (
-a varchar(30) default NULL,
-KEY a (a(5))
-);
-INSERT INTO t2 VALUES ('alfred');
-INSERT INTO t2 VALUES ('angie');
-INSERT INTO t2 VALUES ('bingo');
-INSERT INTO t2 VALUES ('waffle');
-INSERT INTO t2 VALUES ('lemon');
-create view v2 as select * from t2 where a like 'a%' with check option;
-
-/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
-/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
-/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
-/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
-/*!40103 SET TIME_ZONE='+00:00' */;
-/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
-/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
-/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-DROP TABLE IF EXISTS `t2`;
-CREATE TABLE `t2` (
- `a` varchar(30) default NULL,
- KEY `a` (`a`(5))
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-
-/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
-LOCK TABLES `t2` WRITE;
-INSERT INTO `t2` VALUES ('alfred'),('angie'),('bingo'),('waffle'),('lemon');
UNLOCK TABLES;
-/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
-DROP TABLE IF EXISTS `v2`;
-/*!50001 DROP VIEW IF EXISTS `v2`*/;
-/*!50001 CREATE TABLE `v2` (
- `a` varchar(30)
-) */;
-/*!50001 DROP TABLE IF EXISTS `v2`*/;
-/*!50001 DROP VIEW IF EXISTS `v2`*/;
-/*!50001 CREATE ALGORITHM=UNDEFINED */
-/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
-/*!50001 VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') */
-/*!50002 WITH CASCADED CHECK OPTION */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -1477,37 +1462,10 @@ DROP TABLE IF EXISTS `v2`;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-drop table t2;
-drop view v2;
-drop database db1;
-create database db2;
-use db2;
-create table t1 (a int);
-create table t2 (a int, b varchar(10), primary key(a));
-insert into t2 values (1, "on"), (2, "off"), (10, "pol"), (12, "meg");
-insert into t1 values (289), (298), (234), (456), (789);
-create view v1 as select * from t2;
-create view v2 as select * from t1;
-drop table t1, t2;
-drop view v1, v2;
-drop database db2;
-create database db1;
-use db1;
-show tables;
-Tables_in_db1
-t1
-t2
-v1
-v2
-select * from t2 order by a;
-a b
-1 on
-2 off
-10 pol
-12 meg
-drop table t1, t2;
-drop database db1;
---fields-optionally-enclosed-by="
+DROP TABLE t1;
+#
+# Bug #9558 mysqldump --no-data db t1 t2 format still dumps data
+#
CREATE DATABASE mysqldump_test_db;
USE mysqldump_test_db;
CREATE TABLE t1 ( a INT );
@@ -1596,6 +1554,11 @@ CREATE TABLE `t2` (
</mysqldump>
DROP TABLE t1, t2;
DROP DATABASE mysqldump_test_db;
+#
+# Testing with tables and databases that don't exists
+# or contains illegal characters
+# (Bug #9358 mysqldump crashes if tablename starts with \)
+#
create database mysqldump_test_db;
use mysqldump_test_db;
create table t1(a varchar(30) primary key, b int not null);
@@ -1634,6 +1597,9 @@ mysqldump: Got error: 1102: Incorrect database name 'mysqld\ump_test_db' when se
drop table t1, t2, t3;
drop database mysqldump_test_db;
use test;
+#
+# Bug #9657 mysqldump xml ( -x ) does not format NULL fields correctly
+#
create table t1 (a int(10));
create table t2 (pk int primary key auto_increment,
a int(10), b varchar(30), c datetime, d blob, e text);
@@ -1690,6 +1656,9 @@ insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thir
</database>
</mysqldump>
drop table t1, t2;
+#
+# BUG #12123
+#
create table t1 (a text character set utf8, b text character set latin1);
insert t1 values (0x4F736E616272C3BC636B, 0x4BF66C6E);
select * from t1;
@@ -1700,6 +1669,13 @@ select * from t1;
a b
Osnabrück Köln
drop table t1;
+#
+# BUG#15328 Segmentation fault occured if my.cnf is invalid for escape sequence
+#
+--fields-optionally-enclosed-by="
+#
+# BUG #19025 mysqldump doesn't correctly dump "auto_increment = [int]"
+#
create table `t1` (
t1_name varchar(255) default null,
t1_id int(10) unsigned not null auto_increment,
@@ -1737,7 +1713,174 @@ t1 CREATE TABLE `t1` (
KEY `t1_name` (`t1_name`)
) ENGINE=MyISAM AUTO_INCREMENT=1003 DEFAULT CHARSET=latin1
drop table `t1`;
+#
+# Bug #18536: wrong table order
+#
+create table t1(a int);
+create table t2(a int);
+create table t3(a int);
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+DROP TABLE IF EXISTS `t3`;
+CREATE TABLE `t3` (
+ `a` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+DROP TABLE IF EXISTS `t1`;
+CREATE TABLE `t1` (
+ `a` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+DROP TABLE IF EXISTS `t2`;
+CREATE TABLE `t2` (
+ `a` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+drop table t1, t2, t3;
+#
+# Bug #21288: mysqldump segmentation fault when using --where
+#
+create table t1 (a int);
+mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `t1` WHERE xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': 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 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 (1064)
+mysqldump: Got error: 1064: 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 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 when retrieving data from server
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+DROP TABLE IF EXISTS `t1`;
+CREATE TABLE `t1` (
+ `a` int(11) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+drop table t1;
End of 4.1 tests
+#
+# Bug #10213 mysqldump crashes when dumping VIEWs(on MacOS X)
+#
+create database db1;
+use db1;
+CREATE TABLE t2 (
+a varchar(30) default NULL,
+KEY a (a(5))
+);
+INSERT INTO t2 VALUES ('alfred');
+INSERT INTO t2 VALUES ('angie');
+INSERT INTO t2 VALUES ('bingo');
+INSERT INTO t2 VALUES ('waffle');
+INSERT INTO t2 VALUES ('lemon');
+create view v2 as select * from t2 where a like 'a%' with check option;
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+DROP TABLE IF EXISTS `t2`;
+CREATE TABLE `t2` (
+ `a` varchar(30) default NULL,
+ KEY `a` (`a`(5))
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+LOCK TABLES `t2` WRITE;
+/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
+INSERT INTO `t2` VALUES ('alfred'),('angie'),('bingo'),('waffle'),('lemon');
+/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
+UNLOCK TABLES;
+DROP TABLE IF EXISTS `v2`;
+/*!50001 DROP VIEW IF EXISTS `v2`*/;
+/*!50001 CREATE TABLE `v2` (
+ `a` varchar(30)
+) */;
+/*!50001 DROP TABLE IF EXISTS `v2`*/;
+/*!50001 DROP VIEW IF EXISTS `v2`*/;
+/*!50001 CREATE ALGORITHM=UNDEFINED */
+/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
+/*!50001 VIEW `v2` AS select `t2`.`a` AS `a` from `t2` where (`t2`.`a` like _latin1'a%') */
+/*!50002 WITH CASCADED CHECK OPTION */;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+drop table t2;
+drop view v2;
+drop database db1;
+use test;
+#
+# Bug 10713 mysqldump includes database in create view and referenced tables
+#
+create database db2;
+use db2;
+create table t1 (a int);
+create table t2 (a int, b varchar(10), primary key(a));
+insert into t2 values (1, "on"), (2, "off"), (10, "pol"), (12, "meg");
+insert into t1 values (289), (298), (234), (456), (789);
+create view v1 as select * from t2;
+create view v2 as select * from t1;
+drop table t1, t2;
+drop view v1, v2;
+drop database db2;
+use test;
+create database db1;
+use db1;
+show tables;
+Tables_in_db1
+t1
+t2
+v1
+v2
+select * from t2 order by a;
+a b
+1 on
+2 off
+10 pol
+12 meg
+drop table t1, t2;
+drop database db1;
+use test;
create table t1(a int);
create view v1 as select * from t1;
@@ -1756,11 +1899,10 @@ CREATE TABLE `t1` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
-UNLOCK TABLES;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
@@ -1783,6 +1925,9 @@ DROP TABLE IF EXISTS `v1`;
drop view v1;
drop table t1;
+#
+# Bug #10213 mysqldump crashes when dumping VIEWs(on MacOS X)
+#
create database mysqldump_test_db;
use mysqldump_test_db;
CREATE TABLE t2 (
@@ -1812,12 +1957,11 @@ CREATE TABLE `t2` (
KEY `a` (`a`(5))
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
LOCK TABLES `t2` WRITE;
+/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
INSERT INTO `t2` VALUES ('alfred'),('angie'),('bingo'),('waffle'),('lemon');
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
+UNLOCK TABLES;
DROP TABLE IF EXISTS `v2`;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 CREATE TABLE `v2` (
@@ -1843,6 +1987,9 @@ drop table t2;
drop view v2;
drop database mysqldump_test_db;
use test;
+#
+# Bug #9756
+#
CREATE TABLE t1 (a char(10));
INSERT INTO t1 VALUES ('\'');
@@ -1861,12 +2008,11 @@ CREATE TABLE `t1` (
`a` char(10) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES ('\'');
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -1878,6 +2024,9 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
DROP TABLE t1;
+#
+# Bug #10927 mysqldump: Can't reload dump with view that consist of other view
+#
create table t1(a int, b int, c varchar(30));
insert into t1 values(1, 2, "one"), (2, 4, "two"), (3, 6, "three");
create view v3 as
@@ -1904,12 +2053,11 @@ CREATE TABLE `t1` (
`c` varchar(30) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (1,2,'one'),(2,4,'two'),(3,6,'three');
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
@@ -1956,6 +2104,9 @@ DROP TABLE IF EXISTS `v3`;
drop view v1, v2, v3;
drop table t1;
+#
+# Test for dumping triggers
+#
CREATE TABLE t1 (a int, b bigint default NULL);
CREATE TABLE t2 (a int);
create trigger trg1 before insert on t1 for each row
@@ -2021,12 +2172,11 @@ CREATE TABLE `t1` (
`b` bigint(20) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (1,NULL),(2,NULL),(4,NULL),(11,NULL);
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER ;;
@@ -2057,11 +2207,10 @@ CREATE TABLE `t2` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
LOCK TABLES `t2` WRITE;
-UNLOCK TABLES;
+/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
+UNLOCK TABLES;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER ;;
@@ -2105,22 +2254,20 @@ CREATE TABLE `t1` (
`b` bigint(20) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (1,NULL),(2,NULL),(4,NULL),(11,NULL);
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
DROP TABLE IF EXISTS `t2`;
CREATE TABLE `t2` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
LOCK TABLES `t2` WRITE;
-UNLOCK TABLES;
+/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
/*!40000 ALTER TABLE `t2` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -2158,8 +2305,14 @@ set @fired:= "No";
end if;
end BEFORE # STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER root@localhost
DROP TABLE t1, t2;
+#
+# Bugs #9136, #12917: problems with --defaults-extra-file option
+#
--port=1234
--port=1234
+#
+# Test of fix to BUG 12597
+#
DROP TABLE IF EXISTS `test1`;
Warnings:
Note 1051 Unknown table 'test1'
@@ -2191,6 +2344,9 @@ a2
DROP TRIGGER testref;
DROP TABLE test1;
DROP TABLE test2;
+#
+# BUG#9056 - mysqldump does not dump routines
+#
DROP TABLE IF EXISTS t1;
DROP FUNCTION IF EXISTS bug9056_func1;
DROP FUNCTION IF EXISTS bug9056_func2;
@@ -2234,12 +2390,11 @@ CREATE TABLE `t1` (
`id` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (1),(2),(3),(4),(5);
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
DELIMITER ;;
/*!50003 DROP FUNCTION IF EXISTS `bug9056_func1` */;;
/*!50003 SET SESSION SQL_MODE=""*/;;
@@ -2248,7 +2403,7 @@ RETURN a+b */;;
/*!50003 SET SESSION SQL_MODE=@OLD_SQL_MODE*/;;
/*!50003 DROP FUNCTION IF EXISTS `bug9056_func2` */;;
/*!50003 SET SESSION SQL_MODE=""*/;;
-/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `bug9056_func2`(f1 char binary) RETURNS char(1)
+/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 FUNCTION `bug9056_func2`(f1 char binary) RETURNS char(1) CHARSET latin1
begin
set f1= concat( 'hello', f1 );
return f1;
@@ -2288,6 +2443,9 @@ DROP PROCEDURE bug9056_proc1;
DROP PROCEDURE bug9056_proc2;
DROP PROCEDURE `a'b`;
drop table t1;
+#
+# BUG# 13052 - mysqldump timestamp reloads broken
+#
drop table if exists t1;
create table t1 (`d` timestamp, unique (`d`));
set time_zone='+00:00';
@@ -2323,12 +2481,11 @@ CREATE TABLE `t1` (
UNIQUE KEY `d` (`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES ('2003-10-25 22:00:00'),('2003-10-25 23:00:00');
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -2358,12 +2515,11 @@ CREATE TABLE `t1` (
UNIQUE KEY `d` (`d`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES ('2003-10-26 02:00:00'),('2003-10-26 02:00:00');
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
@@ -2376,6 +2532,9 @@ UNLOCK TABLES;
drop table t1;
set global time_zone=default;
set time_zone=default;
+#
+# Test of fix to BUG 13146 - ansi quotes break loading of triggers
+#
DROP TABLE IF EXISTS `t1 test`;
DROP TABLE IF EXISTS `t2 test`;
CREATE TABLE `t1 test` (
@@ -2405,12 +2564,11 @@ CREATE TABLE "t1 test" (
"a1" int(11) default NULL
);
-
-/*!40000 ALTER TABLE "t1 test" DISABLE KEYS */;
LOCK TABLES "t1 test" WRITE;
+/*!40000 ALTER TABLE "t1 test" DISABLE KEYS */;
INSERT INTO "t1 test" VALUES (1),(2),(3);
-UNLOCK TABLES;
/*!40000 ALTER TABLE "t1 test" ENABLE KEYS */;
+UNLOCK TABLES;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER ;;
@@ -2425,12 +2583,11 @@ CREATE TABLE "t2 test" (
"a2" int(11) default NULL
);
-
-/*!40000 ALTER TABLE "t2 test" DISABLE KEYS */;
LOCK TABLES "t2 test" WRITE;
+/*!40000 ALTER TABLE "t2 test" DISABLE KEYS */;
INSERT INTO "t2 test" VALUES (1),(2),(3);
-UNLOCK TABLES;
/*!40000 ALTER TABLE "t2 test" ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -2441,6 +2598,9 @@ UNLOCK TABLES;
DROP TRIGGER `test trig`;
DROP TABLE `t1 test`;
DROP TABLE `t2 test`;
+#
+# BUG# 12838 mysqldump -x with views exits with error
+#
drop table if exists t1;
create table t1 (a int, b varchar(32), c varchar(32));
insert into t1 values (1, 'first value', 'xxxx');
@@ -2476,12 +2636,11 @@ CREATE TABLE `t1` (
`c` varchar(32) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (1,'first value','xxxx'),(2,'second value','tttt'),(3,'third value','vvv vvv');
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
DROP TABLE IF EXISTS `v0`;
/*!50001 DROP VIEW IF EXISTS `v0`*/;
/*!50001 CREATE TABLE `v0` (
@@ -2503,6 +2662,8 @@ DROP TABLE IF EXISTS `v2`;
`b` varchar(32),
`c` varchar(32)
) */;
+
+USE `test`;
/*!50001 DROP TABLE IF EXISTS `v0`*/;
/*!50001 DROP VIEW IF EXISTS `v0`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
@@ -2532,6 +2693,10 @@ drop view v2;
drop view v0;
drop view v1;
drop table t1;
+#
+# BUG#14554 - mysqldump does not separate words "ROW" and "BEGIN"
+# for tables with trigger created in the IGNORE_SPACE sql mode.
+#
SET @old_sql_mode = @@SQL_MODE;
SET SQL_MODE = IGNORE_SPACE;
CREATE TABLE t1 (a INT);
@@ -2561,11 +2726,10 @@ CREATE TABLE `t1` (
`a` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
-UNLOCK TABLES;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!50003 SET @OLD_SQL_MODE=@@SQL_MODE*/;
DELIMITER ;;
@@ -2588,6 +2752,9 @@ DELIMITER ;
DROP TRIGGER tr1;
DROP TABLE t1;
+#
+# Bug #13318: Bad result with empty field and --hex-blob
+#
create table t1 (a binary(1), b blob);
insert into t1 values ('','');
@@ -2607,12 +2774,11 @@ CREATE TABLE `t1` (
`b` blob
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (0x00,'');
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -2640,12 +2806,11 @@ CREATE TABLE `t1` (
`b` blob
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (0x00,'');
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -2657,44 +2822,9 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
drop table t1;
-create table t1(a int);
-create table t2(a int);
-create table t3(a int);
-
-/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
-/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
-/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
-/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
-/*!40103 SET TIME_ZONE='+00:00' */;
-/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
-/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
-/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-DROP TABLE IF EXISTS `t3`;
-CREATE TABLE `t3` (
- `a` int(11) default NULL
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-DROP TABLE IF EXISTS `t1`;
-CREATE TABLE `t1` (
- `a` int(11) default NULL
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-DROP TABLE IF EXISTS `t2`;
-CREATE TABLE `t2` (
- `a` int(11) default NULL
-) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
-
-/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
-/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
-/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
-/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
-/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
-/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
-/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-
-drop table t1, t2, t3;
-End of 4.1 tests
+#
+# Bug 14871 Invalid view dump output
+#
create table t1 (a int);
insert into t1 values (289), (298), (234), (456), (789);
create definer = CURRENT_USER view v1 as select * from t1;
@@ -2721,6 +2851,9 @@ a
789
drop table t1;
drop view v1, v2, v3, v4, v5;
+#
+# Bug #16878 dump of trigger
+#
create table t1 (a int, created datetime);
create table t2 (b int, created datetime);
create trigger tr1 before insert on t1 for each row set
@@ -2743,6 +2876,9 @@ end AFTER # root@localhost
drop trigger tr1;
drop trigger tr2;
drop table t1, t2;
+#
+# Bug#18462 mysqldump does not dump view structures correctly
+#
create table t (qty int, price int);
insert into t values(3, 50);
insert into t values(5, 51);
@@ -2762,6 +2898,10 @@ mysqldump {
drop view v1;
drop view v2;
drop table t;
+#
+# Bug#14857 Reading dump files with single statement stored routines fails.
+# fixed by patch for bug#16878
+#
/*!50003 CREATE FUNCTION `f`() RETURNS bigint(20)
return 42 */|
/*!50003 CREATE PROCEDURE `p`()
@@ -2776,6 +2916,9 @@ p CREATE DEFINER=`root`@`localhost` PROCEDURE `p`()
select 42
drop function f;
drop procedure p;
+#
+# Bug #17371 Unable to dump a schema with invalid views
+#
create table t1 ( id serial );
create view v1 as select * from t1;
drop table t1;
@@ -2785,6 +2928,9 @@ mysqldump {
} mysqldump
drop view v1;
+# BUG#17201 Spurious 'DROP DATABASE' in output,
+# also confusion between tables and views.
+# Example code from Markus Popp
create database mysqldump_test_db;
use mysqldump_test_db;
create table t1 (id int);
@@ -2815,17 +2961,18 @@ CREATE TABLE `t1` (
`id` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
INSERT INTO `t1` VALUES (1232131),(4711),(3231),(815);
-UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
DROP TABLE IF EXISTS `v1`;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE TABLE `v1` (
`id` int(11)
) */;
+
+USE `mysqldump_test_db`;
/*!50001 DROP TABLE IF EXISTS `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 CREATE ALGORITHM=UNDEFINED */
@@ -2844,6 +2991,9 @@ DROP TABLE IF EXISTS `v1`;
drop view v1;
drop table t1;
drop database mysqldump_test_db;
+#
+# Bug21014 Segmentation fault of mysqldump on view
+#
create database mysqldump_tables;
use mysqldump_tables;
create table basetable ( id serial, tag varchar(64) );
@@ -2851,46 +3001,189 @@ create database mysqldump_views;
use mysqldump_views;
create view nasishnasifu as select mysqldump_tables.basetable.id from mysqldump_tables.basetable;
-/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
-/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
-/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
-/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
-/*!40103 SET TIME_ZONE='+00:00' */;
-/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
-/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
-/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
-/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
-
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_tables` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `mysqldump_tables`;
-DROP TABLE IF EXISTS `basetable`;
CREATE TABLE `basetable` (
`id` bigint(20) unsigned NOT NULL auto_increment,
`tag` varchar(64) default NULL,
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
-/*!40000 ALTER TABLE `basetable` DISABLE KEYS */;
-LOCK TABLES `basetable` WRITE;
-UNLOCK TABLES;
-/*!40000 ALTER TABLE `basetable` ENABLE KEYS */;
-
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_views` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `mysqldump_views`;
-DROP TABLE IF EXISTS `nasishnasifu`;
-/*!50001 DROP VIEW IF EXISTS `nasishnasifu`*/;
/*!50001 CREATE TABLE `nasishnasifu` (
`id` bigint(20) unsigned
) */;
-/*!50001 DROP TABLE IF EXISTS `nasishnasifu`*/;
-/*!50001 DROP VIEW IF EXISTS `nasishnasifu`*/;
+
+USE `mysqldump_tables`;
+
+USE `mysqldump_views`;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `mysqldump_views`.`nasishnasifu` AS select `mysqldump_tables`.`basetable`.`id` AS `id` from `mysqldump_tables`.`basetable` */;
+drop view nasishnasifu;
+drop database mysqldump_views;
+drop table mysqldump_tables.basetable;
+drop database mysqldump_tables;
+#
+# Bug20221 Dumping of multiple databases containing view(s) yields maleformed dumps
+#
+create database mysqldump_dba;
+use mysqldump_dba;
+create table t1 (f1 int, f2 int);
+insert into t1 values (1,1);
+create view v1 as select f1, f2 from t1;
+create database mysqldump_dbb;
+use mysqldump_dbb;
+create table t1 (f1 int, f2 int);
+insert into t1 values (2,2);
+create view v1 as select f1, f2 from t1;
+drop view v1;
+drop table t1;
+drop database mysqldump_dbb;
+use mysqldump_dba;
+drop view v1;
+drop table t1;
+drop database mysqldump_dba;
+select * from mysqldump_dba.v1;
+f1 f2
+1 1
+select * from mysqldump_dbb.v1;
+f1 f2
+2 2
+use mysqldump_dba;
+drop view v1;
+drop table t1;
+drop database mysqldump_dba;
+use mysqldump_dbb;
+drop view v1;
+drop table t1;
+drop database mysqldump_dbb;
+use test;
+#
+# Bug#21215 mysqldump creating incomplete backups without warning
+#
+create user mysqltest_1@localhost;
+create table t1(a int, b varchar(34));
+reset master;
+mysqldump: Couldn't execute 'FLUSH TABLES': Access denied; you need the RELOAD privilege for this operation (1227)
+mysqldump: Couldn't execute 'FLUSH TABLES': Access denied; you need the RELOAD privilege for this operation (1227)
+grant RELOAD on *.* to mysqltest_1@localhost;
+mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need the SUPER,REPLICATION CLIENT privilege for this operation (1227)
+mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need the SUPER,REPLICATION CLIENT privilege for this operation (1227)
+grant REPLICATION CLIENT on *.* to mysqltest_1@localhost;
+CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=537;
+CREATE TABLE `t1` (
+ `a` int(11) default NULL,
+ `b` varchar(34) default NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+drop table t1;
+drop user mysqltest_1@localhost;
+#
+# Bug #21527 mysqldump incorrectly tries to LOCK TABLES on the
+# information_schema database.
+#
+# Bug #21424 mysqldump failing to export/import views
+#
+create database mysqldump_myDB;
+use mysqldump_myDB;
+create user myDB_User;
+grant create, create view, select, insert on mysqldump_myDB.* to myDB_User@localhost;
+create table t1 (c1 int);
+insert into t1 values (3);
+use mysqldump_myDB;
+create table u1 (f1 int);
+insert into u1 values (4);
+create view v1 (c1) as select * from t1;
+use mysqldump_myDB;
+drop view v1;
+drop table t1;
+drop table u1;
+revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
+drop user myDB_User;
+drop database mysqldump_myDB;
+flush privileges;
+# Bug #21424 continues from here.
+# Restore. Flush Privileges test ends.
+#
+use mysqldump_myDB;
+select * from mysqldump_myDB.v1;
+c1
+3
+select * from mysqldump_myDB.u1;
+f1
+4
+use mysqldump_myDB;
+drop view v1;
+drop table t1;
+drop table u1;
+revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
+drop user myDB_User;
+drop database mysqldump_myDB;
+use test;
+#
+# BUG#13926: --order-by-primary fails if PKEY contains quote character
+#
+DROP TABLE IF EXISTS `t1`;
+CREATE TABLE `t1` (
+`a b` INT,
+`c"d` INT,
+`e``f` INT,
+PRIMARY KEY (`a b`, `c"d`, `e``f`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+insert into t1 values (0815, 4711, 2006);
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO,ANSI' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+DROP TABLE IF EXISTS "t1";
+CREATE TABLE "t1" (
+ "a b" int(11) NOT NULL default '0',
+ "c""d" int(11) NOT NULL default '0',
+ "e`f" int(11) NOT NULL default '0',
+ PRIMARY KEY ("a b","c""d","e`f")
+);
+
+LOCK TABLES "t1" WRITE;
+/*!40000 ALTER TABLE "t1" DISABLE KEYS */;
+INSERT INTO "t1" VALUES (815,4711,2006);
+/*!40000 ALTER TABLE "t1" ENABLE KEYS */;
+UNLOCK TABLES;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+DROP TABLE IF EXISTS `t1`;
+CREATE TABLE `t1` (
+ `a b` int(11) NOT NULL default '0',
+ `c"d` int(11) NOT NULL default '0',
+ `e``f` int(11) NOT NULL default '0',
+ PRIMARY KEY (`a b`,`c"d`,`e``f`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
+INSERT INTO `t1` VALUES (815,4711,2006);
+/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
@@ -2901,7 +3194,7 @@ DROP TABLE IF EXISTS `nasishnasifu`;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-drop view nasishnasifu;
-drop database mysqldump_views;
-drop table mysqldump_tables.basetable;
-drop database mysqldump_tables;
+DROP TABLE `t1`;
+#
+# End of 5.0 tests
+#
diff --git a/mysql-test/r/mysqlshow.result b/mysql-test/r/mysqlshow.result
index 942cde83f21..2bf8a58de4e 100644
--- a/mysql-test/r/mysqlshow.result
+++ b/mysql-test/r/mysqlshow.result
@@ -75,3 +75,52 @@ Database: test
2 rows in set.
DROP TABLE t1, t2;
+Database: information_schema
++---------------------------------------+
+| Tables |
++---------------------------------------+
+| CHARACTER_SETS |
+| COLLATIONS |
+| COLLATION_CHARACTER_SET_APPLICABILITY |
+| COLUMNS |
+| COLUMN_PRIVILEGES |
+| KEY_COLUMN_USAGE |
+| ROUTINES |
+| SCHEMATA |
+| SCHEMA_PRIVILEGES |
+| STATISTICS |
+| TABLES |
+| TABLE_CONSTRAINTS |
+| TABLE_PRIVILEGES |
+| TRIGGERS |
+| USER_PRIVILEGES |
+| VIEWS |
++---------------------------------------+
+Database: INFORMATION_SCHEMA
++---------------------------------------+
+| Tables |
++---------------------------------------+
+| CHARACTER_SETS |
+| COLLATIONS |
+| COLLATION_CHARACTER_SET_APPLICABILITY |
+| COLUMNS |
+| COLUMN_PRIVILEGES |
+| KEY_COLUMN_USAGE |
+| ROUTINES |
+| SCHEMATA |
+| SCHEMA_PRIVILEGES |
+| STATISTICS |
+| TABLES |
+| TABLE_CONSTRAINTS |
+| TABLE_PRIVILEGES |
+| TRIGGERS |
+| USER_PRIVILEGES |
+| VIEWS |
++---------------------------------------+
+Wildcard: inf_rmation_schema
++--------------------+
+| Databases |
++--------------------+
+| information_schema |
++--------------------+
+End of 5.0 tests
diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result
index 8055a33ec7d..d9ca863b6bc 100644
--- a/mysql-test/r/mysqltest.result
+++ b/mysql-test/r/mysqltest.result
@@ -441,3 +441,9 @@ select-me
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 'insertz error query' at line 1
drop table t1;
drop table t1;
+sleep;
+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 'sleep' at line 1
+sleep;
+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 'sleep' at line 1
+;
+ERROR 42000: Query was empty
diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result
index 09c4f9b29f9..d2111db24fe 100644
--- a/mysql-test/r/ndb_basic.result
+++ b/mysql-test/r/ndb_basic.result
@@ -748,3 +748,4 @@ f1 f2 f3
111111 aaaaaa 1
222222 bbbbbb 2
drop table t1;
+Illegal ndb error code: 1186
diff --git a/mysql-test/r/ndb_condition_pushdown.result b/mysql-test/r/ndb_condition_pushdown.result
index 4e5597a4851..aefbcbf6ede 100644
--- a/mysql-test/r/ndb_condition_pushdown.result
+++ b/mysql-test/r/ndb_condition_pushdown.result
@@ -1307,7 +1307,7 @@ select auto from t1 where
('1901-01-01 01:01:01' between date_time and date_time)
order by auto;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort
+1 SIMPLE t1 range medium_index medium_index 3 NULL 10 Using where with pushed condition; Using filesort
select auto from t1 where
("aaaa" between string and string) and
("aaaa" between vstring and vstring) and
@@ -1409,7 +1409,7 @@ select auto from t1 where
('1901-01-01 01:01:01' not between date_time and date_time)
order by auto;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where with pushed condition; Using filesort
+1 SIMPLE t1 range medium_index medium_index 3 NULL 20 Using where with pushed condition; Using filesort
select auto from t1 where
("aaaa" not between string and string) and
("aaaa" not between vstring and vstring) and
diff --git a/mysql-test/r/ndb_lock.result b/mysql-test/r/ndb_lock.result
index 3b433023843..2c212b9cfef 100644
--- a/mysql-test/r/ndb_lock.result
+++ b/mysql-test/r/ndb_lock.result
@@ -64,17 +64,26 @@ pk u o
insert into t1 values (1,1,1);
drop table t1;
create table t1 (x integer not null primary key, y varchar(32), z integer, key(z)) engine = ndb;
-insert into t1 values (1,'one',1), (2,'two',2),(3,"three",3);
+insert into t1 values (1,'one',1);
begin;
select * from t1 where x = 1 for update;
x y z
1 one 1
begin;
-select * from t1 where x = 2 for update;
+select * from t1 where x = 1 for update;
+ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+rollback;
+rollback;
+insert into t1 values (2,'two',2),(3,"three",3);
+begin;
+select * from t1 where x = 1 for update;
x y z
-2 two 2
+1 one 1
select * from t1 where x = 1 for update;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
+select * from t1 where x = 2 for update;
+x y z
+2 two 2
rollback;
commit;
begin;
diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result
index 18eb10f0673..daedfa50b80 100644
--- a/mysql-test/r/null.result
+++ b/mysql-test/r/null.result
@@ -97,39 +97,39 @@ Warnings:
Warning 1265 Data truncated for column 'd' at row 1
UPDATE t1 SET d=NULL;
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'd' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'd' at row 1
INSERT INTO t1 (a) values (null);
ERROR 23000: Column 'a' cannot be null
INSERT INTO t1 (a) values (1/null);
ERROR 23000: Column 'a' cannot be null
INSERT INTO t1 (a) values (null),(null);
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' at row 1
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' at row 2
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'a' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'a' at row 2
INSERT INTO t1 (b) values (null);
ERROR 23000: Column 'b' cannot be null
INSERT INTO t1 (b) values (1/null);
ERROR 23000: Column 'b' cannot be null
INSERT INTO t1 (b) values (null),(null);
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'b' at row 1
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'b' at row 2
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'b' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'b' at row 2
INSERT INTO t1 (c) values (null);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) values (1/null);
ERROR 23000: Column 'c' cannot be null
INSERT INTO t1 (c) values (null),(null);
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'c' at row 1
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'c' at row 2
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'c' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'c' at row 2
INSERT INTO t1 (d) values (null);
ERROR 23000: Column 'd' cannot be null
INSERT INTO t1 (d) values (1/null);
ERROR 23000: Column 'd' cannot be null
INSERT INTO t1 (d) values (null),(null);
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'd' at row 1
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'd' at row 2
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'd' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for 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 7f746a3dbd8..6eb3cf312a0 100644
--- a/mysql-test/r/null_key.result
+++ b/mysql-test/r/null_key.result
@@ -342,7 +342,7 @@ index (id2)
);
insert into t1 values(null,null),(1,1);
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'id2' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for 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 2d9d39393b1..5629d3dab33 100644
--- a/mysql-test/r/odbc.result
+++ b/mysql-test/r/odbc.result
@@ -14,3 +14,14 @@ explain select * from t1 where b is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
drop table t1;
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY);
+INSERT INTO t1 VALUES (NULL);
+SELECT sql_no_cache a, last_insert_id() FROM t1 WHERE a IS NULL;
+a last_insert_id()
+1 1
+SELECT sql_no_cache a, last_insert_id() FROM t1 WHERE a IS NULL;
+a last_insert_id()
+SELECT sql_no_cache a, last_insert_id() FROM t1;
+a last_insert_id()
+1 1
+DROP TABLE t1;
diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result
index 225e306b3cf..7cdd5e1b152 100644
--- a/mysql-test/r/olap.result
+++ b/mysql-test/r/olap.result
@@ -611,7 +611,7 @@ C
NULL
EXPLAIN SELECT type FROM v1 GROUP BY type WITH ROLLUP;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using filesort
+1 SIMPLE t1 ALL NULL NULL NULL NULL 10 Using filesort
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 (a int(11) NOT NULL);
@@ -620,8 +620,8 @@ CREATE VIEW v1 AS
SELECT a, LENGTH(a), COUNT(*) FROM t1 GROUP BY a WITH ROLLUP;
DESC v1;
Field Type Null Key Default Extra
-a bigint(11) YES NULL
-LENGTH(a) bigint(10) YES NULL
+a int(11) YES 0
+LENGTH(a) int(10) YES NULL
COUNT(*) bigint(21) NO 0
SELECT * FROM v1;
a LENGTH(a) COUNT(*)
diff --git a/mysql-test/r/openssl_1.result b/mysql-test/r/openssl_1.result
index 1fcfb11525e..8f9fd50eced 100644
--- a/mysql-test/r/openssl_1.result
+++ b/mysql-test/r/openssl_1.result
@@ -3,9 +3,12 @@ create table t1(f1 int);
insert into t1 values (5);
grant select on test.* to ssl_user1@localhost require SSL;
grant select on test.* to ssl_user2@localhost require cipher "DHE-RSA-AES256-SHA";
-grant select on test.* to ssl_user3@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "/C=SE/L=Uppsala/O=MySQL AB/CN=MySQL Client/emailAddress=abstract.mysql.developer@mysql.com";
-grant select on test.* to ssl_user4@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "/C=SE/L=Uppsala/O=MySQL AB/CN=MySQL Client/emailAddress=abstract.mysql.developer@mysql.com" ISSUER "/C=SE/L=Uppsala/O=MySQL AB/CN=Abstract MySQL Developer/emailAddress=abstract.mysql.developer@mysql.com";
+grant select on test.* to ssl_user3@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "/C=SE/ST=Uppsala/L=Uppsala/O=MySQL AB";
+grant select on test.* to ssl_user4@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "/C=SE/ST=Uppsala/L=Uppsala/O=MySQL AB" ISSUER "/C=SE/ST=Uppsala/L=Uppsala/O=MySQL AB";
+grant select on test.* to ssl_user5@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "xxx";
flush privileges;
+connect(localhost,ssl_user5,,test,MASTER_PORT,MASTER_SOCKET);
+ERROR 28000: Access denied for user 'ssl_user5'@'localhost' (using password: NO)
SHOW STATUS LIKE 'Ssl_cipher';
Variable_name Value
Ssl_cipher DHE-RSA-AES256-SHA
@@ -39,7 +42,7 @@ f1
delete from t1;
ERROR 42000: DELETE command denied to user 'ssl_user4'@'localhost' for table 't1'
drop user ssl_user1@localhost, ssl_user2@localhost,
-ssl_user3@localhost, ssl_user4@localhost;
+ssl_user3@localhost, ssl_user4@localhost, ssl_user5@localhost;
drop table t1;
mysqltest: Could not open connection 'default': 2026 SSL connection error
mysqltest: Could not open connection 'default': 2026 SSL connection error
diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result
index a36935a583d..64653de5e9c 100644
--- a/mysql-test/r/order_by.result
+++ b/mysql-test/r/order_by.result
@@ -280,6 +280,8 @@ info text NOT NULL default '',
ipnr varchar(30) NOT NULL default '',
PRIMARY KEY (member_id)
) ENGINE=MyISAM PACK_KEYS=1;
+Warnings:
+Warning 1101 BLOB/TEXT column 'info' can't have a default value
insert into t1 (member_id) values (1),(2),(3);
select member_id, nickname, voornaam FROM t1
ORDER by lastchange_datum DESC LIMIT 2;
@@ -852,3 +854,40 @@ b a
20 1
10 2
DROP TABLE t1;
+CREATE TABLE t1 (a int, b int, PRIMARY KEY (a));
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
+explain SELECT t1.b as a, t2.b as c FROM
+t1 LEFT JOIN t1 t2 ON (t1.a = t2.a AND t2.a = 2)
+ORDER BY c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
+1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1
+SELECT t2.b as c FROM
+t1 LEFT JOIN t1 t2 ON (t1.a = t2.a AND t2.a = 2)
+ORDER BY c;
+c
+NULL
+NULL
+2
+explain SELECT t1.b as a, t2.b as c FROM
+t1 JOIN t1 t2 ON (t1.a = t2.a AND t2.a = 2)
+ORDER BY c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1
+1 SIMPLE t2 const PRIMARY PRIMARY 4 const 1
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 SELECT * from t1;
+CREATE TABLE t3 LIKE t1;
+INSERT INTO t3 SELECT * from t1;
+CREATE TABLE t4 LIKE t1;
+INSERT INTO t4 SELECT * from t1;
+INSERT INTO t1 values (0,0),(4,4);
+SELECT t2.b FROM t1 LEFT JOIN (t2, t3 LEFT JOIN t4 ON t3.a=t4.a)
+ON (t1.a=t2.a AND t1.b=t3.b) order by t2.b;
+b
+NULL
+NULL
+1
+2
+3
+DROP TABLE t1,t2,t3,t4;
diff --git a/mysql-test/r/perror.result b/mysql-test/r/perror.result
new file mode 100644
index 00000000000..4946523bc42
--- /dev/null
+++ b/mysql-test/r/perror.result
@@ -0,0 +1 @@
+Illegal error code: 10000
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index 3ce2f5169e2..080187cfa7b 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -485,6 +485,20 @@ execute stmt;
pnum
deallocate prepare stmt;
drop table t1, t2;
+drop table if exists t1;
+create temporary table if not exists t1 (a1 int);
+prepare stmt from "delete t1 from t1 where (cast(a1/3 as unsigned) * 3) = a1";
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+execute stmt;
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+execute stmt;
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+execute stmt;
+drop temporary table t1;
+deallocate prepare stmt;
create table t1 (a varchar(20));
insert into t1 values ('foo');
prepare stmt FROM 'SELECT char_length (a) FROM t1';
@@ -502,77 +516,6 @@ SELECT FOUND_ROWS();
FOUND_ROWS()
2
deallocate prepare stmt;
-create table t1 (a char(3) not null, b char(3) not null,
-c char(3) not null, primary key (a, b, c));
-create table t2 like t1;
-prepare stmt from
-"select t1.a from (t1 left outer join t2 on t2.a=1 and t1.b=t2.b)
- where t1.a=1";
-execute stmt;
-a
-execute stmt;
-a
-execute stmt;
-a
-prepare stmt from
-"select t1.a, t1.b, t1.c, t2.a, t2.b, t2.c from
-(t1 left outer join t2 on t2.a=? and t1.b=t2.b)
-left outer join t2 t3 on t3.a=? where t1.a=?";
-set @a:=1, @b:=1, @c:=1;
-execute stmt using @a, @b, @c;
-a b c a b c
-execute stmt using @a, @b, @c;
-a b c a b c
-execute stmt using @a, @b, @c;
-a b c a b c
-deallocate prepare stmt;
-drop table t1,t2;
-SET @aux= "SELECT COUNT(*)
- FROM INFORMATION_SCHEMA.COLUMNS A,
- INFORMATION_SCHEMA.COLUMNS B
- WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
- AND A.TABLE_NAME = B.TABLE_NAME
- AND A.COLUMN_NAME = B.COLUMN_NAME AND
- A.TABLE_NAME = 'user'";
-prepare my_stmt from @aux;
-execute my_stmt;
-COUNT(*)
-37
-execute my_stmt;
-COUNT(*)
-37
-execute my_stmt;
-COUNT(*)
-37
-deallocate prepare my_stmt;
-drop procedure if exists p1|
-drop table if exists t1|
-create table t1 (id int)|
-insert into t1 values(1)|
-create procedure p1(a int, b int)
-begin
-declare c int;
-select max(id)+1 into c from t1;
-insert into t1 select a+b;
-insert into t1 select a-b;
-insert into t1 select a-c;
-end|
-set @a= 3, @b= 4|
-prepare stmt from "call p1(?, ?)"|
-execute stmt using @a, @b|
-execute stmt using @a, @b|
-select * from t1|
-id
-1
-7
--1
-1
-7
--1
--5
-deallocate prepare stmt|
-drop procedure p1|
-drop table t1|
drop table if exists t1;
Warnings:
Note 1051 Unknown table 't1'
@@ -636,47 +579,6 @@ id
3
deallocate prepare stmt;
drop table t1, t2;
-create table t1 (a int);
-insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
-prepare stmt from "select * from t1 limit ?, ?";
-set @offset=0, @limit=1;
-execute stmt using @offset, @limit;
-a
-1
-select * from t1 limit 0, 1;
-a
-1
-set @offset=3, @limit=2;
-execute stmt using @offset, @limit;
-a
-4
-5
-select * from t1 limit 3, 2;
-a
-4
-5
-prepare stmt from "select * from t1 limit ?";
-execute stmt using @limit;
-a
-1
-2
-prepare stmt from "select * from t1 where a in (select a from t1 limit ?)";
-ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
-prepare stmt from "select * from t1 union all select * from t1 limit ?, ?";
-set @offset=9;
-set @limit=2;
-execute stmt using @offset, @limit;
-a
-10
-1
-prepare stmt from "(select * from t1 limit ?, ?) union all
- (select * from t1 limit ?, ?) order by a limit ?";
-execute stmt using @offset, @limit, @offset, @limit, @limit;
-a
-10
-10
-drop table t1;
-deallocate prepare stmt;
create table t1 (id int);
prepare stmt from "insert into t1 (id) select id from t1 union select id from t1";
execute stmt;
@@ -777,15 +679,6 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
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 '? from t1' at line 1
drop table t1;
-CREATE TABLE b12651_T1(a int) ENGINE=MYISAM;
-CREATE TABLE b12651_T2(b int) ENGINE=MYISAM;
-CREATE VIEW b12651_V1 as SELECT b FROM b12651_T2;
-PREPARE b12651 FROM 'SELECT 1 FROM b12651_T1 WHERE a IN (SELECT b FROM b12651_V1)';
-EXECUTE b12651;
-1
-DROP VIEW b12651_V1;
-DROP TABLE b12651_T1, b12651_T2;
-DEALLOCATE PREPARE b12651;
prepare stmt from "select @@time_zone";
execute stmt;
@@time_zone
@@ -1002,6 +895,147 @@ select @@max_prepared_stmt_count, @@prepared_stmt_count;
@@max_prepared_stmt_count @@prepared_stmt_count
3 0
set global max_prepared_stmt_count= @old_max_prepared_stmt_count;
+drop table if exists t1;
+create temporary table if not exists t1 (a1 int);
+prepare stmt from "delete t1 from t1 where (cast(a1/3 as unsigned) * 3) = a1";
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+execute stmt;
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+execute stmt;
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+execute stmt;
+drop temporary table t1;
+deallocate prepare stmt;
+End of 4.1 tests
+create table t1 (a varchar(20));
+insert into t1 values ('foo');
+prepare stmt FROM 'SELECT char_length (a) FROM t1';
+ERROR 42000: FUNCTION test.char_length does not exist
+drop table t1;
+create table t1 (a char(3) not null, b char(3) not null,
+c char(3) not null, primary key (a, b, c));
+create table t2 like t1;
+prepare stmt from
+"select t1.a from (t1 left outer join t2 on t2.a=1 and t1.b=t2.b)
+ where t1.a=1";
+execute stmt;
+a
+execute stmt;
+a
+execute stmt;
+a
+prepare stmt from
+"select t1.a, t1.b, t1.c, t2.a, t2.b, t2.c from
+(t1 left outer join t2 on t2.a=? and t1.b=t2.b)
+left outer join t2 t3 on t3.a=? where t1.a=?";
+set @a:=1, @b:=1, @c:=1;
+execute stmt using @a, @b, @c;
+a b c a b c
+execute stmt using @a, @b, @c;
+a b c a b c
+execute stmt using @a, @b, @c;
+a b c a b c
+deallocate prepare stmt;
+drop table t1,t2;
+SET @aux= "SELECT COUNT(*)
+ FROM INFORMATION_SCHEMA.COLUMNS A,
+ INFORMATION_SCHEMA.COLUMNS B
+ WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
+ AND A.TABLE_NAME = B.TABLE_NAME
+ AND A.COLUMN_NAME = B.COLUMN_NAME AND
+ A.TABLE_NAME = 'user'";
+prepare my_stmt from @aux;
+execute my_stmt;
+COUNT(*)
+37
+execute my_stmt;
+COUNT(*)
+37
+execute my_stmt;
+COUNT(*)
+37
+deallocate prepare my_stmt;
+drop procedure if exists p1|
+drop table if exists t1|
+create table t1 (id int)|
+insert into t1 values(1)|
+create procedure p1(a int, b int)
+begin
+declare c int;
+select max(id)+1 into c from t1;
+insert into t1 select a+b;
+insert into t1 select a-b;
+insert into t1 select a-c;
+end|
+set @a= 3, @b= 4|
+prepare stmt from "call p1(?, ?)"|
+execute stmt using @a, @b|
+execute stmt using @a, @b|
+select * from t1|
+id
+1
+7
+-1
+1
+7
+-1
+-5
+deallocate prepare stmt|
+drop procedure p1|
+drop table t1|
+create table t1 (a int);
+insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+prepare stmt from "select * from t1 limit ?, ?";
+set @offset=0, @limit=1;
+execute stmt using @offset, @limit;
+a
+1
+select * from t1 limit 0, 1;
+a
+1
+set @offset=3, @limit=2;
+execute stmt using @offset, @limit;
+a
+4
+5
+select * from t1 limit 3, 2;
+a
+4
+5
+prepare stmt from "select * from t1 limit ?";
+execute stmt using @limit;
+a
+1
+2
+prepare stmt from "select * from t1 where a in (select a from t1 limit ?)";
+ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
+prepare stmt from "select * from t1 union all select * from t1 limit ?, ?";
+set @offset=9;
+set @limit=2;
+execute stmt using @offset, @limit;
+a
+10
+1
+prepare stmt from "(select * from t1 limit ?, ?) union all
+ (select * from t1 limit ?, ?) order by a limit ?";
+execute stmt using @offset, @limit, @offset, @limit, @limit;
+a
+10
+10
+drop table t1;
+deallocate prepare stmt;
+CREATE TABLE b12651_T1(a int) ENGINE=MYISAM;
+CREATE TABLE b12651_T2(b int) ENGINE=MYISAM;
+CREATE VIEW b12651_V1 as SELECT b FROM b12651_T2;
+PREPARE b12651 FROM 'SELECT 1 FROM b12651_T1 WHERE a IN (SELECT b FROM b12651_V1)';
+EXECUTE b12651;
+1
+DROP VIEW b12651_V1;
+DROP TABLE b12651_T1, b12651_T2;
+DEALLOCATE PREPARE b12651;
create table t1 (id int);
prepare ins_call from "insert into t1 (id) values (1)";
execute ins_call;
@@ -1263,3 +1297,18 @@ ERROR 3D000: No database selected
create temporary table t1 (i int);
ERROR 3D000: No database selected
use test;
+DROP TABLE IF EXISTS t1, t2, t3;
+CREATE TABLE t1 (i BIGINT, j BIGINT);
+CREATE TABLE t2 (i BIGINT);
+CREATE TABLE t3 (i BIGINT, j BIGINT);
+PREPARE stmt FROM "SELECT * FROM t1 JOIN t2 ON (t2.i = t1.i)
+ LEFT JOIN t3 ON ((t3.i, t3.j) = (t1.i, t1.j))
+ WHERE t1.i = ?";
+SET @a= 1;
+EXECUTE stmt USING @a;
+i j i i j
+EXECUTE stmt USING @a;
+i j i i j
+DEALLOCATE PREPARE stmt;
+DROP TABLE IF EXISTS t1, t2, t3;
+End of 5.0 tests.
diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result
index 3c736a508d3..ac8ae6def9f 100644
--- a/mysql-test/r/ps_1general.result
+++ b/mysql-test/r/ps_1general.result
@@ -298,7 +298,7 @@ t9 MyISAM 10 Dynamic 2 216 432 # 2048 0 NULL # # # latin1_swedish_ci NULL
prepare stmt4 from ' show status like ''Threads_running'' ';
execute stmt4;
Variable_name Value
-Threads_running 1
+Threads_running #
prepare stmt4 from ' show variables like ''sql_mode'' ';
execute stmt4;
Variable_name Value
diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result
index 92dc7c342d3..2a7b0e959af 100644
--- a/mysql-test/r/ps_2myisam.result
+++ b/mysql-test/r/ps_2myisam.result
@@ -1304,7 +1304,7 @@ set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'a' at row 1
select a,b from t1 order by a;
a b
0 two
@@ -1775,7 +1775,7 @@ NULL as const12, @arg12 as param12,
show create table t5 ;
Table Create Table
t5 CREATE TABLE `t5` (
- `const01` bigint(1) NOT NULL default '0',
+ `const01` int(1) NOT NULL default '0',
`param01` bigint(20) default NULL,
`const02` decimal(2,1) NOT NULL default '0.0',
`param02` decimal(65,30) default NULL,
@@ -1805,7 +1805,7 @@ t5 CREATE TABLE `t5` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t5 ;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
-def test t5 t5 const01 const01 8 1 1 N 32769 0 63
+def test t5 t5 const01 const01 3 1 1 N 32769 0 63
def test t5 t5 param01 param01 8 20 1 Y 32768 0 63
def test t5 t5 const02 const02 246 4 3 N 1 1 63
def test t5 t5 param02 param02 246 67 32 Y 0 30 63
diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result
index 243e6fcd3bf..88e8bf3ce04 100644
--- a/mysql-test/r/ps_3innodb.result
+++ b/mysql-test/r/ps_3innodb.result
@@ -1287,7 +1287,7 @@ set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'a' at row 1
select a,b from t1 order by a;
a b
0 two
@@ -1758,7 +1758,7 @@ NULL as const12, @arg12 as param12,
show create table t5 ;
Table Create Table
t5 CREATE TABLE `t5` (
- `const01` bigint(1) NOT NULL default '0',
+ `const01` int(1) NOT NULL default '0',
`param01` bigint(20) default NULL,
`const02` decimal(2,1) NOT NULL default '0.0',
`param02` decimal(65,30) default NULL,
@@ -1788,7 +1788,7 @@ t5 CREATE TABLE `t5` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t5 ;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
-def test t5 t5 const01 const01 8 1 1 N 32769 0 63
+def test t5 t5 const01 const01 3 1 1 N 32769 0 63
def test t5 t5 param01 param01 8 20 1 Y 32768 0 63
def test t5 t5 const02 const02 246 4 3 N 1 1 63
def test t5 t5 param02 param02 246 67 32 Y 0 30 63
diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result
index 524e8b4ff68..0e4c6fc3077 100644
--- a/mysql-test/r/ps_4heap.result
+++ b/mysql-test/r/ps_4heap.result
@@ -1288,7 +1288,7 @@ set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'a' at row 1
select a,b from t1 order by a;
a b
0 two
@@ -1759,7 +1759,7 @@ NULL as const12, @arg12 as param12,
show create table t5 ;
Table Create Table
t5 CREATE TABLE `t5` (
- `const01` bigint(1) NOT NULL default '0',
+ `const01` int(1) NOT NULL default '0',
`param01` bigint(20) default NULL,
`const02` decimal(2,1) NOT NULL default '0.0',
`param02` decimal(65,30) default NULL,
@@ -1789,7 +1789,7 @@ t5 CREATE TABLE `t5` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t5 ;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
-def test t5 t5 const01 const01 8 1 1 N 32769 0 63
+def test t5 t5 const01 const01 3 1 1 N 32769 0 63
def test t5 t5 param01 param01 8 20 1 Y 32768 0 63
def test t5 t5 const02 const02 246 4 3 N 1 1 63
def test t5 t5 param02 param02 246 67 32 Y 0 30 63
diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result
index 831037496af..1e337072ecb 100644
--- a/mysql-test/r/ps_5merge.result
+++ b/mysql-test/r/ps_5merge.result
@@ -1330,7 +1330,7 @@ set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'a' at row 1
select a,b from t1 order by a;
a b
0 two
@@ -1695,7 +1695,7 @@ NULL as const12, @arg12 as param12,
show create table t5 ;
Table Create Table
t5 CREATE TABLE `t5` (
- `const01` bigint(1) NOT NULL default '0',
+ `const01` int(1) NOT NULL default '0',
`param01` bigint(20) default NULL,
`const02` decimal(2,1) NOT NULL default '0.0',
`param02` decimal(65,30) default NULL,
@@ -1725,7 +1725,7 @@ t5 CREATE TABLE `t5` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t5 ;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
-def test t5 t5 const01 const01 8 1 1 N 32769 0 63
+def test t5 t5 const01 const01 3 1 1 N 32769 0 63
def test t5 t5 param01 param01 8 20 1 Y 32768 0 63
def test t5 t5 const02 const02 246 4 3 N 1 1 63
def test t5 t5 param02 param02 246 67 32 Y 0 30 63
@@ -4344,7 +4344,7 @@ set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'a' at row 1
select a,b from t1 order by a;
a b
0 two
@@ -4709,7 +4709,7 @@ NULL as const12, @arg12 as param12,
show create table t5 ;
Table Create Table
t5 CREATE TABLE `t5` (
- `const01` bigint(1) NOT NULL default '0',
+ `const01` int(1) NOT NULL default '0',
`param01` bigint(20) default NULL,
`const02` decimal(2,1) NOT NULL default '0.0',
`param02` decimal(65,30) default NULL,
@@ -4739,7 +4739,7 @@ t5 CREATE TABLE `t5` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t5 ;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
-def test t5 t5 const01 const01 8 1 1 N 32769 0 63
+def test t5 t5 const01 const01 3 1 1 N 32769 0 63
def test t5 t5 param01 param01 8 20 1 Y 32768 0 63
def test t5 t5 const02 const02 246 4 3 N 1 1 63
def test t5 t5 param02 param02 246 67 32 Y 0 30 63
diff --git a/mysql-test/r/ps_6bdb.result b/mysql-test/r/ps_6bdb.result
index 4d7b4b81fd6..49e3f9d9bb7 100644
--- a/mysql-test/r/ps_6bdb.result
+++ b/mysql-test/r/ps_6bdb.result
@@ -1287,7 +1287,7 @@ set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'a' at row 1
select a,b from t1 order by a;
a b
0 two
@@ -1758,7 +1758,7 @@ NULL as const12, @arg12 as param12,
show create table t5 ;
Table Create Table
t5 CREATE TABLE `t5` (
- `const01` bigint(1) NOT NULL default '0',
+ `const01` int(1) NOT NULL default '0',
`param01` bigint(20) default NULL,
`const02` decimal(2,1) NOT NULL default '0.0',
`param02` decimal(65,30) default NULL,
@@ -1788,7 +1788,7 @@ t5 CREATE TABLE `t5` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t5 ;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
-def test t5 t5 const01 const01 8 1 1 N 32769 0 63
+def test t5 t5 const01 const01 3 1 1 N 32769 0 63
def test t5 t5 param01 param01 8 20 1 Y 32768 0 63
def test t5 t5 const02 const02 246 4 3 N 1 1 63
def test t5 t5 param02 param02 246 67 32 Y 0 30 63
diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result
index 000a20da655..b1986ca62dc 100644
--- a/mysql-test/r/ps_7ndb.result
+++ b/mysql-test/r/ps_7ndb.result
@@ -1287,7 +1287,7 @@ set @arg00=NULL;
set @arg01=2;
execute stmt1 using @arg00, @arg01;
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'a' at row 1
select a,b from t1 order by a;
a b
0 two
@@ -1758,7 +1758,7 @@ NULL as const12, @arg12 as param12,
show create table t5 ;
Table Create Table
t5 CREATE TABLE `t5` (
- `const01` bigint(1) NOT NULL default '0',
+ `const01` int(1) NOT NULL default '0',
`param01` bigint(20) default NULL,
`const02` decimal(2,1) NOT NULL default '0.0',
`param02` decimal(65,30) default NULL,
@@ -1788,7 +1788,7 @@ t5 CREATE TABLE `t5` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t5 ;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
-def test t5 t5 const01 const01 8 1 1 N 32769 0 63
+def test t5 t5 const01 const01 3 1 1 N 32769 0 63
def test t5 t5 param01 param01 8 20 1 Y 32768 0 63
def test t5 t5 const02 const02 246 4 3 N 1 1 63
def test t5 t5 param02 param02 246 67 32 Y 0 30 63
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index 926a980f9c4..5224280e134 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -947,18 +947,24 @@ COUNT(*)
Warnings:
Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
+Warning 1292 Truncated incorrect INTEGER value: '20050327 invalid'
+Warning 1292 Truncated incorrect INTEGER value: '20050327 invalid'
SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050328 invalid';
COUNT(*)
0
Warnings:
Warning 1292 Incorrect datetime value: '20050328 invalid' for column 'date' at row 1
Warning 1292 Incorrect datetime value: '20050328 invalid' for column 'date' at row 1
+Warning 1292 Truncated incorrect INTEGER value: '20050328 invalid'
+Warning 1292 Truncated incorrect INTEGER value: '20050328 invalid'
SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050327 invalid';
COUNT(*)
0
Warnings:
Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
Warning 1292 Incorrect datetime value: '20050327 invalid' for column 'date' at row 1
+Warning 1292 Truncated incorrect INTEGER value: '20050327 invalid'
+Warning 1292 Truncated incorrect INTEGER value: '20050327 invalid'
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result
index a1f03a292c5..add95613d62 100644
--- a/mysql-test/r/range.result
+++ b/mysql-test/r/range.result
@@ -750,13 +750,13 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
EXPLAIN SELECT a,b FROM v1 WHERE a < 2 and b=3;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
EXPLAIN SELECT a,b FROM t1 WHERE a < 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
EXPLAIN SELECT a,b FROM v1 WHERE a < 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 4 Using where; Using index
SELECT a,b FROM t1 WHERE a < 2 and b=3;
a b
1 3
@@ -799,13 +799,13 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from v1 where a in (3,4) and b in (1,2,3);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
+1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from t1 where a between 3 and 4 and b between 1 and 2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from v1 where a between 3 and 4 and b between 1 and 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
+1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL # Using where; Using index
drop view v1;
drop table t1;
create table t3 (a int);
@@ -838,3 +838,106 @@ select a, hex(filler) from t1 where a not between 'b' and 'b';
a hex(filler)
a 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
drop table t1,t2,t3;
+create table t1 (a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t2 (a int, key(a));
+insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C;
+set @a="select * from t2 force index (a) where a NOT IN(0";
+select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z;
+count(*)
+1000
+set @a=concat(@a, ')');
+insert into t2 values (11),(13),(15);
+set @b= concat("explain ", @a);
+prepare stmt1 from @b;
+execute stmt1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index a a 5 NULL 1003 Using where; Using index
+prepare stmt1 from @a;
+execute stmt1;
+a
+11
+13
+15
+drop table t1, t2;
+CREATE TABLE t1 (
+id int NOT NULL DEFAULT '0',
+b int NOT NULL DEFAULT '0',
+c int NOT NULL DEFAULT '0',
+INDEX idx1(b,c), INDEX idx2(c));
+INSERT INTO t1(id) VALUES (1), (2), (3), (4), (5), (6), (7), (8);
+INSERT INTO t1(b,c) VALUES (3,4), (3,4);
+SELECT * FROM t1 WHERE b<=3 AND 3<=c;
+id b c
+0 3 4
+0 3 4
+SELECT * FROM t1 WHERE 3 BETWEEN b AND c;
+id b c
+0 3 4
+0 3 4
+EXPLAIN SELECT * FROM t1 WHERE b<=3 AND 3<=c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx1,idx2 idx2 4 NULL 3 Using where
+EXPLAIN SELECT * FROM t1 WHERE 3 BETWEEN b AND c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx1,idx2 idx2 4 NULL 3 Using where
+SELECT * FROM t1 WHERE 0 < b OR 0 > c;
+id b c
+0 3 4
+0 3 4
+SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c;
+id b c
+0 3 4
+0 3 4
+EXPLAIN SELECT * FROM t1 WHERE 0 < b OR 0 > c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge idx1,idx2 idx1,idx2 4,4 NULL 4 Using sort_union(idx1,idx2); Using where
+EXPLAIN SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge idx1,idx2 idx1,idx2 4,4 NULL 4 Using sort_union(idx1,idx2); Using where
+DROP TABLE t1;
+CREATE TABLE t1 (
+item char(20) NOT NULL default '',
+started datetime NOT NULL default '0000-00-00 00:00:00',
+price decimal(16,3) NOT NULL default '0.000',
+PRIMARY KEY (item,started)
+) ENGINE=MyISAM;
+INSERT INTO t1 VALUES
+('A1','2005-11-01 08:00:00',1000),
+('A1','2005-11-15 00:00:00',2000),
+('A1','2005-12-12 08:00:00',3000),
+('A2','2005-12-01 08:00:00',1000);
+EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ref PRIMARY PRIMARY 20 const 2 Using where
+Warnings:
+Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
+Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
+SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
+item started price
+A1 2005-11-01 08:00:00 1000.000
+A1 2005-11-15 00:00:00 2000.000
+Warnings:
+Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
+Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
+SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
+item started price
+A1 2005-11-01 08:00:00 1000.000
+A1 2005-11-15 00:00:00 2000.000
+DROP INDEX `PRIMARY` ON t1;
+EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using where
+Warnings:
+Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
+SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
+item started price
+A1 2005-11-01 08:00:00 1000.000
+A1 2005-11-15 00:00:00 2000.000
+Warnings:
+Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00' for column 'started' at row 1
+SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
+item started price
+A1 2005-11-01 08:00:00 1000.000
+A1 2005-11-15 00:00:00 2000.000
+DROP TABLE t1;
diff --git a/mysql-test/r/repair.result b/mysql-test/r/repair.result
index d8fa4dbbb72..9b07281aa7b 100644
--- a/mysql-test/r/repair.result
+++ b/mysql-test/r/repair.result
@@ -41,3 +41,14 @@ Table Op Msg_type Msg_text
test.t1 repair warning Number of rows changed from 0 to 1
test.t1 repair status OK
drop table t1;
+CREATE TABLE t1(a INT, KEY(a));
+INSERT INTO t1 VALUES(1),(2),(3),(4),(5);
+SET myisam_repair_threads=2;
+REPAIR TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+SHOW INDEX FROM t1;
+Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
+t1 1 a 1 a A 5 NULL NULL YES BTREE
+SET myisam_repair_threads=@@global.myisam_repair_threads;
+DROP TABLE t1;
diff --git a/mysql-test/r/row.result b/mysql-test/r/row.result
index 1762587415d..5b5f8b7b954 100644
--- a/mysql-test/r/row.result
+++ b/mysql-test/r/row.result
@@ -181,3 +181,128 @@ SELECT ROW(1,1,1) = ROW(1,1,1) as `1`, ROW(1,1,1) = ROW(1,2,1) as `0`, ROW(1,NUL
select row(NULL,1)=(2,0);
row(NULL,1)=(2,0)
0
+CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b));
+INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (1,2), (3,2), (3,3);
+EXPLAIN SELECT * FROM t1 WHERE a=3 AND b=2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const PRIMARY PRIMARY 8 const,const 1 Using index
+EXPLAIN SELECT * FROM t1 WHERE (a,b)=(3,2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const PRIMARY PRIMARY 8 const,const 1 Using index
+SELECT * FROM t1 WHERE a=3 and b=2;
+a b
+3 2
+SELECT * FROM t1 WHERE (a,b)=(3,2);
+a b
+3 2
+CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c));
+INSERT INTO t2 VALUES
+(1,1,2), (3,1,3), (1,2,2), (4,4,2),
+(1,1,1), (3,1,1), (1,2,1);
+EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=t2.b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 Using index
+1 SIMPLE t2 ref PRIMARY PRIMARY 8 test.t1.a,test.t1.b 1 Using index
+EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 Using index
+1 SIMPLE t2 ref PRIMARY PRIMARY 8 test.t1.a,test.t1.b 1 Using index
+SELECT * FROM t1,t2 WHERE t1.a=t2.a and t1.b=t2.b;
+a b a b c
+1 1 1 1 1
+1 1 1 1 2
+1 2 1 2 1
+1 2 1 2 2
+3 1 3 1 1
+3 1 3 1 3
+SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b);
+a b a b c
+1 1 1 1 1
+1 1 1 1 2
+1 2 1 2 1
+1 2 1 2 2
+3 1 3 1 1
+3 1 3 1 3
+EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 5 Using where; Using index
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using index
+EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 5 Using where; Using index
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using index
+SELECT * FROM t1,t2 WHERE t1.a=1 and t1.b=t2.b;
+a b a b c
+1 1 1 1 2
+1 1 3 1 3
+1 2 1 2 2
+1 1 1 1 1
+1 1 3 1 1
+1 2 1 2 1
+SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,2);
+a b a b c
+1 2 1 1 1
+1 2 1 1 2
+1 2 1 2 1
+1 2 1 2 2
+3 2 3 1 1
+3 2 3 1 3
+EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b+1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 Using index
+1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a 1 Using where; Using index
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`a` = `test`.`t1`.`a`) and (`test`.`t1`.`b` = (`test`.`t2`.`b` + 1)))
+SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b+1);
+a b a b c
+1 2 1 1 1
+1 2 1 1 2
+3 2 3 1 1
+3 2 3 1 3
+EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE (t1.a-1,t1.b)=(t2.a-1,t2.b+1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 8 NULL 6 Using index
+1 SIMPLE t2 index NULL PRIMARY 12 NULL 7 Using where; Using index
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where (((`test`.`t1`.`a` - 1) = (`test`.`t2`.`a` - 1)) and (`test`.`t1`.`b` = (`test`.`t2`.`b` + 1)))
+SELECT * FROM t1,t2 WHERE (t1.a-1,t1.b)=(t2.a-1,t2.b+1);
+a b a b c
+1 2 1 1 2
+3 2 3 1 3
+1 2 1 1 1
+3 2 3 1 1
+EXPLAIN SELECT * FROM t2 WHERE a=3 AND b=2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref PRIMARY PRIMARY 8 const,const 1 Using index
+EXPLAIN SELECT * FROM t2 WHERE (a,b)=(3,2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 ref PRIMARY PRIMARY 8 const,const 1 Using index
+SELECT * FROM t2 WHERE a=3 and b=2;
+a b c
+SELECT * FROM t2 WHERE (a,b)=(3,2);
+a b c
+EXPLAIN SELECT * FROM t1,t2 WHERE t2.a=t1.a AND t2.b=2 AND t2.c=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 12 test.t1.a,const,const 1 Using index
+EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE (t2.a,(t2.b,t2.c))=(t1.a,(2,1));
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 12 test.t1.a,const,const 1 Using index
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 2) and (`test`.`t2`.`a` = `test`.`t1`.`a`))
+SELECT * FROM t1,t2 WHERE (t2.a,(t2.b,t2.c))=(t1.a,(2,1));
+a b a b c
+1 1 1 2 1
+1 2 1 2 1
+EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE t2.a=t1.a AND (t2.b,t2.c)=(2,1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index PRIMARY PRIMARY 8 NULL 6 Using index
+1 SIMPLE t2 eq_ref PRIMARY PRIMARY 12 test.t1.a,const,const 1 Using index
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where ((`test`.`t2`.`c` = 1) and (`test`.`t2`.`b` = 2) and (`test`.`t2`.`a` = `test`.`t1`.`a`))
+SELECT * FROM t1,t2 WHERE t2.a=t1.a AND (t2.b,t2.c)=(2,1);
+a b a b c
+1 1 1 2 1
+1 2 1 2 1
+DROP TABLE t1,t2;
diff --git a/mysql-test/r/rpl_insert_id.result b/mysql-test/r/rpl_insert_id.result
index cd66e8727c1..e425cce9508 100644
--- a/mysql-test/r/rpl_insert_id.result
+++ b/mysql-test/r/rpl_insert_id.result
@@ -1,9 +1,20 @@
+#
+# Setup
+#
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;
+use test;
+drop table if exists t1, t2, t3;
+#
+# See if queries that use both auto_increment and LAST_INSERT_ID()
+# are replicated well
+#
+# We also check how the foreign_key_check variable is replicated
+#
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);
@@ -38,6 +49,9 @@ select * from t2;
b c
5 0
6 11
+#
+# check if INSERT SELECT in auto_increment is well replicated (bug #490)
+#
drop table t2;
drop table t1;
create table t1(a int auto_increment, key(a));
@@ -68,12 +82,35 @@ b c
9 13
drop table t1;
drop table t2;
+#
+# Bug#8412: Error codes reported in binary log for CHARACTER SET,
+# FOREIGN_KEY_CHECKS
+#
SET TIMESTAMP=1000000000;
CREATE TABLE t1 ( a INT UNIQUE );
SET FOREIGN_KEY_CHECKS=0;
INSERT INTO t1 VALUES (1),(1);
ERROR 23000: Duplicate entry '1' for key 1
drop table t1;
+#
+# Bug#14553: NULL in WHERE resets LAST_INSERT_ID
+#
+create table t1(a int auto_increment, key(a));
+create table t2(a int);
+insert into t1 (a) values (null);
+insert into t2 (a) select a from t1 where a is null;
+insert into t2 (a) select a from t1 where a is null;
+select * from t2;
+a
+1
+select * from t2;
+a
+1
+drop table t1;
+drop table t2;
+#
+# End of 4.1 tests
+#
drop function if exists bug15728;
drop function if exists bug15728_insert;
drop table if exists t1, t2;
@@ -197,3 +234,6 @@ n b
2 100
3 350
drop table t1;
+
+# End of 5.0 tests
+
diff --git a/mysql-test/r/rpl_max_relay_size.result b/mysql-test/r/rpl_max_relay_size.result
index fbe3b89828a..1fa49db6013 100644
--- a/mysql-test/r/rpl_max_relay_size.result
+++ b/mysql-test/r/rpl_max_relay_size.result
@@ -5,9 +5,15 @@ reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
stop slave;
+#
+# Generate a big enough master's binlog to cause relay log rotations
+#
create table t1 (a int);
drop table t1;
reset slave;
+#
+# Test 1
+#
set global max_binlog_size=8192;
set global max_relay_log_size=8192-1;
select @@global.max_relay_log_size;
@@ -15,47 +21,251 @@ select @@global.max_relay_log_size;
4096
start slave;
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 72952 # # master-bin.000001 Yes Yes 0 0 72952 # None 0 No #
+Slave_IO_State #
+Master_Host 127.0.0.1
+Master_User root
+Master_Port MASTER_PORT
+Connect_Retry 1
+Master_Log_File master-bin.000001
+Read_Master_Log_Pos 72952
+Relay_Log_File #
+Relay_Log_Pos #
+Relay_Master_Log_File master-bin.000001
+Slave_IO_Running Yes
+Slave_SQL_Running Yes
+Replicate_Do_DB
+Replicate_Ignore_DB
+Replicate_Do_Table
+Replicate_Ignore_Table
+Replicate_Wild_Do_Table
+Replicate_Wild_Ignore_Table
+Last_Errno 0
+Last_Error
+Skip_Counter 0
+Exec_Master_Log_Pos 72952
+Relay_Log_Space #
+Until_Condition None
+Until_Log_File
+Until_Log_Pos 0
+Master_SSL_Allowed No
+Master_SSL_CA_File
+Master_SSL_CA_Path
+Master_SSL_Cert
+Master_SSL_Cipher
+Master_SSL_Key
+Seconds_Behind_Master #
+#
+# Test 2
+#
stop slave;
reset slave;
set global max_relay_log_size=(5*4096);
select @@global.max_relay_log_size;
-@@global.max_relay_log_size
-20480
+@@global.max_relay_log_size 20480
start slave;
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 72952 # # master-bin.000001 Yes Yes 0 0 72952 # None 0 No #
+Slave_IO_State #
+Master_Host 127.0.0.1
+Master_User root
+Master_Port MASTER_PORT
+Connect_Retry 1
+Master_Log_File master-bin.000001
+Read_Master_Log_Pos 72952
+Relay_Log_File #
+Relay_Log_Pos #
+Relay_Master_Log_File master-bin.000001
+Slave_IO_Running Yes
+Slave_SQL_Running Yes
+Replicate_Do_DB
+Replicate_Ignore_DB
+Replicate_Do_Table
+Replicate_Ignore_Table
+Replicate_Wild_Do_Table
+Replicate_Wild_Ignore_Table
+Last_Errno 0
+Last_Error
+Skip_Counter 0
+Exec_Master_Log_Pos 72952
+Relay_Log_Space #
+Until_Condition None
+Until_Log_File
+Until_Log_Pos 0
+Master_SSL_Allowed No
+Master_SSL_CA_File
+Master_SSL_CA_Path
+Master_SSL_Cert
+Master_SSL_Cipher
+Master_SSL_Key
+Seconds_Behind_Master #
+#
+# Test 3: max_relay_log_size = 0
+#
stop slave;
reset slave;
set global max_relay_log_size=0;
select @@global.max_relay_log_size;
-@@global.max_relay_log_size
-0
+@@global.max_relay_log_size 0
start slave;
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 72952 # # master-bin.000001 Yes Yes 0 0 72952 # None 0 No #
+Slave_IO_State #
+Master_Host 127.0.0.1
+Master_User root
+Master_Port MASTER_PORT
+Connect_Retry 1
+Master_Log_File master-bin.000001
+Read_Master_Log_Pos 72952
+Relay_Log_File #
+Relay_Log_Pos #
+Relay_Master_Log_File master-bin.000001
+Slave_IO_Running Yes
+Slave_SQL_Running Yes
+Replicate_Do_DB
+Replicate_Ignore_DB
+Replicate_Do_Table
+Replicate_Ignore_Table
+Replicate_Wild_Do_Table
+Replicate_Wild_Ignore_Table
+Last_Errno 0
+Last_Error
+Skip_Counter 0
+Exec_Master_Log_Pos 72952
+Relay_Log_Space #
+Until_Condition None
+Until_Log_File
+Until_Log_Pos 0
+Master_SSL_Allowed No
+Master_SSL_CA_File
+Master_SSL_CA_Path
+Master_SSL_Cert
+Master_SSL_Cipher
+Master_SSL_Key
+Seconds_Behind_Master #
+#
+# Test 4: Tests below are mainly to ensure that we have not coded with wrong assumptions
+#
stop slave;
reset slave;
flush logs;
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 4 # # No No 0 0 0 # None 0 No #
+Slave_IO_State #
+Master_Host 127.0.0.1
+Master_User root
+Master_Port MASTER_PORT
+Connect_Retry 1
+Master_Log_File
+Read_Master_Log_Pos 4
+Relay_Log_File #
+Relay_Log_Pos #
+Relay_Master_Log_File
+Slave_IO_Running No
+Slave_SQL_Running No
+Replicate_Do_DB
+Replicate_Ignore_DB
+Replicate_Do_Table
+Replicate_Ignore_Table
+Replicate_Wild_Do_Table
+Replicate_Wild_Ignore_Table
+Last_Errno 0
+Last_Error
+Skip_Counter 0
+Exec_Master_Log_Pos 0
+Relay_Log_Space #
+Until_Condition None
+Until_Log_File
+Until_Log_Pos 0
+Master_SSL_Allowed No
+Master_SSL_CA_File
+Master_SSL_CA_Path
+Master_SSL_Cert
+Master_SSL_Cipher
+Master_SSL_Key
+Seconds_Behind_Master #
+#
+# Test 5
+#
reset slave;
start slave;
flush logs;
create table t1 (a int);
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 73038 # # master-bin.000001 Yes Yes 0 0 73038 # None 0 No #
+Slave_IO_State #
+Master_Host 127.0.0.1
+Master_User root
+Master_Port MASTER_PORT
+Connect_Retry 1
+Master_Log_File master-bin.000001
+Read_Master_Log_Pos 73038
+Relay_Log_File #
+Relay_Log_Pos #
+Relay_Master_Log_File master-bin.000001
+Slave_IO_Running Yes
+Slave_SQL_Running Yes
+Replicate_Do_DB
+Replicate_Ignore_DB
+Replicate_Do_Table
+Replicate_Ignore_Table
+Replicate_Wild_Do_Table
+Replicate_Wild_Ignore_Table
+Last_Errno 0
+Last_Error
+Skip_Counter 0
+Exec_Master_Log_Pos 73038
+Relay_Log_Space #
+Until_Condition None
+Until_Log_File
+Until_Log_Pos 0
+Master_SSL_Allowed No
+Master_SSL_CA_File
+Master_SSL_CA_Path
+Master_SSL_Cert
+Master_SSL_Cipher
+Master_SSL_Key
+Seconds_Behind_Master #
+#
+# Test 6: one more rotation, to be sure Relay_Log_Space is correctly updated
+#
flush logs;
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_PORT 1 master-bin.000001 73114 # # master-bin.000001 Yes Yes 0 0 73114 # None 0 No #
+Slave_IO_State #
+Master_Host 127.0.0.1
+Master_User root
+Master_Port MASTER_PORT
+Connect_Retry 1
+Master_Log_File master-bin.000001
+Read_Master_Log_Pos 73114
+Relay_Log_File #
+Relay_Log_Pos #
+Relay_Master_Log_File master-bin.000001
+Slave_IO_Running Yes
+Slave_SQL_Running Yes
+Replicate_Do_DB
+Replicate_Ignore_DB
+Replicate_Do_Table
+Replicate_Ignore_Table
+Replicate_Wild_Do_Table
+Replicate_Wild_Ignore_Table
+Last_Errno 0
+Last_Error
+Skip_Counter 0
+Exec_Master_Log_Pos 73114
+Relay_Log_Space #
+Until_Condition None
+Until_Log_File
+Until_Log_Pos 0
+Master_SSL_Allowed No
+Master_SSL_CA_File
+Master_SSL_CA_Path
+Master_SSL_Cert
+Master_SSL_Cipher
+Master_SSL_Key
+Seconds_Behind_Master #
flush logs;
show master status;
-File Position Binlog_Do_DB Binlog_Ignore_DB
-master-bin.000002 98
+File master-bin.000002
+Position 98
+Binlog_Do_DB
+Binlog_Ignore_DB
+#
+# End of 4.1 tests
+#
diff --git a/mysql-test/r/rpl_ndb_innodb_trans.result b/mysql-test/r/rpl_ndb_innodb_trans.result
new file mode 100644
index 00000000000..148e6247b03
--- /dev/null
+++ b/mysql-test/r/rpl_ndb_innodb_trans.result
@@ -0,0 +1,103 @@
+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, unique(a)) engine=ndbcluster;
+create table t2 (a int, unique(a)) engine=innodb;
+begin;
+insert into t1 values(1);
+insert into t2 values(1);
+rollback;
+select count(*) from t1;
+count(*)
+0
+select count(*) from t2;
+count(*)
+0
+select count(*) from t1;
+count(*)
+0
+select count(*) from t2;
+count(*)
+0
+begin;
+load data infile '../std_data_ln/rpl_loaddata.dat' into table t2;
+Warnings:
+Warning 1262 Row 1 was truncated; it contained more data than there were input columns
+Warning 1262 Row 2 was truncated; it contained more data than there were input columns
+load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
+Warnings:
+Warning 1262 Row 1 was truncated; it contained more data than there were input columns
+Warning 1262 Row 2 was truncated; it contained more data than there were input columns
+rollback;
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
+select count(*) from t1;
+count(*)
+2
+select count(*) from t2;
+count(*)
+0
+select count(*) from t1;
+count(*)
+2
+select count(*) from t2;
+count(*)
+0
+delete from t1;
+delete from t2;
+begin;
+load data infile '../std_data_ln/rpl_loaddata.dat' into table t2;
+Warnings:
+Warning 1262 Row 1 was truncated; it contained more data than there were input columns
+Warning 1262 Row 2 was truncated; it contained more data than there were input columns
+load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
+Warnings:
+Warning 1262 Row 1 was truncated; it contained more data than there were input columns
+Warning 1262 Row 2 was truncated; it contained more data than there were input columns
+rollback;
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
+select count(*) from t1;
+count(*)
+2
+select count(*) from t2;
+count(*)
+0
+select count(*) from t1;
+count(*)
+2
+select count(*) from t2;
+count(*)
+0
+delete from t1;
+delete from t2;
+begin;
+insert into t2 values(3),(4);
+insert into t1 values(3),(4);
+load data infile '../std_data_ln/rpl_loaddata.dat' into table t2;
+Warnings:
+Warning 1262 Row 1 was truncated; it contained more data than there were input columns
+Warning 1262 Row 2 was truncated; it contained more data than there were input columns
+load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
+Warnings:
+Warning 1262 Row 1 was truncated; it contained more data than there were input columns
+Warning 1262 Row 2 was truncated; it contained more data than there were input columns
+rollback;
+Warnings:
+Warning 1196 Some non-transactional changed tables couldn't be rolled back
+select count(*) from t1;
+count(*)
+4
+select count(*) from t2;
+count(*)
+0
+select count(*) from t1;
+count(*)
+4
+select count(*) from t2;
+count(*)
+0
+drop table t1,t2;
diff --git a/mysql-test/r/rpl_sp.result b/mysql-test/r/rpl_sp.result
index 5dfda16c763..7b096b27733 100644
--- a/mysql-test/r/rpl_sp.result
+++ b/mysql-test/r/rpl_sp.result
@@ -420,4 +420,48 @@ SELECT * FROM t1;
col
test
DROP PROCEDURE p1;
+
+---> Test for BUG#20438
+
+---> Preparing environment...
+---> connection: master
+DROP PROCEDURE IF EXISTS p1;
+DROP FUNCTION IF EXISTS f1;
+
+---> Synchronizing slave with master...
+
+---> connection: master
+
+---> Creating procedure...
+/*!50003 CREATE PROCEDURE p1() SET @a = 1 */;
+/*!50003 CREATE FUNCTION f1() RETURNS INT RETURN 0 */;
+
+---> Checking on master...
+SHOW CREATE PROCEDURE p1;
+Procedure sql_mode Create Procedure
+p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
+SET @a = 1
+SHOW CREATE FUNCTION f1;
+Function sql_mode Create Function
+f1 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
+RETURN 0
+
+---> Synchronizing slave with master...
+---> connection: master
+
+---> Checking on slave...
+SHOW CREATE PROCEDURE p1;
+Procedure sql_mode Create Procedure
+p1 CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
+SET @a = 1
+SHOW CREATE FUNCTION f1;
+Function sql_mode Create Function
+f1 CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11)
+RETURN 0
+
+---> connection: master
+
+---> Cleaning up...
+DROP PROCEDURE p1;
+DROP FUNCTION f1;
drop table t1;
diff --git a/mysql-test/r/rpl_trigger.result b/mysql-test/r/rpl_trigger.result
index 3e4a3349e13..49f0f5c4c44 100644
--- a/mysql-test/r/rpl_trigger.result
+++ b/mysql-test/r/rpl_trigger.result
@@ -896,3 +896,50 @@ Tables_in_test (t_)
SHOW TRIGGERS;
Trigger Event Table Statement Timing Created sql_mode Definer
RESET MASTER;
+START SLAVE;
+
+---> Test for BUG#20438
+
+---> Preparing environment...
+---> connection: master
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+
+---> Synchronizing slave with master...
+
+---> connection: master
+
+---> Creating objects...
+CREATE TABLE t1(c INT);
+CREATE TABLE t2(c INT);
+/*!50003 CREATE TRIGGER t1_bi BEFORE INSERT ON t1
+FOR EACH ROW
+INSERT INTO t2 VALUES(NEW.c * 10) */;
+
+---> Inserting value...
+INSERT INTO t1 VALUES(1);
+
+---> Checking on master...
+SELECT * FROM t1;
+c
+1
+SELECT * FROM t2;
+c
+10
+
+---> Synchronizing slave with master...
+---> connection: master
+
+---> Checking on slave...
+SELECT * FROM t1;
+c
+1
+SELECT * FROM t2;
+c
+10
+
+---> connection: master
+
+---> Cleaning up...
+DROP TABLE t1;
+DROP TABLE t2;
diff --git a/mysql-test/r/rpl_view.result b/mysql-test/r/rpl_view.result
index cf4c161b296..601f3d9cd14 100644
--- a/mysql-test/r/rpl_view.result
+++ b/mysql-test/r/rpl_view.result
@@ -54,3 +54,56 @@ slave-bin.000001 # Query 1 # use `test`; delete from v1 where a=2
slave-bin.000001 # Query 1 # use `test`; ALTER ALGORITHM=UNDEFINED DEFINER=root@localhost SQL SECURITY DEFINER VIEW v1 AS select a as b from t1
slave-bin.000001 # Query 1 # use `test`; drop view v1
slave-bin.000001 # Query 1 # use `test`; drop table t1
+
+---> Test for BUG#20438
+
+---> Preparing environment...
+---> connection: master
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS v1;
+
+---> Synchronizing slave with master...
+
+---> connection: master
+
+---> Creating objects...
+CREATE TABLE t1(c INT);
+/*!50003 CREATE VIEW v1 AS SELECT * FROM t1 */;
+
+---> Inserting value...
+INSERT INTO t1 VALUES(1);
+
+---> Checking on master...
+SELECT * FROM t1;
+c
+1
+
+---> Synchronizing slave with master...
+---> connection: master
+
+---> Checking on slave...
+SELECT * FROM t1;
+c
+1
+
+---> connection: master
+
+---> Cleaning up...
+DROP VIEW v1;
+DROP TABLE t1;
+create table t1(a int, b int);
+insert into t1 values (1, 1), (1, 2), (1, 3);
+create view v1(a, b) as select a, sum(b) from t1 group by a;
+explain v1;
+Field Type Null Key Default Extra
+a int(11) YES NULL
+b decimal(32,0) YES NULL
+show create table v1;
+View Create View
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a`,sum(`t1`.`b`) AS `b` from `t1` group by `t1`.`a`
+select * from v1;
+a b
+1 6
+drop table t1;
+drop view v1;
+End of 5.0 tests
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index 280df0bdd89..543dfd82eae 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -2328,9 +2328,9 @@ 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;
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 t4 const id4 NULL NULL NULL 1
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
+1 SIMPLE t2 ALL NULL 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
@@ -2736,6 +2736,81 @@ SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1;
i='1e+01' i=1e+01 i in (1e+01,1e+01) i in ('1e+01','1e+01')
1 1 1 1
DROP TABLE t1;
+CREATE TABLE t1 (a int, b int);
+INSERT INTO t1 VALUES (1,1), (2,1), (4,10);
+CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b));
+INSERT INTO t2 VALUES (1,NULL), (2,10);
+ALTER TABLE t1 ENABLE KEYS;
+EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index b b 5 NULL 2 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
+SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
+a b a b
+1 NULL 1 1
+1 NULL 2 1
+1 NULL 4 10
+2 10 4 10
+EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index b b 5 NULL 2 Using index
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
+SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
+a b a b
+1 NULL 1 1
+1 NULL 2 1
+1 NULL 4 10
+2 10 4 10
+DROP TABLE IF EXISTS t1,t2;
+CREATE TABLE t1 (key1 float default NULL, UNIQUE KEY key1 (key1));
+CREATE TABLE t2 (key2 float default NULL, UNIQUE KEY key2 (key2));
+INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941);
+INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941);
+explain select max(key1) from t1 where key1 <= 0.6158;
+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(key2) from t2 where key2 <= 1.6158;
+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 min(key1) from t1 where key1 >= 0.3762;
+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 min(key2) from t2 where key2 >= 1.3762;
+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(key1), min(key2) from t1, t2
+where key1 <= 0.6158 and key2 >= 1.3762;
+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(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
+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 min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
+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(key1) from t1 where key1 <= 0.6158;
+max(key1)
+0.61580002307892
+select max(key2) from t2 where key2 <= 1.6158;
+max(key2)
+1.6158000230789
+select min(key1) from t1 where key1 >= 0.3762;
+min(key1)
+0.37619999051094
+select min(key2) from t2 where key2 >= 1.3762;
+min(key2)
+1.3761999607086
+select max(key1), min(key2) from t1, t2
+where key1 <= 0.6158 and key2 >= 1.3762;
+max(key1) min(key2)
+0.61580002307892 1.3761999607086
+select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
+max(key1)
+0.61580002307892
+select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
+min(key1)
+0.37619999051094
+DROP TABLE t1,t2;
CREATE TABLE t1 (
K2C4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '',
K4N4 varchar(4) character set latin1 collate latin1_bin NOT NULL default '0000',
@@ -3395,3 +3470,50 @@ a t1.b + 0 t1.c + 0 a t2.b + 0 c d
1 0 1 1 0 1 NULL
2 0 1 NULL NULL NULL NULL
drop table t1,t2;
+SELECT 0.9888889889 * 1.011111411911;
+0.9888889889 * 1.011111411911
+0.9998769417899202067879
+prepare stmt from 'select 1 as " a "';
+Warnings:
+Warning 1466 Leading spaces are removed from name ' a '
+execute stmt;
+a
+1
+CREATE TABLE t1 (a int NOT NULL PRIMARY KEY, b int NOT NULL);
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4);
+CREATE TABLE t2 (c int NOT NULL, INDEX idx(c));
+INSERT INTO t2 VALUES
+(1), (1), (1), (1), (1), (1), (1), (1),
+(2), (2), (2), (2),
+(3), (3),
+(4);
+EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1
+1 SIMPLE t2 ref idx idx 4 const 7 Using index
+EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1
+1 SIMPLE t2 ref idx idx 4 const 1 Using index
+DROP TABLE t1, t2;
+CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a int);
+INSERT INTO t1 VALUES (1,2), (2,NULL), (3,2);
+CREATE TABLE t2 (b int, c INT, INDEX idx1(b));
+INSERT INTO t2 VALUES (2,1), (3,2);
+CREATE TABLE t3 (d int, e int, INDEX idx1(d));
+INSERT INTO t3 VALUES (2,10), (2,20), (1,30), (2,40), (2,50);
+EXPLAIN
+SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id
+WHERE t1.id=2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1
+1 SIMPLE t2 const idx1 NULL NULL NULL 1
+1 SIMPLE t3 ref idx1 idx1 5 const 3 Using where
+SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id
+WHERE t1.id=2;
+id a b c d e
+2 NULL NULL NULL 2 10
+2 NULL NULL NULL 2 20
+2 NULL NULL NULL 2 40
+2 NULL NULL NULL 2 50
+DROP TABLE t1,t2,t3;
diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
index 994501767ba..7bdfa78066c 100644
--- a/mysql-test/r/show_check.result
+++ b/mysql-test/r/show_check.result
@@ -625,3 +625,7 @@ View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select sql_cache 1 AS `1`
DROP PROCEDURE p1;
DROP VIEW v1;
+SHOW TABLES FROM no_such_database;
+ERROR 42000: Unknown database 'no_such_database'
+SHOW COLUMNS FROM no_such_table;
+ERROR 42S02: Table 'test.no_such_table' doesn't exist
diff --git a/mysql-test/r/sp-code.result b/mysql-test/r/sp-code.result
index 8bdb9a724d7..4ae38861d29 100644
--- a/mysql-test/r/sp-code.result
+++ b/mysql-test/r/sp-code.result
@@ -155,11 +155,11 @@ Pos Instruction
0 stmt 9 "drop temporary table if exists sudoku..."
1 stmt 1 "create temporary table sudoku_work ( ..."
2 stmt 1 "create temporary table sudoku_schedul..."
-3 stmt 95 "call sudoku_init("
+3 stmt 95 "call sudoku_init()"
4 jump_if_not 7(8) p_naive@0
5 stmt 4 "update sudoku_work set cnt = 0 where ..."
6 jump 8
-7 stmt 95 "call sudoku_count("
+7 stmt 95 "call sudoku_count()"
8 stmt 6 "insert into sudoku_schedule (row,col)..."
9 set v_scounter@2 0
10 set v_i@3 1
@@ -199,3 +199,10 @@ Pos Instruction
44 jump 14
45 stmt 9 "drop temporary table sudoku_work, sud..."
drop procedure sudoku_solve;
+DROP PROCEDURE IF EXISTS p1;
+CREATE PROCEDURE p1() CREATE INDEX idx ON t1 (c1);
+SHOW PROCEDURE CODE p1;
+Pos Instruction
+0 stmt 2 "CREATE INDEX idx ON t1 (c1)"
+DROP PROCEDURE p1;
+End of 5.0 tests.
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index 924963017eb..85ea624ce2f 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -634,6 +634,45 @@ flush tables;
return 5;
end|
ERROR 0A000: FLUSH is not allowed in stored function or trigger
+create function bug8409() returns int begin reset query cache;
+return 1; end|
+ERROR 0A000: RESET is not allowed in stored function or trigger
+create function bug8409() returns int begin reset master;
+return 1; end|
+ERROR 0A000: RESET is not allowed in stored function or trigger
+create function bug8409() returns int begin reset slave;
+return 1; end|
+ERROR 0A000: RESET is not allowed in stored function or trigger
+create function bug8409() returns int begin flush hosts;
+return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+create function bug8409() returns int begin flush privileges;
+return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+create function bug8409() returns int begin flush tables with read lock;
+return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+create function bug8409() returns int begin flush tables;
+return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+create function bug8409() returns int begin flush logs;
+return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+create function bug8409() returns int begin flush status;
+return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+create function bug8409() returns int begin flush slave;
+return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+create function bug8409() returns int begin flush master;
+return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+create function bug8409() returns int begin flush des_key_file;
+return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+create function bug8409() returns int begin flush user_resources;
+return 1; end|
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
create procedure bug9529_901234567890123456789012345678901234567890123456789012345()
begin
end|
@@ -1174,3 +1213,16 @@ drop procedure bug15091;
drop function if exists bug16896;
create aggregate function bug16896() returns int return 1;
ERROR 42000: AGGREGATE is not supported for stored functions
+DROP PROCEDURE IF EXISTS bug14702;
+CREATE IF NOT EXISTS PROCEDURE bug14702()
+BEGIN
+END;
+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 'IF NOT EXISTS PROCEDURE bug14702()
+BEGIN
+END' at line 1
+CREATE PROCEDURE IF NOT EXISTS bug14702()
+BEGIN
+END;
+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 'IF NOT EXISTS bug14702()
+BEGIN
+END' at line 1
diff --git a/mysql-test/r/sp-security.result b/mysql-test/r/sp-security.result
index a53b4c4d246..1198efc4f3b 100644
--- a/mysql-test/r/sp-security.result
+++ b/mysql-test/r/sp-security.result
@@ -451,3 +451,55 @@ SELECT Host,User,Password FROM mysql.user WHERE User='user19857';
Host User Password
localhost user19857 *82DC221D557298F6CE9961037DB1C90604792F5C
DROP USER user19857@localhost;
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS v1;
+DROP FUNCTION IF EXISTS f_suid;
+DROP PROCEDURE IF EXISTS p_suid;
+DROP FUNCTION IF EXISTS f_evil;
+DELETE FROM mysql.user WHERE user LIKE 'mysqltest\_%';
+DELETE FROM mysql.db WHERE user LIKE 'mysqltest\_%';
+DELETE FROM mysql.tables_priv WHERE user LIKE 'mysqltest\_%';
+DELETE FROM mysql.columns_priv WHERE user LIKE 'mysqltest\_%';
+FLUSH PRIVILEGES;
+CREATE TABLE t1 (i INT);
+CREATE FUNCTION f_suid(i INT) RETURNS INT SQL SECURITY DEFINER RETURN 0;
+CREATE PROCEDURE p_suid(IN i INT) SQL SECURITY DEFINER SET @c:= 0;
+CREATE USER mysqltest_u1@localhost;
+GRANT EXECUTE ON test.* TO mysqltest_u1@localhost;
+CREATE DEFINER=mysqltest_u1@localhost FUNCTION f_evil () RETURNS INT
+SQL SECURITY INVOKER
+BEGIN
+SET @a:= CURRENT_USER();
+SET @b:= (SELECT COUNT(*) FROM t1);
+RETURN @b;
+END|
+CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT f_evil();
+SELECT COUNT(*) FROM t1;
+ERROR 42000: SELECT command denied to user 'mysqltest_u1'@'localhost' for table 't1'
+SELECT f_evil();
+ERROR 42000: SELECT command denied to user 'mysqltest_u1'@'localhost' for table 't1'
+SELECT @a, @b;
+@a @b
+mysqltest_u1@localhost NULL
+SELECT f_suid(f_evil());
+ERROR 42000: SELECT command denied to user 'mysqltest_u1'@'localhost' for table 't1'
+SELECT @a, @b;
+@a @b
+mysqltest_u1@localhost NULL
+CALL p_suid(f_evil());
+ERROR 42000: SELECT command denied to user 'mysqltest_u1'@'localhost' for table 't1'
+SELECT @a, @b;
+@a @b
+mysqltest_u1@localhost NULL
+SELECT * FROM v1;
+ERROR 42000: SELECT command denied to user 'mysqltest_u1'@'localhost' for table 'v1'
+SELECT @a, @b;
+@a @b
+mysqltest_u1@localhost NULL
+DROP VIEW v1;
+DROP FUNCTION f_evil;
+DROP USER mysqltest_u1@localhost;
+DROP PROCEDURE p_suid;
+DROP FUNCTION f_suid;
+DROP TABLE t1;
+End of 5.0 tests.
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 96bf2f01f86..061b754b6cd 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -4872,8 +4872,6 @@ declare continue handler for sqlexception begin end;
select no_such_function();
end|
call bug18787()|
-no_such_function()
-NULL
drop procedure bug18787|
create database bug18344_012345678901|
use bug18344_012345678901|
@@ -4921,7 +4919,7 @@ create table t3 as select * from v1|
show create table t3|
Table Create Table
t3 CREATE TABLE `t3` (
- `j` bigint(11) default NULL
+ `j` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t3|
j
@@ -5057,4 +5055,406 @@ concat('data was: /', var1, '/')
data was: /1/
drop table t3|
drop procedure bug15217|
+DROP PROCEDURE IF EXISTS bug21013 |
+CREATE PROCEDURE bug21013(IN lim INT)
+BEGIN
+DECLARE i INT DEFAULT 0;
+WHILE (i < lim) DO
+SET @b = LOCATE(_latin1'b', @a, 1);
+SET i = i + 1;
+END WHILE;
+END |
+SET @a = _latin2"aaaaaaaaaa" |
+CALL bug21013(10) |
+DROP PROCEDURE bug21013 |
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8|
+use mysqltest1|
+CREATE FUNCTION bug16211_f1() RETURNS CHAR(10)
+RETURN ""|
+CREATE FUNCTION bug16211_f2() RETURNS CHAR(10) CHARSET koi8r
+RETURN ""|
+CREATE FUNCTION mysqltest2.bug16211_f3() RETURNS CHAR(10)
+RETURN ""|
+CREATE FUNCTION mysqltest2.bug16211_f4() RETURNS CHAR(10) CHARSET koi8r
+RETURN ""|
+SHOW CREATE FUNCTION bug16211_f1|
+Function sql_mode Create Function
+bug16211_f1 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f1`() RETURNS char(10) CHARSET utf8
+RETURN ""
+SHOW CREATE FUNCTION bug16211_f2|
+Function sql_mode Create Function
+bug16211_f2 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f2`() RETURNS char(10) CHARSET koi8r
+RETURN ""
+SHOW CREATE FUNCTION mysqltest2.bug16211_f3|
+Function sql_mode Create Function
+bug16211_f3 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f3`() RETURNS char(10) CHARSET utf8
+RETURN ""
+SHOW CREATE FUNCTION mysqltest2.bug16211_f4|
+Function sql_mode Create Function
+bug16211_f4 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f4`() RETURNS char(10) CHARSET koi8r
+RETURN ""
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f1"|
+dtd_identifier
+char(10) CHARSET utf8
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f2"|
+dtd_identifier
+char(10) CHARSET koi8r
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f3"|
+dtd_identifier
+char(10) CHARSET utf8
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f4"|
+dtd_identifier
+char(10) CHARSET koi8r
+SELECT CHARSET(bug16211_f1())|
+CHARSET(bug16211_f1())
+utf8
+SELECT CHARSET(bug16211_f2())|
+CHARSET(bug16211_f2())
+koi8r
+SELECT CHARSET(mysqltest2.bug16211_f3())|
+CHARSET(mysqltest2.bug16211_f3())
+utf8
+SELECT CHARSET(mysqltest2.bug16211_f4())|
+CHARSET(mysqltest2.bug16211_f4())
+koi8r
+ALTER DATABASE mysqltest1 CHARACTER SET cp1251|
+ALTER DATABASE mysqltest2 CHARACTER SET cp1251|
+SHOW CREATE FUNCTION bug16211_f1|
+Function sql_mode Create Function
+bug16211_f1 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f1`() RETURNS char(10) CHARSET utf8
+RETURN ""
+SHOW CREATE FUNCTION bug16211_f2|
+Function sql_mode Create Function
+bug16211_f2 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f2`() RETURNS char(10) CHARSET koi8r
+RETURN ""
+SHOW CREATE FUNCTION mysqltest2.bug16211_f3|
+Function sql_mode Create Function
+bug16211_f3 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f3`() RETURNS char(10) CHARSET utf8
+RETURN ""
+SHOW CREATE FUNCTION mysqltest2.bug16211_f4|
+Function sql_mode Create Function
+bug16211_f4 CREATE DEFINER=`root`@`localhost` FUNCTION `bug16211_f4`() RETURNS char(10) CHARSET koi8r
+RETURN ""
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f1"|
+dtd_identifier
+char(10) CHARSET utf8
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f2"|
+dtd_identifier
+char(10) CHARSET koi8r
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f3"|
+dtd_identifier
+char(10) CHARSET utf8
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f4"|
+dtd_identifier
+char(10) CHARSET koi8r
+SELECT CHARSET(bug16211_f1())|
+CHARSET(bug16211_f1())
+utf8
+SELECT CHARSET(bug16211_f2())|
+CHARSET(bug16211_f2())
+koi8r
+SELECT CHARSET(mysqltest2.bug16211_f3())|
+CHARSET(mysqltest2.bug16211_f3())
+utf8
+SELECT CHARSET(mysqltest2.bug16211_f4())|
+CHARSET(mysqltest2.bug16211_f4())
+koi8r
+use test|
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+DROP DATABASE IF EXISTS mysqltest1|
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8|
+use mysqltest1|
+CREATE PROCEDURE bug16676_p1(
+IN p1 CHAR(10),
+INOUT p2 CHAR(10),
+OUT p3 CHAR(10))
+BEGIN
+SELECT CHARSET(p1), COLLATION(p1);
+SELECT CHARSET(p2), COLLATION(p2);
+SELECT CHARSET(p3), COLLATION(p3);
+END|
+CREATE PROCEDURE bug16676_p2(
+IN p1 CHAR(10) CHARSET koi8r,
+INOUT p2 CHAR(10) CHARSET cp1251,
+OUT p3 CHAR(10) CHARSET greek)
+BEGIN
+SELECT CHARSET(p1), COLLATION(p1);
+SELECT CHARSET(p2), COLLATION(p2);
+SELECT CHARSET(p3), COLLATION(p3);
+END|
+SET @v2 = 'b'|
+SET @v3 = 'c'|
+CALL bug16676_p1('a', @v2, @v3)|
+CHARSET(p1) COLLATION(p1)
+utf8 utf8_general_ci
+CHARSET(p2) COLLATION(p2)
+utf8 utf8_general_ci
+CHARSET(p3) COLLATION(p3)
+utf8 utf8_general_ci
+CALL bug16676_p2('a', @v2, @v3)|
+CHARSET(p1) COLLATION(p1)
+koi8r koi8r_general_ci
+CHARSET(p2) COLLATION(p2)
+cp1251 cp1251_general_ci
+CHARSET(p3) COLLATION(p3)
+greek greek_general_ci
+use test|
+DROP DATABASE mysqltest1|
+drop table if exists t3|
+drop table if exists t4|
+drop procedure if exists bug8153_subselect|
+drop procedure if exists bug8153_subselect_a|
+drop procedure if exists bug8153_subselect_b|
+drop procedure if exists bug8153_proc_a|
+drop procedure if exists bug8153_proc_b|
+create table t3 (a int)|
+create table t4 (a int)|
+insert into t3 values (1), (1), (2), (3)|
+insert into t4 values (1), (1)|
+create procedure bug8153_subselect()
+begin
+declare continue handler for sqlexception
+begin
+select 'statement failed';
+end;
+update t3 set a=a+1 where (select a from t4 where a=1) is null;
+select 'statement after update';
+end|
+call bug8153_subselect()|
+statement failed
+statement failed
+statement after update
+statement after update
+select * from t3|
+a
+1
+1
+2
+3
+call bug8153_subselect()|
+statement failed
+statement failed
+statement after update
+statement after update
+select * from t3|
+a
+1
+1
+2
+3
+drop procedure bug8153_subselect|
+create procedure bug8153_subselect_a()
+begin
+declare continue handler for sqlexception
+begin
+select 'in continue handler';
+end;
+select 'reachable code a1';
+call bug8153_subselect_b();
+select 'reachable code a2';
+end|
+create procedure bug8153_subselect_b()
+begin
+select 'reachable code b1';
+update t3 set a=a+1 where (select a from t4 where a=1) is null;
+select 'unreachable code b2';
+end|
+call bug8153_subselect_a()|
+reachable code a1
+reachable code a1
+reachable code b1
+reachable code b1
+in continue handler
+in continue handler
+reachable code a2
+reachable code a2
+select * from t3|
+a
+1
+1
+2
+3
+call bug8153_subselect_a()|
+reachable code a1
+reachable code a1
+reachable code b1
+reachable code b1
+in continue handler
+in continue handler
+reachable code a2
+reachable code a2
+select * from t3|
+a
+1
+1
+2
+3
+drop procedure bug8153_subselect_a|
+drop procedure bug8153_subselect_b|
+create procedure bug8153_proc_a()
+begin
+declare continue handler for sqlexception
+begin
+select 'in continue handler';
+end;
+select 'reachable code a1';
+call bug8153_proc_b();
+select 'reachable code a2';
+end|
+create procedure bug8153_proc_b()
+begin
+select 'reachable code b1';
+select no_such_function();
+select 'unreachable code b2';
+end|
+call bug8153_proc_a()|
+reachable code a1
+reachable code a1
+reachable code b1
+reachable code b1
+in continue handler
+in continue handler
+reachable code a2
+reachable code a2
+drop procedure bug8153_proc_a|
+drop procedure bug8153_proc_b|
+drop table t3|
+drop table t4|
+drop procedure if exists bug19862|
+CREATE TABLE t11 (a INT)|
+CREATE TABLE t12 (a INT)|
+CREATE FUNCTION bug19862(x INT) RETURNS INT
+BEGIN
+INSERT INTO t11 VALUES (x);
+RETURN x+1;
+END|
+INSERT INTO t12 VALUES (1), (2)|
+SELECT bug19862(a) FROM t12 ORDER BY 1|
+bug19862(a)
+2
+3
+SELECT * FROM t11|
+a
+1
+2
+DROP TABLE t11, t12|
+DROP FUNCTION bug19862|
+drop table if exists t3|
+drop database if exists mysqltest1|
+create table t3 (a int)|
+insert into t3 (a) values (1), (2)|
+create database mysqltest1|
+use mysqltest1|
+drop database mysqltest1|
+select database()|
+database()
+NULL
+select * from (select 1 as a) as t1 natural join (select * from test.t3) as t2|
+a
+1
+use test|
+drop table t3|
+DROP PROCEDURE IF EXISTS bug16899_p1|
+DROP FUNCTION IF EXISTS bug16899_f1|
+CREATE DEFINER=1234567890abcdefGHIKL@localhost PROCEDURE bug16899_p1()
+BEGIN
+SET @a = 1;
+END|
+ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16)
+CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY
+FUNCTION bug16899_f1() RETURNS INT
+BEGIN
+RETURN 1;
+END|
+ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60)
+drop procedure if exists bug21416|
+create procedure bug21416() show create procedure bug21416|
+call bug21416()|
+Procedure sql_mode Create Procedure
+bug21416 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug21416`()
+show create procedure bug21416
+drop procedure bug21416|
+CREATE TABLE t3 (
+Member_ID varchar(15) NOT NULL,
+PRIMARY KEY (Member_ID)
+)|
+CREATE TABLE t4 (
+ID int(10) unsigned NOT NULL auto_increment,
+Member_ID varchar(15) NOT NULL default '',
+Action varchar(12) NOT NULL,
+Action_Date datetime NOT NULL,
+Track varchar(15) default NULL,
+User varchar(12) default NULL,
+Date_Updated timestamp NOT NULL default CURRENT_TIMESTAMP on update
+CURRENT_TIMESTAMP,
+PRIMARY KEY (ID),
+KEY Action (Action),
+KEY Action_Date (Action_Date)
+)|
+INSERT INTO t3(Member_ID) VALUES
+('111111'), ('222222'), ('333333'), ('444444'), ('555555'), ('666666')|
+INSERT INTO t4(Member_ID, Action, Action_Date, Track) VALUES
+('111111', 'Disenrolled', '2006-03-01', 'CAD' ),
+('111111', 'Enrolled', '2006-03-01', 'CAD' ),
+('111111', 'Disenrolled', '2006-07-03', 'CAD' ),
+('222222', 'Enrolled', '2006-03-07', 'CAD' ),
+('222222', 'Enrolled', '2006-03-07', 'CHF' ),
+('222222', 'Disenrolled', '2006-08-02', 'CHF' ),
+('333333', 'Enrolled', '2006-03-01', 'CAD' ),
+('333333', 'Disenrolled', '2006-03-01', 'CAD' ),
+('444444', 'Enrolled', '2006-03-01', 'CAD' ),
+('555555', 'Disenrolled', '2006-03-01', 'CAD' ),
+('555555', 'Enrolled', '2006-07-21', 'CAD' ),
+('555555', 'Disenrolled', '2006-03-01', 'CHF' ),
+('666666', 'Enrolled', '2006-02-09', 'CAD' ),
+('666666', 'Enrolled', '2006-05-12', 'CHF' ),
+('666666', 'Disenrolled', '2006-06-01', 'CAD' )|
+DROP FUNCTION IF EXISTS bug21493|
+Warnings:
+Note 1305 FUNCTION bug21493 does not exist
+CREATE FUNCTION bug21493(paramMember VARCHAR(15)) RETURNS varchar(45)
+BEGIN
+DECLARE tracks VARCHAR(45);
+SELECT GROUP_CONCAT(Track SEPARATOR ', ') INTO tracks FROM t4
+WHERE Member_ID=paramMember AND Action='Enrolled' AND
+(Track,Action_Date) IN (SELECT Track, MAX(Action_Date) FROM t4
+WHERE Member_ID=paramMember GROUP BY Track);
+RETURN tracks;
+END|
+SELECT bug21493('111111')|
+bug21493('111111')
+NULL
+SELECT bug21493('222222')|
+bug21493('222222')
+CAD
+SELECT bug21493(Member_ID) FROM t3|
+bug21493(Member_ID)
+NULL
+CAD
+CAD
+CAD
+CAD
+CHF
+DROP FUNCTION bug21493|
+DROP TABLE t3,t4|
drop table t1,t2;
diff --git a/mysql-test/r/sp.result.orig b/mysql-test/r/sp.result.orig
deleted file mode 100644
index 663204681f2..00000000000
--- a/mysql-test/r/sp.result.orig
+++ /dev/null
@@ -1,4853 +0,0 @@
-use test;
-drop table if exists t1,t2,t3,t4;
-create table t1 (
-id char(16) not null default '',
-data int not null
-);
-create table t2 (
-s char(16),
-i int,
-d double
-);
-drop procedure if exists foo42;
-create procedure foo42()
-insert into test.t1 values ("foo", 42);
-call foo42();
-select * from t1;
-id data
-foo 42
-delete from t1;
-drop procedure foo42;
-drop procedure if exists bar;
-create procedure bar(x char(16), y int)
-insert into test.t1 values (x, y);
-call bar("bar", 666);
-select * from t1;
-id data
-bar 666
-delete from t1;
-drop procedure if exists empty|
-create procedure empty()
-begin
-end|
-call empty()|
-drop procedure empty|
-drop procedure if exists scope|
-create procedure scope(a int, b float)
-begin
-declare b int;
-declare c float;
-begin
-declare c int;
-end;
-end|
-drop procedure scope|
-drop procedure if exists two|
-create procedure two(x1 char(16), x2 char(16), y int)
-begin
-insert into test.t1 values (x1, y);
-insert into test.t1 values (x2, y);
-end|
-call two("one", "two", 3)|
-select * from t1|
-id data
-one 3
-two 3
-delete from t1|
-drop procedure two|
-drop procedure if exists locset|
-create procedure locset(x char(16), y int)
-begin
-declare z1, z2 int;
-set z1 = y;
-set z2 = z1+2;
-insert into test.t1 values (x, z2);
-end|
-call locset("locset", 19)|
-select * from t1|
-id data
-locset 21
-delete from t1|
-drop procedure locset|
-drop procedure if exists setcontext|
-create procedure setcontext()
-begin
-declare data int default 2;
-insert into t1 (id, data) values ("foo", 1);
-replace t1 set data = data, id = "bar";
-update t1 set id = "kaka", data = 3 where t1.data = data;
-end|
-call setcontext()|
-select * from t1|
-id data
-foo 1
-kaka 3
-delete from t1|
-drop procedure setcontext|
-create table t3 ( d date, i int, f double, s varchar(32) )|
-drop procedure if exists nullset|
-create procedure nullset()
-begin
-declare ld date;
-declare li int;
-declare lf double;
-declare ls varchar(32);
-set ld = null, li = null, lf = null, ls = null;
-insert into t3 values (ld, li, lf, ls);
-insert into t3 (i, f, s) values ((ld is null), 1, "ld is null"),
-((li is null), 1, "li is null"),
-((li = 0), null, "li = 0"),
-((lf is null), 1, "lf is null"),
-((lf = 0), null, "lf = 0"),
-((ls is null), 1, "ls is null");
-end|
-call nullset()|
-select * from t3|
-d i f s
-NULL NULL NULL NULL
-NULL 1 1 ld is null
-NULL 1 1 li is null
-NULL NULL NULL li = 0
-NULL 1 1 lf is null
-NULL NULL NULL lf = 0
-NULL 1 1 ls is null
-drop table t3|
-drop procedure nullset|
-drop procedure if exists mixset|
-create procedure mixset(x char(16), y int)
-begin
-declare z int;
-set @z = y, z = 666, max_join_size = 100;
-insert into test.t1 values (x, z);
-end|
-call mixset("mixset", 19)|
-show variables like 'max_join_size'|
-Variable_name Value
-max_join_size 100
-select id,data,@z from t1|
-id data @z
-mixset 666 19
-delete from t1|
-drop procedure mixset|
-drop procedure if exists zip|
-create procedure zip(x char(16), y int)
-begin
-declare z int;
-call zap(y, z);
-call bar(x, z);
-end|
-drop procedure if exists zap|
-create procedure zap(x int, out y int)
-begin
-declare z int;
-set z = x+1, y = z;
-end|
-call zip("zip", 99)|
-select * from t1|
-id data
-zip 100
-delete from t1|
-drop procedure zip|
-drop procedure bar|
-call zap(7, @zap)|
-select @zap|
-@zap
-8
-drop procedure zap|
-drop procedure if exists c1|
-create procedure c1(x int)
-call c2("c", x)|
-drop procedure if exists c2|
-create procedure c2(s char(16), x int)
-call c3(x, s)|
-drop procedure if exists c3|
-create procedure c3(x int, s char(16))
-call c4("level", x, s)|
-drop procedure if exists c4|
-create procedure c4(l char(8), x int, s char(16))
-insert into t1 values (concat(l,s), x)|
-call c1(42)|
-select * from t1|
-id data
-levelc 42
-delete from t1|
-drop procedure c1|
-drop procedure c2|
-drop procedure c3|
-drop procedure c4|
-drop procedure if exists iotest|
-create procedure iotest(x1 char(16), x2 char(16), y int)
-begin
-call inc2(x2, y);
-insert into test.t1 values (x1, y);
-end|
-drop procedure if exists inc2|
-create procedure inc2(x char(16), y int)
-begin
-call inc(y);
-insert into test.t1 values (x, y);
-end|
-drop procedure if exists inc|
-create procedure inc(inout io int)
-set io = io + 1|
-call iotest("io1", "io2", 1)|
-select * from t1|
-id data
-io2 2
-io1 1
-delete from t1|
-drop procedure iotest|
-drop procedure inc2|
-drop procedure if exists incr|
-create procedure incr(inout x int)
-call inc(x)|
-select @zap|
-@zap
-8
-call incr(@zap)|
-select @zap|
-@zap
-9
-drop procedure inc|
-drop procedure incr|
-drop procedure if exists cbv1|
-create procedure cbv1()
-begin
-declare y int default 3;
-call cbv2(y+1, y);
-insert into test.t1 values ("cbv1", y);
-end|
-drop procedure if exists cbv2|
-create procedure cbv2(y1 int, inout y2 int)
-begin
-set y2 = 4711;
-insert into test.t1 values ("cbv2", y1);
-end|
-call cbv1()|
-select * from t1|
-id data
-cbv2 4
-cbv1 4711
-delete from t1|
-drop procedure cbv1|
-drop procedure cbv2|
-insert into t2 values ("a", 1, 1.1), ("b", 2, 1.2), ("c", 3, 1.3)|
-drop procedure if exists sub1|
-create procedure sub1(id char(16), x int)
-insert into test.t1 values (id, x)|
-drop procedure if exists sub2|
-create procedure sub2(id char(16))
-begin
-declare x int;
-set x = (select sum(t.i) from test.t2 t);
-insert into test.t1 values (id, x);
-end|
-drop procedure if exists sub3|
-create function sub3(i int) returns int
-return i+1|
-call sub1("sub1a", (select 7))|
-call sub1("sub1b", (select max(i) from t2))|
-call sub1("sub1c", (select i,d from t2 limit 1))|
-ERROR 21000: Operand should contain 1 column(s)
-call sub1("sub1d", (select 1 from (select 1) a))|
-call sub2("sub2")|
-select * from t1|
-id data
-sub1a 7
-sub1b 3
-sub1d 1
-sub2 6
-select sub3((select max(i) from t2))|
-sub3((select max(i) from t2))
-4
-drop procedure sub1|
-drop procedure sub2|
-drop function sub3|
-delete from t1|
-delete from t2|
-drop procedure if exists a0|
-create procedure a0(x int)
-while x do
-set x = x-1;
-insert into test.t1 values ("a0", x);
-end while|
-call a0(3)|
-select * from t1|
-id data
-a0 2
-a0 1
-a0 0
-delete from t1|
-drop procedure a0|
-drop procedure if exists a|
-create procedure a(x int)
-while x > 0 do
-set x = x-1;
-insert into test.t1 values ("a", x);
-end while|
-call a(3)|
-select * from t1|
-id data
-a 2
-a 1
-a 0
-delete from t1|
-drop procedure a|
-drop procedure if exists b|
-create procedure b(x int)
-repeat
-insert into test.t1 values (repeat("b",3), x);
-set x = x-1;
-until x = 0 end repeat|
-call b(3)|
-select * from t1|
-id data
-bbb 3
-bbb 2
-bbb 1
-delete from t1|
-drop procedure b|
-drop procedure if exists b2|
-create procedure b2(x int)
-repeat(select 1 into outfile 'b2');
-insert into test.t1 values (repeat("b2",3), x);
-set x = x-1;
-until x = 0 end repeat|
-drop procedure b2|
-drop procedure if exists c|
-create procedure c(x int)
-hmm: while x > 0 do
-insert into test.t1 values ("c", x);
-set x = x-1;
-iterate hmm;
-insert into test.t1 values ("x", x);
-end while hmm|
-call c(3)|
-select * from t1|
-id data
-c 3
-c 2
-c 1
-delete from t1|
-drop procedure c|
-drop procedure if exists d|
-create procedure d(x int)
-hmm: while x > 0 do
-insert into test.t1 values ("d", x);
-set x = x-1;
-leave hmm;
-insert into test.t1 values ("x", x);
-end while|
-call d(3)|
-select * from t1|
-id data
-d 3
-delete from t1|
-drop procedure d|
-drop procedure if exists e|
-create procedure e(x int)
-foo: loop
-if x = 0 then
-leave foo;
-end if;
-insert into test.t1 values ("e", x);
-set x = x-1;
-end loop foo|
-call e(3)|
-select * from t1|
-id data
-e 3
-e 2
-e 1
-delete from t1|
-drop procedure e|
-drop procedure if exists f|
-create procedure f(x int)
-if x < 0 then
-insert into test.t1 values ("f", 0);
-elseif x = 0 then
-insert into test.t1 values ("f", 1);
-else
-insert into test.t1 values ("f", 2);
-end if|
-call f(-2)|
-call f(0)|
-call f(4)|
-select * from t1|
-id data
-f 0
-f 1
-f 2
-delete from t1|
-drop procedure f|
-drop procedure if exists g|
-create procedure g(x int)
-case
-when x < 0 then
-insert into test.t1 values ("g", 0);
-when x = 0 then
-insert into test.t1 values ("g", 1);
-else
-insert into test.t1 values ("g", 2);
-end case|
-call g(-42)|
-call g(0)|
-call g(1)|
-select * from t1|
-id data
-g 0
-g 1
-g 2
-delete from t1|
-drop procedure g|
-drop procedure if exists h|
-create procedure h(x int)
-case x
-when 0 then
-insert into test.t1 values ("h0", x);
-when 1 then
-insert into test.t1 values ("h1", x);
-else
-insert into test.t1 values ("h?", x);
-end case|
-call h(0)|
-call h(1)|
-call h(17)|
-select * from t1|
-id data
-h0 0
-h1 1
-h? 17
-delete from t1|
-drop procedure h|
-drop procedure if exists i|
-create procedure i(x int)
-foo:
-begin
-if x = 0 then
-leave foo;
-end if;
-insert into test.t1 values ("i", x);
-end foo|
-call i(0)|
-call i(3)|
-select * from t1|
-id data
-i 3
-delete from t1|
-drop procedure i|
-insert into t1 values ("foo", 3), ("bar", 19)|
-insert into t2 values ("x", 9, 4.1), ("y", -1, 19.2), ("z", 3, 2.2)|
-drop procedure if exists sel1|
-create procedure sel1()
-begin
-select * from t1;
-end|
-call sel1()|
-id data
-foo 3
-bar 19
-drop procedure sel1|
-drop procedure if exists sel2|
-create procedure sel2()
-begin
-select * from t1;
-select * from t2;
-end|
-call sel2()|
-id data
-foo 3
-bar 19
-s i d
-x 9 4.1
-y -1 19.2
-z 3 2.2
-drop procedure sel2|
-delete from t1|
-delete from t2|
-drop procedure if exists into_test|
-create procedure into_test(x char(16), y int)
-begin
-insert into test.t1 values (x, y);
-select id,data into x,y from test.t1 limit 1;
-insert into test.t1 values (concat(x, "2"), y+2);
-end|
-call into_test("into", 100)|
-select * from t1|
-id data
-into 100
-into2 102
-delete from t1|
-drop procedure into_test|
-drop procedure if exists into_tes2|
-create procedure into_test2(x char(16), y int)
-begin
-insert into test.t1 values (x, y);
-select id,data into x,@z from test.t1 limit 1;
-insert into test.t1 values (concat(x, "2"), y+2);
-end|
-call into_test2("into", 100)|
-select id,data,@z from t1|
-id data @z
-into 100 100
-into2 102 100
-delete from t1|
-drop procedure into_test2|
-drop procedure if exists into_test3|
-create procedure into_test3()
-begin
-declare x char(16);
-declare y int;
-select * into x,y from test.t1 limit 1;
-insert into test.t2 values (x, y, 0.0);
-end|
-insert into t1 values ("into3", 19)|
-call into_test3()|
-call into_test3()|
-select * from t2|
-s i d
-into3 19 0
-into3 19 0
-delete from t1|
-delete from t2|
-drop procedure into_test3|
-drop procedure if exists into_test4|
-create procedure into_test4()
-begin
-declare x int;
-select data into x from test.t1 limit 1;
-insert into test.t3 values ("into4", x);
-end|
-delete from t1|
-create table t3 ( s char(16), d int)|
-call into_test4()|
-Warnings:
-Warning 1329 No data - zero rows fetched, selected, or processed
-select * from t3|
-s d
-into4 NULL
-insert into t1 values ("i4", 77)|
-call into_test4()|
-select * from t3|
-s d
-into4 NULL
-into4 77
-delete from t1|
-drop table t3|
-drop procedure into_test4|
-drop procedure if exists into_outfile|
-create procedure into_outfile(x char(16), y int)
-begin
-insert into test.t1 values (x, y);
-select * into outfile "../tmp/spout" from test.t1;
-insert into test.t1 values (concat(x, "2"), y+2);
-end|
-call into_outfile("ofile", 1)|
-delete from t1|
-drop procedure into_outfile|
-drop procedure if exists into_dumpfile|
-create procedure into_dumpfile(x char(16), y int)
-begin
-insert into test.t1 values (x, y);
-select * into dumpfile "../tmp/spdump" from test.t1 limit 1;
-insert into test.t1 values (concat(x, "2"), y+2);
-end|
-call into_dumpfile("dfile", 1)|
-delete from t1|
-drop procedure into_dumpfile|
-drop procedure if exists create_select|
-create procedure create_select(x char(16), y int)
-begin
-insert into test.t1 values (x, y);
-create temporary table test.t3 select * from test.t1;
-insert into test.t3 values (concat(x, "2"), y+2);
-end|
-call create_select("cs", 90)|
-select * from t1, t3|
-id data id data
-cs 90 cs 90
-cs 90 cs2 92
-drop table t3|
-delete from t1|
-drop procedure create_select|
-drop function if exists e|
-create function e() returns double
-return 2.7182818284590452354|
-set @e = e()|
-select e(), @e|
-e() @e
-2.718281828459 2.718281828459
-drop function if exists inc|
-create function inc(i int) returns int
-return i+1|
-select inc(1), inc(99), inc(-71)|
-inc(1) inc(99) inc(-71)
-2 100 -70
-drop function if exists mul|
-create function mul(x int, y int) returns int
-return x*y|
-select mul(1,1), mul(3,5), mul(4711, 666)|
-mul(1,1) mul(3,5) mul(4711, 666)
-1 15 3137526
-drop function if exists append|
-create function append(s1 char(8), s2 char(8)) returns char(16)
-return concat(s1, s2)|
-select append("foo", "bar")|
-append("foo", "bar")
-foobar
-drop function if exists fac|
-create function fac(n int unsigned) returns bigint unsigned
-begin
-declare f bigint unsigned default 1;
-while n > 1 do
-set f = f * n;
-set n = n - 1;
-end while;
-return f;
-end|
-select fac(1), fac(2), fac(5), fac(10)|
-fac(1) fac(2) fac(5) fac(10)
-1 2 120 3628800
-drop function if exists fun|
-create function fun(d double, i int, u int unsigned) returns double
-return mul(inc(i), fac(u)) / e()|
-select fun(2.3, 3, 5)|
-fun(2.3, 3, 5)
-176.58213176229
-insert into t2 values (append("xxx", "yyy"), mul(4,3), e())|
-insert into t2 values (append("a", "b"), mul(2,mul(3,4)), fun(1.7, 4, 6))|
-select * from t2 where s = append("a", "b")|
-s i d
-ab 24 1324.36598821719
-select * from t2 where i = mul(4,3) or i = mul(mul(3,4),2)|
-s i d
-xxxyyy 12 2.71828182845905
-ab 24 1324.36598821719
-select * from t2 where d = e()|
-s i d
-xxxyyy 12 2.71828182845905
-select * from t2|
-s i d
-xxxyyy 12 2.71828182845905
-ab 24 1324.36598821719
-delete from t2|
-drop function e|
-drop function inc|
-drop function mul|
-drop function append|
-drop function fun|
-drop procedure if exists hndlr1|
-create procedure hndlr1(val int)
-begin
-declare x int default 0;
-declare foo condition for 1136;
-declare bar condition for sqlstate '42S98'; # Just for testing syntax
-declare zip condition for sqlstate value '42S99'; # Just for testing syntax
-declare continue handler for foo set x = 1;
-insert into test.t1 values ("hndlr1", val, 2); # Too many values
-if (x) then
-insert into test.t1 values ("hndlr1", val); # This instead then
-end if;
-end|
-call hndlr1(42)|
-select * from t1|
-id data
-hndlr1 42
-delete from t1|
-drop procedure hndlr1|
-drop procedure if exists hndlr2|
-create procedure hndlr2(val int)
-begin
-declare x int default 0;
-begin
-declare exit handler for sqlstate '21S01' set x = 1;
-insert into test.t1 values ("hndlr2", val, 2); # Too many values
-end;
-insert into test.t1 values ("hndlr2", x);
-end|
-call hndlr2(42)|
-select * from t1|
-id data
-hndlr2 1
-delete from t1|
-drop procedure hndlr2|
-drop procedure if exists hndlr3|
-create procedure hndlr3(val int)
-begin
-declare x int default 0;
-declare continue handler for sqlexception # Any error
-begin
-declare z int;
-set z = 2 * val;
-set x = 1;
-end;
-if val < 10 then
-begin
-declare y int;
-set y = val + 10;
-insert into test.t1 values ("hndlr3", y, 2); # Too many values
-if x then
-insert into test.t1 values ("hndlr3", y);
-end if;
-end;
-end if;
-end|
-call hndlr3(3)|
-select * from t1|
-id data
-hndlr3 13
-delete from t1|
-drop procedure hndlr3|
-create table t3 ( id char(16), data int )|
-drop procedure if exists hndlr4|
-create procedure hndlr4()
-begin
-declare x int default 0;
-declare val int; # No default
-declare continue handler for sqlstate '02000' set x=1;
-select data into val from test.t3 where id='z' limit 1; # No hits
-insert into test.t3 values ('z', val);
-end|
-call hndlr4()|
-select * from t3|
-id data
-z NULL
-drop table t3|
-drop procedure hndlr4|
-drop procedure if exists cur1|
-create procedure cur1()
-begin
-declare a char(16);
-declare b int;
-declare c double;
-declare done int default 0;
-declare c cursor for select * from test.t2;
-declare continue handler for sqlstate '02000' set done = 1;
-open c;
-repeat
-fetch c into a, b, c;
-if not done then
-insert into test.t1 values (a, b+c);
-end if;
-until done end repeat;
-close c;
-end|
-insert into t2 values ("foo", 42, -1.9), ("bar", 3, 12.1), ("zap", 666, -3.14)|
-call cur1()|
-select * from t1|
-id data
-foo 40
-bar 15
-zap 663
-drop procedure cur1|
-create table t3 ( s char(16), i int )|
-drop procedure if exists cur2|
-create procedure cur2()
-begin
-declare done int default 0;
-declare c1 cursor for select id,data from test.t1;
-declare c2 cursor for select i from test.t2;
-declare continue handler for sqlstate '02000' set done = 1;
-open c1;
-open c2;
-repeat
-begin
-declare a char(16);
-declare b,c int;
-fetch from c1 into a, b;
-fetch next from c2 into c;
-if not done then
-if b < c then
-insert into test.t3 values (a, b);
-else
-insert into test.t3 values (a, c);
-end if;
-end if;
-end;
-until done end repeat;
-close c1;
-close c2;
-end|
-call cur2()|
-select * from t3|
-s i
-foo 40
-bar 3
-zap 663
-delete from t1|
-delete from t2|
-drop table t3|
-drop procedure cur2|
-drop procedure if exists chistics|
-create procedure chistics()
-language sql
-modifies sql data
-not deterministic
-sql security definer
-comment 'Characteristics procedure test'
- insert into t1 values ("chistics", 1)|
-show create procedure chistics|
-Procedure sql_mode Create Procedure
-chistics CREATE PROCEDURE `chistics`()
- MODIFIES SQL DATA
- COMMENT 'Characteristics procedure test'
-insert into t1 values ("chistics", 1)
-call chistics()|
-select * from t1|
-id data
-chistics 1
-delete from t1|
-alter procedure chistics sql security invoker|
-show create procedure chistics|
-Procedure sql_mode Create Procedure
-chistics CREATE PROCEDURE `chistics`()
- MODIFIES SQL DATA
- SQL SECURITY INVOKER
- COMMENT 'Characteristics procedure test'
-insert into t1 values ("chistics", 1)
-drop procedure chistics|
-drop function if exists chistics|
-create function chistics() returns int
-language sql
-deterministic
-sql security invoker
-comment 'Characteristics procedure test'
- return 42|
-show create function chistics|
-Function sql_mode Create Function
-chistics CREATE FUNCTION `chistics`() RETURNS int(11)
- DETERMINISTIC
- SQL SECURITY INVOKER
- COMMENT 'Characteristics procedure test'
-return 42
-select chistics()|
-chistics()
-42
-alter function chistics
-no sql
-comment 'Characteristics function test'|
-show create function chistics|
-Function sql_mode Create Function
-chistics CREATE FUNCTION `chistics`() RETURNS int(11)
- NO SQL
- DETERMINISTIC
- SQL SECURITY INVOKER
- COMMENT 'Characteristics function test'
-return 42
-drop function chistics|
-insert into t1 values ("foo", 1), ("bar", 2), ("zip", 3)|
-set @@sql_mode = 'ANSI'|
-drop procedure if exists modes$
-create procedure modes(out c1 int, out c2 int)
-begin
-declare done int default 0;
-declare x int;
-declare c cursor for select data from t1;
-declare continue handler for sqlstate '02000' set done = 1;
-select 1 || 2 into c1;
-set c2 = 0;
-open c;
-repeat
-fetch c into x;
-if not done then
-set c2 = c2 + 1;
-end if;
-until done end repeat;
-close c;
-end$
-set @@sql_mode = ''|
-set sql_select_limit = 1|
-call modes(@c1, @c2)|
-set sql_select_limit = default|
-select @c1, @c2|
-@c1 @c2
-12 3
-delete from t1|
-drop procedure modes|
-create database sp_db1|
-drop database sp_db1|
-create database sp_db2|
-use sp_db2|
-create table t3 ( s char(4), t int )|
-insert into t3 values ("abcd", 42), ("dcba", 666)|
-use test|
-drop database sp_db2|
-create database sp_db3|
-use sp_db3|
-drop procedure if exists dummy|
-create procedure dummy(out x int)
-set x = 42|
-use test|
-drop database sp_db3|
-select type,db,name from mysql.proc where db = 'sp_db3'|
-type db name
-drop procedure if exists rc|
-create procedure rc()
-begin
-delete from t1;
-insert into t1 values ("a", 1), ("b", 2), ("c", 3);
-end|
-call rc()|
-select row_count()|
-row_count()
-3
-update t1 set data=42 where id = "b";
-select row_count()|
-row_count()
-1
-delete from t1|
-select row_count()|
-row_count()
-3
-delete from t1|
-select row_count()|
-row_count()
-0
-select * from t1|
-id data
-select row_count()|
-row_count()
--1
-drop procedure rc|
-drop function if exists f0|
-drop function if exists f1|
-drop function if exists f2|
-drop function if exists f3|
-drop function if exists f4|
-drop function if exists f5|
-drop function if exists f6|
-drop function if exists f7|
-drop function if exists f8|
-drop function if exists f9|
-drop function if exists f10|
-drop function if exists f11|
-drop function if exists f12_1|
-drop function if exists f12_2|
-drop view if exists v0|
-drop view if exists v1|
-drop view if exists v2|
-delete from t1|
-delete from t2|
-insert into t1 values ("a", 1), ("b", 2) |
-insert into t2 values ("a", 1, 1.0), ("b", 2, 2.0), ("c", 3, 3.0) |
-create function f1() returns int
-return (select sum(data) from t1)|
-select f1()|
-f1()
-3
-select id, f1() from t1|
-id f1()
-a 3
-b 3
-create function f2() returns int
-return (select data from t1 where data <= (select sum(data) from t1) limit 1)|
-select f2()|
-f2()
-1
-select id, f2() from t1|
-id f2()
-a 1
-b 1
-create function f3() returns int
-begin
-declare n int;
-declare m int;
-set n:= (select min(data) from t1);
-set m:= (select max(data) from t1);
-return n < m;
-end|
-select f3()|
-f3()
-1
-select id, f3() from t1|
-id f3()
-a 1
-b 1
-select f1(), f3()|
-f1() f3()
-3 1
-select id, f1(), f3() from t1|
-id f1() f3()
-a 3 1
-b 3 1
-create function f4() returns double
-return (select d from t1, t2 where t1.data = t2.i and t1.id= "b")|
-select f4()|
-f4()
-2
-select s, f4() from t2|
-s f4()
-a 2
-b 2
-c 2
-create function f5(i int) returns int
-begin
-if i <= 0 then
-return 0;
-elseif i = 1 then
-return (select count(*) from t1 where data = i);
-else
-return (select count(*) + f5( i - 1) from t1 where data = i);
-end if;
-end|
-select f5(1)|
-f5(1)
-1
-select f5(2)|
-ERROR HY000: Recursive stored functions and triggers are not allowed.
-select f5(3)|
-ERROR HY000: Recursive stored functions and triggers are not allowed.
-create function f6() returns int
-begin
-declare n int;
-set n:= f1();
-return (select count(*) from t1 where data <= f7() and data <= n);
-end|
-create function f7() returns int
-return (select sum(data) from t1 where data <= f1())|
-select f6()|
-f6()
-2
-select id, f6() from t1|
-id f6()
-a 2
-b 2
-create view v1 (a) as select f1()|
-select * from v1|
-a
-3
-select id, a from t1, v1|
-id a
-a 3
-b 3
-select * from v1, v1 as v|
-a a
-3 3
-create view v2 (a) as select a*10 from v1|
-select * from v2|
-a
-30
-select id, a from t1, v2|
-id a
-a 30
-b 30
-select * from v1, v2|
-a a
-3 30
-create function f8 () returns int
-return (select count(*) from v2)|
-select *, f8() from v1|
-a f8()
-3 1
-drop function f1|
-select * from v1|
-ERROR HY000: View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
-create function f1() returns int
-return (select sum(data) from t1) + (select sum(data) from v1)|
-select f1()|
-ERROR HY000: Recursive stored functions and triggers are not allowed.
-select * from v1|
-ERROR HY000: Recursive stored functions and triggers are not allowed.
-select * from v2|
-ERROR HY000: Recursive stored functions and triggers are not allowed.
-drop function f1|
-create function f1() returns int
-return (select sum(data) from t1)|
-create function f0() returns int
-return (select * from (select 100) as r)|
-select f0()|
-f0()
-100
-select *, f0() from (select 1) as t|
-1 f0()
-1 100
-create view v0 as select f0()|
-select * from v0|
-f0()
-100
-select *, f0() from v0|
-f0() f0()
-100 100
-lock tables t1 read, t1 as t11 read|
-select f3()|
-f3()
-1
-select id, f3() from t1 as t11|
-id f3()
-a 1
-b 1
-select f0()|
-f0()
-100
-select * from v0|
-f0()
-100
-select *, f0() from v0, (select 123) as d1|
-f0() 123 f0()
-100 123 100
-select id, f3() from t1|
-ERROR HY000: Table 't1' was not locked with LOCK TABLES
-select f4()|
-ERROR HY000: Table 't2' was not locked with LOCK TABLES
-unlock tables|
-lock tables v2 read, mysql.proc read|
-select * from v2|
-a
-30
-select * from v1|
-a
-3
-select * from v1, t1|
-ERROR HY000: Table 't1' was not locked with LOCK TABLES
-select f4()|
-ERROR HY000: Table 't2' was not locked with LOCK TABLES
-unlock tables|
-create function f9() returns int
-begin
-declare a, b int;
-drop temporary table if exists t3;
-create temporary table t3 (id int);
-insert into t3 values (1), (2), (3);
-set a:= (select count(*) from t3);
-set b:= (select count(*) from t3 t3_alias);
-return a + b;
-end|
-select f9()|
-f9()
-6
-Warnings:
-Note 1051 Unknown table 't3'
-select f9() from t1 limit 1|
-f9()
-6
-create function f10() returns int
-begin
-drop temporary table if exists t3;
-create temporary table t3 (id int);
-insert into t3 select id from t4;
-return (select count(*) from t3);
-end|
-select f10()|
-ERROR 42S02: Table 'test.t4' doesn't exist
-create table t4 as select 1 as id|
-select f10()|
-f10()
-1
-create function f11() returns int
-begin
-drop temporary table if exists t3;
-create temporary table t3 (id int);
-insert into t3 values (1), (2), (3);
-return (select count(*) from t3 as a, t3 as b);
-end|
-select f11()|
-ERROR HY000: Can't reopen table: 'a'
-select f11() from t1|
-ERROR HY000: Can't reopen table: 'a'
-create function f12_1() returns int
-begin
-drop temporary table if exists t3;
-create temporary table t3 (id int);
-insert into t3 values (1), (2), (3);
-return f12_2();
-end|
-create function f12_2() returns int
-return (select count(*) from t3)|
-drop temporary table t3|
-select f12_1()|
-ERROR 42S02: Table 'test.t3' doesn't exist
-select f12_1() from t1 limit 1|
-ERROR 42S02: Table 'test.t3' doesn't exist
-drop function f0|
-drop function f1|
-drop function f2|
-drop function f3|
-drop function f4|
-drop function f5|
-drop function f6|
-drop function f7|
-drop function f8|
-drop function f9|
-drop function f10|
-drop function f11|
-drop function f12_1|
-drop function f12_2|
-drop view v0|
-drop view v1|
-drop view v2|
-delete from t1 |
-delete from t2 |
-drop table t4|
-drop table if exists t3|
-create table t3 (n int unsigned not null primary key, f bigint unsigned)|
-drop procedure if exists ifac|
-create procedure ifac(n int unsigned)
-begin
-declare i int unsigned default 1;
-if n > 20 then
-set n = 20; # bigint overflow otherwise
-end if;
-while i <= n do
-begin
-insert into test.t3 values (i, fac(i));
-set i = i + 1;
-end;
-end while;
-end|
-call ifac(20)|
-select * from t3|
-n f
-1 1
-2 2
-3 6
-4 24
-5 120
-6 720
-7 5040
-8 40320
-9 362880
-10 3628800
-11 39916800
-12 479001600
-13 6227020800
-14 87178291200
-15 1307674368000
-16 20922789888000
-17 355687428096000
-18 6402373705728000
-19 121645100408832000
-20 2432902008176640000
-drop table t3|
-show function status like '%f%'|
-Db Name Type Definer Modified Created Security_type Comment
-test fac FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
-drop procedure ifac|
-drop function fac|
-show function status like '%f%'|
-Db Name Type Definer Modified Created Security_type Comment
-drop table if exists t3|
-create table t3 (
-i int unsigned not null primary key,
-p bigint unsigned not null
-)|
-insert into t3 values
-( 0, 3), ( 1, 5), ( 2, 7), ( 3, 11), ( 4, 13),
-( 5, 17), ( 6, 19), ( 7, 23), ( 8, 29), ( 9, 31),
-(10, 37), (11, 41), (12, 43), (13, 47), (14, 53),
-(15, 59), (16, 61), (17, 67), (18, 71), (19, 73),
-(20, 79), (21, 83), (22, 89), (23, 97), (24, 101),
-(25, 103), (26, 107), (27, 109), (28, 113), (29, 127),
-(30, 131), (31, 137), (32, 139), (33, 149), (34, 151),
-(35, 157), (36, 163), (37, 167), (38, 173), (39, 179),
-(40, 181), (41, 191), (42, 193), (43, 197), (44, 199)|
-drop procedure if exists opp|
-create procedure opp(n bigint unsigned, out pp bool)
-begin
-declare r double;
-declare b, s bigint unsigned default 0;
-set r = sqrt(n);
-again:
-loop
-if s = 45 then
-set b = b+200, s = 0;
-else
-begin
-declare p bigint unsigned;
-select t.p into p from test.t3 t where t.i = s;
-if b+p > r then
-set pp = 1;
-leave again;
-end if;
-if mod(n, b+p) = 0 then
-set pp = 0;
-leave again;
-end if;
-set s = s+1;
-end;
-end if;
-end loop;
-end|
-drop procedure if exists ip|
-create procedure ip(m int unsigned)
-begin
-declare p bigint unsigned;
-declare i int unsigned;
-set i=45, p=201;
-while i < m do
-begin
-declare pp bool default 0;
-call opp(p, pp);
-if pp then
-insert into test.t3 values (i, p);
-set i = i+1;
-end if;
-set p = p+2;
-end;
-end while;
-end|
-show create procedure opp|
-Procedure sql_mode Create Procedure
-opp CREATE PROCEDURE `opp`(n bigint unsigned, out pp bool)
-begin
-declare r double;
-declare b, s bigint unsigned default 0;
-set r = sqrt(n);
-again:
-loop
-if s = 45 then
-set b = b+200, s = 0;
-else
-begin
-declare p bigint unsigned;
-select t.p into p from test.t3 t where t.i = s;
-if b+p > r then
-set pp = 1;
-leave again;
-end if;
-if mod(n, b+p) = 0 then
-set pp = 0;
-leave again;
-end if;
-set s = s+1;
-end;
-end if;
-end loop;
-end
-show procedure status like '%p%'|
-Db Name Type Definer Modified Created Security_type Comment
-test ip PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
-test opp PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
-call ip(200)|
-select * from t3 where i=45 or i=100 or i=199|
-i p
-45 211
-100 557
-199 1229
-drop table t3|
-drop procedure opp|
-drop procedure ip|
-show procedure status like '%p%'|
-Db Name Type Definer Modified Created Security_type Comment
-drop table if exists t3|
-create table t3 ( f bigint unsigned not null )|
-drop procedure if exists fib|
-create procedure fib(n int unsigned)
-begin
-if n > 1 then
-begin
-declare x, y bigint unsigned;
-declare c cursor for select f from t3 order by f desc limit 2;
-open c;
-fetch c into y;
-fetch c into x;
-close c;
-insert into t3 values (x+y);
-call fib(n-1);
-end;
-end if;
-end|
-set @@max_sp_recursion_depth= 20|
-insert into t3 values (0), (1)|
-call fib(3)|
-select * from t3 order by f asc|
-f
-0
-1
-1
-2
-delete from t3|
-insert into t3 values (0), (1)|
-call fib(10)|
-select * from t3 order by f asc|
-f
-0
-1
-1
-2
-3
-5
-8
-13
-21
-34
-55
-drop table t3|
-drop procedure fib|
-set @@max_sp_recursion_depth= 0|
-drop procedure if exists bar|
-create procedure bar(x char(16), y int)
-comment "111111111111" sql security invoker
-insert into test.t1 values (x, y)|
-show procedure status like 'bar'|
-Db Name Type Definer Modified Created Security_type Comment
-test bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 INVOKER 111111111111
-alter procedure bar comment "2222222222" sql security definer|
-alter procedure bar comment "3333333333"|
-alter procedure bar|
-show create procedure bar|
-Procedure sql_mode Create Procedure
-bar CREATE PROCEDURE `bar`(x char(16), y int)
- COMMENT '3333333333'
-insert into test.t1 values (x, y)
-show procedure status like 'bar'|
-Db Name Type Definer Modified Created Security_type Comment
-test bar PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER 3333333333
-drop procedure bar|
-drop procedure if exists p1|
-create procedure p1 ()
-select (select s1 from t3) from t3|
-create table t3 (s1 int)|
-call p1()|
-(select s1 from t3)
-insert into t3 values (1)|
-call p1()|
-(select s1 from t3)
-1
-drop procedure p1|
-drop table t3|
-drop function if exists foo|
-create function `foo` () returns int
-return 5|
-select `foo` ()|
-`foo` ()
-5
-drop function `foo`|
-drop function if exists t1max|
-create function t1max() returns int
-begin
-declare x int;
-select max(data) into x from t1;
-return x;
-end|
-insert into t1 values ("foo", 3), ("bar", 2), ("zip", 5), ("zap", 1)|
-select t1max()|
-t1max()
-5
-drop function t1max|
-create table t3 (
-v char(16) not null primary key,
-c int unsigned not null
-)|
-create function getcount(s char(16)) returns int
-begin
-declare x int;
-select count(*) into x from t3 where v = s;
-if x = 0 then
-insert into t3 values (s, 1);
-else
-update t3 set c = c+1 where v = s;
-end if;
-return x;
-end|
-select * from t1 where data = getcount("bar")|
-id data
-zap 1
-select * from t3|
-v c
-bar 4
-select getcount("zip")|
-getcount("zip")
-0
-select getcount("zip")|
-getcount("zip")
-1
-select * from t3|
-v c
-bar 4
-zip 2
-select getcount(id) from t1 where data = 3|
-getcount(id)
-0
-select getcount(id) from t1 where data = 5|
-getcount(id)
-1
-select * from t3|
-v c
-bar 4
-zip 3
-foo 1
-drop table t3|
-drop function getcount|
-drop table if exists t3|
-drop procedure if exists h_ee|
-drop procedure if exists h_es|
-drop procedure if exists h_en|
-drop procedure if exists h_ew|
-drop procedure if exists h_ex|
-drop procedure if exists h_se|
-drop procedure if exists h_ss|
-drop procedure if exists h_sn|
-drop procedure if exists h_sw|
-drop procedure if exists h_sx|
-drop procedure if exists h_ne|
-drop procedure if exists h_ns|
-drop procedure if exists h_nn|
-drop procedure if exists h_we|
-drop procedure if exists h_ws|
-drop procedure if exists h_ww|
-drop procedure if exists h_xe|
-drop procedure if exists h_xs|
-drop procedure if exists h_xx|
-create table t3 (a smallint primary key)|
-insert into t3 (a) values (1)|
-create procedure h_ee()
-deterministic
-begin
-declare continue handler for 1062 -- ER_DUP_ENTRY
-select 'Outer (bad)' as 'h_ee';
-begin
-declare continue handler for 1062 -- ER_DUP_ENTRY
-select 'Inner (good)' as 'h_ee';
-insert into t3 values (1);
-end;
-end|
-create procedure h_es()
-deterministic
-begin
-declare continue handler for 1062 -- ER_DUP_ENTRY
-select 'Outer (good)' as 'h_es';
-begin
--- integrity constraint violation
-declare continue handler for sqlstate '23000'
- select 'Inner (bad)' as 'h_es';
-insert into t3 values (1);
-end;
-end|
-create procedure h_en()
-deterministic
-begin
-declare continue handler for 1329 -- ER_SP_FETCH_NO_DATA
-select 'Outer (good)' as 'h_en';
-begin
-declare x int;
-declare continue handler for sqlstate '02000' -- no data
-select 'Inner (bad)' as 'h_en';
-select a into x from t3 where a = 42;
-end;
-end|
-create procedure h_ew()
-deterministic
-begin
-declare continue handler for 1264 -- ER_WARN_DATA_OUT_OF_RANGE
-select 'Outer (good)' as 'h_ew';
-begin
-declare continue handler for sqlwarning
-select 'Inner (bad)' as 'h_ew';
-insert into t3 values (123456789012);
-end;
-delete from t3;
-insert into t3 values (1);
-end|
-create procedure h_ex()
-deterministic
-begin
-declare continue handler for 1062 -- ER_DUP_ENTRY
-select 'Outer (good)' as 'h_ex';
-begin
-declare continue handler for sqlexception
-select 'Inner (bad)' as 'h_ex';
-insert into t3 values (1);
-end;
-end|
-create procedure h_se()
-deterministic
-begin
--- integrity constraint violation
-declare continue handler for sqlstate '23000'
-select 'Outer (bad)' as 'h_se';
-begin
-declare continue handler for 1062 -- ER_DUP_ENTRY
-select 'Inner (good)' as 'h_se';
-insert into t3 values (1);
-end;
-end|
-create procedure h_ss()
-deterministic
-begin
--- integrity constraint violation
-declare continue handler for sqlstate '23000'
-select 'Outer (bad)' as 'h_ss';
-begin
--- integrity constraint violation
-declare continue handler for sqlstate '23000'
-select 'Inner (good)' as 'h_ss';
-insert into t3 values (1);
-end;
-end|
-create procedure h_sn()
-deterministic
-begin
--- Note: '02000' is more specific than NOT FOUND ;
--- there might be other not found states
-declare continue handler for sqlstate '02000' -- no data
-select 'Outer (good)' as 'h_sn';
-begin
-declare x int;
-declare continue handler for not found
-select 'Inner (bad)' as 'h_sn';
-select a into x from t3 where a = 42;
-end;
-end|
-create procedure h_sw()
-deterministic
-begin
--- data exception - numeric value out of range
-declare continue handler for sqlstate '22003'
- select 'Outer (good)' as 'h_sw';
-begin
-declare continue handler for sqlwarning
-select 'Inner (bad)' as 'h_sw';
-insert into t3 values (123456789012);
-end;
-delete from t3;
-insert into t3 values (1);
-end|
-create procedure h_sx()
-deterministic
-begin
--- integrity constraint violation
-declare continue handler for sqlstate '23000'
-select 'Outer (good)' as 'h_sx';
-begin
-declare continue handler for sqlexception
-select 'Inner (bad)' as 'h_sx';
-insert into t3 values (1);
-end;
-end|
-create procedure h_ne()
-deterministic
-begin
-declare continue handler for not found
-select 'Outer (bad)' as 'h_ne';
-begin
-declare x int;
-declare continue handler for 1329 -- ER_SP_FETCH_NO_DATA
-select 'Inner (good)' as 'h_ne';
-select a into x from t3 where a = 42;
-end;
-end|
-create procedure h_ns()
-deterministic
-begin
-declare continue handler for not found
-select 'Outer (bad)' as 'h_ns';
-begin
-declare x int;
-declare continue handler for sqlstate '02000' -- no data
-select 'Inner (good)' as 'h_ns';
-select a into x from t3 where a = 42;
-end;
-end|
-create procedure h_nn()
-deterministic
-begin
-declare continue handler for not found
-select 'Outer (bad)' as 'h_nn';
-begin
-declare x int;
-declare continue handler for not found
-select 'Inner (good)' as 'h_nn';
-select a into x from t3 where a = 42;
-end;
-end|
-create procedure h_we()
-deterministic
-begin
-declare continue handler for sqlwarning
-select 'Outer (bad)' as 'h_we';
-begin
-declare continue handler for 1264 -- ER_WARN_DATA_OUT_OF_RANGE
-select 'Inner (good)' as 'h_we';
-insert into t3 values (123456789012);
-end;
-delete from t3;
-insert into t3 values (1);
-end|
-create procedure h_ws()
-deterministic
-begin
-declare continue handler for sqlwarning
-select 'Outer (bad)' as 'h_ws';
-begin
--- data exception - numeric value out of range
-declare continue handler for sqlstate '22003'
- select 'Inner (good)' as 'h_ws';
-insert into t3 values (123456789012);
-end;
-delete from t3;
-insert into t3 values (1);
-end|
-create procedure h_ww()
-deterministic
-begin
-declare continue handler for sqlwarning
-select 'Outer (bad)' as 'h_ww';
-begin
-declare continue handler for sqlwarning
-select 'Inner (good)' as 'h_ww';
-insert into t3 values (123456789012);
-end;
-delete from t3;
-insert into t3 values (1);
-end|
-create procedure h_xe()
-deterministic
-begin
-declare continue handler for sqlexception
-select 'Outer (bad)' as 'h_xe';
-begin
-declare continue handler for 1062 -- ER_DUP_ENTRY
-select 'Inner (good)' as 'h_xe';
-insert into t3 values (1);
-end;
-end|
-create procedure h_xs()
-deterministic
-begin
-declare continue handler for sqlexception
-select 'Outer (bad)' as 'h_xs';
-begin
--- integrity constraint violation
-declare continue handler for sqlstate '23000'
- select 'Inner (good)' as 'h_xs';
-insert into t3 values (1);
-end;
-end|
-create procedure h_xx()
-deterministic
-begin
-declare continue handler for sqlexception
-select 'Outer (bad)' as 'h_xx';
-begin
-declare continue handler for sqlexception
-select 'Inner (good)' as 'h_xx';
-insert into t3 values (1);
-end;
-end|
-call h_ee()|
-h_ee
-Inner (good)
-call h_es()|
-h_es
-Outer (good)
-call h_en()|
-h_en
-Outer (good)
-call h_ew()|
-h_ew
-Outer (good)
-call h_ex()|
-h_ex
-Outer (good)
-call h_se()|
-h_se
-Inner (good)
-call h_ss()|
-h_ss
-Inner (good)
-call h_sn()|
-h_sn
-Outer (good)
-call h_sw()|
-h_sw
-Outer (good)
-call h_sx()|
-h_sx
-Outer (good)
-call h_ne()|
-h_ne
-Inner (good)
-call h_ns()|
-h_ns
-Inner (good)
-call h_nn()|
-h_nn
-Inner (good)
-call h_we()|
-h_we
-Inner (good)
-call h_ws()|
-h_ws
-Inner (good)
-call h_ww()|
-h_ww
-Inner (good)
-call h_xe()|
-h_xe
-Inner (good)
-call h_xs()|
-h_xs
-Inner (good)
-call h_xx()|
-h_xx
-Inner (good)
-drop table t3|
-drop procedure h_ee|
-drop procedure h_es|
-drop procedure h_en|
-drop procedure h_ew|
-drop procedure h_ex|
-drop procedure h_se|
-drop procedure h_ss|
-drop procedure h_sn|
-drop procedure h_sw|
-drop procedure h_sx|
-drop procedure h_ne|
-drop procedure h_ns|
-drop procedure h_nn|
-drop procedure h_we|
-drop procedure h_ws|
-drop procedure h_ww|
-drop procedure h_xe|
-drop procedure h_xs|
-drop procedure h_xx|
-drop procedure if exists bug822|
-create procedure bug822(a_id char(16), a_data int)
-begin
-declare n int;
-select count(*) into n from t1 where id = a_id and data = a_data;
-if n = 0 then
-insert into t1 (id, data) values (a_id, a_data);
-end if;
-end|
-delete from t1|
-call bug822('foo', 42)|
-call bug822('foo', 42)|
-call bug822('bar', 666)|
-select * from t1|
-id data
-foo 42
-bar 666
-delete from t1|
-drop procedure bug822|
-drop procedure if exists bug1495|
-create procedure bug1495()
-begin
-declare x int;
-select data into x from t1 order by id limit 1;
-if x > 10 then
-insert into t1 values ("less", x-10);
-else
-insert into t1 values ("more", x+10);
-end if;
-end|
-insert into t1 values ('foo', 12)|
-call bug1495()|
-delete from t1 where id='foo'|
-insert into t1 values ('bar', 7)|
-call bug1495()|
-delete from t1 where id='bar'|
-select * from t1|
-id data
-less 2
-more 17
-delete from t1|
-drop procedure bug1495|
-drop procedure if exists bug1547|
-create procedure bug1547(s char(16))
-begin
-declare x int;
-select data into x from t1 where s = id limit 1;
-if x > 10 then
-insert into t1 values ("less", x-10);
-else
-insert into t1 values ("more", x+10);
-end if;
-end|
-insert into t1 values ("foo", 12), ("bar", 7)|
-call bug1547("foo")|
-call bug1547("bar")|
-select * from t1|
-id data
-foo 12
-bar 7
-less 2
-more 17
-delete from t1|
-drop procedure bug1547|
-drop table if exists t70|
-create table t70 (s1 int,s2 int)|
-insert into t70 values (1,2)|
-drop procedure if exists bug1656|
-create procedure bug1656(out p1 int, out p2 int)
-select * into p1, p1 from t70|
-call bug1656(@1, @2)|
-select @1, @2|
-@1 @2
-2 NULL
-drop table t70|
-drop procedure bug1656|
-create table t3(a int)|
-drop procedure if exists bug1862|
-create procedure bug1862()
-begin
-insert into t3 values(2);
-flush tables;
-end|
-call bug1862()|
-call bug1862()|
-select * from t3|
-a
-2
-2
-drop table t3|
-drop procedure bug1862|
-drop procedure if exists bug1874|
-create procedure bug1874()
-begin
-declare x int;
-declare y double;
-select max(data) into x from t1;
-insert into t2 values ("max", x, 0);
-select min(data) into x from t1;
-insert into t2 values ("min", x, 0);
-select sum(data) into x from t1;
-insert into t2 values ("sum", x, 0);
-select avg(data) into y from t1;
-insert into t2 values ("avg", 0, y);
-end|
-insert into t1 (data) values (3), (1), (5), (9), (4)|
-call bug1874()|
-select * from t2|
-s i d
-max 9 0
-min 1 0
-sum 22 0
-avg 0 4.4
-delete from t1|
-delete from t2|
-drop procedure bug1874|
-drop procedure if exists bug2260|
-create procedure bug2260()
-begin
-declare v1 int;
-declare c1 cursor for select data from t1;
-declare continue handler for not found set @x2 = 1;
-open c1;
-fetch c1 into v1;
-set @x2 = 2;
-close c1;
-end|
-call bug2260()|
-select @x2|
-@x2
-2
-drop procedure bug2260|
-drop procedure if exists bug2267_1|
-create procedure bug2267_1()
-begin
-show procedure status;
-end|
-drop procedure if exists bug2267_2|
-create procedure bug2267_2()
-begin
-show function status;
-end|
-drop procedure if exists bug2267_3|
-create procedure bug2267_3()
-begin
-show create procedure bug2267_1;
-end|
-drop procedure if exists bug2267_4|
-drop function if exists bug2267_4|
-create procedure bug2267_4()
-begin
-show create function bug2267_4;
-end|
-create function bug2267_4() returns int return 100|
-call bug2267_1()|
-Db Name Type Definer Modified Created Security_type Comment
-test bug2267_1 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
-test bug2267_2 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
-test bug2267_3 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
-test bug2267_4 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
-call bug2267_2()|
-Db Name Type Definer Modified Created Security_type Comment
-test bug2267_4 FUNCTION root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
-call bug2267_3()|
-Procedure sql_mode Create Procedure
-bug2267_1 CREATE PROCEDURE `bug2267_1`()
-begin
-show procedure status;
-end
-call bug2267_4()|
-Function sql_mode Create Function
-bug2267_4 CREATE FUNCTION `bug2267_4`() RETURNS int(11)
-return 100
-drop procedure bug2267_1|
-drop procedure bug2267_2|
-drop procedure bug2267_3|
-drop procedure bug2267_4|
-drop function bug2267_4|
-drop procedure if exists bug2227|
-create procedure bug2227(x int)
-begin
-declare y float default 2.6;
-declare z char(16) default "zzz";
-select 1.3, x, y, 42, z;
-end|
-call bug2227(9)|
-1.3 x y 42 z
-1.3 9 2.6 42 zzz
-drop procedure bug2227|
-drop procedure if exists bug2614|
-create procedure bug2614()
-begin
-drop table if exists t3;
-create table t3 (id int default '0' not null);
-insert into t3 select 12;
-insert into t3 select * from t3;
-end|
-call bug2614()|
-call bug2614()|
-drop table t3|
-drop procedure bug2614|
-drop function if exists bug2674|
-create function bug2674() returns int
-return @@sort_buffer_size|
-set @osbs = @@sort_buffer_size|
-set @@sort_buffer_size = 262000|
-select bug2674()|
-bug2674()
-262000
-drop function bug2674|
-set @@sort_buffer_size = @osbs|
-drop procedure if exists bug3259_1 |
-create procedure bug3259_1 () begin end|
-drop procedure if exists BUG3259_2 |
-create procedure BUG3259_2 () begin end|
-drop procedure if exists Bug3259_3 |
-create procedure Bug3259_3 () begin end|
-call BUG3259_1()|
-call BUG3259_1()|
-call bug3259_2()|
-call Bug3259_2()|
-call bug3259_3()|
-call bUG3259_3()|
-drop procedure bUg3259_1|
-drop procedure BuG3259_2|
-drop procedure BUG3259_3|
-drop function if exists bug2772|
-create function bug2772() returns char(10) character set latin2
-return 'a'|
-select bug2772()|
-bug2772()
-a
-drop function bug2772|
-drop procedure if exists bug2776_1|
-create procedure bug2776_1(out x int)
-begin
-declare v int;
-set v = default;
-set x = v;
-end|
-drop procedure if exists bug2776_2|
-create procedure bug2776_2(out x int)
-begin
-declare v int default 42;
-set v = default;
-set x = v;
-end|
-set @x = 1|
-call bug2776_1(@x)|
-select @x|
-@x
-NULL
-call bug2776_2(@x)|
-select @x|
-@x
-42
-drop procedure bug2776_1|
-drop procedure bug2776_2|
-create table t3 (s1 smallint)|
-insert into t3 values (123456789012)|
-Warnings:
-Warning 1264 Out of range value adjusted for column 's1' at row 1
-drop procedure if exists bug2780|
-create procedure bug2780()
-begin
-declare exit handler for sqlwarning set @x = 1;
-set @x = 0;
-insert into t3 values (123456789012);
-insert into t3 values (0);
-end|
-call bug2780()|
-select @x|
-@x
-1
-select * from t3|
-s1
-32767
-32767
-drop procedure bug2780|
-drop table t3|
-create table t3 (content varchar(10) )|
-insert into t3 values ("test1")|
-insert into t3 values ("test2")|
-create table t4 (f1 int, rc int, t3 int)|
-drop procedure if exists bug1863|
-create procedure bug1863(in1 int)
-begin
-declare ind int default 0;
-declare t1 int;
-declare t2 int;
-declare t3 int;
-declare rc int default 0;
-declare continue handler for 1065 set rc = 1;
-drop temporary table if exists temp_t1;
-create temporary table temp_t1 (
-f1 int auto_increment, f2 varchar(20), primary key (f1)
-);
-insert into temp_t1 (f2) select content from t3;
-select f2 into t3 from temp_t1 where f1 = 10;
-if (rc) then
-insert into t4 values (1, rc, t3);
-end if;
-insert into t4 values (2, rc, t3);
-end|
-call bug1863(10)|
-Warnings:
-Note 1051 Unknown table 'temp_t1'
-Warning 1329 No data - zero rows fetched, selected, or processed
-call bug1863(10)|
-Warnings:
-Warning 1329 No data - zero rows fetched, selected, or processed
-select * from t4|
-f1 rc t3
-2 0 NULL
-2 0 NULL
-drop procedure bug1863|
-drop temporary table temp_t1;
-drop table t3, t4|
-create table t3 (
-OrderID int not null,
-MarketID int,
-primary key (OrderID)
-)|
-create table t4 (
-MarketID int not null,
-Market varchar(60),
-Status char(1),
-primary key (MarketID)
-)|
-insert t3 (OrderID,MarketID) values (1,1)|
-insert t3 (OrderID,MarketID) values (2,2)|
-insert t4 (MarketID,Market,Status) values (1,"MarketID One","A")|
-insert t4 (MarketID,Market,Status) values (2,"MarketID Two","A")|
-drop procedure if exists bug2656_1|
-create procedure bug2656_1()
-begin
-select
-m.Market
-from t4 m JOIN t3 o
-ON o.MarketID != 1 and o.MarketID = m.MarketID;
-end |
-drop procedure if exists bug2656_2|
-create procedure bug2656_2()
-begin
-select
-m.Market
-from
-t4 m, t3 o
-where
-m.MarketID != 1 and m.MarketID = o.MarketID;
-end |
-call bug2656_1()|
-Market
-MarketID Two
-call bug2656_1()|
-Market
-MarketID Two
-call bug2656_2()|
-Market
-MarketID Two
-call bug2656_2()|
-Market
-MarketID Two
-drop procedure bug2656_1|
-drop procedure bug2656_2|
-drop table t3, t4|
-drop procedure if exists bug3426|
-create procedure bug3426(in_time int unsigned, out x int)
-begin
-if in_time is null then
-set @stamped_time=10;
-set x=1;
-else
-set @stamped_time=in_time;
-set x=2;
-end if;
-end|
-call bug3426(1000, @i)|
-select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
-@i time
-2 01-01-1970 03:16:40
-call bug3426(NULL, @i)|
-select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
-@i time
-1 01-01-1970 03:00:10
-alter procedure bug3426 sql security invoker|
-call bug3426(NULL, @i)|
-select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
-@i time
-1 01-01-1970 03:00:10
-call bug3426(1000, @i)|
-select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
-@i time
-2 01-01-1970 03:16:40
-drop procedure bug3426|
-create table t3 (
-a int primary key,
-ach char(1)
-) engine = innodb|
-create table t4 (
-b int primary key ,
-bch char(1)
-) engine = innodb|
-insert into t3 values (1 , 'aCh1' ) , ('2' , 'aCh2')|
-Warnings:
-Warning 1265 Data truncated for column 'ach' at row 1
-Warning 1265 Data truncated for column 'ach' at row 2
-insert into t4 values (1 , 'bCh1' )|
-Warnings:
-Warning 1265 Data truncated for column 'bch' at row 1
-drop procedure if exists bug3448|
-create procedure bug3448()
-select * from t3 inner join t4 on t3.a = t4.b|
-select * from t3 inner join t4 on t3.a = t4.b|
-a ach b bch
-1 a 1 b
-call bug3448()|
-a ach b bch
-1 a 1 b
-call bug3448()|
-a ach b bch
-1 a 1 b
-drop procedure bug3448|
-drop table t3, t4|
-create table t3 (
-id int unsigned auto_increment not null primary key,
-title VARCHAR(200),
-body text,
-fulltext (title,body)
-)|
-insert into t3 (title,body) values
-('MySQL Tutorial','DBMS stands for DataBase ...'),
-('How To Use MySQL Well','After you went through a ...'),
-('Optimizing MySQL','In this tutorial we will show ...'),
-('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),
-('MySQL vs. YourSQL','In the following database comparison ...'),
-('MySQL Security','When configured properly, MySQL ...')|
-drop procedure if exists bug3734 |
-create procedure bug3734 (param1 varchar(100))
-select * from t3 where match (title,body) against (param1)|
-call bug3734('database')|
-id title body
-5 MySQL vs. YourSQL In the following database comparison ...
-1 MySQL Tutorial DBMS stands for DataBase ...
-call bug3734('Security')|
-id title body
-6 MySQL Security When configured properly, MySQL ...
-drop procedure bug3734|
-drop table t3|
-drop procedure if exists bug3863|
-create procedure bug3863()
-begin
-set @a = 0;
-while @a < 5 do
-set @a = @a + 1;
-end while;
-end|
-call bug3863()|
-select @a|
-@a
-5
-call bug3863()|
-select @a|
-@a
-5
-drop procedure bug3863|
-create table t3 (
-id int(10) unsigned not null default 0,
-rid int(10) unsigned not null default 0,
-msg text not null,
-primary key (id),
-unique key rid (rid, id)
-)|
-drop procedure if exists bug2460_1|
-create procedure bug2460_1(in v int)
-begin
-( select n0.id from t3 as n0 where n0.id = v )
-union
-( select n0.id from t3 as n0, t3 as n1
-where n0.id = n1.rid and n1.id = v )
-union
-( select n0.id from t3 as n0, t3 as n1, t3 as n2
-where n0.id = n1.rid and n1.id = n2.rid and n2.id = v );
-end|
-call bug2460_1(2)|
-id
-call bug2460_1(2)|
-id
-insert into t3 values (1, 1, 'foo'), (2, 1, 'bar'), (3, 1, 'zip zap')|
-call bug2460_1(2)|
-id
-2
-1
-call bug2460_1(2)|
-id
-2
-1
-drop procedure if exists bug2460_2|
-create procedure bug2460_2()
-begin
-drop table if exists t3;
-create temporary table t3 (s1 int);
-insert into t3 select 1 union select 1;
-end|
-call bug2460_2()|
-call bug2460_2()|
-select * from t3|
-s1
-1
-drop procedure bug2460_1|
-drop procedure bug2460_2|
-drop table t3|
-set @@sql_mode = ''|
-drop procedure if exists bug2564_1|
-create procedure bug2564_1()
-comment 'Joe''s procedure'
- insert into `t1` values ("foo", 1)|
-set @@sql_mode = 'ANSI_QUOTES'|
-drop procedure if exists bug2564_2|
-create procedure bug2564_2()
-insert into "t1" values ('foo', 1)|
-set @@sql_mode = ''$
-drop function if exists bug2564_3$
-create function bug2564_3(x int, y int) returns int
-return x || y$
-set @@sql_mode = 'ANSI'$
-drop function if exists bug2564_4$
-create function bug2564_4(x int, y int) returns int
-return x || y$
-set @@sql_mode = ''|
-show create procedure bug2564_1|
-Procedure sql_mode Create Procedure
-bug2564_1 CREATE PROCEDURE `bug2564_1`()
- COMMENT 'Joe''s procedure'
-insert into `t1` values ("foo", 1)
-show create procedure bug2564_2|
-Procedure sql_mode Create Procedure
-bug2564_2 ANSI_QUOTES CREATE PROCEDURE "bug2564_2"()
-insert into "t1" values ('foo', 1)
-show create function bug2564_3|
-Function sql_mode Create Function
-bug2564_3 CREATE FUNCTION `bug2564_3`(x int, y int) RETURNS int(11)
-return x || y
-show create function bug2564_4|
-Function sql_mode Create Function
-bug2564_4 REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI CREATE FUNCTION "bug2564_4"(x int, y int) RETURNS int(11)
-return x || y
-drop procedure bug2564_1|
-drop procedure bug2564_2|
-drop function bug2564_3|
-drop function bug2564_4|
-drop function if exists bug3132|
-create function bug3132(s char(20)) returns char(50)
-return concat('Hello, ', s, '!')|
-select bug3132('Bob') union all select bug3132('Judy')|
-bug3132('Bob')
-Hello, Bob!
-Hello, Judy!
-drop function bug3132|
-drop procedure if exists bug3843|
-create procedure bug3843()
-analyze table t1|
-call bug3843()|
-Table Op Msg_type Msg_text
-test.t1 analyze status OK
-call bug3843()|
-Table Op Msg_type Msg_text
-test.t1 analyze status Table is already up to date
-select 1+2|
-1+2
-3
-drop procedure bug3843|
-create table t3 ( s1 char(10) )|
-insert into t3 values ('a'), ('b')|
-drop procedure if exists bug3368|
-create procedure bug3368(v char(10))
-begin
-select group_concat(v) from t3;
-end|
-call bug3368('x')|
-group_concat(v)
-x,x
-call bug3368('yz')|
-group_concat(v)
-yz,yz
-drop procedure bug3368|
-drop table t3|
-create table t3 (f1 int, f2 int)|
-insert into t3 values (1,1)|
-drop procedure if exists bug4579_1|
-create procedure bug4579_1 ()
-begin
-declare sf1 int;
-select f1 into sf1 from t3 where f1=1 and f2=1;
-update t3 set f2 = f2 + 1 where f1=1 and f2=1;
-call bug4579_2();
-end|
-drop procedure if exists bug4579_2|
-create procedure bug4579_2 ()
-begin
-end|
-call bug4579_1()|
-call bug4579_1()|
-Warnings:
-Warning 1329 No data - zero rows fetched, selected, or processed
-call bug4579_1()|
-Warnings:
-Warning 1329 No data - zero rows fetched, selected, or processed
-drop procedure bug4579_1|
-drop procedure bug4579_2|
-drop table t3|
-drop procedure if exists bug2773|
-create function bug2773() returns int return null|
-create table t3 as select bug2773()|
-show create table t3|
-Table Create Table
-t3 CREATE TABLE `t3` (
- `bug2773()` int(11) default NULL
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-drop table t3|
-drop function bug2773|
-drop procedure if exists bug3788|
-create function bug3788() returns date return cast("2005-03-04" as date)|
-select bug3788()|
-bug3788()
-2005-03-04
-drop function bug3788|
-create function bug3788() returns binary(1) return 5|
-select bug3788()|
-bug3788()
-5
-drop function bug3788|
-create table t3 (f1 int, f2 int, f3 int)|
-insert into t3 values (1,1,1)|
-drop procedure if exists bug4726|
-create procedure bug4726()
-begin
-declare tmp_o_id INT;
-declare tmp_d_id INT default 1;
-while tmp_d_id <= 2 do
-begin
-select f1 into tmp_o_id from t3 where f2=1 and f3=1;
-set tmp_d_id = tmp_d_id + 1;
-end;
-end while;
-end|
-call bug4726()|
-call bug4726()|
-call bug4726()|
-drop procedure bug4726|
-drop table t3|
-drop procedure if exists bug4902|
-create procedure bug4902()
-begin
-show charset like 'foo';
-show collation like 'foo';
-show column types;
-show create table t1;
-show create database test;
-show databases like 'foo';
-show errors;
-show columns from t1;
-show grants for 'root'@'localhost';
-show keys from t1;
-show open tables like 'foo';
-show privileges;
-show status like 'foo';
-show tables like 'foo';
-show variables like 'foo';
-show warnings;
-end|
-call bug4902()|
-Charset Description Default collation Maxlen
-Collation Charset Id Default Compiled Sortlen
-Type Size Min_Value Max_Value Prec Scale Nullable Auto_Increment Unsigned Zerofill Searchable Case_Sensitive Default Comment
-tinyint 1 -128 127 0 0 YES YES NO YES YES NO NULL,0 A very small integer
-tinyint unsigned 1 0 255 0 0 YES YES YES YES YES NO NULL,0 A very small integer
-Table Create Table
-t1 CREATE TABLE `t1` (
- `id` char(16) NOT NULL default '',
- `data` int(11) NOT NULL
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-Database Create Database
-test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */
-Database (foo)
-Level Code Message
-Field Type Null Key Default Extra
-id char(16) NO
-data int(11) NO
-Grants for root@localhost
-GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
-Database Table In_use Name_locked
-Privilege Context Comment
-Alter Tables To alter the table
-Alter routine Functions,Procedures To alter or drop stored functions/procedures
-Create Databases,Tables,Indexes To create new databases and tables
-Create routine Functions,Procedures To use CREATE FUNCTION/PROCEDURE
-Create temporary tables Databases To use CREATE TEMPORARY TABLE
-Create view Tables To create new views
-Create user Server Admin To create new users
-Delete Tables To delete existing rows
-Drop Databases,Tables To drop databases, tables, and views
-Execute Functions,Procedures To execute stored routines
-File File access on server To read and write files on the server
-Grant option Databases,Tables,Functions,Procedures To give to other users those privileges you possess
-Index Tables To create or drop indexes
-Insert Tables To insert data into tables
-Lock tables Databases To use LOCK TABLES (together with SELECT privilege)
-Process Server Admin To view the plain text of currently executing queries
-References Databases,Tables To have references on tables
-Reload Server Admin To reload or refresh tables, logs and privileges
-Replication client Server Admin To ask where the slave or master servers are
-Replication slave Server Admin To read binary log events from the master
-Select Tables To retrieve rows from table
-Show databases Server Admin To see all databases with SHOW DATABASES
-Show view Tables To see views with SHOW CREATE VIEW
-Shutdown Server Admin To shut down the server
-Super Server Admin To use KILL thread, SET GLOBAL, CHANGE MASTER, etc.
-Update Tables To update existing rows
-Usage Server Admin No privileges - allow connect only
-Variable_name Value
-Tables_in_test (foo)
-Variable_name Value
-Level Code Message
-call bug4902()|
-Charset Description Default collation Maxlen
-Collation Charset Id Default Compiled Sortlen
-Type Size Min_Value Max_Value Prec Scale Nullable Auto_Increment Unsigned Zerofill Searchable Case_Sensitive Default Comment
-tinyint 1 -128 127 0 0 YES YES NO YES YES NO NULL,0 A very small integer
-tinyint unsigned 1 0 255 0 0 YES YES YES YES YES NO NULL,0 A very small integer
-Table Create Table
-t1 CREATE TABLE `t1` (
- `id` char(16) NOT NULL default '',
- `data` int(11) NOT NULL
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-Database Create Database
-test CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET latin1 */
-Database (foo)
-Level Code Message
-Field Type Null Key Default Extra
-id char(16) NO
-data int(11) NO
-Grants for root@localhost
-GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
-Database Table In_use Name_locked
-Privilege Context Comment
-Alter Tables To alter the table
-Alter routine Functions,Procedures To alter or drop stored functions/procedures
-Create Databases,Tables,Indexes To create new databases and tables
-Create routine Functions,Procedures To use CREATE FUNCTION/PROCEDURE
-Create temporary tables Databases To use CREATE TEMPORARY TABLE
-Create view Tables To create new views
-Create user Server Admin To create new users
-Delete Tables To delete existing rows
-Drop Databases,Tables To drop databases, tables, and views
-Execute Functions,Procedures To execute stored routines
-File File access on server To read and write files on the server
-Grant option Databases,Tables,Functions,Procedures To give to other users those privileges you possess
-Index Tables To create or drop indexes
-Insert Tables To insert data into tables
-Lock tables Databases To use LOCK TABLES (together with SELECT privilege)
-Process Server Admin To view the plain text of currently executing queries
-References Databases,Tables To have references on tables
-Reload Server Admin To reload or refresh tables, logs and privileges
-Replication client Server Admin To ask where the slave or master servers are
-Replication slave Server Admin To read binary log events from the master
-Select Tables To retrieve rows from table
-Show databases Server Admin To see all databases with SHOW DATABASES
-Show view Tables To see views with SHOW CREATE VIEW
-Shutdown Server Admin To shut down the server
-Super Server Admin To use KILL thread, SET GLOBAL, CHANGE MASTER, etc.
-Update Tables To update existing rows
-Usage Server Admin No privileges - allow connect only
-Variable_name Value
-Tables_in_test (foo)
-Variable_name Value
-Level Code Message
-drop procedure bug4902|
-drop procedure if exists bug4902_2|
-create procedure bug4902_2()
-begin
-show processlist;
-end|
-call bug4902_2()|
-Id User Host db Command Time State Info
-# root localhost test Query # NULL show processlist
-call bug4902_2()|
-Id User Host db Command Time State Info
-# root localhost test Query # NULL show processlist
-drop procedure bug4902_2|
-drop procedure if exists bug4904|
-create procedure bug4904()
-begin
-declare continue handler for sqlstate 'HY000' begin end;
-create table t2 as select * from t3;
-end|
-call bug4904()|
-ERROR 42S02: Table 'test.t3' doesn't exist
-drop procedure bug4904|
-create table t3 (s1 char character set latin1, s2 char character set latin2)|
-drop procedure if exists bug4904|
-create procedure bug4904 ()
-begin
-declare continue handler for sqlstate 'HY000' begin end;
-select s1 from t3 union select s2 from t3;
-end|
-call bug4904()|
-drop procedure bug4904|
-drop table t3|
-drop procedure if exists bug336|
-create procedure bug336(out y int)
-begin
-declare x int;
-set x = (select sum(t.data) from test.t1 t);
-set y = x;
-end|
-insert into t1 values ("a", 2), ("b", 3)|
-call bug336(@y)|
-select @y|
-@y
-5
-delete from t1|
-drop procedure bug336|
-drop procedure if exists bug3157|
-create procedure bug3157()
-begin
-if exists(select * from t1) then
-set @n= @n + 1;
-end if;
-if (select count(*) from t1) then
-set @n= @n + 1;
-end if;
-end|
-set @n = 0|
-insert into t1 values ("a", 1)|
-call bug3157()|
-select @n|
-@n
-2
-delete from t1|
-drop procedure bug3157|
-drop procedure if exists bug5251|
-create procedure bug5251()
-begin
-end|
-select created into @c1 from mysql.proc
-where db='test' and name='bug5251'|
-alter procedure bug5251 comment 'foobar'|
-select count(*) from mysql.proc
-where db='test' and name='bug5251' and created = @c1|
-count(*)
-1
-drop procedure bug5251|
-drop procedure if exists bug5251|
-create procedure bug5251()
-checksum table t1|
-call bug5251()|
-Table Checksum
-test.t1 0
-call bug5251()|
-Table Checksum
-test.t1 0
-drop procedure bug5251|
-drop procedure if exists bug5287|
-create procedure bug5287(param1 int)
-label1:
-begin
-declare c cursor for select 5;
-loop
-if param1 >= 0 then
-leave label1;
-end if;
-end loop;
-end|
-call bug5287(1)|
-drop procedure bug5287|
-drop procedure if exists bug5307|
-create procedure bug5307()
-begin
-end; set @x = 3|
-call bug5307()|
-select @x|
-@x
-3
-drop procedure bug5307|
-drop procedure if exists bug5258|
-create procedure bug5258()
-begin
-end|
-drop procedure if exists bug5258_aux|
-create procedure bug5258_aux()
-begin
-declare c, m char(19);
-select created,modified into c,m from mysql.proc where name = 'bug5258';
-if c = m then
-select 'Ok';
-else
-select c, m;
-end if;
-end|
-call bug5258_aux()|
-Ok
-Ok
-drop procedure bug5258|
-drop procedure bug5258_aux|
-drop function if exists bug4487|
-create function bug4487() returns char
-begin
-declare v char;
-return v;
-end|
-select bug4487()|
-bug4487()
-NULL
-drop function bug4487|
-drop procedure if exists bug4941|
-drop procedure if exists bug4941|
-create procedure bug4941(out x int)
-begin
-declare c cursor for select i from t2 limit 1;
-open c;
-fetch c into x;
-close c;
-end|
-insert into t2 values (null, null, null)|
-set @x = 42|
-call bug4941(@x)|
-select @x|
-@x
-NULL
-delete from t1|
-drop procedure bug4941|
-drop procedure if exists bug3583|
-drop procedure if exists bug3583|
-create procedure bug3583()
-begin
-declare c int;
-select * from t1;
-select count(*) into c from t1;
-select c;
-end|
-insert into t1 values ("x", 3), ("y", 5)|
-set @x = @@query_cache_size|
-set global query_cache_size = 10*1024*1024|
-flush status|
-flush query cache|
-show status like 'Qcache_hits'|
-Variable_name Value
-Qcache_hits 0
-call bug3583()|
-id data
-x 3
-y 5
-c
-2
-show status like 'Qcache_hits'|
-Variable_name Value
-Qcache_hits 0
-call bug3583()|
-id data
-x 3
-y 5
-c
-2
-call bug3583()|
-id data
-x 3
-y 5
-c
-2
-show status like 'Qcache_hits'|
-Variable_name Value
-Qcache_hits 2
-set global query_cache_size = @x|
-flush status|
-flush query cache|
-delete from t1|
-drop procedure bug3583|
-drop procedure if exists bug4905|
-create table t3 (s1 int,primary key (s1))|
-drop procedure if exists bug4905|
-create procedure bug4905()
-begin
-declare v int;
-declare continue handler for sqlstate '23000' set v = 5;
-insert into t3 values (1);
-end|
-call bug4905()|
-select row_count()|
-row_count()
-1
-call bug4905()|
-select row_count()|
-row_count()
-0
-call bug4905()|
-select row_count()|
-row_count()
-0
-select * from t3|
-s1
-1
-drop procedure bug4905|
-drop table t3|
-drop procedure if exists bug6029|
-drop procedure if exists bug6029|
-create procedure bug6029()
-begin
-declare exit handler for 1136 select '1136';
-declare exit handler for sqlstate '23000' select 'sqlstate 23000';
-declare continue handler for sqlexception select 'sqlexception';
-insert into t3 values (1);
-insert into t3 values (1,2);
-end|
-create table t3 (s1 int, primary key (s1))|
-insert into t3 values (1)|
-call bug6029()|
-sqlstate 23000
-sqlstate 23000
-delete from t3|
-call bug6029()|
-1136
-1136
-drop procedure bug6029|
-drop table t3|
-drop procedure if exists bug8540|
-create procedure bug8540()
-begin
-declare x int default 1;
-select x as y, x+0 as z;
-end|
-call bug8540()|
-y z
-1 1
-drop procedure bug8540|
-create table t3 (s1 int)|
-drop procedure if exists bug6642|
-create procedure bug6642()
-select abs(count(s1)) from t3|
-call bug6642()|
-abs(count(s1))
-0
-call bug6642()|
-abs(count(s1))
-0
-drop procedure bug6642|
-insert into t3 values (0),(1)|
-drop procedure if exists bug7013|
-create procedure bug7013()
-select s1,count(s1) from t3 group by s1 with rollup|
-call bug7013()|
-s1 count(s1)
-0 1
-1 1
-NULL 2
-call bug7013()|
-s1 count(s1)
-0 1
-1 1
-NULL 2
-drop procedure bug7013|
-drop table if exists t4|
-create table t4 (
-a mediumint(8) unsigned not null auto_increment,
-b smallint(5) unsigned not null,
-c char(32) not null,
-primary key (a)
-) engine=myisam default charset=latin1|
-insert into t4 values (1, 2, 'oneword')|
-insert into t4 values (2, 2, 'anotherword')|
-drop procedure if exists bug7743|
-create procedure bug7743 ( searchstring char(28) )
-begin
-declare var mediumint(8) unsigned;
-select a into var from t4 where b = 2 and c = binary searchstring limit 1;
-select var;
-end|
-call bug7743("oneword")|
-var
-1
-call bug7743("OneWord")|
-var
-NULL
-Warnings:
-Warning 1329 No data - zero rows fetched, selected, or processed
-call bug7743("anotherword")|
-var
-2
-call bug7743("AnotherWord")|
-var
-NULL
-Warnings:
-Warning 1329 No data - zero rows fetched, selected, or processed
-drop procedure bug7743|
-drop table t4|
-delete from t3|
-insert into t3 values(1)|
-drop procedure if exists bug7992_1|
-Warnings:
-Note 1305 PROCEDURE bug7992_1 does not exist
-drop procedure if exists bug7992_2|
-Warnings:
-Note 1305 PROCEDURE bug7992_2 does not exist
-create procedure bug7992_1()
-begin
-declare i int;
-select max(s1)+1 into i from t3;
-end|
-create procedure bug7992_2()
-insert into t3 (s1) select max(t4.s1)+1 from t3 as t4|
-call bug7992_1()|
-call bug7992_1()|
-call bug7992_2()|
-call bug7992_2()|
-drop procedure bug7992_1|
-drop procedure bug7992_2|
-drop table t3|
-create table t3 ( userid bigint(20) not null default 0 )|
-drop procedure if exists bug8116|
-create procedure bug8116(in _userid int)
-select * from t3 where userid = _userid|
-call bug8116(42)|
-userid
-call bug8116(42)|
-userid
-drop procedure bug8116|
-drop table t3|
-drop procedure if exists bug6857|
-create procedure bug6857(counter int)
-begin
-declare t0, t1 int;
-declare plus bool default 0;
-set t0 = current_time();
-while counter > 0 do
-set counter = counter - 1;
-end while;
-set t1 = current_time();
-if t1 > t0 then
-set plus = 1;
-end if;
-select plus;
-end|
-drop procedure bug6857|
-drop procedure if exists bug8757|
-create procedure bug8757()
-begin
-declare x int;
-declare c1 cursor for select data from t1 limit 1;
-begin
-declare y int;
-declare c2 cursor for select i from t2 limit 1;
-open c2;
-fetch c2 into y;
-close c2;
-select 2,y;
-end;
-open c1;
-fetch c1 into x;
-close c1;
-select 1,x;
-end|
-delete from t1|
-delete from t2|
-insert into t1 values ("x", 1)|
-insert into t2 values ("y", 2, 0.0)|
-call bug8757()|
-2 y
-2 2
-1 x
-1 1
-delete from t1|
-delete from t2|
-drop procedure bug8757|
-drop procedure if exists bug8762|
-drop procedure if exists bug8762; create procedure bug8762() begin end|
-drop procedure if exists bug8762; create procedure bug8762() begin end|
-drop procedure bug8762|
-drop function if exists bug5240|
-create function bug5240 () returns int
-begin
-declare x int;
-declare c cursor for select data from t1 limit 1;
-open c;
-fetch c into x;
-close c;
-return x;
-end|
-delete from t1|
-insert into t1 values ("answer", 42)|
-select id, bug5240() from t1|
-id bug5240()
-answer 42
-drop function bug5240|
-drop function if exists bug5278|
-create function bug5278 () returns char
-begin
-SET PASSWORD FOR 'bob'@'%.loc.gov' = PASSWORD('newpass');
-return 'okay';
-end|
-select bug5278()|
-ERROR 42000: Can't find any matching row in the user table
-select bug5278()|
-ERROR 42000: Can't find any matching row in the user table
-drop function bug5278|
-drop procedure if exists p1|
-create table t3(id int)|
-insert into t3 values(1)|
-create procedure bug7992()
-begin
-declare i int;
-select max(id)+1 into i from t3;
-end|
-call bug7992()|
-call bug7992()|
-drop procedure bug7992|
-drop table t3|
-create table t3 (
-lpitnumber int(11) default null,
-lrecordtype int(11) default null
-)|
-create table t4 (
-lbsiid int(11) not null default '0',
-ltradingmodeid int(11) not null default '0',
-ltradingareaid int(11) not null default '0',
-csellingprice decimal(19,4) default null,
-primary key (lbsiid,ltradingmodeid,ltradingareaid)
-)|
-create table t5 (
-lbsiid int(11) not null default '0',
-ltradingareaid int(11) not null default '0',
-primary key (lbsiid,ltradingareaid)
-)|
-drop procedure if exists bug8849|
-create procedure bug8849()
-begin
-insert into t5
-(
-t5.lbsiid,
-t5.ltradingareaid
-)
-select distinct t3.lpitnumber, t4.ltradingareaid
-from
-t4 join t3 on
-t3.lpitnumber = t4.lbsiid
-and t3.lrecordtype = 1
-left join t4 as price01 on
-price01.lbsiid = t4.lbsiid and
-price01.ltradingmodeid = 1 and
-t4.ltradingareaid = price01.ltradingareaid;
-end|
-call bug8849()|
-call bug8849()|
-call bug8849()|
-drop procedure bug8849|
-drop tables t3,t4,t5|
-drop procedure if exists bug8937|
-create procedure bug8937()
-begin
-declare s,x,y,z int;
-declare a float;
-select sum(data),avg(data),min(data),max(data) into s,x,y,z from t1;
-select s,x,y,z;
-select avg(data) into a from t1;
-select a;
-end|
-delete from t1|
-insert into t1 (data) values (1), (2), (3), (4), (6)|
-call bug8937()|
-s x y z
-16 3 1 6
-a
-3.2
-drop procedure bug8937|
-delete from t1|
-drop procedure if exists bug6900|
-drop procedure if exists bug9074|
-drop procedure if exists bug6900_9074|
-create table t3 (w char unique, x char)|
-insert into t3 values ('a', 'b')|
-create procedure bug6900()
-begin
-declare exit handler for sqlexception select '1';
-begin
-declare exit handler for sqlexception select '2';
-insert into t3 values ('x', 'y', 'z');
-end;
-end|
-create procedure bug9074()
-begin
-declare x1, x2, x3, x4, x5, x6 int default 0;
-begin
-declare continue handler for sqlstate '23000' set x5 = 1;
-insert into t3 values ('a', 'b');
-set x6 = 1;
-end;
-begin1_label:
-begin
-declare continue handler for sqlstate '23000' set x1 = 1;
-insert into t3 values ('a', 'b');
-set x2 = 1;
-begin2_label:
-begin
-declare exit handler for sqlstate '23000' set x3 = 1;
-set x4= 1;
-insert into t3 values ('a','b');
-set x4= 0;
-end begin2_label;
-end begin1_label;
-select x1, x2, x3, x4, x5, x6;
-end|
-create procedure bug6900_9074(z int)
-begin
-declare exit handler for sqlstate '23000' select '23000';
-begin
-declare exit handler for sqlexception select 'sqlexception';
-if z = 1 then
-insert into t3 values ('a', 'b');
-else
-insert into t3 values ('x', 'y', 'z');
-end if;
-end;
-end|
-call bug6900()|
-2
-2
-call bug9074()|
-x1 x2 x3 x4 x5 x6
-1 1 1 1 1 1
-call bug6900_9074(0)|
-sqlexception
-sqlexception
-call bug6900_9074(1)|
-23000
-23000
-drop procedure bug6900|
-drop procedure bug9074|
-drop procedure bug6900_9074|
-drop table t3|
-drop procedure if exists avg|
-create procedure avg ()
-begin
-end|
-call avg ()|
-drop procedure avg|
-drop procedure if exists bug6129|
-set @old_mode= @@sql_mode;
-set @@sql_mode= "ERROR_FOR_DIVISION_BY_ZERO";
-create procedure bug6129()
-select @@sql_mode|
-call bug6129()|
-@@sql_mode
-ERROR_FOR_DIVISION_BY_ZERO
-set @@sql_mode= "NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO"|
-call bug6129()|
-@@sql_mode
-ERROR_FOR_DIVISION_BY_ZERO
-set @@sql_mode= "NO_ZERO_IN_DATE"|
-call bug6129()|
-@@sql_mode
-ERROR_FOR_DIVISION_BY_ZERO
-set @@sql_mode=@old_mode;
-drop procedure bug6129|
-drop procedure if exists bug9856|
-create procedure bug9856()
-begin
-declare v int;
-declare c cursor for select data from t1;
-declare exit handler for sqlexception, not found select '16';
-open c;
-fetch c into v;
-select v;
-end|
-delete from t1|
-call bug9856()|
-16
-16
-call bug9856()|
-16
-16
-drop procedure bug9856|
-drop procedure if exists bug9674_1|
-drop procedure if exists bug9674_2|
-create procedure bug9674_1(out arg int)
-begin
-declare temp_in1 int default 0;
-declare temp_fl1 int default 0;
-set temp_in1 = 100;
-set temp_fl1 = temp_in1/10;
-set arg = temp_fl1;
-end|
-create procedure bug9674_2()
-begin
-declare v int default 100;
-select v/10;
-end|
-call bug9674_1(@sptmp)|
-call bug9674_1(@sptmp)|
-select @sptmp|
-@sptmp
-10
-call bug9674_2()|
-v/10
-10.0000
-call bug9674_2()|
-v/10
-10.0000
-drop procedure bug9674_1|
-drop procedure bug9674_2|
-drop procedure if exists bug9598_1|
-drop procedure if exists bug9598_2|
-create procedure bug9598_1(in var_1 char(16),
-out var_2 integer, out var_3 integer)
-begin
-set var_2 = 50;
-set var_3 = 60;
-end|
-create procedure bug9598_2(in v1 char(16),
-in v2 integer,
-in v3 integer,
-in v4 integer,
-in v5 integer)
-begin
-select v1,v2,v3,v4,v5;
-call bug9598_1(v1,@tmp1,@tmp2);
-select v1,v2,v3,v4,v5;
-end|
-call bug9598_2('Test',2,3,4,5)|
-v1 v2 v3 v4 v5
-Test 2 3 4 5
-v1 v2 v3 v4 v5
-Test 2 3 4 5
-select @tmp1, @tmp2|
-@tmp1 @tmp2
-50 60
-drop procedure bug9598_1|
-drop procedure bug9598_2|
-drop procedure if exists bug9902|
-create function bug9902() returns int(11)
-begin
-set @x = @x + 1;
-return @x;
-end|
-set @qcs1 = @@query_cache_size|
-set global query_cache_size = 100000|
-set @x = 1|
-insert into t1 values ("qc", 42)|
-select bug9902() from t1|
-bug9902()
-2
-select bug9902() from t1|
-bug9902()
-3
-select @x|
-@x
-3
-set global query_cache_size = @qcs1|
-delete from t1|
-drop function bug9902|
-drop function if exists bug9102|
-create function bug9102() returns blob return 'a'|
-select bug9102()|
-bug9102()
-a
-drop function bug9102|
-drop function if exists bug7648|
-create function bug7648() returns bit(8) return 'a'|
-select bug7648()|
-bug7648()
-a
-drop function bug7648|
-drop function if exists bug9775|
-create function bug9775(v1 char(1)) returns enum('a','b') return v1|
-select bug9775('a'),bug9775('b'),bug9775('c')|
-bug9775('a') bug9775('b') bug9775('c')
-a b
-Warnings:
-Warning 1265 Data truncated for column 'bug9775('c')' at row 1
-drop function bug9775|
-create function bug9775(v1 int) returns enum('a','b') return v1|
-select bug9775(1),bug9775(2),bug9775(3)|
-bug9775(1) bug9775(2) bug9775(3)
-a b
-Warnings:
-Warning 1265 Data truncated for column 'bug9775(3)' at row 1
-drop function bug9775|
-create function bug9775(v1 char(1)) returns set('a','b') return v1|
-select bug9775('a'),bug9775('b'),bug9775('a,b'),bug9775('c')|
-bug9775('a') bug9775('b') bug9775('a,b') bug9775('c')
-a b a
-Warnings:
-Warning 1265 Data truncated for column 'v1' at row 1
-Warning 1265 Data truncated for column 'bug9775('c')' at row 1
-drop function bug9775|
-create function bug9775(v1 int) returns set('a','b') return v1|
-select bug9775(1),bug9775(2),bug9775(3),bug9775(4)|
-bug9775(1) bug9775(2) bug9775(3) bug9775(4)
-a b a,b
-Warnings:
-Warning 1265 Data truncated for column 'bug9775(4)' at row 1
-drop function bug9775|
-drop function if exists bug8861|
-create function bug8861(v1 int) returns year return v1|
-select bug8861(05)|
-bug8861(05)
-2005
-set @x = bug8861(05)|
-select @x|
-@x
-2005
-drop function bug8861|
-drop procedure if exists bug9004_1|
-drop procedure if exists bug9004_2|
-create procedure bug9004_1(x char(16))
-begin
-insert into t1 values (x, 42);
-insert into t1 values (x, 17);
-end|
-create procedure bug9004_2(x char(16))
-call bug9004_1(x)|
-call bug9004_1('12345678901234567')|
-Warnings:
-Warning 1265 Data truncated for column 'x' at row 1
-call bug9004_2('12345678901234567890')|
-Warnings:
-Warning 1265 Data truncated for column 'x' at row 1
-delete from t1|
-drop procedure bug9004_1|
-drop procedure bug9004_2|
-drop procedure if exists bug7293|
-insert into t1 values ('secret', 0)|
-create procedure bug7293(p1 varchar(100))
-begin
-if exists (select id from t1 where soundex(p1)=soundex(id)) then
-select 'yes';
-end if;
-end;|
-call bug7293('secret')|
-yes
-yes
-call bug7293 ('secrete')|
-yes
-yes
-drop procedure bug7293|
-delete from t1|
-drop procedure if exists bug9841|
-drop view if exists v1|
-create view v1 as select * from t1, t2 where id = s|
-create procedure bug9841 ()
-update v1 set data = 10|
-call bug9841()|
-drop view v1|
-drop procedure bug9841|
-drop procedure if exists bug5963|
-create procedure bug5963_1 () begin declare v int; set v = (select s1 from t3); select v; end;|
-create table t3 (s1 int)|
-insert into t3 values (5)|
-call bug5963_1()|
-v
-5
-call bug5963_1()|
-v
-5
-drop procedure bug5963_1|
-drop table t3|
-create procedure bug5963_2 (cfk_value int)
-begin
-if cfk_value in (select cpk from t3) then
-set @x = 5;
-end if;
-end;
-|
-create table t3 (cpk int)|
-insert into t3 values (1)|
-call bug5963_2(1)|
-call bug5963_2(1)|
-drop procedure bug5963_2|
-drop table t3|
-drop function if exists bug9559|
-create function bug9559()
-returns int
-begin
-set @y = -6/2;
-return @y;
-end|
-select bug9559()|
-bug9559()
--3
-drop function bug9559|
-drop procedure if exists bug10961|
-create procedure bug10961()
-begin
-declare v char;
-declare x int;
-declare c cursor for select * from dual;
-declare continue handler for sqlexception select x;
-set x = 1;
-open c;
-set x = 2;
-fetch c into v;
-set x = 3;
-close c;
-end|
-call bug10961()|
-x
-1
-x
-2
-x
-3
-call bug10961()|
-x
-1
-x
-2
-x
-3
-drop procedure bug10961|
-DROP PROCEDURE IF EXISTS bug6866|
-DROP VIEW IF EXISTS tv|
-Warnings:
-Note 1051 Unknown table 'test.tv'
-DROP TABLE IF EXISTS tt1,tt2,tt3|
-Warnings:
-Note 1051 Unknown table 'tt1'
-Note 1051 Unknown table 'tt2'
-Note 1051 Unknown table 'tt3'
-CREATE TABLE tt1 (a1 int, a2 int, a3 int, data varchar(10))|
-CREATE TABLE tt2 (a2 int, data2 varchar(10))|
-CREATE TABLE tt3 (a3 int, data3 varchar(10))|
-INSERT INTO tt1 VALUES (1, 1, 4, 'xx')|
-INSERT INTO tt2 VALUES (1, 'a')|
-INSERT INTO tt2 VALUES (2, 'b')|
-INSERT INTO tt2 VALUES (3, 'c')|
-INSERT INTO tt3 VALUES (4, 'd')|
-INSERT INTO tt3 VALUES (5, 'e')|
-INSERT INTO tt3 VALUES (6, 'f')|
-CREATE VIEW tv AS
-SELECT tt1.*, tt2.data2, tt3.data3
-FROM tt1 INNER JOIN tt2 ON tt1.a2 = tt2.a2
-LEFT JOIN tt3 ON tt1.a3 = tt3.a3
-ORDER BY tt1.a1, tt2.a2, tt3.a3|
-CREATE PROCEDURE bug6866 (_a1 int)
-BEGIN
-SELECT * FROM tv WHERE a1 = _a1;
-END|
-CALL bug6866(1)|
-a1 a2 a3 data data2 data3
-1 1 4 xx a d
-CALL bug6866(1)|
-a1 a2 a3 data data2 data3
-1 1 4 xx a d
-CALL bug6866(1)|
-a1 a2 a3 data data2 data3
-1 1 4 xx a d
-DROP PROCEDURE bug6866;
-DROP VIEW tv|
-DROP TABLE tt1, tt2, tt3|
-DROP PROCEDURE IF EXISTS bug10136|
-create table t3 ( name char(5) not null primary key, val float not null)|
-insert into t3 values ('aaaaa', 1), ('bbbbb', 2), ('ccccc', 3)|
-create procedure bug10136()
-begin
-declare done int default 3;
-repeat
-select * from t3;
-set done = done - 1;
-until done <= 0 end repeat;
-end|
-call bug10136()|
-name val
-aaaaa 1
-bbbbb 2
-ccccc 3
-name val
-aaaaa 1
-bbbbb 2
-ccccc 3
-name val
-aaaaa 1
-bbbbb 2
-ccccc 3
-call bug10136()|
-name val
-aaaaa 1
-bbbbb 2
-ccccc 3
-name val
-aaaaa 1
-bbbbb 2
-ccccc 3
-name val
-aaaaa 1
-bbbbb 2
-ccccc 3
-call bug10136()|
-name val
-aaaaa 1
-bbbbb 2
-ccccc 3
-name val
-aaaaa 1
-bbbbb 2
-ccccc 3
-name val
-aaaaa 1
-bbbbb 2
-ccccc 3
-drop procedure bug10136|
-drop table t3|
-drop procedure if exists bug11529|
-create procedure bug11529()
-begin
-declare c cursor for select id, data from t1 where data in (10,13);
-open c;
-begin
-declare vid char(16);
-declare vdata int;
-declare exit handler for not found begin end;
-while true do
-fetch c into vid, vdata;
-end while;
-end;
-close c;
-end|
-insert into t1 values
-('Name1', 10),
-('Name2', 11),
-('Name3', 12),
-('Name4', 13),
-('Name5', 14)|
-call bug11529()|
-call bug11529()|
-delete from t1|
-drop procedure bug11529|
-drop procedure if exists bug6063|
-drop procedure if exists bug7088_1|
-drop procedure if exists bug7088_2|
-drop procedure if exists bug9565_sub|
-drop procedure if exists bug9565|
-create procedure bug9565_sub()
-begin
-select * from t1;
-end|
-create procedure bug9565()
-begin
-insert into t1 values ("one", 1);
-call bug9565_sub();
-end|
-call bug9565()|
-id data
-one 1
-delete from t1|
-drop procedure bug9565_sub|
-drop procedure bug9565|
-drop procedure if exists bug9538|
-create procedure bug9538()
-set @@sort_buffer_size = 1000000|
-set @x = @@sort_buffer_size|
-set @@sort_buffer_size = 2000000|
-select @@sort_buffer_size|
-@@sort_buffer_size
-2000000
-call bug9538()|
-select @@sort_buffer_size|
-@@sort_buffer_size
-1000000
-set @@sort_buffer_size = @x|
-drop procedure bug9538|
-drop procedure if exists bug8692|
-create table t3 (c1 varchar(5), c2 char(5), c3 enum('one','two'), c4 text, c5 blob, c6 char(5), c7 varchar(5))|
-insert into t3 values ('', '', '', '', '', '', NULL)|
-Warnings:
-Warning 1265 Data truncated for column 'c3' at row 1
-create procedure bug8692()
-begin
-declare v1 VARCHAR(10);
-declare v2 VARCHAR(10);
-declare v3 VARCHAR(10);
-declare v4 VARCHAR(10);
-declare v5 VARCHAR(10);
-declare v6 VARCHAR(10);
-declare v7 VARCHAR(10);
-declare c8692 cursor for select c1,c2,c3,c4,c5,c6,c7 from t3;
-open c8692;
-fetch c8692 into v1,v2,v3,v4,v5,v6,v7;
-select v1, v2, v3, v4, v5, v6, v7;
-end|
-call bug8692()|
-v1 v2 v3 v4 v5 v6 v7
- NULL
-drop procedure bug8692|
-drop table t3|
-drop function if exists bug10055|
-create function bug10055(v char(255)) returns char(255) return lower(v)|
-select t.column_name, bug10055(t.column_name)
-from information_schema.columns as t
-where t.table_schema = 'test' and t.table_name = 't1'|
-column_name bug10055(t.column_name)
-id id
-data data
-drop function bug10055|
-drop procedure if exists bug12297|
-create procedure bug12297(lim int)
-begin
-set @x = 0;
-repeat
-insert into t1(id,data)
-values('aa', @x);
-set @x = @x + 1;
-until @x >= lim
-end repeat;
-end|
-call bug12297(10)|
-drop procedure bug12297|
-drop function if exists f_bug11247|
-drop procedure if exists p_bug11247|
-create function f_bug11247(param int)
-returns int
-return param + 1|
-create procedure p_bug11247(lim int)
-begin
-declare v int default 0;
-while v < lim do
-set v= f_bug11247(v);
-end while;
-end|
-call p_bug11247(10)|
-drop function f_bug11247|
-drop procedure p_bug11247|
-drop procedure if exists bug12168|
-drop table if exists t3, t4|
-create table t3 (a int)|
-insert into t3 values (1),(2),(3),(4)|
-create table t4 (a int)|
-create procedure bug12168(arg1 char(1))
-begin
-declare b, c integer;
-if arg1 = 'a' then
-begin
-declare c1 cursor for select a from t3 where a % 2;
-declare continue handler for not found set b = 1;
-set b = 0;
-open c1;
-c1_repeat: repeat
-fetch c1 into c;
-if (b = 1) then
-leave c1_repeat;
-end if;
-insert into t4 values (c);
-until b = 1
-end repeat;
-end;
-end if;
-if arg1 = 'b' then
-begin
-declare c2 cursor for select a from t3 where not a % 2;
-declare continue handler for not found set b = 1;
-set b = 0;
-open c2;
-c2_repeat: repeat
-fetch c2 into c;
-if (b = 1) then
-leave c2_repeat;
-end if;
-insert into t4 values (c);
-until b = 1
-end repeat;
-end;
-end if;
-end|
-call bug12168('a')|
-select * from t4|
-a
-1
-3
-truncate t4|
-call bug12168('b')|
-select * from t4|
-a
-2
-4
-truncate t4|
-call bug12168('a')|
-select * from t4|
-a
-1
-3
-truncate t4|
-call bug12168('b')|
-select * from t4|
-a
-2
-4
-truncate t4|
-drop table t3, t4|
-drop procedure if exists bug12168|
-drop table if exists t3|
-drop procedure if exists bug11333|
-create table t3 (c1 char(128))|
-insert into t3 values
-('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')|
-create procedure bug11333(i int)
-begin
-declare tmp varchar(128);
-set @x = 0;
-repeat
-select c1 into tmp from t3
-where c1 = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
-set @x = @x + 1;
-until @x >= i
-end repeat;
-end|
-call bug11333(10)|
-drop procedure bug11333|
-drop table t3|
-drop function if exists bug9048|
-create function bug9048(f1 char binary) returns char binary
-begin
-set f1= concat( 'hello', f1 );
-return f1;
-end|
-drop function bug9048|
-drop procedure if exists bug12849_1|
-create procedure bug12849_1(inout x char) select x into x|
-set @var='a'|
-call bug12849_1(@var)|
-select @var|
-@var
-a
-drop procedure bug12849_1|
-drop procedure if exists bug12849_2|
-create procedure bug12849_2(inout foo varchar(15))
-begin
-select concat(foo, foo) INTO foo;
-end|
-set @var='abcd'|
-call bug12849_2(@var)|
-select @var|
-@var
-abcdabcd
-drop procedure bug12849_2|
-drop procedure if exists bug131333|
-drop function if exists bug131333|
-create procedure bug131333()
-begin
-begin
-declare a int;
-select a;
-set a = 1;
-select a;
-end;
-begin
-declare b int;
-select b;
-end;
-end|
-create function bug131333()
-returns int
-begin
-begin
-declare a int;
-set a = 1;
-end;
-begin
-declare b int;
-return b;
-end;
-end|
-call bug131333()|
-a
-NULL
-a
-1
-b
-NULL
-select bug131333()|
-bug131333()
-NULL
-drop procedure bug131333|
-drop function bug131333|
-drop function if exists bug12379|
-drop procedure if exists bug12379_1|
-drop procedure if exists bug12379_2|
-drop procedure if exists bug12379_3|
-drop table if exists t3|
-create table t3 (c1 char(1) primary key not null)|
-create function bug12379()
-returns integer
-begin
-insert into t3 values('X');
-insert into t3 values('X');
-return 0;
-end|
-create procedure bug12379_1()
-begin
-declare exit handler for sqlexception select 42;
-select bug12379();
-END|
-create procedure bug12379_2()
-begin
-declare exit handler for sqlexception begin end;
-select bug12379();
-end|
-create procedure bug12379_3()
-begin
-select bug12379();
-end|
-select bug12379()|
-ERROR 23000: Duplicate entry 'X' for key 1
-select 1|
-1
-1
-call bug12379_1()|
-bug12379()
-42
-42
-select 2|
-2
-2
-call bug12379_2()|
-bug12379()
-select 3|
-3
-3
-call bug12379_3()|
-ERROR 23000: Duplicate entry 'X' for key 1
-select 4|
-4
-4
-drop function bug12379|
-drop procedure bug12379_1|
-drop procedure bug12379_2|
-drop procedure bug12379_3|
-drop table t3|
-drop procedure if exists bug13124|
-create procedure bug13124()
-begin
-declare y integer;
-set @x=y;
-end|
-call bug13124()|
-drop procedure bug13124|
-drop procedure if exists bug12979_1|
-create procedure bug12979_1(inout d decimal(5)) set d = d / 2|
-set @bug12979_user_var = NULL|
-call bug12979_1(@bug12979_user_var)|
-drop procedure bug12979_1|
-drop procedure if exists bug12979_2|
-create procedure bug12979_2()
-begin
-declare internal_var decimal(5);
-set internal_var= internal_var / 2;
-select internal_var;
-end|
-call bug12979_2()|
-internal_var
-NULL
-drop procedure bug12979_2|
-drop table if exists t3|
-drop procedure if exists bug6127|
-create table t3 (s1 int unique)|
-set @sm=@@sql_mode|
-set sql_mode='traditional'|
-create procedure bug6127()
-begin
-declare continue handler for sqlstate '23000'
- begin
-declare continue handler for sqlstate '22003'
- insert into t3 values (0);
-insert into t3 values (1000000000000000);
-end;
-insert into t3 values (1);
-insert into t3 values (1);
-end|
-call bug6127()|
-select * from t3|
-s1
-0
-1
-call bug6127()|
-ERROR 23000: Duplicate entry '0' for key 1
-select * from t3|
-s1
-0
-1
-set sql_mode=@sm|
-drop table t3|
-drop procedure bug6127|
-drop procedure if exists bug12589_1|
-drop procedure if exists bug12589_2|
-drop procedure if exists bug12589_3|
-create procedure bug12589_1()
-begin
-declare spv1 decimal(3,3);
-set spv1= 123.456;
-set spv1 = 'test';
-create temporary table tm1 as select spv1;
-show create table tm1;
-drop temporary table tm1;
-end|
-create procedure bug12589_2()
-begin
-declare spv1 decimal(6,3);
-set spv1= 123.456;
-create temporary table tm1 as select spv1;
-show create table tm1;
-drop temporary table tm1;
-end|
-create procedure bug12589_3()
-begin
-declare spv1 decimal(6,3);
-set spv1= -123.456;
-create temporary table tm1 as select spv1;
-show create table tm1;
-drop temporary table tm1;
-end|
-call bug12589_1()|
-Table Create Table
-tm1 CREATE TEMPORARY TABLE `tm1` (
- `spv1` decimal(3,3) default NULL
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-Warnings:
-Warning 1264 Out of range value adjusted for column 'spv1' at row 1
-Warning 1366 Incorrect decimal value: 'test' for column 'spv1' at row 1
-call bug12589_2()|
-Table Create Table
-tm1 CREATE TEMPORARY TABLE `tm1` (
- `spv1` decimal(6,3) default NULL
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-call bug12589_3()|
-Table Create Table
-tm1 CREATE TEMPORARY TABLE `tm1` (
- `spv1` decimal(6,3) default NULL
-) ENGINE=MyISAM DEFAULT CHARSET=latin1
-drop procedure bug12589_1|
-drop procedure bug12589_2|
-drop procedure bug12589_3|
-drop table if exists t3|
-drop procedure if exists bug7049_1|
-drop procedure if exists bug7049_2|
-drop procedure if exists bug7049_3|
-drop procedure if exists bug7049_4|
-drop function if exists bug7049_1|
-drop function if exists bug7049_2|
-create table t3 ( x int unique )|
-create procedure bug7049_1()
-begin
-insert into t3 values (42);
-insert into t3 values (42);
-end|
-create procedure bug7049_2()
-begin
-declare exit handler for sqlexception
-select 'Caught it' as 'Result';
-call bug7049_1();
-select 'Missed it' as 'Result';
-end|
-create procedure bug7049_3()
-call bug7049_1()|
-create procedure bug7049_4()
-begin
-declare exit handler for sqlexception
-select 'Caught it' as 'Result';
-call bug7049_3();
-select 'Missed it' as 'Result';
-end|
-create function bug7049_1()
-returns int
-begin
-insert into t3 values (42);
-insert into t3 values (42);
-return 42;
-end|
-create function bug7049_2()
-returns int
-begin
-declare x int default 0;
-declare continue handler for sqlexception
-set x = 1;
-set x = bug7049_1();
-return x;
-end|
-call bug7049_2()|
-Result
-Caught it
-select * from t3|
-x
-42
-delete from t3|
-call bug7049_4()|
-Result
-Caught it
-select * from t3|
-x
-42
-select bug7049_2()|
-bug7049_2()
-1
-drop table t3|
-drop procedure bug7049_1|
-drop procedure bug7049_2|
-drop procedure bug7049_3|
-drop procedure bug7049_4|
-drop function bug7049_1|
-drop function bug7049_2|
-drop function if exists bug13941|
-drop procedure if exists bug13941|
-create function bug13941(p_input_str text)
-returns text
-begin
-declare p_output_str text;
-set p_output_str = p_input_str;
-set p_output_str = replace(p_output_str, 'xyzzy', 'plugh');
-set p_output_str = replace(p_output_str, 'test', 'prova');
-set p_output_str = replace(p_output_str, 'this', 'questo');
-set p_output_str = replace(p_output_str, ' a ', 'una ');
-set p_output_str = replace(p_output_str, 'is', '');
-return p_output_str;
-end|
-create procedure bug13941(out sout varchar(128))
-begin
-set sout = 'Local';
-set sout = ifnull(sout, 'DEF');
-end|
-select bug13941('this is a test')|
-bug13941('this is a test')
-questo una prova
-call bug13941(@a)|
-select @a|
-@a
-Local
-drop function bug13941|
-drop procedure bug13941|
-DROP PROCEDURE IF EXISTS bug13095;
-DROP TABLE IF EXISTS bug13095_t1;
-DROP VIEW IF EXISTS bug13095_v1;
-CREATE PROCEDURE bug13095(tbl_name varchar(32))
-BEGIN
-SET @str =
-CONCAT("CREATE TABLE ", tbl_name, "(stuff char(15))");
-SELECT @str;
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-SET @str =
-CONCAT("INSERT INTO ", tbl_name, " VALUES('row1'),('row2'),('row3')" );
-SELECT @str;
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-SET @str =
-CONCAT("CREATE VIEW bug13095_v1(c1) AS SELECT stuff FROM ", tbl_name);
-SELECT @str;
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-SELECT * FROM bug13095_v1;
-SET @str =
-"DROP VIEW bug13095_v1";
-SELECT @str;
-PREPARE stmt FROM @str;
-EXECUTE stmt;
-END|
-CALL bug13095('bug13095_t1');
-@str
-CREATE TABLE bug13095_t1(stuff char(15))
-@str
-INSERT INTO bug13095_t1 VALUES('row1'),('row2'),('row3')
-@str
-CREATE VIEW bug13095_v1(c1) AS SELECT stuff FROM bug13095_t1
-c1
-row1
-row2
-row3
-@str
-DROP VIEW bug13095_v1
-DROP PROCEDURE IF EXISTS bug13095;
-DROP VIEW IF EXISTS bug13095_v1;
-DROP TABLE IF EXISTS bug13095_t1;
-drop procedure if exists bug14210|
-set @@session.max_heap_table_size=16384|
-select @@session.max_heap_table_size|
-@@session.max_heap_table_size
-16384
-create table t3 (a char(255)) engine=InnoDB|
-create procedure bug14210_fill_table()
-begin
-declare table_size, max_table_size int default 0;
-select @@session.max_heap_table_size into max_table_size;
-delete from t3;
-insert into t3 (a) values (repeat('a', 255));
-repeat
-insert into t3 select a from t3;
-select count(*)*255 from t3 into table_size;
-until table_size > max_table_size*2 end repeat;
-end|
-call bug14210_fill_table()|
-drop procedure bug14210_fill_table|
-create table t4 like t3|
-create procedure bug14210()
-begin
-declare a char(255);
-declare done int default 0;
-declare c cursor for select * from t3;
-declare continue handler for sqlstate '02000' set done = 1;
-open c;
-repeat
-fetch c into a;
-if not done then
-insert into t4 values (upper(a));
-end if;
-until done end repeat;
-close c;
-end|
-call bug14210()|
-select count(*) from t4|
-count(*)
-256
-drop table t3, t4|
-drop procedure bug14210|
-set @@session.max_heap_table_size=default|
-drop function if exists bug14723|
-drop procedure if exists bug14723|
-/*!50003 create function bug14723()
-returns bigint(20)
-main_loop: begin
-return 42;
-end */;;
-show create function bug14723;;
-Function sql_mode Create Function
-bug14723 CREATE FUNCTION `bug14723`() RETURNS bigint(20)
-main_loop: begin
-return 42;
-end
-select bug14723();;
-bug14723()
-42
-/*!50003 create procedure bug14723()
-main_loop: begin
-select 42;
-end */;;
-show create procedure bug14723;;
-Procedure sql_mode Create Procedure
-bug14723 CREATE PROCEDURE `bug14723`()
-main_loop: begin
-select 42;
-end
-call bug14723();;
-42
-42
-drop function bug14723|
-drop procedure bug14723|
-create procedure bug14845()
-begin
-declare a char(255);
-declare done int default 0;
-declare c cursor for select count(*) from t1 where 1 = 0;
-declare continue handler for sqlstate '02000' set done = 1;
-open c;
-repeat
-fetch c into a;
-if not done then
-select a;
-end if;
-until done end repeat;
-close c;
-end|
-call bug14845()|
-a
-0
-drop procedure bug14845|
-drop procedure if exists bug13549_1|
-drop procedure if exists bug13549_2|
-CREATE PROCEDURE `bug13549_2`()
-begin
-call bug13549_1();
-end|
-CREATE PROCEDURE `bug13549_1`()
-begin
-declare done int default 0;
-set done= not done;
-end|
-CALL bug13549_2()|
-drop procedure bug13549_2|
-drop procedure bug13549_1|
-drop function if exists bug10100f|
-drop procedure if exists bug10100p|
-drop procedure if exists bug10100t|
-drop procedure if exists bug10100pt|
-drop procedure if exists bug10100pv|
-drop procedure if exists bug10100pd|
-drop procedure if exists bug10100pc|
-create function bug10100f(prm int) returns int
-begin
-if prm > 1 then
-return prm * bug10100f(prm - 1);
-end if;
-return 1;
-end|
-create procedure bug10100p(prm int, inout res int)
-begin
-set res = res * prm;
-if prm > 1 then
-call bug10100p(prm - 1, res);
-end if;
-end|
-create procedure bug10100t(prm int)
-begin
-declare res int;
-set res = 1;
-call bug10100p(prm, res);
-select res;
-end|
-create table t3 (a int)|
-insert into t3 values (0)|
-create view v1 as select a from t3;
-create procedure bug10100pt(level int, lim int)
-begin
-if level < lim then
-update t3 set a=level;
-FLUSH TABLES;
-call bug10100pt(level+1, lim);
-else
-select * from t3;
-end if;
-end|
-create procedure bug10100pv(level int, lim int)
-begin
-if level < lim then
-update v1 set a=level;
-FLUSH TABLES;
-call bug10100pv(level+1, lim);
-else
-select * from v1;
-end if;
-end|
-prepare stmt2 from "select * from t3;";
-create procedure bug10100pd(level int, lim int)
-begin
-if level < lim then
-select level;
-prepare stmt1 from "update t3 set a=a+2";
-execute stmt1;
-FLUSH TABLES;
-execute stmt1;
-FLUSH TABLES;
-execute stmt1;
-FLUSH TABLES;
-deallocate prepare stmt1;
-execute stmt2;
-select * from t3;
-call bug10100pd(level+1, lim);
-else
-execute stmt2;
-end if;
-end|
-create procedure bug10100pc(level int, lim int)
-begin
-declare lv int;
-declare c cursor for select a from t3;
-open c;
-if level < lim then
-select level;
-fetch c into lv;
-select lv;
-update t3 set a=level+lv;
-FLUSH TABLES;
-call bug10100pc(level+1, lim);
-else
-select * from t3;
-end if;
-close c;
-end|
-set @@max_sp_recursion_depth=4|
-select @@max_sp_recursion_depth|
-@@max_sp_recursion_depth
-4
-select bug10100f(3)|
-ERROR HY000: Recursive stored functions and triggers are not allowed.
-select bug10100f(6)|
-ERROR HY000: Recursive stored functions and triggers are not allowed.
-call bug10100t(5)|
-res
-120
-call bug10100pt(1,5)|
-a
-4
-call bug10100pv(1,5)|
-a
-4
-update t3 set a=1|
-call bug10100pd(1,5)|
-level
-1
-a
-7
-a
-7
-level
-2
-a
-13
-a
-13
-level
-3
-a
-19
-a
-19
-level
-4
-a
-25
-a
-25
-a
-25
-select * from t3|
-a
-25
-update t3 set a=1|
-call bug10100pc(1,5)|
-level
-1
-lv
-1
-level
-2
-lv
-2
-level
-3
-lv
-4
-level
-4
-lv
-7
-a
-11
-select * from t3|
-a
-11
-set @@max_sp_recursion_depth=0|
-select @@max_sp_recursion_depth|
-@@max_sp_recursion_depth
-0
-select bug10100f(5)|
-ERROR HY000: Recursive stored functions and triggers are not allowed.
-call bug10100t(5)|
-ERROR HY000: Recursive limit 0 (as set by the max_sp_recursion_depth variable) was exceeded for routine bug10100p
-set @@max_sp_recursion_depth=255|
-set @var=1|
-call bug10100p(255, @var)|
-call bug10100pt(1,255)|
-call bug10100pv(1,255)|
-call bug10100pd(1,255)|
-call bug10100pc(1,255)|
-set @@max_sp_recursion_depth=0|
-deallocate prepare stmt2|
-drop function bug10100f|
-drop procedure bug10100p|
-drop procedure bug10100t|
-drop procedure bug10100pt|
-drop procedure bug10100pv|
-drop procedure bug10100pd|
-drop procedure bug10100pc|
-drop view v1|
-drop procedure if exists bug13729|
-drop table if exists t3|
-create table t3 (s1 int, primary key (s1))|
-insert into t3 values (1),(2)|
-create procedure bug13729()
-begin
-declare continue handler for sqlexception select 55;
-update t3 set s1 = 1;
-end|
-call bug13729()|
-55
-55
-select * from t3|
-s1
-1
-2
-drop procedure bug13729|
-drop table t3|
-drop procedure if exists bug14643_1|
-drop procedure if exists bug14643_2|
-create procedure bug14643_1()
-begin
-declare continue handler for sqlexception select 'boo' as 'Handler';
-begin
-declare v int default undefined_var;
-if v = 1 then
-select 1;
-else
-select v, isnull(v);
-end if;
-end;
-end|
-create procedure bug14643_2()
-begin
-declare continue handler for sqlexception select 'boo' as 'Handler';
-case undefined_var
-when 1 then
-select 1;
-else
-select 2;
-end case;
-select undefined_var;
-end|
-call bug14643_1()|
-Handler
-boo
-v isnull(v)
-NULL 1
-call bug14643_2()|
-Handler
-boo
-Handler
-boo
-drop procedure bug14643_1|
-drop procedure bug14643_2|
-drop procedure if exists bug14304|
-drop table if exists t3, t4|
-create table t3(a int primary key auto_increment)|
-create table t4(a int primary key auto_increment)|
-create procedure bug14304()
-begin
-insert into t3 set a=null;
-insert into t4 set a=null;
-insert into t4 set a=null;
-insert into t4 set a=null;
-insert into t4 set a=null;
-insert into t4 set a=null;
-insert into t4 select null as a;
-insert into t3 set a=null;
-insert into t3 set a=null;
-select * from t3;
-end|
-call bug14304()|
-a
-1
-2
-3
-drop procedure bug14304|
-drop table t3, t4|
-drop procedure if exists bug14376|
-create procedure bug14376()
-begin
-declare x int default x;
-end|
-call bug14376()|
-ERROR 42S22: Unknown column 'x' in 'field list'
-drop procedure bug14376|
-create procedure bug14376()
-begin
-declare x int default 42;
-begin
-declare x int default x;
-select x;
-end;
-end|
-call bug14376()|
-x
-42
-drop procedure bug14376|
-create procedure bug14376(x int)
-begin
-declare x int default x;
-select x;
-end|
-call bug14376(4711)|
-x
-4711
-drop procedure bug14376|
-drop procedure if exists bug5967|
-drop table if exists t3|
-create table t3 (a varchar(255))|
-insert into t3 (a) values ("a - table column")|
-create procedure bug5967(a varchar(255))
-begin
-declare i varchar(255);
-declare c cursor for select a from t3;
-select a;
-select a from t3 into i;
-select i as 'Parameter takes precedence over table column'; open c;
-fetch c into i;
-close c;
-select i as 'Parameter takes precedence over table column in cursors';
-begin
-declare a varchar(255) default 'a - local variable';
-declare c1 cursor for select a from t3;
-select a as 'A local variable takes precedence over parameter';
-open c1;
-fetch c1 into i;
-close c1;
-select i as 'A local variable takes precedence over parameter in cursors';
-begin
-declare a varchar(255) default 'a - local variable in a nested compound statement';
-declare c2 cursor for select a from t3;
-select a as 'A local variable in a nested compound statement takes precedence over a local variable in the outer statement';
-select a from t3 into i;
-select i as 'A local variable in a nested compound statement takes precedence over table column';
-open c2;
-fetch c2 into i;
-close c2;
-select i as 'A local variable in a nested compound statement takes precedence over table column in cursors';
-end;
-end;
-end|
-call bug5967("a - stored procedure parameter")|
-a
-a - stored procedure parameter
-Parameter takes precedence over table column
-a - stored procedure parameter
-Parameter takes precedence over table column in cursors
-a - stored procedure parameter
-A local variable takes precedence over parameter
-a - local variable
-A local variable takes precedence over parameter in cursors
-a - local variable
-A local variable in a nested compound statement takes precedence over a local variable in the outer statement
-a - local variable in a nested compound statement
-A local variable in a nested compound statement takes precedence over table column
-a - local variable in a nested compound statement
-A local variable in a nested compound statement takes precedence over table column in cursors
-a - local variable in a nested compound statement
-drop procedure bug5967|
-drop procedure if exists bug13012|
-create procedure bug13012()
-BEGIN
-REPAIR TABLE t1;
-BACKUP TABLE t1 to '../tmp';
-DROP TABLE t1;
-RESTORE TABLE t1 FROM '../tmp';
-END|
-call bug13012()|
-Table Op Msg_type Msg_text
-test.t1 repair status OK
-Table Op Msg_type Msg_text
-test.t1 backup status OK
-Table Op Msg_type Msg_text
-test.t1 restore status OK
-drop procedure bug13012|
-create view v1 as select * from t1|
-create procedure bug13012()
-BEGIN
-REPAIR TABLE t1,t2,t3,v1;
-OPTIMIZE TABLE t1,t2,t3,v1;
-ANALYZE TABLE t1,t2,t3,v1;
-END|
-call bug13012()|
-Table Op Msg_type Msg_text
-test.t1 repair status OK
-test.t2 repair status OK
-test.t3 repair status OK
-test.v1 repair error 'test.v1' is not BASE TABLE
-Table Op Msg_type Msg_text
-test.t1 optimize status OK
-test.t2 optimize status OK
-test.t3 optimize status OK
-test.v1 optimize error 'test.v1' is not BASE TABLE
-Table Op Msg_type Msg_text
-test.t1 analyze status Table is already up to date
-test.t2 analyze status Table is already up to date
-test.t3 analyze status Table is already up to date
-test.v1 analyze error 'test.v1' is not BASE TABLE
-Warnings:
-Error 1347 'test.v1' is not BASE TABLE
-call bug13012()|
-Table Op Msg_type Msg_text
-test.t1 repair status OK
-test.t2 repair status OK
-test.t3 repair status OK
-test.v1 repair error 'test.v1' is not BASE TABLE
-Table Op Msg_type Msg_text
-test.t1 optimize status OK
-test.t2 optimize status OK
-test.t3 optimize status OK
-test.v1 optimize error 'test.v1' is not BASE TABLE
-Table Op Msg_type Msg_text
-test.t1 analyze status Table is already up to date
-test.t2 analyze status Table is already up to date
-test.t3 analyze status Table is already up to date
-test.v1 analyze error 'test.v1' is not BASE TABLE
-Warnings:
-Error 1347 'test.v1' is not BASE TABLE
-call bug13012()|
-Table Op Msg_type Msg_text
-test.t1 repair status OK
-test.t2 repair status OK
-test.t3 repair status OK
-test.v1 repair error 'test.v1' is not BASE TABLE
-Table Op Msg_type Msg_text
-test.t1 optimize status OK
-test.t2 optimize status OK
-test.t3 optimize status OK
-test.v1 optimize error 'test.v1' is not BASE TABLE
-Table Op Msg_type Msg_text
-test.t1 analyze status Table is already up to date
-test.t2 analyze status Table is already up to date
-test.t3 analyze status Table is already up to date
-test.v1 analyze error 'test.v1' is not BASE TABLE
-Warnings:
-Error 1347 'test.v1' is not BASE TABLE
-drop procedure bug13012|
-drop view v1;
-select * from t1|
-id data
-aa 0
-aa 1
-aa 2
-aa 3
-aa 4
-aa 5
-aa 6
-aa 7
-aa 8
-aa 9
-drop schema if exists mysqltest1|
-Warnings:
-Note 1008 Can't drop database 'mysqltest1'; database doesn't exist
-drop schema if exists mysqltest2|
-Warnings:
-Note 1008 Can't drop database 'mysqltest2'; database doesn't exist
-drop schema if exists mysqltest3|
-Warnings:
-Note 1008 Can't drop database 'mysqltest3'; database doesn't exist
-create schema mysqltest1|
-create schema mysqltest2|
-create schema mysqltest3|
-use mysqltest3|
-create procedure mysqltest1.p1 (out prequestid varchar(100))
-begin
-call mysqltest2.p2('call mysqltest3.p3(1, 2)');
-end|
-create procedure mysqltest2.p2(in psql text)
-begin
-declare lsql text;
-set @lsql= psql;
-prepare lstatement from @lsql;
-execute lstatement;
-deallocate prepare lstatement;
-end|
-create procedure mysqltest3.p3(in p1 int)
-begin
-select p1;
-end|
-call mysqltest1.p1(@rs)|
-ERROR 42000: Incorrect number of arguments for PROCEDURE mysqltest3.p3; expected 1, got 2
-call mysqltest1.p1(@rs)|
-ERROR 42000: Incorrect number of arguments for PROCEDURE mysqltest3.p3; expected 1, got 2
-call mysqltest1.p1(@rs)|
-ERROR 42000: Incorrect number of arguments for PROCEDURE mysqltest3.p3; expected 1, got 2
-drop schema if exists mysqltest1|
-drop schema if exists mysqltest2|
-drop schema if exists mysqltest3|
-use test|
-drop table if exists t3|
-drop procedure if exists bug15441|
-create table t3 (id int not null primary key, county varchar(25))|
-insert into t3 (id, county) values (1, 'York')|
-create procedure bug15441(c varchar(25))
-begin
-update t3 set id=2, county=values(c);
-end|
-call bug15441('county')|
-ERROR 42S22: Unknown column 'c' in 'field list'
-drop procedure bug15441|
-create procedure bug15441(county varchar(25))
-begin
-declare c varchar(25) default "hello";
-insert into t3 (id, county) values (1, county)
-on duplicate key update county= values(county);
-select * from t3;
-update t3 set id=2, county=values(id);
-select * from t3;
-end|
-call bug15441('Yale')|
-id county
-1 Yale
-id county
-2 NULL
-drop table t3|
-drop procedure bug15441|
-drop procedure if exists bug14498_1|
-drop procedure if exists bug14498_2|
-drop procedure if exists bug14498_3|
-drop procedure if exists bug14498_4|
-drop procedure if exists bug14498_5|
-create procedure bug14498_1()
-begin
-declare continue handler for sqlexception select 'error' as 'Handler';
-if v then
-select 'yes' as 'v';
-else
-select 'no' as 'v';
-end if;
-select 'done' as 'End';
-end|
-create procedure bug14498_2()
-begin
-declare continue handler for sqlexception select 'error' as 'Handler';
-while v do
-select 'yes' as 'v';
-end while;
-select 'done' as 'End';
-end|
-create procedure bug14498_3()
-begin
-declare continue handler for sqlexception select 'error' as 'Handler';
-repeat
-select 'maybe' as 'v';
-until v end repeat;
-select 'done' as 'End';
-end|
-create procedure bug14498_4()
-begin
-declare continue handler for sqlexception select 'error' as 'Handler';
-case v
-when 1 then
-select '1' as 'v';
-when 2 then
-select '2' as 'v';
-else
-select '?' as 'v';
-end case;
-select 'done' as 'End';
-end|
-create procedure bug14498_5()
-begin
-declare continue handler for sqlexception select 'error' as 'Handler';
-case
-when v = 1 then
-select '1' as 'v';
-when v = 2 then
-select '2' as 'v';
-else
-select '?' as 'v';
-end case;
-select 'done' as 'End';
-end|
-call bug14498_1()|
-Handler
-error
-End
-done
-call bug14498_2()|
-Handler
-error
-End
-done
-call bug14498_3()|
-v
-maybe
-Handler
-error
-End
-done
-call bug14498_4()|
-Handler
-error
-End
-done
-call bug14498_5()|
-Handler
-error
-End
-done
-drop procedure bug14498_1|
-drop procedure bug14498_2|
-drop procedure bug14498_3|
-drop procedure bug14498_4|
-drop procedure bug14498_5|
-drop table if exists t3|
-drop procedure if exists bug15231_1|
-drop procedure if exists bug15231_2|
-drop procedure if exists bug15231_3|
-drop procedure if exists bug15231_4|
-create table t3 (id int not null)|
-create procedure bug15231_1()
-begin
-declare xid integer;
-declare xdone integer default 0;
-declare continue handler for not found set xdone = 1;
-set xid=null;
-call bug15231_2(xid);
-select xid, xdone;
-end|
-create procedure bug15231_2(inout ioid integer)
-begin
-select "Before NOT FOUND condition is triggered" as '1';
-select id into ioid from t3 where id=ioid;
-select "After NOT FOUND condtition is triggered" as '2';
-if ioid is null then
-set ioid=1;
-end if;
-end|
-create procedure bug15231_3()
-begin
-declare exit handler for sqlwarning
-select 'Caught it (wrong)' as 'Result';
-call bug15231_4();
-end|
-create procedure bug15231_4()
-begin
-declare x decimal(2,1);
-set x = 'zap';
-select 'Missed it (correct)' as 'Result';
-end|
-call bug15231_1()|
-1
-Before NOT FOUND condition is triggered
-2
-After NOT FOUND condtition is triggered
-xid xdone
-1 0
-Warnings:
-Warning 1329 No data - zero rows fetched, selected, or processed
-call bug15231_3()|
-Result
-Missed it (correct)
-Warnings:
-Warning 1366 Incorrect decimal value: 'zap' for column 'x' at row 1
-drop table if exists t3|
-drop procedure if exists bug15231_1|
-drop procedure if exists bug15231_2|
-drop procedure if exists bug15231_3|
-drop procedure if exists bug15231_4|
-drop procedure if exists bug15011|
-create table t3 (c1 int primary key)|
-insert into t3 values (1)|
-create procedure bug15011()
-deterministic
-begin
-declare continue handler for 1062
-select 'Outer' as 'Handler';
-begin
-declare continue handler for 1062
-select 'Inner' as 'Handler';
-insert into t3 values (1);
-end;
-end|
-call bug15011()|
-Handler
-Inner
-drop procedure bug15011|
-drop table t3|
-drop table t1,t2;
diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result
index 16464d67301..291cc6777e3 100644
--- a/mysql-test/r/strict.result
+++ b/mysql-test/r/strict.result
@@ -5,7 +5,9 @@ select @@sql_mode;
REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (col1 date);
-INSERT INTO t1 VALUES('2004-01-01'),('0000-10-31'),('2004-02-29');
+INSERT INTO t1 VALUES('2004-01-01'),('2004-02-29');
+INSERT INTO t1 VALUES('0000-10-31');
+ERROR 22007: Incorrect date value: '0000-10-31' for column 'col1' at row 1
INSERT INTO t1 VALUES('2004-0-31');
ERROR 22007: Incorrect date value: '2004-0-31' for column 'col1' at row 1
INSERT INTO t1 VALUES('2004-01-02'),('2004-0-31');
@@ -54,7 +56,6 @@ Warning 1265 Data truncated for column 'col1' at row 3
select * from t1;
col1
2004-01-01
-0000-10-31
2004-02-29
2004-01-02
2004-01-03
@@ -121,7 +122,9 @@ col1
drop table t1;
set @@sql_mode='ansi,traditional';
CREATE TABLE t1 (col1 datetime);
-INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('0000-10-31 15:30:00'),('2004-02-29 15:30:00');
+INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('2004-02-29 15:30:00');
+INSERT INTO t1 VALUES('0000-10-31 15:30:00');
+ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col1' at row 1
INSERT INTO t1 VALUES('2004-0-31 15:30:00');
ERROR 22007: Incorrect datetime value: '2004-0-31 15:30:00' for column 'col1' at row 1
INSERT INTO t1 VALUES('2004-10-0 15:30:00');
@@ -141,7 +144,6 @@ ERROR 22007: Incorrect datetime value: '59' for column 'col1' at row 1
select * from t1;
col1
2004-10-31 15:30:00
-0000-10-31 15:30:00
2004-02-29 15:30:00
drop table t1;
CREATE TABLE t1 (col1 timestamp);
@@ -204,6 +206,7 @@ INSERT INTO t1 (col1) VALUES (STR_TO_DATE('15.10.2004','%d.%m.%Y'));
INSERT INTO t1 (col2) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
INSERT INTO t1 (col3) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
+ERROR 22007: Incorrect date value: '0000-10-31 15:30:00' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
ERROR 22007: Incorrect date value: '2004-00-31 15:30:00' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
@@ -219,6 +222,7 @@ ERROR HY000: Incorrect datetime value: '15.13.2004 15.30' for function str_to_ti
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
+ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col2' at row 1
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
ERROR 22007: Incorrect datetime value: '2004-00-31 15:30:00' for column 'col2' at row 1
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
@@ -255,6 +259,7 @@ INSERT INTO t1 (col1) VALUES (CAST('2004-10-15' AS DATE));
INSERT INTO t1 (col2) VALUES (CAST('2004-10-15 10:15' AS DATETIME));
INSERT INTO t1 (col3) VALUES (CAST('2004-10-15 10:15' AS DATETIME));
INSERT INTO t1 (col1) VALUES(CAST('0000-10-31' AS DATE));
+ERROR 22007: Truncated incorrect datetime value: '0000-10-31'
INSERT INTO t1 (col1) VALUES(CAST('2004-10-0' AS DATE));
ERROR 22007: Incorrect date value: '2004-10-00' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(CAST('2004-0-10' AS DATE));
@@ -262,6 +267,7 @@ ERROR 22007: Incorrect date value: '2004-00-10' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(CAST('0000-00-00' AS DATE));
ERROR 22007: Truncated incorrect datetime value: '0000-00-00'
INSERT INTO t1 (col2) VALUES(CAST('0000-10-31 15:30' AS DATETIME));
+ERROR 22007: Truncated incorrect datetime value: '0000-10-31 15:30'
INSERT INTO t1 (col2) VALUES(CAST('2004-10-0 15:30' AS DATETIME));
ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col2' at row 1
INSERT INTO t1 (col2) VALUES(CAST('2004-0-10 15:30' AS DATETIME));
@@ -269,7 +275,7 @@ ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col2' a
INSERT INTO t1 (col2) VALUES(CAST('0000-00-00' AS DATETIME));
ERROR 22007: Truncated incorrect datetime value: '0000-00-00'
INSERT INTO t1 (col3) VALUES(CAST('0000-10-31 15:30' AS DATETIME));
-ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1
+ERROR 22007: Truncated incorrect datetime value: '0000-10-31 15:30'
INSERT INTO t1 (col3) VALUES(CAST('2004-10-0 15:30' AS DATETIME));
ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col3' at row 1
INSERT INTO t1 (col3) VALUES(CAST('2004-0-10 15:30' AS DATETIME));
@@ -282,6 +288,7 @@ INSERT INTO t1 (col1) VALUES (CONVERT('2004-10-15',DATE));
INSERT INTO t1 (col2) VALUES (CONVERT('2004-10-15 10:15',DATETIME));
INSERT INTO t1 (col3) VALUES (CONVERT('2004-10-15 10:15',DATETIME));
INSERT INTO t1 (col1) VALUES(CONVERT('0000-10-31' , DATE));
+ERROR 22007: Truncated incorrect datetime value: '0000-10-31'
INSERT INTO t1 (col1) VALUES(CONVERT('2004-10-0' , DATE));
ERROR 22007: Incorrect date value: '2004-10-00' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(CONVERT('2004-0-10' , DATE));
@@ -289,6 +296,7 @@ ERROR 22007: Incorrect date value: '2004-00-10' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(CONVERT('0000-00-00',DATE));
ERROR 22007: Truncated incorrect datetime value: '0000-00-00'
INSERT INTO t1 (col2) VALUES(CONVERT('0000-10-31 15:30',DATETIME));
+ERROR 22007: Truncated incorrect datetime value: '0000-10-31 15:30'
INSERT INTO t1 (col2) VALUES(CONVERT('2004-10-0 15:30',DATETIME));
ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col2' at row 1
INSERT INTO t1 (col2) VALUES(CONVERT('2004-0-10 15:30',DATETIME));
@@ -296,7 +304,7 @@ ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col2' a
INSERT INTO t1 (col2) VALUES(CONVERT('0000-00-00',DATETIME));
ERROR 22007: Truncated incorrect datetime value: '0000-00-00'
INSERT INTO t1 (col3) VALUES(CONVERT('0000-10-31 15:30',DATETIME));
-ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1
+ERROR 22007: Truncated incorrect datetime value: '0000-10-31 15:30'
INSERT INTO t1 (col3) VALUES(CONVERT('2004-10-0 15:30',DATETIME));
ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col3' at row 1
INSERT INTO t1 (col3) VALUES(CONVERT('2004-0-10 15:30',DATETIME));
@@ -989,16 +997,16 @@ ERROR 23000: Column 'col2' cannot be null
INSERT INTO t1 VALUES (103,'',NULL);
ERROR 23000: Column 'col3' cannot be null
UPDATE t1 SET col1=NULL WHERE col1 =100;
-ERROR 22004: Column set to default value; NULL supplied to NOT NULL column 'col1' at row 1
+ERROR 22004: Column was set to data type implicit default; NULL supplied for NOT NULL column 'col1' at row 1
UPDATE t1 SET col2 =NULL WHERE col2 ='hello';
-ERROR 22004: Column set to default value; NULL supplied to NOT NULL column 'col2' at row 1
+ERROR 22004: Column was set to data type implicit default; NULL supplied for NOT NULL column 'col2' at row 1
UPDATE t1 SET col2 =NULL where col3 IS NOT NULL;
-ERROR 22004: Column set to default value; NULL supplied to NOT NULL column 'col2' at row 1
+ERROR 22004: Column was set to data type implicit default; NULL supplied for NOT NULL column 'col2' at row 1
INSERT IGNORE INTO t1 values (NULL,NULL,NULL);
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'col1' at row 1
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'col2' at row 1
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'col3' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'col1' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'col2' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'col3' at row 1
SELECT * FROM t1;
col1 col2 col3
100 hello 2004-08-20
@@ -1023,11 +1031,11 @@ ERROR HY000: Field 'col2' doesn't have a default value
INSERT INTO t1 (col1) SELECT 1;
ERROR HY000: Field 'col2' doesn't have a default value
INSERT INTO t1 SELECT 1,NULL;
-ERROR 22004: Column set to default value; NULL supplied to NOT NULL column 'col2' at row 1
+ERROR 22004: Column was set to data type implicit default; NULL supplied for NOT NULL column 'col2' at row 1
INSERT IGNORE INTO t1 values (NULL,NULL);
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'col1' at row 1
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'col2' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'col1' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'col2' at row 1
INSERT IGNORE INTO t1 (col1) values (3);
Warnings:
Warning 1364 Field 'col2' doesn't have a default value
diff --git a/mysql-test/r/strict_autoinc_1myisam.result b/mysql-test/r/strict_autoinc_1myisam.result
new file mode 100644
index 00000000000..5d3c2698cda
--- /dev/null
+++ b/mysql-test/r/strict_autoinc_1myisam.result
@@ -0,0 +1,27 @@
+set @org_mode=@@sql_mode;
+create table t1
+(
+`a` tinyint(4) NOT NULL auto_increment,
+primary key (`a`)
+) engine = 'MYISAM' ;
+set @@sql_mode='strict_all_tables';
+insert into t1 values(1000);
+ERROR 22003: Out of range value adjusted for column 'a' at row 1
+select count(*) from t1;
+count(*)
+0
+set auto_increment_increment=1000;
+set auto_increment_offset=700;
+insert into t1 values(null);
+ERROR 22003: Out of range value adjusted for column 'a' at row 1
+select count(*) from t1;
+count(*)
+0
+set @@sql_mode=@org_mode;
+insert into t1 values(null);
+Warnings:
+Warning 1264 Out of range value adjusted for column 'a' at row 1
+select * from t1;
+a
+127
+drop table t1;
diff --git a/mysql-test/r/strict_autoinc_2innodb.result b/mysql-test/r/strict_autoinc_2innodb.result
new file mode 100644
index 00000000000..f1936ff4de3
--- /dev/null
+++ b/mysql-test/r/strict_autoinc_2innodb.result
@@ -0,0 +1,27 @@
+set @org_mode=@@sql_mode;
+create table t1
+(
+`a` tinyint(4) NOT NULL auto_increment,
+primary key (`a`)
+) engine = 'InnoDB' ;
+set @@sql_mode='strict_all_tables';
+insert into t1 values(1000);
+ERROR 22003: Out of range value adjusted for column 'a' at row 1
+select count(*) from t1;
+count(*)
+0
+set auto_increment_increment=1000;
+set auto_increment_offset=700;
+insert into t1 values(null);
+ERROR 22003: Out of range value adjusted for column 'a' at row 1
+select count(*) from t1;
+count(*)
+0
+set @@sql_mode=@org_mode;
+insert into t1 values(null);
+Warnings:
+Warning 1264 Out of range value adjusted for column 'a' at row 1
+select * from t1;
+a
+127
+drop table t1;
diff --git a/mysql-test/r/strict_autoinc_3heap.result b/mysql-test/r/strict_autoinc_3heap.result
new file mode 100644
index 00000000000..aa0be270ac5
--- /dev/null
+++ b/mysql-test/r/strict_autoinc_3heap.result
@@ -0,0 +1,27 @@
+set @org_mode=@@sql_mode;
+create table t1
+(
+`a` tinyint(4) NOT NULL auto_increment,
+primary key (`a`)
+) engine = 'MEMORY' ;
+set @@sql_mode='strict_all_tables';
+insert into t1 values(1000);
+ERROR 22003: Out of range value adjusted for column 'a' at row 1
+select count(*) from t1;
+count(*)
+0
+set auto_increment_increment=1000;
+set auto_increment_offset=700;
+insert into t1 values(null);
+ERROR 22003: Out of range value adjusted for column 'a' at row 1
+select count(*) from t1;
+count(*)
+0
+set @@sql_mode=@org_mode;
+insert into t1 values(null);
+Warnings:
+Warning 1264 Out of range value adjusted for column 'a' at row 1
+select * from t1;
+a
+127
+drop table t1;
diff --git a/mysql-test/r/strict_autoinc_4bdb.result b/mysql-test/r/strict_autoinc_4bdb.result
new file mode 100644
index 00000000000..73683b645e2
--- /dev/null
+++ b/mysql-test/r/strict_autoinc_4bdb.result
@@ -0,0 +1,27 @@
+set @org_mode=@@sql_mode;
+create table t1
+(
+`a` tinyint(4) NOT NULL auto_increment,
+primary key (`a`)
+) engine = 'BDB' ;
+set @@sql_mode='strict_all_tables';
+insert into t1 values(1000);
+ERROR 22003: Out of range value adjusted for column 'a' at row 1
+select count(*) from t1;
+count(*)
+0
+set auto_increment_increment=1000;
+set auto_increment_offset=700;
+insert into t1 values(null);
+ERROR 22003: Out of range value adjusted for column 'a' at row 1
+select count(*) from t1;
+count(*)
+0
+set @@sql_mode=@org_mode;
+insert into t1 values(null);
+Warnings:
+Warning 1264 Out of range value adjusted for column 'a' at row 1
+select * from t1;
+a
+127
+drop table t1;
diff --git a/mysql-test/r/strict_autoinc_5ndb.result b/mysql-test/r/strict_autoinc_5ndb.result
new file mode 100644
index 00000000000..d0d62d05b32
--- /dev/null
+++ b/mysql-test/r/strict_autoinc_5ndb.result
@@ -0,0 +1,27 @@
+set @org_mode=@@sql_mode;
+create table t1
+(
+`a` tinyint(4) NOT NULL auto_increment,
+primary key (`a`)
+) engine = 'NDB' ;
+set @@sql_mode='strict_all_tables';
+insert into t1 values(1000);
+ERROR 22003: Out of range value adjusted for column 'a' at row 1
+select count(*) from t1;
+count(*)
+0
+set auto_increment_increment=1000;
+set auto_increment_offset=700;
+insert into t1 values(null);
+ERROR 22003: Out of range value adjusted for column 'a' at row 1
+select count(*) from t1;
+count(*)
+0
+set @@sql_mode=@org_mode;
+insert into t1 values(null);
+Warnings:
+Warning 1264 Out of range value adjusted for column 'a' at row 1
+select * from t1;
+a
+127
+drop table t1;
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 07630ffee0f..c6a31856a24 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -1011,7 +1011,7 @@ INSERT INTO t1 VALUES (1);
UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i));
select * from t1;
i
-1
+2
drop table t1;
CREATE TABLE t1 (a int(1));
EXPLAIN EXTENDED SELECT (SELECT RAND() FROM t1) FROM t1;
@@ -1087,24 +1087,24 @@ 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'
+ `a` int(1) NOT NULL default '0',
+ `(SELECT 1)` int(1) NOT NULL default '0'
) ENGINE=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'
+ `a` int(1) NOT NULL default '0',
+ `(SELECT a)` int(1) NOT NULL default '0'
) ENGINE=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(3) NOT NULL default '0'
+ `a` int(1) NOT NULL default '0',
+ `(SELECT a+0)` int(3) NOT NULL default '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
CREATE TABLE t1 SELECT (SELECT 1 as a UNION SELECT 1+1 limit 1,1) as a;
@@ -1203,7 +1203,7 @@ UPDATE t1 SET t.i=i+(SELECT MAX(i) FROM (SELECT 1) t);
ERROR 42S22: Unknown column 't.i' in 'field list'
select * from t1;
i
-1
+3
drop table t1;
CREATE TABLE t1 (
id int(11) default NULL
@@ -2854,6 +2854,118 @@ a
3
4
DROP TABLE t1,t2,t3;
+purge master logs before (select adddate(current_timestamp(), interval -4 day));
+CREATE TABLE t1 (f1 INT);
+CREATE TABLE t2 (f2 INT);
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1 WHERE f1 > ALL (SELECT f2 FROM t2);
+f1
+1
+SELECT * FROM t1 WHERE f1 > ALL (SELECT f2 FROM t2 WHERE 1=0);
+f1
+1
+INSERT INTO t2 VALUES (1);
+INSERT INTO t2 VALUES (2);
+SELECT * FROM t1 WHERE f1 > ALL (SELECT f2 FROM t2 WHERE f2=0);
+f1
+1
+DROP TABLE t1, t2;
+select 1 from dual where 1 < any (select 2);
+1
+1
+select 1 from dual where 1 < all (select 2);
+1
+1
+select 1 from dual where 2 > any (select 1);
+1
+1
+select 1 from dual where 2 > all (select 1);
+1
+1
+select 1 from dual where 1 < any (select 2 from dual);
+1
+1
+select 1 from dual where 1 < all (select 2 from dual where 1!=1);
+1
+1
+create table t1 (s1 char);
+insert into t1 values (1),(2);
+select * from t1 where (s1 < any (select s1 from t1));
+s1
+1
+select * from t1 where not (s1 < any (select s1 from t1));
+s1
+2
+select * from t1 where (s1 < ALL (select s1+1 from t1));
+s1
+1
+select * from t1 where not(s1 < ALL (select s1+1 from t1));
+s1
+2
+select * from t1 where (s1+1 = ANY (select s1 from t1));
+s1
+1
+select * from t1 where NOT(s1+1 = ANY (select s1 from t1));
+s1
+2
+select * from t1 where (s1 = ALL (select s1/s1 from t1));
+s1
+1
+select * from t1 where NOT(s1 = ALL (select s1/s1 from t1));
+s1
+2
+drop table t1;
+create table t1 (
+retailerID varchar(8) NOT NULL,
+statusID int(10) unsigned NOT NULL,
+changed datetime NOT NULL,
+UNIQUE KEY retailerID (retailerID, statusID, changed)
+);
+INSERT INTO t1 VALUES("0026", "1", "2005-12-06 12:18:56");
+INSERT INTO t1 VALUES("0026", "2", "2006-01-06 12:25:53");
+INSERT INTO t1 VALUES("0037", "1", "2005-12-06 12:18:56");
+INSERT INTO t1 VALUES("0037", "2", "2006-01-06 12:25:53");
+INSERT INTO t1 VALUES("0048", "1", "2006-01-06 12:37:50");
+INSERT INTO t1 VALUES("0059", "1", "2006-01-06 12:37:50");
+select * from t1 r1
+where (r1.retailerID,(r1.changed)) in
+(SELECT r2.retailerId,(max(changed)) from t1 r2
+group by r2.retailerId);
+retailerID statusID changed
+0026 2 2006-01-06 12:25:53
+0037 2 2006-01-06 12:25:53
+0048 1 2006-01-06 12:37:50
+0059 1 2006-01-06 12:37:50
+drop table t1;
+create table t1(a int, primary key (a));
+insert into t1 values (10);
+create table t2 (a int primary key, b varchar(32), c int, unique key b(c, b));
+insert into t2(a, c, b) values (1,10,'359'), (2,10,'35988'), (3,10,'35989');
+explain SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
+1 PRIMARY r const PRIMARY PRIMARY 4 const 1
+2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using where
+SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
+a a b
+10 3 35989
+explain SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system PRIMARY NULL NULL NULL 1
+1 PRIMARY r const PRIMARY PRIMARY 4 const 1
+2 DEPENDENT SUBQUERY t2 range b b 40 NULL 2 Using where
+SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
+a a b
+10 1 359
+drop table t1,t2;
create table t1 (df decimal(5,1));
insert into t1 values(1.1);
insert into t1 values(2.2);
@@ -3204,3 +3316,109 @@ i
10000000000000000000
DROP TABLE t1;
DROP TABLE t2;
+CREATE TABLE t1 (
+id bigint(20) unsigned NOT NULL auto_increment,
+name varchar(255) NOT NULL,
+PRIMARY KEY (id)
+);
+INSERT INTO t1 VALUES
+(1, 'Balazs'), (2, 'Joe'), (3, 'Frank');
+CREATE TABLE t2 (
+id bigint(20) unsigned NOT NULL auto_increment,
+mid bigint(20) unsigned NOT NULL,
+date date NOT NULL,
+PRIMARY KEY (id)
+);
+INSERT INTO t2 VALUES
+(1, 1, '2006-03-30'), (2, 2, '2006-04-06'), (3, 3, '2006-04-13'),
+(4, 2, '2006-04-20'), (5, 1, '2006-05-01');
+SELECT *,
+(SELECT date FROM t2 WHERE mid = t1.id
+ORDER BY date DESC LIMIT 0, 1) AS date_last,
+(SELECT date FROM t2 WHERE mid = t1.id
+ORDER BY date DESC LIMIT 3, 1) AS date_next_to_last
+FROM t1;
+id name date_last date_next_to_last
+1 Balazs 2006-05-01 NULL
+2 Joe 2006-04-20 NULL
+3 Frank 2006-04-13 NULL
+SELECT *,
+(SELECT COUNT(*) FROM t2 WHERE mid = t1.id
+ORDER BY date DESC LIMIT 1, 1) AS date_count
+FROM t1;
+id name date_count
+1 Balazs NULL
+2 Joe NULL
+3 Frank NULL
+SELECT *,
+(SELECT date FROM t2 WHERE mid = t1.id
+ORDER BY date DESC LIMIT 0, 1) AS date_last,
+(SELECT date FROM t2 WHERE mid = t1.id
+ORDER BY date DESC LIMIT 1, 1) AS date_next_to_last
+FROM t1;
+id name date_last date_next_to_last
+1 Balazs 2006-05-01 2006-03-30
+2 Joe 2006-04-20 2006-04-06
+3 Frank 2006-04-13 NULL
+DROP TABLE t1,t2;
+CREATE TABLE t1 (
+i1 int(11) NOT NULL default '0',
+i2 int(11) NOT NULL default '0',
+t datetime NOT NULL default '0000-00-00 00:00:00',
+PRIMARY KEY (i1,i2,t)
+);
+INSERT INTO t1 VALUES
+(24,1,'2005-03-03 16:31:31'),(24,1,'2005-05-27 12:40:07'),
+(24,1,'2005-05-27 12:40:08'),(24,1,'2005-05-27 12:40:10'),
+(24,1,'2005-05-27 12:40:25'),(24,1,'2005-05-27 12:40:30'),
+(24,2,'2005-03-03 13:43:05'),(24,2,'2005-03-03 16:23:31'),
+(24,2,'2005-03-03 16:31:30'),(24,2,'2005-05-27 12:37:02'),
+(24,2,'2005-05-27 12:40:06');
+CREATE TABLE t2 (
+i1 int(11) NOT NULL default '0',
+i2 int(11) NOT NULL default '0',
+t datetime default NULL,
+PRIMARY KEY (i1)
+);
+INSERT INTO t2 VALUES (24,1,'2006-06-20 12:29:40');
+EXPLAIN
+SELECT * FROM t1,t2
+WHERE t1.t = (SELECT t1.t FROM t1
+WHERE t1.t < t2.t AND t1.i2=1 AND t2.i1=t1.i1
+ORDER BY t1.t DESC LIMIT 1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 system NULL NULL NULL NULL 1
+1 PRIMARY t1 index NULL PRIMARY 16 NULL 11 Using where; Using index
+2 DEPENDENT SUBQUERY t1 range PRIMARY PRIMARY 16 NULL 5 Using where; Using index
+SELECT * FROM t1,t2
+WHERE t1.t = (SELECT t1.t FROM t1
+WHERE t1.t < t2.t AND t1.i2=1 AND t2.i1=t1.i1
+ORDER BY t1.t DESC LIMIT 1);
+i1 i2 t i1 i2 t
+24 1 2005-05-27 12:40:30 24 1 2006-06-20 12:29:40
+DROP TABLE t1, t2;
+CREATE TABLE t1 (i INT);
+(SELECT i FROM t1) UNION (SELECT i FROM t1);
+i
+SELECT sql_no_cache * FROM t1 WHERE NOT EXISTS
+(
+(SELECT i FROM t1) UNION
+(SELECT i FROM t1)
+);
+i
+SELECT * FROM t1
+WHERE NOT EXISTS (((SELECT i FROM t1) UNION (SELECT i FROM t1)));
+i
+explain select ((select t11.i from t1 t11) union (select t12.i from t1 t12))
+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 'union (select t12.i from t1 t12))
+from t1' at line 1
+explain select * from t1 where not exists
+((select t11.i from t1 t11) union (select t12.i from t1 t12));
+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 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table
+4 UNION t12 system NULL NULL NULL NULL 0 const row not found
+NULL UNION RESULT <union2,4> ALL NULL NULL NULL NULL NULL
+DROP TABLE t1;
diff --git a/mysql-test/r/subselect2.result b/mysql-test/r/subselect2.result
index 026bcb4b370..75aa339fb29 100644
--- a/mysql-test/r/subselect2.result
+++ b/mysql-test/r/subselect2.result
@@ -132,3 +132,15 @@ id select_type table type possible_keys key key_len ref rows Extra
5 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX PRIMARY 34 func 1 Using index; Using where
6 DEPENDENT SUBQUERY t3 unique_subquery PRIMARY,FFOLDERID_IDX,CMFLDRPARNT_IDX PRIMARY 34 func 1 Using index; Using where
drop table t1, t2, t3, t4;
+CREATE TABLE t1 (a int(10) , PRIMARY KEY (a)) Engine=InnoDB;
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 (a int(10), PRIMARY KEY (a)) Engine=InnoDB;
+INSERT INTO t2 VALUES (1);
+CREATE TABLE t3 (a int(10), b int(10), c int(10),
+PRIMARY KEY (a)) Engine=InnoDB;
+INSERT INTO t3 VALUES (1,2,1);
+SELECT t1.* FROM t1 WHERE (SELECT COUNT(*) FROM t3,t2 WHERE t3.c=t2.a
+and t2.a='1' AND t1.a=t3.b) > 0;
+a
+2
+DROP TABLE t1,t2,t3;
diff --git a/mysql-test/r/trigger.result b/mysql-test/r/trigger.result
index f3e797d2344..c687d4c49c8 100644
--- a/mysql-test/r/trigger.result
+++ b/mysql-test/r/trigger.result
@@ -626,12 +626,51 @@ Trigger Event Table Statement Timing Created sql_mode Definer
t1_bi INSERT t1 set new.a = '2004-01-00' BEFORE # root@localhost
drop table t1;
create table t1 (id int);
+create trigger t1_ai after insert on t1 for each row reset query cache;
+ERROR 0A000: RESET is not allowed in stored function or trigger
+create trigger t1_ai after insert on t1 for each row reset master;
+ERROR 0A000: RESET is not allowed in stored function or trigger
+create trigger t1_ai after insert on t1 for each row reset slave;
+ERROR 0A000: RESET is not allowed in stored function or trigger
+create trigger t1_ai after insert on t1 for each row flush hosts;
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+create trigger t1_ai after insert on t1 for each row flush tables with read lock;
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+create trigger t1_ai after insert on t1 for each row flush logs;
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+create trigger t1_ai after insert on t1 for each row flush status;
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+create trigger t1_ai after insert on t1 for each row flush slave;
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+create trigger t1_ai after insert on t1 for each row flush master;
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+create trigger t1_ai after insert on t1 for each row flush des_key_file;
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+create trigger t1_ai after insert on t1 for each row flush user_resources;
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
create trigger t1_ai after insert on t1 for each row flush tables;
ERROR 0A000: FLUSH is not allowed in stored function or trigger
create trigger t1_ai after insert on t1 for each row flush privileges;
ERROR 0A000: FLUSH is not allowed in stored function or trigger
-create procedure p1() flush tables;
+drop procedure if exists p1;
create trigger t1_ai after insert on t1 for each row call p1();
+create procedure p1() flush tables;
+insert into t1 values (0);
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+drop procedure p1;
+create procedure p1() reset query cache;
+insert into t1 values (0);
+ERROR 0A000: RESET is not allowed in stored function or trigger
+drop procedure p1;
+create procedure p1() reset master;
+insert into t1 values (0);
+ERROR 0A000: RESET is not allowed in stored function or trigger
+drop procedure p1;
+create procedure p1() reset slave;
+insert into t1 values (0);
+ERROR 0A000: RESET is not allowed in stored function or trigger
+drop procedure p1;
+create procedure p1() flush hosts;
insert into t1 values (0);
ERROR 0A000: FLUSH is not allowed in stored function or trigger
drop procedure p1;
@@ -639,6 +678,38 @@ create procedure p1() flush privileges;
insert into t1 values (0);
ERROR 0A000: FLUSH is not allowed in stored function or trigger
drop procedure p1;
+create procedure p1() flush tables with read lock;
+insert into t1 values (0);
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+drop procedure p1;
+create procedure p1() flush tables;
+insert into t1 values (0);
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+drop procedure p1;
+create procedure p1() flush logs;
+insert into t1 values (0);
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+drop procedure p1;
+create procedure p1() flush status;
+insert into t1 values (0);
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+drop procedure p1;
+create procedure p1() flush slave;
+insert into t1 values (0);
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+drop procedure p1;
+create procedure p1() flush master;
+insert into t1 values (0);
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+drop procedure p1;
+create procedure p1() flush des_key_file;
+insert into t1 values (0);
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+drop procedure p1;
+create procedure p1() flush user_resources;
+insert into t1 values (0);
+ERROR 0A000: FLUSH is not allowed in stored function or trigger
+drop procedure p1;
drop table t1;
create table t1 (id int, data int, username varchar(16));
insert into t1 (id, data) values (1, 0);
@@ -1089,4 +1160,17 @@ begin
set @a:= 1;
end|
ERROR HY000: Triggers can not be created on system tables
+use test|
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+CREATE TABLE t1(c INT);
+CREATE TABLE t2(c INT);
+CREATE DEFINER=1234567890abcdefGHIKL@localhost
+TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1;
+ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16)
+CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY
+TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW SET @a = 2;
+ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60)
+DROP TABLE t1;
+DROP TABLE t2;
End of 5.0 tests
diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result
index 2281ed44e3f..f0ac00cedfa 100644
--- a/mysql-test/r/type_bit.result
+++ b/mysql-test/r/type_bit.result
@@ -572,4 +572,34 @@ def test t1 t1 a a 16 7 1 Y 0 0 63
a
`
drop table t1;
+create table bug15583(b BIT(8), n INT);
+insert into bug15583 values(128, 128);
+insert into bug15583 values(null, null);
+insert into bug15583 values(0, 0);
+insert into bug15583 values(255, 255);
+select hex(b), bin(b), oct(b), hex(n), bin(n), oct(n) from bug15583;
+hex(b) bin(b) oct(b) hex(n) bin(n) oct(n)
+80 10000000 200 80 10000000 200
+NULL NULL NULL NULL NULL NULL
+0 0 0 0 0 0
+FF 11111111 377 FF 11111111 377
+select hex(b)=hex(n) as should_be_onetrue, bin(b)=bin(n) as should_be_onetrue, oct(b)=oct(n) as should_be_onetrue from bug15583;
+should_be_onetrue should_be_onetrue should_be_onetrue
+1 1 1
+NULL NULL NULL
+1 1 1
+1 1 1
+select hex(b + 0), bin(b + 0), oct(b + 0), hex(n), bin(n), oct(n) from bug15583;
+hex(b + 0) bin(b + 0) oct(b + 0) hex(n) bin(n) oct(n)
+80 10000000 200 80 10000000 200
+NULL NULL NULL NULL NULL NULL
+0 0 0 0 0 0
+FF 11111111 377 FF 11111111 377
+select conv(b, 10, 2), conv(b + 0, 10, 2) from bug15583;
+conv(b, 10, 2) conv(b + 0, 10, 2)
+10000000 10000000
+NULL NULL
+0 0
+11111111 11111111
+drop table bug15583;
End of 5.0 tests
diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result
index 4fd220045c2..73b67a2241e 100644
--- a/mysql-test/r/type_blob.result
+++ b/mysql-test/r/type_blob.result
@@ -503,6 +503,8 @@ foobar boggle
fish 10
drop table t1;
create table t1 (id integer auto_increment unique,imagem LONGBLOB not null default '');
+Warnings:
+Warning 1101 BLOB/TEXT column 'imagem' can't have a default value
insert into t1 (id) values (1);
select
charset(load_file('../../std_data/words.dat')),
@@ -788,3 +790,21 @@ NULL
616100000000
620000000000
drop table t1;
+create table t1 (a text default '');
+Warnings:
+Warning 1101 BLOB/TEXT column 'a' can't have a default value
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` text
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+insert into t1 values (default);
+select * from t1;
+a
+NULL
+drop table t1;
+set @@sql_mode='TRADITIONAL';
+create table t1 (a text default '');
+ERROR 42000: BLOB/TEXT column 'a' can't have a default value
+set @@sql_mode='';
+End of 5.0 tests
diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result
index e88eebffb55..ed15293bb45 100644
--- a/mysql-test/r/type_date.result
+++ b/mysql-test/r/type_date.result
@@ -27,12 +27,12 @@ INSERT INTO t1 VALUES ( "2000-1-2" );
INSERT INTO t1 VALUES ( "2000-1-3" );
INSERT INTO t1 VALUES ( "2000-1-4" );
INSERT INTO t1 VALUES ( "2000-1-5" );
-SELECT * FROM t1 WHERE datum BETWEEN "2000-1-2" AND "2000-1-4";
+SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND cast("2000-1-4" as date);
datum
2000-01-02
2000-01-03
2000-01-04
-SELECT * FROM t1 WHERE datum BETWEEN "2000-1-2" AND datum - INTERVAL 100 DAY;
+SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND datum - INTERVAL 100 DAY;
datum
DROP TABLE t1;
CREATE TABLE t1 (
@@ -104,3 +104,9 @@ SELECT * FROM t1;
y
0000
DROP TABLE t1;
+create table t1(start_date date, end_date date);
+insert into t1 values ('2000-01-01','2000-01-02');
+select 1 from t1 where cast('2000-01-01 12:01:01' as datetime) between start_date and end_date;
+1
+1
+drop table t1;
diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result
index 85f899be5d8..49e4827cb97 100644
--- a/mysql-test/r/type_datetime.result
+++ b/mysql-test/r/type_datetime.result
@@ -26,6 +26,8 @@ Table Op Msg_type Msg_text
test.t1 check status OK
delete from t1;
insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959"),("20030100000000"),("20030000000000");
+Warnings:
+Warning 1264 Out of range value adjusted for column 't' at row 5
insert into t1 values ("2003-003-03");
insert into t1 values ("20030102T131415"),("2001-01-01T01:01:01"), ("2001-1-1T1:01:01");
select * from t1;
@@ -34,7 +36,7 @@ t
2069-12-31 00:00:00
1970-01-01 00:00:00
1999-12-31 00:00:00
-0000-01-01 00:00:00
+0000-00-00 00:00:00
0001-01-01 00:00:00
9999-12-31 00:00:00
2000-10-10 00:00:00
@@ -166,3 +168,14 @@ dt
0000-00-00 00:00:00
0000-00-00 00:00:00
drop table t1;
+CREATE TABLE t1(a DATETIME NOT NULL);
+INSERT INTO t1 VALUES ('20060606155555');
+SELECT a FROM t1 WHERE a=(SELECT MAX(a) FROM t1) AND (a="20060606155555");
+a
+2006-06-06 15:55:55
+PREPARE s FROM 'SELECT a FROM t1 WHERE a=(SELECT MAX(a) FROM t1) AND (a="20060606155555")';
+EXECUTE s;
+a
+2006-06-06 15:55:55
+DROP PREPARE s;
+DROP TABLE t1;
diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result
index 4caec152a1f..33f1ece0390 100644
--- a/mysql-test/r/type_newdecimal.result
+++ b/mysql-test/r/type_newdecimal.result
@@ -915,9 +915,13 @@ drop table t1;
select cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15));
cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15))
0.000000000100000
-select ln(14000) c1, convert(ln(14000),decimal(2,3)) c2, cast(ln(14000) as decimal(2,3)) c3;
+select ln(14000) c1, convert(ln(14000),decimal(5,3)) c2, cast(ln(14000) as decimal(5,3)) c3;
c1 c2 c3
9.5468126085974 9.547 9.547
+select convert(ln(14000),decimal(2,3)) c1;
+ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
+select cast(ln(14000) as decimal(2,3)) c1;
+ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
create table t1 (sl decimal(70,30));
ERROR 42000: Too big precision 70 specified for column 'sl'. Maximum is 65.
create table t1 (sl decimal(32,31));
diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result
index bd89c09e94d..e949d734944 100644
--- a/mysql-test/r/type_ranges.result
+++ b/mysql-test/r/type_ranges.result
@@ -38,6 +38,9 @@ KEY (ulong),
KEY (ulonglong,ulong),
KEY (options,flags)
);
+Warnings:
+Warning 1101 BLOB/TEXT column 'mediumblob_col' can't have a default value
+Warning 1101 BLOB/TEXT column 'longblob_col' can't have a default value
show full fields from t1;
Field Type Collation Null Key Default Extra Privileges Comment
auto int(5) unsigned NULL NO PRI NULL auto_increment #
@@ -54,7 +57,7 @@ ushort smallint(5) unsigned zerofill NULL NO MUL 00000 #
umedium mediumint(8) unsigned NULL NO MUL 0 #
ulong int(11) unsigned NULL NO MUL 0 #
ulonglong bigint(13) unsigned NULL NO MUL 0 #
-time_stamp timestamp NULL YES CURRENT_TIMESTAMP #
+time_stamp timestamp NULL NO CURRENT_TIMESTAMP #
date_field date NULL YES NULL #
time_field time NULL YES NULL #
date_time datetime NULL YES NULL #
@@ -226,7 +229,7 @@ ushort smallint(5) unsigned zerofill NULL NO 00000 #
umedium mediumint(8) unsigned NULL NO MUL 0 #
ulong int(11) unsigned NULL NO MUL 0 #
ulonglong bigint(13) unsigned NULL NO MUL 0 #
-time_stamp timestamp NULL YES CURRENT_TIMESTAMP #
+time_stamp timestamp NULL NO CURRENT_TIMESTAMP #
date_field char(10) latin1_swedish_ci YES NULL #
time_field time NULL YES NULL #
date_time datetime NULL YES NULL #
@@ -252,7 +255,7 @@ ushort smallint(5) unsigned zerofill NULL NO 00000 #
umedium mediumint(8) unsigned NULL NO 0 #
ulong int(11) unsigned NULL NO 0 #
ulonglong bigint(13) unsigned NULL NO 0 #
-time_stamp timestamp NULL YES 0000-00-00 00:00:00 #
+time_stamp timestamp NULL NO 0000-00-00 00:00:00 #
date_field char(10) latin1_swedish_ci YES NULL #
time_field time NULL YES NULL #
date_time datetime NULL YES NULL #
@@ -273,7 +276,7 @@ create table t2 (primary key (auto)) select auto+1 as auto,1 as t1, 'a' as t2, r
show full columns from t2;
Field Type Collation Null Key Default Extra Privileges Comment
auto bigint(12) unsigned NULL NO PRI 0 #
-t1 bigint(1) NULL NO 0 #
+t1 int(1) NULL NO 0 #
t2 varchar(1) latin1_swedish_ci NO #
t3 varchar(256) latin1_swedish_ci NO #
t4 varbinary(256) NULL NO #
@@ -301,7 +304,7 @@ show full columns from t3;
Field Type Collation Null Key Default Extra Privileges Comment
c1 int(11) NULL YES NULL #
c2 int(11) NULL YES NULL #
-const bigint(1) NULL NO 0 #
+const int(1) NULL NO 0 #
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_timestamp.result b/mysql-test/r/type_timestamp.result
index 0817cc3b6c7..445ada578d0 100644
--- a/mysql-test/r/type_timestamp.result
+++ b/mysql-test/r/type_timestamp.result
@@ -201,9 +201,9 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
show columns from t1;
Field Type Null Key Default Extra
-t1 timestamp YES 2003-01-01 00:00:00
+t1 timestamp NO 2003-01-01 00:00:00
t2 datetime YES NULL
-t3 timestamp YES 0000-00-00 00:00:00
+t3 timestamp NO 0000-00-00 00:00:00
drop table t1;
create table t1 (t1 timestamp default now(), t2 datetime, t3 timestamp);
SET TIMESTAMP=1000000002;
@@ -225,9 +225,9 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
show columns from t1;
Field Type Null Key Default Extra
-t1 timestamp YES CURRENT_TIMESTAMP
+t1 timestamp NO CURRENT_TIMESTAMP
t2 datetime YES NULL
-t3 timestamp YES 0000-00-00 00:00:00
+t3 timestamp NO 0000-00-00 00:00:00
drop table t1;
create table t1 (t1 timestamp default '2003-01-01 00:00:00' on update now(), t2 datetime);
SET TIMESTAMP=1000000004;
@@ -251,7 +251,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
show columns from t1;
Field Type Null Key Default Extra
-t1 timestamp YES 2003-01-01 00:00:00
+t1 timestamp NO 2003-01-01 00:00:00
t2 datetime YES NULL
drop table t1;
create table t1 (t1 timestamp default now() on update now(), t2 datetime);
@@ -276,7 +276,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
show columns from t1;
Field Type Null Key Default Extra
-t1 timestamp YES CURRENT_TIMESTAMP
+t1 timestamp NO CURRENT_TIMESTAMP
t2 datetime YES NULL
drop table t1;
create table t1 (t1 timestamp, t2 datetime, t3 timestamp);
@@ -302,9 +302,9 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
show columns from t1;
Field Type Null Key Default Extra
-t1 timestamp YES CURRENT_TIMESTAMP
+t1 timestamp NO CURRENT_TIMESTAMP
t2 datetime YES NULL
-t3 timestamp YES 0000-00-00 00:00:00
+t3 timestamp NO 0000-00-00 00:00:00
drop table t1;
create table t1 (t1 timestamp default current_timestamp on update current_timestamp, t2 datetime);
SET TIMESTAMP=1000000009;
@@ -328,7 +328,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
show columns from t1;
Field Type Null Key Default Extra
-t1 timestamp YES CURRENT_TIMESTAMP
+t1 timestamp NO CURRENT_TIMESTAMP
t2 datetime YES NULL
delete from t1;
insert into t1 values ('2004-04-01 00:00:00', '2004-04-01 00:00:00');
@@ -493,3 +493,18 @@ a b c
6 NULL 2006-06-06 06:06:06
drop table t1;
set time_zone= @@global.time_zone;
+CREATE TABLE t1 (
+`id` int(11) NOT NULL auto_increment,
+`username` varchar(80) NOT NULL default '',
+`posted_on` timestamp NOT NULL default '0000-00-00 00:00:00',
+PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
+show fields from t1;
+Field Type Null Key Default Extra
+id int(11) NO PRI NULL auto_increment
+username varchar(80) NO
+posted_on timestamp NO 0000-00-00 00:00:00
+select is_nullable from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='t1' and COLUMN_NAME='posted_on';
+is_nullable
+NO
+drop table t1;
diff --git a/mysql-test/r/type_varchar.result b/mysql-test/r/type_varchar.result
index e74850bba33..1d707b83a4d 100644
--- a/mysql-test/r/type_varchar.result
+++ b/mysql-test/r/type_varchar.result
@@ -422,3 +422,34 @@ DROP TABLE IF EXISTS t1;
CREATE TABLE t1(f1 CHAR(100) DEFAULT 'test');
INSERT INTO t1 VALUES(SUBSTR(f1, 1, 3));
DROP TABLE IF EXISTS t1;
+drop table if exists t1, t2, t3;
+create table t3 (
+id int(11),
+en varchar(255) character set utf8,
+cz varchar(255) character set utf8
+);
+truncate table t3;
+insert into t3 (id, en, cz) values
+(1,'en string 1','cz string 1'),
+(2,'en string 2','cz string 2'),
+(3,'en string 3','cz string 3');
+create table t1 (
+id int(11),
+name_id int(11)
+);
+insert into t1 (id, name_id) values (1,1), (2,3), (3,3);
+create table t2 (id int(11));
+insert into t2 (id) values (1), (2), (3);
+select t1.*, t2.id, t3.en, t3.cz from t1 left join t2 on t1.id=t2.id
+left join t3 on t1.id=t3.id order by t3.id;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def test t1 t1 id id 3 11 1 Y 32768 0 63
+def test t1 t1 name_id name_id 3 11 1 Y 32768 0 63
+def test t2 t2 id id 3 11 1 Y 32768 0 63
+def test t3 t3 en en 253 255 11 Y 0 0 8
+def test t3 t3 cz cz 253 255 11 Y 0 0 8
+id name_id id en cz
+1 1 1 en string 1 cz string 1
+2 3 2 en string 2 cz string 2
+3 3 3 en string 3 cz string 3
+drop table t1, t2, t3;
diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result
index 484c42c41bf..8e37cca6aa9 100644
--- a/mysql-test/r/udf.result
+++ b/mysql-test/r/udf.result
@@ -93,6 +93,18 @@ NULL
0R
FR
DROP TABLE bug19904;
+CREATE DEFINER=CURRENT_USER() FUNCTION should_not_parse
+RETURNS STRING SONAME "should_not_parse.so";
+ERROR HY000: Incorrect usage of SONAME and DEFINER
+CREATE DEFINER=someone@somewhere FUNCTION should_not_parse
+RETURNS STRING SONAME "should_not_parse.so";
+ERROR HY000: Incorrect usage of SONAME and DEFINER
+create table t1(f1 int);
+insert into t1 values(1),(2);
+explain select myfunc_int(f1) from t1 order by 1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
+drop table t1;
End of 5.0 tests.
DROP FUNCTION metaphon;
DROP FUNCTION myfunc_double;
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index 426387e04f5..12463658bf9 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -691,9 +691,9 @@ t1 CREATE TABLE `t1` (
`da` datetime default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
-create table t1 SELECT dt from t2 UNION select sc from t2;
-select * from t1;
-dt
+create table t1 SELECT dt from t2 UNION select trim(sc) from t2;
+select trim(dt) from t1;
+trim(dt)
1972-10-22 11:50:00
testc
show create table t1;
@@ -732,7 +732,7 @@ tetetetetest
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `dt` longblob
+ `dt` blob
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 SELECT sv from t2 UNION select b from t2;
@@ -743,7 +743,7 @@ tetetetetest
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `sv` longblob
+ `sv` blob
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 SELECT i from t2 UNION select d from t2 UNION select b from t2;
@@ -755,7 +755,7 @@ tetetetetest
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `i` longblob
+ `i` blob
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 SELECT sv from t2 UNION select tx from t2;
@@ -766,7 +766,7 @@ teeeeeeeeeeeest
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `sv` longtext
+ `sv` text
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
create table t1 SELECT b from t2 UNION select tx from t2;
@@ -777,7 +777,7 @@ teeeeeeeeeeeest
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `b` longblob
+ `b` blob
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1,t2;
create table t1 select 1 union select -1;
@@ -1306,6 +1306,21 @@ id
5
99
drop table t1;
+create table t1(f1 char(1), f2 char(5), f3 binary(1), f4 binary(5), f5 timestamp, f6 varchar(1) character set utf8 collate utf8_general_ci, f7 text);
+create table t2 as select *, f6 as f8 from t1 union select *, f7 from t1;
+show create table t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `f1` char(1) default NULL,
+ `f2` char(5) default NULL,
+ `f3` binary(1) default NULL,
+ `f4` binary(5) default NULL,
+ `f5` timestamp NOT NULL default '0000-00-00 00:00:00',
+ `f6` varchar(1) character set utf8 default NULL,
+ `f7` text,
+ `f8` mediumtext character set utf8
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1, t2;
(select avg(1)) union (select avg(1)) union (select avg(1)) union
(select avg(1)) union (select avg(1)) union (select avg(1)) union
(select avg(1)) union (select avg(1)) union (select avg(1)) union
@@ -1350,4 +1365,9 @@ drop table t1;
(select avg(1)) union (select avg(1)) union (select avg(1)) union
(select avg(1)) union (select avg(1)) union (select avg(1));
avg(1)
-NULL
+1.0000
+select _utf8'12' union select _latin1'12345';
+12
+12
+12345
+End of 5.0 tests
diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result
index 7439f9132fb..1664a907c99 100644
--- a/mysql-test/r/user_var.result
+++ b/mysql-test/r/user_var.result
@@ -256,3 +256,48 @@ t1 CREATE TABLE `t1` (
`@first_var` longtext
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
+set @a=18446744071710965857;
+select @a;
+@a
+18446744071710965857
+CREATE TABLE `bigfailure` (
+`afield` BIGINT UNSIGNED NOT NULL
+);
+INSERT INTO `bigfailure` VALUES (18446744071710965857);
+SELECT * FROM bigfailure;
+afield
+18446744071710965857
+select * from (SELECT afield FROM bigfailure) as b;
+afield
+18446744071710965857
+select * from bigfailure where afield = (SELECT afield FROM bigfailure);
+afield
+18446744071710965857
+select * from bigfailure where afield = 18446744071710965857;
+afield
+18446744071710965857
+select * from bigfailure where afield = 18446744071710965856+1;
+afield
+18446744071710965857
+SET @a := (SELECT afield FROM bigfailure);
+SELECT @a;
+@a
+18446744071710965857
+SET @a := (select afield from (SELECT afield FROM bigfailure) as b);
+SELECT @a;
+@a
+18446744071710965857
+SET @a := (select * from bigfailure where afield = (SELECT afield FROM bigfailure));
+SELECT @a;
+@a
+18446744071710965857
+drop table bigfailure;
+create table t1(f1 int, f2 int);
+insert into t1 values (1,2),(2,3),(3,1);
+select @var:=f2 from t1 group by f1 order by f2 desc limit 1;
+@var:=f2
+3
+select @var;
+@var
+3
+drop table t1;
diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result
index a0e516d2397..cd834a789bd 100644
--- a/mysql-test/r/variables.result
+++ b/mysql-test/r/variables.result
@@ -689,6 +689,12 @@ select @@log_queries_not_using_indexes;
show variables like 'log_queries_not_using_indexes';
Variable_name Value
log_queries_not_using_indexes OFF
+select @@"";
+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
+select @@&;
+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
+select @@@;
+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
End of 5.0 tests
set global binlog_cache_size =@my_binlog_cache_size;
set global connect_timeout =@my_connect_timeout;
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result
index 281cd473c2c..8ad2e62545b 100644
--- a/mysql-test/r/view.result
+++ b/mysql-test/r/view.result
@@ -49,7 +49,7 @@ select v1.b from v1;
ERROR 42S22: Unknown column 'v1.b' in 'field list'
explain extended select c from v1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5
Warnings:
Note 1003 select (`test`.`t1`.`b` + 1) AS `c` from `test`.`t1`
create algorithm=temptable view v2 (c) as select b+1 from t1;
@@ -83,7 +83,7 @@ c
12
explain extended select c from v3;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5
Warnings:
Note 1003 select ((`test`.`t1`.`b` + 1) + 1) AS `c` from `test`.`t1`
create algorithm=temptable view v4 (c) as select c+1 from v2;
@@ -193,7 +193,7 @@ c d
2 5
3 10
drop view v100;
-ERROR 42S02: Unknown table 'test.v100'
+ERROR 42S02: Unknown table 'v100'
drop view t1;
ERROR HY000: 'test.t1' is not VIEW
drop table v1;
@@ -376,7 +376,7 @@ c
30
explain extended select * from v1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
Warnings:
Note 1003 select `test`.`t1`.`b` AS `c` from `test`.`t1` where (`test`.`t1`.`a` < 3)
update v1 set c=c+1;
@@ -1391,9 +1391,9 @@ a a b
4 NULL NULL
explain extended select * from t3 left join v3 on (t3.a = v3.a);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 ALL NULL NULL NULL NULL 3
-1 PRIMARY t1 ALL NULL NULL NULL NULL 3
-1 PRIMARY t2 ALL NULL NULL NULL NULL 2
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2
Warnings:
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `b` from `test`.`t3` left join (`test`.`t1` left join `test`.`t2` on((`test`.`t1`.`a` = `test`.`t2`.`a`))) on((`test`.`t3`.`a` = `test`.`t1`.`a`)) where 1
create view v1 (a) as select a from t1;
@@ -1406,9 +1406,9 @@ a a b
4 NULL NULL
explain extended select * from t3 left join v4 on (t3.a = v4.a);
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t3 ALL NULL NULL NULL NULL 3
-1 PRIMARY t1 ALL NULL NULL NULL NULL 3
-1 PRIMARY t2 ALL NULL NULL NULL NULL 2
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2
Warnings:
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `b` from `test`.`t3` left join (`test`.`t1` left join (`test`.`t2`) on((`test`.`t1`.`a` = `test`.`t2`.`a`))) on((`test`.`t3`.`a` = `test`.`t1`.`a`)) where 1
prepare stmt1 from "select * from t3 left join v4 on (t3.a = v4.a);";
@@ -1495,7 +1495,7 @@ insert into v3(b) values (10);
insert into v3(a) select a from t2;
insert into v3(b) select b from t2;
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' at row 2
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'a' at row 2
insert into v3(a) values (1) on duplicate key update a=a+10000+VALUES(a);
select * from t1;
a b
@@ -2321,12 +2321,12 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref a a 10 const,test.t1.b 2 Using where; Using index
EXPLAIN SELECT * FROM v1 WHERE a=1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
-1 PRIMARY t2 ref a a 10 const,test.t1.b 2 Using where; Using index
+1 SIMPLE t1 ref a a 5 const 1 Using where; Using index
+1 SIMPLE t2 ref a a 10 const,test.t1.b 2 Using where; Using index
EXPLAIN SELECT * FROM v2 WHERE a=1;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
-1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where
+1 SIMPLE t1 ref a a 5 const 1 Using where; Using index
+1 SIMPLE t3 ALL NULL NULL NULL NULL 3 Using where
DROP VIEW v1,v2;
DROP TABLE t1,t2,t3;
create table t1 (f1 int);
@@ -2409,7 +2409,7 @@ insert into t1 values (1),(2);
create view v1 as select * from t1;
explain select id from v1 order by id;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 index NULL PRIMARY 4 NULL 2 Using index
+1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index
drop view v1;
drop table t1;
create table t1(f1 int, f2 int);
@@ -2480,7 +2480,7 @@ 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(a) FROM v1;
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
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
SELECT MIN(a) FROM t1;
MIN(a)
0
@@ -2492,7 +2492,7 @@ 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 MIN(a) FROM v1;
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
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 (x varchar(10));
@@ -2586,13 +2586,13 @@ INSERT INTO t1 VALUES
(4, '2005-01-03'), (5, '2005-01-04'), (6, '2005-01-05'),
(7, '2005-01-05'), (8, '2005-01-05'), (9, '2005-01-06');
CREATE VIEW v1 AS SELECT * FROM t1;
-SELECT * FROM t1 WHERE td BETWEEN '2005.01.02' AND '2005.01.04';
+SELECT * FROM t1 WHERE td BETWEEN CAST('2005.01.02' AS DATE) AND CAST('2005.01.04' AS DATE);
id td
2 2005-01-02
3 2005-01-02
4 2005-01-03
5 2005-01-04
-SELECT * FROM v1 WHERE td BETWEEN '2005.01.02' AND '2005.01.04';
+SELECT * FROM v1 WHERE td BETWEEN CAST('2005.01.02' AS DATE) AND CAST('2005.01.04' AS DATE);
id td
2 2005-01-02
3 2005-01-02
@@ -2735,4 +2735,204 @@ m e
4 a
1 b
DROP VIEW v1;
-DROP TABLE IF EXISTS t1,t2;
+DROP TABLE t1,t2;
+CREATE TABLE t1 (a INT NOT NULL, b INT NULL DEFAULT NULL);
+CREATE VIEW v1 AS SELECT a, b FROM t1;
+INSERT INTO v1 (b) VALUES (2);
+Warnings:
+Warning 1423 Field of view 'test.v1' underlying table doesn't have a default value
+SET SQL_MODE = STRICT_ALL_TABLES;
+INSERT INTO v1 (b) VALUES (4);
+ERROR HY000: Field of view 'test.v1' underlying table doesn't have a default value
+SET SQL_MODE = '';
+SELECT * FROM t1;
+a b
+0 2
+DROP VIEW v1;
+DROP TABLE t1;
+CREATE TABLE t1 (firstname text, surname text);
+INSERT INTO t1 VALUES
+("Bart","Simpson"),("Milhouse","van Houten"),("Montgomery","Burns");
+CREATE VIEW v1 AS SELECT CONCAT(firstname," ",surname) AS name FROM t1;
+SELECT CONCAT(LEFT(name,LENGTH(name)-INSTR(REVERSE(name)," ")),
+LEFT(name,LENGTH(name)-INSTR(REVERSE(name)," "))) AS f1
+FROM v1;
+f1
+BartBart
+Milhouse vanMilhouse van
+MontgomeryMontgomery
+DROP VIEW v1;
+DROP TABLE t1;
+CREATE TABLE t1 (i int, j int);
+CREATE VIEW v1 AS SELECT COALESCE(i,j) FROM t1;
+DESCRIBE v1;
+Field Type Null Key Default Extra
+COALESCE(i,j) int(11) YES NULL
+CREATE TABLE t2 SELECT COALESCE(i,j) FROM t1;
+DESCRIBE t2;
+Field Type Null Key Default Extra
+COALESCE(i,j) int(11) YES NULL
+DROP VIEW v1;
+DROP TABLE t1,t2;
+CREATE TABLE t1 (s varchar(10));
+INSERT INTO t1 VALUES ('yadda'), ('yady');
+SELECT TRIM(BOTH 'y' FROM s) FROM t1;
+TRIM(BOTH 'y' FROM s)
+adda
+ad
+CREATE VIEW v1 AS SELECT TRIM(BOTH 'y' FROM s) FROM t1;
+SELECT * FROM v1;
+TRIM(BOTH 'y' FROM s)
+adda
+ad
+DROP VIEW v1;
+SELECT TRIM(LEADING 'y' FROM s) FROM t1;
+TRIM(LEADING 'y' FROM s)
+adda
+ady
+CREATE VIEW v1 AS SELECT TRIM(LEADING 'y' FROM s) FROM t1;
+SELECT * FROM v1;
+TRIM(LEADING 'y' FROM s)
+adda
+ady
+DROP VIEW v1;
+SELECT TRIM(TRAILING 'y' FROM s) FROM t1;
+TRIM(TRAILING 'y' FROM s)
+yadda
+yad
+CREATE VIEW v1 AS SELECT TRIM(TRAILING 'y' FROM s) FROM t1;
+SELECT * FROM v1;
+TRIM(TRAILING 'y' FROM s)
+yadda
+yad
+DROP VIEW v1;
+DROP TABLE t1;
+CREATE TABLE t1 (x INT, y INT);
+CREATE ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
+SHOW CREATE VIEW v1;
+View Create View
+v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select `t1`.`x` AS `x` from `t1`
+ALTER VIEW v1 AS SELECT x, y FROM t1;
+SHOW CREATE VIEW v1;
+View Create View
+v1 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select `t1`.`x` AS `x`,`t1`.`y` AS `y` from `t1`
+DROP VIEW v1;
+DROP TABLE t1;
+CREATE TABLE t1 (s1 char);
+INSERT INTO t1 VALUES ('Z');
+CREATE VIEW v1 AS SELECT s1 collate latin1_german1_ci AS col FROM t1;
+CREATE VIEW v2 (col) AS SELECT s1 collate latin1_german1_ci FROM t1;
+INSERT INTO v1 (col) VALUES ('b');
+INSERT INTO v2 (col) VALUES ('c');
+SELECT s1 FROM t1;
+s1
+Z
+b
+c
+DROP VIEW v1, v2;
+DROP TABLE t1;
+CREATE TABLE t1 (id INT);
+CREATE VIEW v1 AS SELECT id FROM t1;
+SHOW TABLES;
+Tables_in_test
+t1
+v1
+DROP VIEW v2,v1;
+ERROR 42S02: Unknown table 'v2'
+SHOW TABLES;
+Tables_in_test
+t1
+CREATE VIEW v1 AS SELECT id FROM t1;
+DROP VIEW t1,v1;
+ERROR HY000: 'test.t1' is not VIEW
+SHOW TABLES;
+Tables_in_test
+t1
+DROP TABLE t1;
+DROP VIEW IF EXISTS v1;
+CREATE DATABASE bug21261DB;
+USE bug21261DB;
+CREATE TABLE t1 (x INT);
+CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
+GRANT INSERT, UPDATE ON v1 TO 'user21261'@'localhost';
+GRANT INSERT, UPDATE ON t1 TO 'user21261'@'localhost';
+CREATE TABLE t2 (y INT);
+GRANT SELECT ON t2 TO 'user21261'@'localhost';
+INSERT INTO v1 (x) VALUES (5);
+UPDATE v1 SET x=1;
+GRANT SELECT ON v1 TO 'user21261'@'localhost';
+GRANT SELECT ON t1 TO 'user21261'@'localhost';
+UPDATE v1,t2 SET x=1 WHERE x=y;
+SELECT * FROM t1;
+x
+1
+REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost';
+DROP USER 'user21261'@'localhost';
+DROP VIEW v1;
+DROP TABLE t1;
+DROP DATABASE bug21261DB;
+USE test;
+create table t1 (f1 datetime);
+create view v1 as select * from t1 where f1 between now() and now() + interval 1 minute;
+show create view v1;
+View Create View
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`f1` AS `f1` from `t1` where (`t1`.`f1` between now() and (now() + interval 1 minute))
+drop view v1;
+drop table t1;
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS v1;
+DROP VIEW IF EXISTS v2;
+CREATE TABLE t1(a INT, b INT);
+CREATE DEFINER=1234567890abcdefGHIKL@localhost
+VIEW v1 AS SELECT a FROM t1;
+ERROR HY000: String '1234567890abcdefGHIKL' is too long for user name (should be no longer than 16)
+CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY
+VIEW v2 AS SELECT b FROM t1;
+ERROR HY000: String '1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY' is too long for host name (should be no longer than 60)
+DROP TABLE t1;
+DROP FUNCTION IF EXISTS f1;
+DROP FUNCTION IF EXISTS f2;
+DROP VIEW IF EXISTS v1, v2;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (i INT);
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+INSERT INTO v1 VALUES (0);
+RETURN 0;
+END |
+SELECT f1();
+f1()
+0
+CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t1;
+CREATE FUNCTION f2() RETURNS INT
+BEGIN
+INSERT INTO v2 VALUES (0);
+RETURN 0;
+END |
+SELECT f2();
+ERROR HY000: The target table v2 of the INSERT is not updatable
+DROP FUNCTION f1;
+DROP FUNCTION f2;
+DROP VIEW v1, v2;
+DROP TABLE t1;
+CREATE TABLE t1 (s1 int);
+CREATE VIEW v1 AS SELECT * FROM t1;
+EXPLAIN SELECT * 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
+EXPLAIN SELECT * FROM v1;
+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), (3), (2);
+EXPLAIN SELECT * FROM t1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
+EXPLAIN SELECT * FROM v1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 3
+DROP VIEW v1;
+DROP TABLE t1;
+End of 5.0 tests.
diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result
index 7f63d790fb8..35e7afc0a7b 100644
--- a/mysql-test/r/view_grant.result
+++ b/mysql-test/r/view_grant.result
@@ -103,7 +103,7 @@ ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for tabl
grant select on mysqltest.t1 to mysqltest_1@localhost;
explain select c from mysqltest.v1;
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
+1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found
show create view mysqltest.v1;
ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for table 'v1'
explain select c from mysqltest.v2;
@@ -123,7 +123,7 @@ ERROR 42000: SHOW VIEW command denied to user 'mysqltest_1'@'localhost' for tabl
grant show view on mysqltest.* to mysqltest_1@localhost;
explain select c from mysqltest.v1;
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
+1 SIMPLE t1 system NULL NULL NULL NULL 0 const row not found
show create view mysqltest.v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v1` AS select (`mysqltest`.`t1`.`a` + 1) AS `c`,(`mysqltest`.`t1`.`b` + 1) AS `d` from `mysqltest`.`t1`
@@ -136,7 +136,7 @@ View Create View
v2 CREATE ALGORITHM=TEMPTABLE DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v2` AS select (`mysqltest`.`t1`.`a` + 1) AS `c`,(`mysqltest`.`t1`.`b` + 1) AS `d` from `mysqltest`.`t1`
explain select c from mysqltest.v3;
id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 system NULL NULL NULL NULL 0 const row not found
+1 SIMPLE t2 system NULL NULL NULL NULL 0 const row not found
show create view mysqltest.v3;
View Create View
v3 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `mysqltest`.`v3` AS select (`mysqltest`.`t2`.`a` + 1) AS `c`,(`mysqltest`.`t2`.`b` + 1) AS `d` from `mysqltest`.`t2`
diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result
index d66a26ec8c1..59a4a045355 100644
--- a/mysql-test/r/warnings.result
+++ b/mysql-test/r/warnings.result
@@ -72,7 +72,7 @@ drop table t1;
create table t1(a tinyint, b int not null, c date, d char(5));
load data infile '../std_data_ln/warnings_loaddata.dat' into table t1 fields terminated by ',';
Warnings:
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'b' at row 2
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'b' at row 2
Warning 1265 Data truncated for column 'd' at row 3
Warning 1265 Data truncated for column 'c' at row 4
Warning 1261 Row 5 doesn't contain data for all columns
@@ -86,7 +86,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 1263 Column set to default value; NULL supplied to NOT NULL column 'a' at row 1
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'a' at row 1
Warning 1264 Out of range value adjusted for column 'b' at row 2
Warning 1265 Data truncated for column 'c' at row 2
Warning 1264 Out of range value adjusted for column 'a' at row 3
@@ -99,7 +99,7 @@ Warning 1265 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 1263 Column set to default value; NULL supplied to NOT NULL column 'a' at row 2
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'a' at row 2
update t1 set c='mysql ab' where c='test';
Warnings:
Warning 1265 Data truncated for column 'c' at row 4
@@ -115,7 +115,7 @@ Warnings:
Warning 1265 Data truncated for column 'b' at row 1
Warning 1265 Data truncated for column 'b' at row 2
Warning 1265 Data truncated for column 'b' at row 3
-Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' at row 4
+Warning 1263 Column was set to data type implicit default; NULL supplied for NOT NULL column 'a' at row 4
Warning 1265 Data truncated for column 'b' at row 4
insert into t2(b) values('mysqlab');
Warnings:
@@ -173,6 +173,13 @@ alter table t1 engine=isam;
Warnings:
Warning 1266 Using storage engine MyISAM for table 't1'
drop table t1;
+create table t1 (id int) engine=merge;
+Warnings:
+Warning 1266 Using storage engine MyISAM for table 't1'
+alter table t1 engine=merge;
+Warnings:
+Warning 1266 Using storage engine MyISAM for table 't1'
+drop table t1;
create table t1 (id int) type=heap;
Warnings:
Warning 1287 'TYPE=storage_engine' is deprecated; use 'ENGINE=storage_engine' instead
diff --git a/mysql-test/std_data/14897.frm b/mysql-test/std_data/14897.frm
new file mode 100644
index 00000000000..aff11b467b0
--- /dev/null
+++ b/mysql-test/std_data/14897.frm
Binary files differ
diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test
index fbe1ee2b8c8..0e9e141f6d8 100644
--- a/mysql-test/t/case.test
+++ b/mysql-test/t/case.test
@@ -133,8 +133,6 @@ select min(a), min(case when 1=1 then a else NULL end),
from t1 where b=3 group by b;
drop table t1;
-# End of 4.1 tests
-
#
# Tests for bug #9939: conversion of the arguments for COALESCE and IFNULL
@@ -154,3 +152,4 @@ SELECT IFNULL(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM,
FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM;
DROP TABLE t1,t2;
+# End of 4.1 tests
diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test
index 533da542855..ecc92ed01d1 100644
--- a/mysql-test/t/cast.test
+++ b/mysql-test/t/cast.test
@@ -204,7 +204,19 @@ SELECT CAST(v AS DECIMAL), CAST(tt AS DECIMAL), CAST(t AS DECIMAL),
CAST(mt AS DECIMAL), CAST(lt AS DECIMAL) from t1;
DROP TABLE t1;
-# Bug @10237 (CAST(NULL DECIMAL) crashes server)
+
+#
+# Bug #10237 (CAST(NULL DECIMAL) crashes server)
#
select cast(NULL as decimal(6)) as t1;
+
+#
+# Bug #17903: cast to char results in binary
+#
+set names latin1;
+select hex(cast('a' as char(2) binary));
+select hex(cast('a' as binary(2)));
+select hex(cast('a' as char(2) binary));
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/compare.test b/mysql-test/t/compare.test
index a42ba5ac88a..337035a8095 100644
--- a/mysql-test/t/compare.test
+++ b/mysql-test/t/compare.test
@@ -37,3 +37,12 @@ SELECT CHAR(31) = '', '' = CHAR(31);
SELECT CHAR(30) = '', '' = CHAR(30);
# End of 4.1 tests
+
+#
+#Bug #21159: Optimizer: wrong result after AND with different data types
+#
+create table t1 (a tinyint(1),b binary(1));
+insert into t1 values (0x01,0x01);
+select * from t1 where a=b;
+select * from t1 where a=b and b=0x01;
+drop table if exists t1;
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index 07edbf206fe..db73782fdbf 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -674,4 +674,10 @@ create table t1(f1 varchar(800) binary not null, key(f1)) engine = innodb
insert into t1 values('aaa');
drop table t1;
+#
+# Bug#21772: can not name a column 'upgrade' when create a table
+#
+create table t1 (upgrade int);
+drop table t1;
+
# End of 5.0 tests
diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test
index a028f6ced6d..8bd48b7da2c 100644
--- a/mysql-test/t/csv.test
+++ b/mysql-test/t/csv.test
@@ -1384,3 +1384,27 @@ truncate table t1; -- truncate
--disable_info
drop table t1;
+#
+# Bug #15205 Select from CSV table without the datafile causes crash
+#
+# NOTE: the bug is not deterministic
+
+# The crash happens because the necessary cleanup after an error wasn't
+# performed. Namely, the table share, inserted in the hash during table
+# open, was not deleted from hash. At the same time the share was freed
+# when an error was encountered. Thus, subsequent access to the hash
+# resulted in scanning through deleted memory and we were geting a crash.
+# that's why we need two tables in the bugtest
+
+create table bug15205 (val int(11) default null) engine=csv;
+create table bug15205_2 (val int(11) default null) engine=csv;
+--exec rm $MYSQLTEST_VARDIR/master-data/test/bug15205.CSV
+# system error (can't open the datafile)
+--error ER_GET_ERRNO
+select * from bug15205;
+select * from bug15205_2;
+--exec touch $MYSQLTEST_VARDIR/master-data/test/bug15205.CSV
+select * from bug15205;
+drop table bug15205;
+drop table bug15205_2;
+
diff --git a/mysql-test/t/ctype_cp1250_ch.test b/mysql-test/t/ctype_cp1250_ch.test
index 2d1e5f0bf9d..65550e0c193 100644
--- a/mysql-test/t/ctype_cp1250_ch.test
+++ b/mysql-test/t/ctype_cp1250_ch.test
@@ -44,4 +44,14 @@ INSERT INTO t1 VALUES (NULL, 'aaaaaaa');
select * from t1 where str like 'aa%';
drop table t1;
+#
+# Bug#19741 segfault with cp1250 charset + like + primary key + 64bit os
+#
+set names cp1250;
+create table t1 (a varchar(15) collate cp1250_czech_cs NOT NULL, primary key(a));
+insert into t1 values("abcdefghá");
+insert into t1 values("ááèè");
+select a from t1 where a like "abcdefghá";
+drop table t1;
+
# End of 4.1 tests
diff --git a/mysql-test/t/ctype_gbk.test b/mysql-test/t/ctype_gbk.test
index 7aec48586d8..5ff138fa97b 100644
--- a/mysql-test/t/ctype_gbk.test
+++ b/mysql-test/t/ctype_gbk.test
@@ -42,3 +42,13 @@ DROP TABLE t1;
select hex(convert(_gbk 0xA14041 using ucs2));
# End of 4.1 tests
+
+#
+# Bug#21620 ALTER TABLE affects other columns
+#
+create table t1 (c1 text not null, c2 text not null) character set gbk;
+alter table t1 change c1 c1 mediumtext character set gbk not null;
+show create table t1;
+drop table t1;
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test
index 2d6b55600b1..c18c46b6b08 100644
--- a/mysql-test/t/ctype_recoding.test
+++ b/mysql-test/t/ctype_recoding.test
@@ -187,4 +187,16 @@ select rpad(c1,3,'ö'), rpad('ö',3,c1) from t1;
#select case c1 when 'ß' then 'ß' when 'ö' then 'ö' else 'c' end from t1;
#select export_set(5,c1,'ö'), export_set(5,'ö',c1) from t1;
drop table t1;
-# End of 4.1 tests
+
+#
+# Bug 20695: problem with field default value's character set
+#
+
+set names koi8r;
+create table t1(a char character set cp1251 default _koi8r 0xFF);
+show create table t1;
+drop table t1;
+--error 1067
+create table t1(a char character set latin1 default _cp1251 0xFF);
+
+--echo End of 4.1 tests
diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test
index eea0b06b224..8116d39e3db 100644
--- a/mysql-test/t/ctype_ucs.test
+++ b/mysql-test/t/ctype_ucs.test
@@ -465,7 +465,51 @@ INSERT INTO t1 VALUES (1, 'ZZZZZ'), (1, 'ZZZ'), (2, 'ZZZ'), (2, 'ZZZZZ');
SELECT id, MIN(s) FROM t1 GROUP BY id;
DROP TABLE t1;
-# End of 4.1 tests
+
+#
+# Bug #20536: md5() with GROUP BY and UCS2 return different results on myisam/innodb
+#
+
+--disable_warnings
+drop table if exists bug20536;
+--enable_warnings
+
+set names latin1;
+create table bug20536 (id bigint not null auto_increment primary key, name
+varchar(255) character set ucs2 not null);
+insert into `bug20536` (`id`,`name`) values (1, _latin1 x'7465737431'), (2, "'test\\_2'");
+select md5(name) from bug20536;
+select sha1(name) from bug20536;
+select make_set(3, name, upper(name)) from bug20536;
+select export_set(5, name, upper(name)) from bug20536;
+select export_set(5, name, upper(name), ",", 5) from bug20536;
+
+# Some broken functions: add these tests just to document current behavior.
+
+# PASSWORD and OLD_PASSWORD don't work with UCS2 strings, but to fix it would
+# not be backwards compatible in all cases, so it's best to leave it alone
+select password(name) from bug20536;
+select old_password(name) from bug20536;
+
+# Disable test case as encrypt relies on 'crypt' function.
+# "decrypt" is noramlly tested in func_crypt.test which have a
+# "have_crypt.inc" test
+--disable_parsing
+# ENCRYPT relies on OS function crypt() which takes a NUL-terminated string; it
+# doesn't return good results for strings with embedded 0 bytes. It won't be
+# fixed unless we choose to re-implement the crypt() function ourselves to take
+# an extra size_t string_length argument.
+select encrypt(name, 'SALT') from bug20536;
+--enable_parsing
+
+# QUOTE doesn't work with UCS2 data. It would require a total rewrite
+# of Item_func_quote::val_str(), which isn't worthwhile until UCS2 is
+# supported fully as a client character set.
+select quote(name) from bug20536;
+
+drop table bug20536;
+
+--echo End of 4.1 tests
#
# Conversion from an UCS2 string to a decimal column
@@ -497,3 +541,5 @@ create table t1(a blob, b text charset utf8, c text charset ucs2);
select data_type, character_octet_length, character_maximum_length
from information_schema.columns where table_name='t1';
drop table t1;
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test
index 77b76a14171..67ca6f45188 100644
--- a/mysql-test/t/ctype_utf8.test
+++ b/mysql-test/t/ctype_utf8.test
@@ -728,6 +728,24 @@ select repeat(_utf8'+',3) as h union select NULL;
select ifnull(NULL, _utf8'string');
#
+# Bug#9509 Optimizer: wrong result after AND with comparisons
+#
+set names utf8;
+create table t1 (s1 char(5) character set utf8 collate utf8_lithuanian_ci);
+insert into t1 values ('I'),('K'),('Y');
+select * from t1 where s1 < 'K' and s1 = 'Y';
+select * from t1 where 'K' > s1 and s1 = 'Y';
+drop table t1;
+
+create table t1 (s1 char(5) character set utf8 collate utf8_czech_ci);
+insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i');
+select * from t1 where s1 > 'd' and s1 = 'CH';
+select * from t1 where 'd' < s1 and s1 = 'CH';
+select * from t1 where s1 = 'cH' and s1 <> 'ch';
+select * from t1 where 'cH' = s1 and s1 <> 'ch';
+drop table t1;
+
+#
# Bug#10714: Inserting double value into utf8 column crashes server
#
create table t1 (a varchar(255)) default character set utf8;
@@ -879,6 +897,17 @@ DROP TABLE t2;
DROP TABLE t1;
#
+# Bug#17313: N'xxx' and _utf8'xxx' are not equivalent
+#
+CREATE TABLE t1 (item varchar(255)) default character set utf8;
+INSERT INTO t1 VALUES (N'\\');
+INSERT INTO t1 VALUES (_utf8'\\');
+INSERT INTO t1 VALUES (N'Cote d\'Ivoire');
+INSERT INTO t1 VALUES (_utf8'Cote d\'Ivoire');
+SELECT item FROM t1 ORDER BY item;
+DROP TABLE t1;
+
+#
# Bug#17705: Corruption of compressed index when index length changes between
# 254 and 256
#
@@ -1026,6 +1055,37 @@ ALTER TABLE t1 ADD KEY idx (tid,val(11));
SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNÝ ADSL';
DROP TABLE t1;
+
+#
+# Bug 20709: problem with utf8 fields in temporary tables
+#
+
+create table t1(a char(200) collate utf8_unicode_ci NOT NULL default '')
+ default charset=utf8 collate=utf8_unicode_ci;
+insert into t1 values (unhex('65')), (unhex('C3A9')), (unhex('65'));
+explain select distinct a from t1;
+select distinct a from t1;
+explain select a from t1 group by a;
+select a from t1 group by a;
+drop table t1;
+
+#
+# Bug#20393: User name truncation in mysql client
+# Bug#21432: Database/Table name limited to 64 bytes, not chars, problems with multi-byte
+#
+set names utf8;
+#create user юзер_юзер@localhost;
+grant select on test.* to юзер_юзер@localhost;
+--exec $MYSQL --default-character-set=utf8 --user=юзер_юзер -e "select user()"
+revoke all on test.* from юзер_юзер@localhost;
+drop user юзер_юзер@localhost;
+
+create database имÑ_базы_в_кодировке_утф8_длиной_больше_чем_45;
+use имÑ_базы_в_кодировке_утф8_длиной_больше_чем_45;
+select database();
+drop database имÑ_базы_в_кодировке_утф8_длиной_больше_чем_45;
+use test;
+
# End of 4.1 tests
#
@@ -1104,3 +1164,23 @@ execute my_stmt using @a;
set @a:=null;
execute my_stmt using @a;
drop table if exists t1;
+
+#
+# Bug#19960: Inconsistent results when joining
+# InnoDB tables using partial UTF8 indexes
+#
+CREATE TABLE t1 (
+ colA int(11) NOT NULL,
+ colB varchar(255) character set utf8 NOT NULL,
+ PRIMARY KEY (colA)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+INSERT INTO t1 (colA, colB) VALUES (1, 'foo'), (2, 'foo bar');
+CREATE TABLE t2 (
+ colA int(11) NOT NULL,
+ colB varchar(255) character set utf8 NOT NULL,
+ KEY bad (colA,colB(3))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar');
+SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB
+WHERE t1.colA < 3;
+DROP TABLE t1, t2;
diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test
index 21c228145ac..a81487d273d 100644
--- a/mysql-test/t/date_formats.test
+++ b/mysql-test/t/date_formats.test
@@ -290,7 +290,6 @@ drop table t1;
select str_to_date( 1, NULL );
select str_to_date( NULL, 1 );
select str_to_date( 1, IF(1=1,NULL,NULL) );
-# End of 4.1 tests
#
# Bug#11326
@@ -321,3 +320,10 @@ SELECT TIME_FORMAT("12:00:00", '%l %p');
SELECT TIME_FORMAT("23:00:00", '%l %p');
SELECT TIME_FORMAT("24:00:00", '%l %p');
SELECT TIME_FORMAT("25:00:00", '%l %p');
+
+#
+# Bug#20729: Bad date_format() call makes mysql server crash
+#
+SELECT DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896);
+
+--echo "End of 4.1 tests"
diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test
index 4284bd2a06d..865e1746fd3 100644
--- a/mysql-test/t/delete.test
+++ b/mysql-test/t/delete.test
@@ -153,6 +153,16 @@ DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a LIMIT 1;
SELECT * FROM t1;
DROP TABLE t1;
+#
+# Bug #21392: multi-table delete with alias table name fails with
+# 1003: Incorrect table name
+#
+
+create table t1 (a int);
+delete `4.t1` from t1 as `4.t1` where `4.t1`.a = 5;
+delete FROM `4.t1` USING t1 as `4.t1` where `4.t1`.a = 5;
+drop table t1;
+
# End of 4.1 tests
#
@@ -171,3 +181,14 @@ delete t2.*,t3.* from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b;
# This should be empty
select * from t3;
drop table t1,t2,t3;
+
+#
+# Bug #8143: deleting '0000-00-00' values using IS NULL
+#
+
+create table t1(a date not null);
+insert into t1 values (0);
+select * from t1 where a is null;
+delete from t1 where a is null;
+select count(*) from t1;
+drop table t1;
diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test
index 33b06e9bc11..3ad33dddcbe 100644
--- a/mysql-test/t/derived.test
+++ b/mysql-test/t/derived.test
@@ -157,7 +157,7 @@ UPDATE `t1` AS P1 INNER JOIN (SELECT aaaa FROM `t1` GROUP BY N HAVING Count(M) >
delete P1.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
select * from t1;
--replace_result P2 p2
---error 1288
+--error ER_UNKNOWN_TABLE
delete P1.*,P2.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
-- error 1054
delete P1.* from `t1` AS P1 INNER JOIN (SELECT aaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N;
diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test
index 61250a7105e..e517380ba9b 100644
--- a/mysql-test/t/distinct.test
+++ b/mysql-test/t/distinct.test
@@ -385,6 +385,17 @@ insert into t1 values (1, "line number one"), (2, "line number two"), (3, "line
select distinct id, IFNULL(dsc, '-') from t1;
drop table t1;
+#
+# Bug 21456: SELECT DISTINCT(x) produces incorrect results when using order by
+#
+CREATE TABLE t1 (a int primary key, b int);
+
+INSERT INTO t1 (a,b) values (1,1), (2,3), (3,2);
+
+explain SELECT DISTINCT a, b FROM t1 ORDER BY b;
+SELECT DISTINCT a, b FROM t1 ORDER BY b;
+DROP TABLE t1;
+
# End of 4.1 tests
diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test
index 7cd943d46da..a1451773e90 100644
--- a/mysql-test/t/drop.test
+++ b/mysql-test/t/drop.test
@@ -81,3 +81,44 @@ show tables;
drop table t1;
# End of 4.1 tests
+
+
+#
+# Test for bug#21216 "Simultaneous DROP TABLE and SHOW OPEN TABLES causes
+# server to crash". Crash (caused by failed assertion in 5.0 or by null
+# pointer dereference in 5.1) happened when one ran SHOW OPEN TABLES
+# while concurrently doing DROP TABLE (or RENAME TABLE, CREATE TABLE LIKE
+# or any other command that takes name-lock) in other connection.
+#
+# Also includes test for similar bug#12212 "Crash that happens during
+# removing of database name from cache" reappeared in 5.1 as bug#19403
+# In its case crash happened when one concurrently executed DROP DATABASE
+# and one of name-locking command.
+#
+--disable_warnings
+drop database if exists mysqltest;
+drop table if exists t1;
+--enable_warnings
+create table t1 (i int);
+lock tables t1 read;
+create database mysqltest;
+connect (addconroot1, localhost, root,,);
+--send drop table t1
+connect (addconroot2, localhost, root,,);
+# Server should not crash in any of the following statements
+--disable_result_log
+show open tables;
+--enable_result_log
+--send drop database mysqltest
+connection default;
+select 1;
+unlock tables;
+connection addconroot1;
+--reap
+connection addconroot2;
+--reap
+disconnect addconroot1;
+disconnect addconroot2;
+connection default;
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test
index 773c9121af0..c2218b3451b 100644
--- a/mysql-test/t/federated.test
+++ b/mysql-test/t/federated.test
@@ -1365,6 +1365,62 @@ drop table federated.t1, federated.t2;
connection slave;
drop table federated.t1, federated.t2;
+#
+# BUG #18764: Delete conditions causing inconsistencies in Federated tables
+#
+connection slave;
+--disable_warnings
+DROP TABLE IF EXISTS federated.test;
+--enable_warnings
+CREATE TABLE federated.test (
+ `id` int(11) NOT NULL,
+ `val1` varchar(255) NOT NULL,
+ `val2` varchar(255) NOT NULL,
+ PRIMARY KEY (`id`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+connection master;
+--disable_warnings
+DROP TABLE IF EXISTS federated.test_local;
+DROP TABLE IF EXISTS federated.test_remote;
+--enable_warnings
+CREATE TABLE federated.test_local (
+ `id` int(11) NOT NULL,
+ `val1` varchar(255) NOT NULL,
+ `val2` varchar(255) NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+INSERT INTO federated.test_local VALUES (1, 'foo', 'bar'),
+(2, 'bar', 'foo');
+
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+eval CREATE TABLE federated.test_remote (
+ `id` int(11) NOT NULL,
+ `val1` varchar(255) NOT NULL,
+ `val2` varchar(255) NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=FEDERATED DEFAULT CHARSET=latin1
+CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/test';
+
+insert into federated.test_remote select * from federated.test_local;
+
+select * from federated.test_remote;
+
+delete from federated.test_remote where id in (1,2);
+
+insert into federated.test_remote select * from federated.test_local;
+
+select * from federated.test_remote;
+--disable_warnings
+DROP TABLE federated.test_local;
+DROP TABLE federated.test_remote;
+--enable_warnings
+connection slave;
+--disable_warnings
+DROP TABLE federated.test;
+--enable_warnings
+
#
# Additional test for bug#18437 "Wrong values inserted with a before
# update trigger on NDB table". SQL-layer didn't properly inform
@@ -1425,4 +1481,67 @@ drop table t1;
connection master;
drop table t1;
+#
+# Bug #17608: String literals lost during INSERT query on FEDERATED table
+#
+connection slave;
+create table t1 (a longblob not null);
+connection master;
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+eval create table t1
+ (a longblob not null) engine=federated
+ connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/test/t1';
+insert into t1 values (repeat('a',5000));
+select length(a) from t1;
+connection slave;
+select length(a) from t1;
+drop table t1;
+connection master;
+drop table t1;
+
+#
+# BUG #15133: unique index with nullable value not accepted in federated table
+#
+
+connection slave;
+--disable_warnings
+DROP TABLE IF EXISTS federated.test;
+CREATE TABLE federated.test (
+ `i` int(11) NOT NULL,
+ `j` int(11) NOT NULL,
+ `c` varchar(30) default NULL,
+ PRIMARY KEY (`i`,`j`),
+ UNIQUE KEY `i` (`i`,`c`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+--enable_warnings
+
+connection master;
+--disable_warnings
+DROP TABLE IF EXISTS federated.test1;
+DROP TABLE IF EXISTS federated.test2;
+--enable_warnings
+
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+eval create table federated.test1 (
+ i int not null,
+ j int not null,
+ c varchar(30),
+ primary key (i,j),
+ unique key (i, c))
+engine = federated
+connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/test';
+
+--replace_result $SLAVE_MYPORT SLAVE_PORT
+eval create table federated.test2 (
+ i int default null,
+ j int not null,
+ c varchar(30),
+ key (i))
+engine = federated
+connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/test';
+drop table federated.test1, federated.test2;
+
+connection slave;
+drop table federated.test;
+
source include/federated_cleanup.inc;
diff --git a/mysql-test/t/func_compress.test b/mysql-test/t/func_compress.test
index 4ae749f2343..eeb5d509b94 100644
--- a/mysql-test/t/func_compress.test
+++ b/mysql-test/t/func_compress.test
@@ -57,3 +57,17 @@ select uncompress(a), uncompressed_length(a) from t1;
drop table t1;
# End of 4.1 tests
+
+#
+# Bug #18539: uncompress(d) is null: impossible?
+#
+create table t1 (a varchar(32) not null);
+insert into t1 values ('foo');
+explain select * from t1 where uncompress(a) is null;
+select * from t1 where uncompress(a) is null;
+explain select *, uncompress(a) from t1;
+select *, uncompress(a) from t1;
+select *, uncompress(a), uncompress(a) is null from t1;
+drop table t1;
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test
index fbfdfa3b5d0..98c21986aa9 100644
--- a/mysql-test/t/func_gconcat.test
+++ b/mysql-test/t/func_gconcat.test
@@ -433,3 +433,17 @@ create table t1 (c1 varchar(10), c2 int);
select charset(group_concat(c1 order by c2)) from t1;
drop table t1;
+#
+# Bug #16712: group_concat returns odd string instead of intended result
+#
+CREATE TABLE t1 (a INT(10), b LONGTEXT, PRIMARY KEY (a));
+
+SET GROUP_CONCAT_MAX_LEN = 20000000;
+
+INSERT INTO t1 VALUES (1,REPEAT(CONCAT('A',CAST(CHAR(0) AS BINARY),'B'), 40000));
+INSERT INTO t1 SELECT a + 1, b FROM t1;
+
+SELECT a, CHAR_LENGTH(b) FROM t1;
+SELECT CHAR_LENGTH( GROUP_CONCAT(b) ) FROM t1;
+SET GROUP_CONCAT_MAX_LEN = 1024;
+DROP TABLE t1;
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index e8c5fa18a25..079d107fad8 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -566,6 +566,19 @@ INSERT INTO t1 VALUES
SELECT MAX(b) FROM t1;
EXPLAIN SELECT MAX(b) FROM t1;
DROP TABLE t1;
+#
+# Bug #16792 query with subselect, join, and group not returning proper values
+#
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 VALUES (1,1),(1,2),(2,3);
+
+SELECT (SELECT COUNT(DISTINCT t1.b)) FROM t1 GROUP BY t1.a;
+SELECT (SELECT COUNT(DISTINCT 12)) FROM t1 GROUP BY t1.a;
+# an attempt to test all aggregate function with no table.
+SELECT AVG(2), BIT_AND(2), BIT_OR(2), BIT_XOR(2), COUNT(*), COUNT(12),
+ COUNT(DISTINCT 12), MIN(2),MAX(2),STD(2), VARIANCE(2),SUM(2),
+ GROUP_CONCAT(2),GROUP_CONCAT(DISTINCT 2);
+DROP TABLE t1;
# End of 4.1 tests
@@ -660,3 +673,30 @@ SELECT SUM(a) FROM t1 GROUP BY b/c;
DROP TABLE t1;
set div_precision_increment= @sav_dpi;
+#
+# Bug #20868: Client connection is broken on SQL query error
+#
+CREATE TABLE t1 (a INT PRIMARY KEY, b INT);
+INSERT INTO t1 VALUES (1,1), (2,2);
+
+CREATE TABLE t2 (a INT PRIMARY KEY, b INT);
+INSERT INTO t2 VALUES (1,1), (3,3);
+
+SELECT SQL_NO_CACHE
+ (SELECT SUM(c.a) FROM t1 ttt, t2 ccc
+ WHERE ttt.a = ccc.b AND ttt.a = t.a GROUP BY ttt.a) AS minid
+FROM t1 t, t2 c WHERE t.a = c.b;
+
+DROP TABLE t1,t2;
+
+#
+# Bug #10966: Variance functions return wrong data type
+#
+
+create table t1 select variance(0);
+show create table t1;
+drop table t1;
+create table t1 select stddev(0);
+show create table t1;
+drop table t1;
+
diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test
index 0475dd4bdb6..52a5512d070 100644
--- a/mysql-test/t/func_misc.test
+++ b/mysql-test/t/func_misc.test
@@ -78,7 +78,13 @@ connection default;
DROP TABLE t1;
-# End of 4.1 tests
+#
+# Bug #21531: EXPORT_SET() doesn't accept args with coercible character sets
+#
+select export_set(3, _latin1'foo', _utf8'bar', ',', 4);
+
+--echo End of 4.1 tests
+
#
# Test for BUG#9535
@@ -87,7 +93,9 @@ create table t1 as select uuid(), length(uuid());
show create table t1;
drop table t1;
+#
# Bug #6760: Add SLEEP() function
+#
create table t1 (a timestamp default '2005-05-05 01:01:01',
b timestamp default '2005-05-05 01:01:01');
insert into t1 set a = now();
@@ -117,4 +125,4 @@ drop table t2;
drop table t1;
set global query_cache_size=default;
-# End of 5.0 tests
+--echo End of 5.0 tests
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test
index 56a03283d3a..45415882ac7 100644
--- a/mysql-test/t/func_str.test
+++ b/mysql-test/t/func_str.test
@@ -690,6 +690,38 @@ select * from t1 where f1='test' and (f2= sha("test") or f2= sha("TEST"));
select * from t1 where f1='test' and (f2= sha("TEST") or f2= sha("test"));
drop table t1;
+#
+# Bug#18243: REVERSE changes its argument
+#
+
+CREATE TABLE t1 (a varchar(10));
+INSERT INTO t1 VALUES ('abc'), ('xyz');
+
+SELECT a, CONCAT(a,' ',a) AS c FROM t1
+ HAVING LEFT(c,LENGTH(c)-INSTR(REVERSE(c)," ")) = a;
+
+SELECT a, CONCAT(a,' ',a) AS c FROM t1
+ HAVING LEFT(CONCAT(a,' ',a),
+ LENGTH(CONCAT(a,' ',a))-
+ INSTR(REVERSE(CONCAT(a,' ',a))," ")) = a;
+
+DROP TABLE t1;
+
+#
+# Bug#17526: WRONG PRINT for TRIM FUNCTION with two arguments
+#
+
+CREATE TABLE t1 (s varchar(10));
+INSERT INTO t1 VALUES ('yadda'), ('yaddy');
+
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(s) > 'ab';
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM('y' FROM s) > 'ab';
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(LEADING 'y' FROM s) > 'ab';
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(TRAILING 'y' FROM s) > 'ab';
+EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(BOTH 'y' FROM s) > 'ab';
+
+DROP TABLE t1;
+
--echo End of 4.1 tests
#
@@ -721,4 +753,31 @@ select cast(rtrim(ltrim(' 20.06 ')) as decimal(19,2));
select conv("18383815659218730760",10,10) + 0;
select "18383815659218730760" + 0;
+#
+# Bug #21698: substitution of a string field for a constant under a function
+#
+
+CREATE TABLE t1 (code varchar(10));
+INSERT INTO t1 VALUES ('a12'), ('A12'), ('a13');
+
+SELECT ASCII(code), code FROM t1 WHERE code='A12';
+SELECT ASCII(code), code FROM t1 WHERE code='A12' AND ASCII(code)=65;
+
+INSERT INTO t1 VALUES ('a12 '), ('A12 ');
+
+SELECT LENGTH(code), code FROM t1 WHERE code='A12';
+SELECT LENGTH(code), code FROM t1 WHERE code='A12' AND LENGTH(code)=5;
+
+ALTER TABLE t1 ADD INDEX (code);
+CREATE TABLE t2 (id varchar(10) PRIMARY KEY);
+INSERT INTO t2 VALUES ('a11'), ('a12'), ('a13'), ('a14');
+
+SELECT * FROM t1 INNER JOIN t2 ON t1.code=t2.id
+ WHERE t2.id='a12' AND (LENGTH(code)=5 OR code < 'a00');
+EXPLAIN EXTENDED
+SELECT * FROM t1 INNER JOIN t2 ON code=id
+ WHERE id='a12' AND (LENGTH(code)=5 OR code < 'a00');
+
+DROP TABLE t1,t2;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/func_test.test b/mysql-test/t/func_test.test
index f2ff47704c9..0ea89cd0913 100644
--- a/mysql-test/t/func_test.test
+++ b/mysql-test/t/func_test.test
@@ -108,9 +108,6 @@ select 5.1 mod 3, 5.1 mod -3, -5.1 mod 3, -5.1 mod -3;
select 5 mod 3, 5 mod -3, -5 mod 3, -5 mod -3;
-# End of 4.1 tests
-
-#
# Bug#6726: NOT BETWEEN parse failure
#
create table t1 (a int, b int);
@@ -127,3 +124,5 @@ SELECT GREATEST(1,NULL) FROM DUAL;
SELECT LEAST('xxx','aaa',NULL,'yyy') FROM DUAL;
SELECT LEAST(1.1,1.2,NULL,1.0) FROM DUAL;
SELECT GREATEST(1.5E+2,1.3E+2,NULL) FROM DUAL;
+
+# End of 4.1 tests
diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test
index 188e5667009..7303be31e03 100644
--- a/mysql-test/t/func_time.test
+++ b/mysql-test/t/func_time.test
@@ -318,6 +318,37 @@ select timestampdiff(SQL_TSI_DAY, '1986-02-01', '1986-03-01') as a1,
timestampdiff(SQL_TSI_DAY, '1996-02-01', '1996-03-01') as a3,
timestampdiff(SQL_TSI_DAY, '2000-02-01', '2000-03-01') as a4;
+# bug 16226
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:27');
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:28');
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:29');
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:27');
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:28');
+SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:29');
+
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:27');
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:28');
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:29');
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:27');
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:28');
+SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:29');
+
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:27');
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:28');
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:29');
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:27');
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:28');
+SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:29');
+
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:27');
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:28');
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:29');
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:27');
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:28');
+SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29');
+
+# end of bug
+
select date_add(time,INTERVAL 1 SECOND) from t1;
drop table t1;
@@ -376,22 +407,32 @@ select monthname(str_to_date(null, '%m')), monthname(str_to_date(null, '%m')),
monthname(str_to_date(1, '%m')), monthname(str_to_date(0, '%m'));
#
+# Bug #16327: problem with timestamp < 1970
+#
+
+set time_zone='-6:00';
+create table t1(a timestamp);
+insert into t1 values (19691231190001);
+select * from t1;
+drop table t1;
+
+#
# Bug#16377 result of DATE/TIME functions were compared as strings which
# can lead to a wrong result.
-#
+# Now wrong dates should be compared only with CAST()
create table t1(f1 date, f2 time, f3 datetime);
insert into t1 values ("2006-01-01", "12:01:01", "2006-01-01 12:01:01");
insert into t1 values ("2006-01-02", "12:01:02", "2006-01-02 12:01:02");
-select f1 from t1 where f1 between "2006-1-1" and 20060101;
-select f1 from t1 where f1 between "2006-1-1" and "2006.1.1";
-select f1 from t1 where date(f1) between "2006-1-1" and "2006.1.1";
-select f2 from t1 where f2 between "12:1:2" and "12:2:2";
-select f2 from t1 where time(f2) between "12:1:2" and "12:2:2";
-select f3 from t1 where f3 between "2006-1-1 12:1:1" and "2006-1-1 12:1:2";
-select f3 from t1 where timestamp(f3) between "2006-1-1 12:1:1" and "2006-1-1 12:1:2";
-select f1 from t1 where "2006-1-1" between f1 and f3;
-select f1 from t1 where "2006-1-1" between date(f1) and date(f3);
-select f1 from t1 where "2006-1-1" between f1 and 'zzz';
+select f1 from t1 where f1 between CAST("2006-1-1" as date) and CAST(20060101 as date);
+select f1 from t1 where f1 between cast("2006-1-1" as date) and cast("2006.1.1" as date);
+select f1 from t1 where date(f1) between cast("2006-1-1" as date) and cast("2006.1.1" as date);
+select f2 from t1 where f2 between cast("12:1:2" as time) and cast("12:2:2" as time);
+select f2 from t1 where time(f2) between cast("12:1:2" as time) and cast("12:2:2" as time);
+select f3 from t1 where f3 between cast("2006-1-1 12:1:1" as datetime) and cast("2006-1-1 12:1:2" as datetime);
+select f3 from t1 where timestamp(f3) between cast("2006-1-1 12:1:1" as datetime) and cast("2006-1-1 12:1:2" as datetime);
+select f1 from t1 where cast("2006-1-1" as date) between f1 and f3;
+select f1 from t1 where cast("2006-1-1" as date) between date(f1) and date(f3);
+select f1 from t1 where cast("2006-1-1" as date) between f1 and cast('zzz' as date);
select f1 from t1 where makedate(2006,1) between date(f1) and date(f3);
select f1 from t1 where makedate(2006,2) between date(f1) and date(f3);
drop table t1;
@@ -405,7 +446,25 @@ create table t1 select now() - now(), curtime() - curtime(),
show create table t1;
drop table t1;
-# End of 4.1 tests
+#
+# Bug #19844 time_format in Union truncates values
+#
+
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H)
+union
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%H') As H);
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H)
+union
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 DAY)),'%k') As H);
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H)
+union
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%H') As H);
+
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H)
+union
+(select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H);
+
+--echo End of 4.1 tests
explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1,
timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2;
@@ -524,3 +583,21 @@ DROP TABLE t1,t2;
# Restore timezone to default
set time_zone= @@global.time_zone;
+
+#
+# 21913: DATE_FORMAT() Crashes mysql server if I use it through
+# mysql-connector-j driver.
+#
+
+SET NAMES latin1;
+SET character_set_results = NULL;
+SHOW VARIABLES LIKE 'character_set_results';
+
+CREATE TABLE testBug8868 (field1 DATE, field2 VARCHAR(32) CHARACTER SET BINARY);
+INSERT INTO testBug8868 VALUES ('2006-09-04', 'abcd');
+
+SELECT DATE_FORMAT(field1,'%b-%e %l:%i%p') as fmtddate, field2 FROM testBug8868;
+
+DROP TABLE testBug8868;
+
+SET NAMES DEFAULT;
diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test
index 4c6ff9b2fe7..7bba34be3ff 100644
--- a/mysql-test/t/gis.test
+++ b/mysql-test/t/gis.test
@@ -281,7 +281,7 @@ INSERT INTO t1 VALUES(GeomFromText('POINT(580848489 219587743)'));
INSERT INTO t1 VALUES(GeomFromText('POINT(11247614 782797569)'));
drop table t1;
-create table t1 select POINT(1,3);
+create table t1 select GeomFromWKB(POINT(1,3));
show create table t1;
drop table t1;
@@ -416,3 +416,9 @@ select * from t1;
select asbinary(g) from t1;
--disable_metadata
drop table t1;
+
+
+create table t1 select GeomFromText('point(1 1)');
+desc t1;
+drop table t1;
+
diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test
index a9d52f559ca..d3781d58780 100644
--- a/mysql-test/t/grant.test
+++ b/mysql-test/t/grant.test
@@ -362,6 +362,8 @@ revoke all on mysqltest_2.t2 from mysqltest_3@localhost;
#test the db/table level privileges
grant all on mysqltest_2.* to mysqltest_3@localhost;
grant select on *.* to mysqltest_3@localhost;
+# Next grant is needed to trigger bug#7391. Do not optimize!
+grant select on mysqltest_2.t1 to mysqltest_3@localhost;
flush privileges;
disconnect conn1;
connect (conn2,localhost,mysqltest_3,,);
@@ -680,4 +682,185 @@ drop table t2;
drop table t1;
+#
+# Bug#20214: Incorrect error when user calls SHOW CREATE VIEW on non
+# privileged view
+#
+
+connection master;
+
+CREATE DATABASE mysqltest3;
+use mysqltest3;
+
+CREATE TABLE t_nn (c1 INT);
+CREATE VIEW v_nn AS SELECT * FROM t_nn;
+
+CREATE DATABASE mysqltest2;
+use mysqltest2;
+
+CREATE TABLE t_nn (c1 INT);
+CREATE VIEW v_nn AS SELECT * FROM t_nn;
+CREATE VIEW v_yn AS SELECT * FROM t_nn;
+CREATE VIEW v_gy AS SELECT * FROM t_nn;
+CREATE VIEW v_ny AS SELECT * FROM t_nn;
+CREATE VIEW v_yy AS SELECT * FROM t_nn WHERE c1=55;
+
+GRANT SHOW VIEW ON mysqltest2.v_ny TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
+GRANT SELECT ON mysqltest2.v_yn TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
+GRANT SELECT ON mysqltest2.* TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
+GRANT SHOW VIEW,SELECT ON mysqltest2.v_yy TO 'mysqltest_1'@'localhost' IDENTIFIED BY 'mysqltest_1';
+
+connect (mysqltest_1, localhost, mysqltest_1, mysqltest_1,);
+
+# fail because of missing SHOW VIEW (have generic SELECT)
+--error ER_TABLEACCESS_DENIED_ERROR
+SHOW CREATE VIEW mysqltest2.v_nn;
+--error ER_TABLEACCESS_DENIED_ERROR
+SHOW CREATE TABLE mysqltest2.v_nn;
+
+
+
+# fail because of missing SHOW VIEW
+--error ER_TABLEACCESS_DENIED_ERROR
+SHOW CREATE VIEW mysqltest2.v_yn;
+--error ER_TABLEACCESS_DENIED_ERROR
+SHOW CREATE TABLE mysqltest2.v_yn;
+
+
+
+# succeed (despite of missing SELECT, having SHOW VIEW bails us out)
+SHOW CREATE TABLE mysqltest2.v_ny;
+
+# succeed (despite of missing SELECT, having SHOW VIEW bails us out)
+SHOW CREATE VIEW mysqltest2.v_ny;
+
+
+
+# fail because of missing (specific or generic) SELECT
+--error ER_TABLEACCESS_DENIED_ERROR
+SHOW CREATE TABLE mysqltest3.t_nn;
+
+# fail because of missing (specific or generic) SELECT (not because it's not a view!)
+--error ER_TABLEACCESS_DENIED_ERROR
+SHOW CREATE VIEW mysqltest3.t_nn;
+
+
+
+# fail because of missing missing (specific or generic) SELECT (and SHOW VIEW)
+--error ER_TABLEACCESS_DENIED_ERROR
+SHOW CREATE VIEW mysqltest3.v_nn;
+--error ER_TABLEACCESS_DENIED_ERROR
+SHOW CREATE TABLE mysqltest3.v_nn;
+
+
+
+# succeed thanks to generic SELECT
+SHOW CREATE TABLE mysqltest2.t_nn;
+
+# fail because it's not a view! (have generic SELECT though)
+--error ER_WRONG_OBJECT
+SHOW CREATE VIEW mysqltest2.t_nn;
+
+
+
+# succeed, have SELECT and SHOW VIEW
+SHOW CREATE VIEW mysqltest2.v_yy;
+
+# succeed, have SELECT and SHOW VIEW
+SHOW CREATE TABLE mysqltest2.v_yy;
+
+
+
+#clean-up
+connection master;
+
+# succeed, we're root
+SHOW CREATE TABLE mysqltest2.v_nn;
+SHOW CREATE VIEW mysqltest2.v_nn;
+
+SHOW CREATE TABLE mysqltest2.t_nn;
+
+# fail because it's not a view!
+--error ER_WRONG_OBJECT
+SHOW CREATE VIEW mysqltest2.t_nn;
+
+
+
+DROP VIEW mysqltest2.v_nn;
+DROP VIEW mysqltest2.v_yn;
+DROP VIEW mysqltest2.v_ny;
+DROP VIEW mysqltest2.v_yy;
+
+DROP TABLE mysqltest2.t_nn;
+
+DROP DATABASE mysqltest2;
+
+
+
+DROP VIEW mysqltest3.v_nn;
+DROP TABLE mysqltest3.t_nn;
+
+DROP DATABASE mysqltest3;
+
+REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'mysqltest_1'@'localhost';
+DROP USER 'mysqltest_1'@'localhost';
+
+# restore the original database
+use test;
+
+#
+# Bug #10668: CREATE USER does not enforce username length limit
+#
+--error ER_WRONG_STRING_LENGTH
+create user mysqltest1_thisisreallytoolong;
+
+#
+# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause.
+#
+# These checks are intended to ensure that appropriate errors are risen when
+# illegal user name or hostname is specified in user-clause of GRANT/REVOKE
+# statements.
+#
+
+# Working with database-level privileges.
+
+--error ER_WRONG_STRING_LENGTH
+GRANT CREATE ON mysqltest.* TO 1234567890abcdefGHIKL@localhost;
+
+--error ER_WRONG_STRING_LENGTH
+GRANT CREATE ON mysqltest.* TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+
+--error ER_WRONG_STRING_LENGTH
+REVOKE CREATE ON mysqltest.* FROM 1234567890abcdefGHIKL@localhost;
+
+--error ER_WRONG_STRING_LENGTH
+REVOKE CREATE ON mysqltest.* FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+
+# Working with table-level privileges.
+
+--error ER_WRONG_STRING_LENGTH
+GRANT CREATE ON t1 TO 1234567890abcdefGHIKL@localhost;
+
+--error ER_WRONG_STRING_LENGTH
+GRANT CREATE ON t1 TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+
+--error ER_WRONG_STRING_LENGTH
+REVOKE CREATE ON t1 FROM 1234567890abcdefGHIKL@localhost;
+
+--error ER_WRONG_STRING_LENGTH
+REVOKE CREATE ON t1 FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+
+# Working with routine-level privileges.
+
+--error ER_WRONG_STRING_LENGTH
+GRANT EXECUTE ON PROCEDURE p1 TO 1234567890abcdefGHIKL@localhost;
+
+--error ER_WRONG_STRING_LENGTH
+GRANT EXECUTE ON PROCEDURE p1 TO some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+
+--error ER_WRONG_STRING_LENGTH
+REVOKE EXECUTE ON PROCEDURE p1 FROM 1234567890abcdefGHIKL@localhost;
+--error ER_WRONG_STRING_LENGTH
+REVOKE EXECUTE ON PROCEDURE t1 FROM some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY;
+--echo End of 5.0 tests
diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test
index 2b9a273df7e..66128e56515 100644
--- a/mysql-test/t/grant2.test
+++ b/mysql-test/t/grant2.test
@@ -188,6 +188,24 @@ disconnect con9;
connection default;
#
+# Bug# 16180 - Setting SQL_LOG_OFF without SUPER privilege is silently ignored
+#
+create database mysqltest_1;
+grant select, insert, update on `mysqltest\_1`.* to mysqltest_1@localhost;
+connect (con10,localhost,mysqltest_1,,);
+connection con10;
+--error 1227
+set sql_log_off = 1;
+--error 1227
+set sql_log_bin = 0;
+disconnect con10;
+connection default;
+delete from mysql.user where user like 'mysqltest\_1';
+delete from mysql.db where user like 'mysqltest\_1';
+drop database mysqltest_1;
+flush privileges;
+
+# End of 4.1 tests
# Create and drop user
#
set sql_mode='maxdb';
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test
index fb9835c5d7f..8a514108dc3 100644
--- a/mysql-test/t/group_by.test
+++ b/mysql-test/t/group_by.test
@@ -632,3 +632,38 @@ group by t1.c1;
show warnings;
drop table t1, t2;
+#
+# Bug #20466: a view is mixing data when there's a trigger on the table
+#
+CREATE TABLE t1 (a tinyint(3), b varchar(255), PRIMARY KEY (a));
+
+INSERT INTO t1 VALUES (1,'-----'), (6,'Allemagne'), (17,'Autriche'),
+ (25,'Belgique'), (54,'Danemark'), (62,'Espagne'), (68,'France');
+
+CREATE TABLE t2 (a tinyint(3), b tinyint(3), PRIMARY KEY (a), KEY b (b));
+
+INSERT INTO t2 VALUES (1,1), (2,1), (6,6), (18,17), (15,25), (16,25),
+ (17,25), (10,54), (5,62),(3,68);
+
+CREATE VIEW v1 AS select t1.a, concat(t1.b,'') AS b, t1.b as real_b from t1;
+
+explain
+SELECT straight_join sql_no_cache v1.a, v1.b, v1.real_b from t2, v1
+where t2.b=v1.a GROUP BY t2.b;
+SELECT straight_join sql_no_cache v1.a, v1.b, v1.real_b from t2, v1
+where t2.b=v1.a GROUP BY t2.b;
+
+DROP VIEW v1;
+DROP TABLE t1,t2;
+
+#
+# Bug #21174: Index degrades sort performance and
+# optimizer does not honor IGNORE INDEX
+#
+CREATE TABLE t1 (a INT, b INT, KEY(a));
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3,3), (4,4);
+
+EXPLAIN SELECT a, SUM(b) FROM t1 GROUP BY a LIMIT 2;
+EXPLAIN SELECT a, SUM(b) FROM t1 IGNORE INDEX (a) GROUP BY a LIMIT 2;
+
+DROP TABLE t1;
diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test
index 874f3cd1a80..5427727a8f4 100644
--- a/mysql-test/t/group_min_max.test
+++ b/mysql-test/t/group_min_max.test
@@ -746,3 +746,51 @@ EXPLAIN SELECT DISTINCT a,a FROM t1 ORDER BY a;
SELECT DISTINCT a,a FROM t1 ORDER BY a;
DROP TABLE t1;
+
+#
+# Bug #21007: NATURAL JOIN (any JOIN (2 x NATURAL JOIN)) crashes the server
+#
+
+CREATE TABLE t1 (id1 INT, id2 INT);
+CREATE TABLE t2 (id2 INT, id3 INT, id5 INT);
+CREATE TABLE t3 (id3 INT, id4 INT);
+CREATE TABLE t4 (id4 INT);
+CREATE TABLE t5 (id5 INT, id6 INT);
+CREATE TABLE t6 (id6 INT);
+
+INSERT INTO t1 VALUES(1,1);
+INSERT INTO t2 VALUES(1,1,1);
+INSERT INTO t3 VALUES(1,1);
+INSERT INTO t4 VALUES(1);
+INSERT INTO t5 VALUES(1,1);
+INSERT INTO t6 VALUES(1);
+
+-- original bug query
+SELECT * FROM
+t1
+ NATURAL JOIN
+(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6)
+ ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5));
+
+-- inner join swapped
+SELECT * FROM
+t1
+ NATURAL JOIN
+(((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6) on t3.id4 = t5.id5) JOIN t2
+ ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5));
+
+-- one join less, no ON cond
+SELECT * FROM t1 NATURAL JOIN ((t3 join (t5 NATURAL JOIN t6)) JOIN t2);
+
+-- wrong error message: 'id2' - ambiguous column
+SELECT * FROM
+(t2 JOIN (t3 NATURAL JOIN t4, t5 NATURAL JOIN t6)
+ ON (t3.id3 = t2.id3 AND t5.id5 = t2.id5))
+ NATURAL JOIN
+t1;
+SELECT * FROM
+(t2 JOIN ((t3 NATURAL JOIN t4) join (t5 NATURAL JOIN t6)))
+ NATURAL JOIN
+t1;
+
+DROP TABLE t1,t2,t3,t4,t5,t6;
diff --git a/mysql-test/t/handler.test b/mysql-test/t/handler.test
index a7f1eeaa2cc..bf18b8da941 100644
--- a/mysql-test/t/handler.test
+++ b/mysql-test/t/handler.test
@@ -1,3 +1,4 @@
+-- source include/not_embedded.inc
#
# test of HANDLER ...
#
diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test
index fb715fccefe..03ba8661a3c 100644
--- a/mysql-test/t/heap_btree.test
+++ b/mysql-test/t/heap_btree.test
@@ -165,6 +165,26 @@ SELECT * from t1;
DROP TABLE t1;
#
+# Bug #9719: problem with delete
+#
+
+create table t1(a int not null, key using btree(a)) engine=heap;
+insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3);
+select a from t1 where a > 2 order by a;
+delete from t1 where a < 4;
+select a from t1 order by a;
+insert into t1 values (2), (2), (2), (1), (1), (3), (3), (3), (3);
+select a from t1 where a > 4 order by a;
+delete from t1 where a > 4;
+select a from t1 order by a;
+select a from t1 where a > 3 order by a;
+delete from t1 where a >= 2;
+select a from t1 order by a;
+drop table t1;
+
+--echo End of 4.1 tests
+
+#
# BUG#18160 - Memory-/HEAP Table endless growing indexes
#
CREATE TABLE t1(val INT, KEY USING BTREE(val)) ENGINE=memory;
@@ -184,4 +204,4 @@ CREATE TABLE t1 (a INT, UNIQUE USING BTREE(a)) ENGINE=MEMORY;
INSERT INTO t1 VALUES(NULL),(NULL);
DROP TABLE t1;
-# End of 4.1 tests
+--echo End of 5.0 tests
diff --git a/mysql-test/t/im_daemon_life_cycle.imtest b/mysql-test/t/im_daemon_life_cycle.imtest
index 3afc36935f8..a07da161279 100644
--- a/mysql-test/t/im_daemon_life_cycle.imtest
+++ b/mysql-test/t/im_daemon_life_cycle.imtest
@@ -6,22 +6,7 @@
#
###########################################################################
---source include/im_check_os.inc
-
-###########################################################################
-
-# Wait for mysqld1 (guarded instance) to start.
-
---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
-
-# Let IM detect that mysqld1 is online. This delay should be longer than
-# monitoring interval.
-
---sleep 3
-
-# Check that start conditions are as expected.
-
-SHOW INSTANCES;
+--source include/im_check_env.inc
###########################################################################
diff --git a/mysql-test/t/im_life_cycle.imtest b/mysql-test/t/im_life_cycle.imtest
index c3a5fb0a648..ddfb62d312e 100644
--- a/mysql-test/t/im_life_cycle.imtest
+++ b/mysql-test/t/im_life_cycle.imtest
@@ -6,34 +6,7 @@
#
###########################################################################
---source include/im_check_os.inc
-
-###########################################################################
-#
-# 1.1.1. Check that Instance Manager is able:
-# - to read definitions of two mysqld-instances;
-# - to start the first instance;
-# - to understand 'nonguarded' option and keep the second instance down;
-#
-###########################################################################
-
---echo
---echo --------------------------------------------------------------------
---echo -- 1.1.1.
---echo --------------------------------------------------------------------
-
-# Wait for mysqld1 (guarded instance) to start.
-
---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
-
-# Let IM detect that mysqld1 is online. This delay should be longer than
-# monitoring interval.
-
---sleep 3
-
-# Check that start conditions are as expected.
-
-SHOW INSTANCES;
+--source include/im_check_env.inc
###########################################################################
#
@@ -54,9 +27,10 @@ START INSTANCE mysqld2;
# FIXME: START INSTANCE should be synchronous.
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
-# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
-# synchronous. Even waiting for mysqld to start by looking at its pid file is
-# not enough, because IM may not detect that mysqld has started.
+# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
+# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
+# its pid file is not enough, because it is unknown when IM detects that
+# mysqld has started.
# SHOW INSTANCES;
--connect (mysql_con,localhost,root,,mysql,$IM_MYSQLD2_PORT,$IM_MYSQLD2_SOCK)
@@ -86,9 +60,10 @@ STOP INSTANCE mysqld2;
# FIXME: STOP INSTANCE should be synchronous.
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 stopped
-# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
-# synchronous. Even waiting for mysqld to start by looking at its pid file is
-# not enough, because IM may not detect that mysqld has started.
+# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
+# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
+# its pid file is not enough, because it is unknown when IM detects that
+# mysqld has started.
# SHOW INSTANCES;
###########################################################################
@@ -114,8 +89,8 @@ START INSTANCE mysqld1;
###########################################################################
#
-# 1.1.5. Check that Instance Manager reports correct errors for 'STOP INSTANCE'
-# command:
+# 1.1.5. Check that Instance Manager reports correct errors for
+# 'STOP INSTANCE' command:
# - if the client tries to start unregistered instance;
# - if the client tries to start already stopped instance;
# - if the client submits invalid arguments;
@@ -146,12 +121,10 @@ STOP INSTANCE mysqld3;
--echo -- 1.1.6.
--echo --------------------------------------------------------------------
-SHOW INSTANCES;
-
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD1_PATH_PID restarted 30
-# Give some time to IM to detect that mysqld was restarted. It should be longer
-# than monitoring interval.
+# Give some time to IM to detect that mysqld was restarted. It should be
+# longer than monitoring interval.
--sleep 3
@@ -172,16 +145,18 @@ START INSTANCE mysqld2;
# FIXME: START INSTANCE should be synchronous.
--exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD2_PATH_PID 30 started
-# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
-# synchronous. Even waiting for mysqld to start by looking at its pid file is
-# not enough, because IM may not detect that mysqld has started.
+# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
+# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
+# its pid file is not enough, because it is unknown when IM detects that
+# mysqld has started.
# SHOW INSTANCES;
--exec $MYSQL_TEST_DIR/t/kill_n_check.sh $IM_MYSQLD2_PATH_PID killed 10
-# FIXME: SHOW INSTANCES is not deterministic unless START INSTANCE is
-# synchronous. Even waiting for mysqld to start by looking at its pid file is
-# not enough, because IM may not detect that mysqld has started.
+# FIXME: Result of SHOW INSTANCES here is not deterministic unless START
+# INSTANCE is synchronous. Even waiting for mysqld to start by looking at
+# its pid file is not enough, because it is unknown when IM detects that
+# mysqld has started.
# SHOW INSTANCES;
###########################################################################
diff --git a/mysql-test/t/im_options_set.imtest b/mysql-test/t/im_options_set.imtest
index a9b64861f99..6a70c31c0a4 100644
--- a/mysql-test/t/im_options_set.imtest
+++ b/mysql-test/t/im_options_set.imtest
@@ -38,33 +38,7 @@
###########################################################################
---source include/im_check_os.inc
-
-###########################################################################
-#
-# 0. Check starting conditions.
-#
-###########################################################################
-
-# - check the configuration file;
-
---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ;
-
-# - check the running instances.
-
---connect (mysql1_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
-
---connection mysql1_con
-
-SHOW VARIABLES LIKE 'server_id';
-
---connection default
-
-# - check the internal cache.
-# TODO: we should check only server_id option here.
-
-# SHOW INSTANCE OPTIONS mysqld1;
-# SHOW INSTANCE OPTIONS mysqld2;
+--source include/im_check_env.inc
###########################################################################
#
diff --git a/mysql-test/t/im_options_unset.imtest b/mysql-test/t/im_options_unset.imtest
index 40629805d45..074c9a3b869 100644
--- a/mysql-test/t/im_options_unset.imtest
+++ b/mysql-test/t/im_options_unset.imtest
@@ -45,33 +45,7 @@
###########################################################################
---source include/im_check_os.inc
-
-###########################################################################
-#
-# 0. Check starting conditions.
-#
-###########################################################################
-
-# - check the configuration file;
-
---exec grep server_id $MYSQLTEST_VARDIR/im.cnf ;
-
-# - check the running instances.
-
---connect (mysql1_con,localhost,root,,mysql,$IM_MYSQLD1_PORT,$IM_MYSQLD1_SOCK)
-
---connection mysql1_con
-
-SHOW VARIABLES LIKE 'server_id';
-
---connection default
-
-# - check the internal cache.
-# TODO: we should check only server_id option here.
-
-# SHOW INSTANCE OPTIONS mysqld1;
-# SHOW INSTANCE OPTIONS mysqld2;
+--source include/im_check_env.inc
###########################################################################
#
diff --git a/mysql-test/t/im_utils.imtest b/mysql-test/t/im_utils.imtest
index 47902eeba52..52878f6c2b5 100644
--- a/mysql-test/t/im_utils.imtest
+++ b/mysql-test/t/im_utils.imtest
@@ -6,37 +6,17 @@
#
###########################################################################
---source include/im_check_os.inc
+--source include/im_check_env.inc
###########################################################################
#
-# Check starting conditions. This test case assumes that:
-# - two mysqld-instances are registered;
-# - the first instance is online;
-# - the second instance is offline;
+# Check 'SHOW INSTANCE OPTIONS' command.
#
-
-# Wait for mysqld1 (guarded instance) to start.
-
---exec $MYSQL_TEST_DIR/t/wait_for_process.sh $IM_MYSQLD1_PATH_PID 30 started
-
-# Let IM detect that mysqld1 is online. This delay should be longer than
-# monitoring interval.
-
---sleep 3
-
-# Check that start conditions are as expected.
-
-SHOW INSTANCES;
-
-#
-# Check 'SHOW INSTANCE OPTIONS' command:
-# - check that options of both offline and online instances are accessible;
-# - since configuration of an mysqld-instance contains directories, we should
-# completely ignore the second column (values) in order to make the test
-# case produce the same results on different installations;
-# TODO: ignore values of only directory-specific options.
+# Since configuration of an mysqld-instance contains directories, we should
+# completely ignore the second column (values) in order to make the test
+# case produce the same results on different installations;
+# TODO: ignore values of only directory-specific options.
#
--replace_column 2 VALUE
diff --git a/mysql-test/t/index_merge.test b/mysql-test/t/index_merge.test
index 3da5711bf7a..30eb0b40fca 100644
--- a/mysql-test/t/index_merge.test
+++ b/mysql-test/t/index_merge.test
@@ -383,3 +383,35 @@ explain select * from t3 where a=1 and b=1;
drop table t3;
drop table t0, t1, t2;
+
+#
+# BUG#20256 - LOCK WRITE - MyISAM
+#
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES(1);
+CREATE TABLE t2(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b));
+INSERT INTO t2(a,b) VALUES
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),
+(1,2);
+LOCK TABLES t1 WRITE, t2 WRITE;
+INSERT INTO t2(a,b) VALUES(1,2);
+SELECT t2.a FROM t1,t2 WHERE t2.b=2 AND t2.a=1;
+UNLOCK TABLES;
+DROP TABLE t1, t2;
diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test
index a2e19112cf9..9e5dac8b853 100644
--- a/mysql-test/t/information_schema.test
+++ b/mysql-test/t/information_schema.test
@@ -887,4 +887,47 @@ DROP FUNCTION f1;
DROP PROCEDURE p1;
DROP USER mysql_bug20230@localhost;
+#
+# Bug#18925: subqueries with MIN/MAX functions on INFORMARTION_SCHEMA
+#
+
+SELECT t.table_name, c1.column_name
+ FROM information_schema.tables t
+ INNER JOIN
+ information_schema.columns c1
+ ON t.table_schema = c1.table_schema AND
+ t.table_name = c1.table_name
+ WHERE t.table_schema = 'information_schema' AND
+ c1.ordinal_position =
+ ( SELECT COALESCE(MIN(c2.ordinal_position),1)
+ FROM information_schema.columns c2
+ WHERE c2.table_schema = t.table_schema AND
+ c2.table_name = t.table_name AND
+ c2.column_name LIKE '%SCHEMA%'
+ );
+SELECT t.table_name, c1.column_name
+ FROM information_schema.tables t
+ INNER JOIN
+ information_schema.columns c1
+ ON t.table_schema = c1.table_schema AND
+ t.table_name = c1.table_name
+ WHERE t.table_schema = 'information_schema' AND
+ c1.ordinal_position =
+ ( SELECT COALESCE(MIN(c2.ordinal_position),1)
+ FROM information_schema.columns c2
+ WHERE c2.table_schema = 'information_schema' AND
+ c2.table_name = t.table_name AND
+ c2.column_name LIKE '%SCHEMA%'
+ );
+
+#
+# Bug#21231: query with a simple non-correlated subquery over
+# INFORMARTION_SCHEMA.TABLES
+#
+
+SELECT MAX(table_name) FROM information_schema.tables;
+SELECT table_name from information_schema.tables
+ WHERE table_name=(SELECT MAX(table_name)
+ FROM information_schema.tables);
+
# End of 5.0 tests.
diff --git a/mysql-test/t/information_schema_db.test b/mysql-test/t/information_schema_db.test
index 2cfa766d799..4dfe1ad56b5 100644
--- a/mysql-test/t/information_schema_db.test
+++ b/mysql-test/t/information_schema_db.test
@@ -98,3 +98,60 @@ where table_schema='test';
drop function f1;
drop function f2;
drop view v1, v2;
+
+#
+# Bug#20543: select on information_schema strange warnings, view, different
+# schemas/users
+#
+#
+create database testdb_1;
+create user testdb_1@localhost;
+grant all on testdb_1.* to testdb_1@localhost with grant option;
+
+create user testdb_2@localhost;
+grant all on test.* to testdb_2@localhost with grant option;
+
+connect (testdb_1,localhost,testdb_1,,test);
+use testdb_1;
+create table t1 (f1 char(4));
+create view v1 as select f1 from t1;
+grant insert on v1 to testdb_2@localhost;
+
+create table t3 (f1 char(4), f2 char(4));
+create view v3 as select f1,f2 from t3;
+grant insert(f1), insert(f2) on v3 to testdb_2@localhost;
+
+connect (testdb_2,localhost,testdb_2,,test);
+create view v2 as select f1 from testdb_1.v1;
+create view v4 as select f1,f2 from testdb_1.v3;
+
+connection testdb_1;
+revoke insert(f1) on v3 from testdb_2@localhost;
+connection testdb_2;
+
+--error 1345
+show create view v4;
+--error 1345
+show fields from v4;
+
+show fields from v2;
+show fields from testdb_1.v1;
+show create view v2;
+--error 1142
+show create view testdb_1.v1;
+
+select table_name from information_schema.columns a
+where a.table_name = 'v2';
+select view_definition from information_schema.views a
+where a.table_name = 'v2';
+select view_definition from information_schema.views a
+where a.table_name = 'testdb_1.v1';
+
+--error 1356
+select * from v2;
+
+connection default;
+drop view testdb_1.v1,v2, testdb_1.v3, v4;
+drop database testdb_1;
+drop user testdb_1@localhost;
+drop user testdb_2@localhost;
diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test
index 71b178d0e57..0c083ccdfd3 100644
--- a/mysql-test/t/innodb.test
+++ b/mysql-test/t/innodb.test
@@ -1079,7 +1079,7 @@ drop table t1,t2,t3;
#
create table t1 (id int, name char(10) not null, name2 char(10) not null) engine=innodb;
insert into t1 values(1,'first','fff'),(2,'second','sss'),(3,'third','ttt');
-select name2 from t1 union all select name from t1 union all select id from t1;
+select trim(name2) from t1 union all select trim(name) from t1 union all select trim(id) from t1;
drop table t1;
#
diff --git a/mysql-test/t/innodb_mysql.test b/mysql-test/t/innodb_mysql.test
index c7d2e2c0acd..59dbe5e96d4 100644
--- a/mysql-test/t/innodb_mysql.test
+++ b/mysql-test/t/innodb_mysql.test
@@ -59,6 +59,65 @@ where
drop table t1, t2;
#
+# Bug#17212: results not sorted correctly by ORDER BY when using index
+# (repeatable only w/innodb because of index props)
+#
+CREATE TABLE t1 (a int, b int, KEY b (b)) Engine=InnoDB;
+CREATE TABLE t2 (a int, b int, PRIMARY KEY (a,b)) Engine=InnoDB;
+CREATE TABLE t3 (a int, b int, c int, PRIMARY KEY (a),
+ UNIQUE KEY b (b,c), KEY a (a,b,c)) Engine=InnoDB;
+
+INSERT INTO t1 VALUES (1, 1);
+INSERT INTO t1 SELECT a + 1, b + 1 FROM t1;
+INSERT INTO t1 SELECT a + 2, b + 2 FROM t1;
+
+INSERT INTO t2 VALUES (1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8);
+INSERT INTO t2 SELECT a + 1, b FROM t2;
+DELETE FROM t2 WHERE a = 1 AND b < 2;
+
+INSERT INTO t3 VALUES (1,1,1),(2,1,2);
+INSERT INTO t3 SELECT a + 2, a + 2, 3 FROM t3;
+INSERT INTO t3 SELECT a + 4, a + 4, 3 FROM t3;
+
+# demonstrate a problem when a must-use-sort table flag
+# (sort_by_table=1) is being neglected.
+SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
+ t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
+ ORDER BY t1.b LIMIT 2;
+
+# demonstrate the problem described in the bug report
+SELECT STRAIGHT_JOIN SQL_NO_CACHE t1.b, t1.a FROM t1, t3, t2 WHERE
+ t3.a = t2.a AND t2.b = t1.a AND t3.b = 1 AND t3.c IN (1, 2)
+ ORDER BY t1.b LIMIT 5;
+DROP TABLE t1, t2, t3;
+
+
+# BUG#21077 (The testcase is not deterministic so correct execution doesn't
+# prove anything) For proof one should track if sequence of ha_innodb::* func
+# calls is correct.
+CREATE TABLE `t1` (`id1` INT) ;
+INSERT INTO `t1` (`id1`) VALUES (1),(5),(2);
+
+CREATE TABLE `t2` (
+ `id1` INT,
+ `id2` INT NOT NULL,
+ `id3` INT,
+ `id4` INT NOT NULL,
+ UNIQUE (`id2`,`id4`),
+ KEY (`id1`)
+) ENGINE=InnoDB;
+
+INSERT INTO `t2`(`id1`,`id2`,`id3`,`id4`) VALUES
+(1,1,1,0),
+(1,1,2,1),
+(5,1,2,2),
+(6,1,2,3),
+(1,2,2,2),
+(1,2,1,1);
+
+SELECT `id1` FROM `t1` WHERE `id1` NOT IN (SELECT `id1` FROM `t2` WHERE `id2` = 1 AND `id3` = 2);
+DROP TABLE t1, t2;
+#
# Bug #12882 min/max inconsistent on empty table
#
@@ -223,3 +282,23 @@ explain select distinct f1 a, f1 b from t1;
explain select distinct f1, f2 from t1;
drop table t1;
+#
+# Test for bug #17164: ORed FALSE blocked conversion of outer join into join
+#
+
+CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20),
+ INDEX (name)) ENGINE=InnoDB;
+CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11),
+ FOREIGN KEY (fkey) REFERENCES t2(id)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B');
+INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3);
+
+EXPLAIN
+SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
+ WHERE t1.name LIKE 'A%';
+
+EXPLAIN
+SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
+ WHERE t1.name LIKE 'A%' OR FALSE;
+
+DROP TABLE t1,t2;
diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test
index 05953a1fd49..6f86ed897ac 100644
--- a/mysql-test/t/insert_select.test
+++ b/mysql-test/t/insert_select.test
@@ -247,3 +247,159 @@ CREATE TABLE t2 (z int, y int);
CREATE TABLE t3 (a int, b int);
INSERT INTO t3 (SELECT x, y FROM t1 JOIN t2 USING (y) WHERE z = 1);
DROP TABLE IF EXISTS t1,t2,t3;
+
+#
+# Bug #21774: Column count doesn't match value count at row x
+#
+CREATE DATABASE bug21774_1;
+CREATE DATABASE bug21774_2;
+
+CREATE TABLE bug21774_1.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
+CREATE TABLE bug21774_2.t1(id VARCHAR(10) NOT NULL,label VARCHAR(255));
+CREATE TABLE bug21774_1.t2(id VARCHAR(10) NOT NULL,label VARCHAR(255));
+
+INSERT INTO bug21774_2.t1 SELECT t1.* FROM bug21774_1.t1;
+
+use bug21774_1;
+INSERT INTO bug21774_2.t1 SELECT t1.* FROM t1;
+
+DROP DATABASE bug21774_1;
+DROP DATABASE bug21774_2;
+
+#
+# Bug #20989: View '(null).(null)' references invalid table(s)... on
+# SQL SECURITY INVOKER
+#
+# this is really the fact that REPLACE ... SELECT required additional
+# INSERT privs (on tables that are part of a view) over the related
+# REPLACE, SELECT
+#
+
+CREATE DATABASE meow;
+
+connect (root,localhost,root,,meow);
+connection root;
+
+CREATE TABLE table_target ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
+CREATE TABLE table_target2 ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
+CREATE TABLE table_target3 ( mexs_id CHAR(8), messzeit TIMESTAMP, PRIMARY KEY (mexs_id));
+CREATE VIEW view_target2 AS SELECT mexs_id,messzeit FROM table_target2;
+CREATE SQL SECURITY INVOKER VIEW view_target3 AS SELECT mexs_id,messzeit FROM table_target3;
+
+CREATE TABLE table_stations ( mexs_id VARCHAR(8), icao VARCHAR(4), country CHAR(2), PRIMARY KEY (mexs_id), UNIQUE KEY icao (icao), KEY country (country), CONSTRAINT stations_ibfk_8 FOREIGN KEY (country) REFERENCES countries (country) ON UPDATE CASCADE);
+INSERT INTO table_stations VALUES ('87654321','XXXX','YY');
+
+CREATE TABLE table_countries ( country CHAR(2), iso_short_en VARCHAR(64), PRIMARY KEY (country));
+INSERT INTO table_countries VALUES ('YY','Entenhausen');
+
+CREATE ALGORITHM=MERGE SQL SECURITY INVOKER VIEW view_stations AS select table_stations.mexs_id AS mexs_id, table_stations.icao AS icao, table_stations.country AS landescode from (table_stations join table_countries on((table_stations.country = table_countries.country)));
+
+CREATE TABLE table_source ( id varchar(4), datetime TIMESTAMP, PRIMARY KEY (id));
+INSERT INTO table_source VALUES ('XXXX','2006-07-12 07:50:00');
+
+GRANT SELECT ON table_source TO user20989@localhost;
+GRANT SELECT ON table_countries TO user20989@localhost;
+GRANT SELECT ON table_stations TO user20989@localhost;
+GRANT SELECT ON view_stations TO user20989@localhost;
+GRANT SELECT ON table_target TO user20989@localhost;
+GRANT SELECT ON table_target2 TO user20989@localhost;
+GRANT INSERT,DELETE,SELECT ON view_target3 TO user20989@localhost;
+
+connect (user20989,localhost,user20989,,meow);
+connection user20989;
+
+--error 1142
+REPLACE INTO table_target
+SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
+FROM table_source
+INNER JOIN view_stations AS stations
+ON table_source.id = stations.icao
+LEFT JOIN table_target AS old
+USING (mexs_id);
+
+--error 1142
+REPLACE INTO view_target2
+SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
+FROM table_source
+INNER JOIN view_stations AS stations
+ON table_source.id = stations.icao
+LEFT JOIN view_target2 AS old
+USING (mexs_id);
+
+--error 1356
+REPLACE INTO view_target3
+SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
+FROM table_source
+INNER JOIN view_stations AS stations
+ON table_source.id = stations.icao
+LEFT JOIN view_target3 AS old
+USING (mexs_id);
+
+connection root;
+disconnect user20989;
+
+GRANT INSERT,DELETE ON table_target TO user20989@localhost;
+GRANT INSERT,DELETE,SELECT ON view_target2 TO user20989@localhost;
+GRANT INSERT,DELETE,SELECT ON table_target3 TO user20989@localhost;
+
+connect (user20989,localhost,user20989,,meow);
+connection user20989;
+
+REPLACE INTO table_target
+SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
+FROM table_source
+INNER JOIN view_stations AS stations
+ON table_source.id = stations.icao
+LEFT JOIN table_target AS old
+USING (mexs_id);
+
+--error 1142
+REPLACE INTO table_target2 VALUES ('00X45Y78','2006-07-12 07:50:00');
+REPLACE INTO view_target2 VALUES ('12X45Y78','2006-07-12 07:50:00');
+
+SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
+FROM table_source
+INNER JOIN view_stations AS stations
+ON table_source.id = stations.icao
+LEFT JOIN view_target2 AS old
+USING (mexs_id);
+
+REPLACE INTO view_target2
+SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
+FROM table_source
+INNER JOIN view_stations AS stations
+ON table_source.id = stations.icao
+LEFT JOIN view_target2 AS old
+USING (mexs_id);
+
+REPLACE INTO view_target3
+SELECT stations.mexs_id AS mexs_id, datetime AS messzeit
+FROM table_source
+INNER JOIN view_stations AS stations
+ON table_source.id = stations.icao
+LEFT JOIN view_target3 AS old
+USING (mexs_id);
+
+connection root;
+disconnect user20989;
+
+SELECT * FROM table_target;
+SELECT * FROM view_target2;
+SELECT * FROM view_target3;
+
+DROP VIEW view_stations;
+DROP TABLE table_source;
+DROP TABLE table_countries;
+DROP TABLE table_stations;
+DROP TABLE table_target;
+DROP TABLE table_target2;
+DROP TABLE table_target3;
+DROP VIEW view_target2;
+DROP VIEW view_target3;
+DROP USER user20989@localhost;
+
+disconnect root;
+
+connection default;
+
+DROP DATABASE meow;
diff --git a/mysql-test/t/insert_update.test b/mysql-test/t/insert_update.test
index eda768be1bc..b3813864464 100644
--- a/mysql-test/t/insert_update.test
+++ b/mysql-test/t/insert_update.test
@@ -115,4 +115,27 @@ INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a) ;
DROP TABLE t1;
+#
+# Bug#21555: incorrect behavior with INSERT ... ON DUPL KEY UPDATE and VALUES
+#
+
+
# End of 4.1 tests
+CREATE TABLE t1
+(
+ a BIGINT UNSIGNED,
+ b BIGINT UNSIGNED,
+ PRIMARY KEY (a)
+);
+
+INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b =
+ IF(VALUES(b) > t1.b, VALUES(b), t1.b);
+SELECT * FROM t1;
+INSERT INTO t1 VALUES (45, 2) ON DUPLICATE KEY UPDATE b =
+ IF(VALUES(b) > t1.b, VALUES(b), t1.b);
+SELECT * FROM t1;
+INSERT INTO t1 VALUES (45, 1) ON DUPLICATE KEY UPDATE b =
+ IF(VALUES(b) > t1.b, VALUES(b), t1.b);
+SELECT * FROM t1;
+
+DROP TABLE t1;
diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test
index dc4e240750c..20462f2ca3f 100644
--- a/mysql-test/t/join_outer.test
+++ b/mysql-test/t/join_outer.test
@@ -760,27 +760,6 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t2 ON t1.a = t2.a WHERE t1.a > IF(t1.a = t2.b
DROP TABLE t1,t2;
#
-# Test for bug #17164: ORed FALSE blocked conversion of outer join into join
-#
-
-CREATE TABLE t1 (id int(11) NOT NULL PRIMARY KEY, name varchar(20),
- INDEX (name)) ENGINE=InnoDB;
-CREATE TABLE t2 (id int(11) NOT NULL PRIMARY KEY, fkey int(11),
- FOREIGN KEY (fkey) REFERENCES t2(id)) ENGINE=InnoDB;
-INSERT INTO t1 VALUES (1,'A1'),(2,'A2'),(3,'B');
-INSERT INTO t2 VALUES (1,1),(2,2),(3,2),(4,3),(5,3);
-
-EXPLAIN
-SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
- WHERE t1.name LIKE 'A%';
-
-EXPLAIN
-SELECT COUNT(*) FROM t2 LEFT JOIN t1 ON t2.fkey = t1.id
- WHERE t1.name LIKE 'A%' OR FALSE;
-
-DROP TABLE t1,t2;
-
-#
# Bug 19396: LEFT OUTER JOIN over views in curly braces
#
--disable_warnings
diff --git a/mysql-test/t/limit.test b/mysql-test/t/limit.test
index 6df865278f6..cf7789428b2 100644
--- a/mysql-test/t/limit.test
+++ b/mysql-test/t/limit.test
@@ -60,4 +60,14 @@ select 1 as a from t1 union all select 1 from dual limit 1;
(select 1 as a from t1) union all (select 1 from dual) limit 1;
drop table t1;
+#
+# Bug #21787: COUNT(*) + ORDER BY + LIMIT returns wrong result
+#
+create table t1 (a int);
+insert into t1 values (1),(2),(3),(4),(5),(6),(7);
+explain select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
+select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
+explain select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
+select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3;
+
# End of 4.1 tests
diff --git a/mysql-test/t/loaddata_autocom_innodb.test b/mysql-test/t/loaddata_autocom_innodb.test
new file mode 100644
index 00000000000..d7f152cb286
--- /dev/null
+++ b/mysql-test/t/loaddata_autocom_innodb.test
@@ -0,0 +1,4 @@
+--source include/have_innodb.inc
+let $engine_type= InnoDB;
+
+--source include/loaddata_autocom.inc
diff --git a/mysql-test/t/loaddata_autocom_ndb.test b/mysql-test/t/loaddata_autocom_ndb.test
new file mode 100644
index 00000000000..f4a6743aabe
--- /dev/null
+++ b/mysql-test/t/loaddata_autocom_ndb.test
@@ -0,0 +1,4 @@
+--source include/have_ndb.inc
+let $engine_type=ndbcluster;
+
+--source include/loaddata_autocom.inc
diff --git a/mysql-test/t/lowercase_fs_off.test b/mysql-test/t/lowercase_fs_off.test
new file mode 100644
index 00000000000..7f7b573e7ee
--- /dev/null
+++ b/mysql-test/t/lowercase_fs_off.test
@@ -0,0 +1,27 @@
+#
+# Specific tests for case sensitive file systems
+# i.e. lower_case_filesystem=OFF
+#
+-- source include/have_case_sensitive_file_system.inc
+
+connect (master,localhost,root,,);
+connection master;
+create database d1;
+grant all on d1.* to 'sample'@'localhost' identified by 'password';
+flush privileges;
+
+connect (sample,localhost,sample,password,d1);
+connection sample;
+select database();
+--error 1044
+create database d2;
+--error 1044
+create database D1;
+disconnect sample;
+
+connection master;
+drop database if exists d1;
+disconnect master;
+connection default;
+
+# End of 4.1 tests
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test
index 639129e1393..93fbc631680 100644
--- a/mysql-test/t/merge.test
+++ b/mysql-test/t/merge.test
@@ -389,4 +389,19 @@ create table tm (b bit(1)) engine = merge union = (t1,t2);
select * from tm;
drop table tm, t1, t2;
-# End of 5.0 tests
+#
+# Bug #17766: The server accepts to create MERGE tables which cannot work
+#
+create table t1 (a int) insert_method = last engine = merge;
+--error ER_OPEN_AS_READONLY
+insert into t1 values (1);
+create table t2 (a int) engine = myisam;
+alter table t1 union (t2);
+insert into t1 values (1);
+alter table t1 insert_method = no;
+--error ER_OPEN_AS_READONLY
+insert into t1 values (1);
+drop table t2;
+drop table t1;
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test
index 7dee5ebdf41..5ec4edea8c7 100644
--- a/mysql-test/t/myisam.test
+++ b/mysql-test/t/myisam.test
@@ -489,6 +489,42 @@ select c1 from t1 order by c1 limit 1;
drop table t1;
#
+# Bug #14400 Join could miss concurrently inserted row
+#
+# Partial key.
+create table t1 (a int not null, primary key(a));
+create table t2 (a int not null, b int not null, primary key(a,b));
+insert into t1 values (1),(2),(3),(4),(5),(6);
+insert into t2 values (1,1),(2,1);
+lock tables t1 read local, t2 read local;
+select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
+connect (root,localhost,root,,test,$MASTER_MYPORT,master.sock);
+insert into t2 values(2,0);
+disconnect root;
+connection default;
+select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
+drop table t1,t2;
+#
+# Full key.
+CREATE TABLE t1 (c1 varchar(250) NOT NULL);
+CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1));
+INSERT INTO t1 VALUES ('test000001'), ('test000002'), ('test000003');
+INSERT INTO t2 VALUES ('test000002'), ('test000003'), ('test000004');
+LOCK TABLES t1 READ LOCAL, t2 READ LOCAL;
+SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
+ WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
+connect (con1,localhost,root,,);
+connection con1;
+INSERT INTO t2 VALUES ('test000001'), ('test000005');
+disconnect con1;
+connection default;
+SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
+ WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
+DROP TABLE t1,t2;
+
+# End of 4.0 tests
+
+#
# Test RTREE index
#
--error 1235, 1289
diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test
index ac4c323f51e..9e3eabf474b 100644
--- a/mysql-test/t/mysql.test
+++ b/mysql-test/t/mysql.test
@@ -20,16 +20,16 @@ insert into t1 values(1);
--disable_query_log
# Test delimiter : supplied on the command line
-select "Test delimiter : from command line" as " ";
+select "Test delimiter : from command line" as "_";
--exec $MYSQL test --delimiter=":" -e "select * from t1:"
# Test delimiter :; supplied on the command line
-select "Test delimiter :; from command line" as " ";
+select "Test delimiter :; from command line" as "_";
--exec $MYSQL test --delimiter=":;" -e "select * from t1:;"
# Test 'go' command (vertical output) \G
-select "Test 'go' command(vertical output) \G" as " ";
+select "Test 'go' command(vertical output) \G" as "_";
--exec $MYSQL test -e "select * from t1\G"
# Test 'go' command \g
-select "Test 'go' command \g" as " ";
+select "Test 'go' command \g" as "_";
--exec $MYSQL test -e "select * from t1\g"
--enable_query_log
drop table t1;
@@ -52,8 +52,8 @@ drop table t1;
--exec $MYSQL --default-character-set=cp932 test -e "charset utf8;"
# its usage to switch internally in mysql to requested charset
---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; set @@session.character_set_client= cp932; select 'ƒ\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('ƒ\'); select * from t1; drop table t1;"
---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; set character_set_client= cp932; select 'ƒ\'"
+--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('ƒ\'); select * from t1; drop table t1;"
+--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'"
--exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select 'ƒ\'"
--exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select 'ƒ\'"
@@ -70,13 +70,81 @@ drop table t1;
#
# "DESCRIBE" commands may return strange NULLness flags.
#
+--exec $MYSQL --default-character-set utf8 test -e "create table t1 (i int, j int not null, k int); insert into t1 values (null, 1, null); select * from t1; describe t1; drop table t1;"
--exec $MYSQL -t --default-character-set utf8 test -e "create table t1 (i int, j int not null, k int); insert into t1 values (null, 1, null); select * from t1; describe t1; drop table t1;"
#
# Bug#19564: mysql displays NULL instead of space
#
+--exec $MYSQL test -e "create table b19564 (i int, s1 char(1)); insert into b19564 values (1, 'x'); insert into b19564 values (2, NULL); insert into b19564 values (3, ' '); select * from b19564 order by i; drop table b19564;"
--exec $MYSQL -t test -e "create table b19564 (i int, s1 char(1)); insert into b19564 values (1, 'x'); insert into b19564 values (2, NULL); insert into b19564 values (3, ' '); select * from b19564 order by i; drop table b19564;"
---echo End of 5.0 tests
+#
+# Bug#21618: NULL shown as empty string in client
+#
+--exec $MYSQL test -e "select unhex('zz');"
+--exec $MYSQL -t test -e "select unhex('zz');"
+
+# Bug#19265 describe command does not work from mysql prompt
+#
+
+create table t1(a int, b varchar(255), c int);
+--exec $MYSQL test -e "desc t1"
+--exec $MYSQL test -e "desc t1\g"
+drop table t1;
+--disable_parsing
+#
+# Bug#21042 mysql client segfaults on importing a mysqldump export
+#
+--error 1
+--exec $MYSQL test -e "connect verylongdatabasenamethatshouldblowthe256byteslongbufferincom_connectfunctionxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxendcccccccdxxxxxxxxxxxxxxxxxkskskskskkskskskskskskskskskskkskskskskkskskskskskskskskskend" 2>&1
+--enable_parsing
+
+
+#
+# Bug #20432: mysql client interprets commands in comments
+#
+# if the client sees the 'use' within the comment, we haven't fixed
+--exec echo "/*" > $MYSQLTEST_VARDIR/tmp/bug20432.sql
+--exec echo "use" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
+--exec echo "*/" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
+
+# SQL can have embedded comments => workie
+--exec echo "select /*" > $MYSQLTEST_VARDIR/tmp/bug20432.sql
+--exec echo "use" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
+--exec echo "*/ 1" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
+
+# client commands on the other hand must be at BOL => error
+--exec echo "/*" > $MYSQLTEST_VARDIR/tmp/bug20432.sql
+--exec echo "xxx" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
+--exec echo "*/ use" >> $MYSQLTEST_VARDIR/tmp/bug20432.sql
+--error 1
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
+
+# client comment recognized, but parameter missing => error
+--exec echo "use" > $MYSQLTEST_VARDIR/tmp/bug20432.sql
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20432.sql 2>&1
+
+#
+# Bug #20328: mysql client interprets commands in comments
+#
+--exec $MYSQL -e 'help' > $MYSQLTEST_VARDIR/tmp/bug20328_1.result
+--exec $MYSQL -e 'help ' > $MYSQLTEST_VARDIR/tmp/bug20328_2.result
+--exec diff $MYSQLTEST_VARDIR/tmp/bug20328_1.result $MYSQLTEST_VARDIR/tmp/bug20328_2.result
+
+#
+# Bug #20103: Escaping with backslash does not work
+#
+--exec echo "SET SQL_MODE = 'NO_BACKSLASH_ESCAPES';" > $MYSQLTEST_VARDIR/tmp/bug20103.sql
+--exec echo "SELECT '\';" >> $MYSQLTEST_VARDIR/tmp/bug20103.sql
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20103.sql 2>&1
+
+--exec echo "SET SQL_MODE = '';" > $MYSQLTEST_VARDIR/tmp/bug20103.sql
+--exec echo "SELECT '\';';" >> $MYSQLTEST_VARDIR/tmp/bug20103.sql
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20103.sql 2>&1
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/mysql_client_test.test b/mysql-test/t/mysql_client_test.test
index b61deeac001..66a27abd61a 100644
--- a/mysql-test/t/mysql_client_test.test
+++ b/mysql-test/t/mysql_client_test.test
@@ -8,8 +8,8 @@
# server or run mysql-test-run --debug mysql_client_test and check
# var/log/mysql_client_test.trace
---disable_result_log
---exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M
+--exec echo "$MYSQL_CLIENT_TEST" > $MYSQLTEST_VARDIR/log/mysql_client_test.log 2>&1
+--exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.log 2>&1
# End of 4.1 tests
echo ok;
diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test
index c2cd15c3f0f..0691cb7c76b 100644
--- a/mysql-test/t/mysqlbinlog.test
+++ b/mysql-test/t/mysqlbinlog.test
@@ -42,21 +42,21 @@ select "--- Local --" as "";
#
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000001
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/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 $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000002
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLTEST_VARDIR/log/master-bin.000002 2> /dev/null
# this should show almost nothing
--disable_query_log
select "--- --database --" as "";
--enable_query_log
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --database=nottest $MYSQLTEST_VARDIR/log/master-bin.000001
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --database=nottest $MYSQLTEST_VARDIR/log/master-bin.000001 2> /dev/null
# this test for position option
--disable_query_log
@@ -81,14 +81,14 @@ select "--- Remote --" as "";
select "--- Broken LOAD DATA --" as "";
--enable_query_log
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 2> /dev/null
# And this too ! (altough it is documented)
--disable_query_log
select "--- --database --" as "";
--enable_query_log
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --database=nottest master-bin.000001
+--exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --database=nottest master-bin.000001 2> /dev/null
# Strangely but this works
--disable_query_log
diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test
index bc88be001ab..338e16363ea 100644
--- a/mysql-test/t/mysqlcheck.test
+++ b/mysql-test/t/mysqlcheck.test
@@ -9,3 +9,17 @@
--replace_result 'Table is already up to date' OK
--exec $MYSQL_CHECK --analyze --optimize --databases test information_schema mysql
--exec $MYSQL_CHECK --analyze --optimize information_schema schemata
+
+#
+# Bug #16502: mysqlcheck tries to check views
+#
+create table t1 (a int);
+create view v1 as select * from t1;
+--replace_result 'Table is already up to date' OK
+--exec $MYSQL_CHECK --analyze --optimize --databases test
+--replace_result 'Table is already up to date' OK
+--exec $MYSQL_CHECK --all-in-1 --analyze --optimize --databases test
+drop view v1;
+drop table t1;
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index 858d8910781..6dfb24c2e75 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -16,9 +16,9 @@ INSERT INTO t1 VALUES (1), (2);
--exec $MYSQL_DUMP --skip-create --skip-comments -X test t1
DROP TABLE t1;
-#
-# Bug #2005
-#
+--echo #
+--echo # Bug #2005
+--echo #
CREATE TABLE t1 (a decimal(64, 20));
INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"),
@@ -26,9 +26,9 @@ INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"),
--exec $MYSQL_DUMP --compact test t1
DROP TABLE t1;
-#
-# Bug #2055
-#
+--echo #
+--echo # Bug #2055
+--echo #
CREATE TABLE t1 (a double);
INSERT INTO t1 VALUES ('-9e999999');
@@ -38,9 +38,9 @@ INSERT INTO t1 VALUES ('-9e999999');
--exec $MYSQL_DUMP --compact test t1
DROP TABLE t1;
-#
-# Bug #3361 mysqldump quotes DECIMAL values inconsistently
-#
+--echo #
+--echo # Bug #3361 mysqldump quotes DECIMAL values inconsistently
+--echo #
CREATE TABLE t1 (a DECIMAL(10,5), b FLOAT);
@@ -69,28 +69,28 @@ INSERT INTO t1 VALUES (1, "test", "tes"), (2, "TEST", "TES");
--exec $MYSQL_DUMP --skip-create --compact -X test t1
DROP TABLE t1;
-#
-# Bug #1707
-#
+--echo #
+--echo # Bug #1707
+--echo #
CREATE TABLE t1 (`a"b"` char(2));
INSERT INTO t1 VALUES ("1\""), ("\"2");
--exec $MYSQL_DUMP --compact --skip-create -X test t1
DROP TABLE t1;
-#
-# Bug #1994
-# Bug #4261
-#
+--echo #
+--echo # Bug #1994
+--echo # Bug #4261
+--echo #
CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET koi8r;
INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5'), (NULL);
--exec $MYSQL_DUMP --skip-comments --skip-extended-insert test t1
DROP TABLE t1;
-#
-# Bug #2634
-#
+--echo #
+--echo # Bug #2634
+--echo #
CREATE TABLE t1 (a int) ENGINE=MYISAM;
INSERT INTO t1 VALUES (1), (2);
@@ -98,17 +98,17 @@ INSERT INTO t1 VALUES (1), (2);
--exec $MYSQL_DUMP --skip-comments --compatible=mysql323 test t1
DROP TABLE t1;
-#
-# Bug #2592 'mysqldump doesn't quote "tricky" names correctly'
-#
+--echo #
+--echo # Bug #2592 'mysqldump doesn't quote "tricky" names correctly'
+--echo #
create table ```a` (i int);
--exec $MYSQL_DUMP --compact test
drop table ```a`;
-#
-# Bug #2591 "mysqldump quotes names inconsistently"
-#
+--echo #
+--echo # Bug #2591 "mysqldump quotes names inconsistently"
+--echo #
create table t1(a int);
--exec $MYSQL_DUMP --comments=0 test
@@ -119,9 +119,9 @@ set global sql_mode='ANSI_QUOTES';
set global sql_mode='';
drop table t1;
-#
-# Bug #2705 'mysqldump --tab extra output'
-#
+--echo #
+--echo # Bug #2705 'mysqldump --tab extra output'
+--echo #
create table t1(a int);
insert into t1 values (1),(2),(3);
@@ -135,9 +135,9 @@ insert into t1 values (1),(2),(3);
--exec rm $MYSQLTEST_VARDIR/tmp/t1.txt
drop table t1;
-#
-# Bug #6101: create database problem
-#
+--echo #
+--echo # Bug #6101: create database problem
+--echo #
--exec $MYSQL_DUMP --skip-comments --databases test
@@ -145,32 +145,34 @@ create database mysqldump_test_db character set latin2 collate latin2_bin;
--exec $MYSQL_DUMP --skip-comments --databases mysqldump_test_db
drop database mysqldump_test_db;
-#
-# Bug #7020
-# Check that we don't dump in UTF8 in compatible mode by default,
-# but use the default compiled values, or the values given in
-# --default-character-set=xxx. However, we should dump in UTF8
-# if it is explicitely set.
+--echo #
+--echo # Bug #7020
+--echo # Check that we don't dump in UTF8 in compatible mode by default,
+--echo # but use the default compiled values, or the values given in
+--echo # --default-character-set=xxx. However, we should dump in UTF8
+--echo # if it is explicitely set.
CREATE TABLE t1 (a CHAR(10));
INSERT INTO t1 VALUES (_latin1 'ÄÖÜß');
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments test t1
-#
-# Bug#8063: make test mysqldump [ fail ]
-# We cannot tes this command because its output depends
-# on --default-character-set incompiled into "mysqldump" program.
-# If the future we can move this command into a separate test with
-# checking that "mysqldump" is compiled with "latin1"
-#
+
+--echo #
+--echo # Bug#8063: make test mysqldump [ fail ]
+--echo # We cannot tes this command because its output depends
+--echo # on --default-character-set incompiled into "mysqldump" program.
+--echo # If the future we can move this command into a separate test with
+--echo # checking that "mysqldump" is compiled with "latin1"
+--echo #
+
#--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --compatible=mysql323 test t1
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --compatible=mysql323 --default-character-set=cp850 test t1
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=cp850 --compatible=mysql323 test t1
--exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=utf8 --compatible=mysql323 test t1
DROP TABLE t1;
-#
-# WL #2319: Exclude Tables from dump
-#
+--echo #
+--echo # WL #2319: Exclude Tables from dump
+--echo #
CREATE TABLE t1 (a int);
CREATE TABLE t2 (a int);
@@ -180,18 +182,18 @@ INSERT INTO t2 VALUES (4),(5),(6);
DROP TABLE t1;
DROP TABLE t2;
-#
-# Bug #8830
-#
+--echo #
+--echo # Bug #8830
+--echo #
CREATE TABLE t1 (`b` blob);
INSERT INTO `t1` VALUES (0x602010000280100005E71A);
--exec $MYSQL_DUMP --skip-extended-insert --hex-blob test --skip-comments t1
DROP TABLE t1;
-#
-# Test for --insert-ignore
-#
+--echo #
+--echo # Test for --insert-ignore
+--echo #
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1),(2),(3);
@@ -200,10 +202,10 @@ INSERT INTO t1 VALUES (4),(5),(6);
--exec $MYSQL_DUMP --skip-comments --insert-ignore --delayed-insert test t1
DROP TABLE t1;
-#
-# Bug #10286: mysqldump -c crashes on table that has many fields with long
-# names
-#
+--echo #
+--echo # Bug #10286: mysqldump -c crashes on table that has many fields with long
+--echo # names
+--echo #
create table t1 (
F_c4ca4238a0b923820dcc509a6f75849b int,
F_c81e728d9d4c2f636f067f89cc14862c int,
@@ -539,83 +541,18 @@ insert into t1 (F_8d3bba7425e7c98c50f52ca1b52d3735) values (1);
--exec $MYSQL_DUMP --skip-comments -c test
drop table t1;
-#
-# Test for --add-drop-database
-#
+--echo #
+--echo # Test for --add-drop-database
+--echo #
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1),(2),(3);
--exec $MYSQL_DUMP --add-drop-database --skip-comments --databases test
DROP TABLE t1;
-
-#
-# Bug #10213 mysqldump crashes when dumping VIEWs(on MacOS X)
-#
-
-create database db1;
-use db1;
-
-CREATE TABLE t2 (
- a varchar(30) default NULL,
- KEY a (a(5))
-);
-
-INSERT INTO t2 VALUES ('alfred');
-INSERT INTO t2 VALUES ('angie');
-INSERT INTO t2 VALUES ('bingo');
-INSERT INTO t2 VALUES ('waffle');
-INSERT INTO t2 VALUES ('lemon');
-create view v2 as select * from t2 where a like 'a%' with check option;
---exec $MYSQL_DUMP --skip-comments db1
-drop table t2;
-drop view v2;
-drop database db1;
-
-#
-# Bug 10713 mysqldump includes database in create view and referenced tables
-#
-
-# create table and views in db2
-create database db2;
-use db2;
-create table t1 (a int);
-create table t2 (a int, b varchar(10), primary key(a));
-insert into t2 values (1, "on"), (2, "off"), (10, "pol"), (12, "meg");
-insert into t1 values (289), (298), (234), (456), (789);
-create view v1 as select * from t2;
-create view v2 as select * from t1;
-
-# dump tables and view from db2
---exec $MYSQL_DUMP db2 > $MYSQLTEST_VARDIR/tmp/bug10713.sql
-
-# drop the db, tables and views
-drop table t1, t2;
-drop view v1, v2;
-drop database db2;
-
-# create db1 and reload dump
-create database db1;
-use db1;
---exec $MYSQL db1 < $MYSQLTEST_VARDIR/tmp/bug10713.sql
-
-# check that all tables and views could be created
-show tables;
-select * from t2 order by a;
-
-drop table t1, t2;
-drop database db1;
-
-#
-# BUG#15328 Segmentation fault occured if my.cnf is invalid for escape sequence
-#
-
---exec $MYSQL_MY_PRINT_DEFAULTS --defaults-file=$MYSQL_TEST_DIR/std_data/bug15328.cnf mysqldump
-
-
-#
-# Bug #9558 mysqldump --no-data db t1 t2 format still dumps data
-#
+--echo #
+--echo # Bug #9558 mysqldump --no-data db t1 t2 format still dumps data
+--echo #
CREATE DATABASE mysqldump_test_db;
USE mysqldump_test_db;
@@ -630,11 +567,11 @@ INSERT INTO t2 VALUES (1), (2);
DROP TABLE t1, t2;
DROP DATABASE mysqldump_test_db;
-#
-# Testing with tables and databases that don't exists
-# or contains illegal characters
-# (Bug #9358 mysqldump crashes if tablename starts with \)
-#
+--echo #
+--echo # Testing with tables and databases that don't exists
+--echo # or contains illegal characters
+--echo # (Bug #9358 mysqldump crashes if tablename starts with \)
+--echo #
create database mysqldump_test_db;
use mysqldump_test_db;
create table t1(a varchar(30) primary key, b int not null);
@@ -694,9 +631,9 @@ drop database mysqldump_test_db;
use test;
-#
-# Bug #9657 mysqldump xml ( -x ) does not format NULL fields correctly
-#
+--echo #
+--echo # Bug #9657 mysqldump xml ( -x ) does not format NULL fields correctly
+--echo #
create table t1 (a int(10));
create table t2 (pk int primary key auto_increment,
@@ -706,9 +643,10 @@ insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thir
--exec $MYSQL_DUMP --skip-comments --xml --no-create-info test
drop table t1, t2;
-#
-# BUG #12123
-#
+--echo #
+--echo # BUG #12123
+--echo #
+
create table t1 (a text character set utf8, b text character set latin1);
insert t1 values (0x4F736E616272C3BC636B, 0x4BF66C6E);
select * from t1;
@@ -719,9 +657,16 @@ select * from t1;
drop table t1;
-#
-# BUG #19025 mysqldump doesn't correctly dump "auto_increment = [int]"
-#
+--echo #
+--echo # BUG#15328 Segmentation fault occured if my.cnf is invalid for escape sequence
+--echo #
+
+--exec $MYSQL_MY_PRINT_DEFAULTS --config-file=$MYSQL_TEST_DIR/std_data/bug15328.cnf mysqldump
+
+--echo #
+--echo # BUG #19025 mysqldump doesn't correctly dump "auto_increment = [int]"
+--echo #
+
create table `t1` (
t1_name varchar(255) default null,
t1_id int(10) unsigned not null auto_increment,
@@ -748,8 +693,88 @@ show create table `t1`;
drop table `t1`;
+--echo #
+--echo # Bug #18536: wrong table order
+--echo #
+
+create table t1(a int);
+create table t2(a int);
+create table t3(a int);
+--error 6
+--exec $MYSQL_DUMP --skip-comments --force --no-data test t3 t1 non_existing t2
+drop table t1, t2, t3;
+
+--echo #
+--echo # Bug #21288: mysqldump segmentation fault when using --where
+--echo #
+
+create table t1 (a int);
+--error 2
+--exec $MYSQL_DUMP --skip-comments --force test t1 --where='xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 2>&1
+drop table t1;
+
--echo End of 4.1 tests
+--echo #
+--echo # Bug #10213 mysqldump crashes when dumping VIEWs(on MacOS X)
+--echo #
+
+create database db1;
+use db1;
+
+CREATE TABLE t2 (
+ a varchar(30) default NULL,
+ KEY a (a(5))
+);
+
+INSERT INTO t2 VALUES ('alfred');
+INSERT INTO t2 VALUES ('angie');
+INSERT INTO t2 VALUES ('bingo');
+INSERT INTO t2 VALUES ('waffle');
+INSERT INTO t2 VALUES ('lemon');
+create view v2 as select * from t2 where a like 'a%' with check option;
+--exec $MYSQL_DUMP --skip-comments db1
+drop table t2;
+drop view v2;
+drop database db1;
+use test;
+
+--echo #
+--echo # Bug 10713 mysqldump includes database in create view and referenced tables
+--echo #
+
+# create table and views in db2
+create database db2;
+use db2;
+create table t1 (a int);
+create table t2 (a int, b varchar(10), primary key(a));
+insert into t2 values (1, "on"), (2, "off"), (10, "pol"), (12, "meg");
+insert into t1 values (289), (298), (234), (456), (789);
+create view v1 as select * from t2;
+create view v2 as select * from t1;
+
+# dump tables and view from db2
+--exec $MYSQL_DUMP db2 > $MYSQLTEST_VARDIR/tmp/bug10713.sql
+
+# drop the db, tables and views
+drop table t1, t2;
+drop view v1, v2;
+drop database db2;
+use test;
+
+# create db1 and reload dump
+create database db1;
+use db1;
+--exec $MYSQL db1 < $MYSQLTEST_VARDIR/tmp/bug10713.sql
+
+# check that all tables and views could be created
+show tables;
+select * from t2 order by a;
+
+drop table t1, t2;
+drop database db1;
+use test;
+
#
# dump of view
#
@@ -759,9 +784,9 @@ create view v1 as select * from t1;
drop view v1;
drop table t1;
-#
-# Bug #10213 mysqldump crashes when dumping VIEWs(on MacOS X)
-#
+--echo #
+--echo # Bug #10213 mysqldump crashes when dumping VIEWs(on MacOS X)
+--echo #
create database mysqldump_test_db;
use mysqldump_test_db;
@@ -783,18 +808,18 @@ drop view v2;
drop database mysqldump_test_db;
use test;
-#
-# Bug #9756
-#
+--echo #
+--echo # Bug #9756
+--echo #
CREATE TABLE t1 (a char(10));
INSERT INTO t1 VALUES ('\'');
--exec $MYSQL_DUMP --skip-comments test t1
DROP TABLE t1;
-#
-# Bug #10927 mysqldump: Can't reload dump with view that consist of other view
-#
+--echo #
+--echo # Bug #10927 mysqldump: Can't reload dump with view that consist of other view
+--echo #
create table t1(a int, b int, c varchar(30));
@@ -813,9 +838,10 @@ select v3.a from v3, v1 where v1.a=v3.a and v3.b=3 limit 1;
drop view v1, v2, v3;
drop table t1;
-#
-# Test for dumping triggers
-#
+
+--echo #
+--echo # Test for dumping triggers
+--echo #
CREATE TABLE t1 (a int, b bigint default NULL);
CREATE TABLE t2 (a int);
@@ -863,9 +889,9 @@ show tables;
show triggers;
DROP TABLE t1, t2;
-#
-# Bugs #9136, #12917: problems with --defaults-extra-file option
-#
+--echo #
+--echo # Bugs #9136, #12917: problems with --defaults-extra-file option
+--echo #
--system echo '[mysqltest1]' > $MYSQLTEST_VARDIR/tmp/tmp.cnf
--system echo 'port=1234' >> $MYSQLTEST_VARDIR/tmp/tmp.cnf
@@ -873,9 +899,9 @@ DROP TABLE t1, t2;
--exec $MYSQL_MY_PRINT_DEFAULTS -e $MYSQLTEST_VARDIR/tmp/tmp.cnf mysqltest1 mysqltest1
--system rm $MYSQLTEST_VARDIR/tmp/tmp.cnf
-#
-# Test of fix to BUG 12597
-#
+--echo #
+--echo # Test of fix to BUG 12597
+--echo #
DROP TABLE IF EXISTS `test1`;
CREATE TABLE `test1` (
@@ -911,9 +937,9 @@ DROP TRIGGER testref;
DROP TABLE test1;
DROP TABLE test2;
-#
-# BUG#9056 - mysqldump does not dump routines
-#
+--echo #
+--echo # BUG#9056 - mysqldump does not dump routines
+--echo #
--disable_warnings
DROP TABLE IF EXISTS t1;
@@ -960,9 +986,10 @@ DROP PROCEDURE bug9056_proc2;
DROP PROCEDURE `a'b`;
drop table t1;
-#
-# BUG# 13052 - mysqldump timestamp reloads broken
-#
+--echo #
+--echo # BUG# 13052 - mysqldump timestamp reloads broken
+--echo #
+
--disable_warnings
drop table if exists t1;
--enable_warnings
@@ -982,9 +1009,10 @@ drop table t1;
set global time_zone=default;
set time_zone=default;
-#
-# Test of fix to BUG 13146 - ansi quotes break loading of triggers
-#
+--echo #
+--echo # Test of fix to BUG 13146 - ansi quotes break loading of triggers
+--echo #
+
--disable_warnings
DROP TABLE IF EXISTS `t1 test`;
DROP TABLE IF EXISTS `t2 test`;
@@ -1015,9 +1043,9 @@ DROP TRIGGER `test trig`;
DROP TABLE `t1 test`;
DROP TABLE `t2 test`;
-#
-# BUG# 12838 mysqldump -x with views exits with error
-#
+--echo #
+--echo # BUG# 12838 mysqldump -x with views exits with error
+--echo #
--disable_warnings
drop table if exists t1;
@@ -1039,10 +1067,10 @@ drop view v0;
drop view v1;
drop table t1;
-#
-# BUG#14554 - mysqldump does not separate words "ROW" and "BEGIN"
-# for tables with trigger created in the IGNORE_SPACE sql mode.
-#
+--echo #
+--echo # BUG#14554 - mysqldump does not separate words "ROW" and "BEGIN"
+--echo # for tables with trigger created in the IGNORE_SPACE sql mode.
+--echo #
SET @old_sql_mode = @@SQL_MODE;
SET SQL_MODE = IGNORE_SPACE;
@@ -1063,31 +1091,19 @@ SET SQL_MODE = @old_sql_mode;
DROP TRIGGER tr1;
DROP TABLE t1;
-#
-# Bug #13318: Bad result with empty field and --hex-blob
-#
+--echo #
+--echo # Bug #13318: Bad result with empty field and --hex-blob
+--echo #
+
create table t1 (a binary(1), b blob);
insert into t1 values ('','');
--exec $MYSQL_DUMP --skip-comments --skip-extended-insert --hex-blob test t1
--exec $MYSQL_DUMP --skip-comments --hex-blob test t1
drop table t1;
-#
-# Bug #18536: wrong table order
-#
-
-create table t1(a int);
-create table t2(a int);
-create table t3(a int);
---error 6
---exec $MYSQL_DUMP --skip-comments --force --no-data test t3 t1 non_existing t2
-drop table t1, t2, t3;
-
---echo End of 4.1 tests
-
-#
-# Bug 14871 Invalid view dump output
-#
+--echo #
+--echo # Bug 14871 Invalid view dump output
+--echo #
create table t1 (a int);
insert into t1 values (289), (298), (234), (456), (789);
@@ -1114,9 +1130,9 @@ select * from v3 order by a;
drop table t1;
drop view v1, v2, v3, v4, v5;
-#
-# Bug #16878 dump of trigger
-#
+--echo #
+--echo # Bug #16878 dump of trigger
+--echo #
create table t1 (a int, created datetime);
create table t2 (b int, created datetime);
@@ -1144,11 +1160,10 @@ drop trigger tr1;
drop trigger tr2;
drop table t1, t2;
+--echo #
+--echo # Bug#18462 mysqldump does not dump view structures correctly
+--echo #
-#
-# Bug#18462 mysqldump does not dump view structures correctly
-#
-#
create table t (qty int, price int);
insert into t values(3, 50);
insert into t values(5, 51);
@@ -1165,11 +1180,11 @@ drop view v2;
drop table t;
-#
-# Bug#14857 Reading dump files with single statement stored routines fails.
-# fixed by patch for bug#16878
-#
-#
+--echo #
+--echo # Bug#14857 Reading dump files with single statement stored routines fails.
+--echo # fixed by patch for bug#16878
+--echo #
+
DELIMITER |;
/*!50003 CREATE FUNCTION `f`() RETURNS bigint(20)
return 42 */|
@@ -1181,10 +1196,10 @@ show create procedure p;
drop function f;
drop procedure p;
-#
-# Bug #17371 Unable to dump a schema with invalid views
-#
-#
+--echo #
+--echo # Bug #17371 Unable to dump a schema with invalid views
+--echo #
+
create table t1 ( id serial );
create view v1 as select * from t1;
drop table t1;
@@ -1195,9 +1210,9 @@ drop table t1;
--echo } mysqldump
drop view v1;
-# BUG#17201 Spurious 'DROP DATABASE' in output,
-# also confusion between tables and views.
-# Example code from Markus Popp
+--echo # BUG#17201 Spurious 'DROP DATABASE' in output,
+--echo # also confusion between tables and views.
+--echo # Example code from Markus Popp
create database mysqldump_test_db;
use mysqldump_test_db;
@@ -1212,7 +1227,9 @@ drop view v1;
drop table t1;
drop database mysqldump_test_db;
-# Bug21014 Segmentation fault of mysqldump on view
+--echo #
+--echo # Bug21014 Segmentation fault of mysqldump on view
+--echo #
create database mysqldump_tables;
use mysqldump_tables;
@@ -1222,9 +1239,179 @@ create database mysqldump_views;
use mysqldump_views;
create view nasishnasifu as select mysqldump_tables.basetable.id from mysqldump_tables.basetable;
---exec $MYSQL_DUMP --skip-comments --databases mysqldump_tables mysqldump_views;
+--exec $MYSQL_DUMP --skip-comments --compact --databases mysqldump_tables mysqldump_views;
drop view nasishnasifu;
drop database mysqldump_views;
drop table mysqldump_tables.basetable;
drop database mysqldump_tables;
+
+--echo #
+--echo # Bug20221 Dumping of multiple databases containing view(s) yields maleformed dumps
+--echo #
+
+create database mysqldump_dba;
+use mysqldump_dba;
+create table t1 (f1 int, f2 int);
+insert into t1 values (1,1);
+create view v1 as select f1, f2 from t1;
+
+create database mysqldump_dbb;
+use mysqldump_dbb;
+create table t1 (f1 int, f2 int);
+insert into t1 values (2,2);
+create view v1 as select f1, f2 from t1;
+
+--exec $MYSQL_DUMP --skip-comments --add-drop-database --databases mysqldump_dba mysqldump_dbb > $MYSQLTEST_VARDIR/tmp/bug20221_backup;
+
+drop view v1;
+drop table t1;
+drop database mysqldump_dbb;
+use mysqldump_dba;
+drop view v1;
+drop table t1;
+drop database mysqldump_dba;
+
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20221_backup;
+
+select * from mysqldump_dba.v1;
+select * from mysqldump_dbb.v1;
+
+use mysqldump_dba;
+drop view v1;
+drop table t1;
+drop database mysqldump_dba;
+use mysqldump_dbb;
+drop view v1;
+drop table t1;
+drop database mysqldump_dbb;
+use test;
+
+--echo #
+--echo # Bug#21215 mysqldump creating incomplete backups without warning
+--echo #
+
+# Create user without sufficient privs to perform the requested operation
+create user mysqltest_1@localhost;
+create table t1(a int, b varchar(34));
+
+# To get consistent output, reset the master, starts over from first log
+reset master;
+
+# Execute mysqldump, will fail on FLUSH TABLES
+--error 2
+--exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1
+
+# Execute mysqldump, will fail on FLUSH TABLES
+# use --force, should no affect behaviour
+--error 2
+--exec $MYSQL_DUMP --compact --force --master-data -u mysqltest_1 test 2>&1
+
+# Add RELOAD grants
+grant RELOAD on *.* to mysqltest_1@localhost;
+
+# Execute mysqldump, will fail on SHOW MASTER STATUS
+--error 2
+--exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1
+
+# Execute mysqldump, will fail on SHOW MASTER STATUS.
+# use --force, should not alter behaviour
+--error 2
+--exec $MYSQL_DUMP --compact --force --master-data -u mysqltest_1 test 2>&1
+
+# Add REPLICATION CLIENT grants
+grant REPLICATION CLIENT on *.* to mysqltest_1@localhost;
+
+# Execute mysqldump, should now succeed
+--exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1
+
+# Clean up
+drop table t1;
+drop user mysqltest_1@localhost;
+
+--echo #
+--echo # Bug #21527 mysqldump incorrectly tries to LOCK TABLES on the
+--echo # information_schema database.
+--echo #
+--echo # Bug #21424 mysqldump failing to export/import views
+--echo #
+
+# Do as root
+connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
+connection root;
+create database mysqldump_myDB;
+use mysqldump_myDB;
+create user myDB_User;
+grant create, create view, select, insert on mysqldump_myDB.* to myDB_User@localhost;
+create table t1 (c1 int);
+insert into t1 values (3);
+
+# Do as a user
+connect (user1,localhost,myDB_User,,mysqldump_myDB,$MASTER_MYPORT,$MASTER_MYSOCK);
+connection user1;
+use mysqldump_myDB;
+create table u1 (f1 int);
+insert into u1 values (4);
+create view v1 (c1) as select * from t1;
+
+# Backup should not fail for Bug #21527. Flush priviliges test begins.
+--exec $MYSQL_DUMP --skip-comments --add-drop-table --flush-privileges --ignore-table=mysql.general_log --ignore-table=mysql.slow_log --databases mysqldump_myDB mysql > $MYSQLTEST_VARDIR/tmp/bug21527.sql
+
+# Clean up
+connection root;
+use mysqldump_myDB;
+drop view v1;
+drop table t1;
+drop table u1;
+revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
+drop user myDB_User;
+drop database mysqldump_myDB;
+flush privileges;
+
+--echo # Bug #21424 continues from here.
+--echo # Restore. Flush Privileges test ends.
+--echo #
+
+--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21527.sql;
+
+# Do as a user
+connection user1;
+use mysqldump_myDB;
+
+# Ultimate test for correct data.
+select * from mysqldump_myDB.v1;
+select * from mysqldump_myDB.u1;
+
+#Final cleanup.
+connection root;
+use mysqldump_myDB;
+drop view v1;
+drop table t1;
+drop table u1;
+revoke all privileges on mysqldump_myDB.* from myDB_User@localhost;
+drop user myDB_User;
+drop database mysqldump_myDB;
+use test;
+
+--echo #
+--echo # BUG#13926: --order-by-primary fails if PKEY contains quote character
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS `t1`;
+CREATE TABLE `t1` (
+ `a b` INT,
+ `c"d` INT,
+ `e``f` INT,
+ PRIMARY KEY (`a b`, `c"d`, `e``f`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+insert into t1 values (0815, 4711, 2006);
+
+--exec $MYSQL_DUMP --skip-comments --compatible=ansi --order-by-primary test t1
+--exec $MYSQL_DUMP --skip-comments --order-by-primary test t1
+DROP TABLE `t1`;
+--enable_warnings
+
+--echo #
+--echo # End of 5.0 tests
+--echo #
diff --git a/mysql-test/t/mysqlshow.test b/mysql-test/t/mysqlshow.test
index 78c4ae2b531..9ed93079f57 100644
--- a/mysql-test/t/mysqlshow.test
+++ b/mysql-test/t/mysqlshow.test
@@ -25,3 +25,12 @@ select "---- -v -t ---------" as "";
select "---- -v -v -t ------" as "";
--exec $MYSQL_SHOW test -v -v -t
DROP TABLE t1, t2;
+
+#
+# Bug #19147: mysqlshow INFORMATION_SCHEMA does not work
+#
+--exec $MYSQL_SHOW information_schema
+--exec $MYSQL_SHOW INFORMATION_SCHEMA
+--exec $MYSQL_SHOW inf_rmation_schema
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test
index 3968eb519e1..6a0b805f43b 100644
--- a/mysql-test/t/mysqltest.test
+++ b/mysql-test/t/mysqltest.test
@@ -1125,3 +1125,18 @@ drop table t1;
drop table t1;
+#
+# Bug#19890 mysqltest: "query" command is broken
+#
+
+# It should be possible to use the command "query" to force mysqltest to
+# send the command to the server although it's a builtin mysqltest command.
+--error 1064
+query sleep;
+
+--error 1064
+--query sleep
+
+# Just an empty query command
+--error 1065
+query ;
diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test
index 5d79d5eb9f9..6c1a4e44f4b 100644
--- a/mysql-test/t/ndb_basic.test
+++ b/mysql-test/t/ndb_basic.test
@@ -700,3 +700,13 @@ select * from t1 order by f1;
select * from t1 order by f2;
select * from t1 order by f3;
drop table t1;
+
+#
+# Bug#16561 Unknown ERROR msg "ERROR 1186 (HY000): Binlog closed" by perror
+#
+
+# As long there is no error code 1186 defined by NDB
+# we should get a message "Illegal ndb error code: 1186"
+--error 1
+--exec $MY_PERROR --ndb 1186 2>&1
+
diff --git a/mysql-test/t/ndb_lock.test b/mysql-test/t/ndb_lock.test
index 54214ee72ec..48a8b77dcd7 100644
--- a/mysql-test/t/ndb_lock.test
+++ b/mysql-test/t/ndb_lock.test
@@ -73,7 +73,7 @@ drop table t1;
create table t1 (x integer not null primary key, y varchar(32), z integer, key(z)) engine = ndb;
-insert into t1 values (1,'one',1), (2,'two',2),(3,"three",3);
+insert into t1 values (1,'one',1);
# PK access
connection con1;
@@ -82,12 +82,23 @@ select * from t1 where x = 1 for update;
connection con2;
begin;
-select * from t1 where x = 2 for update;
--error 1205
select * from t1 where x = 1 for update;
rollback;
connection con1;
+rollback;
+insert into t1 values (2,'two',2),(3,"three",3);
+begin;
+select * from t1 where x = 1 for update;
+
+connection con2;
+--error 1205
+select * from t1 where x = 1 for update;
+select * from t1 where x = 2 for update;
+rollback;
+
+connection con1;
commit;
# table scan
diff --git a/mysql-test/t/odbc.test b/mysql-test/t/odbc.test
index d4b6fc35e74..6a754bb32a7 100644
--- a/mysql-test/t/odbc.test
+++ b/mysql-test/t/odbc.test
@@ -21,4 +21,14 @@ select * from t1 where a is null;
explain select * from t1 where b is null;
drop table t1;
+#
+# Bug #14553: NULL in WHERE resets LAST_INSERT_ID
+#
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY);
+INSERT INTO t1 VALUES (NULL);
+SELECT sql_no_cache a, last_insert_id() FROM t1 WHERE a IS NULL;
+SELECT sql_no_cache a, last_insert_id() FROM t1 WHERE a IS NULL;
+SELECT sql_no_cache a, last_insert_id() FROM t1;
+DROP TABLE t1;
+
# End of 4.1 tests
diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test
index afee381f5b7..49f8fc4d7d4 100644
--- a/mysql-test/t/openssl_1.test
+++ b/mysql-test/t/openssl_1.test
@@ -10,14 +10,18 @@ insert into t1 values (5);
grant select on test.* to ssl_user1@localhost require SSL;
grant select on test.* to ssl_user2@localhost require cipher "DHE-RSA-AES256-SHA";
-grant select on test.* to ssl_user3@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "/C=SE/L=Uppsala/O=MySQL AB/CN=MySQL Client/emailAddress=abstract.mysql.developer@mysql.com";
-grant select on test.* to ssl_user4@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "/C=SE/L=Uppsala/O=MySQL AB/CN=MySQL Client/emailAddress=abstract.mysql.developer@mysql.com" ISSUER "/C=SE/L=Uppsala/O=MySQL AB/CN=Abstract MySQL Developer/emailAddress=abstract.mysql.developer@mysql.com";
+grant select on test.* to ssl_user3@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "/C=SE/ST=Uppsala/L=Uppsala/O=MySQL AB";
+grant select on test.* to ssl_user4@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "/C=SE/ST=Uppsala/L=Uppsala/O=MySQL AB" ISSUER "/C=SE/ST=Uppsala/L=Uppsala/O=MySQL AB";
+grant select on test.* to ssl_user5@localhost require cipher "DHE-RSA-AES256-SHA" AND SUBJECT "xxx";
flush privileges;
connect (con1,localhost,ssl_user1,,,,,SSL);
connect (con2,localhost,ssl_user2,,,,,SSL);
connect (con3,localhost,ssl_user3,,,,,SSL);
connect (con4,localhost,ssl_user4,,,,,SSL);
+--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
+--error 1045
+connect (con5,localhost,ssl_user5,,,,,SSL);
connection con1;
# Check ssl turned on
@@ -49,7 +53,7 @@ delete from t1;
connection default;
drop user ssl_user1@localhost, ssl_user2@localhost,
-ssl_user3@localhost, ssl_user4@localhost;
+ssl_user3@localhost, ssl_user4@localhost, ssl_user5@localhost;
drop table t1;
diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test
index 98e542dac95..1104c859ab8 100644
--- a/mysql-test/t/order_by.test
+++ b/mysql-test/t/order_by.test
@@ -578,3 +578,35 @@ INSERT INTO t1 VALUES (1,30), (2,20), (1,10), (2,30), (1,20), (2,10);
DROP TABLE t1;
# End of 4.1 tests
+
+#
+# Bug#21302: Result not properly sorted when using an ORDER BY on a second
+# table in a join
+#
+CREATE TABLE t1 (a int, b int, PRIMARY KEY (a));
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3);
+
+explain SELECT t1.b as a, t2.b as c FROM
+ t1 LEFT JOIN t1 t2 ON (t1.a = t2.a AND t2.a = 2)
+ORDER BY c;
+SELECT t2.b as c FROM
+ t1 LEFT JOIN t1 t2 ON (t1.a = t2.a AND t2.a = 2)
+ORDER BY c;
+
+# check that it still removes sort of const table
+explain SELECT t1.b as a, t2.b as c FROM
+ t1 JOIN t1 t2 ON (t1.a = t2.a AND t2.a = 2)
+ORDER BY c;
+
+CREATE TABLE t2 LIKE t1;
+INSERT INTO t2 SELECT * from t1;
+CREATE TABLE t3 LIKE t1;
+INSERT INTO t3 SELECT * from t1;
+CREATE TABLE t4 LIKE t1;
+INSERT INTO t4 SELECT * from t1;
+INSERT INTO t1 values (0,0),(4,4);
+
+SELECT t2.b FROM t1 LEFT JOIN (t2, t3 LEFT JOIN t4 ON t3.a=t4.a)
+ON (t1.a=t2.a AND t1.b=t3.b) order by t2.b;
+
+DROP TABLE t1,t2,t3,t4;
diff --git a/mysql-test/t/perror.test b/mysql-test/t/perror.test
new file mode 100644
index 00000000000..a4b99d8aa22
--- /dev/null
+++ b/mysql-test/t/perror.test
@@ -0,0 +1,19 @@
+#
+# Check if the variable MY_PERROR is set
+#
+--require r/have_perror.require
+disable_query_log;
+eval select LENGTH("$MY_PERROR") > 0 as "have_perror";
+enable_query_log;
+
+--exec $MY_PERROR 150 > /dev/null
+--exec $MY_PERROR --silent 120 > /dev/null
+
+#
+# Bug#16561 Unknown ERROR msg "ERROR 1186 (HY000): Binlog closed" by perror
+#
+
+# Test with error code 10000 as it's a common "unknown error"
+# As there is no error code defined for 10000, expect error
+--error 1
+--exec $MY_PERROR 10000 2>&1
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index ff66b265fae..5b2e37ecc94 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -491,6 +491,31 @@ deallocate prepare stmt;
drop table t1, t2;
#
+#
+# Bug#19399 "Stored Procedures 'Lost Connection' when dropping/creating
+# tables"
+# Check that multi-delete tables are also cleaned up before re-execution.
+#
+--disable_warnings
+drop table if exists t1;
+create temporary table if not exists t1 (a1 int);
+--enable_warnings
+# exact delete syntax is essential
+prepare stmt from "delete t1 from t1 where (cast(a1/3 as unsigned) * 3) = a1";
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+# the server crashed on the next statement without the fix
+execute stmt;
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+# the problem was in memory corruption: repeat the test just in case
+execute stmt;
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+execute stmt;
+drop temporary table t1;
+deallocate prepare stmt;
+
# Bug#6102 "Server crash with prepared statement and blank after
# function name"
# ensure that stored functions are cached when preparing a statement
@@ -514,86 +539,6 @@ SELECT FOUND_ROWS();
deallocate prepare stmt;
#
-# Bug#8115: equality propagation and prepared statements
-#
-
-create table t1 (a char(3) not null, b char(3) not null,
- c char(3) not null, primary key (a, b, c));
-create table t2 like t1;
-
-# reduced query
-prepare stmt from
- "select t1.a from (t1 left outer join t2 on t2.a=1 and t1.b=t2.b)
- where t1.a=1";
-execute stmt;
-execute stmt;
-execute stmt;
-
-# original query
-prepare stmt from
-"select t1.a, t1.b, t1.c, t2.a, t2.b, t2.c from
-(t1 left outer join t2 on t2.a=? and t1.b=t2.b)
-left outer join t2 t3 on t3.a=? where t1.a=?";
-
-set @a:=1, @b:=1, @c:=1;
-
-execute stmt using @a, @b, @c;
-execute stmt using @a, @b, @c;
-execute stmt using @a, @b, @c;
-
-deallocate prepare stmt;
-
-drop table t1,t2;
-
-
-#
-# Bug#9383: INFORMATION_SCHEMA.COLUMNS, JOIN, Crash, prepared statement
-#
-
-eval SET @aux= "SELECT COUNT(*)
- FROM INFORMATION_SCHEMA.COLUMNS A,
- INFORMATION_SCHEMA.COLUMNS B
- WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
- AND A.TABLE_NAME = B.TABLE_NAME
- AND A.COLUMN_NAME = B.COLUMN_NAME AND
- A.TABLE_NAME = 'user'";
-
-let $exec_loop_count= 3;
-eval prepare my_stmt from @aux;
-while ($exec_loop_count)
-{
- eval execute my_stmt;
- dec $exec_loop_count;
-}
-deallocate prepare my_stmt;
-
-# Test CALL in prepared mode
-delimiter |;
---disable_warnings
-drop procedure if exists p1|
-drop table if exists t1|
---enable_warnings
-create table t1 (id int)|
-insert into t1 values(1)|
-create procedure p1(a int, b int)
-begin
- declare c int;
- select max(id)+1 into c from t1;
- insert into t1 select a+b;
- insert into t1 select a-b;
- insert into t1 select a-c;
-end|
-set @a= 3, @b= 4|
-prepare stmt from "call p1(?, ?)"|
-execute stmt using @a, @b|
-execute stmt using @a, @b|
-select * from t1|
-deallocate prepare stmt|
-drop procedure p1|
-drop table t1|
-delimiter ;|
-
-#
# Bug#9096 "select doesn't return all matched records if prepared statements
# is used"
# The bug was is bad co-operation of the optimizer's algorithm which determines
@@ -668,35 +613,6 @@ deallocate prepare stmt;
drop table t1, t2;
#
-# Bug#7306 LIMIT ?, ? and also WL#1785 " Prepared statements: implement
-# support for placeholders in LIMIT clause."
-# Add basic test coverage for the feature.
-#
-create table t1 (a int);
-insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
-prepare stmt from "select * from t1 limit ?, ?";
-set @offset=0, @limit=1;
-execute stmt using @offset, @limit;
-select * from t1 limit 0, 1;
-set @offset=3, @limit=2;
-execute stmt using @offset, @limit;
-select * from t1 limit 3, 2;
-prepare stmt from "select * from t1 limit ?";
-execute stmt using @limit;
---error 1235
-prepare stmt from "select * from t1 where a in (select a from t1 limit ?)";
-prepare stmt from "select * from t1 union all select * from t1 limit ?, ?";
-set @offset=9;
-set @limit=2;
-execute stmt using @offset, @limit;
-prepare stmt from "(select * from t1 limit ?, ?) union all
- (select * from t1 limit ?, ?) order by a limit ?";
-execute stmt using @offset, @limit, @offset, @limit, @limit;
-
-drop table t1;
-deallocate prepare stmt;
-
-#
# Bug#11060 "Server crashes on calling stored procedure with INSERT SELECT
# UNION SELECT" aka "Server crashes on re-execution of prepared INSERT ...
# SELECT with UNION".
@@ -813,22 +729,6 @@ select ??;
select ? from t1;
--enable_ps_protocol
drop table t1;
-
-#
-# Bug#12651
-# (Crash on a PS including a subquery which is a select from a simple view)
-#
-CREATE TABLE b12651_T1(a int) ENGINE=MYISAM;
-CREATE TABLE b12651_T2(b int) ENGINE=MYISAM;
-CREATE VIEW b12651_V1 as SELECT b FROM b12651_T2;
-
-PREPARE b12651 FROM 'SELECT 1 FROM b12651_T1 WHERE a IN (SELECT b FROM b12651_V1)';
-EXECUTE b12651;
-
-DROP VIEW b12651_V1;
-DROP TABLE b12651_T1, b12651_T2;
-DEALLOCATE PREPARE b12651;
-
#
# Bug#9359 "Prepared statements take snapshot of system vars at PREPARE
# time"
@@ -1063,7 +963,172 @@ select @@max_prepared_stmt_count, @@prepared_stmt_count;
set global max_prepared_stmt_count= @old_max_prepared_stmt_count;
--enable_ps_protocol
-# End of 4.1 tests
+#
+# Bug#19399 "Stored Procedures 'Lost Connection' when dropping/creating
+# tables"
+# Check that multi-delete tables are also cleaned up before re-execution.
+#
+--disable_warnings
+drop table if exists t1;
+create temporary table if not exists t1 (a1 int);
+--enable_warnings
+# exact delete syntax is essential
+prepare stmt from "delete t1 from t1 where (cast(a1/3 as unsigned) * 3) = a1";
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+# the server crashed on the next statement without the fix
+execute stmt;
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+# the problem was in memory corruption: repeat the test just in case
+execute stmt;
+drop temporary table t1;
+create temporary table if not exists t1 (a1 int);
+execute stmt;
+drop temporary table t1;
+deallocate prepare stmt;
+
+--echo End of 4.1 tests
+############################# 5.0 tests start ################################
+#
+#
+# Bug#6102 "Server crash with prepared statement and blank after
+# function name"
+# ensure that stored functions are cached when preparing a statement
+# before we open tables
+#
+create table t1 (a varchar(20));
+insert into t1 values ('foo');
+--error 1305
+prepare stmt FROM 'SELECT char_length (a) FROM t1';
+drop table t1;
+
+#
+# Bug#8115: equality propagation and prepared statements
+#
+
+create table t1 (a char(3) not null, b char(3) not null,
+ c char(3) not null, primary key (a, b, c));
+create table t2 like t1;
+
+# reduced query
+prepare stmt from
+ "select t1.a from (t1 left outer join t2 on t2.a=1 and t1.b=t2.b)
+ where t1.a=1";
+execute stmt;
+execute stmt;
+execute stmt;
+
+# original query
+prepare stmt from
+"select t1.a, t1.b, t1.c, t2.a, t2.b, t2.c from
+(t1 left outer join t2 on t2.a=? and t1.b=t2.b)
+left outer join t2 t3 on t3.a=? where t1.a=?";
+
+set @a:=1, @b:=1, @c:=1;
+
+execute stmt using @a, @b, @c;
+execute stmt using @a, @b, @c;
+execute stmt using @a, @b, @c;
+
+deallocate prepare stmt;
+
+drop table t1,t2;
+
+
+#
+# Bug#9383: INFORMATION_SCHEMA.COLUMNS, JOIN, Crash, prepared statement
+#
+
+eval SET @aux= "SELECT COUNT(*)
+ FROM INFORMATION_SCHEMA.COLUMNS A,
+ INFORMATION_SCHEMA.COLUMNS B
+ WHERE A.TABLE_SCHEMA = B.TABLE_SCHEMA
+ AND A.TABLE_NAME = B.TABLE_NAME
+ AND A.COLUMN_NAME = B.COLUMN_NAME AND
+ A.TABLE_NAME = 'user'";
+
+let $exec_loop_count= 3;
+eval prepare my_stmt from @aux;
+while ($exec_loop_count)
+{
+ eval execute my_stmt;
+ dec $exec_loop_count;
+}
+deallocate prepare my_stmt;
+
+# Test CALL in prepared mode
+delimiter |;
+--disable_warnings
+drop procedure if exists p1|
+drop table if exists t1|
+--enable_warnings
+create table t1 (id int)|
+insert into t1 values(1)|
+create procedure p1(a int, b int)
+begin
+ declare c int;
+ select max(id)+1 into c from t1;
+ insert into t1 select a+b;
+ insert into t1 select a-b;
+ insert into t1 select a-c;
+end|
+set @a= 3, @b= 4|
+prepare stmt from "call p1(?, ?)"|
+execute stmt using @a, @b|
+execute stmt using @a, @b|
+select * from t1|
+deallocate prepare stmt|
+drop procedure p1|
+drop table t1|
+delimiter ;|
+
+
+#
+# Bug#7306 LIMIT ?, ? and also WL#1785 " Prepared statements: implement
+# support for placeholders in LIMIT clause."
+# Add basic test coverage for the feature.
+#
+create table t1 (a int);
+insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+prepare stmt from "select * from t1 limit ?, ?";
+set @offset=0, @limit=1;
+execute stmt using @offset, @limit;
+select * from t1 limit 0, 1;
+set @offset=3, @limit=2;
+execute stmt using @offset, @limit;
+select * from t1 limit 3, 2;
+prepare stmt from "select * from t1 limit ?";
+execute stmt using @limit;
+--error 1235
+prepare stmt from "select * from t1 where a in (select a from t1 limit ?)";
+prepare stmt from "select * from t1 union all select * from t1 limit ?, ?";
+set @offset=9;
+set @limit=2;
+execute stmt using @offset, @limit;
+prepare stmt from "(select * from t1 limit ?, ?) union all
+ (select * from t1 limit ?, ?) order by a limit ?";
+execute stmt using @offset, @limit, @offset, @limit, @limit;
+
+drop table t1;
+deallocate prepare stmt;
+
+#
+# Bug#12651
+# (Crash on a PS including a subquery which is a select from a simple view)
+#
+CREATE TABLE b12651_T1(a int) ENGINE=MYISAM;
+CREATE TABLE b12651_T2(b int) ENGINE=MYISAM;
+CREATE VIEW b12651_V1 as SELECT b FROM b12651_T2;
+
+PREPARE b12651 FROM 'SELECT 1 FROM b12651_T1 WHERE a IN (SELECT b FROM b12651_V1)';
+EXECUTE b12651;
+
+DROP VIEW b12651_V1;
+DROP TABLE b12651_T1, b12651_T2;
+DEALLOCATE PREPARE b12651;
+
+
#
# Bug #14956: ROW_COUNT() returns incorrect result after EXECUTE of prepared
@@ -1264,4 +1329,33 @@ create temporary table t1 (i int);
# Restore the old environemnt
#
use test;
-# End of 5.0 tests
+
+
+#
+# BUG#21166: Prepared statement causes signal 11 on second execution
+#
+# Changes in an item tree done by optimizer weren't properly
+# registered and went unnoticed, which resulted in preliminary freeing
+# of used memory.
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2, t3;
+--enable_warnings
+
+CREATE TABLE t1 (i BIGINT, j BIGINT);
+CREATE TABLE t2 (i BIGINT);
+CREATE TABLE t3 (i BIGINT, j BIGINT);
+
+PREPARE stmt FROM "SELECT * FROM t1 JOIN t2 ON (t2.i = t1.i)
+ LEFT JOIN t3 ON ((t3.i, t3.j) = (t1.i, t1.j))
+ WHERE t1.i = ?";
+
+SET @a= 1;
+EXECUTE stmt USING @a;
+EXECUTE stmt USING @a;
+
+DEALLOCATE PREPARE stmt;
+DROP TABLE IF EXISTS t1, t2, t3;
+
+
+--echo End of 5.0 tests.
diff --git a/mysql-test/t/ps_1general.test b/mysql-test/t/ps_1general.test
index 72b69fc8d9f..8d0f9885e80 100644
--- a/mysql-test/t/ps_1general.test
+++ b/mysql-test/t/ps_1general.test
@@ -316,6 +316,7 @@ prepare stmt4 from ' show table status from test like ''t9%'' ';
--replace_column 8 # 12 # 13 # 14 #
# Bug#4288
execute stmt4;
+--replace_column 2 #
prepare stmt4 from ' show status like ''Threads_running'' ';
execute stmt4;
prepare stmt4 from ' show variables like ''sql_mode'' ';
diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test
index d53b05b98b1..240851e6ac4 100644
--- a/mysql-test/t/range.test
+++ b/mysql-test/t/range.test
@@ -656,3 +656,87 @@ explain select * from t1 where a not between 'b' and 'b';
select a, hex(filler) from t1 where a not between 'b' and 'b';
drop table t1,t2,t3;
+
+#
+# BUG#21282
+#
+create table t1 (a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t2 (a int, key(a));
+insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C;
+
+set @a="select * from t2 force index (a) where a NOT IN(0";
+select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z;
+set @a=concat(@a, ')');
+
+insert into t2 values (11),(13),(15);
+
+set @b= concat("explain ", @a);
+
+prepare stmt1 from @b;
+execute stmt1;
+
+prepare stmt1 from @a;
+execute stmt1;
+
+drop table t1, t2;
+
+#
+# Bug #18165: range access for BETWEEN with a constant for the first argument
+#
+
+CREATE TABLE t1 (
+ id int NOT NULL DEFAULT '0',
+ b int NOT NULL DEFAULT '0',
+ c int NOT NULL DEFAULT '0',
+ INDEX idx1(b,c), INDEX idx2(c));
+
+INSERT INTO t1(id) VALUES (1), (2), (3), (4), (5), (6), (7), (8);
+
+INSERT INTO t1(b,c) VALUES (3,4), (3,4);
+
+SELECT * FROM t1 WHERE b<=3 AND 3<=c;
+SELECT * FROM t1 WHERE 3 BETWEEN b AND c;
+
+EXPLAIN SELECT * FROM t1 WHERE b<=3 AND 3<=c;
+EXPLAIN SELECT * FROM t1 WHERE 3 BETWEEN b AND c;
+
+SELECT * FROM t1 WHERE 0 < b OR 0 > c;
+SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c;
+
+EXPLAIN SELECT * FROM t1 WHERE 0 < b OR 0 > c;
+EXPLAIN SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c;
+
+DROP TABLE t1;
+
+#
+# Bug #16249: different results for a range with an without index
+# when a range condition use an invalid datetime constant
+#
+
+CREATE TABLE t1 (
+ item char(20) NOT NULL default '',
+ started datetime NOT NULL default '0000-00-00 00:00:00',
+ price decimal(16,3) NOT NULL default '0.000',
+ PRIMARY KEY (item,started)
+) ENGINE=MyISAM;
+
+INSERT INTO t1 VALUES
+('A1','2005-11-01 08:00:00',1000),
+('A1','2005-11-15 00:00:00',2000),
+('A1','2005-12-12 08:00:00',3000),
+('A2','2005-12-01 08:00:00',1000);
+
+EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
+SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
+SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
+
+DROP INDEX `PRIMARY` ON t1;
+
+EXPLAIN SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
+SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
+SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
+
+DROP TABLE t1;
+
+# End of 5.0 tests
diff --git a/mysql-test/t/repair.test b/mysql-test/t/repair.test
index 16e1d76d460..91a7442226a 100644
--- a/mysql-test/t/repair.test
+++ b/mysql-test/t/repair.test
@@ -34,4 +34,15 @@ repair table t1;
repair table t1 use_frm;
drop table t1;
+#
+# BUG#18874 - Setting myisam_repair_threads > 1, index cardinality always 1
+#
+CREATE TABLE t1(a INT, KEY(a));
+INSERT INTO t1 VALUES(1),(2),(3),(4),(5);
+SET myisam_repair_threads=2;
+REPAIR TABLE t1;
+SHOW INDEX FROM t1;
+SET myisam_repair_threads=@@global.myisam_repair_threads;
+DROP TABLE t1;
+
# End of 4.1 tests
diff --git a/mysql-test/t/row.test b/mysql-test/t/row.test
index 6301cc0f584..63c611e6be6 100644
--- a/mysql-test/t/row.test
+++ b/mysql-test/t/row.test
@@ -92,3 +92,50 @@ SELECT ROW(NULL,10) <=> ROW(3,NULL);
#
SELECT ROW(1,1,1) = ROW(1,1,1) as `1`, ROW(1,1,1) = ROW(1,2,1) as `0`, ROW(1,NULL,1) = ROW(2,2,1) as `0`, ROW(1,NULL,1) = ROW(1,2,2) as `0`, ROW(1,NULL,1) = ROW(1,2,1) as `null` ;
select row(NULL,1)=(2,0);
+
+#
+# Bug #16081: row equalities are to be used for query optimizations
+#
+
+CREATE TABLE t1 (a int, b int, PRIMARY KEY (a,b));
+INSERT INTO t1 VALUES (1,1), (2,1), (3,1), (1,2), (3,2), (3,3);
+
+EXPLAIN SELECT * FROM t1 WHERE a=3 AND b=2;
+EXPLAIN SELECT * FROM t1 WHERE (a,b)=(3,2);
+SELECT * FROM t1 WHERE a=3 and b=2;
+SELECT * FROM t1 WHERE (a,b)=(3,2);
+
+CREATE TABLE t2 (a int, b int, c int, PRIMARY KEY (a,b,c));
+INSERT INTO t2 VALUES
+ (1,1,2), (3,1,3), (1,2,2), (4,4,2),
+ (1,1,1), (3,1,1), (1,2,1);
+
+EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=t2.b;
+EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b);
+SELECT * FROM t1,t2 WHERE t1.a=t2.a and t1.b=t2.b;
+SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b);
+
+EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a AND t1.b=2;
+EXPLAIN SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,2);
+SELECT * FROM t1,t2 WHERE t1.a=1 and t1.b=t2.b;
+SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,2);
+
+EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b+1);
+SELECT * FROM t1,t2 WHERE (t1.a,t1.b)=(t2.a,t2.b+1);
+
+EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE (t1.a-1,t1.b)=(t2.a-1,t2.b+1);
+SELECT * FROM t1,t2 WHERE (t1.a-1,t1.b)=(t2.a-1,t2.b+1);
+
+EXPLAIN SELECT * FROM t2 WHERE a=3 AND b=2;
+EXPLAIN SELECT * FROM t2 WHERE (a,b)=(3,2);
+SELECT * FROM t2 WHERE a=3 and b=2;
+SELECT * FROM t2 WHERE (a,b)=(3,2);
+
+EXPLAIN SELECT * FROM t1,t2 WHERE t2.a=t1.a AND t2.b=2 AND t2.c=1;
+EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE (t2.a,(t2.b,t2.c))=(t1.a,(2,1));
+SELECT * FROM t1,t2 WHERE (t2.a,(t2.b,t2.c))=(t1.a,(2,1));
+
+EXPLAIN EXTENDED SELECT * FROM t1,t2 WHERE t2.a=t1.a AND (t2.b,t2.c)=(2,1);
+SELECT * FROM t1,t2 WHERE t2.a=t1.a AND (t2.b,t2.c)=(2,1);
+
+DROP TABLE t1,t2;
diff --git a/mysql-test/t/rpl_insert_id.test b/mysql-test/t/rpl_insert_id.test
index 90a123cf5dc..3c46a5b4ca1 100644
--- a/mysql-test/t/rpl_insert_id.test
+++ b/mysql-test/t/rpl_insert_id.test
@@ -1,10 +1,21 @@
-# See if queries that use both auto_increment and LAST_INSERT_ID()
-# are replicated well
-
-# We also check how the foreign_key_check variable is replicated
+--echo #
+--echo # Setup
+--echo #
source include/master-slave.inc;
source include/have_innodb.inc;
+use test;
+--disable_warnings
+drop table if exists t1, t2, t3;
+--enable_warnings
+
+--echo #
+--echo # See if queries that use both auto_increment and LAST_INSERT_ID()
+--echo # are replicated well
+--echo #
+--echo # We also check how the foreign_key_check variable is replicated
+--echo #
+
connection master;
create table t1(a int auto_increment, key(a));
create table t2(b int auto_increment, c int, key(b));
@@ -39,7 +50,9 @@ select * from t1;
select * from t2;
connection master;
-# check if INSERT SELECT in auto_increment is well replicated (bug #490)
+--echo #
+--echo # check if INSERT SELECT in auto_increment is well replicated (bug #490)
+--echo #
drop table t2;
drop table t1;
@@ -62,10 +75,11 @@ save_master_pos;
connection slave;
sync_with_master;
-#
-# Bug#8412: Error codes reported in binary log for CHARACTER SET,
-# FOREIGN_KEY_CHECKS
-#
+--echo #
+--echo # Bug#8412: Error codes reported in binary log for CHARACTER SET,
+--echo # FOREIGN_KEY_CHECKS
+--echo #
+
connection master;
SET TIMESTAMP=1000000000;
CREATE TABLE t1 ( a INT UNIQUE );
@@ -77,8 +91,29 @@ sync_slave_with_master;
connection master;
drop table t1;
sync_slave_with_master;
-# End of 4.1 tests
+
+--echo #
+--echo # Bug#14553: NULL in WHERE resets LAST_INSERT_ID
+--echo #
+
+connection master;
+create table t1(a int auto_increment, key(a));
+create table t2(a int);
+insert into t1 (a) values (null);
+insert into t2 (a) select a from t1 where a is null;
+insert into t2 (a) select a from t1 where a is null;
+select * from t2;
+sync_slave_with_master;
+connection slave;
+select * from t2;
+connection master;
+drop table t1;
+drop table t2;
+sync_slave_with_master;
+--echo #
+--echo # End of 4.1 tests
+--echo #
#
# BUG#15728: LAST_INSERT_ID function inside a stored function returns 0
@@ -209,7 +244,10 @@ select * from t1 order by n;
connection master;
drop table t1;
+sync_slave_with_master;
+
+--echo
+--echo # End of 5.0 tests
+--echo
-# End of 5.0 tests
-sync_slave_with_master;
diff --git a/mysql-test/t/rpl_max_relay_size.test b/mysql-test/t/rpl_max_relay_size.test
index 9b6b06e0b14..be1fbf172fc 100644
--- a/mysql-test/t/rpl_max_relay_size.test
+++ b/mysql-test/t/rpl_max_relay_size.test
@@ -7,7 +7,11 @@ source include/master-slave.inc;
connection slave;
stop slave;
connection master;
-# Generate a big enough master's binlog to cause relay log rotations
+
+--echo #
+--echo # Generate a big enough master's binlog to cause relay log rotations
+--echo #
+
create table t1 (a int);
let $1=800;
disable_query_log;
@@ -23,6 +27,11 @@ drop table t1;
save_master_pos;
connection slave;
reset slave;
+
+--echo #
+--echo # Test 1
+--echo #
+
set global max_binlog_size=8192;
set global max_relay_log_size=8192-1; # mapped to 4096
select @@global.max_relay_log_size;
@@ -30,7 +39,13 @@ start slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 #
+--vertical_results
show slave status;
+
+--echo #
+--echo # Test 2
+--echo #
+
stop slave;
reset slave;
set global max_relay_log_size=(5*4096);
@@ -39,7 +54,13 @@ start slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 #
+--vertical_results
show slave status;
+
+--echo #
+--echo # Test 3: max_relay_log_size = 0
+--echo #
+
stop slave;
reset slave;
set global max_relay_log_size=0;
@@ -48,9 +69,12 @@ start slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 #
+--vertical_results
show slave status;
-# Tests below are mainly to ensure that we have not coded with wrong assumptions
+--echo #
+--echo # Test 4: Tests below are mainly to ensure that we have not coded with wrong assumptions
+--echo #
stop slave;
reset slave;
@@ -59,8 +83,13 @@ reset slave;
flush logs;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 #
+--vertical_results
show slave status;
+--echo #
+--echo # Test 5
+--echo #
+
reset slave;
start slave;
sync_with_master;
@@ -75,8 +104,13 @@ connection slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 #
+--vertical_results
show slave status;
-# one more rotation, to be sure Relay_Log_Space is correctly updated
+
+--echo #
+--echo # Test 6: one more rotation, to be sure Relay_Log_Space is correctly updated
+--echo #
+
flush logs;
connection master;
drop table t1;
@@ -85,6 +119,7 @@ connection slave;
sync_with_master;
--replace_result $MASTER_MYPORT MASTER_PORT
--replace_column 1 # 8 # 9 # 23 # 33 #
+--vertical_results
show slave status;
connection master;
@@ -92,5 +127,6 @@ connection master;
flush logs;
show master status;
-# End of 4.1 tests
-#
+--echo #
+--echo # End of 4.1 tests
+--echo #
diff --git a/mysql-test/t/rpl_ndb_innodb_trans-slave.opt b/mysql-test/t/rpl_ndb_innodb_trans-slave.opt
new file mode 100644
index 00000000000..627becdbfb5
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_innodb_trans-slave.opt
@@ -0,0 +1 @@
+--innodb
diff --git a/mysql-test/t/rpl_ndb_innodb_trans.test b/mysql-test/t/rpl_ndb_innodb_trans.test
new file mode 100644
index 00000000000..127c2464570
--- /dev/null
+++ b/mysql-test/t/rpl_ndb_innodb_trans.test
@@ -0,0 +1,66 @@
+# Test of a transaction mixing the two engines
+
+-- source include/have_ndb.inc
+-- source include/have_innodb.inc
+-- source include/master-slave.inc
+
+create table t1 (a int, unique(a)) engine=ndbcluster;
+create table t2 (a int, unique(a)) engine=innodb;
+
+
+begin;
+insert into t1 values(1);
+insert into t2 values(1);
+rollback;
+
+select count(*) from t1;
+select count(*) from t2;
+sync_slave_with_master;
+select count(*) from t1;
+select count(*) from t2;
+connection master;
+
+begin;
+load data infile '../std_data_ln/rpl_loaddata.dat' into table t2;
+load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
+rollback;
+
+select count(*) from t1;
+select count(*) from t2;
+sync_slave_with_master;
+select count(*) from t1;
+select count(*) from t2;
+connection master;
+
+delete from t1;
+delete from t2;
+begin;
+load data infile '../std_data_ln/rpl_loaddata.dat' into table t2;
+load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
+rollback;
+
+select count(*) from t1;
+select count(*) from t2;
+sync_slave_with_master;
+select count(*) from t1;
+select count(*) from t2;
+connection master;
+
+delete from t1;
+delete from t2;
+begin;
+insert into t2 values(3),(4);
+insert into t1 values(3),(4);
+load data infile '../std_data_ln/rpl_loaddata.dat' into table t2;
+load data infile '../std_data_ln/rpl_loaddata.dat' into table t1;
+rollback;
+
+select count(*) from t1;
+select count(*) from t2;
+sync_slave_with_master;
+select count(*) from t1;
+select count(*) from t2;
+connection master;
+
+drop table t1,t2;
+sync_slave_with_master;
diff --git a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test
index 8be17be3822..7479794eded 100644
--- a/mysql-test/t/rpl_sp.test
+++ b/mysql-test/t/rpl_sp.test
@@ -435,6 +435,86 @@ connection master;
DROP PROCEDURE p1;
+
+#
+# BUG#20438: CREATE statements for views, stored routines and triggers can be
+# not replicable.
+#
+
+--echo
+--echo ---> Test for BUG#20438
+
+# Prepare environment.
+
+--echo
+--echo ---> Preparing environment...
+--echo ---> connection: master
+--connection master
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+DROP FUNCTION IF EXISTS f1;
+--enable_warnings
+
+--echo
+--echo ---> Synchronizing slave with master...
+
+--save_master_pos
+--connection slave
+--sync_with_master
+
+--echo
+--echo ---> connection: master
+--connection master
+
+# Test.
+
+--echo
+--echo ---> Creating procedure...
+
+/*!50003 CREATE PROCEDURE p1() SET @a = 1 */;
+
+/*!50003 CREATE FUNCTION f1() RETURNS INT RETURN 0 */;
+
+--echo
+--echo ---> Checking on master...
+
+SHOW CREATE PROCEDURE p1;
+SHOW CREATE FUNCTION f1;
+
+--echo
+--echo ---> Synchronizing slave with master...
+
+--save_master_pos
+--connection slave
+--sync_with_master
+
+--echo ---> connection: master
+
+--echo
+--echo ---> Checking on slave...
+
+SHOW CREATE PROCEDURE p1;
+SHOW CREATE FUNCTION f1;
+
+# Cleanup.
+
+--echo
+--echo ---> connection: master
+--connection master
+
+--echo
+--echo ---> Cleaning up...
+
+DROP PROCEDURE p1;
+DROP FUNCTION f1;
+
+--save_master_pos
+--connection slave
+--sync_with_master
+--connection master
+
+
# cleanup
connection master;
drop table t1;
diff --git a/mysql-test/t/rpl_trigger.test b/mysql-test/t/rpl_trigger.test
index 35f0a0b0a4b..3c8cbb97b31 100644
--- a/mysql-test/t/rpl_trigger.test
+++ b/mysql-test/t/rpl_trigger.test
@@ -331,6 +331,98 @@ SHOW TRIGGERS;
RESET MASTER;
+# Restart slave.
+
+connection slave;
+START SLAVE;
+
+
+#
+# BUG#20438: CREATE statements for views, stored routines and triggers can be
+# not replicable.
+#
+
+--echo
+--echo ---> Test for BUG#20438
+
+# Prepare environment.
+
+--echo
+--echo ---> Preparing environment...
+--echo ---> connection: master
+--connection master
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+--echo
+--echo ---> Synchronizing slave with master...
+
+--save_master_pos
+--connection slave
+--sync_with_master
+
+--echo
+--echo ---> connection: master
+--connection master
+
+# Test.
+
+--echo
+--echo ---> Creating objects...
+
+CREATE TABLE t1(c INT);
+CREATE TABLE t2(c INT);
+
+/*!50003 CREATE TRIGGER t1_bi BEFORE INSERT ON t1
+ FOR EACH ROW
+ INSERT INTO t2 VALUES(NEW.c * 10) */;
+
+--echo
+--echo ---> Inserting value...
+
+INSERT INTO t1 VALUES(1);
+
+--echo
+--echo ---> Checking on master...
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+--echo
+--echo ---> Synchronizing slave with master...
+
+--save_master_pos
+--connection slave
+--sync_with_master
+
+--echo ---> connection: master
+
+--echo
+--echo ---> Checking on slave...
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+# Cleanup.
+
+--echo
+--echo ---> connection: master
+--connection master
+
+--echo
+--echo ---> Cleaning up...
+
+DROP TABLE t1;
+DROP TABLE t2;
+
+--save_master_pos
+--connection slave
+--sync_with_master
+--connection master
+
#
# End of tests
diff --git a/mysql-test/t/rpl_view.test b/mysql-test/t/rpl_view.test
index 0a0c6a6dddb..812e5d44d58 100644
--- a/mysql-test/t/rpl_view.test
+++ b/mysql-test/t/rpl_view.test
@@ -45,3 +45,108 @@ drop table t1;
sync_slave_with_master;
--replace_column 2 # 5 #
show binlog events limit 1,100;
+
+
+
+#
+# BUG#20438: CREATE statements for views, stored routines and triggers can be
+# not replicable.
+#
+
+--echo
+--echo ---> Test for BUG#20438
+
+# Prepare environment.
+
+--echo
+--echo ---> Preparing environment...
+--echo ---> connection: master
+--connection master
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+
+--echo
+--echo ---> Synchronizing slave with master...
+
+--save_master_pos
+--connection slave
+--sync_with_master
+
+--echo
+--echo ---> connection: master
+--connection master
+
+# Test.
+
+--echo
+--echo ---> Creating objects...
+
+CREATE TABLE t1(c INT);
+
+/*!50003 CREATE VIEW v1 AS SELECT * FROM t1 */;
+
+--echo
+--echo ---> Inserting value...
+
+INSERT INTO t1 VALUES(1);
+
+--echo
+--echo ---> Checking on master...
+
+SELECT * FROM t1;
+
+--echo
+--echo ---> Synchronizing slave with master...
+
+--save_master_pos
+--connection slave
+--sync_with_master
+
+--echo ---> connection: master
+
+--echo
+--echo ---> Checking on slave...
+
+SELECT * FROM t1;
+
+# Cleanup.
+
+--echo
+--echo ---> connection: master
+--connection master
+
+--echo
+--echo ---> Cleaning up...
+
+DROP VIEW v1;
+DROP TABLE t1;
+
+--save_master_pos
+--connection slave
+--sync_with_master
+--connection master
+
+#
+# BUG#19419: "VIEW: View that the column name is different
+# by master and slave is made".
+#
+connection master;
+create table t1(a int, b int);
+insert into t1 values (1, 1), (1, 2), (1, 3);
+create view v1(a, b) as select a, sum(b) from t1 group by a;
+
+sync_slave_with_master;
+explain v1;
+show create table v1;
+select * from v1;
+
+connection master;
+drop table t1;
+drop view v1;
+
+sync_slave_with_master;
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index b75d0dd8bb6..36b3749b4d7 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -2304,6 +2304,51 @@ INSERT INTO t1 VALUES (10);
SELECT i='1e+01',i=1e+01, i in (1e+01,1e+01), i in ('1e+01','1e+01') FROM t1;
DROP TABLE t1;
+#
+# Bug #21019: First result of SELECT COUNT(*) different than consecutive runs
+#
+CREATE TABLE t1 (a int, b int);
+INSERT INTO t1 VALUES (1,1), (2,1), (4,10);
+
+CREATE TABLE t2 (a int PRIMARY KEY, b int, KEY b (b));
+INSERT INTO t2 VALUES (1,NULL), (2,10);
+ALTER TABLE t1 ENABLE KEYS;
+
+EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
+SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
+EXPLAIN SELECT STRAIGHT_JOIN SQL_NO_CACHE COUNT(*) FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
+SELECT STRAIGHT_JOIN SQL_NO_CACHE * FROM t2, t1 WHERE t1.b = t2.b OR t2.b IS NULL;
+DROP TABLE IF EXISTS t1,t2;
+#
+# Bug #20954 "avg(keyval) retuns 0.38 but max(keyval) returns an empty set"
+#
+--disable_ps_protocol
+CREATE TABLE t1 (key1 float default NULL, UNIQUE KEY key1 (key1));
+CREATE TABLE t2 (key2 float default NULL, UNIQUE KEY key2 (key2));
+INSERT INTO t1 VALUES (0.3762),(0.3845),(0.6158),(0.7941);
+INSERT INTO t2 VALUES (1.3762),(1.3845),(1.6158),(1.7941);
+
+explain select max(key1) from t1 where key1 <= 0.6158;
+explain select max(key2) from t2 where key2 <= 1.6158;
+explain select min(key1) from t1 where key1 >= 0.3762;
+explain select min(key2) from t2 where key2 >= 1.3762;
+explain select max(key1), min(key2) from t1, t2
+where key1 <= 0.6158 and key2 >= 1.3762;
+explain select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
+explain select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
+
+select max(key1) from t1 where key1 <= 0.6158;
+select max(key2) from t2 where key2 <= 1.6158;
+select min(key1) from t1 where key1 >= 0.3762;
+select min(key2) from t2 where key2 >= 1.3762;
+select max(key1), min(key2) from t1, t2
+where key1 <= 0.6158 and key2 >= 1.3762;
+select max(key1) from t1 where key1 <= 0.6158 and rand() + 0.5 >= 0.5;
+select min(key1) from t1 where key1 >= 0.3762 and rand() + 0.5 >= 0.5;
+
+DROP TABLE t1,t2;
+--enable_ps_protocol
+
# End of 4.1 tests
#
@@ -2901,3 +2946,55 @@ from t1 left outer join t2 on t1.a = t2.c and t2.b <> 1
where t1.b <> 1 order by t1.a;
drop table t1,t2;
+
+#
+# Bug #20569: Garbage in DECIMAL results from some mathematical functions
+#
+SELECT 0.9888889889 * 1.011111411911;
+
+#
+# Bug #10977: No warning issued if a column name is truncated
+#
+prepare stmt from 'select 1 as " a "';
+execute stmt;
+
+#
+# Bug #21390: wrong estimate of rows after elimination of const tables
+#
+
+CREATE TABLE t1 (a int NOT NULL PRIMARY KEY, b int NOT NULL);
+INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4);
+
+CREATE TABLE t2 (c int NOT NULL, INDEX idx(c));
+INSERT INTO t2 VALUES
+ (1), (1), (1), (1), (1), (1), (1), (1),
+ (2), (2), (2), (2),
+ (3), (3),
+ (4);
+
+EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=1;
+EXPLAIN SELECT b FROM t1, t2 WHERE b=c AND a=4;
+
+DROP TABLE t1, t2;
+
+#
+# No matches for a join after substitution of a const table
+#
+
+CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a int);
+INSERT INTO t1 VALUES (1,2), (2,NULL), (3,2);
+
+CREATE TABLE t2 (b int, c INT, INDEX idx1(b));
+INSERT INTO t2 VALUES (2,1), (3,2);
+
+CREATE TABLE t3 (d int, e int, INDEX idx1(d));
+INSERT INTO t3 VALUES (2,10), (2,20), (1,30), (2,40), (2,50);
+
+EXPLAIN
+SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id
+ WHERE t1.id=2;
+SELECT * FROM t1 LEFT JOIN t2 ON t2.b=t1.a INNER JOIN t3 ON t3.d=t1.id
+ WHERE t1.id=2;
+
+
+DROP TABLE t1,t2,t3;
diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test
index 6937cbe949d..65a81545c87 100644
--- a/mysql-test/t/show_check.test
+++ b/mysql-test/t/show_check.test
@@ -495,4 +495,15 @@ SHOW CREATE VIEW v1;
DROP PROCEDURE p1;
DROP VIEW v1;
+
+#
+# Check that SHOW TABLES and SHOW COLUMNS give a error if there is no
+# referenced database and table respectively.
+#
+--error ER_BAD_DB_ERROR
+SHOW TABLES FROM no_such_database;
+--error ER_NO_SUCH_TABLE
+SHOW COLUMNS FROM no_such_table;
+
+
# End of 5.0 tests.
diff --git a/mysql-test/t/sp-code.test b/mysql-test/t/sp-code.test
index 0a26ea644f6..72efa831059 100644
--- a/mysql-test/t/sp-code.test
+++ b/mysql-test/t/sp-code.test
@@ -190,3 +190,25 @@ delimiter ;//
show procedure code sudoku_solve;
drop procedure sudoku_solve;
+
+
+#
+# Bug#19207: Final parenthesis omitted for CREATE INDEX in Stored
+# Procedure
+#
+# Wrong criteria was used to distinguish the case when there was no
+# lookahead performed in the parser. Bug affected only statements
+# ending in one-character token without any optional tail, like CREATE
+# INDEX and CALL.
+#
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+CREATE PROCEDURE p1() CREATE INDEX idx ON t1 (c1);
+SHOW PROCEDURE CODE p1;
+
+DROP PROCEDURE p1;
+
+
+--echo End of 5.0 tests.
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index a4ab5d98922..abb36f040d2 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -899,6 +899,45 @@ begin
flush tables;
return 5;
end|
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function bug8409() returns int begin reset query cache;
+return 1; end|
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function bug8409() returns int begin reset master;
+return 1; end|
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function bug8409() returns int begin reset slave;
+return 1; end|
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function bug8409() returns int begin flush hosts;
+return 1; end|
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function bug8409() returns int begin flush privileges;
+return 1; end|
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function bug8409() returns int begin flush tables with read lock;
+return 1; end|
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function bug8409() returns int begin flush tables;
+return 1; end|
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function bug8409() returns int begin flush logs;
+return 1; end|
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function bug8409() returns int begin flush status;
+return 1; end|
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function bug8409() returns int begin flush slave;
+return 1; end|
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function bug8409() returns int begin flush master;
+return 1; end|
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function bug8409() returns int begin flush des_key_file;
+return 1; end|
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create function bug8409() returns int begin flush user_resources;
+return 1; end|
#
@@ -1707,6 +1746,28 @@ create aggregate function bug16896() returns int return 1;
#
+# BUG#14702: misleading error message when syntax error in CREATE
+# PROCEDURE
+#
+# Misleading error message was given when IF NOT EXISTS was used in
+# CREATE PROCEDURE.
+#
+--disable_warnings
+DROP PROCEDURE IF EXISTS bug14702;
+--enable_warnings
+
+--error ER_PARSE_ERROR
+CREATE IF NOT EXISTS PROCEDURE bug14702()
+BEGIN
+END;
+
+--error ER_PARSE_ERROR
+CREATE PROCEDURE IF NOT EXISTS bug14702()
+BEGIN
+END;
+
+
+#
# BUG#NNNN: New bug synopsis
#
#--disable_warnings
diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test
index d323b180216..a5d509f29b7 100644
--- a/mysql-test/t/sp-security.test
+++ b/mysql-test/t/sp-security.test
@@ -790,4 +790,80 @@ SELECT Host,User,Password FROM mysql.user WHERE User='user19857';
DROP USER user19857@localhost;
-# End of 5.0 bugs.
+--disconnect con1root
+--connection default
+
+
+#
+# BUG#18630: Arguments of suid routine calculated in wrong security
+# context
+#
+# Arguments of suid routines were calculated in definer's security
+# context instead of caller's context thus creating security hole.
+#
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS v1;
+DROP FUNCTION IF EXISTS f_suid;
+DROP PROCEDURE IF EXISTS p_suid;
+DROP FUNCTION IF EXISTS f_evil;
+--enable_warnings
+DELETE FROM mysql.user WHERE user LIKE 'mysqltest\_%';
+DELETE FROM mysql.db WHERE user LIKE 'mysqltest\_%';
+DELETE FROM mysql.tables_priv WHERE user LIKE 'mysqltest\_%';
+DELETE FROM mysql.columns_priv WHERE user LIKE 'mysqltest\_%';
+FLUSH PRIVILEGES;
+
+CREATE TABLE t1 (i INT);
+CREATE FUNCTION f_suid(i INT) RETURNS INT SQL SECURITY DEFINER RETURN 0;
+CREATE PROCEDURE p_suid(IN i INT) SQL SECURITY DEFINER SET @c:= 0;
+
+CREATE USER mysqltest_u1@localhost;
+# Thanks to this grant statement privileges of anonymous users on
+# 'test' database are not applicable for mysqltest_u1@localhost.
+GRANT EXECUTE ON test.* TO mysqltest_u1@localhost;
+
+delimiter |;
+CREATE DEFINER=mysqltest_u1@localhost FUNCTION f_evil () RETURNS INT
+ SQL SECURITY INVOKER
+BEGIN
+ SET @a:= CURRENT_USER();
+ SET @b:= (SELECT COUNT(*) FROM t1);
+ RETURN @b;
+END|
+delimiter ;|
+
+CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT f_evil();
+
+connect (conn1, localhost, mysqltest_u1,,);
+
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT COUNT(*) FROM t1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT f_evil();
+SELECT @a, @b;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT f_suid(f_evil());
+SELECT @a, @b;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+CALL p_suid(f_evil());
+SELECT @a, @b;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+SELECT * FROM v1;
+SELECT @a, @b;
+
+disconnect conn1;
+connection default;
+
+DROP VIEW v1;
+DROP FUNCTION f_evil;
+DROP USER mysqltest_u1@localhost;
+DROP PROCEDURE p_suid;
+DROP FUNCTION f_suid;
+DROP TABLE t1;
+
+--echo End of 5.0 tests.
diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test
index 25c96042e6f..4707a9b0d30 100644
--- a/mysql-test/t/sp.test
+++ b/mysql-test/t/sp.test
@@ -5962,6 +5962,433 @@ call bug15217()|
drop table t3|
drop procedure bug15217|
+
+#
+# BUG#21013: Performance Degrades when importing data that uses
+# Trigger and Stored Procedure
+#
+# This is a performance and memory leak test. Run with large number
+# passed to bug21013() procedure.
+#
+--disable_warnings
+DROP PROCEDURE IF EXISTS bug21013 |
+--enable_warnings
+
+CREATE PROCEDURE bug21013(IN lim INT)
+BEGIN
+ DECLARE i INT DEFAULT 0;
+ WHILE (i < lim) DO
+ SET @b = LOCATE(_latin1'b', @a, 1);
+ SET i = i + 1;
+ END WHILE;
+END |
+
+SET @a = _latin2"aaaaaaaaaa" |
+CALL bug21013(10) |
+
+DROP PROCEDURE bug21013 |
+
+
+#
+# BUG#16211: Stored function return type for strings is ignored
+#
+
+# Prepare: create database with fixed, pre-defined character set.
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1|
+DROP DATABASE IF EXISTS mysqltest2|
+--enable_warnings
+
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8|
+CREATE DATABASE mysqltest2 DEFAULT CHARACTER SET utf8|
+
+# Test case:
+
+use mysqltest1|
+
+# - Create two stored functions -- with and without explicit CHARSET-clause
+# for return value;
+
+CREATE FUNCTION bug16211_f1() RETURNS CHAR(10)
+ RETURN ""|
+
+CREATE FUNCTION bug16211_f2() RETURNS CHAR(10) CHARSET koi8r
+ RETURN ""|
+
+CREATE FUNCTION mysqltest2.bug16211_f3() RETURNS CHAR(10)
+ RETURN ""|
+
+CREATE FUNCTION mysqltest2.bug16211_f4() RETURNS CHAR(10) CHARSET koi8r
+ RETURN ""|
+
+# - Check that CHARSET-clause is specified for the second function;
+
+SHOW CREATE FUNCTION bug16211_f1|
+SHOW CREATE FUNCTION bug16211_f2|
+
+SHOW CREATE FUNCTION mysqltest2.bug16211_f3|
+SHOW CREATE FUNCTION mysqltest2.bug16211_f4|
+
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f1"|
+
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f2"|
+
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f3"|
+
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f4"|
+
+SELECT CHARSET(bug16211_f1())|
+SELECT CHARSET(bug16211_f2())|
+
+SELECT CHARSET(mysqltest2.bug16211_f3())|
+SELECT CHARSET(mysqltest2.bug16211_f4())|
+
+# - Alter database character set.
+
+ALTER DATABASE mysqltest1 CHARACTER SET cp1251|
+ALTER DATABASE mysqltest2 CHARACTER SET cp1251|
+
+# - Check that CHARSET-clause has not changed.
+
+SHOW CREATE FUNCTION bug16211_f1|
+SHOW CREATE FUNCTION bug16211_f2|
+
+SHOW CREATE FUNCTION mysqltest2.bug16211_f3|
+SHOW CREATE FUNCTION mysqltest2.bug16211_f4|
+
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f1"|
+
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "mysqltest1" AND ROUTINE_NAME = "bug16211_f2"|
+
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f3"|
+
+SELECT dtd_identifier
+FROM INFORMATION_SCHEMA.ROUTINES
+WHERE ROUTINE_SCHEMA = "mysqltest2" AND ROUTINE_NAME = "bug16211_f4"|
+
+SELECT CHARSET(bug16211_f1())|
+SELECT CHARSET(bug16211_f2())|
+
+SELECT CHARSET(mysqltest2.bug16211_f3())|
+SELECT CHARSET(mysqltest2.bug16211_f4())|
+
+# Cleanup.
+
+use test|
+
+DROP DATABASE mysqltest1|
+DROP DATABASE mysqltest2|
+
+
+#
+# BUG#16676: Database CHARSET not used for stored procedures
+#
+
+# Prepare: create database with fixed, pre-defined character set.
+
+--disable_warnings
+DROP DATABASE IF EXISTS mysqltest1|
+--enable_warnings
+
+CREATE DATABASE mysqltest1 DEFAULT CHARACTER SET utf8|
+
+# Test case:
+
+use mysqltest1|
+
+# - Create two stored procedures -- with and without explicit CHARSET-clause;
+
+CREATE PROCEDURE bug16676_p1(
+ IN p1 CHAR(10),
+ INOUT p2 CHAR(10),
+ OUT p3 CHAR(10))
+BEGIN
+ SELECT CHARSET(p1), COLLATION(p1);
+ SELECT CHARSET(p2), COLLATION(p2);
+ SELECT CHARSET(p3), COLLATION(p3);
+END|
+
+CREATE PROCEDURE bug16676_p2(
+ IN p1 CHAR(10) CHARSET koi8r,
+ INOUT p2 CHAR(10) CHARSET cp1251,
+ OUT p3 CHAR(10) CHARSET greek)
+BEGIN
+ SELECT CHARSET(p1), COLLATION(p1);
+ SELECT CHARSET(p2), COLLATION(p2);
+ SELECT CHARSET(p3), COLLATION(p3);
+END|
+
+# - Call procedures.
+
+SET @v2 = 'b'|
+SET @v3 = 'c'|
+
+CALL bug16676_p1('a', @v2, @v3)|
+CALL bug16676_p2('a', @v2, @v3)|
+
+# Cleanup.
+
+use test|
+
+DROP DATABASE mysqltest1|
+#
+# BUG#8153: Stored procedure with subquery and continue handler, wrong result
+#
+
+--disable_warnings
+drop table if exists t3|
+drop table if exists t4|
+drop procedure if exists bug8153_subselect|
+drop procedure if exists bug8153_subselect_a|
+drop procedure if exists bug8153_subselect_b|
+drop procedure if exists bug8153_proc_a|
+drop procedure if exists bug8153_proc_b|
+--enable_warnings
+
+create table t3 (a int)|
+create table t4 (a int)|
+insert into t3 values (1), (1), (2), (3)|
+insert into t4 values (1), (1)|
+
+## Testing the use case reported in Bug#8153
+
+create procedure bug8153_subselect()
+begin
+ declare continue handler for sqlexception
+ begin
+ select 'statement failed';
+ end;
+ update t3 set a=a+1 where (select a from t4 where a=1) is null;
+ select 'statement after update';
+end|
+
+call bug8153_subselect()|
+select * from t3|
+
+call bug8153_subselect()|
+select * from t3|
+
+drop procedure bug8153_subselect|
+
+## Testing a subselect with a non local handler
+
+create procedure bug8153_subselect_a()
+begin
+ declare continue handler for sqlexception
+ begin
+ select 'in continue handler';
+ end;
+
+ select 'reachable code a1';
+ call bug8153_subselect_b();
+ select 'reachable code a2';
+end|
+
+create procedure bug8153_subselect_b()
+begin
+ select 'reachable code b1';
+ update t3 set a=a+1 where (select a from t4 where a=1) is null;
+ select 'unreachable code b2';
+end|
+
+call bug8153_subselect_a()|
+select * from t3|
+
+call bug8153_subselect_a()|
+select * from t3|
+
+drop procedure bug8153_subselect_a|
+drop procedure bug8153_subselect_b|
+
+## Testing extra use cases, found while investigating
+## This is related to BUG#18787, with a non local handler
+
+create procedure bug8153_proc_a()
+begin
+ declare continue handler for sqlexception
+ begin
+ select 'in continue handler';
+ end;
+
+ select 'reachable code a1';
+ call bug8153_proc_b();
+ select 'reachable code a2';
+end|
+
+create procedure bug8153_proc_b()
+begin
+ select 'reachable code b1';
+ select no_such_function();
+ select 'unreachable code b2';
+end|
+
+call bug8153_proc_a()|
+
+drop procedure bug8153_proc_a|
+drop procedure bug8153_proc_b|
+drop table t3|
+drop table t4|
+
+#
+# BUG#19862: Sort with filesort by function evaluates function twice
+#
+--disable_warnings
+drop procedure if exists bug19862|
+--enable_warnings
+CREATE TABLE t11 (a INT)|
+CREATE TABLE t12 (a INT)|
+CREATE FUNCTION bug19862(x INT) RETURNS INT
+ BEGIN
+ INSERT INTO t11 VALUES (x);
+ RETURN x+1;
+ END|
+INSERT INTO t12 VALUES (1), (2)|
+SELECT bug19862(a) FROM t12 ORDER BY 1|
+SELECT * FROM t11|
+DROP TABLE t11, t12|
+DROP FUNCTION bug19862|
+# Bug#21002 "Derived table not selecting from a "real" table fails in JOINs"
+#
+# A regression caused by the fix for Bug#18444: for derived tables we should
+# set an empty string as the current database. They do not belong to any
+# database and must be usable even if there is no database
+# selected.
+--disable_warnings
+drop table if exists t3|
+drop database if exists mysqltest1|
+--enable_warnings
+create table t3 (a int)|
+insert into t3 (a) values (1), (2)|
+
+create database mysqltest1|
+use mysqltest1|
+drop database mysqltest1|
+
+# No current database
+select database()|
+
+select * from (select 1 as a) as t1 natural join (select * from test.t3) as t2|
+use test|
+drop table t3|
+
+
+#
+# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause.
+#
+
+# Prepare.
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS bug16899_p1|
+DROP FUNCTION IF EXISTS bug16899_f1|
+--enable_warnings
+
+--error ER_WRONG_STRING_LENGTH
+CREATE DEFINER=1234567890abcdefGHIKL@localhost PROCEDURE bug16899_p1()
+BEGIN
+ SET @a = 1;
+END|
+
+--error ER_WRONG_STRING_LENGTH
+CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY
+ FUNCTION bug16899_f1() RETURNS INT
+BEGIN
+ RETURN 1;
+END|
+
+
+#
+# BUG#21416: SP: Recursion level higher than zero needed for non-recursive call
+#
+--disable_warnings
+drop procedure if exists bug21416|
+--enable_warnings
+create procedure bug21416() show create procedure bug21416|
+call bug21416()|
+drop procedure bug21416|
+
+#
+# BUG#21493: Crash on the second call of a procedure containing
+# a select statement that uses an IN aggregating subquery
+#
+
+CREATE TABLE t3 (
+ Member_ID varchar(15) NOT NULL,
+ PRIMARY KEY (Member_ID)
+)|
+
+CREATE TABLE t4 (
+ ID int(10) unsigned NOT NULL auto_increment,
+ Member_ID varchar(15) NOT NULL default '',
+ Action varchar(12) NOT NULL,
+ Action_Date datetime NOT NULL,
+ Track varchar(15) default NULL,
+ User varchar(12) default NULL,
+ Date_Updated timestamp NOT NULL default CURRENT_TIMESTAMP on update
+ CURRENT_TIMESTAMP,
+ PRIMARY KEY (ID),
+ KEY Action (Action),
+ KEY Action_Date (Action_Date)
+)|
+
+
+INSERT INTO t3(Member_ID) VALUES
+ ('111111'), ('222222'), ('333333'), ('444444'), ('555555'), ('666666')|
+
+INSERT INTO t4(Member_ID, Action, Action_Date, Track) VALUES
+ ('111111', 'Disenrolled', '2006-03-01', 'CAD' ),
+ ('111111', 'Enrolled', '2006-03-01', 'CAD' ),
+ ('111111', 'Disenrolled', '2006-07-03', 'CAD' ),
+ ('222222', 'Enrolled', '2006-03-07', 'CAD' ),
+ ('222222', 'Enrolled', '2006-03-07', 'CHF' ),
+ ('222222', 'Disenrolled', '2006-08-02', 'CHF' ),
+ ('333333', 'Enrolled', '2006-03-01', 'CAD' ),
+ ('333333', 'Disenrolled', '2006-03-01', 'CAD' ),
+ ('444444', 'Enrolled', '2006-03-01', 'CAD' ),
+ ('555555', 'Disenrolled', '2006-03-01', 'CAD' ),
+ ('555555', 'Enrolled', '2006-07-21', 'CAD' ),
+ ('555555', 'Disenrolled', '2006-03-01', 'CHF' ),
+ ('666666', 'Enrolled', '2006-02-09', 'CAD' ),
+ ('666666', 'Enrolled', '2006-05-12', 'CHF' ),
+ ('666666', 'Disenrolled', '2006-06-01', 'CAD' )|
+
+#--disable_warnings
+DROP FUNCTION IF EXISTS bug21493|
+#--enable_warnings
+
+CREATE FUNCTION bug21493(paramMember VARCHAR(15)) RETURNS varchar(45)
+BEGIN
+DECLARE tracks VARCHAR(45);
+SELECT GROUP_CONCAT(Track SEPARATOR ', ') INTO tracks FROM t4
+ WHERE Member_ID=paramMember AND Action='Enrolled' AND
+ (Track,Action_Date) IN (SELECT Track, MAX(Action_Date) FROM t4
+ WHERE Member_ID=paramMember GROUP BY Track);
+RETURN tracks;
+END|
+
+SELECT bug21493('111111')|
+SELECT bug21493('222222')|
+
+SELECT bug21493(Member_ID) FROM t3|
+
+DROP FUNCTION bug21493|
+DROP TABLE t3,t4|
+
#
# BUG#NNNN: New bug synopsis
#
diff --git a/mysql-test/t/sp.test.orig b/mysql-test/t/sp.test.orig
deleted file mode 100644
index a4b99620344..00000000000
--- a/mysql-test/t/sp.test.orig
+++ /dev/null
@@ -1,5716 +0,0 @@
-#
-# Basic stored PROCEDURE tests
-#
-# Please keep this file free of --error cases and other
-# things that will not run in a single debugged mysqld
-# process (e.g. master-slave things).
-#
-# Test cases for bugs are added at the end. See template there.
-#
-# Tests that require --error go into sp-error.test
-# Tests that require inndb go into sp_trans.test
-# Tests that check privilege and security issues go to sp-security.test.
-# Tests that require multiple connections, except security/privilege tests,
-# go to sp-thread.
-# Tests that uses 'goto' to into sp-goto.test (currently disabled)
-# Tests that destroys system tables (e.g. mysql.proc) for error testing
-# go to sp-destruct.
-
-use test;
-
-# Test tables
-#
-# t1 and t2 are reused throughout the file, and dropped at the end.
-# t3 and up are created and dropped when needed.
-#
---disable_warnings
-drop table if exists t1,t2,t3,t4;
---enable_warnings
-create table t1 (
- id char(16) not null default '',
- data int not null
-);
-create table t2 (
- s char(16),
- i int,
- d double
-);
-
-
-# Single statement, no params.
---disable_warnings
-drop procedure if exists foo42;
---enable_warnings
-create procedure foo42()
- insert into test.t1 values ("foo", 42);
-
-call foo42();
-select * from t1;
-delete from t1;
-drop procedure foo42;
-
-
-# Single statement, two IN params.
---disable_warnings
-drop procedure if exists bar;
---enable_warnings
-create procedure bar(x char(16), y int)
- insert into test.t1 values (x, y);
-
-call bar("bar", 666);
-select * from t1;
-delete from t1;
-# Don't drop procedure yet...
-
-
-# Now for multiple statements...
-delimiter |;
-
-# Empty statement
---disable_warnings
-drop procedure if exists empty|
---enable_warnings
-create procedure empty()
-begin
-end|
-
-call empty()|
-drop procedure empty|
-
-# Scope test. This is legal (warnings might be possible in the future,
-# but for the time being, we just accept it).
---disable_warnings
-drop procedure if exists scope|
---enable_warnings
-create procedure scope(a int, b float)
-begin
- declare b int;
- declare c float;
-
- begin
- declare c int;
- end;
-end|
-
-drop procedure scope|
-
-# Two statements.
---disable_warnings
-drop procedure if exists two|
---enable_warnings
-create procedure two(x1 char(16), x2 char(16), y int)
-begin
- insert into test.t1 values (x1, y);
- insert into test.t1 values (x2, y);
-end|
-
-call two("one", "two", 3)|
-select * from t1|
-delete from t1|
-drop procedure two|
-
-
-# Simple test of local variables and SET.
---disable_warnings
-drop procedure if exists locset|
---enable_warnings
-create procedure locset(x char(16), y int)
-begin
- declare z1, z2 int;
- set z1 = y;
- set z2 = z1+2;
- insert into test.t1 values (x, z2);
-end|
-
-call locset("locset", 19)|
-select * from t1|
-delete from t1|
-drop procedure locset|
-
-
-# In some contexts local variables are not recognized
-# (and in some, you have to qualify the identifier).
---disable_warnings
-drop procedure if exists setcontext|
---enable_warnings
-create procedure setcontext()
-begin
- declare data int default 2;
-
- insert into t1 (id, data) values ("foo", 1);
- replace t1 set data = data, id = "bar";
- update t1 set id = "kaka", data = 3 where t1.data = data;
-end|
-
-call setcontext()|
-select * from t1|
-delete from t1|
-drop procedure setcontext|
-
-
-# Set things to null
-create table t3 ( d date, i int, f double, s varchar(32) )|
-
---disable_warnings
-drop procedure if exists nullset|
---enable_warnings
-create procedure nullset()
-begin
- declare ld date;
- declare li int;
- declare lf double;
- declare ls varchar(32);
-
- set ld = null, li = null, lf = null, ls = null;
- insert into t3 values (ld, li, lf, ls);
-
- insert into t3 (i, f, s) values ((ld is null), 1, "ld is null"),
- ((li is null), 1, "li is null"),
- ((li = 0), null, "li = 0"),
- ((lf is null), 1, "lf is null"),
- ((lf = 0), null, "lf = 0"),
- ((ls is null), 1, "ls is null");
-end|
-
-call nullset()|
-select * from t3|
-drop table t3|
-drop procedure nullset|
-
-
-# The peculiar (non-standard) mixture of variables types in SET.
---disable_warnings
-drop procedure if exists mixset|
---enable_warnings
-create procedure mixset(x char(16), y int)
-begin
- declare z int;
-
- set @z = y, z = 666, max_join_size = 100;
- insert into test.t1 values (x, z);
-end|
-
-call mixset("mixset", 19)|
-show variables like 'max_join_size'|
-select id,data,@z from t1|
-delete from t1|
-drop procedure mixset|
-
-
-# Multiple CALL statements, one with OUT parameter.
---disable_warnings
-drop procedure if exists zip|
---enable_warnings
-create procedure zip(x char(16), y int)
-begin
- declare z int;
- call zap(y, z);
- call bar(x, z);
-end|
-
-# SET local variables and OUT parameter.
---disable_warnings
-drop procedure if exists zap|
---enable_warnings
-create procedure zap(x int, out y int)
-begin
- declare z int;
- set z = x+1, y = z;
-end|
-
-call zip("zip", 99)|
-select * from t1|
-delete from t1|
-drop procedure zip|
-drop procedure bar|
-
-# Top-level OUT parameter
-call zap(7, @zap)|
-select @zap|
-
-drop procedure zap|
-
-
-# "Deep" calls...
---disable_warnings
-drop procedure if exists c1|
---enable_warnings
-create procedure c1(x int)
- call c2("c", x)|
---disable_warnings
-drop procedure if exists c2|
---enable_warnings
-create procedure c2(s char(16), x int)
- call c3(x, s)|
---disable_warnings
-drop procedure if exists c3|
---enable_warnings
-create procedure c3(x int, s char(16))
- call c4("level", x, s)|
---disable_warnings
-drop procedure if exists c4|
---enable_warnings
-create procedure c4(l char(8), x int, s char(16))
- insert into t1 values (concat(l,s), x)|
-
-call c1(42)|
-select * from t1|
-delete from t1|
-drop procedure c1|
-drop procedure c2|
-drop procedure c3|
-drop procedure c4|
-
-# INOUT test
---disable_warnings
-drop procedure if exists iotest|
---enable_warnings
-create procedure iotest(x1 char(16), x2 char(16), y int)
-begin
- call inc2(x2, y);
- insert into test.t1 values (x1, y);
-end|
-
---disable_warnings
-drop procedure if exists inc2|
---enable_warnings
-create procedure inc2(x char(16), y int)
-begin
- call inc(y);
- insert into test.t1 values (x, y);
-end|
-
---disable_warnings
-drop procedure if exists inc|
---enable_warnings
-create procedure inc(inout io int)
- set io = io + 1|
-
-call iotest("io1", "io2", 1)|
-select * from t1|
-delete from t1|
-drop procedure iotest|
-drop procedure inc2|
-
-# Propagating top-level @-vars
---disable_warnings
-drop procedure if exists incr|
---enable_warnings
-create procedure incr(inout x int)
- call inc(x)|
-
-# Before
-select @zap|
-call incr(@zap)|
-# After
-select @zap|
-
-drop procedure inc|
-drop procedure incr|
-
-# Call-by-value test
-# The expected result is:
-# ("cbv2", 4)
-# ("cbv1", 4711)
---disable_warnings
-drop procedure if exists cbv1|
---enable_warnings
-create procedure cbv1()
-begin
- declare y int default 3;
-
- call cbv2(y+1, y);
- insert into test.t1 values ("cbv1", y);
-end|
-
---disable_warnings
-drop procedure if exists cbv2|
---enable_warnings
-create procedure cbv2(y1 int, inout y2 int)
-begin
- set y2 = 4711;
- insert into test.t1 values ("cbv2", y1);
-end|
-
-call cbv1()|
-select * from t1|
-delete from t1|
-drop procedure cbv1|
-drop procedure cbv2|
-
-
-# Subselect arguments
-
-insert into t2 values ("a", 1, 1.1), ("b", 2, 1.2), ("c", 3, 1.3)|
-
---disable_warnings
-drop procedure if exists sub1|
---enable_warnings
-create procedure sub1(id char(16), x int)
- insert into test.t1 values (id, x)|
-
---disable_warnings
-drop procedure if exists sub2|
---enable_warnings
-create procedure sub2(id char(16))
-begin
- declare x int;
- set x = (select sum(t.i) from test.t2 t);
- insert into test.t1 values (id, x);
-end|
-
---disable_warnings
-drop procedure if exists sub3|
---enable_warnings
-create function sub3(i int) returns int
- return i+1|
-
-call sub1("sub1a", (select 7))|
-call sub1("sub1b", (select max(i) from t2))|
---error ER_OPERAND_COLUMNS
-call sub1("sub1c", (select i,d from t2 limit 1))|
-call sub1("sub1d", (select 1 from (select 1) a))|
-call sub2("sub2")|
-select * from t1|
-select sub3((select max(i) from t2))|
-drop procedure sub1|
-drop procedure sub2|
-drop function sub3|
-delete from t1|
-delete from t2|
-
-# Basic tests of the flow control constructs
-
-# Just test on 'x'...
---disable_warnings
-drop procedure if exists a0|
---enable_warnings
-create procedure a0(x int)
-while x do
- set x = x-1;
- insert into test.t1 values ("a0", x);
-end while|
-
-call a0(3)|
-select * from t1|
-delete from t1|
-drop procedure a0|
-
-
-# The same, but with a more traditional test.
---disable_warnings
-drop procedure if exists a|
---enable_warnings
-create procedure a(x int)
-while x > 0 do
- set x = x-1;
- insert into test.t1 values ("a", x);
-end while|
-
-call a(3)|
-select * from t1|
-delete from t1|
-drop procedure a|
-
-
-# REPEAT
---disable_warnings
-drop procedure if exists b|
---enable_warnings
-create procedure b(x int)
-repeat
- insert into test.t1 values (repeat("b",3), x);
- set x = x-1;
-until x = 0 end repeat|
-
-call b(3)|
-select * from t1|
-delete from t1|
-drop procedure b|
-
-
-# Check that repeat isn't parsed the wrong way
---disable_warnings
-drop procedure if exists b2|
---enable_warnings
-create procedure b2(x int)
-repeat(select 1 into outfile 'b2');
- insert into test.t1 values (repeat("b2",3), x);
- set x = x-1;
-until x = 0 end repeat|
-
-# We don't actually want to call it.
-drop procedure b2|
-
-
-# Labelled WHILE with ITERATE (pointless really)
---disable_warnings
-drop procedure if exists c|
---enable_warnings
-create procedure c(x int)
-hmm: while x > 0 do
- insert into test.t1 values ("c", x);
- set x = x-1;
- iterate hmm;
- insert into test.t1 values ("x", x);
-end while hmm|
-
-call c(3)|
-select * from t1|
-delete from t1|
-drop procedure c|
-
-
-# Labelled WHILE with LEAVE
---disable_warnings
-drop procedure if exists d|
---enable_warnings
-create procedure d(x int)
-hmm: while x > 0 do
- insert into test.t1 values ("d", x);
- set x = x-1;
- leave hmm;
- insert into test.t1 values ("x", x);
-end while|
-
-call d(3)|
-select * from t1|
-delete from t1|
-drop procedure d|
-
-
-# LOOP, with simple IF statement
---disable_warnings
-drop procedure if exists e|
---enable_warnings
-create procedure e(x int)
-foo: loop
- if x = 0 then
- leave foo;
- end if;
- insert into test.t1 values ("e", x);
- set x = x-1;
-end loop foo|
-
-call e(3)|
-select * from t1|
-delete from t1|
-drop procedure e|
-
-
-# A full IF statement
---disable_warnings
-drop procedure if exists f|
---enable_warnings
-create procedure f(x int)
-if x < 0 then
- insert into test.t1 values ("f", 0);
-elseif x = 0 then
- insert into test.t1 values ("f", 1);
-else
- insert into test.t1 values ("f", 2);
-end if|
-
-call f(-2)|
-call f(0)|
-call f(4)|
-select * from t1|
-delete from t1|
-drop procedure f|
-
-
-# This form of CASE is really just syntactic sugar for IF-ELSEIF-...
---disable_warnings
-drop procedure if exists g|
---enable_warnings
-create procedure g(x int)
-case
-when x < 0 then
- insert into test.t1 values ("g", 0);
-when x = 0 then
- insert into test.t1 values ("g", 1);
-else
- insert into test.t1 values ("g", 2);
-end case|
-
-call g(-42)|
-call g(0)|
-call g(1)|
-select * from t1|
-delete from t1|
-drop procedure g|
-
-
-# The "simple CASE"
---disable_warnings
-drop procedure if exists h|
---enable_warnings
-create procedure h(x int)
-case x
-when 0 then
- insert into test.t1 values ("h0", x);
-when 1 then
- insert into test.t1 values ("h1", x);
-else
- insert into test.t1 values ("h?", x);
-end case|
-
-call h(0)|
-call h(1)|
-call h(17)|
-select * from t1|
-delete from t1|
-drop procedure h|
-
-
-# It's actually possible to LEAVE a BEGIN-END block
---disable_warnings
-drop procedure if exists i|
---enable_warnings
-create procedure i(x int)
-foo:
-begin
- if x = 0 then
- leave foo;
- end if;
- insert into test.t1 values ("i", x);
-end foo|
-
-call i(0)|
-call i(3)|
-select * from t1|
-delete from t1|
-drop procedure i|
-
-
-# SELECT with one of more result set sent back to the clinet
-insert into t1 values ("foo", 3), ("bar", 19)|
-insert into t2 values ("x", 9, 4.1), ("y", -1, 19.2), ("z", 3, 2.2)|
-
---disable_warnings
-drop procedure if exists sel1|
---enable_warnings
-create procedure sel1()
-begin
- select * from t1;
-end|
-
-call sel1()|
-drop procedure sel1|
-
---disable_warnings
-drop procedure if exists sel2|
---enable_warnings
-create procedure sel2()
-begin
- select * from t1;
- select * from t2;
-end|
-
-call sel2()|
-drop procedure sel2|
-delete from t1|
-delete from t2|
-
-# SELECT INTO local variables
---disable_warnings
-drop procedure if exists into_test|
---enable_warnings
-create procedure into_test(x char(16), y int)
-begin
- insert into test.t1 values (x, y);
- select id,data into x,y from test.t1 limit 1;
- insert into test.t1 values (concat(x, "2"), y+2);
-end|
-
-call into_test("into", 100)|
-select * from t1|
-delete from t1|
-drop procedure into_test|
-
-
-# SELECT INTO with a mix of local and global variables
---disable_warnings
-drop procedure if exists into_tes2|
---enable_warnings
-create procedure into_test2(x char(16), y int)
-begin
- insert into test.t1 values (x, y);
- select id,data into x,@z from test.t1 limit 1;
- insert into test.t1 values (concat(x, "2"), y+2);
-end|
-
-call into_test2("into", 100)|
-select id,data,@z from t1|
-delete from t1|
-drop procedure into_test2|
-
-
-# SELECT * INTO ... (bug test)
---disable_warnings
-drop procedure if exists into_test3|
---enable_warnings
-create procedure into_test3()
-begin
- declare x char(16);
- declare y int;
-
- select * into x,y from test.t1 limit 1;
- insert into test.t2 values (x, y, 0.0);
-end|
-
-insert into t1 values ("into3", 19)|
-# Two call needed for bug test
-call into_test3()|
-call into_test3()|
-select * from t2|
-delete from t1|
-delete from t2|
-drop procedure into_test3|
-
-
-# SELECT INTO with no data is a warning ("no data", which we will
-# not see normally). When not caught, execution proceeds.
---disable_warnings
-drop procedure if exists into_test4|
---enable_warnings
-create procedure into_test4()
-begin
- declare x int;
-
- select data into x from test.t1 limit 1;
- insert into test.t3 values ("into4", x);
-end|
-
-delete from t1|
-create table t3 ( s char(16), d int)|
-call into_test4()|
-select * from t3|
-insert into t1 values ("i4", 77)|
-call into_test4()|
-select * from t3|
-delete from t1|
-drop table t3|
-drop procedure into_test4|
-
-
-# These two (and the two procedures above) caused an assert() to fail in
-# sql_base.cc:lock_tables() at some point.
---disable_warnings
-drop procedure if exists into_outfile|
---enable_warnings
-create procedure into_outfile(x char(16), y int)
-begin
- insert into test.t1 values (x, y);
- select * into outfile "../tmp/spout" from test.t1;
- insert into test.t1 values (concat(x, "2"), y+2);
-end|
-
---system rm -f $MYSQLTEST_VARDIR/tmp/spout
-call into_outfile("ofile", 1)|
---system rm -f $MYSQLTEST_VARDIR/tmp/spout
-delete from t1|
-drop procedure into_outfile|
-
---disable_warnings
-drop procedure if exists into_dumpfile|
---enable_warnings
-create procedure into_dumpfile(x char(16), y int)
-begin
- insert into test.t1 values (x, y);
- select * into dumpfile "../tmp/spdump" from test.t1 limit 1;
- insert into test.t1 values (concat(x, "2"), y+2);
-end|
-
---system rm -f $MYSQLTEST_VARDIR/tmp/spdump
-call into_dumpfile("dfile", 1)|
---system rm -f $MYSQLTEST_VARDIR/tmp/spdump
-delete from t1|
-drop procedure into_dumpfile|
-
---disable_warnings
-drop procedure if exists create_select|
---enable_warnings
-create procedure create_select(x char(16), y int)
-begin
- insert into test.t1 values (x, y);
- create temporary table test.t3 select * from test.t1;
- insert into test.t3 values (concat(x, "2"), y+2);
-end|
-
-call create_select("cs", 90)|
-select * from t1, t3|
-drop table t3|
-delete from t1|
-drop procedure create_select|
-
-
-# A minimal, constant FUNCTION.
---disable_warnings
-drop function if exists e|
---enable_warnings
-create function e() returns double
- return 2.7182818284590452354|
-
-set @e = e()|
-select e(), @e|
-
-# A minimal function with one argument
---disable_warnings
-drop function if exists inc|
---enable_warnings
-create function inc(i int) returns int
- return i+1|
-
-select inc(1), inc(99), inc(-71)|
-
-# A minimal function with two arguments
---disable_warnings
-drop function if exists mul|
---enable_warnings
-create function mul(x int, y int) returns int
- return x*y|
-
-select mul(1,1), mul(3,5), mul(4711, 666)|
-
-# A minimal string function
---disable_warnings
-drop function if exists append|
---enable_warnings
-create function append(s1 char(8), s2 char(8)) returns char(16)
- return concat(s1, s2)|
-
-select append("foo", "bar")|
-
-# A function with flow control
---disable_warnings
-drop function if exists fac|
---enable_warnings
-create function fac(n int unsigned) returns bigint unsigned
-begin
- declare f bigint unsigned default 1;
-
- while n > 1 do
- set f = f * n;
- set n = n - 1;
- end while;
- return f;
-end|
-
-select fac(1), fac(2), fac(5), fac(10)|
-
-# Nested calls
---disable_warnings
-drop function if exists fun|
---enable_warnings
-create function fun(d double, i int, u int unsigned) returns double
- return mul(inc(i), fac(u)) / e()|
-
-select fun(2.3, 3, 5)|
-
-
-# Various function calls in differen statements
-
-insert into t2 values (append("xxx", "yyy"), mul(4,3), e())|
-insert into t2 values (append("a", "b"), mul(2,mul(3,4)), fun(1.7, 4, 6))|
-
-# Disable PS because double's give a bit different values
---disable_ps_protocol
-select * from t2 where s = append("a", "b")|
-select * from t2 where i = mul(4,3) or i = mul(mul(3,4),2)|
-select * from t2 where d = e()|
-select * from t2|
---enable_ps_protocol
-delete from t2|
-
-drop function e|
-drop function inc|
-drop function mul|
-drop function append|
-drop function fun|
-
-
-#
-# CONDITIONs and HANDLERs
-#
-
---disable_warnings
-drop procedure if exists hndlr1|
---enable_warnings
-create procedure hndlr1(val int)
-begin
- declare x int default 0;
- declare foo condition for 1136;
- declare bar condition for sqlstate '42S98'; # Just for testing syntax
- declare zip condition for sqlstate value '42S99'; # Just for testing syntax
- declare continue handler for foo set x = 1;
-
- insert into test.t1 values ("hndlr1", val, 2); # Too many values
- if (x) then
- insert into test.t1 values ("hndlr1", val); # This instead then
- end if;
-end|
-
-call hndlr1(42)|
-select * from t1|
-delete from t1|
-drop procedure hndlr1|
-
---disable_warnings
-drop procedure if exists hndlr2|
---enable_warnings
-create procedure hndlr2(val int)
-begin
- declare x int default 0;
-
- begin
- declare exit handler for sqlstate '21S01' set x = 1;
-
- insert into test.t1 values ("hndlr2", val, 2); # Too many values
- end;
-
- insert into test.t1 values ("hndlr2", x);
-end|
-
-call hndlr2(42)|
-select * from t1|
-delete from t1|
-drop procedure hndlr2|
-
-
---disable_warnings
-drop procedure if exists hndlr3|
---enable_warnings
-create procedure hndlr3(val int)
-begin
- declare x int default 0;
- declare continue handler for sqlexception # Any error
- begin
- declare z int;
-
- set z = 2 * val;
- set x = 1;
- end;
-
- if val < 10 then
- begin
- declare y int;
-
- set y = val + 10;
- insert into test.t1 values ("hndlr3", y, 2); # Too many values
- if x then
- insert into test.t1 values ("hndlr3", y);
- end if;
- end;
- end if;
-end|
-
-call hndlr3(3)|
-select * from t1|
-delete from t1|
-drop procedure hndlr3|
-
-
-# Variables might be uninitialized when using handlers
-# (Otherwise the compiler can detect if a variable is not set, but
-# not in this case.)
-create table t3 ( id char(16), data int )|
-
---disable_warnings
-drop procedure if exists hndlr4|
---enable_warnings
-create procedure hndlr4()
-begin
- declare x int default 0;
- declare val int; # No default
- declare continue handler for sqlstate '02000' set x=1;
-
- select data into val from test.t3 where id='z' limit 1; # No hits
-
- insert into test.t3 values ('z', val);
-end|
-
-call hndlr4()|
-select * from t3|
-drop table t3|
-drop procedure hndlr4|
-
-
-#
-# Cursors
-#
---disable_warnings
-drop procedure if exists cur1|
---enable_warnings
-create procedure cur1()
-begin
- declare a char(16);
- declare b int;
- declare c double;
- declare done int default 0;
- declare c cursor for select * from test.t2;
- declare continue handler for sqlstate '02000' set done = 1;
-
- open c;
- repeat
- fetch c into a, b, c;
- if not done then
- insert into test.t1 values (a, b+c);
- end if;
- until done end repeat;
- close c;
-end|
-
-insert into t2 values ("foo", 42, -1.9), ("bar", 3, 12.1), ("zap", 666, -3.14)|
-call cur1()|
-select * from t1|
-drop procedure cur1|
-
-create table t3 ( s char(16), i int )|
-
---disable_warnings
-drop procedure if exists cur2|
---enable_warnings
-create procedure cur2()
-begin
- declare done int default 0;
- declare c1 cursor for select id,data from test.t1;
- declare c2 cursor for select i from test.t2;
- declare continue handler for sqlstate '02000' set done = 1;
-
- open c1;
- open c2;
- repeat
- begin
- declare a char(16);
- declare b,c int;
-
- fetch from c1 into a, b;
- fetch next from c2 into c;
- if not done then
- if b < c then
- insert into test.t3 values (a, b);
- else
- insert into test.t3 values (a, c);
- end if;
- end if;
- end;
- until done end repeat;
- close c1;
- close c2;
-end|
-
-call cur2()|
-select * from t3|
-delete from t1|
-delete from t2|
-drop table t3|
-drop procedure cur2|
-
-
-# The few characteristics we parse
---disable_warnings
-drop procedure if exists chistics|
---enable_warnings
-create procedure chistics()
- language sql
- modifies sql data
- not deterministic
- sql security definer
- comment 'Characteristics procedure test'
- insert into t1 values ("chistics", 1)|
-
-show create procedure chistics|
-# Call it, just to make sure.
-call chistics()|
-select * from t1|
-delete from t1|
-alter procedure chistics sql security invoker|
-show create procedure chistics|
-drop procedure chistics|
-
---disable_warnings
-drop function if exists chistics|
---enable_warnings
-create function chistics() returns int
- language sql
- deterministic
- sql security invoker
- comment 'Characteristics procedure test'
- return 42|
-
-show create function chistics|
-# Call it, just to make sure.
-select chistics()|
-alter function chistics
- no sql
- comment 'Characteristics function test'|
-show create function chistics|
-drop function chistics|
-
-
-# Check mode settings
-insert into t1 values ("foo", 1), ("bar", 2), ("zip", 3)|
-
-set @@sql_mode = 'ANSI'|
-delimiter $|
---disable_warnings
-drop procedure if exists modes$
---enable_warnings
-create procedure modes(out c1 int, out c2 int)
-begin
- declare done int default 0;
- declare x int;
- declare c cursor for select data from t1;
- declare continue handler for sqlstate '02000' set done = 1;
-
- select 1 || 2 into c1;
- set c2 = 0;
- open c;
- repeat
- fetch c into x;
- if not done then
- set c2 = c2 + 1;
- end if;
- until done end repeat;
- close c;
-end$
-delimiter |$
-set @@sql_mode = ''|
-
-set sql_select_limit = 1|
-call modes(@c1, @c2)|
-set sql_select_limit = default|
-
-select @c1, @c2|
-delete from t1|
-drop procedure modes|
-
-
-# Check that dropping a database without routines works.
-# (Dropping with routines is tested in sp-security.test)
-# First an empty db.
-create database sp_db1|
-drop database sp_db1|
-
-# Again, with a table.
-create database sp_db2|
-use sp_db2|
-# Just put something in here...
-create table t3 ( s char(4), t int )|
-insert into t3 values ("abcd", 42), ("dcba", 666)|
-use test|
-drop database sp_db2|
-
-# And yet again, with just a procedure.
-create database sp_db3|
-use sp_db3|
---disable_warnings
-drop procedure if exists dummy|
---enable_warnings
-create procedure dummy(out x int)
- set x = 42|
-use test|
-drop database sp_db3|
-# Check that it's gone
-select type,db,name from mysql.proc where db = 'sp_db3'|
-
-
-# ROW_COUNT() function after a CALL
-# We test the other cases here too, although it's not strictly SP specific
---disable_warnings
-drop procedure if exists rc|
---enable_warnings
-create procedure rc()
-begin
- delete from t1;
- insert into t1 values ("a", 1), ("b", 2), ("c", 3);
-end|
-
-call rc()|
-select row_count()|
---disable_ps_protocol
-update t1 set data=42 where id = "b";
-select row_count()|
---enable_ps_protocol
-delete from t1|
-select row_count()|
-delete from t1|
-select row_count()|
-select * from t1|
-select row_count()|
-drop procedure rc|
-
-
-#
-# Let us test how well new locking scheme works.
-#
-
-# Let us prepare playground
---disable_warnings
-drop function if exists f0|
-drop function if exists f1|
-drop function if exists f2|
-drop function if exists f3|
-drop function if exists f4|
-drop function if exists f5|
-drop function if exists f6|
-drop function if exists f7|
-drop function if exists f8|
-drop function if exists f9|
-drop function if exists f10|
-drop function if exists f11|
-drop function if exists f12_1|
-drop function if exists f12_2|
-drop view if exists v0|
-drop view if exists v1|
-drop view if exists v2|
---enable_warnings
-delete from t1|
-delete from t2|
-insert into t1 values ("a", 1), ("b", 2) |
-insert into t2 values ("a", 1, 1.0), ("b", 2, 2.0), ("c", 3, 3.0) |
-
-# Test the simplest function using tables
-create function f1() returns int
- return (select sum(data) from t1)|
-select f1()|
-# This should work too (and give 2 rows as result)
-select id, f1() from t1|
-
-# Function which uses two instances of table simultaneously
-create function f2() returns int
- return (select data from t1 where data <= (select sum(data) from t1) limit 1)|
-select f2()|
-select id, f2() from t1|
-
-# Function which uses the same table twice in different queries
-create function f3() returns int
-begin
- declare n int;
- declare m int;
- set n:= (select min(data) from t1);
- set m:= (select max(data) from t1);
- return n < m;
-end|
-select f3()|
-select id, f3() from t1|
-
-# Calling two functions using same table
-select f1(), f3()|
-select id, f1(), f3() from t1|
-
-# Function which uses two different tables
-create function f4() returns double
- return (select d from t1, t2 where t1.data = t2.i and t1.id= "b")|
-select f4()|
-select s, f4() from t2|
-
-# Recursive functions which due to this recursion require simultaneous
-# access to several instance of the same table won't work
-create function f5(i int) returns int
-begin
- if i <= 0 then
- return 0;
- elseif i = 1 then
- return (select count(*) from t1 where data = i);
- else
- return (select count(*) + f5( i - 1) from t1 where data = i);
- end if;
-end|
-select f5(1)|
-# Since currently recursive functions are disallowed ER_SP_NO_RECURSION
-# error will be returned, once we will allow them error about
-# insufficient number of locked tables will be returned instead.
---error ER_SP_NO_RECURSION
-select f5(2)|
---error ER_SP_NO_RECURSION
-select f5(3)|
-
-# OTOH this should work
-create function f6() returns int
-begin
- declare n int;
- set n:= f1();
- return (select count(*) from t1 where data <= f7() and data <= n);
-end|
-create function f7() returns int
- return (select sum(data) from t1 where data <= f1())|
-select f6()|
-select id, f6() from t1|
-
-#
-# Let us test how new locking work with views
-#
-# The most trivial view
-create view v1 (a) as select f1()|
-select * from v1|
-select id, a from t1, v1|
-select * from v1, v1 as v|
-# A bit more complex construction
-create view v2 (a) as select a*10 from v1|
-select * from v2|
-select id, a from t1, v2|
-select * from v1, v2|
-
-# Nice example where the same view is used on
-# on different expression levels
-create function f8 () returns int
- return (select count(*) from v2)|
-
-select *, f8() from v1|
-
-# Let us test what will happen if function is missing
-drop function f1|
---error 1356
-select * from v1|
-
-# And what will happen if we have recursion which involves
-# views and functions ?
-create function f1() returns int
- return (select sum(data) from t1) + (select sum(data) from v1)|
---error ER_SP_NO_RECURSION
-select f1()|
---error ER_SP_NO_RECURSION
-select * from v1|
---error ER_SP_NO_RECURSION
-select * from v2|
-# Back to the normal cases
-drop function f1|
-create function f1() returns int
- return (select sum(data) from t1)|
-
-# Let us also test some weird cases where no real tables is used
-create function f0() returns int
- return (select * from (select 100) as r)|
-select f0()|
-select *, f0() from (select 1) as t|
-create view v0 as select f0()|
-select * from v0|
-select *, f0() from v0|
-
-#
-# Let us test how well prelocking works with explicit LOCK TABLES.
-#
-lock tables t1 read, t1 as t11 read|
-# These should work well
-select f3()|
-select id, f3() from t1 as t11|
-# Degenerate cases work too :)
-select f0()|
-select * from v0|
-select *, f0() from v0, (select 123) as d1|
-# But these should not !
---error 1100
-select id, f3() from t1|
---error 1100
-select f4()|
-unlock tables|
-
-# Let us test how LOCK TABLES which implicitly depends on functions
-# works
-lock tables v2 read, mysql.proc read|
-select * from v2|
-select * from v1|
-# These should not work as we have too little instances of tables locked
---error 1100
-select * from v1, t1|
---error 1100
-select f4()|
-unlock tables|
-
-# Tests for handling of temporary tables in functions.
-#
-# Unlike for permanent tables we should be able to create, use
-# and drop such tables in functions.
-#
-# Simplest function using temporary table. It is also test case for bug
-# #12198 "Temporary table aliasing does not work inside stored functions"
-create function f9() returns int
-begin
- declare a, b int;
- drop temporary table if exists t3;
- create temporary table t3 (id int);
- insert into t3 values (1), (2), (3);
- set a:= (select count(*) from t3);
- set b:= (select count(*) from t3 t3_alias);
- return a + b;
-end|
-# This will emit warning as t3 was not existing before.
-select f9()|
-select f9() from t1 limit 1|
-
-# Function which uses both temporary and permanent tables.
-create function f10() returns int
-begin
- drop temporary table if exists t3;
- create temporary table t3 (id int);
- insert into t3 select id from t4;
- return (select count(*) from t3);
-end|
-# Check that we don't ignore completely tables used in function
---error ER_NO_SUCH_TABLE
-select f10()|
-create table t4 as select 1 as id|
-select f10()|
-
-# Practical cases which we don't handle well (yet)
-#
-# Function which does not work because of well-known and documented
-# limitation of MySQL. We can't use the several instances of the
-# same temporary table in statement.
-create function f11() returns int
-begin
- drop temporary table if exists t3;
- create temporary table t3 (id int);
- insert into t3 values (1), (2), (3);
- return (select count(*) from t3 as a, t3 as b);
-end|
---error ER_CANT_REOPEN_TABLE
-select f11()|
---error ER_CANT_REOPEN_TABLE
-select f11() from t1|
-# We don't handle temporary tables used by nested functions well
-create function f12_1() returns int
-begin
- drop temporary table if exists t3;
- create temporary table t3 (id int);
- insert into t3 values (1), (2), (3);
- return f12_2();
-end|
-create function f12_2() returns int
- return (select count(*) from t3)|
-# We need clean start to get error
-drop temporary table t3|
---error ER_NO_SUCH_TABLE
-select f12_1()|
---error ER_NO_SUCH_TABLE
-select f12_1() from t1 limit 1|
-
-# Cleanup
-drop function f0|
-drop function f1|
-drop function f2|
-drop function f3|
-drop function f4|
-drop function f5|
-drop function f6|
-drop function f7|
-drop function f8|
-drop function f9|
-drop function f10|
-drop function f11|
-drop function f12_1|
-drop function f12_2|
-drop view v0|
-drop view v1|
-drop view v2|
-delete from t1 |
-delete from t2 |
-drop table t4|
-
-# End of non-bug tests
-
-
-#
-# Some "real" examples
-#
-
-# fac
-
---disable_warnings
-drop table if exists t3|
---enable_warnings
-create table t3 (n int unsigned not null primary key, f bigint unsigned)|
-
---disable_warnings
-drop procedure if exists ifac|
---enable_warnings
-create procedure ifac(n int unsigned)
-begin
- declare i int unsigned default 1;
-
- if n > 20 then
- set n = 20; # bigint overflow otherwise
- end if;
- while i <= n do
- begin
- insert into test.t3 values (i, fac(i));
- set i = i + 1;
- end;
- end while;
-end|
-
-call ifac(20)|
-select * from t3|
-drop table t3|
---replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
-show function status like '%f%'|
-drop procedure ifac|
-drop function fac|
---replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
-show function status like '%f%'|
-
-
-# primes
-
---disable_warnings
-drop table if exists t3|
---enable_warnings
-
-create table t3 (
- i int unsigned not null primary key,
- p bigint unsigned not null
-)|
-
-insert into t3 values
- ( 0, 3), ( 1, 5), ( 2, 7), ( 3, 11), ( 4, 13),
- ( 5, 17), ( 6, 19), ( 7, 23), ( 8, 29), ( 9, 31),
- (10, 37), (11, 41), (12, 43), (13, 47), (14, 53),
- (15, 59), (16, 61), (17, 67), (18, 71), (19, 73),
- (20, 79), (21, 83), (22, 89), (23, 97), (24, 101),
- (25, 103), (26, 107), (27, 109), (28, 113), (29, 127),
- (30, 131), (31, 137), (32, 139), (33, 149), (34, 151),
- (35, 157), (36, 163), (37, 167), (38, 173), (39, 179),
- (40, 181), (41, 191), (42, 193), (43, 197), (44, 199)|
-
---disable_warnings
-drop procedure if exists opp|
---enable_warnings
-create procedure opp(n bigint unsigned, out pp bool)
-begin
- declare r double;
- declare b, s bigint unsigned default 0;
-
- set r = sqrt(n);
-
- again:
- loop
- if s = 45 then
- set b = b+200, s = 0;
- else
- begin
- declare p bigint unsigned;
-
- select t.p into p from test.t3 t where t.i = s;
- if b+p > r then
- set pp = 1;
- leave again;
- end if;
- if mod(n, b+p) = 0 then
- set pp = 0;
- leave again;
- end if;
- set s = s+1;
- end;
- end if;
- end loop;
-end|
-
---disable_warnings
-drop procedure if exists ip|
---enable_warnings
-create procedure ip(m int unsigned)
-begin
- declare p bigint unsigned;
- declare i int unsigned;
-
- set i=45, p=201;
-
- while i < m do
- begin
- declare pp bool default 0;
-
- call opp(p, pp);
- if pp then
- insert into test.t3 values (i, p);
- set i = i+1;
- end if;
- set p = p+2;
- end;
- end while;
-end|
-show create procedure opp|
---replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
-show procedure status like '%p%'|
-
-# This isn't the fastest way in the world to compute prime numbers, so
-# don't be too ambitious. ;-)
-call ip(200)|
-# We don't want to select the entire table here, just pick a few
-# examples.
-# The expected result is:
-# i p
-# --- ----
-# 45 211
-# 100 557
-# 199 1229
-select * from t3 where i=45 or i=100 or i=199|
-drop table t3|
-drop procedure opp|
-drop procedure ip|
---replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
-show procedure status like '%p%'|
-
-
-# Fibonacci, for recursion test. (Yet Another Numerical series :)
-#
---disable_warnings
-drop table if exists t3|
---enable_warnings
-create table t3 ( f bigint unsigned not null )|
-
-# We deliberately do it the awkward way, fetching the last two
-# values from the table, in order to exercise various statements
-# and table accesses at each turn.
---disable_warnings
-drop procedure if exists fib|
---enable_warnings
-create procedure fib(n int unsigned)
-begin
- if n > 1 then
- begin
- declare x, y bigint unsigned;
- declare c cursor for select f from t3 order by f desc limit 2;
-
- open c;
- fetch c into y;
- fetch c into x;
- close c;
- insert into t3 values (x+y);
- call fib(n-1);
- end;
- end if;
-end|
-
-# Enable recursion
-set @@max_sp_recursion_depth= 20|
-
-# Minimum test: recursion of 3 levels
-
-insert into t3 values (0), (1)|
-
-call fib(3)|
-
-select * from t3 order by f asc|
-
-delete from t3|
-
-# The original test, 20 levels, ran into memory limits on some machines
-# and builds. Try 10 instead...
-
-insert into t3 values (0), (1)|
-
-call fib(10)|
-
-select * from t3 order by f asc|
-drop table t3|
-drop procedure fib|
-set @@max_sp_recursion_depth= 0|
-
-#
-# Comment & suid
-#
-
---disable_warnings
-drop procedure if exists bar|
---enable_warnings
-create procedure bar(x char(16), y int)
- comment "111111111111" sql security invoker
- insert into test.t1 values (x, y)|
---replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
-show procedure status like 'bar'|
-alter procedure bar comment "2222222222" sql security definer|
-alter procedure bar comment "3333333333"|
-alter procedure bar|
-show create procedure bar|
---replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
-show procedure status like 'bar'|
-drop procedure bar|
-
-#
-# rexecution
-#
---disable_warnings
-drop procedure if exists p1|
---enable_warnings
-create procedure p1 ()
- select (select s1 from t3) from t3|
-
-create table t3 (s1 int)|
-
-call p1()|
-insert into t3 values (1)|
-call p1()|
-drop procedure p1|
-drop table t3|
-
-#
-# backticks
-#
---disable_warnings
-drop function if exists foo|
---enable_warnings
-create function `foo` () returns int
- return 5|
-select `foo` ()|
-drop function `foo`|
-
-#
-# Implicit LOCK/UNLOCK TABLES for table access in functions
-#
-
---disable_warnings
-drop function if exists t1max|
---enable_warnings
-create function t1max() returns int
-begin
- declare x int;
- select max(data) into x from t1;
- return x;
-end|
-
-insert into t1 values ("foo", 3), ("bar", 2), ("zip", 5), ("zap", 1)|
-select t1max()|
-drop function t1max|
-
-create table t3 (
- v char(16) not null primary key,
- c int unsigned not null
-)|
-
-create function getcount(s char(16)) returns int
-begin
- declare x int;
-
- select count(*) into x from t3 where v = s;
- if x = 0 then
- insert into t3 values (s, 1);
- else
- update t3 set c = c+1 where v = s;
- end if;
- return x;
-end|
-
-select * from t1 where data = getcount("bar")|
-select * from t3|
-select getcount("zip")|
-select getcount("zip")|
-select * from t3|
-select getcount(id) from t1 where data = 3|
-select getcount(id) from t1 where data = 5|
-select * from t3|
-drop table t3|
-drop function getcount|
-
-
-# Test cases for different combinations of condition handlers in nested
-# begin-end blocks in stored procedures.
-#
-# Note that the standard specifies that the most specific handler should
-# be triggered even if it's an outer handler masked by a less specific
-# handler in an inner block.
-# Note also that '02000' is more specific than NOT FOUND; there might be
-# other '02xxx' states, even if we currently do not issue them in any
-# situation (e.g. '02001').
-#
-# The combinations we test are these:
-#
-# Inner
-# errcode sqlstate not found sqlwarning sqlexception
-# Outer +------------+------------+------------+------------+------------+
-#errcode | h_ee (i) | h_es (o) | h_en (o) | h_ew (o) | h_ex (o) |
-#sqlstate | h_se (i) | h_ss (i) | h_sn (o) | h_sw (o) | h_sx (o) |
-#not found | h_ne (i) | h_ns (i) | h_nn (i) | | |
-#sqlwarning | h_we (i) | h_ws (i) | | h_ww (i) | |
-#sqlexception | h_xe (i) | h_xs (i) | | | h_xx (i) |
-# +------------+---------------------------------------------------+
-#
-# (i) means that the inner handler is the one that should be invoked,
-# (o) means that the outer handler should be invoked.
-#
-# ('not found', 'sqlwarning' and 'sqlexception' are mutually exclusive, hence
-# no tests for those combinations.)
-#
-
---disable_warnings
-drop table if exists t3|
-drop procedure if exists h_ee|
-drop procedure if exists h_es|
-drop procedure if exists h_en|
-drop procedure if exists h_ew|
-drop procedure if exists h_ex|
-drop procedure if exists h_se|
-drop procedure if exists h_ss|
-drop procedure if exists h_sn|
-drop procedure if exists h_sw|
-drop procedure if exists h_sx|
-drop procedure if exists h_ne|
-drop procedure if exists h_ns|
-drop procedure if exists h_nn|
-drop procedure if exists h_we|
-drop procedure if exists h_ws|
-drop procedure if exists h_ww|
-drop procedure if exists h_xe|
-drop procedure if exists h_xs|
-drop procedure if exists h_xx|
---enable_warnings
-
-# smallint - to get out of range warnings
-# primary key - to get constraint errors
-create table t3 (a smallint primary key)|
-
-insert into t3 (a) values (1)|
-
-create procedure h_ee()
- deterministic
-begin
- declare continue handler for 1062 -- ER_DUP_ENTRY
- select 'Outer (bad)' as 'h_ee';
-
- begin
- declare continue handler for 1062 -- ER_DUP_ENTRY
- select 'Inner (good)' as 'h_ee';
-
- insert into t3 values (1);
- end;
-end|
-
-create procedure h_es()
- deterministic
-begin
- declare continue handler for 1062 -- ER_DUP_ENTRY
- select 'Outer (good)' as 'h_es';
-
- begin
- -- integrity constraint violation
- declare continue handler for sqlstate '23000'
- select 'Inner (bad)' as 'h_es';
-
- insert into t3 values (1);
- end;
-end|
-
-create procedure h_en()
- deterministic
-begin
- declare continue handler for 1329 -- ER_SP_FETCH_NO_DATA
- select 'Outer (good)' as 'h_en';
-
- begin
- declare x int;
- declare continue handler for sqlstate '02000' -- no data
- select 'Inner (bad)' as 'h_en';
-
- select a into x from t3 where a = 42;
- end;
-end|
-
-create procedure h_ew()
- deterministic
-begin
- declare continue handler for 1264 -- ER_WARN_DATA_OUT_OF_RANGE
- select 'Outer (good)' as 'h_ew';
-
- begin
- declare continue handler for sqlwarning
- select 'Inner (bad)' as 'h_ew';
-
- insert into t3 values (123456789012);
- end;
- delete from t3;
- insert into t3 values (1);
-end|
-
-create procedure h_ex()
- deterministic
-begin
- declare continue handler for 1062 -- ER_DUP_ENTRY
- select 'Outer (good)' as 'h_ex';
-
- begin
- declare continue handler for sqlexception
- select 'Inner (bad)' as 'h_ex';
-
- insert into t3 values (1);
- end;
-end|
-
-create procedure h_se()
- deterministic
-begin
- -- integrity constraint violation
- declare continue handler for sqlstate '23000'
- select 'Outer (bad)' as 'h_se';
-
- begin
- declare continue handler for 1062 -- ER_DUP_ENTRY
- select 'Inner (good)' as 'h_se';
-
- insert into t3 values (1);
- end;
-end|
-
-create procedure h_ss()
- deterministic
-begin
- -- integrity constraint violation
- declare continue handler for sqlstate '23000'
- select 'Outer (bad)' as 'h_ss';
-
- begin
- -- integrity constraint violation
- declare continue handler for sqlstate '23000'
- select 'Inner (good)' as 'h_ss';
-
- insert into t3 values (1);
- end;
-end|
-
-create procedure h_sn()
- deterministic
-begin
- -- Note: '02000' is more specific than NOT FOUND ;
- -- there might be other not found states
- declare continue handler for sqlstate '02000' -- no data
- select 'Outer (good)' as 'h_sn';
-
- begin
- declare x int;
- declare continue handler for not found
- select 'Inner (bad)' as 'h_sn';
-
- select a into x from t3 where a = 42;
- end;
-end|
-
-create procedure h_sw()
- deterministic
-begin
- -- data exception - numeric value out of range
- declare continue handler for sqlstate '22003'
- select 'Outer (good)' as 'h_sw';
-
- begin
- declare continue handler for sqlwarning
- select 'Inner (bad)' as 'h_sw';
-
- insert into t3 values (123456789012);
- end;
- delete from t3;
- insert into t3 values (1);
-end|
-
-create procedure h_sx()
- deterministic
-begin
- -- integrity constraint violation
- declare continue handler for sqlstate '23000'
- select 'Outer (good)' as 'h_sx';
-
- begin
- declare continue handler for sqlexception
- select 'Inner (bad)' as 'h_sx';
-
- insert into t3 values (1);
- end;
-end|
-
-create procedure h_ne()
- deterministic
-begin
- declare continue handler for not found
- select 'Outer (bad)' as 'h_ne';
-
- begin
- declare x int;
- declare continue handler for 1329 -- ER_SP_FETCH_NO_DATA
- select 'Inner (good)' as 'h_ne';
-
- select a into x from t3 where a = 42;
- end;
-end|
-
-create procedure h_ns()
- deterministic
-begin
- declare continue handler for not found
- select 'Outer (bad)' as 'h_ns';
-
- begin
- declare x int;
- declare continue handler for sqlstate '02000' -- no data
- select 'Inner (good)' as 'h_ns';
-
- select a into x from t3 where a = 42;
- end;
-end|
-
-create procedure h_nn()
- deterministic
-begin
- declare continue handler for not found
- select 'Outer (bad)' as 'h_nn';
-
- begin
- declare x int;
- declare continue handler for not found
- select 'Inner (good)' as 'h_nn';
-
- select a into x from t3 where a = 42;
- end;
-end|
-
-create procedure h_we()
- deterministic
-begin
- declare continue handler for sqlwarning
- select 'Outer (bad)' as 'h_we';
-
- begin
- declare continue handler for 1264 -- ER_WARN_DATA_OUT_OF_RANGE
- select 'Inner (good)' as 'h_we';
-
- insert into t3 values (123456789012);
- end;
- delete from t3;
- insert into t3 values (1);
-end|
-
-create procedure h_ws()
- deterministic
-begin
- declare continue handler for sqlwarning
- select 'Outer (bad)' as 'h_ws';
-
- begin
- -- data exception - numeric value out of range
- declare continue handler for sqlstate '22003'
- select 'Inner (good)' as 'h_ws';
-
- insert into t3 values (123456789012);
- end;
- delete from t3;
- insert into t3 values (1);
-end|
-
-create procedure h_ww()
- deterministic
-begin
- declare continue handler for sqlwarning
- select 'Outer (bad)' as 'h_ww';
-
- begin
- declare continue handler for sqlwarning
- select 'Inner (good)' as 'h_ww';
-
- insert into t3 values (123456789012);
- end;
- delete from t3;
- insert into t3 values (1);
-end|
-
-create procedure h_xe()
- deterministic
-begin
- declare continue handler for sqlexception
- select 'Outer (bad)' as 'h_xe';
-
- begin
- declare continue handler for 1062 -- ER_DUP_ENTRY
- select 'Inner (good)' as 'h_xe';
-
- insert into t3 values (1);
- end;
-end|
-
-create procedure h_xs()
- deterministic
-begin
- declare continue handler for sqlexception
- select 'Outer (bad)' as 'h_xs';
-
- begin
- -- integrity constraint violation
- declare continue handler for sqlstate '23000'
- select 'Inner (good)' as 'h_xs';
-
- insert into t3 values (1);
- end;
-end|
-
-create procedure h_xx()
- deterministic
-begin
- declare continue handler for sqlexception
- select 'Outer (bad)' as 'h_xx';
-
- begin
- declare continue handler for sqlexception
- select 'Inner (good)' as 'h_xx';
-
- insert into t3 values (1);
- end;
-end|
-
-call h_ee()|
-call h_es()|
-call h_en()|
-call h_ew()|
-call h_ex()|
-call h_se()|
-call h_ss()|
-call h_sn()|
-call h_sw()|
-call h_sx()|
-call h_ne()|
-call h_ns()|
-call h_nn()|
-call h_we()|
-call h_ws()|
-call h_ww()|
-call h_xe()|
-call h_xs()|
-call h_xx()|
-
-drop table t3|
-drop procedure h_ee|
-drop procedure h_es|
-drop procedure h_en|
-drop procedure h_ew|
-drop procedure h_ex|
-drop procedure h_se|
-drop procedure h_ss|
-drop procedure h_sn|
-drop procedure h_sw|
-drop procedure h_sx|
-drop procedure h_ne|
-drop procedure h_ns|
-drop procedure h_nn|
-drop procedure h_we|
-drop procedure h_ws|
-drop procedure h_ww|
-drop procedure h_xe|
-drop procedure h_xs|
-drop procedure h_xx|
-
-
-#
-# Test cases for old bugs
-#
-
-#
-# BUG#822
-#
---disable_warnings
-drop procedure if exists bug822|
---enable_warnings
-create procedure bug822(a_id char(16), a_data int)
-begin
- declare n int;
- select count(*) into n from t1 where id = a_id and data = a_data;
- if n = 0 then
- insert into t1 (id, data) values (a_id, a_data);
- end if;
-end|
-
-delete from t1|
-call bug822('foo', 42)|
-call bug822('foo', 42)|
-call bug822('bar', 666)|
-select * from t1|
-delete from t1|
-drop procedure bug822|
-
-#
-# BUG#1495
-#
---disable_warnings
-drop procedure if exists bug1495|
---enable_warnings
-create procedure bug1495()
-begin
- declare x int;
-
- select data into x from t1 order by id limit 1;
- if x > 10 then
- insert into t1 values ("less", x-10);
- else
- insert into t1 values ("more", x+10);
- end if;
-end|
-
-insert into t1 values ('foo', 12)|
-call bug1495()|
-delete from t1 where id='foo'|
-insert into t1 values ('bar', 7)|
-call bug1495()|
-delete from t1 where id='bar'|
-select * from t1|
-delete from t1|
-drop procedure bug1495|
-
-#
-# BUG#1547
-#
---disable_warnings
-drop procedure if exists bug1547|
---enable_warnings
-create procedure bug1547(s char(16))
-begin
- declare x int;
-
- select data into x from t1 where s = id limit 1;
- if x > 10 then
- insert into t1 values ("less", x-10);
- else
- insert into t1 values ("more", x+10);
- end if;
-end|
-
-insert into t1 values ("foo", 12), ("bar", 7)|
-call bug1547("foo")|
-call bug1547("bar")|
-select * from t1|
-delete from t1|
-drop procedure bug1547|
-
-#
-# BUG#1656
-#
---disable_warnings
-drop table if exists t70|
---enable_warnings
-create table t70 (s1 int,s2 int)|
-insert into t70 values (1,2)|
-
---disable_warnings
-drop procedure if exists bug1656|
---enable_warnings
-create procedure bug1656(out p1 int, out p2 int)
- select * into p1, p1 from t70|
-
-call bug1656(@1, @2)|
-select @1, @2|
-drop table t70|
-drop procedure bug1656|
-
-#
-# BUG#1862
-#
-create table t3(a int)|
-
---disable_warnings
-drop procedure if exists bug1862|
---enable_warnings
-create procedure bug1862()
-begin
- insert into t3 values(2);
- flush tables;
-end|
-
-call bug1862()|
-# the second call caused a segmentation
-call bug1862()|
-select * from t3|
-drop table t3|
-drop procedure bug1862|
-
-#
-# BUG#1874
-#
---disable_warnings
-drop procedure if exists bug1874|
---enable_warnings
-create procedure bug1874()
-begin
- declare x int;
- declare y double;
- select max(data) into x from t1;
- insert into t2 values ("max", x, 0);
- select min(data) into x from t1;
- insert into t2 values ("min", x, 0);
- select sum(data) into x from t1;
- insert into t2 values ("sum", x, 0);
- select avg(data) into y from t1;
- insert into t2 values ("avg", 0, y);
-end|
-
-insert into t1 (data) values (3), (1), (5), (9), (4)|
-call bug1874()|
-select * from t2|
-delete from t1|
-delete from t2|
-drop procedure bug1874|
-
-#
-# BUG#2260
-#
---disable_warnings
-drop procedure if exists bug2260|
---enable_warnings
-create procedure bug2260()
-begin
- declare v1 int;
- declare c1 cursor for select data from t1;
- declare continue handler for not found set @x2 = 1;
-
- open c1;
- fetch c1 into v1;
- set @x2 = 2;
- close c1;
-end|
-
-call bug2260()|
-select @x2|
-drop procedure bug2260|
-
-#
-# BUG#2267 "Lost connect if stored procedure has SHOW FUNCTION STATUS"
-#
---disable_warnings
-drop procedure if exists bug2267_1|
---enable_warnings
-create procedure bug2267_1()
-begin
- show procedure status;
-end|
-
---disable_warnings
-drop procedure if exists bug2267_2|
---enable_warnings
-create procedure bug2267_2()
-begin
- show function status;
-end|
-
---disable_warnings
-drop procedure if exists bug2267_3|
---enable_warnings
-create procedure bug2267_3()
-begin
- show create procedure bug2267_1;
-end|
-
---disable_warnings
-drop procedure if exists bug2267_4|
-drop function if exists bug2267_4|
---enable_warnings
-create procedure bug2267_4()
-begin
- show create function bug2267_4;
-end|
-create function bug2267_4() returns int return 100|
-
---replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
-call bug2267_1()|
---replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
-call bug2267_2()|
-call bug2267_3()|
-call bug2267_4()|
-
-drop procedure bug2267_1|
-drop procedure bug2267_2|
-drop procedure bug2267_3|
-drop procedure bug2267_4|
-drop function bug2267_4|
-
-#
-# BUG#2227
-#
---disable_warnings
-drop procedure if exists bug2227|
---enable_warnings
-create procedure bug2227(x int)
-begin
- declare y float default 2.6;
- declare z char(16) default "zzz";
-
- select 1.3, x, y, 42, z;
-end|
-
-call bug2227(9)|
-drop procedure bug2227|
-
-#
-# BUG#2614 "Stored procedure with INSERT ... SELECT that does not
-# contain any tables crashes server"
-#
---disable_warnings
-drop procedure if exists bug2614|
---enable_warnings
-create procedure bug2614()
-begin
- drop table if exists t3;
- create table t3 (id int default '0' not null);
- insert into t3 select 12;
- insert into t3 select * from t3;
-end|
-
---disable_warnings
-call bug2614()|
---enable_warnings
-call bug2614()|
-drop table t3|
-drop procedure bug2614|
-
-#
-# BUG#2674
-#
---disable_warnings
-drop function if exists bug2674|
---enable_warnings
-create function bug2674() returns int
- return @@sort_buffer_size|
-
-set @osbs = @@sort_buffer_size|
-set @@sort_buffer_size = 262000|
-select bug2674()|
-drop function bug2674|
-set @@sort_buffer_size = @osbs|
-
-#
-# BUG#3259
-#
---disable_warnings
-drop procedure if exists bug3259_1 |
---enable_warnings
-create procedure bug3259_1 () begin end|
---disable_warnings
-drop procedure if exists BUG3259_2 |
---enable_warnings
-create procedure BUG3259_2 () begin end|
---disable_warnings
-drop procedure if exists Bug3259_3 |
---enable_warnings
-create procedure Bug3259_3 () begin end|
-
-call BUG3259_1()|
-call BUG3259_1()|
-call bug3259_2()|
-call Bug3259_2()|
-call bug3259_3()|
-call bUG3259_3()|
-
-drop procedure bUg3259_1|
-drop procedure BuG3259_2|
-drop procedure BUG3259_3|
-
-#
-# BUG#2772
-#
---disable_warnings
-drop function if exists bug2772|
---enable_warnings
-create function bug2772() returns char(10) character set latin2
- return 'a'|
-
-select bug2772()|
-drop function bug2772|
-
-#
-# BUG#2776
-#
---disable_warnings
-drop procedure if exists bug2776_1|
---enable_warnings
-create procedure bug2776_1(out x int)
-begin
- declare v int;
-
- set v = default;
- set x = v;
-end|
-
---disable_warnings
-drop procedure if exists bug2776_2|
---enable_warnings
-create procedure bug2776_2(out x int)
-begin
- declare v int default 42;
-
- set v = default;
- set x = v;
-end|
-
-set @x = 1|
-call bug2776_1(@x)|
-select @x|
-call bug2776_2(@x)|
-select @x|
-drop procedure bug2776_1|
-drop procedure bug2776_2|
-
-#
-# BUG#2780
-#
-create table t3 (s1 smallint)|
-
-insert into t3 values (123456789012)|
-
---disable_warnings
-drop procedure if exists bug2780|
---enable_warnings
-create procedure bug2780()
-begin
- declare exit handler for sqlwarning set @x = 1;
-
- set @x = 0;
- insert into t3 values (123456789012);
- insert into t3 values (0);
-end|
-
-call bug2780()|
-select @x|
-select * from t3|
-
-drop procedure bug2780|
-drop table t3|
-
-#
-# BUG#1863
-#
-create table t3 (content varchar(10) )|
-insert into t3 values ("test1")|
-insert into t3 values ("test2")|
-create table t4 (f1 int, rc int, t3 int)|
-
---disable_warnings
-drop procedure if exists bug1863|
---enable_warnings
-create procedure bug1863(in1 int)
-begin
-
- declare ind int default 0;
- declare t1 int;
- declare t2 int;
- declare t3 int;
-
- declare rc int default 0;
- declare continue handler for 1065 set rc = 1;
-
- drop temporary table if exists temp_t1;
- create temporary table temp_t1 (
- f1 int auto_increment, f2 varchar(20), primary key (f1)
- );
-
- insert into temp_t1 (f2) select content from t3;
-
- select f2 into t3 from temp_t1 where f1 = 10;
-
- if (rc) then
- insert into t4 values (1, rc, t3);
- end if;
-
- insert into t4 values (2, rc, t3);
-
-end|
-
-call bug1863(10)|
-call bug1863(10)|
-select * from t4|
-
-drop procedure bug1863|
-drop temporary table temp_t1;
-drop table t3, t4|
-
-#
-# BUG#2656
-#
-
-create table t3 (
- OrderID int not null,
- MarketID int,
- primary key (OrderID)
-)|
-
-create table t4 (
- MarketID int not null,
- Market varchar(60),
- Status char(1),
- primary key (MarketID)
-)|
-
-insert t3 (OrderID,MarketID) values (1,1)|
-insert t3 (OrderID,MarketID) values (2,2)|
-insert t4 (MarketID,Market,Status) values (1,"MarketID One","A")|
-insert t4 (MarketID,Market,Status) values (2,"MarketID Two","A")|
-
---disable_warnings
-drop procedure if exists bug2656_1|
---enable_warnings
-create procedure bug2656_1()
-begin
- select
- m.Market
- from t4 m JOIN t3 o
- ON o.MarketID != 1 and o.MarketID = m.MarketID;
-end |
-
---disable_warnings
-drop procedure if exists bug2656_2|
---enable_warnings
-create procedure bug2656_2()
-begin
- select
- m.Market
- from
- t4 m, t3 o
- where
- m.MarketID != 1 and m.MarketID = o.MarketID;
-
-end |
-
-call bug2656_1()|
-call bug2656_1()|
-call bug2656_2()|
-call bug2656_2()|
-drop procedure bug2656_1|
-drop procedure bug2656_2|
-drop table t3, t4|
-
-
-#
-# BUG#3426
-#
---disable_warnings
-drop procedure if exists bug3426|
---enable_warnings
-create procedure bug3426(in_time int unsigned, out x int)
-begin
- if in_time is null then
- set @stamped_time=10;
- set x=1;
- else
- set @stamped_time=in_time;
- set x=2;
- end if;
-end|
-
-call bug3426(1000, @i)|
-select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
-call bug3426(NULL, @i)|
-select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
-# Clear SP cache
-alter procedure bug3426 sql security invoker|
-call bug3426(NULL, @i)|
-select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
-call bug3426(1000, @i)|
-select @i, from_unixtime(@stamped_time, '%d-%m-%Y %h:%i:%s') as time|
-
-drop procedure bug3426|
-
-#
-# BUG#3448
-#
---disable_warnings
-create table t3 (
- a int primary key,
- ach char(1)
-) engine = innodb|
-
-create table t4 (
- b int primary key ,
- bch char(1)
-) engine = innodb|
---enable_warnings
-
-insert into t3 values (1 , 'aCh1' ) , ('2' , 'aCh2')|
-insert into t4 values (1 , 'bCh1' )|
-
---disable_warnings
-drop procedure if exists bug3448|
---enable_warnings
-create procedure bug3448()
- select * from t3 inner join t4 on t3.a = t4.b|
-
-select * from t3 inner join t4 on t3.a = t4.b|
-call bug3448()|
-call bug3448()|
-
-drop procedure bug3448|
-drop table t3, t4|
-
-
-#
-# BUG#3734
-#
-create table t3 (
- id int unsigned auto_increment not null primary key,
- title VARCHAR(200),
- body text,
- fulltext (title,body)
-)|
-
-insert into t3 (title,body) values
- ('MySQL Tutorial','DBMS stands for DataBase ...'),
- ('How To Use MySQL Well','After you went through a ...'),
- ('Optimizing MySQL','In this tutorial we will show ...'),
- ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'),
- ('MySQL vs. YourSQL','In the following database comparison ...'),
- ('MySQL Security','When configured properly, MySQL ...')|
-
---disable_warnings
-drop procedure if exists bug3734 |
---enable_warnings
-create procedure bug3734 (param1 varchar(100))
- select * from t3 where match (title,body) against (param1)|
-
-call bug3734('database')|
-call bug3734('Security')|
-
-drop procedure bug3734|
-drop table t3|
-
-#
-# BUG#3863
-#
---disable_warnings
-drop procedure if exists bug3863|
---enable_warnings
-create procedure bug3863()
-begin
- set @a = 0;
- while @a < 5 do
- set @a = @a + 1;
- end while;
-end|
-
-call bug3863()|
-select @a|
-call bug3863()|
-select @a|
-
-drop procedure bug3863|
-
-#
-# BUG#2460
-#
-
-create table t3 (
- id int(10) unsigned not null default 0,
- rid int(10) unsigned not null default 0,
- msg text not null,
- primary key (id),
- unique key rid (rid, id)
-)|
-
---disable_warnings
-drop procedure if exists bug2460_1|
---enable_warnings
-create procedure bug2460_1(in v int)
-begin
- ( select n0.id from t3 as n0 where n0.id = v )
- union
- ( select n0.id from t3 as n0, t3 as n1
- where n0.id = n1.rid and n1.id = v )
- union
- ( select n0.id from t3 as n0, t3 as n1, t3 as n2
- where n0.id = n1.rid and n1.id = n2.rid and n2.id = v );
-end|
-
-call bug2460_1(2)|
-call bug2460_1(2)|
-insert into t3 values (1, 1, 'foo'), (2, 1, 'bar'), (3, 1, 'zip zap')|
-call bug2460_1(2)|
-call bug2460_1(2)|
-
---disable_warnings
-drop procedure if exists bug2460_2|
---enable_warnings
-create procedure bug2460_2()
-begin
- drop table if exists t3;
- create temporary table t3 (s1 int);
- insert into t3 select 1 union select 1;
-end|
-
-call bug2460_2()|
-call bug2460_2()|
-select * from t3|
-
-drop procedure bug2460_1|
-drop procedure bug2460_2|
-drop table t3|
-
-
-#
-# BUG#2564
-#
-set @@sql_mode = ''|
---disable_warnings
-drop procedure if exists bug2564_1|
---enable_warnings
-create procedure bug2564_1()
- comment 'Joe''s procedure'
- insert into `t1` values ("foo", 1)|
-
-set @@sql_mode = 'ANSI_QUOTES'|
---disable_warnings
-drop procedure if exists bug2564_2|
---enable_warnings
-create procedure bug2564_2()
- insert into "t1" values ('foo', 1)|
-
-delimiter $|
-set @@sql_mode = ''$
---disable_warnings
-drop function if exists bug2564_3$
---enable_warnings
-create function bug2564_3(x int, y int) returns int
- return x || y$
-
-set @@sql_mode = 'ANSI'$
---disable_warnings
-drop function if exists bug2564_4$
---enable_warnings
-create function bug2564_4(x int, y int) returns int
- return x || y$
-delimiter |$
-
-set @@sql_mode = ''|
-show create procedure bug2564_1|
-show create procedure bug2564_2|
-show create function bug2564_3|
-show create function bug2564_4|
-
-drop procedure bug2564_1|
-drop procedure bug2564_2|
-drop function bug2564_3|
-drop function bug2564_4|
-
-#
-# BUG#3132
-#
---disable_warnings
-drop function if exists bug3132|
---enable_warnings
-create function bug3132(s char(20)) returns char(50)
- return concat('Hello, ', s, '!')|
-
-select bug3132('Bob') union all select bug3132('Judy')|
-drop function bug3132|
-
-#
-# BUG#3843
-#
---disable_warnings
-drop procedure if exists bug3843|
---enable_warnings
-create procedure bug3843()
- analyze table t1|
-
-# Testing for packets out of order
-call bug3843()|
-call bug3843()|
-select 1+2|
-
-drop procedure bug3843|
-
-#
-# BUG#3368
-#
-create table t3 ( s1 char(10) )|
-insert into t3 values ('a'), ('b')|
-
---disable_warnings
-drop procedure if exists bug3368|
---enable_warnings
-create procedure bug3368(v char(10))
-begin
- select group_concat(v) from t3;
-end|
-
-call bug3368('x')|
-call bug3368('yz')|
-drop procedure bug3368|
-drop table t3|
-
-#
-# BUG#4579
-#
-create table t3 (f1 int, f2 int)|
-insert into t3 values (1,1)|
-
---disable_warnings
-drop procedure if exists bug4579_1|
---enable_warnings
-create procedure bug4579_1 ()
-begin
- declare sf1 int;
-
- select f1 into sf1 from t3 where f1=1 and f2=1;
- update t3 set f2 = f2 + 1 where f1=1 and f2=1;
- call bug4579_2();
-end|
-
---disable_warnings
-drop procedure if exists bug4579_2|
---enable_warnings
-create procedure bug4579_2 ()
-begin
-end|
-
-call bug4579_1()|
-call bug4579_1()|
-call bug4579_1()|
-
-drop procedure bug4579_1|
-drop procedure bug4579_2|
-drop table t3|
-
-#
-# BUG#2773: Function's data type ignored in stored procedures
-#
---disable_warnings
-drop procedure if exists bug2773|
---enable_warnings
-
-create function bug2773() returns int return null|
-create table t3 as select bug2773()|
-show create table t3|
-drop table t3|
-drop function bug2773|
-
-#
-# BUG#3788: Stored procedure packet error
-#
---disable_warnings
-drop procedure if exists bug3788|
---enable_warnings
-
-create function bug3788() returns date return cast("2005-03-04" as date)|
-select bug3788()|
-drop function bug3788|
-
-create function bug3788() returns binary(1) return 5|
-select bug3788()|
-drop function bug3788|
-
-
-#
-# BUG#4726
-#
-create table t3 (f1 int, f2 int, f3 int)|
-insert into t3 values (1,1,1)|
-
---disable_warnings
-drop procedure if exists bug4726|
---enable_warnings
-create procedure bug4726()
-begin
- declare tmp_o_id INT;
- declare tmp_d_id INT default 1;
-
- while tmp_d_id <= 2 do
- begin
- select f1 into tmp_o_id from t3 where f2=1 and f3=1;
- set tmp_d_id = tmp_d_id + 1;
- end;
- end while;
-end|
-
-call bug4726()|
-call bug4726()|
-call bug4726()|
-
-drop procedure bug4726|
-drop table t3|
-
-#
-# BUG#4318
-#
-
---disable_parsing # Don't know if HANDLER commands can work with SPs, or at all..
-create table t3 (s1 int)|
-insert into t3 values (3), (4)|
-
---disable_warnings
-drop procedure if exists bug4318|
---enable_warnings
-create procedure bug4318()
- handler t3 read next|
-
-handler t3 open|
-# Expect no results, as tables are closed, but there shouldn't be any errors
-call bug4318()|
-call bug4318()|
-handler t3 close|
-
-drop procedure bug4318|
-drop table t3|
---enable_parsing
-
-#
-# BUG#4902: Stored procedure with SHOW WARNINGS leads to packet error
-#
-# Added tests for most other show commands we could find too.
-# (Skipping those already tested, and the ones depending on optional handlers.)
-#
-# Note: This will return a large number of results of different formats,
-# which makes it impossible to filter with --replace_column.
-# It's possible that some of these are not deterministic across
-# platforms. If so, just remove the offending command.
-#
---disable_warnings
-drop procedure if exists bug4902|
---enable_warnings
-create procedure bug4902()
-begin
- show charset like 'foo';
- show collation like 'foo';
- show column types;
- show create table t1;
- show create database test;
- show databases like 'foo';
- show errors;
- show columns from t1;
- show grants for 'root'@'localhost';
- show keys from t1;
- show open tables like 'foo';
- show privileges;
- show status like 'foo';
- show tables like 'foo';
- show variables like 'foo';
- show warnings;
-end|
---disable_parsing
-show binlog events;
-show storage engines;
-show master status;
-show slave hosts;
-show slave status;
---enable_parsing
-
-call bug4902()|
-call bug4902()|
-
-drop procedure bug4902|
-
-# We need separate SP for SHOW PROCESSLIST since we want use replace_column
---disable_warnings
-drop procedure if exists bug4902_2|
---enable_warnings
-create procedure bug4902_2()
-begin
- show processlist;
-end|
---replace_column 1 # 6 # 3 localhost
-call bug4902_2()|
---replace_column 1 # 6 # 3 localhost
-call bug4902_2()|
-drop procedure bug4902_2|
-
-#
-# BUG#4904
-#
---disable_warnings
-drop procedure if exists bug4904|
---enable_warnings
-create procedure bug4904()
-begin
- declare continue handler for sqlstate 'HY000' begin end;
-
- create table t2 as select * from t3;
-end|
-
--- error 1146
-call bug4904()|
-
-drop procedure bug4904|
-
-create table t3 (s1 char character set latin1, s2 char character set latin2)|
-
---disable_warnings
-drop procedure if exists bug4904|
---enable_warnings
-create procedure bug4904 ()
-begin
- declare continue handler for sqlstate 'HY000' begin end;
-
- select s1 from t3 union select s2 from t3;
-end|
-
-call bug4904()|
-
-drop procedure bug4904|
-drop table t3|
-
-#
-# BUG#336
-#
---disable_warnings
-drop procedure if exists bug336|
---enable_warnings
-create procedure bug336(out y int)
-begin
- declare x int;
- set x = (select sum(t.data) from test.t1 t);
- set y = x;
-end|
-
-insert into t1 values ("a", 2), ("b", 3)|
-call bug336(@y)|
-select @y|
-delete from t1|
-drop procedure bug336|
-
-#
-# BUG#3157
-#
---disable_warnings
-drop procedure if exists bug3157|
---enable_warnings
-create procedure bug3157()
-begin
- if exists(select * from t1) then
- set @n= @n + 1;
- end if;
- if (select count(*) from t1) then
- set @n= @n + 1;
- end if;
-end|
-
-set @n = 0|
-insert into t1 values ("a", 1)|
-call bug3157()|
-select @n|
-delete from t1|
-drop procedure bug3157|
-
-#
-# BUG#5251: mysql changes creation time of a procedure/function when altering
-#
---disable_warnings
-drop procedure if exists bug5251|
---enable_warnings
-create procedure bug5251()
-begin
-end|
-
-select created into @c1 from mysql.proc
- where db='test' and name='bug5251'|
---sleep 2
-alter procedure bug5251 comment 'foobar'|
-select count(*) from mysql.proc
- where db='test' and name='bug5251' and created = @c1|
-
-drop procedure bug5251|
-
-#
-# BUG#5279: Stored procedure packets out of order if CHECKSUM TABLE
-#
---disable_warnings
-drop procedure if exists bug5251|
---enable_warnings
-create procedure bug5251()
- checksum table t1|
-
-call bug5251()|
-call bug5251()|
-drop procedure bug5251|
-
-#
-# BUG#5287: Stored procedure crash if leave outside loop
-#
---disable_warnings
-drop procedure if exists bug5287|
---enable_warnings
-create procedure bug5287(param1 int)
-label1:
- begin
- declare c cursor for select 5;
-
- loop
- if param1 >= 0 then
- leave label1;
- end if;
- end loop;
-end|
-call bug5287(1)|
-drop procedure bug5287|
-
-
-#
-# BUG#5307: Stored procedure allows statement after BEGIN ... END
-#
---disable_warnings
-drop procedure if exists bug5307|
---enable_warnings
-create procedure bug5307()
-begin
-end; set @x = 3|
-
-call bug5307()|
-select @x|
-drop procedure bug5307|
-
-#
-# BUG#5258: Stored procedure modified date is 0000-00-00
-# (This was a design flaw)
---disable_warnings
-drop procedure if exists bug5258|
---enable_warnings
-create procedure bug5258()
-begin
-end|
-
---disable_warnings
-drop procedure if exists bug5258_aux|
---enable_warnings
-create procedure bug5258_aux()
-begin
- declare c, m char(19);
-
- select created,modified into c,m from mysql.proc where name = 'bug5258';
- if c = m then
- select 'Ok';
- else
- select c, m;
- end if;
-end|
-
-call bug5258_aux()|
-
-drop procedure bug5258|
-drop procedure bug5258_aux|
-
-#
-# BUG#4487: Stored procedure connection aborted if uninitialized char
-#
---disable_warnings
-drop function if exists bug4487|
---enable_warnings
-create function bug4487() returns char
-begin
- declare v char;
- return v;
-end|
-
-select bug4487()|
-drop function bug4487|
-
-
-#
-# BUG#4941: Stored procedure crash fetching null value into variable.
-#
---disable_warnings
-drop procedure if exists bug4941|
---enable_warnings
---disable_warnings
-drop procedure if exists bug4941|
---enable_warnings
-create procedure bug4941(out x int)
-begin
- declare c cursor for select i from t2 limit 1;
- open c;
- fetch c into x;
- close c;
-end|
-
-insert into t2 values (null, null, null)|
-set @x = 42|
-call bug4941(@x)|
-select @x|
-delete from t1|
-drop procedure bug4941|
-
-
-#
-# BUG#3583: query cache doesn't work for stored procedures
-#
---disable_warnings
-drop procedure if exists bug3583|
---enable_warnings
---disable_warnings
-drop procedure if exists bug3583|
---enable_warnings
-create procedure bug3583()
-begin
- declare c int;
-
- select * from t1;
- select count(*) into c from t1;
- select c;
-end|
-
-insert into t1 values ("x", 3), ("y", 5)|
-set @x = @@query_cache_size|
-set global query_cache_size = 10*1024*1024|
-
-flush status|
-flush query cache|
-show status like 'Qcache_hits'|
-call bug3583()|
-show status like 'Qcache_hits'|
-call bug3583()|
-call bug3583()|
-show status like 'Qcache_hits'|
-
-set global query_cache_size = @x|
-flush status|
-flush query cache|
-delete from t1|
-drop procedure bug3583|
-
-#
-# BUG#4905: Stored procedure doesn't clear for "Rows affected"
-#
---disable_warnings
-drop procedure if exists bug4905|
---enable_warnings
-
-create table t3 (s1 int,primary key (s1))|
-
---disable_warnings
-drop procedure if exists bug4905|
---enable_warnings
-create procedure bug4905()
-begin
- declare v int;
- declare continue handler for sqlstate '23000' set v = 5;
-
- insert into t3 values (1);
-end|
-
-call bug4905()|
-select row_count()|
-call bug4905()|
-select row_count()|
-call bug4905()|
-select row_count()|
-select * from t3|
-
-drop procedure bug4905|
-drop table t3|
-
-#
-# BUG#6022: Stored procedure shutdown problem with self-calling function.
-#
-
---disable_parsing # until we implement support for recursive stored functions.
---disable_warnings
-drop function if exists bug6022|
---enable_warnings
-
---disable_warnings
-drop function if exists bug6022|
---enable_warnings
-create function bug6022(x int) returns int
-begin
- if x < 0 then
- return 0;
- else
- return bug6022(x-1);
- end if;
-end|
-
-select bug6022(5)|
-drop function bug6022|
---enable_parsing
-
-#
-# BUG#6029: Stored procedure specific handlers should have priority
-#
---disable_warnings
-drop procedure if exists bug6029|
---enable_warnings
-
---disable_warnings
-drop procedure if exists bug6029|
---enable_warnings
-create procedure bug6029()
-begin
- declare exit handler for 1136 select '1136';
- declare exit handler for sqlstate '23000' select 'sqlstate 23000';
- declare continue handler for sqlexception select 'sqlexception';
-
- insert into t3 values (1);
- insert into t3 values (1,2);
-end|
-
-create table t3 (s1 int, primary key (s1))|
-insert into t3 values (1)|
-call bug6029()|
-delete from t3|
-call bug6029()|
-
-drop procedure bug6029|
-drop table t3|
-
-#
-# BUG#8540: Local variable overrides an alias
-#
---disable_warnings
-drop procedure if exists bug8540|
---enable_warnings
-
-create procedure bug8540()
-begin
- declare x int default 1;
- select x as y, x+0 as z;
-end|
-
-call bug8540()|
-drop procedure bug8540|
-
-#
-# BUG#6642: Stored procedure crash if expression with set function
-#
-create table t3 (s1 int)|
-
---disable_warnings
-drop procedure if exists bug6642|
---enable_warnings
-
-create procedure bug6642()
- select abs(count(s1)) from t3|
-
-call bug6642()|
-call bug6642()|
-drop procedure bug6642|
-
-#
-# BUG#7013: Stored procedure crash if group by ... with rollup
-#
-insert into t3 values (0),(1)|
---disable_warnings
-drop procedure if exists bug7013|
---enable_warnings
-create procedure bug7013()
- select s1,count(s1) from t3 group by s1 with rollup|
-call bug7013()|
-call bug7013()|
-drop procedure bug7013|
-
-#
-# BUG#7743: 'Lost connection to MySQL server during query' on Stored Procedure
-#
---disable_warnings
-drop table if exists t4|
---enable_warnings
-create table t4 (
- a mediumint(8) unsigned not null auto_increment,
- b smallint(5) unsigned not null,
- c char(32) not null,
- primary key (a)
-) engine=myisam default charset=latin1|
-insert into t4 values (1, 2, 'oneword')|
-insert into t4 values (2, 2, 'anotherword')|
-
---disable_warnings
-drop procedure if exists bug7743|
---enable_warnings
-create procedure bug7743 ( searchstring char(28) )
-begin
- declare var mediumint(8) unsigned;
- select a into var from t4 where b = 2 and c = binary searchstring limit 1;
- select var;
-end|
-
-call bug7743("oneword")|
-call bug7743("OneWord")|
-call bug7743("anotherword")|
-call bug7743("AnotherWord")|
-drop procedure bug7743|
-drop table t4|
-
-#
-# BUG#7992: SELECT .. INTO variable .. within Stored Procedure crashes
-# the server
-#
-delete from t3|
-insert into t3 values(1)|
-drop procedure if exists bug7992_1|
-drop procedure if exists bug7992_2|
-create procedure bug7992_1()
-begin
- declare i int;
- select max(s1)+1 into i from t3;
-end|
-create procedure bug7992_2()
- insert into t3 (s1) select max(t4.s1)+1 from t3 as t4|
-
-call bug7992_1()|
-call bug7992_1()|
-call bug7992_2()|
-call bug7992_2()|
-
-drop procedure bug7992_1|
-drop procedure bug7992_2|
-drop table t3|
-
-#
-# BUG#8116: calling simple stored procedure twice in a row results
-# in server crash
-#
-create table t3 ( userid bigint(20) not null default 0 )|
-
---disable_warnings
-drop procedure if exists bug8116|
---enable_warnings
-create procedure bug8116(in _userid int)
- select * from t3 where userid = _userid|
-
-call bug8116(42)|
-call bug8116(42)|
-drop procedure bug8116|
-drop table t3|
-
-#
-# BUG#6857: current_time() in STORED PROCEDURES
-#
---disable_warnings
-drop procedure if exists bug6857|
---enable_warnings
-create procedure bug6857(counter int)
-begin
- declare t0, t1 int;
- declare plus bool default 0;
-
- set t0 = current_time();
- while counter > 0 do
- set counter = counter - 1;
- end while;
- set t1 = current_time();
- if t1 > t0 then
- set plus = 1;
- end if;
- select plus;
-end|
-
-# QQ: This is currently disabled. Not only does it slow down a normal test
-# run, it makes running with valgrind (or similar tools) extremely
-# painful.
-# Make sure this takes at least one second on all machines in all builds.
-# 30000 makes it about 3 seconds on an old 1.1GHz linux.
-#call bug6857(300000)|
-
-drop procedure bug6857|
-
-#
-# BUG#8757: Stored Procedures: Scope of Begin and End Statements do not
-# work properly.
---disable_warnings
-drop procedure if exists bug8757|
---enable_warnings
-create procedure bug8757()
-begin
- declare x int;
- declare c1 cursor for select data from t1 limit 1;
-
- begin
- declare y int;
- declare c2 cursor for select i from t2 limit 1;
-
- open c2;
- fetch c2 into y;
- close c2;
- select 2,y;
- end;
- open c1;
- fetch c1 into x;
- close c1;
- select 1,x;
-end|
-
-delete from t1|
-delete from t2|
-insert into t1 values ("x", 1)|
-insert into t2 values ("y", 2, 0.0)|
-
-call bug8757()|
-
-delete from t1|
-delete from t2|
-drop procedure bug8757|
-
-
-#
-# BUG#8762: Stored Procedures: Inconsistent behavior
-# of DROP PROCEDURE IF EXISTS statement.
---disable_warnings
-drop procedure if exists bug8762|
---enable_warnings
-# Doesn't exist
-drop procedure if exists bug8762; create procedure bug8762() begin end|
-# Does exist
-drop procedure if exists bug8762; create procedure bug8762() begin end|
-drop procedure bug8762|
-
-
-#
-# BUG#5240: Stored procedure crash if function has cursor declaration
-#
---disable_warnings
-drop function if exists bug5240|
---enable_warnings
-create function bug5240 () returns int
-begin
- declare x int;
- declare c cursor for select data from t1 limit 1;
-
- open c;
- fetch c into x;
- close c;
- return x;
-end|
-
-delete from t1|
-insert into t1 values ("answer", 42)|
-select id, bug5240() from t1|
-drop function bug5240|
-
-#
-# BUG#5278: Stored procedure packets out of order if SET PASSWORD.
-#
---disable_warnings
-drop function if exists bug5278|
---enable_warnings
-create function bug5278 () returns char
-begin
- SET PASSWORD FOR 'bob'@'%.loc.gov' = PASSWORD('newpass');
- return 'okay';
-end|
-
---error 1133
-select bug5278()|
---error 1133
-select bug5278()|
-drop function bug5278|
-
-#
-# BUG#7992: rolling back temporary Item tree changes in SP
-#
---disable_warnings
-drop procedure if exists p1|
---enable_warnings
-create table t3(id int)|
-insert into t3 values(1)|
-create procedure bug7992()
-begin
- declare i int;
- select max(id)+1 into i from t3;
-end|
-
-call bug7992()|
-call bug7992()|
-drop procedure bug7992|
-drop table t3|
-delimiter ;|
-
-#
-# BUG#8849: problem with insert statement with table alias's
-#
-# Rolling back changes to AND/OR structure of ON and WHERE clauses in SP
-#
-
-delimiter |;
-create table t3 (
- lpitnumber int(11) default null,
- lrecordtype int(11) default null
-)|
-
-create table t4 (
- lbsiid int(11) not null default '0',
- ltradingmodeid int(11) not null default '0',
- ltradingareaid int(11) not null default '0',
- csellingprice decimal(19,4) default null,
- primary key (lbsiid,ltradingmodeid,ltradingareaid)
-)|
-
-create table t5 (
- lbsiid int(11) not null default '0',
- ltradingareaid int(11) not null default '0',
- primary key (lbsiid,ltradingareaid)
-)|
-
---disable_warnings
-drop procedure if exists bug8849|
---enable_warnings
-create procedure bug8849()
-begin
- insert into t5
- (
- t5.lbsiid,
- t5.ltradingareaid
- )
- select distinct t3.lpitnumber, t4.ltradingareaid
- from
- t4 join t3 on
- t3.lpitnumber = t4.lbsiid
- and t3.lrecordtype = 1
- left join t4 as price01 on
- price01.lbsiid = t4.lbsiid and
- price01.ltradingmodeid = 1 and
- t4.ltradingareaid = price01.ltradingareaid;
-end|
-
-call bug8849()|
-call bug8849()|
-call bug8849()|
-drop procedure bug8849|
-drop tables t3,t4,t5|
-
-#
-# BUG#8937: Stored Procedure: AVG() works as SUM() in SELECT ... INTO statement
-#
---disable_warnings
-drop procedure if exists bug8937|
---enable_warnings
-create procedure bug8937()
-begin
- declare s,x,y,z int;
- declare a float;
-
- select sum(data),avg(data),min(data),max(data) into s,x,y,z from t1;
- select s,x,y,z;
- select avg(data) into a from t1;
- select a;
-end|
-
-delete from t1|
-insert into t1 (data) values (1), (2), (3), (4), (6)|
-call bug8937()|
-
-drop procedure bug8937|
-delete from t1|
-
-
-#
-# BUG#6900: Stored procedure inner handler ignored
-# BUG#9074: STORED PROC: The scope of every handler declared is not
-# properly applied
-#
---disable_warnings
-drop procedure if exists bug6900|
-drop procedure if exists bug9074|
-drop procedure if exists bug6900_9074|
---enable_warnings
-
-create table t3 (w char unique, x char)|
-insert into t3 values ('a', 'b')|
-
-create procedure bug6900()
-begin
- declare exit handler for sqlexception select '1';
-
- begin
- declare exit handler for sqlexception select '2';
-
- insert into t3 values ('x', 'y', 'z');
- end;
-end|
-
-create procedure bug9074()
-begin
- declare x1, x2, x3, x4, x5, x6 int default 0;
-
- begin
- declare continue handler for sqlstate '23000' set x5 = 1;
-
- insert into t3 values ('a', 'b');
- set x6 = 1;
- end;
-
- begin1_label:
- begin
- declare continue handler for sqlstate '23000' set x1 = 1;
-
- insert into t3 values ('a', 'b');
- set x2 = 1;
-
- begin2_label:
- begin
- declare exit handler for sqlstate '23000' set x3 = 1;
-
- set x4= 1;
- insert into t3 values ('a','b');
- set x4= 0;
- end begin2_label;
- end begin1_label;
-
- select x1, x2, x3, x4, x5, x6;
-end|
-
-create procedure bug6900_9074(z int)
-begin
- declare exit handler for sqlstate '23000' select '23000';
-
- begin
- declare exit handler for sqlexception select 'sqlexception';
-
- if z = 1 then
- insert into t3 values ('a', 'b');
- else
- insert into t3 values ('x', 'y', 'z');
- end if;
- end;
-end|
-
-call bug6900()|
-call bug9074()|
-call bug6900_9074(0)|
-call bug6900_9074(1)|
-
-drop procedure bug6900|
-drop procedure bug9074|
-drop procedure bug6900_9074|
-drop table t3|
-
-
-#
-# BUG#7185: Stored procedure crash if identifier is AVG
-#
---disable_warnings
-drop procedure if exists avg|
---enable_warnings
-create procedure avg ()
-begin
-end|
-
-call avg ()|
-drop procedure avg|
-
-
-#
-# BUG#6129: Stored procedure won't display @@sql_mode value
-#
---disable_warnings
-drop procedure if exists bug6129|
---enable_warnings
-set @old_mode= @@sql_mode;
-set @@sql_mode= "ERROR_FOR_DIVISION_BY_ZERO";
-create procedure bug6129()
- select @@sql_mode|
-call bug6129()|
-set @@sql_mode= "NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO"|
-call bug6129()|
-set @@sql_mode= "NO_ZERO_IN_DATE"|
-call bug6129()|
-set @@sql_mode=@old_mode;
-
-drop procedure bug6129|
-
-
-#
-# BUG#9856: Stored procedures: crash if handler for sqlexception, not found
-#
---disable_warnings
-drop procedure if exists bug9856|
---enable_warnings
-create procedure bug9856()
-begin
- declare v int;
- declare c cursor for select data from t1;
- declare exit handler for sqlexception, not found select '16';
-
- open c;
- fetch c into v;
- select v;
-end|
-
-delete from t1|
-call bug9856()|
-call bug9856()|
-drop procedure bug9856|
-
-
-#
-# BUG##9674: Stored Procs: Using declared vars in algebric operation causes
-# system crash.
-#
---disable_warnings
-drop procedure if exists bug9674_1|
-drop procedure if exists bug9674_2|
---enable_warnings
-create procedure bug9674_1(out arg int)
-begin
- declare temp_in1 int default 0;
- declare temp_fl1 int default 0;
-
- set temp_in1 = 100;
- set temp_fl1 = temp_in1/10;
- set arg = temp_fl1;
-end|
-
-create procedure bug9674_2()
-begin
- declare v int default 100;
-
- select v/10;
-end|
-
-call bug9674_1(@sptmp)|
-call bug9674_1(@sptmp)|
-select @sptmp|
-call bug9674_2()|
-call bug9674_2()|
-drop procedure bug9674_1|
-drop procedure bug9674_2|
-
-
-#
-# BUG#9598: stored procedure call within stored procedure overwrites IN variable
-#
---disable_warnings
-drop procedure if exists bug9598_1|
-drop procedure if exists bug9598_2|
---enable_warnings
-create procedure bug9598_1(in var_1 char(16),
- out var_2 integer, out var_3 integer)
-begin
- set var_2 = 50;
- set var_3 = 60;
-end|
-
-create procedure bug9598_2(in v1 char(16),
- in v2 integer,
- in v3 integer,
- in v4 integer,
- in v5 integer)
-begin
- select v1,v2,v3,v4,v5;
- call bug9598_1(v1,@tmp1,@tmp2);
- select v1,v2,v3,v4,v5;
-end|
-
-call bug9598_2('Test',2,3,4,5)|
-select @tmp1, @tmp2|
-
-drop procedure bug9598_1|
-drop procedure bug9598_2|
-
-
-#
-# BUG#9902: Crash with simple stored function using user defined variables
-#
---disable_warnings
-drop procedure if exists bug9902|
---enable_warnings
-create function bug9902() returns int(11)
-begin
- set @x = @x + 1;
- return @x;
-end|
-
-set @qcs1 = @@query_cache_size|
-set global query_cache_size = 100000|
-set @x = 1|
-insert into t1 values ("qc", 42)|
-select bug9902() from t1|
-select bug9902() from t1|
-select @x|
-
-set global query_cache_size = @qcs1|
-delete from t1|
-drop function bug9902|
-
-
-#
-# BUG#9102: Stored proccedures: function which returns blob causes crash
-#
---disable_warnings
-drop function if exists bug9102|
---enable_warnings
-create function bug9102() returns blob return 'a'|
-select bug9102()|
-drop function bug9102|
-
-
-#
-# BUG#7648: Stored procedure crash when invoking a function that returns a bit
-#
---disable_warnings
-drop function if exists bug7648|
---enable_warnings
-create function bug7648() returns bit(8) return 'a'|
-select bug7648()|
-drop function bug7648|
-
-
-#
-# BUG#9775: crash if create function that returns enum or set
-#
---disable_warnings
-drop function if exists bug9775|
---enable_warnings
-create function bug9775(v1 char(1)) returns enum('a','b') return v1|
-select bug9775('a'),bug9775('b'),bug9775('c')|
-drop function bug9775|
-create function bug9775(v1 int) returns enum('a','b') return v1|
-select bug9775(1),bug9775(2),bug9775(3)|
-drop function bug9775|
-
-create function bug9775(v1 char(1)) returns set('a','b') return v1|
-select bug9775('a'),bug9775('b'),bug9775('a,b'),bug9775('c')|
-drop function bug9775|
-create function bug9775(v1 int) returns set('a','b') return v1|
-select bug9775(1),bug9775(2),bug9775(3),bug9775(4)|
-drop function bug9775|
-
-
-#
-# BUG#8861: If Return is a YEAR data type, value is not shown in year format
-#
---disable_warnings
-drop function if exists bug8861|
---enable_warnings
-create function bug8861(v1 int) returns year return v1|
-select bug8861(05)|
-set @x = bug8861(05)|
-select @x|
-drop function bug8861|
-
-
-#
-# BUG#9004: Inconsistent behaviour of SP re. warnings
-#
---disable_warnings
-drop procedure if exists bug9004_1|
-drop procedure if exists bug9004_2|
---enable_warnings
-create procedure bug9004_1(x char(16))
-begin
- insert into t1 values (x, 42);
- insert into t1 values (x, 17);
-end|
-create procedure bug9004_2(x char(16))
- call bug9004_1(x)|
-
-# Truncation warnings expected...
-call bug9004_1('12345678901234567')|
-call bug9004_2('12345678901234567890')|
-
-delete from t1|
-drop procedure bug9004_1|
-drop procedure bug9004_2|
-
-#
-# BUG#7293: Stored procedure crash with soundex
-#
---disable_warnings
-drop procedure if exists bug7293|
---enable_warnings
-insert into t1 values ('secret', 0)|
-create procedure bug7293(p1 varchar(100))
-begin
- if exists (select id from t1 where soundex(p1)=soundex(id)) then
- select 'yes';
- end if;
-end;|
-call bug7293('secret')|
-call bug7293 ('secrete')|
-drop procedure bug7293|
-delete from t1|
-
-
-#
-# BUG#9841: Unexpected read lock when trying to update a view in a
-# stored procedure
-#
---disable_warnings
-drop procedure if exists bug9841|
-drop view if exists v1|
---enable_warnings
-
-create view v1 as select * from t1, t2 where id = s|
-create procedure bug9841 ()
- update v1 set data = 10|
-call bug9841()|
-
-drop view v1|
-drop procedure bug9841|
-
-
-#
-# BUG#5963 subqueries in SET/IF
-#
---disable_warnings
-drop procedure if exists bug5963|
---enable_warnings
-
-create procedure bug5963_1 () begin declare v int; set v = (select s1 from t3); select v; end;|
-create table t3 (s1 int)|
-insert into t3 values (5)|
-call bug5963_1()|
-call bug5963_1()|
-drop procedure bug5963_1|
-drop table t3|
-
-create procedure bug5963_2 (cfk_value int)
-begin
- if cfk_value in (select cpk from t3) then
- set @x = 5;
- end if;
- end;
-|
-create table t3 (cpk int)|
-insert into t3 values (1)|
-call bug5963_2(1)|
-call bug5963_2(1)|
-drop procedure bug5963_2|
-drop table t3|
-
-
-#
-# BUG#9559: Functions: Numeric Operations using -ve value gives incorrect
-# results.
-#
---disable_warnings
-drop function if exists bug9559|
---enable_warnings
-create function bug9559()
- returns int
-begin
- set @y = -6/2;
- return @y;
-end|
-
-select bug9559()|
-
-drop function bug9559|
-
-
-#
-# BUG#10961: Stored procedures: crash if select * from dual
-#
---disable_warnings
-drop procedure if exists bug10961|
---enable_warnings
-# "select * from dual" results in an error, so the cursor will not open
-create procedure bug10961()
-begin
- declare v char;
- declare x int;
- declare c cursor for select * from dual;
- declare continue handler for sqlexception select x;
-
- set x = 1;
- open c;
- set x = 2;
- fetch c into v;
- set x = 3;
- close c;
-end|
-
-call bug10961()|
-call bug10961()|
-
-drop procedure bug10961|
-
-#
-# BUG #6866: Second call of a stored procedure using a view with on expressions
-#
-
---disable_warnings
-DROP PROCEDURE IF EXISTS bug6866|
---enable_warnings
-
-DROP VIEW IF EXISTS tv|
-DROP TABLE IF EXISTS tt1,tt2,tt3|
-
-CREATE TABLE tt1 (a1 int, a2 int, a3 int, data varchar(10))|
-CREATE TABLE tt2 (a2 int, data2 varchar(10))|
-CREATE TABLE tt3 (a3 int, data3 varchar(10))|
-
-INSERT INTO tt1 VALUES (1, 1, 4, 'xx')|
-
-INSERT INTO tt2 VALUES (1, 'a')|
-INSERT INTO tt2 VALUES (2, 'b')|
-INSERT INTO tt2 VALUES (3, 'c')|
-
-INSERT INTO tt3 VALUES (4, 'd')|
-INSERT INTO tt3 VALUES (5, 'e')|
-INSERT INTO tt3 VALUES (6, 'f')|
-
-CREATE VIEW tv AS
-SELECT tt1.*, tt2.data2, tt3.data3
- FROM tt1 INNER JOIN tt2 ON tt1.a2 = tt2.a2
- LEFT JOIN tt3 ON tt1.a3 = tt3.a3
- ORDER BY tt1.a1, tt2.a2, tt3.a3|
-
-CREATE PROCEDURE bug6866 (_a1 int)
-BEGIN
-SELECT * FROM tv WHERE a1 = _a1;
-END|
-
-CALL bug6866(1)|
-CALL bug6866(1)|
-CALL bug6866(1)|
-
-DROP PROCEDURE bug6866;
-
-DROP VIEW tv|
-DROP TABLE tt1, tt2, tt3|
-
-#
-# BUG#10136: items cleunup
-#
---disable_warnings
-DROP PROCEDURE IF EXISTS bug10136|
---enable_warnings
-create table t3 ( name char(5) not null primary key, val float not null)|
-insert into t3 values ('aaaaa', 1), ('bbbbb', 2), ('ccccc', 3)|
-create procedure bug10136()
-begin
- declare done int default 3;
-
- repeat
- select * from t3;
- set done = done - 1;
- until done <= 0 end repeat;
-
-end|
-call bug10136()|
-call bug10136()|
-call bug10136()|
-drop procedure bug10136|
-drop table t3|
-
-#
-# BUG#11529: crash server after use stored procedure
-#
---disable_warnings
-drop procedure if exists bug11529|
---enable_warnings
-create procedure bug11529()
-begin
- declare c cursor for select id, data from t1 where data in (10,13);
-
- open c;
- begin
- declare vid char(16);
- declare vdata int;
- declare exit handler for not found begin end;
-
- while true do
- fetch c into vid, vdata;
- end while;
- end;
- close c;
-end|
-
-insert into t1 values
- ('Name1', 10),
- ('Name2', 11),
- ('Name3', 12),
- ('Name4', 13),
- ('Name5', 14)|
-
-call bug11529()|
-call bug11529()|
-delete from t1|
-drop procedure bug11529|
-
-
-#
-# BUG#6063: Stored procedure labels are subject to restrictions (partial)
-# BUG#7088: Stored procedures: labels won't work if character set is utf8
-#
---disable_warnings
-drop procedure if exists bug6063|
-drop procedure if exists bug7088_1|
-drop procedure if exists bug7088_2|
---enable_warnings
-
---disable_parsing # temporarily disabled until Bar fixes BUG#11986
-create procedure bug6063()
- lâbel: begin end|
-call bug6063()|
-# QQ Known bug: this will not show the label correctly.
-show create procedure bug6063|
-
-set character set utf8|
-create procedure bug7088_1()
- label1: begin end label1|
-create procedure bug7088_2()
- läbel1: begin end|
-call bug7088_1()|
-call bug7088_2()|
-set character set default|
-show create procedure bug7088_1|
-show create procedure bug7088_2|
-
-drop procedure bug6063|
-drop procedure bug7088_1|
-drop procedure bug7088_2|
---enable_parsing
-
-#
-# BUG#9565: "Wrong locking in stored procedure if a sub-sequent procedure
-# is called".
-#
---disable_warnings
-drop procedure if exists bug9565_sub|
-drop procedure if exists bug9565|
---enable_warnings
-create procedure bug9565_sub()
-begin
- select * from t1;
-end|
-create procedure bug9565()
-begin
- insert into t1 values ("one", 1);
- call bug9565_sub();
-end|
-call bug9565()|
-delete from t1|
-drop procedure bug9565_sub|
-drop procedure bug9565|
-
-
-#
-# BUG#9538: SProc: Creation fails if we try to SET system variable
-# using @@var_name in proc
-#
---disable_warnings
-drop procedure if exists bug9538|
---enable_warnings
-create procedure bug9538()
- set @@sort_buffer_size = 1000000|
-
-set @x = @@sort_buffer_size|
-set @@sort_buffer_size = 2000000|
-select @@sort_buffer_size|
-call bug9538()|
-select @@sort_buffer_size|
-set @@sort_buffer_size = @x|
-
-drop procedure bug9538|
-
-
-#
-# BUG#8692: Cursor fetch of empty string
-#
---disable_warnings
-drop procedure if exists bug8692|
---enable_warnings
-create table t3 (c1 varchar(5), c2 char(5), c3 enum('one','two'), c4 text, c5 blob, c6 char(5), c7 varchar(5))|
-insert into t3 values ('', '', '', '', '', '', NULL)|
-
-create procedure bug8692()
-begin
- declare v1 VARCHAR(10);
- declare v2 VARCHAR(10);
- declare v3 VARCHAR(10);
- declare v4 VARCHAR(10);
- declare v5 VARCHAR(10);
- declare v6 VARCHAR(10);
- declare v7 VARCHAR(10);
- declare c8692 cursor for select c1,c2,c3,c4,c5,c6,c7 from t3;
- open c8692;
- fetch c8692 into v1,v2,v3,v4,v5,v6,v7;
- select v1, v2, v3, v4, v5, v6, v7;
-end|
-
-call bug8692()|
-drop procedure bug8692|
-drop table t3|
-
-#
-# Bug#10055 "Using stored function with information_schema causes empty
-# result set"
-#
---disable_warnings
-drop function if exists bug10055|
---enable_warnings
-create function bug10055(v char(255)) returns char(255) return lower(v)|
-# This select should not crash server and should return all fields in t1
-select t.column_name, bug10055(t.column_name)
-from information_schema.columns as t
-where t.table_schema = 'test' and t.table_name = 't1'|
-drop function bug10055|
-
-#
-# Bug #12297 "SP crashes the server if data inserted inside a lon loop"
-# The test for memleak bug, so actually there is no way to test it
-# from the suite. The test below could be used to check SP memory
-# consumption by passing large input parameter.
-#
-
---disable_warnings
-drop procedure if exists bug12297|
---enable_warnings
-
-create procedure bug12297(lim int)
-begin
- set @x = 0;
- repeat
- insert into t1(id,data)
- values('aa', @x);
- set @x = @x + 1;
- until @x >= lim
- end repeat;
-end|
-
-call bug12297(10)|
-drop procedure bug12297|
-
-#
-# Bug #11247 "Stored procedures: Function calls in long loops leak memory"
-# One more memleak bug test. One could use this test to check that the memory
-# isn't leaking by increasing the input value for p_bug11247.
-#
-
---disable_warnings
-drop function if exists f_bug11247|
-drop procedure if exists p_bug11247|
---enable_warnings
-
-create function f_bug11247(param int)
- returns int
-return param + 1|
-
-create procedure p_bug11247(lim int)
-begin
- declare v int default 0;
-
- while v < lim do
- set v= f_bug11247(v);
- end while;
-end|
-
-call p_bug11247(10)|
-drop function f_bug11247|
-drop procedure p_bug11247|
-#
-# BUG#12168: "'DECLARE CONTINUE HANDLER FOR NOT FOUND ...' in conditional
-# handled incorrectly"
-#
---disable_warnings
-drop procedure if exists bug12168|
-drop table if exists t3, t4|
---enable_warnings
-
-create table t3 (a int)|
-insert into t3 values (1),(2),(3),(4)|
-
-create table t4 (a int)|
-
-create procedure bug12168(arg1 char(1))
-begin
- declare b, c integer;
- if arg1 = 'a' then
- begin
- declare c1 cursor for select a from t3 where a % 2;
- declare continue handler for not found set b = 1;
- set b = 0;
- open c1;
- c1_repeat: repeat
- fetch c1 into c;
- if (b = 1) then
- leave c1_repeat;
- end if;
-
- insert into t4 values (c);
- until b = 1
- end repeat;
- end;
- end if;
- if arg1 = 'b' then
- begin
- declare c2 cursor for select a from t3 where not a % 2;
- declare continue handler for not found set b = 1;
- set b = 0;
- open c2;
- c2_repeat: repeat
- fetch c2 into c;
- if (b = 1) then
- leave c2_repeat;
- end if;
-
- insert into t4 values (c);
- until b = 1
- end repeat;
- end;
- end if;
-end|
-
-call bug12168('a')|
-select * from t4|
-truncate t4|
-call bug12168('b')|
-select * from t4|
-truncate t4|
-call bug12168('a')|
-select * from t4|
-truncate t4|
-call bug12168('b')|
-select * from t4|
-truncate t4|
-drop table t3, t4|
-drop procedure if exists bug12168|
-
-#
-# Bug #11333 "Stored Procedure: Memory blow up on repeated SELECT ... INTO
-# query"
-# One more memleak bug. Use the test to check memory consumption.
-#
-
---disable_warnings
-drop table if exists t3|
-drop procedure if exists bug11333|
---enable_warnings
-
-create table t3 (c1 char(128))|
-
-insert into t3 values
- ('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')|
-
-
-create procedure bug11333(i int)
-begin
- declare tmp varchar(128);
- set @x = 0;
- repeat
- select c1 into tmp from t3
- where c1 = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA';
- set @x = @x + 1;
- until @x >= i
- end repeat;
-end|
-
-call bug11333(10)|
-
-drop procedure bug11333|
-drop table t3|
-
-#
-# BUG#9048: Creating a function with char binary IN parameter fails
-#
---disable_warnings
-drop function if exists bug9048|
---enable_warnings
-create function bug9048(f1 char binary) returns char binary
-begin
- set f1= concat( 'hello', f1 );
- return f1;
-end|
-drop function bug9048|
-
-# Bug #12849 Stored Procedure: Crash on procedure call with CHAR type
-# 'INOUT' parameter
-#
-
---disable_warnings
-drop procedure if exists bug12849_1|
---enable_warnings
-create procedure bug12849_1(inout x char) select x into x|
-set @var='a'|
-call bug12849_1(@var)|
-select @var|
-drop procedure bug12849_1|
-
---disable_warnings
-drop procedure if exists bug12849_2|
---enable_warnings
-create procedure bug12849_2(inout foo varchar(15))
-begin
-select concat(foo, foo) INTO foo;
-end|
-set @var='abcd'|
-call bug12849_2(@var)|
-select @var|
-drop procedure bug12849_2|
-
-#
-# BUG#13133: Local variables in stored procedures are not initialized correctly.
-#
---disable_warnings
-drop procedure if exists bug131333|
-drop function if exists bug131333|
---enable_warnings
-create procedure bug131333()
-begin
- begin
- declare a int;
-
- select a;
- set a = 1;
- select a;
- end;
- begin
- declare b int;
-
- select b;
- end;
-end|
-
-create function bug131333()
- returns int
-begin
- begin
- declare a int;
-
- set a = 1;
- end;
- begin
- declare b int;
-
- return b;
- end;
-end|
-
-call bug131333()|
-select bug131333()|
-
-drop procedure bug131333|
-drop function bug131333|
-
-#
-# BUG#12379: PROCEDURE with HANDLER calling FUNCTION with error get
-# strange result
-#
---disable_warnings
-drop function if exists bug12379|
-drop procedure if exists bug12379_1|
-drop procedure if exists bug12379_2|
-drop procedure if exists bug12379_3|
-drop table if exists t3|
---enable_warnings
-
-create table t3 (c1 char(1) primary key not null)|
-
-create function bug12379()
- returns integer
-begin
- insert into t3 values('X');
- insert into t3 values('X');
- return 0;
-end|
-
-create procedure bug12379_1()
-begin
- declare exit handler for sqlexception select 42;
-
- select bug12379();
-END|
-create procedure bug12379_2()
-begin
- declare exit handler for sqlexception begin end;
-
- select bug12379();
-end|
-create procedure bug12379_3()
-begin
- select bug12379();
-end|
-
---error 1062
-select bug12379()|
-select 1|
-call bug12379_1()|
-select 2|
-call bug12379_2()|
-select 3|
---error 1062
-call bug12379_3()|
-select 4|
-
-drop function bug12379|
-drop procedure bug12379_1|
-drop procedure bug12379_2|
-drop procedure bug12379_3|
-drop table t3|
-
-#
-# Bug #13124 Stored Procedure using SELECT INTO crashes server
-#
-
---disable_warnings
-drop procedure if exists bug13124|
---enable_warnings
-create procedure bug13124()
-begin
- declare y integer;
- set @x=y;
-end|
-call bug13124()|
-drop procedure bug13124|
-
-#
-# Bug #12979 Stored procedures: crash if inout decimal parameter
-#
-
-# check NULL inout parameters processing
-
---disable_warnings
-drop procedure if exists bug12979_1|
---enable_warnings
-create procedure bug12979_1(inout d decimal(5)) set d = d / 2|
-set @bug12979_user_var = NULL|
-call bug12979_1(@bug12979_user_var)|
-drop procedure bug12979_1|
-
-# check NULL local variables processing
-
---disable_warnings
-drop procedure if exists bug12979_2|
---enable_warnings
-create procedure bug12979_2()
-begin
-declare internal_var decimal(5);
-set internal_var= internal_var / 2;
-select internal_var;
-end|
-call bug12979_2()|
-drop procedure bug12979_2|
-
-
-#
-# BUG#6127: Stored procedure handlers within handlers don't work
-#
---disable_warnings
-drop table if exists t3|
-drop procedure if exists bug6127|
---enable_warnings
-create table t3 (s1 int unique)|
-
-set @sm=@@sql_mode|
-set sql_mode='traditional'|
-
-create procedure bug6127()
-begin
- declare continue handler for sqlstate '23000'
- begin
- declare continue handler for sqlstate '22003'
- insert into t3 values (0);
-
- insert into t3 values (1000000000000000);
- end;
-
- insert into t3 values (1);
- insert into t3 values (1);
-end|
-
-call bug6127()|
-select * from t3|
---error ER_DUP_ENTRY
-call bug6127()|
-select * from t3|
-set sql_mode=@sm|
-drop table t3|
-drop procedure bug6127|
-
-
-#
-# BUG#12589: Assert when creating temp. table from decimal stored procedure
-# variable
-#
---disable_warnings
-drop procedure if exists bug12589_1|
-drop procedure if exists bug12589_2|
-drop procedure if exists bug12589_3|
---enable_warnings
-create procedure bug12589_1()
-begin
- declare spv1 decimal(3,3);
- set spv1= 123.456;
-
- set spv1 = 'test';
- create temporary table tm1 as select spv1;
- show create table tm1;
- drop temporary table tm1;
-end|
-
-create procedure bug12589_2()
-begin
- declare spv1 decimal(6,3);
- set spv1= 123.456;
-
- create temporary table tm1 as select spv1;
- show create table tm1;
- drop temporary table tm1;
-end|
-
-create procedure bug12589_3()
-begin
- declare spv1 decimal(6,3);
- set spv1= -123.456;
-
- create temporary table tm1 as select spv1;
- show create table tm1;
- drop temporary table tm1;
-end|
-
-# Note: The type of the field will match the value, not the declared
-# type of the variable. (This is a type checking issue which
-# might be changed later.)
-
-# Warning expected from "set spv1 = 'test'", the value is set to decimal "0".
-call bug12589_1()|
-# No warnings here
-call bug12589_2()|
-call bug12589_3()|
-drop procedure bug12589_1|
-drop procedure bug12589_2|
-drop procedure bug12589_3|
-
-#
-# BUG#7049: Stored procedure CALL errors are ignored
-#
---disable_warnings
-drop table if exists t3|
-drop procedure if exists bug7049_1|
-drop procedure if exists bug7049_2|
-drop procedure if exists bug7049_3|
-drop procedure if exists bug7049_4|
-drop function if exists bug7049_1|
-drop function if exists bug7049_2|
---enable_warnings
-
-create table t3 ( x int unique )|
-
-create procedure bug7049_1()
-begin
- insert into t3 values (42);
- insert into t3 values (42);
-end|
-
-create procedure bug7049_2()
-begin
- declare exit handler for sqlexception
- select 'Caught it' as 'Result';
-
- call bug7049_1();
- select 'Missed it' as 'Result';
-end|
-
-create procedure bug7049_3()
- call bug7049_1()|
-
-create procedure bug7049_4()
-begin
- declare exit handler for sqlexception
- select 'Caught it' as 'Result';
-
- call bug7049_3();
- select 'Missed it' as 'Result';
-end|
-
-create function bug7049_1()
- returns int
-begin
- insert into t3 values (42);
- insert into t3 values (42);
- return 42;
-end|
-
-create function bug7049_2()
- returns int
-begin
- declare x int default 0;
- declare continue handler for sqlexception
- set x = 1;
-
- set x = bug7049_1();
- return x;
-end|
-
-call bug7049_2()|
-select * from t3|
-delete from t3|
-call bug7049_4()|
-select * from t3|
-select bug7049_2()|
-
-drop table t3|
-drop procedure bug7049_1|
-drop procedure bug7049_2|
-drop procedure bug7049_3|
-drop procedure bug7049_4|
-drop function bug7049_1|
-drop function bug7049_2|
-
-
-#
-# BUG#13941: replace() string fuction behaves badly inside stored procedure
-# (BUG#13914: IFNULL is returning garbage in stored procedure)
-#
---disable_warnings
-drop function if exists bug13941|
-drop procedure if exists bug13941|
---enable_warnings
-
-create function bug13941(p_input_str text)
- returns text
-begin
- declare p_output_str text;
-
- set p_output_str = p_input_str;
-
- set p_output_str = replace(p_output_str, 'xyzzy', 'plugh');
- set p_output_str = replace(p_output_str, 'test', 'prova');
- set p_output_str = replace(p_output_str, 'this', 'questo');
- set p_output_str = replace(p_output_str, ' a ', 'una ');
- set p_output_str = replace(p_output_str, 'is', '');
-
- return p_output_str;
-end|
-
-create procedure bug13941(out sout varchar(128))
-begin
- set sout = 'Local';
- set sout = ifnull(sout, 'DEF');
-end|
-
-# Note: The bug showed different behaviour in different types of builds,
-# giving garbage results in some, and seemingly working in others.
-# Running with valgrind (or purify) is the safe way to check that it's
-# really working correctly.
-select bug13941('this is a test')|
-call bug13941(@a)|
-select @a|
-
-drop function bug13941|
-drop procedure bug13941|
-
-
-#
-# BUG#13095: Cannot create VIEWs in prepared statements
-#
-
-delimiter ;|
-
---disable_warnings
-DROP PROCEDURE IF EXISTS bug13095;
-DROP TABLE IF EXISTS bug13095_t1;
-DROP VIEW IF EXISTS bug13095_v1;
---enable_warnings
-
-delimiter |;
-
-CREATE PROCEDURE bug13095(tbl_name varchar(32))
-BEGIN
- SET @str =
- CONCAT("CREATE TABLE ", tbl_name, "(stuff char(15))");
- SELECT @str;
- PREPARE stmt FROM @str;
- EXECUTE stmt;
-
- SET @str =
- CONCAT("INSERT INTO ", tbl_name, " VALUES('row1'),('row2'),('row3')" );
- SELECT @str;
- PREPARE stmt FROM @str;
- EXECUTE stmt;
-
- SET @str =
- CONCAT("CREATE VIEW bug13095_v1(c1) AS SELECT stuff FROM ", tbl_name);
- SELECT @str;
- PREPARE stmt FROM @str;
- EXECUTE stmt;
-
- SELECT * FROM bug13095_v1;
-
- SET @str =
- "DROP VIEW bug13095_v1";
- SELECT @str;
- PREPARE stmt FROM @str;
- EXECUTE stmt;
-END|
-
-delimiter ;|
-
-CALL bug13095('bug13095_t1');
-
---disable_warnings
-DROP PROCEDURE IF EXISTS bug13095;
-DROP VIEW IF EXISTS bug13095_v1;
-DROP TABLE IF EXISTS bug13095_t1;
---enable_warnings
-
-delimiter |;
-
-#
-# BUG#14210: "Simple query with > operator on large table gives server
-# crash"
-# Check that cursors work in case when HEAP tables are converted to
-# MyISAM
-#
---disable_warnings
-drop procedure if exists bug14210|
---enable_warnings
-set @@session.max_heap_table_size=16384|
-select @@session.max_heap_table_size|
-# To trigger the memory corruption the original table must be InnoDB.
-# No harm if it's not, so don't warn if the suite is run with --skip-innodb
---disable_warnings
-create table t3 (a char(255)) engine=InnoDB|
---enable_warnings
-create procedure bug14210_fill_table()
-begin
- declare table_size, max_table_size int default 0;
- select @@session.max_heap_table_size into max_table_size;
- delete from t3;
- insert into t3 (a) values (repeat('a', 255));
- repeat
- insert into t3 select a from t3;
- select count(*)*255 from t3 into table_size;
- until table_size > max_table_size*2 end repeat;
-end|
-call bug14210_fill_table()|
-drop procedure bug14210_fill_table|
-create table t4 like t3|
-
-create procedure bug14210()
-begin
- declare a char(255);
- declare done int default 0;
- declare c cursor for select * from t3;
- declare continue handler for sqlstate '02000' set done = 1;
- open c;
- repeat
- fetch c into a;
- if not done then
- insert into t4 values (upper(a));
- end if;
- until done end repeat;
- close c;
-end|
-call bug14210()|
-select count(*) from t4|
-
-drop table t3, t4|
-drop procedure bug14210|
-set @@session.max_heap_table_size=default|
-
-
-#
-# BUG#1473: Dumping of stored functions seems to cause corruption in
-# the function body
-#
---disable_warnings
-drop function if exists bug14723|
-drop procedure if exists bug14723|
---enable_warnings
-
-delimiter ;;|
-/*!50003 create function bug14723()
- returns bigint(20)
-main_loop: begin
- return 42;
-end */;;
-show create function bug14723;;
-select bug14723();;
-
-/*!50003 create procedure bug14723()
-main_loop: begin
- select 42;
-end */;;
-show create procedure bug14723;;
-call bug14723();;
-
-delimiter |;;
-
-drop function bug14723|
-drop procedure bug14723|
-
-#
-# Bug#14845 "mysql_stmt_fetch returns MYSQL_NO_DATA when COUNT(*) is 0"
-# Check that when fetching from a cursor, COUNT(*) works properly.
-#
-create procedure bug14845()
-begin
- declare a char(255);
- declare done int default 0;
- declare c cursor for select count(*) from t1 where 1 = 0;
- declare continue handler for sqlstate '02000' set done = 1;
- open c;
- repeat
- fetch c into a;
- if not done then
- select a;
- end if;
- until done end repeat;
- close c;
-end|
-call bug14845()|
-drop procedure bug14845|
-
-#
-# BUG#13549 "Server crash with nested stored procedures".
-# Server should not crash when during execution of stored procedure
-# we have to parse trigger/function definition and this new trigger/
-# function has more local variables declared than invoking stored
-# procedure and last of these variables is used in argument of NOT
-# operator.
-#
---disable_warnings
-drop procedure if exists bug13549_1|
-drop procedure if exists bug13549_2|
---enable_warnings
-CREATE PROCEDURE `bug13549_2`()
-begin
- call bug13549_1();
-end|
-CREATE PROCEDURE `bug13549_1`()
-begin
- declare done int default 0;
- set done= not done;
-end|
-CALL bug13549_2()|
-drop procedure bug13549_2|
-drop procedure bug13549_1|
-
-#
-# BUG#10100: function (and stored procedure?) recursivity problem
-#
---disable_warnings
-drop function if exists bug10100f|
-drop procedure if exists bug10100p|
-drop procedure if exists bug10100t|
-drop procedure if exists bug10100pt|
-drop procedure if exists bug10100pv|
-drop procedure if exists bug10100pd|
-drop procedure if exists bug10100pc|
---enable_warnings
-# routines with simple recursion
-create function bug10100f(prm int) returns int
-begin
- if prm > 1 then
- return prm * bug10100f(prm - 1);
- end if;
- return 1;
-end|
-create procedure bug10100p(prm int, inout res int)
-begin
- set res = res * prm;
- if prm > 1 then
- call bug10100p(prm - 1, res);
- end if;
-end|
-create procedure bug10100t(prm int)
-begin
- declare res int;
- set res = 1;
- call bug10100p(prm, res);
- select res;
-end|
-
-# a procedure which use tables and recursion
-create table t3 (a int)|
-insert into t3 values (0)|
-create view v1 as select a from t3;
-create procedure bug10100pt(level int, lim int)
-begin
- if level < lim then
- update t3 set a=level;
- FLUSH TABLES;
- call bug10100pt(level+1, lim);
- else
- select * from t3;
- end if;
-end|
-# view & recursion
-create procedure bug10100pv(level int, lim int)
-begin
- if level < lim then
- update v1 set a=level;
- FLUSH TABLES;
- call bug10100pv(level+1, lim);
- else
- select * from v1;
- end if;
-end|
-# dynamic sql & recursion
-prepare stmt2 from "select * from t3;";
-create procedure bug10100pd(level int, lim int)
-begin
- if level < lim then
- select level;
- prepare stmt1 from "update t3 set a=a+2";
- execute stmt1;
- FLUSH TABLES;
- execute stmt1;
- FLUSH TABLES;
- execute stmt1;
- FLUSH TABLES;
- deallocate prepare stmt1;
- execute stmt2;
- select * from t3;
- call bug10100pd(level+1, lim);
- else
- execute stmt2;
- end if;
-end|
-# cursor & recursion
-create procedure bug10100pc(level int, lim int)
-begin
- declare lv int;
- declare c cursor for select a from t3;
- open c;
- if level < lim then
- select level;
- fetch c into lv;
- select lv;
- update t3 set a=level+lv;
- FLUSH TABLES;
- call bug10100pc(level+1, lim);
- else
- select * from t3;
- end if;
- close c;
-end|
-
-set @@max_sp_recursion_depth=4|
-select @@max_sp_recursion_depth|
--- error ER_SP_NO_RECURSION
-select bug10100f(3)|
--- error ER_SP_NO_RECURSION
-select bug10100f(6)|
-call bug10100t(5)|
-call bug10100pt(1,5)|
-call bug10100pv(1,5)|
-update t3 set a=1|
-call bug10100pd(1,5)|
-select * from t3|
-update t3 set a=1|
-call bug10100pc(1,5)|
-select * from t3|
-set @@max_sp_recursion_depth=0|
-select @@max_sp_recursion_depth|
--- error ER_SP_NO_RECURSION
-select bug10100f(5)|
--- error ER_SP_RECURSION_LIMIT
-call bug10100t(5)|
-
-#end of the stack checking
-set @@max_sp_recursion_depth=255|
-set @var=1|
-#disable log because error about stack overrun contains numbers which
-#depend on a system
--- disable_result_log
--- error ER_STACK_OVERRUN_NEED_MORE
-call bug10100p(255, @var)|
--- error ER_STACK_OVERRUN_NEED_MORE
-call bug10100pt(1,255)|
--- error ER_STACK_OVERRUN_NEED_MORE
-call bug10100pv(1,255)|
--- error ER_STACK_OVERRUN_NEED_MORE
-call bug10100pd(1,255)|
--- error ER_STACK_OVERRUN_NEED_MORE
-call bug10100pc(1,255)|
--- enable_result_log
-set @@max_sp_recursion_depth=0|
-
-deallocate prepare stmt2|
-
-drop function bug10100f|
-drop procedure bug10100p|
-drop procedure bug10100t|
-drop procedure bug10100pt|
-drop procedure bug10100pv|
-drop procedure bug10100pd|
-drop procedure bug10100pc|
-drop view v1|
-
-#
-# BUG#13729: Stored procedures: packet error after exception handled
-#
---disable_warnings
-drop procedure if exists bug13729|
-drop table if exists t3|
---enable_warnings
-
-create table t3 (s1 int, primary key (s1))|
-
-insert into t3 values (1),(2)|
-
-create procedure bug13729()
-begin
- declare continue handler for sqlexception select 55;
-
- update t3 set s1 = 1;
-end|
-
-call bug13729()|
-# Used to cause Packets out of order
-select * from t3|
-
-drop procedure bug13729|
-drop table t3|
-
-#
-# BUG#14643: Stored Procedure: Continuing after failed var. initialization
-# crashes server.
-#
---disable_warnings
-drop procedure if exists bug14643_1|
-drop procedure if exists bug14643_2|
---enable_warnings
-
-create procedure bug14643_1()
-begin
- declare continue handler for sqlexception select 'boo' as 'Handler';
-
- begin
- declare v int default undefined_var;
-
- if v = 1 then
- select 1;
- else
- select v, isnull(v);
- end if;
- end;
-end|
-
-create procedure bug14643_2()
-begin
- declare continue handler for sqlexception select 'boo' as 'Handler';
-
- case undefined_var
- when 1 then
- select 1;
- else
- select 2;
- end case;
-
- select undefined_var;
-end|
-
-call bug14643_1()|
-call bug14643_2()|
-
-drop procedure bug14643_1|
-drop procedure bug14643_2|
-
-#
-# BUG#14304: auto_increment field incorrect set in SP
-#
---disable_warnings
-drop procedure if exists bug14304|
-drop table if exists t3, t4|
---enable_warnings
-
-create table t3(a int primary key auto_increment)|
-create table t4(a int primary key auto_increment)|
-
-create procedure bug14304()
-begin
- insert into t3 set a=null;
- insert into t4 set a=null;
- insert into t4 set a=null;
- insert into t4 set a=null;
- insert into t4 set a=null;
- insert into t4 set a=null;
- insert into t4 select null as a;
-
- insert into t3 set a=null;
- insert into t3 set a=null;
-
- select * from t3;
-end|
-
-call bug14304()|
-
-drop procedure bug14304|
-drop table t3, t4|
-
-#
-# BUG#14376: MySQL crash on scoped variable (re)initialization
-#
---disable_warnings
-drop procedure if exists bug14376|
---enable_warnings
-
-create procedure bug14376()
-begin
- declare x int default x;
-end|
-
-# Not the error we want, but that's what we got for now...
---error ER_BAD_FIELD_ERROR
-call bug14376()|
-drop procedure bug14376|
-
-create procedure bug14376()
-begin
- declare x int default 42;
-
- begin
- declare x int default x;
-
- select x;
- end;
-end|
-
-call bug14376()|
-
-drop procedure bug14376|
-
-create procedure bug14376(x int)
-begin
- declare x int default x;
-
- select x;
-end|
-
-call bug14376(4711)|
-
-drop procedure bug14376|
-
-#
-# Bug#5967 "Stored procedure declared variable used instead of column"
-# The bug should be fixed later.
-# Test precedence of names of parameters, variable declarations,
-# variable declarations in nested compound statements, table columns,
-# table columns in cursor declarations.
-# According to the standard, table columns take precedence over
-# variable declarations. In MySQL 5.0 it's vice versa.
-#
-
---disable_warnings
-drop procedure if exists bug5967|
-drop table if exists t3|
---enable_warnings
-create table t3 (a varchar(255))|
-insert into t3 (a) values ("a - table column")|
-create procedure bug5967(a varchar(255))
-begin
- declare i varchar(255);
- declare c cursor for select a from t3;
- select a;
- select a from t3 into i;
- select i as 'Parameter takes precedence over table column'; open c;
- fetch c into i;
- close c;
- select i as 'Parameter takes precedence over table column in cursors';
- begin
- declare a varchar(255) default 'a - local variable';
- declare c1 cursor for select a from t3;
- select a as 'A local variable takes precedence over parameter';
- open c1;
- fetch c1 into i;
- close c1;
- select i as 'A local variable takes precedence over parameter in cursors';
- begin
- declare a varchar(255) default 'a - local variable in a nested compound statement';
- declare c2 cursor for select a from t3;
- select a as 'A local variable in a nested compound statement takes precedence over a local variable in the outer statement';
- select a from t3 into i;
- select i as 'A local variable in a nested compound statement takes precedence over table column';
- open c2;
- fetch c2 into i;
- close c2;
- select i as 'A local variable in a nested compound statement takes precedence over table column in cursors';
- end;
- end;
-end|
-call bug5967("a - stored procedure parameter")|
-drop procedure bug5967|
-
-#
-# Bug#13012 "SP: REPAIR/BACKUP/RESTORE TABLE crashes the server"
-#
---disable_warnings
-drop procedure if exists bug13012|
---enable_warnings
-create procedure bug13012()
-BEGIN
- REPAIR TABLE t1;
- BACKUP TABLE t1 to '../tmp';
- DROP TABLE t1;
- RESTORE TABLE t1 FROM '../tmp';
-END|
-call bug13012()|
-drop procedure bug13012|
-create view v1 as select * from t1|
-create procedure bug13012()
-BEGIN
- REPAIR TABLE t1,t2,t3,v1;
- OPTIMIZE TABLE t1,t2,t3,v1;
- ANALYZE TABLE t1,t2,t3,v1;
-END|
-call bug13012()|
-call bug13012()|
-call bug13012()|
-drop procedure bug13012|
-drop view v1;
-select * from t1|
-
-#
-# A test case for Bug#15392 "Server crashes during prepared statement
-# execute": make sure that stored procedure check for error conditions
-# properly and do not continue execution if an error has been set.
-#
-# It's necessary to use several DBs because in the original code
-# the successful return of mysql_change_db overrode the error from
-# execution.
-drop schema if exists mysqltest1|
-drop schema if exists mysqltest2|
-drop schema if exists mysqltest3|
-create schema mysqltest1|
-create schema mysqltest2|
-create schema mysqltest3|
-use mysqltest3|
-
-create procedure mysqltest1.p1 (out prequestid varchar(100))
-begin
- call mysqltest2.p2('call mysqltest3.p3(1, 2)');
-end|
-
-create procedure mysqltest2.p2(in psql text)
-begin
- declare lsql text;
- set @lsql= psql;
- prepare lstatement from @lsql;
- execute lstatement;
- deallocate prepare lstatement;
-end|
-
-create procedure mysqltest3.p3(in p1 int)
-begin
- select p1;
-end|
-
---error ER_SP_WRONG_NO_OF_ARGS
-call mysqltest1.p1(@rs)|
---error ER_SP_WRONG_NO_OF_ARGS
-call mysqltest1.p1(@rs)|
---error ER_SP_WRONG_NO_OF_ARGS
-call mysqltest1.p1(@rs)|
-drop schema if exists mysqltest1|
-drop schema if exists mysqltest2|
-drop schema if exists mysqltest3|
-use test|
-
-#
-# Bug#15441 "Running SP causes Server to Crash": check that an SP variable
-# can not be used in VALUES() function.
-#
---disable_warnings
-drop table if exists t3|
-drop procedure if exists bug15441|
---enable_warnings
-create table t3 (id int not null primary key, county varchar(25))|
-insert into t3 (id, county) values (1, 'York')|
-
-# First check that a stored procedure that refers to a parameter in VALUES()
-# function won't parse.
-
-create procedure bug15441(c varchar(25))
-begin
- update t3 set id=2, county=values(c);
-end|
---error ER_BAD_FIELD_ERROR
-call bug15441('county')|
-drop procedure bug15441|
-
-# Now check the case when there is an ambiguity between column names
-# and stored procedure parameters: the parser shall resolve the argument
-# of VALUES() function to the column name.
-
-# It's hard to deduce what county refers to in every case (INSERT statement):
-# 1st county refers to the column
-# 2nd county refers to the procedure parameter
-# 3d and 4th county refers to the column, again, but
-# for 4th county it has the value of SP parameter
-
-# In UPDATE statement, just check that values() function returns NULL for
-# non- INSERT...UPDATE statements, as stated in the manual.
-
-create procedure bug15441(county varchar(25))
-begin
- declare c varchar(25) default "hello";
-
- insert into t3 (id, county) values (1, county)
- on duplicate key update county= values(county);
- select * from t3;
-
- update t3 set id=2, county=values(id);
- select * from t3;
-end|
-call bug15441('Yale')|
-drop table t3|
-drop procedure bug15441|
-
-#
-# BUG#14498: Stored procedures: hang if undefined variable and exception
-#
---disable_warnings
-drop procedure if exists bug14498_1|
-drop procedure if exists bug14498_2|
-drop procedure if exists bug14498_3|
-drop procedure if exists bug14498_4|
-drop procedure if exists bug14498_5|
---enable_warnings
-
-create procedure bug14498_1()
-begin
- declare continue handler for sqlexception select 'error' as 'Handler';
-
- if v then
- select 'yes' as 'v';
- else
- select 'no' as 'v';
- end if;
- select 'done' as 'End';
-end|
-
-create procedure bug14498_2()
-begin
- declare continue handler for sqlexception select 'error' as 'Handler';
-
- while v do
- select 'yes' as 'v';
- end while;
- select 'done' as 'End';
-end|
-
-create procedure bug14498_3()
-begin
- declare continue handler for sqlexception select 'error' as 'Handler';
-
- repeat
- select 'maybe' as 'v';
- until v end repeat;
- select 'done' as 'End';
-end|
-
-create procedure bug14498_4()
-begin
- declare continue handler for sqlexception select 'error' as 'Handler';
-
- case v
- when 1 then
- select '1' as 'v';
- when 2 then
- select '2' as 'v';
- else
- select '?' as 'v';
- end case;
- select 'done' as 'End';
-end|
-
-create procedure bug14498_5()
-begin
- declare continue handler for sqlexception select 'error' as 'Handler';
-
- case
- when v = 1 then
- select '1' as 'v';
- when v = 2 then
- select '2' as 'v';
- else
- select '?' as 'v';
- end case;
- select 'done' as 'End';
-end|
-
-call bug14498_1()|
-call bug14498_2()|
-call bug14498_3()|
-call bug14498_4()|
-call bug14498_5()|
-
-drop procedure bug14498_1|
-drop procedure bug14498_2|
-drop procedure bug14498_3|
-drop procedure bug14498_4|
-drop procedure bug14498_5|
-
-#
-# BUG#15231: Stored procedure bug with not found condition handler
-#
---disable_warnings
-drop table if exists t3|
-drop procedure if exists bug15231_1|
-drop procedure if exists bug15231_2|
-drop procedure if exists bug15231_3|
-drop procedure if exists bug15231_4|
---enable_warnings
-
-create table t3 (id int not null)|
-
-create procedure bug15231_1()
-begin
- declare xid integer;
- declare xdone integer default 0;
- declare continue handler for not found set xdone = 1;
-
- set xid=null;
- call bug15231_2(xid);
- select xid, xdone;
-end|
-
-create procedure bug15231_2(inout ioid integer)
-begin
- select "Before NOT FOUND condition is triggered" as '1';
- select id into ioid from t3 where id=ioid;
- select "After NOT FOUND condtition is triggered" as '2';
-
- if ioid is null then
- set ioid=1;
- end if;
-end|
-
-create procedure bug15231_3()
-begin
- declare exit handler for sqlwarning
- select 'Caught it (wrong)' as 'Result';
-
- call bug15231_4();
-end|
-
-create procedure bug15231_4()
-begin
- declare x decimal(2,1);
-
- set x = 'zap';
- select 'Missed it (correct)' as 'Result';
-end|
-
-call bug15231_1()|
-call bug15231_3()|
-
-drop table if exists t3|
-drop procedure if exists bug15231_1|
-drop procedure if exists bug15231_2|
-drop procedure if exists bug15231_3|
-drop procedure if exists bug15231_4|
-
-
-#
-# BUG#15011: error handler in nested block not activated
-#
---disable_warnings
-drop procedure if exists bug15011|
---enable_warnings
-
-create table t3 (c1 int primary key)|
-
-insert into t3 values (1)|
-
-create procedure bug15011()
- deterministic
-begin
- declare continue handler for 1062
- select 'Outer' as 'Handler';
-
- begin
- declare continue handler for 1062
- select 'Inner' as 'Handler';
-
- insert into t3 values (1);
- end;
-end|
-
-call bug15011()|
-
-drop procedure bug15011|
-drop table t3|
-
-
-#
-# BUG#NNNN: New bug synopsis
-#
-#--disable_warnings
-#drop procedure if exists bugNNNN|
-#--enable_warnings
-#create procedure bugNNNN...
-
-# Add bugs above this line. Use existing tables t1 and t2 when
-# practical, or create table t3, t4 etc temporarily (and drop them).
-delimiter ;|
-drop table t1,t2;
diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test
index 75ac0be7aff..6ebbb53ed8e 100644
--- a/mysql-test/t/strict.test
+++ b/mysql-test/t/strict.test
@@ -13,7 +13,9 @@ DROP TABLE IF EXISTS t1;
# Test INSERT with DATE
CREATE TABLE t1 (col1 date);
-INSERT INTO t1 VALUES('2004-01-01'),('0000-10-31'),('2004-02-29');
+INSERT INTO t1 VALUES('2004-01-01'),('2004-02-29');
+--error 1292
+INSERT INTO t1 VALUES('0000-10-31');
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid date value>
@@ -97,7 +99,9 @@ set @@sql_mode='ansi,traditional';
# Test INSERT with DATETIME
CREATE TABLE t1 (col1 datetime);
-INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('0000-10-31 15:30:00'),('2004-02-29 15:30:00');
+INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('2004-02-29 15:30:00');
+--error 1292
+INSERT INTO t1 VALUES('0000-10-31 15:30:00');
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid datetime value>
@@ -190,6 +194,7 @@ INSERT INTO t1 (col3) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid date value>
+--error 1292
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
--error 1292
@@ -211,6 +216,7 @@ INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid datetime value>
+--error 1292
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
--error 1292
@@ -264,6 +270,8 @@ INSERT INTO t1 (col3) VALUES (CAST('2004-10-15 10:15' AS DATETIME));
## Test INSERT with CAST AS DATE into DATE
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid date value>
+
+--error 1292
INSERT INTO t1 (col1) VALUES(CAST('0000-10-31' AS DATE));
--error 1292
@@ -290,6 +298,8 @@ INSERT INTO t1 (col1) VALUES(CAST('0000-00-00' AS DATE));
## Test INSERT with CAST AS DATETIME into DATETIME
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid datetime value>
+
+--error 1292
INSERT INTO t1 (col2) VALUES(CAST('0000-10-31 15:30' AS DATETIME));
--error 1292
@@ -356,6 +366,8 @@ INSERT INTO t1 (col3) VALUES (CONVERT('2004-10-15 10:15',DATETIME));
## Test INSERT with CONVERT to DATE into DATE
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid date value>
+
+--error 1292
INSERT INTO t1 (col1) VALUES(CONVERT('0000-10-31' , DATE));
--error 1292
@@ -381,6 +393,8 @@ INSERT INTO t1 (col1) VALUES(CONVERT('0000-00-00',DATE));
## Test INSERT with CONVERT to DATETIME into DATETIME
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid datetime value>
+
+--error 1292
INSERT INTO t1 (col2) VALUES(CONVERT('0000-10-31 15:30',DATETIME));
--error 1292
diff --git a/mysql-test/t/strict_autoinc_1myisam.test b/mysql-test/t/strict_autoinc_1myisam.test
new file mode 100644
index 00000000000..d9ecce30974
--- /dev/null
+++ b/mysql-test/t/strict_autoinc_1myisam.test
@@ -0,0 +1,8 @@
+#
+# Bug#20573 Strict mode auto-increment
+#
+
+let $type= 'MYISAM' ;
+--source include/strict_autoinc.inc
+
+# end of test
diff --git a/mysql-test/t/strict_autoinc_2innodb.test b/mysql-test/t/strict_autoinc_2innodb.test
new file mode 100644
index 00000000000..83dfe950938
--- /dev/null
+++ b/mysql-test/t/strict_autoinc_2innodb.test
@@ -0,0 +1,10 @@
+-- source include/have_innodb.inc
+
+#
+# Bug#20573 Strict mode auto-increment
+#
+
+let $type= 'InnoDB' ;
+--source include/strict_autoinc.inc
+
+# end of test
diff --git a/mysql-test/t/strict_autoinc_3heap.test b/mysql-test/t/strict_autoinc_3heap.test
new file mode 100644
index 00000000000..f266ecdfda2
--- /dev/null
+++ b/mysql-test/t/strict_autoinc_3heap.test
@@ -0,0 +1,8 @@
+#
+# Bug#20573 Strict mode auto-increment
+#
+
+let $type= 'MEMORY' ;
+--source include/strict_autoinc.inc
+
+# end of test
diff --git a/mysql-test/t/strict_autoinc_4bdb.test b/mysql-test/t/strict_autoinc_4bdb.test
new file mode 100644
index 00000000000..10d6bfd41e7
--- /dev/null
+++ b/mysql-test/t/strict_autoinc_4bdb.test
@@ -0,0 +1,10 @@
+-- source include/have_bdb.inc
+
+#
+# Bug#20573 Strict mode auto-increment
+#
+
+let $type= 'BDB' ;
+--source include/strict_autoinc.inc
+
+# end of test
diff --git a/mysql-test/t/strict_autoinc_5ndb.test b/mysql-test/t/strict_autoinc_5ndb.test
new file mode 100644
index 00000000000..9e2090fddef
--- /dev/null
+++ b/mysql-test/t/strict_autoinc_5ndb.test
@@ -0,0 +1,10 @@
+-- source include/have_ndb.inc
+
+#
+# Bug#20573 Strict mode auto-increment
+#
+
+let $type= 'NDB' ;
+--source include/strict_autoinc.inc
+
+# end of test
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 8916a5cec6d..a4e535ac418 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -1821,6 +1821,103 @@ SELECT * FROM t1
DROP TABLE t1,t2,t3;
+#
+# BUG #10308: purge log with subselect
+#
+
+purge master logs before (select adddate(current_timestamp(), interval -4 day));
+
+
+#
+# Bug#18503: Queries with a quantified subquery returning empty set may
+# return a wrong result.
+#
+CREATE TABLE t1 (f1 INT);
+CREATE TABLE t2 (f2 INT);
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1 WHERE f1 > ALL (SELECT f2 FROM t2);
+SELECT * FROM t1 WHERE f1 > ALL (SELECT f2 FROM t2 WHERE 1=0);
+INSERT INTO t2 VALUES (1);
+INSERT INTO t2 VALUES (2);
+SELECT * FROM t1 WHERE f1 > ALL (SELECT f2 FROM t2 WHERE f2=0);
+DROP TABLE t1, t2;
+
+#
+# Bug#16302: Quantified subquery without any tables gives wrong results
+#
+select 1 from dual where 1 < any (select 2);
+select 1 from dual where 1 < all (select 2);
+select 1 from dual where 2 > any (select 1);
+select 1 from dual where 2 > all (select 1);
+select 1 from dual where 1 < any (select 2 from dual);
+select 1 from dual where 1 < all (select 2 from dual where 1!=1);
+
+# BUG#20975 Wrong query results for subqueries within NOT
+create table t1 (s1 char);
+insert into t1 values (1),(2);
+
+select * from t1 where (s1 < any (select s1 from t1));
+select * from t1 where not (s1 < any (select s1 from t1));
+
+select * from t1 where (s1 < ALL (select s1+1 from t1));
+select * from t1 where not(s1 < ALL (select s1+1 from t1));
+
+select * from t1 where (s1+1 = ANY (select s1 from t1));
+select * from t1 where NOT(s1+1 = ANY (select s1 from t1));
+
+select * from t1 where (s1 = ALL (select s1/s1 from t1));
+select * from t1 where NOT(s1 = ALL (select s1/s1 from t1));
+drop table t1;
+
+#
+# Bug #16255: Subquery in where
+#
+create table t1 (
+ retailerID varchar(8) NOT NULL,
+ statusID int(10) unsigned NOT NULL,
+ changed datetime NOT NULL,
+ UNIQUE KEY retailerID (retailerID, statusID, changed)
+);
+
+INSERT INTO t1 VALUES("0026", "1", "2005-12-06 12:18:56");
+INSERT INTO t1 VALUES("0026", "2", "2006-01-06 12:25:53");
+INSERT INTO t1 VALUES("0037", "1", "2005-12-06 12:18:56");
+INSERT INTO t1 VALUES("0037", "2", "2006-01-06 12:25:53");
+INSERT INTO t1 VALUES("0048", "1", "2006-01-06 12:37:50");
+INSERT INTO t1 VALUES("0059", "1", "2006-01-06 12:37:50");
+
+select * from t1 r1
+ where (r1.retailerID,(r1.changed)) in
+ (SELECT r2.retailerId,(max(changed)) from t1 r2
+ group by r2.retailerId);
+drop table t1;
+
+#
+# Bug #21180: Subselect with index for both WHERE and ORDER BY
+# produces empty result
+#
+create table t1(a int, primary key (a));
+insert into t1 values (10);
+
+create table t2 (a int primary key, b varchar(32), c int, unique key b(c, b));
+insert into t2(a, c, b) values (1,10,'359'), (2,10,'35988'), (3,10,'35989');
+
+explain SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+ ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
+SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+ ORDER BY t2.c DESC, t2.b DESC LIMIT 1) WHERE t1.a = 10;
+
+explain SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+ ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
+SELECT sql_no_cache t1.a, r.a, r.b FROM t1 LEFT JOIN t2 r
+ ON r.a = (SELECT t2.a FROM t2 WHERE t2.c = t1.a AND t2.b <= '359899'
+ ORDER BY t2.c, t2.b LIMIT 1) WHERE t1.a = 10;
+
+drop table t1,t2;
+
# End of 4.1 tests
#
@@ -2131,3 +2228,107 @@ SELECT t1.i FROM t1 WHERE t1.i = CAST((SELECT MAX(i) FROM t2) AS UNSIGNED);
DROP TABLE t1;
DROP TABLE t2;
+
+#
+# Bug#20519: subselect with LIMIT M, N
+#
+
+CREATE TABLE t1 (
+ id bigint(20) unsigned NOT NULL auto_increment,
+ name varchar(255) NOT NULL,
+ PRIMARY KEY (id)
+);
+INSERT INTO t1 VALUES
+ (1, 'Balazs'), (2, 'Joe'), (3, 'Frank');
+
+CREATE TABLE t2 (
+ id bigint(20) unsigned NOT NULL auto_increment,
+ mid bigint(20) unsigned NOT NULL,
+ date date NOT NULL,
+ PRIMARY KEY (id)
+);
+INSERT INTO t2 VALUES
+ (1, 1, '2006-03-30'), (2, 2, '2006-04-06'), (3, 3, '2006-04-13'),
+ (4, 2, '2006-04-20'), (5, 1, '2006-05-01');
+
+SELECT *,
+ (SELECT date FROM t2 WHERE mid = t1.id
+ ORDER BY date DESC LIMIT 0, 1) AS date_last,
+ (SELECT date FROM t2 WHERE mid = t1.id
+ ORDER BY date DESC LIMIT 3, 1) AS date_next_to_last
+ FROM t1;
+SELECT *,
+ (SELECT COUNT(*) FROM t2 WHERE mid = t1.id
+ ORDER BY date DESC LIMIT 1, 1) AS date_count
+ FROM t1;
+SELECT *,
+ (SELECT date FROM t2 WHERE mid = t1.id
+ ORDER BY date DESC LIMIT 0, 1) AS date_last,
+ (SELECT date FROM t2 WHERE mid = t1.id
+ ORDER BY date DESC LIMIT 1, 1) AS date_next_to_last
+ FROM t1;
+DROP TABLE t1,t2;
+
+#
+# Bug#20869: subselect with range access by DESC
+#
+
+CREATE TABLE t1 (
+ i1 int(11) NOT NULL default '0',
+ i2 int(11) NOT NULL default '0',
+ t datetime NOT NULL default '0000-00-00 00:00:00',
+ PRIMARY KEY (i1,i2,t)
+);
+INSERT INTO t1 VALUES
+(24,1,'2005-03-03 16:31:31'),(24,1,'2005-05-27 12:40:07'),
+(24,1,'2005-05-27 12:40:08'),(24,1,'2005-05-27 12:40:10'),
+(24,1,'2005-05-27 12:40:25'),(24,1,'2005-05-27 12:40:30'),
+(24,2,'2005-03-03 13:43:05'),(24,2,'2005-03-03 16:23:31'),
+(24,2,'2005-03-03 16:31:30'),(24,2,'2005-05-27 12:37:02'),
+(24,2,'2005-05-27 12:40:06');
+
+CREATE TABLE t2 (
+ i1 int(11) NOT NULL default '0',
+ i2 int(11) NOT NULL default '0',
+ t datetime default NULL,
+ PRIMARY KEY (i1)
+);
+INSERT INTO t2 VALUES (24,1,'2006-06-20 12:29:40');
+
+EXPLAIN
+SELECT * FROM t1,t2
+ WHERE t1.t = (SELECT t1.t FROM t1
+ WHERE t1.t < t2.t AND t1.i2=1 AND t2.i1=t1.i1
+ ORDER BY t1.t DESC LIMIT 1);
+SELECT * FROM t1,t2
+ WHERE t1.t = (SELECT t1.t FROM t1
+ WHERE t1.t < t2.t AND t1.i2=1 AND t2.i1=t1.i1
+ ORDER BY t1.t DESC LIMIT 1);
+
+DROP TABLE t1, t2;
+
+#
+# Bug#14654 : Cannot select from the same table twice within a UNION
+# statement
+#
+CREATE TABLE t1 (i INT);
+
+(SELECT i FROM t1) UNION (SELECT i FROM t1);
+SELECT sql_no_cache * FROM t1 WHERE NOT EXISTS
+ (
+ (SELECT i FROM t1) UNION
+ (SELECT i FROM t1)
+ );
+
+SELECT * FROM t1
+WHERE NOT EXISTS (((SELECT i FROM t1) UNION (SELECT i FROM t1)));
+
+#TODO:not supported
+--error 1064
+explain select ((select t11.i from t1 t11) union (select t12.i from t1 t12))
+ from t1;
+#supported
+explain select * from t1 where not exists
+ ((select t11.i from t1 t11) union (select t12.i from t1 t12));
+
+DROP TABLE t1;
diff --git a/mysql-test/t/subselect2.test b/mysql-test/t/subselect2.test
index b21eda176b6..162bdd0d90a 100644
--- a/mysql-test/t/subselect2.test
+++ b/mysql-test/t/subselect2.test
@@ -150,3 +150,21 @@ EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JO
drop table t1, t2, t3, t4;
# End of 4.1 tests
+
+#
+# Bug #20792: Incorrect results from aggregate subquery
+#
+CREATE TABLE t1 (a int(10) , PRIMARY KEY (a)) Engine=InnoDB;
+INSERT INTO t1 VALUES (1),(2);
+
+CREATE TABLE t2 (a int(10), PRIMARY KEY (a)) Engine=InnoDB;
+INSERT INTO t2 VALUES (1);
+
+CREATE TABLE t3 (a int(10), b int(10), c int(10),
+ PRIMARY KEY (a)) Engine=InnoDB;
+INSERT INTO t3 VALUES (1,2,1);
+
+SELECT t1.* FROM t1 WHERE (SELECT COUNT(*) FROM t3,t2 WHERE t3.c=t2.a
+ and t2.a='1' AND t1.a=t3.b) > 0;
+
+DROP TABLE t1,t2,t3;
diff --git a/mysql-test/t/system_mysql_db_fix.test b/mysql-test/t/system_mysql_db_fix.test
index 0a2ab180806..fa44b454b4f 100644
--- a/mysql-test/t/system_mysql_db_fix.test
+++ b/mysql-test/t/system_mysql_db_fix.test
@@ -1,6 +1,9 @@
# Embedded server doesn't support external clients
--source include/not_embedded.inc
+# Windows doesn't support execution of shell scripts (to fix!!)
+--source include/not_windows.inc
+
#
# This is the test for mysql_fix_privilege_tables
#
diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test
index 95e8eaae83e..2a145e1eeaa 100644
--- a/mysql-test/t/trigger.test
+++ b/mysql-test/t/trigger.test
@@ -651,17 +651,105 @@ drop table t1;
# of functions and triggers.
create table t1 (id int);
--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create trigger t1_ai after insert on t1 for each row reset query cache;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create trigger t1_ai after insert on t1 for each row reset master;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create trigger t1_ai after insert on t1 for each row reset slave;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create trigger t1_ai after insert on t1 for each row flush hosts;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create trigger t1_ai after insert on t1 for each row flush tables with read lock;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create trigger t1_ai after insert on t1 for each row flush logs;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create trigger t1_ai after insert on t1 for each row flush status;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create trigger t1_ai after insert on t1 for each row flush slave;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create trigger t1_ai after insert on t1 for each row flush master;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create trigger t1_ai after insert on t1 for each row flush des_key_file;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+create trigger t1_ai after insert on t1 for each row flush user_resources;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
create trigger t1_ai after insert on t1 for each row flush tables;
--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
create trigger t1_ai after insert on t1 for each row flush privileges;
-create procedure p1() flush tables;
+--disable_warnings
+drop procedure if exists p1;
+--enable_warnings
+
create trigger t1_ai after insert on t1 for each row call p1();
+create procedure p1() flush tables;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+insert into t1 values (0);
+
+drop procedure p1;
+create procedure p1() reset query cache;
--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
insert into t1 values (0);
+
+drop procedure p1;
+create procedure p1() reset master;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+insert into t1 values (0);
+
+drop procedure p1;
+create procedure p1() reset slave;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+insert into t1 values (0);
+
+drop procedure p1;
+create procedure p1() flush hosts;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+insert into t1 values (0);
+
drop procedure p1;
create procedure p1() flush privileges;
--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
insert into t1 values (0);
+
+drop procedure p1;
+create procedure p1() flush tables with read lock;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+insert into t1 values (0);
+
+drop procedure p1;
+create procedure p1() flush tables;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+insert into t1 values (0);
+
+drop procedure p1;
+create procedure p1() flush logs;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+insert into t1 values (0);
+
+drop procedure p1;
+create procedure p1() flush status;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+insert into t1 values (0);
+
+drop procedure p1;
+create procedure p1() flush slave;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+insert into t1 values (0);
+
+drop procedure p1;
+create procedure p1() flush master;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+insert into t1 values (0);
+
+drop procedure p1;
+create procedure p1() flush des_key_file;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+insert into t1 values (0);
+
+drop procedure p1;
+create procedure p1() flush user_resources;
+--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG
+insert into t1 values (0);
+
drop procedure p1;
drop table t1;
@@ -1301,6 +1389,36 @@ create trigger wont_work after update on event for each row
begin
set @a:= 1;
end|
+use test|
delimiter ;|
+
+#
+# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause.
+#
+
+# Prepare.
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP TABLE IF EXISTS t2;
+--enable_warnings
+
+CREATE TABLE t1(c INT);
+CREATE TABLE t2(c INT);
+
+--error ER_WRONG_STRING_LENGTH
+CREATE DEFINER=1234567890abcdefGHIKL@localhost
+ TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a = 1;
+
+--error ER_WRONG_STRING_LENGTH
+CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY
+ TRIGGER t2_bi BEFORE INSERT ON t2 FOR EACH ROW SET @a = 2;
+
+# Cleanup.
+
+DROP TABLE t1;
+DROP TABLE t2;
+
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test
index e028dbc51d9..998f8f18fbe 100644
--- a/mysql-test/t/type_bit.test
+++ b/mysql-test/t/type_bit.test
@@ -238,4 +238,19 @@ select * from t1;
--disable_metadata
drop table t1;
+#
+# Bug#15583: BIN()/OCT()/CONV() do not work with BIT values
+#
+create table bug15583(b BIT(8), n INT);
+insert into bug15583 values(128, 128);
+insert into bug15583 values(null, null);
+insert into bug15583 values(0, 0);
+insert into bug15583 values(255, 255);
+select hex(b), bin(b), oct(b), hex(n), bin(n), oct(n) from bug15583;
+select hex(b)=hex(n) as should_be_onetrue, bin(b)=bin(n) as should_be_onetrue, oct(b)=oct(n) as should_be_onetrue from bug15583;
+select hex(b + 0), bin(b + 0), oct(b + 0), hex(n), bin(n), oct(n) from bug15583;
+select conv(b, 10, 2), conv(b + 0, 10, 2) from bug15583;
+drop table bug15583;
+
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test
index 503d7ffc0b9..6d79dcc863b 100644
--- a/mysql-test/t/type_blob.test
+++ b/mysql-test/t/type_blob.test
@@ -423,3 +423,18 @@ alter table t1 modify a binary(5);
select hex(a) from t1 order by a;
select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0');
drop table t1;
+
+#
+# Bug #19489: Inconsistent support for DEFAULT in TEXT columns
+#
+create table t1 (a text default '');
+show create table t1;
+insert into t1 values (default);
+select * from t1;
+drop table t1;
+set @@sql_mode='TRADITIONAL';
+--error ER_BLOB_CANT_HAVE_DEFAULT
+create table t1 (a text default '');
+set @@sql_mode='';
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test
index 78bdd9b8a80..c6050753943 100644
--- a/mysql-test/t/type_date.test
+++ b/mysql-test/t/type_date.test
@@ -36,8 +36,8 @@ INSERT INTO t1 VALUES ( "2000-1-2" );
INSERT INTO t1 VALUES ( "2000-1-3" );
INSERT INTO t1 VALUES ( "2000-1-4" );
INSERT INTO t1 VALUES ( "2000-1-5" );
-SELECT * FROM t1 WHERE datum BETWEEN "2000-1-2" AND "2000-1-4";
-SELECT * FROM t1 WHERE datum BETWEEN "2000-1-2" AND datum - INTERVAL 100 DAY;
+SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND cast("2000-1-4" as date);
+SELECT * FROM t1 WHERE datum BETWEEN cast("2000-1-2" as date) AND datum - INTERVAL 100 DAY;
DROP TABLE t1;
#
@@ -115,4 +115,11 @@ INSERT INTO t1 VALUES ('abc');
SELECT * FROM t1;
DROP TABLE t1;
+#
+# Bug#21677: Wrong result when comparing a DATE and a DATETIME in BETWEEN
+#
+create table t1(start_date date, end_date date);
+insert into t1 values ('2000-01-01','2000-01-02');
+select 1 from t1 where cast('2000-01-01 12:01:01' as datetime) between start_date and end_date;
+drop table t1;
# End of 4.1 tests
diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test
index 4b6741b4242..cdf73bf6c89 100644
--- a/mysql-test/t/type_datetime.test
+++ b/mysql-test/t/type_datetime.test
@@ -114,3 +114,14 @@ select * from t1;
drop table t1;
# End of 4.1 tests
+
+#
+# Bug#21475: Wrongly applied constant propagation leads to a false comparison.
+#
+CREATE TABLE t1(a DATETIME NOT NULL);
+INSERT INTO t1 VALUES ('20060606155555');
+SELECT a FROM t1 WHERE a=(SELECT MAX(a) FROM t1) AND (a="20060606155555");
+PREPARE s FROM 'SELECT a FROM t1 WHERE a=(SELECT MAX(a) FROM t1) AND (a="20060606155555")';
+EXECUTE s;
+DROP PREPARE s;
+DROP TABLE t1;
diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test
index 35aff8b3c5a..de1ebd74d17 100644
--- a/mysql-test/t/type_newdecimal.test
+++ b/mysql-test/t/type_newdecimal.test
@@ -947,8 +947,12 @@ select cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(3
#
# Bug #11708 (conversion to decimal fails in decimal part)
#
-select ln(14000) c1, convert(ln(14000),decimal(2,3)) c2, cast(ln(14000) as decimal(2,3)) c3;
-
+select ln(14000) c1, convert(ln(14000),decimal(5,3)) c2, cast(ln(14000) as decimal(5,3)) c3;
+--error 1427
+select convert(ln(14000),decimal(2,3)) c1;
+--error 1427
+select cast(ln(14000) as decimal(2,3)) c1;
+
#
# Bug #8449 (Silent column changes)
#
diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test
index ddfc3f11665..7b4af9e0c69 100644
--- a/mysql-test/t/type_timestamp.test
+++ b/mysql-test/t/type_timestamp.test
@@ -328,3 +328,14 @@ drop table t1;
# Restore timezone to default
set time_zone= @@global.time_zone;
+
+CREATE TABLE t1 (
+`id` int(11) NOT NULL auto_increment,
+`username` varchar(80) NOT NULL default '',
+`posted_on` timestamp NOT NULL default '0000-00-00 00:00:00',
+PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
+
+show fields from t1;
+select is_nullable from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='t1' and COLUMN_NAME='posted_on';
+drop table t1;
diff --git a/mysql-test/t/type_varchar.test b/mysql-test/t/type_varchar.test
index e5614afe4f6..439e98471b2 100644
--- a/mysql-test/t/type_varchar.test
+++ b/mysql-test/t/type_varchar.test
@@ -146,3 +146,44 @@ DROP TABLE IF EXISTS t1;
CREATE TABLE t1(f1 CHAR(100) DEFAULT 'test');
INSERT INTO t1 VALUES(SUBSTR(f1, 1, 3));
DROP TABLE IF EXISTS t1;
+
+#
+# Bug#14897 "ResultSet.getString("table.column") sometimes doesn't find the
+# column"
+# Test that after upgrading an old 4.1 VARCHAR column to 5.0 VARCHAR we preserve
+# the original column metadata.
+#
+--disable_warnings
+drop table if exists t1, t2, t3;
+--enable_warnings
+
+create table t3 (
+ id int(11),
+ en varchar(255) character set utf8,
+ cz varchar(255) character set utf8
+);
+system cp $MYSQL_TEST_DIR/std_data/14897.frm $MYSQLTEST_VARDIR/master-data/test/t3.frm;
+truncate table t3;
+insert into t3 (id, en, cz) values
+(1,'en string 1','cz string 1'),
+(2,'en string 2','cz string 2'),
+(3,'en string 3','cz string 3');
+
+create table t1 (
+ id int(11),
+ name_id int(11)
+);
+insert into t1 (id, name_id) values (1,1), (2,3), (3,3);
+
+create table t2 (id int(11));
+insert into t2 (id) values (1), (2), (3);
+
+# max_length is different for varchar fields in ps-protocol and we can't
+# replace a single metadata column, disable PS protocol
+--disable_ps_protocol
+--enable_metadata
+select t1.*, t2.id, t3.en, t3.cz from t1 left join t2 on t1.id=t2.id
+left join t3 on t1.id=t3.id order by t3.id;
+--disable_metadata
+--enable_ps_protocol
+drop table t1, t2, t3;
diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test
index f3be08c8537..96e559f5c05 100644
--- a/mysql-test/t/udf.test
+++ b/mysql-test/t/udf.test
@@ -1,6 +1,6 @@
--source include/have_udf.inc
#
-# To run this tests the "sql/udf_example.cc" need to be compiled into
+# To run this tests the "sql/udf_example.c" need to be compiled into
# udf_example.so and LD_LIBRARY_PATH should be setup to point out where
# the library are.
#
@@ -109,6 +109,24 @@ SELECT myfunc_double(n) AS f FROM bug19904;
SELECT metaphon(v) AS f FROM bug19904;
DROP TABLE bug19904;
+#
+# Bug#21269: DEFINER-clause is allowed for UDF-functions
+#
+
+--error ER_WRONG_USAGE
+CREATE DEFINER=CURRENT_USER() FUNCTION should_not_parse
+RETURNS STRING SONAME "should_not_parse.so";
+
+--error ER_WRONG_USAGE
+CREATE DEFINER=someone@somewhere FUNCTION should_not_parse
+RETURNS STRING SONAME "should_not_parse.so";
+#
+# Bug#19862: Sort with filesort by function evaluates function twice
+#
+create table t1(f1 int);
+insert into t1 values(1),(2);
+explain select myfunc_int(f1) from t1 order by 1;
+drop table t1;
--echo End of 5.0 tests.
#
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index 7dfe4ac482f..bf5c5e066f0 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -390,8 +390,8 @@ create table t1 SELECT da from t2 UNION select dt from t2;
select * from t1;
show create table t1;
drop table t1;
-create table t1 SELECT dt from t2 UNION select sc from t2;
-select * from t1;
+create table t1 SELECT dt from t2 UNION select trim(sc) from t2;
+select trim(dt) from t1;
show create table t1;
drop table t1;
create table t1 SELECT dt from t2 UNION select sv from t2;
@@ -795,6 +795,14 @@ drop table t1;
# End of 4.1 tests
#
+# Bug#12185: Data type aggregation may produce wrong result
+#
+create table t1(f1 char(1), f2 char(5), f3 binary(1), f4 binary(5), f5 timestamp, f6 varchar(1) character set utf8 collate utf8_general_ci, f7 text);
+create table t2 as select *, f6 as f8 from t1 union select *, f7 from t1;
+show create table t2;
+drop table t1, t2;
+
+#
# Bug#18175: Union select over 129 tables with a sum function fails.
#
(select avg(1)) union (select avg(1)) union (select avg(1)) union
@@ -841,3 +849,10 @@ drop table t1;
(select avg(1)) union (select avg(1)) union (select avg(1)) union
(select avg(1)) union (select avg(1)) union (select avg(1));
+#
+# Bug #16881: password() and union select
+# (The issue was poor handling of character set aggregation.)
+#
+select _utf8'12' union select _latin1'12345';
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test
index e1b23a1782f..644ca506eba 100644
--- a/mysql-test/t/user_var.test
+++ b/mysql-test/t/user_var.test
@@ -144,9 +144,6 @@ select @@version;
--replace_column 1 #
select @@global.version;
-# End of 4.1 tests
-
-#
# Bug #6598: problem with cast(NULL as signed integer);
#
@@ -171,3 +168,46 @@ set @first_var= cast(NULL as CHAR);
create table t1 select @first_var;
show create table t1;
drop table t1;
+
+#
+# Bug #7498 User variable SET saves SIGNED BIGINT as UNSIGNED BIGINT
+#
+
+# First part, set user var to large number and select it
+set @a=18446744071710965857;
+select @a;
+
+# Second part, set user var from large number in table
+# then select it
+CREATE TABLE `bigfailure` (
+ `afield` BIGINT UNSIGNED NOT NULL
+);
+INSERT INTO `bigfailure` VALUES (18446744071710965857);
+SELECT * FROM bigfailure;
+select * from (SELECT afield FROM bigfailure) as b;
+select * from bigfailure where afield = (SELECT afield FROM bigfailure);
+select * from bigfailure where afield = 18446744071710965857;
+# This is fixed in 5.0, to be uncommented there
+#select * from bigfailure where afield = '18446744071710965857';
+select * from bigfailure where afield = 18446744071710965856+1;
+
+SET @a := (SELECT afield FROM bigfailure);
+SELECT @a;
+SET @a := (select afield from (SELECT afield FROM bigfailure) as b);
+SELECT @a;
+SET @a := (select * from bigfailure where afield = (SELECT afield FROM bigfailure));
+SELECT @a;
+
+drop table bigfailure;
+
+#
+# Bug#16861: User defined variable can have a wrong value if a tmp table was
+# used.
+#
+create table t1(f1 int, f2 int);
+insert into t1 values (1,2),(2,3),(3,1);
+select @var:=f2 from t1 group by f1 order by f2 desc limit 1;
+select @var;
+drop table t1;
+
+# End of 4.1 tests
diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test
index 68efcafd1e0..d855b4d8266 100644
--- a/mysql-test/t/variables.test
+++ b/mysql-test/t/variables.test
@@ -585,6 +585,16 @@ show variables like 'ssl%';
select @@log_queries_not_using_indexes;
show variables like 'log_queries_not_using_indexes';
+#
+# Bug#20908: Crash if select @@""
+#
+--error ER_PARSE_ERROR
+select @@"";
+--error ER_PARSE_ERROR
+select @@&;
+--error ER_PARSE_ERROR
+select @@@;
+
--echo End of 5.0 tests
# This is at the very after the versioned tests, since it involves doing
@@ -620,3 +630,4 @@ set global server_id =@my_server_id;
set global slow_launch_time =@my_slow_launch_time;
set global storage_engine =@my_storage_engine;
set global thread_cache_size =@my_thread_cache_size;
+
diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test
index a1c1e9b2ad1..4745804e847 100644
--- a/mysql-test/t/view.test
+++ b/mysql-test/t/view.test
@@ -2449,8 +2449,8 @@ INSERT INTO t1 VALUES
CREATE VIEW v1 AS SELECT * FROM t1;
-SELECT * FROM t1 WHERE td BETWEEN '2005.01.02' AND '2005.01.04';
-SELECT * FROM v1 WHERE td BETWEEN '2005.01.02' AND '2005.01.04';
+SELECT * FROM t1 WHERE td BETWEEN CAST('2005.01.02' AS DATE) AND CAST('2005.01.04' AS DATE);
+SELECT * FROM v1 WHERE td BETWEEN CAST('2005.01.02' AS DATE) AND CAST('2005.01.04' AS DATE);
DROP VIEW v1;
DROP TABLE t1;
@@ -2595,4 +2595,259 @@ CREATE TABLE t2 SELECT * FROM v1;
SELECT * FROM t2;
DROP VIEW v1;
-DROP TABLE IF EXISTS t1,t2;
+DROP TABLE t1,t2;
+
+#
+# Bug#16110: insert permitted into view col w/o default value
+#
+CREATE TABLE t1 (a INT NOT NULL, b INT NULL DEFAULT NULL);
+CREATE VIEW v1 AS SELECT a, b FROM t1;
+
+INSERT INTO v1 (b) VALUES (2);
+
+SET SQL_MODE = STRICT_ALL_TABLES;
+--error 1423
+INSERT INTO v1 (b) VALUES (4);
+SET SQL_MODE = '';
+
+SELECT * FROM t1;
+
+DROP VIEW v1;
+DROP TABLE t1;
+
+#
+# Bug #18243: expression over a view column that with the REVERSE function
+#
+
+CREATE TABLE t1 (firstname text, surname text);
+INSERT INTO t1 VALUES
+ ("Bart","Simpson"),("Milhouse","van Houten"),("Montgomery","Burns");
+
+CREATE VIEW v1 AS SELECT CONCAT(firstname," ",surname) AS name FROM t1;
+SELECT CONCAT(LEFT(name,LENGTH(name)-INSTR(REVERSE(name)," ")),
+ LEFT(name,LENGTH(name)-INSTR(REVERSE(name)," "))) AS f1
+ FROM v1;
+
+DROP VIEW v1;
+DROP TABLE t1;
+
+#
+# Bug #19714: wrong type of a view column specified by an expressions over ints
+#
+
+CREATE TABLE t1 (i int, j int);
+CREATE VIEW v1 AS SELECT COALESCE(i,j) FROM t1;
+DESCRIBE v1;
+CREATE TABLE t2 SELECT COALESCE(i,j) FROM t1;
+DESCRIBE t2;
+
+DROP VIEW v1;
+DROP TABLE t1,t2;
+
+#
+# Bug #17526: views with TRIM functions
+#
+
+CREATE TABLE t1 (s varchar(10));
+INSERT INTO t1 VALUES ('yadda'), ('yady');
+
+SELECT TRIM(BOTH 'y' FROM s) FROM t1;
+CREATE VIEW v1 AS SELECT TRIM(BOTH 'y' FROM s) FROM t1;
+SELECT * FROM v1;
+DROP VIEW v1;
+
+SELECT TRIM(LEADING 'y' FROM s) FROM t1;
+CREATE VIEW v1 AS SELECT TRIM(LEADING 'y' FROM s) FROM t1;
+SELECT * FROM v1;
+DROP VIEW v1;
+
+SELECT TRIM(TRAILING 'y' FROM s) FROM t1;
+CREATE VIEW v1 AS SELECT TRIM(TRAILING 'y' FROM s) FROM t1;
+SELECT * FROM v1;
+DROP VIEW v1;
+
+DROP TABLE t1;
+
+#
+#Bug #21080: ALTER VIEW makes user restate SQL SECURITY mode, and ALGORITHM
+#
+CREATE TABLE t1 (x INT, y INT);
+CREATE ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
+SHOW CREATE VIEW v1;
+
+ALTER VIEW v1 AS SELECT x, y FROM t1;
+SHOW CREATE VIEW v1;
+
+DROP VIEW v1;
+DROP TABLE t1;
+# Bug #21086: server crashes when VIEW defined with a SELECT with COLLATE
+# clause is called
+#
+CREATE TABLE t1 (s1 char);
+INSERT INTO t1 VALUES ('Z');
+
+CREATE VIEW v1 AS SELECT s1 collate latin1_german1_ci AS col FROM t1;
+
+CREATE VIEW v2 (col) AS SELECT s1 collate latin1_german1_ci FROM t1;
+
+# either of these statements will cause crash
+INSERT INTO v1 (col) VALUES ('b');
+INSERT INTO v2 (col) VALUES ('c');
+
+SELECT s1 FROM t1;
+DROP VIEW v1, v2;
+DROP TABLE t1;
+
+#
+# Bug #11551: Asymmetric + undocumented behaviour of DROP VIEW and DROP TABLE
+#
+CREATE TABLE t1 (id INT);
+CREATE VIEW v1 AS SELECT id FROM t1;
+SHOW TABLES;
+
+--error 1051
+DROP VIEW v2,v1;
+SHOW TABLES;
+
+CREATE VIEW v1 AS SELECT id FROM t1;
+--error 1347
+DROP VIEW t1,v1;
+SHOW TABLES;
+
+DROP TABLE t1;
+--disable_warnings
+DROP VIEW IF EXISTS v1;
+--enable_warnings
+
+#
+# Bug #21261: Wrong access rights was required for an insert to a view
+#
+CREATE DATABASE bug21261DB;
+USE bug21261DB;
+CONNECT (root,localhost,root,,bug21261DB);
+CONNECTION root;
+
+CREATE TABLE t1 (x INT);
+CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
+GRANT INSERT, UPDATE ON v1 TO 'user21261'@'localhost';
+GRANT INSERT, UPDATE ON t1 TO 'user21261'@'localhost';
+CREATE TABLE t2 (y INT);
+GRANT SELECT ON t2 TO 'user21261'@'localhost';
+
+CONNECT (user21261, localhost, user21261,, bug21261DB);
+CONNECTION user21261;
+INSERT INTO v1 (x) VALUES (5);
+UPDATE v1 SET x=1;
+CONNECTION root;
+GRANT SELECT ON v1 TO 'user21261'@'localhost';
+GRANT SELECT ON t1 TO 'user21261'@'localhost';
+CONNECTION user21261;
+UPDATE v1,t2 SET x=1 WHERE x=y;
+CONNECTION root;
+SELECT * FROM t1;
+REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost';
+DROP USER 'user21261'@'localhost';
+DROP VIEW v1;
+DROP TABLE t1;
+DROP DATABASE bug21261DB;
+USE test;
+
+#
+# Bug #15950: NOW() optimized away in VIEWs
+#
+create table t1 (f1 datetime);
+create view v1 as select * from t1 where f1 between now() and now() + interval 1 minute;
+show create view v1;
+drop view v1;
+drop table t1;
+#
+# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause.
+#
+
+# Prepare.
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP VIEW IF EXISTS v1;
+DROP VIEW IF EXISTS v2;
+--enable_warnings
+
+CREATE TABLE t1(a INT, b INT);
+
+--error ER_WRONG_STRING_LENGTH
+CREATE DEFINER=1234567890abcdefGHIKL@localhost
+ VIEW v1 AS SELECT a FROM t1;
+
+--error ER_WRONG_STRING_LENGTH
+CREATE DEFINER=some_user_name@1234567890abcdefghij1234567890abcdefghij1234567890abcdefghijQWERTY
+ VIEW v2 AS SELECT b FROM t1;
+
+# Cleanup.
+
+DROP TABLE t1;
+
+
+#
+# BUG#17591: Updatable view not possible with trigger or stored
+# function
+#
+# During prelocking phase we didn't update lock type of view tables,
+# hence READ lock was always requested.
+#
+--disable_warnings
+DROP FUNCTION IF EXISTS f1;
+DROP FUNCTION IF EXISTS f2;
+DROP VIEW IF EXISTS v1, v2;
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+CREATE TABLE t1 (i INT);
+
+CREATE VIEW v1 AS SELECT * FROM t1;
+
+delimiter |;
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+ INSERT INTO v1 VALUES (0);
+ RETURN 0;
+END |
+delimiter ;|
+
+SELECT f1();
+
+CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t1;
+
+delimiter |;
+CREATE FUNCTION f2() RETURNS INT
+BEGIN
+ INSERT INTO v2 VALUES (0);
+ RETURN 0;
+END |
+delimiter ;|
+
+--error ER_NON_UPDATABLE_TABLE
+SELECT f2();
+
+DROP FUNCTION f1;
+DROP FUNCTION f2;
+DROP VIEW v1, v2;
+DROP TABLE t1;
+
+#
+# Bug #5500: wrong select_type in EXPLAIN output for queries over views
+#
+
+CREATE TABLE t1 (s1 int);
+CREATE VIEW v1 AS SELECT * FROM t1;
+
+EXPLAIN SELECT * FROM t1;
+EXPLAIN SELECT * FROM v1;
+
+INSERT INTO t1 VALUES (1), (3), (2);
+
+EXPLAIN SELECT * FROM t1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1);
+EXPLAIN SELECT * FROM v1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1);
+
+DROP VIEW v1;
+DROP TABLE t1;
+--echo End of 5.0 tests.
diff --git a/mysql-test/t/warnings-master.opt b/mysql-test/t/warnings-master.opt
index 3b8baeddb14..e924a22e2ce 100644
--- a/mysql-test/t/warnings-master.opt
+++ b/mysql-test/t/warnings-master.opt
@@ -1 +1 @@
---skip-isam
+--skip-isam --skip-merge
diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test
index 71e847d1d8c..4768c7574e5 100644
--- a/mysql-test/t/warnings.test
+++ b/mysql-test/t/warnings.test
@@ -117,6 +117,10 @@ create table t1 (id int) engine=isam;
alter table t1 engine=isam;
drop table t1;
+create table t1 (id int) engine=merge;
+alter table t1 engine=merge;
+drop table t1;
+
#
# Test for deprecated TYPE= syntax
#