mirror of
https://github.com/MariaDB/server.git
synced 2025-12-13 20:03:16 +03:00
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.
This commit is contained in:
@@ -2938,7 +2938,7 @@ ha_innobase::store_key_val_for_row(
|
|||||||
/* >= 5.0.3 true VARCHAR */
|
/* >= 5.0.3 true VARCHAR */
|
||||||
ulint lenlen;
|
ulint lenlen;
|
||||||
ulint len;
|
ulint len;
|
||||||
byte* data;
|
const byte* data;
|
||||||
ulint key_len;
|
ulint key_len;
|
||||||
ulint true_len;
|
ulint true_len;
|
||||||
CHARSET_INFO* cs;
|
CHARSET_INFO* cs;
|
||||||
@@ -3008,7 +3008,7 @@ ha_innobase::store_key_val_for_row(
|
|||||||
ulint true_len;
|
ulint true_len;
|
||||||
int error=0;
|
int error=0;
|
||||||
ulint blob_len;
|
ulint blob_len;
|
||||||
byte* blob_data;
|
const byte* blob_data;
|
||||||
|
|
||||||
ut_a(key_part->key_part_flag & HA_PART_KEY_SEG);
|
ut_a(key_part->key_part_flag & HA_PART_KEY_SEG);
|
||||||
|
|
||||||
@@ -3668,9 +3668,9 @@ calc_row_difference(
|
|||||||
ulint o_len;
|
ulint o_len;
|
||||||
ulint n_len;
|
ulint n_len;
|
||||||
ulint col_pack_len;
|
ulint col_pack_len;
|
||||||
byte* new_mysql_row_col;
|
const byte* new_mysql_row_col;
|
||||||
byte* o_ptr;
|
const byte* o_ptr;
|
||||||
byte* n_ptr;
|
const byte* n_ptr;
|
||||||
byte* buf;
|
byte* buf;
|
||||||
upd_field_t* ufield;
|
upd_field_t* ufield;
|
||||||
ulint col_type;
|
ulint col_type;
|
||||||
@@ -3688,8 +3688,8 @@ calc_row_difference(
|
|||||||
for (i = 0; i < n_fields; i++) {
|
for (i = 0; i < n_fields; i++) {
|
||||||
field = table->field[i];
|
field = table->field[i];
|
||||||
|
|
||||||
o_ptr = (byte*) old_row + get_field_offset(table, field);
|
o_ptr = (const byte*) old_row + get_field_offset(table, field);
|
||||||
n_ptr = (byte*) new_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 */
|
/* 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
|
Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and
|
||||||
returns a pointer to the data. */
|
returns a pointer to the data. */
|
||||||
|
|
||||||
byte*
|
const byte*
|
||||||
row_mysql_read_true_varchar(
|
row_mysql_read_true_varchar(
|
||||||
/*========================*/
|
/*========================*/
|
||||||
/* out: pointer to the data, we skip the 1 or 2 bytes
|
/* out: pointer to the data, we skip
|
||||||
at the start that are used to store the len */
|
the 1 or 2 bytes at the start that are
|
||||||
|
used to store the len */
|
||||||
ulint* len, /* out: variable-length field length */
|
ulint* len, /* out: variable-length field length */
|
||||||
byte* field, /* in: field in the MySQL format */
|
const byte* field, /* in: field in the MySQL format */
|
||||||
ulint lenlen);/* in: storage length of len: either 1 or 2 bytes */
|
ulint lenlen);/* in: storage length of len: either 1
|
||||||
|
or 2 bytes */
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
Stores a reference to a BLOB in the MySQL format. */
|
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. */
|
Reads a reference to a BLOB in the MySQL format. */
|
||||||
|
|
||||||
byte*
|
const byte*
|
||||||
row_mysql_read_blob_ref(
|
row_mysql_read_blob_ref(
|
||||||
/*====================*/
|
/*====================*/
|
||||||
/* out: pointer to BLOB data */
|
/* out: pointer to BLOB data */
|
||||||
ulint* len, /* out: BLOB length */
|
ulint* len, /* out: BLOB length */
|
||||||
byte* ref, /* in: BLOB reference in the MySQL format */
|
const byte* ref, /* in: BLOB reference in the
|
||||||
ulint col_len); /* in: BLOB reference length (not BLOB
|
MySQL format */
|
||||||
length) */
|
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.
|
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
|
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
|
format differs in a row and in a
|
||||||
key value: in a key value the length
|
key value: in a key value the length
|
||||||
is always stored in 2 bytes! */
|
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
|
SQL NULL; NOTE that dfield may also
|
||||||
get a pointer to mysql_data,
|
get a pointer to mysql_data,
|
||||||
therefore do not discard this as long
|
therefore do not discard this as long
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ such appears. */
|
|||||||
void
|
void
|
||||||
row_sel_convert_mysql_key_to_innobase(
|
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
|
NOTE: we assume that the type info
|
||||||
in the tuple is already according
|
in the tuple is already according
|
||||||
to index! */
|
to index! */
|
||||||
@@ -124,7 +124,7 @@ row_sel_convert_mysql_key_to_innobase(
|
|||||||
conversions */
|
conversions */
|
||||||
ulint buf_len, /* in: buffer length */
|
ulint buf_len, /* in: buffer length */
|
||||||
dict_index_t* index, /* in: index of the key value */
|
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 */
|
ulint key_len, /* in: MySQL key value length */
|
||||||
trx_t* trx); /* in: transaction */
|
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
|
Reads a >= 5.0.3 format true VARCHAR length, in the MySQL row format, and
|
||||||
returns a pointer to the data. */
|
returns a pointer to the data. */
|
||||||
|
|
||||||
byte*
|
const byte*
|
||||||
row_mysql_read_true_varchar(
|
row_mysql_read_true_varchar(
|
||||||
/*========================*/
|
/*========================*/
|
||||||
/* out: pointer to the data, we skip the 1 or 2 bytes
|
/* out: pointer to the data, we skip
|
||||||
at the start that are used to store the len */
|
the 1 or 2 bytes at the start that are
|
||||||
|
used to store the len */
|
||||||
ulint* len, /* out: variable-length field length */
|
ulint* len, /* out: variable-length field length */
|
||||||
byte* field, /* in: field in the MySQL format */
|
const byte* field, /* in: field in the MySQL format */
|
||||||
ulint lenlen) /* in: storage length of len: either 1 or 2 bytes */
|
ulint lenlen) /* in: storage length of len: either 1
|
||||||
|
or 2 bytes */
|
||||||
{
|
{
|
||||||
if (lenlen == 2) {
|
if (lenlen == 2) {
|
||||||
*len = mach_read_from_2_little_endian(field);
|
*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. */
|
Reads a reference to a BLOB in the MySQL format. */
|
||||||
|
|
||||||
byte*
|
const byte*
|
||||||
row_mysql_read_blob_ref(
|
row_mysql_read_blob_ref(
|
||||||
/*====================*/
|
/*====================*/
|
||||||
/* out: pointer to BLOB data */
|
/* out: pointer to BLOB data */
|
||||||
ulint* len, /* out: BLOB length */
|
ulint* len, /* out: BLOB length */
|
||||||
byte* ref, /* in: BLOB reference in the MySQL format */
|
const byte* ref, /* in: BLOB reference in the
|
||||||
ulint col_len) /* in: BLOB reference length (not BLOB
|
MySQL format */
|
||||||
length) */
|
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);
|
*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);
|
return(data);
|
||||||
}
|
}
|
||||||
@@ -245,7 +248,7 @@ row_mysql_store_col_in_innobase_format(
|
|||||||
format differs in a row and in a
|
format differs in a row and in a
|
||||||
key value: in a key value the length
|
key value: in a key value the length
|
||||||
is always stored in 2 bytes! */
|
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
|
SQL NULL; NOTE that dfield may also
|
||||||
get a pointer to mysql_data,
|
get a pointer to mysql_data,
|
||||||
therefore do not discard this as long
|
therefore do not discard this as long
|
||||||
@@ -258,7 +261,7 @@ row_mysql_store_col_in_innobase_format(
|
|||||||
VARCHAR then this is irrelevant */
|
VARCHAR then this is irrelevant */
|
||||||
ulint comp) /* in: nonzero=compact format */
|
ulint comp) /* in: nonzero=compact format */
|
||||||
{
|
{
|
||||||
byte* ptr = mysql_data;
|
const byte* ptr = mysql_data;
|
||||||
const dtype_t* dtype;
|
const dtype_t* dtype;
|
||||||
ulint type;
|
ulint type;
|
||||||
ulint lenlen;
|
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,
|
sign bit negated if the data is a signed integer. In MySQL,
|
||||||
integers are stored in a little-endian format. */
|
integers are stored in a little-endian format. */
|
||||||
|
|
||||||
ptr = buf + col_len;
|
byte* p = buf + col_len;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ptr--;
|
p--;
|
||||||
*ptr = *mysql_data;
|
*p = *mysql_data;
|
||||||
if (ptr == buf) {
|
if (ptr == buf) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -285,10 +288,11 @@ row_mysql_store_col_in_innobase_format(
|
|||||||
|
|
||||||
if (!(dtype->prtype & DATA_UNSIGNED)) {
|
if (!(dtype->prtype & DATA_UNSIGNED)) {
|
||||||
|
|
||||||
*ptr = (byte) (*ptr ^ 128);
|
*p ^= 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf += col_len;
|
buf += col_len;
|
||||||
|
ptr = p;
|
||||||
} else if ((type == DATA_VARCHAR
|
} else if ((type == DATA_VARCHAR
|
||||||
|| type == DATA_VARMYSQL
|
|| type == DATA_VARMYSQL
|
||||||
|| type == DATA_BINARY)) {
|
|| type == DATA_BINARY)) {
|
||||||
|
|||||||
@@ -2255,7 +2255,7 @@ ha_innobase::store_key_val_for_row() in ha_innodb.cc. */
|
|||||||
void
|
void
|
||||||
row_sel_convert_mysql_key_to_innobase(
|
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
|
NOTE: we assume that the type info
|
||||||
in the tuple is already according
|
in the tuple is already according
|
||||||
to index! */
|
to index! */
|
||||||
@@ -2263,19 +2263,19 @@ row_sel_convert_mysql_key_to_innobase(
|
|||||||
conversions */
|
conversions */
|
||||||
ulint buf_len, /* in: buffer length */
|
ulint buf_len, /* in: buffer length */
|
||||||
dict_index_t* index, /* in: index of the key value */
|
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 */
|
ulint key_len, /* in: MySQL key value length */
|
||||||
trx_t* trx) /* in: transaction */
|
trx_t* trx) /* in: transaction */
|
||||||
{
|
{
|
||||||
byte* original_buf = buf;
|
byte* original_buf = buf;
|
||||||
byte* original_key_ptr = key_ptr;
|
const byte* original_key_ptr = key_ptr;
|
||||||
dict_field_t* field;
|
dict_field_t* field;
|
||||||
dfield_t* dfield;
|
dfield_t* dfield;
|
||||||
ulint data_offset;
|
ulint data_offset;
|
||||||
ulint data_len;
|
ulint data_len;
|
||||||
ulint data_field_len;
|
ulint data_field_len;
|
||||||
ibool is_null;
|
ibool is_null;
|
||||||
byte* key_end;
|
const byte* key_end;
|
||||||
ulint n_fields = 0;
|
ulint n_fields = 0;
|
||||||
|
|
||||||
/* For documentation of the key value storage format in MySQL, see
|
/* For documentation of the key value storage format in MySQL, see
|
||||||
|
|||||||
Reference in New Issue
Block a user