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

Method find_next_log

phx_percona/percona/sql/binlog.cc:3850–3889  ·  view source on GitHub ↗

Find the position in the log-index-file for the given log name. @param[out] linfo The filename will be stored here, along with the byte offset of the next filename in the index file. @param need_lock_index If true, LOCK_index will be acquired; otherwise it should already be held by the caller. @note - Before calling this function, one has to call find_log_pos() to set up 'linf

Source from the content-addressed store, hash-verified

3848 @retval LOG_INFO_IO Got IO error while reading file
3849*/
3850int MYSQL_BIN_LOG::find_next_log(LOG_INFO* linfo, bool need_lock_index)
3851{
3852 int error= 0;
3853 uint length;
3854 char fname[FN_REFLEN];
3855 char *full_fname= linfo->log_file_name;
3856
3857 if (need_lock_index)
3858 mysql_mutex_lock(&LOCK_index);
3859 else
3860 mysql_mutex_assert_owner(&LOCK_index);
3861
3862 /* As the file is flushed, we can't get an error here */
3863 my_b_seek(&index_file, linfo->index_file_offset);
3864
3865 linfo->index_file_start_offset= linfo->index_file_offset;
3866 if ((length=my_b_gets(&index_file, fname, FN_REFLEN)) <= 1)
3867 {
3868 error = !index_file.error ? LOG_INFO_EOF : LOG_INFO_IO;
3869 goto err;
3870 }
3871
3872 if (fname[0] != 0)
3873 {
3874 if(normalize_binlog_name(full_fname, fname, is_relay_log))
3875 {
3876 error= LOG_INFO_EOF;
3877 goto err;
3878 }
3879 length= strlen(full_fname);
3880 }
3881
3882 full_fname[length-1]= 0; // kill \n
3883 linfo->index_file_offset= my_b_tell(&index_file);
3884
3885err:
3886 if (need_lock_index)
3887 mysql_mutex_unlock(&LOCK_index);
3888 return error;
3889}
3890
3891
3892/**

Callers

nothing calls this directly

Calls 1

normalize_binlog_nameFunction · 0.85

Tested by

no test coverage detected