schedule
schedule · Cron-formatted schedule type and UTC timestamp-matching functions for PostgreSQL.
Overview
Usage
Sources:
schedule 1.0 adds a validated cron-formatted base type and functions that test or enumerate matching timestamps. It performs schedule calculations only; it does not execute jobs. All calculations are in UTC, so it is unsuitable for a recurring local wall-clock time that must follow daylight-saving transitions.
Core Workflow
Create the extension, cast a cron expression to the custom type, and query its UTC occurrences:
The series includes matching values from the lower bound through the inclusive upper bound.
Function and Operator Index
schedule_containstests membership.schedule_nextandschedule_previousreturn strictly later or earlier matches.schedule_floorandschedule_ceilinginclude the input instant when it matches.schedule_seriesreturns matches across a bounded interval.
Assignment casts to and from text are provided. Comparison operators and a B-tree operator class compare the stored cron strings lexically, not the semantic set of matching timestamps; equivalent schedules written differently can compare unequal.
Operational Notes
The type preserves the original validated expression text. schedule_series asks the Haskell layer to build the complete timestamp array before PostgreSQL returns rows, so bound ranges and frequency to prevent excessive memory use. The source is abandoned, dates from a PostgreSQL 9.5/Nix-era build, and embeds a Haskell runtime; verify toolchain and PostgreSQL ABI compatibility before any use. Handle no-result and timestamp-range errors, and use a maintained scheduler for actual job execution.