@@ -1681,7 +1681,9 @@ static idx_e check_duplicates(thread_db* tdbb,
16811681 index_desc* insertion_idx = insertion->iib_descriptor ;
16821682 record_param rpb;
16831683 rpb.rpb_relation = insertion->iib_relation ;
1684- rpb.rpb_record = NULL ;
1684+
1685+ AutoTempRecord gc_record (VIO_gc_record (tdbb, rpb.rpb_relation ));
1686+ rpb.rpb_record = gc_record;
16851687
16861688 jrd_rel* const relation_1 = insertion->iib_relation ;
16871689 RecordBitmap::Accessor accessor (insertion->iib_duplicates );
@@ -1754,7 +1756,8 @@ static idx_e check_duplicates(thread_db* tdbb,
17541756 }
17551757 } while (accessor.getNext ());
17561758
1757- delete rpb.rpb_record ;
1759+ if (rpb.rpb_record != gc_record)
1760+ delete rpb.rpb_record ;
17581761
17591762 return result;
17601763}
@@ -1952,12 +1955,13 @@ static idx_e check_partner_index(thread_db* tdbb,
19521955 if ((idx->idx_flags & idx_descending) != (partner_idx.idx_flags & idx_descending))
19531956 BTR_complement_key (key);
19541957
1955- RecordBitmap* bitmap = NULL ;
1958+ RecordBitmap bm (*tdbb->getDefaultPool ());
1959+ RecordBitmap* bitmap = &bm;
19561960 BTR_evaluate (tdbb, &retrieval, &bitmap, NULL );
19571961
19581962 // if there is a bitmap, it means duplicates were found
19591963
1960- if (bitmap)
1964+ if (bitmap-> getFirst () )
19611965 {
19621966 index_insertion insertion;
19631967 insertion.iib_descriptor = &partner_idx;
@@ -1972,7 +1976,6 @@ static idx_e check_partner_index(thread_db* tdbb,
19721976 result = result ? idx_e_foreign_references_present : idx_e_ok;
19731977 if (idx->idx_flags & idx_foreign)
19741978 result = result ? idx_e_ok : idx_e_foreign_target_doesnt_exist;
1975- delete bitmap;
19761979 }
19771980 else if (idx->idx_flags & idx_foreign)
19781981 result = idx_e_foreign_target_doesnt_exist;
0 commit comments