347
347
/* Loop thru the relation computing index keys. If there are old versions,
348
348
find them, too. */
349
349
temporary_key key;
350
while (DPM_next(tdbb, &primary, LCK_read, false, false)) {
350
while (DPM_next(tdbb, &primary, LCK_read,
351
#ifdef SCROLLABLE_CURSORS
351
356
if (transaction && !VIO_garbage_collect(tdbb, &primary, transaction))
353
358
if (primary.rpb_flags & rpb_deleted)
393
398
result = BTR_key(tdbb, relation, record, idx, &key, &null_state, false);
395
if (null_state != idx_nulls_none) {
400
check_partner_index(tdbb, relation, record,
401
if (result == idx_e_ok && null_state == idx_nulls_none)
403
result = check_partner_index(tdbb, relation, record,
407
if (result == idx_e_ok) {
410
if (result == idx_e_ok)
408
412
idx_null_state null_state;
409
BTR_key(tdbb, relation, record, idx, &key, &null_state, false);
410
key_is_null = (null_state == idx_nulls_all);
413
result = BTR_key(tdbb, relation, record, idx, &key, &null_state, false);
412
if (isPrimary && null_state != idx_nulls_none)
415
if (result == idx_e_ok)
414
fb_assert(key.key_null_segment < idx->idx_count);
416
const USHORT bad_id = idx->idx_rpt[key.key_null_segment].idx_field;
417
const jrd_fld *bad_fld = MET_get_field(relation, bad_id);
419
ERR_post(isc_not_valid,
420
isc_arg_string, bad_fld->fld_name.c_str(),
421
isc_arg_string, NULL_STRING_MARK, isc_arg_end);
417
if (isPrimary && null_state != idx_nulls_none)
419
fb_assert(key.key_null_segment < idx->idx_count);
421
const USHORT bad_id = idx->idx_rpt[key.key_null_segment].idx_field;
422
const jrd_fld *bad_fld = MET_get_field(relation, bad_id);
424
ERR_post(isc_not_valid,
425
isc_arg_string, bad_fld->fld_name.c_str(),
426
isc_arg_string, NULL_STRING_MARK, isc_arg_end);
429
key_is_null = (null_state == idx_nulls_all);
433
if (result != idx_e_ok)
426
436
if (record != gc_record)
429
439
gc_record->rec_flags &= ~REC_gc_active;
430
440
if (primary.getWindow(tdbb).win_flags & WIN_large_scan)
431
441
--relation->rel_scan_count;
432
ERR_duplicate_error(result, partner_relation,
442
ERR_duplicate_error(result, relation, idx->idx_id);
436
445
if (key.key_length > key_length) {
588
597
signal_index_deletion(tdbb, relation, id);
590
RelationPages* relPages = relation->getPages(tdbb);
591
WIN window(relPages->rel_pg_space_id, relPages->rel_index_root);
599
WIN window(get_root_page(tdbb, relation));
592
600
CCH_FETCH(tdbb, &window, LCK_write, pag_root);
594
602
const bool tree_exists = BTR_delete_index(tdbb, &window, id);
636
fb_assert(relPages->rel_index_root);
628
638
WIN window(relPages->rel_pg_space_id, relPages->rel_index_root);
629
639
index_root_page* root = (index_root_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_root);
720
730
insertion.iib_relation = rpb->rpb_relation;
721
731
insertion.iib_key = &key1;
723
RelationPages* relPages = rpb->rpb_relation->getPages(tdbb);
724
WIN window(relPages->rel_pg_space_id, relPages->rel_index_root);
733
WIN window(get_root_page(tdbb, rpb->rpb_relation));
726
735
index_root_page* root = (index_root_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_root);