From 71ab58a2f1ac2602e9b620aadf5553025deb682b Mon Sep 17 00:00:00 2001 From: michael Date: Fri, 26 Jun 2015 09:00:09 +0000 Subject: [PATCH] * Added ActualSQL and ParamValue log types, correct SQLConnector so it passes log options on git-svn-id: trunk@31157 - --- packages/fcl-db/src/sqldb/sqldb.pp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/fcl-db/src/sqldb/sqldb.pp b/packages/fcl-db/src/sqldb/sqldb.pp index 1b24e0835c..4917018931 100644 --- a/packages/fcl-db/src/sqldb/sqldb.pp +++ b/packages/fcl-db/src/sqldb/sqldb.pp @@ -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:='' + else if (P.DataType in ftBlobTypes) and not (P.DataType in [ftMemo, ftFmtMemo,ftWideMemo]) then + S:='' + 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;