Commit bdd1c10
fix: Restore temp table persistence in --execute-statement mode
Fixes critical regression where temp tables created with SELECT INTO
were not persisting between statements in dependency-aware execution
(\sx mode in nvim plugin).
## Problem
After the execution mode unification refactor (commit e3ec558), temp
tables stopped working in --execute-statement mode. When executing:
```sql
SELECT * FROM web_cte INTO #temp;
GO
SELECT * FROM #temp;
GO
```
Statement #2 would return DUMMY table instead of the temp table data.
## Root Cause
The StatementExecutor.execute() method was removing the INTO clause
during preprocessing (line 175) before execution, so the QueryEngine
never knew to store the result as a temp table. The INTO clause was
being stripped by IntoClauseRemover but the result was never captured.
## Solution
Modified StatementExecutor.execute() to:
1. Capture INTO table name BEFORE preprocessing removes it (Step 0)
2. Execute the query normally
3. If INTO clause was present, materialize the result and store it
in the ExecutionContext's temp_tables registry (Step 4)
This ensures temp tables persist within a single --execute-statement
invocation across multiple dependent statements.
## Changes
**src/execution/statement_executor.rs:**
- Added Step 0: Capture into_table_name before preprocessing
- Added Step 4: Materialize and store result if INTO clause was present
- Uses QueryEngine.materialize_view() to convert DataView to DataTable
- Stores in context.temp_tables for subsequent statement access
## Testing
All 10 statement_executor tests pass.
User scenario now works:
1. \sx on statement #1: Creates #temp with 72,888 rows ✓
2. \sx on statement #2: Queries #temp, returns actual data ✓
Fixes regression introduced in execution mode unification.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent b972e4e commit bdd1c10
1 file changed
Lines changed: 15 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
117 | 120 | | |
118 | 121 | | |
119 | 122 | | |
| |||
133 | 136 | | |
134 | 137 | | |
135 | 138 | | |
136 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
137 | 151 | | |
138 | 152 | | |
139 | 153 | | |
| |||
0 commit comments