Skip to content

PL/Ruby 2.2.0

Choose a tag to compare

@jdatcmd jdatcmd released this 06 Jul 01:34

Native jsonb, modern Ruby, and CI. Verified on PostgreSQL 11 through 18; every push is now checked by GitHub Actions on PostgreSQL 12–18 with Ruby 3.2, 3.3, and 3.4.

All plruby changes are in the shared library — after installing the new binary, ALTER EXTENSION plruby UPDATE completes the upgrade.

Added

  • jsonb_plruby — a companion extension providing TRANSFORM FOR TYPE jsonb: opted-in functions receive jsonb arguments as native Ruby data (Hash/Array/String/Integer/Float/booleans/nil) and return Ruby data into jsonb directly. Integers beyond Float precision and BigDecimal values serialize exactly. Build it from the jsonb_plruby/ subdirectory, then CREATE EXTENSION jsonb_plruby CASCADE.
  • Structured pg_raisepg_raise(level, message, detail:, hint:, sqlstate:) maps onto the ereport fields (like PL/pgSQL's RAISE ... USING); a PL/Ruby caller that rescues the error reads them back via PLRuby::Error#detail / #hint / #sqlstate.
  • PLRuby::Error#detail / #hint — caught database errors carry their DETAIL and HINT alongside the SQLSTATE.
  • Streaming spi_query_prepared — executes a prepared plan through a cursor (block and PLRuby::Cursor forms) instead of materializing; the plan stays reusable after the cursor closes.
  • CI (GitHub Actions) — PostgreSQL 12–18 × system Ruby, plus Ruby 3.3/3.4, building both extensions and running both regression suites on every push and pull request.
  • Ruby 3.3 / 3.4 support, including alternate expected files for their changed diagnostics.
  • Regression suite grown to 37 tests plus the jsonb_plruby suite; new coverage for mid-session CREATE OR REPLACE recompilation.

Changed

  • RubyGems is enabled in the embedded interpreter (was --disable-gems): Ruby 3.4 ships csv, bigdecimal, and base64 as bundled gems that plain require cannot see without it — and gems installed alongside the server's Ruby become requirable. did_you_mean/error_highlight stay disabled so error messages are deterministic.
  • Domain arguments arrive as the base type's Ruby value (a domain over int is an Integer, over int[] an Array); previously they arrived as the text-form String.
  • Validation errors report the first line of the Ruby syntax error (Ruby 3.4's parser otherwise quotes the generated wrapper source over many lines).

Notes