Repository navigation
Normalize deeply nested expressions without a PG_TRY block per level - #21
Conversation
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review complete. No issues found — approved ✅. The change introduces a single new test,
Reviewed commit: b8f5945 |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
00bf861
into
18-constructive
Summary
In WebAssembly builds
pg_query_normalizeruns out of the host engine's native stack at about 770 chained terms (SELECT 1+1+…) on a fresh instance, whilepg_query_parsehandles several thousand.Cause:
const_record_walkerwrapsraw_expression_tree_walkerinPG_TRYfor every node it has no case for. Emscripten implementssetjmpby routing every call made from a function that contains one through a JavaScriptinvoke_*trampoline, so each level of the expression costs wasm → JS → wasm frames on V8's ~1 MB native stack:V8 only compiles cheaper wrappers for those crossings after 1,000 calls on an instance (
--wasm-wrapper-tiering-budget). That is why a warmed-up instance reached about 1,640 terms, and why libpg-query-node 18.2.x, which replaces the instance after an overflow, sees 770 again where 18.1.5 kept its warm (but corrupt) instance.Change:
PG_TRYblock moves into its ownpg_noinlinefunction,const_record_walker_ignore_errors, soconst_record_walkeritself no longer contains asetjmp.raw_expression_tree_walkeris known to handle and that make up nested expressions (A_Expr,BoolExpr,SubLink,FuncCall,List,TypeCast,CaseExpr,JoinExpr, …) call it directly. Everything else still goes through thePG_TRYpath, so unknown node types are ignored as before and stack depth errors still propagate.Result on a fresh instance (Node 24, 32 MB
STACK_SIZE, unchanged): normalize handles 4,000 chained terms, up from about 770. No memory or stack setting changes. Native builds skip onesigsetjmpper expression node.The test commit (
normalize 3000 chained termsintest/wasm_depth.c) is pushed first and fails without the fix.Implemented in session Audit WASM memory history and verify full-stack depth
Review with Devin · Open in Devin Desktop