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

Function log_loaded_block

phx_percona/percona/sql/binlog.cc:2341–2381  ·  view source on GitHub ↗

Load data's io cache specific hook to be executed before a chunk of data is being read into the cache's buffer The fuction instantianates and writes into the binlog replication events along LOAD DATA processing. @param file pointer to io-cache @retval 0 success @retval 1 failure */

Source from the content-addressed store, hash-verified

2339 @retval 1 failure
2340*/
2341int log_loaded_block(IO_CACHE* file)
2342{
2343 DBUG_ENTER("log_loaded_block");
2344 LOAD_FILE_INFO *lf_info;
2345 uint block_len;
2346 /* buffer contains position where we started last read */
2347 uchar* buffer= (uchar*) my_b_get_buffer_start(file);
2348 uint max_event_size= current_thd->variables.max_allowed_packet;
2349 lf_info= (LOAD_FILE_INFO*) file->arg;
2350 if (lf_info->thd->is_current_stmt_binlog_format_row())
2351 DBUG_RETURN(0);
2352 if (lf_info->last_pos_in_file != HA_POS_ERROR &&
2353 lf_info->last_pos_in_file >= my_b_get_pos_in_file(file))
2354 DBUG_RETURN(0);
2355
2356 for (block_len= (uint) (my_b_get_bytes_in_buffer(file)); block_len > 0;
2357 buffer += min(block_len, max_event_size),
2358 block_len -= min(block_len, max_event_size))
2359 {
2360 lf_info->last_pos_in_file= my_b_get_pos_in_file(file);
2361 if (lf_info->wrote_create_file)
2362 {
2363 Append_block_log_event a(lf_info->thd, lf_info->thd->db, buffer,
2364 min(block_len, max_event_size),
2365 lf_info->log_delayed);
2366 if (mysql_bin_log.write_event(&a))
2367 DBUG_RETURN(1);
2368 }
2369 else
2370 {
2371 Begin_load_query_log_event b(lf_info->thd, lf_info->thd->db,
2372 buffer,
2373 min(block_len, max_event_size),
2374 lf_info->log_delayed);
2375 if (mysql_bin_log.write_event(&b))
2376 DBUG_RETURN(1);
2377 lf_info->wrote_create_file= 1;
2378 }
2379 }
2380 DBUG_RETURN(0);
2381}
2382
2383/* Helper function for SHOW BINLOG/RELAYLOG EVENTS */
2384bool show_binlog_events(THD *thd, MYSQL_BIN_LOG *binary_log)

Callers

nothing calls this directly

Calls 1

write_eventMethod · 0.80

Tested by

no test coverage detected