parser-and-nodeslisted
Install: claude install-skill matejformanek/postgres-claude
# Parser & Node-types — operational
Companion docs: `knowledge/idioms/parser-pipeline.md`, `knowledge/idioms/node-types-and-lists.md`.
## 0. The three-tree pipeline — AST → Query → Plan
Every SQL statement flows through three distinct tree shapes; nodes
in each header live or die at a specific stage. Confuse the stages
and your patch will silently fail in a downstream walker.
```
SQL text
│
│ gram.y / scan.l / kwlist.h
▼
1. Raw parsetree (AST) — parsenodes.h utility-stmt nodes
Examples: SelectStmt, + A_Expr / A_Const / ColumnRef /
InsertStmt, A_Expr, FuncCall (raw expression shapes)
ColumnRef, FuncCall → walker: raw_expression_tree_walker
No types resolved, no relations
looked up, no operators resolved.
│
│ parser/analyze.c → transformStmt → transform<Foo>Stmt
│ parser/parse_*.c → adds rangetable, resolves names,
│ picks operator + cast OIDs,
│ applies coercions
▼
2. Query tree — parsenodes.h Query + analyzed
Examples: Query, RangeTblEntry, expression nodes (primnodes.h)
Var, OpExpr, Const, FuncExpr, Examples: Var, OpExpr, Const,
TargetEntry, FromExpr, JoinExpr FuncExpr, Aggref, WindowFunc
→ walker: expression_tree_walker
+ query_tree_walker