Hello list
There is another doubt... I have programmed a C++ object that connects to
MySQL, it has encapsulated its own
MYSQL *mysql
MYSQL_RES *result
...
etc etc
data, so it it possible to have several simultaneous connections to MySQL
performing different jobs, but I have experienced a strange error... Let's
supose (pseudocode) y have the class MY and have 2 instances my1 and my2
MY my1, my2;
both are already connected to the server and both retrieve independently data
by 'real_query' and 'use_result'... but the problem comes when I call
'free_results' for both connections, the program crashes with this message:
*** glibc detected *** double free or corruption (!prev): 0x08053e68 ***
Aborted
The pseudocode I have is this:
-------------------------------------------------------
my1.query + my1.store <--- UNIQUE QUERY (* where ...)
while ( my1.fetch ) {
my2.query + my2.store
if ( my2.fetch ) {
report = my1 + my2 results
} else {
report = my1
}
my2.FreeResult <--- free for every my2.query inside loop
}
my1.FreeResult <--- free for unique my1.query
-------------------------------------------------------
NOTE AGAIN: my1 and my2 are independent connections, have independent
encapsulated handles and variables...
What would happen if I don't free the resources inside the loop, would it
leave unfreed memory resources?
My tables are like this:
TABLE1
----------------------------------
| ID | FIELDX | ... |
----------------------------------
| 0 | x1 | ... |
| 1 | x2 | ... |
| 2 | x3 | ... |
| 3 | x4 | ... |
TABLE2
-------------------------
| ID | FIELDY |
-------------------------
| 0 | y1 |
| 3 | y4 |
if I try a SELECT using condition "WHERE TABLE1.ID=TABLE2.ID" the results will
return only x1-y1 and x4-y4 pairs, and in fact what I need is this the full
pair of data when available, and the data from TABLE1 when there is no pair
in TABLE2
x1-y1
x2
x3
x4-y4
I send a query to connection1---TABLE1 that retrieves all 'x#', and for every
row returned, send a query to connection2---TABLE2 looking for a possible
pair and build a report with both values, and if TABLE2 does not return
nothing then use only value from TABLE1
SO... how should I manage 'mysql_free_results()' when I have multiple
independent connections that make independent queries and free its own
resources allocated? it appears that it affects globally calling this
function, even if it is called in separate connections...
Sorry, I extended too much, maybe is not very clear, but just concentrate on
the question above...
Thanks very much...