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

Comparing ibx/trunk/fbintf/client/2.5/FB25Statement.pas (file contents):
Revision 45 by tony, Tue Dec 6 10:33:46 2016 UTC vs.
Revision 47 by tony, Mon Jan 9 15:31:51 2017 UTC

# Line 242 | Line 242 | type
242      FSQLRecord: TIBXOUTPUTSQLDA;
243      FCursor: String;               { Cursor name...}
244      FCursorSeqNo: integer;
245 +    procedure GetPerfCounters(var counters: TPerfStatistics);
246    protected
247      procedure CheckHandle; override;
248      procedure GetDsqlInfo(info_request: byte; buffer: ISQLInfoResults); override;
# Line 273 | Line 274 | end;
274  
275   implementation
276  
277 < uses IBUtils, FBMessages, FB25Blob, variants, IBErrorCodes, FBArray, FB25Array;
277 > uses IBUtils, FBMessages, FBBlob, FB25Blob, variants, IBErrorCodes, FBArray, FB25Array
278 >  {$IFDEF UNIX}, BaseUnix {$ENDIF};
279  
280  
281   { TIBXSQLVAR }
# Line 386 | Line 388 | begin
388      FBlobMetaData := TFB25BlobMetaData.Create(FStatement.GetAttachment as TFB25Attachment,
389                  FStatement.GetTransaction as TFB25Transaction,
390                  GetRelationName,GetFieldName,GetSubType);
391 +  (FBlobMetaData as TFBBlobMetaData).SetCharSetID(GetCharSetID);
392    Result := FBlobMetaData;
393   end;
394  
# Line 468 | Line 471 | procedure TIBXSQLVAR.SetIsNull(Value: Bo
471   begin
472    if Value then
473    begin
474 <    if not IsNullable then
475 <      IsNullable := True;
473 <
474 <      FNullIndicator := -1;
474 >    IsNullable := true;
475 >    FNullIndicator := -1;
476      Changed;
477    end
478    else
# Line 836 | Line 837 | end;
837  
838   { TFB25Statement }
839  
840 + procedure TFB25Statement.GetPerfCounters(var counters: TPerfStatistics);
841 + var DBInfo: IDBInformation;
842 +    i: integer;
843 + {$IFDEF UNIX}
844 +  times: tms;
845 + {$ENDIF}
846 + begin
847 +  {$IFDEF UNIX}
848 +  FpTimes(times);
849 +  counters[psUserTime] := times.tms_utime;
850 +  {$ELSE}
851 +  counters[psUserTime] := 0;
852 +  {$ENDIF}
853 +  counters[psRealTime] := Int64(TimeStampToMSecs(DateTimeToTimeStamp(Now)));
854 +
855 +  DBInfo := GetAttachment.GetDBInformation([isc_info_reads,isc_info_writes,
856 +         isc_info_fetches, isc_info_num_buffers, isc_info_current_memory,
857 +         isc_info_max_memory]);
858 +  if DBInfo <> nil then
859 +  begin
860 +    for i := 0 to DBInfo.Count - 1 do
861 +    with DBInfo[i] do
862 +    case getItemType of
863 +    isc_info_reads:
864 +      counters[psReads] := AsInteger;
865 +    isc_info_writes:
866 +      counters[psWrites] := AsInteger;
867 +    isc_info_fetches:
868 +      counters[psFetches] := AsInteger;
869 +    isc_info_num_buffers:
870 +      counters[psBuffers] := AsInteger;
871 +    isc_info_current_memory:
872 +      counters[psCurrentMemory] := AsInteger;
873 +    isc_info_max_memory:
874 +      counters[psMaxMemory] := AsInteger;
875 +    end;
876 +  end;
877 + end;
878 +
879   procedure TFB25Statement.CheckHandle;
880   begin
881    if FHandle = nil then
# Line 887 | Line 927 | begin
927      else
928        FSQLStatementType := SQLUnknown;
929  
890    { Done getting the type }
930      case FSQLStatementType of
931        SQLGetSegment,
932        SQLPutSegment,
# Line 958 | Line 997 | begin
997    try
998      TRHandle := (aTransaction as TFB25Transaction).Handle;
999      with Firebird25ClientAPI do
961    case FSQLStatementType of
962    SQLSelect:
963      IBError(ibxeIsAExecuteProcedure,[]);
964
965    SQLExecProcedure:
1000      begin
1001 <      Call(isc_dsql_execute2(StatusVector,
1002 <                          @(TRHandle),
1003 <                          @FHandle,
1004 <                          SQLDialect,
1005 <                          FSQLParams.AsXSQLDA,
1006 <                          FSQLRecord.AsXSQLDA), True);
973 <      Result := TResults.Create(FSQLRecord);
974 <      FSingleResults := true;
975 <    end
976 <    else
977 <      Call(isc_dsql_execute(StatusVector,
978 <                           @(TRHandle),
979 <                           @FHandle,
980 <                           SQLDialect,
981 <                           FSQLParams.AsXSQLDA), True);
1001 >      if FCollectStatistics then
1002 >        GetPerfCounters(FBeforeStats);
1003 >
1004 >      case FSQLStatementType of
1005 >      SQLSelect:
1006 >        IBError(ibxeIsAExecuteProcedure,[]);
1007  
1008 +      SQLExecProcedure:
1009 +      begin
1010 +        Call(isc_dsql_execute2(StatusVector,
1011 +                            @(TRHandle),
1012 +                            @FHandle,
1013 +                            SQLDialect,
1014 +                            FSQLParams.AsXSQLDA,
1015 +                            FSQLRecord.AsXSQLDA), True);
1016 +        Result := TResults.Create(FSQLRecord);
1017 +        FSingleResults := true;
1018 +      end
1019 +      else
1020 +        Call(isc_dsql_execute(StatusVector,
1021 +                             @(TRHandle),
1022 +                             @FHandle,
1023 +                             SQLDialect,
1024 +                             FSQLParams.AsXSQLDA), True);
1025 +
1026 +      end;
1027 +      if FCollectStatistics then
1028 +      begin
1029 +        GetPerfCounters(FAfterStats);
1030 +        FStatisticsAvailable := true;
1031 +      end;
1032      end;
1033    finally
1034      if aTransaction <> FTransactionIntf then
# Line 1008 | Line 1057 | begin
1057  
1058   with Firebird25ClientAPI do
1059   begin
1060 +   if FCollectStatistics then
1061 +     GetPerfCounters(FBeforeStats);
1062 +
1063     TRHandle := (aTransaction as TFB25Transaction).Handle;
1064     Call(isc_dsql_execute2(StatusVector,
1065                         @(TRHandle),
# Line 1023 | Line 1075 | begin
1075         isc_dsql_set_cursor_name(StatusVector, @FHandle, PChar(FCursor), 0),
1076         True);
1077     end;
1078 +
1079 +   if FCollectStatistics then
1080 +   begin
1081 +     GetPerfCounters(FAfterStats);
1082 +     FStatisticsAvailable := true;
1083 +   end;
1084   end;
1085   Inc(FCursorSeqNo);
1086   FSingleResults := false;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines