Repository navigation
fix(convert): refuse trees too deep to convert, and stop copying || operands - #86
Merged
Merged
Conversation
…perands A flat chain such as a + a + ... parsed and checked, but converting it recursed once per operand and overflowed the stack: the CLI aborted and a Python host segfaulted. A || chain also deep-copied its left operand at every level, so memory grew with the square of its length. - Conversion measures the tree's depth, iteratively, before serialising it, and refuses past 512 levels (128 on WebAssembly) with SQ0006. - || converts its operands in place instead of cloning them. - CLI and Python tests cover +, - and || chains past the limit, a || chain within it, and a long AND chain, which the parser balances.
Contributor
Author
|
D94 gate on the exact head 861e0e1 (base main 7850e8d):
Landing by fast-forward to main. |
kvlonge
referenced
this pull request
Nov 6, 2026
…cases Five statements move from matching to declared_divergence. They are corrections of main's silent tie conversion, not converter regressions: main converted different values tied on every order key without declaring a divergence, which is the wrong value D172 fixes. - generated/hazards/array_agg__aggregate.toml#node_within_group_combination_0_integer_integer - generated/hazards/array_agg__aggregate.toml#node_within_group_combination_0_text_text - generated/hazards/listagg__aggregate.toml#node_within_group_1_combination_0_text_text - generated/hazards/listagg__aggregate.toml#node_within_group_combination_0_text_literal_text_text - generated/hazards/listagg__window.toml#node_window_function_2_combination_0_text_literal_text_text The other 11 entries are additions from the D153c receipts and the new group_mixed cases: nine statements, rlike.syntax syntax_only to matching, and to-binary unmeasured to refused. Nothing else moves.
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.
Why
A flat chain such as
SELECT total + total + … AS x FROM orderspassedcheckbut crashedconvert: past about 2,600 terms the CLI overflowed its stack and aborted, and a Python host segfaulted, which kills the interpreter. A||chain also took memory growing with the square of its length (about 1 GB at 800 terms), because each level copied its left operand.Changes
||converts its operands in place instead of cloning them, so its memory stays linear.Verification
+,-and||chains past the limit (SQ0006, no crash), a||chain within it, and a long AND chain that converts. Both tests fail on the unfixed code.+chain returns SQ0006 at 354 MB peak;||refuses beyond about 509 terms; a 3,000-term AND chain converts.