firebird_fdw
Firebird外部数据源包装器
仓库
ibarwick/firebird_fdw
https://github.com/ibarwick/firebird_fdw
源码
firebird_fdw-1.4.1.tar.gz
firebird_fdw-1.4.1.tar.gz
概览
| 扩展包名 | 版本 | 分类 | 许可证 | 语言 |
|---|---|---|---|---|
firebird_fdw | 1.4.1 | FDW | PostgreSQL | C |
| ID | 扩展名 | Bin | Lib | Load | Create | Trust | Reloc | 模式 |
|---|---|---|---|---|---|---|---|---|
| 8750 | firebird_fdw | 否 | 是 | 否 | 是 | 否 | 是 | - |
| 相关扩展 | mysql_fdw oracle_fdw tds_fdw db2_fdw wrappers odbc_fdw jdbc_fdw postgres_fdw |
|---|
pg18 breaks
版本
| 类型 | 仓库 | 版本 | PG 大版本 | 包名 | 依赖 |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.4.1 | 1817161514 | firebird_fdw | - |
| RPM | PIGSTY | 1.4.1 | 1817161514 | firebird_fdw_$v | libfq |
| DEB | PIGSTY | 1.4.1 | 1817161514 | postgresql-$v-firebird-fdw | libfq |
构建
您可以使用 pig build 命令构建 firebird_fdw 扩展的 RPM / DEB 包:
pig build pkg firebird_fdw # 构建 RPM / DEB 包
安装
您可以直接安装 firebird_fdw 扩展包的预置二进制包,首先确保 PGDG 和 PIGSTY 仓库已经添加并启用:
pig repo add pgsql -u # 添加仓库并更新缓存
使用 pig 或者是 apt/yum/dnf 安装扩展:
pig install firebird_fdw; # 当前活跃 PG 版本安装
pig ext install -y firebird_fdw -v 18 # PG 18
pig ext install -y firebird_fdw -v 17 # PG 17
pig ext install -y firebird_fdw -v 16 # PG 16
pig ext install -y firebird_fdw -v 15 # PG 15
pig ext install -y firebird_fdw -v 14 # PG 14
dnf install -y firebird_fdw_18 # PG 18
dnf install -y firebird_fdw_17 # PG 17
dnf install -y firebird_fdw_16 # PG 16
dnf install -y firebird_fdw_15 # PG 15
dnf install -y firebird_fdw_14 # PG 14
apt install -y postgresql-18-firebird-fdw # PG 18
apt install -y postgresql-17-firebird-fdw # PG 17
apt install -y postgresql-16-firebird-fdw # PG 16
apt install -y postgresql-15-firebird-fdw # PG 15
apt install -y postgresql-14-firebird-fdw # PG 14
创建扩展:
CREATE EXTENSION firebird_fdw;
用法
创建服务器
CREATE EXTENSION firebird_fdw;
CREATE SERVER firebird_server FOREIGN DATA WRAPPER firebird_fdw
OPTIONS (address 'localhost', database '/path/to/database.fdb');
服务器选项: address(默认 localhost)、port(默认 3050)、database(必填,Firebird 数据库文件路径)、updatable(默认 true)、disable_pushdowns(禁用 WHERE 子句下推)、quote_identifiers、implicit_bool_type(启用整数到布尔值的转换)、batch_size(PostgreSQL 14+)。
创建用户映射
CREATE USER MAPPING FOR CURRENT_USER SERVER firebird_server
OPTIONS (username 'sysdba', password 'masterke');
创建外部表
CREATE FOREIGN TABLE fb_test (
id smallint,
val varchar(2048)
)
SERVER firebird_server
OPTIONS (table_name 'fdw_test');
列名映射:
CREATE FOREIGN TABLE fb_mapped (
id smallint OPTIONS (column_name 'test_id'),
val varchar(2048) OPTIONS (column_name 'test_val')
)
SERVER firebird_server
OPTIONS (table_name 'fdw_test');
自定义查询(只读):
CREATE FOREIGN TABLE fb_query (
id smallint,
val varchar(2048)
)
SERVER firebird_server
OPTIONS (query $$ SELECT id, val FROM fdw_test WHERE id > 10 $$);
表选项: table_name、query(与 table_name 互斥,只读)、updatable、estimated_row_count、quote_identifier、batch_size。
列选项: column_name、quote_identifier、implicit_bool_type。
导入外部模式
IMPORT FOREIGN SCHEMA someschema
FROM SERVER firebird_server
INTO public
OPTIONS (import_views 'true', verbose 'true');
导入选项: import_not_null(默认 true)、import_views(默认 true)、updatable、verbose。
schema 参数在 Firebird 中没有特殊含义,可以设置为任意值。
CRUD 操作
SELECT * FROM fb_test WHERE id > 5;
INSERT INTO fb_test VALUES (10, 'new record');
UPDATE fb_test SET val = 'updated' WHERE id = 10;
DELETE FROM fb_test WHERE id = 10;