@@ -198,6 +198,7 @@ impl<'a: 'b, 'b, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'
198198 rows. push ( row) ;
199199 }
200200
201+ let value_name = self . context . temp_table ( ) ;
201202 let column_refs: Vec < ColumnRef > = inferred_types
202203 . into_iter ( )
203204 . enumerate ( )
@@ -208,7 +209,7 @@ impl<'a: 'b, 'b, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'
208209 false ,
209210 ColumnDesc :: new ( typ, None , false , None ) ?,
210211 ) ;
211- column_ref. set_ref_table ( self . context . temp_table ( ) , ColumnId :: default ( ) , true ) ;
212+ column_ref. set_ref_table ( value_name . clone ( ) , ColumnId :: default ( ) , true ) ;
212213 Ok ( ColumnRef ( Arc :: new ( column_ref) ) )
213214 } )
214215 . collect :: < Result < _ , DatabaseError > > ( ) ?;
@@ -416,13 +417,9 @@ impl<'a: 'b, 'b, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'
416417 ) ) ;
417418 }
418419 let table_alias = Arc :: new ( name. value . to_lowercase ( ) ) ;
420+ let table = tables. pop ( ) . unwrap_or_else ( || self . context . temp_table ( ) ) ;
419421
420- plan = self . bind_alias (
421- plan,
422- alias_column,
423- table_alias,
424- tables. pop ( ) . unwrap_or ( Arc :: new ( "_temp_table_" . to_string ( ) ) ) ,
425- ) ?;
422+ plan = self . bind_alias ( plan, alias_column, table_alias, table) ?;
426423 }
427424 plan
428425 }
0 commit comments