Merge trift2.:/MySQL/M50/mysql-5.0

into  trift2.:/MySQL/M50/push-5.0


client/mysqldump.c:
  Auto merged
This commit is contained in:
unknown 2008-03-14 14:32:01 +01:00
commit ed86d34b6d
81 changed files with 1343 additions and 410 deletions

View file

@ -1125,6 +1125,7 @@ int main(int argc,char *argv[])
}
if (mysql_server_init(emb_argc, emb_argv, (char**) server_default_groups))
{
put_error(NULL);
free_defaults(defaults_argv);
my_end(0);
exit(1);

View file

@ -3306,6 +3306,7 @@ static int do_show_master_status(MYSQL *mysql_con)
my_printf_error(0, "Error: Binlogging on server not active",
MYF(0));
mysql_free_result(master);
maybe_exit(EX_MYSQLERR);
return 1;
}
mysql_free_result(master);

View file

@ -15,6 +15,7 @@
extern const char *unknown_sqlstate;
extern const char *cant_connect_sqlstate;
extern const char *not_error_sqlstate;
#ifdef __cplusplus

View file

@ -1486,7 +1486,7 @@ my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql)
const char *STDCALL mysql_sqlstate(MYSQL *mysql)
{
return mysql->net.sqlstate;
return mysql ? mysql->net.sqlstate : cant_connect_sqlstate;
}
uint STDCALL mysql_warning_count(MYSQL *mysql)

View file

@ -47,6 +47,8 @@ C_MODE_START
#include <sql_common.h>
#include "embedded_priv.h"
extern unsigned int mysql_server_last_errno;
extern char mysql_server_last_error[MYSQL_ERRMSG_SIZE];
static my_bool emb_read_query_result(MYSQL *mysql);
@ -1084,3 +1086,11 @@ bool Protocol::net_store_data(const char *from, uint length)
return false;
}
void vprint_msg_to_log(enum loglevel level __attribute__((unused)),
const char *format, va_list argsi)
{
vsnprintf(mysql_server_last_error, sizeof(mysql_server_last_error),
format, argsi);
mysql_server_last_errno= CR_UNKNOWN_ERROR;
}

View file

@ -1325,6 +1325,7 @@ set @a=repeat(' ',20);
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
Warnings:
Note 1265 Data truncated for column 'v' at row 1
Note 1265 Data truncated for column 'c' at row 1
select concat('*',v,'*',c,'*',t,'*') from t1;
concat('*',v,'*',c,'*',t,'*')
*+ *+*+ *

View file

@ -21,3 +21,19 @@ show status like "binlog_cache_disk_use";
Variable_name Value
Binlog_cache_disk_use 1
drop table t1;
CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=MyISAM;
CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
CREATE FUNCTION bug23333()
RETURNS int(11)
DETERMINISTIC
BEGIN
INSERT INTO t1 VALUES (NULL);
SELECT COUNT(*) FROM t1 INTO @a;
RETURN @a;
END|
INSERT INTO t2 VALUES (2),(10+bug23333());
SHOW MASTER STATUS;
File Position Binlog_Do_DB Binlog_Ignore_DB
# 184136
DROP FUNCTION bug23333;
DROP TABLE t1, t2;

View file

@ -53,3 +53,41 @@ a b
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: ''
drop table if exists t1;
CREATE TABLE t1 (b int(2) zerofill, c int(2) zerofill);
INSERT INTO t1 (b,c) VALUES (1,2), (1,1), (2,2);
SELECT CONCAT(b,c), CONCAT(b,c) = '0101' FROM t1;
CONCAT(b,c) CONCAT(b,c) = '0101'
0102 0
0101 1
0202 0
EXPLAIN EXTENDED SELECT b,c FROM t1 WHERE b = 1 AND CONCAT(b,c) = '0101';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using where
Warnings:
Note 1003 select `test`.`t1`.`b` AS `b`,`test`.`t1`.`c` AS `c` from `test`.`t1` where ((`test`.`t1`.`b` = 1) and (concat(_binary'01',`test`.`t1`.`c`) = _latin1'0101'))
SELECT b,c FROM t1 WHERE b = 1 AND CONCAT(b,c) = '0101';
b c
01 01
CREATE TABLE t2 (a int);
INSERT INTO t2 VALUES (1),(2);
SELECT a,
(SELECT COUNT(*) FROM t1
WHERE b = t2.a AND CONCAT(b,c) = CONCAT('0',t2.a,'01')) x
FROM t2 ORDER BY a;
a x
1 1
2 0
EXPLAIN EXTENDED
SELECT a,
(SELECT COUNT(*) FROM t1
WHERE b = t2.a AND CONCAT(b,c) = CONCAT('0',t2.a,'01')) x
FROM t2 ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using filesort
2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where
Warnings:
Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1
Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1
Note 1003 select `test`.`t2`.`a` AS `a`,(select count(0) AS `COUNT(*)` from `test`.`t1` where ((`test`.`t1`.`b` = `test`.`t2`.`a`) and (concat(`test`.`t1`.`b`,`test`.`t1`.`c`) = concat(_latin1'0',`test`.`t2`.`a`,_latin1'01')))) AS `x` from `test`.`t2` order by `test`.`t2`.`a`
DROP TABLE t1,t2;
End of 5.0 tests

View file

@ -1532,4 +1532,18 @@ Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 7
drop table t1,t2;
CREATE TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1));
DROP TABLE t1;
CREATE TABLE t1(c1 VARCHAR(33), KEY (c1) USING BTREE);
DROP TABLE t1;
CREATE TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1) USING HASH) ENGINE=MEMORY;
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 c1 1 c1 NULL 0 NULL NULL YES HASH
DROP TABLE t1;
CREATE TABLE t1(c1 VARCHAR(33), KEY USING HASH (c1) USING BTREE) ENGINE=MEMORY;
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 c1 1 c1 A NULL NULL NULL YES BTREE
DROP TABLE t1;
End of 5.0 tests

View file

@ -40,6 +40,6 @@ IN ind DECIMAL(10,2))
BEGIN
INSERT INTO t4 VALUES (ins1, ins2, ind);
END
master-bin.000001 776 Query 1 995 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93))
master-bin.000001 995 Query 1 1084 use `test`; DROP PROCEDURE bug18293
master-bin.000001 1084 Query 1 1163 use `test`; DROP TABLE t4
master-bin.000001 776 Query 1 987 use `test`; INSERT INTO t4 VALUES ( NAME_CONST('ins1',_latin1 0x466F6F2773206120426172), NAME_CONST('ins2',_cp932 0xED40ED41ED42), NAME_CONST('ind',47.93))
master-bin.000001 987 Query 1 1076 use `test`; DROP PROCEDURE bug18293
master-bin.000001 1076 Query 1 1155 use `test`; DROP TABLE t4

View file

@ -931,4 +931,19 @@ SELECT GROUP_CONCAT(DISTINCT b, a ORDER BY b) FROM t1;
GROUP_CONCAT(DISTINCT b, a ORDER BY b)
11,22,32
DROP TABLE t1, t2, t3;
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (),();
SELECT s1.d1 FROM
(
SELECT
t1.a as d1,
GROUP_CONCAT(DISTINCT t1.a) AS d2
FROM
t1 AS t1,
t1 AS t2
GROUP BY 1
) AS s1;
d1
NULL
DROP TABLE t1;
End of 5.0 tests

View file

@ -207,6 +207,25 @@ test
SELECT NAME_CONST('test', 'test');
test
test
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2),(3);
SELECT NAME_CONST('flag',1) * MAX(a) FROM t1;
NAME_CONST('flag',1) * MAX(a)
3
SELECT NAME_CONST('flag',1.5) * MAX(a) FROM t1;
NAME_CONST('flag',1.5) * MAX(a)
4.5
SELECT NAME_CONST('flag',-1) * MAX(a) FROM t1;
NAME_CONST('flag',-1) * MAX(a)
-3
SELECT NAME_CONST('flag',-1.5) * MAX(a) FROM t1;
NAME_CONST('flag',-1.5) * MAX(a)
-4.5
SELECT NAME_CONST('flag', SQRT(4)) * MAX(a) FROM t1;
ERROR HY000: Incorrect arguments to NAME_CONST
SELECT NAME_CONST('flag',-SQRT(4)) * MAX(a) FROM t1;
ERROR HY000: Incorrect arguments to NAME_CONST
DROP TABLE t1;
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (5), (2);
SELECT NAME_CONST(x,2) FROM (SELECT a x FROM t1) t;

View file

@ -666,6 +666,8 @@ timestampadd(SQL_TSI_SECOND, 1, date)
select timestampadd(SQL_TSI_FRAC_SECOND, 1, date) from t1;
timestampadd(SQL_TSI_FRAC_SECOND, 1, date)
2003-01-02 00:00:00.000001
Warnings:
Warning 1287 'FRAC_SECOND' is deprecated; use 'MICROSECOND' instead
select timestampdiff(MONTH, '2001-02-01', '2001-05-01') as a;
a
3
@ -699,6 +701,8 @@ a
select timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a;
a
7689538999999
Warnings:
Warning 1287 'FRAC_SECOND' is deprecated; use 'MICROSECOND' instead
select timestampdiff(SQL_TSI_DAY, '1986-02-01', '1986-03-01') as a1,
timestampdiff(SQL_TSI_DAY, '1900-02-01', '1900-03-01') as a2,
timestampdiff(SQL_TSI_DAY, '1996-02-01', '1996-03-01') as a3,
@ -1069,6 +1073,7 @@ timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Warning 1287 'FRAC_SECOND' is deprecated; use 'MICROSECOND' instead
Note 1003 select timestampdiff(WEEK,_latin1'2001-02-01',_latin1'2001-05-01') AS `a1`,timestampdiff(SECOND_FRAC,_latin1'2001-02-01 12:59:59.120000',_latin1'2001-05-01 12:58:58.119999') AS `a2`
select last_day('2005-00-00');
last_day('2005-00-00')
@ -1285,4 +1290,22 @@ DATE_ADD(20071108, INTERVAL 1 DAY)
select LAST_DAY('2007-12-06 08:59:19.05') - INTERVAL 1 SECOND;
LAST_DAY('2007-12-06 08:59:19.05') - INTERVAL 1 SECOND
2007-12-30 23:59:59
SELECT TIMESTAMPADD(FRAC_SECOND, 1, '2008-02-18');
TIMESTAMPADD(FRAC_SECOND, 1, '2008-02-18')
2008-02-18 00:00:00.000001
Warnings:
Warning 1287 'FRAC_SECOND' is deprecated; use 'MICROSECOND' instead
SELECT TIMESTAMPDIFF(FRAC_SECOND, '2008-02-17', '2008-02-18');
TIMESTAMPDIFF(FRAC_SECOND, '2008-02-17', '2008-02-18')
86400000000
Warnings:
Warning 1287 'FRAC_SECOND' is deprecated; use 'MICROSECOND' instead
SELECT DATE_ADD('2008-02-18', INTERVAL 1 FRAC_SECOND);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FRAC_SECOND)' at line 1
SELECT DATE_SUB('2008-02-18', INTERVAL 1 FRAC_SECOND);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FRAC_SECOND)' at line 1
SELECT '2008-02-18' + INTERVAL 1 FRAC_SECOND;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FRAC_SECOND' at line 1
SELECT '2008-02-18' - INTERVAL 1 FRAC_SECOND;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FRAC_SECOND' at line 1
End of 5.0 tests

