Corrupted mysql table, cause crash in mysql.h (c++)
- by Francesco
i've created a very simple mysql class in c+, but when happen that mysql crash , indexes of tables become corrupted, and all my c++ programs crash too because seems that are unable to recognize corrupted table and allowing me to handle the issue ..
Q_RES = mysql_real_query(MY_mysql, tmp_query.c_str(), (unsigned int) tmp_query.size());
if (Q_RES != 0) {
if (Q_RES == CR_COMMANDS_OUT_OF_SYNC) cout << "errorquery : CR_COMMANDS_OUT_OF_SYNC " << endl;
if (Q_RES == CR_SERVER_GONE_ERROR) cout << "errorquery : CR_SERVER_GONE_ERROR " << endl;
if (Q_RES == CR_SERVER_LOST) cout << "errorquery : CR_SERVER_LOST " << endl;
LAST_ERROR = mysql_error(MY_mysql);
if (n_retrycount < n_retry_limit) { // RETRY!
n_retrycount++;
sleep(1);
cout << "SLEEP - query retry! " << endl;
ping();
return select_sql(tmp_query);
}
return false;
}
MY_result = mysql_store_result(MY_mysql);
B_stored_results = true;
cout << "b8" << endl;
LAST_affected_rows = (mysql_num_rows(MY_result) + 1); // coult return -1
cout << "b8-1" << endl;
the program terminate with a "segmentation fault" after doing the "b8" and before the "b8-1"
, Q_RES have no issue even if the table is corrupted.. i would like to know if there is a way to recognize that the table have problems and so then i can run a mysql repair or mysql check ..
thanks,
Francesco