|
@@ -49,7 +49,7 @@ type
|
|
|
TSQLScript = class;
|
|
|
|
|
|
|
|
|
- TDBEventType = (detCustom, detPrepare, detExecute, detFetch, detCommit, detRollBack);
|
|
|
+ TDBEventType = (detCustom, detPrepare, detExecute, detFetch, detCommit, detRollBack, detParamValue, detActualSQL);
|
|
|
TDBEventTypes = set of TDBEventType;
|
|
|
TDBLogNotifyEvent = Procedure (Sender : TSQLConnection; EventType : TDBEventType; Const Msg : String) of object;
|
|
|
|
|
@@ -116,7 +116,8 @@ type
|
|
|
const
|
|
|
SingleQuotes : TQuoteChars = ('''','''');
|
|
|
DoubleQuotes : TQuoteChars = ('"','"');
|
|
|
- LogAllEvents = [detCustom, detPrepare, detExecute, detFetch, detCommit, detRollBack];
|
|
|
+ LogAllEvents = [detCustom, detPrepare, detExecute, detFetch, detCommit, detRollBack];
|
|
|
+ LogAllEventsExtra = [detCustom, detPrepare, detExecute, detFetch, detCommit, detRollBack, detParamValue,detActualSQL];
|
|
|
StatementTokens : Array[TStatementType] of string = ('(unknown)', 'select',
|
|
|
'insert', 'update', 'delete',
|
|
|
'create', 'get', 'put', 'execute',
|
|
@@ -190,6 +191,7 @@ type
|
|
|
function GetAsSQLText(Param : TParam) : string; overload; virtual;
|
|
|
function GetHandle : pointer; virtual;
|
|
|
Function LogEvent(EventType : TDBEventType) : Boolean;
|
|
|
+ Procedure LogParams(Const AParams : TParams); virtual;
|
|
|
Procedure Log(EventType : TDBEventType; Const Msg : String); virtual;
|
|
|
Procedure RegisterStatement(S : TCustomSQLStatement);
|
|
|
Procedure UnRegisterStatement(S : TCustomSQLStatement);
|
|
@@ -1579,6 +1581,27 @@ begin
|
|
|
Result:=(Assigned(FOnLog) or Assigned(GlobalDBLogHook)) and (EventType in LogEvents);
|
|
|
end;
|
|
|
|
|
|
+procedure TSQLConnection.LogParams(const AParams: TParams);
|
|
|
+
|
|
|
+Var
|
|
|
+ S : String;
|
|
|
+ P : TParam;
|
|
|
+
|
|
|
+begin
|
|
|
+ if not LogEvent(detParamValue) then
|
|
|
+ Exit;
|
|
|
+ For P in AParams do
|
|
|
+ begin
|
|
|
+ if P.IsNull then
|
|
|
+ S:='<NULL>'
|
|
|
+ else if (P.DataType in ftBlobTypes) and not (P.DataType in [ftMemo, ftFmtMemo,ftWideMemo]) then
|
|
|
+ S:='<BLOB>'
|
|
|
+ else
|
|
|
+ S:=P.AsString;
|
|
|
+ Log(detParamValue,Format(SLogParamValue,[P.Name,S]));
|
|
|
+ end;
|
|
|
+end;
|
|
|
+
|
|
|
procedure TSQLConnection.Log(EventType: TDBEventType; const Msg: String);
|
|
|
|
|
|
Var
|
|
@@ -3273,6 +3296,9 @@ begin
|
|
|
FProxy.Role:=Self.Role;
|
|
|
FProxy.UserName:=Self.UserName;
|
|
|
FProxy.FTransaction:=Self.Transaction;
|
|
|
+ FProxy.LogEvents:=Self.LogEvents;
|
|
|
+ FProxy.OnLog:=Self.OnLog;
|
|
|
+ FProxy.Options:=Self.Options;
|
|
|
D:=GetConnectionDef(ConnectorType);
|
|
|
D.ApplyParams(Params,FProxy);
|
|
|
FProxy.Connected:=True;
|