Skip to content

Commit

Permalink
MDEV-12951 Server crash [mysqld got exception 0xc0000005]
Browse files Browse the repository at this point in the history
Same as MDEV-12725 but for federated (not X).
Set and reset mysql.net->thd appropriately.
  • Loading branch information
vuvova committed Sep 18, 2017
1 parent e78712d commit e6ce97a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
11 changes: 11 additions & 0 deletions mysql-test/suite/federated/net_thd_crash-12951.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set global query_cache_size= 16*1024*1024;
set global query_cache_type= 1;
create table t1 (i int) engine=innodb;
create table t2 (i int) engine=federated
CONNECTION="mysql://root@localhost:MASTER_MYPORT/test/t1";
select * from t2;
i
drop table t2;
drop table t1;
set global query_cache_type= default;
set global query_cache_size= default;
23 changes: 23 additions & 0 deletions mysql-test/suite/federated/net_thd_crash-12951.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# MDEV-12951 Server crash [mysqld got exception 0xc0000005]
#

--source include/have_innodb.inc

set global query_cache_size= 16*1024*1024;
set global query_cache_type= 1;

create table t1 (i int) engine=innodb;
--replace_result $MASTER_MYPORT MASTER_MYPORT
eval create table t2 (i int) engine=federated
CONNECTION="mysql://root@localhost:$MASTER_MYPORT/test/t1";

select * from t2;

source include/restart_mysqld.inc;

drop table t2;
drop table t1;

set global query_cache_type= default;
set global query_cache_size= default;
9 changes: 7 additions & 2 deletions storage/federated/ha_federated.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2980,6 +2980,9 @@ int ha_federated::reset(void)
}
reset_dynamic(&results);

if (mysql)
mysql->net.thd= NULL;

return 0;
}

Expand Down Expand Up @@ -3200,12 +3203,14 @@ int ha_federated::real_query(const char *query, size_t length)
int rc= 0;
DBUG_ENTER("ha_federated::real_query");

if (!mysql && (rc= real_connect()))
if (!query || !length)
goto end;

if (!query || !length)
if (!mysql && (rc= real_connect()))
goto end;

mysql->net.thd= table->in_use;

rc= mysql_real_query(mysql, query, (uint) length);

end:
Expand Down

0 comments on commit e6ce97a

Please sign in to comment.