List:General Discussion« Previous MessageNext Message »
From:Miguel Cardenas Date:September 22 2005 4:09am
Subject:Re: mysql_free_result() & 2 different connections
View as plain text  
> 4.1.4 is beta version, isn't it ? I'll suggest you try the latest
> binary for 4.1 available for your setup.

Oooooops, sorry, type mismatch error... I mean 4.1.14, the most recent

> > I suspect that the current version of MySQL frees the resources
> > automatically,
> no, it does not :-)

I thought that, 'cos my doubt on it I have insisted to findout more

> again, showing _real_ code would help, or a strip-down code that
> crashes. The MySQL api does not free ressources automatically, so if
> you have the crash on two different system, I would think the bug
> comes from your code.

Well, in fact you are right... I took a look again to the mysql_store_result() 
and mysql_use_result() and that lighted my brain!

It was a logic error... inside the while I was making a free_result() every 
loop that made a fetch_row(), and not once per query, that was the first 
thing... as you said in the last message, I did not check for NULL return to 
perform the free() and because of that was the random crash (sometimes NULL, 
sometimes not)...

The problem was not mysql nor what I was thinking, but your last mail made me 
to discover the real problem :D

> nop, you MYSQL_RES, and it's value. did you set to NULL after freeing
> it ? that would help.

well, I had a member function

void MYCLASS::FreeResult (void) {
   mysql_free_result(sql_result);
}

and now modified it this way

void MYCLASS::FreeResult (void) {
   if (sql_result) {
      mysql_free_result(sql_result);
      sql_result = NULL;
   }
}

> again, I doubt it's a bug in the api, I use various 4.0.x, 4.1.x daily

Well, as I said, it was a double logic error, I should not anymore copy/paste 
from other programs trusting that they do what I remember they do, it will be 
better to start always from zero the code, even for test only purposes...

Thanks for your patience and help during this time... your ideas were very 
useful...

Regards

Thread
mysql_free_result() & 2 different connectionsMiguel Cardenas17 Sep
  • Re: mysql_free_result() & 2 different connectionsPooly18 Sep
    • mysql_free_result() CRASHESMiguel Cardenas18 Sep
    • Re: mysql_free_result() & 2 different connectionsMiguel Cardenas20 Sep
      • Re: mysql_free_result() & 2 different connectionsPooly20 Sep
        • Re: mysql_free_result() & 2 different connectionsMiguel Cardenas20 Sep
          • Re: mysql_free_result() & 2 different connectionsPooly20 Sep
            • Re: mysql_free_result() & 2 different connectionsMiguel Cardenas21 Sep
              • Re: mysql_free_result() & 2 different connectionsPooly21 Sep
                • Re: mysql_free_result() & 2 different connectionsMiguel Cardenas22 Sep