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

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

# Line 88 | Line 88 | type
88  
89   implementation
90  
91 < uses FBMessages, FB30Statement, FBParamBlock;
91 > uses FBMessages, FB30Statement, FBParamBlock, Math;
92  
93   const
94    sLookupBlobMetaData = 'Select F.RDB$FIELD_SUB_TYPE, F.RDB$SEGMENT_LENGTH, RDB$CHARACTER_SET_ID, F.RDB$FIELD_TYPE '+
# Line 102 | Line 102 | var stmt: IStatement;
102   begin
103    if FHasFullMetaData then Exit;
104  
105  FCharSetID := 0;
105    FSegmentSize := 80;
107  FUnconfirmedCharacterSet := false;
106    if (GetColumnName <> '') and (GetRelationName <> '') then
107    begin
108      stmt := TFB30Statement.Create(FAttachment,FTransaction, sLookupBlobMetaData ,FAttachment.SQLDialect);
# Line 119 | Line 117 | begin
117            IBError(ibxeInvalidBlobMetaData,[nil]);
118          FSubType := Data[0].AsInteger;
119          FSegmentSize := Data[1].AsInteger;
120 <        FCharSetID := Data[2].AsInteger;
120 >        if FUnconfirmedCharacterSet then
121 >          FCharSetID := Data[2].AsInteger;
122        end
123        else
124          IBError(ibxeInvalidBlobMetaData,[nil]);
125  
126      end;
127 <  end
129 <  else
130 <    FUnconfirmedCharacterSet := true;
127 >  end;
128  
129 <    if (FCharSetID > 1) and FAttachment.HasDefaultCharSet then
129 >    if FUnconfirmedCharacterSet and (FCharSetID > 1) and FAttachment.HasDefaultCharSet then
130      begin
131        FCharSetID := FAttachment.CharSetID;
132        FUnconfirmedCharacterSet := false;
# Line 318 | Line 315 | begin
315  
316    LocalBuffer := PChar(@Buffer);
317    repeat
318 <    localCount := Count;
318 >    localCount := Min(Count,MaxuShort);
319      with Firebird30ClientAPI do
320        returnCode := FBlobIntf.getSegment(StatusIntf,localCount, LocalBuffer, @BytesRead);
321      SignalActivity;
# Line 336 | Line 333 | begin
333   end;
334  
335   function TFB30Blob.Write(const Buffer; Count: Longint): Longint;
336 + var
337 +  LocalBuffer: PChar;
338 +  localCount: uShort;
339   begin
340    CheckWritable;
341    Result := 0;
342    if Count = 0 then Exit;
343  
344 <  with Firebird30ClientAPI do
345 <  begin
346 <    FBlobIntf.putSegment(StatusIntf,Count,@Buffer);
347 <    Check4DataBaseError;
348 <  end;
344 >  LocalBuffer := PChar(@Buffer);
345 >  repeat
346 >    localCount := Min(Count,MaxuShort);
347 >    with Firebird30ClientAPI do
348 >    begin
349 >      FBlobIntf.putSegment(StatusIntf,localCount,LocalBuffer);
350 >      Check4DataBaseError;
351 >    end;
352 >    Inc(LocalBuffer,localCount);
353 >    Inc(Result,localCount);
354 >    Dec(Count,localCount);
355 >  until Count = 0;
356    ClearStringCache;
357    SignalActivity;
351  Result := Count;
358   end;
359  
360   end.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines