Doug Whitfield

Doug Whitfield at

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.

Ben Sturmfels at 2017-12-05T21:31:06Z

that's correct. I really meant the regex piece. The ultimate issue, it turns out, is the string has changed in MariaDB 10.2. Thanks for the response!

Doug Whitfield at 2017-12-05T22:01:42Z

@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?

Ben Sturmfels at 2017-12-05T23:13:00Z

No. I think it might have been more clear if the original formatting had come through from GNU Social, but it's all good info regardless. :)

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.

Doug Whitfield at 2017-12-06T12:22:42Z