slave.c
/* Reports SLAVE STATUS to a structure specified */
Reports SLAVE STATUS to a structure specified
Reports SLAVE STATUS to a structure specified
void slave_status(MYSQL * slave, SLAVE_STATUS * st)
{
    st->io_running = 0;
    st->sql_running = 0;
    st->lag = 0;
    MYSQL_RES *res = slave_query(slave, "SHOW SLAVE STATUS", 0);
    if (!res)
        return;
    MYSQL_ROW row = mysql_fetch_row(res);
    if (row) {
        if (row[10] && !strcmp(row[10], "Yes"))
            st->io_running = 1;
        if (row[11] && !strcmp(row[11], "Yes"))
            st->sql_running = 1;
        if (row[32]) {
            st->lag = atoi(row[32]);
            if (st->lag < 0)
                st->lag = 0;
        } else {
            st->lag = -1;
        }
    }
    mysql_free_result(res);
}
void slave_status ( MYSQL * slave , SLAVE_STATUS * st ) { st -> io_running = 0 ; st -> sql_running = 0 ; st -> lag = 0 ; MYSQL_RES * res = slave_query ( slave , " " , 0 ) ; if ( ! res ) return ; MYSQL_ROW row = mysql_fetch_row ( res ) ; if ( row ) { if ( row [ 10 ] && ! strcmp ( row [ 10 ] , " " ) ) st -> io_running = 1 ; if ( row [ 11 ] && ! strcmp ( row [ 11 ] , " " ) ) st -> sql_running = 1 ; if ( row [ 32 ] ) { st -> lag = atoi ( row [ 32 ] ) ; if ( st -> lag < 0 ) st -> lag = 0 ; } else { st -> lag = -1 ; } } mysql_free_result ( res ) ; }
Reports SLAVE STATUS to a structure specified
Reports SLAVE STATUS to a structure specified
/* Unknown lag may be lag too, if I/O thread is dead */