Repository navigation
Conversation
…finition The definition update re-creates the function with CREATE OR REPLACE and a hard-coded CALLED ON NULL INPUT. Attributes that are not spelled out reset to their defaults, so editing the body of a STRICT PARALLEL SAFE function made it non-strict and PARALLEL UNSAFE, and reset COST and ROWS. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
breken-ai
requested review from
a team,
avallete and
soedirgo
as code owners
September 26, 2026 04:00
This branch has not been deployed
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.
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
PATCH /functions/:idwith a newdefinitionre-creates the function withCREATE OR REPLACE FUNCTION(generateCreateFunctionSql). That SQL hard-codesCALLED ON NULL INPUT. It also never writes outPARALLEL,COSTorROWS.CREATE OR REPLACEresets every attribute that it doesn't spell out to its default. So editing only the body of this function:silently changes it. Here is what
pg_procshows before and after the edit:update(id, { definition })on masterproisstricttruefalseproparallelsuprocost5100prorows31000Losing
STRICTchanges what the function returns: a null argument now runs the body instead of returning null. LosingPARALLEL SAFEmakes every query that calls the function run without parallel plans.What is the new behavior?
When
definitionis updated,update()readsproisstrict,proparallel,procost,prorowsandproretsetfrompg_procfor the function. It passes them togenerateCreateFunctionSql, which then emitsSTRICTorCALLED ON NULL INPUT,PARALLEL …,COST …, and, for set-returning functions only,ROWS …. The create path is unchanged.Additional context
I added the test
update definition keeps strictness, parallel safety, cost and rowstotest/lib/functions.ts.masterit fails and reports the reset values from the table above.test/index.test.tspasses 148/148 against thetest/dbimage (supabase/postgres:14.1.0).npm run checkandprettier -care clean.LEAKPROOFis left out on purpose. Only superusers can set it, so carrying it over would make definition updates fail for non-superuser owners.This PR was prepared with an AI coding assistant (Claude Code). I reproduced the failure and ran the tests against a real Postgres.
🤖 Generated with Claude Code