Skip to content
Permalink
Browse files

Move code from TDBObjectEditor.GetDefiners to new TDBConnection.AllUs…

…erHostCombinations
  • Loading branch information...
ansgarbecker committed Jul 22, 2019
1 parent 0d054a1 commit db9e76bd78d32b45aedd67511954998fcfd184a7
Showing with 24 additions and 25 deletions.
  1. +0 −21 source/apphelpers.pas
  2. +20 −0 source/dbconnection.pas
  3. +1 −1 source/event_editor.pas
  4. +1 −1 source/routine_editor.pas
  5. +1 −1 source/trigger_editor.pas
  6. +1 −1 source/view.pas
@@ -29,7 +29,6 @@ TOrderCol = class(TObject)
TDBObjectEditor = class(TFrame)
private
FModified: Boolean;
FDefiners: TStringList;
procedure SetModified(Value: Boolean);
protected
public
@@ -38,7 +37,6 @@ TDBObjectEditor = class(TFrame)
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 @@ function TDBObjectEditor.DeInit: TModalResult;
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 @@ TDBConnection = class(TComponent)
FResultCount: Integer;
FStatementNum: Cardinal;
FCurrentUserHostCombination: String;
FAllUserHostCombinations: TStringList;
FLockedByThread: TThread;
FQuoteChar: Char;
FQuoteChars: String;
@@ -364,6 +365,7 @@ TDBConnection = class(TComponent)
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 @@ TDBConnection = class(TComponent)
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 @@ function TDBConnection.GetCurrentUserHostCombination: String;
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 @@ procedure TfrmEventEditor.chkStartsEndsClick(Sender: TObject);
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 @@ procedure TfrmRoutineEditor.comboTypeSelect(Sender: TObject);
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 @@ procedure TfrmTriggerEditor.comboChange(Sender: TObject);
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 @@ procedure TfrmView.Init(Obj: TDBObject);
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;


0 comments on commit db9e76b

Please sign in to comment.
You can’t perform that action at this time.