Commit c99c5c24 authored by marko's avatar marko

branches/zip: Add const qualifiers to the functions that read MySQL data.

row_mysql_read_true_varchar(), row_mysql_read_blob_ref(),
row_mysql_store_col_in_innobase_format(),
row_sel_convert_mysql_key_to_innobase(): Add const qualifiers.

row_sel_convert_mysql_key_to_innobase(): Document that the first parameter
is in/out.
parent 60c44c3a
......@@ -2938,7 +2938,7 @@ ha_innobase::store_key_val_for_row(
/* >= 5.0.3 true VARCHAR */
ulint lenlen;
ulint len;
byte* data;
const byte* data;
ulint key_len;
ulint true_len;
CHARSET_INFO* cs;
......@@ -3008,7 +3008,7 @@ ha_innobase::store_key_val_for_row(
ulint true_len;
int error=0;
ulint blob_len;
byte* blob_data;
const byte* blob_data;
ut_a(key_part->key_part_flag & HA_PART_KEY_SEG);
......@@ -3668,9 +3668,9 @@ calc_row_difference(
ulint o_len;
ulint n_len;
ulint col_pack_len;
byte* new_mysql_row_col;
byte* o_ptr;
byte* n_ptr;
const byte* new_mysql_row_col;
const byte* o_ptr;
const byte* n_ptr;
byte* buf;
upd_field_t* ufield;
ulint col_type;
......@@ -3688,8 +3688,8 @@ calc_row_difference(
for (i = 0; i < n_fields; i++) {
field = table->field[i];
o_ptr = (byte*) old_row + get_field_offset(table, field);
n_ptr = (byte*) new_row + get_field_offset(table, field);
o_ptr = (const byte*) old_row + get_field_offset(table, field);
n_ptr = (const byte*) new_row + get_field_offset(table, field);
/* Use new_mysql_row_col and col_pack_len save the values */
......
......@@ -47,14 +47,16 @@ row_mysql_store_true_var_len(
Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and
returns a pointer to the data. */
byte*
const byte*
row_mysql_read_true_varchar(
/*========================*/
/* out: pointer to the data, we skip the 1 or 2 bytes
at the start that are used to store the len */
/* out: pointer to the data, we skip
the 1 or 2 bytes at the start that are
used to store the len */
ulint* len, /* out: variable-length field length */
byte* field, /* in: field in the MySQL format */
ulint lenlen);/* in: storage length of len: either 1 or 2 bytes */
const byte* field, /* in: field in the MySQL format */
ulint lenlen);/* in: storage length of len: either 1
or 2 bytes */
/***********************************************************************
Stores a reference to a BLOB in the MySQL format. */
......@@ -70,14 +72,15 @@ row_mysql_store_blob_ref(
/***********************************************************************
Reads a reference to a BLOB in the MySQL format. */
byte*
const byte*
row_mysql_read_blob_ref(
/*====================*/
/* out: pointer to BLOB data */
ulint* len, /* out: BLOB length */
byte* ref, /* in: BLOB reference in the MySQL format */
ulint col_len); /* in: BLOB reference length (not BLOB
length) */
const byte* ref, /* in: BLOB reference in the
MySQL format */
ulint col_len); /* in: BLOB reference length
(not BLOB length) */
/******************************************************************
Stores a non-SQL-NULL field given in the MySQL format in the InnoDB format.
The counterpart of this function is row_sel_field_store_in_mysql_format() in
......@@ -101,7 +104,7 @@ row_mysql_store_col_in_innobase_format(
format differs in a row and in a
key value: in a key value the length
is always stored in 2 bytes! */
byte* mysql_data, /* in: MySQL column value, not
const byte* mysql_data, /* in: MySQL column value, not
SQL NULL; NOTE that dfield may also
get a pointer to mysql_data,
therefore do not discard this as long
......
......@@ -116,7 +116,7 @@ such appears. */
void
row_sel_convert_mysql_key_to_innobase(
/*==================================*/
dtuple_t* tuple, /* in: tuple where to build;
dtuple_t* tuple, /* in/out: tuple where to build;
NOTE: we assume that the type info
in the tuple is already according
to index! */
......@@ -124,7 +124,7 @@ row_sel_convert_mysql_key_to_innobase(
conversions */
ulint buf_len, /* in: buffer length */
dict_index_t* index, /* in: index of the key value */
byte* key_ptr, /* in: MySQL key value */
const byte* key_ptr, /* in: MySQL key value */
ulint key_len, /* in: MySQL key value length */
trx_t* trx); /* in: transaction */
/************************************************************************
......
......@@ -142,14 +142,16 @@ row_mysql_store_true_var_len(
Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and
returns a pointer to the data. */
byte*
const byte*
row_mysql_read_true_varchar(
/*========================*/
/* out: pointer to the data, we skip the 1 or 2 bytes
at the start that are used to store the len */
/* out: pointer to the data, we skip
the 1 or 2 bytes at the start that are
used to store the len */
ulint* len, /* out: variable-length field length */
byte* field, /* in: field in the MySQL format */
ulint lenlen) /* in: storage length of len: either 1 or 2 bytes */
const byte* field, /* in: field in the MySQL format */
ulint lenlen) /* in: storage length of len: either 1
or 2 bytes */
{
if (lenlen == 2) {
*len = mach_read_from_2_little_endian(field);
......@@ -204,20 +206,21 @@ row_mysql_store_blob_ref(
/***********************************************************************
Reads a reference to a BLOB in the MySQL format. */
byte*
const byte*
row_mysql_read_blob_ref(
/*====================*/
/* out: pointer to BLOB data */
ulint* len, /* out: BLOB length */
byte* ref, /* in: BLOB reference in the MySQL format */
ulint col_len) /* in: BLOB reference length (not BLOB
length) */
const byte* ref, /* in: BLOB reference in the
MySQL format */
ulint col_len) /* in: BLOB reference length
(not BLOB length) */
{
byte* data;
const byte* data;
*len = mach_read_from_n_little_endian(ref, col_len - 8);
ut_memcpy(&data, ref + col_len - 8, sizeof(byte*));
ut_memcpy(&data, ref + col_len - 8, sizeof *data);
return(data);
}
......@@ -245,7 +248,7 @@ row_mysql_store_col_in_innobase_format(
format differs in a row and in a
key value: in a key value the length
is always stored in 2 bytes! */
byte* mysql_data, /* in: MySQL column value, not
const byte* mysql_data, /* in: MySQL column value, not
SQL NULL; NOTE that dfield may also
get a pointer to mysql_data,
therefore do not discard this as long
......@@ -258,7 +261,7 @@ row_mysql_store_col_in_innobase_format(
VARCHAR then this is irrelevant */
ulint comp) /* in: nonzero=compact format */
{
byte* ptr = mysql_data;
const byte* ptr = mysql_data;
const dtype_t* dtype;
ulint type;
ulint lenlen;
......@@ -272,11 +275,11 @@ row_mysql_store_col_in_innobase_format(
sign bit negated if the data is a signed integer. In MySQL,
integers are stored in a little-endian format. */
ptr = buf + col_len;
byte* p = buf + col_len;
for (;;) {
ptr--;
*ptr = *mysql_data;
p--;
*p = *mysql_data;
if (ptr == buf) {
break;
}
......@@ -285,10 +288,11 @@ row_mysql_store_col_in_innobase_format(
if (!(dtype->prtype & DATA_UNSIGNED)) {
*ptr = (byte) (*ptr ^ 128);
*p ^= 128;
}
buf += col_len;
ptr = p;
} else if ((type == DATA_VARCHAR
|| type == DATA_VARMYSQL
|| type == DATA_BINARY)) {
......
......@@ -2255,7 +2255,7 @@ ha_innobase::store_key_val_for_row() in ha_innodb.cc. */
void
row_sel_convert_mysql_key_to_innobase(
/*==================================*/
dtuple_t* tuple, /* in: tuple where to build;
dtuple_t* tuple, /* in/out: tuple where to build;
NOTE: we assume that the type info
in the tuple is already according
to index! */
......@@ -2263,19 +2263,19 @@ row_sel_convert_mysql_key_to_innobase(
conversions */
ulint buf_len, /* in: buffer length */
dict_index_t* index, /* in: index of the key value */
byte* key_ptr, /* in: MySQL key value */
const byte* key_ptr, /* in: MySQL key value */
ulint key_len, /* in: MySQL key value length */
trx_t* trx) /* in: transaction */
{
byte* original_buf = buf;
byte* original_key_ptr = key_ptr;
const byte* original_key_ptr = key_ptr;
dict_field_t* field;
dfield_t* dfield;
ulint data_offset;
ulint data_len;
ulint data_field_len;
ibool is_null;
byte* key_end;
const byte* key_end;
ulint n_fields = 0;
/* For documentation of the key value storage format in MySQL, see
......
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