Corrupted mysql table, cause crash in mysql.h (c++) -


I have created a very simple mysql class in C ++, but when it happens that mysql crash, the sequence of tables corrupts And all my C ++ program crash even because it seems that the contaminated table is unable to recognize and I am allowed to handle the problem ..

  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 & lt; & Lt; "Error type: CR_COMMANDS_OUT_OF_SYNC" & lt; & Lt; Endl; If (Q_RES == CR_SERVER_GONE_ERROR) cout & lt; & Lt; "Error type: CR_SERVER_GONE_ERROR" & lt; & Lt; Endl; If (Q_RES == CR_SERVER_LOST) cout & lt; & Lt; "Error type: CR_SERVER_LOST" & lt; & Lt; Endl; LAST_ERROR = mysql_error (MY_mysql); If (n_retrycount & lt; n_retry_limit) {// Retry! N_retrycount ++; Sleep (1); Cout & lt; & Lt; "Sleep - Retry the query!" & Lt; & Lt; Endl; Ping (); Return select_sql (tmp_query); }     return false; } MY_result = mysql_store_result (MY_mysql); B_stored_results = true; Cout & lt; & Lt; "B8" & lt; & Lt; Endl; LAST_affected_rows = (mysql_num_rows (MY_result) + 1); // colt return -1 COAT & lt; & Lt; "B8-1" & lt; & Lt; Endl;  

The program ends with "section fault" before "b8" and "b8-1", Q_RES is not a problem, even if the table is corrupted .. I would like To know if the table has a problem and there is a way to identify it, then I can run a MySQL repair or mysql check.

Thanks, Francesco

You have to check the return value of mysql_store_result () - it can be null.

mysql_store_result () returns a blank pointer if the statement does not return the result set (for example, if it was an INSERT statement).

mysql_store_result () also returns the tap pointer if the result set failed to read.

This is probably not a problem with the database, it can check whether mysql_error () returns a nonempty string or not, can check whether or not myzql_errno () nonzero Returns, or mysql_field_count () returns zero. Is getting corrupted.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -