@@ -150,13 +150,20 @@ pack_row(TABLE *table, MY_BITMAP const* cols,
150
150
the various member functions of Field and subclasses expect to
151
151
write.
152
152
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.
155
156
156
157
At most @c colcnt columns are read: if the table is larger than
157
158
that, the remaining fields are not filled in.
158
159
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
160
167
@param table Table to unpack into
161
168
@param colcnt Number of columns to read from record
162
169
@param row_data
@@ -170,10 +177,8 @@ pack_row(TABLE *table, MY_BITMAP const* cols,
170
177
171
178
@retval 0 No error
172
179
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.
177
182
*/
178
183
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
179
184
int
@@ -184,8 +189,8 @@ unpack_row(Relay_log_info const *rli,
184
189
{
185
190
DBUG_ENTER (" unpack_row" );
186
191
DBUG_ASSERT (row_data);
192
+ DBUG_ASSERT (table);
187
193
size_t const master_null_byte_count= (bitmap_bits_set (cols) + 7 ) / 8 ;
188
- int error= 0 ;
189
194
190
195
uchar const *null_ptr= row_data;
191
196
uchar const *pack_ptr= row_data + master_null_byte_count;
@@ -201,14 +206,21 @@ unpack_row(Relay_log_info const *rli,
201
206
// The "current" null bits
202
207
unsigned int null_bits= *null_ptr++;
203
208
uint i= 0 ;
204
- table_def *tabledef;
205
- TABLE *conv_table;
206
- bool table_found= rli->get_table_data (table, &tabledef, &conv_table);
209
+ table_def *tabledef= NULL ;
210
+ TABLE *conv_table= NULL ;
211
+ bool table_found= rli && rli ->get_table_data (table, &tabledef, &conv_table);
207
212
DBUG_PRINT (" debug" , (" Table data: table_found: %d, tabldef: %p, conv_table: %p" ,
208
213
table_found, tabledef, conv_table));
209
214
DBUG_ASSERT (table_found);
210
- if (!table_found)
211
- return HA_ERR_GENERIC;
215
+
216
+ /*
217
+ If rli is NULL it means that there is no source table and that the
218
+ row shall just be unpacked without doing any checks. This feature
219
+ is used by MySQL Backup, but can be used for other purposes as
220
+ well.
221
+ */
222
+ if (rli && !table_found)
223
+ DBUG_RETURN (HA_ERR_GENERIC);
212
224
213
225
for (field_ptr= begin_ptr ; field_ptr < end_ptr && *field_ptr ; ++field_ptr)
214
226
{
@@ -221,7 +233,7 @@ unpack_row(Relay_log_info const *rli,
221
233
conv_table ? conv_table->field [field_ptr - begin_ptr] : NULL ;
222
234
Field *const f=
223
235
conv_field ? conv_field : *field_ptr;
224
- DBUG_PRINT (" debug" , (" Conversion %srequired for field '%s' (#%d )" ,
236
+ DBUG_PRINT (" debug" , (" Conversion %srequired for field '%s' (#%ld )" ,
225
237
conv_field ? " " : " not " ,
226
238
(*field_ptr)->field_name , field_ptr - begin_ptr));
227
239
DBUG_ASSERT (f != NULL );
@@ -285,7 +297,7 @@ unpack_row(Relay_log_info const *rli,
285
297
conv_field->val_str (&value_string);
286
298
DBUG_PRINT (" debug" , (" Copying field '%s' of type '%s' with value '%s'" ,
287
299
(*field_ptr)->field_name ,
288
- source_type.c_ptr (), value_string.c_ptr ()));
300
+ source_type.c_ptr_safe (), value_string.c_ptr_safe ()));
289
301
#endif
290
302
copy.set (*field_ptr, f, TRUE );
291
303
(*copy.do_copy )(©);
@@ -296,7 +308,7 @@ unpack_row(Relay_log_info const *rli,
296
308
(*field_ptr)->val_str (&value_string);
297
309
DBUG_PRINT (" debug" , (" Value of field '%s' of type '%s' is now '%s'" ,
298
310
(*field_ptr)->field_name ,
299
- target_type.c_ptr (), value_string.c_ptr ()));
311
+ target_type.c_ptr_safe (), value_string.c_ptr_safe ()));
300
312
#endif
301
313
}
302
314
@@ -344,7 +356,7 @@ unpack_row(Relay_log_info const *rli,
344
356
*master_reclength = table->s ->reclength ;
345
357
}
346
358
347
- DBUG_RETURN (error );
359
+ DBUG_RETURN (0 );
348
360
}
349
361
350
362
/* *
0 commit comments