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 '+ |
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); |
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; |
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; |
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. |