Skip to content
Permalink
Browse files
Merge 10.0 into 10.1
  • Loading branch information
dr-m committed May 23, 2017
2 parents 70df2be + 725e47b commit b61700c
Show file tree
Hide file tree
Showing 77 changed files with 488 additions and 184 deletions.
@@ -3059,7 +3059,6 @@ static int com_server_help(String *buffer __attribute__((unused)),
{
unsigned int num_fields= mysql_num_fields(result);
my_ulonglong num_rows= mysql_num_rows(result);
mysql_fetch_fields(result);
if (num_fields==3 && num_rows==1)
{
if (!(cur= mysql_fetch_row(result)))
@@ -1130,15 +1130,15 @@ static int check_version_match(void)

int main(int argc, char **argv)
{
char self_name[FN_REFLEN];
char self_name[FN_REFLEN + 1];

MY_INIT(argv[0]);

#if __WIN__
if (GetModuleFileName(NULL, self_name, FN_REFLEN) == 0)
#endif
{
strncpy(self_name, argv[0], FN_REFLEN);
strmake_buf(self_name, argv[0]);
}

if (init_dynamic_string(&ds_args, "", 512, 256) ||
@@ -614,6 +614,7 @@ static my_bool sql_connect(MYSQL *mysql, uint wait)

static int execute_commands(MYSQL *mysql,int argc, char **argv)
{
int ret = 0;
const char *status;
/*
MySQL documentation relies on the fact that mysqladmin will
@@ -1104,7 +1105,8 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
if (strcmp(typed_password, verified) != 0)
{
my_printf_error(0,"Passwords don't match",MYF(ME_BELL));
return -1;
ret = -1;
goto password_done;
}
}
else
@@ -1131,7 +1133,8 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
{
my_printf_error(0, "Could not determine old_passwords setting from server; error: '%s'",
error_flags, mysql_error(mysql));
return -1;
ret = -1;
goto password_done;
}
else
{
@@ -1142,7 +1145,8 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
"Could not get old_passwords setting from "
"server; error: '%s'",
error_flags, mysql_error(mysql));
return -1;
ret = -1;
goto password_done;
}
if (!mysql_num_rows(res))
old= 1;
@@ -1167,15 +1171,15 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
{
my_printf_error(0, "Can't turn off logging; error: '%s'",
error_flags, mysql_error(mysql));
return -1;
ret = -1;
}
else
if (mysql_query(mysql,buff))
{
if (mysql_errno(mysql)!=1290)
{
my_printf_error(0,"unable to change password; error: '%s'",
error_flags, mysql_error(mysql));
return -1;
}
else
{
@@ -1189,9 +1193,10 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
" --skip-grant-tables).\n"
"Use: \"mysqladmin flush-privileges password '*'\""
" instead", error_flags);
return -1;
}
ret = -1;
}
password_done:
/* free up memory from prompted password */
if (typed_password != argv[1])
{
@@ -1293,7 +1298,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
return 1;
}
}
return 0;
return ret;
}

/**
@@ -2252,7 +2252,7 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
int2store(buf + BIN_LOG_HEADER_SIZE, binlog_flags);

size_t tlen = strlen(logname);
if (tlen > UINT_MAX)
if (tlen > sizeof(buf) - 10)
{
error("Log name too long.");
DBUG_RETURN(ERROR_STOP);
@@ -2845,6 +2845,8 @@ static uint get_table_structure(char *table, char *db, char *table_type,

my_free(scv_buff);

if (path)
my_fclose(sql_file, MYF(MY_WME));
DBUG_RETURN(0);
}
else
@@ -5927,8 +5929,7 @@ static my_bool get_view_structure(char *table, char* db)
dynstr_free(&ds_view);
}

if (switch_character_set_results(mysql, default_charset))
DBUG_RETURN(1);
switch_character_set_results(mysql, default_charset);

/* If a separate .sql file was opened, close it now */
if (sql_file != md_result_file)
@@ -1721,13 +1721,12 @@ void log_msg(const char *fmt, ...)
int cat_file(DYNAMIC_STRING* ds, const char* filename)
{
int fd;
size_t len;
int len;
char buff[16384];

if ((fd= my_open(filename, O_RDONLY, MYF(0))) < 0)
return 1;
while((len= my_read(fd, (uchar*)&buff,
sizeof(buff)-1, MYF(0))) > 0)
while((len= (int)my_read(fd, (uchar*)&buff, sizeof(buff)-1, MYF(0))) > 0)
{
char *p= buff, *start= buff,*end=buff+len;
while (p < end)
@@ -673,21 +673,4 @@
#define __STDC_FORMAT_MACROS
#endif

/*
stat structure (from <sys/stat.h>) is conditionally defined
to have different layout and size depending on the defined macros.
The correct macro is defined in my_config.h, which means it MUST be
included first (or at least before <features.h> - so, practically,
before including any system headers).

Check the include order by looking at __GLIBC__ (defined in <features.h>)

But we cannot force all third-party clients/connectors to include
my_config.h first. So, their crashes are their responsibility,
we enable this check only for MariaDB sources (SAFE_MUTEX check).
*/
#if defined(__GLIBC__) && defined(SAFE_MUTEX)
#error <my_config.h> MUST be included first!
#endif

#endif
@@ -606,22 +606,23 @@ ANALYZE
},
"block-nl-join": {
"table": {
"table_name": "<subquery2>",
"table_name": "t2",
"access_type": "ALL",
"possible_keys": ["distinct_key"],
"r_loops": 1,
"rows": 2,
"r_rows": 2,
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 100
"r_filtered": 0,
"attached_condition": "<in_optimizer>(t2.b,t2.b in (subquery#2))"
},
"buffer_type": "flat",
"buffer_size": "256Kb",
"join_type": "BNL",
"r_filtered": 100,
"materialized": {
"unique": 1,
"r_filtered": null
},
"subqueries": [
{
"query_block": {
"select_id": 2,
"r_loops": 1,
@@ -638,24 +639,7 @@ ANALYZE
}
}
}
},
"block-nl-join": {
"table": {
"table_name": "t2",
"access_type": "ALL",
"r_loops": 1,
"rows": 2,
"r_rows": 2,
"r_total_time_ms": "REPLACED",
"filtered": 100,
"r_filtered": 100
},
"buffer_type": "incremental",
"buffer_size": "256Kb",
"join_type": "BNL",
"attached_condition": "(t2.b = `<subquery2>`.a)",
"r_filtered": 0
}
]
}
}
drop table t1,t2;
@@ -2628,5 +2628,26 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ref idx idx 5 test.t1.a 140 Using index; FirstMatch(t1)
drop view v1;
drop table t1,t2;
#
# Bug mdev-12812: mergeable derived / view with subqueries
# NOT subject to semi-join optimizations
#
CREATE TABLE t1 (c1 varchar(3)) ENGINE=MyISAM;
INSERT INTO t1 VALUES ('foo'),('foo');
CREATE TABLE t2 (c2 varchar(3)) ENGINE=MyISAM;
INSERT INTO t2 VALUES ('bar'),('qux'),('foo');
SELECT STRAIGHT_JOIN *
FROM ( SELECT * FROM t1 WHERE c1 IN ( SELECT c2 FROM t2 ) ) AS sq;
c1
foo
foo
EXPLAIN EXTENDED SELECT STRAIGHT_JOIN *
FROM ( SELECT * FROM t1 WHERE c1 IN ( SELECT c2 FROM t2 ) ) AS sq;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 3 100.00 Using where
Warnings:
Note 1003 select straight_join `test`.`t1`.`c1` AS `c1` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`c1`,<exists>(select `test`.`t2`.`c2` from `test`.`t2` where (<cache>(`test`.`t1`.`c1`) = `test`.`t2`.`c2`)))
DROP TABLE t1, t2;
set optimizer_switch=@exit_optimizer_switch;
set join_cache_level=@exit_join_cache_level;
@@ -3107,4 +3107,58 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 range idx idx 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
drop table t1,t2;
set optimizer_switch= @tmp_mdev12675;
#
# MDEV-12817: subquery NOT subject to semi-join optimizations
# in ON expression of INNER JOIN
#
CREATE TABLE t1 (c1 int) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (c2 int) ENGINE=MyISAM;
INSERT INTO t2 VALUES (3),(4);
CREATE TABLE t3 (c3 int) ENGINE=MyISAM;
INSERT INTO t3 VALUES (5),(6);
CREATE TABLE t4 (c4 int) ENGINE=MyISAM;
INSERT INTO t4 VALUES (7),(8);
SELECT c1
FROM t1
LEFT JOIN
( t2 INNER JOIN t3 ON ( 1 IN ( SELECT c4 FROM t4 ) ) )
ON (c1 = c3);
c1
1
2
EXPLAIN EXTENDED SELECT c1
FROM t1
LEFT JOIN
( t2 INNER JOIN t3 ON ( 1 IN ( SELECT c4 FROM t4 ) ) )
ON (c1 = c3);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00 Using where
2 SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`c1` AS `c1` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t3`.`c3` = `test`.`t1`.`c1`) and <cache>(<in_optimizer>(1,<exists>(select `test`.`t4`.`c4` from `test`.`t4` where (1 = `test`.`t4`.`c4`)))))) where 1
# mdev-12820
SELECT *
FROM t1
LEFT JOIN
( ( SELECT * FROM t2 WHERE c2 IN ( SELECT c3 FROM t3 ) ) AS sq INNER JOIN t4 )
ON (c1 = c2);
c1 c2 c4
1 NULL NULL
2 NULL NULL
EXPLAIN EXTENDED SELECT *
FROM t1
LEFT JOIN
( ( SELECT * FROM t2 WHERE c2 IN ( SELECT c3 FROM t3 ) ) AS sq INNER JOIN t4 )
ON (c1 = c2);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t4`.`c4` AS `c4` from `test`.`t1` left join (`test`.`t2` join `test`.`t4`) on(((`test`.`t2`.`c2` = `test`.`t1`.`c1`) and <in_optimizer>(`test`.`t1`.`c1`,<exists>(select `test`.`t3`.`c3` from `test`.`t3` where (<cache>(`test`.`t2`.`c2`) = `test`.`t3`.`c3`))))) where 1
DROP TABLE t1,t2,t3,t4;
set optimizer_switch=@subselect_sj_tmp;
@@ -3121,6 +3121,60 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 range idx idx 5 NULL 2 Using where; Using index; Using join buffer (flat, BNL join)
drop table t1,t2;
set optimizer_switch= @tmp_mdev12675;
#
# MDEV-12817: subquery NOT subject to semi-join optimizations
# in ON expression of INNER JOIN
#
CREATE TABLE t1 (c1 int) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (c2 int) ENGINE=MyISAM;
INSERT INTO t2 VALUES (3),(4);
CREATE TABLE t3 (c3 int) ENGINE=MyISAM;
INSERT INTO t3 VALUES (5),(6);
CREATE TABLE t4 (c4 int) ENGINE=MyISAM;
INSERT INTO t4 VALUES (7),(8);
SELECT c1
FROM t1
LEFT JOIN
( t2 INNER JOIN t3 ON ( 1 IN ( SELECT c4 FROM t4 ) ) )
ON (c1 = c3);
c1
1
2
EXPLAIN EXTENDED SELECT c1
FROM t1
LEFT JOIN
( t2 INNER JOIN t3 ON ( 1 IN ( SELECT c4 FROM t4 ) ) )
ON (c1 = c3);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
1 PRIMARY t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join)
2 SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`c1` AS `c1` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(((`test`.`t3`.`c3` = `test`.`t1`.`c1`) and <cache>(<in_optimizer>(1,<exists>(select `test`.`t4`.`c4` from `test`.`t4` where (1 = `test`.`t4`.`c4`)))))) where 1
# mdev-12820
SELECT *
FROM t1
LEFT JOIN
( ( SELECT * FROM t2 WHERE c2 IN ( SELECT c3 FROM t3 ) ) AS sq INNER JOIN t4 )
ON (c1 = c2);
c1 c2 c4
1 NULL NULL
2 NULL NULL
EXPLAIN EXTENDED SELECT *
FROM t1
LEFT JOIN
( ( SELECT * FROM t2 WHERE c2 IN ( SELECT c3 FROM t3 ) ) AS sq INNER JOIN t4 )
ON (c1 = c2);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join)
1 PRIMARY t4 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (incremental, BNL join)
3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1003 select `test`.`t1`.`c1` AS `c1`,`test`.`t2`.`c2` AS `c2`,`test`.`t4`.`c4` AS `c4` from `test`.`t1` left join (`test`.`t2` join `test`.`t4`) on(((`test`.`t2`.`c2` = `test`.`t1`.`c1`) and <in_optimizer>(`test`.`t1`.`c1`,<exists>(select `test`.`t3`.`c3` from `test`.`t3` where (<cache>(`test`.`t2`.`c2`) = `test`.`t3`.`c3`))))) where 1
DROP TABLE t1,t2,t3,t4;
set optimizer_switch=@subselect_sj_tmp;
#
# BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off
@@ -0,0 +1,17 @@
include/master-slave.inc
[connection master]
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
call mtr.add_suppression("Slave SQL: The incident LOST_EVENTS occured on the master. .*");
SET GLOBAL max_binlog_cache_size = 4096;
SET GLOBAL binlog_cache_size = 4096;
SET GLOBAL max_binlog_stmt_cache_size = 4096;
SET GLOBAL binlog_stmt_cache_size = 4096;
CREATE TABLE t1(a INT PRIMARY KEY, data VARCHAR(30000)) ENGINE=MYISAM;
ERROR HY000: Writing one row to the row-based binary log failed
include/wait_for_slave_sql_error_and_skip.inc [errno=1590]
SET GLOBAL max_binlog_cache_size= ORIGINAL_VALUE;
SET GLOBAL binlog_cache_size= ORIGINAL_VALUE;
SET GLOBAL max_binlog_stmt_cache_size= ORIGINAL_VALUE;
SET GLOBAL binlog_stmt_cache_size= ORIGINAL_VALUE;
DROP TABLE t1;
include/rpl_end.inc
@@ -0,0 +1 @@
--binlog_checksum=1 --binlog-annotate-row-events=1

0 comments on commit b61700c

Please sign in to comment.