| 1 | #include "duckdb/planner/binder.hpp" | 
|---|---|
| 2 | #include "duckdb/parser/statement/explain_statement.hpp" | 
| 3 | #include "duckdb/planner/operator/logical_explain.hpp" | 
| 4 | |
| 5 | namespace duckdb { | 
| 6 | |
| 7 | BoundStatement Binder::Bind(ExplainStatement &stmt) { | 
| 8 | BoundStatement result; | 
| 9 | |
| 10 | // bind the underlying statement | 
| 11 | auto plan = Bind(statement&: *stmt.stmt); | 
| 12 | // get the unoptimized logical plan, and create the explain statement | 
| 13 | auto logical_plan_unopt = plan.plan->ToString(); | 
| 14 | auto explain = make_uniq<LogicalExplain>(args: std::move(plan.plan), args&: stmt.explain_type); | 
| 15 | explain->logical_plan_unopt = logical_plan_unopt; | 
| 16 | |
| 17 | result.plan = std::move(explain); | 
| 18 | 	result.names = {"explain_key", "explain_value"};  | 
| 19 | result.types = {LogicalType::VARCHAR, LogicalType::VARCHAR}; | 
| 20 | properties.return_type = StatementReturnType::QUERY_RESULT; | 
| 21 | return result; | 
| 22 | } | 
| 23 | |
| 24 | } // namespace duckdb | 
| 25 |