PostgreSQL Extension
In Development
pg_kalam is a remote-only PostgreSQL foreign data wrapper extension. PostgreSQL hosts the FDW callbacks, DDL hook, and local relation surface, while KalamDB executes scans, writes, and mirrored DDL over gRPC on the shared RPC listener.
Prebuilt release assets are published on the KalamDB GitHub Releases page for the current Linux x86_64 PostgreSQL extension target. Other platforms or PostgreSQL majors can still be built from source with pgrx.
KalamDB also publishes a ready-to-run Docker image with PostgreSQL and pg_kalam preinstalled at jamals86/pg-kalam on Docker Hub .
This chapter documents the current supported remote-mode surface. The codebase no longer contains an embedded-mode PostgreSQL runtime.
Keep these rules in mind from the start:
- Point
CREATE SERVER ... OPTIONS (host, port)at KalamDB’s RPC listener, not the HTTP API port. - Add
shared_preload_libraries = 'pg_kalam'and restart PostgreSQL if you wantCREATE TABLE ... USING kalamdband the DDL mirroring hook to work. CREATE TABLE ... USING kalamdbandkalam_exec(...)currently assume a default foreign server namedkalam_server.- Use
CREATE FOREIGN TABLE ... SERVER <name>when you need a non-default server or you want to mirror a relation explicitly.
What You Can Do Today
- Install the extension into PostgreSQL 13 through 18, with
pg16as the default build target. - Create remote server definitions with host, port, optional auth header, timeout, and TLS material.
- Define KalamDB tables from PostgreSQL with
CREATE TABLE ... USING kalamdb. - Expose relations explicitly with
CREATE FOREIGN TABLE ... SERVER ...when you need a non-default server name. - Run
SELECT,INSERT,UPDATE, andDELETEthrough FDW callbacks. - Use top-level
BEGIN,COMMIT, andROLLBACKblocks for explicit transactions on shared and user tables. - Observe bridge sessions and explicit transactions with
system.sessionsandsystem.transactions. - Use
kalam_exec(...)for direct remote SQL when you want to bypass the relation wrapper. - Work with
FILEcolumns asJSONBFileRefpayloads on the PostgreSQL side.
Current Capability Map
| Area | Status | Notes |
|---|---|---|
| Remote bridge | Available | kalam_compiled_mode() returns remote |
CREATE TABLE ... USING kalamdb | Available with limits | Requires shared_preload_libraries = 'pg_kalam' and the default server kalam_server |
CREATE FOREIGN TABLE ... SERVER ... | Available | Use this path for non-default server names and explicit mirroring |
| Shared and user table DML | Available | SELECT, INSERT, UPDATE, and DELETE run through FDW callbacks |
| Stream tables | Available with limits | Stream-table DDL works; explicit transactions reject stream-table writes |
| Explicit transactions | Available with limits | Top-level BEGIN, COMMIT, and ROLLBACK; no DDL inside explicit transactions |
| Pushdown | Partial | Projection plus simple equality filters; PostgreSQL still reapplies quals locally |
| Direct statement passthrough | Available with limits | kalam_exec(...) uses the default server and is revoked from PUBLIC |
| Helper SQL functions | Available | kalam_version, kalam_compiled_mode, kalam_user_id, kalam_user_id_guc_name, snowflake_id, kalam_exec |
IMPORT FOREIGN SCHEMA | Not available | Remote mode currently returns an unsupported error |
| Data type conversions | Mixed | See Data Type Conversions for the exact current mapping and runtime caveats |
Read This Section In Order
Recommended Workflow
Use the PostgreSQL extension when you want PostgreSQL tooling, SQL clients, or migrations to operate against KalamDB tables without switching your operators to the HTTP API or an SDK.
In most cases the flow is:
- Download the matching
pg_kalamrelease asset for your PostgreSQL major, or build it from source. - Install the extension into the exact PostgreSQL instance you will use and add it to
shared_preload_libraries. - Give KalamDB a stable RPC address and point the default
kalam_serverforeign server at that endpoint. - Define tables with
CREATE TABLE ... USING kalamdb, or useCREATE FOREIGN TABLE ... SERVER ...for non-default servers. - Set
kalam.user_idin sessions that work with user-scoped tables. - Use top-level
BEGIN ... COMMITwhen you need explicit transaction batching on shared or user tables. - Use
kalam_exec(...)only when you need direct remote SQL and can satisfy its privilege model.