1
|
|
|
# MIT License |
2
|
|
|
# |
3
|
|
|
# Copyright (c) 2017 Matt Boyer |
4
|
|
|
# |
5
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy |
6
|
|
|
# of this software and associated documentation files (the "Software"), to deal |
7
|
|
|
# in the Software without restriction, including without limitation the rights |
8
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
9
|
|
|
# copies of the Software, and to permit persons to whom the Software is |
10
|
|
|
# furnished to do so, subject to the following conditions: |
11
|
|
|
# |
12
|
|
|
# The above copyright notice and this permission notice shall be included in |
13
|
|
|
# all copies or substantial portions of the Software. |
14
|
|
|
# |
15
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
18
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
20
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
21
|
|
|
# SOFTWARE. |
22
|
|
|
|
23
|
|
|
VALID_PAGE_SIZES = (1, 512, 1024, 2048, 4096, 8192, 16384, 32768) |
24
|
|
|
|
25
|
|
|
SQLITE_TABLE_COLUMNS = { |
26
|
|
|
'sqlite_master': ('type', 'name', 'tbl_name', 'rootpage', 'sql',), |
27
|
|
|
'sqlite_sequence': ('name', 'seq',), |
28
|
|
|
'sqlite_stat1': ('tbl', 'idx', 'stat',), |
29
|
|
|
'sqlite_stat2': ('tbl', 'idx', 'sampleno', 'sample'), |
30
|
|
|
'sqlite_stat3': ('tbl', 'idx', 'nEq', 'nLt', 'nDLt', 'sample'), |
31
|
|
|
'sqlite_stat4': ('tbl', 'idx', 'nEq', 'nLt', 'nDLt', 'sample'), |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
# These are the integers used in ptrmap entries to designate the kind of page |
35
|
|
|
# for which a given ptrmap entry holds a notional "child to parent" pointer |
36
|
|
|
BTREE_ROOT_PAGE = 1 |
37
|
|
|
FREELIST_PAGE = 2 |
38
|
|
|
FIRST_OFLOW_PAGE = 3 |
39
|
|
|
NON_FIRST_OFLOW_PAGE = 4 |
40
|
|
|
BTREE_NONROOT_PAGE = 5 |
41
|
|
|
|
42
|
|
|
PTRMAP_PAGE_TYPES = ( |
43
|
|
|
BTREE_ROOT_PAGE, |
44
|
|
|
FREELIST_PAGE, |
45
|
|
|
FIRST_OFLOW_PAGE, |
46
|
|
|
NON_FIRST_OFLOW_PAGE, |
47
|
|
|
BTREE_NONROOT_PAGE, |
48
|
|
|
) |
49
|
|
|
|
50
|
|
|
OVERFLOW_PAGE_TYPES = ( |
51
|
|
|
FIRST_OFLOW_PAGE, |
52
|
|
|
NON_FIRST_OFLOW_PAGE, |
53
|
|
|
) |
54
|
|
|
|
55
|
|
|
# These are identifiers used internally to keep track of page types *before* |
56
|
|
|
# specialised objects can be instantiated |
57
|
|
|
FREELIST_TRUNK_PAGE = 'freelist_trunk' |
58
|
|
|
FREELIST_LEAF_PAGE = 'freelist_leaf' |
59
|
|
|
PTRMAP_PAGE = 'ptrmap_page' |
60
|
|
|
UNKNOWN_PAGE = 'unknown' |
61
|
|
|
|
62
|
|
|
FREELIST_PAGE_TYPES = ( |
63
|
|
|
FREELIST_TRUNK_PAGE, |
64
|
|
|
FREELIST_LEAF_PAGE, |
65
|
|
|
) |
66
|
|
|
|
67
|
|
|
NON_BTREE_PAGE_TYPES = ( |
68
|
|
|
FREELIST_TRUNK_PAGE, |
69
|
|
|
FIRST_OFLOW_PAGE, |
70
|
|
|
NON_FIRST_OFLOW_PAGE, |
71
|
|
|
PTRMAP_PAGE, |
72
|
|
|
) |
73
|
|
|
|