Make TConnectionParameters.IsMySQL specific to MySQL only, and rename the grouped type checks to IsAnyMySQL, IsAnyMSSQL etc. This way the status bar now shows "MySQL", not "MySQL or MariaDB"

This commit is contained in:
Ansgar Becker
2020-02-22 09:06:37 +01:00
parent e97b8ae7fe
commit 05d02627f3
10 changed files with 72 additions and 57 deletions

View File

@ -1299,9 +1299,9 @@ begin
lblHost.Caption := _('Hostname / IP:');
end;
end;
editHost.RightButton.Visible := Params.IsSQLite;
editHost.RightButton.Visible := Params.IsAnySQLite;
chkLoginPrompt.Enabled := Params.NetTypeGroup in [ngMySQL, ngMSSQL, ngPgSQL];
chkWindowsAuth.Enabled := Params.IsMSSQL;
chkWindowsAuth.Enabled := Params.IsAnyMSSQL;
lblUsername.Enabled := (Params.NetTypeGroup in [ngMySQL, ngMSSQL, ngPgSQL])
and ((not chkLoginPrompt.Checked) or (not chkLoginPrompt.Enabled))
and ((not chkWindowsAuth.Checked) or (not chkWindowsAuth.Enabled));
@ -1311,8 +1311,8 @@ begin
lblPort.Enabled := Params.NetType in [ntMySQL_TCPIP, ntMySQL_SSHtunnel, ntMSSQL_TCPIP, ntPgSQL_TCPIP, ntPgSQL_SSHtunnel];
editPort.Enabled := lblPort.Enabled;
updownPort.Enabled := lblPort.Enabled;
chkCompressed.Enabled := Params.IsMySQL;
lblDatabase.Caption := IfThen(Params.IsPostgreSQL, _('Database')+':', _('Databases')+':');
chkCompressed.Enabled := Params.IsAnyMySQL;
lblDatabase.Caption := IfThen(Params.IsAnyPostgreSQL, _('Database')+':', _('Databases')+':');
lblDatabase.Enabled := Params.NetTypeGroup in [ngMySQL, ngMSSQL, ngPgSQL];
editDatabases.Enabled := lblDatabase.Enabled;
// SSH tunnel tab:

View File

