@@ -156,6 +156,41 @@ pack_row(TABLE *table, MY_BITMAP const* cols,
156156#endif
157157
158158#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
159+ static void insert_row_fields (std::string* row_query, TABLE* table)
160+ {
161+ static uint32_t max_field_len= 100 ;
162+ row_query->append (" (" );
163+ String buf;
164+ #ifndef DBUG_OFF
165+ uint index= 0 ;
166+ #endif
167+ for (Field **ptr=table->field ; *ptr; ptr++)
168+ {
169+ #ifndef DBUG_OFF
170+ // Set the read bit to avoid assertions in val_str().
171+ bool flip= false ;
172+ if (table->read_set && !bitmap_is_set (table->read_set , index))
173+ {
174+ flip= true ;
175+ bitmap_flip_bit (table->read_set , index);
176+ }
177+ #endif
178+ String *s = (*ptr)->val_str (&buf, &buf);
179+ if (!s)
180+ row_query->append (" NULL" );
181+ else
182+ row_query->append (s->ptr (), min (max_field_len, s->length ()));
183+ row_query->append (" ," );
184+ #ifndef DBUG_OFF
185+ if (flip)
186+ bitmap_flip_bit (table->read_set , index);
187+ ++index;
188+ #endif
189+ }
190+ if (row_query->back () == ' ,' )
191+ row_query->back () = ' )' ;
192+ }
193+
159194/* *
160195 Unpack a row into @c table->record[0].
161196
@@ -181,6 +216,8 @@ pack_row(TABLE *table, MY_BITMAP const* cols,
181216 @param row_end
182217 Pointer to variable that will hold the value of the
183218 end position for the data in the row event
219+ @param row_query
220+ Append the fields to this string
184221
185222 @retval 0 No error
186223
@@ -195,7 +232,8 @@ int unpack_row_with_column_info(TABLE *table, uint const colcnt,
195232 ulong *const master_reclength,
196233 uchar const *const row_end,
197234 table_def* tabledef,
198- TABLE *conv_table)
235+ TABLE *conv_table,
236+ std::string* row_query)
199237{
200238 DBUG_ENTER (" unpack_row_with_column_info" );
201239 uchar const *null_bits= row_data;
@@ -273,6 +311,9 @@ int unpack_row_with_column_info(TABLE *table, uint const colcnt,
273311 }
274312 ++null_bit_index;
275313 }
314+
315+ insert_row_fields (row_query, table);
316+
276317 *current_row_end = pack_ptr;
277318 if (master_reclength)
278319 {
@@ -318,6 +359,9 @@ int unpack_row_with_column_info(TABLE *table, uint const colcnt,
318359 Pointer to variable that will hold the value of the
319360 end position for the data in the row event
320361
362+ @param row_query
363+ Append the fields to this string
364+
321365 @retval 0 No error
322366
323367 @retval HA_ERR_GENERIC
@@ -328,7 +372,7 @@ unpack_row(Relay_log_info const *rli,
328372 TABLE *table, uint const colcnt,
329373 uchar const *const row_data, MY_BITMAP const *cols,
330374 uchar const **const current_row_end, ulong *const master_reclength,
331- uchar const *const row_end)
375+ uchar const *const row_end, std::string* row_query )
332376{
333377 DBUG_ENTER (" unpack_row" );
334378 DBUG_ASSERT (row_data);
@@ -382,7 +426,8 @@ unpack_row(Relay_log_info const *rli,
382426 {
383427 DBUG_RETURN (unpack_row_with_column_info (table, colcnt, row_data, cols,
384428 current_row_end, master_reclength,
385- row_end, tabledef, conv_table));
429+ row_end, tabledef, conv_table,
430+ row_query));
386431 }
387432
388433 for (field_ptr= begin_ptr ; field_ptr < end_ptr && *field_ptr ; ++field_ptr)
@@ -568,6 +613,7 @@ unpack_row(Relay_log_info const *rli,
568613 }
569614 }
570615
616+ insert_row_fields (row_query, table);
571617 /*
572618 We should now have read all the null bytes, otherwise something is
573619 really wrong.
0 commit comments