From 51cdaa9995371f3435cfe284f1bff8c35de1dff0 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sun, 27 Dec 2009 23:32:52 +0000 Subject: [PATCH] Some queries do not fail with mysql_real_query(), but later, after calling mysql_store_result(). Pass them to the application. Fixes issue #1563. --- source/mysql_connection.pas | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/mysql_connection.pas b/source/mysql_connection.pas index 683e376f..14f5732d 100644 --- a/source/mysql_connection.pas +++ b/source/mysql_connection.pas @@ -377,6 +377,7 @@ begin FLastQueryDuration := GetTickCount - TimerStart; FLastQueryNetworkDuration := 0; if querystatus <> 0 then begin + // Most errors will show up here, some others slightly later, after mysql_store_result() Log(lcError, GetLastError); raise Exception.Create(GetLastError); end else begin @@ -386,6 +387,12 @@ begin TimerStart := GetTickCount; Result := mysql_store_result(FHandle); FLastQueryNetworkDuration := GetTickCount - TimerStart; + if (Result = nil) and (FRowsAffected = -1) then begin + // Indicates a late error, e.g. triggered by mysql_store_result(), after selecting a stored + // function with invalid SQL body. Also SHOW TABLE STATUS on older servers. + Log(lcError, GetLastError); + raise Exception.Create(GetLastError); + end; if Result <> nil then begin FRowsFound := mysql_num_rows(Result); FRowsAffected := 0;