Skip to content

Key the statement cache on the SQL text instead of its hash - #2602

Merged
mathiasrw merged 1 commit into
AlaSQL:developfrom
zzoraemon043:fix/sql-cache-key
Oct 19, 2026
Merged

mathiasrw merged 1 commit into
AlaSQL:developfrom
zzoraemon043:fix/sql-cache-key

Conversation

@zzoraemon043

Copy link
Copy Markdown
Contributor

Fixes #2587

alasql.dexec looked up db.sqlCache and db.astCache by a 32-bit hash of the SQL text and never compared the text on a hit, so two statements with the same hash shared one compiled statement. The key is now the text itself (plus the joinstar option as before), option B from the issue.

Added test/test2587.js with the colliding pair from the issue (SELECT 369825 AS a / SELECT 1025164 AS a); it fails before the change.

I ran the suite with mocha on Node instead of bun: the only difference before and after the change is the new test going from failing to passing. The remaining failures (Test 107-B, 1645, CLI) fail the same way on develop on my machine (Windows).

@mathiasrw

Copy link
Copy Markdown
Member

Smooth!

@mathiasrw
mathiasrw merged commit ec4938e into AlaSQL:develop Oct 19, 2026
10 checks passed
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.

Statement cache returns another query's result when two SQL texts share a hash

2 participants