Repository navigation
Conversation
Root cause: In RecursiveCTEChunkGenerator, the function collectTableNodesWithStorage() was searching for table nodes by storage ID. However, during execution of recursive CTEs, the updateStorage() method is called on table nodes (line 155), which changes their storage ID to point to new temporary tables. For nested recursive CTEs, when the inner CTE x was executed multiple times during the outer CTE q's recursion, the table nodes in x's tree had their storage IDs updated, but the RecursiveCTETable stored in the Un→ The fix: Changed collectTableNodesWithStorage() to collectTableNodesWithTemporaryTableName(), which searches for table nodes by their temporary table name instead of storage ID. The temporary table name (CTE name) is stable and doesn't change during execution, making it a reliable identifier for finding self-referencing table nodes in recursive CTEs.
Contributor
|
Workflow [PR], commit [03b0818] Summary: ❌
|
pamarcos
marked this pull request as ready for review
December 9, 2025 17:43
pamarcos
marked this pull request as draft
December 9, 2025 19:03
pamarcos
marked this pull request as ready for review
December 9, 2025 19:07
yariks5s
approved these changes
Dec 10, 2025
Member
Author
robot-clickhouse
added a commit
that referenced
this pull request
Dec 10, 2025
This was referenced Dec 10, 2025
robot-clickhouse
added a commit
that referenced
this pull request
Dec 10, 2025
This was referenced Dec 10, 2025
robot-clickhouse
added a commit
that referenced
this pull request
Dec 10, 2025
This was referenced Dec 10, 2025
robot-clickhouse
added a commit
that referenced
this pull request
Dec 10, 2025
This was referenced Dec 10, 2025
robot-clickhouse
added a commit
that referenced
this pull request
Dec 10, 2025
clickhouse-gh Bot
added a commit
that referenced
this pull request
Dec 10, 2025
Backport #91827 to 25.11: Fix LOGICAL_ERROR in RecursiveCTEChunkGenerator
clickhouse-gh Bot
added a commit
that referenced
this pull request
Dec 10, 2025
Backport #91827 to 25.9: Fix LOGICAL_ERROR in RecursiveCTEChunkGenerator
pamarcos
added a commit
that referenced
this pull request
Dec 11, 2025
Backport #91827 to 25.10: Fix LOGICAL_ERROR in RecursiveCTEChunkGenerator
pamarcos
added a commit
that referenced
this pull request
Dec 11, 2025
Backport #91827 to 25.8: Fix LOGICAL_ERROR in RecursiveCTEChunkGenerator
pamarcos
added a commit
that referenced
this pull request
Dec 11, 2025
Backport #91827 to 25.3: Fix LOGICAL_ERROR in RecursiveCTEChunkGenerator
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.
Root cause:
Given the SQL statement
In RecursiveCTEChunkGenerator, the function
collectTableNodesWithStorage() was searching for table nodes by storage ID. However, during execution of recursive CTEs, the updateStorage() method is called on table nodes (line 155), which changes their storage ID to point to new temporary tables. For nested recursive CTEs, when the inner CTE x was executed multiple times during the outer CTE q's recursion, the table nodes in x's tree had their storage IDs updated, but the RecursiveCTETable stored in the Un→
The fix:
Changed collectTableNodesWithStorage() to
collectTableNodesWithTemporaryTableName(), which searches for table nodes by their temporary table name instead of storage ID. The temporary table name (CTE name) is stable and doesn't change during execution, making it a reliable identifier for finding self-referencing table nodes in recursive CTEs.
Closes #85773
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix LOGICAL_ERROR in RecursiveCTEChunkGenerator
Documentation entry for user-facing changes