Repository navigation
fix(database): schema-qualify ltree @> in has_tree_access for TimescaleDB 2.30 - #216
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
π’ Approval recommended
The focused migration change correctly addresses the TimescaleDB regression without changing the function signature or authorization semantics.
0 open findings
What changed in this PR
Schema-qualifies the ltree access operator to preserve history and revert functionality on TimescaleDB 2.30+.
Changes:
- Uses
operator(public.@>)inhas_tree_access. - Documents why qualification is required for planner inlining.
| File | Description |
|---|---|
packages/βdatabase/βspace/βmigrate/βidempotent/β001_memory.sql |
Qualifies the ltree operator in the access check. |
π§ Review effort: Balanced
π‘ Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
jgpruitt
approved these changes
Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix the memory history and revert functions on TimescaleDB 2.30+.
has_tree_accessnow usesoperator(public.@>)instead of an unqualified@>.Problem
CI started to fail on
main-equivalent code (seen first on #215) in two space-migration integration tests:The CI Postgres image (
docker/Dockerfile.postgres) installstimescaledb-2-postgresql-18without a version pin, so it now gets 2.30.2. I bisected with a minimal repro against the TimescaleDB versions in the image:operator does not existThe failing pattern: an inlinable SQL function (no
set search_path) that uses an extension operator, in theWHEREclause of a hypertable query withORDER BY <time> LIMIT 1. From 2.30.0, the inlined body does not resolve the operator, although the calling function setssearch_pathto includepublic. The same query on a plain table works.In this schema, that hits
resolve_memory_id_from_historyand the snapshot lookup inrevert_memory(both on thememory_eventhypertable).get_memory_historyalready usedoperator(public.<@)for its own subtree filter.Fix
Schema-qualify the operator in
has_tree_access. The function stays inlinable (noset search_path), which is why it must not depend on the caller'ssearch_path. Extensions are always installedwith schema public(ensureExtension), so the qualifier is safe.has_tree_accessandtree_accessare the only inlinable SQL functions in the space schema, andtree_accessuses no operators.Idempotent migrations re-run on every boot, so existing spaces get the new body without a schema version bump. The signature does not change.
Production impact
If production moves to TimescaleDB 2.30+,
memory.historyby path andmemory.revertwould fail without this fix.Testing
packages/database/space/migrate/migrate.integration.test.tsandpackages/server/rpc/memory/memory.integration.test.ts.