Skip to content

db2odbc_fdw

Foreign data wrapper for accessing IBM Db2 through an ODBC data source

db2odbc_fdw · Foreign data wrapper for accessing IBM Db2 through an ODBC data source

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100359db2odbc_fdwdb2odbc_fdw1.0FDWApache-2.0C

PostgreSQL · 12

Usage

Sources:

db2odbc_fdw is a PostgreSQL 12-era read wrapper for DB2 through an operating-system ODBC data source. A foreign table maps to a user-supplied remote sql_query; server options include the ODBC dsn and an optional cached-connection setting.

CREATE EXTENSION db2odbc_fdw;
CREATE SERVER db2_server
  FOREIGN DATA WRAPPER db2odbc_fdw OPTIONS (dsn 'REPORTING');
CREATE USER MAPPING FOR report_role SERVER db2_server
  OPTIONS (username 'reporter', password 'secret');
CREATE FOREIGN TABLE db2_customer (id integer, name text)
  SERVER db2_server OPTIONS (sql_query 'SELECT ID, NAME FROM CUSTOMER');

Use a real secret workflow rather than keeping the example password in SQL, restrict access to user mappings and ODBC configuration, and never grant the FDW or server to PUBLIC. The reviewed C source logs the DSN, username, password, and remote query through its debug macro while opening a connection. Treat server logs as credential-bearing, suppress or patch this logging before use, and rotate any credential exposed during testing. Treat sql_query as trusted administrator input because it defines remote SQL.

Upstream points advanced users to a fuller DB2 FDW and documents PostgreSQL 12 only. Validate ODBC driver ABI, encodings, numeric and timestamp conversion, nulls, remote errors, connection retry/caching, cancellation, timeouts, credential rotation, transaction boundaries, and predicate behavior. Assume no write or distributed-transaction semantics unless the exact code and tests demonstrate them.

Table reader