Originally posted by: singh
No (it should not). Do you have a sample program that could demonstrate this problem? Is this a multi-threaded program by any chance? Also, what compiler/platform are you using?
g++ 3.3.1 on Linux/X86
It is a mutithreaded program, and no I don't have a simple example to demonstrate it.
Basically, this thread reads a queue of objects (with appropriate locks around it) that need to be pushed into the database, builds the insert query, and runs it.
The object queue can stack up pretty good sometimes, and if the insert query is to big, the DB server has fits. So there's a loop in here that builds queries for 100 objects at a time. I use and ostringstream object to build them.
On rare occasions, when I go to run this query at the end of this loop over 100 objects, the ostringstream object (qstr) is empty (qstr.str.size() = 0), despite the fact that I know it went through the loop that builds the queries 100 times, and that it had some length before it started the loop - I push the beginning of the query - "INSERT INTO sieve_results VALUES" before the loop to actually add the data.
When I run this query it generally has a size on the order of 70,000
After each query, I reset the ostringstream object with
qstr.seekp(0);
qstr.str("");
I have a run going now that shows the size of the ostringstream object during the course of that 100-long loop to see what's happening inside. But as I said, it's a relatively rare occurence, so it may take awhile to find a case.