View file

@ -138,3 +138,20 @@ SELECT user, host, db, select_priv FROM mysql.db where user = 'CUser2' order by
user host db select_priv
DROP USER CUser2@localhost;
DROP USER CUser2@LOCALHOST;
CREATE DATABASE mysqltest_1;
CREATE TABLE mysqltest_1.t1 (a INT);
CREATE USER 'mysqltest1'@'%';
GRANT SELECT, UPDATE ON `mysqltest_1`.* TO 'mysqltest1'@'%';
REVOKE SELECT ON `mysqltest_1`.* FROM 'mysqltest1'@'%';
GRANT SELECT, UPDATE ON `mysqltest\_1`.* TO 'mysqltest1'@'%';
FLUSH PRIVILEGES;
SHOW GRANTS;
Grants for mysqltest1@%
GRANT USAGE ON *.* TO 'mysqltest1'@'%'
GRANT SELECT, UPDATE ON `mysqltest\_1`.* TO 'mysqltest1'@'%'
GRANT UPDATE ON `mysqltest_1`.* TO 'mysqltest1'@'%'
SELECT * FROM mysqltest_1.t1;
a
DROP USER 'mysqltest1'@'%';
DROP DATABASE mysqltest_1;
End of 5.0 tests

View file

@ -256,6 +256,7 @@ set @a=repeat(' ',20);
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
Warnings:
Note 1265 Data truncated for column 'v' at row 1
Note 1265 Data truncated for column 'c' at row 1
select concat('*',v,'*',c,'*',t,'*') from t1;
concat('*',v,'*',c,'*',t,'*')
*+ *+*+ *

View file

@ -1901,6 +1901,7 @@ set @a=repeat(' ',20);
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
Warnings:
Note 1265 Data truncated for column 'v' at row 1
Note 1265 Data truncated for column 'c' at row 1
select concat('*',v,'*',c,'*',t,'*') from t1;
concat('*',v,'*',c,'*',t,'*')
*+ *+*+ *

View file

@ -1240,4 +1240,10 @@ t1 CREATE TABLE `t1` (
UNIQUE KEY `aa` (`a`(1))
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1;
set @my_innodb_autoextend_increment=@@global.innodb_autoextend_increment;
set global innodb_autoextend_increment=8;
set global innodb_autoextend_increment=@my_innodb_autoextend_increment;
set @my_innodb_commit_concurrency=@@global.innodb_commit_concurrency;
set global innodb_commit_concurrency=0;
set global innodb_commit_concurrency=@my_innodb_commit_concurrency;
End of 5.0 tests

View file

@ -1104,6 +1104,7 @@ set @a=repeat(' ',20);
insert into t1 values (concat('+',@a),concat('+',@a),concat('+',@a));
Warnings:
Note 1265 Data truncated for column 'v' at row 1
Note 1265 Data truncated for column 'c' at row 1
select concat('*',v,'*',c,'*',t,'*') from t1;
concat('*',v,'*',c,'*',t,'*')
*+ *+*+ *

View file

@ -0,0 +1 @@
mysqldump: Error: Binlogging on server not active

View file

@ -429,3 +429,21 @@ Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 5
DROP TABLE t1,t2,t3,t4;
CREATE TABLE t1 (
a int(11) default NULL,
b int(11) default NULL,
KEY a (a,b)
);
INSERT INTO t1 VALUES (0,10),(0,11),(0,12);
CREATE TABLE t2 (
a int(11) default NULL,
b int(11) default NULL,
KEY a (a)
);
INSERT INTO t2 VALUES (3,NULL),(3,11),(3,12);
SELECT * FROM t2 inner join t1 WHERE ( t1.a = 0 OR t1.a IS NULL) AND t2.a = 3 AND t2.b = t1.b;
a b a b
3 11 0 11
3 12 0 12
drop table t1, t2;
End of 5.0 tests

View file

@ -1064,3 +1064,15 @@ a b
10 00:00:10
0 00:00:00
DROP TABLE t1;
#
# Bug#31590: Wrong error message on sort buffer being too small.
#
create table t1(a int, b tinytext);
insert into t1 values (1,2),(3,2);
set session sort_buffer_size= 30000;
Warnings:
Warning 1292 Truncated incorrect sort_buffer_size value: '30000'
set session max_sort_length= 2180;
select * from t1 order by b;
ERROR HY001: Out of sort memory; increase server sort buffer size
drop table t1;

View file

@ -1153,3 +1153,16 @@ explain select * from t1 where dateval >= '2007-01-01 00:00:00' and dateval <= '
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range dateval dateval 4 NULL 2 Using where
drop table t1;
CREATE TABLE t1 (
a varchar(32), index (a)
) DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
INSERT INTO t1 VALUES
('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A');
SELECT a FROM t1 WHERE a='b' OR a='B';
a
B
B
EXPLAIN SELECT a FROM t1 WHERE a='b' OR a='B';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 35 NULL 3 Using where; Using index
DROP TABLE t1;

View file

@ -434,3 +434,12 @@ SELECT @x;
@x
99
DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT);
INSERT INTO t1 VALUES (1,1);
SELECT ROW(a, 1) IN (SELECT SUM(b), 1) FROM t1 GROUP BY a;
ROW(a, 1) IN (SELECT SUM(b), 1)
1
SELECT ROW(a, 1) IN (SELECT SUM(b), 3) FROM t1 GROUP BY a;
ROW(a, 1) IN (SELECT SUM(b), 3)
0
DROP TABLE t1;

View file

@ -4328,4 +4328,31 @@ SELECT * FROM t1 WHERE c1 > NULL + 1;
c1
DROP TABLE t1;
CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY);
INSERT INTO t1 (a) VALUES ('foo0'), ('bar0'), ('baz0');
SELECT * FROM t1 WHERE a IN (CONCAT('foo', 0), 'bar');
a
foo0
DROP TABLE t1;
CREATE TABLE t1 (a INT, b INT);
CREATE TABLE t2 (a INT, c INT, KEY(a));
INSERT INTO t1 VALUES (1, 1), (2, 2);
INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5),
(2, 1), (2, 2), (2, 3), (2, 4), (2, 5),
(3, 1), (3, 2), (3, 3), (3, 4), (3, 5),
(4, 1), (4, 2), (4, 3), (4, 4), (4, 5);
FLUSH STATUS;
SELECT DISTINCT b FROM t1 LEFT JOIN t2 USING(a) WHERE c <= 3;
b
1
2
SHOW STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 2
Handler_read_next 0
Handler_read_prev 0
Handler_read_rnd 0
Handler_read_rnd_next 6
DROP TABLE t1, t2;
End of 5.0 tests

View file

@ -6629,6 +6629,23 @@ end//
call proc_33618(20);
drop table t_33618;
drop procedure proc_33618;
#
# Bug#30787: Stored function ignores user defined alias.
#
use test;
drop function if exists func30787;
create table t1(f1 int);
insert into t1 values(1),(2);
create function func30787(p1 int) returns int
begin
return p1;
end |
select (select func30787(f1)) as ttt from t1;
ttt
1
2
drop function func30787;
drop table t1;
# ------------------------------------------------------------------
# -- End of 5.0 tests
# ------------------------------------------------------------------

View file

@ -934,6 +934,8 @@ NULL NULL
DROP TABLE t1;
CREATE TABLE t1 (col1 CHAR(5), col2 VARCHAR(6));
INSERT INTO t1 VALUES ('hello', 'hello'),('he', 'he'),('hello ', 'hello ');
Warnings:
Note 1265 Data truncated for column 'col1' at row 3
INSERT INTO t1 (col1) VALUES ('hellobob');
ERROR 22001: Data too long for column 'col1' at row 1
INSERT INTO t1 (col2) VALUES ('hellobob');

View file

@ -4147,103 +4147,37 @@ DROP TABLE t1,t2;
create table t1(a int,b int,key(a),key(b));
insert into t1(a,b) values (1,2),(2,1),(2,3),(3,4),(5,4),(5,5),
(6,7),(7,4),(5,3);
select sum(a),a from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1
)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1)
group by a;
sum(a) a
select sum(a),a from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1)
group by a;
ERROR HY000: Thread stack overrun detected
explain select sum(a),a from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1
)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1)
group by a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 index a a 5 NULL 9 Using where; Using index
2 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
3 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
4 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
5 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
6 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
7 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
8 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
9 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
10 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
11 SUBQUERY t1 range a a 5 NULL 9 Using where; Using temporary; Using filesort
12 SUBQUERY t1 range a a 5 NULL 1 Using where; Using temporary; Using filesort
13 SUBQUERY t1 index NULL a 5 NULL 9 Using index
explain select sum(a),a from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1)
group by a;
ERROR HY000: Thread stack overrun detected
5
4
3
2
1
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
drop table t1;
CREATE TABLE t1 (a1 INT, a2 INT);
CREATE TABLE t2 (b1 INT, b2 INT);

View file

