@@ -914,10 +914,27 @@ function TfrmTableEditor.ComposeAlterStatement: TSQLBatch;
914914 Specs.Add(' ADD ' + Constraint.SQLCode);
915915 end ;
916916
917-
918917 FinishSpecs;
919918
920- // Separate queries from here on
919+ // Separate ALTER TABLE .. ALTER INDEX query for visible/invisible indexes features, which gets otherwise
920+ // ignored in MySQL and MariaDB when done by a drop + add combined query. See issue #1388
921+ if Conn.SqlProvider.Has(qIndexInvisible) then begin
922+ for i:=0 to FKeys.Count-1 do begin
923+ if FKeys[i].Modified then begin
924+ Specs.Add(' ALTER INDEX ' + Conn.QuoteIdent(FKeys[i].Name ) + ' ' +
925+ IfThen(
926+ FKeys[i].Visible,
927+ Conn.SqlProvider.GetSql(qIndexVisible),
928+ Conn.SqlProvider.GetSql(qIndexInvisible)
929+ )
930+ );
931+ end ;
932+ end ;
933+ FinishSpecs;
934+ end ;
935+
936+
937+ // *** Separate queries from here on
921938
922939 // Drop indexes, also changed indexes, which will be readded below
923940 for i:=0 to FDeletedKeys.Count-1 do begin
@@ -2091,7 +2108,10 @@ procedure TfrmTableEditor.treeIndexesGetImageIndex(Sender: TBaseVirtualTree;
20912108 if not (Kind in [ikNormal, ikSelected]) then
20922109 Exit;
20932110 case VT.GetNodeLevel(Node) of
2094- 0 : ImageIndex := FKeys[Node.Index].ImageIndex;
2111+ 0 : begin
2112+ ImageIndex := FKeys[Node.Index].ImageIndex;
2113+ Ghosted := not FKeys[Node.Index].Visible;
2114+ end ;
20952115 1 : begin
20962116 TblKey := FKeys[Node.Parent.Index];
20972117 if TblKey.IsExpression(Node.Index) then
@@ -2122,7 +2142,11 @@ procedure TfrmTableEditor.treeIndexesGetText(Sender: TBaseVirtualTree;
21222142 IndexColNumAlgorithm: CellText := TblKey.Algorithm;
21232143 IndexColNumComment: CellText := TblKey.Comment;
21242144 IndexColNumDirection: CellText := ' ' ; // Column collation
2125- IndexColNumVisibility: CellText := IfThen(TblKey.Visible, ' Visible' , ' Invisible' );
2145+ IndexColNumVisibility: CellText := IfThen(
2146+ TblKey.Visible,
2147+ DBObject.Connection.SqlProvider.GetSql(qIndexVisible),
2148+ DBObject.Connection.SqlProvider.GetSql(qIndexInvisible)
2149+ );
21262150 end ;
21272151 end ;
21282152 1 : begin
@@ -2360,7 +2384,7 @@ procedure TfrmTableEditor.treeIndexesEditing(Sender: TBaseVirtualTree;
23602384 IndexColNumType: Allowed := True;
23612385 IndexColNumAlgorithm: Allowed := True;
23622386 IndexColNumComment: Allowed := True;
2363- IndexColNumVisibility: Allowed := DBObject.Connection.Has(frInvisibleIndexes );
2387+ IndexColNumVisibility: Allowed := DBObject.Connection.SqlProvider. Has(qIndexInvisible );
23642388 end ;
23652389 end
23662390 else case Column of
@@ -2406,7 +2430,9 @@ procedure TfrmTableEditor.treeIndexesCreateEditor(Sender: TBaseVirtualTree;
24062430 end else if (Level = 0 ) and (Column = IndexColNumVisibility) then begin
24072431 // Visibility pulldown
24082432 EnumEditor := TEnumEditorLink.Create(VT, True, nil );
2409- EnumEditor.ValueList := Explode(' ,' , ' Visible,Invisible' );
2433+ EnumEditor.ValueList.Add(' ' );
2434+ EnumEditor.ValueList.Add(DBObject.Connection.SqlProvider.GetSql(qIndexVisible));
2435+ EnumEditor.ValueList.Add(DBObject.Connection.SqlProvider.GetSql(qIndexInvisible));
24102436 EditLink := EnumEditor;
24112437 end else if (Level = 1 ) and (Column = IndexColNumName) then begin
24122438 // Column names pulldown
@@ -2449,7 +2475,7 @@ procedure TfrmTableEditor.treeIndexesNewText(Sender: TBaseVirtualTree;
24492475 end ;
24502476 IndexColNumAlgorithm: TblKey.Algorithm := NewText;
24512477 IndexColNumComment: TblKey.Comment := NewText;
2452- IndexColNumVisibility: TblKey.Visible := SameText(NewText, ' Visible ' );
2478+ IndexColNumVisibility: TblKey.Visible := SameText(NewText, DBObject.Connection.SqlProvider.GetSql(qIndexVisible) );
24532479 end ;
24542480 // Needs to be called manually for Name and IndexType properties:
24552481 TblKey.Modification(Sender);
0 commit comments