Examine query error messages for "(errno: 123)" and add the more meaningful message returned by perror.exe . Adds a static error message list from my local 5.1.22 server. This is especially helpful in the foreign key editor, where any InnoDB error seems to be the more cryptic one by default, while there are lots of possible error causes. See issue #400.

This commit is contained in:
Ansgar Becker
2009-08-23 22:53:52 +00:00
parent b1aaeaaaf4
commit 45eba2139c
2 changed files with 90 additions and 1 deletions

View File

@ -5,7 +5,7 @@ interface
uses
Windows, Messages, Forms, Db, Classes, ZConnection, ZDataSet, StdCtrls, SysUtils,
ZMessages,
HeidiComp;
HeidiComp, SynRegExpr, mysql_structures;
{$IFDEF EXAMPLE_APP}
const
@ -311,10 +311,24 @@ begin
end;
procedure TMysqlQueryThread.SetState(AResult: Integer; AComment: String);
var
rx: TRegExpr;
msg: String;
begin
debug(Format('qry: Setting status %d with comment %s', [AResult, AComment]));
FResult := AResult;
FComment := AComment;
if FResult <> MQR_SUCCESS then begin
// Find "(errno: 123)" in message and add more meaningful message from perror.exe
rx := TRegExpr.Create;
rx.Expression := '.+\(errno\:\s+(\d+)\)';
if rx.Exec(FComment) then begin
msg := MySQLErrorCodes.Values[rx.Match[1]];
if msg <> '' then
FComment := FComment + CRLF + CRLF + msg;
end;
rx.Free;
end;
end;
end.