2469
2469
ut_ad(len != UNIV_SQL_NULL);
2470
2470
UNIV_MEM_ASSERT_RW(data, len);
2471
UNIV_MEM_ASSERT_W(dest, templ->mysql_col_len);
2472
UNIV_MEM_INVALID(dest, templ->mysql_col_len);
2472
2474
if (templ->type == DATA_INT) {
2473
2475
/* Convert integer data from Innobase to a little-endian
2503
2505
dest = row_mysql_store_true_var_len(
2504
2506
dest, len, templ->mysql_length_bytes);
2507
/* Copy the actual data. Leave the rest of the
2508
buffer uninitialized. */
2509
ut_memcpy(dest, data, len);
2507
2513
/* Copy the actual data */
2508
2514
ut_memcpy(dest, data, len);
2510
/* Pad with trailing spaces. We pad with spaces also the
2511
unused end of a >= 5.0.3 true VARCHAR column, just in case
2512
MySQL expects its contents to be deterministic. */
2516
/* Pad with trailing spaces. */
2514
2518
pad_ptr = dest + len;
3015
3019
/************************************************************************
3020
Copies a cached field for MySQL from the fetch cache. */
3023
row_sel_copy_cached_field_for_mysql(
3024
/*================================*/
3025
byte* buf, /* in/out: row buffer */
3026
byte* cache, /* in: cached row */
3027
const mysql_row_templ_t*templ) /* in: column template */
3031
buf += templ->mysql_col_offset;
3032
cache += templ->mysql_col_offset;
3034
UNIV_MEM_ASSERT_W(buf, templ->mysql_col_len);
3036
if (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR
3037
&& templ->type != DATA_INT) {
3038
/* Check for != DATA_INT to make sure we do
3039
not treat MySQL ENUM or SET as a true VARCHAR!
3040
Find the actual length of the true VARCHAR field. */
3041
row_mysql_read_true_varchar(
3042
&len, cache, templ->mysql_length_bytes);
3043
len += templ->mysql_length_bytes;
3044
UNIV_MEM_INVALID(buf, templ->mysql_col_len);
3046
len = templ->mysql_col_len;
3049
ut_memcpy(buf, cache, len);
3052
/************************************************************************
3016
3053
Pops a cached row for MySQL from the fetch cache. */
3028
3065
ut_ad(prebuilt->n_fetch_cached > 0);
3029
3066
ut_ad(prebuilt->mysql_prefix_len <= prebuilt->mysql_row_len);
3068
UNIV_MEM_ASSERT_W(buf, prebuilt->mysql_row_len);
3070
cached_rec = prebuilt->fetch_cache[prebuilt->fetch_cache_first];
3031
3072
if (UNIV_UNLIKELY(prebuilt->keep_other_fields_on_keyread)) {
3032
3073
/* Copy cache record field by field, don't touch fields that
3033
3074
are not covered by current key */
3034
cached_rec = prebuilt->fetch_cache[
3035
prebuilt->fetch_cache_first];
3037
3076
for (i = 0; i < prebuilt->n_template; i++) {
3038
3077
templ = prebuilt->mysql_template + i;
3039
#if 0 /* Some of the cached_rec may legitimately be uninitialized. */
3040
UNIV_MEM_ASSERT_RW(cached_rec
3041
+ templ->mysql_col_offset,
3042
templ->mysql_col_len);
3044
ut_memcpy(buf + templ->mysql_col_offset,
3045
cached_rec + templ->mysql_col_offset,
3046
templ->mysql_col_len);
3078
row_sel_copy_cached_field_for_mysql(
3079
buf, cached_rec, templ);
3047
3080
/* Copy NULL bit of the current field from cached_rec
3049
3082
if (templ->mysql_null_bit_mask) {
3053
3086
& (byte)templ->mysql_null_bit_mask;
3058
#if 0 /* Some of the cached_rec may legitimately be uninitialized. */
3059
UNIV_MEM_ASSERT_RW(prebuilt->fetch_cache
3060
[prebuilt->fetch_cache_first],
3061
prebuilt->mysql_prefix_len);
3064
prebuilt->fetch_cache[prebuilt->fetch_cache_first],
3065
prebuilt->mysql_prefix_len);
3089
} else if (prebuilt->mysql_prefix_len > 63) {
3090
/* The record is long. Copy it field by field, in case
3091
there are some long VARCHAR column of which only a
3092
small length is being used. */
3093
UNIV_MEM_INVALID(buf, prebuilt->mysql_prefix_len);
3095
/* First copy the NULL bits. */
3096
ut_memcpy(buf, cached_rec, prebuilt->null_bitmap_len);
3097
/* Then copy the requested fields. */
3099
for (i = 0; i < prebuilt->n_template; i++) {
3100
row_sel_copy_cached_field_for_mysql(
3101
buf, cached_rec, prebuilt->mysql_template + i);
3104
ut_memcpy(buf, cached_rec, prebuilt->mysql_prefix_len);
3067
3107
prebuilt->n_fetch_cached--;
3068
3108
prebuilt->fetch_cache_first++;