mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Issue #1965: show SQL warnings in forms: event editor, copy table, create database, insert files, load CSV
This commit is contained in:
@ -377,6 +377,7 @@ begin
|
||||
Exit;
|
||||
end;
|
||||
FConnection.Query('DROP TABLE '+TargetTable);
|
||||
FConnection.ShowWarnings;
|
||||
end;
|
||||
|
||||
Screen.Cursor := crHourglass;
|
||||
@ -479,8 +480,11 @@ begin
|
||||
try
|
||||
MainForm.ShowStatusMsg(_('Creating table ...'));
|
||||
FConnection.Query(CreateCode);
|
||||
if InsertCode <> '' then
|
||||
FConnection.ShowWarnings;
|
||||
if InsertCode <> '' then begin
|
||||
FConnection.Query(InsertCode);
|
||||
FConnection.ShowWarnings;
|
||||
end;
|
||||
// actRefresh takes care of whether the table editor is open
|
||||
// See also issue #1597
|
||||
MainForm.actRefresh.Execute
|
||||
|
@ -138,6 +138,7 @@ begin
|
||||
if modifyDB = '' then try
|
||||
sql := GetCreateStatement;
|
||||
FConnection.Query(sql);
|
||||
FConnection.ShowWarnings;
|
||||
AppSettings.WriteString(asCreateDbCollation, comboCollation.Text);
|
||||
MainForm.RefreshTree;
|
||||
// Close form
|
||||
@ -154,6 +155,7 @@ begin
|
||||
if modifyDB = editDBName.Text then begin
|
||||
// Alter database
|
||||
FConnection.Query(sql);
|
||||
FConnection.ShowWarnings;
|
||||
end else begin
|
||||
// Rename database
|
||||
ObjectsInOldDb := FConnection.GetDBObjects(modifyDB, True);
|
||||
@ -180,6 +182,7 @@ begin
|
||||
if AllDatabases.IndexOf(editDBName.Text) = -1 then begin
|
||||
// Target db does not exist - create it
|
||||
FConnection.Query(GetCreateStatement);
|
||||
FConnection.ShowWarnings;
|
||||
end else begin
|
||||
if MessageDialog(f_('Database "%s" exists. But it does not contain objects with same names as in "%s", so it''s uncritical to move everything. Move all objects to "%s"?', [editDBName.Text, modifyDB, editDBName.Text]),
|
||||
mtConfirmation, [mbYes, mbCancel]) <> mrYes then
|
||||
@ -195,6 +198,7 @@ begin
|
||||
Delete(sql, Length(sql)-1, 2);
|
||||
sql := 'RENAME TABLE '+sql;
|
||||
FConnection.Query(sql);
|
||||
FConnection.ShowWarnings;
|
||||
FConnection.ClearDbObjects(modifyDB);
|
||||
FConnection.ClearDbObjects(editDBName.Text);
|
||||
end;
|
||||
@ -202,6 +206,7 @@ begin
|
||||
ObjectsLeft := FConnection.GetDBObjects(modifyDB);
|
||||
if ObjectsLeft.Count = 0 then begin
|
||||
FConnection.Query('DROP DATABASE '+FConnection.QuoteIdent(modifyDB));
|
||||
FConnection.ShowWarnings;
|
||||
MainForm.RefreshTree;
|
||||
end;
|
||||
end;
|
||||
|
@ -4788,7 +4788,9 @@ procedure TMySQLConnection.ShowWarnings;
|
||||
var
|
||||
Warnings: TDBQuery;
|
||||
begin
|
||||
if WarningCount > 0 then begin
|
||||
// Log warnings
|
||||
// SHOW WARNINGS is implemented as of MySQL 4.1.0
|
||||
if (WarningCount > 0) and (ServerVersionInt >= 40100) then begin
|
||||
Warnings := GetResults('SHOW WARNINGS');
|
||||
while not Warnings.Eof do begin
|
||||
Log(lcError, Warnings.Col('Level') + ': ('+Warnings.Col('Code')+') ' + Warnings.Col('Message'));
|
||||
|
@ -231,6 +231,7 @@ begin
|
||||
sql := ComposeAlterStatement;
|
||||
try
|
||||
MainForm.ActiveConnection.Query(sql);
|
||||
MainForm.ActiveConnection.ShowWarnings;
|
||||
DBObject.Name := editName.Text;
|
||||
DBObject.UnloadDetails;
|
||||
tabALTERcode.TabVisible := ObjectExists;
|
||||
|
@ -659,6 +659,7 @@ begin
|
||||
sql := sql + ')';
|
||||
try
|
||||
FConnection.Query(sql);
|
||||
FConnection.ShowWarnings;
|
||||
Mainform.ProgressStep;
|
||||
except
|
||||
on E:EDbError do begin
|
||||
|
@ -300,7 +300,6 @@ procedure Tloaddataform.btnImportClick(Sender: TObject);
|
||||
var
|
||||
StartTickCount: Cardinal;
|
||||
i: Integer;
|
||||
Warnings: TDBQuery;
|
||||
begin
|
||||
Screen.Cursor := crHourglass;
|
||||
StartTickCount := GetTickCount;
|
||||
@ -309,9 +308,11 @@ begin
|
||||
// Truncate table before importing
|
||||
if chkTruncateTable.Checked then try
|
||||
FConnection.Query('TRUNCATE TABLE ' + FConnection.QuotedDbAndTableName(comboDatabase.Text, comboTable.Text));
|
||||
FConnection.ShowWarnings;
|
||||
except
|
||||
try
|
||||
FConnection.Query('DELETE FROM ' + FConnection.QuotedDbAndTableName(comboDatabase.Text, comboTable.Text));
|
||||
FConnection.ShowWarnings;
|
||||
except
|
||||
on E:EDbError do
|
||||
ErrorDialog(_('Cannot truncate table'), E.Message);
|
||||
@ -335,20 +336,8 @@ begin
|
||||
1: ClientParse(Sender);
|
||||
end;
|
||||
MainForm.LogSQL(FormatNumber(FRowCount)+' rows imported in '+FormatNumber((GetTickcount-StartTickCount)/1000, 3)+' seconds.');
|
||||
// SHOW WARNINGS is implemented as of MySQL 4.1.0
|
||||
if FConnection.Parameters.IsAnyMySQL and (FConnection.ServerVersionInt >= 40100) then begin
|
||||
Warnings := FConnection.GetResults('SHOW WARNINGS');
|
||||
while not Warnings.Eof do begin
|
||||
MainForm.LogSQL(Warnings.Col(0)+' ('+Warnings.Col(1)+'): '+Warnings.Col(2), lcError);
|
||||
Warnings.Next;
|
||||
end;
|
||||
if Warnings.RecordCount > 0 then begin
|
||||
ErrorDialog(f_('Your file was imported but the server returned %s warnings and/or notes. See the log panel for details.', [FormatNumber(Warnings.RecordCount)]));
|
||||
ModalResult := mrNone;
|
||||
end;
|
||||
end;
|
||||
// Hint user if zero rows were detected in file
|
||||
if (ModalResult <> mrNone) and (FRowCount = 0) then begin
|
||||
if FRowCount = 0 then begin
|
||||
ErrorDialog(_('No rows were imported'),
|
||||
_('This can have several causes:')+CRLF+
|
||||
_(' - File is empty')+CRLF+
|
||||
@ -450,6 +439,7 @@ begin
|
||||
|
||||
|
||||
FConnection.Query(SQL);
|
||||
FConnection.ShowWarnings;
|
||||
FRowCount := Max(FConnection.RowsAffected, 0);
|
||||
end;
|
||||
|
||||
@ -571,6 +561,7 @@ var
|
||||
OutStream.Read(PAnsiChar(SA)^, ChunkSize);
|
||||
OutStream.Size := 0;
|
||||
FConnection.Query(UTF8ToString(SA), False, lcScript);
|
||||
FConnection.ShowWarnings;
|
||||
SQL := '';
|
||||
RowCountInChunk := 0;
|
||||
end;
|
||||
|
Reference in New Issue
Block a user