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)
|
TDBObjectEditor = class(TFrame)
|
||||||
private
|
private
|
||||||
FModified: Boolean;
|
FModified: Boolean;
|
||||||
FDefiners: TStringList;
|
|
||||||
procedure SetModified(Value: Boolean);
|
procedure SetModified(Value: Boolean);
|
||||||
protected
|
protected
|
||||||
public
|
public
|
||||||
@ -38,7 +37,6 @@ type
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Init(Obj: TDBObject); virtual;
|
procedure Init(Obj: TDBObject); virtual;
|
||||||
function DeInit: TModalResult;
|
function DeInit: TModalResult;
|
||||||
function GetDefiners: TStringList;
|
|
||||||
property Modified: Boolean read FModified write SetModified;
|
property Modified: Boolean read FModified write SetModified;
|
||||||
function ApplyModifications: TModalResult; virtual; abstract;
|
function ApplyModifications: TModalResult; virtual; abstract;
|
||||||
end;
|
end;
|
||||||
@ -1976,25 +1974,6 @@ begin
|
|||||||
end;
|
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/
|
// Following code taken from OneInst.pas, http://assarbad.net/de/stuff/!import/nico.old/
|
||||||
|
@ -333,6 +333,7 @@ type
|
|||||||
FResultCount: Integer;
|
FResultCount: Integer;
|
||||||
FStatementNum: Cardinal;
|
FStatementNum: Cardinal;
|
||||||
FCurrentUserHostCombination: String;
|
FCurrentUserHostCombination: String;
|
||||||
|
FAllUserHostCombinations: TStringList;
|
||||||
FLockedByThread: TThread;
|
FLockedByThread: TThread;
|
||||||
FQuoteChar: Char;
|
FQuoteChar: Char;
|
||||||
FQuoteChars: String;
|
FQuoteChars: String;
|
||||||
@ -364,6 +365,7 @@ type
|
|||||||
function GetServerUptime: Integer;
|
function GetServerUptime: Integer;
|
||||||
function GetServerNow: TDateTime;
|
function GetServerNow: TDateTime;
|
||||||
function GetCurrentUserHostCombination: String;
|
function GetCurrentUserHostCombination: String;
|
||||||
|
function GetAllUserHostCombinations: TStringList;
|
||||||
function DecodeAPIString(a: AnsiString): String;
|
function DecodeAPIString(a: AnsiString): String;
|
||||||
function ExtractIdentifier(var SQL: String): String;
|
function ExtractIdentifier(var SQL: String): String;
|
||||||
function GetRowCount(Obj: TDBObject): Int64; virtual; abstract;
|
function GetRowCount(Obj: TDBObject): Int64; virtual; abstract;
|
||||||
@ -448,6 +450,7 @@ type
|
|||||||
property InformationSchemaObjects: TStringList read GetInformationSchemaObjects;
|
property InformationSchemaObjects: TStringList read GetInformationSchemaObjects;
|
||||||
property ResultCount: Integer read FResultCount;
|
property ResultCount: Integer read FResultCount;
|
||||||
property CurrentUserHostCombination: String read GetCurrentUserHostCombination;
|
property CurrentUserHostCombination: String read GetCurrentUserHostCombination;
|
||||||
|
property AllUserHostCombinations: TStringList read GetAllUserHostCombinations;
|
||||||
property LockedByThread: TThread read FLockedByThread write SetLockedByThread;
|
property LockedByThread: TThread read FLockedByThread write SetLockedByThread;
|
||||||
property Datatypes: TDBDataTypeArray read FDatatypes;
|
property Datatypes: TDBDataTypeArray read FDatatypes;
|
||||||
property Favorites: TStringList read FFavorites;
|
property Favorites: TStringList read FFavorites;
|
||||||
@ -4317,6 +4320,23 @@ begin
|
|||||||
end;
|
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;
|
function TDBConnection.ExplainAnalyzer(SQL, DatabaseName: String): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
|
@ -372,7 +372,7 @@ end;
|
|||||||
procedure TfrmEventEditor.comboDefinerDropDown(Sender: TObject);
|
procedure TfrmEventEditor.comboDefinerDropDown(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
// Populate definers from mysql.user
|
// Populate definers from mysql.user
|
||||||
(Sender as TComboBox).Items.Assign(GetDefiners);
|
(Sender as TComboBox).Items.Assign(DBObject.Connection.AllUserHostCombinations);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ end;
|
|||||||
procedure TfrmRoutineEditor.comboDefinerDropDown(Sender: TObject);
|
procedure TfrmRoutineEditor.comboDefinerDropDown(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
// Populate definers from mysql.user
|
// Populate definers from mysql.user
|
||||||
(Sender as TComboBox).Items.Assign(GetDefiners);
|
(Sender as TComboBox).Items.Assign(DBObject.Connection.AllUserHostCombinations);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ end;
|
|||||||
procedure TfrmTriggerEditor.comboDefinerDropDown(Sender: TObject);
|
procedure TfrmTriggerEditor.comboDefinerDropDown(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
// Populate definers from mysql.user
|
// Populate definers from mysql.user
|
||||||
(Sender as TComboBox).Items.Assign(GetDefiners);
|
(Sender as TComboBox).Items.Assign(DBObject.Connection.AllUserHostCombinations);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ end;
|
|||||||
procedure TfrmView.comboDefinerDropDown(Sender: TObject);
|
procedure TfrmView.comboDefinerDropDown(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
// Populate definers from mysql.user
|
// Populate definers from mysql.user
|
||||||
(Sender as TComboBox).Items.Assign(GetDefiners);
|
(Sender as TComboBox).Items.Assign(DBObject.Connection.AllUserHostCombinations);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user