Issue #135: basic support for ClickHouse MySQL protocol

This commit is contained in:
Ansgar Becker
2021-02-08 19:52:42 +01:00
parent 3cf4409ddf
commit 7597385618
4 changed files with 75 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

View File

@ -1430,7 +1430,7 @@ begin
editUsername.Enabled := lblUsername.Enabled;
lblPassword.Enabled := lblUsername.Enabled;
editPassword.Enabled := lblUsername.Enabled;
lblPort.Enabled := Params.NetType in [ntMySQL_TCPIP, ntMySQL_SSHtunnel, ntMySQL_ProxySQLAdmin, ntMSSQL_TCPIP, ntPgSQL_TCPIP, ntPgSQL_SSHtunnel];
lblPort.Enabled := Params.NetType in [ntMySQL_TCPIP, ntMySQL_SSHtunnel, ntMySQL_ProxySQLAdmin, ntMySQL_ClickHouse, ntMSSQL_TCPIP, ntPgSQL_TCPIP, ntPgSQL_SSHtunnel];
editPort.Enabled := lblPort.Enabled;
updownPort.Enabled := lblPort.Enabled;
chkCompressed.Enabled := Params.IsAnyMySQL;
@ -1440,7 +1440,7 @@ begin
// SSH tunnel tab:
tabSSHtunnel.TabVisible := Params.NetType in [ntMySQL_SSHtunnel, ntPgSQL_SSHtunnel];
// Advanced tab:
chkWantSSL.Enabled := Params.NetType in [ntMySQL_TCPIP, ntMySQL_SSHtunnel, ntMySQL_ProxySQLAdmin, ntPgSQL_TCPIP, ntPgSQL_SSHtunnel];
chkWantSSL.Enabled := Params.NetType in [ntMySQL_TCPIP, ntMySQL_SSHtunnel, ntMySQL_ProxySQLAdmin, ntMySQL_ClickHouse, ntPgSQL_TCPIP, ntPgSQL_SSHtunnel];
lblSSLPrivateKey.Enabled := Params.WantSSL;
editSSLPrivateKey.Enabled := Params.WantSSL;
lblSSLCACertificate.Enabled := Params.WantSSL;

View File

