(p *common.Page, hwm common.Pgid, stack []common.Pgid, reachable map[common.Pgid]*common.Page, freed map[common.Pgid]bool, ch chan error)
| 153 | } |
| 154 | |
| 155 | func verifyPageReachable(p *common.Page, hwm common.Pgid, stack []common.Pgid, reachable map[common.Pgid]*common.Page, freed map[common.Pgid]bool, ch chan error) { |
| 156 | if p.Id() > hwm { |
| 157 | ch <- fmt.Errorf("page %d: out of bounds: %d (stack: %v)", int(p.Id()), int(hwm), stack) |
| 158 | } |
| 159 | |
| 160 | // Ensure each page is only referenced once. |
| 161 | for i := common.Pgid(0); i <= common.Pgid(p.Overflow()); i++ { |
| 162 | var id = p.Id() + i |
| 163 | if _, ok := reachable[id]; ok { |
| 164 | ch <- fmt.Errorf("page %d: multiple references (stack: %v)", int(id), stack) |
| 165 | } |
| 166 | reachable[id] = p |
| 167 | } |
| 168 | |
| 169 | // We should only encounter un-freed leaf and branch pages. |
| 170 | if freed[p.Id()] { |
| 171 | ch <- fmt.Errorf("page %d: reachable freed", int(p.Id())) |
| 172 | } else if !p.IsBranchPage() && !p.IsLeafPage() { |
| 173 | ch <- fmt.Errorf("page %d: invalid type: %s (stack: %v)", int(p.Id()), p.Typ(), stack) |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | // recursivelyCheckPageKeyOrder verifies database consistency with respect to b-tree |
| 178 | // key order constraints: |
no test coverage detected