substRef
Replaces every direct column reference to name with repl, rebuilding the surrounding nodes through the same construction paths a hand-written tree takes (labels included; the replacement is inserted as a closed tree and never re-entered, so references inside repl keep binding to the pre-rewrite frame). Callers guard where substitution is legal; this walk itself is purely structural and never reassociates anything.
Parameters
e | the expression to rewrite |
name | the column whose references take the replacement |
repl | the replacement tree |
Returns
the rewritten expression.