@ -271,7 +271,8 @@ type
ntPgSQL_TCPIP,
ntPgSQL_SSHtunnel,
ntSQLite,
ntMySQL_ProxySQLAdmin
ntMySQL_ProxySQLAdmin,
ntMySQL_ClickHouse
);
TNetTypeGroup = (ngMySQL, ngMSSQL, ngPgSQL, ngSQLite);
TNetGroupLibs = TDictionary<TNetTypeGroup, TStringList>;
@ -314,6 +315,7 @@ type
function IsInfiniDB: Boolean;
function IsInfobright: Boolean;
function IsProxySQLAdmin: Boolean;
function IsClickHouse: Boolean;
function IsAzure: Boolean;
function IsMemSQL: Boolean;
function IsRedshift: Boolean;
@ -1471,6 +1473,7 @@ function TConnectionParameters.NetTypeName(LongFormat: Boolean): String;
const
PrefixMysql = 'MariaDB or MySQL';
PrefixProxysql = 'ProxySQL Admin';
PrefixClickhouse = 'ClickHouse MySQL';
PrefixMssql = 'Microsoft SQL Server';
PrefixPostgres = 'PostgreSQL';
PrefixRedshift = 'Redshift PG';
@ -1485,6 +1488,7 @@ begin
ntMySQL_NamedPipe: Result := PrefixMysql+' (named pipe)';
ntMySQL_SSHtunnel: Result := PrefixMysql+' (SSH tunnel)';
ntMySQL_ProxySQLAdmin: Result := PrefixProxysql+' (Experimental)';
ntMySQL_ClickHouse: Result := PrefixClickhouse+' (Experimental)';
ntMSSQL_NamedPipe: Result := PrefixMssql+' (named pipe)';
ntMSSQL_TCPIP: Result := PrefixMssql+' (TCP/IP)';
ntMSSQL_SPX: Result := PrefixMssql+' (SPX/IPX)';
@ -1505,6 +1509,7 @@ begin
else if IsInfobright then Result := 'Infobright'
else if IsMemSQL then Result := 'MemSQL'
else if IsProxySQLAdmin then Result := 'ProxySQL Admin'
else if IsClickHouse then Result := 'ClickHouse MySQL'
else if IsMySQL(True) then Result := 'MySQL'
else Result := PrefixMysql;
end;
@ -1529,7 +1534,7 @@ end;
function TConnectionParameters.GetNetTypeGroup: TNetTypeGroup;
begin
case FNetType of
ntMySQL_TCPIP, ntMySQL_NamedPipe, ntMySQL_SSHtunnel, ntMySQL_ProxySQLAdmin:
ntMySQL_TCPIP, ntMySQL_NamedPipe, ntMySQL_SSHtunnel, ntMySQL_ProxySQLAdmin, ntMySQL_ClickHouse:
Result := ngMySQL;
ntMSSQL_NamedPipe, ntMSSQL_TCPIP, ntMSSQL_SPX, ntMSSQL_VINES, ntMSSQL_RPC:
Result := ngMSSQL;
@ -1589,6 +1594,7 @@ begin
and (not IsInfiniDB)
and (not IsInfobright)
and (not IsProxySQLAdmin)
and (not IsClickHouse)
and (not IsMemSQL);
end;
end;
@ -1624,6 +1630,12 @@ begin
end;
function TConnectionParameters.IsClickHouse: Boolean;
begin
Result := NetType = ntMySQL_ClickHouse;
end;
function TConnectionParameters.IsAzure: Boolean;
begin
Result := IsAnyMSSQL and (Pos('azure', LowerCase(ServerVersion)) > 0);
@ -1655,7 +1667,8 @@ begin
else if IsInfiniDB then Result := 172
else if IsInfobright then Result := 173
else if IsMemSQL then Result := 194
else if IsProxySQLAdmin then Result := 197;
else if IsProxySQLAdmin then Result := 197
else if IsClickHouse then Result := 203;
end;
ngMSSQL: begin
Result := 123;
@ -1679,6 +1692,8 @@ begin
ngMySQL: begin
if IsProxySQLAdmin then
Result := 6032
else if IsClickHouse then
Result := 8123 // todo: is that correct?
else
Result := 3306;
end;
@ -2100,7 +2115,7 @@ begin
end;
case FParameters.NetType of
ntMySQL_TCPIP, ntMySQL_ProxySQLAdmin: begin
ntMySQL_TCPIP, ntMySQL_ProxySQLAdmin, ntMySQL_ClickHouse: begin
end;
ntMySQL_NamedPipe: begin
@ -2886,7 +2901,7 @@ begin
except // silently fail if IS does not exist, on super old servers
end;
if (ServerVersionInt >= 50124) and (not Parameters.IsProxySQLAdmin) then
if (ServerVersionInt >= 50124) and (not Parameters.IsProxySQLAdmin) and (not Parameters.IsClickHouse) then
FSQLSpecifities[spLockedTables] := 'SHOW OPEN TABLES FROM %s WHERE '+QuoteIdent('in_use')+'!=0';
end;
@ -3783,7 +3798,7 @@ begin
if FThreadId = 0 then begin
Ping(False);
if FActive then begin
if Parameters.IsProxySQLAdmin then
if Parameters.IsProxySQLAdmin or Parameters.IsClickHouse then
FThreadID := FLib.mysql_thread_id(FHandle)
else
FThreadID := StrToInt64Def(GetVar('SELECT CONNECTION_ID()'), 0);

View File

