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:
Ansgar Becker
2015-01-30 14:39:14 +00:00
parent daae16e583
commit cf6c8e0618

View File

@ -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