mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 20:50:20 +08:00
Revert previous commit. Disabling foreign key checks while deleting rows leaves orphaned rows in foreign tables. Other solution to be discussed.
This commit is contained in:
@ -3680,8 +3680,6 @@ var
|
|||||||
TableOrView: TDBObject;
|
TableOrView: TDBObject;
|
||||||
Objects: TDBObjectList;
|
Objects: TDBObjectList;
|
||||||
Names: String;
|
Names: String;
|
||||||
DisableForeignKeys: Boolean;
|
|
||||||
Conn: TDBConnection;
|
|
||||||
begin
|
begin
|
||||||
// Delete rows from selected tables and views
|
// Delete rows from selected tables and views
|
||||||
|
|
||||||
@ -3702,17 +3700,11 @@ begin
|
|||||||
mtConfirmation, [mbOk, mbCancel]) = mrOk then begin
|
mtConfirmation, [mbOk, mbCancel]) = mrOk then begin
|
||||||
Screen.Cursor := crHourglass;
|
Screen.Cursor := crHourglass;
|
||||||
EnableProgress(Objects.Count);
|
EnableProgress(Objects.Count);
|
||||||
Conn := ActiveConnection;
|
|
||||||
try
|
try
|
||||||
DisableForeignKeys := (Conn.Parameters.NetTypeGroup = ngMySQL) and (Conn.ServerVersionInt >= 40014);
|
|
||||||
if DisableForeignKeys then
|
|
||||||
Conn.Query('SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0');
|
|
||||||
for TableOrView in Objects do begin
|
for TableOrView in Objects do begin
|
||||||
TableOrView.Connection.Query(TableOrView.Connection.GetSQLSpecifity(spEmptyTable) + TableOrView.QuotedName);
|
TableOrView.Connection.Query(TableOrView.Connection.GetSQLSpecifity(spEmptyTable) + TableOrView.QuotedName);
|
||||||
ProgressStep;
|
ProgressStep;
|
||||||
end;
|
end;
|
||||||
if DisableForeignKeys then
|
|
||||||
Conn.Query('SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS');
|
|
||||||
actRefresh.Execute;
|
actRefresh.Execute;
|
||||||
except
|
except
|
||||||
on E:EDatabaseError do begin
|
on E:EDatabaseError do begin
|
||||||
|
Reference in New Issue
Block a user