11/* ****************************************************************************
22
3- Copyright (c) 2011, 2017 , Oracle and/or its affiliates. All Rights Reserved.
3+ Copyright (c) 2011, 2018 , Oracle and/or its affiliates. All Rights Reserved.
44
55This program is free software; you can redistribute it and/or modify it under
66the terms of the GNU General Public License, version 2.0, as published by the
@@ -462,6 +462,8 @@ row_log_table_open(
462462 *avail = srv_sort_buf_size - log->tail .bytes ;
463463
464464 if (size > *avail) {
465+ /* Make sure log->tail.buf is large enough */
466+ ut_ad (size <= sizeof log->tail .buf );
465467 return (log->tail .buf );
466468 } else {
467469 return (log->tail .block + log->tail .bytes );
@@ -574,12 +576,10 @@ row_log_table_delete(
574576{
575577 ulint old_pk_extra_size;
576578 ulint old_pk_size;
577- ulint ext_size = 0 ;
578579 ulint mrec_size;
579580 ulint avail_size;
580581 mem_heap_t * heap = NULL ;
581582 const dtuple_t * old_pk;
582- row_ext_t * ext = NULL ;
583583
584584 if (index->is_corrupted ()
585585 || !dict_index_is_online_ddl (index)
@@ -659,29 +659,8 @@ row_log_table_delete(
659659 &old_pk_extra_size);
660660 ut_ad (old_pk_extra_size < 0x100 );
661661
662- mrec_size = 6 + old_pk_size;
663-
664- /* Log enough prefix of the BLOB unless both the
665- old and new table are in COMPACT or REDUNDANT format,
666- which store the prefix in the clustered index record. */
667- if (rec_offs_any_extern (offsets)
668- && (dict_table_has_atomic_blobs (index->table )
669- || dict_table_has_atomic_blobs (new_table))) {
670-
671- /* Build a cache of those off-page column prefixes
672- that are referenced by secondary indexes. It can be
673- that none of the off-page columns are needed. */
674- row_build (ROW_COPY_DATA, index, rec,
675- offsets, NULL , NULL , NULL , &ext, heap);
676- if (ext) {
677- /* Log the row_ext_t, ext->ext and ext->buf */
678- ext_size = ext->n_ext * ext->max_len
679- + sizeof (*ext)
680- + ext->n_ext * sizeof (ulint)
681- + (ext->n_ext - 1 ) * sizeof ext->len ;
682- mrec_size += ext_size;
683- }
684- }
662+ /* 2 = 1 (extra_size) + at least 1 byte payload */
663+ mrec_size = 2 + old_pk_size;
685664
686665 /* Check if we need to log virtual column data */
687666 if (ventry->n_v_fields > 0 ) {
@@ -695,43 +674,12 @@ row_log_table_delete(
695674 *b++ = ROW_T_DELETE;
696675 *b++ = static_cast <byte>(old_pk_extra_size);
697676
698- /* Log the size of external prefix we saved */
699- mach_write_to_4 (b, ext_size);
700- b += 4 ;
701-
702677 rec_convert_dtuple_to_temp (
703678 b + old_pk_extra_size, new_index,
704679 old_pk->fields , old_pk->n_fields , NULL );
705680
706681 b += old_pk_size;
707682
708- if (ext_size) {
709- ulint cur_ext_size = sizeof (*ext)
710- + (ext->n_ext - 1 ) * sizeof ext->len ;
711-
712- memcpy (b, ext, cur_ext_size);
713- b += cur_ext_size;
714-
715- /* Check if we need to col_map to adjust the column
716- number. If columns were added/removed/reordered,
717- adjust the column number. */
718- if (const ulint* col_map =
719- index->online_log ->col_map ) {
720- for (ulint i = 0 ; i < ext->n_ext ; i++) {
721- const_cast <ulint&>(ext->ext [i]) =
722- col_map[ext->ext [i]];
723- }
724- }
725-
726- memcpy (b, ext->ext , ext->n_ext * sizeof (*ext->ext ));
727- b += ext->n_ext * sizeof (*ext->ext );
728-
729- ext_size -= cur_ext_size
730- + ext->n_ext * sizeof (*ext->ext );
731- memcpy (b, ext->buf , ext_size);
732- b += ext_size;
733- }
734-
735683 /* log virtual columns */
736684 if (ventry->n_v_fields > 0 ) {
737685 rec_convert_dtuple_to_temp (
@@ -1785,8 +1733,6 @@ row_log_table_apply_delete_low(
17851733 const dtuple_t * ventry, /* !< in: dtuple holding
17861734 virtual column info */
17871735 const ulint* offsets, /* !< in: offsets on pcur */
1788- const row_ext_t * save_ext, /* !< in: saved external field
1789- info, or NULL */
17901736 mem_heap_t * heap, /* !< in/out: memory heap */
17911737 mtr_t * mtr) /* !< in/out: mini-transaction,
17921738 will be committed */
@@ -1808,15 +1754,10 @@ row_log_table_apply_delete_low(
18081754 /* Build a row template for purging secondary index entries. */
18091755 row = row_build (
18101756 ROW_COPY_DATA, index, btr_pcur_get_rec (pcur),
1811- offsets, NULL , NULL , NULL ,
1812- save_ext ? NULL : &ext, heap);
1757+ offsets, NULL , NULL , NULL , &ext, heap);
18131758 if (ventry) {
18141759 dtuple_copy_v_fields (row, ventry);
18151760 }
1816-
1817- if (!save_ext) {
1818- save_ext = ext;
1819- }
18201761 } else {
18211762 row = NULL ;
18221763 }
@@ -1835,7 +1776,7 @@ row_log_table_apply_delete_low(
18351776 }
18361777
18371778 const dtuple_t * entry = row_build_index_entry (
1838- row, save_ext , index, heap);
1779+ row, ext , index, heap);
18391780
18401781 mtr_start (mtr);
18411782
@@ -1896,10 +1837,7 @@ row_log_table_apply_delete(
18961837 mem_heap_t * offsets_heap, /* !< in/out: memory heap
18971838 that can be emptied */
18981839 mem_heap_t * heap, /* !< in/out: memory heap */
1899- const row_log_t * log, /* !< in: online log */
1900- const row_ext_t * save_ext, /* !< in: saved external field
1901- info, or NULL */
1902- ulint ext_size) /* !< in: external field size */
1840+ const row_log_t * log) /* !< in: online log */
19031841{
19041842 dict_table_t * new_table = log->table ;
19051843 dict_index_t * index = new_table->first_index ();
@@ -2009,15 +1947,13 @@ row_log_table_apply_delete(
20091947 }
20101948
20111949 if (num_v) {
2012- byte* b = (byte*)mrec + rec_offs_data_size (moffsets)
2013- + ext_size;
1950+ byte* b = (byte*)mrec + rec_offs_data_size (moffsets);
20141951 trx_undo_read_v_cols (log->table , b, old_pk, false ,
20151952 &(log->col_map [log->n_old_col ]));
20161953 }
20171954
20181955 return (row_log_table_apply_delete_low (trx, &pcur, old_pk,
2019- offsets, save_ext,
2020- heap, &mtr));
1956+ offsets, heap, &mtr));
20211957}
20221958
20231959/* *****************************************************/ /* *
@@ -2231,7 +2167,7 @@ row_log_table_apply_update(
22312167 /* Some BLOBs are missing, so we are interpreting
22322168 this ROW_T_UPDATE as ROW_T_DELETE (see *1). */
22332169 error = row_log_table_apply_delete_low (
2234- trx, &pcur, old_pk, cur_offsets, NULL , heap, &mtr);
2170+ trx, &pcur, old_pk, cur_offsets, heap, &mtr);
22352171 goto func_exit_committed;
22362172 }
22372173
@@ -2270,7 +2206,7 @@ row_log_table_apply_update(
22702206 }
22712207
22722208 error = row_log_table_apply_delete_low (
2273- trx, &pcur, old_pk, cur_offsets, NULL , heap, &mtr);
2209+ trx, &pcur, old_pk, cur_offsets, heap, &mtr);
22742210 ut_ad (mtr.has_committed ());
22752211
22762212 if (error == DB_SUCCESS) {
@@ -2416,16 +2352,14 @@ row_log_table_apply_op(
24162352 ulint extra_size;
24172353 const mrec_t * next_mrec;
24182354 dtuple_t * old_pk;
2419- row_ext_t * ext;
2420- ulint ext_size;
24212355
24222356 ut_ad (dup->index ->is_clustered ());
24232357 ut_ad (dup->index ->table != log->table );
24242358 ut_ad (log->head .total <= log->tail .total );
24252359
24262360 *error = DB_SUCCESS;
24272361
2428- /* 3 = 1 (op type) + 1 (ext_size ) + at least 1 byte payload */
2362+ /* 3 = 1 (op type) + 1 (extra_size ) + at least 1 byte payload */
24292363 if (mrec + 3 >= mrec_end) {
24302364 return (NULL );
24312365 }
@@ -2482,14 +2416,12 @@ row_log_table_apply_op(
24822416 break ;
24832417
24842418 case ROW_T_DELETE:
2485- /* 1 (extra_size) + 4 (ext_size) + at least 1 (payload) */
2486- if (mrec + 6 >= mrec_end) {
2419+ /* 1 (extra_size) + at least 1 (payload) */
2420+ if (mrec + 2 >= mrec_end) {
24872421 return (NULL );
24882422 }
24892423
24902424 extra_size = *mrec++;
2491- ext_size = mach_read_from_4 (mrec);
2492- mrec += 4 ;
24932425 ut_ad (mrec < mrec_end);
24942426
24952427 /* We assume extra_size < 0x100 for the PRIMARY KEY prefix.
@@ -2498,7 +2430,7 @@ row_log_table_apply_op(
24982430
24992431 rec_offs_set_n_fields (offsets, new_index->n_uniq + 2 );
25002432 rec_init_offsets_temp (mrec, new_index, offsets);
2501- next_mrec = mrec + rec_offs_data_size (offsets) + ext_size ;
2433+ next_mrec = mrec + rec_offs_data_size (offsets);
25022434 if (log->table ->n_v_cols ) {
25032435 if (next_mrec + 2 > mrec_end) {
25042436 return (NULL );
@@ -2513,33 +2445,9 @@ row_log_table_apply_op(
25132445
25142446 log->head .total += next_mrec - mrec_start;
25152447
2516- /* If there are external fields, retrieve those logged
2517- prefix info and reconstruct the row_ext_t */
2518- if (ext_size) {
2519- /* We use memcpy to avoid unaligned
2520- access on some non-x86 platforms.*/
2521- ext = static_cast <row_ext_t *>(
2522- mem_heap_dup (heap,
2523- mrec + rec_offs_data_size (offsets),
2524- ext_size));
2525-
2526- byte* ext_start = reinterpret_cast <byte*>(ext);
2527-
2528- ulint ext_len = sizeof (*ext)
2529- + (ext->n_ext - 1 ) * sizeof ext->len ;
2530-
2531- ext->ext = reinterpret_cast <ulint*>(ext_start + ext_len);
2532- ext_len += ext->n_ext * sizeof (*ext->ext );
2533-
2534- ext->buf = static_cast <byte*>(ext_start + ext_len);
2535- } else {
2536- ext = NULL ;
2537- }
2538-
25392448 *error = row_log_table_apply_delete (
25402449 thr, new_trx_id_col,
2541- mrec, offsets, offsets_heap, heap,
2542- log, ext, ext_size);
2450+ mrec, offsets, offsets_heap, heap, log);
25432451 break ;
25442452
25452453 case ROW_T_UPDATE:
0 commit comments