ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/branches/udr/client/FBOutputBlock.pas
(Generate patch)

Comparing ibx/trunk/fbintf/client/FBOutputBlock.pas (file contents):
Revision 142 by tony, Sun Apr 2 11:40:29 2017 UTC vs.
Revision 143 by tony, Fri Feb 23 12:11:21 2018 UTC

# Line 46 | Line 46 | uses
46  
47   const
48    DefaultBufferSize = 32000;
49 <  DBInfoDefaultBufferSize = 512;
49 >  DBInfoDefaultBufferSize = DefaultBufferSize; {allow for database page}
50  
51   type
52    TItemDataType = (dtString, dtString2, dtByte, dtBytes, dtInteger, dtIntegerFixed, dtnone,
53 <    dtList,dtSpecial);
53 >    dtList,dtSpecial, dtDateTime, dtOctetString);
54  
55    POutputBlockItemData = ^TOutputBlockItemData;
56    TOutputBlockItemData = record
# Line 93 | Line 93 | type
93      function AddBytesItem(BufPtr: PByte): POutputBlockItemData;
94      function AddListItem(BufPtr: PByte): POutputBlockItemData; virtual;
95      function AddSpecialItem(BufPtr: PByte): POutputBlockItemData; virtual;
96 +    function AddDateTimeItem(BufPtr: PByte): POutputBlockItemData;
97 +    function AddOctetString(BufPtr: PByte): POutputBlockItemData;
98    public
99      constructor Create(aSize: integer = DefaultBufferSize);
100      destructor Destroy; override;
# Line 133 | Line 135 | type
135      function getAsString: AnsiString;
136      function getAsByte: byte;
137      function getAsBytes: TByteArray;
138 +    function getAsDateTime: TDateTime;
139      function CopyTo(stream: TStream; count: integer): integer;
140    end;
141  
# Line 179 | Line 182 | type
182      procedure DecodeVersionString(var Version: byte; var VersionString: AnsiString);
183      procedure DecodeUserNames(UserNames: TStrings);
184      function getOperationCounts: TDBOperationCounts;
185 < end;
185 >  end;
186  
187    { TDBInformation }
188  
# Line 189 | Line 192 | type
192      procedure DoParseBuffer; override;
193    public
194      constructor Create(aSize: integer=DBInfoDefaultBufferSize);
195 +  {$IFNDEF FPC}
196 +    function Find(ItemType: byte): IDBInfoItem;
197 +  {$ENDIF}
198    end;
199  
200    { TServiceQueryResultItem }
# Line 203 | Line 209 | type
209      function AddListItem(BufPtr: PByte): POutputBlockItemData; override;
210      function AddSpecialItem(BufPtr: PByte): POutputBlockItemData; override;
211      procedure DoParseBuffer; override;
212 +  {$IFNDEF FPC}
213 +  public
214 +    function Find(ItemType: byte): IServiceQueryResultItem;
215 +  {$ENDIF}
216    end;
217  
218  
# Line 322 | Line 332 | function TCustomOutputBlock<_TItem,_IIte
332   var P: POutputBlockItemData;
333   begin
334    P := inherited Find(ItemType);
335 <  Result := _TItem.Create(self,P)
335 >  if P = nil then
336 >    Result := nil
337 >  else
338 >    Result := _TItem.Create(self,P)
339   end;
340  
341   {$ELSE}
# Line 344 | Line 357 | var P: POutputBlockItemData;
357      Obj: TOutputBlockItem;
358   begin
359    P := inherited Find(ItemType);
360 <  Obj := TOutputBlockItemClass(_TItem).Create(self.Owner,P);
361 <  if Obj.QueryInterface(GetTypeData(TypeInfo(_IItem))^.Guid,Result) <> 0 then
362 <    IBError(ibxeInterfaceNotSupported,[GuidToString(GetTypeData(TypeInfo(_IItem))^.Guid)]);
360 >  if P = nil then
361 >    Result := Default(_IITEM)
362 >  else
363 >  begin
364 >    Obj := TOutputBlockItemClass(_TItem).Create(self.Owner,P);
365 >    if Obj.QueryInterface(GetTypeData(TypeInfo(_IItem))^.Guid,Result) <> 0 then
366 >      IBError(ibxeInterfaceNotSupported,[GuidToString(GetTypeData(TypeInfo(_IItem))^.Guid)]);
367 >  end;
368   end;
369  
370   { TCustomOutputBlock }
# Line 428 | Line 446 | end;
446  
447   function TOutputBlockItem.getSize: integer;
448   begin
449 <  Result := FItemData^.FDataLength;
449 >  if FItemData = nil then
450 >    Result := 0
451 >  else
452 >    Result := FItemData^.FDataLength;
453   end;
454  
455   procedure TOutputBlockItem.getRawBytes(var Buffer);
# Line 484 | Line 505 | begin
505          len := DecodeInteger(FBufPtr+1,2);
506        SetString(Result,FBufPtr+3,len,CP_ACP);
507      end;
508 +  dtOctetString:
509 +    begin
510 +      with FirebirdClientAPI do
511 +        len := DecodeInteger(FBufPtr+1,2);
512 +      SetString(Result,FBufPtr+3,len,CP_NONE);
513 +    end;
514    else
515      IBError(ibxeOutputBlockTypeError,[nil]);
516    end;
# Line 517 | Line 544 | begin
544      IBError(ibxeOutputBlockTypeError,[nil]);
545   end;
546  
547 + function TOutputBlockItem.getAsDateTime: TDateTime;
548 + var aDate: integer;
549 +    aTime: integer;
550 + begin
551 +  with FItemData^, FirebirdClientAPI do
552 +  if FDataType = dtDateTime then
553 +  begin
554 +    aDate := DecodeInteger(FBufPtr+3,4);
555 +    aTime := DecodeInteger(FBufPtr+7,4);
556 +    Result := SQLDecodeDate(@aDate) + SQLDecodeTime(@aTime)
557 +  end
558 +  else
559 +    IBError(ibxeOutputBlockTypeError,[nil]);
560 + end;
561 +
562 +
563   function TOutputBlockItem.CopyTo(stream: TStream; count: integer): integer;
564   var len: integer;
565   begin
# Line 677 | Line 720 | begin
720    end;
721   end;
722  
723 + function TOutputBlock.AddDateTimeItem(BufPtr: PByte): POutputBlockItemData;
724 + begin
725 +  new(Result);
726 +  with Result^ do
727 +  begin
728 +    FDataType := dtDateTime;
729 +    FBufPtr := BufPtr;
730 +    with FirebirdClientAPI do
731 +      FDataLength := DecodeInteger(FBufPtr+1, 2);
732 +    FSize := FDataLength + 3;
733 +    SetLength(FSubItems,0);
734 +  end;
735 + end;
736 +
737 + function TOutputBlock.AddOctetString(BufPtr: PByte): POutputBlockItemData;
738 + begin
739 +  new(Result);
740 +  with Result^ do
741 +  begin
742 +    FDataType := dtOctetString;
743 +    FBufPtr := BufPtr;
744 +    with FirebirdClientAPI do
745 +      FDataLength := DecodeInteger(FBufPtr+1, 2);
746 +    FSize := FDataLength + 3;
747 +    SetLength(FSubItems,0);
748 +  end;
749 + end;
750 +
751   constructor TOutputBlock.Create(aSize: integer);
752   begin
753    inherited Create;
# Line 913 | Line 984 | begin
984      isc_info_fetches,
985      isc_info_marks,
986      isc_info_reads,
987 <    isc_info_writes:
987 >    isc_info_writes,
988 >    isc_info_active_tran_count,
989 >    fb_info_pages_used,
990 >    fb_info_pages_free,
991 >    fb_info_conn_flags:
992        FItems[index] := AddIntegerItem(P);
993  
994      isc_info_implementation,
995      isc_info_base_level:
996        FItems[index] := AddBytesItem(P);
997  
998 +    isc_info_creation_date:
999 +      FItems[index] := AddDateTimeItem(P);
1000 +
1001 +    fb_info_page_contents:
1002 +      FItems[index] := AddOctetString(P);
1003 +
1004 +    fb_info_crypt_key:
1005 +      FItems[index] := AddStringItem(P);
1006 +
1007      isc_info_db_id,
1008      isc_info_version,
1009      isc_info_backout_count,
# Line 941 | Line 1025 | begin
1025    end;
1026   end;
1027  
1028 + {$IFNDEF FPC}
1029 + function TDBInformation.Find(ItemType: byte): IDBInfoItem;
1030 + begin
1031 +  Result := inherited Find(ItemType);
1032 +  if Result.GetSize = 0 then
1033 +    Result := nil;
1034 + end;
1035 + {$ENDIF}
1036 +
1037   constructor TDBInformation.Create(aSize: integer);
1038   begin
1039    inherited Create(aSize);
# Line 1013 | Line 1106 | begin
1106  
1107        isc_info_svc_get_users:
1108          case integer(P^) of
1109 +        isc_spb_sec_admin,
1110          isc_spb_sec_userid,
1111          isc_spb_sec_groupid:
1112            FSubItems[i] := AddIntegerItem(P);
# Line 1117 | Line 1211 | begin
1211    end;
1212   end;
1213  
1214 + {$IFNDEF FPC}
1215 + function TServiceQueryResults.Find(ItemType: byte): IServiceQueryResultItem;
1216 + begin
1217 +  Result := inherited Find(ItemType);
1218 +  if Result.GetSize = 0 then
1219 +    Result := nil;
1220 + end;
1221 + {$ENDIF}
1222 +
1223   { TSQLInfoResultsBuffer }
1224  
1225   function TSQLInfoResultsBuffer.AddListItem(BufPtr: PByte): POutputBlockItemData;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines