mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
Issue #1313: support MariaDB's COMPRESSED attribute for columns in table editor
This commit is contained in:
@@ -42,7 +42,7 @@ type
|
||||
Name, OldName: String;
|
||||
DataType, OldDataType: TDBDatatype;
|
||||
LengthSet: String;
|
||||
Unsigned, AllowNull, ZeroFill, LengthCustomized, Invisible: Boolean;
|
||||
Unsigned, AllowNull, ZeroFill, LengthCustomized, Invisible, Compressed: Boolean;
|
||||
DefaultType: TColumnDefaultType;
|
||||
DefaultText: String;
|
||||
OnUpdateType: TColumnDefaultType;
|
||||
@@ -437,7 +437,7 @@ type
|
||||
frShowCharset, frIntegerDisplayWidth, frShowFunctionStatus, frShowProcedureStatus,
|
||||
frShowTriggers, frShowEvents, frColumnDefaultParentheses, frForeignKeyChecksVar,
|
||||
frHelpKeyword, frEditVariables, frCreateView, frCreateProcedure, frCreateFunction,
|
||||
frCreateTrigger, frCreateEvent, frInvisibleColumns);
|
||||
frCreateTrigger, frCreateEvent, frInvisibleColumns, frCompressedColumns);
|
||||
|
||||
TDBConnection = class(TComponent)
|
||||
private
|
||||
@@ -6770,6 +6770,7 @@ begin
|
||||
frCreateEvent: Result := ServerVersionInt >= 50100;
|
||||
frInvisibleColumns: Result := (FParameters.IsMariaDB and (ServerVersionInt >= 100303)) or
|
||||
(FParameters.IsMySQL(True) and (ServerVersionInt >= 80023));
|
||||
frCompressedColumns: Result := (FParameters.IsMariaDB and (ServerVersionInt >= 100301));
|
||||
end;
|
||||
else Result := False;
|
||||
end;
|
||||
@@ -10699,6 +10700,7 @@ begin
|
||||
SRID := FromSerialized('SRID', '0').ToInteger;
|
||||
NumVal := FromSerialized('Status', Integer(esUntouched).ToString);
|
||||
FStatus := TEditingStatus(NumVal.ToInteger);
|
||||
Compressed := FromSerialized('Compressed', '0').ToInteger.ToBoolean;
|
||||
|
||||
Attributes.Free;
|
||||
end;
|
||||
@@ -10734,6 +10736,7 @@ begin
|
||||
Virtuality := s.Virtuality;
|
||||
Invisible := s.Invisible;
|
||||
SRID := s.SRID;
|
||||
Compressed := s.Compressed;
|
||||
FStatus := s.FStatus;
|
||||
end else
|
||||
inherited;
|
||||
@@ -10767,6 +10770,8 @@ begin
|
||||
s.AddPair('GenerationExpression', GenerationExpression);
|
||||
s.AddPair('Virtuality', Virtuality);
|
||||
s.AddPair('Invisible', Invisible.ToInteger.ToString);
|
||||
s.AddPair('SRID', SRID.ToString);
|
||||
s.AddPair('Compressed', Compressed.ToInteger.ToString);
|
||||
s.AddPair('Status', Integer(FStatus).ToString);
|
||||
|
||||
Result := Implode(LINEDELIMITER, s);
|
||||
@@ -10818,6 +10823,8 @@ begin
|
||||
Result := Result + ' UNSIGNED';
|
||||
if (DataType.Category in [dtcInteger, dtcReal]) and ZeroFill then
|
||||
Result := Result + ' ZEROFILL';
|
||||
if Compressed and FConnection.Parameters.IsMariaDB then
|
||||
Result := Result + ' /*!100301 COMPRESSED*/';
|
||||
Result := Result + ' '; // Add space after each part
|
||||
end;
|
||||
|
||||
@@ -10929,6 +10936,7 @@ begin
|
||||
end;
|
||||
Unsigned := ExecRegExpr('\bunsigned\b', Source.ToLowerInvariant);
|
||||
ZeroFill := ExecRegExpr('\bzerofill\b', Source.ToLowerInvariant);
|
||||
Compressed := ExecRegExpr('\bcompressed\W', Source.ToLowerInvariant);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
@@ -408,8 +408,8 @@ object frmTableEditor: TfrmTableEditor
|
||||
Top = 2
|
||||
Caption = 'Add'
|
||||
ImageIndex = 45
|
||||
OnClick = btnAddIndexClick
|
||||
Wrap = True
|
||||
OnClick = btnAddIndexClick
|
||||
end
|
||||
object btnRemoveIndex: TToolButton
|
||||
Left = 1
|
||||
@@ -417,8 +417,8 @@ object frmTableEditor: TfrmTableEditor
|
||||
Top = 37
|
||||
Caption = 'Remove'
|
||||
ImageIndex = 46
|
||||
OnClick = btnRemoveIndexClick
|
||||
Wrap = True
|
||||
OnClick = btnRemoveIndexClick
|
||||
end
|
||||
object btnClearIndexes: TToolButton
|
||||
Left = 1
|
||||
@@ -426,8 +426,8 @@ object frmTableEditor: TfrmTableEditor
|
||||
Top = 72
|
||||
Caption = 'Clear'
|
||||
ImageIndex = 26
|
||||
OnClick = btnClearIndexesClick
|
||||
Wrap = True
|
||||
OnClick = btnClearIndexesClick
|
||||
end
|
||||
object btnMoveUpIndex: TToolButton
|
||||
Left = 1
|
||||
@@ -435,8 +435,8 @@ object frmTableEditor: TfrmTableEditor
|
||||
Top = 107
|
||||
Caption = 'Up'
|
||||
ImageIndex = 74
|
||||
OnClick = btnMoveUpIndexClick
|
||||
Wrap = True
|
||||
OnClick = btnMoveUpIndexClick
|
||||
end
|
||||
object btnMoveDownIndex: TToolButton
|
||||
Left = 1
|
||||
@@ -472,8 +472,8 @@ object frmTableEditor: TfrmTableEditor
|
||||
Top = 2
|
||||
Caption = 'Add'
|
||||
ImageIndex = 45
|
||||
OnClick = btnAddForeignKeyClick
|
||||
Wrap = True
|
||||
OnClick = btnAddForeignKeyClick
|
||||
end
|
||||
object btnRemoveForeignKey: TToolButton
|
||||
Left = 1
|
||||
@@ -481,8 +481,8 @@ object frmTableEditor: TfrmTableEditor
|
||||
Caption = 'Remove'
|
||||
Enabled = False
|
||||
ImageIndex = 46
|
||||
OnClick = btnRemoveForeignKeyClick
|
||||
Wrap = True
|
||||
OnClick = btnRemoveForeignKeyClick
|
||||
end
|
||||
object btnClearForeignKeys: TToolButton
|
||||
Left = 1
|
||||
@@ -536,7 +536,7 @@ object frmTableEditor: TfrmTableEditor
|
||||
Options = [coDraggable, coEnabled, coParentBidiMode, coParentColor, coResizable, coShowDropMark, coVisible, coAllowFocus]
|
||||
Position = 5
|
||||
Text = 'On DELETE'
|
||||
Width = 110
|
||||
Width = 114
|
||||
end>
|
||||
Header.Options = [hoAutoResize, hoColumnResize, hoDrag, hoShowSortGlyphs, hoVisible, hoDisableAnimatedResize]
|
||||
Header.PopupMenu = MainForm.popupListHeader
|
||||
@@ -581,8 +581,8 @@ object frmTableEditor: TfrmTableEditor
|
||||
Top = 2
|
||||
Caption = 'Add'
|
||||
ImageIndex = 45
|
||||
OnClick = btnAddCheckConstraintClick
|
||||
Wrap = True
|
||||
OnClick = btnAddCheckConstraintClick
|
||||
end
|
||||
object btnRemoveCheckConstraint: TToolButton
|
||||
Left = 1
|
||||
@@ -590,8 +590,8 @@ object frmTableEditor: TfrmTableEditor
|
||||
Caption = 'Remove'
|
||||
Enabled = False
|
||||
ImageIndex = 46
|
||||
OnClick = btnRemoveCheckConstraintClick
|
||||
Wrap = True
|
||||
OnClick = btnRemoveCheckConstraintClick
|
||||
end
|
||||
object btnClearCheckConstraints: TToolButton
|
||||
Left = 1
|
||||
@@ -621,7 +621,7 @@ object frmTableEditor: TfrmTableEditor
|
||||
Options = [coDraggable, coEnabled, coParentBidiMode, coParentColor, coResizable, coShowDropMark, coVisible, coAllowFocus, coEditable]
|
||||
Position = 1
|
||||
Text = 'Check clause'
|
||||
Width = 530
|
||||
Width = 534
|
||||
end>
|
||||
Header.Options = [hoAutoResize, hoColumnResize, hoDrag, hoShowSortGlyphs, hoVisible, hoDisableAnimatedResize]
|
||||
Header.PopupMenu = MainForm.popupListHeader
|
||||
@@ -1082,6 +1082,12 @@ object frmTableEditor: TfrmTableEditor
|
||||
Options = [coDraggable, coEnabled, coParentBidiMode, coParentColor, coResizable, coShowDropMark, coVisible, coAllowFocus]
|
||||
Position = 13
|
||||
Text = 'Invisible'
|
||||
end
|
||||
item
|
||||
Hint = 'Storage-Engine Independent Column Compression'
|
||||
Options = [coDraggable, coEnabled, coParentBidiMode, coParentColor, coResizable, coShowDropMark, coAllowFocus]
|
||||
Position = 14
|
||||
Text = 'Compressed'
|
||||
end>
|
||||
Header.Options = [hoColumnResize, hoDblClickResize, hoDrag, hoVisible, hoDisableAnimatedResize]
|
||||
Header.PopupMenu = MainForm.popupListHeader
|
||||
|
||||
@@ -231,7 +231,8 @@ type
|
||||
const ColNumVirtuality = 11;
|
||||
const ColNumSrid = 12;
|
||||
const ColNumInvisible = 13;
|
||||
const ColNumsCheckboxes = [ColNumUnsigned, ColNumAllownull, ColNumZerofill, ColNumInvisible];
|
||||
const ColNumCompressed = 14;
|
||||
const ColNumsCheckboxes = [ColNumUnsigned, ColNumAllownull, ColNumZerofill, ColNumInvisible, ColNumCompressed];
|
||||
procedure ValidateColumnControls;
|
||||
procedure ValidateIndexControls;
|
||||
procedure MoveFocusedIndexPart(NewIdx: Cardinal);
|
||||
@@ -315,8 +316,9 @@ begin
|
||||
//comboInsertMethod.Width := comboCollation.Width;
|
||||
if DBObject.Connection.Parameters.IsMariaDB then begin
|
||||
with listColumns.Header do begin
|
||||
Columns[10].Options := Columns[10].Options + [coVisible];
|
||||
Columns[11].Options := Columns[11].Options + [coVisible];
|
||||
Columns[ColNumExpression].Options := Columns[ColNumExpression].Options + [coVisible];
|
||||
Columns[ColNumVirtuality].Options := Columns[ColNumVirtuality].Options + [coVisible];
|
||||
Columns[ColNumCompressed].Options := Columns[ColNumCompressed].Options + [coVisible];
|
||||
end;
|
||||
end;
|
||||
listColumns.BeginUpdate;
|
||||
@@ -1276,7 +1278,9 @@ begin
|
||||
Checked := (Col.Unsigned and (Column=ColNumUnsigned))
|
||||
or (Col.AllowNull and (Column=ColNumAllownull))
|
||||
or (Col.ZeroFill and (Column = ColNumZerofill))
|
||||
or (Col.Invisible and (Column = ColNumInvisible));
|
||||
or (Col.Invisible and (Column = ColNumInvisible))
|
||||
or (Col.Compressed and (Column = ColNumCompressed))
|
||||
;
|
||||
if CellEditingAllowed(Node, Column) then begin
|
||||
if Checked then ImageIndex := 128
|
||||
else ImageIndex := 127;
|
||||
@@ -1386,6 +1390,8 @@ begin
|
||||
|
||||
ColNumInvisible: Result := DBObject.Connection.Has(frInvisibleColumns);
|
||||
|
||||
ColNumCompressed: Result := DBObject.Connection.Has(frCompressedColumns);
|
||||
|
||||
else Result := True;
|
||||
end;
|
||||
|
||||
@@ -1426,7 +1432,8 @@ begin
|
||||
ColNumUnsigned,
|
||||
ColNumAllownull,
|
||||
ColNumZerofill,
|
||||
ColNumInvisible: CellText := ''; // Checkbox
|
||||
ColNumInvisible,
|
||||
ColNumCompressed: CellText := ''; // Checkbox
|
||||
|
||||
ColNumDefault: begin
|
||||
case Col.DefaultType of
|
||||
@@ -1725,6 +1732,13 @@ begin
|
||||
VT.InvalidateNode(Node);
|
||||
end;
|
||||
|
||||
ColNumCompressed: begin
|
||||
Col.Compressed := not Col.Compressed;
|
||||
Col.Status := esModified;
|
||||
Modification(Sender);
|
||||
VT.InvalidateNode(Node);
|
||||
end;
|
||||
|
||||
else begin
|
||||
// All other cells go into edit mode please
|
||||
// Explicitely done on OnClick, not in OnFocusChanged which seemed annoying for keyboard users
|
||||
|
||||
Reference in New Issue
Block a user