MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BackupFormat.hpp
1 /*
2  Copyright (C) 2003, 2005-2008 MySQL AB, 2008 Sun Microsystems, Inc.
3  All rights reserved. Use is subject to license terms.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 #ifndef BACKUP_FORMAT_HPP
20 #define BACKUP_FORMAT_HPP
21 
22 #include <ndb_types.h>
23 
24 static const char BACKUP_MAGIC[] = { 'N', 'D', 'B', 'B', 'C', 'K', 'U', 'P' };
25 
26 struct BackupFormat {
27 
31  enum SectionType {
32  FILE_HEADER = 1,
33  FRAGMENT_HEADER = 2,
34  FRAGMENT_FOOTER = 3,
35  TABLE_LIST = 4,
36  TABLE_DESCRIPTION = 5,
37  GCP_ENTRY = 6,
38  FRAGMENT_INFO = 7,
39  EMPTY_ENTRY = 8
40  };
41 
42  struct FileHeader {
43  char Magic[8];
44  Uint32 BackupVersion;
45 
46  Uint32 SectionType;
47  Uint32 SectionLength;
48  Uint32 FileType;
49  Uint32 BackupId;
50  Uint32 BackupKey_0;
51  Uint32 BackupKey_1;
52  Uint32 ByteOrder;
53  Uint32 NdbVersion;
54  Uint32 MySQLVersion;
55  };
56 
58  char Magic[8];
59  Uint32 NdbVersion;
60 
61  Uint32 SectionType;
62  Uint32 SectionLength;
63  Uint32 FileType;
64  Uint32 BackupId;
65  Uint32 BackupKey_0;
66  Uint32 BackupKey_1;
67  Uint32 ByteOrder;
68  };
69 
73  enum FileType {
74  CTL_FILE = 1,
75  LOG_FILE = 2, //redo log file for backup.
76  DATA_FILE = 3,
77  LCP_FILE = 4,
78  UNDO_FILE = 5 //undo log for backup.
79  };
80 
84  struct DataFile {
85 
86  struct FragmentHeader {
87  Uint32 SectionType;
88  Uint32 SectionLength;
89  Uint32 TableId;
90  Uint32 FragmentNo;
91  Uint32 ChecksumType;
92  };
93 
94  struct VariableData {
95  Uint32 Sz;
96  Uint32 Id;
97  Uint32 Data[1];
98  };
99 
100  struct Record {
101  Uint32 Length;
102  Uint32 NullBitmask[1];
103  Uint32 DataFixedKeys[1];
104  Uint32 DataFixedAttributes[1];
105  VariableData DataVariableAttributes[1];
106  };
107 
108  struct FragmentFooter {
109  Uint32 SectionType;
110  Uint32 SectionLength;
111  Uint32 TableId;
112  Uint32 FragmentNo;
113  Uint32 NoOfRecords;
114  Uint32 Checksum;
115  };
116 
117  /* optional padding for O_DIRECT */
118  struct EmptyEntry {
119  Uint32 SectionType;
120  Uint32 SectionLength;
121  /* not used data */
122  };
123  };
124 
128  struct CtlFile {
129 
133  struct TableList {
134  Uint32 SectionType;
135  Uint32 SectionLength;
136  Uint32 TableIds[1]; // Length = SectionLength - 2
137  };
138 
143  Uint32 SectionType;
144  Uint32 SectionLength;
145  Uint32 TableType;
146  Uint32 DictTabInfo[1]; // Length = SectionLength - 3
147  };
148 
152  struct GCPEntry {
153  Uint32 SectionType;
154  Uint32 SectionLength;
155  Uint32 StartGCP;
156  Uint32 StopGCP;
157  };
158 
162  struct FragmentInfo {
163  Uint32 SectionType;
164  Uint32 SectionLength;
165  Uint32 TableId;
166  Uint32 FragmentNo;
167  Uint32 NoOfRecordsLow;
168  Uint32 NoOfRecordsHigh;
169  Uint32 FilePosLow;
170  Uint32 FilePosHigh;
171  };
172  };
173 
177  struct LogFile {
178 
182  struct LogEntry {
183  Uint32 Length;
184  Uint32 TableId;
185  // If TriggerEvent & 0x10000 == true then GCI is right after data
186  Uint32 TriggerEvent;
187  Uint32 FragId;
188  Uint32 Data[1]; // Len = Length - 3
189  };
190 
195  Uint32 Length;
196  Uint32 TableId;
197  // If TriggerEvent & 0x10000 == true then GCI is right after data
198  Uint32 TriggerEvent;
199  Uint32 Data[1]; // Len = Length - 2
200  };
201  };
202 
206  struct LcpFile {
207  CtlFile::TableList TableList;
208  CtlFile::TableDescription TableDescription;
209  DataFile::FragmentHeader FragmentHeader;
211  DataFile::FragmentFooter FragmentFooter;
212  };
213 };
214 
215 #endif