Firebird Empty Varchar fields, Range Check Errors

Hello,

DataAbstract version 10.0.0.1605
Database Firebird 3.0,
Driver IBDAC 9.3.2

When compiling the application, I include the sources of the RemObjects SDK and DataAbstract frameworks.
If I try to edit a record that has a varchar field filled with an empty string (null’s work ok)
an exception of Exception class ERangeError with message ‘Range check error’ is raised in the line

unit uDaMemDataSet;
TDADBSupport.ExtractFieldData(ldata, fOffsets[i], lSize, fDataTypeArray[i], GetStoreStringsAsReference, lbuf);

This message appears on the DEBUG profile where the $RANGECHECK compilation option is on.
On older versions of DataAbstract this does not happen.
On the RELEASE profile with $RANGECHECK OFF the exception does not appear but I do not know if other problems can occur.

In DEBUG mode I prefer to use the $RANGECHECK ON option to be able to find other problems in my code.

It’s a bit annoying when the debug version behaves differently than the release version.

Best regards,
Tiberiu Stoicescu

Hi,

Is it possible to create a simple testcase?

You can drop it to support@ for keeping privacy.

Hello,

I have attached an example of editing for WideString fields with Empty value. It is not exactly the situation encountered initially but it also manifests itself on this type of fields.

Please compile with the library sources and compilation options from RemObjects_user.inc and DataAbstract_user.inc attached.

I am using Delphi 12.2 Patch 1 and RemObjects DataAbstract 10.0.0.1605
TestEditMemDataset.zip (2.8 MB)

Logged as bugs://D19516.

bugs://D19516 was closed as fixed.

Hi,

  • update uDAMemDataset.pas as
function TDAMemoryDataset.GetNativeFieldData(Index: Integer; var Buffer: TBytes): Boolean;
..
    if IsReferencedField(fDataTypeArray[index]) then begin
      if fDataTypeArray[index] in ft_AnsiStringValues then begin
        if Length(Buffer) > lsize then
          Buffer[lsize] := 0;
      end
      else if fDataTypeArray[index] in ft_WideStringValues then begin
        if Length(Buffer) > lsize * SizeOf(UnicodeChar) then
          PUnicodeChar(@Buffer[lsize * SizeOf(UnicodeChar)])^ := #0;
      end;
    end;
  end;
end;
  • launch C:\Program Files (x86)\RemObjects Software\Build\install_DA.cmd with admin rights for rebuilding .bpl and .dcu

note: this fix will be included into .1609