Browse Source

* Actually log new log types (ActualSQL and ParamValue)

git-svn-id: trunk@31158 -
michael 10 years ago
parent
commit
ba506acf9f

+ 6 - 1
packages/fcl-db/src/sqldb/interbase/ibconnection.pp

@@ -692,8 +692,11 @@ begin
     tr := aTransaction.Handle;
     
     if assigned(AParams) and (AParams.count > 0) then
+      begin
       buf := AParams.ParseSQL(buf,false,sqEscapeSlash in ConnOptions, sqEscapeRepeat in ConnOptions,psInterbase,paramBinding);
-
+      if LogEvent(detActualSQL) then
+        Log(detActualSQL,Buf);
+      end;
     if isc_dsql_prepare(@Status[0], @tr, @Statement, 0, @Buf[1], Dialect, nil) <> 0 then
       CheckError('PrepareStatement', Status);
     if assigned(AParams) and (AParams.count > 0) then
@@ -836,6 +839,8 @@ var tr : pointer;
 begin
   tr := aTransaction.Handle;
   if Assigned(APArams) and (AParams.count > 0) then SetParameters(cursor, atransaction, AParams);
+  if LogEvent(detParamValue) then
+    LogParams(AParams);
   with cursor as TIBCursor do
   begin
     if FStatementType = stExecProcedure then

+ 4 - 0
packages/fcl-db/src/sqldb/mssql/mssqlconn.pp

@@ -611,7 +611,11 @@ var c: TDBLibCursor;
 begin
   c:=cursor as TDBLibCursor;
 
+  if LogEvent(detParamValues) then
+    LogParams(AParams);
   cmd := c.ReplaceParams(AParams);
+  if LogEvent(detActualSQL) then
+    Log(detActualSQL,Cmd);
   Execute(cmd);
 
   res := SUCCEED;

+ 6 - 1
packages/fcl-db/src/sqldb/mysql/mysqlconn.inc

@@ -599,7 +599,12 @@ begin
       // paramreplacestring kan een probleem geven bij postgres als hij niet meer gewoon $ is?
       C.FStatement := stringsreplace(C.FStatement,ParamNames,ParamValues,[rfReplaceAll]);
       end;
-    Log(detExecute, C.FStatement);
+    if LogEvent(detParamValue) then
+      LogParams(AParams);
+    if LogEvent(detExecute) then
+      Log(detExecute, C.FStatement);
+    if LogEvent(detActualSQL) then
+      Log(detActualSQL,C.FStatement);
     if mysql_query(FMySQL,Pchar(C.FStatement))<>0 then
       begin
       if not ForcedClose then

+ 4 - 0
packages/fcl-db/src/sqldb/oracle/oracleconnection.pp

@@ -599,6 +599,8 @@ var i        : integer;
 begin
   with cursor as TOracleCursor do
     begin
+    if LogEvent(detActualSQL) then
+      Log(detActualSQL,Buf);
     if OCIStmtPrepare2(TOracleTrans(ATransaction.Handle).FOciSvcCtx,FOciStmt,FOciError,@buf[1],length(buf),nil,0,OCI_NTV_SYNTAX,OCI_DEFAULT) = OCI_ERROR then
       HandleError;
     // Get statement type
@@ -830,6 +832,8 @@ procedure TOracleConnection.Execute(cursor: TSQLCursor; ATransaction: TSQLTransa
   end;
 begin
   if Assigned(AParams) and (AParams.Count > 0) then SetParameters(cursor, ATransaction, AParams);
+  if LogEvent(detParamValue) then
+    LogParams(AParams);
   if cursor.FStatementType = stSelect then
     begin
     if OCIStmtExecute(TOracleTrans(ATransaction.Handle).FOciSvcCtx,(cursor as TOracleCursor).FOciStmt,FOciError,0,0,nil,nil,OCI_DEFAULT) = OCI_ERROR then

+ 4 - 0
packages/fcl-db/src/sqldb/postgres/pqconnection.pp

@@ -931,6 +931,8 @@ begin
       s := s + ' as ' + buf;
       if LogEvent(detPrepare) then
         Log(detPrepare,S);
+      if LogEvent(detActualSQL) then
+        Log(detActualSQL,S);
       res := PQexec(tr.PGConn,pchar(s));
       CheckResultError(res,nil,SErrPrepareFailed);
       // if statement is INSERT, UPDATE, DELETE with RETURNING clause, then
@@ -992,6 +994,8 @@ begin
     PQclear(res);
     if FStatementType in [stInsert,stUpdate,stDelete,stSelect] then
       begin
+      if LogEvent(detParamValue) then
+        LogParams(AParams);
       if Assigned(AParams) and (AParams.Count > 0) then
         begin
         l:=AParams.Count;

+ 5 - 1
packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp

@@ -233,6 +233,8 @@ Procedure TSQLite3Cursor.Prepare(Buf : String; AParams : TParams);
 begin
   if assigned(AParams) and (AParams.Count > 0) then
     Buf := AParams.ParseSQL(Buf,false,false,false,psInterbase,fparambinding);
+  if (detActualSQL in fconnection.LogEvents) then
+    fconnection.Log(detActualSQL,Buf);
   checkerror(sqlite3_prepare(fhandle,pchar(Buf),length(Buf),@fstatement,@ftail));
   FPrepared:=True;
 end;
@@ -530,7 +532,9 @@ begin
   checkerror(sqlite3_reset(sc.fstatement));
   If (AParams<>Nil) and (AParams.count > 0) then
     SC.BindParams(AParams);
-  SC.Execute;    
+  If LogEvent(detParamValues) then
+    LogParams(AParams);
+  SC.Execute;
 end;
 
 Function NextWord(Var S : ShortString; Sep : Char) : String;