mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Move code from TDBObjectEditor.GetDefiners to new TDBConnection.AllUserHostCombinations
This commit is contained in:
@ -29,7 +29,6 @@ type
|
||||
TDBObjectEditor = class(TFrame)
|
||||
private
|
||||
FModified: Boolean;
|
||||
FDefiners: TStringList;
|
||||
procedure SetModified(Value: Boolean);
|
||||
protected
|
||||
public
|
||||
@ -38,7 +37,6 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure Init(Obj: TDBObject); virtual;
|
||||
function DeInit: TModalResult;
|
||||
function GetDefiners: TStringList;
|
||||
property Modified: Boolean read FModified write SetModified;
|
||||
function ApplyModifications: TModalResult; virtual; abstract;
|
||||
end;
|
||||
@ -1976,25 +1974,6 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TDBObjectEditor.GetDefiners: TStringList;
|
||||
function q(s: String): String;
|
||||
begin
|
||||
Result := DBObject.Connection.QuoteIdent(s);
|
||||
end;
|
||||
begin
|
||||
// For populating combobox items
|
||||
if not Assigned(FDefiners) then begin
|
||||
try
|
||||
FDefiners := DBObject.Connection.GetCol('SELECT CONCAT('+q('User')+', '+esc('@')+', '+q('Host')+') FROM '+
|
||||
q('mysql')+'.'+q('user')+' WHERE '+q('User')+'!='+esc('')+' ORDER BY '+q('User')+', '+q('Host'));
|
||||
except on E:EDbError do
|
||||
FDefiners := TStringList.Create;
|
||||
end;
|
||||
end;
|
||||
Result := FDefiners;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
|
||||
// Following code taken from OneInst.pas, http://assarbad.net/de/stuff/!import/nico.old/
|
||||
|
@ -333,6 +333,7 @@ type
|
||||
FResultCount: Integer;
|
||||
FStatementNum: Cardinal;
|
||||
FCurrentUserHostCombination: String;
|
||||
FAllUserHostCombinations: TStringList;
|
||||
FLockedByThread: TThread;
|
||||
FQuoteChar: Char;
|
||||
FQuoteChars: String;
|
||||
@ -364,6 +365,7 @@ type
|
||||
function GetServerUptime: Integer;
|
||||
function GetServerNow: TDateTime;
|
||||
function GetCurrentUserHostCombination: String;
|
||||
function GetAllUserHostCombinations: TStringList;
|
||||
function DecodeAPIString(a: AnsiString): String;
|
||||
function ExtractIdentifier(var SQL: String): String;
|
||||
function GetRowCount(Obj: TDBObject): Int64; virtual; abstract;
|
||||
@ -448,6 +450,7 @@ type
|
||||
property InformationSchemaObjects: TStringList read GetInformationSchemaObjects;
|
||||
property ResultCount: Integer read FResultCount;
|
||||
property CurrentUserHostCombination: String read GetCurrentUserHostCombination;
|
||||
property AllUserHostCombinations: TStringList read GetAllUserHostCombinations;
|
||||
property LockedByThread: TThread read FLockedByThread write SetLockedByThread;
|
||||
property Datatypes: TDBDataTypeArray read FDatatypes;
|
||||
property Favorites: TStringList read FFavorites;
|
||||
@ -4317,6 +4320,23 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function TDBConnection.GetAllUserHostCombinations: TStringList;
|
||||
begin
|
||||
// For populating combobox items
|
||||
if not Assigned(FAllUserHostCombinations) then begin
|
||||
try
|
||||
FAllUserHostCombinations := GetCol('SELECT CONCAT('+QuoteIdent('User')+', '+EscapeString('@')+', '+QuoteIdent('Host')+') '+
|
||||
'FROM '+QuoteIdent('mysql')+'.'+QuoteIdent('user')+' '+
|
||||
'WHERE '+QuoteIdent('User')+'!='+EscapeString('')+' '+
|
||||
'ORDER BY '+QuoteIdent('User')+', '+QuoteIdent('Host'));
|
||||
except on E:EDbError do
|
||||
FAllUserHostCombinations := TStringList.Create;
|
||||
end;
|
||||
end;
|
||||
Result := FAllUserHostCombinations;
|
||||
end;
|
||||
|
||||
|
||||
function TDBConnection.ExplainAnalyzer(SQL, DatabaseName: String): Boolean;
|
||||
begin
|
||||
Result := False;
|
||||
|
@ -372,7 +372,7 @@ end;
|
||||
procedure TfrmEventEditor.comboDefinerDropDown(Sender: TObject);
|
||||
begin
|
||||
// Populate definers from mysql.user
|
||||
(Sender as TComboBox).Items.Assign(GetDefiners);
|
||||
(Sender as TComboBox).Items.Assign(DBObject.Connection.AllUserHostCombinations);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -219,7 +219,7 @@ end;
|
||||
procedure TfrmRoutineEditor.comboDefinerDropDown(Sender: TObject);
|
||||
begin
|
||||
// Populate definers from mysql.user
|
||||
(Sender as TComboBox).Items.Assign(GetDefiners);
|
||||
(Sender as TComboBox).Items.Assign(DBObject.Connection.AllUserHostCombinations);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -214,7 +214,7 @@ end;
|
||||
procedure TfrmTriggerEditor.comboDefinerDropDown(Sender: TObject);
|
||||
begin
|
||||
// Populate definers from mysql.user
|
||||
(Sender as TComboBox).Items.Assign(GetDefiners);
|
||||
(Sender as TComboBox).Items.Assign(DBObject.Connection.AllUserHostCombinations);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -118,7 +118,7 @@ end;
|
||||
procedure TfrmView.comboDefinerDropDown(Sender: TObject);
|
||||
begin
|
||||
// Populate definers from mysql.user
|
||||
(Sender as TComboBox).Items.Assign(GetDefiners);
|
||||
(Sender as TComboBox).Items.Assign(DBObject.Connection.AllUserHostCombinations);
|
||||
end;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user