Bug #1041 mysql_free_result() causes an warning message if result is empty
Submitted: 13 Aug 2003 7:40 Modified: 9 Apr 2008 6:01
Reporter: Alexander Shikoff Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0.14 OS:FreeBSD (FreeBSD 4.8-STABLE)
Assigned to: CPU Architecture:Any

[13 Aug 2003 7:40] Alexander Shikoff
Description:
Is it a bug?

SELECT returns an empty result if database is empty.
In this case function mysql_store_result() returns
non-NULL value, but the calling of function mysql_free_result causes next message:

trafusers in free(): warning: page is already free

I was surprised, and tried next construction:
(fpc was used, FreeBSD 4.8-STABLE)
...
 if NumOfRows>0 then 
   mysql_free_result(QUERY_RES) 
 else Dispose(QUERY_RES);
...

It works. Can you fix this?

How to repeat:
Example in fpc 1.0.6

Uses mysql;
Var QUERY_RES: PMYSQL_RES;

Begin
....
{Here we assume that current table of database is empty. Then result of
executing 'SELECT' query is empty.}

 QUERY_RES:=mysql_store_result(mysql_sock);

 if QUERY_RES=nil then 
  {here is an error};
 else
 Begin
  NumOfRows := mysql_num_rows(QUERY_RES); {NumOfRows now is eq. to 0}
  mysql_free_result(QUERY_RES); {this causes an warning}
 End;

....

End.
[13 Aug 2003 10:40] Indrek Siitan
I tried repeating this in C, but wasn't able - the problem is most probably
with the FPC MySQL API, which is not developer by MySQL AB, but a guy
named Michael Van Canneyt, so we cannot really support it.
[9 Apr 2008 6:01] Susanne Ebrecht
Many thanks for writing a bug report.

I'll close this now because it's not in newer MySQL versions by using newer FreeBSD versions.