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 |
696 |
|
procedure TIBSQL.ExecQuery; |
697 |
|
var |
698 |
|
fetch_res: ISC_STATUS; |
699 |
+ |
{$IFDEF IBXQUERYSTATS} |
700 |
+ |
stats: TPerfCounters; |
701 |
+ |
{$ENDIF} |
702 |
+ |
{$IFDEF IBXQUERYTIME} |
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; |
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 |
|
|
903 |
|
Transaction.TransactionIntf, |
904 |
|
SQL.Text, |
905 |
|
GenerateParamNames); |
906 |
+ |
{$IFDEF IBXQUERYSTATS} |
907 |
+ |
FStatement.EnableStatistics(true); |
908 |
+ |
{$ENDIF} |
909 |
|
FMetaData := FStatement.GetMetaData; |
910 |
|
FSQLParams := FStatement.GetSQLParams; |
911 |
|
FStatement.SetRetainInterfaces(true); |