@ -100,23 +100,15 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
CREATE TABLE t1(a INT)
DATA DIRECTORY='TEST_DIR/master-data/mysql'
INDEX DIRECTORY='TEST_DIR/master-data/mysql';
RENAME TABLE t1 TO user;
ERROR HY000: Can't create/write to file 'TEST_DIR/master-data/mysql/user.MYI' (Errcode: 17)
DROP TABLE t1;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
DATA DIRECTORY='TEST_DIR/tmp'
INDEX DIRECTORY='TEST_DIR/tmp';
ERROR HY000: Can't create/write to file 'TEST_DIR/tmp/t1.MYI' (Errcode: 17)
CREATE TABLE t2(a INT)
DATA DIRECTORY='TEST_DIR/tmp'
INDEX DIRECTORY='TEST_DIR/tmp';
RENAME TABLE t2 TO t1;
ERROR HY000: Can't create/write to file 'TEST_DIR/tmp/t1.MYI' (Errcode: 17)
DROP TABLE t2;
show create table t1;
Table Create Table
t1 CREATE TEMPORARY TABLE `t1` (
@ -138,27 +130,38 @@ select * from t1;
a
42
drop table t1;
execute stmt;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` char(10) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/'
drop table t1;
execute stmt;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c` char(10) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/tmp/'
drop table t1;
deallocate prepare stmt;
CREATE TABLE t1(a INT)
DATA DIRECTORY='TEST_DIR/var/master-data/test';
Got one of the listed errors
CREATE TABLE t1(a INT)
DATA DIRECTORY='TEST_DIR/var/master-data/';
Got one of the listed errors
CREATE TABLE t1(a INT)
INDEX DIRECTORY='TEST_DIR/var/master-data';
Got one of the listed errors
CREATE TABLE t1(a INT)
INDEX DIRECTORY='TEST_DIR/var/master-data_var';
Got one of the listed errors
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;
ERROR HY000: Can't create/write to file './db1/t1.MYD' (Errcode: 17)
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;
ERROR HY000: Can't create/write to file './test/t1.MYD' (Errcode: 17)
SET SESSION keep_files_on_create = FALSE;
CREATE TABLE t1 (a INT) ENGINE MYISAM;
DROP TABLE t1;
End of 5.0 tests

View file

@ -46,3 +46,12 @@ CREATE TABLE t2 (a int);
lock tables t1 write,t1 as b write, t2 write, t2 as c read;
drop table t2,t1;
unlock tables;
create temporary table t1(f1 int);
lock tables t1 write;
insert into t1 values (1);
show columns from t1;
Field Type Null Key Default Extra
f1 int(11) YES NULL
insert into t1 values(2);
drop table t1;
unlock tables;

View file

@ -125,6 +125,7 @@ create table t1 (c char(2), vc varchar(2));
insert into t1 values(0x4120, 0x4120);
insert into t1 values(0x412020, 0x412020);
Warnings:
Note 1265 Data truncated for column 'c' at row 1
Note 1265 Data truncated for column 'vc' at row 1
drop table t1;
set @old_sql_mode= @@sql_mode, sql_mode= 'traditional';

View file

@ -85,3 +85,11 @@ t1 CREATE TABLE `t1` (
`f1` set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','1') default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
CREATE TABLE t1(c set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64'));
INSERT INTO t1 VALUES(7);
INSERT INTO t1 VALUES(9223372036854775808);
SELECT * FROM t1;
c
1,2,3
64
DROP TABLE t1;

View file

@ -3618,6 +3618,30 @@ ERROR HY000: Field of view 'test.v1' underlying table doesn't have a default val
set @@sql_mode=@old_mode;
drop view v1;
drop table t1;
create table t1 (a int, key(a));
create table t2 (c int);
create view v1 as select a b from t1;
create view v2 as select 1 a from t2, v1 where c in
(select 1 from t1 where b = a);
insert into t1 values (1), (1);
insert into t2 values (1), (1);
prepare stmt from "select * from v2 where a = 1";
execute stmt;
a
1
1
1
1
drop view v1, v2;
drop table t1, t2;
CREATE TABLE t1 (a INT);
CREATE VIEW v1 AS SELECT p.a AS a FROM t1 p, t1 q;
INSERT INTO t1 VALUES (1), (1);
SELECT MAX(a), COUNT(DISTINCT a) FROM v1 GROUP BY a;
MAX(a) COUNT(DISTINCT a)
1 1
DROP VIEW v1;
DROP TABLE t1;
# -----------------------------------------------------------------
# -- Bug#34337: Server crash when Altering a view using a table name.
# -----------------------------------------------------------------

View file

@ -298,4 +298,42 @@ DROP TABLE t3;
DROP PROCEDURE sp1;
DROP PROCEDURE sp2;
DROP PROCEDURE sp3;
create table t1 (c_char char(255), c_varchar varchar(255), c_tinytext tinytext);
create table t2 (c_tinyblob tinyblob);
set @c = repeat(' ', 256);
set @q = repeat('q', 256);
set sql_mode = '';
insert into t1 values(@c, @c, @c);
Warnings:
Note 1265 Data truncated for column 'c_char' at row 1
Note 1265 Data truncated for column 'c_varchar' at row 1
Note 1265 Data truncated for column 'c_tinytext' at row 1
insert into t2 values(@c);
Warnings:
Warning 1265 Data truncated for column 'c_tinyblob' at row 1
insert into t1 values(@q, @q, @q);
Warnings:
Warning 1265 Data truncated for column 'c_char' at row 1
Warning 1265 Data truncated for column 'c_varchar' at row 1
Warning 1265 Data truncated for column 'c_tinytext' at row 1
insert into t2 values(@q);
Warnings:
Warning 1265 Data truncated for column 'c_tinyblob' at row 1
set sql_mode = 'traditional';
insert into t1 values(@c, @c, @c);
Warnings:
Note 1265 Data truncated for column 'c_char' at row 1
Note 1265 Data truncated for column 'c_varchar' at row 1
Note 1265 Data truncated for column 'c_tinytext' at row 1
insert into t2 values(@c);
ERROR 22001: Data too long for column 'c_tinyblob' at row 1
insert into t1 values(@q, NULL, NULL);
ERROR 22001: Data too long for column 'c_char' at row 1
insert into t1 values(NULL, @q, NULL);
ERROR 22001: Data too long for column 'c_varchar' at row 1
insert into t1 values(NULL, NULL, @q);
ERROR 22001: Data too long for column 'c_tinytext' at row 1
insert into t2 values(@q);
ERROR 22001: Data too long for column 'c_tinyblob' at row 1
drop table t1, t2;
End of 5.0 tests

View file

@ -37,3 +37,28 @@ show status like "binlog_cache_disk_use";
drop table t1;
#
# Bug #30604: different flagging of time_zone_used in normal and ps-protocol
#
CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=MyISAM;
CREATE TABLE t2 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY) ENGINE=InnoDB;
DELIMITER |;
# the function does not deal with time objects
CREATE FUNCTION bug23333()
RETURNS int(11)
DETERMINISTIC
BEGIN
INSERT INTO t1 VALUES (NULL);
SELECT COUNT(*) FROM t1 INTO @a;
RETURN @a;
END|
DELIMITER ;|
INSERT INTO t2 VALUES (2),(10+bug23333());
--replace_column 1 #
SHOW MASTER STATUS;
DROP FUNCTION bug23333;
DROP TABLE t1, t2;

View file

@ -46,3 +46,34 @@ insert into t1 values (0x01,0x01);
select * from t1 where a=b;
select * from t1 where a=b and b=0x01;
drop table if exists t1;
#
# Bug #31887: DML Select statement not returning same results when executed
# in version 5
#
CREATE TABLE t1 (b int(2) zerofill, c int(2) zerofill);
INSERT INTO t1 (b,c) VALUES (1,2), (1,1), (2,2);
SELECT CONCAT(b,c), CONCAT(b,c) = '0101' FROM t1;
EXPLAIN EXTENDED SELECT b,c FROM t1 WHERE b = 1 AND CONCAT(b,c) = '0101';
SELECT b,c FROM t1 WHERE b = 1 AND CONCAT(b,c) = '0101';
CREATE TABLE t2 (a int);
INSERT INTO t2 VALUES (1),(2);
SELECT a,
(SELECT COUNT(*) FROM t1
WHERE b = t2.a AND CONCAT(b,c) = CONCAT('0',t2.a,'01')) x
FROM t2 ORDER BY a;
EXPLAIN EXTENDED
SELECT a,
(SELECT COUNT(*) FROM t1
WHERE b = t2.a AND CONCAT(b,c) = CONCAT('0',t2.a,'01')) x
FROM t2 ORDER BY a;
DROP TABLE t1,t2;
--echo End of 5.0 tests

View file

@ -1148,4 +1148,28 @@ create table t2 select sql_big_result f1,count(f2) from t1 group by f1;
show status like 'handler_read%';
drop table t1,t2;
#
# Bug #25162: Backing up DB from 5.1 adds 'USING BTREE' to KEYs on table creates
#
# Show that the old syntax for index type is supported
CREATE TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1));
DROP TABLE t1;
# Show that the new syntax for index type is supported
CREATE TABLE t1(c1 VARCHAR(33), KEY (c1) USING BTREE);
DROP TABLE t1;
# Show that in case of multiple index type definitions, the last one takes
# precedence
CREATE TABLE t1(c1 VARCHAR(33), KEY USING BTREE (c1) USING HASH) ENGINE=MEMORY;
SHOW INDEX FROM t1;
DROP TABLE t1;
CREATE TABLE t1(c1 VARCHAR(33), KEY USING HASH (c1) USING BTREE) ENGINE=MEMORY;
SHOW INDEX FROM t1;
DROP TABLE t1;
--echo End of 5.0 tests

View file

@ -640,4 +640,21 @@ SELECT GROUP_CONCAT(DISTINCT b, a ORDER BY b) FROM t1;
DROP TABLE t1, t2, t3;
#
# Bug #34747: crash in debug assertion check after derived table
#
CREATE TABLE t1(a INT);
INSERT INTO t1 VALUES (),();
SELECT s1.d1 FROM
(
SELECT
t1.a as d1,
GROUP_CONCAT(DISTINCT t1.a) AS d2
FROM
t1 AS t1,
t1 AS t2
GROUP BY 1
) AS s1;
DROP TABLE t1;
--echo End of 5.0 tests

View file

@ -204,6 +204,24 @@ SELECT NAME_CONST('test', 1.0);
SELECT NAME_CONST('test', -1.0);
SELECT NAME_CONST('test', 'test');
#
# Bug #34749: Server crash when using NAME_CONST() with an aggregate function
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2),(3);
# NAME_CONST() + aggregate.
SELECT NAME_CONST('flag',1) * MAX(a) FROM t1;
SELECT NAME_CONST('flag',1.5) * MAX(a) FROM t1;
# Now, wrap the INT_ITEM in Item_func_neg and watch the pretty explosions
SELECT NAME_CONST('flag',-1) * MAX(a) FROM t1;
SELECT NAME_CONST('flag',-1.5) * MAX(a) FROM t1;
--error ER_WRONG_ARGUMENTS
SELECT NAME_CONST('flag', SQRT(4)) * MAX(a) FROM t1;
--error ER_WRONG_ARGUMENTS
SELECT NAME_CONST('flag',-SQRT(4)) * MAX(a) FROM t1;
DROP TABLE t1;
#
# Bug #27545: erroneous usage of NAME_CONST with a name as the first parameter
# resolved against a column name of a derived table hangs the client

View file

@ -336,7 +336,7 @@ select date_add(date,INTERVAL "1" QUARTER) from t1;
select timestampadd(MINUTE, 1, date) from t1;
select timestampadd(WEEK, 1, date) from t1;
select timestampadd(SQL_TSI_SECOND, 1, date) from t1;
# Prepared statements doesn't support FRAC_SECOND yet
# mysqltest.c discards an expected 'deprecated' warning on prepare stage
--disable_ps_protocol
select timestampadd(SQL_TSI_FRAC_SECOND, 1, date) from t1;
--enable_ps_protocol
@ -351,7 +351,10 @@ select timestampdiff(SQL_TSI_HOUR, '2001-02-01', '2001-05-01') as a;
select timestampdiff(SQL_TSI_DAY, '2001-02-01', '2001-05-01') as a;
select timestampdiff(SQL_TSI_MINUTE, '2001-02-01 12:59:59', '2001-05-01 12:58:59') as a;
select timestampdiff(SQL_TSI_SECOND, '2001-02-01 12:59:59', '2001-05-01 12:58:58') as a;
# mysqltest.c discards an expected 'deprecated' warning on prepare stage
--disable_ps_protocol
select timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a;
--enable_ps_protocol
select timestampdiff(SQL_TSI_DAY, '1986-02-01', '1986-03-01') as a1,
timestampdiff(SQL_TSI_DAY, '1900-02-01', '1900-03-01') as a2,
@ -804,4 +807,26 @@ select DATE_ADD(20071108, INTERVAL 1 DAY);
select LAST_DAY('2007-12-06 08:59:19.05') - INTERVAL 1 SECOND;
#
# Bug#33834: FRAC_SECOND: Applicability not clear in documentation
#
# Show that he use of FRAC_SECOND, for anything other than
# TIMESTAMPADD / TIMESTAMPDIFF, is a server error.
# mysqltest.c discards an expected 'deprecated' warning on prepare stage
--disable_ps_protocol
SELECT TIMESTAMPADD(FRAC_SECOND, 1, '2008-02-18');
SELECT TIMESTAMPDIFF(FRAC_SECOND, '2008-02-17', '2008-02-18');
--enable_ps_protocol
--error ER_PARSE_ERROR
SELECT DATE_ADD('2008-02-18', INTERVAL 1 FRAC_SECOND);
--error ER_PARSE_ERROR
SELECT DATE_SUB('2008-02-18', INTERVAL 1 FRAC_SECOND);
--error ER_PARSE_ERROR
SELECT '2008-02-18' + INTERVAL 1 FRAC_SECOND;
--error ER_PARSE_ERROR
SELECT '2008-02-18' - INTERVAL 1 FRAC_SECOND;
--echo End of 5.0 tests

