40
40
Classes @c Db_ref and @c Table_ref are used to identify databases and tables
41
41
inside mysql server instance.
43
These classes abstract the way a table or database is identified inside mysqld,
44
so that when this changes (introduction of global db/table ids, introduction
45
of catalogues) it is easy to adapt backup code to the new identification schema.
43
These classes abstract the way a table or database is identified inside
44
mysqld, so that when this changes (introduction of global db/table ids,
45
introduction of catalogues) it is easy to adapt backup code to the new
46
identification schema.
47
48
Regardless of the internal representation, classes provide methods returning
48
db/table name as a @c String object. Also, each table belongs to some database
49
and a method returning @c Db_ref object identifying this database is present.
50
For @c Db_ref objects there is @c catalog() method returning name of the
51
catalogue, but currently it always returns null string.
49
db/table name as a @c String object. Also, each table belongs to some
50
database and a method returning @c Db_ref object identifying this database is
51
present. For @c Db_ref objects there is @c catalog() method returning name of
52
the catalogue, but currently it always returns null string.
53
54
Classes are implemented so that the memory for storing names can be allocated
54
55
outside an instance. This allows for sharing space used e.g., to store
81
82
{ return my_null_string; }
83
84
bool operator==(const Db_ref &db) const
84
{ return stringcmp(m_name,&db.name())==0; }
85
{ return stringcmp(m_name, &db.name()) == 0; }
86
87
bool operator!=(const Db_ref &db) const
87
{ return ! this->operator==(db); }
88
{ return ! this->operator == (db); }
91
92
// Constructors are made protected as clients of this class are
92
93
// not supposed to create instances (see comment inside Table_ref)
94
Db_ref(const String &name): m_name(&name)
95
Db_ref(const String &name) :m_name(&name)
97
98
friend class Table_ref;
121
122
bool operator==(const Table_ref &t) const
123
124
return m_db == t.db() &&
124
stringcmp(m_name,&t.name()) == 0;
125
stringcmp(m_name, &t.name()) == 0;
127
128
bool operator!=(const Table_ref &db) const
128
129
{ return ! this->operator==(db); }
130
typedef char describe_buf[512];
132
/// Produce string identifying the table (e.g. for error reporting)
133
const char* describe(char *buf, size_t len) const
135
my_snprintf(buf,len,"%s.%s",db().name().ptr(),name().ptr());
139
const char* describe(describe_buf &buf) const
140
{ return describe(buf,sizeof(buf)); }
131
typedef char name_buf[FN_REFLEN];
133
// Produce string identifying the table (e.g. for error reporting)
134
const char* describe(char *buf, size_t len) const;
135
const char* describe(name_buf &buf) const
136
{ return describe(buf, sizeof(buf)); }
138
// Produce string identifying the table in internal format.
139
const char* internal_name(char *buf, size_t len) const;
140
const char* internal_name(name_buf &buf) const
141
{ return internal_name(buf, sizeof(buf)); };
174
175
adds this interface to a list of tables represented by a linked list of
175
176
@c TABLE_LIST structures as used elsewhere in the code. On the other hand,
176
177
much more space efficient implementations are possible, as for each table we
177
need to store only table's identity (db/table name). In any case, the interface
178
to the list remains the same, as defined by this class.
178
need to store only table's identity (db/table name). In any case, the
179
interface to the list remains the same, as defined by this class.
187
186
virtual ~Table_list() {}
189
188
/// Return reference to given list element. Elements are counted from 0.
190
virtual Table_ref operator[](uint pos) const =0;
189
virtual Table_ref operator[](ulong pos) const =0;
192
191
/// Return number of elements in the list.
193
virtual uint count() const =0;
192
virtual ulong count() const =0;
200
199
@brief Used for data transfers between backup kernel and backup/restore
203
Apart from allocated memory a @c Buffer structure contains fields informing about
204
its size and holding other information about contained data. Buffers are
202
Apart from allocated memory a @c Buffer structure contains fields informing
203
about its size and holding other information about contained data. Buffers are
205
204
created and memory is allocated by backup kernel. It is also kernel's
206
205
responsibility to write contents of buffers to a backup stream.
208
207
Data created by a backup driver is opaque to the kernel. However, to support
209
208
selective restores, each block of data can be assigned to one of the tables
210
being backed-up. This is done by setting @c table_no member of the
209
being backed-up. This is done by setting @c table_num member of the
211
210
buffer structure to the number of the table to which this data belongs. Tables
212
211
are numbered from 1 according to their position in the list passed when driver
213
212
is created (@c m_tables member of @c Driver class). If
214
213
some of the data doesn't correspond to any particular table, then
215
@c table_no should be set to 0.
214
@c table_num should be set to 0.
217
216
This way, driver can create several "streams" of data blocks. For each table
218
217
there is a stream corresponding to that table and there is one "shared stream"
219
consisting of blocks with @c table_no set to 0. Upon restore, kernel
218
consisting of blocks with @c table_num set to 0. Upon restore, kernel
220
219
sends to a restore driver only blocks corresponding to the tables being
221
220
restored plus all the blocks from the shared stream.
258
257
size_t size; ///< size of the buffer (of memory block pointed by data).
259
uint table_no; ///< Number of the table to which data in the buffer belongs.
258
uint table_num; ///< Number of the table to which data in the buffer belongs.
260
259
bool last; ///< TRUE if this is last block of data in the stream.
261
260
byte *data; ///< Pointer to data area.
263
Buffer(): size(0),table_no(0),last(FALSE), data(NULL)
262
Buffer() :size(0), table_num(0), last(FALSE), data(NULL)
266
265
void reset(size_t len)
281
280
typedef backup::result_t Backup_result_t;
282
281
typedef backup::Engine Backup_engine;
283
typedef Backup_result_t backup_factory(::handlerton *,Backup_engine*&);
282
typedef Backup_result_t backup_factory(::handlerton *, Backup_engine*&);