FirebirdSQL logo
 Connecting to Firebird from ApplicationsFirebird Events 

The Firebird ODBC driver supports multiple simultaneous connections to different databases and different servers, each connection operating independently of any others.

Multithreading

Thread protection can be specified at two levels:

  1. sharing an environment handle

  2. sharing a connection handle

By default, the driver is built using the following define:

#define DRIVER_LOCKED_LEVEL     DRIVER_LOCKED_LEVEL_CONNECT

which enables a single connection to share multiple local threads.

The default setting is reflected in the initial setup of the DSN on Windows: SAFETHREAD=Y.

If the driver is built using the following define:

#define DRIVER_LOCKED_LEVEL     DRIVER_LOCKED_LEVEL_NONE

then the driver is built without multi-threading support and responsibility for threading control is transferred to the Firebird client library.This provides for fastest performance.

If you have a build that was made with this define, you should make it the default thread behaviour for the DSN by configuring SAFETHREAD=N in its interface.

If the driver is built using the following define:

#define DRIVER_LOCKED_LEVEL     DRIVER_LOCKED_LEVEL_ENV

then a single environment handle can be shared by multiple local threads.

Note

You may save a specific set of connection conditions or overrides in a FILEDSN.

Transactions

Firebird supports three transaction isolation levels:

  • READ COMMITTED

  • SNAPSHOT (“concurrency” or “repeatable read”)

  • SNAPSHOT TABLE STABILITY “consistency”)

The default isolation level of the ODBC/JDBC driver is READ COMMITTED, which maps with read committed in other database systems.Firebird’s other isolation levels do not map so easily.In the ODBC/JDBC driver, SNAPSHOT maps to REPEATABLE READ and SNAPSHOT TABLE STABILITY maps to SERIALIZABLE, with some tweaks.

Since version 2.0, the driver has been able to support every transaction configuration that Firebird can support, including table reservation (“table blocking”).That was achieved by incorporating the so-called “EmbeddedSQL” syntax that is native to the old pre-compiler, gpre, to prepare calls to the ODBC API by the function SQLExecDirect.

Locking

Firebird implements optimistic row-level locking under all conditions.A transaction does not attempt to lock a record until it is ready to post an update operation affecting that record.It can happen, though rarely, for an update to fail because another client has a lock on the record, even if the transaction that fails started before the one which secured the lock.

Firebird’s record versioning engine is able to achieve a granularity finer than that provided by traditional row-level locking.Versioning allows any number of transactions to read a consistent copy of any given record, even if other transactions are updating the same row simultaneously.Readers and writers never block one another and Firebird’s maintenance of record versions is totally transparent to the user.