If we do this via raw calls, it would work something like this:
- Add accessors on the planner
.state and .commands that return placeholder Value objects representing the executor state and the commands used by a nested instance.
- Add a function on the planner
.createSubplanner (or something). This function takes a FunctionCall, wraps it into a SubplanFunctionCall and puts it on the list of calls, then returns a new planner object initialised with the context of the parent.
- When planning, if we encounter a
SubplanFunctionCall, recurse and plan that call before continuing. Use the same internal state for tracking slot liveness etc, as the same state array will be used throughout all the nested calls.
- When looking at function arguments and return values, if we encounter a
StateValue, encode the special register ID for the state. If we encounter a CommandsValue and the current call is a SubplanFunctionCall, ABI-encode the the list of commands for that subplan and insert as a literal value into the state.
- If we encounter a
CommandsValue in a call that's not a SubplanFunctionCall, throw an error. If we encounter a SubplanFunctionCall that doesn't have a CommandsValue, throw an error.
If we do this via raw calls, it would work something like this:
.stateand.commandsthat return placeholderValueobjects representing the executor state and the commands used by a nested instance..createSubplanner(or something). This function takes aFunctionCall, wraps it into aSubplanFunctionCalland puts it on the list of calls, then returns a new planner object initialised with the context of the parent.SubplanFunctionCall, recurse and plan that call before continuing. Use the same internal state for tracking slot liveness etc, as the same state array will be used throughout all the nested calls.StateValue, encode the special register ID for the state. If we encounter aCommandsValueand the current call is aSubplanFunctionCall, ABI-encode the the list of commands for that subplan and insert as a literal value into the state.CommandsValuein a call that's not aSubplanFunctionCall, throw an error. If we encounter aSubplanFunctionCallthat doesn't have aCommandsValue, throw an error.