mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-16 03:30:50 +08:00
Cache the myriad of SELECT 123::regclass queries in a hash table on the PostgreSQL connection object. Closes #249, closes #538
This commit is contained in:
@ -86,6 +86,8 @@ type
|
|||||||
// General purpose editing status flag
|
// General purpose editing status flag
|
||||||
TEditingStatus = (esUntouched, esModified, esDeleted, esAddedUntouched, esAddedModified, esAddedDeleted);
|
TEditingStatus = (esUntouched, esModified, esDeleted, esAddedUntouched, esAddedModified, esAddedDeleted);
|
||||||
|
|
||||||
|
TIntStringPairs = TDictionary<Integer, String>;
|
||||||
|
|
||||||
TColumnDefaultType = (cdtNothing, cdtText, cdtNull, cdtAutoInc, cdtExpression);
|
TColumnDefaultType = (cdtNothing, cdtText, cdtNull, cdtAutoInc, cdtExpression);
|
||||||
|
|
||||||
// Column object, many of them in a TObjectList
|
// Column object, many of them in a TObjectList
|
||||||
@ -342,6 +344,7 @@ type
|
|||||||
FKeepAliveTimer: TTimer;
|
FKeepAliveTimer: TTimer;
|
||||||
FFavorites: TStringList;
|
FFavorites: TStringList;
|
||||||
FPrefetchResults: TDBQueryList;
|
FPrefetchResults: TDBQueryList;
|
||||||
|
FRegClasses: TIntStringPairs;
|
||||||
procedure SetActive(Value: Boolean); virtual; abstract;
|
procedure SetActive(Value: Boolean); virtual; abstract;
|
||||||
procedure DoBeforeConnect; virtual;
|
procedure DoBeforeConnect; virtual;
|
||||||
procedure DoAfterConnect; virtual;
|
procedure DoAfterConnect; virtual;
|
||||||
@ -449,6 +452,7 @@ type
|
|||||||
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;
|
||||||
|
property RegClasses: TIntStringPairs read FRegClasses;
|
||||||
function GetLockedTableCount(db: String): Integer;
|
function GetLockedTableCount(db: String): Integer;
|
||||||
function IdentifierEquals(Ident1, Ident2: String): Boolean;
|
function IdentifierEquals(Ident1, Ident2: String): Boolean;
|
||||||
published
|
published
|
||||||
@ -1498,6 +1502,8 @@ begin
|
|||||||
FCurrentUserHostCombination := '';
|
FCurrentUserHostCombination := '';
|
||||||
FKeepAliveTimer := TTimer.Create(Self);
|
FKeepAliveTimer := TTimer.Create(Self);
|
||||||
FFavorites := TStringList.Create;
|
FFavorites := TStringList.Create;
|
||||||
|
// PG only, cache for 123::regclass queries:
|
||||||
|
FRegClasses := TIntStringPairs.Create;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1548,6 +1554,7 @@ begin
|
|||||||
ClearCache(True);
|
ClearCache(True);
|
||||||
FKeepAliveTimer.Free;
|
FKeepAliveTimer.Free;
|
||||||
FFavorites.Free;
|
FFavorites.Free;
|
||||||
|
FRegClasses.Free;
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -7063,7 +7070,12 @@ begin
|
|||||||
Result := '';
|
Result := '';
|
||||||
for i:=0 to ColumnCount-1 do begin
|
for i:=0 to ColumnCount-1 do begin
|
||||||
FieldTypeOID := PQftable(FCurrentResults, i);
|
FieldTypeOID := PQftable(FCurrentResults, i);
|
||||||
Result := FConnection.GetVar('SELECT '+IntToStr(FieldTypeOID)+'::regclass');
|
if not FConnection.RegClasses.ContainsKey(FieldTypeOID) then begin
|
||||||
|
Result := FConnection.GetVar('SELECT '+IntToStr(FieldTypeOID)+'::regclass');
|
||||||
|
FConnection.RegClasses.Add(FieldTypeOID, Result);
|
||||||
|
end else begin
|
||||||
|
FConnection.RegClasses.TryGetValue(FieldTypeOID, Result);
|
||||||
|
end;
|
||||||
if Result <> '' then
|
if Result <> '' then
|
||||||
Break;
|
Break;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user