Commit bac43d74 authored by Julius Goryavsky's avatar Julius Goryavsky

MDEV-30732: additional changes after fix

parent 715b5c13
...@@ -7115,7 +7115,7 @@ wsrep_store_key_val_for_row( ...@@ -7115,7 +7115,7 @@ wsrep_store_key_val_for_row(
field = key_part->field; field = key_part->field;
mysql_type = field->type(); mysql_type = field->type();
if (mysql_type == MYSQL_TYPE_VARCHAR) { if (mysql_type == MYSQL_TYPE_VARCHAR) {
/* >= 5.0.3 true VARCHAR */ /* >= 5.0.3 true VARCHAR */
ulint lenlen; ulint lenlen;
...@@ -7175,13 +7175,13 @@ wsrep_store_key_val_for_row( ...@@ -7175,13 +7175,13 @@ wsrep_store_key_val_for_row(
true_len = sizeof(sorted); true_len = sizeof(sorted);
} }
if (data) { if (true_len > 0) {
memcpy(sorted, data, true_len); memcpy(sorted, data, true_len);
true_len = wsrep_innobase_mysql_sort(
mysql_type, cs->number, sorted, true_len,
REC_VERSION_56_MAX_INDEX_COL_LEN);
} }
true_len = wsrep_innobase_mysql_sort(
mysql_type, cs->number, sorted, true_len,
REC_VERSION_56_MAX_INDEX_COL_LEN);
if (wsrep_protocol_version > 1) { if (wsrep_protocol_version > 1) {
/* Note that we always reserve the maximum possible /* Note that we always reserve the maximum possible
length of the true VARCHAR in the key value, though length of the true VARCHAR in the key value, though
...@@ -7194,7 +7194,9 @@ wsrep_store_key_val_for_row( ...@@ -7194,7 +7194,9 @@ wsrep_store_key_val_for_row(
wsrep_thd_query(thd)); wsrep_thd_query(thd));
true_len = buff_space; true_len = buff_space;
} }
memcpy(buff, sorted, true_len); if (true_len > 0) {
memcpy(buff, sorted, true_len);
}
buff += true_len; buff += true_len;
buff_space -= true_len; buff_space -= true_len;
} else { } else {
...@@ -7266,14 +7268,12 @@ wsrep_store_key_val_for_row( ...@@ -7266,14 +7268,12 @@ wsrep_store_key_val_for_row(
true_len = key_len; true_len = key_len;
} }
if (blob_data) { if (blob_len > 0) {
memcpy(sorted, blob_data, true_len); memcpy(sorted, blob_data, true_len);
true_len = wsrep_innobase_mysql_sort(
mysql_type, cs->number, sorted, true_len,
REC_VERSION_56_MAX_INDEX_COL_LEN);
} }
true_len = wsrep_innobase_mysql_sort(
mysql_type, cs->number, sorted, true_len,
REC_VERSION_56_MAX_INDEX_COL_LEN);
/* Note that we always reserve the maximum possible /* Note that we always reserve the maximum possible
length of the BLOB prefix in the key value. */ length of the BLOB prefix in the key value. */
...@@ -7289,7 +7289,9 @@ wsrep_store_key_val_for_row( ...@@ -7289,7 +7289,9 @@ wsrep_store_key_val_for_row(
} else { } else {
buff += key_len; buff += key_len;
} }
memcpy(buff, sorted, true_len); if (true_len > 0) {
memcpy(buff, sorted, true_len);
}
} else { } else {
/* Here we handle all other data types except the /* Here we handle all other data types except the
true VARCHAR, BLOB and TEXT. Note that the column true VARCHAR, BLOB and TEXT. Note that the column
...@@ -7350,7 +7352,7 @@ wsrep_store_key_val_for_row( ...@@ -7350,7 +7352,7 @@ wsrep_store_key_val_for_row(
&error); &error);
} }
if (src_start) { if (true_len > 0) {
memcpy(sorted, src_start, true_len); memcpy(sorted, src_start, true_len);
} }
...@@ -7364,9 +7366,11 @@ wsrep_store_key_val_for_row( ...@@ -7364,9 +7366,11 @@ wsrep_store_key_val_for_row(
wsrep_thd_query(thd)); wsrep_thd_query(thd));
true_len = buff_space; true_len = buff_space;
} }
memcpy(buff, sorted, true_len); if (true_len > 0) {
memcpy(buff, sorted, true_len);
}
} else { } else {
if (src_start) { if (true_len > 0) {
memcpy(buff, src_start, true_len); memcpy(buff, src_start, true_len);
} }
} }
......
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