jsonb_plruby
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
plruby | 1.0 | LANG | MIT | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 3160 | plruby | No | Yes | No | Yes | No | No | pg_catalog |
| 3161 | jsonb_plruby | No | Yes | No | Yes | No | Yes | - |
| 3162 | hstore_plruby | No | Yes | No | Yes | No | Yes | - |
| 3163 | ltree_plruby | No | Yes | No | Yes | No | Yes | - |
| Related | plruby plruby hstore_plruby ltree_plruby jsonb_plperl jsonb_plpython3u |
|---|
Extension control default_version is 1.0; shipped in the PL/Ruby 2.5.0 package.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.0 | 1817161514 | plruby | plruby |
| RPM | PIGSTY | 2.5.0 | 1817161514 | plruby_$v | ruby-libs |
| DEB | PIGSTY | 2.5.0 | 1817161514 | postgresql-$v-plruby | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| el8.aarch64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| el9.x86_64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| el9.aarch64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| el10.x86_64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| el10.aarch64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| d12.x86_64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| d12.aarch64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| d13.x86_64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| d13.aarch64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| u22.x86_64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| u22.aarch64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| u24.x86_64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| u24.aarch64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| u26.x86_64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
| u26.aarch64 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 | PIGSTY 2.5.0 |
Build
You can build the RPM / DEB packages for plruby using pig build:
pig build pkg plruby # build RPM / DEB packages
Install
You can install plruby directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install plruby; # Install for current active PG version
pig ext install -y plruby -v 18 # PG 18
pig ext install -y plruby -v 17 # PG 17
pig ext install -y plruby -v 16 # PG 16
pig ext install -y plruby -v 15 # PG 15
pig ext install -y plruby -v 14 # PG 14
dnf install -y plruby_18 # PG 18
dnf install -y plruby_17 # PG 17
dnf install -y plruby_16 # PG 16
dnf install -y plruby_15 # PG 15
dnf install -y plruby_14 # PG 14
apt install -y postgresql-18-plruby # PG 18
apt install -y postgresql-17-plruby # PG 17
apt install -y postgresql-16-plruby # PG 16
apt install -y postgresql-15-plruby # PG 15
apt install -y postgresql-14-plruby # PG 14
Create Extension:
CREATE EXTENSION jsonb_plruby CASCADE; -- requires: plruby
Usage
Sources:
jsonb_plruby installs a PostgreSQL transform between jsonb and native Ruby values for the plruby language. A transformed jsonb argument becomes a Ruby Hash, Array, String, Integer, Float, true, false, or nil; compatible Ruby values can be returned directly as jsonb.
Install and Use the Transform
CREATE EXTENSION plruby;
CREATE EXTENSION jsonb_plruby;
CREATE FUNCTION ruby_mark_processed(jsonb)
RETURNS jsonb
LANGUAGE plruby
TRANSFORM FOR TYPE jsonb
AS $$
value = args[0]
value['processed'] = true
value
$$;
SELECT ruby_mark_processed('{"id": 42}'::jsonb);
The transform is used only by functions that declare TRANSFORM FOR TYPE jsonb. Other PL/Ruby functions keep the language’s ordinary JSONB conversion behavior.
Objects and Caveats
jsonb_to_plruby(internal)implements SQL-to-Ruby conversion.plruby_to_jsonb(internal)implements Ruby-to-SQL conversion.- The extension version is
1.0, it requiresplruby, and it is relocatable. - Ruby
Hashkeys returned to PostgreSQL must be valid JSON object keys, and numeric/special values must be representable by PostgreSQLjsonb. Test nested values and numeric limits explicitly. - PL/Ruby remains untrusted. Installing this transform does not sandbox Ruby code or reduce the privileges required to create PL/Ruby functions.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.