Fix wrong "DROP [index name]" clause when turning a normal key into a primary key. Fixes issue #2011.

This commit is contained in:
Ansgar Becker
2010-06-16 18:55:33 +00:00
parent d114097d48
commit e16d1bcc59
3 changed files with 6 additions and 2 deletions

View File

@ -2642,6 +2642,7 @@ begin
if Key.Name = '' then Key.Name := rx.Match[2]; // PRIMARY
Key.OldName := Key.Name;
Key.IndexType := rx.Match[2];
Key.OldIndexType := Key.IndexType;
Key.Algorithm := rx.Match[7];
if Key.IndexType = '' then Key.IndexType := 'KEY'; // KEY
Key.Columns := Explode(',', rx.Match[5]);

View File

@ -70,7 +70,7 @@ type
TTableKey = class(TObject)
public
Name, OldName: String;
IndexType, Algorithm: String;
IndexType, OldIndexType, Algorithm: String;
Columns, SubParts: TStringList;
Modified, Added: Boolean;
constructor Create;

View File

@ -433,6 +433,8 @@ begin
end;
DeletedKeys.Clear;
for i:=0 to FKeys.Count-1 do begin
FKeys[i].OldName := FKeys[i].Name;
FKeys[i].OldIndexType := FKeys[i].IndexType;
FKeys[i].Added := False;
FKeys[i].Modified := False;
end;
@ -563,7 +565,7 @@ begin
for i:=0 to FKeys.Count-1 do begin
Mainform.ProgressBarStatus.StepIt;
if FKeys[i].Modified and (not FKeys[i].Added) then begin
if FKeys[i].IndexType = PKEY then
if FKeys[i].OldIndexType = PKEY then
IndexSQL := 'PRIMARY KEY'
else
IndexSQL := 'INDEX ' + Mainform.Mask(FKeys[i].OldName);
@ -1247,6 +1249,7 @@ begin
TblKey.Name := 'Index '+IntToStr(FKeys.Count+1);
TblKey.OldName := TblKey.Name;
TblKey.IndexType := KEY;
TblKey.OldIndexType := TblKey.IndexType;
TblKey.Added := True;
FKeys.Add(TblKey);
Modification(Sender);