Skip to content

bool_plperlu

transform between bool and plperlu

Overview

PackageVersionCategoryLicenseLanguage
plperlu1.0LANGPostgreSQLC
IDExtensionBinLibLoadCreateTrustRelocSchema
3270plperluNoYesNoYesNoNopg_catalog
3271bool_plperluNoNoNoYesNoNo-
3272jsonb_plperluNoNoNoYesNoNo-
3273hstore_plperluNoNoNoYesNoNo-

Version

PG18PG17PG16PG15PG14
1.01.01.01.01.0

Install

Note: This is a built-in contrib extension of PostgreSQL

CREATE EXTENSION bool_plperlu;

Usage

bool_plperlu: Transform between bool and PL/Perl untrusted

Provides a transform for the bool type for PL/Perl Untrusted. 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_plperlu;

CREATE FUNCTION check_flag_u(val boolean) RETURNS text
LANGUAGE plperlu 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_u(true);   -- flag is set
SELECT check_flag_u(false);  -- flag is not set

Was this page helpful?