View file

@ -134,3 +134,29 @@ SELECT user, host, db, select_priv FROM mysql.db where user = 'CUser2' order by
DROP USER CUser2@localhost;
DROP USER CUser2@LOCALHOST;
#
# Bug#31194: Privilege ordering does not order properly for wildcard values
#
CREATE DATABASE mysqltest_1;
CREATE TABLE mysqltest_1.t1 (a INT);
CREATE USER 'mysqltest1'@'%';
GRANT SELECT, UPDATE ON `mysqltest_1`.* TO 'mysqltest1'@'%';
REVOKE SELECT ON `mysqltest_1`.* FROM 'mysqltest1'@'%';
GRANT SELECT, UPDATE ON `mysqltest\_1`.* TO 'mysqltest1'@'%';
FLUSH PRIVILEGES;
connect (conn1,localhost,mysqltest1,,);
connection conn1;
SHOW GRANTS;
SELECT * FROM mysqltest_1.t1;
disconnect conn1;
connection default;
DROP USER 'mysqltest1'@'%';
DROP DATABASE mysqltest_1;
--echo End of 5.0 tests

View file

@ -982,4 +982,18 @@ desc t1;
show create table t1;
drop table t1;
#
# Bug #34223: Assertion failed: (optp->var_type & 127) == 8,
# file .\my_getopt.c, line 830
#
set @my_innodb_autoextend_increment=@@global.innodb_autoextend_increment;
set global innodb_autoextend_increment=8;
set global innodb_autoextend_increment=@my_innodb_autoextend_increment;
set @my_innodb_commit_concurrency=@@global.innodb_commit_concurrency;
set global innodb_commit_concurrency=0;
set global innodb_commit_concurrency=@my_innodb_commit_concurrency;
--echo End of 5.0 tests

View file

@ -0,0 +1 @@
--skip-log-bin

View file

@ -0,0 +1,6 @@
# Embedded server doesn't support external clients
--source include/not_embedded.inc
--replace_regex /MASTER_LOG_POS=[0-9]+/XX/
--error 2
--exec $MYSQL_DUMP --compact --master-data=2 test 2>&1

View file

@ -240,3 +240,26 @@ SHOW STATUS LIKE "handler_read%";
DROP TABLE t1,t2,t3,t4;
# End of 4.1 tests
#
# BUG#34945 "ref_or_null queries that are null_rejecting and have a null value crash mysql"
#
CREATE TABLE t1 (
a int(11) default NULL,
b int(11) default NULL,
KEY a (a,b)
);
INSERT INTO t1 VALUES (0,10),(0,11),(0,12);
CREATE TABLE t2 (
a int(11) default NULL,
b int(11) default NULL,
KEY a (a)
);
INSERT INTO t2 VALUES (3,NULL),(3,11),(3,12);
SELECT * FROM t2 inner join t1 WHERE ( t1.a = 0 OR t1.a IS NULL) AND t2.a = 3 AND t2.b = t1.b;
drop table t1, t2;
-- echo End of 5.0 tests

View file

@ -726,3 +726,15 @@ SELECT a, b FROM t1 ORDER BY b DESC;
SELECT a, b FROM t1 ORDER BY SEC_TO_TIME(a) DESC;
DROP TABLE t1;
--echo #
--echo # Bug#31590: Wrong error message on sort buffer being too small.
--echo #
create table t1(a int, b tinytext);
insert into t1 values (1,2),(3,2);
set session sort_buffer_size= 30000;
set session max_sort_length= 2180;
--error 1038
select * from t1 order by b;
drop table t1;

View file

@ -955,4 +955,21 @@ explain select * from t1 where dateval >= '2007-01-01 00:00:00' and dateval <= '
drop table t1;
#
# Bug #33833: different or-ed predicates were erroneously merged into one that
# resulted in ref access instead of range access and a wrong result set
#
CREATE TABLE t1 (
a varchar(32), index (a)
) DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
INSERT INTO t1 VALUES
('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A');
SELECT a FROM t1 WHERE a='b' OR a='B';
EXPLAIN SELECT a FROM t1 WHERE a='b' OR a='B';
DROP TABLE t1;
# End of 5.0 tests

View file

@ -224,3 +224,16 @@ SET @x:= (SELECT h FROM t1 WHERE (a,b,c,d,e,f,g)=(1,2,3,4,5,6,7));
SELECT @x;
DROP TABLE t1;
#
# Bug #34620: item_row.cc:50: Item_row::illegal_method_call(const char*):
# Assertion `0' failed
#
CREATE TABLE t1 (a INT, b INT);
INSERT INTO t1 VALUES (1,1);
SELECT ROW(a, 1) IN (SELECT SUM(b), 1) FROM t1 GROUP BY a;
SELECT ROW(a, 1) IN (SELECT SUM(b), 3) FROM t1 GROUP BY a;
DROP TABLE t1;

View file

@ -3672,4 +3672,33 @@ DROP TABLE t1;
--echo
###########################################################################
#
# Bug #33764: Wrong result with IN(), CONCAT() and implicit type conversion
#
CREATE TABLE t1 (a VARCHAR(10) NOT NULL PRIMARY KEY);
INSERT INTO t1 (a) VALUES ('foo0'), ('bar0'), ('baz0');
SELECT * FROM t1 WHERE a IN (CONCAT('foo', 0), 'bar');
DROP TABLE t1;
#
# Bug #32942 now() - interval '7200' second is NOT pre-calculated, causing "full table scan"
#
CREATE TABLE t1 (a INT, b INT);
CREATE TABLE t2 (a INT, c INT, KEY(a));
INSERT INTO t1 VALUES (1, 1), (2, 2);
INSERT INTO t2 VALUES (1, 1), (1, 2), (1, 3), (1, 4), (1, 5),
(2, 1), (2, 2), (2, 3), (2, 4), (2, 5),
(3, 1), (3, 2), (3, 3), (3, 4), (3, 5),
(4, 1), (4, 2), (4, 3), (4, 4), (4, 5);
FLUSH STATUS;
SELECT DISTINCT b FROM t1 LEFT JOIN t2 USING(a) WHERE c <= 3;
SHOW STATUS LIKE 'Handler_read%';
DROP TABLE t1, t2;
--echo End of 5.0 tests

View file

@ -7774,6 +7774,25 @@ call proc_33618(20);
drop table t_33618;
drop procedure proc_33618;
--echo #
--echo # Bug#30787: Stored function ignores user defined alias.
--echo #
use test;
--disable_warnings
drop function if exists func30787;
--enable_warnings
create table t1(f1 int);
insert into t1 values(1),(2);
delimiter |;
create function func30787(p1 int) returns int
begin
return p1;
end |
delimiter ;|
select (select func30787(f1)) as ttt from t1;
drop function func30787;
drop table t1;
--echo # ------------------------------------------------------------------
--echo # -- End of 5.0 tests

View file

@ -3006,92 +3006,44 @@ DROP TABLE t1,t2;
create table t1(a int,b int,key(a),key(b));
insert into t1(a,b) values (1,2),(2,1),(2,3),(3,4),(5,4),(5,5),
(6,7),(7,4),(5,3);
# test for the stack overflow bug
select sum(a),a from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1
)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1)
group by a;
--replace_regex /overrun.*$/overrun detected/
--error 1436
select sum(a),a from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1)
group by a;
# test for the memory consumption & subquery slowness bug
explain select sum(a),a from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1
)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1)
group by a;
--replace_regex /overrun.*$/overrun detected/
--error 1436
explain select sum(a),a from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1 where a> ( select sum(a) from t1 where a> (
select sum(a) from t1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1
)group by b limit 1)group by b limit 1)group by b limit 1)
group by a;
let $nesting= 26;
let $should_work_nesting= 5;
let $start= select sum(a),a from t1 where a> ( select sum(a) from t1 ;
let $end= )group by a ;
let $start_app= where a> ( select sum(a) from t1 ;
let $end_pre= )group by b limit 1 ;
--disable_result_log
--disable_query_log
# At least 4 level nesting should work without errors
while ($should_work_nesting)
{
--echo $should_work_nesting
eval $start $end;
eval explain $start $end;
let $start= $start
$start_app;
let $end= $end_pre
$end;
dec $should_work_nesting;
}
# Other may fail with the 'stack overrun error'
while ($nesting)
{
--echo $nesting
--error 0,1436
eval $start $end;
--error 0,1436
eval explain $start $end;
let $start= $start
$start_app;
let $end= $end_pre
$end;
dec $nesting;
}
--enable_result_log
--enable_query_log
drop table t1;
#

View file

@ -127,29 +127,22 @@ drop table t1;
#
# BUG#32111 - Security Breach via DATA/INDEX DIRECORY and RENAME TABLE
#
--replace_result $MYSQLTEST_VARDIR TEST_DIR
eval CREATE TABLE t1(a INT)
DATA DIRECTORY='$MYSQLTEST_VARDIR/master-data/mysql'
INDEX DIRECTORY='$MYSQLTEST_VARDIR/master-data/mysql';
--write_file $MYSQLTEST_VARDIR/tmp/t1.MYI
EOF
--replace_result $MYSQLTEST_VARDIR TEST_DIR
--error 1
RENAME TABLE t1 TO user;
DROP TABLE t1;
#
# Test specifying DATA DIRECTORY that is the same as what would normally
# have been chosen. (Bug #8707)
#
disable_query_log;
eval create table t1 (i int) data directory = "$MYSQLTEST_VARDIR/master-data/test/";
enable_query_log;
show create table t1;
drop table t1;
disable_query_log;
eval create table t1 (i int) index directory = "$MYSQLTEST_VARDIR/master-data/test/";
enable_query_log;
show create table t1;
drop table t1;
eval CREATE TABLE t1(a INT)
DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp'
INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp';
--replace_result $MYSQLTEST_VARDIR TEST_DIR
eval CREATE TABLE t2(a INT)
DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp'
INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp';
--replace_result $MYSQLTEST_VARDIR TEST_DIR
--error 1
RENAME TABLE t2 TO t1;
DROP TABLE t2;
--remove_file $MYSQLTEST_VARDIR/tmp/t1.MYI
#
# Bug#8706 - temporary table with data directory option fails
@ -188,44 +181,61 @@ connection default;
select * from t1;
drop table t1;
#
# CREATE TABLE with DATA DIRECTORY option
#
# Protect ourselves from data left in tmp/ by a previos possibly failed
# test
--system rm -f $MYSQLTEST_VARDIR/tmp/t1.*
--disable_query_log
eval prepare stmt from "create table t1 (c char(10)) data directory='$MYSQLTEST_VARDIR/tmp'";
--enable_query_log
execute stmt;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
show create table t1;
drop table t1;
execute stmt;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
show create table t1;
drop table t1;
deallocate prepare stmt;
#
# Bug#32167 another privilege bypass with DATA/INDEX DIRECORY
#
--replace_result $MYSQL_TEST_DIR TEST_DIR
--error 1,1210
eval CREATE TABLE t1(a INT)
DATA DIRECTORY='$MYSQL_TEST_DIR/var/master-data/test';
--replace_result $MYSQL_TEST_DIR TEST_DIR
--error 1,1210
eval CREATE TABLE t1(a INT)
DATA DIRECTORY='$MYSQL_TEST_DIR/var/master-data/';
--replace_result $MYSQL_TEST_DIR TEST_DIR
--error 1,1210
eval CREATE TABLE t1(a INT)
INDEX DIRECTORY='$MYSQL_TEST_DIR/var/master-data';
--replace_result $MYSQL_TEST_DIR TEST_DIR
--error 1,1210
eval CREATE TABLE t1(a INT)
INDEX DIRECTORY='$MYSQL_TEST_DIR/var/master-data_var';
--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;
--write_file $MYSQLTEST_VARDIR/master-data/test/t1.MYD
EOF
--disable_abort_on_error
--error 1
CREATE TABLE t1 (a INT) ENGINE MYISAM;
--error 0,1
--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.MYD;
--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;
SET SESSION keep_files_on_create = FALSE;
CREATE TABLE t1 (a INT) ENGINE MYISAM;
DROP TABLE t1;
--echo End of 5.0 tests

