Skip to content

pg_fsm

Transactional state-machine guards, actions and history.

pg_extensions · Transactional state-machine guards, actions and history.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
102092pg_fsmpg_extensions0.3.0FEATMatroid-SAL-1.0Rust

PostgreSQL · 14, 15, 16, 17

Usage

Sources:

pg_fsm 0.3.0 defines finite state machines in pgfsm, with transition guards, actions, table bindings and history.

Core Workflow

CREATE EXTENSION pg_fsm;
SELECT pgfsm.create_machine('order_flow', 'draft', 'Order workflow');
SELECT pgfsm.add_state('order_flow', 'submitted');
SELECT pgfsm.add_transition('order_flow', 'draft', 'submitted', 'submit');
SELECT * FROM pgfsm.list_machines();

Operational Boundaries

The control does not require superuser-only installation, but object-creation privileges still apply. No preload is required. Define states and transitions, then bind an application state column or call the transition API. Guards/actions execute database expressions, so restrict their authors. pg_fsm.enabled disables enforcement when false; pg_fsm.disable_default_notify suppresses the implicit notification. Version 0.3.0 adds idempotent seeding with if_not_exists. This project is distinct from the extension whose canonical name is fsm. This is an unsupported proof of concept under Matroid Source Available License 1.0. APIs may change. Version 0.3.0 is the new upgrade baseline: earlier 0.2.0 installations require a rehearsed data migration/recreation, not ordinary ALTER EXTENSION UPDATE. Back up data and dependencies before following that destructive upstream path.

Table reader