| 275 | // IndexErrorContext class |
| 276 | |
| 277 | void IndexErrorContext::raise(thread_db* tdbb, idx_e result, Record* record) |
| 278 | { |
| 279 | fb_assert(result != idx_e_ok); |
| 280 | |
| 281 | if (result == idx_e_conversion || result == idx_e_interrupt) |
| 282 | ERR_punt(); |
| 283 | |
| 284 | const MetaName& relationName = isLocationDefined ? m_location.relation->rel_name : m_relation->rel_name; |
| 285 | const USHORT indexId = isLocationDefined ? m_location.indexId : m_index->idx_id; |
| 286 | |
| 287 | MetaName indexName(m_indexName), constraintName; |
| 288 | |
| 289 | if (indexName.isEmpty()) |
| 290 | MET_lookup_index(tdbb, indexName, relationName, indexId + 1); |
| 291 | |
| 292 | if (indexName.hasData()) |
| 293 | MET_lookup_cnstrt_for_index(tdbb, constraintName, indexName); |
| 294 | else |
| 295 | indexName = "***unknown***"; |
| 296 | |
| 297 | const bool haveConstraint = constraintName.hasData(); |
| 298 | |
| 299 | if (!haveConstraint) |
| 300 | constraintName = "***unknown***"; |
| 301 | |
| 302 | switch (result) |
| 303 | { |
| 304 | case idx_e_keytoobig: |
| 305 | ERR_post_nothrow(Arg::Gds(isc_imp_exc) << |
| 306 | Arg::Gds(isc_keytoobig) << Arg::Str(indexName)); |
| 307 | break; |
| 308 | |
| 309 | case idx_e_foreign_target_doesnt_exist: |
| 310 | ERR_post_nothrow(Arg::Gds(isc_foreign_key) << |
| 311 | Arg::Str(constraintName) << Arg::Str(relationName) << |
| 312 | Arg::Gds(isc_foreign_key_target_doesnt_exist)); |
| 313 | break; |
| 314 | |
| 315 | case idx_e_foreign_references_present: |
| 316 | ERR_post_nothrow(Arg::Gds(isc_foreign_key) << |
| 317 | Arg::Str(constraintName) << Arg::Str(relationName) << |
| 318 | Arg::Gds(isc_foreign_key_references_present)); |
| 319 | break; |
| 320 | |
| 321 | case idx_e_duplicate: |
| 322 | if (haveConstraint) |
| 323 | { |
| 324 | ERR_post_nothrow(Arg::Gds(isc_unique_key_violation) << |
| 325 | Arg::Str(constraintName) << Arg::Str(relationName)); |
| 326 | } |
| 327 | else |
| 328 | ERR_post_nothrow(Arg::Gds(isc_no_dup) << Arg::Str(indexName)); |
| 329 | break; |
| 330 | |
| 331 | default: |
| 332 | fb_assert(false); |
| 333 | } |
| 334 |
no test coverage detected