235
235
mem_heap_free(buf->heap);
238
/******************************************************//**
239
Insert a data tuple into a sort buffer.
240
@return number of rows added, 0 if out of space */
238
/** Convert the field data from compact to redundant format.
239
@param[in] row_field field to copy from
240
@param[out] field field to copy to
241
@param[in] len length of the field data
242
@param[in] zip_size compressed BLOB page size,
243
zero for uncompressed BLOBs
244
@param[in,out] heap memory heap where to allocate data when
245
converting to ROW_FORMAT=REDUNDANT, or NULL
247
row_merge_buf_redundant_convert(). */
250
row_merge_buf_redundant_convert(
251
const dfield_t* row_field,
257
ut_ad(DATA_MBMINLEN(field->type.mbminmaxlen) == 1);
258
ut_ad(DATA_MBMAXLEN(field->type.mbminmaxlen) > 1);
260
byte* buf = (byte*) mem_heap_alloc(heap, len);
261
ulint field_len = row_field->len;
262
ut_ad(field_len <= len);
264
if (row_field->ext) {
265
const byte* field_data = static_cast<byte*>(
266
dfield_get_data(row_field));
269
ut_a(field_len >= BTR_EXTERN_FIELD_REF_SIZE);
270
ut_a(memcmp(field_data + field_len - BTR_EXTERN_FIELD_REF_SIZE,
271
field_ref_zero, BTR_EXTERN_FIELD_REF_SIZE));
273
byte* data = btr_copy_externally_stored_field(
274
&ext_len, field_data, zip_size, field_len, heap);
276
ut_ad(ext_len < len);
278
memcpy(buf, data, ext_len);
281
memcpy(buf, row_field->data, field_len);
284
memset(buf + field_len, 0x20, len - field_len);
286
dfield_set_data(field, buf, len);
289
/** Insert a data tuple into a sort buffer.
290
@param[in,out] buf sort buffer
291
@param[in] fts_index fts index to be created
292
@param[in] old_table original table
293
@param[in,out] psort_info parallel sort info
294
@param[in] row table row
295
@param[in] ext cache of externally stored
296
column prefixes, or NULL
297
@param[in,out] doc_id Doc ID if we are creating
299
@param[in,out] conv_heap memory heap where to allocate data when
300
converting to ROW_FORMAT=REDUNDANT, or NULL
302
row_merge_buf_redundant_convert()
303
@param[in,out] exceed_page set if the record size exceeds the page size
304
when converting to ROW_FORMAT=REDUNDANT
305
@return number of rows added, 0 if out of space */
243
308
row_merge_buf_add(
245
row_merge_buf_t* buf, /*!< in/out: sort buffer */
246
dict_index_t* fts_index,/*!< in: fts index to be created */
247
const dict_table_t* old_table,/*!< in: original table */
248
fts_psort_t* psort_info, /*!< in: parallel sort info */
249
const dtuple_t* row, /*!< in: table row */
250
const row_ext_t* ext, /*!< in: cache of externally stored
251
column prefixes, or NULL */
252
doc_id_t* doc_id) /*!< in/out: Doc ID if we are
253
creating FTS index */
309
row_merge_buf_t* buf,
310
dict_index_t* fts_index,
311
const dict_table_t* old_table,
312
fts_psort_t* psort_info,
314
const row_ext_t* ext,
316
mem_heap_t* conv_heap,
256
320
const dict_index_t* index;
468
if (field->len != UNIV_SQL_NULL
469
&& col->mtype == DATA_MYSQL
470
&& col->len != field->len) {
472
if (conv_heap != NULL) {
473
row_merge_buf_redundant_convert(
474
row_field, field, col->len,
475
dict_table_zip_size(old_table),
478
/* Field length mismatch should not
479
happen when rebuilding redundant row
481
ut_ad(dict_table_is_comp(index->table));
405
486
len = dfield_get_len(field);
1581
1680
row_merge_buf_t* buf = merge_buf[i];
1582
1681
merge_file_t* file = &files[i];
1583
1682
ulint rows_added = 0;
1683
bool exceed_page = false;
1585
1685
if (UNIV_LIKELY
1586
1686
(row && (rows_added = row_merge_buf_add(
1587
1687
buf, fts_index, old_table,
1588
psort_info, row, ext, &doc_id)))) {
1688
psort_info, row, ext, &doc_id,
1689
conv_heap, &exceed_page)))) {
1590
1691
/* If we are creating FTS index,
1591
1692
a single row can generate more
1592
1693
records for tokenized word */
1593
1694
file->n_rec += rows_added;
1697
err = DB_TOO_BIG_RECORD;
1594
1701
if (doc_id > max_doc_id) {
1595
1702
max_doc_id = doc_id;