Anybody know C well enough to tell me what this does? if (strcmp (row[slave_io_field], "Yes") != 0 || strcmp (row[slave_sql_field], "Yes") != 0) { mysql_free_result (res); mysql_close (&mysql); die (STATE_CRITICAL, "%s\n", slaveresult); } It's clearly checking for "Yes", but if it finds "Yes!" what happens? I could change things to be the string I'm finding, but that's not really ideal.
@dw it looks as though it's asking whether the database is connected to the master replica, and if not, frees the memory for the current database query (mysql_free_result
), closes the database connection (mysql_close
) and halts with a critical error (die
). The replica status is an educated guess based on the variable names and https://dev.mysql.com/doc/refman/5.7/en/show-slave-status.html.
@dw the "%s\n"
is a format string. The die
function takes the variable slaveresult
, and stuffs it in place of the %s
- basically adding a new line after the error message. Is that what you're asking about?
I wasn't sure if it was like grep, so it picks up every instance of Yes or if it was matching the entire string. Me and another sysadmin looked at it and were like "well, the behavior certainly makes it look like it's not grep" but we weren't sure. I went to file a bug but someone beat me to it by a five hours.