Access Violation in TIBCQuery

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
troberts
Posts: 9
Joined: Thu 01 Mar 2012 01:51

Access Violation in TIBCQuery

Post by troberts » Thu 01 Mar 2012 02:24

I have a situation which generates an access violation in TIBCQuery under some very specific circumstances. Here is my code:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  sDBFileName: string;
begin
  sDBFileName := 'C:\Temp\TESTDB.FDB';
  qry := TIBCQuery.Create(nil);
  con := TIBCConnection.Create(nil);

  DeleteFile(sDBFileName);

  con.Database := 'localhost:' + sDBFileName;
  con.ClientLibrary := 'fbclient.dll';
  con.Username := 'SYSDBA';
  con.Password := 'masterkey';
  con.Options.Charset := 'UTF8';
  con.Options.UseUnicode := True;
  con.Options.CharLength := 1;
  con.LoginPrompt := False;

  con.Params.Clear;
  con.Params.Add('USER ''SYSDBA''');
  con.Params.Add('PASSWORD ''masterkey''');
  con.Params.Add('PAGE_SIZE 4096');
  //con.Params.Add('DEFAULT CHARACTER SET ASCII');  //this works
  //con.Params.Add('DEFAULT CHARACTER SET UTF8');   //this also works
  con.Params.Add('DEFAULT CHARACTER SET NONE');     //this doesn't work

  con.CreateDatabase;
  con.Disconnect;
  con.Connect;

  con.ExecSQL('CREATE TABLE LOG_REMOTESITE (' +
    'LOG_REMOTESITEID     BIGINT NOT NULL, ' +
    'REMOTESITEID         BIGINT NOT NULL, ' +
    'CHANGEOPERATION      CHAR NOT NULL, ' +
    'CHANGETIME           TIMESTAMP NOT NULL, ' +
    'NEW_SITECODE         VARCHAR(20) CHARACTER SET UTF8, ' +
    'OLD_SITECODE         VARCHAR(20) CHARACTER SET UTF8, ' +
    'NEW_SITEDESCRIPTION  VARCHAR(100) CHARACTER SET UTF8, ' +
    'OLD_SITEDESCRIPTION  VARCHAR(100) CHARACTER SET UTF8, ' +
    'NEW_MINNUMBER        BIGINT, ' +
    'OLD_MINNUMBER        BIGINT, ' +
    'NEW_MAXNUMBER        BIGINT, ' +
    'OLD_MAXNUMBER        BIGINT, ' +
    'NEW_DATABASEGUID     VARCHAR(31) CHARACTER SET ASCII, ' +
    'OLD_DATABASEGUID     VARCHAR(31) CHARACTER SET ASCII, ' +
    'NEW_FQDN             VARCHAR(200) CHARACTER SET UTF8, ' +
    'OLD_FQDN             VARCHAR(200) CHARACTER SET UTF8, ' +
    'NEW_IPADDRESS        VARCHAR(30) CHARACTER SET UTF8, ' +
    'OLD_IPADDRESS        VARCHAR(30) CHARACTER SET UTF8, ' +
    'NEW_COUNTRYID        BIGINT, ' +
    'OLD_COUNTRYID        BIGINT, ' +
    'NEW_TIMEZONE         NUMERIC(3,1), ' +
    'OLD_TIMEZONE         NUMERIC(3,1), ' +
    'NEW_ISACTIVE         CHAR CHECK (NEW_ISACTIVE is null or (NEW_ISACTIVE in (''F'',''T'') )), ' +
    'OLD_ISACTIVE         CHAR CHECK (OLD_ISACTIVE is null or (OLD_ISACTIVE in (''F'',''T'') ))) ', []);

  qry.Connection := con;
  qry.SQL.Add('SELECT * FROM LOG_REMOTESITE');
  qry.Open;  //AV occurs here
  qry.Close;

  qry.Free;
  con.Free;
end;
The code above will result in an access violation when the query is opened. The AV only occurs when the database is created with a character set of NONE (UTF8 and ASCII both work). The AV also only occurs with the 24 fields listed. If I delete a field or add an extra one everything works fine.

I can work around this problem by changing the character set of the database, but I am curious as to why it is occurring in the code as shown.

troberts
Posts: 9
Joined: Thu 01 Mar 2012 01:51

Post by troberts » Thu 01 Mar 2012 02:39

Sorry I forgot to mention that I am using XE2, FB 2.5 and the latest version of IBDAC (downloaded in January this year).

AndreyZ

Post by AndreyZ » Thu 01 Mar 2012 12:05

Thank you for the information. We have reproduced the problem and investigation of the problem is in progress. As soon as we have any results we will let you know.

troberts
Posts: 9
Joined: Thu 01 Mar 2012 01:51

Post by troberts » Thu 01 Mar 2012 19:58

Thanks very much Andrey.

Tim.

AndreyZ

Post by AndreyZ » Fri 02 Mar 2012 07:10

We have fixed the problem. This fix will be included in the next IBDAC build.

troberts
Posts: 9
Joined: Thu 01 Mar 2012 01:51

Post by troberts » Sun 04 Mar 2012 20:10

Great, thanks a lot. Do you have any idea when this will be available?

AndreyZ

Post by AndreyZ » Mon 05 Mar 2012 06:52

This fix is included in the latest IBDAC version 4.1.5 .

troberts
Posts: 9
Joined: Thu 01 Mar 2012 01:51

Post by troberts » Wed 07 Mar 2012 20:01

Thanks for your help Andrey.

Post Reply