~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/ndb/src/kernel/blocks/backup/BackupFormat.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#ifndef BACKUP_FORMAT_HPP
 
17
#define BACKUP_FORMAT_HPP
 
18
 
 
19
#include <ndb_types.h>
 
20
 
 
21
static const char BACKUP_MAGIC[] = { 'N', 'D', 'B', 'B', 'C', 'K', 'U', 'P' };
 
22
 
 
23
struct BackupFormat {
 
24
 
 
25
  /**
 
26
   * Section types in file
 
27
   */
 
28
  enum SectionType {
 
29
    FILE_HEADER       = 1,
 
30
    FRAGMENT_HEADER   = 2,
 
31
    FRAGMENT_FOOTER   = 3,
 
32
    TABLE_LIST        = 4,
 
33
    TABLE_DESCRIPTION = 5,
 
34
    GCP_ENTRY         = 6,
 
35
    FRAGMENT_INFO     = 7,
 
36
    EMPTY_ENTRY       = 8
 
37
  };
 
38
 
 
39
  struct FileHeader {
 
40
    char Magic[8];
 
41
    Uint32 NdbVersion;
 
42
 
 
43
    Uint32 SectionType;
 
44
    Uint32 SectionLength;
 
45
    Uint32 FileType;
 
46
    Uint32 BackupId;
 
47
    Uint32 BackupKey_0;
 
48
    Uint32 BackupKey_1;
 
49
    Uint32 ByteOrder;
 
50
  };
 
51
  
 
52
  /**
 
53
   * File types
 
54
   */
 
55
  enum FileType {
 
56
    CTL_FILE = 1,
 
57
    LOG_FILE = 2,
 
58
    DATA_FILE = 3,
 
59
    LCP_FILE = 4
 
60
  };
 
61
  
 
62
  /**
 
63
   * Data file formats
 
64
   */
 
65
  struct DataFile {
 
66
 
 
67
    struct FragmentHeader {
 
68
      Uint32 SectionType;
 
69
      Uint32 SectionLength;
 
70
      Uint32 TableId;
 
71
      Uint32 FragmentNo;
 
72
      Uint32 ChecksumType;
 
73
    };
 
74
    
 
75
    struct VariableData {
 
76
      Uint32 Sz;
 
77
      Uint32 Id;
 
78
      Uint32 Data[1];
 
79
    };
 
80
    
 
81
    struct Record {
 
82
      Uint32 Length;
 
83
      Uint32 NullBitmask[1];
 
84
      Uint32 DataFixedKeys[1];
 
85
      Uint32 DataFixedAttributes[1];
 
86
      VariableData DataVariableAttributes[1];
 
87
    };
 
88
    
 
89
    struct FragmentFooter {
 
90
      Uint32 SectionType;
 
91
      Uint32 SectionLength;
 
92
      Uint32 TableId;
 
93
      Uint32 FragmentNo;
 
94
      Uint32 NoOfRecords;
 
95
      Uint32 Checksum;
 
96
    };
 
97
 
 
98
    /* optional padding for O_DIRECT */
 
99
    struct EmptyEntry {
 
100
      Uint32 SectionType;
 
101
      Uint32 SectionLength;
 
102
      /* not used data */
 
103
    };
 
104
  };
 
105
 
 
106
  /**
 
107
   * CTL file formats
 
108
   */
 
109
  struct CtlFile {
 
110
    
 
111
    /**
 
112
     * Table list
 
113
     */
 
114
    struct TableList {
 
115
      Uint32 SectionType;
 
116
      Uint32 SectionLength;
 
117
      Uint32 TableIds[1];      // Length = SectionLength - 2
 
118
    };
 
119
 
 
120
    /**
 
121
     * Table description(s)
 
122
     */
 
123
    struct TableDescription {
 
124
      Uint32 SectionType;
 
125
      Uint32 SectionLength;
 
126
      Uint32 TableType;
 
127
      Uint32 DictTabInfo[1];   // Length = SectionLength - 3
 
128
    };
 
129
 
 
130
    /**
 
131
     * GCP Entry
 
132
     */
 
133
    struct GCPEntry {
 
134
      Uint32 SectionType;
 
135
      Uint32 SectionLength;
 
136
      Uint32 StartGCP;
 
137
      Uint32 StopGCP;
 
138
    };
 
139
 
 
140
    /**
 
141
     * Fragment Info
 
142
     */
 
143
    struct FragmentInfo {
 
144
      Uint32 SectionType;
 
145
      Uint32 SectionLength;
 
146
      Uint32 TableId;
 
147
      Uint32 FragmentNo;
 
148
      Uint32 NoOfRecordsLow;
 
149
      Uint32 NoOfRecordsHigh;
 
150
      Uint32 FilePosLow;
 
151
      Uint32 FilePosHigh;
 
152
    };
 
153
  };
 
154
 
 
155
  /**
 
156
   * LOG file format
 
157
   */
 
158
  struct LogFile {
 
159
 
 
160
    /**
 
161
     * Log Entry
 
162
     */
 
163
    struct LogEntry {
 
164
      Uint32 Length;
 
165
      Uint32 TableId;
 
166
      // If TriggerEvent & 0x10000 == true then GCI is right after data
 
167
      Uint32 TriggerEvent;
 
168
      Uint32 FragId;
 
169
      Uint32 Data[1]; // Len = Length - 3
 
170
    };
 
171
 
 
172
    /**
 
173
     * Log Entry pre NDBD_FRAGID_VERSION
 
174
     */
 
175
    struct LogEntry_no_fragid {
 
176
      Uint32 Length;
 
177
      Uint32 TableId;
 
178
      // If TriggerEvent & 0x10000 == true then GCI is right after data
 
179
      Uint32 TriggerEvent;
 
180
      Uint32 Data[1]; // Len = Length - 2
 
181
    };
 
182
  };
 
183
 
 
184
  /**
 
185
   * LCP file format
 
186
   */
 
187
  struct LcpFile {
 
188
    CtlFile::TableList TableList;
 
189
    CtlFile::TableDescription TableDescription;
 
190
    DataFile::FragmentHeader FragmentHeader;
 
191
    DataFile::Record Record;
 
192
    DataFile::FragmentFooter FragmentFooter;
 
193
  };
 
194
};
 
195
 
 
196
#endif