Skip to content

Commit 86291b0

Browse files
author
Mats Kindahl
committed
Merging with mysql-5.1-rep+2-delivery1
2 parents 28286c7 + a3c4467 commit 86291b0

File tree

2 files changed

+32
-14
lines changed

2 files changed

+32
-14
lines changed

sql/rpl_record.cc

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,20 @@ pack_row(TABLE *table, MY_BITMAP const* cols,
150150
the various member functions of Field and subclasses expect to
151151
write.
152152
153-
The row is assumed to only consist of the fields for which the corresponding
154-
bit in bitset @c cols is set; the other parts of the record are left alone.
153+
The row is assumed to only consist of the fields for which the
154+
corresponding bit in bitset @c cols is set; the other parts of the
155+
record are left alone.
155156
156157
At most @c colcnt columns are read: if the table is larger than
157158
that, the remaining fields are not filled in.
158159
159-
@param rli Relay log info
160+
@note The relay log information can be NULL, which means that no
161+
checking or comparison with the source table is done, simply
162+
because it is not used. This feature is used by MySQL Backup to
163+
unpack a row from from the backup image, but can be used for other
164+
purposes as well.
165+
166+
@param rli Relay log info, which can be NULL
160167
@param table Table to unpack into
161168
@param colcnt Number of columns to read from record
162169
@param row_data
@@ -170,10 +177,8 @@ pack_row(TABLE *table, MY_BITMAP const* cols,
170177
171178
@retval 0 No error
172179
173-
@retval ER_NO_DEFAULT_FOR_FIELD
174-
Returned if one of the fields existing on the slave but not on the
175-
master does not have a default value (and isn't nullable)
176-
180+
@retval HA_ERR_GENERIC
181+
A generic, internal, error caused the unpacking to fail.
177182
*/
178183
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
179184
int
@@ -185,8 +190,8 @@ unpack_row(Relay_log_info const *rli,
185190
{
186191
DBUG_ENTER("unpack_row");
187192
DBUG_ASSERT(row_data);
193+
DBUG_ASSERT(table);
188194
size_t const master_null_byte_count= (bitmap_bits_set(cols) + 7) / 8;
189-
int error= 0;
190195

191196
uchar const *null_ptr= row_data;
192197
uchar const *pack_ptr= row_data + master_null_byte_count;
@@ -202,14 +207,21 @@ unpack_row(Relay_log_info const *rli,
202207
// The "current" null bits
203208
unsigned int null_bits= *null_ptr++;
204209
uint i= 0;
205-
table_def *tabledef;
206-
TABLE *conv_table;
207-
bool table_found= rli->get_table_data(table, &tabledef, &conv_table);
210+
table_def *tabledef= NULL;
211+
TABLE *conv_table= NULL;
212+
bool table_found= rli && rli->get_table_data(table, &tabledef, &conv_table);
208213
DBUG_PRINT("debug", ("Table data: table_found: %d, tabldef: %p, conv_table: %p",
209214
table_found, tabledef, conv_table));
210215
DBUG_ASSERT(table_found);
211-
if (!table_found)
212-
return HA_ERR_GENERIC;
216+
217+
/*
218+
If rli is NULL it means that there is no source table and that the
219+
row shall just be unpacked without doing any checks. This feature
220+
is used by MySQL Backup, but can be used for other purposes as
221+
well.
222+
*/
223+
if (rli && !table_found)
224+
DBUG_RETURN(HA_ERR_GENERIC);
213225

214226
for (field_ptr= begin_ptr ; field_ptr < end_ptr && *field_ptr ; ++field_ptr)
215227
{
@@ -372,7 +384,7 @@ unpack_row(Relay_log_info const *rli,
372384
*master_reclength = table->s->reclength;
373385
}
374386

375-
DBUG_RETURN(error);
387+
DBUG_RETURN(0);
376388
}
377389

378390
/**

sql/rpl_utility.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,12 @@ can_convert_field_to(Field *field,
592592
{
593593
if (metadata == 0) // Metadata can only be zero if no metadata was provided
594594
{
595+
/*
596+
If there is no metadata, we either have an old event where no
597+
metadata were supplied, or a type that does not require any
598+
metadata. In either case, conversion can be done but no
599+
conversion table is necessary.
600+
*/
595601
DBUG_PRINT("debug", ("Base types are identical, but there is no metadata"));
596602
*order_var= 0;
597603
DBUG_RETURN(true);

0 commit comments

Comments
 (0)