rep_fdw
rep_fdw · Replicate table changes to another PostgreSQL server through postgres_fdw
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100378 | rep_fdw | rep_fdw | 0.1.0 | ETL | PostgreSQL | SQL |
| Relationships | |
|---|---|
| Requires | plpgsql postgres_fdw |
Usage
Sources:
rep_fdw version 0.1.0 is an experimental trigger-based row copier built on postgres_fdw. It synchronously mirrors INSERT, UPDATE, and DELETE operations to a generated foreign table, but it has no durable queue, conflict protocol, schema synchronization, or robust SQL quoting and should not be used as a production replication system.
Core Workflow
The extension creates objects in the rep_fdw schema and requires postgres_fdw:
create_f_table(text, text, text) introspects a local table and creates a foreign table named with the f_ prefix. generar_trigger(text) installs an AFTER-row trigger whose tr_ftable() handler writes the old or new row to the remote table during local DML.
Correctness and Security Boundary
create_usermap(text, text, text) creates a user mapping for PUBLIC and places the supplied password in PostgreSQL catalog options. This is much broader than a per-role mapping; restrict catalog visibility, ownership, and function execution, and prefer manually managed least-privilege mappings.
The trigger constructs identifiers, values, and predicates through string concatenation. Quotes, NULL values, unusual types, or hostile input can break statements or alter their meaning. UPDATE and DELETE match all old column values rather than a declared primary key, so duplicates and concurrent changes are ambiguous.
Remote writes are synchronous: an FDW error can abort local DML, while network partitions and transaction recovery still require explicit testing. Use rep_fdw only with disposable data to study the approach. Use maintained logical replication or a queue-based design when correctness, replay, monitoring, or recovery matters.