Throw successive result sets from stored procedures away, until we have real support for multi results. Otherwise mysql_ping() crashes on the next query. Fixes issue #1850.

This commit is contained in:
Ansgar Becker
2010-04-12 21:03:13 +00:00
parent 6f9e2a88d2
commit 43e35c8192

View File

@ -492,9 +492,10 @@ end;
}
function TMySQLConnection.Query(SQL: String; DoStoreResult: Boolean=False; LogCategory: TMySQLLogCategory=lcSQL): PMYSQL_RES;
var
querystatus: Integer;
querystatus, i: Integer;
NativeSQL: AnsiString;
TimerStart: Cardinal;
NextResult: PMYSQL_RES;
begin
if not Ping then
Active := True;
@ -530,6 +531,17 @@ begin
Log(lcDebug, IntToStr(RowsFound)+' rows found.');
if not DoStoreResult then
mysql_free_result(Result);
// No support for real multi results yet, throw them away, so mysql_ping() does not crash on the *next* query.
i := 1;
while mysql_next_result(FHandle) = 0 do begin
Inc(i);
Log(lcDebug, 'Storing and freeing result #'+IntToStr(i)+' from multiple result set ...');
NextResult := mysql_store_result(FHandle);
if NextResult <> nil then
mysql_free_result(NextResult);
end;
end else begin
// Query did not return a result
FRowsFound := 0;