plx 1.0
plx lets you write PostgreSQL stored functions and triggers in a Ruby, PHP,
JavaScript, or Python dialect. At CREATE FUNCTION time the body is transpiled
to plpgsql and stored in pg_proc.prosrc; at run time it executes on the
standard plpgsql interpreter, with no separate language runtime in the backend.
Highlights
- Dialect-pluggable front end (growing set):
plxruby,plxphp,plxjs,
plxpython3, each at full plpgsql construct parity. Language names carry a
plxprefix, so the extension coexists with native PL/Ruby and PL/PHP. - The generated plpgsql is visible in
pg_proc.prosrcand re-transpile is
idempotent (a sentinel comment records the version and embeds the original
source). plx_strbuild, an expanded-object string builder with amortized-O(1) append,
addressing plpgsql's O(n^2) in-loop string concatenation. The dialect append
operators (s << x,$s .= x,s += xon a string) lower onto it. On
PostgreSQL 18 this is about 170x faster thans := s || 'x'and faster than
the native PLs' own append; on PostgreSQL 13 to 17 it is correct but not
accelerated (the in-place path needs a PostgreSQL 18 planner feature).- Benchmarks against plpgsql, the plx dialects, PL/Perl, PL/Python3, and native
PL/Ruby and PL/PHP. Regression suite, corpus runner, and fuzzer. - Full documentation: per-dialect chapters, a plpgsql parity matrix, a user
guide, an architecture document, and a transpiler specification.
Compatibility
Tested against PostgreSQL 13, 14, 15, 16, 17, and 18. The full regression suite
passes on each.
Install
make PG_CONFIG=/path/to/pg_config
make install PG_CONFIG=/path/to/pg_config
CREATE EXTENSION plx;See the CHANGELOG
for the full list.