Skip to content

Fix crash for subqueries referenced in another subquery#552

Merged
simolus3 merged 2 commits intomainfrom
fix-cte-json-reference
Mar 6, 2026
Merged

Fix crash for subqueries referenced in another subquery#552
simolus3 merged 2 commits intomainfrom
fix-cte-json-reference

Conversation

@simolus3
Copy link
Contributor

@simolus3 simolus3 commented Mar 6, 2026

This fixes a report from Discord.

In StreamQueryParser, subqueryResultSets stores expanded subqueries which is used to inline column references. When we parse another subquery with access to a subquery that has already been joined, we need to pass subqueryResultSets down to the inner parser to avoid internal error: result set from scope has not been registered errors. This PR fixes that, and adds a regression test with a query derived from the original report.

@changeset-bot
Copy link

changeset-bot bot commented Mar 6, 2026

🦋 Changeset detected

Latest commit: ae138cb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 18 packages
Name Type
@powersync/service-sync-rules Patch
@powersync/service-jpgwire Patch
@powersync/service-core-tests Patch
@powersync/service-core Patch
@powersync/lib-services-framework Patch
@powersync/service-module-mongodb-storage Patch
@powersync/service-module-mongodb Patch
@powersync/service-module-mssql Patch
@powersync/service-module-mysql Patch
@powersync/service-module-postgres-storage Patch
@powersync/service-module-postgres Patch
@powersync/lib-service-postgres Patch
@powersync/service-module-core Patch
@powersync/service-image Patch
test-client Patch
@powersync/service-rsocket-router Patch
@powersync/lib-service-mongodb Patch
@powersync/service-schema Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

rkistner
rkistner previously approved these changes Mar 6, 2026
@simolus3 simolus3 marked this pull request as ready for review March 6, 2026 11:20
@simolus3 simolus3 requested a review from rkistner March 6, 2026 11:20
@simolus3
Copy link
Contributor Author

simolus3 commented Mar 6, 2026

I've simplified the regression test a bit, the original query had some other issues that made the generated sync plan very complicated (it was correct in both cases though, but it took me quite some time to double-check).

@simolus3 simolus3 merged commit acf1486 into main Mar 6, 2026
31 checks passed
@simolus3 simolus3 deleted the fix-cte-json-reference branch March 6, 2026 12:43
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