29 # include "page0zip.ic"
40 #ifndef UNIV_HOTBACKUP
46 # define lock_move_reorganize_page(block, temp_block) ((void) 0)
47 # define buf_LRU_stat_inc_unzip() ((void) 0)
50 #ifndef UNIV_HOTBACKUP
62 static const byte infimum_extra[] = {
68 static const byte infimum_data[] = {
69 0x69, 0x6e, 0x66, 0x69,
70 0x6d, 0x75, 0x6d, 0x00
73 static const byte supremum_extra_data[] = {
77 0x73, 0x75, 0x70, 0x72,
78 0x65, 0x6d, 0x75, 0x6d
85 #define ASSERT_ZERO(b, s) \
86 ut_ad(!memcmp(b, field_ref_zero, ut_min(s, sizeof field_ref_zero)))
89 #define ASSERT_ZERO_BLOB(b) \
90 ut_ad(!memcmp(b, field_ref_zero, sizeof field_ref_zero))
94 #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
96 __attribute__((format (printf, 1, 2)))
111 fputs(
" InnoDB: ", stderr);
113 res = vfprintf(stderr, fmt, ap);
120 # define page_zip_fail(fmt_args) page_zip_fail_func fmt_args
124 # define page_zip_fail(fmt_args)
127 #ifndef UNIV_HOTBACKUP
142 + PAGE_ZIP_DIR_SLOT_SIZE
143 + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN
146 - REC_N_NEW_EXTRA_BYTES)
148 - compressBound(2 * (n_fields + 1));
149 return(size > 0 ? (ulint) size : 0);
164 ulint size = PAGE_ZIP_DIR_SLOT_SIZE
166 - PAGE_HEAP_NO_USER_LOW);
176 page_zip_dir_user_size(
180 ulint size = PAGE_ZIP_DIR_SLOT_SIZE
182 ut_ad(size <= page_zip_dir_size(page_zip));
191 page_zip_dir_find_low(
199 for (; slot < end; slot += PAGE_ZIP_DIR_SLOT_SIZE) {
221 ut_ad(page_zip_simple_validate(page_zip));
223 return(page_zip_dir_find_low(end - page_zip_dir_user_size(page_zip),
233 page_zip_dir_find_free(
240 ut_ad(page_zip_simple_validate(page_zip));
242 return(page_zip_dir_find_low(end - page_zip_dir_size(page_zip),
243 end - page_zip_dir_user_size(page_zip),
259 ut_ad(page_zip_simple_validate(page_zip));
260 ut_ad(slot < page_zip_dir_size(page_zip) / PAGE_ZIP_DIR_SLOT_SIZE);
262 - PAGE_ZIP_DIR_SLOT_SIZE * (slot + 1)));
265 #ifndef UNIV_HOTBACKUP
270 page_zip_compress_write_log(
291 - PAGE_HEAP_NO_USER_LOW;
294 trailer_size *= PAGE_ZIP_DIR_SLOT_SIZE + REC_NODE_PTR_SIZE;
296 trailer_size *= PAGE_ZIP_DIR_SLOT_SIZE
297 + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN;
299 trailer_size *= PAGE_ZIP_DIR_SLOT_SIZE;
304 #if FIL_PAGE_DATA > PAGE_DATA
305 # error "FIL_PAGE_DATA > PAGE_DATA"
327 - trailer_size, trailer_size);
336 page_zip_get_n_prev_extern(
358 ut_ad(heap_no >= PAGE_HEAP_NO_USER_LOW);
359 left = heap_no - PAGE_HEAP_NO_USER_LOW;
360 if (UNIV_UNLIKELY(!left)) {
364 for (i = 0; i < n_recs; i++) {
365 const rec_t* r = page + (page_zip_dir_get(page_zip, i)
366 & PAGE_ZIP_DIR_SLOT_MASK);
385 page_zip_fixed_field_encode(
392 if (UNIV_LIKELY(val < 126)) {
401 *buf++ = (byte) (0x80 | val >> 8);
413 page_zip_fields_encode(
422 const byte* buf_start = buf;
425 ulint trx_id_col = 0;
429 ut_ad(trx_id_pos == ULINT_UNDEFINED || trx_id_pos < n);
431 for (i = col = 0; i < n; i++) {
432 dict_field_t* field = dict_index_get_nth_field(index, i);
446 if (UNIV_UNLIKELY(column->
len > 255)
447 || UNIV_UNLIKELY(column->
mtype == DATA_BLOB)) {
454 buf = page_zip_fixed_field_encode(
455 buf, fixed_sum << 1 | 1);
465 if (fixed_sum && UNIV_UNLIKELY
472 buf = page_zip_fixed_field_encode(
473 buf, fixed_sum << 1 | 1);
478 if (i && UNIV_UNLIKELY(i == trx_id_pos)) {
483 buf = page_zip_fixed_field_encode(
484 buf, fixed_sum << 1 | 1);
500 buf = page_zip_fixed_field_encode(
501 buf, fixed_sum << 1 | 1);
506 buf = page_zip_fixed_field_encode(
514 buf = page_zip_fixed_field_encode(buf, fixed_sum << 1 | 1);
517 if (trx_id_pos != ULINT_UNDEFINED) {
528 *buf++ = (byte) (0x80 | i >> 8);
532 ut_ad((ulint) (buf - buf_start) <= (n + 2) * 2);
533 return((ulint) (buf - buf_start));
560 status = REC_STATUS_ORDINARY;
562 status = REC_STATUS_NODE_PTR;
565 min_mark = REC_INFO_MIN_REC_FLAG;
574 rec = page + PAGE_NEW_INFIMUM;
581 if (UNIV_UNLIKELY(offs == PAGE_NEW_SUPREMUM)) {
586 ut_a(heap_no >= PAGE_HEAP_NO_USER_LOW);
587 ut_a(heap_no < n_heap);
588 ut_a(offs < UNIV_PAGE_SIZE - PAGE_DIR);
589 ut_a(offs >= PAGE_ZIP_START);
590 #if PAGE_ZIP_DIR_SLOT_MASK & (PAGE_ZIP_DIR_SLOT_MASK + 1)
591 # error "PAGE_ZIP_DIR_SLOT_MASK is not 1 less than a power of 2"
594 offs |= PAGE_ZIP_DIR_SLOT_OWNED;
598 if (UNIV_UNLIKELY(info_bits & REC_INFO_DELETED_FLAG)) {
599 info_bits &= ~REC_INFO_DELETED_FLAG;
600 offs |= PAGE_ZIP_DIR_SLOT_DEL;
602 ut_a(info_bits == min_mark);
609 if (UNIV_LIKELY_NULL(recs)) {
611 ut_a(!recs[heap_no - PAGE_HEAP_NO_USER_LOW]);
613 recs[heap_no - PAGE_HEAP_NO_USER_LOW] = rec;
623 ut_ad(!(offs & ~PAGE_ZIP_DIR_SLOT_MASK));
627 ut_a(heap_no >= PAGE_HEAP_NO_USER_LOW);
628 ut_a(heap_no < n_heap);
630 ut_a(!rec[-REC_N_NEW_EXTRA_BYTES]);
635 if (UNIV_LIKELY_NULL(recs)) {
637 ut_a(!recs[heap_no - PAGE_HEAP_NO_USER_LOW]);
639 recs[heap_no - PAGE_HEAP_NO_USER_LOW] = rec;
646 ut_a(i + PAGE_HEAP_NO_USER_LOW == n_heap);
651 extern "C" void* page_zip_zalloc(
void* opaque, uInt items, uInt size);
653 extern "C" void* page_zip_zalloc
660 return(
mem_heap_zalloc(static_cast<mem_block_info_t *>(opaque), items * size));
665 extern "C" void page_zip_free(
void *opaque,
void *address);
667 extern "C" void page_zip_free(
void *,
void *)
679 z_stream* strm =
static_cast<z_stream *
>(stream);
681 strm->zalloc = page_zip_zalloc;
682 strm->zfree = page_zip_free;
686 #if 0 || defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
688 # define PAGE_ZIP_COMPRESS_DBG
691 #ifdef PAGE_ZIP_COMPRESS_DBG
694 UNIV_INTERN ibool page_zip_compress_dbg;
699 UNIV_INTERN
unsigned page_zip_compress_log;
706 page_zip_compress_deflate(
713 if (UNIV_UNLIKELY(page_zip_compress_dbg)) {
716 if (UNIV_LIKELY_NULL(logfile)) {
717 fwrite(strm->next_in, 1, strm->avail_in, logfile);
719 status = deflate(strm, flush);
720 if (UNIV_UNLIKELY(page_zip_compress_dbg)) {
721 fprintf(stderr,
" -> %d\n", status);
733 # define deflate(strm, flush) page_zip_compress_deflate(logfile, strm, flush)
735 # define FILE_LOGFILE FILE* logfile,
737 # define LOGFILE logfile,
740 # define FILE_LOGFILE
750 page_zip_compress_node_ptrs(
762 ulint* offsets = NULL;
765 const rec_t* rec = *recs++;
767 offsets = rec_get_offsets(rec, index, offsets,
768 ULINT_UNDEFINED, &heap);
777 c_stream->avail_in = rec - REC_N_NEW_EXTRA_BYTES
780 if (c_stream->avail_in) {
781 err = deflate(c_stream, Z_NO_FLUSH);
782 if (UNIV_UNLIKELY(err != Z_OK)) {
786 ut_ad(!c_stream->avail_in);
789 c_stream->next_in = (byte*) rec;
792 ut_ad(c_stream->avail_in);
794 err = deflate(c_stream, Z_NO_FLUSH);
795 if (UNIV_UNLIKELY(err != Z_OK)) {
799 ut_ad(!c_stream->avail_in);
801 memcpy(storage - REC_NODE_PTR_SIZE
803 c_stream->next_in, REC_NODE_PTR_SIZE);
804 c_stream->next_in += REC_NODE_PTR_SIZE;
815 page_zip_compress_sec(
828 const rec_t* rec = *recs++;
831 c_stream->avail_in = rec - REC_N_NEW_EXTRA_BYTES
834 if (UNIV_LIKELY(c_stream->avail_in)) {
835 UNIV_MEM_ASSERT_RW(c_stream->next_in,
837 err = deflate(c_stream, Z_NO_FLUSH);
838 if (UNIV_UNLIKELY(err != Z_OK)) {
843 ut_ad(!c_stream->avail_in);
844 ut_ad(c_stream->next_in == rec - REC_N_NEW_EXTRA_BYTES);
848 c_stream->next_in = (byte*) rec;
860 page_zip_compress_clust_ext(
865 const ulint* offsets,
886 if (UNIV_UNLIKELY(i == trx_id_col)) {
890 src = rec_get_nth_field(rec, offsets, i, &len);
891 ut_ad(src + DATA_TRX_ID_LEN
892 == rec_get_nth_field(rec, offsets,
894 ut_ad(len == DATA_ROLL_PTR_LEN);
898 = src - c_stream->next_in;
900 if (c_stream->avail_in) {
901 err = deflate(c_stream, Z_NO_FLUSH);
902 if (UNIV_UNLIKELY(err != Z_OK)) {
908 ut_ad(!c_stream->avail_in);
909 ut_ad(c_stream->next_in == src);
912 - (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN)
915 DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
918 += DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN;
923 src = rec_get_nth_field(rec, offsets, i, &len);
927 c_stream->avail_in = src
929 if (UNIV_LIKELY(c_stream->avail_in)) {
930 err = deflate(c_stream, Z_NO_FLUSH);
931 if (UNIV_UNLIKELY(err != Z_OK)) {
937 ut_ad(!c_stream->avail_in);
938 ut_ad(c_stream->next_in == src);
947 <= BTR_EXTERN_FIELD_REF_SIZE)) {
952 ut_ad(*externs == c_stream->next_out
953 + c_stream->avail_out
961 (page_zip_dir_find_low(
973 memcpy(*externs, c_stream->next_in
974 - BTR_EXTERN_FIELD_REF_SIZE,
975 BTR_EXTERN_FIELD_REF_SIZE);
987 page_zip_compress_clust(
1004 ulint* offsets = NULL;
1006 byte* externs = storage - n_dense
1007 * (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
1009 ut_ad(*n_blobs == 0);
1012 const rec_t* rec = *recs++;
1014 offsets = rec_get_offsets(rec, index, offsets,
1015 ULINT_UNDEFINED, &heap);
1023 c_stream->avail_in = rec - REC_N_NEW_EXTRA_BYTES
1024 - c_stream->next_in;
1026 if (c_stream->avail_in) {
1027 err = deflate(c_stream, Z_NO_FLUSH);
1028 if (UNIV_UNLIKELY(err != Z_OK)) {
1033 ut_ad(!c_stream->avail_in);
1034 ut_ad(c_stream->next_in == rec - REC_N_NEW_EXTRA_BYTES);
1038 c_stream->next_in = (byte*) rec;
1046 err = page_zip_compress_clust_ext(
1048 c_stream, rec, offsets, trx_id_col,
1049 deleted, storage, &externs, n_blobs);
1051 if (UNIV_UNLIKELY(err != Z_OK)) {
1060 src = rec_get_nth_field(rec, offsets,
1062 ut_ad(src + DATA_TRX_ID_LEN
1063 == rec_get_nth_field(rec, offsets,
1064 trx_id_col + 1, &len));
1065 ut_ad(len == DATA_ROLL_PTR_LEN);
1071 c_stream->avail_in = src - c_stream->next_in;
1073 if (c_stream->avail_in) {
1074 err = deflate(c_stream, Z_NO_FLUSH);
1075 if (UNIV_UNLIKELY(err != Z_OK)) {
1081 ut_ad(!c_stream->avail_in);
1082 ut_ad(c_stream->next_in == src);
1085 - (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN)
1088 DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
1091 += DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN;
1099 - c_stream->next_in;
1101 if (c_stream->avail_in) {
1102 err = deflate(c_stream, Z_NO_FLUSH);
1103 if (UNIV_UNLIKELY(err != Z_OK)) {
1108 ut_ad(!c_stream->avail_in);
1109 }
while (--n_dense);
1140 ulint* offsets = NULL;
1143 #ifndef UNIV_HOTBACKUP
1146 #ifdef PAGE_ZIP_COMPRESS_DBG
1147 FILE* logfile = NULL;
1153 ut_ad(page_zip_simple_validate(page_zip));
1157 UNIV_MEM_ASSERT_RW(page, UNIV_PAGE_SIZE);
1160 ut_a(!memcmp(page + (PAGE_NEW_INFIMUM - REC_N_NEW_EXTRA_BYTES),
1161 infimum_extra,
sizeof infimum_extra));
1162 ut_a(!memcmp(page + PAGE_NEW_INFIMUM,
1163 infimum_data,
sizeof infimum_data));
1164 ut_a(page[PAGE_NEW_SUPREMUM - REC_N_NEW_EXTRA_BYTES]
1166 <= PAGE_DIR_SLOT_MAX_N_OWNED);
1167 ut_a(!memcmp(page + (PAGE_NEW_SUPREMUM - REC_N_NEW_EXTRA_BYTES + 1),
1168 supremum_extra_data,
sizeof supremum_extra_data));
1172 == PAGE_NEW_SUPREMUM);
1183 #ifdef PAGE_ZIP_COMPRESS_DBG
1184 if (UNIV_UNLIKELY(page_zip_compress_dbg)) {
1185 fprintf(stderr,
"compress %p %p %lu %lu %lu\n",
1186 (
void*) page_zip, (
void*) page,
1190 if (UNIV_UNLIKELY(page_zip_compress_log)) {
1192 char logfilename[9];
1194 "%08x", page_zip_compress_log++);
1195 logfile = fopen(logfilename,
"wb");
1199 fwrite(page, 1, UNIV_PAGE_SIZE, logfile);
1209 #ifndef UNIV_HOTBACKUP
1213 if (UNIV_UNLIKELY(n_dense * PAGE_ZIP_DIR_SLOT_SIZE
1220 + n_fields * (2 +
sizeof *offsets)
1221 + n_dense * ((
sizeof *recs)
1222 - PAGE_ZIP_DIR_SLOT_SIZE)
1223 + UNIV_PAGE_SIZE * 4
1224 + (512 << MAX_MEM_LEVEL));
1226 recs =
static_cast<const unsigned char **
>(
mem_heap_zalloc(heap, n_dense *
sizeof *recs));
1228 fields =
static_cast<byte *
>(
mem_heap_alloc(heap, (n_fields + 1) * 2));
1236 err = deflateInit2(&c_stream, Z_DEFAULT_COMPRESSION,
1237 Z_DEFLATED, UNIV_PAGE_SIZE_SHIFT,
1238 MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);
1241 c_stream.next_out = buf;
1244 c_stream.avail_out = buf_end - buf - 1;
1249 index, DATA_TRX_ID);
1250 ut_ad(trx_id_col > 0);
1251 ut_ad(trx_id_col != ULINT_UNDEFINED);
1253 slot_size = PAGE_ZIP_DIR_SLOT_SIZE
1254 + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN;
1259 == ULINT_UNDEFINED);
1261 slot_size = PAGE_ZIP_DIR_SLOT_SIZE;
1264 slot_size = PAGE_ZIP_DIR_SLOT_SIZE + REC_NODE_PTR_SIZE;
1265 trx_id_col = ULINT_UNDEFINED;
1268 if (UNIV_UNLIKELY(c_stream.avail_out <= n_dense * slot_size
1273 c_stream.avail_out -= n_dense * slot_size;
1274 c_stream.avail_in = page_zip_fields_encode(n_fields, index,
1275 trx_id_col, fields);
1276 c_stream.next_in = fields;
1277 if (UNIV_LIKELY(!trx_id_col)) {
1278 trx_id_col = ULINT_UNDEFINED;
1281 UNIV_MEM_ASSERT_RW(c_stream.next_in, c_stream.avail_in);
1282 err = deflate(&c_stream, Z_FULL_FLUSH);
1287 ut_ad(!c_stream.avail_in);
1289 page_zip_dir_encode(page, buf_end, recs);
1291 c_stream.next_in = (byte*) page + PAGE_ZIP_START;
1293 storage = buf_end - n_dense * PAGE_ZIP_DIR_SLOT_SIZE;
1296 if (UNIV_UNLIKELY(!n_dense)) {
1299 err = page_zip_compress_node_ptrs(LOGFILE
1300 &c_stream, recs, n_dense,
1301 index, storage, heap);
1302 if (UNIV_UNLIKELY(err != Z_OK)) {
1305 }
else if (UNIV_LIKELY(trx_id_col == ULINT_UNDEFINED)) {
1307 err = page_zip_compress_sec(LOGFILE
1308 &c_stream, recs, n_dense);
1309 if (UNIV_UNLIKELY(err != Z_OK)) {
1314 err = page_zip_compress_clust(LOGFILE
1315 &c_stream, recs, n_dense,
1316 index, &n_blobs, trx_id_col,
1317 buf_end - PAGE_ZIP_DIR_SLOT_SIZE
1320 if (UNIV_UNLIKELY(err != Z_OK)) {
1326 ut_ad(!c_stream.avail_in);
1332 - (c_stream.next_in - page);
1333 ut_a(c_stream.avail_in <= UNIV_PAGE_SIZE - PAGE_ZIP_START - PAGE_DIR);
1335 UNIV_MEM_ASSERT_RW(c_stream.next_in, c_stream.avail_in);
1336 err = deflate(&c_stream, Z_FINISH);
1338 if (UNIV_UNLIKELY(err != Z_STREAM_END)) {
1340 deflateEnd(&c_stream);
1343 #ifdef PAGE_ZIP_COMPRESS_DBG
1348 #ifndef UNIV_HOTBACKUP
1355 err = deflateEnd(&c_stream);
1358 ut_ad(buf + c_stream.total_out == c_stream.next_out);
1359 ut_ad((ulint) (storage - c_stream.next_out) >= c_stream.avail_out);
1363 UNIV_MEM_VALID(buf, c_stream.total_out);
1368 memset(c_stream.next_out, 0, c_stream.avail_out + 1);
1373 page_zip->
m_end = PAGE_DATA + c_stream.total_out;
1384 memcpy(page_zip->
data + PAGE_DATA, buf,
1387 #ifdef UNIV_ZIP_DEBUG
1388 ut_a(page_zip_validate(page_zip, page));
1392 #ifndef UNIV_HOTBACKUP
1393 page_zip_compress_write_log(page_zip, page, index, mtr);
1399 #ifdef PAGE_ZIP_COMPRESS_DBG
1404 fseek(logfile, UNIV_PAGE_SIZE, SEEK_SET);
1405 fwrite(sz, 1,
sizeof sz, logfile);
1409 #ifndef UNIV_HOTBACKUP
1431 return(rec1 > rec2);
1453 page_zip_fields_free(
1471 page_zip_fields_decode(
1487 for (b = buf, n = 0; b < end; n++) {
1495 if (UNIV_UNLIKELY(n > REC_MAX_N_FIELDS)) {
1497 page_zip_fail((
"page_zip_fields_decode: n = %lu\n",
1502 if (UNIV_UNLIKELY(b > end)) {
1504 page_zip_fail((
"page_zip_fields_decode: %p > %p\n",
1505 (
const void*) b, (
const void*) end));
1509 table = dict_mem_table_create(
"ZIP_DUMMY", DICT_HDR_SPACE, n,
1511 index = dict_mem_index_create(
"ZIP_DUMMY",
"ZIP_DUMMY",
1512 DICT_HDR_SPACE, 0, n);
1513 index->
table = table;
1519 for (b = buf, i = 0; i < n; i++) {
1525 if (UNIV_UNLIKELY(val & 0x80)) {
1527 val = (val & 0x7f) << 8 | *b++;
1529 mtype = DATA_FIXBINARY;
1530 }
else if (UNIV_UNLIKELY(val >= 126)) {
1533 mtype = DATA_BINARY;
1534 }
else if (val <= 1) {
1537 mtype = DATA_BINARY;
1541 mtype = DATA_FIXBINARY;
1544 dict_mem_table_add_col(table, NULL, NULL, mtype,
1545 val & 1 ? DATA_NOT_NULL : 0, len);
1546 dict_index_add_col(index, table,
1547 dict_table_get_nth_col(table, i), 0);
1551 if (UNIV_UNLIKELY(val & 0x80)) {
1552 val = (val & 0x7f) << 8 | *b++;
1558 val = ULINT_UNDEFINED;
1559 }
else if (UNIV_UNLIKELY(val >= n)) {
1560 page_zip_fields_free(index);
1569 if (UNIV_UNLIKELY(index->
n_nullable > val)) {
1570 page_zip_fields_free(index);
1587 page_zip_dir_decode(
1606 if (UNIV_UNLIKELY(n_recs > n_dense)) {
1607 page_zip_fail((
"page_zip_dir_decode 1: %lu > %lu\n",
1608 (ulong) n_recs, (ulong) n_dense));
1615 slot = page + (UNIV_PAGE_SIZE - PAGE_DIR - PAGE_DIR_SLOT_SIZE);
1616 UNIV_PREFETCH_RW(slot);
1619 memset(slot + PAGE_DIR_SLOT_SIZE, 0, PAGE_DIR);
1622 slot -= PAGE_DIR_SLOT_SIZE;
1623 UNIV_PREFETCH_RW(slot);
1626 for (i = 0; i < n_recs; i++) {
1627 ulint offs = page_zip_dir_get(page_zip, i);
1629 if (offs & PAGE_ZIP_DIR_SLOT_OWNED) {
1631 slot -= PAGE_DIR_SLOT_SIZE;
1632 UNIV_PREFETCH_RW(slot);
1635 if (UNIV_UNLIKELY((offs & PAGE_ZIP_DIR_SLOT_MASK)
1636 < PAGE_ZIP_START + REC_N_NEW_EXTRA_BYTES)) {
1637 page_zip_fail((
"page_zip_dir_decode 2: %u %u %lx\n",
1638 (
unsigned) i, (
unsigned) n_recs,
1643 recs[i] = page + (offs & PAGE_ZIP_DIR_SLOT_MASK);
1648 const page_dir_slot_t* last_slot = page_dir_get_nth_slot(
1651 if (UNIV_UNLIKELY(slot != last_slot)) {
1652 page_zip_fail((
"page_zip_dir_decode 3: %p != %p\n",
1654 (
const void*) last_slot));
1660 for (; i < n_dense; i++) {
1661 ulint offs = page_zip_dir_get(page_zip, i);
1663 if (UNIV_UNLIKELY(offs & ~PAGE_ZIP_DIR_SLOT_MASK)) {
1664 page_zip_fail((
"page_zip_dir_decode 4: %u %u %lx\n",
1665 (
unsigned) i, (
unsigned) n_dense,
1670 recs[i] = page + offs;
1673 if (UNIV_LIKELY(n_dense > 1)) {
1674 page_zip_dir_sort(recs, recs_aux, 0, n_dense);
1684 page_zip_set_extra_bytes(
1697 rec = page + PAGE_NEW_INFIMUM;
1699 for (i = 0; i < n; i++) {
1700 offs = page_zip_dir_get(page_zip, i);
1702 if (UNIV_UNLIKELY(offs & PAGE_ZIP_DIR_SLOT_DEL)) {
1703 info_bits |= REC_INFO_DELETED_FLAG;
1705 if (UNIV_UNLIKELY(offs & PAGE_ZIP_DIR_SLOT_OWNED)) {
1706 info_bits |= n_owned;
1711 offs &= PAGE_ZIP_DIR_SLOT_MASK;
1712 if (UNIV_UNLIKELY(offs < PAGE_ZIP_START
1713 + REC_N_NEW_EXTRA_BYTES)) {
1714 page_zip_fail((
"page_zip_set_extra_bytes 1:"
1716 (
unsigned) i, (
unsigned) n,
1723 rec[-REC_N_NEW_EXTRA_BYTES] = (byte) info_bits;
1731 page[PAGE_NEW_SUPREMUM - REC_N_NEW_EXTRA_BYTES] = (byte) n_owned;
1737 if (UNIV_LIKELY(i == n)) {
1741 page_zip_fail((
"page_zip_set_extra_bytes 2: %u != %u\n",
1742 (
unsigned) i, (
unsigned) n));
1746 offs = page_zip_dir_get(page_zip, i);
1750 if (UNIV_UNLIKELY(!offs)
1751 || UNIV_UNLIKELY(offs & ~PAGE_ZIP_DIR_SLOT_MASK)) {
1753 page_zip_fail((
"page_zip_set_extra_bytes 3: %lx\n",
1759 rec[-REC_N_NEW_EXTRA_BYTES] = 0;
1765 offs = page_zip_dir_get(page_zip, i);
1770 rec[-REC_N_NEW_EXTRA_BYTES] = 0;
1782 page_zip_apply_log_ext(
1785 const ulint* offsets,
1792 byte* next_out = rec;
1801 if (UNIV_UNLIKELY(i == trx_id_col)) {
1803 dst = rec_get_nth_field(rec, offsets,
1805 if (UNIV_UNLIKELY(dst - next_out >= end - data)
1807 (len < (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN))
1809 page_zip_fail((
"page_zip_apply_log_ext:"
1811 " %p - %p >= %p - %p\n",
1814 (
const void*) next_out,
1816 (
const void*) data));
1820 memcpy(next_out, data, dst - next_out);
1821 data += dst - next_out;
1822 next_out = dst + (DATA_TRX_ID_LEN
1823 + DATA_ROLL_PTR_LEN);
1825 dst = rec_get_nth_field(rec, offsets,
1828 >= BTR_EXTERN_FIELD_REF_SIZE);
1830 len += dst - next_out
1833 if (UNIV_UNLIKELY(data + len >= end)) {
1834 page_zip_fail((
"page_zip_apply_log_ext: "
1835 "ext %p+%lu >= %p\n",
1838 (
const void*) end));
1842 memcpy(next_out, data, len);
1850 len = rec_get_end(rec, offsets) - next_out;
1851 if (UNIV_UNLIKELY(data + len >= end)) {
1852 page_zip_fail((
"page_zip_apply_log_ext: "
1853 "last %p+%lu >= %p\n",
1856 (
const void*) end));
1859 memcpy(next_out, data, len);
1888 const byte*
const end = data + size;
1897 if (UNIV_UNLIKELY(!val)) {
1901 val = (val & 0x7f) << 8 | *data++;
1902 if (UNIV_UNLIKELY(!val)) {
1903 page_zip_fail((
"page_zip_apply_log:"
1904 " invalid val %x%x\n",
1905 data[-2], data[-1]));
1909 if (UNIV_UNLIKELY(data >= end)) {
1910 page_zip_fail((
"page_zip_apply_log: %p >= %p\n",
1912 (
const void*) end));
1915 if (UNIV_UNLIKELY((val >> 1) > n_dense)) {
1916 page_zip_fail((
"page_zip_apply_log: %lu>>1 > %lu\n",
1917 (ulong) val, (ulong) n_dense));
1922 rec = recs[(val >> 1) - 1];
1924 hs = ((val >> 1) + 1) << REC_HEAP_NO_SHIFT;
1925 hs |= heap_status & ((1 << REC_HEAP_NO_SHIFT) - 1);
1931 if (UNIV_UNLIKELY(hs > heap_status)) {
1932 page_zip_fail((
"page_zip_apply_log: %lu > %lu\n",
1933 (ulong) hs, (ulong) heap_status));
1935 }
else if (hs == heap_status) {
1937 if (UNIV_UNLIKELY(val & 1)) {
1939 page_zip_fail((
"page_zip_apply_log:"
1940 " attempting to create"
1941 " deleted rec %lu\n",
1945 heap_status += 1 << REC_HEAP_NO_SHIFT;
1954 offs = rec_get_offsets(rec, index, offsets,
1955 ULINT_UNDEFINED, &heap);
1958 if (UNIV_LIKELY_NULL(heap)) {
1964 #if REC_STATUS_NODE_PTR != TRUE
1965 # error "REC_STATUS_NODE_PTR != TRUE"
1968 hs & REC_STATUS_NODE_PTR,
1970 rec_offs_make_valid(rec, index, offsets);
1974 byte* start = rec_get_start(rec, offsets);
1975 byte* b = rec - REC_N_NEW_EXTRA_BYTES;
1976 while (b != start) {
1985 if (UNIV_UNLIKELY(hs & REC_STATUS_NODE_PTR)) {
1986 page_zip_fail((
"page_zip_apply_log: "
1987 "%lu&REC_STATUS_NODE_PTR\n",
1992 data = page_zip_apply_log_ext(
1993 rec, offsets, trx_id_col, data, end);
1995 if (UNIV_UNLIKELY(!data)) {
1998 }
else if (UNIV_UNLIKELY(hs & REC_STATUS_NODE_PTR)) {
2000 - REC_NODE_PTR_SIZE;
2002 if (UNIV_UNLIKELY(data + len >= end)) {
2003 page_zip_fail((
"page_zip_apply_log: "
2004 "node_ptr %p+%lu >= %p\n",
2007 (
const void*) end));
2010 memcpy(rec, data, len);
2012 }
else if (UNIV_LIKELY(trx_id_col == ULINT_UNDEFINED)) {
2017 if (UNIV_UNLIKELY(data + len >= end)) {
2018 page_zip_fail((
"page_zip_apply_log: "
2019 "sec %p+%lu >= %p\n",
2022 (
const void*) end));
2026 memcpy(rec, data, len);
2034 if (UNIV_UNLIKELY(data + l >= end)
2035 || UNIV_UNLIKELY(len < (DATA_TRX_ID_LEN
2036 + DATA_ROLL_PTR_LEN))) {
2037 page_zip_fail((
"page_zip_apply_log: "
2038 "trx_id %p+%lu >= %p\n",
2041 (
const void*) end));
2046 memcpy(rec, data, l);
2050 b = rec + l + (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
2051 len = rec_get_end(rec, offsets) - b;
2052 if (UNIV_UNLIKELY(data + len >= end)) {
2053 page_zip_fail((
"page_zip_apply_log: "
2054 "clust %p+%lu >= %p\n",
2057 (
const void*) end));
2060 memcpy(b, data, len);
2071 page_zip_decompress_node_ptrs(
2082 ulint heap_status = REC_STATUS_NODE_PTR
2083 | PAGE_HEAP_NO_USER_LOW << REC_HEAP_NO_SHIFT;
2085 const byte* storage;
2088 d_stream->avail_in -= n_dense
2089 * (PAGE_ZIP_DIR_SLOT_SIZE + REC_NODE_PTR_SIZE);
2092 for (slot = 0; slot < n_dense; slot++) {
2093 rec_t* rec = recs[slot];
2095 d_stream->avail_out = rec - REC_N_NEW_EXTRA_BYTES
2096 - d_stream->next_out;
2098 ut_ad(d_stream->avail_out < UNIV_PAGE_SIZE
2099 - PAGE_ZIP_START - PAGE_DIR);
2100 switch (inflate(d_stream, Z_SYNC_FLUSH)) {
2107 if (!d_stream->avail_out) {
2112 page_zip_fail((
"page_zip_decompress_node_ptrs:"
2113 " 1 inflate(Z_SYNC_FLUSH)=%s\n",
2118 ut_ad(d_stream->next_out == rec - REC_N_NEW_EXTRA_BYTES);
2120 d_stream->next_out = rec;
2123 heap_status += 1 << REC_HEAP_NO_SHIFT;
2126 offsets = rec_get_offsets(rec, index, offsets,
2127 ULINT_UNDEFINED, &heap);
2135 - REC_NODE_PTR_SIZE;
2137 switch (inflate(d_stream, Z_SYNC_FLUSH)) {
2142 if (!d_stream->avail_out) {
2147 page_zip_fail((
"page_zip_decompress_node_ptrs:"
2148 " 2 inflate(Z_SYNC_FLUSH)=%s\n",
2156 memset(d_stream->next_out, 0, REC_NODE_PTR_SIZE);
2157 d_stream->next_out += REC_NODE_PTR_SIZE;
2159 ut_ad(d_stream->next_out == rec_get_end(rec, offsets));
2167 if (UNIV_UNLIKELY(d_stream->avail_out > UNIV_PAGE_SIZE
2168 - PAGE_ZIP_START - PAGE_DIR)) {
2170 page_zip_fail((
"page_zip_decompress_node_ptrs:"
2171 " avail_out = %u\n",
2172 d_stream->avail_out));
2176 if (UNIV_UNLIKELY(inflate(d_stream, Z_FINISH) != Z_STREAM_END)) {
2177 page_zip_fail((
"page_zip_decompress_node_ptrs:"
2178 " inflate(Z_FINISH)=%s\n",
2181 inflateEnd(d_stream);
2189 if (UNIV_UNLIKELY(inflateEnd(d_stream) != Z_OK)) {
2197 memset(d_stream->next_out, 0,
2198 page_dir_get_nth_slot(page,
2200 - d_stream->next_out);
2204 page_zip->m_start = PAGE_DATA + d_stream->total_in;
2209 const byte* mod_log_ptr;
2210 mod_log_ptr = page_zip_apply_log(d_stream->next_in,
2211 d_stream->avail_in + 1,
2213 ULINT_UNDEFINED, heap_status,
2216 if (UNIV_UNLIKELY(!mod_log_ptr)) {
2219 page_zip->
m_end = mod_log_ptr - page_zip->
data;
2220 page_zip->
m_nonempty = mod_log_ptr != d_stream->next_in;
2224 (page_zip_get_trailer_len(page_zip,
2227 page_zip_fail((
"page_zip_decompress_node_ptrs:"
2228 " %lu + %lu >= %lu, %lu\n",
2229 (ulong) page_zip_get_trailer_len(
2232 (ulong) page_zip->
m_end,
2240 - n_dense * PAGE_ZIP_DIR_SLOT_SIZE;
2242 for (slot = 0; slot < n_dense; slot++) {
2243 rec_t* rec = recs[slot];
2245 offsets = rec_get_offsets(rec, index, offsets,
2246 ULINT_UNDEFINED, &heap);
2250 storage -= REC_NODE_PTR_SIZE;
2252 memcpy(rec_get_end(rec, offsets) - REC_NODE_PTR_SIZE,
2253 storage, REC_NODE_PTR_SIZE);
2264 page_zip_decompress_sec(
2274 ulint heap_status = REC_STATUS_ORDINARY
2275 | PAGE_HEAP_NO_USER_LOW << REC_HEAP_NO_SHIFT;
2281 d_stream->avail_in -= n_dense * PAGE_ZIP_DIR_SLOT_SIZE;
2283 for (slot = 0; slot < n_dense; slot++) {
2284 rec_t* rec = recs[slot];
2287 d_stream->avail_out = rec - REC_N_NEW_EXTRA_BYTES
2288 - d_stream->next_out;
2290 if (UNIV_LIKELY(d_stream->avail_out)) {
2291 switch (inflate(d_stream, Z_SYNC_FLUSH)) {
2298 if (!d_stream->avail_out) {
2303 page_zip_fail((
"page_zip_decompress_sec:"
2304 " inflate(Z_SYNC_FLUSH)=%s\n",
2310 ut_ad(d_stream->next_out == rec - REC_N_NEW_EXTRA_BYTES);
2314 d_stream->next_out = rec;
2318 heap_status += 1 << REC_HEAP_NO_SHIFT;
2327 if (UNIV_UNLIKELY(d_stream->avail_out > UNIV_PAGE_SIZE
2328 - PAGE_ZIP_START - PAGE_DIR)) {
2330 page_zip_fail((
"page_zip_decompress_sec:"
2331 " avail_out = %u\n",
2332 d_stream->avail_out));
2336 if (UNIV_UNLIKELY(inflate(d_stream, Z_FINISH) != Z_STREAM_END)) {
2337 page_zip_fail((
"page_zip_decompress_sec:"
2338 " inflate(Z_FINISH)=%s\n",
2341 inflateEnd(d_stream);
2349 if (UNIV_UNLIKELY(inflateEnd(d_stream) != Z_OK)) {
2357 memset(d_stream->next_out, 0,
2358 page_dir_get_nth_slot(page,
2360 - d_stream->next_out);
2364 page_zip->m_start = PAGE_DATA + d_stream->total_in;
2369 const byte* mod_log_ptr;
2370 mod_log_ptr = page_zip_apply_log(d_stream->next_in,
2371 d_stream->avail_in + 1,
2373 ULINT_UNDEFINED, heap_status,
2376 if (UNIV_UNLIKELY(!mod_log_ptr)) {
2379 page_zip->
m_end = mod_log_ptr - page_zip->
data;
2380 page_zip->
m_nonempty = mod_log_ptr != d_stream->next_in;
2383 if (UNIV_UNLIKELY(page_zip_get_trailer_len(page_zip, FALSE, NULL)
2386 page_zip_fail((
"page_zip_decompress_sec: %lu + %lu >= %lu\n",
2387 (ulong) page_zip_get_trailer_len(
2388 page_zip, FALSE, NULL),
2389 (ulong) page_zip->
m_end,
2406 page_zip_decompress_clust_ext(
2410 const ulint* offsets,
2419 if (UNIV_UNLIKELY(i == trx_id_col)) {
2421 dst = rec_get_nth_field(rec, offsets, i, &len);
2422 if (UNIV_UNLIKELY(len < DATA_TRX_ID_LEN
2423 + DATA_ROLL_PTR_LEN)) {
2425 page_zip_fail((
"page_zip_decompress_clust_ext:"
2426 " len[%lu] = %lu\n",
2427 (ulong) i, (ulong) len));
2433 page_zip_fail((
"page_zip_decompress_clust_ext:"
2434 " DB_TRX_ID at %lu is ext\n",
2439 d_stream->avail_out = dst - d_stream->next_out;
2441 switch (inflate(d_stream, Z_SYNC_FLUSH)) {
2445 if (!d_stream->avail_out) {
2450 page_zip_fail((
"page_zip_decompress_clust_ext:"
2451 " 1 inflate(Z_SYNC_FLUSH)=%s\n",
2456 ut_ad(d_stream->next_out == dst);
2461 memset(dst, 0, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
2463 d_stream->next_out += DATA_TRX_ID_LEN
2464 + DATA_ROLL_PTR_LEN;
2466 dst = rec_get_nth_field(rec, offsets, i, &len);
2467 ut_ad(len >= BTR_EXTERN_FIELD_REF_SIZE);
2470 d_stream->avail_out = dst - d_stream->next_out;
2471 switch (inflate(d_stream, Z_SYNC_FLUSH)) {
2475 if (!d_stream->avail_out) {
2480 page_zip_fail((
"page_zip_decompress_clust_ext:"
2481 " 2 inflate(Z_SYNC_FLUSH)=%s\n",
2486 ut_ad(d_stream->next_out == dst);
2499 memset(d_stream->next_out, 0,
2500 BTR_EXTERN_FIELD_REF_SIZE);
2514 page_zip_decompress_clust(
2528 ulint heap_status = REC_STATUS_ORDINARY
2529 | PAGE_HEAP_NO_USER_LOW << REC_HEAP_NO_SHIFT;
2530 const byte* storage;
2531 const byte* externs;
2536 d_stream->avail_in -= n_dense * (PAGE_ZIP_DIR_SLOT_SIZE
2538 + DATA_ROLL_PTR_LEN);
2541 for (slot = 0; slot < n_dense; slot++) {
2542 rec_t* rec = recs[slot];
2544 d_stream->avail_out = rec - REC_N_NEW_EXTRA_BYTES
2545 - d_stream->next_out;
2547 ut_ad(d_stream->avail_out < UNIV_PAGE_SIZE
2548 - PAGE_ZIP_START - PAGE_DIR);
2549 err = inflate(d_stream, Z_SYNC_FLUSH);
2557 if (UNIV_LIKELY(!d_stream->avail_out)) {
2562 page_zip_fail((
"page_zip_decompress_clust:"
2563 " 1 inflate(Z_SYNC_FLUSH)=%s\n",
2568 ut_ad(d_stream->next_out == rec - REC_N_NEW_EXTRA_BYTES);
2570 d_stream->next_out = rec;
2573 heap_status += 1 << REC_HEAP_NO_SHIFT;
2576 offsets = rec_get_offsets(rec, index, offsets,
2577 ULINT_UNDEFINED, &heap);
2587 (!page_zip_decompress_clust_ext(
2588 d_stream, rec, offsets, trx_id_col))) {
2595 byte* dst = rec_get_nth_field(rec, offsets,
2597 if (UNIV_UNLIKELY(len < DATA_TRX_ID_LEN
2598 + DATA_ROLL_PTR_LEN)) {
2600 page_zip_fail((
"page_zip_decompress_clust:"
2601 " len = %lu\n", (ulong) len));
2605 d_stream->avail_out = dst - d_stream->next_out;
2607 switch (inflate(d_stream, Z_SYNC_FLUSH)) {
2611 if (!d_stream->avail_out) {
2616 page_zip_fail((
"page_zip_decompress_clust:"
2617 " 2 inflate(Z_SYNC_FLUSH)=%s\n",
2622 ut_ad(d_stream->next_out == dst);
2627 memset(dst, 0, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
2629 d_stream->next_out += DATA_TRX_ID_LEN
2630 + DATA_ROLL_PTR_LEN;
2634 d_stream->avail_out = rec_get_end(rec, offsets)
2635 - d_stream->next_out;
2637 switch (inflate(d_stream, Z_SYNC_FLUSH)) {
2641 if (!d_stream->avail_out) {
2646 page_zip_fail((
"page_zip_decompress_clust:"
2647 " 3 inflate(Z_SYNC_FLUSH)=%s\n",
2658 if (UNIV_UNLIKELY(d_stream->avail_out > UNIV_PAGE_SIZE
2659 - PAGE_ZIP_START - PAGE_DIR)) {
2661 page_zip_fail((
"page_zip_decompress_clust:"
2662 " avail_out = %u\n",
2663 d_stream->avail_out));
2667 if (UNIV_UNLIKELY(inflate(d_stream, Z_FINISH) != Z_STREAM_END)) {
2668 page_zip_fail((
"page_zip_decompress_clust:"
2669 " inflate(Z_FINISH)=%s\n",
2672 inflateEnd(d_stream);
2680 if (UNIV_UNLIKELY(inflateEnd(d_stream) != Z_OK)) {
2688 memset(d_stream->next_out, 0,
2689 page_dir_get_nth_slot(page,
2691 - d_stream->next_out);
2695 page_zip->m_start = PAGE_DATA + d_stream->total_in;
2700 const byte* mod_log_ptr;
2701 mod_log_ptr = page_zip_apply_log(d_stream->next_in,
2702 d_stream->avail_in + 1,
2704 trx_id_col, heap_status,
2707 if (UNIV_UNLIKELY(!mod_log_ptr)) {
2710 page_zip->
m_end = mod_log_ptr - page_zip->
data;
2711 page_zip->
m_nonempty = mod_log_ptr != d_stream->next_in;
2714 if (UNIV_UNLIKELY(page_zip_get_trailer_len(page_zip, TRUE, NULL)
2717 page_zip_fail((
"page_zip_decompress_clust: %lu + %lu >= %lu\n",
2718 (ulong) page_zip_get_trailer_len(
2719 page_zip, TRUE, NULL),
2720 (ulong) page_zip->
m_end,
2726 - n_dense * PAGE_ZIP_DIR_SLOT_SIZE;
2728 externs = storage - n_dense
2729 * (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
2733 for (slot = 0; slot < n_dense; slot++) {
2737 rec_t* rec = recs[slot];
2738 ibool exists = !page_zip_dir_find_free(
2740 offsets = rec_get_offsets(rec, index, offsets,
2741 ULINT_UNDEFINED, &heap);
2743 dst = rec_get_nth_field(rec, offsets,
2745 ut_ad(len >= DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
2746 storage -= DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN;
2747 memcpy(dst, storage,
2748 DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
2762 dst = rec_get_nth_field(rec, offsets, i, &len);
2764 if (UNIV_UNLIKELY(len < BTR_EXTERN_FIELD_REF_SIZE)) {
2765 page_zip_fail((
"page_zip_decompress_clust:"
2773 if (UNIV_LIKELY(exists)) {
2779 (externs < page_zip->data
2780 + page_zip->
m_end)) {
2781 page_zip_fail((
"page_zip_"
2782 "decompress_clust: "
2784 (
const void*) externs,
2792 memcpy(dst, externs,
2793 BTR_EXTERN_FIELD_REF_SIZE);
2800 BTR_EXTERN_FIELD_REF_SIZE);
2829 ulint trx_id_col = ULINT_UNDEFINED;
2832 #ifndef UNIV_HOTBACKUP
2836 ut_ad(page_zip_simple_validate(page_zip));
2837 UNIV_MEM_ASSERT_W(page, UNIV_PAGE_SIZE);
2842 if (UNIV_UNLIKELY(n_dense * PAGE_ZIP_DIR_SLOT_SIZE
2844 page_zip_fail((
"page_zip_decompress 1: %lu %lu\n",
2850 heap =
mem_heap_create(n_dense * (3 *
sizeof *recs) + UNIV_PAGE_SIZE);
2851 recs =
static_cast<byte **
>(
mem_heap_alloc(heap, n_dense * (2 *
sizeof *recs)));
2855 memcpy(page, page_zip->
data, PAGE_DATA);
2858 #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
2862 ut_a(!memcmp(PAGE_HEADER + PAGE_LEVEL + page,
2863 PAGE_HEADER + PAGE_LEVEL + page_zip->
data,
2864 PAGE_DATA - (PAGE_HEADER + PAGE_LEVEL)));
2869 memcpy(PAGE_HEADER + page, PAGE_HEADER + page_zip->
data,
2870 PAGE_LEVEL - PAGE_N_DIR_SLOTS);
2872 #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
2874 ut_a(!memcmp(page, page_zip->
data, PAGE_DATA));
2878 #ifdef UNIV_ZIP_DEBUG
2880 memset(PAGE_DATA + page, 0x55, UNIV_PAGE_SIZE - PAGE_DATA);
2882 UNIV_MEM_INVALID(PAGE_DATA + page, UNIV_PAGE_SIZE - PAGE_DATA);
2885 if (UNIV_UNLIKELY(!page_zip_dir_decode(page_zip, page, recs,
2886 recs + n_dense, n_dense))) {
2893 memcpy(page + (PAGE_NEW_INFIMUM - REC_N_NEW_EXTRA_BYTES),
2894 infimum_extra,
sizeof infimum_extra);
2900 page_zip_dir_get(page_zip, 0)
2901 & PAGE_ZIP_DIR_SLOT_MASK);
2903 memcpy(page + PAGE_NEW_INFIMUM, infimum_data,
sizeof infimum_data);
2904 memcpy(page + (PAGE_NEW_SUPREMUM - REC_N_NEW_EXTRA_BYTES + 1),
2905 supremum_extra_data,
sizeof supremum_extra_data);
2909 d_stream.next_in = page_zip->
data + PAGE_DATA;
2913 d_stream.next_out = page + PAGE_ZIP_START;
2914 d_stream.avail_out = UNIV_PAGE_SIZE - PAGE_ZIP_START;
2916 if (UNIV_UNLIKELY(inflateInit2(&d_stream, UNIV_PAGE_SIZE_SHIFT)
2922 if (UNIV_UNLIKELY(inflate(&d_stream, Z_BLOCK) != Z_OK)) {
2924 page_zip_fail((
"page_zip_decompress:"
2925 " 1 inflate(Z_BLOCK)=%s\n", d_stream.msg));
2929 if (UNIV_UNLIKELY(inflate(&d_stream, Z_BLOCK) != Z_OK)) {
2931 page_zip_fail((
"page_zip_decompress:"
2932 " 2 inflate(Z_BLOCK)=%s\n", d_stream.msg));
2936 index = page_zip_fields_decode(
2937 page + PAGE_ZIP_START, d_stream.next_out,
2940 if (UNIV_UNLIKELY(!index)) {
2947 d_stream.next_out = page + PAGE_ZIP_START;
2951 ulint n = 1 + 1 + REC_OFFS_HEADER_SIZE
2953 offsets =
static_cast<unsigned long *
>(
mem_heap_alloc(heap, n *
sizeof(ulint)));
2963 (!page_zip_decompress_node_ptrs(page_zip, &d_stream,
2964 recs, n_dense, index,
2970 ? REC_INFO_MIN_REC_FLAG : 0;
2972 if (UNIV_UNLIKELY(!page_zip_set_extra_bytes(page_zip, page,
2976 }
else if (UNIV_LIKELY(trx_id_col == ULINT_UNDEFINED)) {
2978 if (UNIV_UNLIKELY(!page_zip_decompress_sec(page_zip, &d_stream,
2984 if (UNIV_UNLIKELY(!page_zip_set_extra_bytes(page_zip,
2987 page_zip_fields_free(index);
2993 if (UNIV_UNLIKELY(!page_zip_decompress_clust(page_zip,
3001 if (UNIV_UNLIKELY(!page_zip_set_extra_bytes(page_zip,
3008 UNIV_MEM_ASSERT_RW(page, UNIV_PAGE_SIZE);
3010 page_zip_fields_free(index);
3012 #ifndef UNIV_HOTBACKUP
3027 #ifdef UNIV_ZIP_DEBUG
3032 page_zip_hexdump_func(
3038 const byte* s = buf;
3040 const ulint width = 32;
3042 fprintf(stderr,
"%s:\n", name);
3044 for (addr = 0; addr < size; addr += width) {
3047 fprintf(stderr,
"%04lx ", (ulong) addr);
3049 i =
ut_min(width, size - addr);
3052 fprintf(stderr,
"%02x", *s++);
3062 #define page_zip_hexdump(buf, size) page_zip_hexdump_func(#buf, buf, size)
3065 UNIV_INTERN ibool page_zip_validate_header_only = FALSE;
3072 page_zip_validate_low(
3080 byte* temp_page_buf;
3089 page_zip_fail((
"page_zip_validate: page header\n"));
3090 page_zip_hexdump(page_zip,
sizeof *page_zip);
3092 page_zip_hexdump(page, UNIV_PAGE_SIZE);
3098 if (page_zip_validate_header_only) {
3104 temp_page_buf =
ut_malloc(2 * UNIV_PAGE_SIZE);
3105 temp_page =
ut_align(temp_page_buf, UNIV_PAGE_SIZE);
3107 #ifdef UNIV_DEBUG_VALGRIND
3112 VALGRIND_GET_VBITS(page, temp_page, UNIV_PAGE_SIZE);
3113 UNIV_MEM_ASSERT_RW(page, UNIV_PAGE_SIZE);
3114 # if UNIV_WORD_SIZE == 4
3115 VALGRIND_GET_VBITS(page_zip, &temp_page_zip,
sizeof temp_page_zip);
3119 UNIV_MEM_ASSERT_RW(page_zip,
sizeof *page_zip);
3121 VALGRIND_GET_VBITS(page_zip->
data, temp_page,
3126 temp_page_zip = *page_zip;
3129 fputs(
"page_zip_validate(): failed to decompress\n", stderr);
3133 page_zip_fail((
"page_zip_validate: n_blobs: %u!=%u\n",
3138 if (page_zip->m_start != temp_page_zip.m_start) {
3139 page_zip_fail((
"page_zip_validate: m_start: %u!=%u\n",
3140 page_zip->m_start, temp_page_zip.m_start));
3144 if (page_zip->
m_end != temp_page_zip.
m_end) {
3145 page_zip_fail((
"page_zip_validate: m_end: %u!=%u\n",
3150 page_zip_fail((
"page_zip_validate(): m_nonempty: %u!=%u\n",
3155 if (memcmp(page + PAGE_HEADER, temp_page + PAGE_HEADER,
3164 byte info_bits_diff;
3168 ut_a(offset >= PAGE_NEW_SUPREMUM);
3171 info_bits_diff = page[offset] ^ temp_page[offset];
3173 if (info_bits_diff == REC_INFO_MIN_REC_FLAG) {
3174 temp_page[offset] = page[offset];
3176 if (!memcmp(page + PAGE_HEADER,
3177 temp_page + PAGE_HEADER,
3178 UNIV_PAGE_SIZE - PAGE_HEADER
3183 page_zip_fail((
"page_zip_validate: "
3186 "%lu,%lu,0x%02lx)\n",
3189 (ulong) page[offset]));
3194 page_zip_fail((
"page_zip_validate: content\n"));
3200 page_zip_hexdump(page_zip,
sizeof *page_zip);
3202 page_zip_hexdump(page, UNIV_PAGE_SIZE);
3203 page_zip_hexdump(temp_page, UNIV_PAGE_SIZE);
3219 return(page_zip_validate_low(page_zip, page,
3230 page_zip_header_cmp(
3252 page_zip_write_rec_ext(
3258 const ulint* offsets,
3265 const byte* start = rec;
3268 byte* externs = storage;
3276 externs -= (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN)
3282 - (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN)
3283 - n_ext * BTR_EXTERN_FIELD_REF_SIZE
3284 < externs - BTR_EXTERN_FIELD_REF_SIZE * page_zip->
n_blobs);
3287 ulint blob_no = page_zip_get_n_prev_extern(
3288 page_zip, rec, index);
3289 byte* ext_end = externs - page_zip->
n_blobs
3291 ut_ad(blob_no <= page_zip->n_blobs);
3296 ASSERT_ZERO_BLOB(ext_end - n_ext
3297 * BTR_EXTERN_FIELD_REF_SIZE);
3298 memmove(ext_end - n_ext
3299 * BTR_EXTERN_FIELD_REF_SIZE,
3304 ut_a(blob_no + n_ext <= page_zip->n_blobs);
3310 if (UNIV_UNLIKELY(i == trx_id_col)) {
3316 src = rec_get_nth_field(rec, offsets,
3318 ut_ad(len == DATA_TRX_ID_LEN);
3319 ut_ad(src + DATA_TRX_ID_LEN
3320 == rec_get_nth_field(
3323 ut_ad(len == DATA_ROLL_PTR_LEN);
3326 ASSERT_ZERO(data, src - start);
3327 memcpy(data, start, src - start);
3328 data += src - start;
3329 start = src + (DATA_TRX_ID_LEN
3330 + DATA_ROLL_PTR_LEN);
3333 memcpy(storage - (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN)
3335 src, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
3338 src = rec_get_nth_field(rec, offsets,
3343 >= BTR_EXTERN_FIELD_REF_SIZE);
3346 ASSERT_ZERO(data, src - start);
3347 memcpy(data, start, src - start);
3348 data += src - start;
3353 ut_ad(data < externs);
3354 memcpy(externs, src, BTR_EXTERN_FIELD_REF_SIZE);
3361 ASSERT_ZERO(data, len);
3362 memcpy(data, start, len);
3378 const ulint* offsets,
3388 ut_ad(page_zip_simple_validate(page_zip));
3390 > PAGE_DATA + page_zip_dir_size(page_zip));
3394 ut_ad(page_zip->m_start >= PAGE_DATA);
3398 ut_ad(page_zip_header_cmp(page_zip, page));
3406 slot = page_zip_dir_find(page_zip,
page_offset(rec));
3410 *slot |= PAGE_ZIP_DIR_SLOT_DEL >> 8;
3412 *slot &= ~(PAGE_ZIP_DIR_SLOT_DEL >> 8);
3415 ut_ad(rec_get_start((rec_t*) rec, offsets) >= page + PAGE_ZIP_START);
3416 ut_ad(rec_get_end((rec_t*) rec, offsets) <= page + UNIV_PAGE_SIZE
3417 - PAGE_DIR - PAGE_DIR_SLOT_SIZE
3421 ut_ad(heap_no >= PAGE_HEAP_NO_USER_LOW);
3425 data = page_zip->
data + page_zip->
m_end;
3431 if (UNIV_UNLIKELY(heap_no - 1 >= 64)) {
3432 *data++ = (byte) (0x80 | (heap_no - 1) >> 7);
3435 *data++ = (byte) ((heap_no - 1) << 1);
3440 const byte* b = rec - REC_N_NEW_EXTRA_BYTES;
3447 while (b != start) {
3456 * PAGE_ZIP_DIR_SLOT_SIZE;
3466 ut_ad(trx_id_col != ULINT_UNDEFINED);
3471 data = page_zip_write_rec_ext(
3473 rec, index, offsets, create,
3474 trx_id_col, heap_no, storage, data);
3478 = rec_get_nth_field(rec, offsets,
3480 ut_ad(len == DATA_TRX_ID_LEN);
3481 ut_ad(src + DATA_TRX_ID_LEN
3482 == rec_get_nth_field(
3484 trx_id_col + 1, &len));
3485 ut_ad(len == DATA_ROLL_PTR_LEN);
3488 ASSERT_ZERO(data, src - rec);
3489 memcpy(data, rec, src - rec);
3494 - (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN)
3497 DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
3499 src += DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN;
3505 ASSERT_ZERO(data, len);
3506 memcpy(data, src, len);
3513 == ULINT_UNDEFINED);
3519 ASSERT_ZERO(data, len);
3520 memcpy(data, rec, len);
3533 ut_ad(data + len < storage - REC_NODE_PTR_SIZE
3535 ASSERT_ZERO(data, len);
3536 memcpy(data, rec, len);
3540 memcpy(storage - REC_NODE_PTR_SIZE
3548 page_zip->
m_end = data - page_zip->
data;
3551 #ifdef UNIV_ZIP_DEBUG
3571 ut_ad(!page == !page_zip);
3574 (end_ptr < ptr + (2 + 2 + BTR_EXTERN_FIELD_REF_SIZE))) {
3582 if (UNIV_UNLIKELY(offset < PAGE_ZIP_START)
3583 || UNIV_UNLIKELY(offset >= UNIV_PAGE_SIZE)
3584 || UNIV_UNLIKELY(z_offset >= UNIV_PAGE_SIZE)) {
3592 if (UNIV_UNLIKELY(!page_zip)
3598 #ifdef UNIV_ZIP_DEBUG
3599 ut_a(page_zip_validate(page_zip, page));
3602 memcpy(page + offset,
3603 ptr + 4, BTR_EXTERN_FIELD_REF_SIZE);
3604 memcpy(page_zip->
data + z_offset,
3605 ptr + 4, BTR_EXTERN_FIELD_REF_SIZE);
3607 #ifdef UNIV_ZIP_DEBUG
3608 ut_a(page_zip_validate(page_zip, page));
3612 return(ptr + (2 + 2 + BTR_EXTERN_FIELD_REF_SIZE));
3626 const ulint* offsets,
3639 ut_ad(page_zip_simple_validate(page_zip));
3641 > PAGE_DATA + page_zip_dir_size(page_zip));
3647 ut_ad(page_zip->m_start >= PAGE_DATA);
3648 ut_ad(page_zip_header_cmp(page_zip, page));
3658 blob_no = page_zip_get_n_prev_extern(page_zip, rec, index)
3660 ut_a(blob_no < page_zip->n_blobs);
3664 * (PAGE_ZIP_DIR_SLOT_SIZE
3665 + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
3667 field = rec_get_nth_field(rec, offsets, n, &len);
3669 externs -= (blob_no + 1) * BTR_EXTERN_FIELD_REF_SIZE;
3672 memcpy(externs, field, BTR_EXTERN_FIELD_REF_SIZE);
3674 #ifdef UNIV_ZIP_DEBUG
3675 ut_a(page_zip_validate(page_zip, page));
3679 #ifndef UNIV_HOTBACKUP
3681 mtr, 11 + 2 + 2 + BTR_EXTERN_FIELD_REF_SIZE);
3682 if (UNIV_UNLIKELY(!log_ptr)) {
3692 memcpy(log_ptr, externs, BTR_EXTERN_FIELD_REF_SIZE);
3714 ut_ad(!page == !page_zip);
3716 if (UNIV_UNLIKELY(end_ptr < ptr + (2 + 2 + REC_NODE_PTR_SIZE))) {
3724 if (UNIV_UNLIKELY(offset < PAGE_ZIP_START)
3725 || UNIV_UNLIKELY(offset >= UNIV_PAGE_SIZE)
3726 || UNIV_UNLIKELY(z_offset >= UNIV_PAGE_SIZE)) {
3739 if (UNIV_UNLIKELY(!page_zip)
3745 #ifdef UNIV_ZIP_DEBUG
3746 ut_a(page_zip_validate(page_zip, page));
3749 field = page + offset;
3750 storage = page_zip->
data + z_offset;
3754 * PAGE_ZIP_DIR_SLOT_SIZE;
3756 heap_no = 1 + (storage_end - storage) / REC_NODE_PTR_SIZE;
3758 if (UNIV_UNLIKELY((storage_end - storage) % REC_NODE_PTR_SIZE)
3759 || UNIV_UNLIKELY(heap_no < PAGE_HEAP_NO_USER_LOW)
3765 memcpy(field, ptr + 4, REC_NODE_PTR_SIZE);
3766 memcpy(storage, ptr + 4, REC_NODE_PTR_SIZE);
3768 #ifdef UNIV_ZIP_DEBUG
3769 ut_a(page_zip_validate(page_zip, page));
3773 return(ptr + (2 + 2 + REC_NODE_PTR_SIZE));
3794 ut_ad(page_zip_simple_validate(page_zip));
3796 > PAGE_DATA + page_zip_dir_size(page_zip));
3799 ut_ad(page_zip->m_start >= PAGE_DATA);
3800 ut_ad(page_zip_header_cmp(page_zip, page));
3805 UNIV_MEM_ASSERT_RW(rec, size);
3809 * PAGE_ZIP_DIR_SLOT_SIZE
3811 field = rec + size - REC_NODE_PTR_SIZE;
3813 #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
3814 ut_a(!memcmp(storage, field, REC_NODE_PTR_SIZE));
3816 #if REC_NODE_PTR_SIZE != 4
3817 # error "REC_NODE_PTR_SIZE != 4"
3820 memcpy(storage, field, REC_NODE_PTR_SIZE);
3823 #ifndef UNIV_HOTBACKUP
3825 11 + 2 + 2 + REC_NODE_PTR_SIZE);
3826 if (UNIV_UNLIKELY(!log_ptr)) {
3836 memcpy(log_ptr, field, REC_NODE_PTR_SIZE);
3837 log_ptr += REC_NODE_PTR_SIZE;
3851 const ulint* offsets,
3863 ut_ad(page_zip_simple_validate(page_zip));
3865 > PAGE_DATA + page_zip_dir_size(page_zip));
3869 ut_ad(page_zip->m_start >= PAGE_DATA);
3870 ut_ad(page_zip_header_cmp(page_zip, page));
3878 * PAGE_ZIP_DIR_SLOT_SIZE
3880 * (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
3882 #if DATA_TRX_ID + 1 != DATA_ROLL_PTR
3883 # error "DATA_TRX_ID + 1 != DATA_ROLL_PTR"
3885 field = rec_get_nth_field(rec, offsets, trx_id_col, &len);
3886 ut_ad(len == DATA_TRX_ID_LEN);
3887 ut_ad(field + DATA_TRX_ID_LEN
3888 == rec_get_nth_field(rec, offsets, trx_id_col + 1, &len));
3889 ut_ad(len == DATA_ROLL_PTR_LEN);
3890 #if defined UNIV_DEBUG || defined UNIV_ZIP_DEBUG
3891 ut_a(!memcmp(storage, field, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN));
3893 #if DATA_TRX_ID_LEN != 6
3894 # error "DATA_TRX_ID_LEN != 6"
3897 #if DATA_ROLL_PTR_LEN != 7
3898 # error "DATA_ROLL_PTR_LEN != 7"
3901 memcpy(storage, field, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
3909 #ifdef UNIV_ZIP_DEBUG
3915 UNIV_INTERN ibool page_zip_clear_rec_disable;
3927 const ulint* offsets)
3936 ut_ad(page_zip_header_cmp(page_zip, page));
3939 ut_ad(heap_no >= PAGE_HEAP_NO_USER_LOW);
3947 #ifdef UNIV_ZIP_DEBUG
3948 !page_zip_clear_rec_disable &&
3951 + 1 + ((heap_no - 1) >= 64)
3952 + page_zip_get_trailer_len(page_zip,
3963 byte* storage = page_zip->
data
3966 - PAGE_HEAP_NO_USER_LOW)
3967 * PAGE_ZIP_DIR_SLOT_SIZE;
3969 memset(storage - (heap_no - 1) * REC_NODE_PTR_SIZE,
3970 0, REC_NODE_PTR_SIZE);
3973 byte* storage = page_zip->
data
3976 - PAGE_HEAP_NO_USER_LOW)
3977 * PAGE_ZIP_DIR_SLOT_SIZE;
3979 memset(storage - (heap_no - 1)
3980 * (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN),
3981 0, DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
3985 data = page_zip->
data + page_zip->
m_end;
3987 if (UNIV_UNLIKELY(heap_no - 1 >= 64)) {
3988 *data++ = (byte) (0x80 | (heap_no - 1) >> 7);
3991 *data++ = (byte) ((heap_no - 1) << 1 | 1);
3995 page_zip->
m_end = data - page_zip->
data;
4009 byte* field = rec_get_nth_field(
4010 rec, offsets, i, &len);
4012 - BTR_EXTERN_FIELD_REF_SIZE,
4013 0, BTR_EXTERN_FIELD_REF_SIZE);
4019 #ifdef UNIV_ZIP_DEBUG
4020 ut_a(page_zip_validate(page_zip, page));
4035 byte* slot = page_zip_dir_find(page_zip,
page_offset(rec));
4039 *slot |= (PAGE_ZIP_DIR_SLOT_DEL >> 8);
4041 *slot &= ~(PAGE_ZIP_DIR_SLOT_DEL >> 8);
4043 #ifdef UNIV_ZIP_DEBUG
4059 byte* slot = page_zip_dir_find(page_zip,
page_offset(rec));
4063 *slot |= (PAGE_ZIP_DIR_SLOT_OWNED >> 8);
4065 *slot &= ~(PAGE_ZIP_DIR_SLOT_OWNED >> 8);
4076 const byte* prev_rec,
4077 const byte* free_rec,
4085 ut_ad(prev_rec != rec);
4087 ut_ad(page_zip_simple_validate(page_zip));
4096 byte* start = end - page_zip_dir_user_size(page_zip);
4098 if (UNIV_LIKELY(!free_rec)) {
4103 start += PAGE_ZIP_DIR_SLOT_SIZE;
4106 slot_rec = page_zip_dir_find_low(start, end,
4113 - (PAGE_HEAP_NO_USER_LOW + 1);
4115 if (UNIV_LIKELY_NULL(free_rec)) {
4122 + PAGE_HEAP_NO_USER_LOW);
4123 ut_ad(rec >= free_rec);
4124 slot_free = page_zip_dir_find(page_zip,
page_offset(free_rec));
4126 slot_free += PAGE_ZIP_DIR_SLOT_SIZE;
4131 + PAGE_HEAP_NO_USER_LOW);
4135 - PAGE_ZIP_DIR_SLOT_SIZE * n_dense;
4139 memmove(slot_free - PAGE_ZIP_DIR_SLOT_SIZE, slot_free,
4140 slot_rec - slot_free);
4157 const ulint* offsets,
4173 slot_rec = page_zip_dir_find(page_zip,
page_offset(rec));
4181 if (UNIV_UNLIKELY(!free)) {
4184 - PAGE_ZIP_DIR_SLOT_SIZE
4186 - PAGE_HEAP_NO_USER_LOW);
4188 slot_free = page_zip_dir_find_free(page_zip,
4190 ut_a(slot_free < slot_rec);
4192 slot_free += PAGE_ZIP_DIR_SLOT_SIZE;
4195 if (UNIV_LIKELY(slot_rec > slot_free)) {
4196 memmove(slot_free + PAGE_ZIP_DIR_SLOT_SIZE,
4198 slot_rec - slot_free);
4211 if (UNIV_UNLIKELY(n_ext)) {
4217 blob_no = page_zip_get_n_prev_extern(page_zip, rec, index);
4218 ut_a(blob_no + n_ext <= page_zip->n_blobs);
4222 * (PAGE_ZIP_DIR_SLOT_SIZE
4223 + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
4225 ext_end = externs - page_zip->
n_blobs
4231 memmove(ext_end + n_ext * BTR_EXTERN_FIELD_REF_SIZE, ext_end,
4233 * BTR_EXTERN_FIELD_REF_SIZE);
4234 memset(ext_end, 0, n_ext * BTR_EXTERN_FIELD_REF_SIZE);
4240 rec[-REC_N_NEW_EXTRA_BYTES] = 0;
4242 page_zip_clear_rec(page_zip, rec, index, offsets);
4264 - (PAGE_HEAP_NO_USER_LOW + 1);
4267 - PAGE_ZIP_DIR_SLOT_SIZE * n_dense;
4271 stored = dir - n_dense * REC_NODE_PTR_SIZE;
4272 }
else if (UNIV_UNLIKELY(is_clustered)) {
4277 stored = dir - n_dense
4278 * (DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
4282 - (PAGE_ZIP_DIR_SLOT_SIZE
4283 + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN),
4284 PAGE_ZIP_DIR_SLOT_SIZE
4285 + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN);
4286 memmove(externs - (PAGE_ZIP_DIR_SLOT_SIZE
4287 + DATA_TRX_ID_LEN + DATA_ROLL_PTR_LEN),
4288 externs, stored - externs);
4292 ASSERT_ZERO(stored - PAGE_ZIP_DIR_SLOT_SIZE,
4293 PAGE_ZIP_DIR_SLOT_SIZE);
4298 memmove(stored - PAGE_ZIP_DIR_SLOT_SIZE, stored, dir - stored);
4316 ut_ad(ptr && end_ptr);
4317 ut_ad(!page == !page_zip);
4319 if (UNIV_UNLIKELY(end_ptr < ptr + (1 + 1))) {
4324 offset = (ulint) *ptr++;
4325 len = (ulint) *ptr++;
4327 if (UNIV_UNLIKELY(!len) || UNIV_UNLIKELY(offset + len >= PAGE_DATA)) {
4334 if (UNIV_UNLIKELY(end_ptr < ptr + len)) {
4340 if (UNIV_UNLIKELY(!page_zip)) {
4344 #ifdef UNIV_ZIP_DEBUG
4345 ut_a(page_zip_validate(page_zip, page));
4348 memcpy(page + offset, ptr, len);
4349 memcpy(page_zip->
data + offset, ptr, len);
4351 #ifdef UNIV_ZIP_DEBUG
4352 ut_a(page_zip_validate(page_zip, page));
4359 #ifndef UNIV_HOTBACKUP
4364 page_zip_write_header_log(
4370 byte* log_ptr =
mlog_open(mtr, 11 + 1 + 1);
4373 ut_ad(offset < PAGE_DATA);
4374 ut_ad(offset + length < PAGE_DATA);
4376 # error "PAGE_DATA > 255"
4378 ut_ad(length < 256);
4381 if (UNIV_UNLIKELY(!log_ptr)) {
4388 *log_ptr++ = (byte) offset;
4389 *log_ptr++ = (byte) length;
4420 page_t* page = buf_block_get_frame(block);
4425 ut_ad(mtr_memo_contains(mtr, block, MTR_MEMO_PAGE_X_FIX));
4429 UNIV_MEM_ASSERT_RW(page, UNIV_PAGE_SIZE);
4435 #ifndef UNIV_HOTBACKUP
4436 temp_block = buf_block_alloc(buf_pool);
4437 btr_search_drop_page_hash_index(block);
4440 ut_ad(block == back_block1);
4441 temp_block = back_block2;
4443 temp_page = temp_block->
frame;
4448 btr_blob_dbg_remove(page, index,
"zip_reorg");
4459 page_get_infimum_rec(temp_page),
4466 ut_ad(max_trx_id != 0);
4474 #ifndef UNIV_HOTBACKUP
4482 #ifndef UNIV_HOTBACKUP
4488 #ifndef UNIV_HOTBACKUP
4507 ut_ad(mtr_memo_contains_page(mtr, page, MTR_MEMO_PAGE_X_FIX));
4508 ut_ad(mtr_memo_contains_page(mtr, src, MTR_MEMO_PAGE_X_FIX));
4510 #ifdef UNIV_ZIP_DEBUG
4515 ut_a(page_zip_validate_low(src_zip, src, TRUE));
4518 if (UNIV_UNLIKELY(src_zip->
n_blobs)) {
4528 UNIV_MEM_ASSERT_W(page, UNIV_PAGE_SIZE);
4530 UNIV_MEM_ASSERT_RW(src, UNIV_PAGE_SIZE);
4537 #if PAGE_MAX_TRX_ID + 8 != PAGE_HEADER_PRIV_END
4538 # error "PAGE_MAX_TRX_ID + 8 != PAGE_HEADER_PRIV_END"
4540 memcpy(PAGE_HEADER + page, PAGE_HEADER + src,
4541 PAGE_HEADER_PRIV_END);
4542 memcpy(PAGE_DATA + page, PAGE_DATA + src,
4544 memcpy(PAGE_HEADER + page_zip->
data, PAGE_HEADER + src_zip->
data,
4545 PAGE_HEADER_PRIV_END);
4546 memcpy(PAGE_DATA + page_zip->
data, PAGE_DATA + src_zip->
data,
4553 memcpy(page_zip, src_zip,
sizeof *page_zip);
4554 page_zip->
data = data;
4556 ut_ad(page_zip_get_trailer_len(page_zip,
4567 if (UNIV_LIKELY(offs != PAGE_NEW_SUPREMUM)) {
4568 rec_t* rec = page + offs;
4569 ut_a(rec[-REC_N_NEW_EXTRA_BYTES]
4570 & REC_INFO_MIN_REC_FLAG);
4571 rec[-REC_N_NEW_EXTRA_BYTES] &= ~ REC_INFO_MIN_REC_FLAG;
4575 #ifdef UNIV_ZIP_DEBUG
4576 ut_a(page_zip_validate(page_zip, page));
4578 btr_blob_dbg_add(page, index,
"page_zip_copy_recs");
4580 page_zip_compress_write_log(page_zip, page, index, mtr);
4599 ut_ad(ptr && end_ptr);
4600 ut_ad(!page == !page_zip);
4602 if (UNIV_UNLIKELY(ptr + (2 + 2) > end_ptr)) {
4612 if (UNIV_UNLIKELY(ptr + 8 + size + trailer_size > end_ptr)) {
4618 if (UNIV_UNLIKELY(!page_zip)
4633 - trailer_size, ptr + 8 + size, trailer_size);
4642 return(ptr + 8 + size + trailer_size);
4658 const Bytef* s =
static_cast<const Bytef *
>(data);
4669 return((ulint) adler);