From eaadfb3f603a764565c61df695cdf6373406a3d1 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Fri, 19 Aug 2011 06:27:00 +0000 Subject: [PATCH] Implement TDBConnection.GetServerVariables, and use that in various places. Also, indicate Percona server version using version_comment variable. See http://www.heidisql.com/forum.php?t=8035 . --- res/icons/server-percona.png | Bin 0 -> 721 bytes source/dbconnection.pas | 81 +++++++++++++++++++++--------- source/main.dfm | 94 +++++++++++++++++------------------ source/main.pas | 2 +- 4 files changed, 105 insertions(+), 72 deletions(-) create mode 100644 res/icons/server-percona.png diff --git a/res/icons/server-percona.png b/res/icons/server-percona.png new file mode 100644 index 0000000000000000000000000000000000000000..fa0f317fc8a81747a3149663663ad1ce8996e81f GIT binary patch literal 721 zcmV;?0xtcDP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02y>eSaefwW^{L9 za%BKeVQFr3E>1;MAa*k@H7+{| z)VF@#q`v9XdbR!!D^xt+%#`OqR}bgE=#pc8J4-S9!%~$OpH`{<$G|I9|9x1Za_P+s zMHdW19#lxMzUq}*@OGNwzqivB|Kr1NrYZb<*)5xgV#w2Ksg@TlGXGI zw9Bq}(JJ!?Ey)VAO^?~@XV zPN4iBxVk*?8+Q|gxf$+82~D~eC;T6V?j%4rx_`28y`?z4^YitBm=HpP-o==s{sl&A{zi?F9+glPT0pM`Kf`44pV9UnH4?rg~pI2v9#$&)gpkWs- zXs|ot%#kpO3z}>$K*ckFcry@h1mYf`>)e20fsvg7+MS_w4r3;Q00000NkvXXu0mjf DgH1X{ literal 0 HcmV?d00001 diff --git a/source/dbconnection.pas b/source/dbconnection.pas index c753e61b..b2cd9c42 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -322,6 +322,7 @@ type function NetTypeName(NetType: TNetType; LongFormat: Boolean): String; function GetNetTypeGroup: TNetTypeGroup; function IsMariaDB: Boolean; + function IsPercona: Boolean; property ImageIndex: Integer read GetImageIndex; published property NetType: TNetType read FNetType write FNetType; @@ -443,6 +444,7 @@ type function ConnectionInfo: TStringList; function GetLastResults: TDBQueryList; virtual; abstract; function GetCreateCode(Database, Name: String; NodeType: TListNodeType): String; virtual; abstract; + function GetServerVariables: TDBQuery; virtual; abstract; procedure ClearDbObjects(db: String); procedure ClearAllDbObjects; procedure ParseTableStructure(CreateTable: String; Columns: TTableColumnList; Keys: TTableKeyList; ForeignKeys: TForeignKeyList); @@ -524,6 +526,7 @@ type function GetLastResults: TDBQueryList; override; function GetCreateCode(Database, Name: String; NodeType: TListNodeType): String; override; property LastRawResults: TMySQLRawResults read FLastRawResults; + function GetServerVariables: TDBQuery; override; end; TAdoRawResults = Array of _RecordSet; @@ -552,6 +555,7 @@ type function GetDBObjects(db: String; Refresh: Boolean=False): TDBObjectList; override; function GetLastResults: TDBQueryList; override; function GetCreateCode(Database, Name: String; NodeType: TListNodeType): String; override; + function GetServerVariables: TDBQuery; override; property LastRawResults: TAdoRawResults read FLastRawResults; end; @@ -767,6 +771,8 @@ var begin if IsMariaDB then My := 'MariaDB' + else if IsPercona then + My := 'Percona' else My := 'MySQL'; if LongFormat then case NetType of @@ -814,6 +820,12 @@ begin end; +function TConnectionParameters.IsPercona: Boolean; +begin + Result := Pos('percona server', LowerCase(ServerVersion)) > 0; +end; + + function TConnectionParameters.GetImageIndex: Integer; begin case NetTypeGroup of @@ -821,6 +833,8 @@ begin Result := 164; if IsMariaDB then Result := 166; + if IsPercona then + Result := 169; end; ngMSSQL: Result := 123; else Result := ICONINDEX_SERVER; @@ -953,6 +967,7 @@ var ExitCode: LongWord; sslca, sslkey, sslcert: PAnsiChar; DoSSL, SSLsettingsComplete: Boolean; + Vars: TDBQuery; begin // Init library if libmysql_handle = 0 then begin @@ -1104,8 +1119,16 @@ begin FConnectionStarted := GetTickCount div 1000; FServerStarted := FConnectionStarted - StrToIntDef(GetVar('SHOW STATUS LIKE ''Uptime''', 1), 1); FServerVersionUntouched := DecodeAPIString(mysql_get_server_info(FHandle)); - FServerOS := GetVar('SHOW VARIABLES LIKE ' + EscapeString('version_compile_os'), 1); - FRealHostname := GetVar('SHOW VARIABLES LIKE ' + EscapeString('hostname'), 1); + Vars := GetServerVariables; + while not Vars.Eof do begin + if Vars.Col(0) = 'version_compile_os' then + FServerOS := Vars.Col(1); + if Vars.Col(0) = 'hostname' then + FRealHostname := Vars.Col(1); + if (Vars.Col(0) = 'version_comment') and (Vars.Col(1) <> '') then + FServerVersionUntouched := FServerVersionUntouched + ' - ' + Vars.Col(1); + Vars.Next; + end; DoAfterConnect; if FDatabase <> '' then begin tmpdb := FDatabase; @@ -2038,9 +2061,9 @@ end; function TMySQLConnection.GetTableEngines: TStringList; var - ShowEngines, HaveEngines: TDBQuery; + Results: TDBQuery; engineName, engineSupport: String; - PossibleEngines: TStringList; + rx: TRegExpr; begin // After a disconnect Ping triggers the cached engines to be reset Log(lcDebug, 'Fetching list of table engines ...'); @@ -2048,42 +2071,38 @@ begin if not Assigned(FTableEngines) then begin FTableEngines := TStringList.Create; try - ShowEngines := GetResults('SHOW ENGINES'); - while not ShowEngines.Eof do begin - engineName := ShowEngines.Col('Engine'); - engineSupport := LowerCase(ShowEngines.Col('Support')); + Results := GetResults('SHOW ENGINES'); + while not Results.Eof do begin + engineName := Results.Col('Engine'); + engineSupport := LowerCase(Results.Col('Support')); // Add to dropdown if supported if (engineSupport = 'yes') or (engineSupport = 'default') then FTableEngines.Add(engineName); // Check if this is the default engine if engineSupport = 'default' then FTableEngineDefault := engineName; - ShowEngines.Next; + Results.Next; end; + Results.Free; except // Ignore errors on old servers and try a fallback: // Manually fetch available engine types by analysing have_* options // This is for servers below 4.1 or when the SHOW ENGINES statement has // failed for some other reason - HaveEngines := GetResults('SHOW VARIABLES LIKE ''have%'''); + Results := GetServerVariables; // Add default engines which will not show in a have_* variable: FTableEngines.CommaText := 'MyISAM,MRG_MyISAM,HEAP'; FTableEngineDefault := 'MyISAM'; - // Possible other engines: - PossibleEngines := TStringList.Create; - PossibleEngines.CommaText := 'ARCHIVE,BDB,BLACKHOLE,CSV,EXAMPLE,FEDERATED,INNODB,ISAM'; - while not HaveEngines.Eof do begin - engineName := copy(HaveEngines.Col(0), 6, Length(HaveEngines.Col(0))); - // Strip additional "_engine" suffix, fx from "have_blackhole_engine" - if Pos('_', engineName) > 0 then - engineName := copy(engineName, 0, Pos('_', engineName)-1); - engineName := UpperCase(engineName); - // Add engine to list if it's a) in HaveEngineList and b) activated - if (PossibleEngines.IndexOf(engineName) > -1) - and (LowerCase(HaveEngines.Col(1)) = 'yes') then - FTableEngines.Add(engineName); - HaveEngines.Next; + rx := TRegExpr.Create; + rx.ModifierI := True; + rx.Expression := '^have_(ARCHIVE|BDB|BLACKHOLE|CSV|EXAMPLE|FEDERATED|INNODB|ISAM)(_engine)?$'; + while not Results.Eof do begin + if rx.Exec(Results.Col(0)) and (LowerCase(Results.Col(1)) = 'yes') then + FTableEngines.Add(UpperCase(rx.Match[1])); + Results.Next; end; + rx.Free; + Results.Free; end; end; Result := FTableEngines; @@ -2180,6 +2199,20 @@ begin end; +function TMySQLConnection.GetServerVariables: TDBQuery; +begin + // Return server variables + Result := GetResults('SHOW VARIABLES'); +end; + + +function TAdoDBConnection.GetServerVariables: TDBQuery; +begin + // Enumerate some config values on MS SQL + Result := GetResults('SELECT '+QuoteIdent('comment')+', '+QuoteIdent('value')+' FROM '+QuoteIdent('master')+'.'+QuoteIdent('dbo')+'.'+QuoteIdent('syscurconfigs')+' ORDER BY '+QuoteIdent('comment')); +end; + + function TDBConnection.GetInformationSchemaObjects: TStringList; var Objects: TDBObjectList; diff --git a/source/main.dfm b/source/main.dfm index 177d4a41..7b5dbf43 100644 --- a/source/main.dfm +++ b/source/main.dfm @@ -2612,133 +2612,133 @@ object MainForm: TMainForm Left = 104 Top = 160 Bitmap = { - 494C0101A90050019C0110001000FFFFFFFF2110FFFFFFFFFFFFFFFF424D3600 + 494C0101AA005001B00110001000FFFFFFFF2110FFFFFFFFFFFFFFFF424D3600 000000000000360000002800000040000000B0020000010020000000000000B0 0200000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000081A205D0C3745870000 0112000001120732448703171F5D000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000020E44020E4A98031467B3031364B1020C3E8C00030F460000 + 0008000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000051013484BCFF7FF21B1 - DEF31BADDDF331C2F4FF010E1348000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + DEF31BADDDF331C2F4FF010E1348000000000000000000000000000000030000 + 03230000000003115AA70628D1FF0628D1FF0628D1FF0628D1FF0628CFFE041A + 8AD000020D410000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000206072D4AD0F7FF82DE - F9FF78D9F9FF2AC0F4FF0005072D000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + F9FF78D9F9FF2AC0F4FF0005072D000000000000000000000004020F4F9D010D + 42910000000003115AA70628D1FF0628D1FF0628D1FF0628D1FF0628D1FF0628 + D1FF0626C5F80107246B00000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000003266577B172DAF8FF8BE0 - FAFF82DDF9FF52D0F6FF0D5975B1000000030000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + FAFF82DDF9FF52D0F6FF0D5975B10000000300000000020A35810628D1FF010D + 43920000000003115AA7051C93D603115AA7031362AF0521AAE60628D1FF0628 + D1FF0628D1FF0627C9FA00031048000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000224E599968D8F9FF71DAF8FF8AE0 - FAFF81DDF9FF4FCEF7FF30C2F4FF094157990000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + FAFF81DDF9FF4FCEF7FF30C2F4FF094157990001062C0625C1F50628D1FF010D + 4392000000000000052A0000000600000000000000000000000E010C3E8C0628 + CDFD0628D1FF0628D1FF051C93D60000000A0000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000009050D0F3F1538428464D7 - F8FF57D2F8FF0A364587010B0E3F000000090000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + F8FF57D2F8FF0A364587010B0E3F00000009020D43910628D1FF0628D1FF010D + 4392000000000000000004171D5816647FB7135970AC020A0D3C00000002020D + 47950628D1FF0628D1FF0628D1FF000416530000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000002F81 - 99C9267F99C90000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 99C9267F99C9000000000000000000000000051D96D80628D1FF0628D1FF010D + 43920000000004151A5429BEF2FC2AC3F8FF2AC3F8FF26B1E0F3010406280000 + 01170627CAFB0628D1FF0628D1FF020E48960000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000000000000000000050D - 1042040D10420000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 - 0000000000000000000000000000000000000000000000000000000000000000 + 1042040D10420000000000000000000000000628C9FA0629D1FF0629D1FF020D + 449200000000135C75B02AC3F8FF2AC3F8FF2AC3F8FF2AC3F8FF092D397B0000 + 0000041D92D50629D1FF0629D1FF03156BB70000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000934CDFA0A37D5FF0A37D5FF0313 + 4A970000000011526CA92AC3F8FF2AC3F8FF2AC3F8FF2AC3F8FF082732740000 + 0000062694D50A37D5FF0A37D5FF051B6EB70000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000A349CD80E4ADAFF0E4ADAFF0932 + 91D00000000102090C3B26AFE1F42AC3F8FF2AC3F8FF2096C3E3000101170000 + 01150E48D1FA0E4ADAFF0E4ADAFF04194C970000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000051D4892125DDEFF125DDEFF125D + DEFF020B195600000000010608300A314385092A387B0002031D00000002061E + 4892125DDEFF125DDEFF125DDEFF010917540000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000003072E1666D3F61770E3FF1770 + E3FF1564CBF1030E1C5B0000000500000000000000000000000D06214189176E + DDFC1770E3FF1770E3FF104EA2D80000000B0000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000006213D841B84E8FF1B84 + E8FF1B84E8FF1B84E8FF135BA0D40C3861A50D3D69AC1669B9E41B84E8FF1B84 + E8FF1B84E8FF1B7FE0FB020A134A000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000050B375CA02094 + EBFE2097EDFF2097EDFF2097EDFF2097EDFF2097EDFF2097EDFF2097EDFF2097 + EDFF1E8EE0F905192B6E00000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000000000000000003051B + 296B1D88C6E824AAF2FF24AAF2FF24AAF2FF24AAF2FF24AAF2FF24A7F0FE186F + A3D2020A10440000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 + 00000000011304151E5B0D3F589A13597BB5125676B20B364C8F020D13490000 + 0008000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000 diff --git a/source/main.pas b/source/main.pas index 54109b32..1738f5ea 100644 --- a/source/main.pas +++ b/source/main.pas @@ -8002,7 +8002,7 @@ begin FreeAndNil(Results); Screen.Cursor := crHourglass; if vt = ListVariables then begin - Results := Conn.GetResults('SHOW VARIABLES'); + Results := Conn.GetServerVariables; end else if vt = ListStatus then begin Results := Conn.GetResults('SHOW /*!50002 GLOBAL */ STATUS'); FStatusServerUptime := Conn.ServerUptime;