# firebird driver manual

## Preface

libdbi is a database abstraction layer written in C. It implements a framework that can utilize separate driver libraries for specific database servers. The libdbi-drivers project provides the drivers necessary to talk to the supported database servers.

This manual provides information about the Firebird/Interbase driver. The manual is intended for programmers who write applications linked against libdbi and who want their applications to work with Firebird or Interbase database engines.

Questions and comments about the Firebird/Interbase driver should be sent to the libdbi-drivers-devel mailing list. Visit the libdbi-drivers-devel list page to subscribe and for further information. Questions and comments about the libdbi library should be sent to the appropriate libdbi mailing list.

The Firebird/Interbase driver was developed by Christian Stamgren.

## Introduction

Firebird is the free cousin of the InterBase SQL database engine, which has a long and winding history related to the repeated reinventions of the Borland, then Inprise, then Borland/Inprise, then again Borland company. Although the internal name of the driver is "firebird", it is supposed to work with the InterBase products as well.

## Installation

This chapter describes the prerequisites and the procedures to build and install the firebird driver from the sources.

### Prerequisites

The following packages have to be installed on your system:

libdbi

- This library provides the framework of the database abstraction layer which can utilize the firebird driver to perform database operations. The download page as well as the mailing lists with bug reports and patches are accessible at sourceforge.net/projects/libdbi. The current version of the firebird driver requires libdbi version 0.8.x.

libfbembed

- This library implements the client API for Firebird/InterBase databases which provides access both locally and through the network. Find the most recent release at www.firebirdsql.org. The current version of the firebird driver was tested with Firebird versions 1.5.3 and 2.0.3 and should work with all recent releases.

### Build and install the firebird driver

First you have to unpack the libdbi-drivers archive in a suitable directory. Unpacking will create a new subdirectory `libdbi-drivers-X.Y` where "X.Y" denotes the version:

    $ tar -xzf libdbi-drivers-X.Y.tar.gz

The libdbi-drivers project consists of several drivers that use a common build system. Therefore you must tell configure explicitly that you want to build the firebird driver (you can list as many drivers as you want to build):

    $ cd libdbi-drivers

    $ ./configure --with-firebird

Run `./configure --help` to find out about additional options.

Then build the driver with the command:

    $ make

If the command results in error messages about the Makefile syntax, you may have to explicitly invoke `gmake`, the GNU version of make, on your system.

Then install the driver with the command (you'll need root permissions to do this):

    $ make install

To test the operation of the newly installed driver, use the command:

    $ make check

This command creates and runs a test program that performs a few basic input and output tests. The program will ask for an administrator username and password. Default Firebird installations usually call the database superuser "sysdba" so this user is always a good start. Be sure to provide the name of a database which does not already exist (avoid 'test' which is used on many systems). To keep file permission problems out of this test (more on this below), you may prefer to keep the hostname empty and to specify a directory with write access.

If for some reason you need to re-create the autoconf/automake-related files, try running `./autogen.sh`.

## Driver options

Your application has to initialize libdbi drivers by setting some driver options with the `dbi_conn_set_option()` and the `dbi_conn_set_option_numeric()` library functions. The firebird driver supports the following general options:

host

- The hostname or IP address of the Firebird database server. Use "localhost" or the real hostname of your local computer to connect to a Firebird server running on the local machine through the network (this is the only way to connect to a local super-server). Do not set the host option if you want to work with a local database, without going through a server.

username

- The name of the user accessing the database.

password

- The password of the user accessing the database.

dbname

- The name of the database used for the initial connection. If your program must be able to connect to a fresh Firebird installation, use the test database `libdbitest` created by `make check`.

encoding

- The IANA name of a character encoding which is to be used as the connection encoding. Input and output data will be silently converted from and to this character encoding, respectively. If you set this option to "auto", the connection encoding will be the same as the default encoding of the database.

In addition, the following firebird-specific options are supported:

firebird_dbdir

- This is the directory that holds the Firebird database files. Depending on the settings of the `host` option, this may refer to a directory on a local or on a remote machine. The ownership and the permissions must match the mode of access. If you create or access a file locally (i.e. with `host` not set), the account you're logged in needs write and execute permissions. If you set the `host`, the account your server runs in must have write and execute permissions. This is true even if you connect to your own machine via localhost. Default server installations use the "firebird" account. The database directory should then be owned by firebird:firebird with write and execute permissions for both the user and the group. It should then be sufficient to add yourself to the firebird group to gain access to the database directory.

  If this option is not specified, a compile-time default directory will be used. Needless to say, this is going to work only if you work on localhost. By default, this directory (usually `/usr/local/var/lib/libdbi/firebird`) has read and write permissions for everyone with the sticky bit set. If this is not suitable for your application, use a custom directory with your preferred permissions instead.

## Peculiarities you should know about

This chapter lists known peculiarities of the firebird driver. This includes Firebird features that differ from what you know from the other database servers supported by libdbi, and it includes features and misfeatures introduced by the firebird driver. It is the intention of the libdbi developers to reduce the number of misfeatures in future releases if possible.

### Firebird (mis)features

- To determine the number of matches, all results have to be retrieved first. This is very inefficient and may provide a bottleneck for large applications.

- DATETIME and TIME do not appear to support timezones

- char, unsigned char, long long, and unsigned long long types are not supported.

&freedoc-license;