Commit ab747690 authored by marko's avatar marko

branches/zip: Fix errors in bit arithmetics.

page_zip_fixed_field_encode(), page_zip_fields_encode(),
page_zip_fields_decode(): Do not waste one bit when encoding quantities
larger than 127.

page_zip_apply_log(), page_zip_write_rec(): Decode and encode
heap_no >= 127 correctly.
parent a67a1628
...@@ -180,7 +180,7 @@ page_zip_fixed_field_encode( ...@@ -180,7 +180,7 @@ page_zip_fixed_field_encode(
*/ */
*buf++ = val; *buf++ = val;
} else { } else {
*buf++ = 0x80 | val >> 7; *buf++ = 0x80 | val >> 8;
*buf++ = 0xff & val; *buf++ = 0xff & val;
} }
...@@ -290,7 +290,7 @@ page_zip_fields_encode( ...@@ -290,7 +290,7 @@ page_zip_fields_encode(
if (trx_id_col < 128) { if (trx_id_col < 128) {
*buf++ = trx_id_col; *buf++ = trx_id_col;
} else { } else {
*buf++ = 0x80 | trx_id_col >> 7; *buf++ = 0x80 | trx_id_col >> 8;
*buf++ = 0xff & trx_id_col; *buf++ = 0xff & trx_id_col;
} }
} }
...@@ -857,7 +857,7 @@ page_zip_fields_decode( ...@@ -857,7 +857,7 @@ page_zip_fields_decode(
if (UNIV_UNLIKELY(val & 0x80)) { if (UNIV_UNLIKELY(val & 0x80)) {
/* fixed length > 62 bytes */ /* fixed length > 62 bytes */
val = (val & 0x7f) << 7 | *b++; val = (val & 0x7f) << 8 | *b++;
len = val >> 1; len = val >> 1;
mtype = DATA_FIXBINARY; mtype = DATA_FIXBINARY;
} else if (UNIV_UNLIKELY(val >= 126)) { } else if (UNIV_UNLIKELY(val >= 126)) {
...@@ -884,7 +884,7 @@ page_zip_fields_decode( ...@@ -884,7 +884,7 @@ page_zip_fields_decode(
if (trx_id_col) { if (trx_id_col) {
ulint val = *b++; ulint val = *b++;
if (UNIV_UNLIKELY(val & 0x80)) { if (UNIV_UNLIKELY(val & 0x80)) {
val = (val & 0x7f) << 7 | *b++; val = (val & 0x7f) << 8 | *b++;
} }
if (UNIV_UNLIKELY(val >= n)) { if (UNIV_UNLIKELY(val >= n)) {
...@@ -1107,7 +1107,7 @@ page_zip_apply_log( ...@@ -1107,7 +1107,7 @@ page_zip_apply_log(
return(data - 1); return(data - 1);
} }
if (val & 0x80) { if (val & 0x80) {
val = (val & 0x7f) << 7 | *data++; val = (val & 0x7f) << 8 | *data++;
} }
if (UNIV_UNLIKELY(data >= end)) { if (UNIV_UNLIKELY(data >= end)) {
return(NULL); return(NULL);
...@@ -1733,11 +1733,10 @@ page_zip_write_rec( ...@@ -1733,11 +1733,10 @@ page_zip_write_rec(
/* Identify the record by writing its heap number - 1. /* Identify the record by writing its heap number - 1.
0 is reserved to indicate the end of the modification log. */ 0 is reserved to indicate the end of the modification log. */
if (heap_no - 1 >= 128) { if (UNIV_UNLIKELY(heap_no - 1 >= 128)) {
*data++ = 0x80 | (heap_no - 1) >> 7; *data++ = 0x80 | (heap_no - 1) >> 8;
} else {
*data++ = heap_no - 1;
} }
*data++ = heap_no - 1;
{ {
const byte* start = rec_get_start((rec_t*) rec, offsets); const byte* start = rec_get_start((rec_t*) rec, offsets);
......
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