660 { |
660 { |
661 prevTimeDiff = timeDiff; |
661 prevTimeDiff = timeDiff; |
662 TTime time; |
662 TTime time; |
663 time.UniversalTime(); |
663 time.UniversalTime(); |
664 TDateTime dt = time.DateTime(); |
664 TDateTime dt = time.DateTime(); |
665 TheSqlSrvProfileTraceBuf8.Format(_L8("% 8X¬%012ld¬TME¬%02d:%02d:%02d:%06d¬Prep8=%08d¬Prep16=%08d¬Ex8=%08d¬Ex16=%08d"), |
665 TheSqlSrvProfileTraceBuf8.Format(_L8("[SQL]¬\"%X\"¬¬TME¬¬¬¬¬¬¬¬¬¬¬¬%02d:%02d:%02d:%06d¬Prep8¬%d¬Prep16¬%d¬Ex8¬%d¬Ex16¬%d"), |
666 0, timeDiff, dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond(), |
666 timeDiff, dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond(), |
667 TheSqlSrvProfilerPreparedCnt8, TheSqlSrvProfilerPreparedCnt16, |
667 TheSqlSrvProfilerPreparedCnt8, TheSqlSrvProfilerPreparedCnt16, |
668 TheSqlSrvProfilerExecutedCnt8, TheSqlSrvProfilerExecutedCnt16); |
668 TheSqlSrvProfilerExecutedCnt8, TheSqlSrvProfilerExecutedCnt16); |
669 if(TheSqlSrvProfilerTraceToFile) |
669 if(TheSqlSrvProfilerTraceToFile) |
670 { |
670 { |
671 TheSqlSrvProfileTraceBuf8.Append(_L8("\r\n")); |
671 TheSqlSrvProfileTraceBuf8.Append(_L8("\r\n")); |
756 ttlExecTime = aIpcTraceData[ipcCallIdx].iExecutionTime; |
756 ttlExecTime = aIpcTraceData[ipcCallIdx].iExecutionTime; |
757 count = ++aIpcTraceData[ipcCallIdx].iCount; |
757 count = ++aIpcTraceData[ipcCallIdx].iCount; |
758 } |
758 } |
759 if(ipcCallIdx >= 0 || (ipcCallIdx == KErrNotFound && TheSqlSrvProfilerTraceLevel == 2)) |
759 if(ipcCallIdx >= 0 || (ipcCallIdx == KErrNotFound && TheSqlSrvProfilerTraceLevel == 2)) |
760 { |
760 { |
761 TheSqlSrvProfileTraceBuf.Format(_L("% 8X¬%012ld¬IPC¬%08u¬%20.20S¬%012ld¬%010d¬%08d¬%04d¬%04d¬%04d¬%04d¬rc=%d"), |
761 TheSqlSrvProfileTraceBuf.Format(_L("[SQL]¬\"%X\"¬%ld¬IPC¬%u¬%S¬%ld¬%d¬%d¬%d¬%d¬%d¬%d¬rc¬%d"), |
762 aDbHandle, |
762 //[SQL] |
763 timeFromStart, |
763 aDbHandle, //Database handle |
764 aIpcCounter, |
764 timeFromStart, //Time from start, microseconds |
765 &ipcCallName, |
765 //IPC |
766 ttlExecTime, |
766 aIpcCounter, //IPC sequence counter for this database (connection) |
767 executionTime, |
767 &ipcCallName, //IPC call name |
768 count, |
768 ttlExecTime, //All time spent in this IPC call type for this database (connection) |
769 TheSqlSrvProfilerFileRead, |
769 executionTime, //This IPC call execution time |
770 TheSqlSrvProfilerFileWrite, |
770 count, //This IPC call sequence counter for this database (connection) |
771 TheSqlSrvProfilerFileSync, |
771 TheSqlSrvProfilerFileRead, //File read count, performed during this IPC |
772 TheSqlSrvProfilerFileSetSize, |
772 TheSqlSrvProfilerFileWrite, //File write count, performed during this IPC |
773 aRetCode); |
773 TheSqlSrvProfilerFileSync, //File flush count, performed during this IPC |
|
774 TheSqlSrvProfilerFileSetSize, //File set size count, performed during this IPC |
|
775 aRetCode); //IPC call - return code |
774 SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace); |
776 SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace); |
775 } |
777 } |
776 } |
778 } |
777 } |
779 } |
778 |
780 |
786 return; |
788 return; |
787 } |
789 } |
788 TPtrC ipcCallName; |
790 TPtrC ipcCallName; |
789 (void)SqlIpcTraceIdxAndName(aFuncCode, ipcCallName); |
791 (void)SqlIpcTraceIdxAndName(aFuncCode, ipcCallName); |
790 TInt64 timeFromStart = SqlTimeFromStartUs(); |
792 TInt64 timeFromStart = SqlTimeFromStartUs(); |
791 TheSqlSrvProfileTraceBuf.Format(_L("% 8X¬%012ld¬ERR¬%08u¬%20.20S¬err=%d"), |
793 TheSqlSrvProfileTraceBuf.Format(_L("[SQL]¬\"%X\"¬%ld¬ERR¬%u¬%S¬¬¬¬¬¬¬¬err¬%d"), |
792 aDbHandle, |
794 //[SQL] |
793 timeFromStart, |
795 aDbHandle, //Database (connection) handle |
794 aIpcCounter, |
796 timeFromStart, //Time from start, microseconds |
795 &ipcCallName, |
797 //ERR |
796 aError); |
798 aIpcCounter, //IPC sequence counter for this database (connection) |
|
799 &ipcCallName, //IPC call name |
|
800 aError); //IPC call - return code |
797 SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace); |
801 SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace); |
798 } |
802 } |
799 } |
803 } |
800 |
804 |
801 //Prints the passed as a parameter 16-bit SQL statement. |
805 //Prints the passed as a parameter 16-bit SQL statement. |
821 _LIT(KPrepare, "Prepare16"); |
825 _LIT(KPrepare, "Prepare16"); |
822 _LIT(KExec, "Exec16"); |
826 _LIT(KExec, "Exec16"); |
823 _LIT(KEmptyStr, ""); |
827 _LIT(KEmptyStr, ""); |
824 if(pos == 0) |
828 if(pos == 0) |
825 { |
829 { |
826 line.Format(_L("% 8X¬%012ld¬SQL¬%12.12S¬"), aDbHandle, timeFromStart, aPrepare ? &KPrepare : &KExec); |
830 line.Format(_L("[SQL]¬\"%X\"¬%ld¬SQL¬¬%S¬¬¬¬¬¬¬¬¬¬"), aDbHandle, timeFromStart, aPrepare ? &KPrepare : &KExec); |
827 } |
831 } |
828 else |
832 else |
829 { |
833 { |
830 if(!TheSqlSrvProfilerTraceToFile) |
834 if(!TheSqlSrvProfilerTraceToFile) |
831 { |
835 { |
832 line.Format(_L("% 8X¬%012ld¬SQL¬%12.12S¬"), aDbHandle, timeFromStart, &KEmptyStr); |
836 line.Format(_L("[SQL]¬\"%X\"¬%ld¬SQL¬¬%S¬¬¬¬¬¬¬¬¬¬"), aDbHandle, timeFromStart, &KEmptyStr); |
833 } |
837 } |
834 } |
838 } |
835 TInt l = Min(len, (line.MaxLength() - line.Length())); |
839 TInt l = Min(len, (line.MaxLength() - line.Length())); |
836 TPtrC ptr(aSql.Ptr() + pos, l); |
840 TPtrC ptr(aSql.Ptr() + pos, l); |
837 pos += l; |
841 pos += l; |
866 _LIT(KPrepare, "Prepare8"); |
870 _LIT(KPrepare, "Prepare8"); |
867 _LIT(KExec, "Exec8"); |
871 _LIT(KExec, "Exec8"); |
868 _LIT(KEmptyStr, ""); |
872 _LIT(KEmptyStr, ""); |
869 if(pos == 0) |
873 if(pos == 0) |
870 { |
874 { |
871 line.Format(_L("% 8X¬%012ld¬SQL¬%12.12S¬"), aDbHandle, timeFromStart, aPrepare ? &KPrepare : &KExec); |
875 line.Format(_L("[SQL]¬\"%X\"¬%ld¬SQL¬¬%S¬¬¬¬¬¬¬¬¬¬"), aDbHandle, timeFromStart, aPrepare ? &KPrepare : &KExec); |
872 } |
876 } |
873 else |
877 else |
874 { |
878 { |
875 if(!TheSqlSrvProfilerTraceToFile) |
879 if(!TheSqlSrvProfilerTraceToFile) |
876 { |
880 { |
877 line.Format(_L("% 8X¬%012ld¬SQL¬%12.12S¬"), aDbHandle, timeFromStart, &KEmptyStr); |
881 line.Format(_L("[SQL]¬\"%X\"¬%ld¬SQL¬¬%S¬¬¬¬¬¬¬¬¬¬"), aDbHandle, timeFromStart, &KEmptyStr); |
878 } |
882 } |
879 } |
883 } |
880 TInt l = Min(len, (line.MaxLength() - line.Length())); |
884 TInt l = Min(len, (line.MaxLength() - line.Length())); |
881 TPtrC8 ptr(aSql.Ptr() + pos, l); |
885 TPtrC8 ptr(aSql.Ptr() + pos, l); |
882 pos += l; |
886 pos += l; |
902 if(KSqlSrvProfilerDbName().Length() > 0 && (aDbHandle == 0 || TheSqlSrvProfilerHandle != aDbHandle)) |
906 if(KSqlSrvProfilerDbName().Length() > 0 && (aDbHandle == 0 || TheSqlSrvProfilerHandle != aDbHandle)) |
903 { |
907 { |
904 return; |
908 return; |
905 } |
909 } |
906 TInt64 timeFromStart = SqlTimeFromStartUs(); |
910 TInt64 timeFromStart = SqlTimeFromStartUs(); |
907 TheSqlSrvProfileTraceBuf.Format(_L("% 08X¬%012ld¬CRE¬%S"), |
911 TheSqlSrvProfileTraceBuf.Format(_L("[SQL]¬\"%X\"¬%ld¬CRE¬¬¬¬¬¬¬¬¬¬¬¬%S"), |
908 aDbHandle, |
912 aDbHandle, |
909 timeFromStart, |
913 timeFromStart, |
910 &aDbName); |
914 &aDbName); |
911 SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace); |
915 SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace); |
912 } |
916 } |
924 if(KSqlSrvProfilerDbName().Length() > 0 && (aDbHandle == 0 || TheSqlSrvProfilerHandle != aDbHandle)) |
928 if(KSqlSrvProfilerDbName().Length() > 0 && (aDbHandle == 0 || TheSqlSrvProfilerHandle != aDbHandle)) |
925 { |
929 { |
926 return; |
930 return; |
927 } |
931 } |
928 TInt64 timeFromStart = SqlTimeFromStartUs(); |
932 TInt64 timeFromStart = SqlTimeFromStartUs(); |
929 TheSqlSrvProfileTraceBuf.Format(_L("% 8X¬%012ld¬OPN¬%S"), |
933 TheSqlSrvProfileTraceBuf.Format(_L("[SQL]¬\"%X\"¬%ld¬OPN¬¬¬¬¬¬¬¬¬¬¬¬%S"), |
930 aDbHandle, |
934 aDbHandle, |
931 timeFromStart, |
935 timeFromStart, |
932 &aDbName); |
936 &aDbName); |
933 SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace); |
937 SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace); |
934 } |
938 } |
942 if(KSqlSrvProfilerDbName().Length() > 0 && (aDbHandle == 0 || TheSqlSrvProfilerHandle != aDbHandle)) |
946 if(KSqlSrvProfilerDbName().Length() > 0 && (aDbHandle == 0 || TheSqlSrvProfilerHandle != aDbHandle)) |
943 { |
947 { |
944 return; |
948 return; |
945 } |
949 } |
946 TInt64 timeFromStart = SqlTimeFromStartUs(); |
950 TInt64 timeFromStart = SqlTimeFromStartUs(); |
947 TheSqlSrvProfileTraceBuf.Format(_L("% 8X¬%012ld¬CSE"), |
951 TheSqlSrvProfileTraceBuf.Format(_L("[SQL]¬\"%X\"¬%ld¬CSE"), |
948 aDbHandle, |
952 aDbHandle, |
949 timeFromStart); |
953 timeFromStart); |
950 SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace); |
954 SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace); |
951 if(aDbHandle == TheSqlSrvProfilerHandle) |
955 if(aDbHandle == TheSqlSrvProfilerHandle) |
952 { |
956 { |
984 TheSqlSrvTraceFs.Close(); |
988 TheSqlSrvTraceFs.Close(); |
985 TheSqlSrvProfilerTraceToFile = EFalse; |
989 TheSqlSrvProfilerTraceToFile = EFalse; |
986 RDebug::Print(_L("SQL trace file creation failed with err=%d"), err); |
990 RDebug::Print(_L("SQL trace file creation failed with err=%d"), err); |
987 } |
991 } |
988 } |
992 } |
989 TheSqlSrvProfileTraceBuf.Format(_L("% 8X¬%012ld¬SRV¬START"), 0, timeFromStart); |
993 TheSqlSrvProfileTraceBuf.Format(_L("[SQL]¬¬%ld¬SRV¬¬Start"), timeFromStart); |
990 SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace); |
994 SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace); |
991 } |
995 } |
992 |
996 |
993 //Prints a trace when the SQL server stops |
997 //Prints a trace when the SQL server stops |
994 void SqlPrintServerStop() |
998 void SqlPrintServerStop() |
995 { |
999 { |
996 TInt64 timeFromStart = SqlTimeFromStartUs(); |
1000 TInt64 timeFromStart = SqlTimeFromStartUs(); |
997 TheSqlSrvProfileTraceBuf.Format(_L("% 8X¬%012ld¬SRV¬STOP"), 0, timeFromStart); |
1001 TheSqlSrvProfileTraceBuf.Format(_L("[SQL]¬¬%ld¬SRV¬¬Stop"), timeFromStart); |
998 SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace); |
1002 SqlSrvProfilePrintf(ESqlSrvProfilerNonSqlTrace); |
999 if(TheSqlSrvProfilerTraceToFile) |
1003 if(TheSqlSrvProfilerTraceToFile) |
1000 { |
1004 { |
1001 TheTheSqlSrvTraceFile.Close(); |
1005 TheTheSqlSrvTraceFile.Close(); |
1002 TheSqlSrvTraceFs.Close(); |
1006 TheSqlSrvTraceFs.Close(); |