Skip to content

fix(postgres): key the analysis cache on casts and function attributes - #103

Merged
colinhacks merged 2 commits into
mainfrom
fix-fingerprint-casts
Oct 24, 2026
Merged

colinhacks merged 2 commits into
mainfrom
fix-fingerprint-casts

Conversation

@colinhacks

Copy link
Copy Markdown
Owner

The Postgres schema fingerprint, which keys the .reylo/ cache of analyses, missed catalog changes the analysis depends on, so a cached analysis could outlive them:

  • User casts (pg_cast): a cast decides which call the server makes (f(x) through an implicit cast, x::t through a user's function) and whether the analysis may trust a built-in rule. create cast (boolean as int8) with function …, or recreating it as implicit, left the fingerprint unchanged.
  • A function's attributes beyond its text: its default arguments (which let a shorter call reach it), volatility (which the row-count rules read), strictness (which the nullability rules read), kind (an aggregate or a function) and variadic argument. create or replace function plus(int, int default 1), alter function … immutable and alter function … strict left it unchanged.

The query now adds a row per user cast and those five attributes to each function's row. Changing the query moves every project's fingerprint once, so each statement is analyzed again on its next build. The fingerprint test gains those five changes; on main it fails at the first.

The schema fingerprint that keys the .reylo/ cache read user operators
but no user cast, and a function's text but not its default arguments,
volatility, strictness, kind or variadic argument, all of which decide
which call the server makes or what the analysis may assume of it. A
change to any of them now moves the fingerprint, so the cached analyses
are made again.
Copilot AI balanced review requested due to automatic review settings October 24, 2026 00:37
@vercel

vercel Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
reylo Ready Ready Preview Oct 24, 2026 12:40am UTC

Request Review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues. One minor suggestion inline.

Reviewed changes

Reviewed the Postgres schema fingerprint query and its live test at 9f3bf7b.

  • Function attributes in the f row: each user function's row now also includes prokind, provolatile, proisstrict, pronargdefaults and provariadic. These are all NOT NULL columns, so no row becomes NULL and drops out of string_agg. This covers the provolatile read in cardinality.rs:289.
  • A new k row per user cast: pg_cast rows with oid >= 16384 are now included. This matches the cast condition in TRUST_QUERY (engine/postgres/src/postgres.rs:145), which also filters on oid >= 16384 AND castmethod = 'f'.
  • Fingerprint test: the test adds five catalog changes. create or replace and alter function keep the function's oid, so the default, volatility and strictness steps each test their new column directly.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread src/analyze.ts Resolved
@colinhacks
colinhacks merged commit c67c505 into main Oct 24, 2026
7 checks passed
@colinhacks
colinhacks deleted the fix-fingerprint-casts branch October 24, 2026 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants