pg_sexp
pg_sexp · Adds a compact S-expression type with parsing, list operations, matching, containment, and hash/GIN indexing.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 101089 | pg_sexp | pg_sexp | 0.1.0 | TYPE | Apache-2.0 | C |
PostgreSQL · 14, 15, 16, 17, 18
Usage
Sources:
pg_sexp adds a compact binary sexp type for Lisp-style S-expressions. Use it when PostgreSQL must store, inspect, match, and index symbolic lists without flattening them into text.
Core Workflow
Objects and Operators
car(sexp),cdr(sexp),nth(sexp, integer),head(sexp), andsexp_length(sexp)inspect lists.sexp_typeof(sexp)and theis_list,is_atom,is_symbol,is_string,is_number, andis_nilpredicates inspect value kinds.@>performs structural containment;@>>performs key-based, order-independent containment;@~andsexp_findsupport wildcard, rest, and capture patterns.sexp_gin_opssupports GIN containment searches, while equality has hash-index support.
Compatibility and Caveats
Upstream requires PostgreSQL 14 or later. Version 0.1.0 is pre-1.0, so pin the binary format and extension version before storing durable data. Test parser canonicalization, symbol versus string and integer versus float distinctions, duplicate keys, nesting depth, wildcard complexity, and agreement between indexed and sequential results. Deeply nested or adversarial expressions and broad wildcard searches may be expensive; apply input and query limits at the application boundary.