clerk_fdw
clerk_fdw · Foreign data wrapper for querying the Clerk user-management API from PostgreSQL.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100709 | clerk_fdw | clerk_fdw | 0.3.3 | FDW | PostgreSQL | Rust |
PostgreSQL · 14, 15, 16, 17
Usage
Sources:
clerk_fdw is a read-only foreign data wrapper for the Clerk user-management API. It exposes users, organizations, and organization memberships as foreign tables; rows are fetched from Clerk when a scan runs rather than stored in PostgreSQL.
Core Workflow
Version 0.3.3 installs the handler and validator functions. Define the wrapper, a server containing the Clerk secret key, and one or more foreign tables:
If api_key is absent, the implementation reads CLERK_API_KEY from the PostgreSQL server process environment. Protect the foreign server definition and catalog access because server options can contain credentials.
Supported Foreign Objects
object 'users': user identifiers, names, primary email, timestamps, username, and the complete response inattrs.object 'organizations': organization identifier, name, slug, timestamps, creator, andattrs.object 'organization_memberships':user_id,organization_id, androle.
Column names and types must match the mappings implemented by the FDW. Include an attrs jsonb column when the unflattened API object is needed.
Query and Performance Boundaries
The FDW ignores PostgreSQL quals, sort keys, and limits during the remote fetch. A predicate such as WHERE organization_id = 'org_123' is evaluated after the scan, not pushed down to Clerk.
Membership scans first enumerate every organization and then request its memberships. The implementation retries rate-limited membership calls with exponential backoff and can take a long time; materialize results into a local table for repeated analytics. The implementation exposes scan callbacks only, so do not expect INSERT, UPDATE, or DELETE support.
Version 0.3.3 is built for PostgreSQL 14–17, is non-relocatable, and requires superuser privileges to create. It does not require shared_preload_libraries.