Skip to content
ltree_plruby

ltree_plruby

plruby : Transform between ltree and Ruby Arrays for PL/Ruby

Overview

ID Extension Package Version Category License Language
3163
ltree_plruby
plruby
1.0
LANG
MIT
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
Requires
ltree
plruby
See Also
ltree
plruby
hstore_plruby
jsonb_plruby
Siblings
plruby
jsonb_plruby
hstore_plruby

Extension control default_version is 1.0; shipped in the PL/Ruby 2.5.0 package.

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
1.0
18
17
16
15
14
plruby ltree, plruby
RPM
PIGSTY
2.5.0
18
17
16
15
14
plruby_$v ruby-libs
DEB
PIGSTY
2.5.0
18
17
16
15
14
postgresql-$v-plruby -
Linux / 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

Source

pig build pkg plruby;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install plruby;		# install via package name, for the active PG version
pig install ltree_plruby;		# install by extension name, for the current active PG version

pig install ltree_plruby -v 18;   # install for PG 18
pig install ltree_plruby -v 17;   # install for PG 17
pig install ltree_plruby -v 16;   # install for PG 16
pig install ltree_plruby -v 15;   # install for PG 15
pig install ltree_plruby -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION ltree_plruby CASCADE; -- requires ltree, plruby

Usage

Sources:

ltree_plruby installs a PostgreSQL transform between ltree paths and Ruby arrays for the plruby language. An ltree argument becomes an array of label strings, and an array of valid labels can be returned directly as an ltree value.

Install and Use the Transform

CREATE EXTENSION ltree;
CREATE EXTENSION plruby;
CREATE EXTENSION ltree_plruby;

CREATE FUNCTION ruby_append_label(ltree, text)
RETURNS ltree
LANGUAGE plruby
TRANSFORM FOR TYPE ltree
AS $$
  path = args[0]
  path << args[1]
  path
$$;

SELECT ruby_append_label('Top.Science'::ltree, 'Astronomy');

The transform is used only by functions that declare TRANSFORM FOR TYPE ltree.

Objects and Caveats

  • ltree_to_plruby(internal) implements SQL-to-Ruby conversion.
  • plruby_to_ltree(internal) implements Ruby-to-SQL conversion.
  • The extension version is 1.0, it requires both ltree and plruby, and it is relocatable.
  • Every returned array element must be a valid ltree label. PostgreSQL rejects invalid characters, empty labels, or paths that exceed ltree limits.
  • PL/Ruby remains untrusted. Installing this transform does not sandbox Ruby code or reduce the privileges required to create PL/Ruby functions.
Last updated on