| 864 | |
| 865 | |
| 866 | void BTR_create(thread_db* tdbb, |
| 867 | IndexCreation& creation, |
| 868 | SelectivityList& selectivity) |
| 869 | { |
| 870 | /************************************** |
| 871 | * |
| 872 | * B T R _ c r e a t e |
| 873 | * |
| 874 | ************************************** |
| 875 | * |
| 876 | * Functional description |
| 877 | * Create a new index. |
| 878 | * |
| 879 | **************************************/ |
| 880 | |
| 881 | SET_TDBB(tdbb); |
| 882 | const Database* const dbb = tdbb->getDatabase(); |
| 883 | CHECK_DBB(dbb); |
| 884 | |
| 885 | jrd_rel* const relation = creation.relation; |
| 886 | index_desc* const idx = creation.index; |
| 887 | |
| 888 | // Now that the index id has been checked out, create the index. |
| 889 | idx->idx_root = fast_load(tdbb, creation, selectivity); |
| 890 | |
| 891 | // Index is created. Go back to the index root page and update it to |
| 892 | // point to the index. |
| 893 | RelationPages* const relPages = relation->getPages(tdbb); |
| 894 | WIN window(relPages->rel_pg_space_id, relPages->rel_index_root); |
| 895 | index_root_page* const root = (index_root_page*) CCH_FETCH(tdbb, &window, LCK_write, pag_root); |
| 896 | CCH_MARK(tdbb, &window); |
| 897 | root->irt_rpt[idx->idx_id].setRoot(idx->idx_root); |
| 898 | update_selectivity(root, idx->idx_id, selectivity); |
| 899 | |
| 900 | CCH_RELEASE(tdbb, &window); |
| 901 | } |
| 902 | |
| 903 | |
| 904 | bool BTR_delete_index(thread_db* tdbb, WIN* window, USHORT id) |
no test coverage detected