1314 |
|
IBFieldDef := FieldDef as TIBFieldDef; |
1315 |
|
CharacterSetSize := IBFieldDef.CharacterSetSize; |
1316 |
|
CharacterSetName := IBFieldDef.CharacterSetName; |
1317 |
< |
FDataSize := IBFieldDef.DataSize + 1; |
1317 |
> |
FDataSize := IBFieldDef.DataSize; |
1318 |
|
if AutoFieldSize then |
1319 |
|
Size := IBFieldDef.Size; |
1320 |
|
CodePage := IBFieldDef.CodePage; |
1357 |
|
s: RawByteString; |
1358 |
|
begin |
1359 |
|
Buffer := nil; |
1360 |
< |
IBAlloc(Buffer, 0, DataSize); |
1360 |
> |
IBAlloc(Buffer, 0, DataSize + 1); {allow for trailing #0} |
1361 |
|
try |
1362 |
|
Result := GetData(Buffer); |
1363 |
|
if Result then |
1389 |
|
s: RawByteString; |
1390 |
|
begin |
1391 |
|
Buffer := nil; |
1392 |
< |
IBAlloc(Buffer, 0, DataSize); |
1392 |
> |
IBAlloc(Buffer, 0, DataSize + 1); {allow for trailing #0} |
1393 |
|
try |
1394 |
|
s := Value; |
1395 |
|
if StringCodePage(s) <> CodePage then |
1396 |
|
SetCodePage(s,CodePage,CodePage<>CP_NONE); |
1397 |
< |
StrLCopy(Buffer, PChar(s), DataSize-1); |
1397 |
> |
StrLCopy(Buffer, PChar(s), DataSize); |
1398 |
|
if Transliterate then |
1399 |
|
DataSet.Translate(Buffer, Buffer, True); |
1400 |
|
SetData(Buffer); |
1502 |
|
|
1503 |
|
procedure TIBDataLink.ActiveChanged; |
1504 |
|
begin |
1505 |
< |
if FDataSet.Active then |
1505 |
> |
if DetailDataSet.Active and DataSet.Active then |
1506 |
|
FDataSet.RefreshParams; |
1507 |
|
end; |
1508 |
|
|
1961 |
|
Buff: PRecordData; |
1962 |
|
begin |
1963 |
|
Buff := PRecordData(GetActiveBuf); |
1964 |
< |
result := (FQModify.SQL.Text <> '') or |
1965 |
< |
(Assigned(FUpdateObject) and (FUpdateObject.GetSQL(ukModify).Text <> '')) or |
1964 |
> |
result := (Trim(FQModify.SQL.Text) <> '') or |
1965 |
> |
(Assigned(FUpdateObject) and (Trim(FUpdateObject.GetSQL(ukModify).Text) <> '')) or |
1966 |
|
((Buff <> nil) and (Buff^.rdCachedUpdateStatus = cusInserted) and |
1967 |
|
(FCachedUpdates)); |
1968 |
|
end; |
1969 |
|
|
1970 |
|
function TIBCustomDataSet.CanInsert: Boolean; |
1971 |
|
begin |
1972 |
< |
result := (FQInsert.SQL.Text <> '') or |
1973 |
< |
(Assigned(FUpdateObject) and (FUpdateObject.GetSQL(ukInsert).Text <> '')); |
1972 |
> |
result := (Trim(FQInsert.SQL.Text) <> '') or |
1973 |
> |
(Assigned(FUpdateObject) and (Trim(FUpdateObject.GetSQL(ukInsert).Text) <> '')); |
1974 |
|
end; |
1975 |
|
|
1976 |
|
function TIBCustomDataSet.CanDelete: Boolean; |
1977 |
|
begin |
1978 |
< |
if (FQDelete.SQL.Text <> '') or |
1979 |
< |
(Assigned(FUpdateObject) and (FUpdateObject.GetSQL(ukDelete).Text <> '')) then |
1978 |
> |
if (Trim(FQDelete.SQL.Text) <> '') or |
1979 |
> |
(Assigned(FUpdateObject) and (Trim(FUpdateObject.GetSQL(ukDelete).Text) <> '')) then |
1980 |
|
result := True |
1981 |
|
else |
1982 |
|
result := False; |
1984 |
|
|
1985 |
|
function TIBCustomDataSet.CanRefresh: Boolean; |
1986 |
|
begin |
1987 |
< |
result := (FQRefresh.SQL.Text <> '') or |
1988 |
< |
(Assigned(FUpdateObject) and (FUpdateObject.RefreshSQL.Text <> '')); |
1987 |
> |
result := (Trim(FQRefresh.SQL.Text) <> '') or |
1988 |
> |
(Assigned(FUpdateObject) and (Trim(FUpdateObject.RefreshSQL.Text) <> '')); |
1989 |
|
end; |
1990 |
|
|
1991 |
|
procedure TIBCustomDataSet.CheckEditState; |
2637 |
|
begin |
2638 |
|
if Buff <> nil then |
2639 |
|
begin |
2640 |
< |
if (Assigned(FUpdateObject) and (FUpdateObject.RefreshSQL.Text <> '')) then |
2640 |
> |
if (Assigned(FUpdateObject) and (Trim(FUpdateObject.RefreshSQL.Text) <> '')) then |
2641 |
|
begin |
2642 |
|
Qry := TIBSQL.Create(self); |
2643 |
|
Qry.Database := Database; |
3643 |
|
Data := Buff + fdDataOfs; |
3644 |
|
if (fdDataType = SQL_VARYING) or (fdDataType = SQL_TEXT) then |
3645 |
|
begin |
3646 |
< |
if fdDataLength < Field.DataSize then |
3646 |
> |
if fdDataLength <= Field.DataSize then |
3647 |
|
begin |
3648 |
|
Move(Data^, Buffer^, fdDataLength); |
3649 |
|
PChar(Buffer)[fdDataLength] := #0; |
3652 |
|
IBError(ibxeFieldSizeError,[Field.FieldName]) |
3653 |
|
end |
3654 |
|
else |
3655 |
< |
Move(Data^, Buffer^, Field.DataSize); |
3655 |
> |
if fdDataLength <= Field.DataSize then |
3656 |
> |
Move(Data^, Buffer^, Field.DataSize) |
3657 |
> |
else |
3658 |
> |
IBError(ibxeFieldSizeError,[Field.FieldName,Field.DataSize,fdDataLength]) |
3659 |
|
end; |
3660 |
|
end; |
3661 |
|
end; |
3826 |
|
Buff: PChar; |
3827 |
|
CurRec: Integer; |
3828 |
|
pda: PArrayDataArray; |
3829 |
+ |
pbd: PBlobDataArray; |
3830 |
|
i: integer; |
3831 |
|
begin |
3832 |
|
inherited InternalCancel; |
3834 |
|
if Buff <> nil then |
3835 |
|
begin |
3836 |
|
pda := PArrayDataArray(Buff + FArrayCacheOffset); |
3837 |
+ |
pbd := PBlobDataArray(Buff + FBlobCacheOffset); |
3838 |
|
for i := 0 to ArrayFieldCount - 1 do |
3839 |
|
pda^[i].ArrayIntf.CancelChanges; |
3840 |
|
CurRec := FCurrentRecord; |
3841 |
|
AdjustRecordOnInsert(Buff); |
3842 |
|
if (State = dsEdit) then begin |
3843 |
|
CopyRecordBuffer(FOldBuffer, Buff); |
3844 |
+ |
for i := 0 to BlobFieldCount - 1 do |
3845 |
+ |
pbd^[i] := nil; |
3846 |
|
WriteRecordCache(PRecordData(Buff)^.rdRecordNumber, Buff); |
3847 |
|
end else begin |
3848 |
|
CopyRecordBuffer(FModelBuffer, Buff); |
3922 |
|
procedure TIBCustomDataSet.InternalFirst; |
3923 |
|
begin |
3924 |
|
FCurrentRecord := -1; |
3925 |
+ |
if Unidirectional then GetNextRecord; |
3926 |
|
end; |
3927 |
|
|
3928 |
|
procedure TIBCustomDataSet.InternalGotoBookmark(Bookmark: Pointer); |
3948 |
|
procedure TIBCustomDataSet.FieldDefsFromQuery(SourceQuery: TIBSQL); |
3949 |
|
const |
3950 |
|
DefaultSQL = 'Select F.RDB$COMPUTED_BLR, ' + {do not localize} |
3951 |
< |
'F.RDB$DEFAULT_VALUE, R.RDB$FIELD_NAME ' + {do not localize} |
3951 |
> |
'F.RDB$DEFAULT_VALUE, R.RDB$FIELD_NAME ' + {do not localize} |
3952 |
|
'from RDB$RELATION_FIELDS R, RDB$FIELDS F ' + {do not localize} |
3953 |
|
'where R.RDB$RELATION_NAME = :RELATION ' + {do not localize} |
3954 |
|
'and R.RDB$FIELD_SOURCE = F.RDB$FIELD_NAME '+ {do not localize} |
4000 |
|
while not Query.Eof do |
4001 |
|
begin |
4002 |
|
FField := TFieldNode.Create; |
4003 |
< |
FField.FieldName := Query.Fields[2].AsString; |
4003 |
> |
FField.FieldName := TrimRight(Query.Fields[2].AsString); |
4004 |
|
FField.DEFAULT_VALUE := not Query.Fields[1].IsNull; |
4005 |
|
FField.COMPUTED_BLR := not Query.Fields[0].IsNull; |
4006 |
|
FField.IDENTITY_COLUMN := (Query.FieldCount > 3) and not Query.Fields[3].IsNull; |
4655 |
|
fdIsNull := True |
4656 |
|
else |
4657 |
|
begin |
4658 |
< |
Move(Buffer^, Buff[fdDataOfs],fdDataSize); |
4658 |
> |
if fdDataSize >= Field.DataSize then |
4659 |
> |
Move(Buffer^, Buff[fdDataOfs],fdDataSize) |
4660 |
> |
else |
4661 |
> |
IBError(ibxeDBBufferTooSmall,[fdDataSize,Field.FieldName,Field.DataSize]); |
4662 |
> |
|
4663 |
|
if (fdDataType = SQL_TEXT) or (fdDataType = SQL_VARYING) then |
4664 |
|
fdDataLength := StrLen(PChar(Buffer)); |
4665 |
|
fdIsNull := False; |