()
| 11 | ) |
| 12 | |
| 13 | func newStatsCommand() *cobra.Command { |
| 14 | statsCmd := &cobra.Command{ |
| 15 | Use: "stats <bbolt-file>", |
| 16 | Short: "print stats of bbolt database", |
| 17 | Long: strings.TrimLeft(` |
| 18 | usage: bolt stats PATH |
| 19 | |
| 20 | Stats performs an extensive search of the database to track every page |
| 21 | reference. It starts at the current meta page and recursively iterates |
| 22 | through every accessible bucket. |
| 23 | |
| 24 | The following errors can be reported: |
| 25 | |
| 26 | already freed |
| 27 | The page is referenced more than once in the freelist. |
| 28 | |
| 29 | unreachable unfreed |
| 30 | The page is not referenced by a bucket or in the freelist. |
| 31 | |
| 32 | reachable freed |
| 33 | The page is referenced by a bucket but is also in the freelist. |
| 34 | |
| 35 | out of bounds |
| 36 | A page is referenced that is above the high water mark. |
| 37 | |
| 38 | multiple references |
| 39 | A page is referenced by more than one other page. |
| 40 | |
| 41 | invalid type |
| 42 | The page type is not "meta", "leaf", "branch", or "freelist". |
| 43 | |
| 44 | No errors should occur in your database. However, if for some reason you |
| 45 | experience corruption, please submit a ticket to the etcd-io/bbolt project page: |
| 46 | |
| 47 | https://github.com/etcd-io/bbolt/issues |
| 48 | `, "\n"), |
| 49 | Args: cobra.RangeArgs(1, 2), |
| 50 | RunE: func(cmd *cobra.Command, args []string) error { |
| 51 | prefix := "" |
| 52 | if len(args) > 1 { |
| 53 | prefix = args[1] |
| 54 | } |
| 55 | |
| 56 | return statsFunc(cmd, args[0], prefix) |
| 57 | }, |
| 58 | } |
| 59 | |
| 60 | return statsCmd |
| 61 | } |
| 62 | |
| 63 | func statsFunc(cmd *cobra.Command, dbPath string, prefix string) error { |
| 64 | if _, err := checkSourceDBPath(dbPath); err != nil { |
no test coverage detected