diff --git a/client/mysqltest.c b/client/mysqltest.c index a04f18750ef..9c7c4d62f6f 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -5464,6 +5464,7 @@ void init_win_path_patterns() const char* paths[] = { "$MYSQL_TEST_DIR", "$MYSQL_TMP_DIR", "$MYSQLTEST_VARDIR", + "$MASTER_MYSOCK", "./test/" }; int num_paths= sizeof(paths)/sizeof(char*); int i; diff --git a/configure.in b/configure.in index d40df7b7895..db14982840d 100644 --- a/configure.in +++ b/configure.in @@ -7,7 +7,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 5.0.62) +AM_INIT_AUTOMAKE(mysql, 5.0.64) AM_CONFIG_HEADER([include/config.h:config.h.in]) PROTOCOL_VERSION=10 @@ -23,7 +23,7 @@ NDB_SHARED_LIB_VERSION=$NDB_SHARED_LIB_MAJOR_VERSION:0:0 # ndb version NDB_VERSION_MAJOR=5 NDB_VERSION_MINOR=0 -NDB_VERSION_BUILD=62 +NDB_VERSION_BUILD=64 NDB_VERSION_STATUS="" # Set all version vars based on $VERSION. How do we do this more elegant ? diff --git a/include/my_global.h b/include/my_global.h index b0a26e67d9b..e474b620d27 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -533,8 +533,12 @@ C_MODE_END #undef DBUG_OFF #endif -#if defined(_lint) && !defined(DBUG_OFF) -#define DBUG_OFF +/* We might be forced to turn debug off, if not turned off already */ +#if (defined(FORCE_DBUG_OFF) || defined(_lint)) && !defined(DBUG_OFF) +# define DBUG_OFF +# ifdef DBUG_ON +# undef DBUG_ON +# endif #endif #include diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index fefeeb405c5..3356d23053f 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -1325,7 +1325,6 @@ set @a=repeat(' ',20); insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a)); Warnings: Note 1265 Data truncated for column 'v' at row 1 -Note 1265 Data truncated for column 'c' at row 1 select concat('*',v,'*',c,'*',t,'*') from t1; concat('*',v,'*',c,'*',t,'*') *+ *+*+ * diff --git a/mysql-test/r/binlog_innodb.result b/mysql-test/r/binlog_innodb.result index 18b4b7c1c93..180b43f42ac 100644 --- a/mysql-test/r/binlog_innodb.result +++ b/mysql-test/r/binlog_innodb.result @@ -34,6 +34,6 @@ END| INSERT INTO t2 VALUES (2),(10+bug23333()); SHOW MASTER STATUS; File Position Binlog_Do_DB Binlog_Ignore_DB -# 184136 +# 184141 DROP FUNCTION bug23333; DROP TABLE t1, t2; diff --git a/mysql-test/r/ctype_cp932_binlog.result b/mysql-test/r/ctype_cp932_binlog.result index 0b4ca93a0dd..b00124b7799 100644 --- a/mysql-test/r/ctype_cp932_binlog.result +++ b/mysql-test/r/ctype_cp932_binlog.result @@ -34,12 +34,12 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 362 Query 1 528 use `test`; CREATE TABLE t4 (s1 CHAR(50) CHARACTER SET latin1, s2 CHAR(50) CHARACTER SET cp932, d DECIMAL(10,2)) -master-bin.000001 528 Query 1 776 use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE bug18293 (IN ins1 CHAR(50), +master-bin.000001 528 Query 1 777 use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `bug18293`(IN ins1 CHAR(50), IN ins2 CHAR(50) CHARACTER SET cp932, IN ind DECIMAL(10,2)) BEGIN INSERT INTO t4 VALUES (ins1, ins2, ind); END -master-bin.000001 776 Query 1 987 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93)) -master-bin.000001 987 Query 1 1076 use `test`; DROP PROCEDURE bug18293 -master-bin.000001 1076 Query 1 1155 use `test`; DROP TABLE t4 +master-bin.000001 777 Query 1 988 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93)) +master-bin.000001 988 Query 1 1077 use `test`; DROP PROCEDURE bug18293 +master-bin.000001 1077 Query 1 1156 use `test`; DROP TABLE t4 diff --git a/mysql-test/r/ctype_gbk.result b/mysql-test/r/ctype_gbk.result index 6066246a2ef..1b425134095 100644 --- a/mysql-test/r/ctype_gbk.result +++ b/mysql-test/r/ctype_gbk.result @@ -247,4 +247,11 @@ t1 CREATE TABLE `t1` ( `c2` text NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=gbk drop table t1; +CREATE TABLE t1(a MEDIUMTEXT CHARACTER SET gbk, +b MEDIUMTEXT CHARACTER SET big5); +INSERT INTO t1 VALUES +(REPEAT(0x1125,200000), REPEAT(0x1125,200000)), ('', ''), ('', ''); +SELECT a FROM t1 GROUP BY 1 LIMIT 1 INTO @nullll; +SELECT b FROM t1 GROUP BY 1 LIMIT 1 INTO @nullll; +DROP TABLES t1; End of 5.0 tests diff --git a/mysql-test/r/func_concat.result b/mysql-test/r/func_concat.result index 66808afd4e9..7e7c163716e 100644 --- a/mysql-test/r/func_concat.result +++ b/mysql-test/r/func_concat.result @@ -82,3 +82,10 @@ a 1234562 x drop table t1; +CREATE TABLE t1 (c1 varchar(100), c2 varchar(100)); +INSERT INTO t1 VALUES ('',''), ('','First'), ('Random','Random'); +SELECT * FROM t1 WHERE CONCAT(c1,' ',c2) REGEXP 'First.*'; +c1 c2 + First +DROP TABLE t1; +# End of 5.0 tests diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 77d11831842..4dddc35e8a8 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -946,4 +946,30 @@ GROUP BY 1 d1 NULL DROP TABLE t1; +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES(1); +SELECT GROUP_CONCAT(DISTINCT t2.a) FROM t1 LEFT JOIN t2 ON t2.a = t1.a GROUP BY t1.a; +GROUP_CONCAT(DISTINCT t2.a) +NULL +DROP TABLE t1, t2; +CREATE TABLE t1 (a INT, KEY(a)); +CREATE TABLE t2 (b INT); +INSERT INTO t1 VALUES (NULL), (8), (2); +INSERT INTO t2 VALUES (4), (10); +SELECT 1 FROM t1 WHERE t1.a NOT IN +( +SELECT GROUP_CONCAT(DISTINCT t1.a) +FROM t1 WHERE t1.a IN +( +SELECT b FROM t2 +) +AND NOT t1.a >= (SELECT t1.a FROM t1 LIMIT 1) +GROUP BY t1.a +); +1 +1 +1 +1 +DROP TABLE t1, t2; End of 5.0 tests diff --git a/mysql-test/r/heap.result b/mysql-test/r/heap.result index adfcc00174f..906c431b834 100644 --- a/mysql-test/r/heap.result +++ b/mysql-test/r/heap.result @@ -256,7 +256,6 @@ set @a=repeat(' ',20); insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a)); Warnings: Note 1265 Data truncated for column 'v' at row 1 -Note 1265 Data truncated for column 'c' at row 1 select concat('*',v,'*',c,'*',t,'*') from t1; concat('*',v,'*',c,'*',t,'*') *+ *+*+ * diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 774e0bd167b..854712fdb1d 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1901,7 +1901,6 @@ set @a=repeat(' ',20); insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a)); Warnings: Note 1265 Data truncated for column 'v' at row 1 -Note 1265 Data truncated for column 'c' at row 1 select concat('*',v,'*',c,'*',t,'*') from t1; concat('*',v,'*',c,'*',t,'*') *+ *+*+ * diff --git a/mysql-test/r/multi_update_tiny_hash.result b/mysql-test/r/multi_update_tiny_hash.result new file mode 100644 index 00000000000..d8983123aac --- /dev/null +++ b/mysql-test/r/multi_update_tiny_hash.result @@ -0,0 +1,45 @@ +drop table if exists t1, t2; +# +# Bug #36676: multiupdate using LEFT JOIN updates only +# first row or fails with an error: +# ERROR 1022 (23000): Can't write; duplicate key in table '' +# + +# +# Multiupdate creates MyISAM temporary table without MEMORY table +# +CREATE TABLE t1 (ID INT); +CREATE TABLE t2 (ID INT, +s1 TEXT, s2 TEXT, s3 VARCHAR(10), s4 TEXT, s5 VARCHAR(10)); +INSERT INTO t1 VALUES (1),(2); +INSERT INTO t2 VALUES (1,'test', 'test', 'test', 'test', 'test'), +(2,'test', 'test', 'test', 'test', 'test'); +SELECT * FROM t1 LEFT JOIN t2 USING(ID); +ID s1 s2 s3 s4 s5 +1 test test test test test +2 test test test test test +UPDATE t1 LEFT JOIN t2 USING(ID) SET s1 = 'changed'; +UPDATE t1 JOIN t2 USING(ID) SET s2 = 'changed'; +UPDATE t1 LEFT JOIN t2 USING(ID) SET s3 = 'changed'; +UPDATE t1 LEFT JOIN t2 USING(ID) SET s4 = 'changed', s5 = 'changed'; +SELECT * FROM t1 LEFT JOIN t2 USING(ID); +ID s1 s2 s3 s4 s5 +1 changed changed changed changed changed +2 changed changed changed changed changed +DROP TABLE t1, t2; +# +# Multiupdate creates temporary MyISAM table from MEMORY table +# +CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY); +CREATE TABLE t2 (id INT, s1 CHAR(255)); +INSERT INTO t1 VALUES (0), (0), (0), (0), (0), (0), (0), (0); +INSERT INTO t1 (SELECT 0 FROM t1); +INSERT INTO t1 (SELECT 0 FROM t1); +INSERT INTO t1 (SELECT 0 FROM t1); +INSERT INTO t2 (SELECT ID, 'a' FROM t1); +UPDATE t1 LEFT JOIN t2 USING(id) SET s1 = 'b'; +SELECT DISTINCT s1 FROM t1 LEFT JOIN t2 USING(id); +s1 +b +DROP TABLE t1, t2; +# End of 5.0 tests diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 24c1cecfb4f..33f64d600bb 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -1104,7 +1104,6 @@ set @a=repeat(' ',20); insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a)); Warnings: Note 1265 Data truncated for column 'v' at row 1 -Note 1265 Data truncated for column 'c' at row 1 select concat('*',v,'*',c,'*',t,'*') from t1; concat('*',v,'*',c,'*',t,'*') *+ *+*+ * diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index 469250a6fa2..4fd87861ded 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -268,7 +268,7 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.uniq SET @@session.sql_mode=0/*!*/; /*!\C latin1 *//*!*/; SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; -CREATE DEFINER=`root`@`localhost` procedure p1() +CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() begin select 1; end diff --git a/mysql-test/r/repair.result b/mysql-test/r/repair.result index e0548233b86..c59a5300e64 100644 --- a/mysql-test/r/repair.result +++ b/mysql-test/r/repair.result @@ -115,3 +115,39 @@ SET myisam_repair_threads=@@global.myisam_repair_threads; SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size; DROP TABLE t1; End of 4.1 tests +# Test with a saved table from 4.1 +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 9 Fixed 2 5 10 21474836479 1024 0 NULL # # NULL latin1_swedish_ci NULL +SELECT * FROM t1; +id +1 +2 +# Run CHECK TABLE, it should indicate table need a REPAIR TABLE +CHECK TABLE t1 FOR UPGRADE; +Table Op Msg_type Msg_text +test.t1 check error Table upgrade required. Please do "REPAIR TABLE `t1`" to fix it! +# REPAIR old table USE_FRM should fail +REPAIR TABLE t1 USE_FRM; +Table Op Msg_type Msg_text +t1 repair error Failed reparing incompatible .FRM file +# Run REPAIR TABLE to upgrade .frm file +REPAIR TABLE t1; +Table Op Msg_type Msg_text +test.t1 repair status OK +SHOW TABLE STATUS LIKE 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 2 7 14 1970324836974591 1024 0 NULL # # NULL latin1_swedish_ci NULL +SELECT * FROM t1; +id +1 +2 +REPAIR TABLE t1 USE_FRM; +Table Op Msg_type Msg_text +test.t1 repair warning Number of rows changed from 0 to 2 +test.t1 repair status OK +SELECT * FROM t1; +id +1 +2 +DROP TABLE t1; diff --git a/mysql-test/r/rpl_sp.result b/mysql-test/r/rpl_sp.result index 0fe1b4b908e..a5d01f693f5 100644 --- a/mysql-test/r/rpl_sp.result +++ b/mysql-test/r/rpl_sp.result @@ -386,7 +386,7 @@ Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # drop database if exists mysqltest1 master-bin.000001 # Query 1 # create database mysqltest1 master-bin.000001 # Query 1 # use `mysqltest1`; create table t1 (a varchar(100)) -master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo() +master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` PROCEDURE `foo`() begin declare b int; set b = 8; @@ -396,20 +396,20 @@ end master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values ( NAME_CONST('b',8)) master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values (unix_timestamp()) master-bin.000001 # Query 1 # use `mysqltest1`; delete from t1 -master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo2() +master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` PROCEDURE `foo2`() select * from mysqltest1.t1 master-bin.000001 # Query 1 # use `mysqltest1`; alter procedure foo2 contains sql master-bin.000001 # Query 1 # use `mysqltest1`; drop table t1 master-bin.000001 # Query 1 # use `mysqltest1`; create table t1 (a int) master-bin.000001 # Query 1 # use `mysqltest1`; create table t2 like t1 -master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo3() -deterministic +master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` PROCEDURE `foo3`() + DETERMINISTIC insert into t1 values (15) master-bin.000001 # Query 1 # use `mysqltest1`; grant CREATE ROUTINE, EXECUTE on mysqltest1.* to "zedjzlcsjhd"@127.0.0.1 master-bin.000001 # Query 1 # use `mysqltest1`; grant SELECT on mysqltest1.t1 to "zedjzlcsjhd"@127.0.0.1 master-bin.000001 # Query 1 # use `mysqltest1`; grant SELECT, INSERT on mysqltest1.t2 to "zedjzlcsjhd"@127.0.0.1 -master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`zedjzlcsjhd`@`127.0.0.1` procedure foo4() -deterministic +master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`zedjzlcsjhd`@`127.0.0.1` PROCEDURE `foo4`() + DETERMINISTIC begin insert into t2 values(3); insert into t1 values (5); @@ -423,8 +423,8 @@ master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values (5) master-bin.000001 # Query 1 # use `mysqltest1`; delete from t2 master-bin.000001 # Query 1 # use `mysqltest1`; alter table t2 add unique (a) master-bin.000001 # Query 1 # use `mysqltest1`; drop procedure foo4 -master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo4() -deterministic +master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` PROCEDURE `foo4`() + DETERMINISTIC begin insert into t2 values(20),(20); end @@ -433,9 +433,8 @@ master-bin.000001 # Query 1 # use `mysqltest1`; drop procedure foo4 master-bin.000001 # Query 1 # use `mysqltest1`; drop procedure foo master-bin.000001 # Query 1 # use `mysqltest1`; drop procedure foo2 master-bin.000001 # Query 1 # use `mysqltest1`; drop procedure foo3 -master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function fn1(x int) -returns int -deterministic +master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` FUNCTION `fn1`(x int) RETURNS int(11) + DETERMINISTIC begin insert into t1 values (x); return x+2; @@ -444,32 +443,27 @@ master-bin.000001 # Query 1 # use `mysqltest1`; delete t1,t2 from t1,t2 master-bin.000001 # Query 1 # use `mysqltest1`; SELECT `mysqltest1`.`fn1`(20) master-bin.000001 # Query 1 # use `mysqltest1`; insert into t2 values(fn1(21)) master-bin.000001 # Query 1 # use `mysqltest1`; drop function fn1 -master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function fn1() -returns int -no sql +master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` FUNCTION `fn1`() RETURNS int(11) + NO SQL begin return unix_timestamp(); end master-bin.000001 # Query 1 # use `mysqltest1`; delete from t1 master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values(fn1()) -master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`zedjzlcsjhd`@`127.0.0.1` function fn2() -returns int -no sql +master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`zedjzlcsjhd`@`127.0.0.1` FUNCTION `fn2`() RETURNS int(11) + NO SQL begin return unix_timestamp(); end -master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function fn3() -returns int -not deterministic -reads sql data +master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` FUNCTION `fn3`() RETURNS int(11) + READS SQL DATA begin return 0; end master-bin.000001 # Query 1 # use `mysqltest1`; delete from t2 master-bin.000001 # Query 1 # use `mysqltest1`; alter table t2 add unique (a) master-bin.000001 # Query 1 # use `mysqltest1`; drop function fn1 -master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function fn1(x int) -returns int +master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` FUNCTION `fn1`(x int) RETURNS int(11) begin insert into t2 values(x),(x); return 10; @@ -482,15 +476,15 @@ master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values (1) master-bin.000001 # Query 1 # use `mysqltest1`; delete from t1 master-bin.000001 # Query 1 # use `mysqltest1`; drop trigger trg master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values (1) -master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` procedure foo() -not deterministic -reads sql data +master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` PROCEDURE `foo`() + READS SQL DATA select * from t1 master-bin.000001 # Query 1 # use `mysqltest1`; drop procedure foo master-bin.000001 # Query 1 # use `mysqltest1`; drop function fn1 master-bin.000001 # Query 1 # drop database mysqltest1 master-bin.000001 # Query 1 # drop user "zedjzlcsjhd"@127.0.0.1 -master-bin.000001 # Query 1 # use `test`; CREATE DEFINER=`root`@`localhost` function f1() returns int reads sql data +master-bin.000001 # Query 1 # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11) + READS SQL DATA begin declare var integer; declare c cursor for select a from v1; @@ -499,19 +493,21 @@ fetch c into var; close c; return var; end -master-bin.000001 # Query 1 # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 as a +master-bin.000001 # Query 1 # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `a` master-bin.000001 # Query 1 # use `test`; create table t1 (a int) master-bin.000001 # Query 1 # use `test`; insert into t1 (a) values (f1()) master-bin.000001 # Query 1 # use `test`; drop view v1 master-bin.000001 # Query 1 # use `test`; drop function f1 master-bin.000001 # Query 1 # use `test`; DROP TABLE IF EXISTS t1 master-bin.000001 # Query 1 # use `test`; CREATE TABLE t1(col VARCHAR(10)) -master-bin.000001 # Query 1 # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE p1(arg VARCHAR(10)) +master-bin.000001 # Query 1 # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(arg VARCHAR(10)) INSERT INTO t1 VALUES(arg) master-bin.000001 # Query 1 # use `test`; INSERT INTO t1 VALUES( NAME_CONST('arg',_latin1'test')) master-bin.000001 # Query 1 # use `test`; DROP PROCEDURE p1 -master-bin.000001 # Query 1 # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE p1() SET @a = 1 -master-bin.000001 # Query 1 # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION f1() RETURNS INT RETURN 0 +master-bin.000001 # Query 1 # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() +SET @a = 1 +master-bin.000001 # Query 1 # use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11) +RETURN 0 master-bin.000001 # Query 1 # use `test`; DROP PROCEDURE p1 master-bin.000001 # Query 1 # use `test`; DROP FUNCTION f1 master-bin.000001 # Query 1 # use `test`; drop table t1 @@ -520,9 +516,10 @@ master-bin.000001 # Query 1 # drop database if exists mysqltest2 master-bin.000001 # Query 1 # create database mysqltest master-bin.000001 # Query 1 # create database mysqltest2 master-bin.000001 # Query 1 # use `mysqltest2`; create table t ( t integer ) -master-bin.000001 # Query 1 # use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end +master-bin.000001 # Query 1 # use `mysqltest2`; CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqltest`.`test`() +begin end master-bin.000001 # Query 1 # use `mysqltest2`; insert into t values ( 1 ) -master-bin.000001 # Query 1 # use `mysqltest2`; CREATE DEFINER=`root`@`localhost` function f1 () returns int +master-bin.000001 # Query 1 # use `mysqltest2`; CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11) begin insert into t values (1); return 0; @@ -532,3 +529,407 @@ set global log_bin_trust_function_creators=0; set global log_bin_trust_function_creators=0; drop database mysqltest; drop database mysqltest2; +use test; +/*!50001 create procedure `mysqltestbug36570_p1`() */ +begin +select 1; +end| +use mysql| +create procedure test.` mysqltestbug36570_p2`(/*!50001 a int*/)`label`: +begin +select a; +end| +/*!50001 create function test.mysqltestbug36570_f1() */ +returns int +/*!50001 deterministic */ +begin +return 3; +end| +use test| +show procedure status like '%mysqltestbug36570%'; +Db Name Type Definer Modified Created Security_type Comment +test mysqltestbug36570_p2 PROCEDURE root@localhost t t DEFINER +test mysqltestbug36570_p1 PROCEDURE root@localhost t t DEFINER +show create procedure ` mysqltestbug36570_p2`; +Procedure sql_mode Create Procedure + mysqltestbug36570_p2 CREATE DEFINER=`root`@`localhost` PROCEDURE ` mysqltestbug36570_p2`(/*!50001 a int*/) +`label`: +begin +select a; +end +show procedure status like '%mysqltestbug36570%'; +Db Name Type Definer Modified Created Security_type Comment +test mysqltestbug36570_p2 PROCEDURE root@localhost t t DEFINER +test mysqltestbug36570_p1 PROCEDURE root@localhost t t DEFINER +show create procedure ` mysqltestbug36570_p2`; +Procedure sql_mode Create Procedure + mysqltestbug36570_p2 CREATE DEFINER=`root`@`localhost` PROCEDURE ` mysqltestbug36570_p2`(/*!50001 a int*/) +`label`: +begin +select a; +end +call ` mysqltestbug36570_p2`(42); +a +42 +show function status like '%mysqltestbug36570%'; +Db Name Type Definer Modified Created Security_type Comment +test mysqltestbug36570_f1 FUNCTION root@localhost t t DEFINER +flush logs; +/*!40019 SET @@session.max_insert_delayed_threads=0*/; +/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; +DELIMITER /*!*/; +ROLLBACK/*!*/; +SET TIMESTAMP=t/*!*/; +SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=1, @@session.unique_checks=1/*!*/; +SET @@session.sql_mode=0/*!*/; +/*!\C latin1 *//*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +drop database if exists mysqltest1 +/*!*/; +SET TIMESTAMP=t/*!*/; +create database mysqltest1 +/*!*/; +use mysqltest1/*!*/; +SET TIMESTAMP=t/*!*/; +create table t1 (a varchar(100)) +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` PROCEDURE `foo`() +begin +declare b int; +set b = 8; +insert into t1 values (b); +insert into t1 values (unix_timestamp()); +end +/*!*/; +SET TIMESTAMP=t/*!*/; +insert into t1 values ( NAME_CONST('b',8)) +/*!*/; +SET TIMESTAMP=t/*!*/; +insert into t1 values (unix_timestamp()) +/*!*/; +SET TIMESTAMP=t/*!*/; +delete from t1 +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` PROCEDURE `foo2`() +select * from mysqltest1.t1 +/*!*/; +SET TIMESTAMP=t/*!*/; +alter procedure foo2 contains sql +/*!*/; +SET TIMESTAMP=t/*!*/; +drop table t1 +/*!*/; +SET TIMESTAMP=t/*!*/; +create table t1 (a int) +/*!*/; +SET TIMESTAMP=t/*!*/; +create table t2 like t1 +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` PROCEDURE `foo3`() + DETERMINISTIC +insert into t1 values (15) +/*!*/; +SET TIMESTAMP=t/*!*/; +grant CREATE ROUTINE, EXECUTE on mysqltest1.* to "zedjzlcsjhd"@127.0.0.1 +/*!*/; +SET TIMESTAMP=t/*!*/; +grant SELECT on mysqltest1.t1 to "zedjzlcsjhd"@127.0.0.1 +/*!*/; +SET TIMESTAMP=t/*!*/; +grant SELECT, INSERT on mysqltest1.t2 to "zedjzlcsjhd"@127.0.0.1 +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`zedjzlcsjhd`@`127.0.0.1` PROCEDURE `foo4`() + DETERMINISTIC +begin +insert into t2 values(3); +insert into t1 values (5); +end +/*!*/; +SET TIMESTAMP=t/*!*/; +insert into t2 values(3) +/*!*/; +SET TIMESTAMP=t/*!*/; +insert into t1 values (15) +/*!*/; +SET TIMESTAMP=t/*!*/; +insert into t2 values(3) +/*!*/; +SET TIMESTAMP=t/*!*/; +alter procedure foo4 sql security invoker +/*!*/; +SET TIMESTAMP=t/*!*/; +insert into t2 values(3) +/*!*/; +SET TIMESTAMP=t/*!*/; +insert into t1 values (5) +/*!*/; +SET TIMESTAMP=t/*!*/; +delete from t2 +/*!*/; +SET TIMESTAMP=t/*!*/; +alter table t2 add unique (a) +/*!*/; +SET TIMESTAMP=t/*!*/; +drop procedure foo4 +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` PROCEDURE `foo4`() + DETERMINISTIC +begin +insert into t2 values(20),(20); +end +/*!*/; +SET TIMESTAMP=t/*!*/; +insert into t2 values(20),(20) +/*!*/; +SET TIMESTAMP=t/*!*/; +drop procedure foo4 +/*!*/; +SET TIMESTAMP=t/*!*/; +drop procedure foo +/*!*/; +SET TIMESTAMP=t/*!*/; +drop procedure foo2 +/*!*/; +SET TIMESTAMP=t/*!*/; +drop procedure foo3 +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` FUNCTION `fn1`(x int) RETURNS int(11) + DETERMINISTIC +begin +insert into t1 values (x); +return x+2; +end +/*!*/; +SET TIMESTAMP=t/*!*/; +delete t1,t2 from t1,t2 +/*!*/; +SET TIMESTAMP=t/*!*/; +SELECT `mysqltest1`.`fn1`(20) +/*!*/; +SET TIMESTAMP=t/*!*/; +insert into t2 values(fn1(21)) +/*!*/; +SET TIMESTAMP=t/*!*/; +drop function fn1 +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` FUNCTION `fn1`() RETURNS int(11) + NO SQL +begin +return unix_timestamp(); +end +/*!*/; +SET TIMESTAMP=t/*!*/; +delete from t1 +/*!*/; +SET TIMESTAMP=t/*!*/; +insert into t1 values(fn1()) +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`zedjzlcsjhd`@`127.0.0.1` FUNCTION `fn2`() RETURNS int(11) + NO SQL +begin +return unix_timestamp(); +end +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` FUNCTION `fn3`() RETURNS int(11) + READS SQL DATA +begin +return 0; +end +/*!*/; +SET TIMESTAMP=t/*!*/; +delete from t2 +/*!*/; +SET TIMESTAMP=t/*!*/; +alter table t2 add unique (a) +/*!*/; +SET TIMESTAMP=t/*!*/; +drop function fn1 +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` FUNCTION `fn1`(x int) RETURNS int(11) +begin +insert into t2 values(x),(x); +return 10; +end +/*!*/; +SET TIMESTAMP=t/*!*/; +SELECT `mysqltest1`.`fn1`(100) +/*!*/; +SET TIMESTAMP=t/*!*/; +SELECT `mysqltest1`.`fn1`(20) +/*!*/; +SET TIMESTAMP=t/*!*/; +delete from t1 +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` trigger trg before insert on t1 for each row set new.a= 10 +/*!*/; +SET TIMESTAMP=t/*!*/; +insert into t1 values (1) +/*!*/; +SET TIMESTAMP=t/*!*/; +delete from t1 +/*!*/; +SET TIMESTAMP=t/*!*/; +drop trigger trg +/*!*/; +SET TIMESTAMP=t/*!*/; +insert into t1 values (1) +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` PROCEDURE `foo`() + READS SQL DATA +select * from t1 +/*!*/; +SET TIMESTAMP=t/*!*/; +drop procedure foo +/*!*/; +SET TIMESTAMP=t/*!*/; +drop function fn1 +/*!*/; +SET TIMESTAMP=t/*!*/; +drop database mysqltest1 +/*!*/; +SET TIMESTAMP=t/*!*/; +drop user "zedjzlcsjhd"@127.0.0.1 +/*!*/; +use test/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11) + READS SQL DATA +begin +declare var integer; +declare c cursor for select a from v1; +open c; +fetch c into var; +close c; +return var; +end +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `a` +/*!*/; +SET TIMESTAMP=t/*!*/; +create table t1 (a int) +/*!*/; +SET TIMESTAMP=t/*!*/; +insert into t1 (a) values (f1()) +/*!*/; +SET TIMESTAMP=t/*!*/; +drop view v1 +/*!*/; +SET TIMESTAMP=t/*!*/; +drop function f1 +/*!*/; +SET TIMESTAMP=t/*!*/; +DROP TABLE IF EXISTS t1 +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE TABLE t1(col VARCHAR(10)) +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`(arg VARCHAR(10)) +INSERT INTO t1 VALUES(arg) +/*!*/; +SET TIMESTAMP=t/*!*/; +INSERT INTO t1 VALUES( NAME_CONST('arg',_latin1'test')) +/*!*/; +SET TIMESTAMP=t/*!*/; +DROP PROCEDURE p1 +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() +SET @a = 1 +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11) +RETURN 0 +/*!*/; +SET TIMESTAMP=t/*!*/; +DROP PROCEDURE p1 +/*!*/; +SET TIMESTAMP=t/*!*/; +DROP FUNCTION f1 +/*!*/; +SET TIMESTAMP=t/*!*/; +drop table t1 +/*!*/; +SET TIMESTAMP=t/*!*/; +drop database if exists mysqltest +/*!*/; +SET TIMESTAMP=t/*!*/; +drop database if exists mysqltest2 +/*!*/; +SET TIMESTAMP=t/*!*/; +create database mysqltest +/*!*/; +SET TIMESTAMP=t/*!*/; +create database mysqltest2 +/*!*/; +use mysqltest2/*!*/; +SET TIMESTAMP=t/*!*/; +create table t ( t integer ) +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqltest`.`test`() +begin end +/*!*/; +SET TIMESTAMP=t/*!*/; +insert into t values ( 1 ) +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` FUNCTION `f1`() RETURNS int(11) +begin +insert into t values (1); +return 0; +end +/*!*/; +use mysqltest/*!*/; +SET TIMESTAMP=t/*!*/; +SELECT `mysqltest2`.`f1`() +/*!*/; +SET TIMESTAMP=t/*!*/; +drop database mysqltest +/*!*/; +SET TIMESTAMP=t/*!*/; +drop database mysqltest2 +/*!*/; +use test/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` PROCEDURE `mysqltestbug36570_p1`() +begin +select 1; +end +/*!*/; +use mysql/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` PROCEDURE `test`.` mysqltestbug36570_p2`(/*!50001 a int*/) +`label`: +begin +select a; +end +/*!*/; +SET TIMESTAMP=t/*!*/; +CREATE DEFINER=`root`@`localhost` FUNCTION `test`.`mysqltestbug36570_f1`() RETURNS int(11) + DETERMINISTIC +begin +return 3; +end +/*!*/; +DELIMITER ; +# End of log file +ROLLBACK /* added by mysqlbinlog */; +/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; +use test; +drop procedure mysqltestbug36570_p1; +drop procedure ` mysqltestbug36570_p2`; +drop function mysqltestbug36570_f1; diff --git a/mysql-test/r/rpl_view.result b/mysql-test/r/rpl_view.result index be7ed6e8c2a..addaba8c379 100644 --- a/mysql-test/r/rpl_view.result +++ b/mysql-test/r/rpl_view.result @@ -47,11 +47,11 @@ show binlog events limit 1,100; Log_name Pos Event_type Server_id End_log_pos Info slave-bin.000001 # Query 1 # use `test`; create table t1 (a int) slave-bin.000001 # Query 1 # use `test`; insert into t1 values (1) -slave-bin.000001 # Query 1 # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select a from t1 +slave-bin.000001 # Query 1 # use `test`; CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`a` AS `a` from `test`.`t1` slave-bin.000001 # Query 1 # use `test`; insert into v1 values (2) slave-bin.000001 # Query 1 # use `test`; update v1 set a=3 where a=1 slave-bin.000001 # Query 1 # use `test`; delete from v1 where a=2 -slave-bin.000001 # Query 1 # use `test`; ALTER ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select a as b from t1 +slave-bin.000001 # Query 1 # use `test`; ALTER ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`a` AS `b` from `test`.`t1` slave-bin.000001 # Query 1 # use `test`; drop view v1 slave-bin.000001 # Query 1 # use `test`; drop table t1 @@ -112,4 +112,18 @@ CREATE VIEW v1 AS SELECT * FROM t1; ERROR 42S01: Table 'v1' already exists DROP VIEW v1; DROP TABLE t1; +CREATE TABLE t1 (a INT); +# create view as output from mysqldump 10.11 (5.0.62) +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` < 3) */ +/*!50002 WITH CASCADED CHECK OPTION */; +SHOW CREATE VIEW v1; +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` < 3) WITH CASCADED CHECK OPTION +SHOW CREATE VIEW v1; +View Create View +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` < 3) WITH CASCADED CHECK OPTION +DROP VIEW v1; +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result index 0a714635f70..34869862a63 100644 --- a/mysql-test/r/strict.result +++ b/mysql-test/r/strict.result @@ -934,8 +934,6 @@ NULL NULL DROP TABLE t1; CREATE TABLE t1 (col1 CHAR(5), col2 VARCHAR(6)); INSERT INTO t1 VALUES ('hello', 'hello'),('he', 'he'),('hello ', 'hello '); -Warnings: -Note 1265 Data truncated for column 'col1' at row 3 INSERT INTO t1 (col1) VALUES ('hellobob'); ERROR 22001: Data too long for column 'col1' at row 1 INSERT INTO t1 (col2) VALUES ('hellobob'); diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 2de2589fc92..12e3aac486e 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -4374,4 +4374,26 @@ a4 f3 a6 1 NULL NULL 2 NULL NULL DROP TABLE t1, t2, t3, t4; +create table t1 (a float(5,4) zerofill); +create table t2 (a float(5,4),b float(2,0)); +select t1.a from t1 where +t1.a= (select b from t2 limit 1) and not +t1.a= (select a from t2 limit 1) ; +a +drop table t1, t2; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 GROUP BY a); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort +Warnings: +Note 1003 select 1 AS `1` from `test`.`t1` where (1,(select 1 AS `1` from `test`.`t1` group by `test`.`t1`.`a` having ((1) = (1)))) +EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort +Warnings: +Note 1003 select 1 AS `1` from `test`.`t1` where (1,(select 1 AS `1` from `test`.`t1` where (`test`.`t1`.`a` > 3) group by `test`.`t1`.`a` having ((1) = (1)))) +DROP TABLE t1; End of 5.0 tests. diff --git a/mysql-test/r/subselect3.result b/mysql-test/r/subselect3.result index c194ba33756..5221fa09744 100644 --- a/mysql-test/r/subselect3.result +++ b/mysql-test/r/subselect3.result @@ -770,4 +770,13 @@ SELECT ROW(1, 2) IN (SELECT t1.a, 2 FROM t2) FROM t1 GROUP BY t1.a; ROW(1, 2) IN (SELECT t1.a, 2 FROM t2) 1 DROP TABLE t1, t2; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 SELECT * FROM t1; +SELECT 1 FROM t1 WHERE t1.a NOT IN (SELECT 1 FROM t1, t2 WHERE 0); +1 +1 +1 +1 +DROP TABLE t1, t2; End of 5.0 tests diff --git a/mysql-test/r/type_binary.result b/mysql-test/r/type_binary.result index aaa46ab415e..debf4ff8fb8 100644 --- a/mysql-test/r/type_binary.result +++ b/mysql-test/r/type_binary.result @@ -125,7 +125,6 @@ create table t1 (c char(2), vc varchar(2)); insert into t1 values(0x4120, 0x4120); insert into t1 values(0x412020, 0x412020); Warnings: -Note 1265 Data truncated for column 'c' at row 1 Note 1265 Data truncated for column 'vc' at row 1 drop table t1; set @old_sql_mode= @@sql_mode, sql_mode= 'traditional'; diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index 2afd42f702e..03fbc898cc5 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -946,4 +946,11 @@ SELECT ROUND(20061108085411.000002); ROUND(20061108085411.000002) 20061108085411 DROP TABLE t1, t2, t3, t4, t5, t6; +create table t1(`c` decimal(9,2)); +insert into t1 values (300),(201.11); +select max(case 1 when 1 then c else null end) from t1 group by c; +max(case 1 when 1 then c else null end) +201.11 +300.00 +drop table t1; End of 5.0 tests diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result index e74f92205aa..94170a04674 100644 --- a/mysql-test/r/warnings.result +++ b/mysql-test/r/warnings.result @@ -305,7 +305,6 @@ set @q = repeat('q', 256); set sql_mode = ''; insert into t1 values(@c, @c, @c); Warnings: -Note 1265 Data truncated for column 'c_char' at row 1 Note 1265 Data truncated for column 'c_varchar' at row 1 Note 1265 Data truncated for column 'c_tinytext' at row 1 insert into t2 values(@c); @@ -322,7 +321,6 @@ Warning 1265 Data truncated for column 'c_tinyblob' at row 1 set sql_mode = 'traditional'; insert into t1 values(@c, @c, @c); Warnings: -Note 1265 Data truncated for column 'c_char' at row 1 Note 1265 Data truncated for column 'c_varchar' at row 1 Note 1265 Data truncated for column 'c_tinytext' at row 1 insert into t2 values(@c); diff --git a/mysql-test/std_data/bug36055.MYD b/mysql-test/std_data/bug36055.MYD new file mode 100644 index 00000000000..4932a077113 Binary files /dev/null and b/mysql-test/std_data/bug36055.MYD differ diff --git a/mysql-test/std_data/bug36055.MYI b/mysql-test/std_data/bug36055.MYI new file mode 100644 index 00000000000..531c505c102 Binary files /dev/null and b/mysql-test/std_data/bug36055.MYI differ diff --git a/mysql-test/std_data/bug36055.frm b/mysql-test/std_data/bug36055.frm new file mode 100644 index 00000000000..11c9cb31dad Binary files /dev/null and b/mysql-test/std_data/bug36055.frm differ diff --git a/mysql-test/t/ctype_gbk.test b/mysql-test/t/ctype_gbk.test index 3ea696338dc..91fe50d89b9 100644 --- a/mysql-test/t/ctype_gbk.test +++ b/mysql-test/t/ctype_gbk.test @@ -53,4 +53,18 @@ alter table t1 change c1 c1 mediumtext character set gbk not null; show create table t1; drop table t1; +# +# Bug#35993: severe memory corruption and crash with multibyte conversion +# + +CREATE TABLE t1(a MEDIUMTEXT CHARACTER SET gbk, + b MEDIUMTEXT CHARACTER SET big5); +INSERT INTO t1 VALUES + (REPEAT(0x1125,200000), REPEAT(0x1125,200000)), ('', ''), ('', ''); + +SELECT a FROM t1 GROUP BY 1 LIMIT 1 INTO @nullll; +SELECT b FROM t1 GROUP BY 1 LIMIT 1 INTO @nullll; + +DROP TABLES t1; + --echo End of 5.0 tests diff --git a/mysql-test/t/func_concat.test b/mysql-test/t/func_concat.test index 5487ad9c56b..f2aa0d004e5 100644 --- a/mysql-test/t/func_concat.test +++ b/mysql-test/t/func_concat.test @@ -68,3 +68,13 @@ create table t1(f1 varchar(6)) charset=utf8; insert into t1 values ("123456"); select concat(f1, 2) a from t1 union select 'x' a from t1; drop table t1; + +# +# Bug #36488: regexp returns false matches, concatenating with previous rows +# +CREATE TABLE t1 (c1 varchar(100), c2 varchar(100)); +INSERT INTO t1 VALUES ('',''), ('','First'), ('Random','Random'); +SELECT * FROM t1 WHERE CONCAT(c1,' ',c2) REGEXP 'First.*'; +DROP TABLE t1; + +--echo # End of 5.0 tests diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 87632fbdbb8..816ac9c2959 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -657,4 +657,40 @@ SELECT s1.d1 FROM ) AS s1; DROP TABLE t1; +# +# Bug #35298: GROUP_CONCAT with DISTINCT can crash the server +# + +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); + +INSERT INTO t1 VALUES(1); + +SELECT GROUP_CONCAT(DISTINCT t2.a) FROM t1 LEFT JOIN t2 ON t2.a = t1.a GROUP BY t1.a; + +DROP TABLE t1, t2; + +# +# Bug #36024: group_concat distinct in subquery crash +# + +CREATE TABLE t1 (a INT, KEY(a)); +CREATE TABLE t2 (b INT); + +INSERT INTO t1 VALUES (NULL), (8), (2); +INSERT INTO t2 VALUES (4), (10); + +SELECT 1 FROM t1 WHERE t1.a NOT IN +( + SELECT GROUP_CONCAT(DISTINCT t1.a) + FROM t1 WHERE t1.a IN + ( + SELECT b FROM t2 + ) + AND NOT t1.a >= (SELECT t1.a FROM t1 LIMIT 1) + GROUP BY t1.a +); + +DROP TABLE t1, t2; + --echo End of 5.0 tests diff --git a/mysql-test/t/multi_update_tiny_hash-master.opt b/mysql-test/t/multi_update_tiny_hash-master.opt new file mode 100644 index 00000000000..d81cc55090d --- /dev/null +++ b/mysql-test/t/multi_update_tiny_hash-master.opt @@ -0,0 +1 @@ +--set-variable=max_heap_table_size=16384 diff --git a/mysql-test/t/multi_update_tiny_hash.test b/mysql-test/t/multi_update_tiny_hash.test new file mode 100644 index 00000000000..10d469fb076 --- /dev/null +++ b/mysql-test/t/multi_update_tiny_hash.test @@ -0,0 +1,61 @@ +# +# Test of update statement that uses many tables, +# --max_heap_table_size=1 +# + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings + +--echo # +--echo # Bug #36676: multiupdate using LEFT JOIN updates only +--echo # first row or fails with an error: +--echo # ERROR 1022 (23000): Can't write; duplicate key in table '' +--echo # + +--echo + +--echo # +--echo # Multiupdate creates MyISAM temporary table without MEMORY table +--echo # + +CREATE TABLE t1 (ID INT); +CREATE TABLE t2 (ID INT, + s1 TEXT, s2 TEXT, s3 VARCHAR(10), s4 TEXT, s5 VARCHAR(10)); + +INSERT INTO t1 VALUES (1),(2); +INSERT INTO t2 VALUES (1,'test', 'test', 'test', 'test', 'test'), + (2,'test', 'test', 'test', 'test', 'test'); + +SELECT * FROM t1 LEFT JOIN t2 USING(ID); +UPDATE t1 LEFT JOIN t2 USING(ID) SET s1 = 'changed'; +UPDATE t1 JOIN t2 USING(ID) SET s2 = 'changed'; +UPDATE t1 LEFT JOIN t2 USING(ID) SET s3 = 'changed'; +UPDATE t1 LEFT JOIN t2 USING(ID) SET s4 = 'changed', s5 = 'changed'; +SELECT * FROM t1 LEFT JOIN t2 USING(ID); + +DROP TABLE t1, t2; + +--echo # +--echo # Multiupdate creates temporary MyISAM table from MEMORY table +--echo # + +CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY); +CREATE TABLE t2 (id INT, s1 CHAR(255)); + +# insert [1..64] into table `t1` +INSERT INTO t1 VALUES (0), (0), (0), (0), (0), (0), (0), (0); +INSERT INTO t1 (SELECT 0 FROM t1); +INSERT INTO t1 (SELECT 0 FROM t1); +INSERT INTO t1 (SELECT 0 FROM t1); + +INSERT INTO t2 (SELECT ID, 'a' FROM t1); + +UPDATE t1 LEFT JOIN t2 USING(id) SET s1 = 'b'; + +SELECT DISTINCT s1 FROM t1 LEFT JOIN t2 USING(id); + +DROP TABLE t1, t2; + + +--echo # End of 5.0 tests diff --git a/mysql-test/t/repair.test b/mysql-test/t/repair.test index 9870e1749b3..4af0895827c 100644 --- a/mysql-test/t/repair.test +++ b/mysql-test/t/repair.test @@ -113,3 +113,33 @@ SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size; DROP TABLE t1; --echo End of 4.1 tests + +# +# BUG#36055 - mysql_upgrade doesn't really 'upgrade' tables +# + +--echo # Test with a saved table from 4.1 +--copy_file std_data/bug36055.frm $MYSQLTEST_VARDIR/master-data/test/t1.frm +--copy_file std_data/bug36055.MYD $MYSQLTEST_VARDIR/master-data/test/t1.MYD +--copy_file std_data/bug36055.MYI $MYSQLTEST_VARDIR/master-data/test/t1.MYI + +--replace_column 12 # 13 # +SHOW TABLE STATUS LIKE 't1'; +SELECT * FROM t1; + +--echo # Run CHECK TABLE, it should indicate table need a REPAIR TABLE +CHECK TABLE t1 FOR UPGRADE; + +--echo # REPAIR old table USE_FRM should fail +REPAIR TABLE t1 USE_FRM; + +--echo # Run REPAIR TABLE to upgrade .frm file +REPAIR TABLE t1; +--replace_column 12 # 13 # +SHOW TABLE STATUS LIKE 't1'; +SELECT * FROM t1; + +REPAIR TABLE t1 USE_FRM; +SELECT * FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test index f7cd8907e34..f045257d279 100644 --- a/mysql-test/t/rpl_sp.test +++ b/mysql-test/t/rpl_sp.test @@ -577,3 +577,55 @@ set global log_bin_trust_function_creators=0; drop database mysqltest; drop database mysqltest2; sync_slave_with_master; + +# +# Bug#36570: Parse error of CREATE PROCEDURE stmt with comments on slave +# +connection master; +use test; +delimiter |; + +/*!50001 create procedure `mysqltestbug36570_p1`() */ +begin + select 1; +end| + +use mysql| +create procedure test.` mysqltestbug36570_p2`(/*!50001 a int*/)`label`: +begin + select a; +end| + +/*!50001 create function test.mysqltestbug36570_f1() */ + returns int + /*!50001 deterministic */ +begin + return 3; +end| +use test| + +delimiter ;| + +--replace_column 5 t 6 t +show procedure status like '%mysqltestbug36570%'; +show create procedure ` mysqltestbug36570_p2`; + +sync_slave_with_master; +connection slave; + +--replace_column 5 t 6 t +show procedure status like '%mysqltestbug36570%'; +show create procedure ` mysqltestbug36570_p2`; +call ` mysqltestbug36570_p2`(42); + +--replace_column 5 t 6 t +show function status like '%mysqltestbug36570%'; + +connection master; +flush logs; +--replace_regex s/$MYSQL_TEST_DIR/MYSQL_TEST_DIR/ s/TIMESTAMP=[0-9]*/TIMESTAMP=t/ +--exec $MYSQL_BINLOG --short-form $MYSQLTEST_VARDIR/log/master-bin.000001 +use test; +drop procedure mysqltestbug36570_p1; +drop procedure ` mysqltestbug36570_p2`; +drop function mysqltestbug36570_f1; diff --git a/mysql-test/t/rpl_view.test b/mysql-test/t/rpl_view.test index 21748586130..44ef0c3e1eb 100644 --- a/mysql-test/t/rpl_view.test +++ b/mysql-test/t/rpl_view.test @@ -161,4 +161,22 @@ DROP VIEW v1; DROP TABLE t1; sync_slave_with_master; +# +# Bug#32575 Parse error of stmt with extended comments on slave side +# Verify that 'CREATE VIEW' with comments is properly logged to binlog +connection master; +CREATE TABLE t1 (a INT); +--echo # create view as output from mysqldump 10.11 (5.0.62) +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where (`t1`.`a` < 3) */ +/*!50002 WITH CASCADED CHECK OPTION */; +SHOW CREATE VIEW v1; +sync_slave_with_master; +SHOW CREATE VIEW v1; +connection master; +DROP VIEW v1; +DROP TABLE t1; +sync_slave_with_master; + --echo End of 5.0 tests diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index c5edd5414e3..78b4de6e816 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -3259,5 +3259,28 @@ GROUP BY a4; DROP TABLE t1, t2, t3, t4; +# +# BUG#36139 "float, zerofill, crash with subquery" +# +create table t1 (a float(5,4) zerofill); +create table t2 (a float(5,4),b float(2,0)); + +select t1.a from t1 where + t1.a= (select b from t2 limit 1) and not + t1.a= (select a from t2 limit 1) ; + +drop table t1, t2; + +# +# Bug #36011: Server crash with explain extended on query with dependent +# subqueries +# + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 GROUP BY a); +EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1 IN (SELECT 1 FROM t1 WHERE a > 3 GROUP BY a); +DROP TABLE t1; + --echo End of 5.0 tests. diff --git a/mysql-test/t/subselect3.test b/mysql-test/t/subselect3.test index cfbde8c29cd..d7bb1f7186a 100644 --- a/mysql-test/t/subselect3.test +++ b/mysql-test/t/subselect3.test @@ -605,4 +605,17 @@ SELECT ROW(1, 2) IN (SELECT t1.a, 2 FROM t2) FROM t1 GROUP BY t1.a; DROP TABLE t1, t2; +# +# Bug #36005: crash in subselect with single row +# (subselect_single_select_engine::exec) +# + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 SELECT * FROM t1; + +SELECT 1 FROM t1 WHERE t1.a NOT IN (SELECT 1 FROM t1, t2 WHERE 0); + +DROP TABLE t1, t2; + --echo End of 5.0 tests diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index 6841b3cdd68..8a81908296f 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -521,4 +521,12 @@ SELECT ROUND(20061108085411.000002); DROP TABLE t1, t2, t3, t4, t5, t6; +# +# Bug#36023: Incorrect handling of zero length caused an assertion to fail. +# +create table t1(`c` decimal(9,2)); +insert into t1 values (300),(201.11); +select max(case 1 when 1 then c else null end) from t1 group by c; +drop table t1; + --echo End of 5.0 tests diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index d11883a4ea4..94ef309097a 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -14,8 +14,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* To avoid problems with alarms in debug code, we disable DBUG here */ -#undef DBUG_OFF -#define DBUG_OFF +#define FORCE_DBUG_OFF #include #if defined(THREAD) && !defined(DONT_USE_THR_ALARM) diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 68af030f17a..50cff8578c9 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -293,21 +293,15 @@ $CP mysql-test/t/*.def $BASE/mysql-test/t $CP mysql-test/include/*.inc $BASE/mysql-test/include $CP mysql-test/include/*.test $BASE/mysql-test/include $CP mysql-test/t/*.def $BASE/mysql-test/t -$CP mysql-test/std_data/*.dat mysql-test/std_data/*.frm \ - mysql-test/std_data/*.MYD mysql-test/std_data/*.MYI \ - mysql-test/std_data/*.pem mysql-test/std_data/Moscow_leap \ - mysql-test/std_data/Index.xml \ - mysql-test/std_data/des_key_file mysql-test/std_data/*.*001 \ - mysql-test/std_data/*.cnf mysql-test/std_data/*.MY* \ - $BASE/mysql-test/std_data $CP mysql-test/t/*.test mysql-test/t/*.imtest \ mysql-test/t/*.disabled mysql-test/t/*.opt \ mysql-test/t/*.slave-mi mysql-test/t/*.sh mysql-test/t/*.sql $BASE/mysql-test/t $CP mysql-test/r/*.result mysql-test/r/*.require \ $BASE/mysql-test/r -# Copy the additional suites "as is", they are in flux -$tar cf - mysql-test/suite | ( cd $BASE ; $tar xf - ) +# Copy the additional suites and data "as is", they are in flux +$tar cf - mysql-test/suite | ( cd $BASE ; $tar xf - ) +$tar cf - mysql-test/std_data | ( cd $BASE ; $tar xf - ) # Clean up if we did this from a bk tree if [ -d mysql-test/SCCS ] ; then find $BASE/mysql-test -name SCCS -print | xargs rm -rf diff --git a/sql/field.cc b/sql/field.cc index 18bb7153060..d840034f8dc 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5868,6 +5868,7 @@ check_string_copy_error(Field_str *field, Field_longstr::report_if_important_data() ptr - Truncated rest of string end - End of truncated string + count_spaces - Treat traling spaces as important data RETURN VALUES 0 - None was truncated (or we don't count cut fields) @@ -5877,10 +5878,12 @@ check_string_copy_error(Field_str *field, Check if we lost any important data (anything in a binary string, or any non-space in others). If only trailing spaces was lost, send a truncation note, otherwise send a truncation error. + Silently ignore traling spaces if the count_space parameter is FALSE. */ int -Field_longstr::report_if_important_data(const char *ptr, const char *end) +Field_longstr::report_if_important_data(const char *ptr, const char *end, + bool count_spaces) { if ((ptr < end) && table->in_use->count_cuted_fields) { @@ -5890,10 +5893,13 @@ Field_longstr::report_if_important_data(const char *ptr, const char *end) set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1); else set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); + return 2; } - else /* If we lost only spaces then produce a NOTE, not a WARNING */ + else if (count_spaces) + { /* If we lost only spaces then produce a NOTE, not a WARNING */ set_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1); - return 2; + return 2; + } } return 0; } @@ -5929,7 +5935,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) cannot_convert_error_pos, from + length)) return 2; - return report_if_important_data(from_end_pos, from + length); + return report_if_important_data(from_end_pos, from + length, FALSE); } @@ -6388,7 +6394,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs) cannot_convert_error_pos, from + length)) return 2; - return report_if_important_data(from_end_pos, from + length); + return report_if_important_data(from_end_pos, from + length, TRUE); } @@ -7025,7 +7031,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) cannot_convert_error_pos, from + length)) return 2; - return report_if_important_data(from_end_pos, from + length); + return report_if_important_data(from_end_pos, from + length, TRUE); oom_error: /* Fatal OOM error */ diff --git a/sql/field.h b/sql/field.h index c82d65147ac..8d771a151a7 100644 --- a/sql/field.h +++ b/sql/field.h @@ -455,7 +455,8 @@ public: class Field_longstr :public Field_str { protected: - int report_if_important_data(const char *ptr, const char *end); + int report_if_important_data(const char *ptr, const char *end, + bool count_spaces); public: Field_longstr(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, diff --git a/sql/handler.cc b/sql/handler.cc index bfad10f986f..0de772e366b 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1980,6 +1980,8 @@ int handler::ha_check_for_upgrade(HA_CHECK_OPT *check_opt) } } } + if (table->s->frm_version != FRM_VER_TRUE_VARCHAR) + return HA_ADMIN_NEEDS_ALTER; return check_for_upgrade(check_opt); } @@ -2348,8 +2350,8 @@ int ha_init_key_cache(const char *name, KEY_CACHE *key_cache) if (!key_cache->key_cache_inited) { pthread_mutex_lock(&LOCK_global_system_variables); - long tmp_buff_size= (long) key_cache->param_buff_size; - long tmp_block_size= (long) key_cache->param_block_size; + ulong tmp_buff_size= (ulong) key_cache->param_buff_size; + uint tmp_block_size= (uint) key_cache->param_block_size; uint division_limit= key_cache->param_division_limit; uint age_threshold= key_cache->param_age_threshold; pthread_mutex_unlock(&LOCK_global_system_variables); diff --git a/sql/item.cc b/sql/item.cc index 553ba1b152c..9ff1f8c0084 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4156,9 +4156,14 @@ static void convert_zerofill_number_to_string(Item **item, Field_num *field) String tmp(buff,sizeof(buff), field->charset()), *res; res= (*item)->val_str(&tmp); - field->prepend_zeros(res); - pos= (char *) sql_strmake (res->ptr(), res->length()); - *item= new Item_string(pos, res->length(), field->charset()); + if ((*item)->is_null()) + *item= new Item_null(); + else + { + field->prepend_zeros(res); + pos= (char *) sql_strmake (res->ptr(), res->length()); + *item= new Item_string(pos, res->length(), field->charset()); + } } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 4e72f117869..c443364ce52 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -294,6 +294,12 @@ String *Item_func_concat::val_str(String *str) { if (!(res=args[i]->val_str(str))) goto null; + /* + CONCAT accumulates its result in the result of its the first + non-empty argument. Because of this we need is_const to be + evaluated only for it. + */ + is_const= args[i]->const_item() || !args[i]->used_tables(); } else { diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 91f9889b03f..91320d6b56b 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3222,7 +3222,7 @@ void Item_func_group_concat::clear() no_appended= TRUE; if (tree) reset_tree(tree); - if (distinct) + if (unique_filter) unique_filter->reset(); /* No need to reset the table as we never call write_row */ } diff --git a/sql/my_decimal.h b/sql/my_decimal.h index c661579ea66..6a0d05921ec 100644 --- a/sql/my_decimal.h +++ b/sql/my_decimal.h @@ -164,14 +164,23 @@ inline int check_result_and_overflow(uint mask, int result, my_decimal *val) inline uint my_decimal_length_to_precision(uint length, uint scale, bool unsigned_flag) { - return (uint) (length - (scale>0 ? 1:0) - (unsigned_flag ? 0:1)); + /* Precision can't be negative thus ignore unsigned_flag when length is 0. */ + DBUG_ASSERT(length || !scale); + return (uint) (length - (scale>0 ? 1:0) - + (unsigned_flag || !length ? 0:1)); } inline uint32 my_decimal_precision_to_length(uint precision, uint8 scale, bool unsigned_flag) { + /* + When precision is 0 it means that original length was also 0. Thus + unsigned_flag is ignored in this case. + */ + DBUG_ASSERT(precision || !scale); set_if_smaller(precision, DECIMAL_MAX_PRECISION); - return (uint32)(precision + (scale>0 ? 1:0) + (unsigned_flag ? 0:1)); + return (uint32)(precision + (scale>0 ? 1:0) + + (unsigned_flag || !precision ? 0:1)); } inline diff --git a/sql/sp.cc b/sql/sp.cc index 7224d3c4f0e..2392cabb220 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -25,7 +25,8 @@ static bool create_string(THD *thd, String *buf, int sp_type, - sp_name *name, + const char *db, ulong dblen, + const char *name, ulong namelen, const char *params, ulong paramslen, const char *returns, ulong returnslen, const char *body, ulong bodylen, @@ -426,12 +427,13 @@ db_load_routine(THD *thd, int type, sp_name *name, sp_head **sphp, */ if (!create_string(thd, &defstr, - type, - name, - params, strlen(params), - returns, strlen(returns), - body, strlen(body), - &chistics, &definer_user_name, &definer_host_name)) + type, + NULL, 0, + name->m_name.str, name->m_name.length, + params, strlen(params), + returns, strlen(returns), + body, strlen(body), + &chistics, &definer_user_name, &definer_host_name)) { ret= SP_INTERNAL_ERROR; goto end; @@ -518,6 +520,7 @@ db_create_routine(THD *thd, int type, sp_head *sp) DBUG_ENTER("db_create_routine"); DBUG_PRINT("enter", ("type: %d name: %.*s",type,sp->m_name.length, sp->m_name.str)); + String retstr(64); if (!(table= open_proc_table_for_update(thd))) ret= SP_OPEN_TABLE_FAILED; @@ -568,7 +571,6 @@ db_create_routine(THD *thd, int type, sp_head *sp) store(sp->m_params.str, sp->m_params.length, system_charset_info); if (sp->m_type == TYPE_ENUM_FUNCTION) { - String retstr(64); sp_returns_type(thd, retstr, sp); table->field[MYSQL_PROC_FIELD_RETURNS]-> store(retstr.ptr(), retstr.length(), system_charset_info); @@ -625,13 +627,21 @@ db_create_routine(THD *thd, int type, sp_head *sp) String log_query; log_query.set_charset(system_charset_info); - log_query.append(STRING_WITH_LEN("CREATE ")); - append_definer(thd, &log_query, &thd->lex->definer->user, - &thd->lex->definer->host); - log_query.append(thd->lex->stmt_definition_begin, - (char *)sp->m_body_begin - - thd->lex->stmt_definition_begin + - sp->m_body.length); + + if (!create_string(thd, &log_query, + sp->m_type, + (sp->m_explicit_name ? sp->m_db.str : NULL), + (sp->m_explicit_name ? sp->m_db.length : 0), + sp->m_name.str, sp->m_name.length, + sp->m_params.str, sp->m_params.length, + retstr.c_ptr(), retstr.length(), + sp->m_body.str, sp->m_body.length, + sp->m_chistics, &(thd->lex->definer->user), + &(thd->lex->definer->host))) + { + ret= SP_INTERNAL_ERROR; + goto done; + } /* Such a statement can always go directly to binlog, no trans cache */ Query_log_event qinfo(thd, log_query.c_ptr(), log_query.length(), 0, @@ -1797,17 +1807,18 @@ sp_cache_routines_and_add_tables_for_triggers(THD *thd, LEX *lex, */ static bool create_string(THD *thd, String *buf, - int type, - sp_name *name, - const char *params, ulong paramslen, - const char *returns, ulong returnslen, - const char *body, ulong bodylen, - st_sp_chistics *chistics, + int type, + const char *db, ulong dblen, + const char *name, ulong namelen, + const char *params, ulong paramslen, + const char *returns, ulong returnslen, + const char *body, ulong bodylen, + st_sp_chistics *chistics, const LEX_STRING *definer_user, const LEX_STRING *definer_host) { /* Make some room to begin with */ - if (buf->alloc(100 + name->m_qname.length + paramslen + returnslen + bodylen + + if (buf->alloc(100 + dblen + 1 + namelen + paramslen + returnslen + bodylen + chistics->comment.length + 10 /* length of " DEFINER= "*/ + USER_HOST_BUFF_SIZE)) return FALSE; @@ -1818,7 +1829,12 @@ create_string(THD *thd, String *buf, buf->append(STRING_WITH_LEN("FUNCTION ")); else buf->append(STRING_WITH_LEN("PROCEDURE ")); - append_identifier(thd, buf, name->m_name.str, name->m_name.length); + if (dblen > 0) + { + append_identifier(thd, buf, db, dblen); + buf->append('.'); + } + append_identifier(thd, buf, name, namelen); buf->append('('); buf->append(params, paramslen); buf->append(')'); diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 46f3d25c441..aea81e301ef 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -522,6 +522,8 @@ sp_head::init(LEX *lex) m_qname.str= NULL; m_qname.length= 0; + m_explicit_name= false; + m_db.str= NULL; m_db.length= 0; @@ -564,6 +566,8 @@ sp_head::init_sp_name(THD *thd, sp_name *spname) m_name.str= strmake_root(thd->mem_root, spname->m_name.str, spname->m_name.length); + m_explicit_name= spname->m_explicit_name; + if (spname->m_qname.length == 0) spname->init_qname(thd); diff --git a/sql/sp_head.h b/sql/sp_head.h index 0e710196603..11ff7160c03 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -121,6 +121,7 @@ public: st_sp_chistics *m_chistics; ulong m_sql_mode; // For SHOW CREATE and execution LEX_STRING m_qname; // db.name + bool m_explicit_name; /**< Prepend the db name? */ /** Key representing routine in the set of stored routines used by statement. [routine_type]db.name\0 diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 976d7322f56..d1e5837329b 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -832,6 +832,7 @@ JOIN::optimize() "Impossible HAVING" : "Impossible WHERE")); zero_result_cause= having_value == Item::COND_FALSE ? "Impossible HAVING" : "Impossible WHERE"; + tables= 0; error= 0; DBUG_RETURN(0); } @@ -2103,11 +2104,12 @@ JOIN::exec() /* With EXPLAIN EXTENDED we have to restore original ref_array for a derived table which is always materialized. - Otherwise we would not be able to print the query correctly. + We also need to do this when we have temp table(s). + Otherwise we would not be able to print the query correctly. */ - if (items0 && - (thd->lex->describe & DESCRIBE_EXTENDED) && - select_lex->linkage == DERIVED_TABLE_TYPE) + if (items0 && (thd->lex->describe & DESCRIBE_EXTENDED) && + (select_lex->linkage == DERIVED_TABLE_TYPE || + exec_tmp_table1 || exec_tmp_table2)) set_items_ref_array(items0); DBUG_VOID_RETURN; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 9e1a8151e3a..f1de63892d5 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2118,6 +2118,13 @@ static int prepare_for_repair(THD* thd, TABLE_LIST *table_list, const char **ext= table->file->bas_ext(); MY_STAT stat_info; + if (table->s->frm_version != FRM_VER_TRUE_VARCHAR) + { + error= send_check_errmsg(thd, table_list, "repair", + "Failed reparing incompatible .FRM file"); + goto end; + } + /* Check if this is a table type that stores index and data separately, like ISAM or MyISAM. We assume fixed order of engine file name diff --git a/sql/sql_update.cc b/sql/sql_update.cc index a8238141f25..6830564111b 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1440,6 +1440,12 @@ bool multi_update::send_data(List ¬_used_values) tbl->file->position(tbl->record[0]); memcpy((char*) tmp_table->field[field_num]->ptr, (char*) tbl->file->ref, tbl->file->ref_length); + /* + For outer joins a rowid field may have no NOT_NULL_FLAG, + so we have to reset NULL bit for this field. + (set_notnull() resets NULL bit only if available). + */ + tmp_table->field[field_num]->set_notnull(); field_num++; } while ((tbl= tbl_it++)); diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 4c8e6e80c41..de92d6dc3b9 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -649,7 +649,11 @@ bool mysql_create_view(THD *thd, TABLE_LIST *views, buff.append(')'); } buff.append(STRING_WITH_LEN(" AS ")); - buff.append(views->source.str, views->source.length); + buff.append(views->query.str, views->query.length); + if (views->with_check == VIEW_CHECK_LOCAL) + buff.append(STRING_WITH_LEN(" WITH LOCAL CHECK OPTION")); + else if (views->with_check == VIEW_CHECK_CASCADED) + buff.append(STRING_WITH_LEN(" WITH CASCADED CHECK OPTION")); Query_log_event qinfo(thd, buff.ptr(), buff.length(), 0, FALSE); mysql_bin_log.write(&qinfo); @@ -926,8 +930,6 @@ loop_out: } DBUG_RETURN(0); err: - view->query.str= NULL; - view->query.length= 0; view->md5.str= NULL; view->md5.length= 0; DBUG_RETURN(error); diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 44b9951657d..c73247db404 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -307,15 +307,17 @@ static int my_strnxfrm_big5(CHARSET_INFO *cs __attribute__((unused)), { uint16 e; uint dstlen= len; + uchar *dest_end= dest + dstlen; len = srclen; - while (len--) + while (len-- && dest < dest_end) { if ((len > 0) && isbig5code(*src, *(src+1))) { e = big5strokexfrm((uint16) big5code(*src, *(src+1))); *dest++ = big5head(e); - *dest++ = big5tail(e); + if (dest < dest_end) + *dest++ = big5tail(e); src +=2; len--; } else diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index 8ac7d62c9da..d0ba33aa3cc 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -2668,15 +2668,17 @@ static int my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)), { uint16 e; uint dstlen= len; + uchar *dest_end= dest + dstlen; len = srclen; - while (len--) + while (len-- && dest < dest_end) { if ((len > 0) && isgbkcode(*src, *(src+1))) { e = gbksortorder((uint16) gbkcode(*src, *(src+1))); *dest++ = gbkhead(e); - *dest++ = gbktail(e); + if (dest < dest_end) + *dest++ = gbktail(e); src+=2; len--; } else