MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / IDX_modify_flag_uk_modified

Function IDX_modify_flag_uk_modified

src/jrd/idx.cpp:1436–1496  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1434
1435
1436void IDX_modify_flag_uk_modified(thread_db* tdbb,
1437 record_param* org_rpb,
1438 record_param* new_rpb,
1439 jrd_tra* transaction)
1440{
1441/**************************************
1442 *
1443 * I D X _ m o d i f y _ f l a g _ u k _ m o d i f i e d
1444 *
1445 **************************************
1446 *
1447 * Functional description
1448 * Set record flag if key field value was changed by this update or
1449 * if this is second update of this record in the same transaction and
1450 * flag is already set by one of the previous update.
1451 *
1452 **************************************/
1453
1454 SET_TDBB(tdbb);
1455
1456 if ((org_rpb->rpb_flags & rpb_uk_modified) &&
1457 (org_rpb->rpb_transaction_nr == new_rpb->rpb_transaction_nr))
1458 {
1459 new_rpb->rpb_flags |= rpb_uk_modified;
1460 return;
1461 }
1462
1463 jrd_rel* const relation = org_rpb->rpb_relation;
1464 fb_assert(new_rpb->rpb_relation == relation);
1465
1466 RelationPages* const relPages = relation->getPages(tdbb);
1467 WIN window(relPages->rel_pg_space_id, -1);
1468
1469 DSC desc1, desc2;
1470 index_desc idx;
1471 idx.idx_id = idx_invalid;
1472
1473 while (BTR_next_index(tdbb, relation, transaction, &idx, &window))
1474 {
1475 if (!(idx.idx_flags & (idx_primary | idx_unique)) ||
1476 !MET_lookup_partner(tdbb, relation, &idx, 0))
1477 {
1478 continue;
1479 }
1480
1481 for (USHORT i = 0; i < idx.idx_count; i++)
1482 {
1483 const USHORT field_id = idx.idx_rpt[i].idx_field;
1484
1485 const bool flag_org = EVL_field(relation, org_rpb->rpb_record, field_id, &desc1);
1486 const bool flag_new = EVL_field(relation, new_rpb->rpb_record, field_id, &desc2);
1487
1488 if (flag_org != flag_new || (flag_new && MOV_compare(tdbb, &desc1, &desc2)))
1489 {
1490 new_rpb->rpb_flags |= rpb_uk_modified;
1491 CCH_RELEASE(tdbb, &window);
1492 return;
1493 }

Callers 1

VIO_modifyFunction · 0.85

Calls 6

SET_TDBBFunction · 0.85
BTR_next_indexFunction · 0.85
EVL_fieldFunction · 0.85
MOV_compareFunction · 0.85
CCH_RELEASEFunction · 0.85
getPagesMethod · 0.45

Tested by

no test coverage detected