--- ibx/trunk/fbintf/client/3.0/FB30Blob.pas 2016/12/06 10:33:46 46 +++ ibx/trunk/fbintf/client/3.0/FB30Blob.pas 2017/01/09 15:31:51 47 @@ -88,7 +88,7 @@ type implementation -uses FBMessages, FB30Statement, FBParamBlock; +uses FBMessages, FB30Statement, FBParamBlock, Math; const sLookupBlobMetaData = 'Select F.RDB$FIELD_SUB_TYPE, F.RDB$SEGMENT_LENGTH, RDB$CHARACTER_SET_ID, F.RDB$FIELD_TYPE '+ @@ -102,9 +102,7 @@ var stmt: IStatement; begin if FHasFullMetaData then Exit; - FCharSetID := 0; FSegmentSize := 80; - FUnconfirmedCharacterSet := false; if (GetColumnName <> '') and (GetRelationName <> '') then begin stmt := TFB30Statement.Create(FAttachment,FTransaction, sLookupBlobMetaData ,FAttachment.SQLDialect); @@ -119,17 +117,16 @@ begin IBError(ibxeInvalidBlobMetaData,[nil]); FSubType := Data[0].AsInteger; FSegmentSize := Data[1].AsInteger; - FCharSetID := Data[2].AsInteger; + if FUnconfirmedCharacterSet then + FCharSetID := Data[2].AsInteger; end else IBError(ibxeInvalidBlobMetaData,[nil]); end; - end - else - FUnconfirmedCharacterSet := true; + end; - if (FCharSetID > 1) and FAttachment.HasDefaultCharSet then + if FUnconfirmedCharacterSet and (FCharSetID > 1) and FAttachment.HasDefaultCharSet then begin FCharSetID := FAttachment.CharSetID; FUnconfirmedCharacterSet := false; @@ -318,7 +315,7 @@ begin LocalBuffer := PChar(@Buffer); repeat - localCount := Count; + localCount := Min(Count,MaxuShort); with Firebird30ClientAPI do returnCode := FBlobIntf.getSegment(StatusIntf,localCount, LocalBuffer, @BytesRead); SignalActivity; @@ -336,19 +333,28 @@ begin end; function TFB30Blob.Write(const Buffer; Count: Longint): Longint; +var + LocalBuffer: PChar; + localCount: uShort; begin CheckWritable; Result := 0; if Count = 0 then Exit; - with Firebird30ClientAPI do - begin - FBlobIntf.putSegment(StatusIntf,Count,@Buffer); - Check4DataBaseError; - end; + LocalBuffer := PChar(@Buffer); + repeat + localCount := Min(Count,MaxuShort); + with Firebird30ClientAPI do + begin + FBlobIntf.putSegment(StatusIntf,localCount,LocalBuffer); + Check4DataBaseError; + end; + Inc(LocalBuffer,localCount); + Inc(Result,localCount); + Dec(Count,localCount); + until Count = 0; ClearStringCache; SignalActivity; - Result := Count; end; end.