diff options
author | unknown <pem@mysql.com> | 2005-06-10 16:56:34 +0200 |
---|---|---|
committer | unknown <pem@mysql.com> | 2005-06-10 16:56:34 +0200 |
commit | 4b0264dffd689b4d688fb76671c395c02f31aec0 (patch) | |
tree | 0c98e814978a1dbcc67cf6961168656ef81da1f7 /mysql-test | |
parent | 03949f8ce8aba38e691bda665d277df8bc1fbee2 (diff) | |
parent | 846d6be749125abc43c847136cbe8fecdcf2c3e5 (diff) | |
download | mariadb-git-4b0264dffd689b4d688fb76671c395c02f31aec0.tar.gz |
Merge mysql.com:/usr/local/bk/mysql-5.0
into mysql.com:/home/pem/work/mysql-5.0
mysql-test/r/sp.result:
Auto merged
mysql-test/t/sp.test:
Auto merged
sql/item_func.cc:
Auto merged
sql/sp_head.cc:
Auto merged
sql/sp_rcontext.cc:
Auto merged
Diffstat (limited to 'mysql-test')
78 files changed, 1866 insertions, 263 deletions
diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 9963074daf5..3a59a060778 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -35,7 +35,8 @@ testdir = $(benchdir_root)/mysql-test EXTRA_SCRIPTS = mysql-test-run.sh mysql-test-run.pl install_test_db.sh valgrind.supp EXTRA_DIST = $(EXTRA_SCRIPTS) test_SCRIPTS = mysql-test-run install_test_db -test_DATA = std_data/client-key.pem std_data/client-cert.pem std_data/cacert.pem +test_DATA = std_data/client-key.pem std_data/client-cert.pem std_data/cacert.pem \ + std_data/server-cert.pem std_data/server-key.pem CLEANFILES = $(test_SCRIPTS) $(test_DATA) INCLUDES = -I$(srcdir)/../include -I../include -I.. @@ -48,6 +49,7 @@ dist-hook: mkdir -p $(distdir)/t $(distdir)/r $(distdir)/include \ $(distdir)/std_data $(distdir)/lib $(INSTALL_DATA) $(srcdir)/t/*.test $(distdir)/t + $(INSTALL_DATA) $(srcdir)/t/*.sql $(distdir)/t -$(INSTALL_DATA) $(srcdir)/t/*.disabled $(distdir)/t $(INSTALL_DATA) $(srcdir)/t/*.opt $(srcdir)/t/*.sh $(srcdir)/t/*.slave-mi $(distdir)/t $(INSTALL_DATA) $(srcdir)/include/*.inc $(distdir)/include @@ -69,6 +71,7 @@ install-data-local: $(DESTDIR)$(testdir)/lib $(INSTALL_DATA) $(srcdir)/README $(DESTDIR)$(testdir) $(INSTALL_DATA) $(srcdir)/t/*.test $(DESTDIR)$(testdir)/t + $(INSTALL_DATA) $(srcdir)/t/*.sql $(DESTDIR)$(testdir)/t -$(INSTALL_DATA) $(srcdir)/t/*.disabled $(DESTDIR)$(testdir)/t $(INSTALL_DATA) $(srcdir)/t/*.opt $(DESTDIR)$(testdir)/t $(INSTALL_DATA) $(srcdir)/t/*.sh $(DESTDIR)$(testdir)/t diff --git a/mysql-test/include/ps_modify.inc b/mysql-test/include/ps_modify.inc index 04b9734240b..633c317f4b2 100644 --- a/mysql-test/include/ps_modify.inc +++ b/mysql-test/include/ps_modify.inc @@ -174,11 +174,8 @@ where a=2 limit 1'; execute stmt1 ; select a,b from t1 where b = 'bla' ; -# currently (May 2004, Version 4.1) it is impossible --- error 1064 -prepare stmt1 from 'update t1 set b=''bla'' -where a=2 -limit ?'; +prepare stmt1 from 'update t1 set b=''bla'' where a=2 limit ?'; +execute stmt1 using @arg00; --disable_query_log select '------ insert tests ------' as test_sequence ; diff --git a/mysql-test/include/ps_query.inc b/mysql-test/include/ps_query.inc index 9a413bff2f3..63504a0fa2b 100644 --- a/mysql-test/include/ps_query.inc +++ b/mysql-test/include/ps_query.inc @@ -300,10 +300,8 @@ set @arg00=1; prepare stmt1 from ' select a,b from t1 order by a limit 1 '; execute stmt1 ; -# currently (May 2004, Version 4.1) it is impossible --- error 1064 -prepare stmt1 from ' select a,b from t1 -limit ? '; +prepare stmt1 from ' select a,b from t1 limit ? '; +execute stmt1 using @arg00; ##### parameter used in many places set @arg00='b' ; diff --git a/mysql-test/include/show_msg.inc b/mysql-test/include/show_msg.inc new file mode 100755 index 00000000000..5a29541edcf --- /dev/null +++ b/mysql-test/include/show_msg.inc @@ -0,0 +1,19 @@ +#### include/show_msg.inc +# +# This file writes the value set in @message into the +# a protocol file as part of executing a test sequence +# +# Usage: +# Add the following to any *.test file: +# : +# set @message="This is a message example"; +# --source include/show_msg.inc +# : +# + +--disable_query_log +SET @utf8_message = CONVERT(@message using utf8); +select @utf8_message as "" +union +select repeat(CONVERT('-' using utf8),char_length(@utf8_message)); +--enable_query_log diff --git a/mysql-test/include/show_msg80.inc b/mysql-test/include/show_msg80.inc new file mode 100755 index 00000000000..d9a59c5517a --- /dev/null +++ b/mysql-test/include/show_msg80.inc @@ -0,0 +1,23 @@ +#### include/show_msg80.inc +# +# This file writes the value set in @message into the +# a protocol file as part of executing a test sequence +# with a dash line that is fixed on 80 characters. +# This can be used in the case of long messages, +# multi line messages that exceed 80 or if an 80 char +# line is desired for short messages. +# +# Usage: +# Add the following to any *.test file: +# : +# set @message="This is a message example"; +# --source include/show_msg80.inc +# : +# + +--disable_query_log +SET @utf8_message = CONVERT(@message using utf8); +select @utf8_message as "" +union +select repeat(CONVERT('-' using utf8),80); +--enable_query_log diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl index 5f80864d1f7..efa1b3bec21 100644 --- a/mysql-test/lib/mtr_misc.pl +++ b/mysql-test/lib/mtr_misc.pl @@ -25,7 +25,7 @@ sub mtr_full_hostname () { if ( $hostname !~ /\./ ) { my $address= gethostbyname($hostname) - or die "Couldn't resolve $hostname : $!"; + or mtr_error("Couldn't resolve $hostname : $!"); my $fullname= gethostbyaddr($address, AF_INET); $hostname= $fullname if $fullname; } diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 78758e54aa4..7bca422773c 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -17,6 +17,7 @@ sub mtr_spawn ($$$$$$); sub mtr_stop_mysqld_servers ($); sub mtr_kill_leftovers (); sub mtr_record_dead_children (); +sub mtr_exit ($); sub sleep_until_file_created ($$$); # static in C @@ -784,4 +785,17 @@ sub sleep_until_file_created ($$$) { } +############################################################################## +# +# When we exit, we kill off all children +# +############################################################################## + +sub mtr_exit ($) { + my $code= shift; + local $SIG{HUP} = 'IGNORE'; + kill('HUP', -$$); + exit($code); +} + 1; diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index cb41549422f..a258d139bb1 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -268,7 +268,8 @@ sub mtr_warning (@) { } sub mtr_error (@) { - die "mysql-test-run: *** ERROR: ",join(" ", @_),"\n"; + print STDERR "mysql-test-run: *** ERROR: ",join(" ", @_),"\n"; + mtr_exit(1); } sub mtr_debug (@) { diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 52ffff088b5..7b57108466d 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -398,7 +398,7 @@ sub main () { } } - exit(0); + mtr_exit(0); } ############################################################################## @@ -568,7 +568,9 @@ sub command_line_setup () { $opt_vardir= "$glob_mysql_test_dir/var"; } - if ( $opt_vardir !~ m,^/, ) + # We make the path absolute, as the server will do a chdir() before usage + unless ( $opt_vardir =~ m,^/, or + ($glob_win32 and $opt_vardir =~ m,^[a-z]:/,i) ) { # Make absolute path, relative test dir $opt_vardir= "$glob_mysql_test_dir/$opt_vardir"; @@ -1292,9 +1294,9 @@ sub install_db ($$) { mtr_report("Installing \u$type Databases"); open(IN, $init_db_sql) - or error("Can't open $init_db_sql: $!"); + or mtr_error("Can't open $init_db_sql: $!"); open(OUT, ">", $init_db_sql_tmp) - or error("Can't write to $init_db_sql_tmp: $!"); + or mtr_error("Can't write to $init_db_sql_tmp: $!"); while (<IN>) { chomp; @@ -1568,7 +1570,7 @@ sub report_failure_and_restart ($) { { stop_masters_slaves(); } - exit(1); + mtr_exit(1); } # FIXME always terminate on failure?! @@ -2267,5 +2269,5 @@ Options not yet described, or that I want to look into more with-openssl HERE - exit(1); + mtr_exit(1); } diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 45b1e948ac2..bdd92e7941b 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -887,7 +887,7 @@ report_stats () { found_error=0 # Find errors - for i in "^Warning:" "^Error:" "^==.* at 0x" + for i in "^Warning:" "^Error:" "^==.* at 0x" "InnoDB: Warning" do if $GREP "$i" $MY_LOG_DIR/warnings.tmp >> $MY_LOG_DIR/warnings then diff --git a/mysql-test/r/analyze.result b/mysql-test/r/analyze.result new file mode 100644 index 00000000000..0b44a502b13 --- /dev/null +++ b/mysql-test/r/analyze.result @@ -0,0 +1,32 @@ +create table t1 (a bigint); +lock tables t1 write; +insert into t1 values(0); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +unlock tables; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +create table t1 (a bigint); +insert into t1 values(0); +lock tables t1 write; +delete from t1; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +unlock tables; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +create table t1 (a bigint); +insert into t1 values(0); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status OK +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result index 4587c675150..61a42b004a9 100644 --- a/mysql-test/r/auto_increment.result +++ b/mysql-test/r/auto_increment.result @@ -355,3 +355,42 @@ CHECK TABLE t1; Table Op Msg_type Msg_text test.t1 check status OK DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`)); +insert into t1 (b) values (1); +replace into t1 (b) values (2), (1), (3); +select * from t1; +a b +3 1 +2 2 +4 3 +truncate table t1; +insert into t1 (b) values (1); +replace into t1 (b) values (2); +replace into t1 (b) values (1); +replace into t1 (b) values (3); +select * from t1; +a b +3 1 +2 2 +4 3 +drop table t1; +create table t1 (rowid int not null auto_increment, val int not null,primary +key (rowid), unique(val)); +replace into t1 (val) values ('1'),('2'); +replace into t1 (val) values ('1'),('2'); +insert into t1 (val) values ('1'),('2'); +ERROR 23000: Duplicate entry '1' for key 2 +select * from t1; +rowid val +3 1 +4 2 +drop table t1; +create table t1 (a int not null auto_increment primary key, val int); +insert into t1 (val) values (1); +update t1 set a=2 where a=1; +insert into t1 (val) values (1); +select * from t1; +a val +2 1 +3 1 +drop table t1; diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index ae09b8d730c..d622127e8f0 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -434,7 +434,7 @@ d date YES NULL e varchar(1) NO f datetime YES NULL g time YES NULL -h varbinary(23) NO +h longblob NO dd time YES NULL select * from t2; a b c d e f g h dd @@ -513,9 +513,9 @@ drop database mysqltest; select database(); database() NULL -select database(); -database() -NULL +select database(), user(); +database() user() +NULL mysqltest_1@localhost use test; create table t1 (a int, index `primary` (a)); ERROR 42000: Incorrect index name 'primary' @@ -579,7 +579,6 @@ select * from t2; b 1 drop table t1,t2; -use test; create table t1 (a int); create table t1 select * from t1; ERROR HY000: You can't specify target table 't1' for update in FROM clause @@ -597,3 +596,9 @@ ERROR 42000: Incorrect database name 'xyz' create table t1(t1.name int); create table t2(test.t2.name int); drop table t1,t2; +create database mysqltest; +use mysqltest; +drop database mysqltest; +create table test.t1 like x; +ERROR 42000: Incorrect database name 'NULL' +drop table if exists test.t1; diff --git a/mysql-test/r/ctype_cp1250_ch.result b/mysql-test/r/ctype_cp1250_ch.result index 62936b84caf..7b2ca7d7e0e 100644 --- a/mysql-test/r/ctype_cp1250_ch.result +++ b/mysql-test/r/ctype_cp1250_ch.result @@ -7,3 +7,15 @@ SELECT a, length(a), a='', a=' ', a=' ' FROM t1; a length(a) a='' a=' ' a=' ' 0 1 1 1 DROP TABLE t1; +CREATE TABLE t1 ( +popisek varchar(30) collate cp1250_general_ci NOT NULL default '', +PRIMARY KEY (`popisek`) +); +INSERT INTO t1 VALUES ('2005-01-1'); +SELECT * FROM t1 WHERE popisek = '2005-01-1'; +popisek +2005-01-1 +SELECT * FROM t1 WHERE popisek LIKE '2005-01-1'; +popisek +2005-01-1 +drop table t1; diff --git a/mysql-test/r/ctype_uca.result b/mysql-test/r/ctype_uca.result index c6e803904a3..3803dd932d7 100644 --- a/mysql-test/r/ctype_uca.result +++ b/mysql-test/r/ctype_uca.result @@ -2396,3 +2396,27 @@ utf8_unicode_ci 6109 utf8_unicode_ci 61 utf8_unicode_ci 6120 drop table t1; +CREATE TABLE t1 (id int, a varchar(30) character set utf8); +INSERT INTO t1 VALUES (1, _ucs2 0x01310069), (2, _ucs2 0x01310131); +INSERT INTO t1 VALUES (3, _ucs2 0x00690069), (4, _ucs2 0x01300049); +INSERT INTO t1 VALUES (5, _ucs2 0x01300130), (6, _ucs2 0x00490049); +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +a la l ll u lu +ıi 3 ıi 3 II 2 +ıı 4 ıı 4 II 2 +ii 2 ii 2 II 2 +İI 3 ii 2 İI 3 +İİ 4 ii 2 İİ 4 +II 2 ii 2 II 2 +ALTER TABLE t1 MODIFY a VARCHAR(30) character set utf8 collate utf8_turkish_ci; +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +a la l ll u lu +ıi 3 ıi 3 Iİ 3 +ıı 4 ıı 4 II 2 +ii 2 ii 2 İİ 4 +İI 3 iı 3 İI 3 +İİ 4 ii 2 İİ 4 +II 2 ıı 4 II 2 +DROP TABLE t1; diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 4be9139f20b..30f18c09dec 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -891,3 +891,17 @@ string create table t1 (a varchar(255)) default character set utf8; insert into t1 values (1.0); drop table t1; +create table t1 ( +id int not null, +city varchar(20) not null, +key (city(7),id) +) character set=utf8; +insert into t1 values (1,'Durban North'); +insert into t1 values (2,'Durban'); +select * from t1 where city = 'Durban'; +id city +2 Durban +select * from t1 where city = 'Durban '; +id city +2 Durban +drop table t1; diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result index 411cd52b4ca..ddfeeac77b5 100644 --- a/mysql-test/r/delete.result +++ b/mysql-test/r/delete.result @@ -1,4 +1,4 @@ -drop table if exists t1,t11,t12,t2; +drop table if exists t1,t2,t3,t11,t12; CREATE TABLE t1 (a tinyint(3), b tinyint(5)); INSERT INTO t1 VALUES (1,1); INSERT LOW_PRIORITY INTO t1 VALUES (1,2); @@ -172,3 +172,23 @@ a 0 2 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)); +insert into t1 values (1,1),(2,1),(1,3); +insert into t2 values (1,1),(2,2),(3,3); +insert into t3 values (1,1),(2,1),(1,3); +select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b; +a b a b a b +1 1 1 1 1 1 +2 1 2 2 2 1 +1 3 1 1 1 3 +explain select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 +1 SIMPLE t2 index PRIMARY PRIMARY 8 NULL 3 Using where; Using index +1 SIMPLE t3 index PRIMARY PRIMARY 8 NULL 3 Using where; Using index +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; diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index 955ea5b8673..3ad2b73f1d3 100644 --- a/mysql-test/r/distinct.result +++ b/mysql-test/r/distinct.result @@ -464,3 +464,11 @@ SELECT DISTINCT html,SUM(rout)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin; html prod 1 0.0000 drop table t1; +create table t1 (id int, dsc varchar(50)); +insert into t1 values (1, "line number one"), (2, "line number two"), (3, "line number three"); +select distinct id, IFNULL(dsc, '-') from t1; +id IFNULL(dsc, '-') +1 line number one +2 line number two +3 line number three +drop table t1; diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 09ff3fc5a6e..10afb61ba1d 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -343,18 +343,6 @@ GROUP_CONCAT(b ORDER BY b) First Row Second Row DROP TABLE t1; -CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1; -INSERT INTO t1 VALUES (1),(2),(3); -CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a), -CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1; -INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2); -SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz; -a_id b_list -1 1,2,3 -2 4,5 -3 NULL -DROP TABLE t2; -DROP TABLE t1; CREATE TABLE t1 (A_ID INT NOT NULL,A_DESC CHAR(3) NOT NULL,PRIMARY KEY (A_ID)); INSERT INTO t1 VALUES (1,'ABC'), (2,'EFG'), (3,'HIJ'); CREATE TABLE t2 (A_ID INT NOT NULL,B_DESC CHAR(3) NOT NULL,PRIMARY KEY (A_ID,B_DESC)); @@ -462,6 +450,49 @@ SELECT GROUP_CONCAT(id) AS gc FROM t1 HAVING gc IS NULL; gc NULL DROP TABLE t1; +create table t2 (a int, b int); +insert into t2 values (1,1), (2,2); +select b x, (select group_concat(x) from t2) from t2; +x (select group_concat(x) from t2) +1 1,1 +2 2,2 +drop table t2; +create table t1 (d int not null auto_increment,primary key(d), a int, b int, c int); +insert into t1(a,b) values (1,3), (1,4), (1,2), (2,7), (1,1), (1,2), (2,3), (2,3); +select d,a,b from t1 order by a; +d a b +1 1 3 +2 1 4 +3 1 2 +5 1 1 +6 1 2 +4 2 7 +7 2 3 +8 2 3 +explain select a, group_concat(b) from t1 group by a with rollup; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using filesort +select a, group_concat(b) from t1 group by a with rollup; +a group_concat(b) +1 3,4,2,1,2 +2 7,3,3 +NULL 3,4,2,1,2,7,3,3 +select a, group_concat(distinct b) from t1 group by a with rollup; +a group_concat(distinct b) +1 3,4,2,1 +2 7,3 +NULL 3,4,2,1,7 +select a, group_concat(b order by b) from t1 group by a with rollup; +a group_concat(b order by b) +1 1,2,2,3,4 +2 3,3,7 +NULL 1,2,2,3,3,3,4,7 +select a, group_concat(distinct b order by b) from t1 group by a with rollup; +a group_concat(distinct b order by b) +1 1,2,3,4 +2 3,7 +NULL 1,2,3,4,7 +drop table t1; create table t1 (a char(3), b char(20), primary key (a, b)); insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English'); select group_concat(a) from t1 group by b; @@ -469,10 +500,3 @@ group_concat(a) ABW ABW drop table t1; -create table r2 (a int, b int); -insert into r2 values (1,1), (2,2); -select b x, (select group_concat(x) from r2) from r2; -x (select group_concat(x) from r2) -1 1,1 -2 2,2 -drop table r2; diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index 0798a034c3e..c7674c57c8d 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -130,3 +130,19 @@ Warnings: Note 1003 select degrees(pi()) AS `degrees(pi())`,radians(360) AS `radians(360)` select rand(rand); ERROR 42S22: Unknown column 'rand' in 'field list' +create table t1 (col1 int, col2 decimal(60,30)); +insert into t1 values(1,1234567890.12345); +select format(col2,7) from t1; +format(col2,7) +1,234,567,890.1234500 +select format(col2,8) from t1; +format(col2,8) +1,234,567,890.12345000 +insert into t1 values(7,1234567890123456.12345); +select format(col2,6) from t1 where col1=7; +format(col2,6) +1,234,567,890,123,456.123450 +drop table t1; +select round(150, 2); +round(150, 2) +150.00 diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 4293ef5bd85..cb51da75368 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -688,3 +688,21 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: Note 1003 select timestamp_diff(WEEK,_latin1'2001-02-01',_latin1'2001-05-01') AS `a1`,timestamp_diff(SECOND_FRAC,_latin1'2001-02-01 12:59:59.120000',_latin1'2001-05-01 12:58:58.119999') AS `a2` +select last_day('2005-00-00'); +last_day('2005-00-00') +NULL +Warnings: +Warning 1292 Truncated incorrect datetime value: '2005-00-00' +select last_day('2005-00-01'); +last_day('2005-00-01') +NULL +Warnings: +Warning 1292 Truncated incorrect datetime value: '2005-00-01' +select last_day('2005-01-00'); +last_day('2005-01-00') +NULL +Warnings: +Warning 1292 Truncated incorrect datetime value: '2005-01-00' +select time_format('100:00:00', '%H %k %h %I %l'); +time_format('100:00:00', '%H %k %h %I %l') +100 100 04 04 4 diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 88b43c7ce35..937ed401f40 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -711,3 +711,14 @@ select min(b) from t1; min(b) 3000000000 drop table t1; +CREATE TABLE t1 (id int PRIMARY KEY, user_id int, hostname longtext); +INSERT INTO t1 VALUES +(1, 7, 'cache-dtc-af05.proxy.aol.com'), +(2, 3, 'what.ever.com'), +(3, 7, 'cache-dtc-af05.proxy.aol.com'), +(4, 7, 'cache-dtc-af05.proxy.aol.com'); +SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1 +WHERE hostname LIKE '%aol%' + GROUP BY hostname; +hostname no +cache-dtc-af05.proxy.aol.com 1 diff --git a/mysql-test/r/heap.result b/mysql-test/r/heap.result index d2750fd5a43..22304c4a93d 100644 --- a/mysql-test/r/heap.result +++ b/mysql-test/r/heap.result @@ -696,3 +696,8 @@ drop table t1; create table t1 (a int not null, b int not null auto_increment, primary key(a, b)) engine=heap; ERROR 42000: Incorrect table definition; there can be only one auto column and it must be defined as a key +create table t1 (c char(255), primary key(c(90))); +insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); +insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); +ERROR 23000: Duplicate entry 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl' for key 1 +drop table t1; diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 872d1f6ea7f..38eb1d6a3ae 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1,3 +1,4 @@ +DROP TABLE IF EXISTS t0,t1,t2; show variables where variable_name like "skip_show_database"; Variable_name Value skip_show_database OFF @@ -752,3 +753,73 @@ SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHE table_schema count(*) information_schema 15 mysql 17 +create database mysqltest; +create table mysqltest.t1 (f1 int, f2 int); +create table mysqltest.t2 (f1 int); +grant select (f1) on mysqltest.t1 to user1@localhost; +grant select on mysqltest.t2 to user2@localhost; +grant select on mysqltest.* to user3@localhost; +grant select on *.* to user4@localhost; +select * from information_schema.column_privileges; +GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE +'user1'@'localhost' NULL mysqltest t1 f1 SELECT NO +select * from information_schema.table_privileges; +GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE +select * from information_schema.schema_privileges; +GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE +select * from information_schema.user_privileges; +GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE +'user1'@'localhost' NULL USAGE NO +show grants; +Grants for user1@localhost +GRANT USAGE ON *.* TO 'user1'@'localhost' +GRANT SELECT (f1) ON `mysqltest`.`t1` TO 'user1'@'localhost' +select * from information_schema.column_privileges; +GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE +select * from information_schema.table_privileges; +GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE +'user2'@'localhost' NULL mysqltest t2 SELECT NO +select * from information_schema.schema_privileges; +GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE +select * from information_schema.user_privileges; +GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE +'user2'@'localhost' NULL USAGE NO +show grants; +Grants for user2@localhost +GRANT USAGE ON *.* TO 'user2'@'localhost' +GRANT SELECT ON `mysqltest`.`t2` TO 'user2'@'localhost' +select * from information_schema.column_privileges; +GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE +select * from information_schema.table_privileges; +GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE +select * from information_schema.schema_privileges; +GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE +'user3'@'localhost' NULL mysqltest SELECT NO +select * from information_schema.user_privileges; +GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE +'user3'@'localhost' NULL USAGE NO +show grants; +Grants for user3@localhost +GRANT USAGE ON *.* TO 'user3'@'localhost' +GRANT SELECT ON `mysqltest`.* TO 'user3'@'localhost' +select * from information_schema.column_privileges where grantee like '%user%'; +GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE +'user1'@'localhost' NULL mysqltest t1 f1 SELECT NO +select * from information_schema.table_privileges where grantee like '%user%'; +GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME PRIVILEGE_TYPE IS_GRANTABLE +'user2'@'localhost' NULL mysqltest t2 SELECT NO +select * from information_schema.schema_privileges where grantee like '%user%'; +GRANTEE TABLE_CATALOG TABLE_SCHEMA PRIVILEGE_TYPE IS_GRANTABLE +'user3'@'localhost' NULL mysqltest SELECT NO +select * from information_schema.user_privileges where grantee like '%user%'; +GRANTEE TABLE_CATALOG PRIVILEGE_TYPE IS_GRANTABLE +'user1'@'localhost' NULL USAGE NO +'user2'@'localhost' NULL USAGE NO +'user3'@'localhost' NULL USAGE NO +'user4'@'localhost' NULL SELECT NO +show grants; +Grants for user4@localhost +GRANT SELECT ON *.* TO 'user4'@'localhost' +drop user user1@localhost, user2@localhost, user3@localhost, user4@localhost; +use test; +drop database mysqltest; diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 424543ba4b9..31480e32c16 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -931,7 +931,6 @@ a 1 2 truncate table t1; -truncate table t1; insert into t1 values(1),(2); delete from t1; select * from t1; @@ -1451,16 +1450,22 @@ test.t3 NULL test.t4 NULL Warnings: Error 1146 Table 'test.t4' doesn't exist -checksum table t1, t2, t3; +checksum table t1, t2, t3, t4; Table Checksum test.t1 2948697075 test.t2 1157260244 test.t3 1157260244 -checksum table t1, t2, t3 extended; +test.t4 NULL +Warnings: +Error 1146 Table 'test.t4' doesn't exist +checksum table t1, t2, t3, t4 extended; Table Checksum test.t1 3092701434 test.t2 1157260244 test.t3 1157260244 +test.t4 NULL +Warnings: +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'); @@ -1633,14 +1638,14 @@ t2 CREATE TABLE `t2` ( drop table t2, t1; show status like "binlog_cache_use"; Variable_name Value -Binlog_cache_use 154 +Binlog_cache_use 153 show status like "binlog_cache_disk_use"; Variable_name Value Binlog_cache_disk_use 0 create table t1 (a int) engine=innodb; show status like "binlog_cache_use"; Variable_name Value -Binlog_cache_use 155 +Binlog_cache_use 154 show status like "binlog_cache_disk_use"; Variable_name Value Binlog_cache_disk_use 1 @@ -1649,11 +1654,51 @@ delete from t1; commit; show status like "binlog_cache_use"; Variable_name Value -Binlog_cache_use 156 +Binlog_cache_use 155 show status like "binlog_cache_disk_use"; Variable_name Value Binlog_cache_disk_use 1 drop table t1; +create table t1 (c char(10), index (c,c)) engine=innodb; +ERROR 42S21: Duplicate column name 'c' +create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10)) engine=innodb; +alter table t1 add key (c1,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c2,c1,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c1,c2,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c1,c1,c2); +ERROR 42S21: Duplicate column name 'c1' +drop table t1; +create table t1(a int(1) , b int(1)) engine=innodb; +insert into t1 values ('1111', '3333'); +select distinct concat(a, b) from t1; +concat(a, b) +11113333 +drop table t1; +CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB; +SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE); +ERROR HY000: The used table type doesn't support FULLTEXT indexes +DROP TABLE t1; +CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a), +CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2); +SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz; +a_id b_list +1 1,2,3 +2 4,5 +3 NULL +DROP TABLE t2; +DROP TABLE t1; create table t1 (x bigint unsigned not null primary key) engine=innodb; insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1); select * from t1; @@ -1688,24 +1733,6 @@ select count(*) from t1 where x = 18446744073709551601; count(*) 1 drop table t1; -create table t1 (c char(10), index (c,c)) engine=innodb; -ERROR 42S21: Duplicate column name 'c' -create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb; -ERROR 42S21: Duplicate column name 'c1' -create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb; -ERROR 42S21: Duplicate column name 'c1' -create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb; -ERROR 42S21: Duplicate column name 'c1' -create table t1 (c1 char(10), c2 char(10)) engine=innodb; -alter table t1 add key (c1,c1); -ERROR 42S21: Duplicate column name 'c1' -alter table t1 add key (c2,c1,c1); -ERROR 42S21: Duplicate column name 'c1' -alter table t1 add key (c1,c2,c1); -ERROR 42S21: Duplicate column name 'c1' -alter table t1 add key (c1,c1,c2); -ERROR 42S21: Duplicate column name 'c1' -drop table t1; show status like "Innodb_buffer_pool_pages_total"; Variable_name Value Innodb_buffer_pool_pages_total 512 @@ -1717,7 +1744,7 @@ Variable_name Value Innodb_rows_deleted 2070 show status like "Innodb_rows_inserted"; Variable_name Value -Innodb_rows_inserted 31709 +Innodb_rows_inserted 31718 show status like "Innodb_rows_updated"; Variable_name Value Innodb_rows_updated 29530 @@ -2391,13 +2418,51 @@ drop table t1; set storage_engine=MyISAM; create table t1 (v varchar(16384)) engine=innodb; drop table t1; -create table t1(a int(1) , b int(1)) engine=innodb; -insert into t1 values ('1111', '3333'); -select distinct concat(a, b) from t1; -concat(a, b) -11113333 +create table t1 (a char(1), b char(1), key(a, b)) engine=innodb; +insert into t1 values ('8', '6'), ('4', '7'); +select min(a) from t1; +min(a) +4 +select min(b) from t1 where a='8'; +min(b) +6 +drop table t1; +CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`)) ENGINE=innodb; +insert into t1 (b) values (1); +replace into t1 (b) values (2), (1), (3); +select * from t1; +a b +3 1 +2 2 +4 3 +truncate table t1; +insert into t1 (b) values (1); +replace into t1 (b) values (2); +replace into t1 (b) values (1); +replace into t1 (b) values (3); +select * from t1; +a b +3 1 +2 2 +4 3 +drop table t1; +create table t1 (rowid int not null auto_increment, val int not null,primary +key (rowid), unique(val)) engine=innodb; +replace into t1 (val) values ('1'),('2'); +replace into t1 (val) values ('1'),('2'); +insert into t1 (val) values ('1'),('2'); +ERROR 23000: Duplicate entry '1' for key 2 +select * from t1; +rowid val +3 1 +4 2 +drop table t1; +create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB; +insert into t1 (val) values (1); +update t1 set a=2 where a=1; +insert into t1 (val) values (1); +ERROR 23000: Duplicate entry '2' for key 1 +select * from t1; +a val +2 1 drop table t1; -CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB; -SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE); -ERROR HY000: The used table type doesn't support FULLTEXT indexes -DROP TABLE t1; diff --git a/mysql-test/r/innodb_handler.result b/mysql-test/r/innodb_handler.result index 7f4960ffa35..7e853a55e37 100644 --- a/mysql-test/r/innodb_handler.result +++ b/mysql-test/r/innodb_handler.result @@ -132,6 +132,22 @@ a b handler t2 read last; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 handler t2 close; +handler t1 open; +handler t1 read a next; +a b +14 aaa +handler t1 read a next; +a b +15 bbb +handler t1 close; +handler t1 open; +handler t1 read a prev; +a b +22 iii +handler t1 read a prev; +a b +21 hhh +handler t1 close; handler t1 open as t2; handler t2 read first; a b diff --git a/mysql-test/r/key.result b/mysql-test/r/key.result index 98e8851bb7e..3ad8571aadd 100644 --- a/mysql-test/r/key.result +++ b/mysql-test/r/key.result @@ -329,3 +329,28 @@ ERROR 42S21: Duplicate column name 'c1' alter table t1 add key (c1,c1,c2); ERROR 42S21: Duplicate column name 'c1' drop table t1; +create table t1 (a varchar(10), b varchar(10), key(a(10),b(10))); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) default NULL, + `b` varchar(10) default NULL, + KEY `a` (`a`,`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 modify b varchar(20); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10) default NULL, + `b` varchar(20) default NULL, + KEY `a` (`a`,`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 modify a varchar(20); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(20) default NULL, + `b` varchar(20) default NULL, + KEY `a` (`a`,`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 51e56c21a07..87e2fca970b 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -148,3 +148,17 @@ a'b a"b select 'aaa\\','aa''a',"aa""a"; aaa\ aa'a aa"a aaa\ aa'a aa"a +SET @message = 'Here comes a message'; + +Here comes a message +-------------------- +SET @message = USER(); + +root@localhost +-------------- +SET @message = 'Here comes a very very long message that is longer then 80 characters +on multiple lines'; + +Here comes a very very long message that is longer then 80 characters +on multiple lines +-------------------------------------------------------------------------------- diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index 5ba2bc80484..c37a42d3fa7 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -88,7 +88,7 @@ TV NULL NULL 600 NULL NULL NULL 7785 explain extended select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 15 Using temporary; Using filesort +1 SIMPLE t1 ALL NULL NULL NULL NULL 15 Using filesort Warnings: Note 1003 select `test`.`t1`.`product` AS `product`,`test`.`t1`.`country_id` AS `country_id`,`test`.`t1`.`year` AS `year`,sum(`test`.`t1`.`profit`) AS `sum(profit)` from `test`.`t1` group by `test`.`t1`.`product`,`test`.`t1`.`country_id`,`test`.`t1`.`year` with rollup select product, country_id , sum(profit) from t1 group by product desc, country_id with rollup; diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 8371437d664..496d566a5ee 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -634,3 +634,44 @@ 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; diff --git a/mysql-test/r/ps_1general.result b/mysql-test/r/ps_1general.result index 18bc76789b1..54c35873201 100644 --- a/mysql-test/r/ps_1general.result +++ b/mysql-test/r/ps_1general.result @@ -471,13 +471,13 @@ execute stmt1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def id 8 3 1 N 32929 0 63 def select_type 253 19 6 N 1 31 8 -def table 253 64 2 N 1 31 8 -def type 253 10 3 N 1 31 8 +def table 253 64 2 Y 0 31 8 +def type 253 10 3 Y 0 31 8 def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 def key_len 253 4096 0 Y 128 31 63 def ref 253 1024 0 Y 0 31 8 -def rows 8 10 1 N 32929 0 63 +def rows 8 10 1 Y 32928 0 63 def Extra 253 255 14 N 1 31 8 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 4 Using filesort @@ -487,13 +487,13 @@ execute stmt1 using @arg00; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def id 8 3 1 N 32929 0 63 def select_type 253 19 6 N 1 31 8 -def table 253 64 2 N 1 31 8 -def type 253 10 5 N 1 31 8 +def table 253 64 2 Y 0 31 8 +def type 253 10 5 Y 0 31 8 def possible_keys 253 4096 7 Y 0 31 8 def key 253 64 7 Y 0 31 8 def key_len 253 4096 1 Y 128 31 63 def ref 253 1024 0 Y 0 31 8 -def rows 8 10 1 N 32929 0 63 +def rows 8 10 1 Y 32928 0 63 def Extra 253 255 27 N 1 31 8 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 Using where; Using filesort diff --git a/mysql-test/r/ps_2myisam.result b/mysql-test/r/ps_2myisam.result index d6c3d0e78d5..3df9b6dcb6e 100644 --- a/mysql-test/r/ps_2myisam.result +++ b/mysql-test/r/ps_2myisam.result @@ -444,9 +444,10 @@ limit 1 '; execute stmt1 ; a b 1 one -prepare stmt1 from ' select a,b from t1 -limit ? '; -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 2 +prepare stmt1 from ' select a,b from t1 limit ? '; +execute stmt1 using @arg00; +a b +1 one set @arg00='b' ; set @arg01=0 ; set @arg02=2 ; @@ -1151,13 +1152,13 @@ execute stmt1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def id 8 3 1 N 32929 0 63 def select_type 253 19 6 N 1 31 8 -def table 253 64 2 N 1 31 8 -def type 253 10 3 N 1 31 8 +def table 253 64 2 Y 0 31 8 +def type 253 10 3 Y 0 31 8 def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 def key_len 253 4096 0 Y 128 31 63 def ref 253 1024 0 Y 0 31 8 -def rows 8 10 1 N 32929 0 63 +def rows 8 10 1 Y 32928 0 63 def Extra 253 255 0 N 1 31 8 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t9 ALL NULL NULL NULL NULL 2 @@ -1381,10 +1382,8 @@ execute stmt1 ; select a,b from t1 where b = 'bla' ; a b 2 bla -prepare stmt1 from 'update t1 set b=''bla'' -where a=2 -limit ?'; -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 3 +prepare stmt1 from 'update t1 set b=''bla'' where a=2 limit ?'; +execute stmt1 using @arg00; test_sequence ------ insert tests ------ delete from t1 ; diff --git a/mysql-test/r/ps_3innodb.result b/mysql-test/r/ps_3innodb.result index 1bbc1091393..851178e2aee 100644 --- a/mysql-test/r/ps_3innodb.result +++ b/mysql-test/r/ps_3innodb.result @@ -444,9 +444,10 @@ limit 1 '; execute stmt1 ; a b 1 one -prepare stmt1 from ' select a,b from t1 -limit ? '; -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 2 +prepare stmt1 from ' select a,b from t1 limit ? '; +execute stmt1 using @arg00; +a b +1 one set @arg00='b' ; set @arg01=0 ; set @arg02=2 ; @@ -1151,13 +1152,13 @@ execute stmt1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def id 8 3 1 N 32929 0 63 def select_type 253 19 6 N 1 31 8 -def table 253 64 2 N 1 31 8 -def type 253 10 3 N 1 31 8 +def table 253 64 2 Y 0 31 8 +def type 253 10 3 Y 0 31 8 def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 def key_len 253 4096 0 Y 128 31 63 def ref 253 1024 0 Y 0 31 8 -def rows 8 10 1 N 32929 0 63 +def rows 8 10 1 Y 32928 0 63 def Extra 253 255 0 N 1 31 8 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t9 ALL NULL NULL NULL NULL 2 @@ -1364,10 +1365,8 @@ execute stmt1 ; select a,b from t1 where b = 'bla' ; a b 2 bla -prepare stmt1 from 'update t1 set b=''bla'' -where a=2 -limit ?'; -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 3 +prepare stmt1 from 'update t1 set b=''bla'' where a=2 limit ?'; +execute stmt1 using @arg00; test_sequence ------ insert tests ------ delete from t1 ; diff --git a/mysql-test/r/ps_4heap.result b/mysql-test/r/ps_4heap.result index 009b642d7e7..60675a72bdc 100644 --- a/mysql-test/r/ps_4heap.result +++ b/mysql-test/r/ps_4heap.result @@ -445,9 +445,10 @@ limit 1 '; execute stmt1 ; a b 1 one -prepare stmt1 from ' select a,b from t1 -limit ? '; -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 2 +prepare stmt1 from ' select a,b from t1 limit ? '; +execute stmt1 using @arg00; +a b +1 one set @arg00='b' ; set @arg01=0 ; set @arg02=2 ; @@ -1152,13 +1153,13 @@ execute stmt1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def id 8 3 1 N 32929 0 63 def select_type 253 19 6 N 1 31 8 -def table 253 64 2 N 1 31 8 -def type 253 10 3 N 1 31 8 +def table 253 64 2 Y 0 31 8 +def type 253 10 3 Y 0 31 8 def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 def key_len 253 4096 0 Y 128 31 63 def ref 253 1024 0 Y 0 31 8 -def rows 8 10 1 N 32929 0 63 +def rows 8 10 1 Y 32928 0 63 def Extra 253 255 0 N 1 31 8 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t9 ALL NULL NULL NULL NULL 2 @@ -1365,10 +1366,8 @@ execute stmt1 ; select a,b from t1 where b = 'bla' ; a b 2 bla -prepare stmt1 from 'update t1 set b=''bla'' -where a=2 -limit ?'; -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 3 +prepare stmt1 from 'update t1 set b=''bla'' where a=2 limit ?'; +execute stmt1 using @arg00; test_sequence ------ insert tests ------ delete from t1 ; diff --git a/mysql-test/r/ps_5merge.result b/mysql-test/r/ps_5merge.result index 5bd18078213..a177290daa4 100644 --- a/mysql-test/r/ps_5merge.result +++ b/mysql-test/r/ps_5merge.result @@ -487,9 +487,10 @@ limit 1 '; execute stmt1 ; a b 1 one -prepare stmt1 from ' select a,b from t1 -limit ? '; -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 2 +prepare stmt1 from ' select a,b from t1 limit ? '; +execute stmt1 using @arg00; +a b +1 one set @arg00='b' ; set @arg01=0 ; set @arg02=2 ; @@ -1194,13 +1195,13 @@ execute stmt1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def id 8 3 1 N 32929 0 63 def select_type 253 19 6 N 1 31 8 -def table 253 64 2 N 1 31 8 -def type 253 10 3 N 1 31 8 +def table 253 64 2 Y 0 31 8 +def type 253 10 3 Y 0 31 8 def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 def key_len 253 4096 0 Y 128 31 63 def ref 253 1024 0 Y 0 31 8 -def rows 8 10 1 N 32929 0 63 +def rows 8 10 1 Y 32928 0 63 def Extra 253 255 0 N 1 31 8 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t9 ALL NULL NULL NULL NULL 2 @@ -1407,10 +1408,8 @@ execute stmt1 ; select a,b from t1 where b = 'bla' ; a b 2 bla -prepare stmt1 from 'update t1 set b=''bla'' -where a=2 -limit ?'; -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 3 +prepare stmt1 from 'update t1 set b=''bla'' where a=2 limit ?'; +execute stmt1 using @arg00; test_sequence ------ insert tests ------ delete from t1 ; @@ -3500,9 +3499,10 @@ limit 1 '; execute stmt1 ; a b 1 one -prepare stmt1 from ' select a,b from t1 -limit ? '; -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 2 +prepare stmt1 from ' select a,b from t1 limit ? '; +execute stmt1 using @arg00; +a b +1 one set @arg00='b' ; set @arg01=0 ; set @arg02=2 ; @@ -4207,13 +4207,13 @@ execute stmt1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def id 8 3 1 N 32929 0 63 def select_type 253 19 6 N 1 31 8 -def table 253 64 2 N 1 31 8 -def type 253 10 3 N 1 31 8 +def table 253 64 2 Y 0 31 8 +def type 253 10 3 Y 0 31 8 def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 def key_len 253 4096 0 Y 128 31 63 def ref 253 1024 0 Y 0 31 8 -def rows 8 10 1 N 32929 0 63 +def rows 8 10 1 Y 32928 0 63 def Extra 253 255 0 N 1 31 8 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t9 ALL NULL NULL NULL NULL 2 @@ -4420,10 +4420,8 @@ execute stmt1 ; select a,b from t1 where b = 'bla' ; a b 2 bla -prepare stmt1 from 'update t1 set b=''bla'' -where a=2 -limit ?'; -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 3 +prepare stmt1 from 'update t1 set b=''bla'' where a=2 limit ?'; +execute stmt1 using @arg00; test_sequence ------ insert tests ------ delete from t1 ; diff --git a/mysql-test/r/ps_6bdb.result b/mysql-test/r/ps_6bdb.result index 753def70dc0..92399c3b3b9 100644 --- a/mysql-test/r/ps_6bdb.result +++ b/mysql-test/r/ps_6bdb.result @@ -444,9 +444,10 @@ limit 1 '; execute stmt1 ; a b 1 one -prepare stmt1 from ' select a,b from t1 -limit ? '; -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 2 +prepare stmt1 from ' select a,b from t1 limit ? '; +execute stmt1 using @arg00; +a b +1 one set @arg00='b' ; set @arg01=0 ; set @arg02=2 ; @@ -1151,13 +1152,13 @@ execute stmt1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def id 8 3 1 N 32929 0 63 def select_type 253 19 6 N 1 31 8 -def table 253 64 2 N 1 31 8 -def type 253 10 3 N 1 31 8 +def table 253 64 2 Y 0 31 8 +def type 253 10 3 Y 0 31 8 def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 def key_len 253 4096 0 Y 128 31 63 def ref 253 1024 0 Y 0 31 8 -def rows 8 10 1 N 32929 0 63 +def rows 8 10 1 Y 32928 0 63 def Extra 253 255 0 N 1 31 8 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t9 ALL NULL NULL NULL NULL 3 @@ -1364,10 +1365,8 @@ execute stmt1 ; select a,b from t1 where b = 'bla' ; a b 2 bla -prepare stmt1 from 'update t1 set b=''bla'' -where a=2 -limit ?'; -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 3 +prepare stmt1 from 'update t1 set b=''bla'' where a=2 limit ?'; +execute stmt1 using @arg00; test_sequence ------ insert tests ------ delete from t1 ; diff --git a/mysql-test/r/ps_7ndb.result b/mysql-test/r/ps_7ndb.result index a6da6e169db..c7dabc2016d 100644 --- a/mysql-test/r/ps_7ndb.result +++ b/mysql-test/r/ps_7ndb.result @@ -444,9 +444,10 @@ limit 1 '; execute stmt1 ; a b 1 one -prepare stmt1 from ' select a,b from t1 -limit ? '; -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 2 +prepare stmt1 from ' select a,b from t1 limit ? '; +execute stmt1 using @arg00; +a b +3 three set @arg00='b' ; set @arg01=0 ; set @arg02=2 ; @@ -1151,13 +1152,13 @@ execute stmt1; Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr def id 8 3 1 N 32929 0 63 def select_type 253 19 6 N 1 31 8 -def table 253 64 2 N 1 31 8 -def type 253 10 3 N 1 31 8 +def table 253 64 2 Y 0 31 8 +def type 253 10 3 Y 0 31 8 def possible_keys 253 4096 0 Y 0 31 8 def key 253 64 0 Y 0 31 8 def key_len 253 4096 0 Y 128 31 63 def ref 253 1024 0 Y 0 31 8 -def rows 8 10 1 N 32929 0 63 +def rows 8 10 1 Y 32928 0 63 def Extra 253 255 0 N 1 31 8 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t9 ALL NULL NULL NULL NULL 2 @@ -1364,10 +1365,8 @@ execute stmt1 ; select a,b from t1 where b = 'bla' ; a b 2 bla -prepare stmt1 from 'update t1 set b=''bla'' -where a=2 -limit ?'; -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 3 +prepare stmt1 from 'update t1 set b=''bla'' where a=2 limit ?'; +execute stmt1 using @arg00; test_sequence ------ insert tests ------ delete from t1 ; diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index eaed7719673..1c0321ac658 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2682,3 +2682,20 @@ AND FK_firma_id = 2; COUNT(*) 0 drop table t1; +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 VALUES (2), (4), (6); +SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +a +2 +4 +EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 Using where +EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 3 +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where +DROP TABLE t1,t2; diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 1dc97124a07..b6ba737a8ba 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -672,3 +672,17 @@ select default(t30.s1) from t30; end| drop procedure bug10969| drop table t1| +prepare stmt from "select 1"; +create procedure p() deallocate prepare stmt; +ERROR 0A000: DEALLOCATE is not allowed in stored procedures +create function f() returns int begin deallocate prepare stmt; +ERROR 0A000: DEALLOCATE is not allowed in stored procedures +create procedure p() prepare stmt from "select 1"; +ERROR 0A000: PREPARE is not allowed in stored procedures +create function f() returns int begin prepare stmt from "select 1"; +ERROR 0A000: PREPARE is not allowed in stored procedures +create procedure p() execute stmt; +ERROR 0A000: EXECUTE is not allowed in stored procedures +create function f() returns int begin execute stmt; +ERROR 0A000: EXECUTE is not allowed in stored procedures +deallocate prepare stmt; diff --git a/mysql-test/r/sp-threads.result b/mysql-test/r/sp-threads.result index a081e520496..a9d50e6e697 100644 --- a/mysql-test/r/sp-threads.result +++ b/mysql-test/r/sp-threads.result @@ -40,3 +40,18 @@ Id User Host db Command Time State Info unlock tables; drop procedure bug9486; drop table t1, t2; +drop procedure if exists bug11158; +create procedure bug11158() delete t1 from t1, t2 where t1.id = t2.id; +create table t1 (id int, j int); +insert into t1 values (1, 1), (2, 2); +create table t2 (id int); +insert into t2 values (1); +call bug11158(); +select * from t1; +id j +2 2 +lock tables t2 read; +call bug11158(); +unlock tables; +drop procedure bug11158; +drop table t1, t2; diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 1741070669f..bf6a4dbf68c 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -3134,4 +3134,44 @@ x 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 table t1,t2; diff --git a/mysql-test/r/sp_trans.result b/mysql-test/r/sp_trans.result index dee87979ff4..047711bb736 100644 --- a/mysql-test/r/sp_trans.result +++ b/mysql-test/r/sp_trans.result @@ -1,3 +1,4 @@ +drop table if exists t1, t2; drop procedure if exists bug8850| create table t1 (a int) engine=innodb| create procedure bug8850() @@ -20,3 +21,160 @@ a 2 drop table t1| drop procedure bug8850| +drop function if exists bug10015_1| +drop function if exists bug10015_2| +drop function if exists bug10015_3| +drop function if exists bug10015_4| +drop function if exists bug10015_5| +drop function if exists bug10015_6| +drop function if exists bug10015_7| +drop procedure if exists bug10015_8| +create table t1 (id int) engine=innodb| +create table t2 (id int primary key, j int) engine=innodb| +insert into t1 values (1),(2),(3)| +create function bug10015_1() returns int return (select count(*) from t1)| +select *, bug10015_1() from t1| +id bug10015_1() +1 3 +2 3 +3 3 +drop function bug10015_1| +create function bug10015_2() returns int +begin +declare i, s int; +set i:= (select min(id) from t1); +set s:= (select max(id) from t1); +return (s - i); +end| +select *, bug10015_2() from t1| +id bug10015_2() +1 2 +2 2 +3 2 +drop function bug10015_2| +create function bug10015_3() returns int +return (select max(a.id - b.id) from t1 as a, t1 as b where a.id >= b.id)| +select *, bug10015_3() from t1| +id bug10015_3() +1 2 +2 2 +3 2 +drop function bug10015_3| +create function bug10015_4(i int) returns int +begin +declare m int; +set m:= (select max(id) from t2); +insert into t2 values (i, m); +return m; +end| +select *, bug10015_4(id) from t1| +id bug10015_4(id) +1 NULL +2 1 +3 2 +select * from t2| +id j +1 NULL +2 1 +3 2 +drop function bug10015_4| +create function bug10015_5(i int) returns int +begin +if (i = 5) then +insert into t2 values (1, 0); +end if; +return i; +end| +insert into t1 values (bug10015_5(4)), (bug10015_5(5))| +ERROR 23000: Duplicate entry '1' for key 1 +select * from t1| +id +1 +2 +3 +drop function bug10015_5| +create function bug10015_6(i int) returns int +begin +declare continue handler for sqlexception set @error_in_func:= 1; +if (i = 5) then +insert into t2 values (4, 0), (1, 0); +end if; +return i; +end| +set @error_in_func:= 0| +insert into t1 values (bug10015_6(5)), (bug10015_6(6))| +select @error_in_func| +@error_in_func +1 +select * from t1| +id +1 +2 +3 +5 +6 +select * from t2| +id j +1 NULL +2 1 +3 2 +4 0 +drop function bug10015_6| +create function bug10015_7() returns int +begin +alter table t1 add k int; +return 1; +end| +ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger. +create function bug10015_7() returns int +begin +start transaction; +return 1; +end| +ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger. +create function bug10015_7() returns int +begin +drop table t1; +return 1; +end| +ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger. +create function bug10015_7() returns int +begin +drop temporary table t1; +return 1; +end| +drop function bug10015_7| +create function bug10015_7() returns int +begin +commit; +return 1; +end| +ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger. +create function bug10015_7() returns int +begin +call bug10015_8(); +return 1; +end| +create procedure bug10015_8() alter table t1 add k int| +select *, bug10015_7() from t1| +ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger. +drop procedure bug10015_8| +create procedure bug10015_8() start transaction| +select *, bug10015_7() from t1| +ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger. +drop procedure bug10015_8| +create procedure bug10015_8() drop temporary table if exists t1_temp| +select *, bug10015_7() from t1| +id bug10015_7() +1 1 +2 1 +3 1 +5 1 +6 1 +drop procedure bug10015_8| +create procedure bug10015_8() commit| +select *, bug10015_7() from t1| +ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger. +drop procedure bug10015_8| +drop function bug10015_7| +drop table t1, t2| diff --git a/mysql-test/r/sql_mode.result b/mysql-test/r/sql_mode.result index 09adc48259c..c5ba4d15a50 100644 --- a/mysql-test/r/sql_mode.result +++ b/mysql-test/r/sql_mode.result @@ -138,6 +138,8 @@ t1 CREATE TABLE `t1` ( `min_num` decimal(7,6) default '0.000001' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1 ; +set @@SQL_MODE=NULL; +ERROR 42000: Variable 'sql_mode' can't be set to the value of 'NULL' SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=''; show local variables like 'SQL_MODE'; Variable_name Value diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result index 64c9a11b3cd..4d9bc0c7fe1 100644 --- a/mysql-test/r/type_bit.result +++ b/mysql-test/r/type_bit.result @@ -458,3 +458,11 @@ select h from t1; h a drop table t1; +create table t1 (a bit(8)) engine=heap; +insert into t1 values ('1111100000'); +Warnings: +Warning 1264 Out of range value adjusted for column 'a' at row 1 +select a+0 from t1; +a+0 +255 +drop table t1; diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index ab57caacc0f..93467d1d7da 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -414,8 +414,8 @@ Warning 1264 Out of range value adjusted for column 'a' at row 2 Warning 1264 Out of range value adjusted for column 'a' at row 7 select * from t1; a -9999999999 -9999999999 +0 +0 1 1 1 @@ -430,8 +430,8 @@ Warning 1264 Out of range value adjusted for column 'a' at row 2 Warning 1264 Out of range value adjusted for column 'a' at row 7 select * from t1; a -9999999999 -9999999999 +0000000000 +0000000000 0000000001 0000000001 0000000001 @@ -446,8 +446,8 @@ Warning 1264 Out of range value adjusted for column 'a' at row 2 Warning 1264 Out of range value adjusted for column 'a' at row 7 select * from t1; a -9999999999 -9999999999 +0000000000 +0000000000 0000000001 0000000001 0000000001 diff --git a/mysql-test/r/type_newdecimal.result b/mysql-test/r/type_newdecimal.result index f03f2f5a862..b406dbab82f 100644 --- a/mysql-test/r/type_newdecimal.result +++ b/mysql-test/r/type_newdecimal.result @@ -119,7 +119,7 @@ a 99.99 99.99 99.99 -99.99 +0.00 0.00 0.00 0.00 @@ -891,3 +891,40 @@ NULL select abs(NULL); abs(NULL) NULL +set @@sql_mode='traditional'; +create table t1( d1 decimal(18) unsigned, d2 decimal(20) unsigned, d3 decimal (22) unsigned); +insert into t1 values(1,-1,-1); +ERROR 22003: Out of range value adjusted for column 'd2' at row 1 +drop table t1; +create table t1 (col1 decimal(5,2), col2 numeric(5,2)); +insert into t1 values (999.999,999.999); +ERROR 22003: Out of range value adjusted for column 'col1' at row 1 +insert into t1 values (-999.999,-999.999); +ERROR 22003: Out of range value adjusted for column 'col1' at row 1 +select * from t1; +col1 col2 +drop table t1; +set sql_mode=''; +set @sav_dpi= @@div_precision_increment; +set @@div_precision_increment=15; +create table t1 (col1 int, col2 decimal(30,25), col3 numeric(30,25)); +insert into t1 values (1,0.0123456789012345678912345,0.0123456789012345678912345); +select col2/9999999999 from t1 where col1=1; +col2/9999999999 +0.000000000001234567890246913578 +select 9999999999/col2 from t1 where col1=1; +9999999999/col2 +810000007209.000065537105051 +select 77777777/7777777; +77777777/7777777 +10.000000900000090 +drop table t1; +set div_precision_increment= @sav_dpi; +create table t1 (a decimal(4,2)); +insert into t1 values (0.00); +select * from t1 where a > -0.00; +a +select * from t1 where a = -0.00; +a +0.00 +drop table t1; diff --git a/mysql-test/r/type_varchar.result b/mysql-test/r/type_varchar.result index 3bd7fe6b175..e3b12cc36e3 100644 --- a/mysql-test/r/type_varchar.result +++ b/mysql-test/r/type_varchar.result @@ -126,13 +126,13 @@ Some sample data Some samples explain select * from t1 where v like 'This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort +1 SIMPLE t1 range v v 258 NULL 3 Using where; Using index explain select * from t1 where v='This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref v v 257 const 3 Using where +1 SIMPLE t1 ref v v 258 const 3 Using where; Using index explain select * from t1 where v like 'S%' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort +1 SIMPLE t1 range v v 258 NULL 2 Using where; Using index alter table t1 change v v varchar(256); select * from t1 where v like 'This is a test' order by v; v @@ -150,13 +150,13 @@ Some sample data Some samples explain select * from t1 where v like 'This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort +1 SIMPLE t1 range v v 259 NULL 3 Using where; Using index explain select * from t1 where v='This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref v v 257 const 3 Using where +1 SIMPLE t1 ref v v 259 const 3 Using where; Using index explain select * from t1 where v like 'S%' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort +1 SIMPLE t1 range v v 259 NULL 2 Using where; Using index alter table t1 change v v varchar(257); select * from t1 where v like 'This is a test' order by v; v @@ -174,13 +174,13 @@ Some sample data Some samples explain select * from t1 where v like 'This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort +1 SIMPLE t1 range v v 260 NULL 3 Using where; Using index explain select * from t1 where v='This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref v v 257 const 3 Using where +1 SIMPLE t1 ref v v 260 const 3 Using where; Using index explain select * from t1 where v like 'S%' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort +1 SIMPLE t1 range v v 260 NULL 2 Using where; Using index alter table t1 change v v varchar(258); select * from t1 where v like 'This is a test' order by v; v @@ -198,13 +198,13 @@ Some sample data Some samples explain select * from t1 where v like 'This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort +1 SIMPLE t1 range v v 261 NULL 3 Using where; Using index explain select * from t1 where v='This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref v v 257 const 3 Using where +1 SIMPLE t1 ref v v 261 const 3 Using where; Using index explain select * from t1 where v like 'S%' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort +1 SIMPLE t1 range v v 261 NULL 2 Using where; Using index alter table t1 change v v varchar(259); select * from t1 where v like 'This is a test' order by v; v @@ -222,13 +222,13 @@ Some sample data Some samples explain select * from t1 where v like 'This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort +1 SIMPLE t1 range v v 262 NULL 3 Using where; Using index explain select * from t1 where v='This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref v v 257 const 3 Using where +1 SIMPLE t1 ref v v 262 const 3 Using where; Using index explain select * from t1 where v like 'S%' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort +1 SIMPLE t1 range v v 262 NULL 2 Using where; Using index alter table t1 change v v varchar(258); select * from t1 where v like 'This is a test' order by v; v @@ -246,13 +246,13 @@ Some sample data Some samples explain select * from t1 where v like 'This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort +1 SIMPLE t1 range v v 261 NULL 3 Using where; Using index explain select * from t1 where v='This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref v v 257 const 3 Using where +1 SIMPLE t1 ref v v 261 const 3 Using where; Using index explain select * from t1 where v like 'S%' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort +1 SIMPLE t1 range v v 261 NULL 2 Using where; Using index alter table t1 change v v varchar(257); select * from t1 where v like 'This is a test' order by v; v @@ -270,13 +270,13 @@ Some sample data Some samples explain select * from t1 where v like 'This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort +1 SIMPLE t1 range v v 260 NULL 3 Using where; Using index explain select * from t1 where v='This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref v v 257 const 3 Using where +1 SIMPLE t1 ref v v 260 const 3 Using where; Using index explain select * from t1 where v like 'S%' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort +1 SIMPLE t1 range v v 260 NULL 2 Using where; Using index alter table t1 change v v varchar(256); select * from t1 where v like 'This is a test' order by v; v @@ -294,13 +294,13 @@ Some sample data Some samples explain select * from t1 where v like 'This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort +1 SIMPLE t1 range v v 259 NULL 3 Using where; Using index explain select * from t1 where v='This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref v v 257 const 3 Using where +1 SIMPLE t1 ref v v 259 const 3 Using where; Using index explain select * from t1 where v like 'S%' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort +1 SIMPLE t1 range v v 259 NULL 2 Using where; Using index alter table t1 change v v varchar(255); select * from t1 where v like 'This is a test' order by v; v @@ -318,13 +318,13 @@ Some sample data Some samples explain select * from t1 where v like 'This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 3 Using where; Using filesort +1 SIMPLE t1 range v v 258 NULL 3 Using where; Using index explain select * from t1 where v='This is a test' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ref v v 257 const 3 Using where +1 SIMPLE t1 ref v v 258 const 3 Using where; Using index explain select * from t1 where v like 'S%' order by v; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range v v 257 NULL 2 Using where; Using filesort +1 SIMPLE t1 range v v 258 NULL 2 Using where; Using index alter table t1 change v v varchar(254); select * from t1 where v like 'This is a test' order by v; v @@ -392,3 +392,26 @@ group by t1.b, t1.a; a b min(t1.b) 22 NULL NULL drop table t1, t2; +create table t1 (f1 varchar(65500)); +create index index1 on t1(f1(10)); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` varchar(65500) default NULL, + KEY `index1` (`f1`(10)) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 modify f1 varchar(255); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` varchar(255) default NULL, + KEY `index1` (`f1`(10)) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +alter table t1 modify f1 tinytext; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` tinytext, + KEY `index1` (`f1`(10)) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result index 442d0784953..fd516996ae8 100644 --- a/mysql-test/r/warnings.result +++ b/mysql-test/r/warnings.result @@ -181,3 +181,56 @@ drop table t1; set table_type=MYISAM; Warnings: Warning 1287 'table_type' is deprecated; use 'storage_engine' instead +create table t1 (a int); +insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +update t1 set a='abc'; +Warnings: +Warning 1264 Out of range value adjusted for column 'a' at row 1 +Warning 1264 Out of range value adjusted for column 'a' at row 2 +Warning 1264 Out of range value adjusted for column 'a' at row 3 +Warning 1264 Out of range value adjusted for column 'a' at row 4 +Warning 1264 Out of range value adjusted for column 'a' at row 5 +Warning 1264 Out of range value adjusted for column 'a' at row 6 +Warning 1264 Out of range value adjusted for column 'a' at row 7 +Warning 1264 Out of range value adjusted for column 'a' at row 8 +Warning 1264 Out of range value adjusted for column 'a' at row 9 +Warning 1264 Out of range value adjusted for column 'a' at row 10 +show warnings limit 2, 1; +Level Code Message +Warning 1264 Out of range value adjusted for column 'a' at row 3 +show warnings limit 0, 10; +Level Code Message +Warning 1264 Out of range value adjusted for column 'a' at row 1 +Warning 1264 Out of range value adjusted for column 'a' at row 2 +Warning 1264 Out of range value adjusted for column 'a' at row 3 +Warning 1264 Out of range value adjusted for column 'a' at row 4 +Warning 1264 Out of range value adjusted for column 'a' at row 5 +Warning 1264 Out of range value adjusted for column 'a' at row 6 +Warning 1264 Out of range value adjusted for column 'a' at row 7 +Warning 1264 Out of range value adjusted for column 'a' at row 8 +Warning 1264 Out of range value adjusted for column 'a' at row 9 +Warning 1264 Out of range value adjusted for column 'a' at row 10 +show warnings limit 9, 1; +Level Code Message +Warning 1264 Out of range value adjusted for column 'a' at row 10 +show warnings limit 10, 1; +Level Code Message +show warnings limit 9, 2; +Level Code Message +Warning 1264 Out of range value adjusted for column 'a' at row 10 +show warnings limit 0, 0; +Level Code Message +show warnings limit 1; +Level Code Message +Warning 1264 Out of range value adjusted for column 'a' at row 1 +show warnings limit 0; +Level Code Message +show warnings limit 1, 0; +Level Code Message +select * from t1 limit 0; +a +select * from t1 limit 1, 0; +a +select * from t1 limit 0, 0; +a +drop table t1; diff --git a/mysql-test/t/analyze.test b/mysql-test/t/analyze.test new file mode 100644 index 00000000000..faf30279c68 --- /dev/null +++ b/mysql-test/t/analyze.test @@ -0,0 +1,39 @@ +# +# Bug #10901 Analyze Table on new table destroys table +# This is minimal test case to get error +# The problem was that analyze table wrote the shared state to the file and this +# didn't include the inserts while locked. A check was needed to ensure that +# state information was not updated when executing analyze table for a locked table. +# The analyze table had to be within locks and check table had to be after unlocking +# since then it brings the wrong state from disk rather than from the currently +# correct internal state. The insert is needed since it changes the file state, +# number of records. +# The fix is to synchronise the state of the shared state and the current state before +# calling mi_state_info_write +# +create table t1 (a bigint); +lock tables t1 write; +insert into t1 values(0); +analyze table t1; +unlock tables; +check table t1; + +drop table t1; + +create table t1 (a bigint); +insert into t1 values(0); +lock tables t1 write; +delete from t1; +analyze table t1; +unlock tables; +check table t1; + +drop table t1; + +create table t1 (a bigint); +insert into t1 values(0); +analyze table t1; +check table t1; + +drop table t1; + diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test index ef344df5fb6..afc4c722051 100644 --- a/mysql-test/t/auto_increment.test +++ b/mysql-test/t/auto_increment.test @@ -218,3 +218,39 @@ CHECK TABLE t1; INSERT INTO t1 (b) VALUES ('bbbb'); CHECK TABLE t1; DROP TABLE IF EXISTS t1; + +# +# Bug #11080 & #11005 Multi-row REPLACE fails on a duplicate key error +# + +CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`)); +insert into t1 (b) values (1); +replace into t1 (b) values (2), (1), (3); +select * from t1; +truncate table t1; +insert into t1 (b) values (1); +replace into t1 (b) values (2); +replace into t1 (b) values (1); +replace into t1 (b) values (3); +select * from t1; +drop table t1; + +create table t1 (rowid int not null auto_increment, val int not null,primary +key (rowid), unique(val)); +replace into t1 (val) values ('1'),('2'); +replace into t1 (val) values ('1'),('2'); +--error 1062 +insert into t1 (val) values ('1'),('2'); +select * from t1; +drop table t1; + +# +# Test that update changes internal auto-increment value +# + +create table t1 (a int not null auto_increment primary key, val int); +insert into t1 (val) values (1); +update t1 set a=2 where a=1; +insert into t1 (val) values (1); +select * from t1; +drop table t1; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index d9712a28788..d870ff368d3 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -414,14 +414,17 @@ drop database mysqltest; select database(); # Connect without a database -connect (user4,localhost,mysqltest_1,,*NO-ONE*); -select database(); +connect (user1,localhost,mysqltest_1,,*NO-ONE*); +connection user1; +select database(), user(); +connection default; +disconnect user1; +use test; # # Test for Bug 856 'Naming a key "Primary" causes trouble' # -use test; --error 1280 create table t1 (a int, index `primary` (a)); --error 1280 @@ -478,8 +481,6 @@ drop table t1,t2; # This tests two additional possible errors and a hang if # an improper fix is present. # -connection default; -use test; create table t1 (a int); --error 1093 create table t1 select * from t1; @@ -501,3 +502,15 @@ create table t1(xyz.t1.name int); create table t1(t1.name int); create table t2(test.t2.name int); drop table t1,t2; + +# +# Bug#11028: Crash on create table like +# +create database mysqltest; +use mysqltest; +drop database mysqltest; +--error 1102 +create table test.t1 like x; +--disable_warnings +drop table if exists test.t1; +--enable_warnings diff --git a/mysql-test/t/ctype_cp1250_ch.test b/mysql-test/t/ctype_cp1250_ch.test index 06aea7b9979..814da628fb7 100644 --- a/mysql-test/t/ctype_cp1250_ch.test +++ b/mysql-test/t/ctype_cp1250_ch.test @@ -10,3 +10,15 @@ CREATE TABLE t1 (a char(16)) character set cp1250 collate cp1250_czech_cs; INSERT INTO t1 VALUES (''); SELECT a, length(a), a='', a=' ', a=' ' FROM t1; DROP TABLE t1; + +# +# Bug#9759 Empty result with 'LIKE' and cp1250_czech_cs +# +CREATE TABLE t1 ( + popisek varchar(30) collate cp1250_general_ci NOT NULL default '', + PRIMARY KEY (`popisek`) +); +INSERT INTO t1 VALUES ('2005-01-1'); +SELECT * FROM t1 WHERE popisek = '2005-01-1'; +SELECT * FROM t1 WHERE popisek LIKE '2005-01-1'; +drop table t1; diff --git a/mysql-test/t/ctype_uca.test b/mysql-test/t/ctype_uca.test index dfca82fa70a..e5c2acc8b4e 100644 --- a/mysql-test/t/ctype_uca.test +++ b/mysql-test/t/ctype_uca.test @@ -455,3 +455,18 @@ drop table t1; SET collation_connection='utf8_unicode_ci'; -- source include/ctype_filesort.inc + +# +# Check UPPER/LOWER changeing length +# +# Result shorter than argument +CREATE TABLE t1 (id int, a varchar(30) character set utf8); +INSERT INTO t1 VALUES (1, _ucs2 0x01310069), (2, _ucs2 0x01310131); +INSERT INTO t1 VALUES (3, _ucs2 0x00690069), (4, _ucs2 0x01300049); +INSERT INTO t1 VALUES (5, _ucs2 0x01300130), (6, _ucs2 0x00490049); +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +ALTER TABLE t1 MODIFY a VARCHAR(30) character set utf8 collate utf8_turkish_ci; +SELECT a, length(a) la, @l:=lower(a) l, length(@l) ll, @u:=upper(a) u, length(@u) lu +FROM t1 ORDER BY id; +DROP TABLE t1; diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index bac6e60c302..3c49b2a47f7 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -731,3 +731,18 @@ select ifnull(NULL, _utf8'string'); create table t1 (a varchar(255)) default character set utf8; insert into t1 values (1.0); drop table t1; + +# +# Bug#10253 compound index length and utf8 char set +# produces invalid query results +# +create table t1 ( + id int not null, + city varchar(20) not null, + key (city(7),id) +) character set=utf8; +insert into t1 values (1,'Durban North'); +insert into t1 values (2,'Durban'); +select * from t1 where city = 'Durban'; +select * from t1 where city = 'Durban '; +drop table t1; diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index a6335d77a0c..265089adfa2 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -3,7 +3,7 @@ # --disable_warnings -drop table if exists t1,t11,t12,t2; +drop table if exists t1,t2,t3,t11,t12; --enable_warnings CREATE TABLE t1 (a tinyint(3), b tinyint(5)); INSERT INTO t1 VALUES (1,1); @@ -152,3 +152,20 @@ INSERT INTO t1 VALUES (0),(1),(2); DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a LIMIT 1; SELECT * FROM t1; DROP TABLE t1; + +# +# Test of multi-delete where we are not scanning the first table +# + +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)); +insert into t1 values (1,1),(2,1),(1,3); +insert into t2 values (1,1),(2,2),(3,3); +insert into t3 values (1,1),(2,1),(1,3); +select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b; +explain select * from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b; +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; diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test index a3862786cc3..057c9bd9239 100644 --- a/mysql-test/t/distinct.test +++ b/mysql-test/t/distinct.test @@ -332,3 +332,11 @@ CREATE TABLE t1 ( INSERT INTO t1 VALUES ('1',1,0); SELECT DISTINCT html,SUM(rout)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin; drop table t1; + +# +# Bug 9784 DISTINCT IFNULL truncates data +# +create table t1 (id int, dsc varchar(50)); +insert into t1 values (1, "line number one"), (2, "line number two"), (3, "line number three"); +select distinct id, IFNULL(dsc, '-') from t1; +drop table t1; diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 694e0223753..96cd51f58db 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -214,21 +214,6 @@ SELECT GROUP_CONCAT(b ORDER BY b) FROM t1 GROUP BY a; DROP TABLE t1; # -# check null values #1 -# - ---disable_warnings -CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1; -INSERT INTO t1 VALUES (1),(2),(3); -CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a), - CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1; ---enable_warnings -INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2); -SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz; -DROP TABLE t2; -DROP TABLE t1; - -# # check null values #2 # @@ -286,18 +271,31 @@ SELECT GROUP_CONCAT(id) AS gc FROM t1 HAVING gc IS NULL; DROP TABLE t1; # +# Bug #8656: Crash with group_concat on alias in outer table +# +create table t2 (a int, b int); +insert into t2 values (1,1), (2,2); +select b x, (select group_concat(x) from t2) from t2; +drop table t2; + +# +# Bug #7405: problems with rollup +# + +create table t1 (d int not null auto_increment,primary key(d), a int, b int, c int); +insert into t1(a,b) values (1,3), (1,4), (1,2), (2,7), (1,1), (1,2), (2,3), (2,3); +select d,a,b from t1 order by a; +explain select a, group_concat(b) from t1 group by a with rollup; +select a, group_concat(b) from t1 group by a with rollup; +select a, group_concat(distinct b) from t1 group by a with rollup; +select a, group_concat(b order by b) from t1 group by a with rollup; +select a, group_concat(distinct b order by b) from t1 group by a with rollup; +drop table t1; + +# # Bug #6475 # create table t1 (a char(3), b char(20), primary key (a, b)); insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English'); select group_concat(a) from t1 group by b; drop table t1; - -# -# Bug #8656: Crash with group_concat on alias in outer table -# -create table r2 (a int, b int); -insert into r2 values (1,1), (2,2); -select b x, (select group_concat(x) from r2) from r2; -drop table r2; - diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 0eac72782a8..03057af6911 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -67,3 +67,20 @@ explain extended select degrees(pi()),radians(360); --error 1054 select rand(rand); + +# +# Bug #8459 (FORMAT returns incorrect result) +# +create table t1 (col1 int, col2 decimal(60,30)); +insert into t1 values(1,1234567890.12345); +select format(col2,7) from t1; +select format(col2,8) from t1; +insert into t1 values(7,1234567890123456.12345); +select format(col2,6) from t1 where col1=7; +drop table t1; + + +# +# Bug #10083 (round doesn't increase decimals) +# +select round(150, 2); diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 80ddb205110..6ca29ccded2 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -336,3 +336,17 @@ DROP TABLE t1; 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; + +# +# Bug #10568 +# + +select last_day('2005-00-00'); +select last_day('2005-00-01'); +select last_day('2005-01-00'); + +# +# Bug #10590: %h, %I, and %l format specifies should all return results in +# the 0-11 range +# +select time_format('100:00:00', '%H %k %h %I %l'); diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index fbd39019e6d..21d5abcc287 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -522,3 +522,20 @@ insert into t1 values(3000000000); select * from t1; select min(b) from t1; drop table t1; + +# +# Test for bug #11088: GROUP BY a BLOB colimn with COUNT(DISTINCT column1) +# + +CREATE TABLE t1 (id int PRIMARY KEY, user_id int, hostname longtext); + +INSERT INTO t1 VALUES + (1, 7, 'cache-dtc-af05.proxy.aol.com'), + (2, 3, 'what.ever.com'), + (3, 7, 'cache-dtc-af05.proxy.aol.com'), + (4, 7, 'cache-dtc-af05.proxy.aol.com'); + +SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1 + WHERE hostname LIKE '%aol%' + GROUP BY hostname; + diff --git a/mysql-test/t/heap.test b/mysql-test/t/heap.test index 68a84e1c193..75ef5a73cb0 100644 --- a/mysql-test/t/heap.test +++ b/mysql-test/t/heap.test @@ -426,3 +426,12 @@ drop table t1; --error 1075 create table t1 (a int not null, b int not null auto_increment, primary key(a, b)) engine=heap; + +# +# Bug #10566: Verify that we can create a prefixed key with length > 255 +# +create table t1 (c char(255), primary key(c(90))); +insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); +--error 1062 +insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); +drop table t1; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 05dfeb67ccc..7302b3e5e58 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -4,6 +4,11 @@ # Test for information_schema.schemata & # show databases +--disable_warnings +DROP TABLE IF EXISTS t0,t1,t2; +--enable_warnings + + show variables where variable_name like "skip_show_database"; grant select, update, execute on test.* to mysqltest_2@localhost; grant select, update on test.* to mysqltest_1@localhost; @@ -493,3 +498,47 @@ flush privileges; # SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA; +# +# Bug #10964 Information Schema:Authorization check on privilege tables is improper +# + +create database mysqltest; +create table mysqltest.t1 (f1 int, f2 int); +create table mysqltest.t2 (f1 int); +grant select (f1) on mysqltest.t1 to user1@localhost; +grant select on mysqltest.t2 to user2@localhost; +grant select on mysqltest.* to user3@localhost; +grant select on *.* to user4@localhost; + +connect (con1,localhost,user1,,); +connect (con2,localhost,user2,,); +connect (con3,localhost,user3,,); +connect (con4,localhost,user4,,); +connection con1; +select * from information_schema.column_privileges; +select * from information_schema.table_privileges; +select * from information_schema.schema_privileges; +select * from information_schema.user_privileges; +show grants; +connection con2; +select * from information_schema.column_privileges; +select * from information_schema.table_privileges; +select * from information_schema.schema_privileges; +select * from information_schema.user_privileges; +show grants; +connection con3; +select * from information_schema.column_privileges; +select * from information_schema.table_privileges; +select * from information_schema.schema_privileges; +select * from information_schema.user_privileges; +show grants; +connection con4; +select * from information_schema.column_privileges where grantee like '%user%'; +select * from information_schema.table_privileges where grantee like '%user%'; +select * from information_schema.schema_privileges where grantee like '%user%'; +select * from information_schema.user_privileges where grantee like '%user%'; +show grants; +connection default; +drop user user1@localhost, user2@localhost, user3@localhost, user4@localhost; +use test; +drop database mysqltest; diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index dc9645a8326..7b27d589ec3 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -615,7 +615,6 @@ truncate table t1; insert into t1 values(1),(2); select * from t1; truncate table t1; -truncate table t1; insert into t1 values(1),(2); delete from t1; select * from t1; @@ -1056,8 +1055,8 @@ insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, ""); insert t2 select * from t1; insert t3 select * from t1; checksum table t1, t2, t3, t4 quick; -checksum table t1, t2, t3; -checksum table t1, t2, t3 extended; +checksum table t1, t2, t3, t4; +checksum table t1, t2, t3, t4 extended; #show table status; drop table t1,t2,t3; @@ -1177,28 +1176,6 @@ show status like "binlog_cache_disk_use"; drop table t1; # -# range optimizer problem -# - -create table t1 (x bigint unsigned not null primary key) engine=innodb; -insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1); -select * from t1; -select count(*) from t1 where x>0; -select count(*) from t1 where x=0; -select count(*) from t1 where x<0; -select count(*) from t1 where x < -16; -select count(*) from t1 where x = -16; -explain select count(*) from t1 where x > -16; - -# The following result should be (2). To be fixed when we add 'unsigned flag' to -# Field::store(longlong) -select count(*) from t1 where x > -16; -select * from t1 where x > -16; -select count(*) from t1 where x = 18446744073709551601; - -drop table t1; - -# # Bug #6126: Duplicate columns in keys gives misleading error message # --error 1060 @@ -1220,6 +1197,62 @@ alter table t1 add key (c1,c2,c1); alter table t1 add key (c1,c1,c2); drop table t1; +# +# Bug #4082: integer truncation +# + +create table t1(a int(1) , b int(1)) engine=innodb; +insert into t1 values ('1111', '3333'); +select distinct concat(a, b) from t1; +drop table t1; + +# +# BUG#7709 test case - Boolean fulltext query against unsupported +# engines does not fail +# + +CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB; +--error 1214; +SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE); +DROP TABLE t1; + +# +# check null values #1 +# + +--disable_warnings +CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a), + CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1; +--enable_warnings +INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2); +SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz; +DROP TABLE t2; +DROP TABLE t1; + +# +# range optimizer problem +# + +create table t1 (x bigint unsigned not null primary key) engine=innodb; +insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1); +select * from t1; +select count(*) from t1 where x>0; +select count(*) from t1 where x=0; +select count(*) from t1 where x<0; +select count(*) from t1 where x < -16; +select count(*) from t1 where x = -16; +explain select count(*) from t1 where x > -16; + +# The following result should be (2). To be fixed when we add 'unsigned flag' to +# Field::store(longlong) +select count(*) from t1 where x > -16; +select * from t1 where x > -16; +select count(*) from t1 where x = 18446744073709551601; +drop table t1; + + # Test for testable InnoDB status variables. This test # uses previous ones(pages_created, rows_deleted, ...). show status like "Innodb_buffer_pool_pages_total"; @@ -1302,20 +1335,50 @@ create table t1 (v varchar(16384)) engine=innodb; drop table t1; # -# Bug #4082: integer truncation +# BUG#11039 Wrong key length in min() # -create table t1(a int(1) , b int(1)) engine=innodb; -insert into t1 values ('1111', '3333'); -select distinct concat(a, b) from t1; +create table t1 (a char(1), b char(1), key(a, b)) engine=innodb; +insert into t1 values ('8', '6'), ('4', '7'); +select min(a) from t1; +select min(b) from t1 where a='8'; drop table t1; # -# BUG#7709 test case - Boolean fulltext query against unsupported -# engines does not fail +# Bug #11080 & #11005 Multi-row REPLACE fails on a duplicate key error # -CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB; ---error 1214; -SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE); -DROP TABLE t1; +CREATE TABLE t1 ( `a` int(11) NOT NULL auto_increment, `b` int(11) default NULL,PRIMARY KEY (`a`),UNIQUE KEY `b` (`b`)) ENGINE=innodb; +insert into t1 (b) values (1); +replace into t1 (b) values (2), (1), (3); +select * from t1; +truncate table t1; +insert into t1 (b) values (1); +replace into t1 (b) values (2); +replace into t1 (b) values (1); +replace into t1 (b) values (3); +select * from t1; +drop table t1; + +create table t1 (rowid int not null auto_increment, val int not null,primary +key (rowid), unique(val)) engine=innodb; +replace into t1 (val) values ('1'),('2'); +replace into t1 (val) values ('1'),('2'); +--error 1062 +insert into t1 (val) values ('1'),('2'); +select * from t1; +drop table t1; + + +# +# Test that update does not change internal auto-increment value +# + +create table t1 (a int not null auto_increment primary key, val int) engine=InnoDB; +insert into t1 (val) values (1); +update t1 set a=2 where a=1; +# We should get the following error because InnoDB does not update the counter +--error 1062 +insert into t1 (val) values (1); +select * from t1; +drop table t1; diff --git a/mysql-test/t/innodb_handler.test b/mysql-test/t/innodb_handler.test index e8c486caf66..65728519e7b 100644 --- a/mysql-test/t/innodb_handler.test +++ b/mysql-test/t/innodb_handler.test @@ -69,6 +69,16 @@ handler t2 read next; handler t2 read last; handler t2 close; +handler t1 open; +handler t1 read a next; # this used to crash as a bug#5373 +handler t1 read a next; +handler t1 close; + +handler t1 open; +handler t1 read a prev; # this used to crash as a bug#5373 +handler t1 read a prev; +handler t1 close; + handler t1 open as t2; handler t2 read first; alter table t1 engine=innodb; diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test index af3509c8454..9db1523be51 100644 --- a/mysql-test/t/key.test +++ b/mysql-test/t/key.test @@ -324,3 +324,16 @@ alter table t1 add key (c1,c2,c1); --error 1060 alter table t1 add key (c1,c1,c2); drop table t1; + +# +# If we use a partial field for a key that is actually the length of the +# field, and we extend the field, we end up with a key that includes the +# whole new length of the field. +# +create table t1 (a varchar(10), b varchar(10), key(a(10),b(10))); +show create table t1; +alter table t1 modify b varchar(20); +show create table t1; +alter table t1 modify a varchar(20); +show create table t1; +drop table t1; diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 067b0db492f..4e16e57058d 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -295,3 +295,23 @@ select 1 as `a'b`, 2 as `a"b`; # Test escaping of quotes select 'aaa\\','aa''a',"aa""a"; + + + +# +# Check of include/show_msg.inc +# + +# The message contains in most cases a string with the default character set +SET @message = 'Here comes a message'; +--source include/show_msg.inc + +# The message could also contain a string with character set utf8 +SET @message = USER(); +--source include/show_msg.inc + +# The message contains more then 80 characters on multiple lines +SET @message = 'Here comes a very very long message that is longer then 80 characters +on multiple lines'; +--source include/show_msg80.inc + diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test index 3c7b99da25a..0173fabd46f 100644 --- a/mysql-test/t/ndb_restore.test +++ b/mysql-test/t/ndb_restore.test @@ -214,4 +214,4 @@ drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; # Test BUG#10287 # ---exec $NDB_TOOLS_DIR/ndb_select_all -d sys -D , SYSTAB_0 | grep 520093696 +--exec $NDB_TOOLS_DIR/ndb_select_all --no-defaults -d sys -D , SYSTAB_0 | grep 520093696 diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index f4396e41a20..60b77576572 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -664,3 +664,32 @@ select t2.id from t2, t1 where (t1.id=1 and t2.t1_id=t1.id); 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; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index b6132d23d02..372325c4cbd 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2255,3 +2255,19 @@ AND FK_firma_id = 2; drop table t1; +# +# Test for bug #10084: STRAIGHT_JOIN with ON expression +# + +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5); +INSERT INTO t2 VALUES (2), (4), (6); + +SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; + +EXPLAIN SELECT t1.a FROM t1 STRAIGHT_JOIN t2 ON t1.a=t2.a; +EXPLAIN SELECT t1.a FROM t1 INNER JOIN t2 ON t1.a=t2.a; + +DROP TABLE t1,t2; + diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index 891e282e335..faf6d8b4de3 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -965,3 +965,24 @@ drop procedure bug10969| drop table t1| delimiter ;| + +# +# Bug#10975, #10605, #7115: Dynamic SQL by means of +# PREPARE/EXECUTE/DEALLOCATE is not supported yet. +# Check that an error message is returned. +# +prepare stmt from "select 1"; +--error ER_SP_BADSTATEMENT +create procedure p() deallocate prepare stmt; +--error ER_SP_BADSTATEMENT +create function f() returns int begin deallocate prepare stmt; +--error ER_SP_BADSTATEMENT +create procedure p() prepare stmt from "select 1"; +--error ER_SP_BADSTATEMENT +create function f() returns int begin prepare stmt from "select 1"; +--error ER_SP_BADSTATEMENT +create procedure p() execute stmt; +--error ER_SP_BADSTATEMENT +create function f() returns int begin execute stmt; +deallocate prepare stmt; + diff --git a/mysql-test/t/sp-threads.test b/mysql-test/t/sp-threads.test index 608ac3e2ee7..8fec5d14bc1 100644 --- a/mysql-test/t/sp-threads.test +++ b/mysql-test/t/sp-threads.test @@ -84,6 +84,32 @@ reap; drop procedure bug9486; drop table t1, t2; +# +# BUG#11158: Can't perform multi-delete in stored procedure +# +--disable_warnings +drop procedure if exists bug11158; +--enable_warnings +create procedure bug11158() delete t1 from t1, t2 where t1.id = t2.id; +create table t1 (id int, j int); +insert into t1 values (1, 1), (2, 2); +create table t2 (id int); +insert into t2 values (1); +# Procedure should work and cause proper effect (delete only first row) +call bug11158(); +select * from t1; +# Also let us test that we obtain only read (and thus non exclusive) lock +# for table from which we are not going to delete rows. +connection con2root; +lock tables t2 read; +connection con1root; +call bug11158(); +connection con2root; +unlock tables; +connection con1root; +# Clean-up +drop procedure bug11158; +drop table t1, t2; # # BUG#NNNN: New bug synopsis diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index e76dc971df7..20b1a98702c 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -3268,12 +3268,6 @@ drop procedure bug8762| # # BUG#5240: Stored procedure crash if function has cursor declaration # -# The following test case fails in --ps-protocol mode due to some bugs -# in algorithm which calculates list of tables to be locked for queries -# using Stored Functions. It is disabled until Dmitri fixes this. -# ---disable_ps_protocol - --disable_warnings drop function if exists bug5240| --enable_warnings @@ -3293,8 +3287,6 @@ insert into t1 values ("answer", 42)| select id, bug5240() from t1| drop function bug5240| ---enable_ps_protocol - # # BUG#5278: Stored procedure packets out of order if SET PASSWORD. # @@ -3849,6 +3841,50 @@ 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#NNNN: New bug synopsis diff --git a/mysql-test/t/sp_trans.test b/mysql-test/t/sp_trans.test index f5b38ada674..d860d4818ba 100644 --- a/mysql-test/t/sp_trans.test +++ b/mysql-test/t/sp_trans.test @@ -4,6 +4,10 @@ -- source include/have_innodb.inc +--disable_warnings +drop table if exists t1, t2; +--enable_warnings + delimiter |; # @@ -36,6 +40,146 @@ drop procedure bug8850| # +# BUG#10015: Crash in InnoDB if stored routines are used +# (crash happens in auto-commit mode) +# +--disable_warnings +drop function if exists bug10015_1| +drop function if exists bug10015_2| +drop function if exists bug10015_3| +drop function if exists bug10015_4| +drop function if exists bug10015_5| +drop function if exists bug10015_6| +drop function if exists bug10015_7| +drop procedure if exists bug10015_8| +--enable_warnings +create table t1 (id int) engine=innodb| +create table t2 (id int primary key, j int) engine=innodb| +insert into t1 values (1),(2),(3)| +create function bug10015_1() returns int return (select count(*) from t1)| +select *, bug10015_1() from t1| +drop function bug10015_1| +# Test couple of a bit more complex cases +create function bug10015_2() returns int + begin + declare i, s int; + set i:= (select min(id) from t1); + set s:= (select max(id) from t1); + return (s - i); + end| +select *, bug10015_2() from t1| +drop function bug10015_2| +create function bug10015_3() returns int + return (select max(a.id - b.id) from t1 as a, t1 as b where a.id >= b.id)| +select *, bug10015_3() from t1| +drop function bug10015_3| +create function bug10015_4(i int) returns int + begin + declare m int; + set m:= (select max(id) from t2); + insert into t2 values (i, m); + return m; + end| +select *, bug10015_4(id) from t1| +select * from t2| +drop function bug10015_4| +# Now let us test how statement rollback works +# This function will cause the whole stmt to be rolled back, +# there should not be any traces left. +create function bug10015_5(i int) returns int + begin + if (i = 5) then + insert into t2 values (1, 0); + end if; + return i; + end| +--error 1062 +insert into t1 values (bug10015_5(4)), (bug10015_5(5))| +select * from t1| +drop function bug10015_5| +# Thanks to error-handler this function should not cause rollback +# of statement calling it. But insert statement in it should be +# rolled back completely and don't leave any traces in t2. +# Unfortunately we can't implement such behavior in 5.0, so it +# is something to be fixed in later 5.* releases (TODO). +create function bug10015_6(i int) returns int + begin + declare continue handler for sqlexception set @error_in_func:= 1; + if (i = 5) then + insert into t2 values (4, 0), (1, 0); + end if; + return i; + end| +set @error_in_func:= 0| +insert into t1 values (bug10015_6(5)), (bug10015_6(6))| +select @error_in_func| +select * from t1| +select * from t2| +drop function bug10015_6| +# Let us test that we don't allow any statements causing transaction +# commit in stored functions (we test only most interesting cases here). +# Cases which can be caught at creation time: +--error 1422 +create function bug10015_7() returns int + begin + alter table t1 add k int; + return 1; + end| +--error 1422 +create function bug10015_7() returns int + begin + start transaction; + return 1; + end| +--error 1422 +create function bug10015_7() returns int + begin + drop table t1; + return 1; + end| +# It should be OK to drop temporary table. +create function bug10015_7() returns int + begin + drop temporary table t1; + return 1; + end| +drop function bug10015_7| +--error 1422 +create function bug10015_7() returns int + begin + commit; + return 1; + end| +# Now let us test cases which we can catch only at run-time: +create function bug10015_7() returns int + begin + call bug10015_8(); + return 1; + end| +create procedure bug10015_8() alter table t1 add k int| +--error 1422 +select *, bug10015_7() from t1| +drop procedure bug10015_8| +create procedure bug10015_8() start transaction| +--error 1422 +select *, bug10015_7() from t1| +drop procedure bug10015_8| +# Again it is OK to drop temporary table +# We are surpressing warnings since they are not essential +create procedure bug10015_8() drop temporary table if exists t1_temp| +--disable_warnings +select *, bug10015_7() from t1| +--enable_warnings +drop procedure bug10015_8| +create procedure bug10015_8() commit| +--error 1422 +select *, bug10015_7() from t1| +drop procedure bug10015_8| +drop function bug10015_7| +drop table t1, t2| + + +# # BUG#NNNN: New bug synopsis # #--disable_warnings diff --git a/mysql-test/t/sql_mode.test b/mysql-test/t/sql_mode.test index e80752eb71b..6a0c4aecada 100644 --- a/mysql-test/t/sql_mode.test +++ b/mysql-test/t/sql_mode.test @@ -80,6 +80,11 @@ create table t1 ( min_num dec(6,6) default .000001); show create table t1; drop table t1 ; +# +# Bug #10732: Set SQL_MODE to NULL gives garbled error message +# +--error 1231 +set @@SQL_MODE=NULL; # # test for diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test index 19d16f95990..2df5f0ed05d 100644 --- a/mysql-test/t/type_bit.test +++ b/mysql-test/t/type_bit.test @@ -162,3 +162,12 @@ create table t1 (a int, b time, c tinyint, d bool, e char(10), f bit(1), insert into t1 set a=1; select h from t1; drop table t1; + +# +# Bug #10539 +# + +create table t1 (a bit(8)) engine=heap; +insert into t1 values ('1111100000'); +select a+0 from t1; +drop table t1; diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index 9b09c415379..6199bd34fa9 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -911,7 +911,9 @@ DROP TABLE t1; # Bug #10465 # +--disable_warnings CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB; +--enable_warnings INSERT INTO t1 (GRADE) VALUES (151),(252),(343); SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300; SELECT GRADE FROM t1 WHERE GRADE= 151; @@ -923,3 +925,42 @@ DROP TABLE t1; select abs(10/0); select abs(NULL); + +# +# Bug #9894 (negative to unsigned column) +# +set @@sql_mode='traditional'; +create table t1( d1 decimal(18) unsigned, d2 decimal(20) unsigned, d3 decimal (22) unsigned); +--error 1264 +insert into t1 values(1,-1,-1); +drop table t1; +create table t1 (col1 decimal(5,2), col2 numeric(5,2)); +--error 1264 +insert into t1 values (999.999,999.999); +--error 1264 +insert into t1 values (-999.999,-999.999); +select * from t1; +drop table t1; +set sql_mode=''; + +# +# Bug #8425 (insufficient precision of the division) +# +set @sav_dpi= @@div_precision_increment; +set @@div_precision_increment=15; +create table t1 (col1 int, col2 decimal(30,25), col3 numeric(30,25)); +insert into t1 values (1,0.0123456789012345678912345,0.0123456789012345678912345); +select col2/9999999999 from t1 where col1=1; +select 9999999999/col2 from t1 where col1=1; +select 77777777/7777777; +drop table t1; +set div_precision_increment= @sav_dpi; + +# +# Bug #10896 (0.00 > -0.00) +# +create table t1 (a decimal(4,2)); +insert into t1 values (0.00); +select * from t1 where a > -0.00; +select * from t1 where a = -0.00; +drop table t1; diff --git a/mysql-test/t/type_varchar.test b/mysql-test/t/type_varchar.test index 2bffca6b889..1a3a93018a4 100644 --- a/mysql-test/t/type_varchar.test +++ b/mysql-test/t/type_varchar.test @@ -118,3 +118,15 @@ insert into t2 values (22), (22); select t1.a, t1.b, min(t1.b) from t1 inner join t2 ON t2.a = t1.a group by t1.b, t1.a; drop table t1, t2; + +# +# Bug #10543: convert varchar with index to text +# +create table t1 (f1 varchar(65500)); +create index index1 on t1(f1(10)); +show create table t1; +alter table t1 modify f1 varchar(255); +show create table t1; +alter table t1 modify f1 tinytext; +show create table t1; +drop table t1; diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test index 69284b4c6e4..314432af83e 100644 --- a/mysql-test/t/warnings.test +++ b/mysql-test/t/warnings.test @@ -129,3 +129,25 @@ drop table t1; # Test for deprecated table_type variable # set table_type=MYISAM; + +# +# Tests for show warnings limit a, b +# +create table t1 (a int); +insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +# should generate 10 warnings +update t1 set a='abc'; +show warnings limit 2, 1; +show warnings limit 0, 10; +show warnings limit 9, 1; +show warnings limit 10, 1; +show warnings limit 9, 2; +show warnings limit 0, 0; +show warnings limit 1; +show warnings limit 0; +show warnings limit 1, 0; +# make sure behaviour is consistent with select ... limit +select * from t1 limit 0; +select * from t1 limit 1, 0; +select * from t1 limit 0, 0; +drop table t1; |