Repository navigation
Skip the origin cache for queries without a template - #1277
Open
illia-haidar wants to merge 2 commits into
Open
illia-haidar wants to merge 2 commits into
illia-haidar wants to merge 2 commits into
Conversation
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.
Fixes #1276
For a query without a template (
sql.unsafe(),sql.file(), internal queries), theorigingetter falls through tooriginStackCache.set(this.strings, this[originError].stack). Therethis[originError]isfalseandthis.stringsis a new array per query, so every failure (queryError()readsorigin) adds an entry that is never used again. This returns''early for such queries.''for them; only the cache entry goes away.debug: truekeep their current branches.unsafe()still reports its SQLSTATE,queryand stack.The new test,
Failing queries without a template add nothing to the origin cache, runs a failingsql.unsafe()three times. It countsMap.prototype.setcalls keyed by that query's strings array, without measuring memory.0 != 3).Locally, against PostgreSQL 17:
tests/index.js(ESM) passes on Node 26.0.0 and 24.22.1, all 265 tests;eslint src testsis clean.This is independent of #1275: it merges with it without conflicts, and the two together pass the suite (266 tests).
cjs/,deno/andcf/are left for the build step.