Sign in Join
Wiki copytemporary

Database bug reporting

Sorts of bugs

Bugs regarding databases can lie in three areas:

Lazarus builds on the FPC code, which builds on the infrastructure, so problems that show up in Lazarus GUI programs can be caused by bugs from any category.

Reporting bugs

When reporting bugs, it is very useful (and often essential) to have a compilable test program that shows the problem. See Tips on writing bug reports for reasons why.

In case of database bugs, that means that you need to show how to create a database as well so others can repeat the test.

To make this easier, you can write your bug report for common test/demonstration databases such as:

If you don't, please add the DDL (the schema definition) and sample data SQL INSERT statements (or code that performs this).

Bug reporting template

It's annoying to have to write long test programs when you just want to report a bug. However, it's also annoying and time-consuming for developers to have to write a program just to test if behaviour is incorrect.

A possible solution: use a template program and adapt that to your bug.

Lazarus

For Lazarus, you can use one of the demo database applications in your examples directory (e.g. examples\database\sqldbtutorial3) and adapt that. Don't forget to specify how to create the required database (include the needed CREATE TABLE etc SQL) - or specify a well-known sample database as mentioned above.

Free Pascal

A template program can be found below. Please adjust where marked. Once you've tested the program in your own environment, don't forget to remove confidential passwords etc.

pascal
program dberror;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes, sysutils,
  sqldb,
  ibconnection {*REPLACE WITH RELEVANT CONNECTION LIBRARY*};

{
* ADD THE SQL NEEDED TO CREATE THE DATABASE HERE *
also known as the DDL/schema for the database.
For Firebird you can just say to use the Employee sample database.
For MSSQL you can just say to use the Adventureworks sample database.
}

var
  Conn: TibConnection; {*REPLACE WITH RELEVANT CONNECTION *}
  Tran: TSQLTransaction;
  Q: TSQLQuery;
begin
  Conn:=TIBConnection.create(nil); {*REPLACE WITH RELEVANT CONNECTION *}
  Tran:=TSQLTransaction.create(nil);
  Q:=TSQLQuery.Create(nil);
  try
    // *REMOVE IDENTIFYING INFO AND EDIT AS NEEDED*
    Conn.HostName:='127.0.0.1';
    Conn.UserName:='SYSDBA';
    Conn.Password:='masterkey';
    Conn.DatabaseName:='employee';
    // *END IDENTIFIYING INFO*
    Conn.Transaction:=Tran;
    Q.DataBase:=Conn;
    Conn.Open;
    // *EXAMPLE BUG TESTING CODE, REPLACE WITH YOUR OWN*
    Q.SQL.Text:='select now() as RightNow ';
    Q.Open;
    Q.Last; //force recordcount update
    writeln('recordcount: '+inttostr(q.RecordCount));
    Q.Close;
    // *END EXAMPLE BUG TESTING CODE*
    Conn.Close;
  finally
    Q.Free;
    Tran.Free;
    Conn.Free;
  end;
  writeln('Program complete. Press a key to continue.');
  readln;
end.

Of course, if you don't want to use this template but want to directly write a test case for the db test framework, that's very welcome.

See also


From the Free Pascal wiki, page "Database bug reporting", as it stood on 2020-09-16 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 3, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.