summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/mysql.cc7
-rw-r--r--client/mysqldump.c3
-rw-r--r--include/my_base.h1
-rw-r--r--libmysql/libmysql.c2
-rw-r--r--mysql-test/extra/binlog_tests/ctype_cp932.test22
-rw-r--r--mysql-test/include/index_merge1.inc48
-rw-r--r--mysql-test/include/mix1.inc24
-rw-r--r--mysql-test/r/ctype_big5.result6
-rw-r--r--mysql-test/r/ctype_collate.result8
-rw-r--r--mysql-test/r/ctype_latin1.result4
-rw-r--r--mysql-test/r/ctype_ucs.result10
-rw-r--r--mysql-test/r/func_gconcat.result9
-rw-r--r--mysql-test/r/gis-rtree.result13
-rw-r--r--mysql-test/r/index_merge_myisam.result61
-rw-r--r--mysql-test/r/innodb_mysql.result28
-rw-r--r--mysql-test/r/join_nested.result111
-rw-r--r--mysql-test/r/mysqldump.result35
-rw-r--r--mysql-test/r/symlink.result22
-rw-r--r--mysql-test/r/type_enum.result20
-rw-r--r--mysql-test/r/type_ranges.result4
-rw-r--r--mysql-test/r/type_time.result43
-rw-r--r--mysql-test/suite/binlog/r/binlog_row_ctype_cp932.result16
-rwxr-xr-xmysql-test/suite/binlog/r/binlog_stm_ctype_cp932.result16
-rw-r--r--mysql-test/suite/rpl/include/rpl_mixed_ddl.inc2
-rw-r--r--mysql-test/suite/rpl/include/rpl_mixed_dml.inc4
-rw-r--r--mysql-test/suite/rpl/r/rpl_innodb_mixed_ddl.result2
-rw-r--r--mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result12
-rw-r--r--mysql-test/suite/rpl/t/rpl_innodb_mixed_ddl.test3
-rw-r--r--mysql-test/suite/rpl/t/rpl_innodb_mixed_dml.test3
-rw-r--r--mysql-test/t/create_not_windows.test1
-rw-r--r--mysql-test/t/ctype_big5.test7
-rw-r--r--mysql-test/t/ctype_collate.test11
-rw-r--r--mysql-test/t/ctype_latin1.test6
-rw-r--r--mysql-test/t/ctype_ucs.test10
-rw-r--r--mysql-test/t/func_gconcat.test11
-rw-r--r--mysql-test/t/gis-rtree.test19
-rw-r--r--mysql-test/t/join_nested.test114
-rw-r--r--mysql-test/t/mysqldump.test13
-rw-r--r--mysql-test/t/symlink.test39
-rw-r--r--mysql-test/t/type_enum.test17
-rw-r--r--mysql-test/t/type_time.test37
-rw-r--r--mysys/my_conio.c8
-rw-r--r--mysys/my_symlink2.c2
-rw-r--r--scripts/make_binary_distribution.sh1
-rw-r--r--sql/field.cc3
-rw-r--r--sql/field_conv.cc17
-rw-r--r--sql/filesort.cc3
-rw-r--r--sql/item_cmpfunc.cc110
-rw-r--r--sql/item_cmpfunc.h2
-rw-r--r--sql/item_sum.cc1
-rw-r--r--sql/opt_range.cc40
-rw-r--r--sql/set_var.cc2
-rw-r--r--sql/share/charsets/ascii.xml2
-rw-r--r--sql/sql_class.h1
-rw-r--r--sql/sql_insert.cc3
-rw-r--r--sql/sql_select.cc10
-rw-r--r--sql/sql_table.cc3
-rw-r--r--sql/sql_update.cc11
-rw-r--r--sql/unireg.cc2
-rw-r--r--storage/heap/ha_heap.cc20
-rw-r--r--storage/heap/ha_heap.h9
-rw-r--r--storage/myisam/ha_myisam.cc2
-rw-r--r--storage/myisam/mi_create.c4
-rw-r--r--storage/myisam/sp_key.c71
-rw-r--r--strings/conf_to_src.c23
-rw-r--r--strings/ctype-cp932.c14
-rw-r--r--strings/ctype-extra.c19
-rw-r--r--strings/ctype-simple.c2
-rw-r--r--strings/ctype-utf8.c29
-rw-r--r--tests/mysql_client_test.c33
70 files changed, 1132 insertions, 139 deletions
diff --git a/client/mysql.cc b/client/mysql.cc
index 7970fa4db2f..fe057c8b8a4 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -1089,7 +1089,12 @@ static int read_and_execute(bool interactive)
something else is still in console input buffer
*/
} while (tmpbuf.alloced_length() <= clen);
- line= buffer.c_ptr();
+ /*
+ An empty line is returned from my_cgets when there's error reading :
+ Ctrl-c for example
+ */
+ if (line)
+ line= buffer.c_ptr();
#endif /* __NETWARE__ */
#else
if (opt_outfile)
diff --git a/client/mysqldump.c b/client/mysqldump.c
index fe7c03fe77e..0f30ebddacc 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -4458,10 +4458,9 @@ static my_bool get_view_structure(char *table, char* db)
result_table);
check_io(sql_file);
}
+ fprintf(sql_file, "/*!50001 DROP TABLE %s*/;\n", opt_quoted_table);
if (opt_drop)
{
- fprintf(sql_file, "/*!50001 DROP TABLE IF EXISTS %s*/;\n",
- opt_quoted_table);
fprintf(sql_file, "/*!50001 DROP VIEW IF EXISTS %s*/;\n",
opt_quoted_table);
check_io(sql_file);
diff --git a/include/my_base.h b/include/my_base.h
index bbc0c0f1f5c..04127b81b78 100644
--- a/include/my_base.h
+++ b/include/my_base.h
@@ -299,6 +299,7 @@ enum ha_base_keytype {
#define HA_PACK_RECORD 2 /* Request packed record format */
#define HA_CREATE_TMP_TABLE 4
#define HA_CREATE_CHECKSUM 8
+#define HA_CREATE_KEEP_FILES 16 /* don't overwrite .MYD and MYI */
#define HA_CREATE_DELAY_KEY_WRITE 64
#define HA_CREATE_RELIES_ON_SQL_LAYER 128
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index a05d061204b..46d0c8f1037 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -4939,7 +4939,7 @@ static my_bool reset_stmt_handle(MYSQL_STMT *stmt, uint flags)
Reset stored result set if so was requested or it's a part
of cursor fetch.
*/
- if (result->data && (flags & RESET_STORE_RESULT))
+ if (flags & RESET_STORE_RESULT)
{
/* Result buffered */
free_root(&result->alloc, MYF(MY_KEEP_PREALLOC));
diff --git a/mysql-test/extra/binlog_tests/ctype_cp932.test b/mysql-test/extra/binlog_tests/ctype_cp932.test
index fc2fa934641..0839f5d43aa 100644
--- a/mysql-test/extra/binlog_tests/ctype_cp932.test
+++ b/mysql-test/extra/binlog_tests/ctype_cp932.test
@@ -404,6 +404,28 @@ SET collation_connection='cp932_bin';
-- source include/ctype_filesort.inc
#
+# Bug#29333 myisam corruption with
+# character set cp932 collate cp932_japanese_ci
+#
+create table t2 (a char(1));
+insert into t2 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
+insert into t2 values ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
+create table t1 (
+ a varchar(2) character set cp932
+) engine=myisam;
+--disable_warnings
+insert into t1
+select unhex(concat(t24.a, t23.a, t22.a, t21.a))
+from t2 t21, t2 t22, t2 t23, t2 t24;
+--enable_warnings
+delete from t1 where a='';
+alter table t1 add key(a);
+check table t1;
+drop table t1;
+drop table t2;
+
+
+#
# Bug#12547: Inserting long string into varchar causes table crash in cp932
#
create table t1 (col1 varchar(1)) character set cp932;
diff --git a/mysql-test/include/index_merge1.inc b/mysql-test/include/index_merge1.inc
index a3a874a8ed2..2ecdbe583c2 100644
--- a/mysql-test/include/index_merge1.inc
+++ b/mysql-test/include/index_merge1.inc
@@ -439,3 +439,51 @@ INSERT INTO t2(a,b) VALUES(1,2);
SELECT t2.a FROM t1,t2 WHERE t2.b=2 AND t2.a=1;
UNLOCK TABLES;
DROP TABLE t1, t2;
+
+#
+# BUG#29740: HA_KEY_SCAN_NOT_ROR wasn't set for HEAP engine
+#
+CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL,
+ `filler` char(200) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ KEY `a` (`a`),
+ KEY `b` (`b`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1;
+
+insert into t1 values
+(0, 'filler', 0), (1, 'filler', 1), (2, 'filler', 2), (3, 'filler', 3),
+(4, 'filler', 4), (5, 'filler', 5), (6, 'filler', 6), (7, 'filler', 7),
+(8, 'filler', 8), (9, 'filler', 9), (0, 'filler', 0), (1, 'filler', 1),
+(2, 'filler', 2), (3, 'filler', 3), (4, 'filler', 4), (5, 'filler', 5),
+(6, 'filler', 6), (7, 'filler', 7), (8, 'filler', 8), (9, 'filler', 9),
+(10, 'filler', 10), (11, 'filler', 11), (12, 'filler', 12), (13, 'filler', 13),
+(14, 'filler', 14), (15, 'filler', 15), (16, 'filler', 16), (17, 'filler', 17),
+(18, 'filler', 18), (19, 'filler', 19), (4, '5 ', 0), (5, '4 ', 0),
+(4, '4 ', 0), (4, 'qq ', 5), (5, 'qq ', 4), (4, 'zz ', 4);
+
+create table t2(
+ `a` int(11) DEFAULT NULL,
+ `filler` char(200) DEFAULT NULL,
+ `b` int(11) DEFAULT NULL,
+ KEY USING BTREE (`a`),
+ KEY USING BTREE (`b`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1;
+insert into t2 select * from t1;
+
+--echo must use sort-union rather than union:
+--replace_column 9 #
+explain select * from t1 where a=4 or b=4;
+--sorted_result
+select * from t1 where a=4 or b=4;
+--sorted_result
+select * from t1 ignore index(a,b) where a=4 or b=4;
+
+--echo must use union, not sort-union:
+--replace_column 9 #
+explain select * from t2 where a=4 or b=4;
+--sorted_result
+select * from t2 where a=4 or b=4;
+
+drop table t1, t2;
+
diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc
index c032aaea50e..e863e59fad6 100644
--- a/mysql-test/include/mix1.inc
+++ b/mysql-test/include/mix1.inc
@@ -917,5 +917,29 @@ unlock tables;
select * from t1;
drop tables t1;
+#
+# Bug#29310: An InnoDB table was updated when the data wasn't actually changed.
+#
+create table t1(f1 varchar(5) unique, f2 timestamp NOT NULL DEFAULT
+ CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
+insert into t1(f1) values(1);
+--replace_column 1 #
+select @a:=f2 from t1;
+--sleep 5
+update t1 set f1=1;
+--replace_column 1 #
+select @b:=f2 from t1;
+select if(@a=@b,"ok","wrong");
+--sleep 5
+insert into t1(f1) values (1) on duplicate key update f1="1";
+--replace_column 1 #
+select @b:=f2 from t1;
+select if(@a=@b,"ok","wrong");
+--sleep 5
+insert into t1(f1) select f1 from t1 on duplicate key update f1="1";
+--replace_column 1 #
+select @b:=f2 from t1;
+select if(@a=@b,"ok","wrong");
+drop table t1;
--echo End of 5.1 tests
diff --git a/mysql-test/r/ctype_big5.result b/mysql-test/r/ctype_big5.result
index 3f1a87838cf..6d318a445f5 100644
--- a/mysql-test/r/ctype_big5.result
+++ b/mysql-test/r/ctype_big5.result
@@ -193,11 +193,13 @@ select hex(convert(_big5 0xC84041 using ucs2));
hex(convert(_big5 0xC84041 using ucs2))
003F0041
End of 4.1 tests
+set names big5;
create table t1 (a blob);
insert into t1 values (0xEE00);
+select * into outfile 'test/t1.txt' from t1;
delete from t1;
-select hex(load_file('test/t1.txt'));
-hex(load_file('test/t1.txt'))
+select hex(load_file('MYSQLTEST_VARDIR/master-data/test/t1.txt'));;
+hex(load_file('MYSQLTEST_VARDIR/master-data/test/t1.txt'))
5CEE5C300A
load data infile 't1.txt' into table t1;
select hex(a) from t1;
diff --git a/mysql-test/r/ctype_collate.result b/mysql-test/r/ctype_collate.result
index 5417c9da47e..f476ec68371 100644
--- a/mysql-test/r/ctype_collate.result
+++ b/mysql-test/r/ctype_collate.result
@@ -603,3 +603,11 @@ check table t1 extended;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
+create table t1 (a varchar(2) character set latin7 collate latin7_general_ci,key(a));
+insert into t1 set a=0x4c20;
+insert into t1 set a=0x6c;
+insert into t1 set a=0x4c98;
+check table t1 extended;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+drop table t1;
diff --git a/mysql-test/r/ctype_latin1.result b/mysql-test/r/ctype_latin1.result
index 32871563b64..763acd0fea0 100644
--- a/mysql-test/r/ctype_latin1.result
+++ b/mysql-test/r/ctype_latin1.result
@@ -405,3 +405,7 @@ i
1
2
DROP TABLE `abcÿdef`;
+select hex(cast(_ascii 0x7f as char(1) character set latin1));
+hex(cast(_ascii 0x7f as char(1) character set latin1))
+7F
+End of 5.0 tests
diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result
index 6f1c9d3d52a..3720aa2910b 100644
--- a/mysql-test/r/ctype_ucs.result
+++ b/mysql-test/r/ctype_ucs.result
@@ -886,4 +886,14 @@ collation(group_concat(a separator ','))
latin1_swedish_ci
drop table t1;
set names latin1;
+create table t1 (s1 char(1) character set ascii, s2 char(1) character set ucs2);
+insert into t1 (s1) values (0x7f);
+update t1 set s2 = s1;
+select hex(s2) from t1;
+hex(s2)
+007F
+select hex(convert(s1 using latin1)) from t1;
+hex(convert(s1 using latin1))
+7F
+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 3fd204c84c9..b17c5e5409c 100644
--- a/mysql-test/r/func_gconcat.result
+++ b/mysql-test/r/func_gconcat.result
@@ -816,4 +816,13 @@ LENGTH( GROUP_CONCAT( a ) )
65535
SET group_concat_max_len= DEFAULT;
DROP TABLE t1, t2, t3;
+set names latin1;
+create table t1 (id int, name varchar(20)) DEFAULT CHARSET=utf8;
+insert into t1 (id, name) values (1, "óra");
+insert into t1 (id, name) values (2, "óra");
+select b.id, group_concat(b.name) from t1 a, t1 b group by b.id;
+id group_concat(b.name)
+1 óra,óra
+2 óra,óra
+drop table t1;
End of 5.0 tests
diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result
index a3955e8c008..6e3aebe8d47 100644
--- a/mysql-test/r/gis-rtree.result
+++ b/mysql-test/r/gis-rtree.result
@@ -1444,3 +1444,16 @@ OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
DROP TABLE t1;
+CREATE TABLE t1 (a INT, b GEOMETRY NOT NULL, SPATIAL KEY b(b));
+INSERT INTO t1 VALUES (1, GEOMFROMTEXT('LINESTRING(1102218.456 1,2000000 2)'));
+INSERT INTO t1 VALUES (2, GEOMFROMTEXT('LINESTRING(1102218.456 1,2000000 2)'));
+SELECT COUNT(*) FROM t1 WHERE
+MBRINTERSECTS(b, GEOMFROMTEXT('LINESTRING(1 1,1102219 2)') );
+COUNT(*)
+2
+SELECT COUNT(*) FROM t1 IGNORE INDEX (b) WHERE
+MBRINTERSECTS(b, GEOMFROMTEXT('LINESTRING(1 1,1102219 2)') );
+COUNT(*)
+2
+DROP TABLE t1;
+End of 5.0 tests.
diff --git a/mysql-test/r/index_merge_myisam.result b/mysql-test/r/index_merge_myisam.result
index f135d849f76..9d7d06f7f1b 100644
--- a/mysql-test/r/index_merge_myisam.result
+++ b/mysql-test/r/index_merge_myisam.result
@@ -457,6 +457,67 @@ a
1
UNLOCK TABLES;
DROP TABLE t1, t2;
+CREATE TABLE `t1` (
+`a` int(11) DEFAULT NULL,
+`filler` char(200) DEFAULT NULL,
+`b` int(11) DEFAULT NULL,
+KEY `a` (`a`),
+KEY `b` (`b`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1;
+insert into t1 values
+(0, 'filler', 0), (1, 'filler', 1), (2, 'filler', 2), (3, 'filler', 3),
+(4, 'filler', 4), (5, 'filler', 5), (6, 'filler', 6), (7, 'filler', 7),
+(8, 'filler', 8), (9, 'filler', 9), (0, 'filler', 0), (1, 'filler', 1),
+(2, 'filler', 2), (3, 'filler', 3), (4, 'filler', 4), (5, 'filler', 5),
+(6, 'filler', 6), (7, 'filler', 7), (8, 'filler', 8), (9, 'filler', 9),
+(10, 'filler', 10), (11, 'filler', 11), (12, 'filler', 12), (13, 'filler', 13),
+(14, 'filler', 14), (15, 'filler', 15), (16, 'filler', 16), (17, 'filler', 17),
+(18, 'filler', 18), (19, 'filler', 19), (4, '5 ', 0), (5, '4 ', 0),
+(4, '4 ', 0), (4, 'qq ', 5), (5, 'qq ', 4), (4, 'zz ', 4);
+create table t2(
+`a` int(11) DEFAULT NULL,
+`filler` char(200) DEFAULT NULL,
+`b` int(11) DEFAULT NULL,
+KEY USING BTREE (`a`),
+KEY USING BTREE (`b`)
+) ENGINE=MEMORY DEFAULT CHARSET=latin1;
+insert into t2 select * from t1;
+must use sort-union rather than union:
+explain select * from t1 where a=4 or b=4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index_merge a,b a,b 5,5 NULL # Using sort_union(a,b); Using where
+select * from t1 where a=4 or b=4;
+a filler b
+4 4 0
+4 5 0
+4 filler 4
+4 filler 4
+4 qq 5
+4 zz 4
+5 qq 4
+select * from t1 ignore index(a,b) where a=4 or b=4;
+a filler b
+4 4 0
+4 5 0
+4 filler 4
+4 filler 4
+4 qq 5
+4 zz 4
+5 qq 4
+must use union, not sort-union:
+explain select * from t2 where a=4 or b=4;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index_merge a,b a,b 5,5 NULL # Using union(a,b); Using where
+select * from t2 where a=4 or b=4;
+a filler b
+4 4 0
+4 5 0
+4 filler 4
+4 filler 4
+4 qq 5
+4 zz 4
+5 qq 4
+drop table t1, t2;
#---------------- ROR-index_merge tests -----------------------
SET SESSION STORAGE_ENGINE = MyISAM;
drop table if exists t0,t1,t2;
diff --git a/mysql-test/r/innodb_mysql.result b/mysql-test/r/innodb_mysql.result
index 9494a04f593..3dc134352db 100644
--- a/mysql-test/r/innodb_mysql.result
+++ b/mysql-test/r/innodb_mysql.result
@@ -918,4 +918,32 @@ NULL
1
Two
drop tables t1;
+create table t1(f1 varchar(5) unique, f2 timestamp NOT NULL DEFAULT
+CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
+insert into t1(f1) values(1);
+select @a:=f2 from t1;
+@a:=f2
+#
+update t1 set f1=1;
+select @b:=f2 from t1;
+@b:=f2
+#
+select if(@a=@b,"ok","wrong");
+if(@a=@b,"ok","wrong")
+ok
+insert into t1(f1) values (1) on duplicate key update f1="1";
+select @b:=f2 from t1;
+@b:=f2
+#
+select if(@a=@b,"ok","wrong");
+if(@a=@b,"ok","wrong")
+ok
+insert into t1(f1) select f1 from t1 on duplicate key update f1="1";
+select @b:=f2 from t1;
+@b:=f2
+#
+select if(@a=@b,"ok","wrong");
+if(@a=@b,"ok","wrong")
+ok
+drop table t1;
End of 5.1 tests
diff --git a/mysql-test/r/join_nested.result b/mysql-test/r/join_nested.result
index 2dd9af8719e..2bdac08e7fd 100644
--- a/mysql-test/r/join_nested.result
+++ b/mysql-test/r/join_nested.result
@@ -1632,4 +1632,115 @@ INSERT INTO t3 VALUES (1,1);
SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a);
ERROR 23000: Column 'a' in from clause is ambiguous
DROP TABLE t1,t2,t3;
+CREATE TABLE t1 (
+carrier char(2) default NULL,
+id int NOT NULL auto_increment PRIMARY KEY
+);
+INSERT INTO t1 VALUES
+('CO',235371754),('CO',235376554),('CO',235376884),('CO',235377874),
+('CO',231060394),('CO',231059224),('CO',231059314),('CO',231060484),
+('CO',231060274),('CO',231060124),('CO',231060244),('CO',231058594),
+('CO',231058924),('CO',231058504),('CO',231059344),('CO',231060424),
+('CO',231059554),('CO',231060304),('CO',231059644),('CO',231059464),
+('CO',231059764),('CO',231058294),('CO',231058624),('CO',231058864),
+('CO',231059374),('CO',231059584),('CO',231059734),('CO',231059014),
+('CO',231059854),('CO',231059494),('CO',231059794),('CO',231058534),
+('CO',231058324),('CO',231058684),('CO',231059524),('CO',231059974);
+CREATE TABLE t2 (
+scan_date date default NULL,
+package_id int default NULL,
+INDEX scan_date(scan_date),
+INDEX package_id(package_id)
+);
+INSERT INTO t2 VALUES
+('2008-12-29',231062944),('2008-12-29',231065764),('2008-12-29',231066124),
+('2008-12-29',231060094),('2008-12-29',231061054),('2008-12-29',231065644),
+('2008-12-29',231064384),('2008-12-29',231064444),('2008-12-29',231073774),
+('2008-12-29',231058594),('2008-12-29',231059374),('2008-12-29',231066004),
+('2008-12-29',231068494),('2008-12-29',231070174),('2008-12-29',231071884),
+('2008-12-29',231063274),('2008-12-29',231063754),('2008-12-29',231064144),
+('2008-12-29',231069424),('2008-12-29',231073714),('2008-12-29',231058414),
+('2008-12-29',231060994),('2008-12-29',231069154),('2008-12-29',231068614),
+('2008-12-29',231071464),('2008-12-29',231074014),('2008-12-29',231059614),
+('2008-12-29',231059074),('2008-12-29',231059464),('2008-12-29',231069094),
+('2008-12-29',231067294),('2008-12-29',231070144),('2008-12-29',231073804),
+('2008-12-29',231072634),('2008-12-29',231058294),('2008-12-29',231065344),
+('2008-12-29',231066094),('2008-12-29',231069034),('2008-12-29',231058594),
+('2008-12-29',231059854),('2008-12-29',231059884),('2008-12-29',231059914),
+('2008-12-29',231063664),('2008-12-29',231063814),('2008-12-29',231063904);
+CREATE TABLE t3 (
+package_id int default NULL,
+INDEX package_id(package_id)
+);
+INSERT INTO t3 VALUES
+(231058294),(231058324),(231058354),(231058384),(231058414),(231058444),
+(231058474),(231058504),(231058534),(231058564),(231058594),(231058624),
+(231058684),(231058744),(231058804),(231058864),(231058924),(231058954),
+(231059014),(231059074),(231059104),(231059134),(231059164),(231059194),
+(231059224),(231059254),(231059284),(231059314),(231059344),(231059374),
+(231059404),(231059434),(231059464),(231059494),(231059524),(231059554),
+(231059584),(231059614),(231059644),(231059674),(231059704),(231059734),
+(231059764),(231059794),(231059824),(231059854),(231059884),(231059914),
+(231059944),(231059974),(231060004),(231060034),(231060064),(231060094),
+(231060124),(231060154),(231060184),(231060214),(231060244),(231060274),
+(231060304),(231060334),(231060364),(231060394),(231060424),(231060454),
+(231060484),(231060514),(231060544),(231060574),(231060604),(231060634),
+(231060664),(231060694),(231060724),(231060754),(231060784),(231060814),
+(231060844),(231060874),(231060904),(231060934),(231060964),(231060994),
+(231061024),(231061054),(231061084),(231061144),(231061174),(231061204),
+(231061234),(231061294),(231061354),(231061384),(231061414),(231061474),
+(231061564),(231061594),(231061624),(231061684),(231061714),(231061774),
+(231061804),(231061894),(231061984),(231062074),(231062134),(231062224),
+(231062254),(231062314),(231062374),(231062434),(231062494),(231062554),
+(231062584),(231062614),(231062644),(231062704),(231062734),(231062794),
+(231062854),(231062884),(231062944),(231063004),(231063034),(231063064),
+(231063124),(231063154),(231063184),(231063214),(231063274),(231063334),
+(231063394),(231063424),(231063454),(231063514),(231063574),(231063664);
+CREATE TABLE t4 (
+carrier char(2) NOT NULL default '' PRIMARY KEY,
+id int(11) default NULL,
+INDEX id(id)
+);
+INSERT INTO t4 VALUES
+('99',6),('SK',456),('UA',486),('AI',1081),('OS',1111),('VS',1510);
+CREATE TABLE t5 (
+carrier_id int default NULL,
+INDEX carrier_id(carrier_id)
+);
+INSERT INTO t5 VALUES
+(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(456),(456),(456),
+(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),
+(456),(486),(1081),(1111),(1111),(1111),(1111),(1510);
+SELECT COUNT(*)
+FROM((t2 JOIN t1 ON t2.package_id = t1.id)
+JOIN t3 ON t3.package_id = t1.id);
+COUNT(*)
+6
+EXPLAIN
+SELECT COUNT(*)
+FROM ((t2 JOIN t1 ON t2.package_id = t1.id)
+JOIN t3 ON t3.package_id = t1.id)
+LEFT JOIN
+(t5 JOIN t4 ON t5.carrier_id = t4.id)
+ON t4.carrier = t1.carrier;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index package_id package_id 5 NULL 45 Using index
+1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.package_id 1
+1 SIMPLE t4 eq_ref PRIMARY,id PRIMARY 2 test.t1.carrier 1
+1 SIMPLE t5 ref carrier_id carrier_id 5 test.t4.id 22 Using index
+1 SIMPLE t3 ref package_id package_id 5 test.t1.id 1 Using where; Using index
+SELECT COUNT(*)
+FROM ((t2 JOIN t1 ON t2.package_id = t1.id)
+JOIN t3 ON t3.package_id = t1.id)
+LEFT JOIN
+(t5 JOIN t4 ON t5.carrier_id = t4.id)
+ON t4.carrier = t1.carrier;
+COUNT(*)
+6
+DROP TABLE t1,t2,t3,t4,t5;
End of 5.0 tests
diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result
index be3eabb47e9..e8c971a41bc 100644
--- a/mysql-test/r/mysqldump.result
+++ b/mysql-test/r/mysqldump.result
@@ -1890,7 +1890,7 @@ DROP TABLE IF EXISTS `v2`;
/*!50001 CREATE TABLE `v2` (
`a` varchar(30)
) */;
-/*!50001 DROP TABLE IF EXISTS `v2`*/;
+/*!50001 DROP TABLE `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -1981,7 +1981,7 @@ DROP TABLE IF EXISTS `v1`;
/*!50001 CREATE TABLE `v1` (
`a` int(11)
) */;
-/*!50001 DROP TABLE IF EXISTS `v1`*/;
+/*!50001 DROP TABLE `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -2049,7 +2049,7 @@ DROP TABLE IF EXISTS `v2`;
/*!50001 CREATE TABLE `v2` (
`a` varchar(30)
) */;
-/*!50001 DROP TABLE IF EXISTS `v2`*/;
+/*!50001 DROP TABLE `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -2168,7 +2168,7 @@ DROP TABLE IF EXISTS `v3`;
`b` int(11),
`c` varchar(30)
) */;
-/*!50001 DROP TABLE IF EXISTS `v1`*/;
+/*!50001 DROP TABLE `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -2182,7 +2182,7 @@ DROP TABLE IF EXISTS `v3`;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
-/*!50001 DROP TABLE IF EXISTS `v2`*/;
+/*!50001 DROP TABLE `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -2196,7 +2196,7 @@ DROP TABLE IF EXISTS `v3`;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
-/*!50001 DROP TABLE IF EXISTS `v3`*/;
+/*!50001 DROP TABLE `v3`*/;
/*!50001 DROP VIEW IF EXISTS `v3`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -2888,7 +2888,7 @@ DROP TABLE IF EXISTS `v2`;
) */;
USE `test`;
-/*!50001 DROP TABLE IF EXISTS `v0`*/;
+/*!50001 DROP TABLE `v0`*/;
/*!50001 DROP VIEW IF EXISTS `v0`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -2902,7 +2902,7 @@ USE `test`;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
-/*!50001 DROP TABLE IF EXISTS `v1`*/;
+/*!50001 DROP TABLE `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -2916,7 +2916,7 @@ USE `test`;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;
-/*!50001 DROP TABLE IF EXISTS `v2`*/;
+/*!50001 DROP TABLE `v2`*/;
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -3145,6 +3145,7 @@ insert into t values(5, 51);
create view v1 as select qty, price, qty*price as value from t;
create view v2 as select qty from v1;
mysqldump {
+/*!50001 DROP TABLE `v1`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@@ -3159,6 +3160,7 @@ mysqldump {
/*!50001 SET collation_connection = @saved_col_connection */;
} mysqldump {
+/*!50001 DROP TABLE `v2`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@@ -3251,7 +3253,7 @@ DROP TABLE IF EXISTS `v1`;
) */;
USE `mysqldump_test_db`;
-/*!50001 DROP TABLE IF EXISTS `v1`*/;
+/*!50001 DROP TABLE `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -3307,6 +3309,7 @@ USE `mysqldump_views`;
USE `mysqldump_tables`;
USE `mysqldump_views`;
+/*!50001 DROP TABLE `nasishnasifu`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
/*!50001 SET @saved_col_connection = @@collation_connection */;
@@ -3560,6 +3563,16 @@ CREATE TABLE `t1` (
INSERT INTO `t1` VALUES (11,0x7171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171717171);
DROP TABLE t1;
#
+# Bug #28524: mysqldump --skip-add-drop-table is not
+# compatible with views
+#
+CREATE VIEW v1 AS SELECT 1;
+DROP VIEW v1;
+SELECT * FROM v1;
+1
+1
+DROP VIEW v1;
+#
# End of 5.0 tests
#
drop table if exists t1;
@@ -3862,7 +3875,7 @@ DROP TABLE IF EXISTS `v1`;
) */;
USE `mysqldump_test_db`;
-/*!50001 DROP TABLE IF EXISTS `v1`*/;
+/*!50001 DROP TABLE `v1`*/;
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result
index 8ffe88acfa4..aba60f757c6 100644
--- a/mysql-test/r/symlink.result
+++ b/mysql-test/r/symlink.result
@@ -133,4 +133,26 @@ a
42
drop table t1;
End of 4.1 tests
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+USE db2;
+INSERT INTO db2.t1 VALUES (1);
+SELECT * FROM db2.t1;
+b
+1
+RESET QUERY CACHE;
+USE db1;
+SET SESSION keep_files_on_create = TRUE;
+CREATE TABLE t1 (a INT) ENGINE MYISAM;
+Got one of the listed errors
+CREATE TABLE t3 (a INT) Engine=MyISAM;
+INSERT INTO t3 VALUES (1),(2),(3);
+TRUNCATE TABLE t3;
+SELECT * from t3;
+a
+SET SESSION keep_files_on_create = DEFAULT;
+DROP TABLE db2.t1, db1.t3;
+DROP DATABASE db1;
+DROP DATABASE db2;
+USE test;
End of 5.0 tests
diff --git a/mysql-test/r/type_enum.result b/mysql-test/r/type_enum.result
index 9535e6dd18a..ec72a6eb995 100644
--- a/mysql-test/r/type_enum.result
+++ b/mysql-test/r/type_enum.result
@@ -1809,4 +1809,24 @@ f1
drop table t1;
+CREATE TABLE t1 (c1 ENUM('a', '', 'b'));
+INSERT INTO t1 (c1) VALUES ('b');
+INSERT INTO t1 (c1) VALUES ('');
+INSERT INTO t1 (c1) VALUES (0);
+Warnings:
+Warning 1265 Data truncated for column 'c1' at row 1
+INSERT INTO t1 (c1) VALUES ('');
+SELECT c1 + 0, COUNT(c1) FROM t1 GROUP BY c1;
+c1 + 0 COUNT(c1)
+0 1
+2 2
+3 1
+CREATE TABLE t2 SELECT * FROM t1;
+SELECT c1 + 0 FROM t2;
+c1 + 0
+3
+2
+0
+2
+DROP TABLE t1,t2;
End of 5.1 tests
diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result
index ce5bb9ceb2f..22580c155f3 100644
--- a/mysql-test/r/type_ranges.result
+++ b/mysql-test/r/type_ranges.result
@@ -208,10 +208,6 @@ options flags
one one
drop table t2;
create table t2 select * from t1;
-Warnings:
-Warning 1265 Data truncated for column 'options' at row 4
-Warning 1265 Data truncated for column 'options' at row 5
-Warning 1265 Data truncated for column 'options' at row 6
update t2 set string="changed" where auto=16;
show full columns from t1;
Field Type Collation Null Key Default Extra Privileges Comment
diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result
index ce820c0cb8e..d80a3973555 100644
--- a/mysql-test/r/type_time.result
+++ b/mysql-test/r/type_time.result
@@ -85,3 +85,46 @@ sec_to_time(time_to_sec(t))
13:00:00
09:00:00
drop table t1;
+select cast('100:55:50' as time) < cast('24:00:00' as time);
+cast('100:55:50' as time) < cast('24:00:00' as time)
+0
+select cast('100:55:50' as time) < cast('024:00:00' as time);
+cast('100:55:50' as time) < cast('024:00:00' as time)
+0
+select cast('300:55:50' as time) < cast('240:00:00' as time);
+cast('300:55:50' as time) < cast('240:00:00' as time)
+0
+select cast('100:55:50' as time) > cast('24:00:00' as time);
+cast('100:55:50' as time) > cast('24:00:00' as time)
+1
+select cast('100:55:50' as time) > cast('024:00:00' as time);
+cast('100:55:50' as time) > cast('024:00:00' as time)
+1
+select cast('300:55:50' as time) > cast('240:00:00' as time);
+cast('300:55:50' as time) > cast('240:00:00' as time)
+1
+create table t1 (f1 time);
+insert into t1 values ('24:00:00');
+select cast('24:00:00' as time) = (select f1 from t1);
+cast('24:00:00' as time) = (select f1 from t1)
+1
+drop table t1;
+create table t1(f1 time, f2 time);
+insert into t1 values('20:00:00','150:00:00');
+select 1 from t1 where cast('100:00:00' as time) between f1 and f2;
+1
+1
+drop table t1;
+CREATE TABLE t1 (
+f2 date NOT NULL,
+f3 int(11) unsigned NOT NULL default '0',
+PRIMARY KEY (f3, f2)
+);
+insert into t1 values('2007-07-01', 1);
+insert into t1 values('2007-07-01', 2);
+insert into t1 values('2007-07-02', 1);
+insert into t1 values('2007-07-02', 2);
+SELECT sum(f3) FROM t1 where f2='2007-07-01 00:00:00' group by f2;
+sum(f3)
+3
+drop table t1;
diff --git a/mysql-test/suite/binlog/r/binlog_row_ctype_cp932.result b/mysql-test/suite/binlog/r/binlog_row_ctype_cp932.result
index ca70f98c0e6..ef9f76b7d9c 100644
--- a/mysql-test/suite/binlog/r/binlog_row_ctype_cp932.result
+++ b/mysql-test/suite/binlog/r/binlog_row_ctype_cp932.result
@@ -11335,6 +11335,22 @@ cp932_bin 6109
cp932_bin 61
cp932_bin 6120
drop table t1;
+create table t2 (a char(1));
+insert into t2 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
+insert into t2 values ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
+create table t1 (
+a varchar(2) character set cp932
+) engine=myisam;
+insert into t1
+select unhex(concat(t24.a, t23.a, t22.a, t21.a))
+from t2 t21, t2 t22, t2 t23, t2 t24;
+delete from t1 where a='';
+alter table t1 add key(a);
+check table t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+drop table t1;
+drop table t2;
create table t1 (col1 varchar(1)) character set cp932;
insert into t1 values ('a');
insert into t1 values ('ab');
diff --git a/mysql-test/suite/binlog/r/binlog_stm_ctype_cp932.result b/mysql-test/suite/binlog/r/binlog_stm_ctype_cp932.result
index ca70f98c0e6..ef9f76b7d9c 100755
--- a/mysql-test/suite/binlog/r/binlog_stm_ctype_cp932.result
+++ b/mysql-test/suite/binlog/r/binlog_stm_ctype_cp932.result
@@ -11335,6 +11335,22 @@ cp932_bin 6109
cp932_bin 61
cp932_bin 6120
drop table t1;
+create table t2 (a char(1));
+insert into t2 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
+insert into t2 values ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
+create table t1 (
+a varchar(2) character set cp932
+) engine=myisam;
+insert into t1
+select unhex(concat(t24.a, t23.a, t22.a, t21.a))
+from t2 t21, t2 t22, t2 t23, t2 t24;
+delete from t1 where a='';
+alter table t1 add key(a);
+check table t1;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+drop table t1;
+drop table t2;
create table t1 (col1 varchar(1)) character set cp932;
insert into t1 values ('a');
insert into t1 values ('ab');
diff --git a/mysql-test/suite/rpl/include/rpl_mixed_ddl.inc b/mysql-test/suite/rpl/include/rpl_mixed_ddl.inc
index 7ea92a5cc1e..0b13116300e 100644
--- a/mysql-test/suite/rpl/include/rpl_mixed_ddl.inc
+++ b/mysql-test/suite/rpl/include/rpl_mixed_ddl.inc
@@ -67,7 +67,7 @@ ALTER TABLE t2 DROP COLUMN d;
--echo
--echo ******************** SHOW BINLOG EVENTS ********************
--replace_column 2 # 5 #
---replace_regex /table_id: [0-9]+/table_id: #/
+--replace_regex /Server ver: .+/Server ver: #/ /table_id: [0-9]+/table_id: #/
show binlog events from 1;
sync_slave_with_master;
# as we're using UUID we don't SELECT but use "diff" like in rpl_row_UUID
diff --git a/mysql-test/suite/rpl/include/rpl_mixed_dml.inc b/mysql-test/suite/rpl/include/rpl_mixed_dml.inc
index c79eb756c7f..cc225d1bb28 100644
--- a/mysql-test/suite/rpl/include/rpl_mixed_dml.inc
+++ b/mysql-test/suite/rpl/include/rpl_mixed_dml.inc
@@ -326,8 +326,8 @@ DROP VIEW v2;
--echo
--echo ******************** SHOW BINLOG EVENTS ********************
--replace_column 2 # 5 #
---replace_regex /table_id: [0-9]+/table_id: #/ /COMMIT.+xid=[0-9]+.+/#/
-show binlog events from 102;
+--replace_regex /Server ver: .+/Server ver: #/ /table_id: [0-9]+/table_id: #/ /COMMIT.+xid=[0-9]+.+/#/
+show binlog events from 1;
sync_slave_with_master;
# as we're using UUID we don't SELECT but use "diff" like in rpl_row_UUID
--exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test_rpl > $MYSQLTEST_VARDIR/tmp/rpl_switch_stm_row_mixed_master.sql
diff --git a/mysql-test/suite/rpl/r/rpl_innodb_mixed_ddl.result b/mysql-test/suite/rpl/r/rpl_innodb_mixed_ddl.result
index db75a2c5b4d..85308442fd8 100644
--- a/mysql-test/suite/rpl/r/rpl_innodb_mixed_ddl.result
+++ b/mysql-test/suite/rpl/r/rpl_innodb_mixed_ddl.result
@@ -138,7 +138,7 @@ ALTER TABLE t2 DROP COLUMN d;
******************** SHOW BINLOG EVENTS ********************
show binlog events from 1;
Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Format_desc 1 # Server ver: 5.1.16-beta-debug-log, Binlog ver: 4
+master-bin.000001 # Format_desc 1 # Server ver: #
master-bin.000001 # Query 1 # DROP DATABASE IF EXISTS test_rpl
master-bin.000001 # Query 1 # DROP DATABASE IF EXISTS test_rpl_1
master-bin.000001 # Query 1 # CREATE DATABASE test_rpl_1 CHARACTER SET utf8 COLLATE utf8_general_ci
diff --git a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result
index 8c625dc70a4..7100e5cbe9c 100644
--- a/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result
+++ b/mysql-test/suite/rpl/r/rpl_innodb_mixed_dml.result
@@ -684,11 +684,12 @@ CREATE EVENT e1 ON SCHEDULE EVERY '1' SECOND COMMENT 'e_second_comment' DO DELET
==========MASTER==========
SHOW EVENTS;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-test_rpl e1 root@localhost RECURRING NULL 1 SECOND # # ENABLED
+test_rpl e1 root@localhost SYSTEM RECURRING NULL 1 # # NULL ENABLED 1
==========SLAVE===========
USE test_rpl;
SHOW EVENTS;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
+test_rpl e1 @ SYSTEM RECURRING NULL 1 # # NULL SLAVESIDE_DISABLED 1
==========MASTER==========
SELECT COUNT(*) FROM t1;
COUNT(*)
@@ -743,11 +744,12 @@ ALTER EVENT e1 RENAME TO e2;
==========MASTER==========
SHOW EVENTS;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
-test_rpl e2 root@localhost RECURRING NULL 1 SECOND # # ENABLED
+test_rpl e2 root@localhost SYSTEM RECURRING NULL 1 # # NULL ENABLED 1
==========SLAVE===========
USE test_rpl;
SHOW EVENTS;
Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator
+test_rpl e2 @ SYSTEM RECURRING NULL 1 # # NULL SLAVESIDE_DISABLED 1
==========MASTER==========
SELECT COUNT(*) FROM t1;
COUNT(*)
@@ -827,8 +829,9 @@ DELETE FROM t2;
******************** SHOW BINLOG EVENTS ********************
-show binlog events from 102;
+show binlog events from 1;
Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Format_desc 1 # Server ver: #
master-bin.000001 # Query 1 # CREATE DATABASE test_rpl
master-bin.000001 # Query 1 # use `test_rpl`; CREATE TABLE t1 (a int auto_increment not null, b char(254), PRIMARY KEY(a)) ENGINE=innodb
master-bin.000001 # Query 1 # use `test_rpl`; CREATE TABLE t2 (a int auto_increment not null, b char(254), PRIMARY KEY(a)) ENGINE=innodb
@@ -1011,6 +1014,9 @@ master-bin.000001 # Query 1 # use `test_rpl`; DROP TRIGGER tr1
master-bin.000001 # Query 1 # use `test_rpl`; GRANT EVENT ON *.* TO 'root'@'localhost'
master-bin.000001 # Query 1 # use `test_rpl`; INSERT INTO t1 VALUES(1, 'test1')
master-bin.000001 # Xid 1 # #
+master-bin.000001 # Query 1 # use `test_rpl`; CREATE EVENT e1 ON SCHEDULE EVERY '1' SECOND COMMENT 'e_second_comment' DO DELETE FROM t1
+master-bin.000001 # Query 1 # use `test_rpl`; ALTER EVENT e1 RENAME TO e2
+master-bin.000001 # Query 1 # use `test_rpl`; DROP EVENT e2
master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t1
master-bin.000001 # Xid 1 # #
master-bin.000001 # Query 1 # use `test_rpl`; DELETE FROM t2
diff --git a/mysql-test/suite/rpl/t/rpl_innodb_mixed_ddl.test b/mysql-test/suite/rpl/t/rpl_innodb_mixed_ddl.test
index 1d4709bb548..6eb9c7075e4 100644
--- a/mysql-test/suite/rpl/t/rpl_innodb_mixed_ddl.test
+++ b/mysql-test/suite/rpl/t/rpl_innodb_mixed_ddl.test
@@ -5,9 +5,10 @@
# Requirements: define binlog format for mysqld as in example below:
# ./mysql-test-run.pl --mysqld=--binlog-format=mixed
#########################################
-
+--source include/have_binlog_format_mixed.inc
--source include/have_innodb.inc
let $engine_type= innodb;
--source suite/rpl/include/rpl_mixed_ddl.inc
+# End 5.1 Test Case
diff --git a/mysql-test/suite/rpl/t/rpl_innodb_mixed_dml.test b/mysql-test/suite/rpl/t/rpl_innodb_mixed_dml.test
index f6b21c4af1c..d48e847a6c8 100644
--- a/mysql-test/suite/rpl/t/rpl_innodb_mixed_dml.test
+++ b/mysql-test/suite/rpl/t/rpl_innodb_mixed_dml.test
@@ -5,9 +5,10 @@
# Requirements: define binlog format for mysqld as in example below:
# ./mysql-test-run.pl --mysqld=--binlog-format=mixed
#########################################
-
+--source include/have_binlog_format_mixed.inc
--source include/have_innodb.inc
let $engine_type= innodb;
--source suite/rpl/include/rpl_mixed_dml.inc
+# End 5.1 Test Case
diff --git a/mysql-test/t/create_not_windows.test b/mysql-test/t/create_not_windows.test
index 2c1700d9e49..56b4002106d 100644
--- a/mysql-test/t/create_not_windows.test
+++ b/mysql-test/t/create_not_windows.test
@@ -17,6 +17,7 @@ primary key (_id)
show create table `about:text`;
drop table `about:text`;
+
# End of 5.0 tests
#
diff --git a/mysql-test/t/ctype_big5.test b/mysql-test/t/ctype_big5.test
index 8e17a27c550..5f3357e0406 100644
--- a/mysql-test/t/ctype_big5.test
+++ b/mysql-test/t/ctype_big5.test
@@ -68,15 +68,16 @@ select hex(convert(_big5 0xC84041 using ucs2));
#
# Bug#26711 "binary content 0x00 sometimes becomes 0x5C 0x00 after dump/load"
#
+set names big5;
create table t1 (a blob);
insert into t1 values (0xEE00);
---exec $MYSQL_DUMP --default-character-set=big5 -T $MYSQLTEST_VARDIR/master-data/test test t1
+select * into outfile 'test/t1.txt' from t1;
delete from t1;
-select hex(load_file('test/t1.txt'));
+--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
+--eval select hex(load_file('$MYSQLTEST_VARDIR/master-data/test/t1.txt'));
load data infile 't1.txt' into table t1;
select hex(a) from t1;
--exec rm $MYSQLTEST_VARDIR/master-data/test/t1.txt
---exec rm $MYSQLTEST_VARDIR/master-data/test/t1.sql
drop table t1;
--echo End of 5.0 tests
diff --git a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test
index 4bbae42559a..cfef8dfe81a 100644
--- a/mysql-test/t/ctype_collate.test
+++ b/mysql-test/t/ctype_collate.test
@@ -218,3 +218,14 @@ insert into t1 set f1=0x3F3F1E563F;
insert into t1 set f1=0x3F3F;
check table t1 extended;
drop table t1;
+
+#
+# Bug#29461: Sort order of the collation wasn't used when comparing characters
+# with the space character.
+#
+create table t1 (a varchar(2) character set latin7 collate latin7_general_ci,key(a));
+insert into t1 set a=0x4c20;
+insert into t1 set a=0x6c;
+insert into t1 set a=0x4c98;
+check table t1 extended;
+drop table t1;
diff --git a/mysql-test/t/ctype_latin1.test b/mysql-test/t/ctype_latin1.test
index 0a112233ffb..b12436f77ba 100644
--- a/mysql-test/t/ctype_latin1.test
+++ b/mysql-test/t/ctype_latin1.test
@@ -121,3 +121,9 @@ INSERT INTO abcÿdef VALUES (2);
SELECT * FROM `abcÿdef`;
SELECT * FROM abcÿdef;
DROP TABLE `abcÿdef`;
+#
+# Bug#29499 Converting 'del' from ascii to Unicode results in 'question mark'
+#
+select hex(cast(_ascii 0x7f as char(1) character set latin1));
+
+--echo End of 5.0 tests
diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test
index 8828cd10eec..18a18d6c632 100644
--- a/mysql-test/t/ctype_ucs.test
+++ b/mysql-test/t/ctype_ucs.test
@@ -612,4 +612,14 @@ select collation(group_concat(a separator ',')) from t1;
drop table t1;
set names latin1;
+#
+# Bug#29499 Converting 'del' from ascii to Unicode results in 'question mark'
+#
+create table t1 (s1 char(1) character set ascii, s2 char(1) character set ucs2);
+insert into t1 (s1) values (0x7f);
+update t1 set s2 = s1;
+select hex(s2) from t1;
+select hex(convert(s1 using latin1)) from t1;
+drop table t1;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test
index b24015ebb99..6f9b5399b7b 100644
--- a/mysql-test/t/func_gconcat.test
+++ b/mysql-test/t/func_gconcat.test
@@ -551,4 +551,15 @@ SELECT LENGTH( GROUP_CONCAT( a ) ) FROM t3 WHERE b = 3;
SET group_concat_max_len= DEFAULT;
DROP TABLE t1, t2, t3;
+#
+# Bug#29850: Wrong charset of the GROUP_CONCAT result when the select employs
+# a temporary table.
+#
+set names latin1;
+create table t1 (id int, name varchar(20)) DEFAULT CHARSET=utf8;
+insert into t1 (id, name) values (1, "óra");
+insert into t1 (id, name) values (2, "óra");
+select b.id, group_concat(b.name) from t1 a, t1 b group by b.id;
+drop table t1;
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test
index 579ec65f149..88f31143d93 100644
--- a/mysql-test/t/gis-rtree.test
+++ b/mysql-test/t/gis-rtree.test
@@ -827,3 +827,22 @@ INSERT INTO t1 (b) SELECT b FROM t1;
OPTIMIZE TABLE t1;
DROP TABLE t1;
+
+
+#
+# Bug #29070: Error in spatial index
+#
+
+CREATE TABLE t1 (a INT, b GEOMETRY NOT NULL, SPATIAL KEY b(b));
+INSERT INTO t1 VALUES (1, GEOMFROMTEXT('LINESTRING(1102218.456 1,2000000 2)'));
+INSERT INTO t1 VALUES (2, GEOMFROMTEXT('LINESTRING(1102218.456 1,2000000 2)'));
+
+# must return the same number as the next select
+SELECT COUNT(*) FROM t1 WHERE
+ MBRINTERSECTS(b, GEOMFROMTEXT('LINESTRING(1 1,1102219 2)') );
+SELECT COUNT(*) FROM t1 IGNORE INDEX (b) WHERE
+ MBRINTERSECTS(b, GEOMFROMTEXT('LINESTRING(1 1,1102219 2)') );
+
+DROP TABLE t1;
+
+--echo End of 5.0 tests.
diff --git a/mysql-test/t/join_nested.test b/mysql-test/t/join_nested.test
index f29366797f6..5b07d8966f1 100644
--- a/mysql-test/t/join_nested.test
+++ b/mysql-test/t/join_nested.test
@@ -1083,4 +1083,118 @@ SELECT * FROM t1 JOIN (t2 JOIN t3 USING (b)) USING (a);
DROP TABLE t1,t2,t3;
+#
+# BUG#29604: inner nest of left join interleaves with outer tables
+#
+
+CREATE TABLE t1 (
+ carrier char(2) default NULL,
+ id int NOT NULL auto_increment PRIMARY KEY
+);
+INSERT INTO t1 VALUES
+ ('CO',235371754),('CO',235376554),('CO',235376884),('CO',235377874),
+ ('CO',231060394),('CO',231059224),('CO',231059314),('CO',231060484),
+ ('CO',231060274),('CO',231060124),('CO',231060244),('CO',231058594),
+ ('CO',231058924),('CO',231058504),('CO',231059344),('CO',231060424),
+ ('CO',231059554),('CO',231060304),('CO',231059644),('CO',231059464),
+ ('CO',231059764),('CO',231058294),('CO',231058624),('CO',231058864),
+ ('CO',231059374),('CO',231059584),('CO',231059734),('CO',231059014),
+ ('CO',231059854),('CO',231059494),('CO',231059794),('CO',231058534),
+ ('CO',231058324),('CO',231058684),('CO',231059524),('CO',231059974);
+
+CREATE TABLE t2 (
+ scan_date date default NULL,
+ package_id int default NULL,
+ INDEX scan_date(scan_date),
+ INDEX package_id(package_id)
+);
+INSERT INTO t2 VALUES
+ ('2008-12-29',231062944),('2008-12-29',231065764),('2008-12-29',231066124),
+ ('2008-12-29',231060094),('2008-12-29',231061054),('2008-12-29',231065644),
+ ('2008-12-29',231064384),('2008-12-29',231064444),('2008-12-29',231073774),
+ ('2008-12-29',231058594),('2008-12-29',231059374),('2008-12-29',231066004),
+ ('2008-12-29',231068494),('2008-12-29',231070174),('2008-12-29',231071884),
+ ('2008-12-29',231063274),('2008-12-29',231063754),('2008-12-29',231064144),
+ ('2008-12-29',231069424),('2008-12-29',231073714),('2008-12-29',231058414),
+ ('2008-12-29',231060994),('2008-12-29',231069154),('2008-12-29',231068614),
+ ('2008-12-29',231071464),('2008-12-29',231074014),('2008-12-29',231059614),
+ ('2008-12-29',231059074),('2008-12-29',231059464),('2008-12-29',231069094),
+ ('2008-12-29',231067294),('2008-12-29',231070144),('2008-12-29',231073804),
+ ('2008-12-29',231072634),('2008-12-29',231058294),('2008-12-29',231065344),
+ ('2008-12-29',231066094),('2008-12-29',231069034),('2008-12-29',231058594),
+ ('2008-12-29',231059854),('2008-12-29',231059884),('2008-12-29',231059914),
+ ('2008-12-29',231063664),('2008-12-29',231063814),('2008-12-29',231063904);
+
+CREATE TABLE t3 (
+ package_id int default NULL,
+ INDEX package_id(package_id)
+);
+INSERT INTO t3 VALUES
+ (231058294),(231058324),(231058354),(231058384),(231058414),(231058444),
+ (231058474),(231058504),(231058534),(231058564),(231058594),(231058624),
+ (231058684),(231058744),(231058804),(231058864),(231058924),(231058954),
+ (231059014),(231059074),(231059104),(231059134),(231059164),(231059194),
+ (231059224),(231059254),(231059284),(231059314),(231059344),(231059374),
+ (231059404),(231059434),(231059464),(231059494),(231059524),(231059554),
+ (231059584),(231059614),(231059644),(231059674),(231059704),(231059734),
+ (231059764),(231059794),(231059824),(231059854),(231059884),(231059914),
+ (231059944),(231059974),(231060004),(231060034),(231060064),(231060094),
+ (231060124),(231060154),(231060184),(231060214),(231060244),(231060274),
+ (231060304),(231060334),(231060364),(231060394),(231060424),(231060454),
+ (231060484),(231060514),(231060544),(231060574),(231060604),(231060634),
+ (231060664),(231060694),(231060724),(231060754),(231060784),(231060814),
+ (231060844),(231060874),(231060904),(231060934),(231060964),(231060994),
+ (231061024),(231061054),(231061084),(231061144),(231061174),(231061204),
+ (231061234),(231061294),(231061354),(231061384),(231061414),(231061474),
+ (231061564),(231061594),(231061624),(231061684),(231061714),(231061774),
+ (231061804),(231061894),(231061984),(231062074),(231062134),(231062224),
+ (231062254),(231062314),(231062374),(231062434),(231062494),(231062554),
+ (231062584),(231062614),(231062644),(231062704),(231062734),(231062794),
+ (231062854),(231062884),(231062944),(231063004),(231063034),(231063064),
+ (231063124),(231063154),(231063184),(231063214),(231063274),(231063334),
+ (231063394),(231063424),(231063454),(231063514),(231063574),(231063664);
+
+CREATE TABLE t4 (
+ carrier char(2) NOT NULL default '' PRIMARY KEY,
+ id int(11) default NULL,
+ INDEX id(id)
+);
+INSERT INTO t4 VALUES
+ ('99',6),('SK',456),('UA',486),('AI',1081),('OS',1111),('VS',1510);
+
+CREATE TABLE t5 (
+ carrier_id int default NULL,
+ INDEX carrier_id(carrier_id)
+);
+INSERT INTO t5 VALUES
+ (6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+ (6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+ (6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+ (6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+ (6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),
+ (6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(6),(456),(456),(456),
+ (456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),(456),
+ (456),(486),(1081),(1111),(1111),(1111),(1111),(1510);
+
+SELECT COUNT(*)
+ FROM((t2 JOIN t1 ON t2.package_id = t1.id)
+ JOIN t3 ON t3.package_id = t1.id);
+
+EXPLAIN
+SELECT COUNT(*)
+ FROM ((t2 JOIN t1 ON t2.package_id = t1.id)
+ JOIN t3 ON t3.package_id = t1.id)
+ LEFT JOIN
+ (t5 JOIN t4 ON t5.carrier_id = t4.id)
+ ON t4.carrier = t1.carrier;
+SELECT COUNT(*)
+ FROM ((t2 JOIN t1 ON t2.package_id = t1.id)
+ JOIN t3 ON t3.package_id = t1.id)
+ LEFT JOIN
+ (t5 JOIN t4 ON t5.carrier_id = t4.id)
+ ON t4.carrier = t1.carrier;
+
+DROP TABLE t1,t2,t3,t4,t5;
+
--echo End of 5.0 tests
+
diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test
index 0f1fee453a5..38d8a07fe48 100644
--- a/mysql-test/t/mysqldump.test
+++ b/mysql-test/t/mysqldump.test
@@ -1542,6 +1542,19 @@ INSERT INTO t1 SET c1=11, c2=REPEAT('q',509);
DROP TABLE t1;
--echo #
+--echo # Bug #28524: mysqldump --skip-add-drop-table is not
+--echo # compatible with views
+--echo #
+
+CREATE VIEW v1 AS SELECT 1;
+--exec $MYSQL_DUMP --skip-add-drop-table test > $MYSQLTEST_VARDIR/tmp/bug28524.sql
+DROP VIEW v1;
+
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug28524.sql
+SELECT * FROM v1;
+DROP VIEW v1;
+
+--echo #
--echo # End of 5.0 tests
--echo #
diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test
index 981206ca54c..15f50b11e73 100644
--- a/mysql-test/t/symlink.test
+++ b/mysql-test/t/symlink.test
@@ -174,4 +174,43 @@ drop table t1;
--echo End of 4.1 tests
+#
+# Bug #29325: create table overwrites .MYD file of other table (datadir)
+#
+
+CREATE DATABASE db1;
+CREATE DATABASE db2;
+
+USE db2;
+--disable_query_log
+eval CREATE TABLE t1 (b INT) ENGINE MYISAM
+DATA DIRECTORY = '$MYSQLTEST_VARDIR/master-data/db1/';
+--enable_query_log
+
+INSERT INTO db2.t1 VALUES (1);
+SELECT * FROM db2.t1;
+RESET QUERY CACHE;
+
+USE db1;
+
+#no warning from create table
+SET SESSION keep_files_on_create = TRUE;
+--disable_abort_on_error
+--error 1,1
+CREATE TABLE t1 (a INT) ENGINE MYISAM;
+--enable_abort_on_error
+
+CREATE TABLE t3 (a INT) Engine=MyISAM;
+INSERT INTO t3 VALUES (1),(2),(3);
+TRUNCATE TABLE t3;
+SELECT * from t3;
+
+SET SESSION keep_files_on_create = DEFAULT;
+
+DROP TABLE db2.t1, db1.t3;
+DROP DATABASE db1;
+DROP DATABASE db2;
+USE test;
+
+
--echo End of 5.0 tests
diff --git a/mysql-test/t/type_enum.test b/mysql-test/t/type_enum.test
index 1e5b53a2c6e..4d5d5ec8a86 100644
--- a/mysql-test/t/type_enum.test
+++ b/mysql-test/t/type_enum.test
@@ -183,4 +183,21 @@ insert into t1 values(''),(''),('a'),('b');
select * from t1 where f1='';
drop table t1;
+#
+# Bug#29360: Confluence of the special 0 enum value with the normal empty string
+# value during field to field copy.
+#
+
+CREATE TABLE t1 (c1 ENUM('a', '', 'b'));
+INSERT INTO t1 (c1) VALUES ('b');
+INSERT INTO t1 (c1) VALUES ('');
+INSERT INTO t1 (c1) VALUES (0);
+INSERT INTO t1 (c1) VALUES ('');
+
+SELECT c1 + 0, COUNT(c1) FROM t1 GROUP BY c1;
+
+CREATE TABLE t2 SELECT * FROM t1;
+SELECT c1 + 0 FROM t2;
+
+DROP TABLE t1,t2;
--echo End of 5.1 tests
diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test
index cb7e4f85ad1..5fc763be7fe 100644
--- a/mysql-test/t/type_time.test
+++ b/mysql-test/t/type_time.test
@@ -40,3 +40,40 @@ drop table t1;
# ##########################################################
# End of 4.1 tests
+
+#
+# Bug#29555: Comparing time values as strings may lead to a wrong result.
+#
+select cast('100:55:50' as time) < cast('24:00:00' as time);
+select cast('100:55:50' as time) < cast('024:00:00' as time);
+select cast('300:55:50' as time) < cast('240:00:00' as time);
+select cast('100:55:50' as time) > cast('24:00:00' as time);
+select cast('100:55:50' as time) > cast('024:00:00' as time);
+select cast('300:55:50' as time) > cast('240:00:00' as time);
+create table t1 (f1 time);
+insert into t1 values ('24:00:00');
+select cast('24:00:00' as time) = (select f1 from t1);
+drop table t1;
+
+#
+# Bug#29739: Incorrect time comparison in BETWEEN.
+#
+create table t1(f1 time, f2 time);
+insert into t1 values('20:00:00','150:00:00');
+select 1 from t1 where cast('100:00:00' as time) between f1 and f2;
+drop table t1;
+
+#
+# Bug#29729: Wrong conversion error led to an empty result set.
+#
+CREATE TABLE t1 (
+ f2 date NOT NULL,
+ f3 int(11) unsigned NOT NULL default '0',
+ PRIMARY KEY (f3, f2)
+);
+insert into t1 values('2007-07-01', 1);
+insert into t1 values('2007-07-01', 2);
+insert into t1 values('2007-07-02', 1);
+insert into t1 values('2007-07-02', 2);
+SELECT sum(f3) FROM t1 where f2='2007-07-01 00:00:00' group by f2;
+drop table t1;
diff --git a/mysys/my_conio.c b/mysys/my_conio.c
index 1ea1f7a820a..b78966446ee 100644
--- a/mysys/my_conio.c
+++ b/mysys/my_conio.c
@@ -187,15 +187,19 @@ char* my_cgets(char *buffer, size_t clen, size_t* plen)
while (GetLastError() == ERROR_NOT_ENOUGH_MEMORY);
*plen= plen_res;
+ /* We go here on error reading the string (Ctrl-C for example) */
+ if (!*plen)
+ result= NULL; /* purecov: inspected */
+
if (result != NULL)
{
- if (buffer[*plen - 2] == '\r')
+ if (*plen > 1 && buffer[*plen - 2] == '\r')
{
*plen= *plen - 2;
}
else
{
- if (buffer[*plen - 1] == '\r')
+ if (*plen > 0 && buffer[*plen - 1] == '\r')
{
char tmp[3];
int tmplen= sizeof(tmp);
diff --git a/mysys/my_symlink2.c b/mysys/my_symlink2.c
index 6ea22790998..2a46fb3abea 100644
--- a/mysys/my_symlink2.c
+++ b/mysys/my_symlink2.c
@@ -56,11 +56,13 @@ File my_create_with_symlink(const char *linkname, const char *filename,
{
if (!access(filename,F_OK))
{
+ my_errno= errno= EEXIST;
my_error(EE_CANTCREATEFILE, MYF(0), filename, EEXIST);
DBUG_RETURN(-1);
}
if (create_link && !access(linkname,F_OK))
{
+ my_errno= errno= EEXIST;
my_error(EE_CANTCREATEFILE, MYF(0), linkname, EEXIST);
DBUG_RETURN(-1);
}
diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh
index 201a922ee68..02c97f59cb6 100644
--- a/scripts/make_binary_distribution.sh
+++ b/scripts/make_binary_distribution.sh
@@ -312,6 +312,7 @@ MCP mysql-test/t/*.def $BASE/mysql-test/t
MCP 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
diff --git a/sql/field.cc b/sql/field.cc
index 2cd81afca49..a970a6e4318 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -5406,7 +5406,8 @@ int Field_newdate::store(const char *from,uint len,CHARSET_INFO *cs)
else
{
tmp= l_time.day + l_time.month*32 + l_time.year*16*32;
- if (!error && (ret != MYSQL_TIMESTAMP_DATE))
+ if (!error && (ret != MYSQL_TIMESTAMP_DATE) &&
+ thd->count_cuted_fields != CHECK_FIELD_IGNORE)
error= 3; // Datetime was cut (note)
}
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index 44aea9acee0..33c7897c3db 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -795,11 +795,18 @@ int field_conv(Field *to,Field *from)
blob->value.copy();
return blob->store(blob->value.ptr(),blob->value.length(),from->charset());
}
- if ((from->result_type() == STRING_RESULT &&
- (to->result_type() == STRING_RESULT ||
- (from->real_type() != MYSQL_TYPE_ENUM &&
- from->real_type() != MYSQL_TYPE_SET))) ||
- to->type() == MYSQL_TYPE_DECIMAL)
+ if (from->real_type() == MYSQL_TYPE_ENUM &&
+ to->real_type() == MYSQL_TYPE_ENUM &&
+ from->val_int() == 0)
+ {
+ ((Field_enum *)(to))->store_type(0);
+ return 0;
+ }
+ else if ((from->result_type() == STRING_RESULT &&
+ (to->result_type() == STRING_RESULT ||
+ (from->real_type() != MYSQL_TYPE_ENUM &&
+ from->real_type() != MYSQL_TYPE_SET))) ||
+ to->type() == MYSQL_TYPE_DECIMAL)
{
char buff[MAX_FIELD_WIDTH];
String result(buff,sizeof(buff),from->charset());
diff --git a/sql/filesort.cc b/sql/filesort.cc
index e547940797b..b6a5d844eac 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -1120,7 +1120,8 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file,
int flag)
{
int error;
- uint rec_length,sort_length,res_length,offset;
+ uint rec_length,res_length,offset;
+ size_t sort_length;
ulong maxcount;
ha_rows max_rows,org_max_rows;
my_off_t to_start_filepos;
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 3477ce84b21..755e711e383 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -719,6 +719,67 @@ Arg_comparator::can_compare_as_dates(Item *a, Item *b, ulonglong *const_value)
}
+/*
+ Retrieves correct TIME value from the given item.
+
+ SYNOPSIS
+ get_time_value()
+ thd thread handle
+ item_arg [in/out] item to retrieve TIME value from
+ cache_arg [in/out] pointer to place to store the cache item to
+ warn_item [in] unused
+ is_null [out] TRUE <=> the item_arg is null
+
+ DESCRIPTION
+ Retrieves the correct TIME value from given item for comparison by the
+ compare_datetime() function.
+ If item's result can be compared as longlong then its int value is used
+ and a value returned by get_time function is used otherwise.
+ If an item is a constant one then its value is cached and it isn't
+ get parsed again. An Item_cache_int object is used for for cached values.
+ It seamlessly substitutes the original item. The cache item is marked as
+ non-constant to prevent re-caching it again.
+
+ RETURN
+ obtained value
+*/
+
+ulonglong
+get_time_value(THD *thd, Item ***item_arg, Item **cache_arg,
+ Item *warn_item, bool *is_null)
+{
+ ulonglong value;
+ Item *item= **item_arg;
+ MYSQL_TIME ltime;
+
+ if (item->result_as_longlong())
+ {
+ value= item->val_int();
+ *is_null= item->null_value;
+ }
+ else
+ {
+ *is_null= item->get_time(&ltime);
+ value= !*is_null ? TIME_to_ulonglong_datetime(&ltime) : 0;
+ }
+ /*
+ Do not cache GET_USER_VAR() function as its const_item() may return TRUE
+ for the current thread but it still may change during the execution.
+ */
+ if (item->const_item() && cache_arg && (item->type() != Item::FUNC_ITEM ||
+ ((Item_func*)item)->functype() != Item_func::GUSERVAR_FUNC))
+ {
+ Item_cache_int *cache= new Item_cache_int();
+ /* Mark the cache as non-const to prevent re-caching. */
+ cache->set_used_tables(1);
+ cache->store(item, value);
+ *cache_arg= cache;
+ *item_arg= cache_arg;
+ }
+ return value;
+}
+
+
int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg,
Item **a1, Item **a2,
Item_result type)
@@ -757,8 +818,23 @@ int Arg_comparator::set_cmp_func(Item_bool_func2 *owner_arg,
}
is_nulls_eq= test(owner && owner->functype() == Item_func::EQUAL_FUNC);
func= &Arg_comparator::compare_datetime;
+ get_value_func= &get_datetime_value;
return 0;
}
+ else if (type == STRING_RESULT && (*a)->field_type() == MYSQL_TYPE_TIME &&
+ (*b)->field_type() == MYSQL_TYPE_TIME)
+ {
+ /* Compare TIME values as integers. */
+ thd= current_thd;
+ owner= owner_arg;
+ a_cache= 0;
+ b_cache= 0;
+ is_nulls_eq= test(owner && owner->functype() == Item_func::EQUAL_FUNC);
+ func= &Arg_comparator::compare_datetime;
+ get_value_func= &get_time_value;
+ return 0;
+ }
+
return set_compare_func(owner_arg, type);
}
@@ -776,8 +852,10 @@ void Arg_comparator::set_datetime_cmp_func(Item **a1, Item **b1)
b_cache= 0;
is_nulls_eq= FALSE;
func= &Arg_comparator::compare_datetime;
+ get_value_func= &get_datetime_value;
}
+
/*
Retrieves correct DATETIME value from given item.
@@ -891,8 +969,8 @@ int Arg_comparator::compare_datetime()
bool is_null= FALSE;
ulonglong a_value, b_value;
- /* Get DATE/DATETIME value of the 'a' item. */
- a_value= get_datetime_value(thd, &a, &a_cache, *b, &is_null);
+ /* Get DATE/DATETIME/TIME value of the 'a' item. */
+ a_value= (*get_value_func)(thd, &a, &a_cache, *b, &is_null);
if (!is_nulls_eq && is_null)
{
if (owner)
@@ -900,8 +978,8 @@ int Arg_comparator::compare_datetime()
return -1;
}
- /* Get DATE/DATETIME value of the 'b' item. */
- b_value= get_datetime_value(thd, &b, &b_cache, *a, &is_null);
+ /* Get DATE/DATETIME/TIME value of the 'b' item. */
+ b_value= (*get_value_func)(thd, &b, &b_cache, *a, &is_null);
if (is_null)
{
if (owner)
@@ -1771,6 +1849,7 @@ void Item_func_between::fix_length_and_dec()
max_length= 1;
int i;
bool datetime_found= FALSE;
+ int time_items_found= 0;
compare_as_dates= TRUE;
THD *thd= current_thd;
@@ -1791,17 +1870,19 @@ void Item_func_between::fix_length_and_dec()
At least one of items should be a DATE/DATETIME item and other items
should return the STRING result.
*/
- for (i= 0; i < 3; i++)
+ if (cmp_type == STRING_RESULT)
{
- if (args[i]->is_datetime())
+ for (i= 0; i < 3; i++)
{
- datetime_found= TRUE;
- continue;
+ if (args[i]->is_datetime())
+ {
+ datetime_found= TRUE;
+ continue;
+ }
+ if (args[i]->field_type() == MYSQL_TYPE_TIME &&
+ args[i]->result_as_longlong())
+ time_items_found++;
}
- if (args[i]->result_type() == STRING_RESULT)
- continue;
- compare_as_dates= FALSE;
- break;
}
if (!datetime_found)
compare_as_dates= FALSE;
@@ -1811,6 +1892,11 @@ void Item_func_between::fix_length_and_dec()
ge_cmp.set_datetime_cmp_func(args, args + 1);
le_cmp.set_datetime_cmp_func(args, args + 2);
}
+ else if (time_items_found == 3)
+ {
+ /* Compare TIME items as integers. */
+ cmp_type= INT_RESULT;
+ }
else if (args[0]->real_item()->type() == FIELD_ITEM &&
thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
thd->lex->sql_command != SQLCOM_SHOW_CREATE)
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index ee36aca069d..fcbacc32d88 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -42,6 +42,8 @@ class Arg_comparator: public Sql_alloc
bool is_nulls_eq; // TRUE <=> compare for the EQUAL_FUNC
enum enum_date_cmp_type { CMP_DATE_DFLT= 0, CMP_DATE_WITH_DATE,
CMP_DATE_WITH_STR, CMP_STR_WITH_DATE };
+ ulonglong (*get_value_func)(THD *thd, Item ***item_arg, Item **cache_arg,
+ Item *warn_item, bool *is_null);
public:
DTCollation cmp_collation;
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 0fa46d231a9..8fe843a2a2d 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -3089,6 +3089,7 @@ Item_func_group_concat::Item_func_group_concat(THD *thd,
original(item)
{
quick_group= item->quick_group;
+ result.set_charset(collation.collation);
}
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 4944c994d3d..948b268d9a3 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -1264,8 +1264,16 @@ int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler)
thd= head->in_use;
if (!(file= head->file->clone(thd->mem_root)))
{
+ /*
+ Manually set the error flag. Note: there seems to be quite a few
+ places where a failure could cause the server to "hang" the client by
+ sending no response to a query. ATM those are not real errors because
+ the storage engine calls in question happen to never fail with the
+ existing storage engines.
+ */
+ thd->net.report_error= 1; /* purecov: inspected */
/* Caller will free the memory */
- goto failure;
+ goto failure; /* purecov: inspected */
}
head->column_bitmaps_set(&column_bitmap, &column_bitmap);
@@ -7244,6 +7252,11 @@ check_quick_select(PARAM *param,uint idx,SEL_ARG *tree, bool update_tbl_stats)
param->is_ror_scan is cleared if the function detects that the key scan is
not a Rowid-Ordered Retrieval scan ( see comments for is_key_scan_ror
function for description of which key scans are ROR scans)
+
+ RETURN
+ #records E(#records) for given subtree
+ HA_POS_ERROR if subtree cannot be used for record retrieval
+
*/
static ha_rows
@@ -7445,27 +7458,24 @@ check_quick_keys(PARAM *param, uint idx, SEL_ARG *key_tree,
ROR (Rowid Ordered Retrieval) key scan is a key scan that produces
ordered sequence of rowids (ha_xxx::cmp_ref is the comparison function)
- An index scan is a ROR scan if it is done using a condition in form
+ This function is needed to handle a practically-important special case:
+ an index scan is a ROR scan if it is done using a condition in form
- "key1_1=c_1 AND ... AND key1_n=c_n" (1)
+ "key1_1=c_1 AND ... AND key1_n=c_n"
where the index is defined on (key1_1, ..., key1_N [,a_1, ..., a_n])
- and the table has a clustered Primary Key
-
- PRIMARY KEY(a_1, ..., a_n, b1, ..., b_k) with first key parts being
- identical to uncovered parts ot the key being scanned (2)
-
- Scans on HASH indexes are not ROR scans,
- any range scan on clustered primary key is ROR scan (3)
+ and the table has a clustered Primary Key defined as
- Check (1) is made in check_quick_keys()
- Check (3) is made check_quick_select()
- Check (2) is made by this function.
+ PRIMARY KEY(a_1, ..., a_n, b1, ..., b_k)
+
+ i.e. the first key parts of it are identical to uncovered parts ot the
+ key being scanned. This function assumes that the index flags do not
+ include HA_KEY_SCAN_NOT_ROR flag (that is checked elsewhere).
RETURN
- TRUE If the scan is ROR-scan
- FALSE otherwise
+ TRUE The scan is ROR-scan
+ FALSE Otherwise
*/
static bool is_key_scan_ror(PARAM *param, uint keynr, uint8 nparts)
diff --git a/sql/set_var.cc b/sql/set_var.cc
index d9869ce6809..bd5234b42be 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -616,6 +616,8 @@ sys_var_thd_time_zone sys_time_zone(&vars, "time_zone");
/* Global read-only variable containing hostname */
static sys_var_const_str sys_hostname(&vars, "hostname", glob_hostname);
+sys_var_thd_bool sys_keep_files_on_create(&vars, "keep_files_on_create",
+ &SV::keep_files_on_create);
/* Read only variables */
static sys_var_have_variable sys_have_compress(&vars, "have_compress", &have_compress);
diff --git a/sql/share/charsets/ascii.xml b/sql/share/charsets/ascii.xml
index 97006c53680..068fb84eeae 100644
--- a/sql/share/charsets/ascii.xml
+++ b/sql/share/charsets/ascii.xml
@@ -97,7 +97,7 @@
0040 0041 0042 0043 0044 0045 0046 0047 0048 0049 004A 004B 004C 004D 004E 004F
0050 0051 0052 0053 0054 0055 0056 0057 0058 0059 005A 005B 005C 005D 005E 005F
0060 0061 0062 0063 0064 0065 0066 0067 0068 0069 006A 006B 006C 006D 006E 006F
-0070 0071 0072 0073 0074 0075 0076 0077 0078 0079 007A 007B 007C 007D 007E 0000
+0070 0071 0072 0073 0074 0075 0076 0077 0078 0079 007A 007B 007C 007D 007E 007F
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
diff --git a/sql/sql_class.h b/sql/sql_class.h
index f60ec2cfb61..7fa66893f69 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -315,6 +315,7 @@ struct system_variables
my_bool old_mode;
my_bool query_cache_wlock_invalidate;
my_bool engine_condition_pushdown;
+ my_bool keep_files_on_create;
my_bool ndb_force_send;
my_bool ndb_use_copying_alter_table;
my_bool ndb_use_exact_count;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index b4cf5231827..b14241bbef3 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1425,7 +1425,8 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info)
table->file->adjust_next_insert_id_after_explicit_value(
table->next_number_field->val_int());
info->touched++;
- if ((table->file->ha_table_flags() & HA_PARTIAL_COLUMN_READ) ||
+ if ((table->file->ha_table_flags() & HA_PARTIAL_COLUMN_READ &&
+ !bitmap_is_subset(table->write_set, table->read_set)) ||
compare_record(table))
{
if ((error=table->file->ha_update_row(table->record[1],
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index dc8a10a013f..be6d1f74852 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -8703,9 +8703,15 @@ static void restore_prev_nj_state(JOIN_TAB *last)
{
TABLE_LIST *last_emb= last->table->pos_in_table_list->embedding;
JOIN *join= last->join;
- while (last_emb && !(--last_emb->nested_join->counter))
+ while (last_emb)
{
- join->cur_embedding_map &= last_emb->nested_join->nj_map;
+ if (!(--last_emb->nested_join->counter))
+ join->cur_embedding_map&= ~last_emb->nested_join->nj_map;
+ else if (last_emb->nested_join->join_list.elements-1 ==
+ last_emb->nested_join->counter)
+ join->cur_embedding_map|= last_emb->nested_join->nj_map;
+ else
+ break;
last_emb= last_emb->embedding;
}
}
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index c603f1ad77f..dc3e72554fa 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -4655,8 +4655,11 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
DBUG_EXECUTE_IF("sleep_create_like_before_ha_create", my_sleep(6000000););
dst_path[dst_path_length - reg_ext_length]= '\0'; // Remove .frm
+ if (thd->variables.keep_files_on_create)
+ create_info->options|= HA_CREATE_KEEP_FILES;
err= ha_create_table(thd, dst_path, db, table_name, create_info, 1);
VOID(pthread_mutex_unlock(&LOCK_open));
+
if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
{
if (err || !open_temporary_table(thd, dst_path, db, table_name, 1))
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 873aa6cfbeb..1016a23b5ae 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -300,6 +300,17 @@ int mysql_update(THD *thd,
if (cond_value == Item::COND_FALSE)
limit= 0; // Impossible WHERE
}
+
+ /*
+ If a timestamp field settable on UPDATE is present then to avoid wrong
+ update force the table handler to retrieve write-only fields to be able
+ to compare records and detect data change.
+ */
+ if (table->file->ha_table_flags() & HA_PARTIAL_COLUMN_READ &&
+ table->timestamp_field &&
+ (table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_UPDATE ||
+ table->timestamp_field_type == TIMESTAMP_AUTO_SET_ON_BOTH))
+ bitmap_union(table->read_set, table->write_set);
// Don't count on usage of 'only index' when calculating which key to use
table->covering_keys.clear_all();
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 57847bc70c6..f9e8e54439a 100644
--- a/sql/unireg.cc
+++ b/sql/unireg.cc
@@ -355,6 +355,8 @@ int rea_create_table(THD *thd, const char *path,
// Make sure mysql_create_frm din't remove extension
DBUG_ASSERT(*fn_rext(frm_name));
+ if (thd->variables.keep_files_on_create)
+ create_info->options|= HA_CREATE_KEEP_FILES;
if (file->create_handler_files(path, NULL, CHF_CREATE_FLAG, create_info))
goto err_handler;
if (!create_info->frm_only && ha_create_table(thd, path, db, table_name,
diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc
index 86bc2cc516e..f2b67f20c57 100644
--- a/storage/heap/ha_heap.cc
+++ b/storage/heap/ha_heap.cc
@@ -125,6 +125,26 @@ int ha_heap::close(void)
/*
+ Create a copy of this table
+
+ DESCRIPTION
+ Do same as default implementation but use file->s->name instead of
+ table->s->path. This is needed by Windows where the clone() call sees
+ '/'-delimited path in table->s->path, while ha_peap::open() was called
+ with '\'-delimited path.
+*/
+
+handler *ha_heap::clone(MEM_ROOT *mem_root)
+{
+ handler *new_handler= get_new_handler(table->s, mem_root, table->s->db_type());
+ if (new_handler && !new_handler->ha_open(table, file->s->name, table->db_stat,
+ HA_OPEN_IGNORE_IF_LOCKED))
+ return new_handler;
+ return NULL; /* purecov: inspected */
+}
+
+
+/*
Compute which keys to use for scanning
SYNOPSIS
diff --git a/storage/heap/ha_heap.h b/storage/heap/ha_heap.h
index f41c710716d..c414383a4aa 100644
--- a/storage/heap/ha_heap.h
+++ b/storage/heap/ha_heap.h
@@ -32,6 +32,7 @@ class ha_heap: public handler
public:
ha_heap(handlerton *hton, TABLE_SHARE *table);
~ha_heap() {}
+ handler *clone(MEM_ROOT *mem_root);
const char *table_type() const
{
return (table->in_use->variables.sql_mode & MODE_MYSQL323) ?
@@ -55,8 +56,8 @@ public:
ulong index_flags(uint inx, uint part, bool all_parts) const
{
return ((table_share->key_info[inx].algorithm == HA_KEY_ALG_BTREE) ?
- HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | HA_READ_RANGE :
- HA_ONLY_WHOLE_INDEX);
+ HA_READ_NEXT | HA_READ_PREV | HA_READ_ORDER | HA_READ_RANGE :
+ HA_ONLY_WHOLE_INDEX | HA_KEY_SCAN_NOT_ROR);
}
const key_map *keys_to_use_for_scanning() { return &btree_keys; }
uint max_supported_keys() const { return MAX_KEY; }
@@ -108,9 +109,7 @@ public:
enum thr_lock_type lock_type);
int cmp_ref(const uchar *ref1, const uchar *ref2)
{
- HEAP_PTR ptr1=*(HEAP_PTR*)ref1;
- HEAP_PTR ptr2=*(HEAP_PTR*)ref2;
- return ptr1 < ptr2? -1 : (ptr1 > ptr2? 1 : 0);
+ return memcmp(ref1, ref2, sizeof(HEAP_PTR));
}
bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes);
private:
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 20f55545282..c86459ae0a7 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -1889,6 +1889,8 @@ int ha_myisam::create(const char *name, register TABLE *table_arg,
if (ha_create_info->options & HA_LEX_CREATE_TMP_TABLE)
create_flags|= HA_CREATE_TMP_TABLE;
+ if (ha_create_info->options & HA_CREATE_KEEP_FILES)
+ create_flags|= HA_CREATE_KEEP_FILES;
if (options & HA_OPTION_PACK_RECORD)
create_flags|= HA_PACK_RECORD;
if (options & HA_OPTION_CHECKSUM)
diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c
index c177aa8d987..0cac5f08b3b 100644
--- a/storage/myisam/mi_create.c
+++ b/storage/myisam/mi_create.c
@@ -615,7 +615,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
(have_iext ? MY_REPLACE_EXT : MY_APPEND_EXT));
linkname_ptr=0;
/* Replace the current file */
- create_flag=MY_DELETE_OLD;
+ create_flag=(flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD;
}
/*
@@ -689,7 +689,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
fn_format(filename,name,"", MI_NAME_DEXT,
MY_UNPACK_FILENAME | MY_APPEND_EXT);
linkname_ptr=0;
- create_flag=MY_DELETE_OLD;
+ create_flag=(flags & HA_CREATE_KEEP_FILES) ? 0 : MY_DELETE_OLD;
}
if ((dfile=
my_create_with_symlink(linkname_ptr, filename, 0, create_mode,
diff --git a/storage/myisam/sp_key.c b/storage/myisam/sp_key.c
index be4021935c4..3748a38ff81 100644
--- a/storage/myisam/sp_key.c
+++ b/storage/myisam/sp_key.c
@@ -31,11 +31,6 @@ static int sp_get_geometry_mbr(uchar *(*wkb), uchar *end, uint n_dims,
double *mbr, int top);
static int sp_mbr_from_wkb(uchar (*wkb), uint size, uint n_dims, double *mbr);
-static void get_double(double *d, const uchar *pos)
-{
- float8get(*d, pos);
-}
-
uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key,
const uchar *record, my_off_t filepos)
{
@@ -62,48 +57,40 @@ uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key,
for (i = 0, keyseg = keyinfo->seg; keyseg->type; keyseg++, i++)
{
- uint length = keyseg->length;
+ uint length = keyseg->length, start= keyseg->start;
+ double val;
+
+ DBUG_ASSERT(length == sizeof(double));
+ DBUG_ASSERT(!(start % sizeof(double)));
+ DBUG_ASSERT(start < sizeof(mbr));
+ DBUG_ASSERT(keyseg->type == HA_KEYTYPE_DOUBLE);
- pos = ((uchar*)mbr) + keyseg->start;
- if (keyseg->flag & HA_SWAP_KEY)
- {
+ val= mbr[start / sizeof (double)];
#ifdef HAVE_ISNAN
- if (keyseg->type == HA_KEYTYPE_FLOAT)
- {
- float nr;
- float4get(nr, pos);
- if (isnan(nr))
- {
- /* Replace NAN with zero */
- bzero(key, length);
- key+= length;
- continue;
- }
- }
- else if (keyseg->type == HA_KEYTYPE_DOUBLE)
- {
- double nr;
- get_double(&nr, pos);
- if (isnan(nr))
- {
- bzero(key, length);
- key+= length;
- continue;
- }
- }
+ if (isnan(val))
+ {
+ bzero(key, length);
+ key+= length;
+ len+= length;
+ continue;
+ }
#endif
- pos += length;
- while (length--)
- {
+
+ if (keyseg->flag & HA_SWAP_KEY)
+ {
+ uchar buf[sizeof(double)];
+
+ float8store(buf, val);
+ pos= &buf[length];
+ while (pos > buf)
*key++ = *--pos;
- }
}
else
{
- memcpy((uchar*)key, pos, length);
- key += keyseg->length;
+ float8store((uchar *)key, val);
+ key += length;
}
- len += keyseg->length;
+ len+= length;
}
_mi_dpointer(info, key, filepos);
return len;
@@ -141,13 +128,13 @@ static int sp_add_point_to_mbr(uchar *(*wkb), uchar *end, uint n_dims,
{
if ((*wkb) > end - 8)
return -1;
- get_double(&ord, (const uchar*) *wkb);
+ float8get(ord, (const uchar*) *wkb);
(*wkb)+= 8;
if (ord < *mbr)
- float8store((char*) mbr, ord);
+ *mbr= ord;
mbr++;
if (ord > *mbr)
- float8store((char*) mbr, ord);
+ *mbr= ord;
mbr++;
}
return 0;
diff --git a/strings/conf_to_src.c b/strings/conf_to_src.c
index e2ac9846c85..75776d5e6d0 100644
--- a/strings/conf_to_src.c
+++ b/strings/conf_to_src.c
@@ -243,6 +243,28 @@ void dispcset(FILE *f,CHARSET_INFO *cs)
}
+static void
+fprint_copyright(FILE *file)
+{
+ fprintf(file,
+"/* Copyright (C) 2000-2007 MySQL AB\n"
+"\n"
+" This program is free software; you can redistribute it and/or modify\n"
+" it under the terms of the GNU General Public License as published by\n"
+" the Free Software Foundation; version 2 of the License.\n"
+"\n"
+" This program is distributed in the hope that it will be useful,\n"
+" but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
+" GNU General Public License for more details.\n"
+"\n"
+" You should have received a copy of the GNU General Public License\n"
+" along with this program; if not, write to the Free Software\n"
+" Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */\n"
+"\n");
+}
+
+
int
main(int argc, char **argv __attribute__((unused)))
{
@@ -283,6 +305,7 @@ main(int argc, char **argv __attribute__((unused)))
"directory:\n");
fprintf(f, " ./conf_to_src ../sql/share/charsets/ > FILE\n");
fprintf(f, "*/\n\n");
+ fprint_copyright(f);
fprintf(f,"#include <my_global.h>\n");
fprintf(f,"#include <m_ctype.h>\n\n");
diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c
index 72b00679e1c..a0ff0314246 100644
--- a/strings/ctype-cp932.c
+++ b/strings/ctype-cp932.c
@@ -250,9 +250,16 @@ static int my_strnncollsp_cp932(CHARSET_INFO *cs __attribute__((unused)),
const uchar *a_end= a + a_length;
const uchar *b_end= b + b_length;
int res= my_strnncoll_cp932_internal(cs, &a, a_length, &b, b_length);
+
+#ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
+ diff_if_only_endspace_difference= 0;
+#endif
+
if (!res && (a != a_end || b != b_end))
{
- int swap= 0;
+ int swap= 1;
+ if (diff_if_only_endspace_difference)
+ res= 1; /* Assume 'a' is bigger */
/*
Check the next not space character of the longer key. If it's < ' ',
then it's smaller than the other key.
@@ -263,11 +270,12 @@ static int my_strnncollsp_cp932(CHARSET_INFO *cs __attribute__((unused)),
a_end= b_end;
a= b;
swap= -1; /* swap sign of result */
+ res= -res;
}
for (; a < a_end ; a++)
{
- if (*a != ' ')
- return ((int) *a - (int) ' ') ^ swap;
+ if (*a != (uchar) ' ')
+ return (*a < (uchar) ' ') ? -swap : swap;
}
}
return res;
diff --git a/strings/ctype-extra.c b/strings/ctype-extra.c
index 2b66989ed3e..6d595af51ae 100644
--- a/strings/ctype-extra.c
+++ b/strings/ctype-extra.c
@@ -6,6 +6,21 @@
./conf_to_src ../sql/share/charsets/ > FILE
*/
+/* Copyright (C) 2000-2007 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
+
#include <my_global.h>
#include <m_ctype.h>
@@ -908,7 +923,7 @@ uint16 to_uni_ascii_general_ci[] = {
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067,
0x0068,0x0069,0x006A,0x006B,0x006C,0x006D,0x006E,0x006F,
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077,
-0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x0000,
+0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x007F,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
@@ -4589,7 +4604,7 @@ uint16 to_uni_ascii_bin[] = {
0x0060,0x0061,0x0062,0x0063,0x0064,0x0065,0x0066,0x0067,
0x0068,0x0069,0x006A,0x006B,0x006C,0x006D,0x006E,0x006F,
0x0070,0x0071,0x0072,0x0073,0x0074,0x0075,0x0076,0x0077,
-0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x0000,
+0x0078,0x0079,0x007A,0x007B,0x007C,0x007D,0x007E,0x007F,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c
index 9a80b932d20..6b71f29f0d2 100644
--- a/strings/ctype-simple.c
+++ b/strings/ctype-simple.c
@@ -185,7 +185,7 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, size_t a_length,
}
for (end= a + a_length-length; a < end ; a++)
{
- if (*a != ' ')
+ if (map[*a] != ' ')
return (map[*a] < ' ') ? -swap : swap;
}
}
diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c
index 851cef54b5b..2b248f1eed5 100644
--- a/strings/ctype-utf8.c
+++ b/strings/ctype-utf8.c
@@ -2812,16 +2812,19 @@ static int my_strnncoll_utf8_cs(CHARSET_INFO *cs,
static int my_strnncollsp_utf8_cs(CHARSET_INFO *cs,
const uchar *s, size_t slen,
const uchar *t, size_t tlen,
- my_bool diff_if_only_endspace_difference
- __attribute__((unused)))
+ my_bool diff_if_only_endspace_difference)
{
- int s_res,t_res;
- my_wc_t s_wc,t_wc;
- const uchar *se= s+slen;
- const uchar *te= t+tlen;
- int save_diff = 0;
+ int s_res, t_res, res;
+ my_wc_t s_wc, t_wc;
+ const uchar *se= s + slen;
+ const uchar *te= t + tlen;
+ int save_diff= 0;
MY_UNICASE_INFO **uni_plane= cs->caseinfo;
-
+
+#ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE
+ diff_if_only_endspace_difference= 0;
+#endif
+
while ( s < se && t < te )
{
int plane;
@@ -2853,16 +2856,20 @@ static int my_strnncollsp_utf8_cs(CHARSET_INFO *cs,
slen= se-s;
tlen= te-t;
+ res= 0;
if (slen != tlen)
{
- int swap= 0;
+ int swap= 1;
+ if (diff_if_only_endspace_difference)
+ res= 1; /* Assume 'a' is bigger */
if (slen < tlen)
{
slen= tlen;
s= t;
se= te;
swap= -1;
+ res= -res;
}
/*
This following loop uses the fact that in UTF-8
@@ -2876,8 +2883,8 @@ static int my_strnncollsp_utf8_cs(CHARSET_INFO *cs,
*/
for ( ; s < se; s++)
{
- if (*s != ' ')
- return ((int)*s - (int) ' ') ^ swap;
+ if (*s != (uchar) ' ')
+ return (*s < (uchar) ' ') ? -swap : swap;
}
}
return save_diff;
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 51f627a16de..eac1ad413ea 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -16271,6 +16271,38 @@ static void test_bug27592()
}
+
+/*
+ Bug#29687 mysql_stmt_store_result memory leak in libmysqld
+*/
+
+static void test_bug29687()
+{
+ const int NUM_ITERATIONS= 40;
+ int i;
+ int rc;
+ MYSQL_STMT *stmt= NULL;
+
+ DBUG_ENTER("test_bug29687");
+ myheader("test_bug29687");
+
+ stmt= mysql_simple_prepare(mysql, "SELECT 1 FROM dual WHERE 0=2");
+ DIE_UNLESS(stmt);
+
+ for (i= 0; i < NUM_ITERATIONS; i++)
+ {
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+ mysql_stmt_store_result(stmt);
+ while (mysql_stmt_fetch(stmt)==0);
+ mysql_stmt_free_result(stmt);
+ }
+
+ mysql_stmt_close(stmt);
+ DBUG_VOID_RETURN;
+}
+
+
/*
Bug #29692 Single row inserts can incorrectly report a huge number of
row insertions
@@ -16592,6 +16624,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug28505", test_bug28505 },
{ "test_bug28934", test_bug28934 },
{ "test_bug27592", test_bug27592 },
+ { "test_bug29687", test_bug29687 },
{ "test_bug29692", test_bug29692 },
{ 0, 0 }
};