Firebird Foreign Data Wrapper for PostgreSQL
This is an experimental foreign data wrapper (FDW) to connect PostgreSQL
to Firebird. It provides basic functionality, including both read (SELECT)
and write (INSERT/UPDATE/DELETE) support. However it is still very much
work-in-progress; use at your own risk.
firebird_fdw will work with PostgreSQL 9.3 or later (it was developed
against the current development version) and in its current form will not
work with pre-9.3 versions (although it should be simple enough to add
It was written for Firebird 2.5 and may work with earlier versions.
firebird_fdw was developed on Linux and OS X, and should run on any
reasonably POSIX-compliant system.
- Firebird client library (libfbclient) and API header file (ibase.h)
- libfq, a slightly saner API wrapper for the Firebird C API; see:
The Firebird include/library files often end up in non-standard locations;
PG_CPPFLAGS and SHLIB_LINK can be used to provide the appropriate flags.
For OS X they would look something like this:
export PG_CPPFLAGS="-I /Library/Frameworks/Firebird.framework/Versions/A/Headers/"
firebird_fdw is installed as a PostgreSQL extension; it requires the
pg_config binary for the target installation to be in the shell path.
The usual 'make && make install' should take care of the actual compilation.
**NOTE: these options are provisional and may change**
firebird_fdw accepts the following options:
The Firebird server's address (default: localhost)
The database to connect to
The username to connect as (not case-sensitive)
The user's password (note that Firebird only recognizes
the first 8 digits of a password)
The Firebird table name (not case-sensitive).
Cannot be used together with the 'query' option.
A Firebird SQL statement producing a result set which can be
treated like a table. Cannot be used together with the 'table'
Note that while a Firebird foreign table can be defined without any
columns, an error will be raised as soon as any operations are carried
out on it.
Install the extension:
CREATE EXTENSION firebird_fdw;
CREATE FOREIGN DATA WRAPPER firebird
Create a foreign server with appropriate configuration:
CREATE SERVER firebird_server
FOREIGN DATA WRAPPER firebird
Create an appropriate user mapping:
CREATE USER MAPPING FOR CURRENT_USER SERVER firebird_server
OPTIONS(username 'sysdba', password 'masterke');
Create a foreign table referencing the Firebird table 'fdw_test':
CREATE FOREIGN TABLE fb_test(
Create a foreign table as a Firebird query:
CREATE FOREIGN TABLE fb_test(
query 'SELECT id, val FROM fdw_test'
Many; among the more egregious:
- No Firebird transaction support
- No explicit character set/encoding support
- No support for some Firebird datatypes (BLOB, ARRAY)
- TIMESTAMP/TIME: currently sub-second units will be truncated
- No column aliases possible (column names defined in CREATE FOREIGN TABLE
must exactly match the Firebird column names)
- No pushdowns
- No connection caching
* Other FDWs