-
Notifications
You must be signed in to change notification settings - Fork 0
/
fb_struct.h
155 lines (137 loc) · 5.35 KB
/
fb_struct.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//
// Created by volkov on 04.11.2021.
//
#ifndef FB_TRIM_FB_STRUCT_H
#define FB_TRIM_FB_STRUCT_H
typedef signed char SCHAR;
typedef unsigned char UCHAR;
typedef signed short SSHORT;
typedef unsigned short USHORT;
typedef signed int SLONG;
typedef unsigned int ULONG;
struct page_header {
SCHAR page_type;
UCHAR page_flags;
USHORT pag_checksum;
ULONG pag_generation;
ULONG pag_scn;
ULONG reserved;
};
//Universal header_page (cut) for ODS11, ODS12, ODS13
struct header_page
{
struct page_header header;
USHORT hdr_page_size; // Page size of database
USHORT hdr_ods_version; // Version of on-disk structure
SLONG hdr_PAGES; // Page number of PAGES relation
ULONG hdr_next_page; // Page number of next hdr page
SLONG hdr_oldest_transaction; // Oldest interesting transaction
SLONG hdr_oldest_active; // Oldest transaction thought active
SLONG hdr_next_transaction; // Next transaction id
USHORT hdr_sequence; // sequence number of file
USHORT hdr_flags; // Flag settings, see below
SLONG hdr_creation_date[2]; // Date/time of creation
SLONG hdr_attachment_id; // Next attachment id
SLONG hdr_shadow_count; // Event count for shadow synchronization
};
// Header page flags
const USHORT hdr_active_shadow = 0x1; // 1 file is an active shadow file
const USHORT hdr_force_write = 0x2; // 2 database is forced write
const USHORT hdr_crypt_process = 0x4; // 4 Encryption status is changing now
const USHORT hdr_no_reserve = 0x8; // 8 FB unused
const USHORT rdb26_hdr_encrypted = 0x8; // RDB2.6 database is encrypted
const USHORT hdr_SQL_dialect_3 = 0x10; // 16 don't calculate checksums
const USHORT hdr_read_only = 0x20; // 32 don't reserve space for versions
const USHORT hdr_encrypted = 0x40; // 64 FB Database is encrypted
const USHORT rdb26_hdr_replica = 0x40; // RDB2.6 database is a replication target
// Reserved for hdr_shutdown_multi, see below // 128
const USHORT hdr_replica = 0x100; // 256 RDB3 Database is a replication target
const USHORT fb2_hdr_SQL_dialect_3 = 0x100; // 256 FB2 database SQL dialect 3
const USHORT fb2_hdr_read_only = 0x200; // 512 FB2 Database in ReadOnly. If not set, DB is RW
const USHORT hdr_backup_mask = 0xC00;
const USHORT hdr_shutdown_mask = 0x1080;
const USHORT hdr_replica_mask = 0x6000;
// Values for backup mask
const USHORT hdr_nbak_normal = 0x000; // Normal mode. Changes are simply written to main files
const USHORT hdr_nbak_stalled = 0x400; // 1024 Main files are locked. Changes are written to diff file
const USHORT hdr_nbak_merge = 0x800; // 2048 Merging changes from diff file into main files
// Values for shutdown mask
const USHORT hdr_shutdown_none = 0x0;
const USHORT hdr_shutdown_multi = 0x80;
const USHORT hdr_shutdown_full = 0x1000;
const USHORT hdr_shutdown_single = 0x1080;
// Values for replica mask
const USHORT hdr_replica_none = 0x0000;
const USHORT hdr_replica_read_only = 0x2000;
const USHORT hdr_replica_read_write = 0x4000;
//ODS11, ODS12, ODS13
struct blob_page {
struct page_header header;
ULONG blp_lead_page; // First page of blob (for redundancy only)
ULONG blp_sequence; // Sequence within blob
USHORT blp_length; // Bytes on page
USHORT blp_pad; // Unused
ULONG blp_page[1]; // Page number if level 1
};
//ODS11, ODS12, ODS13
struct data_page {
struct page_header header;
ULONG dpg_sequence;
USHORT relation;
USHORT count;
struct dpg_repeat {
USHORT dpg_offset;
USHORT dpg_length;
} dpg_rpt[1];
};
//ODS11
struct pip_page_ods11 {
struct page_header header;
SLONG min;
UCHAR bits[1];
};
//ODS12, ODS13
struct pip_page_ods12 {
struct page_header header;
ULONG min;
ULONG pip_extent;
ULONG pip_used;
UCHAR bits[1];
};
struct btree_page {
struct page_header header;
SLONG btr_sibling; // right sibling page
SLONG btr_left_sibling; // left sibling page
SLONG btr_prefix_total; // sum of all prefixes on page
USHORT btr_relation; // relation id for consistency
USHORT btr_length; // length of data in bucket
UCHAR btr_id; // index id for consistency
UCHAR btr_level; // index level (0 = leaf)
};
const ULONG FIRST_PIP_PAGE = 1;
#define PT_UNDEFINED_PAGE 0
#define PT_HEADER 1
#define PT_PAGE_INVENTORY 2
#define PT_TRANSACTION_INVENTORY 3
#define PT_POINTER_PAGE 4
#define PT_DATA 5
#define PT_INDEX_ROOT 6
#define PT_B_TREE 7
#define PT_BLOB 8
#define PT_GENERATOR 9
#define PT_WRITE_AHEAD_LOG 10
#define MAX_PAGE_TYPE 10
const char *page_type_name[MAX_PAGE_TYPE + 1] = {
"undefined",
"header page",
"page inventory page",
"transaction inventory page",
"pointer page",
"data page",
"index root page",
"index b-tree page",
"blob page",
"generator page",
"write ahead log"
};
#endif //FB_TRIM_FB_STRUCT_H