Hello Everyone,
I have mysql++ 3.1.0 and MySQL 5.1.56-community (Server/Client) installed
I have a multi-thread application, which each thread has its own connection to the DB, my problem is the followings
When the function in the application tried to do the queries on the same table with the sequence, like Lock/Delete/Insert/Unlock, then my application randomly got segfault, I found out the queries sequence caused parameters in function caller to become invalid (stack overflow alike), I passed the a relevant parameter as reference to the callee function, and print out contents of the parameters before and after the queries sequence, the content integrity is fine before the sequence and the content of the parameters become rubbish after the query sequence. I am wondering if any of you have the same problem or know how I can fix, much appreciated.
I put the pseudo-code below. (I locked/unlock twice between query, it does not make any different if I call lock/unlock once)
void function1(struct SOMEDATASTRUCT &a) {
print a; // OK
LOCK TABLES TABLE1 WRITE;
DELETE FROM TABLE1 WHERE ...;
UNLOCK TABLES;
LOCK TABLES TABLE1 WRITE;
INSERT INTO TABLE1 ...
UNLOCK TABLES
print a; //Rubbish :-(
}
Best Regards!
Hai
I have mysql++ 3.1.0 and MySQL 5.1.56-community (Server/Client) installed
I have a multi-thread application, which each thread has its own connection to the DB, my problem is the followings
When the function in the application tried to do the queries on the same table with the sequence, like Lock/Delete/Insert/Unlock, then my application randomly got segfault, I found out the queries sequence caused parameters in function caller to become invalid (stack overflow alike), I passed the a relevant parameter as reference to the callee function, and print out contents of the parameters before and after the queries sequence, the content integrity is fine before the sequence and the content of the parameters become rubbish after the query sequence. I am wondering if any of you have the same problem or know how I can fix, much appreciated.
I put the pseudo-code below. (I locked/unlock twice between query, it does not make any different if I call lock/unlock once)
void function1(struct SOMEDATASTRUCT &a) {
print a; // OK
LOCK TABLES TABLE1 WRITE;
DELETE FROM TABLE1 WHERE ...;
UNLOCK TABLES;
LOCK TABLES TABLE1 WRITE;
INSERT INTO TABLE1 ...
UNLOCK TABLES
print a; //Rubbish :-(
}
Best Regards!
Hai