@@ -622,10 +622,18 @@ void Applier::insertRecord(thread_db* tdbb, TraNumber traNum,
622622 fb_assert (error[2 ] == isc_arg_string);
623623 fb_assert (error[3 ] != 0 );
624624
625- const char * idxName = reinterpret_cast <const char *>(error[3 ]);
625+ const MetaName nameFromErr (reinterpret_cast <const char *>(error[3 ]));
626+ MetaName idxName;
627+ if (error[1 ] == isc_no_dup)
628+ idxName = nameFromErr;
629+ else if (!m_constraintIndexMap.get (nameFromErr, idxName))
630+ {
631+ MET_lookup_index_for_cnstrt (tdbb, idxName, nameFromErr);
632+ m_constraintIndexMap.put (nameFromErr, idxName);
633+ }
626634
627635 index_desc idx;
628- const auto indexed = lookupRecord (tdbb, relation, record, m_bitmap, idx, idxName);
636+ const auto indexed = lookupRecord (tdbb, relation, record, m_bitmap, idx, & idxName);
629637
630638 AutoPtr<Record> cleanup;
631639
@@ -1071,7 +1079,7 @@ bool Applier::compareKey(thread_db* tdbb, jrd_rel* relation, const index_desc& i
10711079bool Applier::lookupRecord (thread_db* tdbb,
10721080 jrd_rel* relation, Record* record,
10731081 RecordBitmap* bitmap,
1074- index_desc& idx, const char * idxName)
1082+ index_desc& idx, const MetaName * idxName)
10751083{
10761084 RecordBitmap::reset (bitmap);
10771085
@@ -1083,16 +1091,16 @@ bool Applier::lookupRecord(thread_db* tdbb,
10831091 }
10841092
10851093 bool haveIdx = false ;
1086- if (idxName)
1094+ if (idxName && idxName-> hasData () )
10871095 {
10881096 SLONG foundRelId;
10891097 IndexStatus idxStatus;
1090- SLONG idx_id = MET_lookup_index_name (tdbb, idxName, &foundRelId, &idxStatus);
1098+ SLONG idx_id = MET_lookup_index_name (tdbb, * idxName, &foundRelId, &idxStatus);
10911099
10921100 fb_assert (idxStatus == MET_object_active);
10931101 fb_assert (foundRelId == relation->rel_id );
10941102
1095- haveIdx = (idxStatus == MET_object_active) && (foundRelId == relation->rel_id ) &&
1103+ haveIdx = (idx_id >= 0 ) && ( idxStatus == MET_object_active) && (foundRelId == relation->rel_id ) &&
10961104 BTR_lookup (tdbb, relation, idx_id, &idx, relation->getPages (tdbb));
10971105 }
10981106
0 commit comments