Skip to content

acdat SQL reference

Complete SQL API lookup for acdat v0.1.1. All types, functions, and catalog tables live in the fixed acdat schema; always pair text or bytea inputs with a matching machine.

Compile a dictionary

acdat.compile(patterns text[], pattern_ids bigint[], replacements text[], priorities integer[], options jsonb) , acdat.machine , defaultNULL, NULL, NULL, '{}'¹
Compile parallel 1D text arrays into a machine. Omitted IDs default to 1..N; NULL priorities default to 0.
acdat.compile(patterns bytea[], pattern_ids bigint[], replacements bytea[], priorities integer[], options jsonb) , acdat.machine , defaultNULL, NULL, NULL, '{}'¹
Binary array overload preserving arbitrary bytes (including \x00).
acdat.compile(text, bigint) , aggregate → acdat.machine , default—
Compile rows of (pattern, pattern_id). Returns NULL for zero rows.
acdat.compile(text, bigint, text, integer) , aggregate → acdat.machine , default—
Compile rows of (pattern, pattern_id, replacement, priority). Returns NULL for zero rows.
acdat.compile(bytea, bigint) , aggregate → acdat.machine , default—
Binary aggregate over (pattern, pattern_id). Returns NULL for zero rows.
acdat.compile(bytea, bigint, bytea, integer) , aggregate → acdat.machine , default—
Binary aggregate over (pattern, pattern_id, replacement, priority). Returns NULL for zero rows.

¹ Defaults apply starting at pattern_ids; patterns is required. options accepts NULL or {}.

Scan and replace

acdat.contains(text, acdat.machine) , boolean , default—
Return true on the first literal match and stop scanning immediately.
acdat.contains(bytea, acdat.machine) , boolean , default—
Binary overload of contains.
acdat.matches(input text, machine acdat.machine, policy text, max_matches integer) , setof acdat.hit , default'all_overlapping', 10000
Return 1-based byte and character offsets for each hit. Candidate limit is checked before overlap resolution.
acdat.matches(input bytea, machine acdat.machine, policy text, max_matches integer) , setof acdat.hit , default'all_overlapping', 10000
Binary overload; start_char and char_length are always NULL.
acdat.replace(input text, machine acdat.machine, policy text, max_replacements integer, max_output_bytes bigint) , text , default'leftmost_longest', 10000, 268435456
Single non-recursive pass rewrite. Errors if a selected match has a NULL replacement or exceeds a limit.
acdat.replace(input bytea, machine acdat.machine, policy text, max_replacements integer, max_output_bytes bigint) , bytea , default'leftmost_longest', 10000, 268435456
Binary overload of replace.

Overlap policies

all_overlapping , matches , defaultdefault for matches
Emit every candidate hit, including prefixes, suffixes, and duplicate literals with distinct IDs.
leftmost_longest , matches / replace , defaultdefault for replace
Leftmost start offset → longer pattern → lower priority integer → lower pattern_id → lower canonical ordinal.
leftmost_priority , matches / replace , default—
Leftmost start offset → lower priority integer → longer pattern → lower pattern_id → lower canonical ordinal.

Inspect and transport

acdat.info(acdat.machine) , jsonb , default—
Metadata JSON: engine, compiler/format versions, input kind, encoding, pattern/state/slot counts, and sizes.
acdat.export(acdat.machine) , bytea , default—
Serialize a compiled machine into a portable binary image.
acdat.validate(bytea) , boolean , default—
Verify a serialized image without raising an error on corruption.
acdat.import(bytea) , acdat.machine , default—
Validate and decode a serialized image; raises an error if malformed.
acdat.source_fingerprint(acdat.machine) , bytea , default—
32-byte SHA-256 digest of the canonical rule set and input kind.
acdat.build_fingerprint(acdat.machine) , bytea , default—
32-byte digest identifying rules plus compiler, engine, and format version.
acdat.artifact_checksum(acdat.machine) , bytea , default—
32-byte checksum of the serialized artifact payload.

Managed dictionary catalog

acdat.publish(p_dictionary_name text, p_semantic_version bigint, p_compiled_machine acdat.machine, p_source_reference jsonb) , bytea , defaultp_source_reference = NULL
Store an immutable ready build and return its 32-byte dictionary-scoped build_id.
acdat.activate(p_dictionary_name text, p_build_id bytea) , void , default—
Atomically point acdat.active_dictionary to a ready build.
acdat.retire_build(p_dictionary_name text, p_build_id bytea) , void , default—
Mark an inactive build as retired.
acdat.active_machine , view , default—
Active ready machines: name, input_kind, version, build_id, machine, info.
acdat.dictionary , table , default—
Dictionary name and fixed input_kind (text or bytea).
acdat.dictionary_version , table , default—
Semantic version, source_fingerprint, and optional source_ref JSON.
acdat.dictionary_build , table , default—
Build metadata, compiler/format/engine info, status (ready / retired), and checksum.
acdat.dictionary_build_data , table , default—
Compiled acdat.machine payload (STORAGE EXTERNAL) keyed by build_id.
acdat.active_dictionary , table , default—
Current active build_id pointer per dictionary.

Types and internal functions

acdat.machine , base type , default—
Variable-length compiled automaton (STORAGE = external).
acdat.hit , composite type , default—
(pattern_id bigint, start_byte integer, byte_length integer, start_char integer, char_length integer, priority integer).
machine_in / machine_out / machine_recv / machine_send , internal I/O , default—
Type I/O functions revoked from PUBLIC; invoked by PostgreSQL.
_compile_*_trans / _compile_final / _catalog_build_id , internal helpers , default—
Aggregate state transition/final and catalog digest helpers revoked from PUBLIC.