slave.c
/* Opens relay log based on SLAVE STATUS and @@datadir */
Opens relay log based on SLAVE STATUS and @@datadir
Opens relay log based on SLAVE STATUS and @@datadir
BINLOG *relaylog_from_slave(MYSQL * slave, BINLOG * relaylog)
{
    MYSQL_RES *res = slave_query(slave, "SHOW SLAVE STATUS", 0);
    if (!res)
        return NULL;
    MYSQL_ROW row = mysql_fetch_row(res);
    BINLOG *bl;
    if (!row || !row[7] || !row[7][0]) {
        mysql_free_result(res);
        return NULL;
    }
    char *filename = row[7];
    guint32 position = atoi(row[8]);
    if (row[7][0] != '/') {
        filename = g_strdup_printf("%s/%s", log_directory, filename);
    } else {
        filename = g_strdup(filename);
    }
    mysql_free_result(res);
    if (!relaylog)
        bl = open_binlog(filename);
    else if (strcmp(filename, relaylog->filename)) {
        free_binlog(relaylog);
        bl = open_binlog(filename);
    } else {
        bl = relaylog;
        g_free(filename);
    }
    if (bl)
        seek_binlog(bl, position);
    return bl;
}
BINLOG * relaylog_from_slave ( MYSQL * slave , BINLOG * relaylog ) { MYSQL_RES * res = slave_query ( slave , " " , 0 ) ; if ( ! res ) return NULL ; MYSQL_ROW row = mysql_fetch_row ( res ) ; BINLOG * bl ; if ( ! row || ! row [ 7 ] || ! row [ 7 ] [ 0 ] ) { mysql_free_result ( res ) ; return NULL ; } char * filename = row [ 7 ] ; guint32 position = atoi ( row [ 8 ] ) ; if ( row [ 7 ] [ 0 ] != ' ' ) { filename = g_strdup_printf ( " " , log_directory , filename ) ; } else { filename = g_strdup ( filename ) ; } mysql_free_result ( res ) ; if ( ! relaylog ) bl = open_binlog ( filename ) ; else if ( strcmp ( filename , relaylog -> filename ) ) { free_binlog ( relaylog ) ; bl = open_binlog ( filename ) ; } else { bl = relaylog ; g_free ( filename ) ; } if ( bl ) seek_binlog ( bl , position ) ; return bl ; }
Opens relay log based on SLAVE STATUS and @@datadir
Opens relay log based on SLAVE STATUS and @@datadir
/* Does not have valid relay log */ /* Not an absolute filename, need to construct some */ // No relay log known/passed // Different filename, must reopen // Same file, we'll need just to seek