MCPcopy Create free account
hub / github.com/Tencent/phxsql / binlog_clone_consistent_snapshot

Function binlog_clone_consistent_snapshot

phx_percona/percona/sql/binlog.cc:1387–1436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1385}
1386
1387static int binlog_clone_consistent_snapshot(handlerton *hton, THD *thd,
1388 THD *from_thd)
1389{
1390 binlog_cache_mngr *from_cache_mngr;
1391 binlog_cache_mngr *cache_mngr;
1392 int err= 0;
1393 char log_file_name[FN_REFLEN];
1394 my_off_t pos;
1395
1396 DBUG_ENTER("binlog_start_consistent_snapshot");
1397
1398 from_cache_mngr= opt_bin_log ?
1399 (binlog_cache_mngr *) thd_get_cache_mngr(from_thd) : NULL;
1400
1401 if (from_cache_mngr == NULL)
1402 {
1403 push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
1404 HA_ERR_UNSUPPORTED,
1405 "WITH CONSISTENT SNAPSHOT FROM SESSION was ignored for "
1406 "binary log, because the specified session does not "
1407 "have a consistent snapshot of binary log "
1408 "coordinates.");
1409 DBUG_RETURN(0);
1410 }
1411
1412 if ((err= thd->binlog_setup_trx_data()))
1413 DBUG_RETURN(err);
1414
1415 cache_mngr= thd_get_cache_mngr(thd);
1416
1417 mysql_mutex_lock(&from_cache_mngr->binlog_info.lock);
1418
1419 pos= from_cache_mngr->binlog_info.pos;
1420 strmake(log_file_name, from_cache_mngr->binlog_info.log_file_name,
1421 sizeof(log_file_name) - 1);
1422
1423 mysql_mutex_unlock(&from_cache_mngr->binlog_info.lock);
1424
1425 mysql_mutex_lock(&cache_mngr->binlog_info.lock);
1426
1427 cache_mngr->binlog_info.pos = pos;
1428 strmake(cache_mngr->binlog_info.log_file_name, log_file_name,
1429 sizeof(cache_mngr->binlog_info.log_file_name) - 1);
1430
1431 mysql_mutex_unlock(&cache_mngr->binlog_info.lock);
1432
1433 trans_register_ha(thd, TRUE, hton);
1434
1435 DBUG_RETURN(err);
1436}
1437
1438/**
1439 This function is called once after each statement.

Callers

nothing calls this directly

Calls 2

thd_get_cache_mngrFunction · 0.85
binlog_setup_trx_dataMethod · 0.80

Tested by

no test coverage detected