Batch Updates issue

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
FredS
Posts: 272
Joined: Mon 10 Nov 2014 17:52

Batch Updates issue

Post by FredS » Sun 20 Sep 2015 23:40

On FB3 (SQLServer works fine) and only in Win64 I get:
Project Project1.exe raised exception class $C0000005 with message 'c0000005 ACCESS_VIOLATION'.

To reproduce you need to call "qu.Execute(RecCount, 0);" at least twice..

Code: Select all

program Project1;

{$APPTYPE CONSOLE}
{$R *.res}

uses
  System.SysUtils, db, Uni, InterBaseUniProvider;

const
  BulkRecords = 2;
var
  Con: TUniConnection;
  qu: TUniQuery;
  FolderID, i, x, RecCount: integer;
begin
  try
    Con := TUniConnection.Create(nil, 'Provider Name=InterBase;Database=..\db\PA.FDB;Port=0;User ID=SYSDBA;Password=masterkey;');
    try
      Con.SpecificOptions.Values['InterBase.ClientLibrary'] := '..\Firebird\fb3_(64)\fbclient.dll';
      Con.SpecificOptions.Values['InterBase.Charset'] := 'UTF8';
      Con.SpecificOptions.Values['InterBase.UseUnicode'] := 'True';
      Con.SpecificOptions.Values['InterBase.Role'] := 'RDB$ADMIN';
      Con.Connect;
      qu := TUniQuery.Create(nil);
      try
        qu.Connection := Con;
        qu.SQL.Text := 'Select First 1 ID from SHAREFOLDERS';
        qu.Open;
        FolderID := qu.Fields[0].AsInteger;
        qu.Close;
        qu.SQL.Text := 'Delete from FOLDERACCESSLIST where USERGROUPSID Like ''S-x-1-0-%'' ';
        qu.ExecSQL;
        qu.SQL.Text := 'INSERT INTO FOLDERACCESSLIST values (:FOLDERID, :USERGROUPSID, :ACCESS, :ACEFLAGS, :MASK)';
        qu.Params[0].DataType := ftLargeint; {FOLDERID}
        qu.Params[1].DataType := ftWideString; {USERGROUPSID}
        qu.Params[2].DataType := ftWideString; {ACCESS}
        qu.Params[3].DataType := ftLargeint; {ACEFLAGS}
        qu.Params[4].DataType := ftLargeint; {MASK}
        qu.Params.ValueCount := BulkRecords; {specify the array dimension}

        RecCount := 0;
        for x := 0 to 1 do begin // Will fire Execute twice
          for i := 0 to 1 do begin // add two recs
            qu.Params[0][RecCount].asLargeInt := FolderID; {FOLDERID}
            qu.Params[1][RecCount].AsString := 'S-x-1-0-' + i.ToString + x.ToString; {USERGROUPSID}
            qu.Params[2][RecCount].AsString := 'A'; {ACCESS}
            qu.Params[3][RecCount].asLargeInt := i; {ACEFLAGS}
            qu.Params[4][RecCount].asLargeInt := x; {MASK}
            Inc(RecCount);
          end;
          if RecCount = BulkRecords then begin // Just in case
            qu.Execute(RecCount, 0);
            RecCount := 0;
          end;
        end;
    finally
      qu.Free;
    end;
  finally
    Con.Free;
  end;

except
  on E: Exception do Writeln(E.ClassName, ': ', E.Message);
end;

end.

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Batch Updates issue

Post by ViktorV » Tue 22 Sep 2015 06:12

Thank you for the information. We have reproduced the problem. We are investigating this behavior of UniDAC, and we will inform you about the results.

Post Reply