@@ -622,10 +622,18 @@ void Applier::insertRecord(thread_db* tdbb, TraNumber traNum,
622
622
fb_assert (error[2 ] == isc_arg_string);
623
623
fb_assert (error[3 ] != 0 );
624
624
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
+ }
626
634
627
635
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);
629
637
630
638
AutoPtr<Record> cleanup;
631
639
@@ -1071,7 +1079,7 @@ bool Applier::compareKey(thread_db* tdbb, jrd_rel* relation, const index_desc& i
1071
1079
bool Applier::lookupRecord (thread_db* tdbb,
1072
1080
jrd_rel* relation, Record* record,
1073
1081
RecordBitmap* bitmap,
1074
- index_desc& idx, const char * idxName)
1082
+ index_desc& idx, const MetaName * idxName)
1075
1083
{
1076
1084
RecordBitmap::reset (bitmap);
1077
1085
@@ -1083,16 +1091,16 @@ bool Applier::lookupRecord(thread_db* tdbb,
1083
1091
}
1084
1092
1085
1093
bool haveIdx = false ;
1086
- if (idxName)
1094
+ if (idxName && idxName-> hasData () )
1087
1095
{
1088
1096
SLONG foundRelId;
1089
1097
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);
1091
1099
1092
1100
fb_assert (idxStatus == MET_object_active);
1093
1101
fb_assert (foundRelId == relation->rel_id );
1094
1102
1095
- haveIdx = (idxStatus == MET_object_active) && (foundRelId == relation->rel_id ) &&
1103
+ haveIdx = (idx_id >= 0 ) && ( idxStatus == MET_object_active) && (foundRelId == relation->rel_id ) &&
1096
1104
BTR_lookup (tdbb, relation, idx_id, &idx, relation->getPages (tdbb));
1097
1105
}
1098
1106
0 commit comments