I have a MySql database with nine tables within it. I need to dynamically upload to six of them from an asynchronous job within C#. However, to speed upload, four of them use
The original question asks:
is there any way in the C# connector to allow theTo this end, it seems there is not. Just slapping two transactions together did not work either, as it does not support serialization (as I thought it wouldn't). However, the alternative question asks:
MySqlBulkLoaderto be associated with a
if there is any way to automatically rollback changes made by previousAnd again, it seems there is not an easy way to rollback the changes. Of course, I could check the tables states before and after, deleting the entries that were not present before; but, this solution is not optimal. However, a solution may present itself in the form of a question. The answer to the original question postulated that there was no way to associate a separate transaction with a
MySqlBulkLoader; yet did not specify that we could make one on our own (a.k.a., extend the
MySqlBulkLoaderclass to include a
Transactioninstance parameter). This would seem to be the solution to the problem, as well as the solution to the question Werner Wolf asked.
However, this was not the solution at all. Since the
MySqlBulkLoader is a simple wrapper for the
LOAD DATA INFILE syntax of SQL, it acts just as the SQL query would. And from the MySQL Reference Manual, we receive our answer:
The statements listed in this section (and any synonyms for them) implicitly end any transaction active in the current session, as if you had done a COMMIT before executing the statement.A statement lower in the section of the webpage is
LOAD DATA INFILE. This is the true answer to our question: it is impossible to associate a
MySqlTransaction, at least to the effect that it would work the way we intend it to. Yet, as stated above, a solution to the problem may be to check the indices of the primary key's of each table, lock the table, save their position, and do a manual "rollback" after an upload has failed.