Skip to content

bool_plperlu

transform between bool and plperlu

plperlu · transform between bool and plperlu

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
3271bool_plperluplperlu1.0LANGPostgreSQLC
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-rNoYesNoYesyesno
Relationships
Requiresplperlu
See Alsoplperl
Siblingsplperlu jsonb_plperlu hstore_plperlu

Packages

PG19PG18PG17PG16PG15
1.01.01.01.01.0
This contrib extension ships with PostgreSQL.

Install

Create this extension with:

CREATE EXTENSION bool_plperlu CASCADE; -- requires 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

Table reader