summaryrefslogtreecommitdiff
path: root/innobase/row/row0row.c
diff options
context:
space:
mode:
Diffstat (limited to 'innobase/row/row0row.c')
-rw-r--r--innobase/row/row0row.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/innobase/row/row0row.c b/innobase/row/row0row.c
index 680539764fd..f075caa7d75 100644
--- a/innobase/row/row0row.c
+++ b/innobase/row/row0row.c
@@ -334,6 +334,7 @@ row_build_row_ref(
ulint ref_len;
ulint pos;
byte* buf;
+ ulint clust_col_prefix_len;
ulint i;
ut_ad(index && rec && heap);
@@ -366,6 +367,22 @@ row_build_row_ref(
field = rec_get_nth_field(rec, pos, &len);
dfield_set_data(dfield, field, len);
+
+ /* If the primary key contains a column prefix, then the
+ secondary index may contain a longer prefix of the same
+ column, or the full column, and we must adjust the length
+ accordingly. */
+
+ clust_col_prefix_len =
+ dict_index_get_nth_field(clust_index, i)->prefix_len;
+
+ if (clust_col_prefix_len > 0) {
+ if (len != UNIV_SQL_NULL
+ && len > clust_col_prefix_len) {
+
+ dfield_set_len(dfield, clust_col_prefix_len);
+ }
+ }
}
ut_ad(dtuple_check_typed(ref));
@@ -396,6 +413,7 @@ row_build_row_ref_in_tuple(
ulint len;
ulint ref_len;
ulint pos;
+ ulint clust_col_prefix_len;
ulint i;
ut_a(ref && index && rec);
@@ -433,6 +451,22 @@ row_build_row_ref_in_tuple(
field = rec_get_nth_field(rec, pos, &len);
dfield_set_data(dfield, field, len);
+
+ /* If the primary key contains a column prefix, then the
+ secondary index may contain a longer prefix of the same
+ column, or the full column, and we must adjust the length
+ accordingly. */
+
+ clust_col_prefix_len =
+ dict_index_get_nth_field(clust_index, i)->prefix_len;
+
+ if (clust_col_prefix_len > 0) {
+ if (len != UNIV_SQL_NULL
+ && len > clust_col_prefix_len) {
+
+ dfield_set_len(dfield, clust_col_prefix_len);
+ }
+ }
}
ut_ad(dtuple_check_typed(ref));