Repository navigation
SQL API, security and performance release. Choose which relations and function families a database installs, and filter your own queries by access with inlinable accessible_* functions and parent-key forms. Paged lists now do the work of one page and generated functions are planned once per session. Depth limits and cycles follow OpenFGA. Fixes a check that let userset subjects through constrained grants and a migrate that dropped RLS policies with CASCADE.
📖 Full write-up: Melange v0.11.0 release notes
Run
melange validatewith the v0.11.0 CLI first: some schemas with cycles throughandorbut notare now rejected. Then runmelange migrate; the security fixes take effect only after migrating. Upgrade the Go runtime for the contextual tuples fix. Lists past the depth limit now raiseM2002instead of returning a truncated result. Without ansql:section inmelange.yaml, every relation and function family is still installed.
⚠ Breaking Changes
-
schema: reject a relation that resolves back to itself on the same object through an intersection or exclusion operand, such as
a: [user] or (b and c)withb: [user] or a. OpenFGA rejects these with 2056 (#137). -
sqlgen: raise
M2002past the depth limit in recursivelist_objectsandlist_subjectsand in nested group walks, instead of silently truncating at 25 levels (#137).Matches OpenFGA v1.22.1: 24 levels list and 25 fail, and a userset or cross-type step at the end of a parent chain counts toward the limit.
-
migrator: refuse to drop orphaned functions that views, materialized views, RLS policies, rules or
BEGIN ATOMICfunctions depend on, unless forced (#138).The error lists the dependents. Unforced drops and
generate migrationUP files no longer useCASCADE. See Dependent objects. -
sqlgen: declare every check function
COST 1000, so queries and RLS policies that callcheck_<type>_<relation>directly can plan differently (#139).
Security
-
sqlgen: check userset subjects against constrained grants (#137).
For
viewer: [user, group#member] and member from owner,check_permissionsaidgroup:eng#memberwas a viewer with nomemberon the owner, and the same held through implied relations whose grant sat in an intersection or under an exclusion. Wildcard tuples also matched userset subjects in some probes. Plain subjects were not affected. -
migrator: stop unforced drops from removing dependents with
CASCADE(#138).Removing a relation dropped its functions with
CASCADE, which also dropped RLS policies that called them and widened access to their tables. -
checker: see contextual tuples on a session reused after plain calls (#137).
PL/pgSQL kept statements resolved against the base view, so on a pooled session a contextual request after a plain one ignored its tuples. Cleanup now drops the view under its own timeout and closes the connection if the drop fails, so a driver that keeps a cancelled session open can no longer leave the view granting its tuples to later requests. pgx and lib/pq were not affected by the latter.
Features
-
sqlgen: generate only the exposed SQL API and what it depends on (#138).
The new
sql:section ofmelange.yaml(and--include-relation,--exclude-relation,--no-<family>) names the exposed relations and thelist_objects,list_subjects,accessible,parent_key,expandandexplainfamilies. Migrate installs those and every relation they resolve through, and records the exposure inmelange_migrations. Public functions raiseM2003for unexposed relations, mapped toValidationErrorin the Go and TypeScript runtimes.statusanddoctorreport exposure drift. See Exposure. -
sqlgen: generate inlinable
accessible_{type}_{relation}functions andaccessible_objectsfor filtering your own queries (#137).PostgreSQL inlines the per-relation function, so your filters, sort and limit are planned with the access set. On the kitchen sink at 1M, a page of 50 documents by name went from 158 ms to 42 ms against
IN list_accessible_objects. -
sqlgen: generate parent-key functions
accessible_{type}_{relation}_by_{link}for relations granted only through one parent link (#137).They return parent IDs, so you filter the link column. For a viewer of a 1M-subject organization, a count went from about 4 s to 70 ms, and a
LATERALpage per parent took 0.9 ms. -
cli: add
melange functionsand a Studio SQL API page: every function a model compiles to, with exact names, signatures, example calls and drift againstpg_proc(#138, #139). -
clientgen: emit exact accessible function names (
SQLAccessibleDocumentViewer, TypeScriptAccessibleFunctions) and follow the exposure; addgenerate client --checkand a Generated Client category indoctor(#138). -
cli: compile explain and expand on demand in
pg_tempwhen their family is not installed, formelange explain,melange expandand Studio (#138). -
migrator: predict what an unforced migrate would do (
Migrator.Plan), and use it for doctor fix hints that work (#138). -
schema: accept parent lookups that cycle across types while changing relation, as OpenFGA does (#137).
-
studio: larger type, more spacing and neutral badges for expected states across every page (#139).
Bug Fixes
- sqlgen: count check resolution steps like OpenFGA: resolve 25 hops and raise
M2002at 26 (#137). - sqlgen: stop userset-filter
list_subjectsrecursing untilstack depth limit exceededon parent cycles (#137). - sqlgen: match the userset relation exactly in nested group walks, where
LIKElet an underscore match any character (#137). - sqlgen: resolve the linking types of excluded intersection parts, and reference only the parent types of intersection tuple-to-userset parts (#137, #138).
- migrator: refuse exposure changes through
MigrateWithTypes, which records no migration (#138). - doctor: report as orphans only the functions the last migration recorded, and suggest a per-call expand leaf cap instead of a session setting that does not exist (#138, #139).
Performance
-
sqlgen: paginate
list_objectsas a top-k query, and page tuple-to-userset compositions a parent at a time (#137). -
sqlgen: plan generated functions once per session with JIT off, fold userset arms at plan time, and call check functions directly instead of through the dispatcher (#137, #139).
-
sqlgen: anchor intersection
list_subjectson direct tuples and parent lookups instead of every subject, walk recursive lists breadth first, and look up subject-keyed sets with= ANY(ARRAY(...))(#137).doctorgains asubject_lookup_indexescheck.Cloud SQL for PostgreSQL 18.6, same instance and client, medians of six runs:
Benchmark v0.10.3 v0.11.0 SaaS ListSubjects 1M, readers of the largest org's contacts 206,743 ms 25.3 ms SaaS ListObjects 1M, first page of 50 contacts, partner 3,457 ms 6.1 ms ListObjects 1M, pull requests, page of 10 117.5 ms 6.9 ms Kitchen sink ListObjects 1M, document can_edit69.5 ms 5.4 ms Kitchen sink ListObjects 1M, document can_view434.8 ms 156.4 ms Outside the OpenFGA suite, 180 of 439 benchmarks are more than 10% faster and 33 more than 10% slower, mostly SaaS checks (worst: org
can_readfor a partner, 0.91 ms to 1.17 ms).
Documentation
- docs: update the Performance reference to a Cloud SQL run of 0.11.0 on PostgreSQL 18 (#143).
- docs: document the exposure, accessible and parent-key functions, on-demand explain and expand, fix hints and dependent objects across the SQL API, configuration, CLI, migrations, Studio and troubleshooting pages (#138, #139).
Testing
- openfgatests: compare the accessible and parent-key functions with every list and check assertion (1,330 list and 1,834 check comparisons), page every
list_objectsassertion in pages of 1 and 2, and replay 232 cases under a restricted exposure (#137, #138). - openfgatests: fuzz accessible functions and random restricted exposures against OpenFGA (#138).
- test: add
BenchmarkSaaS, a multi-tenant model with tiered roles, partner orgs, staff access and a 27-branch view at 100K, 1M and 5M tuples (#137). - bench: run the cloud benchmark on PostgreSQL 18 (#142).
Full Changelog: v0.10.3...v0.11.0