fix crash at using mysqldump

This commit is contained in:
Kentoku SHIBA 2014-03-25 04:35:56 +09:00
parent f2a5353966
commit 20e144a667

View file

@ -5673,6 +5673,12 @@ int spider_close_connection(
SPIDER_CONN *conn;
SPIDER_TRX *trx;
ha_spider tmp_spider;
SPIDER_SHARE tmp_share;
char *tmp_connect_info[SPIDER_TMP_SHARE_CHAR_PTR_COUNT];
uint tmp_connect_info_length[SPIDER_TMP_SHARE_UINT_COUNT];
long tmp_long[SPIDER_TMP_SHARE_LONG_COUNT];
longlong tmp_longlong[SPIDER_TMP_SHARE_LONGLONG_COUNT];
spider_db_handler *dbton_handler[SPIDER_DBTON_SIZE];
char buf[MAX_FIELD_WIDTH];
spider_string tmp_str(buf, MAX_FIELD_WIDTH, &my_charset_bin);
DBUG_ENTER("spider_close_connection");
@ -5680,13 +5686,28 @@ int spider_close_connection(
if (!(trx = (SPIDER_TRX*) *thd_ha_data(thd, spider_hton_ptr)))
DBUG_RETURN(0); /* transaction is not started */
memset(&tmp_share, 0, sizeof(SPIDER_SHARE));
memset(&tmp_connect_info, 0,
sizeof(char *) * SPIDER_TMP_SHARE_CHAR_PTR_COUNT);
memset(tmp_connect_info_length, 0,
sizeof(uint) * SPIDER_TMP_SHARE_UINT_COUNT);
memset(tmp_long, 0, sizeof(long) * SPIDER_TMP_SHARE_LONG_COUNT);
memset(tmp_longlong, 0, sizeof(longlong) * SPIDER_TMP_SHARE_LONGLONG_COUNT);
spider_set_tmp_share_pointer(&tmp_share, (char **) &tmp_connect_info,
tmp_connect_info_length, tmp_long, tmp_longlong);
tmp_share.link_count = 0;
tmp_spider.conns = &conn;
tmp_spider.need_mons = &need_mon;
tmp_spider.trx = trx;
tmp_spider.result_list.sqls = &tmp_str;
tmp_spider.share = &tmp_share;
tmp_spider.dbton_handler = dbton_handler;
memset(dbton_handler, 0, sizeof(spider_db_handler *) * SPIDER_DBTON_SIZE);
while ((conn = (SPIDER_CONN*) my_hash_element(&trx->trx_conn_hash,
roop_count)))
{
bool error = FALSE;
tmp_share.access_charset = conn->access_charset;
SPIDER_BACKUP_DASTATUS;
DBUG_PRINT("info",("spider conn->table_lock=%d", conn->table_lock));
if (conn->table_lock > 0)
@ -5695,13 +5716,32 @@ int spider_close_connection(
conn->disable_reconnect = FALSE;
if (conn->table_lock != 2)
{
spider_db_unlock_tables(&tmp_spider, 0);
if (!tmp_spider.dbton_handler[conn->dbton_id])
{
if (!(tmp_spider.dbton_handler[conn->dbton_id] =
spider_dbton[conn->dbton_id].create_db_handler(&tmp_spider,
NULL)))
{
error = TRUE;
}
if (!error && tmp_spider.dbton_handler[conn->dbton_id]->init())
{
error = TRUE;
}
}
if (!error)
spider_db_unlock_tables(&tmp_spider, 0);
}
conn->table_lock = 0;
}
roop_count++;
SPIDER_CONN_RESTORE_DASTATUS;
}
for (roop_count = 0; roop_count < SPIDER_DBTON_SIZE; ++roop_count)
{
if (tmp_spider.dbton_handler[roop_count])
delete tmp_spider.dbton_handler[roop_count];
}
spider_rollback(spider_hton_ptr, thd, TRUE);
spider_free_trx(trx, TRUE);