bool_plperl

bool_plperl

plperl : transform between bool and plperl

Overview

ID Extension Package Version Category License Language
3261
bool_plperl
plperl
1.0
LANG
PostgreSQL
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-dt-
No
Yes
No
Yes
no
yes
Relationships
Requires
plperl
See Also
plperlu
bool_plperlu
plpgsql
pg_tle
plv8
Siblings
plperl
hstore_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 bool_plperl CASCADE; -- requires plperl

Usage

bool_plperl: Transform between bool and PL/Perl

Provides a transform for the bool type for PL/Perl. When loaded, PostgreSQL boolean values are automatically converted to Perl native boolean representations and vice versa, instead of being passed as strings.

CREATE EXTENSION bool_plperl;

CREATE FUNCTION check_flag(val boolean) RETURNS text
LANGUAGE plperl TRANSFORM FOR TYPE boolean AS $$
  # val is a native Perl boolean (1 or undef), not a string
  if ($_[0]) {
    return "flag is set";
  }
  return "flag is not set";
$$;

SELECT check_flag(true);   -- flag is set
SELECT check_flag(false);  -- flag is not set
Last updated on