ocgeo_fdw
ocgeo_fdw · Foreign data wrapper for the OpenCageData API
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100370 | ocgeo_fdw | ocgeo_fdw | 1.0 | FDW | PostgreSQL | C |
PostgreSQL · 10, 11, 12, 13, 14
Usage
Sources:
- Pinned upstream README
- Version 1.0 installation SQL
- Pinned FDW implementation
- Pinned API client implementation
ocgeo_fdw version 1.0 maps OpenCage’s JSON geocoding API to a read-only foreign table. An equality condition on the q input column performs forward or reverse geocoding; a minimum confidence condition can be sent as an API parameter. Returned fields can include the raw JSON, PostgreSQL point and box values, formatted address, confidence, and address components.
Server, mapping, and query
Without a usable q equality restriction, a simple scan makes no API request. A nested-loop join can make one request per outer row.
Network, quota, and observability limits
Every API request is synchronous inside the PostgreSQL backend and can hold a transaction, connection, and locks while DNS, TLS, rate-limit sleep, and remote execution complete. The built-in limiter controls requests per second only within one backend. It does not enforce daily quota globally across sessions. Joins and rescans can multiply calls, so materialize or cache stable results.
The API key is stored in a user mapping. Debug output can include the full request URL; the README explicitly shows enabling client debug to view it, so do not enable that logging where the key could enter client or server logs. Restrict server usage, apply outbound allowlists, use a low-privilege key, set statement timeouts, and monitor the provider’s authoritative quota counters.
The ocgeo_stats function reports process-local in-memory counters, can include entries for roles used by that backend, and is incorrectly declared IMMUTABLE even though the values change after requests. Do not use it as an audit or billing source. The reviewed source documents only PostgreSQL 9.6 through 14 and has not changed since 2021; libcurl, planner APIs, JSON parsing, TLS policy, provider response fields, and current server majors all require fresh integration tests.