| 53 | } |
| 54 | |
| 55 | RelationPages* jrd_rel::getPagesInternal(thread_db* tdbb, TraNumber tran, bool allocPages) |
| 56 | { |
| 57 | if (tdbb->tdbb_flags & TDBB_use_db_page_space) |
| 58 | return &rel_pages_base; |
| 59 | |
| 60 | Jrd::Attachment* attachment = tdbb->getAttachment(); |
| 61 | Database* dbb = tdbb->getDatabase(); |
| 62 | |
| 63 | RelationPages::InstanceId inst_id; |
| 64 | |
| 65 | if (rel_flags & REL_temp_tran) |
| 66 | { |
| 67 | if (tran != 0 && tran != MAX_TRA_NUMBER) |
| 68 | inst_id = tran; |
| 69 | else if (tdbb->tdbb_temp_traid) |
| 70 | inst_id = tdbb->tdbb_temp_traid; |
| 71 | else if (tdbb->getTransaction()) |
| 72 | inst_id = tdbb->getTransaction()->tra_number; |
| 73 | else // called without transaction, maybe from OPT or CMP ? |
| 74 | return &rel_pages_base; |
| 75 | } |
| 76 | else |
| 77 | inst_id = PAG_attachment_id(tdbb); |
| 78 | |
| 79 | if (!rel_pages_inst) |
| 80 | rel_pages_inst = FB_NEW_POOL(*rel_pool) RelationPagesInstances(*rel_pool); |
| 81 | |
| 82 | FB_SIZE_T pos; |
| 83 | if (!rel_pages_inst->find(inst_id, pos)) |
| 84 | { |
| 85 | if (!allocPages) |
| 86 | return 0; |
| 87 | |
| 88 | RelationPages* newPages = rel_pages_free; |
| 89 | if (!newPages) { |
| 90 | newPages = FB_NEW_POOL(*rel_pool) RelationPages(*rel_pool); |
| 91 | } |
| 92 | else |
| 93 | { |
| 94 | rel_pages_free = newPages->rel_next_free; |
| 95 | newPages->rel_next_free = 0; |
| 96 | } |
| 97 | |
| 98 | fb_assert(newPages->useCount == 0); |
| 99 | |
| 100 | newPages->addRef(); |
| 101 | newPages->rel_instance_id = inst_id; |
| 102 | newPages->rel_pg_space_id = dbb->dbb_page_manager.getTempPageSpaceID(tdbb); |
| 103 | rel_pages_inst->add(newPages); |
| 104 | |
| 105 | // create primary pointer page and index root page |
| 106 | DPM_create_relation_pages(tdbb, this, newPages); |
| 107 | |
| 108 | #ifdef VIO_DEBUG |
| 109 | VIO_trace(DEBUG_WRITES, |
| 110 | "jrd_rel::getPages rel_id %u, inst %" UQUADFORMAT", ppp %" ULONGFORMAT", irp %" ULONGFORMAT", addr 0x%x\n", |
| 111 | rel_id, |
| 112 | newPages->rel_instance_id, |
nothing calls this directly
no test coverage detected