hstore_plperl

hstore_plperl

plperl : transform between hstore and plperl

Overview

ID Extension Package Version Category License Language
3262
hstore_plperl
plperl
1.0
LANG
PostgreSQL
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d--
No
Yes
No
Yes
no
no
Relationships
Requires
hstore
plperl
See Also
hstore_pllua
hstore_plluau
hstore_plperlu
hstore_plpython3u
hstore
plperlu
plpgsql
Siblings
plperl
bool_plperl
jsonb_plperl

Packages

PG18 PG17 PG16 PG15 PG14
1.0
1.0
1.0
1.0
1.0

This is a built-in contrib extension ship with the PostgreSQL kernel

Install

Create this extension with:

CREATE EXTENSION hstore_plperl CASCADE; -- requires hstore, plperl

Usage

hstore_plperl: Transform between hstore and PL/Perl

Provides a transform for the hstore type for PL/Perl. When loaded, hstore values are automatically converted to Perl hashes and vice versa.

CREATE EXTENSION hstore_plperl;

CREATE FUNCTION hstore_to_text(val hstore) RETURNS text
LANGUAGE plperl TRANSFORM FOR TYPE hstore AS $$
  # val is now a Perl hash reference
  my $result = '';
  for my $key (sort keys %$val) {
    $result .= "$key => $val->{$key}\n";
  }
  return $result;
$$;

CREATE FUNCTION make_hstore(key text, value text) RETURNS hstore
LANGUAGE plperl TRANSFORM FOR TYPE hstore AS $$
  my ($k, $v) = @_;
  return { $k => $v };
$$;

SELECT hstore_to_text('a=>1, b=>2'::hstore);
SELECT make_hstore('color', 'blue');
Last updated on