Commit e5fed3b9 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-19586: Avoid std::map::emplace()

GCC 4.7 only knows about std::map::insert(), not emplace().

Also, reformat the function in the common style.
parent b7fc2c89
...@@ -1722,69 +1722,63 @@ recv_parse_or_apply_log_rec_body( ...@@ -1722,69 +1722,63 @@ recv_parse_or_apply_log_rec_body(
@param lsn start LSN of the mini-transaction @param lsn start LSN of the mini-transaction
@param end_lsn end LSN of the mini-transaction */ @param end_lsn end LSN of the mini-transaction */
inline void recv_sys_t::add(mlog_id_t type, const page_id_t page_id, inline void recv_sys_t::add(mlog_id_t type, const page_id_t page_id,
byte* body, byte* rec_end, lsn_t lsn, byte* body, byte* rec_end, lsn_t lsn,
lsn_t end_lsn) lsn_t end_lsn)
{ {
ut_ad(type != MLOG_FILE_DELETE); ut_ad(type != MLOG_FILE_DELETE);
ut_ad(type != MLOG_FILE_CREATE2); ut_ad(type != MLOG_FILE_CREATE2);
ut_ad(type != MLOG_FILE_RENAME2); ut_ad(type != MLOG_FILE_RENAME2);
ut_ad(type != MLOG_FILE_NAME); ut_ad(type != MLOG_FILE_NAME);
ut_ad(type != MLOG_DUMMY_RECORD); ut_ad(type != MLOG_DUMMY_RECORD);
ut_ad(type != MLOG_CHECKPOINT); ut_ad(type != MLOG_CHECKPOINT);
ut_ad(type != MLOG_INDEX_LOAD); ut_ad(type != MLOG_INDEX_LOAD);
ut_ad(type != MLOG_TRUNCATE); ut_ad(type != MLOG_TRUNCATE);
std::pair<map::iterator, bool> p = pages.emplace( std::pair<map::iterator, bool> p = pages.insert(map::value_type
map::value_type(page_id, page_recv_t())); (page_id, page_recv_t()));
page_recv_t& recs = p.first->second; page_recv_t& recs= p.first->second;
ut_ad(p.second == recs.log.empty()); ut_ad(p.second == recs.log.empty());
switch (type) { switch (type) {
case MLOG_INIT_FILE_PAGE2: case MLOG_INIT_FILE_PAGE2:
case MLOG_ZIP_PAGE_COMPRESS: case MLOG_ZIP_PAGE_COMPRESS:
case MLOG_INIT_FREE_PAGE: case MLOG_INIT_FREE_PAGE:
recs.will_not_read(); recs.will_not_read();
mlog_init.add(page_id, lsn); mlog_init.add(page_id, lsn);
default: default:
break; break;
} }
/* Store the log record body in chunks of less than srv_page_size:
heap grows into the buffer pool, and bigger chunks could not
be allocated */
uint32_t len = uint32_t(rec_end - body);
const uint32_t chunk_limit = static_cast<uint32_t>(
RECV_DATA_BLOCK_SIZE);
uint32_t chunk_len = std::min(len, chunk_limit);
recv_t* recv = new /* Store the log record body in limited-size chunks, because the
(mem_heap_alloc(heap, sizeof(recv_t) + chunk_len)) heap grows into the buffer pool. */
recv_t(len, type, lsn, end_lsn); uint32_t len= uint32_t(rec_end - body);
memcpy(recv + 1, body, chunk_len); const uint32_t chunk_limit= static_cast<uint32_t>(RECV_DATA_BLOCK_SIZE);
recs.log.append(recv); uint32_t chunk_len= std::min(len, chunk_limit);
if (UNIV_LIKELY(len == chunk_len)) { recv_t* recv= new (mem_heap_alloc(heap, sizeof(recv_t) + chunk_len))
return; recv_t(len, type, lsn, end_lsn);
} memcpy(recv + 1, body, chunk_len);
recs.log.append(recv);
recv_t::data_t** prev_field = &recv->data.next; if (UNIV_LIKELY(len == chunk_len))
return;
do { recv_t::data_t** prev_field= &recv->data.next;
body += chunk_len;
len -= chunk_len;
chunk_len = std::min(len, chunk_limit);
recv_t::data_t* recv_data = static_cast<recv_t::data_t*> do {
(mem_heap_alloc(heap, sizeof(recv_t::data_t) body += chunk_len;
+ chunk_len)); len -= chunk_len;
*prev_field = recv_data; chunk_len = std::min(len, chunk_limit);
memcpy(recv_data + 1, body, chunk_len); recv_t::data_t* recv_data = static_cast<recv_t::data_t*>
(mem_heap_alloc(heap, sizeof(recv_t::data_t) + chunk_len));
*prev_field = recv_data;
prev_field = &recv_data->next; memcpy(recv_data + 1, body, chunk_len);
} while (len != chunk_len); prev_field= &recv_data->next;
} while (len != chunk_len);
*prev_field = NULL; *prev_field= NULL;
} }
/** Trim old log records for a page /** Trim old log records for a page
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment