~ubuntu-branches/ubuntu/oneiric/firebird2.1/oneiric

« back to all changes in this revision

Viewing changes to src/jrd/idx.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2011-04-22 18:59:44 UTC
  • mfrom: (2.1.24 sid)
  • Revision ID: james.westby@ubuntu.com-20110422185944-egwy9r5xynjddku5
Tags: 2.1.4.18393-0.ds2-2
* apply patch from upstream SVN fixing ICU collations
* remove lintian overrides about manpages shipped in dependency package
* claim compliancy with Policy 3.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
352
                                        false, 
 
353
#endif
 
354
                                        false)) 
 
355
        {
351
356
                if (transaction && !VIO_garbage_collect(tdbb, &primary, transaction))
352
357
                        continue;
353
358
                if (primary.rpb_flags & rpb_deleted)
392
397
                                else {
393
398
                                        result = BTR_key(tdbb, relation, record, idx, &key, &null_state, false);
394
399
                                }
395
 
                                if (null_state != idx_nulls_none) {
396
 
                                        result = idx_e_ok;
397
 
                                }
398
 
                                else {
399
 
                                        result =
400
 
                                                check_partner_index(tdbb, relation, record,
401
 
                                                                                        transaction, idx,
402
 
                                                                                        partner_relation,
403
 
                                                                                        partner_index_id);
 
400
 
 
401
                                if (result == idx_e_ok && null_state == idx_nulls_none)
 
402
                                {
 
403
                                        result = check_partner_index(tdbb, relation, record,
 
404
                                                                                                 transaction, idx,
 
405
                                                                                                 partner_relation,
 
406
                                                                                                 partner_index_id);
404
407
                                }
405
408
                        }
406
409
 
407
 
                        if (result == idx_e_ok) {
 
410
                        if (result == idx_e_ok)
 
411
                        {
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);
411
414
 
412
 
                                if (isPrimary && null_state != idx_nulls_none) 
 
415
                                if (result == idx_e_ok)
413
416
                                {
414
 
                                        fb_assert(key.key_null_segment < idx->idx_count);
415
 
 
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);
418
 
 
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) 
 
418
                                        {
 
419
                                                fb_assert(key.key_null_segment < idx->idx_count);
 
420
 
 
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);
 
423
 
 
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);
 
427
                                        }
 
428
 
 
429
                                        key_is_null = (null_state == idx_nulls_all);
422
430
                                }
423
431
                        }
424
 
                        else {
 
432
 
 
433
                        if (result != idx_e_ok)
 
434
                        {
425
435
                                do {
426
436
                                        if (record != gc_record)
427
437
                                                delete 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,
433
 
                                                                        partner_index_id);
 
442
                                ERR_duplicate_error(result, relation, idx->idx_id);
434
443
                        }
435
444
 
436
445
                        if (key.key_length > key_length) {
587
596
 
588
597
        signal_index_deletion(tdbb, relation, id);
589
598
 
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);
593
601
 
594
602
        const bool tree_exists = BTR_delete_index(tdbb, &window, id);
625
633
 
626
634
        SET_TDBB(tdbb);
627
635
 
 
636
        fb_assert(relPages->rel_index_root);
 
637
 
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);
630
640
 
720
730
        insertion.iib_relation = rpb->rpb_relation;
721
731
        insertion.iib_key = &key1;
722
732
 
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));
725
734
 
726
735
        index_root_page* root = (index_root_page*) CCH_FETCH(tdbb, &window, LCK_read, pag_root);
727
736