View file

@ -49,3 +49,16 @@ drop table t2,t1;
unlock tables;
# End of 4.1 tests
#
# Bug#23588 SHOW COLUMNS on a temporary table causes locking issues
#
create temporary table t1(f1 int);
lock tables t1 write;
insert into t1 values (1);
show columns from t1;
insert into t1 values(2);
drop table t1;
unlock tables;
# End of 5.0 tests

View file

@ -56,3 +56,23 @@ set('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17',
'50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','1'));
show create table t1;
drop table t1;
#
# Bug#15409: Columns with SET datatype with 64-element sets
# may not be updated with integers
#
let $i=64;
let $s='$i';
dec $i;
while ($i) {
let $s='$i',$s;
dec $i;
}
--eval CREATE TABLE t1(c set($s))
INSERT INTO t1 VALUES(7);
INSERT INTO t1 VALUES(9223372036854775808);
SELECT * FROM t1;
DROP TABLE t1;
--# echo End of 5.0 tests

View file

@ -3471,6 +3471,40 @@ set @@sql_mode=@old_mode;
drop view v1;
drop table t1;
#
# Bug #33389: Selecting from a view into a table from within SP or trigger
# crashes server
#
create table t1 (a int, key(a));
create table t2 (c int);
create view v1 as select a b from t1;
create view v2 as select 1 a from t2, v1 where c in
(select 1 from t1 where b = a);
insert into t1 values (1), (1);
insert into t2 values (1), (1);
prepare stmt from "select * from v2 where a = 1";
execute stmt;
drop view v1, v2;
drop table t1, t2;
#
# Bug #33049: Assert while running test-as3ap test(mysql-bench suite)
#
CREATE TABLE t1 (a INT);
CREATE VIEW v1 AS SELECT p.a AS a FROM t1 p, t1 q;
INSERT INTO t1 VALUES (1), (1);
SELECT MAX(a), COUNT(DISTINCT a) FROM v1 GROUP BY a;
DROP VIEW v1;
DROP TABLE t1;
###########################################################################
--echo # -----------------------------------------------------------------

View file

@ -212,4 +212,37 @@ DROP PROCEDURE sp1;
DROP PROCEDURE sp2;
DROP PROCEDURE sp3;
#
# Bug#30059: End-space truncation warnings are inconsistent or incorrect
#
create table t1 (c_char char(255), c_varchar varchar(255), c_tinytext tinytext);
create table t2 (c_tinyblob tinyblob); # not affected by bug, for regression testing
set @c = repeat(' ', 256);
set @q = repeat('q', 256);
set sql_mode = '';
insert into t1 values(@c, @c, @c);
insert into t2 values(@c);
insert into t1 values(@q, @q, @q);
insert into t2 values(@q);
set sql_mode = 'traditional';
insert into t1 values(@c, @c, @c);
--error 1406
insert into t2 values(@c);
--error 1406
insert into t1 values(@q, NULL, NULL);
--error 1406
insert into t1 values(NULL, @q, NULL);
--error 1406
insert into t1 values(NULL, NULL, @q);
--error 1406
insert into t2 values(@q);
drop table t1, t2;
--echo End of 5.0 tests

View file

@ -35,7 +35,7 @@
File my_create(const char *FileName, int CreateFlags, int access_flags,
myf MyFlags)
{
int fd;
int fd, rc;
DBUG_ENTER("my_create");
DBUG_PRINT("my",("Name: '%s' CreateFlags: %d AccessFlags: %d MyFlags: %d",
FileName, CreateFlags, access_flags, MyFlags));
@ -60,6 +60,20 @@ File my_create(const char *FileName, int CreateFlags, int access_flags,
fd = open(FileName, access_flags);
#endif
DBUG_RETURN(my_register_filename(fd, FileName, FILE_BY_CREATE,
EE_CANTCREATEFILE, MyFlags));
rc= my_register_filename(fd, FileName, FILE_BY_CREATE,
EE_CANTCREATEFILE, MyFlags);
/*
my_register_filename() may fail on some platforms even if the call to
*open() above succeeds. In this case, don't leave the stale file because
callers assume the file to not exist if my_create() fails, so they don't
do any cleanups.
*/
if (unlikely(fd >= 0 && rc < 0))
{
int tmp= my_errno;
my_delete(FileName, MyFlags);
my_errno= tmp;
}
DBUG_RETURN(rc);
} /* my_create */

View file

@ -123,11 +123,13 @@ include="-I$pkgincludedir"
# Remove some options that a client doesn't have to care about
# FIXME until we have a --cxxflags, we need to remove -Xa
# and -xstrconst to make --cflags usable for Sun Forte C++
# FIXME until we have a --cxxflags, we need to remove -AC99
# to make --cflags usable for HP C++ (aCC)
for remove in DDBUG_OFF DSAFEMALLOC USAFEMALLOC DSAFE_MUTEX \
DPEDANTIC_SAFEMALLOC DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS \
DEXTRA_DEBUG DHAVE_purify O 'O[0-9]' 'xO[0-9]' 'W[-A-Za-z]*' \
'mtune=[-A-Za-z0-9]*' 'mcpu=[-A-Za-z0-9]*' 'march=[-A-Za-z0-9]*' \
Xa xstrconst "xc99=none" \
Xa xstrconst "xc99=none" AC99 \
unroll2 ip mp restrict
do
# The first option we might strip will always have a space before it because

View file

@ -117,6 +117,7 @@ uint mysql_port=0;
char *mysql_unix_port= 0;
const char *unknown_sqlstate= "HY000";
const char *not_error_sqlstate= "00000";
const char *cant_connect_sqlstate= "08001";
#ifdef HAVE_SMEM
char *shared_memory_base_name= 0;
const char *def_shared_memory_base_name= default_shared_memory_base_name;
@ -131,6 +132,9 @@ static int wait_for_data(my_socket fd, uint timeout);
CHARSET_INFO *default_client_charset_info = &my_charset_latin1;
/* Server error code and message */
unsigned int mysql_server_last_errno;
char mysql_server_last_error[MYSQL_ERRMSG_SIZE];
/****************************************************************************
A modified version of connect(). my_connect() allows you to specify
@ -752,10 +756,18 @@ void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate)
DBUG_PRINT("enter", ("error :%d '%s'", errcode, ER(errcode)));
DBUG_ASSERT(mysql != 0);
net= &mysql->net;
net->last_errno= errcode;
strmov(net->last_error, ER(errcode));
strmov(net->sqlstate, sqlstate);
if (mysql)
{
net= &mysql->net;
net->last_errno= errcode;
strmov(net->last_error, ER(errcode));
strmov(net->sqlstate, sqlstate);
}
else
{
mysql_server_last_errno= errcode;
strmov(mysql_server_last_error, ER(errcode));
}
DBUG_VOID_RETURN;
}
@ -1477,7 +1489,10 @@ mysql_init(MYSQL *mysql)
if (!mysql)
{
if (!(mysql=(MYSQL*) my_malloc(sizeof(*mysql),MYF(MY_WME | MY_ZEROFILL))))
{
set_mysql_error(NULL, CR_OUT_OF_MEMORY, unknown_sqlstate);
return 0;
}
mysql->free_me=1;
}
else
@ -3064,13 +3079,13 @@ unsigned int STDCALL mysql_num_fields(MYSQL_RES *res)
uint STDCALL mysql_errno(MYSQL *mysql)
{
return mysql->net.last_errno;
return mysql ? mysql->net.last_errno : mysql_server_last_errno;
}
const char * STDCALL mysql_error(MYSQL *mysql)
{
return mysql->net.last_error;
return mysql ? mysql->net.last_error : mysql_server_last_error;
}

View file

@ -5861,26 +5861,41 @@ check_string_copy_error(Field_str *field,
}
/*
Send a truncation warning or a truncation error
after storing a too long character string info a field.
Check if we lost any important data and send a truncation error/warning
SYNOPSIS
report_data_too_long()
field - Field
Field_longstr::report_if_important_data()
ptr - Truncated rest of string
end - End of truncated string
RETURN
N/A
RETURN VALUES
0 - None was truncated (or we don't count cut fields)
2 - Some bytes was truncated
NOTE
Check if we lost any important data (anything in a binary string,
or any non-space in others). If only trailing spaces was lost,
send a truncation note, otherwise send a truncation error.
*/
inline void
report_data_too_long(Field_str *field)
int
Field_longstr::report_if_important_data(const char *ptr, const char *end)
{
if (field->table->in_use->abort_on_warning)
field->set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
else
field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
if ((ptr < end) && table->in_use->count_cuted_fields)
{
if (test_if_important_data(field_charset, ptr, end))
{
if (table->in_use->abort_on_warning)
set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
else
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
}
else /* If we lost only spaces then produce a NOTE, not a WARNING */
set_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1);
return 2;
}
return 0;
}
@ -5914,19 +5929,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs)
cannot_convert_error_pos, from + length))
return 2;
/*
Check if we lost any important data (anything in a binary string,
or any non-space in others).
*/
if ((from_end_pos < from + length) && table->in_use->count_cuted_fields)
{
if (test_if_important_data(field_charset, from_end_pos, from + length))
{
report_data_too_long(this);
return 2;
}
}
return 0;
return report_if_important_data(from_end_pos, from + length);
}
@ -6385,16 +6388,7 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs)
cannot_convert_error_pos, from + length))
return 2;
// Check if we lost something other than just trailing spaces
if ((from_end_pos < from + length) && table->in_use->count_cuted_fields)
{
if (test_if_important_data(field_charset, from_end_pos, from + length))
report_data_too_long(this);
else /* If we lost only spaces then produce a NOTE, not a WARNING */
set_warning(MYSQL_ERROR::WARN_LEVEL_NOTE, WARN_DATA_TRUNCATED, 1);
return 2;
}
return 0;
return report_if_important_data(from_end_pos, from + length);
}
@ -7030,13 +7024,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs)
cannot_convert_error_pos, from + length))
return 2;
if (from_end_pos < from + length)
{
report_data_too_long(this);
return 2;
}
return 0;
return report_if_important_data(from_end_pos, from + length);
oom_error:
/* Fatal OOM error */
@ -7883,10 +7871,10 @@ int Field_set::store(const char *from,uint length,CHARSET_INFO *cs)
int Field_set::store(longlong nr, bool unsigned_val)
{
int error= 0;
if ((ulonglong) nr > (ulonglong) (((longlong) 1 << typelib->count) -
(longlong) 1))
ulonglong max_nr= set_bits(ulonglong, typelib->count);
if ((ulonglong) nr > max_nr)
{
nr&= (longlong) (((longlong) 1 << typelib->count) - (longlong) 1);
nr&= max_nr;
set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1);
error=1;
}

