@@ -198,6 +198,7 @@ impl<'a: 'b, 'b, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'
198
198
rows. push ( row) ;
199
199
}
200
200
201
+ let value_name = self . context . temp_table ( ) ;
201
202
let column_refs: Vec < ColumnRef > = inferred_types
202
203
. into_iter ( )
203
204
. enumerate ( )
@@ -208,7 +209,7 @@ impl<'a: 'b, 'b, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'
208
209
false ,
209
210
ColumnDesc :: new ( typ, None , false , None ) ?,
210
211
) ;
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 ) ;
212
213
Ok ( ColumnRef ( Arc :: new ( column_ref) ) )
213
214
} )
214
215
. collect :: < Result < _ , DatabaseError > > ( ) ?;
@@ -416,13 +417,9 @@ impl<'a: 'b, 'b, T: Transaction, A: AsRef<[(&'static str, DataValue)]>> Binder<'
416
417
) ) ;
417
418
}
418
419
let table_alias = Arc :: new ( name. value . to_lowercase ( ) ) ;
420
+ let table = tables. pop ( ) . unwrap_or_else ( || self . context . temp_table ( ) ) ;
419
421
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) ?;
426
423
}
427
424
plan
428
425
}
0 commit comments