Skip to content

bool_plperl

transform between bool and plperl

plperl · transform between bool and plperl

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
3261bool_plperlplperl1.0LANGPostgreSQLC
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-dtrNoYesNoYesyesyes
Relationships
Requiresplperl
See Alsoplperlu
Siblingsplperl hstore_plperl jsonb_plperl

Packages

PG19PG18PG17PG16PG15
1.01.01.01.01.0
This contrib extension ships with PostgreSQL.

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

Table reader