summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--VC++Files/mysys/mysys.dsp5
-rw-r--r--VC++Files/mysys/mysys_ia64.dsp7
-rw-r--r--include/my_global.h2
-rw-r--r--include/my_sys.h5
-rw-r--r--mysql-test/r/information_schema.result12
-rw-r--r--mysql-test/r/information_schema_inno.result21
-rw-r--r--mysql-test/r/join_outer.result18
-rw-r--r--mysql-test/r/range.result76
-rw-r--r--mysql-test/r/reserved_win_names.require2
-rw-r--r--mysql-test/r/reserved_win_names.result7
-rw-r--r--mysql-test/r/sp-error.result4
-rw-r--r--mysql-test/r/subselect.result19
-rw-r--r--mysql-test/t/information_schema_inno.test8
-rw-r--r--mysql-test/t/join_outer.test23
-rw-r--r--mysql-test/t/range.test40
-rw-r--r--mysql-test/t/reserved_win_names-master.opt1
-rw-r--r--mysql-test/t/reserved_win_names.test12
-rw-r--r--mysql-test/t/sp-error.test12
-rw-r--r--mysql-test/t/subselect.test17
-rw-r--r--mysys/Makefile.am2
-rw-r--r--mysys/mf_pack.c2
-rw-r--r--mysys/my_access.c53
-rw-r--r--sql/field_conv.cc6
-rw-r--r--sql/ha_innodb.cc2
-rw-r--r--sql/item.h1
-rw-r--r--sql/item_sum.cc9
-rw-r--r--sql/opt_range.cc139
-rw-r--r--sql/sql_db.cc2
-rw-r--r--sql/sql_delete.cc2
-rw-r--r--sql/sql_parse.cc2
-rw-r--r--sql/sql_select.cc30
-rw-r--r--sql/sql_show.cc17
-rw-r--r--sql/sql_udf.cc2
-rw-r--r--sql/sql_yacc.yy13
-rw-r--r--storage/myisam/rt_split.c20
-rw-r--r--storage/myisam/sp_key.c10
-rw-r--r--storage/ndb/src/kernel/SimBlockList.cpp1
-rw-r--r--storage/ndb/src/ndbapi/Ndb.cpp3
-rw-r--r--strings/my_vsnprintf.c10
39 files changed, 529 insertions, 88 deletions
diff --git a/VC++Files/mysys/mysys.dsp b/VC++Files/mysys/mysys.dsp
index 64c4378b678..428f75d0045 100644
--- a/VC++Files/mysys/mysys.dsp
+++ b/VC++Files/mysys/mysys.dsp
@@ -186,6 +186,11 @@ SOURCE=.\array.c
!ENDIF
# End Source File
+
+# Begin Source File
+SOURCE=".\my_access.c"
+# End Source File
+
# Begin Source File
SOURCE=".\charset-def.c"
diff --git a/VC++Files/mysys/mysys_ia64.dsp b/VC++Files/mysys/mysys_ia64.dsp
index ed2dac53579..a0877457286 100644
--- a/VC++Files/mysys/mysys_ia64.dsp
+++ b/VC++Files/mysys/mysys_ia64.dsp
@@ -163,6 +163,13 @@ LIB32=link.exe -lib
# Name "mysys - WinIA64 Max"
# Name "mysys - WinIA64 TLS_DEBUG"
# Name "mysys - WinIA64 TLS"
+
+# Begin Source File
+
+SOURCE=.\my_access.c
+
+# End Source File
+
# Begin Source File
SOURCE=.\array.c
diff --git a/include/my_global.h b/include/my_global.h
index 5448aa3e871..068832e927d 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -285,7 +285,7 @@ C_MODE_END
# endif
#endif /* TIME_WITH_SYS_TIME */
#ifdef HAVE_UNISTD_H
-#if defined(HAVE_OPENSSL) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__)
+#if defined(HAVE_OPENSSL) && !defined(__FreeBSD__) && !defined(NeXT) && !defined(__OpenBSD__) && !defined(__APPLE__)
#define crypt unistd_crypt
#endif
#include <unistd.h>
diff --git a/include/my_sys.h b/include/my_sys.h
index 473251f26cb..10358470c77 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -600,6 +600,11 @@ extern char *_my_strdup_with_length(const byte *from, uint length,
const char *sFile, uint uLine,
myf MyFlag);
+#ifdef __WIN__
+extern int my_access(const char *path, int amode);
+#else
+#define my_access access
+#endif
#ifndef TERMINATE
extern void TERMINATE(FILE *file);
diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
index 0b993d681e3..ab57a918e98 100644
--- a/mysql-test/r/information_schema.result
+++ b/mysql-test/r/information_schema.result
@@ -412,11 +412,11 @@ NULL test key_1 test t1 UNIQUE
NULL test key_2 test t1 UNIQUE
select * from information_schema.KEY_COLUMN_USAGE where
TABLE_SCHEMA= "test";
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT
-NULL test PRIMARY NULL test t1 a 1 NULL
-NULL test constraint_1 NULL test t1 a 1 NULL
-NULL test key_1 NULL test t1 a 1 NULL
-NULL test key_2 NULL test t1 a 1 NULL
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
+NULL test PRIMARY NULL test t1 a 1 NULL NULL NULL NULL
+NULL test constraint_1 NULL test t1 a 1 NULL NULL NULL NULL
+NULL test key_1 NULL test t1 a 1 NULL NULL NULL NULL
+NULL test key_2 NULL test t1 a 1 NULL NULL NULL NULL
select table_name from information_schema.TABLES where table_schema like "test%";
table_name
t1
@@ -560,7 +560,7 @@ TABLE_NAME= "vo";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
select * from information_schema.KEY_COLUMN_USAGE where
TABLE_NAME= "vo";
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
drop view vo;
select TABLE_NAME,TABLE_TYPE,ENGINE
from information_schema.tables
diff --git a/mysql-test/r/information_schema_inno.result b/mysql-test/r/information_schema_inno.result
index a38139ba753..9dd92baf62f 100644
--- a/mysql-test/r/information_schema_inno.result
+++ b/mysql-test/r/information_schema_inno.result
@@ -1,8 +1,10 @@
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
-CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id),
+CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id, id),
FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE,
FOREIGN KEY (t1_id) REFERENCES t1(id) ON UPDATE CASCADE) ENGINE=INNODB;
+CREATE TABLE t3 (id INT PRIMARY KEY, t2_id INT, INDEX par_ind (t2_id),
+FOREIGN KEY (id, t2_id) REFERENCES t2(t1_id, id) ON DELETE CASCADE) ENGINE=INNODB;
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_SCHEMA= "test";
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE
@@ -10,11 +12,16 @@ NULL test PRIMARY test t1 PRIMARY KEY
NULL test PRIMARY test t2 PRIMARY KEY
NULL test t2_ibfk_1 test t2 FOREIGN KEY
NULL test t2_ibfk_2 test t2 FOREIGN KEY
+NULL test PRIMARY test t3 PRIMARY KEY
+NULL test t3_ibfk_1 test t3 FOREIGN KEY
select * from information_schema.KEY_COLUMN_USAGE where
TABLE_SCHEMA= "test";
-CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT
-NULL test PRIMARY NULL test t1 id 1 NULL
-NULL test PRIMARY NULL test t2 id 1 NULL
-NULL test t2_ibfk_1 NULL test t2 t1_id 1 1
-NULL test t2_ibfk_2 NULL test t2 t1_id 1 1
-drop table t2, t1;
+CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION POSITION_IN_UNIQUE_CONSTRAINT REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
+NULL test PRIMARY NULL test t1 id 1 NULL NULL NULL NULL
+NULL test PRIMARY NULL test t2 id 1 NULL NULL NULL NULL
+NULL test t2_ibfk_1 NULL test t2 t1_id 1 1 test t1 id
+NULL test t2_ibfk_2 NULL test t2 t1_id 1 1 test t1 id
+NULL test PRIMARY NULL test t3 id 1 NULL NULL NULL NULL
+NULL test t3_ibfk_1 NULL test t3 id 1 1 test t2 t1_id
+NULL test t3_ibfk_1 NULL test t3 t2_id 2 2 test t2 id
+drop table t3, t2, t1;
diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result
index 2bf1155d2b5..e69e7603e21 100644
--- a/mysql-test/r/join_outer.result
+++ b/mysql-test/r/join_outer.result
@@ -957,3 +957,21 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 const PRIMARY,id PRIMARY 14 const,const,const,const 1 Using index
1 SIMPLE t3 const PRIMARY PRIMARY 3 const,const 1
drop tables t1,t2,t3;
+CREATE TABLE t1 (EMPNUM INT, GRP INT);
+INSERT INTO t1 VALUES (0, 10);
+INSERT INTO t1 VALUES (2, 30);
+CREATE TABLE t2 (EMPNUM INT, NAME CHAR(5));
+INSERT INTO t2 VALUES (0, 'KERI');
+INSERT INTO t2 VALUES (9, 'BARRY');
+CREATE VIEW v1 AS
+SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS EMPNUM, NAME, GRP
+FROM t2 LEFT OUTER JOIN t1 ON t2.EMPNUM=t1.EMPNUM;
+SELECT * FROM v1;
+EMPNUM NAME GRP
+0 KERI 10
+9 BARRY NULL
+SELECT * FROM v1 WHERE EMPNUM < 10;
+EMPNUM NAME GRP
+0 KERI 10
+9 BARRY NULL
+DROP TABLE t1,t2;
diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result
index 095690fde00..c7d27a8e60d 100644
--- a/mysql-test/r/range.result
+++ b/mysql-test/r/range.result
@@ -584,3 +584,79 @@ SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 2' OR ARG1 != ' 1');
count(*)
4
drop table t1;
+CREATE TABLE t1 (
+id int(11) NOT NULL auto_increment,
+status varchar(20),
+PRIMARY KEY (id),
+KEY (status)
+);
+INSERT INTO t1 VALUES
+(1,'B'), (2,'B'), (3,'B'), (4,'B'), (5,'B'), (6,'B'),
+(7,'B'), (8,'B'), (9,'B'), (10,'B'), (11,'B'), (12,'B'),
+(13,'B'), (14,'B'), (15,'B'), (16,'B'), (17,'B'), (18,'B'),
+(19,'B'), (20,'B'), (21,'B'), (22,'B'), (23,'B'), (24,'B'),
+(25,'A'), (26,'A'), (27,'A'), (28,'A'), (29,'A'), (30,'A'),
+(31,'A'), (32,'A'), (33,'A'), (34,'A'), (35,'A'), (36,'A'),
+(37,'A'), (38,'A'), (39,'A'), (40,'A'), (41,'A'), (42,'A'),
+(43,'A'), (44,'A'), (45,'A'), (46,'A'), (47,'A'), (48,'A'),
+(49,'A'), (50,'A'), (51,'A'), (52,'A'), (53,'C'), (54,'C'),
+(55,'C'), (56,'C'), (57,'C'), (58,'C'), (59,'C'), (60,'C');
+EXPLAIN SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range status status 23 NULL 11 Using where
+EXPLAIN SELECT * FROM t1 WHERE status NOT IN ('A','B');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range status status 23 NULL 11 Using where
+SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
+id status
+53 C
+54 C
+55 C
+56 C
+57 C
+58 C
+59 C
+60 C
+SELECT * FROM t1 WHERE status NOT IN ('A','B');
+id status
+53 C
+54 C
+55 C
+56 C
+57 C
+58 C
+59 C
+60 C
+EXPLAIN SELECT status FROM t1 WHERE status <> 'A' AND status <> 'B';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range status status 23 NULL 11 Using where; Using index
+EXPLAIN SELECT status FROM t1 WHERE status NOT IN ('A','B');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range status status 23 NULL 11 Using where; Using index
+EXPLAIN SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range status status 23 NULL 10 Using where
+EXPLAIN SELECT * FROM t1 WHERE status < 'A' OR status > 'B';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range status status 23 NULL 10 Using where
+SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
+id status
+53 C
+54 C
+55 C
+56 C
+57 C
+58 C
+59 C
+60 C
+SELECT * FROM t1 WHERE status < 'A' OR status > 'B';
+id status
+53 C
+54 C
+55 C
+56 C
+57 C
+58 C
+59 C
+60 C
+DROP TABLE t1;
diff --git a/mysql-test/r/reserved_win_names.require b/mysql-test/r/reserved_win_names.require
new file mode 100644
index 00000000000..7f803aca482
--- /dev/null
+++ b/mysql-test/r/reserved_win_names.require
@@ -0,0 +1,2 @@
+Variable_name Value
+lower_case_table_names 1
diff --git a/mysql-test/r/reserved_win_names.result b/mysql-test/r/reserved_win_names.result
new file mode 100644
index 00000000000..eaa0f71513f
--- /dev/null
+++ b/mysql-test/r/reserved_win_names.result
@@ -0,0 +1,7 @@
+use COM1;
+ERROR 42000: Unknown database 'com1'
+use LPT1;
+ERROR 42000: Unknown database 'lpt1'
+use PRN;
+ERROR 42000: Unknown database 'prn'
+
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result
index 683f3e12091..7c19f60471a 100644
--- a/mysql-test/r/sp-error.result
+++ b/mysql-test/r/sp-error.result
@@ -642,4 +642,8 @@ val x bug8408()
7 7 3
drop function bug8408|
delete from t1|
+drop procedure if exists bug10537|
+create procedure bug10537()
+load data local infile '/tmp/somefile' into table t1|
+ERROR 0A000: LOAD DATA is not allowed in stored procedures
drop table t1|
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 028eb730191..6703147c635 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -333,7 +333,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 Using index
Warnings:
Note 1276 Field or reference 'clinic_uq' of SELECT #2 was resolved in SELECT #1
-Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where exists(select 1 AS `Not_used` from `test`.`t7` where (`test`.`t6`.`clinic_uq` = `test`.`t7`.`uq`))
+Note 1003 select `test`.`t6`.`patient_uq` AS `patient_uq`,`test`.`t6`.`clinic_uq` AS `clinic_uq` from `test`.`t6` where exists(select 1 AS `Not_used` from `test`.`t7` where (`test`.`t7`.`uq` = `test`.`t6`.`clinic_uq`))
select * from t1 where a= (select a from t2,t4 where t2.b=t4.b);
ERROR 23000: Column 'a' in field list is ambiguous
drop table t1,t2,t3;
@@ -1744,7 +1744,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.tt.id 1 Using where; Using index
Warnings:
Note 1276 Field or reference 'tt.id' of SELECT #2 was resolved in SELECT #1
-Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where not(exists(select `test`.`t1`.`id` AS `id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`tt`.`id` = `test`.`t1`.`id`)) having (`test`.`t1`.`id` is not null)))
+Note 1003 select `test`.`tt`.`id` AS `id`,`test`.`tt`.`text` AS `text` from `test`.`t1` `tt` where not(exists(select `test`.`t1`.`id` AS `id` from `test`.`t1` where ((`test`.`t1`.`id` < 8) and (`test`.`t1`.`id` = `test`.`tt`.`id`)) having (`test`.`t1`.`id` is not null)))
insert into t1 (id, text) values (1000, 'text1000'), (1001, 'text1001');
create table t2 (id int not null, text varchar(20) not null default '', primary key (id));
insert into t2 (id, text) values (1, 'text1'), (2, 'text2'), (3, 'text3'), (4, 'text4'), (5, 'text5'), (6, 'text6'), (7, 'text7'), (8, 'text8'), (9, 'text9'), (10, 'text10'), (11, 'text1'), (12, 'text2'), (13, 'text3'), (14, 'text4'), (15, 'text5'), (16, 'text6'), (17, 'text7'), (18, 'text8'), (19, 'text9'), (20, 'text10'),(21, 'text1'), (22, 'text2'), (23, 'text3'), (24, 'text4'), (25, 'text5'), (26, 'text6'), (27, 'text7'), (28, 'text8'), (29, 'text9'), (30, 'text10'), (31, 'text1'), (32, 'text2'), (33, 'text3'), (34, 'text4'), (35, 'text5'), (36, 'text6'), (37, 'text7'), (38, 'text8'), (39, 'text9'), (40, 'text10'), (41, 'text1'), (42, 'text2'), (43, 'text3'), (44, 'text4'), (45, 'text5'), (46, 'text6'), (47, 'text7'), (48, 'text8'), (49, 'text9'), (50, 'text10');
@@ -2272,7 +2272,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where
Warnings:
Note 1276 Field or reference 'up.a' of SELECT #2 was resolved in SELECT #1
-Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where exists(select 1 AS `Not_used` from `test`.`t1` where (`test`.`up`.`a` = `test`.`t1`.`a`))
+Note 1003 select `test`.`up`.`a` AS `a`,`test`.`up`.`b` AS `b` from `test`.`t1` `up` where exists(select 1 AS `Not_used` from `test`.`t1` where (`test`.`t1`.`a` = `test`.`up`.`a`))
drop table t1;
CREATE TABLE t1 (t1_a int);
INSERT INTO t1 VALUES (1);
@@ -2803,3 +2803,16 @@ SELECT s.ip, count( e.itemid ) FROM `t1` e JOIN t2 s ON s.sessionid = e.sessioni
ip count( e.itemid )
10.10.10.1 1
drop tables t1,t2;
+CREATE TABLE t1 (EMPNUM CHAR(3));
+CREATE TABLE t2 (EMPNUM CHAR(3) );
+INSERT INTO t1 VALUES ('E1'),('E2');
+INSERT INTO t2 VALUES ('E1');
+DELETE FROM t1
+WHERE t1.EMPNUM NOT IN
+(SELECT t2.EMPNUM
+FROM t2
+WHERE t1.EMPNUM = t2.EMPNUM);
+select * from t1;
+EMPNUM
+E1
+DROP TABLE t1,t2;
diff --git a/mysql-test/t/information_schema_inno.test b/mysql-test/t/information_schema_inno.test
index af8bd9f98b8..dd7015bfd9a 100644
--- a/mysql-test/t/information_schema_inno.test
+++ b/mysql-test/t/information_schema_inno.test
@@ -8,12 +8,16 @@ DROP TABLE IF EXISTS t1,t2;
#
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
-CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id),
+CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id, id),
FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE,
FOREIGN KEY (t1_id) REFERENCES t1(id) ON UPDATE CASCADE) ENGINE=INNODB;
+
+CREATE TABLE t3 (id INT PRIMARY KEY, t2_id INT, INDEX par_ind (t2_id),
+FOREIGN KEY (id, t2_id) REFERENCES t2(t1_id, id) ON DELETE CASCADE) ENGINE=INNODB;
+
select * from information_schema.TABLE_CONSTRAINTS where
TABLE_SCHEMA= "test";
select * from information_schema.KEY_COLUMN_USAGE where
TABLE_SCHEMA= "test";
-drop table t2, t1;
+drop table t3, t2, t1;
diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test
index 3a34c204905..670e7433926 100644
--- a/mysql-test/t/join_outer.test
+++ b/mysql-test/t/join_outer.test
@@ -676,3 +676,26 @@ left join t3 on t1.art = t3.id where t2.id =1 and t2.x = -5 and t2.y =-8
and t1.gid =1 and t2.gid =1 and t3.set_id =1;
drop tables t1,t2,t3;
+#
+# Test for bug #9938: invalid conversion from outer join to inner join
+# for queries containing indirect reference in WHERE clause
+#
+
+CREATE TABLE t1 (EMPNUM INT, GRP INT);
+INSERT INTO t1 VALUES (0, 10);
+INSERT INTO t1 VALUES (2, 30);
+
+CREATE TABLE t2 (EMPNUM INT, NAME CHAR(5));
+INSERT INTO t2 VALUES (0, 'KERI');
+INSERT INTO t2 VALUES (9, 'BARRY');
+
+CREATE VIEW v1 AS
+SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS EMPNUM, NAME, GRP
+ FROM t2 LEFT OUTER JOIN t1 ON t2.EMPNUM=t1.EMPNUM;
+
+SELECT * FROM v1;
+SELECT * FROM v1 WHERE EMPNUM < 10;
+
+DROP TABLE t1,t2;
+
+
diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test
index 12759d9edb5..a5822602b82 100644
--- a/mysql-test/t/range.test
+++ b/mysql-test/t/range.test
@@ -455,3 +455,43 @@ SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 1' OR ARG1 != ' 2');
SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 2' OR ARG1 != ' 1');
drop table t1;
+#
+# Test for optimization request #10561: to use keys for
+# NOT IN (c1,...,cn) and NOT BETWEEN c1 AND c2
+#
+
+CREATE TABLE t1 (
+ id int(11) NOT NULL auto_increment,
+ status varchar(20),
+ PRIMARY KEY (id),
+ KEY (status)
+);
+
+INSERT INTO t1 VALUES
+(1,'B'), (2,'B'), (3,'B'), (4,'B'), (5,'B'), (6,'B'),
+(7,'B'), (8,'B'), (9,'B'), (10,'B'), (11,'B'), (12,'B'),
+(13,'B'), (14,'B'), (15,'B'), (16,'B'), (17,'B'), (18,'B'),
+(19,'B'), (20,'B'), (21,'B'), (22,'B'), (23,'B'), (24,'B'),
+(25,'A'), (26,'A'), (27,'A'), (28,'A'), (29,'A'), (30,'A'),
+(31,'A'), (32,'A'), (33,'A'), (34,'A'), (35,'A'), (36,'A'),
+(37,'A'), (38,'A'), (39,'A'), (40,'A'), (41,'A'), (42,'A'),
+(43,'A'), (44,'A'), (45,'A'), (46,'A'), (47,'A'), (48,'A'),
+(49,'A'), (50,'A'), (51,'A'), (52,'A'), (53,'C'), (54,'C'),
+(55,'C'), (56,'C'), (57,'C'), (58,'C'), (59,'C'), (60,'C');
+
+EXPLAIN SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
+EXPLAIN SELECT * FROM t1 WHERE status NOT IN ('A','B');
+
+SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
+SELECT * FROM t1 WHERE status NOT IN ('A','B');
+
+EXPLAIN SELECT status FROM t1 WHERE status <> 'A' AND status <> 'B';
+EXPLAIN SELECT status FROM t1 WHERE status NOT IN ('A','B');
+
+EXPLAIN SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
+EXPLAIN SELECT * FROM t1 WHERE status < 'A' OR status > 'B';
+
+SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
+SELECT * FROM t1 WHERE status < 'A' OR status > 'B';
+
+DROP TABLE t1;
diff --git a/mysql-test/t/reserved_win_names-master.opt b/mysql-test/t/reserved_win_names-master.opt
new file mode 100644
index 00000000000..62ab6dad1e0
--- /dev/null
+++ b/mysql-test/t/reserved_win_names-master.opt
@@ -0,0 +1 @@
+--lower_case_table_names=1
diff --git a/mysql-test/t/reserved_win_names.test b/mysql-test/t/reserved_win_names.test
new file mode 100644
index 00000000000..d9b23935ddf
--- /dev/null
+++ b/mysql-test/t/reserved_win_names.test
@@ -0,0 +1,12 @@
+#
+# Test of reserved Windows names
+#
+--require r/reserved_win_names.require
+
+--error 1049
+use COM1;
+--error 1049
+use LPT1;
+--error 1049
+use PRN;
+
diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test
index ff317b4ac28..67e9be5dd5d 100644
--- a/mysql-test/t/sp-error.test
+++ b/mysql-test/t/sp-error.test
@@ -894,6 +894,18 @@ delete from t1|
#
+# BUG#10537: Server crashes while loading data file into table through
+# procedure.
+# Disable load until it's PS and SP safe
+--disable_warnings
+drop procedure if exists bug10537|
+--enable_warnings
+--error ER_SP_BADSTATEMENT
+create procedure bug10537()
+ load data local infile '/tmp/somefile' into table t1|
+
+
+#
# BUG#NNNN: New bug synopsis
#
#--disable_warnings
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index c58a9f9de8e..2e6cea8468b 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -1777,7 +1777,6 @@ DROP TABLE t1,t2;
#
# Test for bug #9516: wrong evaluation of not_null_tables attribute in SQ
#
-
CREATE TABLE t1 ( c1 integer );
INSERT INTO t1 VALUES ( 1 );
INSERT INTO t1 VALUES ( 2 );
@@ -1822,3 +1821,19 @@ CREATE TABLE `t2` (
INSERT INTO `t2` VALUES (1, 1, 1, '10.10.10.1');
SELECT s.ip, count( e.itemid ) FROM `t1` e JOIN t2 s ON s.sessionid = e.sessionid WHERE e.sessionid = ( SELECT sessionid FROM t2 ORDER BY sessionid DESC LIMIT 1 ) GROUP BY s.ip HAVING count( e.itemid ) >0 LIMIT 0 , 30;
drop tables t1,t2;
+
+#
+# Correct building of equal fields list (do not include outer
+# fields) (BUG#6384)
+#
+CREATE TABLE t1 (EMPNUM CHAR(3));
+CREATE TABLE t2 (EMPNUM CHAR(3) );
+INSERT INTO t1 VALUES ('E1'),('E2');
+INSERT INTO t2 VALUES ('E1');
+DELETE FROM t1
+WHERE t1.EMPNUM NOT IN
+ (SELECT t2.EMPNUM
+ FROM t2
+ WHERE t1.EMPNUM = t2.EMPNUM);
+select * from t1;
+DROP TABLE t1,t2;
diff --git a/mysys/Makefile.am b/mysys/Makefile.am
index 40743e36c29..03ee692645f 100644
--- a/mysys/Makefile.am
+++ b/mysys/Makefile.am
@@ -54,7 +54,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
charset.c charset-def.c my_bitmap.c my_bit.c md5.c \
my_gethostbyname.c rijndael.c my_aes.c sha1.c \
my_handler.c my_netware.c my_largepage.c \
- my_windac.c
+ my_windac.c my_access.c
EXTRA_DIST = thr_alarm.c thr_lock.c my_pthread.c my_thr_init.c \
thr_mutex.c thr_rwlock.c
libmysys_a_LIBADD = @THREAD_LOBJECTS@
diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c
index 9193238708d..86172f648f4 100644
--- a/mysys/mf_pack.c
+++ b/mysys/mf_pack.c
@@ -226,7 +226,7 @@ void symdirget(char *dir)
{
char buff[FN_REFLEN];
char *pos=strend(dir);
- if (dir[0] && pos[-1] != FN_DEVCHAR && access(dir, F_OK))
+ if (dir[0] && pos[-1] != FN_DEVCHAR && my_access(dir, F_OK))
{
File file;
uint length;
diff --git a/mysys/my_access.c b/mysys/my_access.c
new file mode 100644
index 00000000000..6a8887e42a6
--- /dev/null
+++ b/mysys/my_access.c
@@ -0,0 +1,53 @@
+/* Copyright (C) 2000 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; either version 2 of the License, or
+ (at your option) any later version.
+
+ 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#include "mysys_priv.h"
+
+#ifdef __WIN__
+
+/*
+ * Check a file or path for accessability.
+ *
+ * SYNOPSIS
+ * file_access()
+ * pathpath to check
+ * amodemode to check
+ *
+ * DESCRIPTION
+ * This function wraps the normal access method because the access
+ * available in MSVCRT> +reports that filenames such as LPT1 and
+ * COM1 are valid (they are but should not be so for us).
+ *
+ * RETURN VALUES
+ * 0 ok
+ * -1 error
+ */
+int my_access(const char *path, int amode)
+{
+ WIN32_FILE_ATTRIBUTE_DATA fileinfo;
+ BOOL result;
+
+ result = GetFileAttributesEx(path, GetFileExInfoStandard,
+ &fileinfo);
+ if (! result)
+ return -1;
+ if ((fileinfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY) &&
+ (amode & 2))
+ return -1;
+ return 0;
+}
+
+#endif
diff --git a/sql/field_conv.cc b/sql/field_conv.cc
index ae784ae0293..15598e59bb9 100644
--- a/sql/field_conv.cc
+++ b/sql/field_conv.cc
@@ -605,7 +605,11 @@ void field_conv(Field *to,Field *from)
to->type() != FIELD_TYPE_DATE &&
to->type() != FIELD_TYPE_DATETIME))
{ // Identical fields
- memcpy(to->ptr,from->ptr,to->pack_length());
+#ifdef HAVE_purify
+ /* This may happen if one does 'UPDATE ... SET x=x' */
+ if (to->ptr != from->ptr)
+#endif
+ memcpy(to->ptr,from->ptr,to->pack_length());
return;
}
}
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index cc7a6dbacb3..09aa9ad4044 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -2606,7 +2606,7 @@ get_innobase_type_from_mysql_type(
return(DATA_MYSQL);
}
case FIELD_TYPE_NEWDECIMAL:
- return(DATA_BINARY);
+ return(DATA_FIXBINARY);
case FIELD_TYPE_LONG:
case FIELD_TYPE_LONGLONG:
case FIELD_TYPE_TINY:
diff --git a/sql/item.h b/sql/item.h
index 2bcc9482f4e..11b9460906e 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1325,6 +1325,7 @@ public:
{
return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables();
}
+ table_map not_null_tables() const { return (*ref)->not_null_tables(); }
void set_result_field(Field *field) { result_field= field; }
bool is_result_field() { return 1; }
void save_in_result_field(bool no_conversions)
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index a5694189976..85abb09531b 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -584,13 +584,8 @@ bool Item_sum_distinct::setup(THD *thd)
{
List<create_field> field_list;
create_field field_def; /* field definition */
-
DBUG_ENTER("Item_sum_distinct::setup");
-
- /*
- Setup can be called twice for ROLLUP items. This is a bug.
- Please add DBUG_ASSERT(tree == 0) here when it's fixed.
- */
+ DBUG_ASSERT(tree == 0);
/*
Virtual table and the tree are created anew on each re-execution of
@@ -610,7 +605,7 @@ bool Item_sum_distinct::setup(THD *thd)
args[0]->unsigned_flag);
if (! (table= create_virtual_tmp_table(thd, field_list)))
- return TRUE;
+ return TRUE;
/* XXX: check that the case of CHAR(0) works OK */
tree_key_length= table->s->reclength - table->s->null_bytes;
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index ef1901a6771..8f0db96edfe 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -3313,6 +3313,38 @@ QUICK_SELECT_I *TRP_ROR_UNION::make_quick(PARAM *param,
/*
+ Build a SEL_TREE for <> predicate
+
+ SYNOPSIS
+ get_ne_mm_tree()
+ param PARAM from SQL_SELECT::test_quick_select
+ cond_func item for the predicate
+ field field in the predicate
+ value constant in the predicate
+ cmp_type compare type for the field
+
+ RETURN
+ Pointer to tree built tree
+*/
+
+static SEL_TREE *get_ne_mm_tree(PARAM *param, Item_func *cond_func,
+ Field *field, Item *value,
+ Item_result cmp_type)
+{
+ SEL_TREE *tree= 0;
+ tree= get_mm_parts(param, cond_func, field, Item_func::LT_FUNC,
+ value, cmp_type);
+ if (tree)
+ {
+ tree= tree_or(param, tree, get_mm_parts(param, cond_func, field,
+ Item_func::GT_FUNC,
+ value, cmp_type));
+ }
+ return tree;
+}
+
+
+/*
Build a SEL_TREE for a simple predicate
SYNOPSIS
@@ -3322,55 +3354,86 @@ QUICK_SELECT_I *TRP_ROR_UNION::make_quick(PARAM *param,
field field in the predicate
value constant in the predicate
cmp_type compare type for the field
+ inv TRUE <> NOT cond_func is considered
+ (makes sense only when cond_func is BETWEEN or IN)
RETURN
- Pointer to thre built tree
+ Pointer to the tree built tree
*/
static SEL_TREE *get_func_mm_tree(PARAM *param, Item_func *cond_func,
Field *field, Item *value,
- Item_result cmp_type)
+ Item_result cmp_type, bool inv)
{
SEL_TREE *tree= 0;
DBUG_ENTER("get_func_mm_tree");
switch (cond_func->functype()) {
+
case Item_func::NE_FUNC:
- tree= get_mm_parts(param, cond_func, field, Item_func::LT_FUNC,
- value, cmp_type);
- if (tree)
- {
- tree= tree_or(param, tree, get_mm_parts(param, cond_func, field,
- Item_func::GT_FUNC,
- value, cmp_type));
- }
+ tree= get_ne_mm_tree(param, cond_func, field, value, cmp_type);
break;
+
case Item_func::BETWEEN:
- tree= get_mm_parts(param, cond_func, field, Item_func::GE_FUNC,
- cond_func->arguments()[1],cmp_type);
- if (tree)
+ if (inv)
{
- tree= tree_and(param, tree, get_mm_parts(param, cond_func, field,
- Item_func::LE_FUNC,
- cond_func->arguments()[2],
- cmp_type));
+ tree= get_mm_parts(param, cond_func, field, Item_func::LT_FUNC,
+ cond_func->arguments()[1],cmp_type);
+ if (tree)
+ {
+ tree= tree_or(param, tree, get_mm_parts(param, cond_func, field,
+ Item_func::GT_FUNC,
+ cond_func->arguments()[2],
+ cmp_type));
+ }
+ }
+ else
+ {
+ tree= get_mm_parts(param, cond_func, field, Item_func::GE_FUNC,
+ cond_func->arguments()[1],cmp_type);
+ if (tree)
+ {
+ tree= tree_and(param, tree, get_mm_parts(param, cond_func, field,
+ Item_func::LE_FUNC,
+ cond_func->arguments()[2],
+ cmp_type));
+ }
}
break;
+
case Item_func::IN_FUNC:
{
Item_func_in *func=(Item_func_in*) cond_func;
- tree= get_mm_parts(param, cond_func, field, Item_func::EQ_FUNC,
- func->arguments()[1], cmp_type);
- if (tree)
+
+ if (inv)
{
- Item **arg, **end;
- for (arg= func->arguments()+2, end= arg+func->argument_count()-2;
- arg < end ; arg++)
+ tree= get_ne_mm_tree(param, cond_func, field,
+ func->arguments()[1], cmp_type);
+ if (tree)
{
- tree= tree_or(param, tree, get_mm_parts(param, cond_func, field,
- Item_func::EQ_FUNC,
- *arg,
- cmp_type));
+ Item **arg, **end;
+ for (arg= func->arguments()+2, end= arg+func->argument_count()-2;
+ arg < end ; arg++)
+ {
+ tree= tree_and(param, tree, get_ne_mm_tree(param, cond_func, field,
+ *arg, cmp_type));
+ }
+ }
+ }
+ else
+ {
+ tree= get_mm_parts(param, cond_func, field, Item_func::EQ_FUNC,
+ func->arguments()[1], cmp_type);
+ if (tree)
+ {
+ Item **arg, **end;
+ for (arg= func->arguments()+2, end= arg+func->argument_count()-2;
+ arg < end ; arg++)
+ {
+ tree= tree_or(param, tree, get_mm_parts(param, cond_func, field,
+ Item_func::EQ_FUNC,
+ *arg, cmp_type));
+ }
}
}
break;
@@ -3402,6 +3465,7 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond)
SEL_TREE *tree=0;
SEL_TREE *ftree= 0;
Item_field *field_item= 0;
+ bool inv= FALSE;
Item *value;
DBUG_ENTER("get_mm_tree");
@@ -3463,8 +3527,21 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond)
}
Item_func *cond_func= (Item_func*) cond;
- if (cond_func->select_optimize() == Item_func::OPTIMIZE_NONE)
- DBUG_RETURN(0); // Can't be calculated
+ if (cond_func->functype() == Item_func::NOT_FUNC)
+ {
+ Item *arg= cond_func->arguments()[0];
+ if (arg->type() == Item::FUNC_ITEM)
+ {
+ cond_func= (Item_func*) arg;
+ if (cond_func->select_optimize() == Item_func::OPTIMIZE_NONE)
+ DBUG_RETURN(0);
+ inv= TRUE;
+ }
+ else
+ DBUG_RETURN(0);
+ }
+ else if (cond_func->select_optimize() == Item_func::OPTIMIZE_NONE)
+ DBUG_RETURN(0);
param->cond= cond;
@@ -3542,7 +3619,7 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond)
Field *field= field_item->field;
Item_result cmp_type= field->cmp_type();
if (!((ref_tables | field->table->map) & param_comp))
- ftree= get_func_mm_tree(param, cond_func, field, value, cmp_type);
+ ftree= get_func_mm_tree(param, cond_func, field, value, cmp_type, inv);
Item_equal *item_equal= field_item->item_equal;
if (item_equal)
{
@@ -3555,7 +3632,7 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond)
continue;
if (!((ref_tables | f->table->map) & param_comp))
{
- tree= get_func_mm_tree(param, cond_func, f, value, cmp_type);
+ tree= get_func_mm_tree(param, cond_func, f, value, cmp_type, inv);
ftree= !ftree ? tree : tree_and(param, ftree, tree);
}
}
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 3bdd800cd2f..d110ff6f778 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -1076,7 +1076,7 @@ bool mysql_change_db(THD *thd, const char *name)
length=unpack_dirname(path,path); // Convert if not unix
if (length && path[length-1] == FN_LIBCHAR)
path[length-1]=0; // remove ending '\'
- if (access(path,F_OK))
+ if (my_access(path,F_OK))
{
my_error(ER_BAD_DB_ERROR, MYF(0), dbname);
my_free(dbname,MYF(0));
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 5baf2afb12b..64454f82511 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -49,7 +49,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
{
my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0),
table_list->view_db.str, table_list->view_name.str);
- DBUG_RETURN(-1);
+ DBUG_RETURN(TRUE);
}
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
thd->proc_info="init";
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 81be6d897e8..677d04685c1 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1274,8 +1274,10 @@ void free_items(Item *item)
void cleanup_items(Item *item)
{
+ DBUG_ENTER("cleanup_items");
for (; item ; item=item->next)
item->cleanup();
+ DBUG_VOID_RETURN;
}
int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd)
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 7f6634f5df9..c36dfbc1cf8 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2818,6 +2818,22 @@ add_key_fields(KEY_FIELD **key_fields,uint *and_level,
if (cond->type() != Item::FUNC_ITEM)
return;
Item_func *cond_func= (Item_func*) cond;
+ if (cond_func->functype() == Item_func::NOT_FUNC)
+ {
+ Item *item= cond_func->arguments()[0];
+ /*
+ At this moment all NOT before simple comparison predicates
+ are eliminated. NOT IN and NOT BETWEEN are treated similar
+ IN and BETWEEN respectively.
+ */
+ if (item->type() == Item::FUNC_ITEM &&
+ ((Item_func *) item)->select_optimize() == Item_func::OPTIMIZE_KEY)
+ {
+ add_key_fields(key_fields,and_level,item,usable_tables);
+ return;
+ }
+ return;
+ }
switch (cond_func->select_optimize()) {
case Item_func::OPTIMIZE_NONE:
break;
@@ -6377,7 +6393,9 @@ static bool check_equality(Item *item, COND_EQUAL *cond_equal)
Item *left_item= ((Item_func*) item)->arguments()[0];
Item *right_item= ((Item_func*) item)->arguments()[1];
if (left_item->type() == Item::FIELD_ITEM &&
- right_item->type() == Item::FIELD_ITEM)
+ right_item->type() == Item::FIELD_ITEM &&
+ !((Item_field*)left_item)->depended_from &&
+ !((Item_field*)right_item)->depended_from)
{
/* The predicate the form field1=field2 is processed */
@@ -6456,13 +6474,15 @@ static bool check_equality(Item *item, COND_EQUAL *cond_equal)
/* The predicate of the form field=const/const=field is processed */
Item *const_item= 0;
Item_field *field_item= 0;
- if (left_item->type() == Item::FIELD_ITEM &&
+ if (left_item->type() == Item::FIELD_ITEM &&
+ !((Item_field*)left_item)->depended_from &&
right_item->const_item())
{
field_item= (Item_field*) left_item;
const_item= right_item;
}
- else if (right_item->type() == Item::FIELD_ITEM &&
+ else if (right_item->type() == Item::FIELD_ITEM &&
+ !((Item_field*)right_item)->depended_from &&
left_item->const_item())
{
field_item= (Item_field*) right_item;
@@ -12658,8 +12678,10 @@ static bool setup_sum_funcs(THD *thd, Item_sum **func_ptr)
Item_sum *func;
DBUG_ENTER("setup_sum_funcs");
while ((func= *(func_ptr++)))
+ {
if (func->setup(thd))
DBUG_RETURN(TRUE);
+ }
DBUG_RETURN(FALSE);
}
@@ -12946,8 +12968,6 @@ bool JOIN::rollup_make_fields(List<Item> &fields_arg, List<Item> &sel_fields,
*/
item= item->copy_or_same(thd);
((Item_sum*) item)->make_unique();
- if (((Item_sum*) item)->setup(thd))
- return 1;
*(*func)= (Item_sum*) item;
(*func)++;
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 1160267732b..267d584d9eb 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -3009,12 +3009,13 @@ static int get_schema_key_column_usage_record(THD *thd,
while ((f_key_info= it++))
{
LEX_STRING *f_info;
+ LEX_STRING *r_info;
List_iterator_fast<LEX_STRING> it(f_key_info->foreign_fields),
it1(f_key_info->referenced_fields);
uint f_idx= 0;
while ((f_info= it++))
{
- it1++; // Ignore r_info
+ r_info= it1++;
f_idx++;
restore_record(table, s->default_values);
store_key_column_usage(table, base_name, file_name,
@@ -3024,6 +3025,17 @@ static int get_schema_key_column_usage_record(THD *thd,
(longlong) f_idx);
table->field[8]->store((longlong) f_idx);
table->field[8]->set_notnull();
+ table->field[9]->store(f_key_info->referenced_db->str,
+ f_key_info->referenced_db->length,
+ system_charset_info);
+ table->field[9]->set_notnull();
+ table->field[10]->store(f_key_info->referenced_table->str,
+ f_key_info->referenced_table->length,
+ system_charset_info);
+ table->field[10]->set_notnull();
+ table->field[11]->store(r_info->str, r_info->length,
+ system_charset_info);
+ table->field[11]->set_notnull();
if (schema_table_store_record(thd, table))
DBUG_RETURN(1);
}
@@ -3771,6 +3783,9 @@ ST_FIELD_INFO key_column_usage_fields_info[]=
{"COLUMN_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 0, 0},
{"ORDINAL_POSITION", 10 ,MYSQL_TYPE_LONG, 0, 0, 0},
{"POSITION_IN_UNIQUE_CONSTRAINT", 10 ,MYSQL_TYPE_LONG, 0, 1, 0},
+ {"REFERENCED_TABLE_SCHEMA", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
+ {"REFERENCED_TABLE_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
+ {"REFERENCED_COLUMN_NAME", NAME_LEN, MYSQL_TYPE_STRING, 0, 1, 0},
{0, 0, MYSQL_TYPE_STRING, 0, 0, 0}
};
diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc
index 575d75380eb..1e81a2783bb 100644
--- a/sql/sql_udf.cc
+++ b/sql/sql_udf.cc
@@ -412,7 +412,7 @@ int mysql_create_function(THD *thd,udf_func *udf)
This is done to ensure that only approved dll from the system
directories are used (to make this even remotely secure).
*/
- if (strchr(udf->dl, '/') || IF_WIN(strchr(dl_name, '\\'),0))
+ if (strchr(udf->dl, '/') || IF_WIN(strchr(udf->dl, '\\'),0))
{
my_message(ER_UDF_NO_PATHS, ER(ER_UDF_NO_PATHS), MYF(0));
DBUG_RETURN(1);
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 1d0c89a6bbb..34e059265fe 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -6611,6 +6611,11 @@ use: USE_SYM ident
load: LOAD DATA_SYM
{
LEX *lex=Lex;
+ if (lex->sphead)
+ {
+ my_error(ER_SP_BADSTATEMENT, MYF(0), "LOAD DATA");
+ YYABORT;
+ }
lex->fname_start= lex->ptr;
}
load_data
@@ -6618,7 +6623,13 @@ load: LOAD DATA_SYM
|
LOAD TABLE_SYM table_ident FROM MASTER_SYM
{
- Lex->sql_command = SQLCOM_LOAD_MASTER_TABLE;
+ LEX *lex=Lex;
+ if (lex->sphead)
+ {
+ my_error(ER_SP_BADSTATEMENT, MYF(0), "LOAD TABLE");
+ YYABORT;
+ }
+ lex->sql_command = SQLCOM_LOAD_MASTER_TABLE;
if (!Select->add_table_to_list(YYTHD, $3, NULL, TL_OPTION_UPDATING))
YYABORT;
};
diff --git a/storage/myisam/rt_split.c b/storage/myisam/rt_split.c
index 005e86805bb..31a7d09ab4f 100644
--- a/storage/myisam/rt_split.c
+++ b/storage/myisam/rt_split.c
@@ -257,18 +257,17 @@ int rtree_split_page(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, uchar *key,
int n_dim;
uchar *source_cur, *cur1, *cur2;
uchar *new_page;
- int err_code = 0;
-
- uint nod_flag = mi_test_if_nod(page);
- uint full_length = key_length + (nod_flag ? nod_flag :
- info->s->base.rec_reflength);
-
- int max_keys = (mi_getint(page)-2) / (full_length);
+ int err_code= 0;
+ uint nod_flag= mi_test_if_nod(page);
+ uint full_length= key_length + (nod_flag ? nod_flag :
+ info->s->base.rec_reflength);
+ int max_keys= (mi_getint(page)-2) / (full_length);
n_dim = keyinfo->keysegs / 2;
- if (!(coord_buf= my_alloca(n_dim * 2 * sizeof(double) * (max_keys + 1 + 4) +
- sizeof(SplitStruct) * (max_keys + 1))))
+ if (!(coord_buf= (double*) my_alloca(n_dim * 2 * sizeof(double) *
+ (max_keys + 1 + 4) +
+ sizeof(SplitStruct) * (max_keys + 1))))
return -1;
task= (SplitStruct *)(coord_buf + n_dim * 2 * (max_keys + 1 + 4));
@@ -311,8 +310,7 @@ int rtree_split_page(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, uchar *key,
cur1 = rt_PAGE_FIRST_KEY(page, nod_flag);
cur2 = rt_PAGE_FIRST_KEY(new_page, nod_flag);
- n1 = 0;
- n2 = 0;
+ n1= n2 = 0;
for (cur = task; cur < stop; ++cur)
{
uchar *to;
diff --git a/storage/myisam/sp_key.c b/storage/myisam/sp_key.c
index b61e8094cde..1d43f89cba9 100644
--- a/storage/myisam/sp_key.c
+++ b/storage/myisam/sp_key.c
@@ -32,7 +32,11 @@ 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 byte *pos)
+{
+ float8get(*d, pos);
+}
+
uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key,
const byte *record, my_off_t filepos)
{
@@ -80,7 +84,7 @@ uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key,
else if (keyseg->type == HA_KEYTYPE_DOUBLE)
{
double nr;
- float8get(nr, pos);
+ get_double(&nr, pos);
if (isnan(nr))
{
bzero(key, length);
@@ -138,7 +142,7 @@ static int sp_add_point_to_mbr(uchar *(*wkb), uchar *end, uint n_dims,
{
if ((*wkb) > end - 8)
return -1;
- float8get(ord, (*wkb));
+ get_double(&ord, *wkb);
(*wkb)+= 8;
if (ord < *mbr)
float8store((char*) mbr, ord);
diff --git a/storage/ndb/src/kernel/SimBlockList.cpp b/storage/ndb/src/kernel/SimBlockList.cpp
index 75a52ae0c4b..bf3958cf137 100644
--- a/storage/ndb/src/kernel/SimBlockList.cpp
+++ b/storage/ndb/src/kernel/SimBlockList.cpp
@@ -39,7 +39,6 @@
#else
enum SIMBLOCKLIST_DUMMY { A_VALUE = 0 };
-static
void * operator new (size_t sz, SIMBLOCKLIST_DUMMY dummy){
char * tmp = (char *)malloc(sz);
diff --git a/storage/ndb/src/ndbapi/Ndb.cpp b/storage/ndb/src/ndbapi/Ndb.cpp
index 5b1a33ce68f..c48e70f1d51 100644
--- a/storage/ndb/src/ndbapi/Ndb.cpp
+++ b/storage/ndb/src/ndbapi/Ndb.cpp
@@ -230,9 +230,10 @@ Remark: Disconnect all connections to the database.
void
Ndb::doDisconnect()
{
- DBUG_ENTER("Ndb::doDisconnect");
NdbTransaction* tNdbCon;
CHECK_STATUS_MACRO_VOID;
+ /* DBUG_ENTER must be after CHECK_STATUS_MACRO_VOID because of 'return' */
+ DBUG_ENTER("Ndb::doDisconnect");
Uint32 tNoOfDbNodes = theImpl->theNoOfDBnodes;
Uint8 *theDBnodes= theImpl->theDBnodes;
diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c
index 4d7c17e977c..935cc2d380d 100644
--- a/strings/my_vsnprintf.c
+++ b/strings/my_vsnprintf.c
@@ -135,6 +135,16 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap)
to+= res_length;
continue;
}
+ else if (*fmt == 'c') /* Character parameter */
+ {
+ register int larg;
+ if (to == end)
+ break;
+ larg = va_arg(ap, int);
+ *to++= (char) larg;
+ continue;
+ }
+
/* We come here on '%%', unknown code or too long parameter */
if (to == end)
break;