ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/runtime/nongui/IBCustomDataSet.pas
(Generate patch)

Comparing ibx/trunk/runtime/nongui/IBCustomDataSet.pas (file contents):
Revision 310 by tony, Sat Jul 18 10:26:30 2020 UTC vs.
Revision 311 by tony, Mon Aug 24 09:32:58 2020 UTC

# Line 1314 | Line 1314 | begin
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;
# Line 1357 | Line 1357 | var
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
# Line 1389 | Line 1389 | var
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);
# Line 1502 | Line 1502 | end;
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  
# Line 3643 | Line 3643 | begin
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;
# Line 3652 | Line 3652 | begin
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;
# Line 3823 | Line 3826 | var
3826    Buff: PChar;
3827    CurRec: Integer;
3828    pda: PArrayDataArray;
3829 +  pbd: PBlobDataArray;
3830    i: integer;
3831   begin
3832    inherited InternalCancel;
# Line 3830 | Line 3834 | begin
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);
# Line 3915 | Line 3922 | end;
3922   procedure TIBCustomDataSet.InternalFirst;
3923   begin
3924    FCurrentRecord := -1;
3925 +  if Unidirectional then GetNextRecord;
3926   end;
3927  
3928   procedure TIBCustomDataSet.InternalGotoBookmark(Bookmark: Pointer);
# Line 3940 | Line 3948 | begin
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, Trim(R.RDB$FIELD_NAME) as 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}
# Line 3948 | Line 3956 | const
3956                 '     (not F.RDB$DEFAULT_VALUE is NULL)) '; {do not localize}
3957  
3958    DefaultSQLODS12 = 'Select F.RDB$COMPUTED_BLR, ' + {do not localize}
3959 <               'F.RDB$DEFAULT_VALUE, R.RDB$FIELD_NAME, R.RDB$IDENTITY_TYPE ' + {do not localize}
3959 >               'F.RDB$DEFAULT_VALUE, Trim(R.RDB$FIELD_NAME) as RDB$FIELD_NAME, R.RDB$IDENTITY_TYPE ' + {do not localize}
3960                 'from RDB$RELATION_FIELDS R, RDB$FIELDS F ' + {do not localize}
3961                 'where R.RDB$RELATION_NAME = :RELATION ' +  {do not localize}
3962                 'and R.RDB$FIELD_SOURCE = F.RDB$FIELD_NAME '+ {do not localize}
# Line 4647 | Line 4655 | begin
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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines