plhaskell
plhaskell · provide trusted and untrusted Haskell procedural languages for PostgreSQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 101217 | plhaskell | plhaskell | 6.0 | LANG | GPL-3.0-or-later | C |
Usage
Sources:
- Project README
- Extension control file
- Version 6.0 SQL language definitions
- Usage and query API
- Trust model
- Known bugs
plhaskell 6.0 embeds Haskell as a PostgreSQL procedural language. Installation creates trusted plhaskell for typed PGm actions and untrusted plhaskellu for IO; only superusers may create functions in the untrusted variant. The database encoding must be UTF-8.
Define a trusted function
The extension also supports composites, arrays, timestamps, advisory locks, parameterized SPI queries, sets, and anonymous blocks. Function volatility controls whether internal queries are read-only; still review every SQL query and imported module.
Runtime and trust boundary
The trusted-language claim relies on the extension’s Haskell type and module restrictions. It also invokes the GHC API and dynamically loaded Haskell runtime inside PostgreSQL backends, so granting ordinary roles permission to create functions materially expands the database execution surface. Independently review the trusted module set, package database, filesystem and SELinux policy, statement timeouts, role privileges, and denial-of-service behavior. Reserve plhaskellu for tightly controlled superuser code.
The default Haskell runtime memory limit is 128 MB; plhaskell.max_memory = 0 disables it and is unsafe for multi-tenant use. Upstream documents failures with some lc_messages values, severe slowdown when a set-returning function is called multiple times, and platform runpath issues. Builds are intended for Linux and tested only on x86-64. Pin matching PostgreSQL, GHC, hint, and runtime libraries, then test backend crashes, errors, upgrades, replication, and dump and restore before production deployment.
Range Types in 6.0
Version 6.0 adds Range a and MultiRange a, with EmptyRange, BoundRange and bound constructors exposed through PGutils. contains and containsMulti test membership; query parameters and results also support ranges and multiranges. No 5.0-to-6.0 SQL upgrade script is shipped in this release; plan preservation of dependent functions before changing an existing installation.