View file

@ -454,6 +454,8 @@ public:
class Field_longstr :public Field_str
{
protected:
int report_if_important_data(const char *ptr, const char *end);
public:
Field_longstr(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, utype unireg_check_arg,

View file

@ -222,8 +222,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
sort_keys= table_sort.sort_keys;
if (memavl < min_sort_memory)
{
my_error(ER_OUTOFMEMORY,MYF(ME_ERROR+ME_WAITTANG),
thd->variables.sortbuff_size);
my_error(ER_OUT_OF_SORTMEMORY,MYF(ME_ERROR+ME_WAITTANG));
goto err;
}
if (open_cached_file(&buffpek_pointers,mysql_tmpdir,TEMP_PREFIX,

View file

@ -117,7 +117,8 @@ void ndb_serialize_cond(const Item *item, void *arg)
if (item->type() == Item::FUNC_ITEM)
{
Item_func *func_item= (Item_func *) item;
if (func_item->functype() == Item_func::UNKNOWN_FUNC &&
if ((func_item->functype() == Item_func::UNKNOWN_FUNC ||
func_item->functype() == Item_func::NEG_FUNC) &&
func_item->const_item())
{
// Skip any arguments since we will evaluate function instead
@ -369,8 +370,9 @@ void ndb_serialize_cond(const Item *item, void *arg)
{
Item_func *func_item= (Item_func *) item;
// Check that we expect a function or functional expression here
if (context->expecting(Item::FUNC_ITEM) ||
func_item->functype() == Item_func::UNKNOWN_FUNC)
if (context->expecting(Item::FUNC_ITEM) ||
func_item->functype() == Item_func::UNKNOWN_FUNC ||
func_item->functype() == Item_func::NEG_FUNC)
context->expect_nothing();
else
{
@ -584,6 +586,7 @@ void ndb_serialize_cond(const Item *item, void *arg)
context->expect(Item::FUNC_ITEM);
break;
}
case Item_func::NEG_FUNC:
case Item_func::UNKNOWN_FUNC:
{
DBUG_PRINT("info", ("UNKNOWN_FUNC %s",

View file

@ -228,6 +228,7 @@ public:
case (Item_func::ISNOTNULL_FUNC): { return NDB_ISNOTNULL_FUNC; }
case (Item_func::LIKE_FUNC): { return NDB_LIKE_FUNC; }
case (Item_func::NOT_FUNC): { return NDB_NOT_FUNC; }
case (Item_func::NEG_FUNC): { return NDB_UNKNOWN_FUNC; }
case (Item_func::UNKNOWN_FUNC): { return NDB_UNKNOWN_FUNC; }
case (Item_func::COND_AND_FUNC): { return NDB_COND_AND_FUNC; }
case (Item_func::COND_OR_FUNC): { return NDB_COND_OR_FUNC; }

View file

@ -1381,6 +1381,13 @@ int ha_delete_table(THD *thd, enum db_type table_type, const char *path,
handler *handler::clone(MEM_ROOT *mem_root)
{
handler *new_handler= get_new_handler(table, mem_root, table->s->db_type);
/*
Allocate handler->ref here because otherwise ha_open will allocate it
on this->table->mem_root and we will not be able to reclaim that memory
when the clone handler object is destroyed.
*/
if (!(new_handler->ref= (byte*) alloc_root(mem_root, ALIGN_SIZE(ref_length)*2)))
return NULL;
if (new_handler && !new_handler->ha_open(table->s->path, table->db_stat,
HA_OPEN_IGNORE_IF_LOCKED))
return new_handler;
@ -1420,8 +1427,9 @@ int handler::ha_open(const char *name, int mode, int test_if_locked)
(void) extra(HA_EXTRA_NO_READCHECK); // Not needed in SQL
DBUG_ASSERT(alloc_root_inited(&table->mem_root));
if (!(ref= (byte*) alloc_root(&table->mem_root, ALIGN_SIZE(ref_length)*2)))
/* ref is already allocated for us if we're called from handler::clone() */
if (!ref && !(ref= (byte*) alloc_root(&table->mem_root,
ALIGN_SIZE(ref_length)*2)))
{
close();
error=HA_ERR_OUT_OF_MEM;

View file

@ -1207,6 +1207,22 @@ bool Item_name_const::is_null()
return value_item->is_null();
}
Item_name_const::Item_name_const(Item *name_arg, Item *val):
value_item(val), name_item(name_arg)
{
if (!(valid_args= name_item->basic_const_item() &&
(value_item->basic_const_item() ||
((value_item->type() == FUNC_ITEM) &&
(((Item_func *) value_item)->functype() ==
Item_func::NEG_FUNC) &&
(((Item_func *) value_item)->key_item()->type() !=
FUNC_ITEM)))))
my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST");
Item::maybe_null= TRUE;
}
Item::Type Item_name_const::type() const
{
/*
@ -1218,8 +1234,17 @@ Item::Type Item_name_const::type() const
if (item->type() == FIELD_ITEM)
((Item_field *) item)->...
we return NULL_ITEM in the case to avoid wrong casting.
valid_args guarantees value_item->basic_const_item(); if type is
FUNC_ITEM, then we have a fudged item_func_neg() on our hands
and return the underlying type.
*/
return valid_args ? value_item->type() : NULL_ITEM;
return valid_args ?
(((value_item->type() == FUNC_ITEM) &&
(((Item_func *) value_item)->functype() == Item_func::NEG_FUNC)) ?
((Item_func *) value_item)->key_item()->type() :
value_item->type()) :
NULL_ITEM;
}
@ -3912,6 +3937,18 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
else if (!from_field)
goto error;
if (!outer_fixed && cached_table && cached_table->select_lex &&
context->select_lex &&
cached_table->select_lex != context->select_lex)
{
int ret;
if ((ret= fix_outer_field(thd, &from_field, reference)) < 0)
goto error;
else if (!ret)
return FALSE;
outer_fixed= 1;
}
/*
if it is not expression from merged VIEW we will set this field.
@ -3927,18 +3964,6 @@ bool Item_field::fix_fields(THD *thd, Item **reference)
if (from_field == view_ref_found)
return FALSE;
if (!outer_fixed && cached_table && cached_table->select_lex &&
context->select_lex &&
cached_table->select_lex != context->select_lex)
{
int ret;
if ((ret= fix_outer_field(thd, &from_field, reference)) < 0)
goto error;
else if (!ret)
return FALSE;
outer_fixed= 1;
}
set_field(from_field);
if (thd->lex->in_sum_func &&
thd->lex->in_sum_func->nest_level ==
@ -4092,6 +4117,30 @@ bool Item_field::subst_argument_checker(byte **arg)
}
/**
Convert a numeric value to a zero-filled string
@param[in,out] item the item to operate on
@param field The field that this value is equated to
This function converts a numeric value to a string. In this conversion
the zero-fill flag of the field is taken into account.
This is required so the resulting string value can be used instead of
the field reference when propagating equalities.
*/
static void convert_zerofill_number_to_string(Item **item, Field_num *field)
{
char buff[MAX_FIELD_WIDTH],*pos;
String tmp(buff,sizeof(buff), field->charset()), *res;
res= (*item)->val_str(&tmp);
field->prepend_zeros(res);
pos= (char *) sql_strmake (res->ptr(), res->length());
*item= new Item_string(pos, res->length(), field->charset());
}
/*
Set a pointer to the multiple equality the field reference belongs to
(if any)
@ -4140,6 +4189,13 @@ Item *Item_field::equal_fields_propagator(byte *arg)
if (!item ||
(cmp_context != (Item_result)-1 && item->cmp_context != cmp_context))
item= this;
else if (field && (field->flags & ZEROFILL_FLAG) && IS_NUM(field->type()))
{
if (item && cmp_context != INT_RESULT)
convert_zerofill_number_to_string(&item, (Field_num *)field);
else
item= this;
}
return item;
}
@ -4311,6 +4367,49 @@ String *Item::check_well_formed_result(String *str, bool send_error)
return str;
}
/*
Compare two items using a given collation
SYNOPSIS
eq_by_collation()
item item to compare with
binary_cmp TRUE <-> compare as binaries
cs collation to use when comparing strings
DESCRIPTION
This method works exactly as Item::eq if the collation cs coincides with
the collation of the compared objects. Otherwise, first the collations that
differ from cs are replaced for cs and then the items are compared by
Item::eq. After the comparison the original collations of items are
restored.
RETURN
1 compared items has been detected as equal
0 otherwise
*/
bool Item::eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs)
{
CHARSET_INFO *save_cs= 0;
CHARSET_INFO *save_item_cs= 0;
if (collation.collation != cs)
{
save_cs= collation.collation;
collation.collation= cs;
}
if (item->collation.collation != cs)
{
save_item_cs= item->collation.collation;
item->collation.collation= cs;
}
bool res= eq(item, binary_cmp);
if (save_cs)
collation.collation= save_cs;
if (save_item_cs)
item->collation.collation= save_item_cs;
return res;
}
/*
Create a field to hold a string value from an item

View file

@ -873,6 +873,7 @@ public:
virtual Field::geometry_type get_geometry_type() const
{ return Field::GEOM_GEOMETRY; };
String *check_well_formed_result(String *str, bool send_error= 0);
bool eq_by_collation(Item *item, bool binary_cmp, CHARSET_INFO *cs);
};
@ -1130,14 +1131,7 @@ class Item_name_const : public Item
Item *name_item;
bool valid_args;
public:
Item_name_const(Item *name_arg, Item *val):
value_item(val), name_item(name_arg)
{
if (!(valid_args= name_item->basic_const_item() &
value_item->basic_const_item()))
my_error(ER_WRONG_ARGUMENTS, MYF(0), "NAME_CONST");
Item::maybe_null= TRUE;
}
Item_name_const(Item *name_arg, Item *val);
bool fix_fields(THD *, Item **);
@ -1989,6 +1983,35 @@ public:
Item_field *filed_for_view_update()
{ return (*ref)->filed_for_view_update(); }
virtual Ref_Type ref_type() { return REF; }
// Row emulation: forwarding of ROW-related calls to ref
uint cols()
{
return ref && result_type() == ROW_RESULT ? (*ref)->cols() : 1;
}
Item* element_index(uint i)
{
return ref && result_type() == ROW_RESULT ? (*ref)->element_index(i) : this;
}
Item** addr(uint i)
{
return ref && result_type() == ROW_RESULT ? (*ref)->addr(i) : 0;
}
bool check_cols(uint c)
{
return ref && result_type() == ROW_RESULT ? (*ref)->check_cols(c)
: Item::check_cols(c);
}
bool null_inside()
{
return ref && result_type() == ROW_RESULT ? (*ref)->null_inside() : 0;
}
void bring_value()
{
if (ref && result_type() == ROW_RESULT)
(*ref)->bring_value();
}
};

View file

@ -2995,7 +2995,10 @@ void in_string::set(uint pos,Item *item)
{
if (res->uses_buffer_owned_by(str))
res->copy();
*str= *res;
if (item->type() == Item::FUNC_ITEM)
str->copy(*res);
else
*str= *res;
}
if (!str->charset())
{

View file

@ -5515,6 +5515,8 @@ Item_func_sp::make_field(Send_field *tmp_field)
DBUG_ENTER("Item_func_sp::make_field");
DBUG_ASSERT(sp_result_field);
sp_result_field->make_field(tmp_field);
if (name)
tmp_field->col_name= name;
DBUG_VOID_RETURN;
}

View file

@ -54,7 +54,8 @@ public:
NOT_FUNC, NOT_ALL_FUNC,
NOW_FUNC, TRIG_COND_FUNC,
SUSERVAR_FUNC, GUSERVAR_FUNC, COLLATE_FUNC,
EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP, UDF_FUNC };
EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP, UDF_FUNC,
NEG_FUNC };
enum optimize_type { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL,
OPTIMIZE_EQUAL };
enum Type type() const { return FUNC_ITEM; }
@ -466,7 +467,7 @@ public:
longlong int_op();
my_decimal *decimal_op(my_decimal *);
const char *func_name() const { return "-"; }
virtual bool basic_const_item() const { return args[0]->basic_const_item(); }
enum Functype functype() const { return NEG_FUNC; }
void fix_length_and_dec();
void fix_num_length_and_dec();
uint decimal_precision() const { return args[0]->decimal_precision(); }

View file

@ -597,6 +597,7 @@ Item_sum_hybrid::fix_fields(THD *thd, Item **ref)
result_field=0;
null_value=1;
fix_length_and_dec();
item= item->real_item();
if (item->type() == Item::FIELD_ITEM)
hybrid_field_type= ((Item_field*) item)->field->type();
else
@ -3459,6 +3460,6 @@ void Item_func_group_concat::print(String *str)
Item_func_group_concat::~Item_func_group_concat()
{
if (unique_filter)
if (!original && unique_filter)
delete unique_filter;
}

View file

@ -2496,12 +2496,7 @@ static void print_buffer_to_nt_eventlog(enum loglevel level, char *buff,
void
*/
#ifdef EMBEDDED_LIBRARY
void vprint_msg_to_log(enum loglevel level __attribute__((unused)),
const char *format __attribute__((unused)),
va_list argsi __attribute__((unused)))
{}
#else /*!EMBEDDED_LIBRARY*/
#ifndef EMBEDDED_LIBRARY
static void print_buffer_to_file(enum loglevel level, const char *buffer)
{
time_t skr;

View file

@ -73,6 +73,7 @@ extern const char *primary_key_name;
#include "mysql_com.h"
#include <violite.h>
#include "unireg.h"
#define IS_NUM(t) ((t) <= FIELD_TYPE_INT24 || (t) == FIELD_TYPE_YEAR || (t) == FIELD_TYPE_NEWDECIMAL)
void init_sql_alloc(MEM_ROOT *root, uint block_size, uint pre_alloc_size);
gptr sql_alloc(unsigned size);
@ -1254,6 +1255,7 @@ void my_dbopt_free(void);
extern time_t server_start_time;
extern char *mysql_data_home,server_version[SERVER_VERSION_LENGTH],
mysql_real_data_home[], *opt_mysql_tmpdir, mysql_charsets_dir[],
mysql_unpacked_real_data_home[],
def_ft_boolean_syntax[sizeof(ft_boolean_syntax)];
#define mysql_tmpdir (my_tmpdir(&mysql_tmpdir_list))
extern MY_TMPDIR mysql_tmpdir_list;

View file

@ -475,14 +475,13 @@ char log_error_file[FN_REFLEN], glob_hostname[FN_REFLEN];
char mysql_real_data_home[FN_REFLEN],
language[FN_REFLEN], reg_ext[FN_EXTLEN], mysql_charsets_dir[FN_REFLEN],
*opt_init_file, *opt_tc_log_file,
mysql_unpacked_real_data_home[FN_REFLEN],
def_ft_boolean_syntax[sizeof(ft_boolean_syntax)];
char *mysql_data_home= mysql_real_data_home;
const key_map key_map_empty(0);
key_map key_map_full(0); // Will be initialized later
const char *opt_date_time_formats[3];
char *mysql_data_home= mysql_real_data_home;
char server_version[SERVER_VERSION_LENGTH];
char *mysqld_unix_port, *opt_mysql_tmpdir;
const char **errmesg; /* Error messages */
@ -2399,10 +2398,6 @@ static void init_signals(void)
struct sigaction sa;
DBUG_ENTER("init_signals");
if (test_flags & TEST_SIGINT)
{
my_sigset(thr_kill_signal, end_thread_signal);
}
my_sigset(THR_SERVER_ALARM,print_signal_warning); // Should never be called!
if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL))
@ -2439,7 +2434,6 @@ static void init_signals(void)
(void) sigemptyset(&set);
my_sigset(SIGPIPE,SIG_IGN);
sigaddset(&set,SIGPIPE);
sigaddset(&set,SIGINT);
#ifndef IGNORE_SIGHUP_SIGQUIT
sigaddset(&set,SIGQUIT);
sigaddset(&set,SIGHUP);
@ -2461,9 +2455,12 @@ static void init_signals(void)
sigaddset(&set,THR_SERVER_ALARM);
if (test_flags & TEST_SIGINT)
{
my_sigset(thr_kill_signal, end_thread_signal);
// May be SIGINT
sigdelset(&set, thr_kill_signal);
}
else
sigaddset(&set,SIGINT);
sigprocmask(SIG_SETMASK,&set,NULL);
pthread_sigmask(SIG_SETMASK,&set,NULL);
DBUG_VOID_RETURN;
@ -5929,7 +5926,7 @@ log and this option does nothing anymore.",
"Data file autoextend increment in megabytes",
(gptr*) &srv_auto_extend_increment,
(gptr*) &srv_auto_extend_increment,
0, GET_LONG, REQUIRED_ARG, 8L, 1L, 1000L, 0, 1L, 0},
0, GET_ULONG, REQUIRED_ARG, 8L, 1L, 1000L, 0, 1L, 0},
{"innodb_buffer_pool_awe_mem_mb", OPT_INNODB_BUFFER_POOL_AWE_MEM_MB,
"If Windows AWE is used, the size of InnoDB buffer pool allocated from the AWE memory.",
(gptr*) &innobase_buffer_pool_awe_mem_mb, (gptr*) &innobase_buffer_pool_awe_mem_mb, 0,
@ -5942,7 +5939,7 @@ log and this option does nothing anymore.",
{"innodb_commit_concurrency", OPT_INNODB_COMMIT_CONCURRENCY,
"Helps in performance tuning in heavily concurrent environments.",
(gptr*) &srv_commit_concurrency, (gptr*) &srv_commit_concurrency,
0, GET_LONG, REQUIRED_ARG, 0, 0, 1000, 0, 1, 0},
0, GET_ULONG, REQUIRED_ARG, 0, 0, 1000, 0, 1, 0},
{"innodb_concurrency_tickets", OPT_INNODB_CONCURRENCY_TICKETS,
"Number of times a thread is allowed to enter InnoDB within the same \
SQL query after it has once got the ticket",
@ -7742,6 +7739,9 @@ static void fix_paths(void)
pos[1]= 0;
}
convert_dirname(mysql_real_data_home,mysql_real_data_home,NullS);
(void) fn_format(buff, mysql_real_data_home, "", "",
(MY_RETURN_REAL_PATH|MY_RESOLVE_SYMLINKS));
(void) unpack_dirname(mysql_unpacked_real_data_home, buff);
convert_dirname(language,language,NullS);
(void) my_load_path(mysql_home,mysql_home,""); // Resolve current dir
(void) my_load_path(mysql_real_data_home,mysql_real_data_home,mysql_home);

View file

@ -261,6 +261,7 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp)
char buff[65];
String str(buff, sizeof(buff), &my_charset_bin);
ulong sql_mode;
bool saved_time_zone_used= thd->time_zone_used;
Open_tables_state open_tables_state_backup;
DBUG_ENTER("db_find_routine");
DBUG_PRINT("enter", ("type: %d name: %.*s",
@ -370,6 +371,11 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp)
definer, created, modified);
done:
/*
Restore the time zone flag as the timezone usage in proc table
does not affect replication.
*/
thd->time_zone_used= saved_time_zone_used;
if (table)
close_proc_table(thd, &open_tables_state_backup);
DBUG_RETURN(ret);

View file

@ -668,7 +668,9 @@ static ulong get_sort(uint count,...)
{
for (; *str ; str++)
{
if (*str == wild_many || *str == wild_one || *str == wild_prefix)
if (*str == wild_prefix && str[1])
str++;
else if (*str == wild_many || *str == wild_one)
{
wild_pos= (uint) (str - start) + 1;
break;

View file

@ -2852,8 +2852,12 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags)
}
if (tables->lock_type != TL_UNLOCK && ! thd->locked_tables)
tables->table->reginfo.lock_type= tables->lock_type == TL_WRITE_DEFAULT ?
thd->update_lock_default : tables->lock_type;
{
if (tables->lock_type == TL_WRITE_DEFAULT)
tables->table->reginfo.lock_type= thd->update_lock_default;
else if (tables->table->s->tmp_table == NO_TMP_TABLE)
tables->table->reginfo.lock_type= tables->lock_type;
}
tables->table->grant= tables->grant;
process_view_routines:

View file

@ -3006,7 +3006,8 @@ bool select_insert::send_eof()
((thd->client_capabilities & CLIENT_FOUND_ROWS) ?
info.touched : info.updated);
id= autoinc_value_of_first_inserted_row > 0 ?
autoinc_value_of_first_inserted_row : thd->last_insert_id;
autoinc_value_of_first_inserted_row : thd->insert_id_used ?
thd->last_insert_id : 0;
::send_ok(thd, (ulong) thd->row_count_func, id, buff);
DBUG_RETURN(0);
}

View file

@ -76,6 +76,7 @@ static void remove_escape(char *name);
static bool append_file_to_dir(THD *thd, const char **filename_ptr,
const char *table_name);
static bool check_show_create_table_access(THD *thd, TABLE_LIST *table);
static bool test_if_data_home_dir(const char *dir);
const char *any_db="*any*"; // Special symbol for check_access
@ -3040,6 +3041,20 @@ mysql_execute_command(THD *thd)
"INDEX DIRECTORY option ignored");
create_info.data_file_name= create_info.index_file_name= NULL;
#else
if (test_if_data_home_dir(lex->create_info.data_file_name))
{
my_error(ER_WRONG_ARGUMENTS,MYF(0),"DATA DIRECORY");
res= -1;
break;
}
if (test_if_data_home_dir(lex->create_info.index_file_name))
{
my_error(ER_WRONG_ARGUMENTS,MYF(0),"INDEX DIRECORY");
res= -1;
break;
}
/* Fix names if symlinked tables */
if (append_file_to_dir(thd, &create_info.data_file_name,
create_table->table_name) ||
@ -7883,3 +7898,48 @@ bool check_string_length(LEX_STRING *str, const char *err_msg,
return TRUE;
}
/*
Check if path does not contain mysql data home directory
SYNOPSIS
test_if_data_home_dir()
dir directory
conv_home_dir converted data home directory
home_dir_len converted data home directory length
RETURN VALUES
0 ok
1 error
*/
static bool test_if_data_home_dir(const char *dir)
{
char path[FN_REFLEN], conv_path[FN_REFLEN];
uint dir_len, home_dir_len= strlen(mysql_unpacked_real_data_home);
DBUG_ENTER("test_if_data_home_dir");
if (!dir)
DBUG_RETURN(0);
(void) fn_format(path, dir, "", "",
(MY_RETURN_REAL_PATH|MY_RESOLVE_SYMLINKS));
dir_len= unpack_dirname(conv_path, dir);
if (home_dir_len <= dir_len)
{
if (lower_case_file_system)
{
if (!my_strnncoll(default_charset_info, (const uchar*) conv_path,
home_dir_len,
(const uchar*) mysql_unpacked_real_data_home,
home_dir_len))
DBUG_RETURN(1);
}
else if (!memcmp(conv_path, mysql_unpacked_real_data_home, home_dir_len))
DBUG_RETURN(1);
}
DBUG_RETURN(0);
}

View file

@ -360,10 +360,10 @@ fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select,
}
}
new_ref= direct_ref ?
new Item_direct_ref(ref->context, item_ref, ref->field_name,
ref->table_name, ref->alias_name_used) :
new Item_ref(ref->context, item_ref, ref->field_name,
ref->table_name, ref->alias_name_used);
new Item_direct_ref(ref->context, item_ref, ref->table_name,
ref->field_name, ref->alias_name_used) :
new Item_ref(ref->context, item_ref, ref->table_name,
ref->field_name, ref->alias_name_used);
if (!new_ref)
return TRUE;
ref->outer_ref= new_ref;
@ -2887,7 +2887,9 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end,
}
}
else if (old->eq_func && new_fields->eq_func &&
old->val->eq(new_fields->val, old->field->binary()))
old->val->eq_by_collation(new_fields->val,
old->field->binary(),
old->field->charset()))
{
old->level= and_level;
@ -10794,7 +10796,7 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab,
we found a row, as no new rows can be added to the result.
*/
if (not_used_in_distinct && found_records != join->found_records)
return NESTED_LOOP_OK;
return NESTED_LOOP_NO_MORE_ROWS;
}
else
join_tab->read_record.file->unlock_row();
@ -11171,19 +11173,42 @@ join_read_key(JOIN_TAB *tab)
}
/*
ref access method implementation: "read_first" function
SYNOPSIS
join_read_always_key()
tab JOIN_TAB of the accessed table
DESCRIPTION
This is "read_fist" function for the "ref" access method.
The functon must leave the index initialized when it returns.
ref_or_null access implementation depends on that.
RETURN
0 - Ok
-1 - Row not found
1 - Error
*/
static int
join_read_always_key(JOIN_TAB *tab)
{
int error;
TABLE *table= tab->table;
/* Initialize the index first */
if (!table->file->inited)
table->file->ha_index_init(tab->ref.key);
/* Perform "Late NULLs Filtering" (see internals manual for explanations) */
for (uint i= 0 ; i < tab->ref.key_parts ; i++)
{
if ((tab->ref.null_rejecting & 1 << i) && tab->ref.items[i]->is_null())
return -1;
}
if (!table->file->inited)
table->file->ha_index_init(tab->ref.key);
}
if (cp_buffer_from_ref(tab->join->thd, &tab->ref))
return -1;
if ((error=table->file->index_read(table->record[0],

View file

@ -458,10 +458,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%pure_parser /* We have threads */
/*
Currently there are 245 shift/reduce conflicts.
Currently there are 240 shift/reduce conflicts.
We should not introduce new conflicts any more.
*/
%expect 245
%expect 240
%token END_OF_INPUT
@ -1111,6 +1111,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <interval_time_st> interval_time_st
%type <interval_time_st> interval_time_stamp
%type <db_type> storage_engines
%type <row_type> row_types
@ -3045,15 +3047,15 @@ column_def:
;
key_def:
key_type opt_ident key_alg '(' key_list ')'
key_type opt_ident key_alg '(' key_list ')' key_alg
{
LEX *lex=Lex;
Key *key= new Key($1, $2, $3, 0, lex->col_list);
Key *key= new Key($1, $2, $7 ? $7 : $3, 0, lex->col_list);
lex->alter_info.key_list.push_back(key);
lex->col_list.empty(); /* Alloced by sql_alloc */
}
| opt_constraint constraint_key_type opt_ident key_alg '(' key_list ')'
| opt_constraint constraint_key_type opt_ident key_alg '(' key_list ')' key_alg
{
LEX *lex=Lex;
const char *key_name= $3 ? $3:$1;
@ -5090,9 +5092,9 @@ simple_expr:
{ $$= new Item_datetime_typecast($3); }
| TIMESTAMP '(' expr ',' expr ')'
{ $$= new Item_func_add_time($3, $5, 1, 0); }
| TIMESTAMP_ADD '(' interval_time_st ',' expr ',' expr ')'
| TIMESTAMP_ADD '(' interval_time_stamp ',' expr ',' expr ')'
{ $$= new Item_date_add_interval($7,$5,$3,0); }
| TIMESTAMP_DIFF '(' interval_time_st ',' expr ',' expr ')'
| TIMESTAMP_DIFF '(' interval_time_stamp ',' expr ',' expr ')'
{ $$= new Item_func_timestamp_diff($5,$7,$3); }
| TRIM '(' expr ')'
{ $$= new Item_func_trim($3); }
@ -6068,21 +6070,40 @@ interval:
| HOUR_MICROSECOND_SYM { $$=INTERVAL_HOUR_MICROSECOND; }
| HOUR_MINUTE_SYM { $$=INTERVAL_HOUR_MINUTE; }
| HOUR_SECOND_SYM { $$=INTERVAL_HOUR_SECOND; }
| MICROSECOND_SYM { $$=INTERVAL_MICROSECOND; }
| MINUTE_MICROSECOND_SYM { $$=INTERVAL_MINUTE_MICROSECOND; }
| MINUTE_SECOND_SYM { $$=INTERVAL_MINUTE_SECOND; }
| SECOND_MICROSECOND_SYM { $$=INTERVAL_SECOND_MICROSECOND; }
| YEAR_MONTH_SYM { $$=INTERVAL_YEAR_MONTH; };
interval_time_stamp:
interval_time_st {}
| FRAC_SECOND_SYM {
$$=INTERVAL_MICROSECOND;
/*
FRAC_SECOND was mistakenly implemented with
a wrong resolution. According to the ODBC
standard it should be nanoseconds, not
microseconds. Changing it to nanoseconds
in MySQL would mean making TIMESTAMPDIFF
and TIMESTAMPADD to return DECIMAL, since
the return value would be too big for BIGINT
Hence we just deprecate the incorrect
implementation without changing its
resolution.
*/
WARN_DEPRECATED("FRAC_SECOND", "MICROSECOND"); // Will be removed in 6.2
}
;
interval_time_st:
DAY_SYM { $$=INTERVAL_DAY; }
| WEEK_SYM { $$=INTERVAL_WEEK; }
| HOUR_SYM { $$=INTERVAL_HOUR; }
| FRAC_SECOND_SYM { $$=INTERVAL_MICROSECOND; }
| MINUTE_SYM { $$=INTERVAL_MINUTE; }
| MONTH_SYM { $$=INTERVAL_MONTH; }
| QUARTER_SYM { $$=INTERVAL_QUARTER; }
| SECOND_SYM { $$=INTERVAL_SECOND; }
| MICROSECOND_SYM { $$=INTERVAL_MICROSECOND; }
| YEAR_SYM { $$=INTERVAL_YEAR; }
;

View file

@ -15214,11 +15214,6 @@ static void test_bug14169()
/*
Test that mysql_insert_id() behaves as documented in our manual
*/
#if 0
Commented out because of Bug#34889.
static void test_mysql_insert_id()
{
my_ulonglong res;
@ -15243,6 +15238,22 @@ static void test_mysql_insert_id()
myquery(rc);
res= mysql_insert_id(mysql);
DIE_UNLESS(res == 0);
/*
Test for bug #34889: mysql_client_test::test_mysql_insert_id test fails
sporadically
*/
rc= mysql_query(mysql, "create table t2 (f1 int not null primary key auto_increment, f2 varchar(255))");
myquery(rc);
rc= mysql_query(mysql, "insert into t2 values (null,'b')");
myquery(rc);
rc= mysql_query(mysql, "insert into t1 select 5,'c'");
myquery(rc);
res= mysql_insert_id(mysql);
DIE_UNLESS(res == 0);
rc= mysql_query(mysql, "drop table t2");
myquery(rc);
rc= mysql_query(mysql, "insert into t1 select null,'d'");
myquery(rc);
res= mysql_insert_id(mysql);
@ -15394,7 +15405,6 @@ static void test_mysql_insert_id()
rc= mysql_query(mysql, "drop table t1,t2");
myquery(rc);
}
#endif
/*
@ -15942,6 +15952,7 @@ static void test_bug27592()
DBUG_VOID_RETURN;
}
#if 0
static void test_bug29948()
{
@ -16017,6 +16028,8 @@ static void test_bug29948()
mysql_close(dbc);
}
#endif
/**
Bug#29306 Truncated data in MS Access with decimal (3,1) columns in a VIEW
*/
@ -16532,7 +16545,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug17667", test_bug17667 },
{ "test_bug19671", test_bug19671 },
{ "test_bug15752", test_bug15752 },
/* { "test_mysql_insert_id", test_mysql_insert_id }, Bug#34889 */
{ "test_mysql_insert_id", test_mysql_insert_id },
{ "test_bug21206", test_bug21206 },
{ "test_bug21726", test_bug21726 },
{ "test_bug15518", test_bug15518 },
@ -16543,7 +16556,7 @@ static struct my_tests_st my_tests[]= {
{ "test_bug28505", test_bug28505 },
{ "test_bug28934", test_bug28934 },
{ "test_bug27592", test_bug27592 },
{ "test_bug29948", test_bug29948 },
/* { "test_bug29948", test_bug29948 }, Bug#35103 */
{ "test_bug29306", test_bug29306 },
{ "test_bug31669", test_bug31669 },
{ "test_bug32265", test_bug32265 },