What about lost connection during executing a query in mysql?

Suppose this situation:
I have an insert query which has an auto-increment key
“Insert into xxx Values(0, 1)”,
what will happen if I call mysql_query(&sql, szQuery), but the connection to sql server is
lost, since physic network error.
I have this question since my project has a wrapper with sql, and want to do auto retry
if query is failed since net error, it will happen in actual enviroment every day which
called net flash disconnect and reconnect.
Some time, client will not get the query result, but the server has finished the insert
query, how can I sync the state between client and server in this case?
Thanks a lot for answering my question!