@ -265,11 +265,12 @@ type
function NetTypeName(LongFormat: Boolean): String;
function IsCompatibleToWin10S: Boolean;
function GetNetTypeGroup: TNetTypeGroup;
function IsMySQL: Boolean;
function IsMSSQL: Boolean;
function IsPostgreSQL: Boolean;
function IsSQLite: Boolean;
function IsAnyMySQL: Boolean;
function IsAnyMSSQL: Boolean;
function IsAnyPostgreSQL: Boolean;
function IsAnySQLite: Boolean;
function IsMariaDB: Boolean;
function IsMySQL: Boolean;
function IsPercona: Boolean;
function IsTokudb: Boolean;
function IsInfiniDB: Boolean;
@ -1408,6 +1409,8 @@ begin
Prefix := 'Infobright'
else if IsMemSQL then
Prefix := 'MemSQL'
else if IsMySQL then
Prefix := 'MySQL'
else
Prefix := 'MariaDB or MySQL';
end;
@ -1491,25 +1494,25 @@ begin
end;
function TConnectionParameters.IsMySQL: Boolean;
function TConnectionParameters.IsAnyMySQL: Boolean;
begin
Result := NetTypeGroup = ngMySQL;
end;
function TConnectionParameters.IsMSSQL: Boolean;
function TConnectionParameters.IsAnyMSSQL: Boolean;
begin
Result := NetTypeGroup = ngMSSQL;
end;
function TConnectionParameters.IsPostgreSQL: Boolean;
function TConnectionParameters.IsAnyPostgreSQL: Boolean;
begin
Result := NetTypeGroup = ngPgSQL;
end;
function TConnectionParameters.IsSQLite;
function TConnectionParameters.IsAnySQLite;
begin
Result := NetTypeGroup = ngSQLite;
end;
@ -1517,49 +1520,61 @@ end;
function TConnectionParameters.IsMariaDB: Boolean;
begin
Result := IsMySQL and (Pos('-mariadb', LowerCase(ServerVersion)) > 0);
Result := IsAnyMySQL and (Pos('-mariadb', LowerCase(ServerVersion)) > 0);
end;
function TConnectionParameters.IsMySQL: Boolean;
begin
Result := IsAnyMySQL
and (not IsMariaDB)
and (not IsPercona)
and (not IsTokudb)
and (not IsInfiniDB)
and (not IsInfobright)
and (not IsMemSQL);
end;
function TConnectionParameters.IsPercona: Boolean;
begin
Result := IsMySQL and (Pos('percona server', LowerCase(ServerVersion)) > 0);
Result := IsAnyMySQL and (Pos('percona server', LowerCase(ServerVersion)) > 0);
end;
function TConnectionParameters.IsTokudb: Boolean;
begin
Result := IsMySQL and (Pos('tokudb', LowerCase(ServerVersion)) > 0);
Result := IsAnyMySQL and (Pos('tokudb', LowerCase(ServerVersion)) > 0);
end;
function TConnectionParameters.IsInfiniDB: Boolean;
begin
Result := IsMySQL and (Pos('infinidb', LowerCase(ServerVersion)) > 0);
Result := IsAnyMySQL and (Pos('infinidb', LowerCase(ServerVersion)) > 0);
end;
function TConnectionParameters.IsInfobright: Boolean;
begin
Result := IsMySQL and (Pos('infobright', LowerCase(ServerVersion)) > 0);
Result := IsAnyMySQL and (Pos('infobright', LowerCase(ServerVersion)) > 0);
end;
function TConnectionParameters.IsAzure: Boolean;
begin
Result := IsMSSQL and (Pos('azure', LowerCase(ServerVersion)) > 0);
Result := IsAnyMSSQL and (Pos('azure', LowerCase(ServerVersion)) > 0);
end;
function TConnectionParameters.IsMemSQL: Boolean;
begin
Result := IsMySQL and (Pos('memsql', LowerCase(ServerVersion)) > 0);
Result := IsAnyMySQL and (Pos('memsql', LowerCase(ServerVersion)) > 0);
end;
function TConnectionParameters.IsRedshift: Boolean;
begin
Result := IsPostgreSQL and (Pos('redshift', LowerCase(ServerVersion)) > 0);
Result := IsAnyPostgreSQL and (Pos('redshift', LowerCase(ServerVersion)) > 0);
end;
@ -4238,7 +4253,7 @@ begin
else begin
// Fallback for target tables which do not yet exist. For example in copytable dialog.
Result := QuoteIdent(DB) + '.';
if Parameters.IsMSSQL then
if Parameters.IsAnyMSSQL then
Result := Result + '.';
Result := Result + QuoteIdent(Obj);
end;
@ -4819,7 +4834,7 @@ begin
KeyQuery := GetResults('SELECT * FROM '+
QuoteIdent(InfSch)+'.'+QuoteIdent(InformationSchemaObjects[ColTableIdx])+' AS col'+
', '+QuoteIdent(InfSch)+'.'+QuoteIdent(InformationSchemaObjects[ConTableIdx])+' AS con'+
' WHERE col.TABLE_SCHEMA='+EscapeString(IfThen(Parameters.IsMSSQL, Table.Schema, Table.Database))+
' WHERE col.TABLE_SCHEMA='+EscapeString(IfThen(Parameters.IsAnyMSSQL, Table.Schema, Table.Database))+
' AND col.TABLE_NAME='+EscapeString(Table.Name)+
' AND col.TABLE_SCHEMA=con.TABLE_SCHEMA'+
' AND col.TABLE_NAME=con.TABLE_NAME'+
@ -7192,7 +7207,7 @@ var
baData: TBytes;
begin
// Return a binary column value as hex AnsiString
if FConnection.Parameters.IsMysql then begin
if FConnection.Parameters.IsAnyMysql then begin
GetColBinData(Column, baData);
Result := HexValue(baData);
end else
@ -7765,7 +7780,7 @@ begin
else case Datatype(i).Category of
dtcInteger, dtcReal: begin
Val := Connection.EscapeString(Cell.NewText);
if (Datatype(i).Index = dtBit) and FConnection.Parameters.IsMySQL then
if (Datatype(i).Index = dtBit) and FConnection.Parameters.IsAnyMySQL then
Val := 'b' + Val;
end;
dtcBinary, dtcSpatial:
@ -8454,7 +8469,7 @@ end;
function TDBObject.QuotedName(AlwaysQuote: Boolean=True; SeparateSegments: Boolean=True): String;
begin
Result := '';
if FConnection.Parameters.IsMSSQL then begin
if FConnection.Parameters.IsAnyMSSQL then begin
// MSSQL expects schema separated from table, and in some situations the whole string quoted as a whole
if Schema <> '' then begin
if SeparateSegments then
@ -8782,7 +8797,7 @@ begin
end;
if InParts(cpComment) then begin
if (Comment <> '') and FConnection.Parameters.IsMySQL then
if (Comment <> '') and FConnection.Parameters.IsAnyMySQL then
Result := Result + 'COMMENT ' + FConnection.EscapeString(Comment) + ' ';
end;

View File

@ -879,7 +879,7 @@ begin
Data := ''
else if GridData.IsNull(Col) then
Data := 'NULL'
else if (GridData.DataType(Col).Index = dtBit) and GridData.Connection.Parameters.IsMySQL then
else if (GridData.DataType(Col).Index = dtBit) and GridData.Connection.Parameters.IsAnyMySQL then
Data := 'b' + esc(Data)
else if (GridData.DataType(Col).Category in [dtcText, dtcTemporal, dtcOther])
or ((GridData.DataType(Col).Category in [dtcBinary, dtcSpatial]) and Mainform.actBlobAsText.Checked)

View File

@ -629,7 +629,7 @@ begin
// Import binaries as-is (byte for byte), and auto-detect encoding of text files.
if FileInfo.IsBinary then begin
FileContent := '';
if FConnection.Parameters.IsMySQL then
if FConnection.Parameters.IsAnyMySQL then
FileContent := '_binary ';
FileContent := FileContent + '0x' + BinToWideHex(ReadBinaryFile(FileInfo.Filename, 0))
end else

View File

@ -155,14 +155,14 @@ begin
FConnection := MainForm.ActiveConnection;
// Disable features supported in MySQL only, if active connection is not MySQL
if not FConnection.Parameters.IsMySQL then begin
if not FConnection.Parameters.IsAnyMySQL then begin
grpParseMethod.ItemIndex := 1;
grpDuplicates.ItemIndex := 0;
end;
grpParseMethod.Controls[0].Enabled := FConnection.Parameters.IsMySQL;
grpDuplicates.Controls[1].Enabled := FConnection.Parameters.IsMySQL;
grpDuplicates.Controls[2].Enabled := FConnection.Parameters.IsMySQL;
chkLowPriority.Enabled := FConnection.Parameters.IsMySQL;
grpParseMethod.Controls[0].Enabled := FConnection.Parameters.IsAnyMySQL;
grpDuplicates.Controls[1].Enabled := FConnection.Parameters.IsAnyMySQL;
grpDuplicates.Controls[2].Enabled := FConnection.Parameters.IsAnyMySQL;
chkLowPriority.Enabled := FConnection.Parameters.IsAnyMySQL;
// Read databases and tables from active connection
comboDatabase.Items.Clear;
@ -319,7 +319,7 @@ begin
end;
MainForm.LogSQL(FormatNumber(RowCount)+' rows imported in '+FormatNumber((GetTickcount-StartTickCount)/1000, 3)+' seconds.');
// SHOW WARNINGS is implemented as of MySQL 4.1.0
if FConnection.Parameters.IsMySQL and (FConnection.ServerVersionInt >= 40100) then begin
if FConnection.Parameters.IsAnyMySQL and (FConnection.ServerVersionInt >= 40100) then begin
Warnings := FConnection.GetResults('SHOW WARNINGS');
while not Warnings.Eof do begin
MainForm.LogSQL(Warnings.Col(0)+' ('+Warnings.Col(1)+'): '+Warnings.Col(2), lcError);

View File

@ -3306,7 +3306,7 @@ var
begin
// Sub menu with EXPLAIN items pops up
SQL := GetCurrentQuery(ActiveQueryTab);
actExplainCurrentQuery.Enabled := ActiveConnection.Parameters.IsMySQL;
actExplainCurrentQuery.Enabled := ActiveConnection.Parameters.IsAnyMySQL;
actExplainAnalyzeCurrentQuery.Enabled := actExplainCurrentQuery.Enabled;
end;
@ -3618,7 +3618,7 @@ var
begin
// Launch mysql.exe
Conn := ActiveConnection;
if not Conn.Parameters.IsMySQL then
if not Conn.Parameters.IsAnyMySQL then
ErrorDialog(_('Command line only works on MySQL connections.'))
else begin
if FIsWine then begin
@ -5250,9 +5250,9 @@ begin
ngPgSQL, ngSQLite: Select := Select + ' SUBSTR(' + DBObj.Connection.QuoteIdent(c.Name) + ', 1, ' + IntToStr(GRIDMAXDATA) + '), ';
else raise Exception.CreateFmt(_(MsgUnhandledNetType), [Integer(DBObj.Connection.Parameters.NetType)]);
end;
end else if DBObj.Connection.Parameters.IsMSSQL and (c.DataType.Index=dtTimestamp) then begin
end else if DBObj.Connection.Parameters.IsAnyMSSQL and (c.DataType.Index=dtTimestamp) then begin
Select := Select + ' CAST(' + DBObj.Connection.QuoteIdent(c.Name) + ' AS INT), ';
end else if DBObj.Connection.Parameters.IsMSSQL and (c.DataType.Index=dtHierarchyid) then begin
end else if DBObj.Connection.Parameters.IsAnyMSSQL and (c.DataType.Index=dtHierarchyid) then begin
Select := Select + ' CAST(' + DBObj.Connection.QuoteIdent(c.Name) + ' AS NVARCHAR('+IntToStr(GRIDMAXDATA)+')), ';
end else begin
Select := Select + ' ' + DBObj.Connection.QuoteIdent(c.Name) + ', ';
@ -6811,7 +6811,7 @@ begin
menuTreeCollapseAll.Enabled := False;
menuTreeOptions.Enabled := False;
end;
if (ActiveConnection <> nil) and (ActiveConnection.Parameters.IsMySQL) then begin
if (ActiveConnection <> nil) and (ActiveConnection.Parameters.IsAnyMySQL) then begin
Version := ActiveConnection.ServerVersionInt;
actCreateView.Enabled := actCreateView.Enabled and (Version >= 50001);
actCreateRoutine.Enabled := actCreateRoutine.Enabled and (Version >= 50003);
@ -7890,7 +7890,7 @@ begin
SynMemoProcessView.Enabled := EnableControls;
pnlProcessView.Enabled := EnableControls;
lblExplainProcess.Enabled := EnableControls and ActiveConnection.Parameters.IsMySQL;
lblExplainProcess.Enabled := EnableControls and ActiveConnection.Parameters.IsAnyMySQL;
menuExplainProcess.Enabled := lblExplainProcess.Enabled;
lblExplainProcessAnalyzer.Enabled := lblExplainProcess.Enabled;
menuExplainAnalyzer.Enabled := lblExplainProcess.Enabled;
@ -8655,7 +8655,7 @@ begin
InvalidateVT(ListTables, VTREE_NOTLOADED, True);
if FActiveDbObj.NodeType = lntGroup then
InvalidateVT(ListTables, VTREE_NOTLOADED, True);
if FActiveDbObj.Connection.Parameters.IsSQLite then // Prefer visible filename over visible left part of path
if FActiveDbObj.Connection.Parameters.IsAnySQLite then // Prefer visible filename over visible left part of path
TabHostName := StrEllipsis(FActiveDbObj.Connection.Parameters.HostName, 60, False)
else
TabHostName := FActiveDbObj.Connection.Parameters.HostName;
@ -10151,7 +10151,7 @@ begin
// Status + command statistics only available in MySQL
if ((vt=ListStatus) or (vt=ListCommandStats))
and (Conn <> nil)
and (not Conn.Parameters.IsMySQL) then begin
and (not Conn.Parameters.IsAnyMySQL) then begin
vt.Clear;
vt.EmptyListMessage := f_('Not available on %s', [Conn.Parameters.NetTypeName(False)]);
vt.Tag := VTREE_LOADED;
@ -12751,7 +12751,7 @@ begin
Tab.treeHelpers.CheckState[Node] := OldCheckState;
Tab.treeHelpers.Expanded[Node] := vsExpanded in OldStates;
// Disable profiling when not on MySQL
if (NodeIndex = HELPERNODE_PROFILE) and (Conn <> nil) and (not Conn.Parameters.IsMySQL) then begin
if (NodeIndex = HELPERNODE_PROFILE) and (Conn <> nil) and (not Conn.Parameters.IsAnyMySQL) then begin
Tab.treeHelpers.CheckState[Node] := csUncheckedNormal;
end;
// Do not check expansion state of children unless the parent node is expanded, to avoid

View File

@ -282,7 +282,7 @@ begin
if DBObject.Name = '' then begin
// Creating new table
editName.Text := '';
if DBObject.Connection.Parameters.IsMySQL then
if DBObject.Connection.Parameters.IsAnyMySQL then
comboCollation.ItemIndex := comboCollation.Items.IndexOf(DBObject.Connection.GetSessionVariable('collation_database'));
PageControlMain.ActivePage := tabBasic;
FColumns := TTableColumnList.Create;
@ -540,7 +540,7 @@ begin
// appending an ALTER COLUMN ... DROP DEFAULT, without getting an "unknown column" error.
// Also, do this after the data type was altered, if from TEXT > VARCHAR e.g.
for i:=0 to FColumns.Count-1 do begin
if (Conn.Parameters.IsMySQL or Conn.Parameters.IsPostgreSQL)
if (Conn.Parameters.IsAnyMySQL or Conn.Parameters.IsAnyPostgreSQL)
and (FColumns[i].FStatus = esModified)
and (FColumns[i].DefaultType = cdtNothing)
and (FColumns[i].OldDataType.HasDefault)
@ -692,7 +692,7 @@ begin
if FColumns[i].Status = esDeleted then begin
Specs.Add('DROP COLUMN '+Conn.QuoteIdent(FColumns[i].OldName));
// MSSQL wants one ALTER TABLE query per DROP COLUMN
if Conn.Parameters.IsMSSQL then
if Conn.Parameters.IsAnyMSSQL then
FinishSpecs;
end;
end;
@ -799,7 +799,7 @@ begin
SQL := SQL + '/*!50100 ' + SynMemoPartitions.Text + ' */';
SQL := SQL + ';' + CRLF;
if DBObject.Connection.Parameters.IsPostgreSQL then begin
if DBObject.Connection.Parameters.IsAnyPostgreSQL then begin
Node := listColumns.GetFirst;
while Assigned(Node) do begin
Col := listColumns.GetNodeData(Node);
@ -1129,7 +1129,7 @@ begin
4: begin
Result := (Col.DataType.Category in [dtcInteger, dtcReal])
and (Col.DataType.Index <> dtBit)
and (DBObject.Connection.Parameters.IsMySQL);
and (DBObject.Connection.Parameters.IsAnyMySQL);
if (not Result) and Col.Unsigned then begin
Col.Unsigned := False;
Col.Status := esModified;
@ -1152,7 +1152,7 @@ begin
6: begin
Result := (Col.DataType.Category in [dtcInteger, dtcReal])
and (Col.DataType.Index <> dtBit)
and (DBObject.Connection.Parameters.IsMySQL);
and (DBObject.Connection.Parameters.IsAnyMySQL);
if (not Result) and Col.ZeroFill then begin
Col.ZeroFill := False;
Col.Status := esModified;

View File

@ -868,16 +868,16 @@ begin
FindText := LowerCase(FindText);
FindTextJokers := LowerCase(FindTextJokers);
RoutineDefinitionColumn := 'LOWER('+RoutineDefinitionColumn+')';
if DBObj.Connection.Parameters.IsSQLite then begin
if DBObj.Connection.Parameters.IsAnySQLite then begin
DBObj.Connection.Query('PRAGMA case_sensitive_like=FALSE');
end;
end else begin
if DBObj.Connection.Parameters.IsSQLite then begin
if DBObj.Connection.Parameters.IsAnySQLite then begin
DBObj.Connection.Query('PRAGMA case_sensitive_like=TRUE');
end;
end;
RoutineSchemaColumn := 'routine_schema';
if DBObj.Connection.Parameters.IsMSSQL then
if DBObj.Connection.Parameters.IsAnyMSSQL then
RoutineSchemaColumn := 'routine_catalog';
Columns := TTableColumnList.Create(True);

View File

@ -581,7 +581,7 @@ begin
// http://dev.mysql.com/doc/refman/5.7/en/show-grants.html
// As of MySQL 5.7.6, SHOW GRANTS output does not include IDENTIFIED BY PASSWORD clauses.
// Use the SHOW CREATE USER statement instead. See Section 14.7.5.12, "SHOW CREATE USER Syntax".
if FConnection.Parameters.IsMySQL and (FConnection.ServerVersionInt < 50706) then begin
if FConnection.Parameters.IsAnyMySQL and (FConnection.ServerVersionInt < 50706) then begin
if not FAdded then begin
editPassword.TextHint := FConnection.UnescapeString(rxGrant.Match[10]);
// Set password for changed user, to silence the error message about invalid length

View File

@ -109,12 +109,12 @@ begin
end;
// Most clauses only supported by MySQL
comboDefiner.Enabled := comboDefiner.Enabled and Obj.Connection.Parameters.IsMySQL;
comboDefiner.Enabled := comboDefiner.Enabled and Obj.Connection.Parameters.IsAnyMySQL;
lblDefiner.Enabled := comboDefiner.Enabled;
comboSecurity.Enabled := comboSecurity.Enabled and Obj.Connection.Parameters.IsMySQL;
comboSecurity.Enabled := comboSecurity.Enabled and Obj.Connection.Parameters.IsAnyMySQL;
lblSecurity.Enabled := comboSecurity.Enabled;
rgAlgorithm.Enabled := rgAlgorithm.Enabled and Obj.Connection.Parameters.IsMySQL;
rgCheck.Enabled := rgCheck.Enabled and Obj.Connection.Parameters.IsMySQL;
rgAlgorithm.Enabled := rgAlgorithm.Enabled and Obj.Connection.Parameters.IsAnyMySQL;
rgCheck.Enabled := rgCheck.Enabled and Obj.Connection.Parameters.IsAnyMySQL;
Modified := False;
btnSave.Enabled := Modified;