| 902 | |
| 903 | |
| 904 | bool BTR_delete_index(thread_db* tdbb, WIN* window, USHORT id) |
| 905 | { |
| 906 | /************************************** |
| 907 | * |
| 908 | * B T R _ d e l e t e _ i n d e x |
| 909 | * |
| 910 | ************************************** |
| 911 | * |
| 912 | * Functional description |
| 913 | * Delete an index if it exists. |
| 914 | * Return true if index tree was there. |
| 915 | * |
| 916 | **************************************/ |
| 917 | SET_TDBB(tdbb); |
| 918 | const Database* dbb = tdbb->getDatabase(); |
| 919 | CHECK_DBB(dbb); |
| 920 | |
| 921 | // Get index descriptor. If index doesn't exist, just leave. |
| 922 | index_root_page* const root = (index_root_page*) window->win_buffer; |
| 923 | |
| 924 | bool tree_exists = false; |
| 925 | if (id >= root->irt_count) |
| 926 | CCH_RELEASE(tdbb, window); |
| 927 | else |
| 928 | { |
| 929 | index_root_page::irt_repeat* irt_desc = root->irt_rpt + id; |
| 930 | CCH_MARK(tdbb, window); |
| 931 | const PageNumber next(window->win_page.getPageSpaceID(), irt_desc->getRoot()); |
| 932 | tree_exists = (irt_desc->getRoot() != 0); |
| 933 | |
| 934 | // remove the pointer to the top-level index page before we delete it |
| 935 | irt_desc->setRoot(0); |
| 936 | irt_desc->irt_flags = 0; |
| 937 | const PageNumber prior = window->win_page; |
| 938 | const USHORT relation_id = root->irt_relation; |
| 939 | |
| 940 | CCH_RELEASE(tdbb, window); |
| 941 | delete_tree(tdbb, relation_id, id, next, prior); |
| 942 | } |
| 943 | |
| 944 | return tree_exists; |
| 945 | } |
| 946 | |
| 947 | |
| 948 | bool BTR_description(thread_db* tdbb, jrd_rel* relation, index_root_page* root, index_desc* idx, |
no test coverage detected