@@ -405,10 +405,10 @@ void insert_stmt::out(std::ostream &out)
405
405
out << " )" ;
406
406
}
407
407
408
- set_list::set_list (modifying_stmt *pprod ) : prod(pprod )
408
+ set_list::set_list (prod *p, table *target ) : prod(p )
409
409
{
410
410
do {
411
- for (auto col : pprod-> victim ->columns ()) {
411
+ for (auto col : target ->columns ()) {
412
412
if (d6 () < 4 )
413
413
continue ;
414
414
auto expr = value_expr::factory (this , col.type );
@@ -434,7 +434,7 @@ update_stmt::update_stmt(prod *p, struct scope *s, table *v)
434
434
: modifying_stmt(p, s, v) {
435
435
scope->refs .push_back (victim);
436
436
search = bool_expr::factory (this );
437
- set_list = make_shared<struct set_list >(this );
437
+ set_list = make_shared<struct set_list >(this , victim );
438
438
}
439
439
440
440
void update_stmt::out (std::ostream &out)
@@ -458,7 +458,7 @@ upsert_stmt::upsert_stmt(prod *p, struct scope *s, table *v)
458
458
if (!victim->constraints .size ())
459
459
fail (" need table w/ constraint for upsert" );
460
460
461
- set_list = std::make_shared<struct set_list >(this );
461
+ set_list = std::make_shared<struct set_list >(this , victim );
462
462
search = bool_expr::factory (this );
463
463
constraint = random_pick (victim->constraints );
464
464
}
@@ -539,11 +539,18 @@ void common_table_expression::out(std::ostream &out)
539
539
540
540
merge_stmt::merge_stmt (prod *p, struct scope *s, table *v)
541
541
: modifying_stmt(p,s,v) {
542
+
542
543
target_table_ = make_shared<target_table>(this , victim);
543
544
data_source = table_ref::factory (this );
544
545
// join_condition = join_cond::factory(this, *target_table_, *data_source);
545
546
join_condition = make_shared<simple_join_cond>(this , *target_table_, *data_source);
546
547
548
+
549
+ /* Put data_source into scope but not target_table. Visibility of
550
+ the latter varies depending on kind of when clause. */
551
+ // for (auto r : data_source->refs)
552
+ // scope->refs.push_back(&*r);
553
+
547
554
clauselist.push_back (when_clause::factory (this ));
548
555
while (d6 ()>4 )
549
556
clauselist.push_back (when_clause::factory (this ));
@@ -598,9 +605,14 @@ void when_clause::accept(prod_visitor *v)
598
605
}
599
606
600
607
when_clause_update::when_clause_update (merge_stmt *p)
601
- : when_clause(p)
608
+ : when_clause(p), myscope(p->scope)
602
609
{
603
- set_list = std::make_shared<struct set_list >(p);
610
+ myscope.tables = scope->tables ;
611
+ myscope.refs = scope->refs ;
612
+ scope = &myscope;
613
+ scope->refs .push_back (&*(p->target_table_ ->refs [0 ]));
614
+
615
+ set_list = std::make_shared<struct set_list >(this , p->victim );
604
616
}
605
617
606
618
void when_clause_update::out (std::ostream &out) {
0 commit comments