@ -16867,6 +16867,32 @@ object MainForm: TMainForm
518BC562B1582C168BC562B1582C168BC562B1582C168BC562B1582C168BC562
891891FF012639FDF74190BB900000000049454E44AE426082}
end>
end
item
Name = 'server-clickhouse'
SourceImages = <
item
Image.Data = {
89504E470D0A1A0A0000000D494844520000006400000064080600000070E295
54000000017352474200AECE1CE90000000467414D410000B18F0BFC61050000
00097048597300000EC300000EC301C76FA864000001E749444154785EEDDC31
2E445114C6F173995A6B190A0A85C226A814347A16424DA36711140AC5CC0AAC
C00A34E4B9312F9148CCDC77E324FFE2FF939BF79E6A3227DF775E356598C710
6DDEA3C44ED98DD7F1F94FC34BCCEADF63BD3D58FE67ADE3B2170FE3FD4AC322
AEEA27BE181F572B715D3FEFE5F8B452FD1E8EEAE57EF9B4D6737CC461D98FCF
F1F9DF6C8C57413810180702E34060B206D2FAA2A05FB20652C6AB26B2B260AC
2C181302E340605CEA30EE10181302E30E81B1B2604C088C3B04C684C0B84360
AC2C1813026342605CEA3056168C09817187C058593056168C95056365C19810
181302634260B206A24E56168C95056342604C088C09813121C986456C0DF338
A9E7B4E598907CDBF5DCD673D772B206A24E56168C95056342604C088C4B1DC6
81C03810180702933510DFB23A650DC4B7AC4E56168C95056365C19810181302
634260B206A21F6FF59CD773D672B27EFB7D3366F1546FFDEDF789AC2C18973A
8C09813121302604C684C0640D449DAC2C182B0BC684C0981018973A8C038171
20300E04266B20BE6575CA1A886F599DAC2C182B0BC6CA823121302604C684C0
640D449DAC2C182B0B66E3FB776AA69C3626A4D3B481DCD4D3C684747287C0B8
43604C084CD640D4C9CA82B1B2604C088C098171A9C3381018078212F1058BDE
7DE51C4B5BF00000000049454E44AE426082}
end>
end>
Left = 593
Top = 339
@ -24636,6 +24662,32 @@ object MainForm: TMainForm
518BC562B1582C168BC562B1582C168BC562B1582C168BC562B1582C168BC562
891891FF012639FDF74190BB900000000049454E44AE426082}
end>
end
item
Name = 'server-clickhouse'
SourceImages = <
item
Image.Data = {
89504E470D0A1A0A0000000D494844520000006400000064080600000070E295
54000000017352474200AECE1CE90000000467414D410000B18F0BFC61050000
00097048597300000EC300000EC301C76FA864000001E749444154785EEDDC31
2E445114C6F173995A6B190A0A85C226A814347A16424DA36711140AC5CC0AAC
C00A34E4B9312F9148CCDC77E324FFE2FF939BF79E6A3227DF775E356598C710
6DDEA3C44ED98DD7F1F94FC34BCCEADF63BD3D58FE67ADE3B2170FE3FD4AC322
AEEA27BE181F572B715D3FEFE5F8B452FD1E8EEAE57EF9B4D6737CC461D98FCF
F1F9DF6C8C57413810180702E34060B206D2FAA2A05FB20652C6AB26B2B260AC
2C181302E340605CEA30EE10181302E30E81B1B2604C088C3B04C684C0B84360
AC2C1813026342605CEA3056168C09817187C058593056168C95056365C19810
181302634260B206A24E56168C95056342604C088C09813121C986456C0DF338
A9E7B4E598907CDBF5DCD673D772B206A24E56168C95056342604C088C4B1DC6
81C03810180702933510DFB23A650DC4B7AC4E56168C95056365C19810181302
634260B206A21F6FF59CD773D672B27EFB7D3366F1546FFDEDF789AC2C18973A
8C09813121302604C684C0640D449DAC2C182B0BC684C0981018973A8C038171
20300E04266B20BE6575CA1A886F599DAC2C182B0BC6CA823121302604C684C0
640D449DAC2C182B0B66E3FB776AA69C3626A4D3B481DCD4D3C684747287C0B8
43604C084CD640D4C9CA82B1B2604C088C098171A9C3381018078212F1058BDE
7DE51C4B5BF00000000049454E44AE426082}
end>
end>
Left = 689
Top = 339