ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/runtime/IBSQL.pas
(Generate patch)

Comparing ibx/trunk/runtime/IBSQL.pas (file contents):
Revision 45 by tony, Tue Dec 6 10:33:46 2016 UTC vs.
Revision 139 by tony, Wed Jan 24 16:16:29 2018 UTC

# Line 37 | Line 37 | unit IBSQL;
37  
38   {$codepage UTF8}
39  
40 + (* Define IBXQUERYSTATS to write to stdout a summary of query execution
41 +   statistics each time a query is executed
42 +
43 +   Define IBXQUERYTIME to write to stdout The local execution time for each
44 +   query
45 +   *)
46 +
47 + { $DEFINE IBXQUERYSTATS}
48 + { $DEFINE IBXQUERYTIME}
49 +
50   interface
51  
52   uses
# Line 684 | Line 694 | begin
694   end;
695  
696   procedure TIBSQL.ExecQuery;
697 +  {$IFDEF IBXQUERYSTATS}
698   var
699 <  fetch_res: ISC_STATUS;
699 >  stats: TPerfCounters;
700 >  {$ENDIF}
701 >  {$IFDEF IBXQUERYTIME}
702 > var
703 >  tmsecs: comp;
704 >  {$ENDIF}
705   begin
706    CheckClosed;
707    if not Prepared then Prepare;
708    CheckValidStatement;
709 +  {$IFDEF IBXQUERYTIME}
710 +  tmsecs := TimeStampToMSecs(DateTimeToTimeStamp(Now));
711 +  {$ENDIF}
712    if SQLStatementType = SQLSelect then
713    begin
714      FResultSet := FStatement.OpenCursor;
# Line 709 | Line 728 | begin
728      if not (csDesigning in ComponentState) then
729        MonitorHook.SQLExecute(Self);
730    end;
731 +  {$IFDEF IBXQUERYTIME}
732 +  writeln('Executing ',FStatement.GetSQLText,
733 +    ' Response time= ',Format('%f msecs',[TimeStampToMSecs(DateTimeToTimeStamp(Now)) - tmsecs]));
734 +  {$ENDIF}
735 +  {$IFDEF IBXQUERYSTATS}
736 +  if FStatement.GetPerfStatistics(stats) then
737 +    writeln('Executing ',FStatement.GetSQLText,
738 +    ' Elapsed time= ', FormatFloat('#0.000',stats[psRealTime]/1000),' sec');
739 +  {$ENDIF}
740    FBase.DoAfterExecQuery(self);
741   end;
742  
# Line 851 | Line 879 | end;
879  
880   procedure TIBSQL.SetDatabase(Value: TIBDatabase);
881   begin
882 +  if Value = FBase.Database then Exit;
883    FBase.Database := Value;
884 +  FreeHandle;
885   end;
886  
887   procedure TIBSQL.Prepare;
# Line 875 | Line 905 | begin
905                       Transaction.TransactionIntf,
906                       SQL.Text,
907                       GenerateParamNames);
908 +  {$IFDEF IBXQUERYSTATS}
909 +  FStatement.EnableStatistics(true);
910 +  {$ENDIF}
911    FMetaData := FStatement.GetMetaData;
912    FSQLParams := FStatement.GetSQLParams;
913    FStatement.SetRetainInterfaces(true);
# Line 905 | Line 938 | end;
938  
939   procedure TIBSQL.SetTransaction(Value: TIBTransaction);
940   begin
941 +  if FBase.Transaction = Value then Exit;
942 +  FreeHandle;
943    FBase.Transaction := Value;
944   end;
945  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines