| 1985 | } |
| 1986 | |
| 1987 | Validation::RTN Validation::walk_index(jrd_rel* relation, index_root_page& root_page, USHORT id) |
| 1988 | { |
| 1989 | /************************************** |
| 1990 | * |
| 1991 | * w a l k _ i n d e x |
| 1992 | * |
| 1993 | ************************************** |
| 1994 | * |
| 1995 | * Functional description |
| 1996 | * Walk all btree pages left-to-right and top-down. |
| 1997 | * Check all the pointers and keys for consistency |
| 1998 | * relative to each other, and check sibling pointers. |
| 1999 | * |
| 2000 | * NOTE: id is the internal index id, relative for each |
| 2001 | * relation. It is 1 less than the user level index id. |
| 2002 | * So errors are reported against index id+1 |
| 2003 | * |
| 2004 | **************************************/ |
| 2005 | Database* dbb = vdr_tdbb->getDatabase(); |
| 2006 | |
| 2007 | const ULONG page_number = root_page.irt_rpt[id].getRoot(); |
| 2008 | if (!page_number) { |
| 2009 | return rtn_ok; |
| 2010 | } |
| 2011 | |
| 2012 | const bool unique = (root_page.irt_rpt[id].irt_flags & (irt_unique | idx_primary)); |
| 2013 | const bool descending = (root_page.irt_rpt[id].irt_flags & irt_descending); |
| 2014 | const bool condition = (root_page.irt_rpt[id].irt_flags & irt_condition); |
| 2015 | |
| 2016 | temporary_key nullKey, *null_key = 0; |
| 2017 | if (unique) |
| 2018 | { |
| 2019 | index_desc idx; |
| 2020 | { |
| 2021 | // No need to evaluate index expression and/or condition |
| 2022 | AutoSetRestoreFlag<UCHAR> flags(&root_page.irt_rpt[id].irt_flags, |
| 2023 | irt_expression | irt_condition, false); |
| 2024 | |
| 2025 | BTR_description(vdr_tdbb, relation, &root_page, &idx, id); |
| 2026 | } |
| 2027 | |
| 2028 | null_key = &nullKey; |
| 2029 | BTR_make_null_key(vdr_tdbb, &idx, null_key); |
| 2030 | } |
| 2031 | |
| 2032 | ULONG next = page_number; |
| 2033 | ULONG down = page_number; |
| 2034 | temporary_key key; |
| 2035 | key.key_length = 0; |
| 2036 | ULONG previous_number = 0; |
| 2037 | UCHAR level = 255; |
| 2038 | |
| 2039 | RecordBitmap::reset(vdr_idx_records); |
| 2040 | |
| 2041 | bool firstNode = true; |
| 2042 | bool nullKeyNode = false; // current node is a null key of unique index |
| 2043 | bool nullKeyHandled = !(unique && null_key); // null key of unique index was handled |
| 2044 |
nothing calls this directly
no test coverage detected