This function clones the input ExecutionPlan by recursively visiting its tree of ops. * When an op is encountered that was constructed as part of a different ExecutionPlan segment, that segment * and its internal members (FilterTree, record mapping, query graphs, and AST segment) are also cloned. */
| 69 | * When an op is encountered that was constructed as part of a different ExecutionPlan segment, that segment |
| 70 | * and its internal members (FilterTree, record mapping, query graphs, and AST segment) are also cloned. */ |
| 71 | ExecutionPlan *ExecutionPlan_Clone(const ExecutionPlan *template) { |
| 72 | ASSERT(template != NULL); |
| 73 | // Store the original AST pointer. |
| 74 | AST *master_ast = QueryCtx_GetAST(); |
| 75 | // Verify that the execution plan template is not prepared yet. |
| 76 | ASSERT(template->prepared == false && "Execution plan cloning should be only on templates"); |
| 77 | ExecutionPlan *clone = _ExecutionPlan_Clone(template); |
| 78 | // Restore the original AST pointer. |
| 79 | QueryCtx_SetAST(master_ast); |
| 80 | return clone; |
| 81 | } |
| 82 |