GetActiveMetaPage returns the active meta page and its page ID (0 or 1).
(path string)
| 123 | |
| 124 | // GetActiveMetaPage returns the active meta page and its page ID (0 or 1). |
| 125 | func GetActiveMetaPage(path string) (*common.Meta, common.Pgid, error) { |
| 126 | _, buf0, err0 := ReadPage(path, 0) |
| 127 | if err0 != nil { |
| 128 | return nil, 0, err0 |
| 129 | } |
| 130 | m0 := common.LoadPageMeta(buf0) |
| 131 | _, buf1, err1 := ReadPage(path, 1) |
| 132 | if err1 != nil { |
| 133 | return nil, 1, err1 |
| 134 | } |
| 135 | m1 := common.LoadPageMeta(buf1) |
| 136 | if m0.Txid() < m1.Txid() { |
| 137 | return m1, 1, nil |
| 138 | } else { |
| 139 | return m0, 0, nil |
| 140 | } |
| 141 | } |